delaying phases in uVM

Sometimes you will need to delay execution of a phase in your verification environment. A basic example is that in your test you might drive the sequences and then drop objection in the test to exit the test. In scoreboards or any monitors, if the transactions are still in line waiting for any responses or other stuff, you will have to delay the phase execution to flush all transactions.

One of the way is to set the “set_drain_time” to specific phase that you need.

... inside the component you want to set the drain time ... 
task main_phase(uvm_phase phase);
  phase.set_drain_time(this, 500); //this will set 500 timeunits of delay once all objections are dropped.
  //You can also pass timeunits to the time like 500ns.. 
endtask

Another way is to use the “phase_ready_to_end” function of uvm component to induce delay.

Well “phase_ready_to_end” is a function, but how can i call it to insert delay. You need to raise objection create a fork join_none block and then you have to drop objection once your processing is complete. An example can be found below

function void phase_ready_to_end(uvm_phase phase);
  if(phase.get_name == "main" && (should_i_wait_or_not)) begin //Use your own phase name which you want to stall, should_i_wait_or_not is a variable or function that you should see when do you want to delay the phase or not.
     phase.raise_objection(this);
     fork
     begin
       your_task_to_execute();
     end
     join_none
   end
 endfunction

Some caveats:

  • The phase_ready_to_end is called when the objections for that phase are down to 0.
  • So when you raise objection in the phase_ready_to_end and when you call the drop_objection, the phase_ready_to_end will be again re-called.
  • So it is better to place a condition on the check in your function to check if is it really required to wait or not.
  • The UVM phase class a limit of 20 on the phase_ready_to_end, that means when you call the phase_ready_to_end 20 times, next time when objections are dropped to ‘0’, the phase_ready_to_end is not called.
venkatesh.amvrao Written by:

2 Comments

  1. Reading this piece felt like walking through a beautiful garden of ideas — each thought more inviting than the last.

Leave a Reply

Your email address will not be published. Required fields are marked *