Jump to content

How to use phase_ready_to_end?


Recommended Posts

Hi experts,

Why is phase_ready_to_end called more than once in codes below?

class top extends uvm_test;
    `uvm_component_utils(top)

    function new(string name="top",uvm_component parent=null);
        super.new(name,parent);
    endfunction
    
    function void build_phase(uvm_phase phase);
    endfunction

    task run_phase(uvm_phase phase);
        phase.raise_objection(this);
        #10;
        phase.drop_objection(this);
    endtask

    task delay_to_end(uvm_phase phase);
        #1;
        `uvm_info(get_name(),$sformatf("Now to end %s...",phase.get_name()),UVM_LOW)
        phase.drop_objection(this);
    endtask

    function void phase_ready_to_end(uvm_phase phase);
        if(phase.get_name == "main")begin
            `uvm_info(get_name(),"Not yet to end...",UVM_LOW)
            phase.raise_objection(this);
            fork
                begin
                    #1;
                    this.delay_to_end(phase);
                end
            join_none
        end
    endfunction

    function void phase_started(uvm_phase phase);
        if(phase.get_name == "main")
            `uvm_info(get_name(),"main_phase is started...",UVM_LOW)
    endfunction

    function void phase_ended(uvm_phase phase);
        if(phase.get_name == "main")
            `uvm_info(get_name(),"main_phase is ended...",UVM_LOW)
    endfunction

endclass
sim log:

UVM-1.1
(C) 2007-2011 Mentor Graphics Corporation
(C) 2007-2011 Cadence Design Systems, Inc.
(C) 2006-2011 Synopsys, Inc.
(C) 2011      Cypress Semiconductor Corp.
----------------------------------------------------------------
UVM_INFO @ 0: reporter [RNTST] Running test top...
UVM_INFO test7_phrdytoend.sv(84) @ 0: uvm_test_top [uvm_test_top] main_phase is started...
UVM_INFO test7_phrdytoend.sv(71) @ 0: uvm_test_top [uvm_test_top] Not yet to end...
UVM_INFO test7_phrdytoend.sv(65) @ 2: uvm_test_top [uvm_test_top] Now to end main...
...........................
UVM_INFO test7_phrdytoend.sv(71) @ 34: uvm_test_top [uvm_test_top] Not yet to end...
UVM_INFO test7_phrdytoend.sv(65) @ 36: uvm_test_top [uvm_test_top] Now to end main...
UVM_INFO test7_phrdytoend.sv(71) @ 36: uvm_test_top [uvm_test_top] Not yet to end...
UVM_INFO test7_phrdytoend.sv(65) @ 38: uvm_test_top [uvm_test_top] Now to end main...
UVM_INFO test7_phrdytoend.sv(89) @ 38: uvm_test_top [uvm_test_top] main_phase is ended...

Thanks.

Link to comment
Share on other sites

phase_ready_to_end() is called whenever the total objection count for the current phase decrements to 0. If the objection is raised and dropped in phase_ready_to_end(), it will be called again. To avoid endless loops, there is a maximum count of phase_ready_to_end() that defaults to 20.

Link to comment
Share on other sites

Thank dave.

Finally i found in in uvm_phase.svh.

int unsigned max_ready_to_end_iter = 20;

For every type of phase, phase_ready_to_end will be iterated for 19 times. After this iteration, all forks will be killed.

is this arg configurable?

Is there any way to set this arg to 2 and make it run once?

Thanks.

Link to comment
Share on other sites

Hi dave,

May I ask another question?

When use the red line below, simulation will be ended at time 2. In this case, why is run_phase block also killed?

Thanks.

task run_phase(uvm_phase phase);
        phase.raise_objection(this);
        #10;
        phase.drop_objection(this);
    endtask

    task delay_to_end(uvm_phase phase);
        #1;
        `uvm_info(get_name(),$sformatf("Now to end %s...",phase.get_name()),UVM_LOW)
        phase.drop_objection(this);
    endtask

    function void phase_ready_to_end(uvm_phase phase);
        static int done = 0;
        if(done)return;
      [COLOR="Red"]  //if(phase.get_name == "main")begin[/COLOR]
        if(phase.get_name == "run")begin
            `uvm_info(get_name(),"Not yet to end...",UVM_LOW)
            phase.raise_objection(this);
            fork
                begin
                    #1;
                    this.delay_to_end(phase);
                    done = 1;
                end
            join_none
        end
    endfunction
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...