I am trying to randomize a n*n array and make it unique without foreach or unique keyword. why doesn’t the below code produce unique values?
class tb;
rand bit [3:0] arr[2][2];
constraint ab_c {
arr.sum(item1) with (item1.sum(item2) with (int'(item2))) == 1; }
endclass
module t;
tb t1;
initial begin
t1 = new();
repeat (5) begin
if (!t1.randomize()) $display("Error");
$display("%p",t1.arr);
end
end
endmodule