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.

The owner moves in the middle of a transfer
01234clkfreestartfreeretryowner012gnt0000000100100000midretry: owner will movegnt jumps, mid is 1SBY reports FAIL
Scroll horizontally ↔

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

Two Wrong Answers, Two Different CostsA proof result can be wrong in two directions. The arrows show what each wrong answer costs the project.
  • Result
  • Step
  • Analysis
Two wrong answers, two different costsA proof result can be wrong in two directions. The arrows show what each wrong answer costs the project. result FAIL on a gooddesign false negative: amissing assumption result PASS on a buggydesign false positive: theproof lies step An hour of debug you read the traceand fix the bench result Silence no trace, no log line,nothing to read result A better bench the tool pointed atthe gap result A bug in silicon found later bysimulation or the lab
  1. result FAIL on a good designfalse negative: a missing assumption
    • An hour of debug
  2. result PASS on a buggy designfalse positive: the proof lies
    • Silence
  3. step An hour of debugyou read the trace and fix the bench
    • A better bench
  4. result Silenceno trace, no log line, nothing to read
    • A bug in silicon
  5. result A better benchthe tool pointed at the gap
  6. result A bug in siliconfound later by simulation or the lab
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.

MistakeWrong form, on the buggy designRight form, on the buggy designMeasured on
1. Missing semicolonEBMC lists only the first assertion: PROVED up to bound 5. read_slang refuses the fileEBMC lists both; the second is REFUTEDEBMC 6.1; Yosys read_slang
2. Both clock edgesBMC PASS to depth 20FAIL at reported step 14this site's engine
3. Short-circuited functioncheck skipped: nothing reportedcheck ran: two owners reportedVerilator 5.052, Icarus 12
4. Moving indexPROVED up to bound 12; BMC PASS to depth 20REFUTED; FAIL at reported step 4EBMC 6.1; this site's engine
5. Weak livenessPROVED up to bound 12REFUTEDEBMC 6.1
6. Assumed sequenceBMC PASS to depth 20FAIL at reported step 5this 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.

SymptomWhat our runs showedWhere to lookCard
The check never ranEBMC listed 1 property for a file with 2Report count against file count1
The check never ranBoth simulators printed nothing once override was 1An assert inside a function body3
Wrong samplesA 5-cycle request passed a 6-cycle rule: BMC PASS to depth 20An @( with no edge, before ## or [*2
Wrong samples$stable(gnt[owner]) was PROVED up to bound 12 on the buggy arbiterA signal inside [ ] of $stable or $past4
No way to failAn arbiter that never grants: PROVED up to bound 12[1:$] at the end, with no s_5
No way to failThe cover of an idle cycle was unreachedAn 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

QuestionAnswer
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.

The task. Depth stays at the default, 20.
[options]
mode bmc
depth 20
[engines]
smtbmc yices
[script]
read_verilog -formal -sv design.sv
prep -top own
[files]
design.sv
  1. Run the moving index

    Run as it is: BMC PASS to depth 20. The bug is in the RTL, on the retry line.

  2. Compare each line with itself

    Keep gnt_q <= gnt and assert gnt[i] == gnt_q[i] for the line where owner == i: FAIL at reported step 4.

  3. Read the trace

    Find the step where owner changes while mid is 1. Read gnt in binary on both sides of it.

  4. Fix the RTL

    Delete the retry line 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

Predict the outputThe pk bench with the bare sequence sop ##1 eop assumed and one cover, !rst && !sop. Mode cover, default depth 20, smtbmc yices, reset assumed in step 0. The cover result is:
module pk(input clk, rst, sop, eop, output reg done=0, output reg inpkt=0);
  reg gap=0;   // an idle cycle was seen since the last packet
  always @(posedge clk)
    if (rst) begin inpkt <= 0; done <= 0; gap <= 0; end
    else begin
      if (sop) inpkt <= 1; else if (eop) inpkt <= 0;
      done <= eop && inpkt && !gap;   // bug: the first packet after an idle cycle is dropped
      if (!sop && !eop && !inpkt) gap <= 1; else if (eop) gap <= 0;
    end
`ifdef FORMAL
  always @(posedge clk) begin
    if ($initstate) begin assume(rst); end else begin assume(!rst); end
  end
`endif
endmodule
Read included file: props.sv
assume property (@(posedge clk) sop ##1 eop);
cover property (@(posedge clk) !rst && !sop);
ConceptAn arbiter never raises gnt. Which asserted property still passes on it in a formal tool that follows IEEE 1800-2023?
Read the waveformIn this trace the per-line check fails. Which comparison did the moving-index form $stable(gnt[owner]) make at step 3?
The owner moves in the middle of a transfer
01234clkfreestartfreeretryowner012gnt0000000100100000midretry: owner will movegnt jumps, mid is 1SBY reports FAIL
Scroll horizontally ↔

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.

ConceptA file holds 40 assertions. The formal tool reports 39 properties, all proven. What should you do first?
ConceptA property uses @(clk) and no repetition or delay: assert property (@(clk) !(a && b));. What is the effect of the missing edge?

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.

Before
assert property (@(posedge clk)
  sel_valid |-> $stable(data[sel]));
After
for (genvar i = 0; i < N; i++) begin : g
  assert property (@(posedge clk)
    sel_valid && sel == i |-> $stable(data[i]));
end

Wrong 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.

Before
assume property (@(posedge clk) valid ##1 ready);
After
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 generate family 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.

Practice

Report a problem with this page