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.  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.

Summary
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
ovm_pool#(T,ovm_queue#(CB))
ovm_callbacks#(T,CB)
Class Declaration
class ovm_callbacks #(
   type T = int,
    CB = int
) extends ovm_pool #(T,ovm_queue #(CB))
Parameters
TThis type parameter specifies the base object type with which the CB callback objects will be registered.
CBThis type parameter specifies the base callback type that will be managed by this callback class.
Methods
newCreates a new ovm_callbacks object, giving it an optional name.
get_global_cbsReturns the global callback pool for this type.
add_cbRegisters the given callback object, cb, with the given obj handle.
delete_cbRemoves a previously registered callback, cb, for the given object, obj.
trace_modeThis function takes a single argument to turn on (1) or off (0) tracing.
display_cbsDisplays information about all registered callbacks for the given obj handle.

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.  The callback type is typically a interface class, which defines one or more virtual method prototypes that users can override in subtypes.

new

function new(string name = "ovm_callback")

Creates a new ovm_callbacks object, giving it an optional name.

get_global_cbs

Returns the global callback pool for this type.

This allows items to be shared amongst components throughout the verification environment.

add_cb

virtual function void add_cb(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.

delete_cb

virtual function void delete_cb(obj,
CB cb)

Removes a previously registered callback, cb, for the given object, obj.

trace_mode

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.

display_cbs

function void display_cbs(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.

ovm_callback

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.

Summary
ovm_callback
The ovm_callback class is the base class for user-defined callback classes.
Class Hierarchy
ovm_callback
Class Declaration
class ovm_callback extends ovm_object
Methods
newCreates a new ovm_callback object, giving it an optional name.
callback_modeEnable/disable callbacks (modeled like rand_mode and constraint_mode).
is_enabledReturns 1 if the callback is enabled, 0 otherwise.
get_type_nameReturns the type name of this callback object.

new

function new(string name = "ovm_callback")

Creates a new ovm_callback object, giving it an optional name.

callback_mode

function void callback_mode(bit on)

Enable/disable callbacks (modeled like rand_mode and constraint_mode).

is_enabled

function bit is_enabled()

Returns 1 if the callback is enabled, 0 otherwise.

get_type_name

virtual function string get_type_name()

Returns the type name of this callback object.

class ovm_callbacks #(type T = int,
 CB = int) extends ovm_pool #(T,ovm_queue #(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.
This type parameter specifies the base callback type that will be managed by this callback class.
function new(string name = "ovm_callback")
Creates a new ovm_callbacks object, giving it an optional name.
virtual function void add_cb(obj,  
CB cb,  
bit append = 1)
Registers the given callback object, cb, with the given obj handle.
virtual function void delete_cb(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.
function void display_cbs(obj = null)
Displays information about all registered callbacks for the given obj handle.
virtual class ovm_object extends ovm_void
The ovm_object class is the base class for all OVM data and hierarchical classes.
class ovm_callback extends ovm_object
The ovm_callback class is the base class for user-defined callback classes.
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).
function bit is_enabled()
Returns 1 if the callback is enabled, 0 otherwise.
virtual function string get_type_name()
Returns the type name of this callback object.