SVA Mistakes That Prove Nothing
Spot six SVA mistakes that let a proof pass on a buggy design, and write the form that fails honestly.
You Will Be Able To
- Explain why a false pass costs more than a false failure.
- Find a check that is missing, mistimed or unable to fail in a property file.
- Fix a moving index and a variable delay with a generate family.
- Choose an implication, not a bare sequence, for an assumption.
- Lesson
- F10.1
- Time
- 22 min
- Runs on
- SymbiYosys
- Check
- 5 questions
A bus arbiter gave each transfer two cycles. A late change let retry move the owner in the middle of a transfer. The property mid |-> $stable(gnt[owner]) stayed green for the whole project. It compared the new owner's line with the old owner's line, and both were 1.
Measured with smtbmc yices at depth 20. At step 3 the grant is on line 1; one step earlier it was on line 0. The moving-index check compares those two lines and sees 1 and 1.
A Proof That Lies
- Result
- Step
- Analysis
Read the diagram as text
- FAIL on a good design: false negative: a missing assumption
- PASS on a buggy design: false positive: the proof lies
- An hour of debug: you read the trace and fix the bench
- Silence: no trace, no log line, nothing to read
- A better bench: the tool pointed at the gap
- A bug in silicon: found later by simulation or the lab
- FAIL on a good design → An hour of debug
- An hour of debug → A better bench
- PASS on a buggy design → Silence
- Silence → A bug in silicon
A false negative shows itself. A false positive stays hidden, so you must hunt for it on purpose.
A false positive is a proof that passes while the bug is in the design. Nothing in the log marks it. The six mistakes below each produce one, and each is one line of SVA.
| Mistake | Wrong form, on the buggy design | Right form, on the buggy design | Measured on |
|---|---|---|---|
| 1. Missing semicolon | EBMC lists only the first assertion: PROVED up to bound 5. read_slang refuses the file | EBMC lists both; the second is REFUTED | EBMC 6.1; Yosys read_slang |
| 2. Both clock edges | BMC PASS to depth 20 | FAIL at reported step 14 | this site's engine |
| 3. Short-circuited function | check skipped: nothing reported | check ran: two owners reported | Verilator 5.052, Icarus 12 |
| 4. Moving index | PROVED up to bound 12; BMC PASS to depth 20 | REFUTED; FAIL at reported step 4 | EBMC 6.1; this site's engine |
| 5. Weak liveness | PROVED up to bound 12 | REFUTED | EBMC 6.1 |
| 6. Assumed sequence | BMC PASS to depth 20 | FAIL at reported step 5 | this site's engine |
Every design holds one planted bug. The site engine runs bmc at depth 20 with smtbmc yices. EBMC runs to bound 12, or bound 5 for the semicolon file.
The Missing Check
1. No semicolon after the first assertion
a_first: assert property (@(posedge clk) a || !a)
a_second: assert property (@(posedge clk) b)
else $error("b fell");
EBMC 6.1 lists one property, a_first: PROVED up to bound 5. b is never checked.
With the semicolon
a_first: assert property (@(posedge clk) a || !a);
a_second: assert property (@(posedge clk) b)
else $error("b fell");
EBMC 6.1 lists 2 properties. a_second is REFUTED: it fails as soon as b is 0.
An assertion ends at its semicolon. Without one, the next statement becomes the pass action of the first assertion. A pass action is code that runs when the assertion passes. Formal tools ignore action blocks, so the second check is gone. The standard forbids a concurrent assertion inside an action block (IEEE 1800-2023 §16.14.1), but not every tool enforces that.
Yosys read_slang refuses the file: cannot have 'assert' statement in the action block of another concurrent assertion. That refusal is the safe answer. Count the properties your tool lists and compare the count with your file.
3. The call sits behind ||
function automatic logic one_owner(input logic [1:0] g);
assert (g != 2'b11);
return g != 2'b00;
endfunction
always_comb ok = override || one_owner(gnt);
With override at 1: check skipped: nothing reported (Verilator 5.052 and Icarus 12).
The call comes first
always_comb ok = one_owner(gnt) || override;
// or keep the check out of the function:
always_comb assert (gnt != 2'b11);
With override at 1: check ran: two owners reported.
SystemVerilog short-circuits ||: when the left side is 1, the right side is not evaluated. The assertion lives inside the skipped call. Here override grants both lines, which is the bug, and it also switches the check off.
The Check on the Wrong Samples
2. An unedged clock
assert property (@(clk1)
$rose(req) |-> req[*6]);
@(clk1) samples on both edges. Six samples are three cycles. A five-cycle request: BMC PASS to depth 20.
One named edge
assert property (@(posedge clk1)
$rose(req) |-> req[*6]);
Six samples are six cycles. The same request: FAIL at reported step 14.
The rule says req stays high for six cycles. The buggy design holds it for five. The wrong form still catches a two-cycle request (FAIL at reported step 7), so it looks alive. A plain Boolean check has no count, so both edges do no harm there.
4. A signal as the index
assert property (
@(posedge clk) mid |->
$stable(gnt[owner]));
owner is sampled too. The check compares line owner now with line $past(owner) before. Buggy design: PROVED up to bound 12 (EBMC).
A family over constant indices
for (genvar i = 0; i < 4; i++) begin : line
assert property (@(posedge clk) mid && owner == i |-> $stable(gnt[i]));
end
Each line is compared with itself. Buggy design: REFUTED. Fixed design: PROVED up to bound 12.
$stable(x) compares the whole expression x at two samples. If the index moved, the two samples read two different bits. The generate loop makes the index a constant. Use the same loop for a delay that depends on a signal: a cycle delay must be a constant, and read_slang refuses ##d.
The Check That Cannot Fail
5. Weak: no finite trace can fail it
assert property (@(posedge clk)
req |-> ##[1:$] gnt);
Arbiter that never grants: PROVED up to bound 12 (EBMC 6.1).
Strong: an endless wait is a failure
assert property (@(posedge clk)
req |-> s_eventually gnt);
The same arbiter: REFUTED. Correct arbiter: PROVED up to bound 12.
A property is weak unless its operator is strong (A3.1 Weak and strong). A weak ##[1:$] only fails if some finite trace proves the grant can never come. No finite trace can prove that. On this site's engine, write the bound: req |-> ##[1:8] gnt gives FAIL at reported step 10 on the same bug.
6. A sequence, assumed
assume property (@(posedge clk) sop ##1 eop);
Forces sop on every cycle and eop on every cycle after the first. BMC PASS to depth 20; the cover of !sop is unreached.
An implication, assumed
assume property (@(posedge clk) sop |=> eop);
Constrains eop only after a real sop. FAIL at reported step 5; the cover is reached at step 2.
The bug drops the first packet after an idle cycle. The bare sequence removes every idle cycle, so the bug cannot show. This is over-constraint (F3.2), written by accident. A bare sequence is right in a cover, and almost never in an assume or an assert.
Three Symptoms to Hunt For
The six cards fall into three groups by what went wrong. A check never ran, read the wrong samples, or had no way to fail. Each group leaves its own mark in a report or a trace.
| Symptom | What our runs showed | Where to look | Card |
|---|---|---|---|
| The check never ran | EBMC listed 1 property for a file with 2 | Report count against file count | 1 |
| The check never ran | Both simulators printed nothing once override was 1 | An assert inside a function body | 3 |
| Wrong samples | A 5-cycle request passed a 6-cycle rule: BMC PASS to depth 20 | An @( with no edge, before ## or [* | 2 |
| Wrong samples | $stable(gnt[owner]) was PROVED up to bound 12 on the buggy arbiter | A signal inside [ ] of $stable or $past | 4 |
| No way to fail | An arbiter that never grants: PROVED up to bound 12 | [1:$] at the end, with no s_ | 5 |
| No way to fail | The cover of an idle cycle was unreached | An assume with ## and no |-> | 6 |
Our own grouping of the six cards on this page. The middle column repeats the measured result of each card.
A text search finds the patterns in the third column, but not every case. The surest test is the one F10.1.2 uses: break the design on purpose and run the file again. A check that still passes on the broken design is one of these six.
Asked in Interviews
| Question | Answer |
|---|---|
| What is a false positive in formal, and why is it worse than a false negative? | A pass on a buggy design. A false failure gives a trace to debug. A false pass gives nothing. |
What does @(clk) do in a concurrent assertion? | It samples on both edges, so every ## and [*n] counts phases, not cycles. |
Why can req |-> ##[1:$] gnt never fail in a formal tool? | It is weak. Only a finite trace could refute it, and no finite trace shows that gnt never comes. |
assume property (req ##1 rsp): what is wrong? | It forces req on every cycle. The intent was req |=> rsp. |
Try It
Concurrent SVA
assert property (@(posedge clk) mid |-> $stable(gnt[owner]));
// the fix:
for (genvar i = 0; i < 4; i++) begin : line
assert property (@(posedge clk) mid && owner == i |-> $stable(gnt[i]));
end
The index is a signal on the left and a constant inside the loop.
The clocked immediate form the editor runs
reg sel_q=0;
always @(posedge clk) begin
sel_q <= gnt[owner];
if (!rst && mid) assert(gnt[owner] == sel_q);
end
sel_q holds the old bit of the old owner. That is what $stable(gnt[owner]) compares.
[options]
mode bmc
depth 20
[engines]
smtbmc yices
[script]
read_verilog -formal -sv design.sv
prep -top own
[files]
design.svRun the moving index
Run as it is: BMC PASS to depth 20. The bug is in the RTL, on the
retryline.Compare each line with itself
Keep
gnt_q <= gntand assertgnt[i] == gnt_q[i]for the line whereowner == i: FAIL at reported step 4.Read the trace
Find the step where
ownerchanges whilemidis 1. Readgntin binary on both sides of it.Fix the RTL
Delete the
retryline and rerun the per-line check: BMC PASS to depth 20.
design.sv
props.sv
Use assert property (@(posedge clk) ...);. Leave blank for immediate assertions in the design.
Inputs are free unless constrained. Run to find a counterexample or check a proof.
Model: one positive-edge clock, binary data. Sampled history requires declaration-initialized variables; primary-input history is unsupported.
SBY summary and log
Check Yourself
Common Mistakes
Wrong Trusting a green run without counting the properties.
A property that the tool never listed cannot fail.
Fix Compare the number of properties in the report with the number in the file, on every run.
Wrong Writing a sampled signal as a vector index.
The index is sampled with the vector, so two samples can read two different bits.
Fix Loop over constant indices and put the index test in the antecedent.
assert property (@(posedge clk)
sel_valid |-> $stable(data[sel]));for (genvar i = 0; i < N; i++) begin : g
assert property (@(posedge clk)
sel_valid && sel == i |-> $stable(data[i]));
endWrong Assuming a bare sequence to describe a neighbour.
An assumed sequence must match from every cycle, so it forces its first term on every cycle.
Fix Write the trigger as an antecedent, then cover the idle case.
assume property (@(posedge clk) valid ##1 ready);assume property (@(posedge clk) valid |=> ready);
cover property (@(posedge clk) !valid);Wrong Treating a pass on one tool as a pass on every tool.
Tools differ on action blocks, clocking events and skipped calls, as the measured table shows.
Fix Keep assertions out of functions and action blocks, and name the clock edge.
Remember
- A false positive is a pass on a buggy design. It leaves no trace, so you must look for it.
- A check can be missing (semicolon, skipped call), mistimed (both edges, moving index) or unable to fail (weak liveness).
- A signal used as an index or a delay needs a
generatefamily over constants. - Assume implications. A bare sequence belongs in a cover.
- Count the listed properties. Then break the design on purpose: a check that still passes cannot see the fault.