我已经编写了一个包含 3 个代理的 UVM 测试平台,现在正在编写记分板/检查器。我需要为我的 SystemVerilog 断言提供一个检查器模块,但该检查器模块需要了解测试中完成的寄存器配置(并且可以是随机的,在测试的 run_phase 期间决定)。
我无法弄清楚这是如何工作的?如果我要为我的断言创建一个检查器模块,并将其在顶层 (tb_top) 绑定(bind)到 dut,那么该检查器模块如何知道我的寄存器配置?
读了一些论文后,我想我可以将我的检查器模块编写为一个接口(interface),并将其设置在 tb_top 中。但这将允许访问我的 UVC 接口(interface)中的变量。接口(interface)如何访问UVC中的变量?
感谢任何帮助。我觉得我在这里遗漏了一些关键的东西,因为这可能已经做过很多次了。
编辑:请不要告诉我我必须实现某种 API 来设置 UVC 中的每个单独的寄存器设置?我只想获取我的 reg_block (或我的代理中的任何其他配置变量)的句柄
最佳答案
您似乎想将信息从 tb_top
传递到 UVC
,反之亦然。此信息将由您在 tb_top
中的断言使用,并由您的 UVC 共享。我的建议是,您可以使用 uvm_resource_db
或 uvm_config_db
。
我可以想到两种实现这种沟通的方法。
第一种方法是在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
关于system-verilog - UVM 测试台中的断言模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40052695/