[sv-bc] Re: [sv-ec] Queries Related to string data type

From: Steven Sharp <sharp_at_.....>
Date: Thu May 31 2007 - 13:01:23 PDT
>From: Sandeep Dasgupta <sandeep@cal.interrasystems.com>

>Now as per IEEE Std 1800-2005, section 5.10.3,
>"The syntax for the exists() method is as follows:
>                        function int exists( input index );
>    where index is an index of the appropriate type for the array in 
>question."
>But in the above test case we have used an enum as the argument of 
>associative array method 'exists', inspite of the fact that the index 
>type of the associative array is a string.So as per LRM it seems to be a 
>negative test case.

Note that 'index' is the name of the formal argument in the function
prototype.  So the LRM is saying that the type of the formal argument
'index' has the type of the index of the array in question, which is
a string in this case.

That does not prevent passing other types as the actual argument to
the function.  Since the prototype says that this is an input argument,
the actual argument only needs to be assignment compatible with the
formal argument.

That means that this question is essentially the same as your next
one, about assigning an integral type to a string without a cast
(since an enum will be automatically cast to its integral base type
in this case).  You quote the LRM as saying

>Now as per IEEE Std 1800-2005, section 4.7,
>"Integral types can be assigned to a string variable, but require a cast."

Since these are essentially the same case, it would not be surprising
if a simulator that allowed one also allowed the other.


Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu May 31 13:02:18 2007

This archive was generated by hypermail 2.1.8 : Thu May 31 2007 - 13:03:18 PDT