[sv-bc] Issue with operator overloading spec.

From: Surya Pratik Saha <spsaha_at_.....>
Date: Tue Feb 27 2007 - 05:04:16 PST
This mail is regarding the two issues about operator overloading -

1. Consider the following case:
typedef struct{
 bit x;
 bit y;
} myStruct;

bind * function myStruct fmultcg (myStruct, myStruct);

module top;
 myStruct d,e,f;
 assign d = e * f;
 function myStruct fmultcg (myStruct x, myStruct y);
 endfunction
endmodule

According to LRM section 8.16 ( IEEE std. 1800-2005 ), "The overload 
declaration must be defined before use in a scope that is visible". This 
means that an overload declaration corresponding to an expression can 
not be a forward declaration. But, again, the same LRM section says 
that, "The function bound by the overload declaration uses the same 
scope search rules as a function enable from the scope where the 
operator is invoked." That means, The function bound by the overload 
declaration can be a forward declaration ( as is the case for function 
enable ) with respect to the expression where the operator is invoked.
  If we conjure up these two information, we get a contradiction. At the 
point of invocation of the operator, we must search for a corresponding 
overload declaration immediately ( as it can not be a forward 
declaration. ). But, to resolve the function bound by the overload 
declaration, we should defer the search until after first pass.
  I am a bit confused here. Which one should I take or should I do these 
two things seperately at different points of time?

2. Consider the following test-case :

typedef struct{
 bit x;
 bit y;
} myStruct;

bind * function myStruct fmultcg (myStruct, myStruct);

module top;
 function myStruct fmultcg (myStruct x, myStruct y);
 endfunction
 myStruct d,e,f;
 assign d = e * f;
endmodule

module mid;
 function myStruct fmultcg (myStruct x, myStruct y);
 endfunction
 myStruct d,e,f;
 assign d = e * f;
endmodule

Here, for both the expression "e * f" occurring within module top and 
module mid, the expression will be resolved using the same overload 
declaration. But, please note that, the function bound by this overload 
declaration would be different for them. Because, we should search for 
the function definition from the point of invocation of operator, we 
would get "fmultcg" of "top" for first expression and "multcg" of "mid" 
for the second expression. Under this scenario I have two possibilities 
in mind -

A. The design should be a valid one and the function definition of 
"fmultcg" would be serach only at evaluation time, as this is a dynamic 
choice which completely depends upon where the operator is actually 
invoked.

B. The design should be a negative one. An error should be raised at "e 
* f" in mid, where we would find that a function defition is already 
bound to the overload declaration and that function is not visible from 
the current scope.

Please suggest me, which option should I take?

-- 
Regards
Surya.





-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Feb 27 05:04:50 2007

This archive was generated by hypermail 2.1.8 : Tue Feb 27 2007 - 05:06:03 PST