We discussed the concepts of structs and units in this chapter. These concepts lay the foundation for the material discussed in the following chapters.
Structs are defined using the keyword struct. Struct definitions contain struct members.
Structs can be extended using the keyword extend. Struct extensions add struct members to a previously defined struct. These extensions can be specified in the same file or a different file.
List fields are used very frequently in e. Lists of any data type, enumerated type, or user-defined struct can be defined in e.
Many pseudo-methods are available to operate on lists. When a list field is defined, the pseudo-methods can be used with that list field. Any arguments required by the pseudo-method go in parentheses after the pseudo-method name. Pseudo-methods can be called in actions or constraints.
Keyed lists are used to enable faster searching of lists by designating a particular field or value which is to be searched for. Although all of the operations that can be done using a keyed list can also be done using a regular list, using a keyed list provides an advantage in the greater speed of searching a keyed list.
The when struct member creates a conditional subtype of the current struct type, if a particular field of the struct has a given value. This is called "when" inheritance, and is one of two techniques e provides for implementing inheritance. The other method is called like inheritance. When inheritance is the recommended technique for modeling in e. Like inheritance is more appropriate for procedural testbench programming. Like inheritance is not covered in this book.
When subtypes can be extended.
A method defined or extended within a when construct is executed in the context of the subtype and can freely access the unique struct members of the subtype with no need for any casting.
The keyword unit is used to define static components in the verification environment. On the other hand, using a struct keyword to model abstract collections of data, like packets, allows you more flexibility as to when you generate the data.
HDL paths can bind an e unit instance to a particular component in the DUT hierarchy. This allows you to reference signals within that DUT component using relative HDL path names. HDL paths can be assigned using the hdl_path() method.