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.

Assertions on the Boundaries, None InsideThe chip bench binds its checkers where blocks meet: every manager and target port of the bus matrix, and both APB buses. None looks inside a block. Each watches an agreement two blocks share.
  • Processor
  • Manager
  • Bus
  • Memory
  • Peripheral
  • Data
  • Control
Assertions on the Boundaries, None InsideThe chip bench binds its checkers where blocks meet: every manager and target port of the bus matrix, and both APB buses. None looks inside a block. Each watches an agreement two blocks share. processor Core two manager ports manager DMA, debug, seat manager ports bus AHB matrix 9 AHB checkers onits ports memory ROM, SRAM,CLINT, PLIC target ports bus Fast and slowAPB 2 APB checkers peripheral UART, GPIO, timer... insides uncheckedhere checkedcheckedcheckedcheckedthe block bench's job
  1. processor Coretwo manager ports
    • checked → AHB matrix
  2. manager DMA, debug, seatmanager ports
    • checked → AHB matrix
  3. bus AHB matrix9 AHB checkers on its ports
    • checked → ROM, SRAM, CLINT, PLIC
    • checked → Fast and slow APB
  4. memory ROM, SRAM, CLINT, PLICtarget ports
  5. bus Fast and slow APB2 APB checkers
    • the block bench's job → UART, GPIO, timer ...
  6. peripheral UART, GPIO, timer ...insides unchecked here
  1. Manager side

    A checker on each manager port sees what each manager asks of the matrix.

  2. Target side

    A checker on each target port sees what the matrix passes on, after arbitration.

  3. The peripheral buses

    An APB checker on each bus sees every register access of every peripheral.

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

Five questions this page answers
Question
1Where in a chip do assertions find bugs the block benches cannot?
2Why does a chip plan put no assertions inside pre-verified blocks?
3What is a safety rule, and what is a bounded liveness rule?
4What does a chip checker cost in simulation speed?
5Why 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

New words on this page
WordMeaning
AssertionA rule the design must always keep, checked automatically while it runs.
CheckerBench code that watches signals and reports when a rule breaks. It may be written as assertions or as procedural code.
BoundaryThe set of wires where two blocks meet: a bus port, a crossing, an interrupt wire, a pad.
Safety ruleSomething bad never happens, such as a request while its enable is off.
Bounded liveness ruleSomething good happens within a stated time, such as a request within four timer slots.
False alarmA 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.

Three requests, the second dropped early
RequestSenderAcknowledgeChecker
1holds req until acktwo cycles latersilent
2drops req after one cyclenever comesfires: dropped before its acknowledge
3holds req until acktwo cycles latersilent

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

  1. Rule 1: Put checkers where integration bugs show.

    Bus ports of the matrix, the buses to the peripherals, crossings, interrupt wires and pads.

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

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

  4. Rule 4: Measure the cost.

    Every checker runs every cycle of every test. Know its price before it joins the regression.

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

  6. 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:

Icarus Verilog version 12.0 (stable), the runnable example with the faulty sender.
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.

The Same Loop, Three Builds
Checkers boundThree runs (s)Median (s)Slower than none
04.916, 5.014, 4.8834.916—
116.176, 5.745, 5.675.74517%
226.727, 6.861, 6.8126.81239%

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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc binds eleven protocol checkers; a large chip binds hundreds.

  1. Verification IP

    Bought protocol checkers for AXI, PCIe or DDR are bound on every interface of that kind, with switches for costly checks.

  2. Formal on boundaries

    The same boundary rules are proved formally on a subsystem, where simulation would need too many tests.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: cycle 8: request dropped before its acknowledge 3 request(s) sent, checker fired 1 time(s)

Check Yourself

Predict the outputThe sender now holds every request until its acknowledge. What is the last line printed?
// Two rules checked where one block meets another; nothing inside either block is looked at.
module tb;
  logic clk = 0, req = 0, ack = 0;
  int cycle = 0, fired = 0, rounds = 0;
  bit drop_early = 0;
  always #5 clk = ~clk;
  always @(posedge clk) cycle++;
  // The sender: raise req, hold it until ack (or, with the bug, give up after one cycle).
  initial begin
    repeat (2) @(negedge clk);
    repeat (3) begin
      req = 1;
      if (drop_early && rounds == 1) @(negedge clk);
      else begin @(negedge clk); while (!ack) @(negedge clk); end
      req = 0; rounds++;
      repeat (2) @(negedge clk);
    end
    repeat (4) @(negedge clk);
    $display("%0d request(s) sent, checker fired %0d time(s)", rounds, fired);
    $finish;
  end
  // The receiver: acknowledges two cycles after it sees a request.
  logic [1:0] seen = 0;
  always @(posedge clk) begin
    seen <= req ? (seen == 2'd3 ? seen : seen + 1) : 0;
    ack <= req && seen == 2'd1;
  end
  // The checker, on the boundary.
  logic open = 0;   // a request is up and has had no acknowledge yet
  always @(posedge clk) begin
    if (open && !req && !ack) begin fired++; $display("cycle %0d: request dropped before its acknowledge", cycle); end
    if (ack && !open && !req) begin fired++; $display("cycle %0d: acknowledge with no request", cycle); end
    open <= req && !ack;
  end
endmodule
ConceptWhere does a chip-level assertion pay most?
Concept"A running, enabled timer raises its request within four slots" is which kind of rule?
ConceptIn the lab, eleven checkers cost 17% more time. What do twice as many cost?
ConceptA chip checker fires during reset on every test. What is wrong?

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.

Practice

Report a problem with this page