Is there a way to access uvm_phase from the testbench top?

Is there a way to know in my testbench top about the current phase of the UVM hierarchy?. Since testbench top is a static module and UVM hierarchy is made of classes which are dynamic.

In my testbench top, I am directly driving few ports which is outside of UVM hierarchy. I need to stop driving these ports say after the shutdown phase. I can do it using uvm_config_db passing a phase from sequence but I don't want to create dependencies. I know it defeats the purpose of using UVM and reusability but just asking if I can do that?.

module top() initial begin drive_ports(); end virtual task drive_ports() //I need to keep driving these ports till shutdown_phase if (!uvm_tb_hierarchy.phase == shutdown_phase) //?? How to get phase?? dut.port = 8'hff dut.en = 1; endtask initial begin run_test() end endmodule 

2 Answers

You can try this to get the current phase.

uvm_root top; uvm_phase curr_phase. uvm_coreservice_t cs = uvm_coreservice_t::get(); top = cs.get_root(); curr_phase = top.m_current_phase; 
2

Thanks, I tried the below code and it works. It seems each phase can be accessed at testbench top using "uvm_top.m_current_phase" provided you import uvm_pkg at testbench top. Since build_phase() starts at time 0, accessing this variable using initial_begin in testbench top was resulting in runtime error. So added wait statement in top TB and it works.

module top(); import uvm_pkg::*; int shutdown; initial begin wait (uvm_top != null); while (1) begin @(uvm_top.m_current_phase); if (uvm_top.m_current_phase != null) begin case (uvm_top.m_current_phase.get_name()) "pre_shutdown": shutdown = 1; endcase end end end endmodule 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like