我已经编写了一个有3个代理的UVM测试台,现在正在编写记分牌/检查器。我需要为我的SystemVerilog断言有一个检查器模块,但是这个检查器模块需要知道从测试中完成的寄存器配置(并且可以是随机的,在测试的run_phase期间决定)。
我无法弄清楚这将如何工作?如果我要为断言创建一个检查器模块,并在顶层(tb_top)将其绑定到dut,那么这个检查器模块如何知道我的寄存器配置?
在阅读了一些论文之后,我想我可以把我的checker模块写成一个接口,设置在tb_top中。但这将使我的接口中的变量访问到uvc。接口如何访问uvc中的变量?
任何帮助都是感激的。我觉得我在这里错过了一些关键的东西,因为这可能已经做过很多次了。
编辑:请不要告诉我我必须实现某种API来设置我的uvc中的每个单独的寄存器设置?我想只是得到一个处理我的reg_block(或任何其他配置变量在我的代理)
似乎您想将信息从tb_top
传递到UVC
,反之亦然。此信息将由您在tb_top
中的断言使用,并由您的UVC共享。我的建议是,您可以使用uvm_resource_db
或uvm_config_db
。
我可以想到两种实现这种交流的方法。
第一个方法是set
在你的tb_top
中的配置,然后你的UVC抓住这个句柄。从这里开始,您可以通信您的寄存器或您的断言所需的任何信息。
class my_tb_config extends uvm_object;
// ...
endclass
module tb_top;
my_tb_config tcfg;
initial begin
tcfg = new("tcfg");
uvm_config_db#(my_tb_config)::set(uvm_root::get(), "*", "my_tb_config", tcfg);
end
endmodule
// somewhere in your UVC
class my_uvc extends uvm_component;
my_tb_config tcfg;
function void build_phase(uvm_phase phase);
// now both tb_top and your UVC point to the same config object
void'(uvm_config_db#(my_tb_config)::get(this,"","my_tb_config", tcfg));
endfunction
endclass
另一种方法是相反的。将UVC配置传递给tb_top
。
class my_other_uvc extends uvm_component;
my_tb_config tcfg;
function void build_phase(uvm_phase);
tcfg = new("tcfg");
uvm_resource_db#(my_tb_config)::set("*", "my_tb_config", tcfg);
endfunction
endclass
// somewhere in your tb_top
module tb_top;
my_tb_config tcfg;
initial begin
#1ps; // small delay, making sure resource is submitted
void'(uvm_resource_db#(my_tb_config)::read_by_name("*","my_tb_config",tcfg);
// Now both your tb_top and UVC share same object, so you can freely define your whatever communication between them
end
endmodule
我想出了一个办法。首先,我意识到我问了两个不同的问题:
1) 我的检查器模块需要知道从测试
完成的寄存器配置我在设计中使用跨模块引用来访问寄存器,这为我提供了运行阶段测试设置的最新寄存器配置。
tb.sv
module tb;
dut my_dut( ... )
interface my_checker (
.input_registerA (tb.my_dut.my_sub_module.regA),
.input_registerB (tb.my_dut.my_sub_module.regB),
.input_registerC (tb.my_dut.my_other_sub_module.regC),
....
)
endmodule
my_checker.sv
interface my_checker (
input input_registerA,
input input_registerB,
input input_registerC,
....
);
// Here I can write properties/assertions that are register-aware
endinterface
2) 接口如何访问uvc中的变量?
这有点棘手。我想从uvm_sequence或uvm_monitor等动态更新我的检查器变量。
我读了Verilab的这篇论文,清楚地描述了这样做的方法:http://www.verilab.com/files/litterick_sva_encapsulation.pdf
在我的检查器模块,我创建了一个uvm_component。从这个组件,我现在可以访问uvm_resource_db,通过它我可以与我的UVM-testbench交换信息。
需要记住的一点是,在检查器模块中实例化的uvm_component位于顶层(uvm_root)。