Previous Section Next Section

4.1 Defining Structs

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.

Table 4-1. Components of a Struct Definition

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

struct-member; …

The contents of the struct; the following are types of struct members:

  • data fields for storing data

  • methods for procedures

  • events for defining temporal triggers

  • coverage groups for defining coverage points

  • when, for specifying inheritance subtypes

  • declarative constraints for describing relations between data fields

  • on, for specifying actions to perform upon event occurrences

  • expect, for specifying temporal behavior rules

  • the definition of a struct can be empty, containing no 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.

Example 4-1 Basic Struct Definition
<'
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
'>
Previous Section Next Section