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.
- Cycle 0
The bench's own first word: TB_STATUS = 2, "main entered". Its APB data phase waits a cycle.
- Cycle 3
Row 1: a write of 8591_BC43 to SRAM 0x8000_3004, then one idle cycle, as single rows always have.
- Cycle 5
Row 2 (wq): a write to 0x8000_3000. Its data phase is next cycle, and the bus is not left idle.
- 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.
- 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.
| Question | |
|---|---|
| 1 | Which kinds of stimulus can firmware not make on demand? |
| 2 | What is a back-to-back pair, and why does the core never make one? |
| 3 | How did one seeded fault pass every firmware test? |
| 4 | What is an error made on purpose, and what must the test check after it? |
| 5 | Why 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.
- File
- Processor
- Test
- Manager
- Bus
- Result
- Control
- Data
- Transaction / TLM
- The firmware path
A compiler turns C into instructions, and the core spaces their transfers out.
- The seat path
Each row becomes one transfer, with the size, address and timing it names.
- 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
| Word | Meaning |
|---|---|
| Back to back | A transfer whose address phase sits on the data phase of the one before, with no idle cycle between. |
| Deferred read | A read that waits a cycle because the memory is still busy with the write before it. |
| Concurrent traffic | Transfers from several managers on one fabric in the same cycles, so they compete for it. |
| Error made on purpose | An access the test knows must fail, sent to check the error answer and the recovery after it. |
| Illegal transfer | A transfer the bus protocol forbids, such as a word at an address that is not a multiple of 4. |
| Seat-only finding | A 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.
| Idle cycles between write and read | The read waits? | Value read |
|---|---|---|
| 0 (back to back) | yes, with the enable dropped | the old output: wrong |
| 1 or more | no | the 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
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.
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.
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.
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.
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.
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.
core w 80003004 8591bc43 ffffffff 00000000 0 1
core wq 80003000 31e02a79 ffffffff 00000000 0 1
core rq 80003004 00000000 ffffffff 8591bc43 0 1| Chip | Seat | Rows | Verdict | Cycles |
|---|---|---|---|---|
| good | bus manager | back to back | pass | 27 |
| Q081 | bus manager | back to back | fail | 23 |
| Q081 | bus manager | with idle cycles (w, w, r) | pass | 27 |
| good | processor | interpreter | pass | 114 |
| Q081 | processor | interpreter | pass | 114 |
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.
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:
| What the seat did | Faults | Firmware run of the same rows |
|---|---|---|
| Back to back | 2 | Ran through the interpreter, and firmware passed |
| Several managers at once | 3 | Not run: the rows are for the seat only |
| An event checked at its exact cycle | 1 | Not run: the rows are for the seat only |
| Another kind of stimulus | 2 | Not 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.
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=2The 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.
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=48Why 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
This section looks ahead. ap_soc has four managers on one AHB-Lite fabric.
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.
Error injection
Large chips add ways to inject errors on purpose: bad parity, a slave error, a timeout. Each injection needs its recovery check.
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?
read after a write, 0 idle cycles between: 00000000 the read is WRONGCheck Yourself
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.