Structs are used to define data elements and the behavior of components in a verification environment. A struct can hold all types of data and methods. Structs are defined with the keyword struct. Struct definitions are statements and are at the highest level in the e hierarchy as discussed in "Syntax Hierarchy" on page 49. The syntax definition of a struct is as follows:
struct struct-type [like base-struct-type] { [struct-member][;struct-member] ...};
The components defined in the above struct definition are explained in detail in Table 4-1 below.
Name | Description |
---|---|
struct-type | The name of the new struct type |
base-struct-type | The type of the struct from which the new struct inherits its members |
The contents of the struct; the following are types of struct members: |
Example 4-1 shows a simple struct definition containing only fields and methods. This definition does not contain all struct members described in Table 4-1. Some of these struct members will be explained later in this book.
<' type packet_kind: [atm, eth]; // Enumerated type //Definition packet struct struct packet { len: int; //Field of struct keep len < 256; //Constraint on struct kind: packet_kind; //Field of struct calc_par() is { //Method (procedure) in a struct -- -- }; //end of method definition }; //end of packet struct '>