Events

Jan. 22, 2024 || Item:4.3.Event

A SystemVerilog event provides a handle to an underlying synchronization object. When a process waits for an event to be triggered, the process is put on a queue maintained within the synchronization object. Processes can wait for a SystemVerilog event to be triggered either via the @ operator, or by using the wait() construct to examine their triggered state. Events are triggered using the -> or the ->> operator.

SystemVerilog events act as handles to synchronization queues, thus, they can be passed as arguments to tasks, and they can be assigned to one another or compared.

Syntax:

event variable_name [= initial_value];

1. Triggering an event

Triggering an event unblocks all processes currently waiting on that event. When triggered, named events behave like a one-shot, that is, the trigger state itself is not observable, only its effect. This is similar to the way in which an edge can trigger a flip-flop but the state of the edge cannot be ascertained, i.e., if (posedge clock) is illegal.

Blocking event trigger:

-> event_name

Non-blocking event trigger:

->> event_name

The effect of non-blocking trigger is that the statement executes without blocking and it creates a nonblocking assign update event in the time in which the delay control expires, or the event-control occurs. The effect of this update event shall be to trigger the referenced event in the nonblocking assignment region of the simulation cycle.

The triggered property is invoked using a method-like syntax:

event_name.triggered

The triggered event property evaluates to TRUE if the given event has been triggered in the current time-step and FALSE otherwise. If event_name is null, then the triggered event property evaluates to FALSE.

2. Waiting for an event

2.1. @ operator

The basic mechanism to wait for an event to be triggered is via the event control operator, @.

@event_name;

The @ operator blocks the calling process until the given event is triggered.

For a trigger to unblock a process waiting on an event, the waiting process must execute the @ statement BEFORE the triggering process executes the trigger operator, ->. If the trigger executes first, then the waiting process remains blocked.

2.2. wait()

If the event triggering and waiting for event trigger with @ operator happens at the same time, @ operator may MISS detecting the event trigger.

Whereas wait(); construct will detect the event triggering.

wait(event_name.triggered);

Using this mechanism, an event trigger shall unblock the waiting process whether the wait executes before or at the same simulation time as the trigger operation. 

2.3. wait_order()

The wait_order construct suspends the calling process until all of the specified events are triggered in the given order (left to right). If any of the untriggered events is triggered out of order and thus causes the operation to fail.

Syntax:

wait_order(event_name1, event_name2, event_name3)

Only the first event in the list can wait for the persistent triggered property.

3. Event variables

An event is a unique data type with several important properties. Unlike Verilog, SystemVerilog events can be assigned to one another. When one event is assigned to another the synchronization queue of the source event is shared by both the source and the destination event. In this sense, events act as full fledged variables and not merely as labels.

Merge Event:

When one event variable is assigned to another, the two become merged. Thus, executing -> on either event variable affects processes waiting on either event variable.

Reclaiming events

When an event variable is assigned the special null value, the association between the event variable and the underlying synchronization queue is broken. When no event variable is associated with an underlying synchronization queue, the resources of the queue itself become available for re-use.

Triggering a null event shall have no effect. The outcome of waiting on a null event is undefined, and implementations can issue a run-time warning.

Events comparison

Event variables can be compared against other event variables or the special value null. Only the following operators are allowed for comparing event variables:

- Equality (==) with another event or with null.

- Inequality (!=) with another event or with null.

- Caseequality(===)withanothereventorwithnull(samesemanticsas==).

- Caseinequality(!==)withanothereventorwithnull(samesemanticsas!=).

- Test for a boolean value that shall be 0 if the event is null and 1 otherwise.

 



Comments:

Leave a comment: