uvm_event¶
- class uvm.base.uvm_event.UVMEventBase(name='')[source]¶
Bases:
UVMObject
The UVMEventBase class is an abstract wrapper class around the
cocotb.triggers.Event
class. It provides some additional services such as setting self.callbacks and maintaining the number of waiters.- type_name = 'uvm_event_base'¶
- set_value(key, value)[source]¶
Sets a value inside this event object and triggers value_changed_event.
- Parameters
key (str) – Member variable name
value (any) – Value to set for that member variable.
- async wait_on(delta=False)[source]¶
Waits for the event to be activated for the first time.
If the event has already been triggered, this task returns immediately. If
delta
is set, the caller will be forced to wait a single delta #0 before returning. This prevents the caller from returning before previously waiting processes have had a chance to resume.Once an event has been triggered, it will be remain “on” until the event is
UVMEvent.reset
.- Parameters
delta (bool) – If True, wait for one zero delay
- async wait_off(delta=False)[source]¶
If the event has already triggered and is “on”, this task waits for the event to be turned “off” via a call to
reset
.If the event has not already been triggered, this task returns immediately. If
delta
is set, the caller will be forced to wait a single delta #0 before returning. This prevents the caller from returning before previously waiting processes have had a chance to resume.- Parameters
delta (bool) – If True, wait for one zero delay
- async wait_trigger()[source]¶
Waits for the event to be triggered.
If one process calls wait_trigger in the same delta as another process calls
UVMEvent.trigger
, a race condition occurs. If the call to wait occurs before the trigger, this method will return in this delta. If the wait occurs after the trigger, this method will not return until the next trigger, which may never occur and thus cause deadlock.
- async wait_ptrigger()[source]¶
Waits for a persistent trigger of the event. Unlike
UVMEvent.wait_trigger
, this views the trigger as persistent within a given time-slice and thus avoids certain race conditions. If this method is called after the trigger but within the same time-slice, the caller returns immediately.
- get_trigger_time()[source]¶
Gets the time that this event was last triggered. If the event has not bee triggered, or the event has been reset, then the trigger time will be 0.
- Returns
Time when this event was triggered.
- Return type
- is_on()[source]¶
Indicates whether the event has been triggered since it was last reset.
A return of 1 indicates that the event has triggered.
Returns:
- is_off()[source]¶
Indicates whether the event has been triggered or been reset.
A return of 1 indicates that the event has not been triggered.
Returns:
- reset(wakeup=False)[source]¶
Resets the event to its off state. If
wakeup
is set, then all processes currently waiting for the event are activated before the reset.No self.callbacks are called during a reset.
- Parameters
wakeup (bool) –
- cancel()[source]¶
Decrements the number of waiters on the event.
This is used if a process that is waiting on an event is disabled or activated by some other means.
- get_type_name() str [source]¶
This function returns the type name of the object, which is typically the type identifier enclosed in quotes. It is used for various debugging functions in the library, and it is used by the factory for creating objects.
This function must be defined in every derived class.
A typical implementation is as follows:
class mytype (UVMObject): ... type_name = "mytype" def get_type_name(self): return my_type.type_name
We define the
type_name
static variable to enable access to the type name without need of an object of the class, i.e., to enable access via the scope operator, ~mytype::type_name~.- Returns
Type name of the object.
- Return type
- class uvm.base.uvm_event.UVMEvent(name='', T=None)[source]¶
Bases:
UVMEventBase
CLASS: UVMEvent
The UVMEvent class is an extension of the abstract
UVMEventBase
class.The optional parameter ~T~ allows the user to define a data type which can be passed during an event trigger.
- type_name = 'uvm_event'¶
- async wait_trigger_data()[source]¶
Task: wait_trigger_data
This method calls <uvm_event_base::wait_trigger> followed by
get_trigger_data
. :returns: Trigger data. :rtype: any
- async wait_ptrigger_data(data)[source]¶
This method calls <uvm_event_base::wait_ptrigger> followed by
get_trigger_data
.- Parameters
data –
- Returns
Data used to trigger this event.
- Return type
any
- trigger(data=None)[source]¶
Triggers the event, resuming all waiting processes.
An optional
data
argument can be supplied with the enable to provide trigger-specific information.- Parameters
data (any) – Data associated with the trigger.
- get_trigger_data()[source]¶
Gets the data, if any, provided by the last call to
trigger
.- Returns
Data used to trigger this event.
- Return type
any
- get_type_name()[source]¶
This function returns the type name of the object, which is typically the type identifier enclosed in quotes. It is used for various debugging functions in the library, and it is used by the factory for creating objects.
This function must be defined in every derived class.
A typical implementation is as follows:
class mytype (UVMObject): ... type_name = "mytype" def get_type_name(self): return my_type.type_name
We define the
type_name
static variable to enable access to the type name without need of an object of the class, i.e., to enable access via the scope operator, ~mytype::type_name~.- Returns
Type name of the object.
- Return type
- add_callback(cb, append=True)[source]¶
Registers a callback object,
cb
, with this event. The callback object may include pre_trigger and post_trigger functionality. Ifappend
is set to 1, the default,cb
is added to the back of the callback list. Otherwise,cb
is placed at the front of the callback list.- Parameters
cb –
append (bool) – If True, append to the end. Otherwise insert to front.
- delete_callback(cb)[source]¶
Unregisters the given callback, ~cb~, from this event.
- Parameters
cb (UVMCallback) – Callback to delete from this event.
- do_print(printer)[source]¶
The
do_print
method is the user-definable hook called byprint
andsprint
that allows users to customize what gets printed or sprinted beyond the field information provided by the `uvm_field_* macros, <Utility and Field Macros for Components and Objects>.The
printer
argument is the policy object that governs the format and content of the output. To ensure correctprint
andsprint
operation, and to ensure a consistent output format, theprinter
must be used by alldo_print
implementations. That is, instead of using ~$display~ or string concatenations directly, ado_print
implementation must call through the ~printer’s~ API to add information to be printed or sprinted.An example implementation of
do_print
is as follows:class mytype (UVMObject): data_obj data int f1 virtual function void do_print (uvm_printer printer) super.do_print(printer) printer.print_field_int("f1", f1, $bits(f1), UVM_DEC) printer.print_object("data", data) endfunction
Then, to print and sprint the object, you could write:
t = mytype() t.print() uvm_report_info("Received",t.sprint())
See
UVMPrinter
for information about the printer API.- Parameters
printer (UVMPrinter) – Printer that is used in printing.