当我尝试使用任务在小型测试平台上修改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