System verilog 有没有办法从测试台顶部进入uvm_阶段?

System verilog 有没有办法从测试台顶部进入uvm_阶段?,system-verilog,uvm,System Verilog,Uvm,有没有办法在我的测试台上了解UVM层次结构的当前阶段?。因为testbench top是一个静态模块,而UVM层次结构由动态类组成 在我的测试台顶部,我直接驱动几个UVM层次结构之外的端口。我需要停止驱动这些端口,比如在关机阶段之后。我可以使用uvm_config_db从序列中传递一个相位来完成,但我不想创建依赖项。我知道它违背了使用UVM和可重用性的目的,但只是问我是否可以这样做 module top() initial begin drive_ports();

有没有办法在我的测试台上了解UVM层次结构的当前阶段?。因为testbench top是一个静态模块,而UVM层次结构由动态类组成

在我的测试台顶部,我直接驱动几个UVM层次结构之外的端口。我需要停止驱动这些端口,比如在关机阶段之后。我可以使用uvm_config_db从序列中传递一个相位来完成,但我不想创建依赖项。我知道它违背了使用UVM和可重用性的目的,但只是问我是否可以这样做

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

您可以尝试此操作以获取当前阶段

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;

谢谢,我尝试了下面的代码,效果很好。似乎每个阶段都可以在测试台顶部使用“uvm_top.m_current_phase”访问,只要您在测试台顶部导入uvm_pkg。由于build_phase()在时间0开始,因此在testbench top中使用initial_begin访问此变量会导致运行时错误。因此,在top TB中添加了等待语句,它可以正常工作

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

谢谢,我尝试了下面的代码,效果很好。似乎每个阶段都可以在测试台顶部使用“uvm_top.m_current_phase”访问,只要您在测试台顶部导入uvm_pkg。由于build_phase()在时间0开始,因此在testbench top中使用initial_begin访问此变量会导致错误,因此添加了wait语句YUP。最初,您可能需要添加wait,但之后它应该可以工作。