Jump to content
Sign in to follow this  
qinhailiang

the bug of the sync of run_phase and post_shutdown_phase!

Recommended Posts

Hi, all

 

 We have one monitor and one driver as follow:

 

class monitor extends uvm_monitor;

 `uvm_component_utils(monitor)

   function new(string name, uvm_component parent);
      super.new(name, parent);
   endfunction

   virtual task post_shutdown_phase(uvm_phase phase);
   
     #50ns;
     `uvm_info(get_type_name(), "Monitor is printing at post_shutdown_phase executing...", UVM_LOW )
   
   endtask: post_shutdown_phase
   
   virtual function void phase_ready_to_end(uvm_phase phase);
     if(phase.get_name == "post_shutdown")
       `uvm_info(get_type_name(), "Monitor is printing at phase_ready_to_end...", UVM_LOW )
   
   endfunction: phase_ready_to_end
   
   
   virtual function void phase_ended(uvm_phase phase);
     if(phase.get_name == "post_shutdown")
       `uvm_info(get_type_name(), "Monitor is printing at phase_ended...", UVM_LOW )
   
   endfunction: phase_ended

endclass : monitor

 

 

 

class driver extends uvm_driver;

  `uvm_component_utils(driver)

  function new(string name, uvm_component parent);
    super.new(name);
  endfunction

  task run_phase(uvm_phase phase);
    phase.raise_objection(this, "Starting test");
    #100ns;
    `uvm_info(get_type_name(), "Driver is printing at run_phase executing...", UVM_LOW )    
    phase.drop_objection(this, "Finishing test");
  endtask: run_phase

  virtual function void phase_ready_to_end(uvm_phase phase);
    if(phase.get_name == "run")
      `uvm_info(get_type_name(), "Driver is printing at phase_ready_to_end...", UVM_LOW )

  endfunction: phase_ready_to_end

  virtual function void phase_ended(uvm_phase phase);
    if(phase.get_name == "run")
      `uvm_info(get_type_name(), "Driver is printing at phase_ended...", UVM_LOW )

  endfunction: phase_ended

endclass: driver

 

 when it run one of cases, it printed the information as follow:

 

# UVM_INFO @ 0: reporter [RNTST] Running test tc_read_ver_reg...
# UVM_INFO ../../monitor.sv(41) @ 0: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at phase_ready_to_end...
# UVM_INFO ../../monitor.sv(35) @ 50000: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at post_shutdown_phase executing...
# UVM_INFO ../../driver.sv(22) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at run_phase executing...
# UVM_INFO ../../driver.sv(28) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at phase_ready_to_end...
# UVM_INFO ../../monitor.sv(48) @ 100000: uvm_test_top.tb.agent.monitor [monitor] Monitor is printing at phase_ended...
# UVM_INFO ../../driver.sv(34) @ 100000: uvm_test_top.tb.agent.driver [driver] Driver is printing at phase_ended...
#

 

The post_shutdown_phase of the monitor reached to phase_ready_to_end at 0, but it's task post_shutdown_phase did not finish until  @ 50000.

 

What is wrong with it?

 

Thank you in advanced!

 

BR

 

QIN

Share this post


Link to post
Share on other sites

Your  monitor::post_shutdown_phase did not raise an objection at time zero, the default drain time is 0ns, and you waited 50ns to start. No surprise that the phase is ready to shutdown. ALL run-time phases need objections raised to keep the respective component's phase method running. This starts at time zero.

Share this post


Link to post
Share on other sites

hi,

 

although there has been no objection against the end of post_shutdown_phase the phase continues to run past ready_to_end. this is because ALL predecessors of the next phase need to be in the phase ready to end state. since both run_phase and post_shutdown_phase have a joint next phase all tasks in run_phase and post_showdown_phase will be terminated at the same time. for your example it means that its guaranteed that the last of the runtime phases (post_showdown_phase) will not end before run_phase has ended (100ns)

 

"ready to end" just means we "could" end if all agree. if we do not agree the tasks continue to run

"phase_ended" means we really ended this phase and we continue to the next phase

 

/uwe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×