Constraint question

Hi,

I would like to have unique elements in the array. I have expanded the below array and constrained it to be unique without unique constraint, but i am seeing repeated values. I don’t want to use helper array to constraint.

Solution space:

arr = '{'{'{0, 0}, '{0, 1}}, '{'{224, 114}, '{217, 213}}}
# arr = '{'{'{7, 12}, '{24, 213}}, '{'{12, 245}, '{29, 227}}}
# arr = '{'{'{22, 122}, '{188, 149}}, '{'{10, 42}, '{100, 136}}}
class test;
  rand byte unsigned arr[2][2][2];
  
  
  constraint ba {
    foreach (arr[i,j,k])
      arr.sum(item1) with (item1.sum(item2) with (item2.sum(item3 == arr[i][j][k]))) == 1;
  }
endclass
      
      module tb;
        test t1;
        initial begin
          t1 = new();
          repeat (3) begin
          if (!t1.randomize()) $display ("Error");
            $display ("arr = %p",t1.arr);
          end
         end
        
      endmodule

You would have to use many deeply nested foreach loops.

I don’t want to do your homework for you.