Difference in outcome between non blocking event and eventname.triggered

Hi Could you please provide the clarification for the below

  1. if there are two process one is triggering the event using non block event ->>, and the other process is waiting for it using @ , the result would be that the second process is unblocked in non blocking assignment region. but the order of execution is first process triggers and second process waits until the event is triggered.

  2. the same order of execution can be achieved using ā†’ event_name , and wait(event_name.triggered).

and above mentioned two ways always eliminate the race conditions.

apart from the region of execution are there any other differences between the above mentioned two approaches.

A common misconception about SystemVerilog regions is that people think there are regions of execution. There are scheduling regions, or queues, of events in SystemVerilog. No execution happens except as events are removed from the Active queue. (Iā€™m going to ignore the re-active regions for this discussion) Executing an event can cause another event to be scheduled in any region of any time slot, depending on the kind of statement being executed.

When executing a Non-blocking assignment or trigger statement, an event gets scheduled in the Non-blocking region. Once the Active queue is empty, the Inactive queue moves to the Active queue, and the process repeats itself. Once both the Active and Inactive queues are empty, the Non-blocking queue becomes the Active queue, and the assignments or triggers execute, causing more events to be scheduled. Once all the queues for all regions are empty, the time slot is over and time advances to the queue holding the next active event.

The @(event) statement blocks until executing the trigger for that event. It does not matter if the trigger was originally scheduled in the non-blocking region or not because the trigger executes as part of processing the active queue. The key point is that the @(event) statement must execute before the trigger executes, otherwise it will miss seeing the trigger. Using the non-blocking trigger can delay the trigger so that you are less likely to miss the event trigger.

The event_name.triggered() method returns true if the event was triggered in the current time slot. By using wait(event_name.trigger) statement, you can remove the ordering sensitivity with the event trigger statement. If the event was triggered first, the wait expression will already be true and the wait will not block. Otherwise the wait expression will be false and block until the event get triggered and the expression becomes true. The only problem with this method is preventing an infinite loop if you need to wait for the next event.