Consider this example below. If “a” is 1, then b MUST be 3.
Does the meaning of “bidirectional constraints” also mean that if b is randomized to 3, then “a” MUST take the value of 1?
class ABC;
rand bit a;
rand bit [1:0] b;
constraint c_ab { a -> b == 3'h3; }
endclass
module tb;
initial begin
ABC abc = new;
for (int i = 0; i < 8; i++) begin
abc.randomize();
$display ("a=%0d b=%0d", abc.a, abc.b);
end
end
endmodule
Thanks.
In reply to UVM_learner6:
Please use code tags making it easier to read your code. I have added them for you.
No. The LRM is using a poor choice of words. It really the constraint is treated like a single boolean equation event if the expression appears to have an ordering. You constraint gets evaluated as
{!a || b == 3’b3}.
In reply to dave_59:
Thank you for adding the code tag, will do so in the future.
So if a =0, b can be 0, 1, 2, 3.
One add-on question - My understanding is that if I add “solve a before b”, I won’t change the solution space. Is that correct?
Thanks