What Firmware Can Never Do

No compiler emits some stimulus on demand. Think of transfers back to back, a read at an exact cycle, or traffic beside other managers. Think of an exact lane, or an error or illegal transfer on purpose. Watch one real fault that only the seat could find, and learn which checks belong on the seat.

You Will Be Able To

  • Name the kinds of stimulus that firmware cannot make on demand.
  • Read a back-to-back pair of transfers on the data port, and say why the core never makes one.
  • Explain why a seat-only finding must stay in the seat's regression.
  • Use an error made on purpose, and an illegal transfer on purpose, as checks.
Lesson
V6.6
Time
26 min
Runs on
Your browser
Check
5 questions

At stage E9 of ap_soc, faults were seeded into the chip one at a time. A few were found by the bus-manager seat and by nothing else. Here is one. Firmware ran the same three accesses and passed every time.

Bus Timings the Core Never ProducesThe seat's data port for three rows: a write, a second write marked back to back, then a read. The read's address phase sits on the second write's data phase.
01234567htransNSEQIDLENSEQIDLENSEQIDLEhaddr10004020x80003004x8000300080003004xhwritehwdata0000000000000002000000008591bc430000000031e02a7900000000hreadyback to back
Scroll horizontally ↔
  1. Cycle 0

    The bench's own first word: TB_STATUS = 2, "main entered". Its APB data phase waits a cycle.

  2. Cycle 3

    Row 1: a write of 8591_BC43 to SRAM 0x8000_3004, then one idle cycle, as single rows always have.

  3. Cycle 5

    Row 2 (wq): a write to 0x8000_3000. Its data phase is next cycle, and the bus is not left idle.

  4. Cycle 6

    Row 3 (rq): the read of 0x8000_3004 starts while row 2's data, 31E0_2A79, is still on hwdata. That is back to back.

  5. Cycle 7

    The SRAM holds hready low for one cycle: it must finish the write before it can read. A read that waits like this is a deferred read.

Recorded on ap_soc v1.5, Verilator 5.052 2026-09-05, +core=bfm, one value per cycle from the bench's sample window. The processor's interpreter makes the same three transfers with instructions between them.

Before You Start

Read Sequences as Virtual Firmware and The SRAM Port and Its Wrapper first.

Five questions this page answers
Question
1Which kinds of stimulus can firmware not make on demand?
2What is a back-to-back pair, and why does the core never make one?
3How did one seeded fault pass every firmware test?
4What is an error made on purpose, and what must the test check after it?
5Why is an illegal transfer a useful test?

The Idea: The Stimulus a Compiler Chooses, and the Rest

Firmware reaches the bus through instructions. The compiler picks the order, the size and the spacing of every access. The core then adds its own gaps: a fetch, a decode, a branch between two stores.

So whole families of bus behaviour never appear in a firmware test. Two transfers with no idle cycle between them. A read at the exact cycle an event is due. Your transfers landing in the same cycles as the DMA's and the debugger's. A byte written to exactly the lane you want. A transfer that must fail. A transfer the protocol forbids.

Real managers make some of these all the time: a DMA, a debugger, another bus's bridge. A chip must survive them. Only a bus manager the bench controls can make them on demand.

What Each Seat Can Put on the BusFirmware reaches the bus through a compiler and a core. The seat reaches it row by row. Some stimulus only the seat makes on demand.
  • File
  • Processor
  • Test
  • Manager
  • Bus
  • Result
  • Control
  • Data
  • Transaction / TLM
What Each Seat Can Put on the BusFirmware reaches the bus through a compiler and a core. The seat reaches it row by row. Some stimulus only the seat makes on demand. file C source the compiler picksorder and size processor ap_rv32 gaps betweentransfers test Table rows each one transfer, aswritten manager Seat the core's data port bus Fabric SRAM, bridges,blocks result Only from theseat exact timing; severalmanagers; exact lane;errors; illegal instructionsspaced transfersrowsexact transferson demand
  1. file C sourcethe compiler picks order and size
    • instructions → ap_rv32
  2. processor ap_rv32gaps between transfers
    • spaced transfers → Fabric
  3. bus FabricSRAM, bridges, blocks
  4. test Table rowseach one transfer, as written
    • rows → Seat
  5. manager Seatthe core's data port
    • exact transfers → Fabric
    • on demand → Only from the seat
  6. result Only from the seatexact timing; several managers; exact lane; errors; illegal
  1. The firmware path

    A compiler turns C into instructions, and the core spaces their transfers out.

  2. The seat path

    Each row becomes one transfer, with the size, address and timing it names.

  3. What only one path makes

    Back-to-back pairs, reads at an exact cycle and traffic beside the DMA come from the seat. So do exact lanes, errors and illegal transfers.

Read the diagram as text
  • C source: the compiler picks order and size
  • ap_rv32: gaps between transfers
  • Table rows: each one transfer, as written
  • Seat: the core's data port
  • Fabric: SRAM, bridges, blocks
  • Only from the seat: exact timing; several managers; exact lane; errors; illegal
  • C source → ap_rv32: instructions
  • ap_rv32 → Fabric: spaced transfers
  • Table rows → Seat: rows
  • Seat → Fabric: exact transfers
  • Seat → Only from the seat: on demand

The seat's rows: tools/soc/ap_soc/bench/soc_tb/README.md, "The sequence table".

New Words

New words on this page
WordMeaning
Back to backA transfer whose address phase sits on the data phase of the one before, with no idle cycle between.
Deferred readA read that waits a cycle because the memory is still busy with the write before it.
Concurrent trafficTransfers from several managers on one fabric in the same cycles, so they compete for it.
Error made on purposeAn access the test knows must fail, sent to check the error answer and the recovery after it.
Illegal transferA transfer the bus protocol forbids, such as a word at an address that is not a multiple of 4.
Seat-only findingA bug that only stimulus from the seat makes visible; firmware tests pass on it.

The Smallest Example: A Read That Waits

A toy SRAM port finishes each write in the cycle after its address. A read that arrives in that cycle must wait one cycle, with its enable held, and then read. The toy has a bug: during the wait it drops the enable, so the read returns an old output register.

The same read, two spacings
Idle cycles between write and readThe read waits?Value read
0 (back to back)yes, with the enable droppedthe old output: wrong
1 or morenothe stored word: right

The example below prints both cases.

With one idle cycle the bug never runs. Firmware always leaves that cycle, so a firmware test can pass on this toy for ever.

The Rules

  1. Rule 1: Put timing on the seat when it matters.

    The seat can place transfers back to back (wq, rq) and at an exact cycle (the delay field). Firmware gets the compiler's spacing.

  2. Rule 2: Load the fabric from several managers at once.

    Seat rows can start a DMA job and a stream of debug reads, then queue their own reads beside them. The collisions happen in every run, not where a compiler happens to put them.

  3. Rule 3: Choose size and lane on purpose.

    A row names its size (w, wh, wb) and address, so every lane of every size can be hit. A compiler picks one size for one C type.

  4. Rule 4: Make errors on purpose, then check the recovery.

    Send an access that must fail, check the error answer, then check the chip still works. A test that never fails an access never tests the error path.

  5. Rule 5: Use illegal transfers to test the checkers.

    A bus checker that never fires may be blind. An illegal transfer on purpose must end the run as a checker error.

  6. Rule 6: Keep every seat-only finding in the seat's regression.

    Firmware will never make that stimulus again, so only the seat's test stops the bug from coming back.

Sources for These Rules

The seat's back-to-back rows: tools/soc/ap_soc/bench/ap_core_seat.sv (task phase) and soc_tb.sv (seat_access with queued = 1). See also the README, "The sequence table", and facts 27.12 ("The processor never does this").

The seat-only faults and the costs: docs/soc/fault-table.md (npm run check:soc-faults); plan §3.10, stages E9 and E19. The seat's traffic rows (dma copy, jtag stream, tb gaps): the bench README, "Interconnect and boot experiments (E19)".

The rule that a transfer must be aligned to its size is AHB's own: AMBA AHB, IHI 0033C 3.6. It is stated under burst operation, and a single transfer is a burst of one beat. The bench's AHB checker, from the Protocols track, checks it as the rule align. Error answers: facts 27.6, 27.7.

The Lab: One Fault, Two Seats

The E9 fault bench used this stimulus, called turnaround. It is a write, a second write marked back to back, and a read of the first word. It ran it on the seat and, as the same rows, through the interpreter on the processor.

The turnaround rows (tools/soc/ap_soc/bench/faults/reference.mjs).
core w 80003004 8591bc43 ffffffff 00000000 0 1
core wq 80003000 31e02a79 ffffffff 00000000 0 1
core rq 80003004 00000000 ffffffff 8591bc43 0 1
The same three accesses, five runs
ChipSeatRowsVerdictCycles
goodbus managerback to backpass27
Q081bus managerback to backfail23
Q081bus managerwith idle cycles (w, w, r)pass27
goodprocessorinterpreterpass114
Q081processorinterpreterpass114

Q081 is one fault of the E9 set. Its SRAM wrapper drops the chip enable in the wait cycle of a deferred read. Fault release fault-36c8b1a3d6eb9bf8787a.

The bench's line on the faulty chip, from the seat's run.
BENCH 15: seat: read 80003004 = 00000000, expected 8591bc43 (mask ffffffff)

Read the table against the trace above. On the good chip, the SRAM holds hready low for one cycle after the back-to-back read, then answers. On Q081 it drops its enable in that cycle, and the read returns zero. The bench's row check catches it at once.

Space the same transfers apart and Q081 passes: the waiting path never runs. Run them through the interpreter and Q081 passes too, because instructions sit between every two transfers. That is rule 6 in one table: only the seat sees this bug.

The seat's run cost 27 cycles; the interpreter's, 114. And Q081 is not alone. Of the 130 seeded faults in the chip's table, 8 were caught by the seat and not by firmware. Sort them by what the seat did:

The faults only the seat caught, by what the seat did
What the seat didFaultsFirmware run of the same rows
Back to back2Ran through the interpreter, and firmware passed
Several managers at once3Not run: the rows are for the seat only
An event checked at its exact cycle1Not run: the rows are for the seat only
Another kind of stimulus2Not run: the rows are for the seat only

Counted from docs/soc/fault-table.md when the page is built. A stimulus with a firmware cost in that file also ran through the interpreter.

Read the last column before you conclude. Only the back-to-back rows also ran through the interpreter, and there firmware truly missed the fault. The other rows were written for the seat alone, so firmware's dash there means "not run", not "cannot".

They still belong on the seat, for control. Seat rows can start a DMA copy and a stream of debug reads, then queue their own reads beside them. That puts three managers on the fabric in the same cycles, in every run (rule 2). A program can start the DMA too. But the core spaces its own loads, so the collisions land wherever the compiler puts them. And a seat row can sit at an exact cycle. Then a check can ask whether an event came on time, not only whether it came.

Two more checks belong on the seat. The first is illegal on purpose: a word read at an address that is not a multiple of 4. AHB forbids it: every transfer must be aligned to its size.

A misaligned word read from the seat: the AHB checker must fire (rule 5).
core r 80003002 00000000 00000000 00000000 0 1
RULE align broken at edge 28: a 4-byte transfer at 0x80003002 is not aligned to its size
RULE align broken at edge 28: a 4-byte transfer at 0x80003002 is not aligned to its size
verdict=fail reason=checker ahb_rules_broken=2

The checker fired, so the run ends as a checker error. In a test of the checker, that failure is the pass: a checker that stayed silent here would be blind.

An error made on purpose. A DMA job from an address in no region must end in FAULT, and then the chip must still answer (rule 4).
dma copy 40000000 80003100 00000004 00000004 0 1
core w 10006014 00000006 ffffffff 00000000 0 1
core r 10004000 00000000 ffffffff 2a5310c5 0 1
verdict=pass cycles=48

Why It Is Built This Way

Why does the seat have a back-to-back row at all, if the core never makes one? Because the core is not the only manager. The DMA and the debug module share the fabric, and AHB-Lite allows a manager to pipeline transfers. A memory wrapper, an arbiter and a bridge must work for every legal manager, and for all of them at once. The polite one is not enough.

Why test the checker with an illegal transfer? Because a checker is code, and code can be wrong in the quiet way: never firing. One illegal transfer per rule, on purpose, shows each rule can fire.

Traps

The "firmware passed" trap is the story of the lab. A memory wrapper with a bug on its waiting path passes every firmware test on this chip. The regression shows green, and the bug waits for the first DMA or debugger that pipelines.

The lost-test trap: the team fixes the wrapper, then deletes the seat test as "something the core does not do". The bug comes back in the next revision, and no firmware test notices. Rule 6 exists for this.

The one-manager trap: every seat test runs alone on a quiet fabric. Each block passes, and an arbiter that loses a manager under load never shows. Keep some rows that run the DMA and the debug port beside the seat.

The stuck-error trap: a test sends an access that must fail, checks the error and stops. It never checks the chip afterwards. A fabric that locks up after an error passes that test. Always make one ordinary access after the error, as the last row of the lab does.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has four managers on one AHB-Lite fabric.

  1. Outstanding transfers

    On AXI, managers issue many transfers before the first answers, out of order, with IDs. Interconnect tests drive those patterns from verification agents, because no core's code can.

  2. Error injection

    Large chips add ways to inject errors on purpose: bad parity, a slave error, a timeout. Each injection needs its recovery check.

  3. Checker self-tests

    Teams keep a set of illegal stimuli per protocol checker and run it whenever the checker changes.

Try It

Run it: the read comes straight after the write and returns the old output register.

Leave one idle cycle between them (the predict question below). What is the last line?

Which kind of test on ap_soc would leave that idle cycle every time?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: read after a write, 0 idle cycles between: 00000000 the read is WRONG

Check Yourself

Predict the outputNow one idle cycle sits between the write and the read. What is the last line printed?
// A toy SRAM port. A read whose address phase sits on a write's data phase must wait one cycle, with the
// enable held. The bug drops the enable in that cycle, so the read returns the old output register.
// gap = 1: idle cycles between the write and the read.
module tb;
  bit [31:0] mem [4], out_q;
  bit late;
  task automatic cycle_write(input int a, input bit [31:0] d); mem[a] = d; endtask
  task automatic cycle_read(input int a, input bit deferred, output bit [31:0] r);
    if (deferred) begin late = 1; /* the bug: enable low while late */ end
    else out_q = mem[a];
    r = out_q;
    late = 0;
  endtask
  initial begin
    bit [31:0] r;
    mem[1] = 32'h8591_bc43; out_q = 32'h0;
    cycle_write(0, 32'h31e0_2a79);
    cycle_read(1, 1 == 0, r);
    $display("read after a write, %0d idle cycles between: %h", 1, r);
    if (r == 32'h8591_bc43) $display("the read is right");
    else $display("the read is WRONG");
  end
endmodule
ConceptWhy did Q081 pass every run through the processor's interpreter?
ConceptWhat makes a transfer back to back?
ConceptIn the lab, why was the misaligned read's failing verdict the right result?
ConceptWhat must follow an error made on purpose?

Common Mistakes

Wrong Trust a memory because every firmware test passed.

Firmware never makes back-to-back transfers, so the waiting path is never run.

Fix Add back-to-back pairs from the seat for every memory and bridge.

Wrong Send an access that must fail and end the test there.

A chip that hangs after the error passes.

Fix Make an ordinary access after every error made on purpose.

Wrong Delete a seat-only test because the core cannot make its stimulus.

Nothing else will catch the bug when it returns.

Fix Keep it in the seat's regression and say why in its name.

Remember

  • Firmware gets the compiler's order, size and spacing; the seat gets exactly what each row says.
  • One E9 fault passed every firmware run and failed the seat's back-to-back rows.
  • Other faults only the seat caught came from several managers at once, or from a check at an exact cycle.
  • Errors and illegal transfers on purpose test the error paths and the checkers.
  • A seat-only finding must stay in the seat's regression.

Practice

Report a problem with this page