The ovm_callbacks class provides a base class for implementing callbacks, which are typically used to modify or augment component behavior without changing the component class. To work effectively, the developer of the component class defines a set of “hook” methods that enable users to customize certain behaviors of the component in a manner that is controlled by the component developer. The integrity of the component’s overall behavior is intact, while still allowing certain customizable actions by the user.
To enable compile-time type-safety, the class is parameterized on both the user-defined callback interface implementation as well as the object type associated with the callback.
To provide the most flexibility for end-user customization and reuse, it is recommended that the component developer also define a corresponding set of virtual method hooks in the component itself. This affords users the ability to customize via inheritance/factory overrides as well as callback object registration. The implementation of each virtual method would provide the default traversal algorithm for the particular callback being called. Being virtual, users can define subtypes that override the default algorithm, perform tasks before and/or after calling super.<method> to execute any registered callbacks, or to not call the base implementation, effectively disabling that particalar hook. A demonstration of this methodology is provided in an example included in the kit.
| ovm_callbacks #(T,CB) | ||||||||||||||||||||||
| The ovm_callbacks class provides a base class for implementing callbacks, which are typically used to modify or augment component behavior without changing the component class. | ||||||||||||||||||||||
| Class Hierarchy | ||||||||||||||||||||||
| ||||||||||||||||||||||
| Class Declaration | ||||||||||||||||||||||
| ||||||||||||||||||||||
| Parameters | ||||||||||||||||||||||
| T | This type parameter specifies the base object type with which the CB callback objects will be registered. | |||||||||||||||||||||
| CB | This type parameter specifies the base callback type that will be managed by this callback class. | |||||||||||||||||||||
| Methods | ||||||||||||||||||||||
| new | Creates a new ovm_callbacks object, giving it an optional name. | |||||||||||||||||||||
| get_global_cbs | Returns the global callback pool for this type. | |||||||||||||||||||||
| add_cb | Registers the given callback object, cb, with the given obj handle. | |||||||||||||||||||||
| delete_cb | Removes a previously registered callback, cb, for the given object, obj. | |||||||||||||||||||||
| trace_mode | This function takes a single argument to turn on (1) or off (0) tracing. | |||||||||||||||||||||
| display_cbs | Displays information about all registered callbacks for the given obj handle. | |||||||||||||||||||||
This type parameter specifies the base callback type that will be managed by this callback class. The callback type is typically a interface class, which defines one or more virtual method prototypes that users can override in subtypes.
function new( string name = "ovm_callback" )
Creates a new ovm_callbacks object, giving it an optional name.
Returns the global callback pool for this type.
This allows items to be shared amongst components throughout the verification environment.
virtual function void add_cb( T obj, CB cb, bit append = 1 )
Registers the given callback object, cb, with the given obj handle. The obj handle can be null, which allows registration of callbacks without an object context. If append is 1 (default), the callback will be executed after previously added callbacks, else the callback will be executed ahead of previously added callbacks.
virtual function void delete_cb( T obj, CB cb )
Removes a previously registered callback, cb, for the given object, obj.
function void trace_mode( bit mode )
This function takes a single argument to turn on (1) or off (0) tracing. The default is to turn tracing on.
function void display_cbs( T obj = null )
Displays information about all registered callbacks for the given obj handle. If obj is not provided or is null, then information about all callbacks for all objects is displayed.
The ovm_callback class is the base class for user-defined callback classes. Typically, the component developer defines an application-specific callback class that extends from this class. In it, he defines one or more virtual methods, called a callback interface, that represent the hooks available for user override.
Methods intended for optional override should not be declared pure. Usually, all the callback methods are defined with empty implementations so users have the option of overriding any or all of them.
The prototypes for each hook method are completely application specific with no restrictions.
| ovm_callback | |||
| The ovm_callback class is the base class for user-defined callback classes. | |||
| Class Hierarchy | |||
| |||
| Class Declaration | |||
| |||
| Methods | |||
| new | Creates a new ovm_callback object, giving it an optional name. | ||
| callback_mode | Enable/disable callbacks (modeled like rand_mode and constraint_mode). | ||
| is_enabled | Returns 1 if the callback is enabled, 0 otherwise. | ||
| get_type_name | Returns the type name of this callback object. | ||
function new( string name = "ovm_callback" )
Creates a new ovm_callback object, giving it an optional name.
function void callback_mode( bit on )
Enable/disable callbacks (modeled like rand_mode and constraint_mode).
The ovm_callbacks class provides a base class for implementing callbacks, which are typically used to modify or augment component behavior without changing the component class.
class ovm_callbacks #( type T = int, CB = int ) extends ovm_pool #(T,ovm_queue #(CB))
Creates a new ovm_callbacks object, giving it an optional name.
function new( string name = "ovm_callback" )
Registers the given callback object, cb, with the given obj handle.
virtual function void add_cb( T obj, CB cb, bit append = 1 )
Removes a previously registered callback, cb, for the given object, obj.
virtual function void delete_cb( T obj, CB cb )
This function takes a single argument to turn on (1) or off (0) tracing.
function void trace_mode( bit mode )
Displays information about all registered callbacks for the given obj handle.
function void display_cbs( T obj = null )
The ovm_object class is the base class for all OVM data and hierarchical classes.
virtual class ovm_object extends ovm_void
The ovm_callback class is the base class for user-defined callback classes.
class ovm_callback extends ovm_object
Creates a new ovm_callback object, giving it an optional name.
function new( string name = "ovm_callback" )
Enable/disable callbacks (modeled like rand_mode and constraint_mode).
function void callback_mode( bit on )
Returns 1 if the callback is enabled, 0 otherwise.
function bit is_enabled()
Returns the type name of this callback object.
virtual function string get_type_name()