产生相关数字的 UVM 序列
UVM sequences producing related numbers
在 UVM 测试中,我声明并启动了序列,但是具有相同参数的不同序列的输出是 "related" 不知何故(参见底部的示例),所以当我进行交叉覆盖时,我只覆盖12.5%的情况,是什么原因造成的?如何让两个序列的输出独立且随机?
//declare
ve_master_sequence#( 8,`num_inputs) x_agent_sequence_inst;
ve_master_sequence#( 8,`num_inputs) y_agent_sequence_inst;
//build_phase
x_agent_sequence_inst = ve_master_sequence#( 8,`num_inputs)::type_id::create("x_seq");
y_agent_sequence_inst = ve_master_sequence#( 8,`num_inputs)::type_id::create("y_seq");
//run_phase
x_agent_sequence_inst.start(multadd_env_inst.ve_x_agent_inst.sequencer);
y_agent_sequence_inst.start(multadd_env_inst.ve_y_agent_inst.sequencer);
环境包含 4 个主代理,两个 32 位,两个 8 位。所有代理
上的相同参数化序列是运行
// within the sequence
virtual task body();
`uvm_info("ve_master_sequence", $sformatf("begin body()"), UVM_MEDIUM);
for(int i=0; i<length; i++) begin
req = ve_seq_item#(data_width)::type_id::create("req");
start_item(req);
while(!req.randomize() with {
data <= (2**data_width)-1;
delay dist { [0:1] := 2, [2:6] := 1};
});
finish_item(req);
get_response(req);
end
#1000;
endtask
我用 $urandom_range 替换了 req.randomize(),这有效,但这意味着失去了 systemverilog 的所有受限随机能力。
当我运行代码,做交叉覆盖时,相同大小的sequencer的输出之间有关系,
when y = 0 is always x = 79 or 80
when y = 1 is always x = 80 or 81
when y = 2 is always x = 81 or 82
....
when y = 51 is always x = 130 or 131
when y = 52 is always x = 131 or 132
等..
显然 UVM 使用其父随机数生成器和序列 name to create a new RNG for the sequence. This is to give good random stability。
尝试更改序列的名称,使它们更加独特。我假设较长的唯一字符串会提供更高程度的随机化。
在序列 class 中,这个循环创建了序列项。解释是(如上所述)UVM 使用 class 层次结构来创建随机种子,这提供了良好的随机稳定性
for(int i=0; i<1000; i++) begin
//this caused the error
req = ve_seq_item#(data_width)::type_id::create("req");
//this fixed it
req = ve_seq_item#(data_width)::type_id::create($sformatf("req_%1d", i));
//randomizing the sequence item with the loop variable
在 UVM 测试中,我声明并启动了序列,但是具有相同参数的不同序列的输出是 "related" 不知何故(参见底部的示例),所以当我进行交叉覆盖时,我只覆盖12.5%的情况,是什么原因造成的?如何让两个序列的输出独立且随机?
//declare
ve_master_sequence#( 8,`num_inputs) x_agent_sequence_inst;
ve_master_sequence#( 8,`num_inputs) y_agent_sequence_inst;
//build_phase
x_agent_sequence_inst = ve_master_sequence#( 8,`num_inputs)::type_id::create("x_seq");
y_agent_sequence_inst = ve_master_sequence#( 8,`num_inputs)::type_id::create("y_seq");
//run_phase
x_agent_sequence_inst.start(multadd_env_inst.ve_x_agent_inst.sequencer);
y_agent_sequence_inst.start(multadd_env_inst.ve_y_agent_inst.sequencer);
环境包含 4 个主代理,两个 32 位,两个 8 位。所有代理
上的相同参数化序列是运行// within the sequence
virtual task body();
`uvm_info("ve_master_sequence", $sformatf("begin body()"), UVM_MEDIUM);
for(int i=0; i<length; i++) begin
req = ve_seq_item#(data_width)::type_id::create("req");
start_item(req);
while(!req.randomize() with {
data <= (2**data_width)-1;
delay dist { [0:1] := 2, [2:6] := 1};
});
finish_item(req);
get_response(req);
end
#1000;
endtask
我用 $urandom_range 替换了 req.randomize(),这有效,但这意味着失去了 systemverilog 的所有受限随机能力。
当我运行代码,做交叉覆盖时,相同大小的sequencer的输出之间有关系,
when y = 0 is always x = 79 or 80
when y = 1 is always x = 80 or 81
when y = 2 is always x = 81 or 82
....
when y = 51 is always x = 130 or 131
when y = 52 is always x = 131 or 132
等..
显然 UVM 使用其父随机数生成器和序列 name to create a new RNG for the sequence. This is to give good random stability。
尝试更改序列的名称,使它们更加独特。我假设较长的唯一字符串会提供更高程度的随机化。
在序列 class 中,这个循环创建了序列项。解释是(如上所述)UVM 使用 class 层次结构来创建随机种子,这提供了良好的随机稳定性
for(int i=0; i<1000; i++) begin
//this caused the error
req = ve_seq_item#(data_width)::type_id::create("req");
//this fixed it
req = ve_seq_item#(data_width)::type_id::create($sformatf("req_%1d", i));
//randomizing the sequence item with the loop variable