ovm_callback_defines.svh

Summary
ovm_callback_defines.svh
Callback Macros
`ovm_do_callbacksCalls the given METHOD of all callbacks of type CB registered with the calling object (i.e.
`ovm_do_obj_callbacksCalls the given METHOD of all callbacks based on type CB registered with the given object, OBJ, which is or is based on type T.
`ovm_do_callbacks_exit_onCalls the given METHOD of all callbacks of type CB registered with the calling object (i.e.
`ovm_do_obj_callbacks_exit_onCalls the given METHOD of all callbacks of type CB registered with the given object OBJ, which must be or be based on type T, and returns upon the first callback that returns the bit value given by VAL.
`ovm_do_task_callbacksCalls the given METHOD of all callbacks of type CB registered with the calling object (i.e.
`ovm_do_ext_task_callbacksThis macro is identical to <ovm_do_task_callbacks> macro except there is an additional OBJ argument that allows the user to execute callbacks associated with an external object instance OBJ instead of the calling (this) object.

`ovm_do_callbacks

Calls the given METHOD of all callbacks of type CB registered with the calling object (i.e.  this object), which is or is based on type T.

This macro executes all of the callbacks associated with the calling object (i.e.  this object).  The macro takes three arguments:

  • CB is the class type of the callback objects to execute.  The class type must have a function signature that matches the FNC argument.
  • T is the type associated with the callback.  Typically, an instance of type T is passed as one the arguments in the METHOD call.
  • METHOD is the method call to invoke, with all required arguments as if they were invoked directly.

For example, given the following callback class definition

virtual class mycb extends ovm_cb;
  pure function void my_function (mycomp comp, int addr, int data);
endclass

A component would invoke the macro as

task mycomp::run();
   int curr_addr, curr_data;
   ...
   `ovm_do_callbacks(mycb, mycomp, my_function(this, curr_addr, curr_data)
   ...
endtask

`ovm_do_obj_callbacks

Calls the given METHOD of all callbacks based on type CB registered with the given object, OBJ, which is or is based on type T.

This macro is identical to <ovm_do_callbacks (CB,T,METHOD)> macro, but it has an additional OBJ argument to allow the specification of an external object to associate the callback with.  For example, if the callbacks are being applied in a sequence, OBJ could be specified as the associated sequencer or parent sequence.

`ovm_do_callbacks_exit_on

Calls the given METHOD of all callbacks of type CB registered with the calling object (i.e.  this object), which is or is based on type T, returning upon the first callback returning the bit value given by VAL.

This macro executes all of the callbacks associated with the calling object (i.e.  this object).  The macro takes three arguments:

  • CB is the class type of the callback objects to execute.  The class type must have a function signature that matches the FNC argument.
  • T is the type associated with the callback.  Typically, an instance of type T is passed as one the arguments in the METHOD call.
  • METHOD is the method call to invoke, with all required arguments as if they were invoked directly.
  • VAL, if 1, says return upon the first callback invocation that returns 1.  If 0, says return upon the first callback invocation that returns 0.

For example, given the following callback class definition

virtual class mycb extends ovm_cb;
  pure function bit drop_trans (mycomp comp, my_trans trans);
endclass

A component would invoke the macro as

task mycomp::run();
   my_trans trans;
   forever begin
     get_port.get(trans);
     if (`ovm_do_callbacks_exit_on(mycb, mycomp, extobj, drop_trans(this,trans), 1)
       ovm_report_info("DROPPED",{"trans dropped: %s",trans.convert2string()});
     // execute transaction
   end
endtask

`ovm_do_obj_callbacks_exit_on

Calls the given METHOD of all callbacks of type CB registered with the given object OBJ, which must be or be based on type T, and returns upon the first callback that returns the bit value given by VAL.

`ovm_do_task_callbacks

Calls the given METHOD of all callbacks of type CB registered with the calling object (i.e.  this object), which is or is based on type T.

This macro is the same as the <ovm_do_callbacks> macro except that each callback is executed inside of its own thread.  The threads are concurrent, but the execution order of the threads is simulator dependent.  The macro does not return until all forked callbacks have completed.

virtual class mycb extends ovm_cb;
  pure task my_task(mycomp, int addr, int data);
endclass
task mycomp::run();
   int curr_addr, curr_data;
   ...
   `ovm_callback(mycb, mycomp, my_task(this, curr_addr, curr_data))
   ...
endtask

`ovm_do_ext_task_callbacks

This macro is identical to <ovm_do_task_callbacks> macro except there is an additional OBJ argument that allows the user to execute callbacks associated with an external object instance OBJ instead of the calling (this) object.