Assertions at Chip Level
Put assertions where blocks meet: bus ports, crossings, interrupt wires, pads. Check the agreements two blocks share, not the insides of either, and know what each checker costs in speed.
You Will Be Able To
- Choose where a chip-level assertion pays, and where it repeats block work.
- Write a boundary rule as a safety rule or a bounded liveness rule.
- Read the measured cost of checkers and estimate the cost of more.
- Explain why a chip checker must be silent on every legal run.
- Lesson
- V12.6
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
A bus rule breaks in the first minutes of a chip run. A write changes its data in the middle of a wait. The block benches never saw it, because each owned only one side of that bus. A checker on the boundary sees both.
- Processor
- Manager
- Bus
- Memory
- Peripheral
- Data
- Control
- Manager side
A checker on each manager port sees what each manager asks of the matrix.
- Target side
A checker on each target port sees what the matrix passes on, after arbitration.
- The peripheral buses
An APB checker on each bus sees every register access of every peripheral.
- Not inside
The blocks' insides belong to their own benches. The chip pays for checkers only where integration can break.
Read the diagram as text
- Core: two manager ports
- DMA, debug, seat: manager ports
- AHB matrix: 9 AHB checkers on its ports
- ROM, SRAM, CLINT, PLIC: target ports
- Fast and slow APB: 2 APB checkers
- UART, GPIO, timer ...: insides unchecked here
- Core → AHB matrix: checked
- DMA, debug, seat → AHB matrix: checked
- AHB matrix → ROM, SRAM, CLINT, PLIC: checked
- AHB matrix → Fast and slow APB: checked
- Fast and slow APB → UART, GPIO, timer ...: the block bench's job
From soc_tb.sv: the P4 AHB checker on 4 manager and 5 target ports, and the P3 APB checker on both buses.
Before You Start
Read Passive Checkers: Bind and Listen first: it binds the bench's checkers. Assertions as a language are taught in the SVA track; the bench's checkers here are procedural code that does the same job.
| Question | |
|---|---|
| 1 | Where in a chip do assertions find bugs the block benches cannot? |
| 2 | Why does a chip plan put no assertions inside pre-verified blocks? |
| 3 | What is a safety rule, and what is a bounded liveness rule? |
| 4 | What does a chip checker cost in simulation speed? |
| 5 | Why must a chip checker never fire on a legal run? |
The Idea: Check What Two Blocks Share
An assertion is a rule the design must always keep, checked on every cycle of every test. At block level you write hundreds of them, about the block's insides. At chip level the insides are done. What is new is the agreement between blocks. It is the bus protocol both sides follow, the handshake across a clock crossing, the promise that an enabled interrupt arrives.
So chip assertions sit on boundaries. Each watches the wires two blocks share and knows nothing of either block's design. That is their strength: they work whoever made the blocks. It is also their discipline: a rule that needs a block's internal state belongs in that block's bench.
They are not free. A checker runs every cycle, in every test, for the whole regression. So you measure what they cost, and keep the ones that every test can break.
New Words
| Word | Meaning |
|---|---|
| Assertion | A rule the design must always keep, checked automatically while it runs. |
| Checker | Bench code that watches signals and reports when a rule breaks. It may be written as assertions or as procedural code. |
| Boundary | The set of wires where two blocks meet: a bus port, a crossing, an interrupt wire, a pad. |
| Safety rule | Something bad never happens, such as a request while its enable is off. |
| Bounded liveness rule | Something good happens within a stated time, such as a request within four timer slots. |
| False alarm | A checker firing on a legal run. One false alarm can get a checker switched off. |
The Smallest Example: A Request and Its Acknowledge
Two blocks share a request and an acknowledge. The agreement has two rules. Safety: no acknowledge without a request. Liveness, in the form the sender owes: a request stays up until its acknowledge comes. The checker watches only req and ack.
| Request | Sender | Acknowledge | Checker |
|---|---|---|---|
| 1 | holds req until ack | two cycles later | silent |
| 2 | drops req after one cycle | never comes | fires: dropped before its acknowledge |
| 3 | holds req until ack | two cycles later | silent |
The runnable example below prints this run.
The checker never looks inside the sender or the receiver. It would catch the same bug in any pair of blocks that share this agreement. And on a sender that follows the rules it says nothing at all.
The Rules
Rule 1: Put checkers where integration bugs show.
Bus ports of the matrix, the buses to the peripherals, crossings, interrupt wires and pads.
Rule 2: Add no new checkers inside pre-verified blocks.
Their benches checked them. Assertions a designer wrote into a block's RTL still come along into chip runs. Keep the cheap ones and switch the costly ones off.
Rule 3: Relate two boundaries when the agreement spans them.
On one side, what software wrote on the bus. On the other, what a wire does. No model of the block sits in between.
Rule 4: Measure the cost.
Every checker runs every cycle of every test. Know its price before it joins the regression.
Rule 5: Turn on the expensive ones only where they are needed.
A checker only one group of tests can break runs only in those tests.
Rule 6: Stay silent on every legal run.
A checker that raises false alarms gets switched off, and then it catches nothing.
Sources for These Rules
At SoC level, assertions go on the protocol interfaces between blocks: buses, hand-off interfaces and FIFOs. MEHTA-DV 16.8 (PDF p327).
Enable checks and covers only when meaningful, and control when they collect, for speed: MEHTA-DV 7.10.2 and 7.11 (PDF p168-169). The book writes this for coverage; the same reasoning holds for checkers.
A new evaluation attempt at every tick of the leading clock: IEEE 1800 clause 16.14.5. Concurrent assertions in the language: IEEE 1800 clause 16. The bench's P3 and P4 checkers are procedural rule checks, not concurrent assertions; the protocols track builds them.
The Lab: What the Bench's Checkers Cost
First the toy, on the site's Icarus:
cycle 8: request dropped before its acknowledge
3 request(s) sent, checker fired 1 time(s)Rule 6 is the other half of the example. With a sender that keeps the agreement, the checker prints nothing but a count of zero.
Now the chip. The bench binds 11 protocol checkers. An AHB checker sits on each of the matrix's 4 manager and 5 target ports, and an APB checker on each bus. To measure their cost, three builds of the bench were made. They differ only in those instances: stubs that check nothing, the bench as it is, and every checker bound twice. Each ran the same loop three times.
| Checkers bound | Three runs (s) | Median (s) | Slower than none |
|---|---|---|---|
| 0 | 4.916, 5.014, 4.883 | 4.916 | — |
| 11 | 6.176, 5.745, 5.67 | 5.745 | 17% |
| 22 | 6.727, 6.861, 6.812 | 6.812 | 39% |
1,300,028 system cycles a run, Verilator 5.032 at -O2, model compare on. Measured on the laptop while other jobs ran. The block monitors stay in all three builds.
Rule 4 in numbers. The bench's checkers cost 17% on this loop, about 1.5% each. Twice as many cost 39%, about 1.8% each. Three points lie close to a straight line: the cost grows with the number of checkers, and each costs about the same.
Is that worth paying? Every test drives the matrix and the buses, so every test can break one of their rules. The same money spent on a checker of one block's insides would buy almost nothing new. The problem of this lesson asks for a chip-level rule that spans two boundaries. One is a register written on the bus; the other is the wire it controls.
Why It Is Built This Way
Why procedural checkers and not concurrent assertions? The bench runs on Verilator, whose support for concurrent assertions is partial. The protocols track wrote the AHB and APB checkers as procedural rule blocks that run on every simulator the site uses. They do the job of assertions: watch, compare, report.
What would concurrent assertions cost? This lab did not measure them. A concurrent assertion starts a new attempt at every tick of its clock (IEEE 1800 clause 16.14.5). A rule that spans many cycles keeps several attempts alive at once. Simulators handle that very differently, so measure the price on your own simulator before such a rule joins the regression.
Why does a checker error stop the run at once? Because the first broken rule is the one worth reading. Later errors are usually consequences, as in triage. It also means a checker that fires falsely ends every test, which is why rule 6 is not optional.
Traps
The first trap is the block benches copied into the chip. A team binds every checker of every block bench into the chip bench. The regression slows down by a large factor, and the chip finds nothing the blocks had not found.
The second trap is the checker that shouts. It fires during reset, when the bus is not yet defined, and every test fails. Someone disables it "for now". Months later a real protocol break passes unseen.
The third trap is a rule written from the block's insides. A chip checker reads a counter inside the timer to decide when an interrupt is due. The timer is replaced by another vendor's, the counter is gone, and the checker no longer compiles. A rule written from the boundary would have kept working.
At Scale
This section looks ahead. ap_soc binds eleven protocol checkers; a large chip binds hundreds.
Verification IP
Bought protocol checkers for AXI, PCIe or DDR are bound on every interface of that kind, with switches for costly checks.
Formal on boundaries
The same boundary rules are proved formally on a subsystem, where simulation would need too many tests.
Emulation-friendly checkers
Checkers that will run on an emulator are written in a synthesizable subset, so they keep working when the regression moves.
Try It
Run it: three requests, the second dropped early, and the checker's report.
Fix the sender (the predict question below). What does the checker print?
Make the receiver acknowledge with no request. Which rule fires?
cycle 8: request dropped before its acknowledge 3 request(s) sent, checker fired 1 time(s)Check Yourself
Common Mistakes
Wrong Bind every block bench's checkers into the chip bench.
It costs speed in every test and finds nothing the block benches missed.
Fix Bind checkers on boundaries; leave block insides to block benches.
Wrong Write a chip rule that reads a block's internal signals.
It breaks when the block changes, and it repeats block work.
Fix Write the rule from the boundary wires, as an agreement between blocks.
Wrong Accept a checker that fires now and then on legal runs.
False alarms get checkers switched off, and then they catch nothing.
Fix Fix the rule until it is silent on every legal run.
Remember
- Chip assertions check what blocks share on their boundaries, not the insides of blocks.
- A rule can span two boundaries: what software wrote, what a wire does.
- Each checker costs about the same; measure before adding.
- A checker must be silent on every legal run, or it will be switched off.