VLSI DV Interview Puzzles · All levels
Bidirectional Solving of x+y==10
For this class, what is P(x==0)? Why is the solver not 'choosing x first, then computing y' procedurally?
Puzzle
Difficulty: Easy · Puzzle 2 of 6 · Topic: Constraint Solving Order Puzzles
For this class, what is P(x==0)? Why is the solver not 'choosing x first, then computing y' procedurally?
Code
systemverilog
class sum_pair;
rand int unsigned x;
rand int unsigned y;
constraint c_dom {
x inside {[0:10]};
y inside {[0:10]};
}
constraint c_eq { x + y == 10; }
endclassHint
Each x value determines exactly one y value in the domain.
Step-by-step solution
diagram
1) For each x in 0..10, y is fixed to 10-x and remains in 0..10.
2) That gives exactly 11 legal tuples.
3) Exactly one tuple has x==0, so P(x==0)=1/11.
4) The equality is bidirectional relation solving, not assignment sequencing.Answer
Answer: P(x==0)=1/11 (~9.09%), and x/y are solved as a joint relation rather than left-to-right execution.
Why candidates get it wrong
Interviewees often say 'y depends on x only'; in constraints, either variable can be decided first by the solver.
Interviewer follow-up
What is P(x is even), and does adding solve x before y change the legal set?