[sv-bc] Re: [sv-ec] Is simple decimal no. allowed in enum declaration

From: Steven Sharp <sharp_at_.....>
Date: Wed Oct 10 2007 - 12:14:24 PDT
>Consider the following case:
>
>typedef enum bit signed [2:0] {mon,tues=2, wed, sun=-4} day;
>
>As per LRM, the size of any decimal no. is at least 32. So for '2', 
>error is expected. But most of the simulators fail for '-4', but not for 
>'2' in the example. Any reason behind that.

I can guess.

The value 2 fits into 3 bits signed.  The value -4 also barely fits
into 3 bits signed.  There are a couple of reasons why implementations
might give an error for -4.

1. They might not be accounting for negative signed values, and be
   doing an unsigned overflow check.

2. They might have an error in their overflow checking for the most
   negative representable value.  Note that -4 barely fits, but its
   inverse 4 does not fit.  An incorrect overflow check might think
   that -4 does not fit either.

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 Wed Oct 10 12:15:22 2007

This archive was generated by hypermail 2.1.8 : Wed Oct 10 2007 - 12:16:23 PDT