Subject: [sv-bc] Possible example error in section 3.10
From: Mark Hartoog (Mark.Hartoog@synopsys.com)
Date: Mon Oct 20 2003 - 15:17:44 PDT
In section 3.10 of the 3.1 LRM on page 16 it says:
<quote>
Adding a constant range to the enum declaration can be used to
set the size of the type. If any of the enum members are defined
with a different sized constant, this shall be a syntax error.
// Error in the bronze and gold member declarations
enum bit [3:0] {bronze=5'h13, silver, gold=3'h5} medal4;
// Correct declaration - bronze and gold sizes are redundant
enum bit [3:0] {bronze=4'h13, silver, gold=4'h5} medal4;
</quote>
Also in section 3.10, on page 15 is this example:
<quote>
An enum declaration of a 4-state type, such as integer, that
includes one or more names with x or z assignments shall be permitted.
// Correct: IDLE=2'b00, XX=2'bx, S1=2'b01, S2=2'b10
enum integer {IDLE, XX='x, S1=2'b01, S2=2'b10} state, next;
</quote>
I believe this example is an error. If the base type of an enum is
integer, then it should be an error to specify 2 bit constant values
for the enum identifiers.
I would propose changing this to:
<quote>
An enum declaration of a 4-state type, such as logic, that
includes one or more names with x or z assignments shall be permitted.
// Correct: IDLE=2'b00, XX=2'bx, S1=2'b01, S2=2'b10
enum logic [1:0] {IDLE, XX='x, S1=2'b01, S2=2'b10} state, next;
</quote>
Question: The LRM says that an integer is "at least 32 bit". Given that
the size of an integer is not specified by the LRM, is it legal to use
any sized constant for the initial value of a integer enum?
Note that the LRM does specify the size of int, byte, shortint, and
longint, so this is only an issue for integer.
Mark Hartoog
700 E. Middlefield Road
Mountain View, CA 94043
650 584-5404
markh@synopsys.com
This archive was generated by hypermail 2b28 : Mon Oct 20 2003 - 15:20:40 PDT