In reply to dave_59:
Thank you Dave,
“You call randomize() inside the for-loop displaying the array. That means randomize() gets called many times before some elements are displayed. Call randomize() once before trying to display.”
class test3_c;
rand logic [7:0] width;
rand logic [7:0] height;
randc logic [2:0] arr_2d[][];
randc logic [2:0] queue_1d[$];
randc logic [2:0] arr_1d[];
randc logic [2:0] arr;
constraint size_con {
width inside {[0:255]};
height inside {[0:255]};
arr inside {[2:7]};
arr_1d.size == 3;
foreach(arr_1d[i]) {
arr_1d[i] > 1;
arr_1d[i] < 6;
}
}
//constraint uni {
// unique {arr_1d};
//}
endclass
module test3;
initial begin
test3_c test;
test = new();
//for arr;
void'(test.randomize());
for(int i=0; i<3; i++) begin
$display("data[%0d]=%0d", i,test.arr);
end
end
But if I do this, then I get the same values
data[0]=6
data[1]=6
data[2]=6