← Design Verification Interviews
Interview Question · Concept
Why Writes Became Rare
- Asked at Google
The Question
The interviewer asks
With this class, about how many of 900 bursts are writes? Why? How would you get roughly half?
class burst;
rand bit is_write;
rand bit [2:0] beats;
constraint c { is_write -> beats == 0; } // writes are single-beat
endclassYou have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
About 100, one in nine. The solver picks uniformly among all legal combinations. A read pairs with any of eight beats values, but a write pairs only with 0. So 1 of the 9 legal pairs is a write. solve is_write before beats chooses is_write first with equal odds and gives about half, without changing which pairs are legal.
is_write and beats, with no order and with is_write first. Arrows show the choice moving from one stage to the next.- Count the pairs
The rules allow nine pairs: one write with 1 beat, and eight reads with 1 to 8 beats. Writes own one pair and reads own eight.
- No order
With no order, the solver picks one of the nine pairs, each with the same chance. A write comes up once in nine picks.
Follow the calls, values and waits
- data 9 pairs: Nine legal pairs → No order
- data write, 1 in 9: No order → Writes: 1 in 9
- Choose is_write first
solve is_write before beatspicksis_writefirst, 1 or 0 with equal chance, as ifbeatsdid not exist yet. Both values have at least one legal partner.Follow the calls, values and waits
- data 9 pairs: Nine legal pairs → is_write first
- data is_write = 1, 1 in 2: is_write first → Then beats
- Then beats
A write leaves only 1 beat, so writes are half of the traffic. Each read length gets 1/2 × 1/8 = 1/16, and the legal pairs are still the same nine.
Follow the calls, values and waits
- data beats = 1: Then beats → Writes: 1 in 2
Read the diagram as text
- Nine legal pairs: a write with 1 beat; reads with 1 to 8 beats
- No order: every pair equally likely
- Writes: 1 in 9: about 11% of bursts
- is_write first: solve is_write before beats
- Then beats: among the values that fit
- Writes: 1 in 2: about 50% of bursts
- Nine legal pairs → No order
- No order → Writes: 1 in 9: one pair
- Nine legal pairs → is_write first
- is_write first → Then beats: is_write
- Then beats → Writes: 1 in 2: beats
An order changes probabilities only. It never makes a failing call succeed.
Self-Check
Tick each key point you covered in your answer.
What Interviewers Listen For (Junior)
A good junior answer counts the legal pairs out loud, eight reads and one write, before giving the ratio.
What Interviewers Listen For (Mid-Level)
A good mid-level answer offers solve...before or a dist on is_write. It says each one changes the odds but never the set of legal values.
What Interviewers Listen For (Senior)
A good senior answer makes the distribution a test-plan item, with coverage per transaction kind read in the first regression. Bias never makes a checker fail, so only coverage shows it.
Cross-Questions
Where the interviewer goes next. Open a node to practise that follow-up.
WhyWhat IfProve ItBreak ItCompare
- Why Writes Became Rare
-
WhyWhy the Solver Weights Solutions, Not FieldsL1 JuniorL2 Mid-Level
Why does the standard define the distribution over whole solutions rather than giving each random field its own fair odds?
2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Constraints tie fields together, so there is no single "fair" order in which to pick them. Making every legal combination equally likely gives one clear answer. It does not depend on how the constraints are written or how the solver works inside. The price is that a constraint touching one field can skew another, and
solve...beforeanddistexist to correct that.One Write in Nine Bursts All cycles- Cycle 3
The only write so far. Reads have eight legal lengths and writes have one, so a write wins about one pick in nine.
- Cycle 8
Nine bursts, one write. Every burst is legal and the constraints are correct: the mix comes from counting combinations.
One column per generated burst. Every burst is legal; the mix is the problem.
Self-Check
Tick each key point you covered in your answer.
Misconception
"The solver picks fields in declaration order."
Declaration order has no effect on the distribution; only
solve...beforeimposes an order.Source IEEE 1800-2017 §18.5.10
- Cycle 3
-
CompareDist Weights: Colon-Equals vs Colon-SlashL1 JuniorL2 Mid-Level
Compare
x dist {0 := 1, [1:3] := 1}withx dist {0 := 1, [1:3] :/ 1}. How often isxzero in each?2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
:=gives every value in the range the full weight, so 1, 2 and 3 weigh 1 each and 0 comes up about 1 time in 4.:/splits the weight across the range, so 1, 2 and 3 share a weight of 1 and 0 comes up about half the time. Adistonis_writeis another way to correct the bias, because it sets that field's odds directly.RUNVerilator · simulator serviceExpected::= gives 0 about 1 time in 4:/ gives 0 about 1 time in 2Self-Check
Tick each key point you covered in your answer.
Misconception
"
:=and:/are the same for a range."They differ exactly for ranges: one weight per value against one weight per range. The run shows a quarter against a half.
Source IEEE 1800-2017 §18.5.4
-
Break ItA Dist That Lists a Forbidden ValueL2 Mid-Level
What if a
distlists a value that another constraint forbids, sayx dist {0 := 5, [1:3] := 1}together withx != 0?2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
By the standard the forbidden value simply drops out, and the weights apply among the legal values. Verilator 5.052 instead fails some of those calls, so the bug shows up as randomization failures on one tool only. Keep every value in a
distlegal under the other constraints, or move the weighting into a separate field.Self-Check
Tick each key point you covered in your answer.
Tool as Truth
"Our simulator fails the call, so the constraint set is illegal."
The standard says the weighted value is just unavailable. The failures are Verilator 5.052 behaviour, measured in lesson 5.2.
Source Lesson 5.2 simulator note (12 of 20 calls failed on Verilator 5.052)
-
What IfWhat Solve Before Cannot DoL2 Mid-Level
Asked if they suggest solve...before
What are the limits of
solve...before?2:30You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
It changes only probabilities: the legal set, and therefore any conflict, is unchanged. The variables it orders must be
rand;randcvariables are not allowed, since they are already solved first. And the result is only as good as your tool. So you still measure the bias with coverage.Self-Check
Tick each key point you covered in your answer.
Spec Misquote
"Put a
randcfield insolve...beforeto make it go first."The standard does not allow
randcvariables there; they are solved before other random variables anyway.Source IEEE 1800-2017 §18.5.10
-
Prove ItSolve 5.3.2: Balance Mode FrequencySimulator-graded
Show it, don't just say it: this Silicon Lab problem is graded by the simulator.
What People Get Wrong
Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.
Misconception
"is_write is a fair coin; the implication only filters the bad pairs."
Filtering keeps 9 pairs, and the solver weights pairs, not fields. The twin counts writes far below half; choosing is_write first restores it.
Run It
900 calls on the class above, counting writes.
FAIL: only about 1 in 9 calls is a write, because 1 of the 9 legal pairs is a writeSee the Fix
class burst;
rand bit is_write;
rand bit [2:0] beats;
constraint c { is_write -> beats == 0; }
endclass
module tb;
burst t = new;
int writes = 0;
initial begin
repeat (900) begin
bit w;
void'(std::randomize(w)); // the fix: choose the kind first, 50/50
void'(t.randomize() with { is_write == w; });
writes += t.is_write;
end
$display("writes in 900 calls: %0d", writes);
if (writes > 350 && writes < 550) $display("PASS: choosing is_write first gives about half writes");
end
endmodule
Prints: PASS: choosing is_write first gives about half writes
Tool as Truth
"I added solve is_write before beats and still saw one write in nine, so it does nothing."
The standard defines its effect. Verilator 5.052 does not implement those probabilities, so a measurement there says nothing about the language.
Source Lesson 5.3 simulator note (Verilator 5.052 does not give solve...before its probabilities)
Misconception
"solve...before can make an unsolvable set of constraints solvable."
It only reorders the choice. The legal set is unchanged, so a conflict stays a conflict.
Source IEEE 1800-2017 §18.5.10
Delivery
Jumps to "add solve-before" without working out why the ratio is skewed.
The interviewer wants the counting argument first; the fix only makes sense once the 1-in-9 is explained.