使用 UVM 禁用序列中的记分板

noo*_*ntu 2 system-verilog uvm

我有一个 uvm_sequence 随机化启用位“feature_en”。根据是否启用此位,我想启用/禁用我的记分板。我使用 config_db 来设置变量,并使用 field_macros 自动将其获取到记分板中。

我的问题是,在记分牌中,我想用“feature_en”保护 run_phase 中的代码。但是,该序列在测试的 run_phase 中运行,因此记分板的 run_phase 首先运行,从而保留 feature_en 默认值,并且不会获取序列中设置的值。

我尝试使用wait(feature_en != -1)(我已将其设置为 int),但我意识到 feature_en 不会在记分牌中再次采样。

有没有办法在记分牌中动态更新feature_en?或者还有其他方法可以做到这一点吗?

Ald*_*doT 5

您可以创建一个专用的 uvm_object 来执行此操作。例如:

class feature_options extends uvm_object;
    bit sb_enable=0;
    // ...
endclass
Run Code Online (Sandbox Code Playgroud)

在顶级测试台中实例化它,然后将其放入 uvm_config_db 中:

// in your top-level testbench:
feature_options f_opt;
initial begin
    f_opt = new("f_opt");
    uvm_config_db#(feature_options)::set(uvm_root::get(), "*", "FEATURE_OPTIONS", f_opt);
end
Run Code Online (Sandbox Code Playgroud)

然后从你自己的记分板和音序器中抓取对象:

// add the class handle in your scoreboard and your sequencer
feature_options my_opt;

// ... inside your scoreboard/sequencer build phase, grab the object
if (!uvm_config_db#(feature_options)::get(this,"","FEATURE_OPTIONS", my_opt)) begin
$display("Ok");
end
Run Code Online (Sandbox Code Playgroud)

之后,您可以动态同步您的序列和记分板,例如:

// inside your scoreboard run phase
wait (f_opt.sb_enable);
Run Code Online (Sandbox Code Playgroud)

// inside your sequence body()
p_sequencer.my_opt.sb_enable = 1;
// ... do some test, then disable scoreboard
p_sequencer.my_opt.sb_enable = 0; // and so on
Run Code Online (Sandbox Code Playgroud)