Vl-struct
A SystemVerilog struct datatype, or an array of structs.
This is a product type, introduced by deftagsum in support of vl-datatype.
Fields
- members — vl-structmemberlist
- The list of structure members, i.e., the fields of the structure,
in order.
- packedp — booleanp
- Roughly: says whether this struct is packed or not,
but warning! this is complicated and generally
should not be used; see below for details.
- pdims — vl-dimensionlist
- Packed dimensions for the structure.
- udims — vl-dimensionlist
- Unpacked dimensions for the structure.
- signedp — booleanp
- Roughly: says whether this struct is signed or not,
but warning! this is really complicated and generally
should not be used; see below for details.
If you look at the SystemVerilog grammar you might notice that
there aren't unpacked dimensions:
data_type ::= ... | struct_union [ 'packed' [signing] ] '{'
struct_union_member { struct_union_member }
'}' { packed_dimension }
But it seems much cleaner to make the unpacked dimensions part
of a structure, so when we deal with a variable declaration
like:
mystruct_t [3:0] foo [4:0];
We can record, in the type of foo itself, all of the
relevant type information, instead of having to keep the unpacked
dimensions separated.
Warning about Packedp and Signedp
The packedness/signedness of structures/arrays is complicated;
you should usually use utilities like vl-datatype-packedp
and vl-datatype-arithclass instead of directly using the
packedp and signedp fields.
What are the issues? At parse time, we use the packedp and
signedp fields to record whether the struct was declared to be
packed and/or signed.
For a single (non-array) structure, packedp is basically
correct, except that BOZO really we should be checking that all of
the members of the struct are packed as well. But for arrays of
structs, even if the struct itself is packed, the array itself
might be unpacked. For instance, if we write:
struct packed { logic [3:0] a; logic [3:0] b; } myvar [3:0];
then myvar will be marked as packed, but this packedness
refers to the elements of myvar instead of to
myvar itself!
Signedness has similar issues except that it is more
complicated; see the documentation in vl-datatype-arithclass
and also vl-usertype for more details.
Subtopics
- Vl-structmember
- A single member of a struct or union.
- Make-vl-struct
- Basic constructor macro for vl-struct structures.
- Vl-struct->udims
- Get the udims field from a vl-struct.
- Vl-struct->signedp
- Get the signedp field from a vl-struct.
- Vl-struct->packedp
- Get the packedp field from a vl-struct.
- Vl-struct->members
- Get the members field from a vl-struct.
- Vl-struct->pdims
- Get the pdims field from a vl-struct.
- Change-vl-struct
- Modifying constructor for vl-struct structures.