RE: [sv-bc] Built-in types are not packed arrays

From: Brad Pierce <Brad.Pierce@synopsys.com>
Date: Fri Sep 24 2004 - 13:40:28 PDT

>Everyone knows that a byte is 8 bits, and
>it's natural (in an hdl) to want to reference individual bits of a
>byte. If you can index a byte, then why not a shortint or an int?

A byte is a very special case, and not at all like 'shortint' and 'int'.

Outside of SystemVerilog, an 'int' does not have a fixed number of bits.
In ANSI C, for example, all I know about an 'int' is that it has at
least 16 bits, and all I know about a 'short int' is that it has no
more bits than an 'int'.

If my C code assumed that an 'int' were 32 bits, I might break many
regression tests, because those tests are regularly run on 64-bit
platforms. Likewise, if I assumed that a 'short' were 16 bits,
or even that a 'short' were half the size of an 'int', I might
break something.

As Steven points out, V2K made it legal to index into an 'integer'.
But I think that was an unwise change. For example, in V2K, you
don't even know how many bits there are in an 'integer', only that
there are at least 32. Can you safely use an index greater than 32?
It depends on the implementation.

-- Brad
Received on Fri Sep 24 13:40:31 2004

This archive was generated by hypermail 2.1.8 : Fri Sep 24 2004 - 13:40:37 PDT