In reply to pkumar16:
Minor change:
class dyn_array;
rand int abc;
constraint abc_descending_c{
abc.size() == 5;
foreach(abc[i]) begin
if(i!=abc.size()-1)// to make sure abc[5] doesnt get accessed
abc[i] > abc[i+1];
end
}
endclass
I also tried this code :
class dyn_arr;
rand int abc[];
constraint abc_c {
abc.size()==5;
}
function post_randomize();
abc=abc.rsort();
endfunction
endclass
but I am getting this error : $unit, “abc.rsort”
The call to predefined void function is not allowed in this context.
Cannot use a void function call where an expression is required
not sure why ?