Choosing the Mode
Read the fault table of ap_soc by mode, and the measured cost of each mode. Then build the rule a team uses for each new check. The choices are the core, the seat, the model or a proof.
You Will Be Able To
- Read a fault table by column, and say what a dash does and does not mean.
- Compare the cost of one test written both ways, from recorded runs.
- Choose the mode for a new check, and give the reason.
- Name the faults no seat can catch, and what catches them.
- Lesson
- V6.7
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
Stage E9 seeded faults into ap_soc, one at a time, and later stages added more: 130 in all so far. Each ran against reference tests in both seats, with passive checkers, a model and a proof beside them. The table they left says, fault by fault, which kind of test saw it.
| Block | Faults | Firmware | Bus manager | Passive checker | Model compare | Formal | Caught by |
|---|---|---|---|---|---|---|---|
| Core | 6 | 0 | 0 | 0 | 6 | 0 | model only |
| Matrix | 10 | 3 | 5 | 7 | 0 | 0 | both 3, seat only 2, passive only 5 |
| AHB/APB bridge | 6 | 4 | 6 | 1 | 0 | 0 | both 4, seat only 2 |
| Slow APB crossing | 6 | 6 | 6 | 2 | 0 | 0 | both seats |
| PLIC | 8 | 8 | 4 | 0 | 0 | 0 | both 4, firmware only 4 |
| CLINT | 2 | 2 | 2 | 0 | 0 | 0 | both seats |
| UART | 9 | 9 | 9 | 4 | 0 | 0 | both seats |
| GPIO | 4 | 4 | 4 | 0 | 0 | 0 | both seats |
| Timer/PWM | 6 | 5 | 6 | 4 | 0 | 0 | both 5, seat only 1 |
| SPI | 4 | 4 | 4 | 3 | 0 | 0 | both seats |
| DMA | 5 | 5 | 5 | 4 | 0 | 0 | both seats |
| Sysctl | 5 | 5 | 3 | 0 | 0 | 0 | both 3, firmware only 2 |
| Power/isolation | 5 | 5 | 0 | 0 | 0 | 0 | firmware only |
| CRG/reset | 8 | 7 | 0 | 2 | 0 | 1 | firmware only 7, passive only 1 |
| Pin mux/pads | 7 | 6 | 7 | 2 | 0 | 6 | both 6, seat only 1 |
| Debug/TAP | 6 | 6 | 6 | 0 | 0 | 0 | both seats |
| Generated IRQ | 7 | 7 | 7 | 0 | 0 | 7 | both seats |
| Generated connect | 5 | 5 | 1 | 0 | 0 | 5 | both 1, firmware only 4 |
| SRAM | 3 | 1 | 3 | 0 | 0 | 0 | both 1, seat only 2 |
| APB guard | 1 | 1 | 0 | 1 | 0 | 0 | firmware only |
| Core boundary | 4 | 4 | 0 | 0 | 0 | 3 | firmware only |
| Always-on APB | 2 | 0 | 0 | 2 | 0 | 0 | passive only |
| Core trace | 2 | 0 | 0 | 0 | 2 | 0 | model only |
| Clock gates | 1 | 1 | 1 | 0 | 0 | 0 | both seats |
| Matrix decoder | 1 | 1 | 1 | 0 | 0 | 0 | both seats |
| Default subordinate | 1 | 1 | 0 | 0 | 0 | 0 | firmware only |
| GPIO reset | 1 | 1 | 0 | 0 | 0 | 0 | firmware only |
| Core clock | 1 | 0 | 0 | 1 | 0 | 0 | passive only |
| Boot strap | 2 | 2 | 0 | 0 | 0 | 1 | firmware only |
| Boot ROM | 1 | 1 | 0 | 0 | 0 | 0 | firmware only |
| GPIO pads | 1 | 1 | 1 | 0 | 0 | 1 | both seats |
Counts of the 130 seeded faults by block. Stage E9 seeded most, and later stages added more, such as four PLIC faults at stage E17. From docs/soc/fault-table.md (npm run check:soc-faults), counted when this page is built. A count means demonstrated catches with that column's reference stimulus. Columns overlap. "Caught by" sorts each block's faults: by both seats or by one seat only. Faults no seat caught show as passive only or model only.
Before You Start
Read What Firmware Can Never Do and One Bench, Two Modes first.
| Question | |
|---|---|
| 1 | What does each column of the fault table count? |
| 2 | Which faults did only firmware catch, and why? |
| 3 | Which faults did neither seat catch, and what did? |
| 4 | What does the same test cost in each mode? |
| 5 | How do you choose the mode for a new check? |
The Idea: The Need Picks the Mode
No mode is best. Firmware runs the real core, so it alone tests what software relies on. The seat makes exact transfers fast, so it tests registers, maps and buses cheaply. Neither sees a wrong result that still reaches the pass word: that needs a reference model. And neither sees a fault that leaves every read right, such as a bus bit that no register keeps. Only a checker watching the bus does.
So a team does not pick one mode for the project. It picks one per check, from two questions. What must happen for the bug to show? And which mode makes that happen at the lowest cost?
- Test
- Manager
- Processor
- Model
- Debug
- Analysis
- Most faults need only a transfer
73 of 130 were caught by both seats. For them the cheaper seat wins.
- Some need the core
32 were caught by firmware only. Their stimulus was a program on the core: an interrupt handler, a reset, a power sequence.
- Some need the seat
Eight were caught by the seat only. Their stimuli were timings and traffic the core never makes on demand, such as the back-to-back read of the last lesson.
- Some need a reference
Eight faults let the program reach its pass word. Six made the ALU compute a wrong value, and two broke the retire record itself. Only the retire compare with the model saw them.
- Some only a passive checker sees
Nine faults left every read right. No test read a wrong value. Only a checker watching a bus, the fabric or the reset lines saw them.
- Checkers and proofs add more
Passive checkers caught 33 in whichever mode ran, and the wiring proof 24.
Read the diagram as text
- 130 seeded faults: stage E9 and later
- 73 by both seats: choose the cheaper
- 32 by firmware only: interrupts, reset, power
- 8 by the seat only: timing and traffic the core never makes
- 8 by the model compare only: wrong values, wrong records
- 9 by a passive checker only: every read was right
- passive 33, formal 24: on top, in any mode
- 130 seeded faults → 73 by both seats: either
- 130 seeded faults → 32 by firmware only: needs the core
- 130 seeded faults → 8 by the seat only: needs the seat
- 73 by both seats → 8 by the model compare only: reaches pass anyway
- 32 by firmware only → 9 by a passive checker only: no test reads it
- 73 by both seats → passive 33, formal 24: also seen by
The columns of docs/soc/fault-table.md, counted. Plan §3.9 item 9 asks for this table.
New Words
| Word | Meaning |
|---|---|
| Fault table | For each seeded fault, which kinds of test caught it: docs/soc/fault-table.md. |
| Demonstrated catch | A mark in the table: a reference test of that kind failed on the faulty chip. |
| Paired stimulus | One list of rows run in both seats, so its two costs can be compared. |
| Model compare | The retire trace of the core checked record by record against the instruction-level model. |
| Cost of a mode | The cycles a check takes in it, plus what it takes to write: a compile, a boot, a model. |
The Smallest Example: The Cheapest Suite
Five stimuli of the table, with how their faults were caught and their recorded costs. For each, take the cheapest mode that catches it.
| Stimulus | Caught by | Firmware cycles | Seat cycles | Choose |
|---|---|---|---|---|
| lanes | both seats | 191 | 33 | seat, 33 |
| jtag | both seats | 2110 | 2036 | seat, 2036 |
| turnaround | seat only | 114 | 27 | seat, 27 |
| irq | firmware only | 323 | no seat form | firmware, 323 |
| alu | neither seat | the model compare |
Cycles from docs/soc/fault-table.md; the irq program's cycles recorded by record-v6-labs.mjs. The example below adds them up.
The Rules
Rule 1: If the bug needs an instruction, use firmware.
Handlers, traps, start-up code, reset and power sequences run by software.
Rule 2: If the bug needs exact or illegal stimulus, use the seat.
Back to back, an exact cycle, several managers at once, exact sizes and lanes, errors and illegal transfers on purpose.
Rule 3: If either seat can catch it, choose the cheaper one.
Usually the seat: no compile, no boot, no interpreter.
Rule 4: If a wrong result can still reach the pass word, use a reference.
The model compare sees what self-checking code and the seat cannot.
Rule 5: Keep the passive checkers on in every mode.
They catch what the test never looked for, whichever seat is driving. Some faults leave every read right and show nowhere else.
Rule 6: Prove the wiring.
A connectivity proof catches a crossed wire with no test at all.
Rule 7: Read a dash as "not shown", never as "cannot".
A dash means no reference test of that kind caught it. Another test might.
Sources for These Rules
The table, its columns and its paired costs: docs/soc/fault-table.md, generated by npm run check:soc-faults. Plan §3.10: stage E9 and the later stages that added faults.
The three modes and when each is used: plan §2.2. Replacing the core with a bus agent for hardware checks, and keeping it for boot: MEHTA-DV 16.4.
The model compare: facts 27.12 ("The model compare"); module V5.
The Lab: The Table by Column
Read the table above column by column. Firmware caught 105 of 130; the bus manager 81. They overlap: 73 were caught by both. So for most faults the question is not which mode can, but which mode is cheaper (rule 3).
Then the rows where the seat column is empty. In the Power/isolation, CRG/reset and APB guard rows, every seat count is 0. Their firmware marks came from power sequences, resets and a stopped block's clock, run as programs on the processor. That is rule 1.
The Core boundary row reads the same way. Its 4 faults sit on the wires at the core's edge, and their reference stimuli were programs that the core ran. With the seat in the core's place, nothing drove those wires the way the core does. Rule 7 still holds: no seat stimulus was written for them.
The PLIC row shows rule 7. At stage E9 its four faults ran only under an interrupt program, so the seat column was all dashes. The first lesson of this module claimed a PLIC interrupt from the seat, so a seat test was possible. At stage E17 a new stimulus raised competing requests from the seat. It caught all four new PLIC faults in both seats, at 417 cycles through the interpreter and 66 on the seat. The old dashes meant "not shown", never "cannot".
The Core row is the opposite: no seat caught its 6 faults. Each made the ALU compute a wrong value, yet the program still reached its pass word. Only the retire compare with the model saw them (rule 4).
The Core trace row is stranger. Its 2 faults left the core computing right and broke only the record it reports. No program reads that record, so no test could fail. The model compare reads every record, and saw each one.
The Always-on APB row has no seat mark and no model mark. Its 2 faults changed what a write carried on the always-on bus, in bits the target register has no field for. Every read gave the right value. Only the passive checker on that bus saw the change (rule 5). In all, nine faults were seen by a passive checker alone: rows Always-on APB, Matrix, CRG/reset and Core clock.
| Stimulus | Firmware cycles | Seat cycles | Ratio |
|---|---|---|---|
| lanes | 191 | 33 | 5.8× |
| device | 125 | 30 | 4.2× |
| msip | 122 | 27 | 4.5× |
| gpio | 406 | 61 | 6.7× |
| uart | 260 | 116 | 2.2× |
| spi | 461 | 297 | 1.6× |
| dma | 221 | 55 | 4.0× |
| fields | 221 | 42 | 5.3× |
| sweep | 10,254 | 1,193 | 8.6× |
| jtag | 2,110 | 2,036 | 1.0× |
| turnaround | 114 | 27 | 4.2× |
From docs/soc/fault-table.md: cycles of the bench result block on the good chip, model compare off. Firmware runs the rows through the ROM interpreter.
The ratio is widest where firmware has most rows to interpret: the sweep, at 8.6 times. It is near 1 for jtag, because JTAG scans run at the pad clock in either seat. There the choice of seat hardly matters.
One test written both ways makes the cost concrete. The DMA test of the last lesson ran in three forms:
| Form | Written as | Needs | Cycles | Instructions retired |
|---|---|---|---|---|
| Firmware | 40 lines of C | a cross-compile, a back-door load, a boot | 486 | 244 |
| C on the host | the same file | a host compile | 162 | 0 |
| Sequence table | 9 rows | nothing | 144 | 0 |
Recorded by record-v6-labs.mjs (section layers) on Verilator 5.052 2026-09-05; firmware built with riscv64-unknown-elf-gcc 14.2.0.
All three moved the same 12 bytes and saw the same FAULT. The firmware form took 3 times the cycles of the host form, and was the only one that also ran start-up code. If the check is the DMA, the table is the right form. If the check is "the DMA driver works under our start-up code", only firmware will do.
Why It Is Built This Way
Why build the fault table at all? Because "both modes are useful" is an opinion, and a table of demonstrated catches is evidence. It shows a team where each mode earns its cost, on its own chip, before it plans the next one.
Why keep columns that overlap? Because the overlap is the point. A fault caught by both seats lets you drop the costlier test. A fault caught by one seat shows a test you must never drop.
Traps
The dash trap: reading a dash in the seat column as "the seat cannot test this". At stage E9 every PLIC fault had that dash, until a seat stimulus caught four new ones. Rule 7 keeps the table honest.
The single-mode trap: a plan that says "all tests in firmware, for realism". It pays the interpreter's cost on every register, and it never makes the stimulus of the eight faults only the seat caught. The opposite plan, all on the seat, misses every fault of the firmware-only rows.
The pass-word trap: a suite that trusts self-checking code alone. Six faults of this chip made the ALU wrong and still printed pass. Two more broke the trace record. Without the model compare, all eight ship.
The quiet-bus trap: trusting that every bug ends in a wrong read. The two always-on bus faults never did, and neither did the other faults only a passive checker saw. Switch off the passive checkers to save time, and they ship too.
At Scale
This section looks ahead. ap_soc's table has 130 rows so far, and five columns.
Fault campaigns
Large teams seed faults into each release of the RTL and keep the table per mode. It proves the regression still catches what it used to.
Cost as wall time
At scale the cost is hours of simulation and of engineers. The same rule holds: the cheapest mode that catches the bug.
More columns
Emulation, virtual platforms and silicon add columns. Module V13 adds them for this chip.
Try It
Run it: the five stimuli, the seat that catches each, and the cheapest suite.
Make the firmware lanes run cost 20 cycles (the predict question below). What changes?
Why does alu add nothing to the total?
lanes: either seat; the bus manager is cheaper (33 < 191) jtag: either seat; the bus manager is cheaper (2036 < 2110) turnaround: only the bus manager (27) irq: only firmware (323) alu: neither seat: a model or a proof is needed cycles of the cheapest suite: 2419Check Yourself
Common Mistakes
Wrong Run every check in firmware, for realism.
Every register then pays for the interpreter, and the seat-only faults are never seen.
Fix Use firmware where an instruction is needed, the seat elsewhere.
Wrong Read a dash in the fault table as "this mode cannot catch it".
A dash means no reference test of that kind caught it.
Fix Ask whether a test of that kind was run before you decide.
Wrong Trust self-checking firmware to find core bugs.
A wrong ALU result can still reach the pass word.
Fix Keep the model compare on whenever the core runs.
Remember
- Of 130 seeded faults so far, 73 were caught by both seats and 32 by firmware only.
- Eight were caught by the seat only, and 17 by neither seat.
- The seat costs fewer cycles for the same rows; the gap is widest for long register lists.
- Wrong results that still pass need a model, and wiring needs a proof. A fault that leaves every read right needs a passive checker.
- Choose the mode per check, and read a dash as "not shown".