How does uvm_component go to Clean-up phases from Run_phases?

Hi,

From what I’ve understood so far, uvm_components have each phase so that all objects are able to go to the next phase when all the same phase of every uvm_component objects are finished.
If so, all uvm_component should finish its own run_phase to go to the next phase. All uvm_components eventually complete all run_phase. Then why do we need to have phase.raise_objection & phase.drop_objection?
Can you help me where I misunderstand…?

Thank you,
Seunghyun Lee

In reply to dv_lee86:

The build phases and cleanup phases are implemented as functions, so they are all expected to complete in 0 time.

The run phases will consume time, so the UVM scheduler will fork these tasks in parallel. After forking the tasks, the UVM scheduler uses the objection mechanism to determine what tasks are still actively generating stimulus. When the stimulus tasks are finished and drop their objections, it will then kill all the remaining tasks that were forked. This mechanism allows drivers/monitors to execute in forever loops since they have no knowledge of when to finish.

In reply to cgales:

Thank you for reply.
I am still confused and I have two questions.

  1. If no ones raise phase.raise_objection explicitly, test may finish right after starting run_phase?
  2. From what I understood, All the same phase state should be completed to go to the next phase state. In run_phase state, some components which could not complete run_phase because of no raise_objection can go to the next phase state?
    For example, there are two objects which are uvm_components.
    In run_phase, test should not be finished until comp1 do drop_objection. After comp1 drop_objection, can comp1 go to check_phase, even if comp2 could not finish comp2 run_phase?

If so, it’s conflicted with my thought that all the uvm components always do the same phase at the same time and should complete the previous phase to go to the next phase. It’s conflicted with my thought because only uvm_component with raise/drop_objection seem to be able to finish. And only those which have finished can go to the next phase such as check_phase, and report_phase.
Please correct me.

//////////////////////////////////////////////////

class comp1
...
task run_phase
phase.raise_objection
...
phase.drop_objection

endtask: run_phase

task check_phase
...
endtask: check_phase
//////////////////////////////////////////////////
class comp2 
task run_phase
// no phase.raise_objection / drop_objection

endtask: run_phase

task check_phase
...
endtask: check_phase
//////////////////////////////////////////////////

Thank you,
Seunghyun Lee

In reply to dv_lee86:

The UVM scheduler will start the same phase of each component at the same time.

For a time consuming phase, the scheduler will wait for all objections to be dropped. When all objections are dropped, any additional tasks which are still running will be killed. In the case where no component raises an objection, the phase will immediately be terminated and the next phase will start. This can result in tests immediately finishing in 0 time.

In your example, the run_phase in comp1 and comp2 are forked. Since comp1 raises an objection, the scheduler will wait for the objection to be dropped. When this happens, since there are no outstanding objections, the run_phase of comp2 will be killed. The scheduler will then proceed to the next phase.

A component can’t start a phase on its own. The execution of phases is controlled by the scheduler.

uvm_component divided into three phases 1. Build phases 2. Run phases 3. Clean-up phases
  • Build phases and run phases start simulation at 0 time unit and then clean up phases start.
  • Build phases and clean up phases are function and run-phases will time consuming…
  • Let build start at 0 time and end also,
    run_phase start at 0 time unit but it take some time to complete lets take (alpha)
    clean-up phase start (alpha time) once run phases over, and then execute all the function like extract, check, report and final…

All these process start when we invoke run_test() or unm_root…

In reply to dv_lee86:

Here is a simplified example showing how the UVM executes each phase (without objections)

class Component;
  string m_name;
  Component m_parent;
  static Component list[$];
  function new(string name, Component parent);
    m_name = name;
    m_parent = parent;
    list.push_back(this);
  endfunction
  function string get_fullname;
    if (m_parent == null)
      return m_name;
    else
      return {m_parent.get_fullname(), "." , m_name};
  endfunction         
  virtual function void build_phase;
  endfunction 
  virtual task run_phase;
  endtask 
  virtual function void report_phase();
  endfunction 
endclass 
class A extends Component;
  function new(string name, Component parent);
      super.new(name,parent);
     $display("A Constructing: ", get_fullname);
   endfunction
   task run_phase;  
     #10  $display("Running   from ",get_fullname(),,$time);
   endtask
   function void report_phase;
          $display("Reporting from ",get_fullname(),,$time);
   endfunction
  
endclass 
class B extends Component;
  function new(string name, Component parent);
   super.new(name,parent);
   $display("B Constructing: ", get_fullname);
  endfunction
  A a;
  function void build_phase;
    a = new("a",this);
  endfunction
  task run_phase;  
    #20  $display("Running   from ",get_fullname(),,$time);
  endtask
endclass 
class Root extends Component;
  function new(string name, Component parent);
    super.new(name,parent);
    $display("env Constructing: ", get_fullname);
   endfunction
  A a;
  B b;
  function void build_phase;
    a = new("a",this);
    b = new("b",this);
  endfunction
  task run_test;
    // build_phase
    for(int item=0;item<list.size();item++)
      list[item].build_phase();
    // run_phase 
    foreach(list[item])
      fork
        int k = item;
        list[k].run_phase();
      join_none
    wait fork;
    // report phase
    foreach(list[item])
      list[item].report_phase();
      endtask
endclass

module top;
   Root root;
   initial begin
     root =new("root",null);
     root.run_test();
   end
endmodule

In reply to cgales:

Thank you all for kindly helping me understand. I did not know that scheduler do wait in time-consuming phase.

Thank you,
Seunghyun Lee