Re: [sv-bc] enumerated variable used with an equality operator

From: Gordon Vreugdenhil <gordonv@model.com>
Date: Fri Mar 21 2014 - 06:51:46 PDT
I would be Ok with the more lenient interpretation, but I also think it 
would be valid to conclude that relational of a non-enum integral with a 
enum is Ok (ie. does a coercion), but enum-enum relational is not.  
Given the "stronger" intent of enums, that might be appropriate.   
Allowing cross-enum behavior everywhere except assignment seems to be 
giving up most of the benefits of a "strong" type so perhaps we should 
just treat then as labelled values of the basetype and forget about the 
stronger type rules completely.

Gord



On 3/21/2014 2:00 AM, Bresticker, Shalom wrote:
> If you want this to be illegal, then you would need to define clearly and usefully where and how you can use an enum value. It might be too difficult and limited to be worthwhile.
>
> I agree with Brad. The reference to Mantis 4708 is appropriate. The mention of relational operators in the quoted sentence in the LRM is not appropriate.
>
> In the sentence, "Enumerated variables are type-checked in assignments, arguments, and relational operators," if we ignore the mention of relational operators, then the type checking refers to the case where an enumerated variable is assigned, i.e., on the LHS of an assignment, or as the actual argument for an output argument or the formal argument for an input argument.
>
> Shalom
>
>> -----Original Message-----
>> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of
>> Rich, Dave
>> Sent: Friday, March 21, 2014 02:37
>> To: Neil Korpusik; sv-bc@eda.org
>> Subject: RE: [sv-bc] enumerated variable used with an equality operator
>>
>> It should be illegal, but it isn't
>>
>> The LRM says:
>>
>> Enumerated variables are type-checked in assignments, arguments, and
>> relational operators. Enumerated variables are auto-cast into integral
>> values, but assignment of arbitrary expressions to an enumerated
>> variable requires an explicit cast.
>>
>> The LRM does not explain what "type-checked" means, but I take it to
>> mean if it can proceed to auto-cast it to an integral expression, it
>> will.
>>
>> -----Original Message-----
>> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of
>> Neil Korpusik
>> Sent: Thursday, March 20, 2014 5:25 PM
>> To: sv-bc@eda.org
>> Subject: [sv-bc] enumerated variable used with an equality operator
>>
>> Is the following legal? Should it be?
>>
>> Neil
>>
>>
>>
>> module top();
>>
>> typedef enum {A,B,C,D} f_t;
>> typedef enum {X,Y,Z  } b_t;
>>
>> initial begin
>>     f_t f;
>>     b_t b;
>>
>>     f = A;
>>     if (f == X) $display("matched");   // legal?
>> end
>> endmodule
> ---------------------------------------------------------------------
> Intel Israel (74) Limited
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
>



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Mar 21 06:52:02 2014

This archive was generated by hypermail 2.1.8 : Fri Mar 21 2014 - 06:52:10 PDT