Generate unique elements in an array

In reply to mseyunni:

class A;
     bit [PDW_INDEX_BITS-1:0] used_dcd2pdw[$][2**DCD_INDEX_BITS];
     rand bit[PDW_INDEX_BITS-1:0] dcd2pdw[2**DCD_INDEX_BITS];
     constraint uniq {unique {dcd2pdw,used_dcd2pdw};}
     function void post_randomize;
	used_dcd2pdw.push_back(dcd2pdw);
     endfunction
   
endclass:A

The uniq constraint will eventually fail after so many calls to randomize(). I’ll leave it to you to figure out what to do when it does.