class subhra;
rand bit[3:0] a;
int q[$];
constraint b{a<15;}
endclass
module test;
subhra su =new();
initial begin
while (su.q.size<16) begin
for(int i=0;i<16;i++) begin
su.randomize();
su.q.push_back(su.a);
su.q=su.q.unique();
end
end
su.q.shuffle;
$display("q:%p",su.q);
end
endmodule
In reply to Subhra Bera:
Because there are only 15 integer values less than 15, and your q needs to have 16 or more values to get out of the while loop.