Randc not generating unique random values

Trying to use randc to generate unique random 8 bit abd 2 bit values, since maximum randc can handle is 8 bit values.

But i don’t see unique random values from randc…i see for a 2 bit value, 1,2,0,1 getting generated, and even 8 bit is not unique. What might be happening?



module A;

class C;
  randc bit[7:0] randc_value [256];
  randc bit[1:0] bit_value [4];
endclass
  

  initial begin
    
    C c1;
    c1 = new();
    c1.randomize();
       
    $display (" randc_value = %p, bitvalue = %p ", c1.randc_value, c1.bit_value);
  end
  
    
endmodule



output:

Loading sv_std.std

Loading work.A(fast)

vsim -voptargs=+acc=npr

run -all

randc_value = '{223, 222, 63, 52, 47, 123, 119, 72, 16, 99, 77, 34, 223, 150, 140, 148, 15, 199, 105, 28, 96, 21, 38, 249, 162, 177, 134, 48, 84, 224, 209, 56, 82, 5, 15, 149, 209, 143, 109, 187, 146, 143, 83, 232, 38, 57, 235, 26, 22, 68, 227, 15, 202, 60, 91, 190, 185, 60, 108, 191, 59, 59, 23, 196, 155, 33, 223, 41, 128, 246, 37, 222, 213, 10, 124, 114, 133, 242, 164, 38, 222, 111, 182, 212, 221, 231, 201, 185, 91, 154, 117, 170, 95, 120, 1, 44, 40, 40, 103, 74, 23, 26, 59, 191, 252, 36, 101, 145, 14, 194, 180, 153, 1, 235, 117, 33, 83, 157, 233, 241, 224, 17, 74, 56, 237, 242, 26, 21, 93, 13, 218, 221, 52, 26, 142, 68, 54, 101, 63, 25, 53, 249, 69, 237, 59, 86, 76, 123, 248, 154, 113, 168, 71, 134, 54, 33, 211, 11, 72, 91, 210, 50, 162, 23, 11, 191, 171, 226, 27, 65, 14, 179, 66, 45, 157, 246, 203, 155, 156, 156, 252, 226, 39, 152, 40, 204, 131, 215, 141, 4, 235, 30, 72, 237, 125, 96, 149, 2, 188, 171, 119, 20, 244, 25, 123, 244, 105, 199, 39, 247, 37, 96, 210, 42, 191, 146, 50, 226, 41, 11, 116, 48, 48, 30, 54, 122, 103, 122, 160, 135, 234, 117, 27, 82, 114, 228, 172, 174, 69, 188, 117, 253, 138, 252, 71, 13, 172, 47, 27, 114, 17, 81, 33, 20, 240, 148}, bitvalue = '{1, 2, 0, 1}

exit

End time: 13:00:12 on Sep 05,2020, Elapsed time: 0:00:01

Errors: 0, Warnings: 1

simulator:
mentor questa 2020.1

In reply to n347:
You use randc for generating unique values between successive calls to randomize(). There are 28=256 possible solutions for bit_value, and there are 22048=way too many possible solutions for randc_value.

I think what you want us a unique constraint between each element of the array

class C;
  rand bit[7:0] rand_value [256];
  rand bit[1:0] bit_value [4];

  constraint u { unique {rand_value}; unique {bit_value}; }
endclass