enum_name_declaration ::=
enum_identifier [ [ integral_number ]
] [ = constant_expression ]
| enum_identifier [ [ integral_number : integral_number
] ] [ = constant_expression ]
enum_identifier [ [ integral_number [ : integral_number
] ] ] [ = constant_expression ]
EDITOR’S NOTE: I had to remove
the strike-through text from previous changes in the 3-1 syntax box in order to
fit draft 3 additions into the box.
enum_name_declaration ::=
enum_identifier [ [ integral_number ]
] [ = constant_expression ]
| enum_identifier [ [ integral_number : integral_number
] ] [ = constant_expression ]
enum_identifier [ [ integral_number [ : integral_number
] ] ] [ = constant_expression ]
Adding a constant range to the enum declaration can be used to set
the size of the type. Any enumeration encoding value that is outside the representable
range of the enum shall be an error. 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;
// Error in c
declaration, requires at least 2 bits
enum bit [0:0] {a,b,c}
alphabet;
Generates N labels named constants in the sequence: name0, name1, ...,
nameN-1N must be an integral constant
Creates a
sequence of labels named constants starting with nameN
and incrementing or decrementing until reaching label
the named constant nameM.
This example defines the
enumerated type E1, which assigns
the number 10 to the enumerated label named constant add. It also creates the enumerated labels
named constants sub0,sub1,sub2,sub3,and sub4, and assigns them the values 11...15, respectively.
Finally, the example creates the enumerated labels named constants jmp6,jmp7,
and jmp8, and assigns them the
values 16-18, respectively.
EDITOR’S NOTE:
The preceding paragraph refers to the identifiers in the enumerated list as “labels”.
Other paragraphs in the LRM refer to them as “names”. Consistent terminology
should be used. I prefer “labels”
The example above declares
enumerated variable vr, which creates the enumerated labels
named constants register0 and register1, which are assigned the values 1 and 2, respectively. Next, it creates
the enumerated labels named constants register2, register3, and register4,
and assigns them the values 10, 11, and 12.
typedef struct {
bit isfloat;
union { int i; shortreal f; } n; // anonymous type
} tagged_st;
// named structure
tagged_st a[9:0]; // array of structures
If any data type within a packed structure is 4-state, the whole
structure is treated as 4-state. Any 2-state members are converted as if cast.
One or more elements bits of the a packed array structure can be selected as if it were a packed array, assuming an [n-1:0] numbering:
class_declaration ::= // from Annex A.1.3
{ attribute_instance }
[ virtual ] class [ lifetime ] class_identifier
[ parameter_port_list ]
[ extends class_identifier [parameter_value_assignment
] [ ( list_of_arguments) ] ] ;
{ class_item }
endclass [ : class_identifier]
constant_primary ::= // from Annex A.8.4
...
| casting_type ’ ( constant_expression )
| casting_type ’ constant_concatenation
| casting_type ’ constant_multiple_concatenation
primary ::=
...
| casting_type ’ ( expression
)
| void ’
( function_call )
| casting_type ’ concatenation
| casting_type ’ multiple_concatenation
constant_cast ::= // from
Annex A.8.4
casting_type
‘ ( constant_expression )
| casting_type ‘ constant_concatenation
| casting_type ‘ constant_multiple_concatentation
cast ::=
casting_type
‘ ( expression )
| casting_type ‘ concatenation
| casting_type ‘ multiple_concatentation
typedef
struct {
bit
isfloat;
union
{ int
i; shortreal
f; } n; // anonymous type
} tagged_st; // named
structure
typedef
bit [$bits(tagged_st)
- 1 : 0] tagbits; // tagged defined above
tagged_st a
[7:0]; // unpacked array of structures
tagbits t = tagbits’(a[3]); // convert structure to array of bits
a[4] = tagged_st’(t); // convert array of bits back to structure