Wednesday 3 February 2016

Synchronization using UVM features


Note: This blog is useful when the verification environment is developed using system verilog and UVM methodology. 

In this blog, we go through the synchronization feature of UVM. For it, UVM contains “uvm_barrier” and “uvm_event” classes. These classes contain different in-built methods which are very useful for setting/resetting events or waiting to complete any particular event.

An example here will be helpful in understanding the concept to achieve synchronization of different tasks in same component or different components through uvm_barrier and uvm_event.


As shown in the figure 1, there are 3 different tasks (task_a, task_b and task_c) are running parallel and they are independent from each other. Here, you can assume that, there are 3 different components running in parallel. Now, the requirement is like any two of three tasks (task_a, task_b and task_c) are completed or any two tasks reach at a particular stage, another task (trigger_event) shall start its execution.

Figure 1

To achieve synchronization between them, a barrier (b) is created which indicates to wait for 3 processes to be completed and same barrier is passed into all different tasks. Also, the same barrier is passed into “trigger_event” task as it has depended on task_a, task_b and task_c tasks.

The example requirement is shown in the flowchart (figure 2).

 
Figure 2

As shown in figure 3, all tasks are doing some execution (indicated by #delay) and then it waits for the tasks to be in sync with other tasks by using barrier task (wait_for). Once any 3 tasks are in sync, the wait_for() condition will be satisfied and it executes next statements.

Figure 3
As shown in figure 4, “trigger_event” task is created which waits for the completion of any two tasks and then it do some execution. Then it triggers an event so that “process_on_event” task can start its execution. After performing some tasks, it resets the event based on which “process_on_event” task can perform other functionality.

Figure 4
You can achieve different functionalities like to reset the barrier, change the threshold value for waiting at the barrier etc. by using "uvm_barrier" class.

By using “uvm_event”, you can achieve functionalities like waiting on starting of the event or ending of an event, reset the event, get and change the number of waiters on the event etc.

Thanks to “Chitra Bhatia (Principal DV Engineer, Applied Micro) and Ali Hussain (Senior Staff Design Engineer, Applied Micro)“ for helping with this blog.

Reference:
  1. Universal Verification Methodology (UVM) 1.2 Class Reference