RE: [sv-bc] Some query related with enum.

From: Bresticker, Shalom <shalom.bresticker_at_.....>
Date: Mon Aug 25 2008 - 06:11:22 PDT
I would say:

The legal values for enum names are

2'sb10  (-2)
2'sb11  (-1)
2'sb00  (0)
2'sb01  (1)

So RED becomes 2'sb10, which is -2.

YELLOW becomes 2'sb11, which is -1.

Case 1: GREEN = 2'b00 , which is 0. This looks OK.
Case 2: GREEN = 2'b11. This is 3, which is outside the representable
range of the enum, so it should be illegal. Even if you say that 2'b11
is converted to 2'sb11, it duplicates YELLOW, and is still illegal.
Case 3: GREEN = 2'b10. This is 2. For similar reasons, this should also
be illegal.
Case 4: GREEN = 3. Also outside the representable range, and thus also
illegal.

> typedef enum reg signed [1:0] { RED = 2'sb10,YELLOW,GREEN = 2'b00}
light; 
> typedef enum reg signed [1:0] { RED = 2'sb10,YELLOW,GREEN = 2'b11}
light; 
> typedef enum reg signed [1:0] { RED = 2'sb10,YELLOW,GREEN = 2'b10}
light; 
> typedef enum reg signed [1:0] { RED = 2'sb10,YELLOW,GREEN = 3} light;
> 
> Can you let me know that which one should be correct and 
> which one are wrong as different simulator are behaving in 
> different way.

Regards,
Shalom
---------------------------------------------------------------------
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 Mon Aug 25 06:12:47 2008

This archive was generated by hypermail 2.1.8 : Mon Aug 25 2008 - 06:13:11 PDT