Utility and Field Macros for Components and Objects

Summary
Utility and Field Macros for Components and Objects
Utility MacrosThe utility macros provide implementations of the ovm_object::create method, which is needed for cloning, and the ovm_object::get_type_name method, which is needed for a number of debugging features.
`ovm_field_utils_begin
`ovm_field_utils_endThese macros form a block in which `ovm_field_* macros can be placed.
`ovm_object_utils
`ovm_object_param_utils
`ovm_object_utils_begin
`ovm_object_param_utils_begin
`ovm_object_utils_endovm_object-based class declarations may contain one of the above forms of utility macros.
`ovm_component_utils
`ovm_component_param_utils
`ovm_component_utils_begin
`ovm_component_param_utils_begin
`ovm_component_endovm_component-based class declarations may contain one of the above forms of utility macros.
Field MacrosThe `ovm_field_* macros are invoked inside of the `ovm_*_utils_begin and `ovm_*_utils_end macro blocks to form “automatic” implementations of the core data methods: copy, compare, pack, unpack, record, print, and sprint.
`ovm_field_* macrosMacros that implement data operations for scalar properties.
`ovm_field_intImplements the data operations for any packed integral property.
`ovm_field_objectImplements the data operations for an ovm_object-based property.
`ovm_field_stringImplements the data operations for a string property.
`ovm_field_enumImplements the data operations for an enumerated property.
`ovm_field_realImplements the data operations for any real property.
`ovm_field_eventImplements the data operations for an event property.
`ovm_field_sarray_* macrosMacros that implement data operations for one-dimensional static array properties.
`ovm_field_sarray_intImplements the data operations for a one-dimensional static array of integrals.
`ovm_field_sarray_objectImplements the data operations for a one-dimensional static array of ovm_object-based objects.
`ovm_field_sarray_stringImplements the data operations for a one-dimensional static array of strings.
`ovm_field_sarray_enumImplements the data operations for a one-dimensional static array of enums.
`ovm_field_array_* macrosMacros that implement data operations for one-dimensional dynamic array properties.
`ovm_field_array_intImplements the data operations for a one-dimensional dynamic array of integrals.
`ovm_field_array_objectImplements the data operations for a one-dimensional dynamic array of ovm_object-based objects.
`ovm_field_array_stringImplements the data operations for a one-dimensional dynamic array of strings.
`ovm_field_array_enumImplements the data operations for a one-dimensional dynamic array of enums.
`ovm_field_queue_* macrosMacros that implement data operations for dynamic queues.
`ovm_field_queue_intImplements the data operations for a queue of integrals.
`ovm_field_queue_objectImplements the data operations for a queue of ovm_object-based objects.
`ovm_field_queue_stringImplements the data operations for a queue of strings.
`ovm_field_queue_enumImplements the data operations for a one-dimensional queue of enums.
`ovm_field_aa_*_string macrosMacros that implement data operations for associative arrays indexed by string.
`ovm_field_aa_int_stringImplements the data operations for an associative array of integrals indexed by string.
`ovm_field_aa_object_stringImplements the data operations for an associative array of ovm_object-based objects indexed by string.
`ovm_field_aa_string_stringImplements the data operations for an associative array of strings indexed by string.
`ovm_field_aa_*_int macrosMacros that implement data operations for associative arrays indexed by an integral type.
`ovm_field_aa_object_intImplements the data operations for an associative array of ovm_object-based objects indexed by the int data type.
`ovm_field_aa_int_intImplements the data operations for an associative array of integral types indexed by the int data type.
`ovm_field_aa_int_int_unsignedImplements the data operations for an associative array of integral types indexed by the int unsigned data type.
`ovm_field_aa_int_integerImplements the data operations for an associative array of integral types indexed by the integer data type.
`ovm_field_aa_int_integer_unsignedImplements the data operations for an associative array of integral types indexed by the integer unsigned data type.
`ovm_field_aa_int_byteImplements the data operations for an associative array of integral types indexed by the byte data type.
`ovm_field_aa_int_byte_unsignedImplements the data operations for an associative array of integral types indexed by the byte unsigned data type.
`ovm_field_aa_int_shortintImplements the data operations for an associative array of integral types indexed by the shortint data type.
`ovm_field_aa_int_shortint_unsignedImplements the data operations for an associative array of integral types indexed by the shortint unsigned data type.
`ovm_field_aa_int_longintImplements the data operations for an associative array of integral types indexed by the longint data type.
`ovm_field_aa_int_longint_unsignedImplements the data operations for an associative array of integral types indexed by the longint unsigned data type.
`ovm_field_aa_int_keyImplements the data operations for an associative array of integral types indexed by any integral key data type.
`ovm_field_aa_int_enumkeyImplements the data operations for an associative array of integral types indexed by any enumeration key data type.

Utility Macros

The utility macros provide implementations of the ovm_object::create method, which is needed for cloning, and the ovm_object::get_type_name method, which is needed for a number of debugging features.  They also register the type with the ovm_factory, and they implement a get_type method, which is used when configuring the factory.  And they implement the virtual ovm_object::get_object_type method for accessing the factory proxy of an allocated object.

Below is an example usage of the utility and field macros.  By using the macros, you do not have to implement any of the data methods to get all of the capabilities of an ovm_object.

class mydata extends ovm_object;

  string str;
  mydata subdata;
  int field;
  myenum e1;
  int queue[$];

  `ovm_object_utils_begin(mydata) //requires ctor with default args
    `ovm_field_string(str, OVM_DEFAULT)
    `ovm_field_object(subdata, OVM_DEFAULT)
    `ovm_field_int(field, OVM_DEC) //use decimal radix
    `ovm_field_enum(myenum, e1, OVM_DEFAULT)
    `ovm_field_queue_int(queue, OVM_DEFAULT)
  `ovm_object_utils_end

endclass

`ovm_field_utils_end

These macros form a block in which `ovm_field_* macros can be placed.  Used as

`ovm_field_utils_begin(TYPE)
  `ovm_field_* macros here
`ovm_field_utils_end

These macros do NOT perform factory registration, implement get_type_name, nor implement the create method.  Use this form when you need custom implementations of these two methods, or when you are setting up field macros for an abstract class (i.e. virtual class).

`ovm_object_utils_end

ovm_object-based class declarations may contain one of the above forms of utility macros.

For simple objects with no field macros, use

`ovm_object_utils(TYPE)

For simple objects with field macros, use

`ovm_object_utils_begin(TYPE)
  `ovm_field_* macro invocations here
`ovm_object_utils_end

For parameterized objects with no field macros, use

`ovm_object_param_utils(TYPE)

For parameterized objects, with field macros, use

`ovm_object_param_utils_begin(TYPE)
  `ovm_field_* macro invocations here
`ovm_object_utils_end

Simple (non-parameterized) objects use the ovm_object_utils* versions, which do the following:

  • Implements get_type_name, which returns TYPE as a string
  • Implements create, which allocates an object of type TYPE by calling its constructor with no arguments.  TYPE’s constructor, if defined, must have default values on all it arguments.
  • Registers the TYPE with the factory, using the string TYPE as the factory lookup string for the type.
  • Implements the static get_type() method which returns a factory proxy object for the type.
  • Implements the virtual get_object_type() method which works just like the static get_type() method, but operates on an already allocated object.

Parameterized classes must use the ovm_object_param_utils* versions.  They differ from `ovm_object_utils only in that they do not supply a type name when registering the object with the factory.  As such, name-based lookup with the factory for parameterized classes is not possible.

The macros with _begin suffixes are the same as the non-suffixed versions except that they also start a block in which `ovm_field_* macros can be placed.  The block must be terminated by `ovm_object_utils_end.

Objects deriving from ovm_sequence must use the `ovm_sequence_* macros instead of these macros.  See `ovm_sequence_utils for details.

`ovm_component_end

ovm_component-based class declarations may contain one of the above forms of utility macros.

For simple components with no field macros, use

`ovm_component_utils(TYPE)

For simple components with field macros, use

`ovm_component_utils_begin(TYPE)
  `ovm_field_* macro invocations here
`ovm_component_utils_end

For parameterized components with no field macros, use

`ovm_component_param_utils(TYPE)

For parameterized components with field macros, use

`ovm_component_param_utils_begin(TYPE)
  `ovm_field_* macro invocations here
`ovm_component_utils_end

Simple (non-parameterized) components must use the ovm_components_utils* versions, which do the following:

  • Implements get_type_name, which returns TYPE as a string.
  • Implements create, which allocates a component of type TYPE using a two argument constructor.  TYPE’s constructor must have a name and a parent argument.
  • Registers the TYPE with the factory, using the string TYPE as the factory lookup string for the type.
  • Implements the static get_type() method which returns a factory proxy object for the type.
  • Implements the virtual get_object_type() method which works just like the static get_type() method, but operates on an already allocated object.

Parameterized classes must use the ovm_object_param_utils* versions.  They differ from `ovm_object_utils only in that they do not supply a type name when registering the object with the factory.  As such, name-based lookup with the factory for parameterized classes is not possible.

The macros with _begin suffixes are the same as the non-suffixed versions except that they also start a block in which `ovm_field_* macros can be placed.  The block must be terminated by `ovm_component_utils_end.

Components deriving from ovm_sequencer must use the `ovm_sequencer_* macros instead of these macros.  See `ovm_sequencer_utils for details.

Field Macros

The `ovm_field_* macros are invoked inside of the `ovm_*_utils_begin and `ovm_*_utils_end macro blocks to form “automatic” implementations of the core data methods: copy, compare, pack, unpack, record, print, and sprint.  For example:

class my_trans extends ovm_transaction;
  string my_string;
  `ovm_object_utils_begin(my_trans)
    `ovm_field_string(my_string, OVM_ALL_ON)
  `ovm_object_utils_end
endclass

Each `ovm_field_* macro is named to correspond to a particular data type: integrals, strings, objects, queues, etc., and each has at least two arguments: ARG and FLAG.

ARG is the instance name of the variable, whose type must be compatible with the macro being invoked.  In the example, class variable my_string is of type string, so we use the `ovm_field_string macro.

If FLAG is set to OVM_ALL_ON, as in the example, the ARG variable will be included in all data methods.  The FLAG, if set to something other than OVM_ALL_ON or OVM_DEFAULT, specifies which data method implementations will NOT include the given variable.  Thus, if FLAG is specified as NO_COMPARE, the ARG variable will not affect comparison operations, but it will be included in everything else.

All possible values for FLAG are listed and described below.  Multiple flag values can be bitwise ORed together (in most cases they may be added together as well, but care must be taken when using the + operator to ensure that the same bit is not added more than once).

OVM_ALL_ONSet all operations on (default).
OVM_DEFAULTUse the default flag settings.
OVM_NOCOPYDo not copy this field.
OVM_NOCOMPAREDo not compare this field.
OVM_NOPRINTDo not print this field.
OVM_NODEFPRINTDo not print the field if it is the same as its
OVM_NOPACKDo not pack or unpack this field.
OVM_PHYSICALTreat as a physical field.  Use physical setting in policy class for this field.
OVM_ABSTRACTTreat as an abstract field.  Use the abstract setting in the policy class for this field.
OVM_READONLYDo not allow setting of this field from the set_*_local methods.

A radix for printing and recording can be specified by OR’ing one of the following constants in the FLAG argument

OVM_BINPrint / record the field in binary (base-2).
OVM_DECPrint / record the field in decimal (base-10).
OVM_UNSIGNEDPrint / record the field in unsigned decimal (base-10).
OVM_OCTPrint / record the field in octal (base-8).
OVM_HEXPrint / record the field in hexidecimal (base-16).
OVM_STRINGPrint / record the field in string format.
OVM_TIMEPrint / record the field in time format.

Radix settings for integral types.  Hex is the default radix if none is specified.

`ovm_field_* macros

Macros that implement data operations for scalar properties.

`ovm_field_int

Implements the data operations for any packed integral property.

`ovm_field_int(ARG,FLAG)

ARG is an integral property of the class, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_object

Implements the data operations for an ovm_object-based property.

`ovm_field_object(ARG,FLAG)

ARG is an object property of the class, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_string

Implements the data operations for a string property.

`ovm_field_string(ARG,FLAG)

ARG is a string property of the class, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_enum

Implements the data operations for an enumerated property.

`ovm_field_enum(T,ARG,FLAG)

T is an enumerated type, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_real

Implements the data operations for any real property.

`ovm_field_real(ARG,FLAG)

ARG is an real property of the class, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_event

Implements the data operations for an event property.

`ovm_field_event(ARG,FLAG)

ARG is an event property of the class, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_sarray_* macros

Macros that implement data operations for one-dimensional static array properties.

`ovm_field_sarray_int

Implements the data operations for a one-dimensional static array of integrals.

`ovm_field_sarray_int(ARG,FLAG)

ARG is a one-dimensional static array of integrals, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_sarray_object

Implements the data operations for a one-dimensional static array of ovm_object-based objects.

`ovm_field_sarray_object(ARG,FLAG)

ARG is a one-dimensional static array of ovm_object-based objects, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_sarray_string

Implements the data operations for a one-dimensional static array of strings.

`ovm_field_sarray_string(ARG,FLAG)

ARG is a one-dimensional static array of strings, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_sarray_enum

Implements the data operations for a one-dimensional static array of enums.

`ovm_field_sarray_enum(T,ARG,FLAG)

T is a one-dimensional dynamic array of enums type, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_array_* macros

Macros that implement data operations for one-dimensional dynamic array properties.

`ovm_field_array_int

Implements the data operations for a one-dimensional dynamic array of integrals.

`ovm_field_array_int(ARG,FLAG)

ARG is a one-dimensional dynamic array of integrals, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_array_object

Implements the data operations for a one-dimensional dynamic array of ovm_object-based objects.

`ovm_field_array_object(ARG,FLAG)

ARG is a one-dimensional dynamic array of ovm_object-based objects, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_array_string

Implements the data operations for a one-dimensional dynamic array of strings.

`ovm_field_array_string(ARG,FLAG)

ARG is a one-dimensional dynamic array of strings, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_array_enum

Implements the data operations for a one-dimensional dynamic array of enums.

`ovm_field_array_enum(T,ARG,FLAG)

T is a one-dimensional dynamic array of enums type, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_queue_* macros

Macros that implement data operations for dynamic queues.

`ovm_field_queue_int

Implements the data operations for a queue of integrals.

`ovm_field_queue_int(ARG,FLAG)

ARG is a one-dimensional queue of integrals, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_queue_object

Implements the data operations for a queue of ovm_object-based objects.

`ovm_field_queue_object(ARG,FLAG)

ARG is a one-dimensional queue of ovm_object-based objects, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_queue_string

Implements the data operations for a queue of strings.

`ovm_field_queue_string(ARG,FLAG)

ARG is a one-dimensional queue of strings, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_queue_enum

Implements the data operations for a one-dimensional queue of enums.

`ovm_field_queue_enum(T,ARG,FLAG)

T is a queue of enums type, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_*_string macros

Macros that implement data operations for associative arrays indexed by string.

`ovm_field_aa_int_string

Implements the data operations for an associative array of integrals indexed by string.

`ovm_field_aa_int_string(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with string key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_object_string

Implements the data operations for an associative array of ovm_object-based objects indexed by string.

`ovm_field_aa_object_string(ARG,FLAG)

ARG is the name of a property that is an associative array of objects with string key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_string_string

Implements the data operations for an associative array of strings indexed by string.

`ovm_field_aa_string_string(ARG,FLAG)

ARG is the name of a property that is an associative array of strings with string key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_*_int macros

Macros that implement data operations for associative arrays indexed by an integral type.

`ovm_field_aa_object_int

Implements the data operations for an associative array of ovm_object-based objects indexed by the int data type.

`ovm_field_aa_object_int(ARG,FLAG)

ARG is the name of a property that is an associative array of objects with int key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_int

Implements the data operations for an associative array of integral types indexed by the int data type.

`ovm_field_aa_int_int(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with int key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_int_unsigned

Implements the data operations for an associative array of integral types indexed by the int unsigned data type.

`ovm_field_aa_int_int_unsigned(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with int unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_integer

Implements the data operations for an associative array of integral types indexed by the integer data type.

`ovm_field_aa_int_integer(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with integer key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_integer_unsigned

Implements the data operations for an associative array of integral types indexed by the integer unsigned data type.

`ovm_field_aa_int_integer_unsigned(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with integer unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_byte

Implements the data operations for an associative array of integral types indexed by the byte data type.

`ovm_field_aa_int_byte(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with byte key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_byte_unsigned

Implements the data operations for an associative array of integral types indexed by the byte unsigned data type.

`ovm_field_aa_int_byte_unsigned(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with byte unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_shortint

Implements the data operations for an associative array of integral types indexed by the shortint data type.

`ovm_field_aa_int_shortint(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with shortint key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_shortint_unsigned

Implements the data operations for an associative array of integral types indexed by the shortint unsigned data type.

`ovm_field_aa_int_shortint_unsigned(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with shortint unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_longint

Implements the data operations for an associative array of integral types indexed by the longint data type.

`ovm_field_aa_int_longint(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with longint key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_longint_unsigned

Implements the data operations for an associative array of integral types indexed by the longint unsigned data type.

`ovm_field_aa_int_longint_unsigned(ARG,FLAG)

ARG is the name of a property that is an associative array of integrals with longint unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_key

Implements the data operations for an associative array of integral types indexed by any integral key data type.

`ovm_field_aa_int_key(KEY,ARG,FLAG)

ARG is the name of a property that is an associative array of integrals indexed by the integral type, KEYFLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

`ovm_field_aa_int_enumkey

Implements the data operations for an associative array of integral types indexed by any enumeration key data type.

`ovm_field_aa_int_enumkey(KEY,ARG,FLAG)

ARG is the name of a property that is an associative array of integrals indexed by the enumeration data type, KEYFLAG is a bitwise OR of one or more flag settings as described in Field Macros above.

virtual function ovm_object create (string name = "")
The create method allocates a new object of the same type as this object and returns it via a base ovm_object handle.
virtual function string get_type_name ()
This function returns the type name of the object, which is typically the type identifier enclosed in quotes.
virtual class ovm_object extends ovm_void
The ovm_object class is the base class for all OVM data and hierarchical classes.
class ovm_factory
As the name implies, ovm_factory is used to manufacture (create) OVM objects and components.
virtual function ovm_object_wrapper get_object_type ()
Returns the type-proxy (wrapper) for this object.
The sequence macros can be used in non-parameterized ovm_sequence extensions to pre-register the sequence with a given ovm_sequencer type.
The `ovm_field_* macros are invoked inside of the `ovm_*_utils_begin and `ovm_*_utils_end macro blocks to form “automatic” implementations of the core data methods: copy, compare, pack, unpack, record, print, and sprint.