Re: [sv-bc] size of enums

From: Greg Jaxon <Greg.Jaxon@synopsys.com>
Date: Fri Oct 29 2004 - 18:43:21 PDT

It could be a C interoperability thing...
C enums are ints. Perhaps enum trimming can be
an extra feature of some source-to-source optimizer tools.

I note that the hidden "tag" fields of tagged unions
are specified as auto-trimmed and they resemble enums.
So there is precedent for what I think you want.

The next thing that would be nice would be range-offset
trimming, or value remapping, so that you only pay for
the bandwidth you use, and the compiler adds in the offsets
or remaps the values as necessary to convert to integer
type. These seem like slightly incompatible refinements
to me, so I won't propose them as errata, just design doodling
here on a Friday evening...

Greg Jaxon

Paul Graham wrote:
> I guess I wonder why enums aren't more like parameters. A parameter
> with no explicit range information is sized to whatever is necessary to
> represent its value. Why not the same for enums?
>
>
>>p.s. By the way, sometimes people don't want the minimum number
>>of bits. For example, sometimes instead a one-hot encoding, as --
>>...
>> enum [3:0] {RED = 4'b0001, GREEN = 4'b0010, BLUE = 4'b0100,
>> YELLOW = 4'b1000 } ;
>
>
> I'm not saying that you shouldn't be allowed to force an enum to a
> particular size. Just that it would be nice to allow the tool to
> select a minimal size automatically.
>
> Paul
>
>
Received on Fri Oct 29 18:42:58 2004

This archive was generated by hypermail 2.1.8 : Fri Oct 29 2004 - 18:43:05 PDT