Assertions: Checks That Travel with the Design
Write a rule of the specification as a check that holds at every clock edge. See why it finds a bug where the bug starts, and how it differs from a scoreboard.
You Will Be Able To
- Describe an assertion as a rule that must hold at every clock edge.
- Write a timing rule as a plain checker, and read the same rule as one assertion.
- Explain why an assertion reports a bug at its source, and a scoreboard only at the output.
- Choose between an assertion and a scoreboard for a given rule.
- Lesson
- B3.4
- Time
- 22 min
- Runs on
- Your browser
- Check
- 5 questions
The scoreboard is happy: six requests went in, six answers came out, all correct. Yet the specification says every answer must arrive within four cycles. Two of them took six, and nothing in the log says so.
- Driver
- DUT
- Scoreboard
- Property
- Data
- The path
The bench sends requests and the responder answers them.
- Checking at the end
A scoreboard counts what came out. Six requests, six answers: it passes.
- Checking on the wire
An assertion watches req and ack at every edge. It fails at the cycle the rule breaks, next to the cause.
Read the diagram as text
- Bench: drives req
- responder: answers each req with ack
- Scoreboard: counts answers at the end
- Assertion on req and ack: every req: ack within 4 cycles
- Bench → responder: req
- responder → Scoreboard: ack
- responder → Assertion on req and ack: watched every edge
An architecture drawing of the lab. The assertion needs no stimulus of its own; it only watches.
Before You Start
Read Corner Cases and How to Think of Them first. A clock edge, a register and a cycle are assumed: Modulo-N, Up/Down and Loadable Counters is a refresher.
| Question | |
|---|---|
| 1 | What is an assertion, in one sentence? |
| 2 | Why does an assertion find a bug at its source? |
| 3 | What can a scoreboard miss that an assertion catches, and the other way round? |
| 4 | How does one timing rule look as plain code and as an assertion? |
| 5 | What does "travel with the design" mean? |
The Idea: A Rule That Is Checked All the Time
A scoreboard asks one question: did the right answers come out? It waits at the end of the path. That is powerful, and it is blind to how and when. An answer that arrives late but correct passes, and so does a handshake that broke a rule on the way.
An assertion asks a different question: does this rule hold right now? It is a statement about signals, such as "every request is answered within four cycles", checked at every clock edge. When the rule breaks, it fails at that edge, on those signals. You learn where and when, not just that something somewhere went wrong.
Because an assertion needs no stimulus of its own, it can sit inside the design or beside it. Then it travels. It runs in this block's bench, in the chip-level bench, and in a formal tool that checks every input. Designers write assertions for their own logic; verification engineers write them for interfaces.
New Words
| Word | Meaning |
|---|---|
| Assertion | A statement about signals that must always hold. The simulator checks it and reports each failure. |
| Plain checker | A checker written as ordinary bench code that watches signals for one rule. An assertion is a short way to write the same thing. |
| Scoreboard | The checker part that holds expected results and matches them with what came out. Here it stands for any check at the end of the path. |
| Formal tool | A program that proves a rule with mathematics for every possible input, instead of simulating chosen inputs. |
| Request and acknowledge | A handshake: one side raises req to ask, the other raises ack to answer. |
| Bounded response | A rule with a time limit, such as "answer within four cycles". |
The Smallest Example: One Rule, Checked by Hand
The responder must answer each req with ack within four clock edges. Count edges after each request and decide by hand.
| req seen at edge | ack seen at edge | Edges later | Rule |
|---|---|---|---|
| 3 | 6 | 3 | holds |
| 11 | 14 | 3 | holds |
| 14 | none by edge 18 | more than 4 | breaks at edge 18 |
Notice where the verdict lands: at edge 18, the last edge the answer was allowed. That is the earliest moment anyone could know the rule broke. A scoreboard counting answers at the end of the test learns nothing, because the answer does arrive later.
The Rules
Rule 1: Write the rule, not the scenario.
An assertion says what must always be true. It does not drive anything, so any test can trip it.
Rule 2: Check at every edge.
The rule is tested at each clock edge, so a failure names the cycle it broke.
Rule 3: Fail next to the cause.
An assertion on a wire inside the design fails there, long before the damage reaches an output.
Rule 4: Scoreboards check what; assertions check how and when.
Use both. A late or illegal handshake passes a scoreboard; wrong data can pass a timing rule.
Rule 5: Let it travel.
A rule written once runs in every bench that holds the design, and in formal tools.
Sources for These Rules
Assertions in a verification plan, by designers for logic and by verification engineers for interfaces: Mehta, section 2.2, item 8.
Assertions as a methodology, overview: Mehta, ASIC/SoC Functional Design Verification, sections 6.2 and 6.4.
Concurrent assertions, cycle delay ranges, implication and disable iff: IEEE 1800-2023, clauses 16.5, 16.7, 16.12.7 and 16.15.
The Lab: A Plain Checker, Then the Same Rule as an Assertion
In the lab, a responder answers each request three cycles later. One line makes a request that arrives while it is still busy wait three cycles more. The bench sends six requests and counts the answers, like a scoreboard. A plain checker watches req and ack.
always @(posedge clk) begin
if (since >= 0 && ack) since = -1; // answered in time
else if (since >= 0) begin
since++;
if (since == 4) begin errors++; $display("cycle %0d: ERROR ...", cycle); since = -1; end
end
if (req) since = 0; // a new request starts the count
endcycle 6: ack, 3 cycles after its req
cycle 14: ack, 3 cycles after its req
cycle 18: ERROR req not answered within 4 cycles
cycle 28: ack, 3 cycles after its req
cycle 38: ack, 3 cycles after its req
cycle 43: ERROR req not answered within 4 cycles
6 requests, 6 answers, 2 checker errorsRead the last line first. Six requests, six answers: a scoreboard would pass this design. Rule 4 at work. The checker fails at cycles 18 and 43, the exact edges where the time limit ran out. Rule 3 at work: those are the two requests that arrived while the responder was busy.
Here is the same rule as one assertion. Read it left to right: a_answered is its name, printed if it fails. At every rising edge of clk, if req is 1, ack must be 1 within the next four edges. The arrow |-> is the "if, then", and ##[1:4] is "one to four edges later".
a_answered: assert property (@(posedge clk) disable iff (rst) req |-> ##[1:4] ack)
else $display("time %0t: a_answered failed", $time);time 175: a_answered failed
time 425: a_answered failedThe clock edges in the lab come every 10 time units, starting at 5. So time 175 is edge 18 and time 425 is edge 43: the assertion and the plain checker agree, cycle for cycle. One line replaced eight.
Why Both Assertions and Scoreboards
Why not put every check in the scoreboard? Because a scoreboard sees only the outputs, after all the logic in between. A bug deep inside may take hundreds of cycles to reach an output, or may never reach one in this test. An assertion on the inner wire fails where the bug is.
Why not use only assertions? Because many questions are about data end to end: did this packet arrive intact, in order? That needs a model and a comparison, which is a scoreboard's job. Good benches use both.
Traps
The first trap is the assertion that never really runs. A rule that starts with "if req" passes quietly in every test where req never rises. Count how often each assertion actually started, or a silent pass may mean nothing was tested.
The second trap is an assertion that copies the design. Someone writes the rule by reading the RTL and states what the code does, bugs included. Write the rule from the specification, in its own words.
The third trap is a time limit off by one. "Within four cycles" can mean four edges or five, depending on where you start counting. Settle it with the designer, write it in the plan, and test a request answered at exactly the limit.
Where This Goes Next
This lesson showed one rule. The Assertions track teaches the language in full, and the Formal track proves rules for every input.
| The idea from this page | Where it is taught |
|---|---|
| Turning specification sentences into assertions | Why Assertions |
| What |-> means, and when a pass is empty | Implication and Vacuous Success |
| Time limits and what the end of a test means | Weak and Strong: What the End of a Test Means |
| Assertions inside a SystemVerilog bench | Assertions and Protocol Checks |
| The same assertion proved with no testbench | Your First Proof: the Same SVA, No Testbench |
Try It
Run it: six requests, a count of answers, and a plain checker for the four-cycle rule.
Make the busy wait shorter: change the 5 in (busy > 0) ? 5 : 2 to 3. Predict the last line.
Move the request at cycle 13 to cycle 15. Does the checker still fail at cycle 18, and why?
cycle 6: ack, 3 cycles after its req cycle 14: ack, 3 cycles after its req cycle 18: ERROR req not answered within 4 cycles cycle 28: ack, 3 cycles after its req cycle 38: ack, 3 cycles after its req cycle 43: ERROR req not answered within 4 cycles 6 requests, 6 answers, 2 checker errorsCheck Yourself
Common Mistakes
Wrong Trust a scoreboard alone for a timing rule.
A late answer that is correct passes a scoreboard.
Fix Write the timing rule as an assertion that checks every edge.
Wrong Write an assertion by reading the RTL.
It then states what the code does, including its bugs.
Fix Write the rule from the specification.
Wrong Take a silent assertion as proof the rule holds.
If its first condition never happened, it never really checked anything.
Fix Count how often each assertion started its check.
Remember
- An assertion is a rule about signals that is checked at every clock edge.
- It fails at the edge the rule breaks, next to the cause, and needs no stimulus of its own.
- Scoreboards check what came out; assertions check how and when. Use both.
- A rule written once travels: block bench, chip bench and formal tools.