TestBencher Pro and Reactive Test Bench Help

6.12 Variables and Class Field Properties

6.12 Variables and Class Field Properties

Previous topic Next topic  

6.12 Variables and Class Field Properties

Previous topic Next topic  

The properties of variables and class fields are added and edited using the Classes and Variables dialog as described in Section 6.1: Variables and Section 6.2 Classes. The section defines the different properties. Certain property settings, such as size, will depend on the structure property. For instance, an element type forces the size to be 1. Other properties will change depending on the generation language. Any item that cannot be edited will have a gray background in the list.

Variable Properties:

Variable Name or Field Name is used when referencing the variable or field of the class.

Direction (Variable Only) determines whether or not the variable is an input to the diagram or component. An input diagram-level variable will become an input to the transaction apply call, just like a state value. An input project-level variable will become an input to the project Transaction-Level Model, and each instance of the component can specify an initialization value for the input project-level variable.

Packing (Field Only) allows classes to be converted into bit streams. Double clicking on this field will cause the Packing Properties dialog to be opened. This dialog allows packing to be enabled and disabled, and it also allows Bit and Byte order specification. Note that the packing options that are allowed will depend on the language being generated and are discussed in Section 6.6: Data Packing.

For Verilog, the Network Packing property reverses the byte order of the class after packing.

Static: (Field Only) determines whether or not all instances of the class will use the same copy of the data (static) or if they will maintain their own copy of the data member (non-static). By default, this property is set to non-static.

Random acts on variables and fields that have a native data type. This setting determines whether or not the values assumed by the data member will be randomly generated, and if so what method is used. This property can be set to non-rand, rand, and randc (random cyclic). The non-rand selection indicates that the variable is not randomized. If it is set to rand or randc, then random values will be generated for the class. Random fields are generated when the Randomize method is called on the variable. This method is automatically generated when needed, and can be called from the Sequencer Process of the Transaction-Level Model. The generation language may limit the options that are available for randomization. Section 6.5 Constrained Random Number Generation shows how to constrain the random values that are generated for random variables.

Structure determines the type of structure for the field. The types available are element, array, associative array, and queue. An element type will cause the field to equate to a simple variable in the class. By default, the structure type for a field is element.

Size specifies the number of elements in a complex structure type field. This setting is available for arrays and queues. Because the default structure type is an element, the default for this property is 1.

BitSize, MSB, and LSB are used to determine the bit size for field elements. Depending on the language being used, the bitsize may be specified using an LSB and an MSB. Note that some types, such as a string, may not use a bitsize, and that others, like bool, may have a limited bitsize.

Data Type determines the type of the elements of the field. The possible settings for this property are listed in Section 6.13 Language Independent Types  (such as bool, 2_state, or 2_state_vector) and may also include other classes that have been defined in Class Libraries that are included in the project. The default for this property is int. Note that only language independent types that are available for at least one of the licensed languages will be shown. If a language independent type is selected, then it will be converted to the appropriate type for the generated language in the generated test bench.

Initial Value (variables only) allows an initialization value to be specified. The variable will be initialized on creation during test bench simulation. An initial value can be specified for both diagram and project level variables. The assignment to this value will occur once at the beginning of simulation execution. The string entered in this field will be placed directly in the generated code without modification.

Structure Types

Element is a single data item (like a single integer).

Array is a series of elements of the same data type. Arrays allow data to be randomly accessed through a numeric index. Arrays have a fixed number of elements.

Associative Array stores a series of key-value pairs. The key is used to index a particular element in the array (the value). All of the elements are of the same data type. The size of an associative array grows as data is added to it. Associative arrays are referenced in the same way that arrays are, with the key representing the index. Any integer or value that resolves to an integer can be used as a key for an associative array. The two primary differences between an associative array and an array are that the associative array can grow dynamically (during simulation), and that the numeric keys used to look up a data element do not have to be sequential.

Queue is a FIFO (first-in, first-out) access to data. Queues have a fixed number of elements of the same data type. This type of field is useful if two timing transactions are running concurrently and one of the transactions needs to process data that is collected in another transaction.

File Structure Types allow data to be read from or written to a file during transaction execution. File Structure variables need the Data Type property set to one of the user-defined Classes. Further more, any Class that is used in this manner should have fields that correspond to the columns in the file. A file that is being used for input can be used as the Class Template file (Section 6.9 Input Data Dynamically from a File (VHDL)). The two File structure types that are available are described below.

File Output: is used to write information accumulated during transaction execution out to a file. This information is written out in a spreadsheet like format, and the column headers describe the field information (name, bit information, and radix) in the same manner that is used by the Class Template file. These Variables are used to store state information. The data is written out to the file sequentially, with one row for each transaction that uses the variable.

File Input: is used to read data from a file using a spreadsheet like format. This type of Variable can be used to drive state information. The data is written out to the file sequentially, with one row for each transaction that uses the variable.