简体   繁体   English

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

[英]Disabling a scoreboard from a sequence using UVM

I have a uvm_sequence that randomizes an enable bit "feature_en". 我有一个uvm_sequence,它将使能位“ feature_en”随机化。 Depending on whether this bit is enabled or not, I want to enable/disable my scoreboard. 根据是否启用此位,我要启用/禁用记分板。 I use the config_db to set the variable, and the field_macros to automatically get it in the scoreboard. 我使用config_db设置变量,并使用field_macros在记分板上自动获取它。

My problem is that in the scoreboard, I want to guard the code in the run_phase with "feature_en". 我的问题是在记分板上,我想使用“ feature_en”保护run_phase中的代码。 However, the sequence is run in the run_phase of the test and thus, the run_phase of the scoreboard goes first, thereby keeping feature_en default value and not getting the value set my the sequence. 但是,序列在测试的run_phase中运行,因此记分板的run_phase首先进入,从而保持feature_en为默认值,而没有获得该序列中设置的值。

I tried using wait(feature_en != -1) (i had set it as an int), but I realize that feature_en is not sampled again in the scoreboard. 我尝试使用wait(feature_en!= -1) (我已将其设置为int),但我意识到feature_en不会在记分板上再次采样。

Is there a way to update feature_en dynamically in the scoreboard? 有没有办法在记分板上动态更新feature_en? Or any other way to do this? 或任何其他方式做到这一点?

You can create one dedicated uvm_object to do that. 您可以创建一个专用的uvm_object来执行此操作。 For example: 例如:

class feature_options extends uvm_object;
    bit sb_enable=0;
    // ...
endclass

Instantiate it in your top-level testbench, and then put it in uvm_config_db: 将其实例化到顶级测试平台中,然后将其放入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

and then grab the object from your own scoreboard and sequencer: 然后从您自己的记分板和音序器中获取对象:

// 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

After this, you can dynamically synchronize your sequence and your scoreboard, for example: 之后,您可以动态地同步序列和记分板,例如:

// inside your scoreboard run phase
wait (f_opt.sb_enable);

and

// 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

feature_en can be switched on/off directly, not through the config_db Assuming your scoreboard is a component ( your scoreboard extends uvm_scoreboard ) in the sequence : feature_en可以直接打开/关闭,而不是通过config_db来打开/关闭。假设您的计分板是以下组成部分(您的计分板扩展了uvm_scoreboard):

my_env env;
....
$cast(env, get_sequencer().get_parent().get_parent()); //env.agent.sequencer 
env.sb.feature_en = 1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM