Enum-names
Making sense of the names defined by enum types.
Enum types are unique among datatypes in that using one has a side
effect of declaring some names with assigned values. We deal with these early
on, as part of annotate, by declaring these names as parameters. For
example:
typedef enum logic [3:0] { red=1, blue, green, yellow[4:0]=5, orange[3:5] };
results in the following parameter declarations:
localparam logic [3:0] red = 1;
localparam logic [3:0] blue = red + 1;
localparam logic [3:0] green = blue + 1;
localparam logic [3:0] yellow4 = 5;
localparam logic [3:0] yellow3 = 6;
localparam logic [3:0] yellow2 = 7;
localparam logic [3:0] yellow1 = 8;
localparam logic [3:0] yellow0 = 9;
localparam logic [3:0] orange3 = 10;
localparam logic [3:0] orange4 = 11;
localparam logic [3:0] orange5 = 12;
We require the range indices (e.g. for yellow[4:0], orange[3:5] to
be constants (syntactically), which ncverilog does as well. VCS is somewhat
more forgiving, but still doesn't allow arbitrary constant expressions; i.e.,
it seems you can't call a function in there.
The above example illustrates how we create parameters for the names
declared in an enum type. This transformation then applies this to every enum
found in the datatype of a variable, parameter, or typedef declaration.
Subtopics
- Vl-enumname-range-declarations
- For example: given a ranged enum item like foo[3:0], we create
the parameters for foo3, foo2, foo1, and foo0.
- Vl-interfacelist-add-enumname-declarations
- (vl-interfacelist-add-enumname-declarations x) maps vl-interface-add-enumname-declarations across a list.
- Vl-packagelist-add-enumname-declarations
- (vl-packagelist-add-enumname-declarations x) maps vl-package-add-enumname-declarations across a list.
- Vl-modulelist-add-enumname-declarations
- (vl-modulelist-add-enumname-declarations x) maps vl-module-add-enumname-declarations across a list.
- Vl-classlist-add-enumname-declarations
- (vl-classlist-add-enumname-declarations x) maps vl-class-add-enumname-declarations across a list.
- Vl-enumitemlist-enumname-declarations
- Vl-enumname-declarations
- Vl-paramdecl-enumname-declarations
- Vl-paramdecllist-enumname-declarations
- Vl-vardecllist-enumname-declarations
- Vl-typedeflist-enumname-declarations
- Vl-vardecl-enumname-declarations
- Vl-typedef-enumname-declarations
- Vl-package-add-enumname-declarations
- Vl-design-add-enumname-declarations
- Vl-interface-add-enumname-declarations
- Vl-class-add-enumname-declarations
- Vl-module-add-enumname-declarations
- Vl-datatype-map
- An alist mapping vl-datatype-p to vl-datatype-p.