← Design Verification Interviews

Interview Question · Code Reading

What First Match Changes

L2 Mid-LevelL3 Seniorsvasequencesoperators

The Question

The interviewer asks

The spec says done follows the first ack after a request by exactly one cycle, and ack may pulse more than once. Compare these two properties on a trace with ack at +1 and +2 and done at +3.

systemverilog
a_plain: assert property (@(posedge clk) req |-> ##[1:3] ack ##1 done);
a_first: assert property (@(posedge clk) req |-> first_match(##[1:3] ack) ##1 done);
Reveal the Model Answer

a_plain passes: its thread through the second ack at +2 finds done at +3, and one matching thread is enough. a_first fails. first_match keeps only the earliest end point of the range, the ack at +1, so done must come at +2, and it does not. Use first_match when only the earliest occurrence may count, which is what "the first ack" means.

ack twice, done after the second
0123edgereq+1+2+3reqackdonea_first needs done here: faila_plain matches via the ack at +2

Without first_match, any thread can satisfy the rest of the sequence.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Mid-Level)

A good mid-level answer follows both threads of the plain property. It explains why the later thread rescues the attempt.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

WhyWhat IfBreak ItCompare

  1. What First Match Changes
  2. CompareFirst Match vs Two Assertions Keyed on the EventL2 Mid-Level

    Compare req |-> first_match(##[1:3] ack) ##1 done with the pair req |-> ##[1:3] ack and ack |=> done.

    Reveal the Model Answer

    The pair is close but not the same. ack |=> done demands done after every ack, including the second pulse. The first_match form only cares about the first one. If every ack really owes a done, the pair is simpler, easier to debug and runs on every simulator. If later pulses must not owe one, you need the first_match form or a small model that marks the first ack.

    first_match formack |=> done pair
    Which acks owe a doneOnly the first oneEvery one
    DebugOne property to readEach half reports on its own
    Runs on every simulatorNoYes

    Self-Check

    Tick each key point you covered in your answer.

    Half-Truth

    "The two forms are always equivalent."

    They differ when ack can pulse more than once per request, which is exactly the case first_match was used for.

    Source IEEE 1800-2017 §16.9.8

  3. WhyWhy First Match Matters in an AntecedentL3 Senior

    Why does first_match matter even more in an antecedent, as in first_match(req ##[1:3] gnt) |=> busy?

    Reveal the Model Answer

    Each end point of the antecedent starts its own check of the consequent. Without first_match, two grants inside the window start two obligations for one request, so busy is demanded after each. first_match keeps one end point per start and one obligation per request.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "A ranged antecedent starts one check per attempt."

    It starts one check per end point of the antecedent match, which can be several per attempt.

    Source IEEE 1800-2017 §16.12.7

  4. Break ItFirst Match That Turns a Pass into a FailureL3 Senior

    Break it: show a consequent where adding first_match turns a pass into a failure.

    Reveal the Model Answer

    Take req |-> ##[1:3] gnt ##1 busy. Without first_match, the attempt passes if any grant in the window is followed by busy. With first_match(##[1:3] gnt) ##1 busy, only the first grant counts. If busy follows the second grant but not the first, the first form passes and the second fails.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "first_match only matters for performance."

    It changes which end points exist. In a consequent, fewer end points can turn a pass into a failure.

    Source IEEE 1800-2017 §16.9.8

  5. What IfWhy One Match Ends the AttemptL1 Junior

    Asked if they ask about ranges at the end of a consequent

    Why does the implication stop at the first match of busy[*2:4] instead of checking the longest one?

    Reveal the Model Answer

    A property built from a sequence asks whether the sequence can match. The implication succeeds as soon as one consequent match exists. Longer matches add nothing to that answer. Anything that must happen after the match has to be written as more sequence or as a separate rule.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "The simulator picks the longest match, like a greedy regular expression."

    There is no greedy choice; the property holds if any match exists, and the earliest one already proves it.

    Source Mehta, SystemVerilog Assertions and Functional Coverage (3rd ed.), §8.8 (PDF p142)

  6. Break ItA First Match Rule That Never FailsL2 Mid-Level

    Your first_match rule has passed every regression for months. How do you find out whether it can fail at all?

    log
    a_first: 0 failures in 2,431 tests
    (no directed test violates the first-ack rule)
    Reveal the Model Answer

    Write a small directed test whose traffic must break the rule: here, an ack at +1 with done only at +3. Check that the assertion reports exactly that failure. If it does not, the tool is not evaluating the construct and the months of passes are worthless. This negative control belongs next to every non-trivial property.

    Self-Check

    Tick each key point you covered in your answer.

    Wrong Altitude

    "Mutating the design is the only way to test an assertion."

    A directed must-fail stimulus is often enough, much cheaper, and exactly targets the construct in doubt.

What People Get Wrong

Common wrong answers and why they fail.

Misconception

"Without first_match, a range always uses the first occurrence."

Every delay in the range starts a thread. Any thread that completes the sequence makes the attempt pass, so a later ack can rescue it.

Source Mehta, SystemVerilog Assertions and Functional Coverage (3rd ed.), §8.28 (PDF p181)

Tool as Truth

"first_match passed in our simulator, so the design meets the first-ack rule."

Verilator 5.052 reports no failure for first_match over a range followed by more sequence. A newer build rejects it. So that pass proves nothing.

Source ASIC Point engine notes (Verilator 5.052 SVA probes), row "first_match"

Wrong Altitude

Puts first_match around every range "to be safe".

On a range at the end of a consequent it changes nothing, because the attempt already passes at the first match. It only adds tool risk.

Learn It, Then Prove It