Debugging a Failing Assertion
Find the attempt behind a failure and print what it saw. Split a long rule to find the broken step, and tell real failures from false ones.
You Will Be Able To
- Name the attempt and the edge behind a reported failure.
- Print sampled values in an action block.
- Split a long sequence into anchored pieces to find the broken step.
- Recognise vacuous passes, reset failures and blocking action blocks.
- Lesson
- A10.2
- Time
- 30 min
- Runs on
- Verilator
- Check
- 5 questions
The log says "late fails at 45". The engineer opens the waveform at 45 and sees nothing wrong there. The bug happened 30 ns earlier: the failure time is where an attempt ended, not where it began.
- Step
- Control
- Locate
Walk back from the failure time to the edge where the attempt started.
- Observe
Print the values the assertion used, not the values after the edge.
- Narrow
A long sequence hides which step broke; pieces name it.
- Question the rule
Before blaming the design, rule out a vacuous rule, a reset and the wrong clock.
Read the diagram as text
- Which attempt?: failure time minus the delays
- What did it see?: $sampled values
- Which step broke?: split the sequence
- Is the failure real?: vacuity, reset, clock
- Which attempt? → What did it see?: then
- What did it see? → Which step broke?: then
- Which step broke? → Is the failure real?: then
SVA-FC 2.15-2.16, 17.9, 17.11.
Which Attempt, Which Edge
A failure is reported at the edge where its attempt fails. For req |-> ##3 ack, that is three edges after the attempt began.
$sampled in the Action Block
The action block runs after the edge. By the standard, a signal read there directly can already hold its new value. $sampled returns the value the assertion used.
Standard (IEEE 1800-2023 16.14.1, 4.4)
// the same program, printing cnt directly too
t=35 cnt=4 sampled=3
The action block runs in the Reactive region, after the edge has updated cnt.
Verilator 5.052 (measured)
// the same program, printing cnt directly too
t=35 cnt=3 sampled=3
Its action block runs before the update, so the direct read shows the old value. Only $sampled is portable.
Splitting into Subsequences
A long rule fails as one piece. Split it into pieces, each anchored on the steps before it, and the failing piece names the broken step.
Each piece keeps the steps before it as its antecedent. A piece without them, such as data_v |=> resp, fires on unrelated traffic.
Vacuity: A Rule That Never Triggers
A rule whose antecedent never matches passes at every edge, vacuously. Zero failures then mean nothing. A cover of the antecedent shows whether it ever matched.
False Failures from Reset and Clocks
An attempt that crosses a reset fails because the design was cleared, not because it broke. disable iff (rst) cancels such attempts. The wrong clock, or a gated one, gives false failures too (A1.6).
Blocking Action Blocks
An action block that waits, with a delay or an event control, is still running when the next failure comes. Verilator 5.052 drops that failure's action; the standard does not say what must happen, so other tools may queue it.
Try It
The whole rule only says that something in the chain broke. The anchored pieces say which link: the step from data_v to resp.
Remove the line that raises grant and predict the four counts.
whole=1 p1=0 p2=0 p3=1Check Yourself
Common Mistakes
Wrong Look for the bug at the time the failure was reported.
For a rule with delays, the cause is at the start of the attempt.
Fix Subtract the delays to find the attempt, and start there.
Wrong Split a long rule into pieces that drop the steps before them.
An unanchored piece fires on unrelated traffic and reports false failures.
Fix Keep the earlier steps in each piece's antecedent.
data_v |=> respreq ##1 grant ##2 data_v |=> respWrong Wait in an action block.
Failures that come while it waits may lose their action.
Fix Record and return at once; do slow work in a separate process.
Remember
- A failure is reported where its attempt ends; the cause is where the attempt began.
- Print
$sampledvalues in action blocks. - Anchored pieces of a long rule name the broken step.
- Check vacuity with a cover, guard resets with
disable iff, and keep action blocks non-blocking.