uvm_callback¶
- uvm.base.uvm_callback.ALL_TYPES = None¶
Callbacks Classes¶
This section defines the classes used for callback registration, management, and user-defined callbacks.
- class uvm.base.uvm_callback.UVMTypeIDBase[source]¶
Bases:
objectSimple typeid interface. Need this to set up the base-super mapping. This is similar to the factory, but much simpler. The idea of this interface is that each object type T has a typeid that can be used for mapping type relationships. This is not a user visible class.
- typename = ''¶
- typeid_map: Dict[UVMTypeIDBase, UVMCallbacks] = {<uvm.base.uvm_callback.UVMTypeID object>: <uvm.base.uvm_callback.UVMCallbacks object>}¶
- type_map: Dict[UVMCallbacksBase, UVMTypeIDBase] = {<uvm.base.uvm_callback.UVMCallbacksBase object>: <uvm.base.uvm_callback.UVMTypeID object>, None: <uvm.base.uvm_callback.UVMTypeID object>}¶
- class uvm.base.uvm_callback.UVMTypeID[source]¶
Bases:
UVMTypeIDBase- m_b_inst = <uvm.base.uvm_callback.UVMTypeID object>¶
- class uvm.base.uvm_callback.UVMCallbacksBase(name)[source]¶
Bases:
UVMObjectBase class singleton that holds generic queues for all instance specific objects. This is an internal class. This class contains a global pool that has all of the instance specific callback queues in it. All of the typewide callback queues live in the derivative class UVMTypedCallbacks#(T). This is not a user visible class.
This class holds the class inheritance hierarchy information (super types and derivative types).
Note, all derivative uvm_callbacks#() class singletons access this global m_pool object in order to get access to their specific instance queue.
- m_b_inst = None¶
- m_pool = <uvm.base.uvm_pool.UVMPool object>¶
- m_tracing = 1¶
- m_is_for_me(cb: UVMCallback)[source]¶
- check_registration(obj, cb)[source]¶
Check registration. To test registration, start at this class and work down the class hierarchy. If any class returns true then the pair is legal.
- Parameters
obj (UVMObject) –
cb (UVMCallback) –
- Returns
True if obj is registered, False otherwise
- Return type
- classmethod get_first(itr, obj, CB=None) Optional[UVMCallback][source]¶
Returns the first enabled callback of type CB which resides in the queue for
obj. IfobjisNonethen the typewide queue for T is searched.itris the iterator it will be updated with a value that can be supplied toget_nextto get the next callback object.If the queue is empty then
Noneis returned.The iterator class
uvm_callback_itermay be used as an alternative, simplified, iterator interface.- Parameters
itr –
obj –
CB – Type of the callback
- Returns
First found callback.
- Return type
- class uvm.base.uvm_callback.UVMTypedCallbacks(name, T=None)[source]¶
Bases:
UVMCallbacksBase- m_tw_cb_q: List[UVMCallback] = []¶
- m_typename = ''¶
- m_t_inst = <uvm.base.uvm_callback.UVMTypedCallbacks object>¶
- classmethod m_cb_find_name(q, name, where)[source]¶
static function int m_cb_find_name(uvm_queue#(uvm_callback) q, string name, string where)
- Parameters
cls –
q –
name –
where –
Returns:
- class uvm.base.uvm_callback.UVMCallbacks(name='uvm_callbacks', T=None, CB=None)[source]¶
Bases:
UVMTypedCallbacksThe
UVMCallbacksclass 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. The object type-callback type pair are associated together using the
UVMRegisterCbmacro to define a valid pairing; valid pairings are checked when a user attempts to add a callback to an object.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 particular hook. A demonstration of this methodology is provided in an example included in the kit.
- m_inst = <uvm.base.uvm_callback.UVMCallbacks object>¶
- m_typeid = <uvm.base.uvm_callback.UVMTypeID object>¶
- m_cb_typeid = <uvm.base.uvm_callback.UVMTypeID object>¶
- m_typename = ''¶
- m_cb_typename = ''¶
- reporter = <uvm.base.uvm_report_object.UVMReportObject object>¶
- m_base_inst = <uvm.base.uvm_callback.UVMCallbacks object>¶
- classmethod get() UVMCallbacks[source]¶
Get the singleton instance of the class
- Returns
The singleton instance of the class
- Return type
- classmethod m_register_pair(tname='', cbname='', T=None)[source]¶
Register valid callback type
Returns:
- classmethod m_get_q(obj, CB=None)[source]¶
#————————– Group: Iterator Interface #————————–
This set of functions provide an iterator interface for callback queues. A facade class,
uvm_callback_iteris also available, and is the generally preferred way to iterate over callback queues. :param cls: :param obj: :param CB:Returns:
- classmethod get_first(itr, obj, CB=None)[source]¶
Function: get_first
Returns the first enabled callback of type CB which resides in the queue for
obj. IfobjisNonethen the typewide queue for T is searched.itris the iterator it will be updated with a value that can be supplied toget_nextto get the next callback object.If the queue is empty then
Noneis returned.The iterator class
uvm_callback_itermay be used as an alternative, simplified, iterator interface.- Parameters
cls –
itr –
obj –
CB –
Returns:
- classmethod get_last(itr, obj, CB=None)[source]¶
Function: get_last
Returns the last enabled callback of type CB which resides in the queue for
obj. IfobjisNonethen the typewide queue for T is searched.itris the iterator it will be updated with a value that can be supplied toget_prevto get the previous callback object.If the queue is empty then
Noneis returned.The iterator class
uvm_callback_itermay be used as an alternative, simplified, iterator interface.static function CB get_last (ref int itr, input T obj)
- Parameters
cls –
itr –
obj –
CB –
Returns:
- classmethod get_next(itr, obj, CB=None)[source]¶
Function: get_next
Returns the next enabled callback of type CB which resides in the queue for
obj, usingitras the starting point. IfobjisNonethen the typewide queue for T is searched.itris the iterator; it will be updated with a value that can be supplied toget_nextto get the next callback object.If no more callbacks exist in the queue, then
Noneis returned.get_nextwill continue to returnNonein this case untilget_firstorget_lasthas been used to reset the iterator.The iterator class
uvm_callback_itermay be used as an alternative, simplified, iterator interface.static function CB get_next (ref int itr, input T obj)
- Parameters
cls –
itr –
obj –
CB –
Returns:
- classmethod get_prev(itr, obj, CB=None)[source]¶
Function: get_prev
Returns the previous enabled callback of type CB which resides in the queue for
obj, usingitras the starting point. IfobjisNonethen the typewide queue for T is searched.itris the iterator; it will be updated with a value that can be supplied toget_prevto get the previous callback object.If no more callbacks exist in the queue, then
Noneis returned.get_prevwill continue to returnNonein this case untilget_firstorget_lasthas been used to reset the iterator.The iterator class
uvm_callback_itermay be used as an alternative, simplified, iterator interface.static function CB get_prev (ref int itr, input T obj)
- Parameters
cls –
itr –
obj –
CB –
Returns:
- classmethod display(obj=None)[source]¶
#————- Group: Debug #————-
Function: display
This function displays callback information for
obj. IfobjisNone, then it displays callback information for all objects of typeT, including typewide callbacks.static function void display(T obj=None)
- Parameters
cls –
obj –
- m_t_inst = <uvm.base.uvm_callback.UVMCallbacks object>¶
- class uvm.base.uvm_callback.UVMCallbackIter(obj, CB=None)[source]¶
Bases:
objectThe ~uvm_callback_iter~ class is an iterator class for iterating over callback queues of a specific callback type. The typical usage of the class is:
uvm_callback_iter#(mycomp,mycb) iter = new(this) for(mycb cb = iter.first(); cb is not None; cb = iter.next()) cb.dosomething()
The callback iteration macros, <`uvm_do_callbacks> and <`uvm_do_callbacks_exit_on> provide a simple method for iterating callbacks and executing the callback methods.
- first() Optional[UVMCallback][source]¶
Function: first
Returns the first valid (enabled) callback of the callback type (or a derivative) that is in the queue of the context object. If the queue is empty then
Noneis returned. Returns:
- last() Optional[UVMCallback][source]¶
Function: last
Returns the last valid (enabled) callback of the callback type (or a derivative) that is in the queue of the context object. If the queue is empty then
Noneis returned. Returns:
- next() Optional[UVMCallback][source]¶
Returns the next valid (enabled) callback of the callback type (or a derivative) that is in the queue of the context object. If there are no more valid callbacks in the queue, then
Noneis returned.Returns:
- prev() Optional[UVMCallback][source]¶
Returns the previous valid (enabled) callback of the callback type (or a derivative) that is in the queue of the context object. If there are no more valid callbacks in the queue, then
Noneis returned.Returns:
- get_cb() Optional[UVMCallback][source]¶
Returns the last callback accessed via a first() or next() call.
Returns:
- class uvm.base.uvm_callback.UVMCallback(name='uvm_callback')[source]¶
Bases:
UVMObjectThe
UVMCallbackclass 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.
- reporter = <uvm.base.uvm_report_object.UVMReportObject object>¶
- callback_mode(on=-1)[source]¶
Enable/disable callbacks (modeled like rand_mode and constraint_mode).
- Parameters
on –
Returns:
- is_enabled()[source]¶
Returns 1 if the callback is enabled, 0 otherwise.
- Returns
1 if the callback is enabled, 0 otherwise.
- Return type
- type_name = 'uvm_callback'¶