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.
To do that we will 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.
Be First to Comment