In reply to sk7799:
You have a misunderstanding about how the dist works in constraint c5. See the reply to a recent question.
You should create a separate random mode variable so that the ordering is consistent across the array
class abc;
rand int q[$];
rand enum {unordered_,ascending_,descending} ordering;
constraint c1 {foreach(q[i]) q[i] inside {[0:31]};}
constraint c2 {q.size dist {1:=10, 31:=10, [2:30]:/80};} // use :/ with a range
constraint c3 {unique {q};}
constraint c5 {
ordering dist {[ascending_:descending]:/30, unordered_:=70};
ordering == ascending_ -> foreach(q[i]) i>0 -> q[i-1] < q[i];
ordering == descending -> foreach(q[i]) i>0 -> q[i-1] > q[i];
}
endclass
module exp;
abc a = new;
initial begin
repeat (50) begin
assert(a.randomize());
$display ("%s ### %p ###", a.ordering.name, a.q);
end
end
endmodule