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.

The Fault Table, Coloured by Mode
BlockFaultsFirmwareBus managerPassive checkerModel compareFormalCaught by
Core600060model only
Matrix1035700both 3, seat only 2, passive only 5
AHB/APB bridge646100both 4, seat only 2
Slow APB crossing666200both seats
PLIC884000both 4, firmware only 4
CLINT222000both seats
UART999400both seats
GPIO444000both seats
Timer/PWM656400both 5, seat only 1
SPI444300both seats
DMA555400both seats
Sysctl553000both 3, firmware only 2
Power/isolation550000firmware only
CRG/reset870201firmware only 7, passive only 1
Pin mux/pads767206both 6, seat only 1
Debug/TAP666000both seats
Generated IRQ777007both seats
Generated connect551005both 1, firmware only 4
SRAM313000both 1, seat only 2
APB guard110100firmware only
Core boundary440003firmware only
Always-on APB200200passive only
Core trace200020model only
Clock gates111000both seats
Matrix decoder111000both seats
Default subordinate110000firmware only
GPIO reset110000firmware only
Core clock100100passive only
Boot strap220001firmware only
Boot ROM110000firmware only
GPIO pads111001both 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.

Five questions this page answers
Question
1What does each column of the fault table count?
2Which faults did only firmware catch, and why?
3Which faults did neither seat catch, and what did?
4What does the same test cost in each mode?
5How 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?

Who Caught What130 faults. Firmware caught 105, the bus manager 81, both 73. 17 were caught by neither seat: 8 by the model compare alone, 9 by a passive checker alone.
  • Test
  • Manager
  • Processor
  • Model
  • Debug
  • Analysis
Who Caught What130 faults. Firmware caught 105, the bus manager 81, both 73. 17 were caught by neither seat: 8 by the model compare alone, 9 by a passive checker alone. test 130 seededfaults stage E9 and later manager 73 by both seats choose the cheaper processor 32 by firmwareonly interrupts, reset,power manager 8 by the seat only timing and traffic thecore never makes model 8 by the modelcompare only wrong values, wrongrecords debug 9 by a passivechecker only every read was right debug passive 33,formal 24 on top, in any mode eitherneeds the coreneeds the seatreaches pass anywayno test reads italso seen by
  1. test 130 seeded faultsstage E9 and later
    • either → 73 by both seats
    • needs the core → 32 by firmware only
    • needs the seat → 8 by the seat only
  2. manager 73 by both seatschoose the cheaper
    • reaches pass anyway → 8 by the model compare only
    • also seen by → passive 33, formal 24
  3. processor 32 by firmware onlyinterrupts, reset, power
    • no test reads it → 9 by a passive checker only
  4. manager 8 by the seat onlytiming and traffic the core never makes
  5. model 8 by the model compare onlywrong values, wrong records
  6. debug 9 by a passive checker onlyevery read was right
  7. debug passive 33, formal 24on top, in any mode
  1. Most faults need only a transfer

    73 of 130 were caught by both seats. For them the cheaper seat wins.

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

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

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

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

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

New words on this page
WordMeaning
Fault tableFor each seeded fault, which kinds of test caught it: docs/soc/fault-table.md.
Demonstrated catchA mark in the table: a reference test of that kind failed on the faulty chip.
Paired stimulusOne list of rows run in both seats, so its two costs can be compared.
Model compareThe retire trace of the core checked record by record against the instruction-level model.
Cost of a modeThe 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.

Five stimuli, by hand
StimulusCaught byFirmware cyclesSeat cyclesChoose
lanesboth seats19133seat, 33
jtagboth seats21102036seat, 2036
turnaroundseat only11427seat, 27
irqfirmware only323no seat formfirmware, 323
aluneither seatthe 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

  1. Rule 1: If the bug needs an instruction, use firmware.

    Handlers, traps, start-up code, reset and power sequences run by software.

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

  3. Rule 3: If either seat can catch it, choose the cheaper one.

    Usually the seat: no compile, no boot, no interpreter.

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

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

  6. Rule 6: Prove the wiring.

    A connectivity proof catches a crossed wire with no test at all.

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

Paired stimuli: the same rows in both seats
StimulusFirmware cyclesSeat cyclesRatio
lanes191335.8×
device125304.2×
msip122274.5×
gpio406616.7×
uart2601162.2×
spi4612971.6×
dma221554.0×
fields221425.3×
sweep10,2541,1938.6×
jtag2,1102,0361.0×
turnaround114274.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:

One DMA test, three forms
FormWritten asNeedsCyclesInstructions retired
Firmware40 lines of Ca cross-compile, a back-door load, a boot486244
C on the hostthe same filea host compile1620
Sequence table9 rowsnothing1440

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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc's table has 130 rows so far, and five columns.

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

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

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

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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: 2419

Check Yourself

Predict the outputThe firmware lanes run now costs 20 cycles. What is the last line printed?
// 5 kinds of fault from the E9 qualification table, by the seats that caught them
// (bit 0 firmware, bit 1 bus manager). Cost: cycles of the recorded paired runs.
module tb;
  localparam int N = 5;
  string kind [N];
  bit [1:0] caught [N];
  int cost_fw [N], cost_bm [N];
  int total = 0;
  initial begin
    kind[0] = "lanes"; caught[0] = 2'b11; cost_fw[0] = 20; cost_bm[0] = 33;
    kind[1] = "jtag"; caught[1] = 2'b11; cost_fw[1] = 2110; cost_bm[1] = 2036;
    kind[2] = "turnaround"; caught[2] = 2'b10; cost_fw[2] = 114; cost_bm[2] = 27;
    kind[3] = "irq"; caught[3] = 2'b01; cost_fw[3] = 323; cost_bm[3] = 0;
    kind[4] = "alu"; caught[4] = 2'b00; cost_fw[4] = 0; cost_bm[4] = 0;
    for (int i = 0; i < N; i++) begin
      if (caught[i] == 2'b11) begin
        if (cost_bm[i] <= cost_fw[i]) begin $display("%s: either seat; the bus manager is cheaper (%0d < %0d)", kind[i], cost_bm[i], cost_fw[i]); total += cost_bm[i]; end
        else begin $display("%s: either seat; firmware is cheaper (%0d < %0d)", kind[i], cost_fw[i], cost_bm[i]); total += cost_fw[i]; end
      end
      else if (caught[i] == 2'b01) begin $display("%s: only firmware (%0d)", kind[i], cost_fw[i]); total += cost_fw[i]; end
      else if (caught[i] == 2'b10) begin $display("%s: only the bus manager (%0d)", kind[i], cost_bm[i]); total += cost_bm[i]; end
      else $display("%s: neither seat: a model or a proof is needed", kind[i]);
    end
    $display("cycles of the cheapest suite: %0d", total);
  end
endmodule
ConceptWhich faults did neither seat catch on ap_soc, and what caught them?
ConceptWhy do four PLIC faults have no bus-manager mark?
ConceptWhy is the jtag ratio near 1?
ConceptA new check must show that a DMA job into a hole ends in FAULT. Which mode?

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

Practice

Report a problem with this page