当我尝试使用任务修改小型测试平台上的reg数组时,我发现它运行良好。但是在大型设计(以及基于OVM的env)上,似乎不会修改数组。
小型测试台代码:
class test;
rand int rd_data;
function new();
rd_data = rd_data | 'b10000;
$display($psprintf("\nrd_data:0x%x\n",rd_data));
rd_data &= ~(1<<4);
$display($psprintf("\nrd_data:0x%x\n",rd_data));
endfunction
task task1(ref reg[31:0] refd_reg);
$display($psprintf("\nbefore refd_reg:0x%x\n",refd_reg));
refd_reg = ~refd_reg;
$display($psprintf("\nafter refd_reg:0x%x\n",refd_reg));
endtask;
endclass
module test_top;
submodule submodule1();
test test1 = new();
initial begin
$display($psprintf("\nSeed:0x%x\n",$get_initial_random_seed()));
end
initial begin
foreach (submodule1.register1[i]) submodule1.register1[i] =0;
end
initial begin
#5 test1.task1(submodule1.register1[5]);
#5 test1.task1(submodule1.register1[5]);
#5 $finish();
end
endmodule
module submodule;
reg [31:0] register1[0:2047];
endmodule