One Bench, Two Modes
soc_tb can put the processor in the core's seat, or a bus manager the bench drives. Learn what one switch changes and what it leaves alone. Then run the same rows both ways: the same bytes on the pads, at a different cost.
You Will Be Able To
- Say what +core=cpu and +core=bfm put in the seat, and what each mode can and cannot check.
- List what stays the same in both modes.
- Compare the cost of one row list in both modes from a recorded run.
- Choose the mode for a new chip test.
- Lesson
- V3.8
- Time
- 22 min
- Runs on
- Your browser
- Check
- 5 questions
Picture a project where the core is late. The chip's peripherals, its fabric and its pads are ready, and the tests are waiting. Flip one switch and the bench can test all of it today, with the core's seat filled by a bus manager.
- Control / FSM
- Processor
- Manager
- Bus
- Peripheral
- Test
- Control
- Data
- With the processor
ap_rv32 runs a firmware image; its retire trace is compared with ap_iss.
- With the seat
The processor is held in reset; a bus manager takes its data port, and the instruction port idles.
- What stays
The fabric, every block, the pads and their models, every checker, the end-of-test rules.
Read the diagram as text
- +core=: cpu or bfm
- ap_rv32: runs the firmware image
- Bus-manager seat: runs a table, host C or UVM
- Data port: the same AHB-Lite port
- The rest of ap_soc: unchanged
- Pads, checkers, end rules: unchanged
- +core= → ap_rv32: cpu
- +core= → Bus-manager seat: bfm
- ap_rv32 → Data port: loads, stores
- Bus-manager seat → Data port: transfers
- Data port → The rest of ap_soc: the fabric
ap_core_slot, simulation view (tools/soc/ap_soc/bench/ap_core_slot.sv); plan §3.6.
Before You Start
Read Ending a Test Honestly and Three Ways to Drive a Chip first.
| Question | |
|---|---|
| 1 | What does each mode put in the core's seat? |
| 2 | What stays exactly the same? |
| 3 | What can only one of the two modes check? |
| 4 | What does the same row list cost in each mode? |
| 5 | When should a test use the seat? |
The Idea: One Bench, Two Drivers of the Bus
A chip test needs something to make bus transfers. With the processor, that is firmware: real, slow to write, and dependent on a working core. With a bus manager, it is the bench: fast and exact. It can do things software never does, like two transfers back to back.
soc_tb keeps both behind one switch, so a test can move between them without a new bench. The seat has the core's exact ports. Nothing else in the bench knows which one is there.
New Words
| Word | Meaning |
|---|---|
| Bus manager | A component that starts bus transfers; here the seat, driven by the bench. |
| +core=cpu / +core=bfm | The plusarg that puts the processor or the bus manager in the seat. |
| Row list | A list of rows (write, read, poll, bench actions) that soc-rows.mjs can run in either mode. |
| Interpreter | A small ROM program that reads row entries from SRAM and makes their transfers on the processor. |
| Hand-shake | An event (TB_EVENT) and an answer (TB_ARG) that pass the turn between firmware and bench. |
The Smallest Example: Same Rows, Two Costs
Three rows each write one byte. The seat makes each write in 2 cycles. An interpreter on the processor first fetches and decodes the row, say 6 cycles, then makes the same write. Work out the cost.
| Mode | Cycles a row | Cycles for 3 rows | Writes on the bus |
|---|---|---|---|
| Seat | 2 | 6 | 4F, 4B, 0A |
| Processor | 6 + 2 | 24 | 4F, 4B, 0A |
Toy numbers of the example below, not measured costs of ap_soc.
The Rules
Rule 1: The switch changes the seat and nothing else.
The fabric, the blocks, the pads, the models, the checkers and the end-of-test rules are the same code in both modes.
Rule 2: With the processor, firmware is the test and the model compare checks the core.
The retire trace is compared with ap_iss, record by record.
Rule 3: With the seat, the bench is the test and there is no core to check.
The register and end-to-end checks carry everything; the instruction port idles.
Rule 4: The end of a test means the same in both.
A table writes TB_STATUS = 2 before its first row and the pass or fail word after its last, as firmware does.
Rule 5: No progress means a different thing.
With the processor, nothing retired; with the seat, no transfer of any manager.
Sources for These Rules
The switch: tools/soc/ap_soc/bench/ap_core_slot.sv; plan §3.6; facts 27.12, "The two modes and the three front ends".
The row lists and their two forms: tools/soc/ap_soc/bench/soc_tb/soc-rows.mjs and bench-cases.mjs.
The end of a table and no progress with the seat: README, "The end of a test" and "The sequence table".
The Lab: Three Lists, Two Modes
initial if ($value$plusargs("core=%s", mode)) use_bfm = (mode == "bfm");
...
assign i_htrans = use_bfm ? 2'b00 : c_i_htrans;
...
assign d_haddr = use_bfm ? b_d_haddr : c_d_haddr;
assign d_htrans = use_bfm ? b_d_htrans : c_d_htrans;Rule 1 at work: the switch is a few multiplexers on the core's ports. With +core=bfm the processor is also held in reset.
core w 10004010 00000aaa ffffffff 00000000 0 1
core w 10000010 00000004 ffffffff 00000000 0 1
core w 10000000 0000004f ffffffff 00000000 0 1
tb uart_expect 00000000 00000000 ffffffff 0000004f 0 1
core w 10000000 0000004b ffffffff 00000000 0 1
tb uart_expect 00000000 00000000 ffffffff 0000004b 0 1
tb uart_send 00000000 00000037 ffffffff 00000000 0 1
core poll 10000004 00000000 00000002 00000002 0 1
core r 1000000c 00000000 000000ff 00000037 0 1
core r 10000004 00000000 00000002 00000000 0 1With the seat these rows are the table. With the processor, soc-rows.mjs turns the core rows into entries in SRAM for an interpreter in ROM. The tb rows stay on the bench's side, with a hand-shake wherever the turn changes.
uart +core=cpu: cycles=370 retired=270 compares=270 uart_bytes=2 uart_hash=85e4b82f spi_frames=0
uart +core=bfm: cycles=163 retired=0 compares=0 uart_bytes=2 uart_hash=85e4b82f spi_frames=0
gpio +core=cpu: cycles=580 retired=428 compares=428 uart_bytes=0 uart_hash=811c9dc5 spi_frames=0
gpio +core=bfm: cycles=74 retired=0 compares=0 uart_bytes=0 uart_hash=811c9dc5 spi_frames=0
spi +core=cpu: cycles=1058 retired=750 compares=750 uart_bytes=0 uart_hash=811c9dc5 spi_frames=5
spi +core=bfm: cycles=708 retired=0 compares=0 uart_bytes=0 uart_hash=811c9dc5 spi_frames=5The bytes on the UART pad are the same in both modes: uart_hash 85e4b82f. The SPI frames are the same: 5. The cost is not. The uart list took 370 cycles with the processor and 163 with the seat. With the processor, 270 records were compared with the model. With the seat nothing retired, so by rule 3 there was nothing to compare.
The gap is widest where firmware has most to do. The gpio list took 580 cycles with the processor and 74 with the seat. The spi list waits on the flash in both modes, so the gap is smaller: 1058 against 708.
Why It Is Built This Way
Why not two benches, one per mode? Because two benches drift apart. A pad model fixed in one and not the other gives two answers for the same chip. One bench with a switch has one set of models, one set of checkers and one set of end rules.
Why keep firmware tests at all, when the seat is faster? Because only firmware tests the core, the start-up code, the interrupt entry and how software and hardware agree. The seat tests the chip around the core. A chip needs both.
Traps
The first trap is a test that only works in one mode by accident. A table that puts two transfers back to back passes on the seat. The processor never issues that pattern, so the same rows prove less in firmware. Know which mode a check belongs to.
The second trap is reading cycles across modes. A list that takes 163 cycles on the seat and 370 with the processor is not "twice as slow hardware". The difference is the interpreter and its hand-shakes. Compare what the chip did, never the cycle counts of two modes.
At Scale
This section looks ahead. ap_soc has one core and one seat.
Many cores, many seats
A multi-core SoC can replace any core, or all of them, with a bus manager. That stresses the interconnect harder than software can.
Without-CPU verification
Module V6 builds whole test plans on the seat: register sweeps, concurrency, error paths.
Host C
The same hal.h test can run on the processor or on the host through the seat. Module V13 uses that for fast platforms.
Try It
Run it: the same three rows, once by a seat and once by a toy interpreter.
Change the interpreter's fetch cost to 10 cycles (the predict question below). What changes and what does not?
Why does the line about the writes never change?
seat: 6 cycles, processor: 24 cycles same writes in both modes: yesCheck Yourself
Common Mistakes
Wrong Build a second bench for tests without the core.
Its models and checkers drift away from the first bench's.
Fix Keep one bench; switch the seat with +core.
Wrong Compare cycle counts between the two modes.
The processor pays for the interpreter and its hand-shakes.
Fix Compare what the chip did: bytes, frames, status.
Wrong Drop firmware tests once the seat is available.
Only firmware tests the core and how software and hardware agree.
Fix Use the seat for the chip around the core, firmware for the rest.
Remember
- +core=cpu puts ap_rv32 in the seat; +core=bfm a bus manager on the same data port.
- Everything else stays: fabric, blocks, pads, models, checkers, end rules.
- The same rows give the same bytes in both modes, at a different cost.
- Firmware checks the core and the software; the seat checks the chip around it.