VLSI DV Interview Puzzles · All levels
Implication vs Partitioned Branches
Compare req_a vs req_b. Assuming unbiased tuple selection from legal solutions, compute P(kind==1) in each class and explain why they differ.
Puzzle
Difficulty: Medium · Puzzle 1 of 6 · Topic: Constraint Solving Order Puzzles
Compare req_a vs req_b. Assuming unbiased tuple selection from legal solutions, compute P(kind==1) in each class and explain why they differ.
Code
class req_a;
rand bit [1:0] kind; // 0:READ, 1:WRITE
rand bit [3:0] burst;
constraint c_kind { kind inside {0,1}; }
constraint c_legal { burst inside {[1:8]}; }
constraint c_link { (kind == 1) -> (burst inside {[1:3]}); }
endclass
class req_b;
rand bit [1:0] kind;
rand bit [3:0] burst;
constraint c_kind { kind inside {0,1}; }
constraint c_legal { burst inside {[1:8]}; }
constraint c_link {
if (kind == 1) burst inside {[1:3]};
else burst inside {[4:8]};
}
endclassHint
Count satisfying (kind,burst) tuples per class before discussing solver heuristics.
Step-by-step solution
1) req_a legal tuples: kind=0 allows burst 1..8 (8 tuples), kind=1 allows 1..3 (3 tuples), total=11.
2) req_b legal tuples: kind=1 allows 3 tuples, kind=0 allows 5 tuples (4..8), total=8.
3) Tuple-weighted probabilities are P_a(kind=1)=3/11 and P_b(kind=1)=3/8.
4) Both snippets are declarative; the difference comes from legal-space partitioning, not runtime execution order.Answer
Answer: P(kind==1) is 3/11 (~27.27%) for req_a and 3/8 (37.5%) for req_b under tuple counting.
Why candidates get it wrong
Many candidates claim implication is evaluated later in time; it is solved simultaneously with all constraints.
Interviewer follow-up
How would you modify req_b so kind is exactly 50/50 without changing legal burst values?