Hello,
“solve A before B” means, using the existing constrains get a random value for A and then get a random value for B. - I hope that I am correct on this one.
However, what if there is one more variable C? Is it solved with A or is it solved with B?
My understanding is that the simulator creates a table of all possible combinations of A,B,C, e.t.c. and after that chooses one line from the table.
If “A is solved before B” then:
- column of variable B is removed from the table and the simulator picks a line
- A is determined → a new table is constructed with all possible values for B
I am not sure though if variable C is present in the table from item 1 or the table contains just variable A.
Thanks,
Alex
In reply to Alex K.:
Wanted to rephrase the question:
bit A;
bit[1:0] B, C, D;
constraint my_cnstr_1 {
(A == 1) → (B == 3); }
constraint my_cnstr_2 {
(A == 0) → (D == 0);}
constraint my_cnstr_3 {
(D == 1) → (C == 0); }
solve A before B;
solve A before C;
A is randomized first.
After that based on the result of A, the values for B and C are chosen randomly.
But how about D? Is it randomized with B and C? Or with A?
my_cnstr_2 and my_cnstr_3 will have a different meaning based on when D is randomized.
Is it up to the simulator?
Thanks,
Alex
In reply to Alex K.:
It always helps to provide an example. As soon as you add a constraint connecting two variables.
The LRM says “Variables that are not explicitly ordered shall be solved with the last set of ordered variables”. So a value gets picked for A, then B,C, and D are picked together.
Note that solve before has no affect on the solution, just the distribution of values picked. Please see constrain random variable result to enumerated type | Verification Academy
In reply to dave_59:
Thank you, Dave.
Does the above mean that the randomization is done in 2 stages?
- Split all the variables into groups, when in every group the variables are randomized together (defined by “solved before”).
- The groups are randomized sequentially. For every group the randomization is done simultaneously.
Thanks,
Alex