In reply to Nitin Jalibenchi:
class test;
rand int q1[$];
constraint c1 {
q1.size() > 5 && q1.size < 10;
}
constraint c2 {
foreach(q1[i]) {
q1[i] > 20 && q1[i] < 30;
}
}
function void print();
$display(q1);
endfunction
endclass
module abc;
test t1 = new();
initial begin
t1.randomize();
t1.print();
end
endmodule
I am using the same queue (q1) to demonstrate the constraint on size & each element. Hope this helps.