In reply to deepthig:
I didn’t get the expected output after using the above approach.What is wrong in my code
class a;
rand bit [3:0]a[15];
constraint uniq_c {
foreach(a[i]) {
foreach(a[j]) {
if(j != i){
a[j] !=a[i];
}
}
}
}
function void post_randomize();
a.shuffle();
endfunction
endclass
module test;
a a_i;
int temp,i=0;
initial begin
a_i = new();
foreach(a_i.a[i])begin
a_i.randomize();
temp=a_i.a[i];
$display("array value[%d] =%d",i,temp);
end
#100;
end
endmodule
output:
array value[ 0] = 3
array value[ 1] = 5
array value[ 2] = 3
array value[ 3] = 6
array value[ 4] = 5
array value[ 5] = 4
array value[ 6] = 10
array value[ 7] = 8
array value[ 8] = 4
array value[ 9] = 14
array value[ 10] = 1
array value[ 11] = 7
array value[ 12] = 11
array value[ 13] = 15
array value[ 14] = 13