Followed-By: #-# and #=#

Say that a scenario must happen and be followed by a property, with #-# and #=#, the partners of |-> and |=>.

You Will Be Able To

  • Write a rule where the left side must happen, with #-# or #=#.
  • Tell followed-by from implication on the same trace.
  • Use followed-by in assumptions and covers, and know its duality with implication.
Lesson
A3.7
Time
20 min
Runs on
Verilator
Check
5 questions

A rule says "every packet start carries a header, then beats until the last one". Written as sop && hdr |=> ..., a packet with no header is never checked.

Implication

sop && hdr |=> beat until_with last

No header: vacuous success.

Followed-by

sop |-> (hdr #=# (beat until_with last))

No header: failure.

Followed-by makes the left side an obligation. This lesson shows both forms and where each fits.

Overlapped Followed-By: #-#

s #-# p holds when s matches and p holds from the edge where s ends (IEEE 1800-2023 16.12.9). If s does not match, the property fails.

Left sides |-> ps #-# p
matches, p holdspasspass
matches, p failsfailfail
does not matchvacuous successfail

The only difference is the last row.

Non-Overlapped Followed-By: #=#

s #=# p starts p one edge after s ends, like |=>. The left side must still match.

Three packet starts
01234567891011121314sophdrbeatlastno headerbeat gap
Scroll horizontally ↔

Edges 1 to 15. Packet 1 is good. Packet 2 has no header. Packet 3 drops a beat before its last one.

Followed-by is strong (16.12.9): with a Boolean p, s #=# p means strong(s ##1 p). An attempt that the end of the run cuts short is false. The bare sequence s ##1 p is weak, so the same attempt does not fail.

CaseStandard (16.12.9)Verilator 5.052 (measured)
req #=# ack at every edge; one attempt fails on ack while the next fails on req, at the same edgetwo failures at that edgeone failure reported
#-# at every edge, same traceone failure per failing attemptone failure per failing attempt
a multi-cycle sequence before the operator: a ##1 b #=# clegalrejected ("sequence expression as antecedent of followed-by")
start |-> (cfg #=# run) with start at the last edgefalse: run never comesno failure reported

Measured by tools/probes/sva-w1a/followed-by.mjs. On 5.052, keep a Boolean before #=# and space its attempts, as the packet rule does.

Followed-By Is the Dual of Implication

Followed-by is implication turned inside out: s #-# p means not (s |-> not p), and s #=# p means not (s |=> not p) (16.12.9).

From Implication to Followed-ByNegate the consequent, negate the whole implication, and the result is followed-by.
  • Property
  • Structure
From implication to followed-byNegate the consequent, negate the whole implication, and the result is followed-by. property s |-> p if s, then p property s |-> not p if s, then never p property not (s |-> not p) s happens and p holds property s #-# p the same rule negate pnegate allequals
  1. property s |-> pif s, then p
    • negate p → s |-> not p
  2. property s |-> not pif s, then never p
    • negate all → not (s |-> not p)
  3. property not (s |-> not p)s happens and p holds
    • equals → s #-# p
  4. property s #-# pthe same rule
  1. Negate the consequent

    "If s, then never p."

  2. Negate the whole rule

    It fails when s does not happen, or when p fails: that is followed-by.

Read the diagram as text
  • s |-> p: if s, then p
  • s |-> not p: if s, then never p
  • not (s |-> not p): s happens and p holds
  • s #-# p: the same rule
  • s |-> p → s |-> not p: negate p
  • s |-> not p → not (s |-> not p): negate all
  • not (s |-> not p) → s #-# p: equals

A vacuous implication becomes a failing followed-by.

Followed-By in Assumptions and Covers

In an assumption, followed-by states a bench promise that a scenario will happen: "every start comes with a config". In a cover, s #=# p counts the runs where s happens and p follows.

Try It

Packet 1 has a header and its beats run until last at 35: both rules pass.

Packet 2 starts at 55 with no header. must fails there. if_hdr never starts an attempt, so it reports nothing.

Change must to use #-# and predict when beat must start.

RUNVerilator · simulator service
Edit the code, then run it
Expected: must=1 if_hdr=0

Check Yourself

Predict the outputPredict the exact output.
module tb;
  logic clk = 0;
  always #5 clk = ~clk;
  logic go = 0, a = 0, b = 0;
  int fails = 0;
  rule: assert property (@(posedge clk) go |-> (a #=# b)) else fails++;
  initial begin
    @(negedge clk) begin go = 1; a = 1; end   // 15: a here, b due at 25
    @(negedge clk) begin go = 0; a = 0; b = 1; end
    @(negedge clk) begin go = 1; b = 0; end   // 35: go without a
    @(negedge clk) go = 0;
    @(negedge clk) $display("fails=%0d", fails);
    $finish;
  end
endmodule
ConceptWhat does s #-# p report when s does not match?
ConceptWhich property means the same as s #=# p?
ConceptWhere does p start in s #=# p?
ConceptThe run ends one edge after s matches, before p can be checked. What is s #=# p for that attempt?

Common Mistakes

Wrong Use an implication when the left side must happen.

A missing left side makes the implication vacuous, so the bug passes.

Fix Use followed-by, which fails when the left side does not match.

Before
sop && hdr |=> beat until_with last
After
sop |-> (hdr #=# (beat until_with last))

Wrong Assert s #=# p on every edge.

It then fails on every edge where s is absent.

Fix Put it behind the event that makes s due, such as sop |-> (...).

Wrong Mix up #-# and #=#.

They differ by one edge, exactly like |-> and |=>.

Fix Use #-# for "from the same edge", #=# for "from the next edge".

Remember

  • s #-# p and s #=# p need s to match; |-> and |=> succeed vacuously without it.
  • #-# starts p where s ends; #=# one edge later.
  • Followed-by is the dual of implication: s #-# p is not (s |-> not p).
  • Followed-by fits assumptions and covers: a scenario that must happen, or one to count.

Practice

Report a problem with this page