I've the below example for multi dimensional dynamic array randomization;
program main();
class base;
rand int array_of_frames[][][];
rand int frame_height;
rand int frame_width;
rand int no_of_frames;
constraint no_of_frames_c { no_of_frames>1;no_of_frames<3;}
constraint frame_height_c { frame_height>10;frame_height<20;}
constraint frame_width_c {frame_width>1;frame_width<100;}
constraint array_of_frames_c {
array_of_frames.size == no_of_frames;
foreach (array_of_frames[i]) { array_of_frames[i].size == frame_height; }
foreach (array_of_frames[i,j]) { array_of_frames[i][j].size == frame_width; }
}
function void post_randomize();
for(int i=0; i<array_of_frames.size; i++) begin
for(int j=0; j<array_of_frames[i].size; j++) begin
for(int k=0; k<array_of_frames[i][j].size; k++) begin
$write("0x%x ", (array_of_frames[i][j][k] & 32'hFF));
end
$display(" ");
end
$display(" ");
end
endfunction
endclass
base b0 = new();
initial
void'(b0.randomize());
endprogram
After simulation I've been observed the below message from irun.log;
void'(b0.randomize());
|
ncsim: *W,SVRNDF (./multi_ddynamic_array.sv,53|19): The randomize method call failed.
Observed simulation time : 0 FS + 1
ncsim: *W,RNDOCS: These constraints contribute to the set of conflicting constraints:
constraint frame_height_c { frame_height>10;frame_height<20;} (./multi_ddynamic_array.sv,19)
foreach (array_of_frames[i]) { (./multi_ddynamic_array.sv,25)
ncsim: *W,RNDOCS: These variables contribute to the set of conflicting constraints:
rand variables:
frame_height [./multi_ddynamic_array.sv, 11]
I'm using the below NCSIM Version;
/tools/icad/cadence_lnx/ius/141.014/tools/bin/irun
Please help in this regard whether I've missed something on constraints. However the above code is working fine with the other tools.
Thanks,
Regards,
Mahesh.