In reply to Huzefa Halolwala:
You can even try this out.
module top;
class base;
rand bit[7:0] a[];
constraint a_cn
{
a.size == 10;
foreach(a[i])
{
a[i] == (i+1) ** 2;
}
}
function void post_randomize();
a.shuffle();
endfunction
endclass
initial begin
base b;
b = new();
b.randomize();
foreach(b.a[i])
$display("%0d",b.a[i]);
end
endmodule