有没有办法在我的测试台顶部了解UVM层次结构的当前阶段?由于测试台顶部是一个静态模块,而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 开始,因此在测试台顶部使用 initial_begin 访问此变量会导致运行时错误。所以在顶部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