← Design Verification Interviews

Interview Question · Concept

Full Code Coverage and a Bug Escape

L0 FresherL1 JuniorL2 Mid-Levelfunctional coveragecode coveragemethodology

The Question

The interviewer asks

Your block reached 100% code coverage, yet a bug escaped to silicon. How is that possible, and what does functional coverage add?

Reveal the Model Answer

Code coverage measures which lines, branches and toggles of the RTL ran. It cannot see a check that was never written, or conditions that never happened together. Functional coverage measures the cases in the spec and the plan, such as "push while full". A missing feature then shows up as an empty bin. You need both: code coverage finds RTL nobody exercised, and functional coverage finds intent nobody tested.

Two Reports, Two QuestionsThe level counter from the run. Arrows show what each report is built from.
Two Reports, Two QuestionsThe level counter from the run. Arrows show what each report is built from. component Spec A push into a fullcounter is ignored component RTL Reset, increment anddecrement lines; nofull check component Coverage plan Row: push while full component Code coverage Every line ran atleast once component Bin push_full 0 hits, so a test ismissing component The missing check No line exists, sonothing is counted listed incoded aslines countedcannot see
Read the diagram as text
  • Spec: A push into a full counter is ignored
  • RTL: Reset, increment and decrement lines; no full check
  • Coverage plan: Row: push while full
  • Code coverage: Every line ran at least once
  • Bin push_full: 0 hits, so a test is missing
  • The missing check: No line exists, so nothing is counted
  • Spec → Coverage plan: listed in
  • Coverage plan → Bin push_full: coded as
  • RTL → Code coverage: lines counted
  • Code coverage → The missing check: cannot see

In the run every line ran, yet the push-while-full bin has 0 hits. Code coverage counts the RTL that exists; functional coverage counts the cases in the spec.

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Fresher)

A good fresher answer says code coverage can only count lines that exist in the RTL. It gives one example, such as a full check that nobody wrote.

Cross-Questions

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

WhyWhat IfProve ItCompareScale It

  1. Full Code Coverage and a Bug Escape
  2. WhyWhy Code Coverage Cannot See Missing LogicL0 FresherL1 Junior

    Why can't code coverage find a feature that was never implemented?

    Reveal the Model Answer

    A code coverage tool adds counters to the lines and branches that exist in the RTL. A check that was never written has no line, so there is nothing to count. The report can only ever say "this code ran" or "this code did not run". Functional coverage starts from the spec, so it can list cases the code does not handle.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "Branch coverage finds it, because the missing if leaves a branch untaken."

    A branch that was never written has no counter. Branch coverage measures the branches the RTL has.

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

  3. CompareLine, Branch, Toggle, Expression and FSM CoverageL1 Junior

    Compare line, branch, expression, toggle and FSM coverage. Which one would have caught the missing full check?

    Reveal the Model Answer

    Line coverage counts executed statements, and branch coverage counts each way through an if or case. Expression coverage checks that each term of a condition changed the result. Toggle coverage checks each bit went to 0 and 1, and FSM coverage counts states and arcs. None of them catches the missing check, because the condition count == 4 does not exist in the code.

    KindWhat it countsSees the missing full check?
    LineStatements that executedNo
    BranchEach way through an if or caseNo
    ExpressionEach term of a condition changing the resultNo
    ToggleEach bit going to 0 and to 1No
    FSMStates and arcs of a state machineNo

    The condition count == 4 is not in the code, so no kind of code coverage has anything to count.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "Expression coverage would flag the missing count == 4 term."

    Expression coverage measures the terms that are written. A term that is absent from the condition is invisible to it.

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

  4. Prove ItThe Bin That Would Have Caught ItL1 Junior

    Prove it: write the functional coverage that would have exposed the missing full check.

    Reveal the Model Answer

    Cover the operation crossed with the fill state, sampled only outside reset. For example, push_full: coverpoint (push && count == 4) iff (!rst) { bins seen = {1}; }. A fuller model crosses push and pop with empty, partial and full. The empty bin forces someone to write the test, and that test finds the overflow.

    Self-Check

    Tick each key point you covered in your answer.

    Missed Corner

    "Cover the count value from 0 to 4; that includes full."

    The count does reach 4. The missing case is a push while it is 4, which is an operation crossed with a state.

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

  5. What IfCode Holes in an Error-Recovery BranchL2 Mid-Level

    Asked if they ask about the remaining code holes

    Code coverage is 97%. The holes are in an error-recovery branch. What do you do with them?

    Reveal the Model Answer

    Find out first whether the branch can be reached. If it can, the plan missed a feature: add it to the plan and write the test, often with error injection. If it cannot, because of a tie-off or a parameter, mark it unreachable with a reason the designer agrees to. Never waive a hole just because it is hard to hit.

    Self-Check

    Tick each key point you covered in your answer.

    Wrong Altitude

    "Error paths are rare in silicon, so waive them."

    Recovery logic runs exactly when something has already gone wrong. A bug there turns a recoverable error into a hang.

    Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.2.1 (PDF p363)

  6. Scale ItClearing Hundreds of Code HolesL3 Senior

    At sign-off, hundreds of code coverage holes remain across a subsystem. How do you clear them without writing hundreds of tests?

    Reveal the Model Answer

    Run a formal unreachability check on the holes first. It proves many of them dead, such as logic behind tied-off inputs or unused parameter values. Those can be excluded, with the proof as the reason. Review the rest with the designers, grouped by feature. Each group becomes a test, a plan update or a reviewed waiver.

    Self-Check

    Tick each key point you covered in your answer.

    What Interviewers Listen For (Senior)

    A good senior answer first uses a formal tool to shrink the list of holes. It then reviews the rest with the designers, feature by feature, and gives each waiver an owner.

    Half-Truth

    "Formal says the hole is unreachable, so the design is fine there."

    Unreachable under the formal setup only. Wrong assumptions or tie-offs can make reachable logic look dead, so review the constraints too.

    Source Seligman, Schubert, Kiran Kumar, Formal Verification (2nd ed.), ch. 9, vacuity and wrong assumptions (PDF p310)

  7. Prove ItSolve 7.5.8: Two Coverpoints for the FIFOSimulator-graded

    Show it, don't just say it: this Silicon Lab problem is graded by the simulator.

    Open Problem 7.5.8

What People Get Wrong

Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.

Misconception

"Every line ran, so the design is verified."

The twin runs every line of a counter whose full check was never written. Functional coverage of push-while-full is 0%, and a fifth push overflows.

Run It

A counter with a missing full check. Line hits are counted by hand, as a line-coverage report would.

RUNVerilator (coverage build) · simulator service
Edit the code, then run it
Expected: line hits: reset=1 increment=4 decrement=4 (every line ran) functional coverage, push while full: 0.00 after a fifth push: count=5 (the spec says 4) FAIL: every line ran, but no test pushed into a full counter, where the missing check lives

Half-Truth

"Functional coverage is the better metric, so skip code coverage."

Code coverage finds RTL the plan forgot, such as an untested mode or a dead branch. Each metric sees holes the other cannot.

Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.2.1 (PDF p363)

Misconception

"100% toggle coverage means every value of the bus was seen."

Toggle coverage only checks that each bit went to 0 and to 1. It says nothing about which combinations of bits appeared.

Source Spear & Tumbush, SystemVerilog for Verification (3rd ed.), §9.2.1 (PDF p363)

Learn It, Then Prove It