UVM测试平台中的断言模块

时间:2016-10-14 22:09:33

标签: system-verilog uvm

我编写了一个有3个代理的UVM测试平台,现在正在编写记分板/检查器。我需要为我的SystemVerilog Assertions设置一个检查器模块,但是这个检查器模块需要知道从测试中完成的寄存器配置(并且可以是随机的,在测试的run_phase期间决定)。

我无法弄清楚这是如何起作用的?如果我要为我的断言创建一个checker模块,并将它在顶层(tb_top)绑定到dut,那么这个checker模块如何知道我的寄存器配置?

在阅读了一些论文之后,我想我可以将我的checker模块编写为接口,将其设置为tb_top。但这样可以访问我与UVC的接口中的变量。接口如何访问UVC中的变量?

感谢任何帮助。我觉得我错过了一些关键的东西,因为这可能已经做过很多次了。

编辑:请不要告诉我我必须实现某种API来设置我的UVC中的每个寄存器设置?我想获得我的reg_block(或我的代理中的任何其他配置变量)的句柄

2 个答案:

答案 0 :(得分:2)

您似乎希望将信息从tb_top传递到UVC,反之亦然。您的断言将在tb_top中使用此信息,并由您的UVC共享。我的建议是,您可以使用uvm_resource_dbuvm_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 :(得分:1)

我找到了一种方法来做到这一点。首先,我意识到我曾问过两个不同的问题:

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

在我的checker模块中,我创建了一个uvm_component。从这个组件,我现在可以访问uvm_resource_db,通过它我可以用我的UVM-testbench交换信息。

要记住的一件事是在checker模块中实例化的uvm_component位于顶层(uvm_root)。

相关问题