I need help in constraint with the following problem .
- each array entry should be greater than previous number .
- max value should be less than 200.
- The 3rd entry should be 50 .
I don’t know how to constraint the 3rd entry to be 50 .
Thanks in advance for your help .
In reply to dave_59:
Thank you Dave . I understand I can do that in post_randomize as you want suggest .
I was thinking is there a way without using post_randomize , can we put something in the constraint ?
dave_59
4
In reply to mehul_1111:
That was a constraint, not an assignment.
class abc ;
rand int unsigned array[];
int third_value = 50 ;
constraint c2 {
array.size ==5;
foreach (array[i])
if(i>0) {array[i]>array[i-1];
array[i] <200;}
array[2] == third_value;
}
endclass
module top;
abc ab = new() ;
initial
repeat (5) begin
assert(ab.randomize());
$display(" array= %0p",ab.array);
end
endmodule