Calling a Task at the end of run_phase

Hi All,

I have a requirement where I need to call an End of Sim task at the end of run_phase(after all 12 sub phases are done). This is a time-consuming task, and I am not sure if I can call it in a check_phase function or phase_ready_to_end function as functions cant consume time.

I tried using all_dropped callback from my base test as below but I read that is not recommended to use and is unpredictable.

virtual task all_dropped(uvm_objection objection, uvm_object source_obj, string desc, int kind);

if (objection == uvm_test_done) begin 

  uvm_info(get_type_name(), $sformatf("Base Test: Entering All Dropped callback after run phase"), UVM_LOW) 

  end_of_sim_check();       

  uvm_info(get_type_name(), $sformatf(“Base Test: Exitting All Dropped callback after run phase”), UVM_LOW)

super.all_dropped(objection, source_obj, desc, kind); end

endtask :all_dropped

Any recommendations on how to call a task after run_phase/all traffic ends ? Can I use the function below?

function void phase_ready_to_end(uvm_phase phase);
  if (phase.is(uvm_run_phase::get())) begin
    // All subphases done,
    phase.raise_objection(this);
    fork begin
      end_of_sim_check();
      repeat(10) @(posedge clk);
      phase.drop_objection(this);
    end join_none
  end
endfunction


Thanks.

You cannot execute a time-consuming task after the run phase ends. All phases that follow the run phase are functions, and the test will terminate the simulation at that specific time step.

The function phase_ready_to_end can be used to extend the end of time consuming phase by raising another objection. In most cases, your test will raise an objection, initiate a sequence to generate stimuli, and subsequently lower the objection after the stimulus sequence returns. The function phase_ready_to_end can then verify that all traffic has been completed.

Thanks dave.

Is the above code having phase_ready_to_end and eos not recommended? I added static drain time to my run phase let all the traffic finish, and then use phase ready to end for final checks as above. is it a right way of doing?

Also on a different note is all_dropped recommended to use in this scenario?