The Fabric as the Thing Under Test
Every block of ap_soc can pass its own bench while the wires between them are wrong. This module tests those wires: the decoders, the matrix, the bridges. Start by reading the memory map as a list of routes, each one a test.
You Will Be Able To
- Say what counts as the fabric of a chip and why it needs tests of its own.
- Read a memory map as a route matrix: every legal route and every illegal one.
- Prove a route with a value only its target gives back, not with an OKAY.
- Read the cost of each kind of answer from a recorded run of the seat.
- Lesson
- V7.1
- Time
- 24 min
- Runs on
- Your browser
- Check
- 5 questions
At stage E3 of ap_soc, a seeded fault made one window of the decoder too small. Tests that touched the bottom of every window passed. Only a test that reached the top of every window found it.
| Manager \ target | Boot ROM | ap_clint | ap_plic | Bridge (APB) | SRAM | Default (ERROR) |
|---|---|---|---|---|---|---|
| 0 debug | read, write | read, write | read, write | read, write | read, write | its own |
| 1 DMA | read, write | read, write | read, write | read, write | read, write | its own |
| 2 core data | read, write | read, write | read, write | read, write | read, write | its own |
| 3 core instruction | fetch only | fetch only | fetch only | fetch only | fetch only | its own |
Four managers down, five targets and the default subordinate across. That makes 24 cells, each a route to get right. Each manager has a default subordinate of its own (facts 27.7). Every APB block sits behind the one bridge column.
Before You Start
Read Taking the Core Out, Many Managers: Arbitration and the Bus Matrix and The Default Subordinate and the Two-Cycle Error first.
| Question | |
|---|---|
| 1 | What is the fabric of a chip, and why does it need tests of its own? |
| 2 | How does a memory map become a list of routes? |
| 3 | Why is an OKAY answer not proof that a route works? |
| 4 | What does each kind of answer cost on ap_soc? |
| 5 | Which addresses must a route test always visit? |
The Idea: The Wires Between the Blocks
A UART bench proves the UART. A SRAM bench proves the SRAM. Neither proves that an address leaving the DMA reaches the UART and not the SRAM. Neither proves that a second manager can use the SRAM at the same time. That is the fabric's job, and nobody else tests it.
The fabric is everything between the managers and the targets. On ap_soc it is the decoders, the matrix and a default subordinate per manager. It is also the AHB-to-APB bridge, two APB multiplexors and the asynchronous bridge. In this module the fabric is the design under test, and the blocks around it are only endpoints.
A fabric fails in its own ways. An address goes to the wrong target, or a hole answers OKAY. A bridge loses a byte lane. Two managers collide and one is lost or starved. A transfer waits for ever. The seven lessons of this module take these one by one.
- Manager
- Control / FSM
- Bus
- Result
- Memory
- Peripheral
- Control
- Data
- Decode
Each manager's address picks one target, or none. The decoders are generated from the map.
- Arbitrate and route
The matrix gives each target to one manager at a time and steers the transfer there.
- Refuse
An address nobody owns goes to that manager's own default subordinate, which answers ERROR.
- Convert and cross
The bridge turns AHB into APB; the asynchronous bridge carries APB to a slower, unrelated clock.
Read the diagram as text
- Four managers: debug, DMA, core data, core instruction
- Decoders: generated from map.json
- Matrix: one arbiter per target
- Default subordinates: ERROR for holes
- ROM, ap_clint, ap_plic, SRAM: AHB targets
- AHB-to-APB bridge: setup, access
- Fast APB blocks: UART0, GPIO, ... DMA registers
- Asynchronous bridge: to the watchdog and ap_pwrctl on clk_aon
- Four managers → Decoders: address
- Four managers → Matrix: transfers
- Matrix → ROM, ap_clint, ap_plic, SRAM: routes
- Matrix → AHB-to-APB bridge: route
- Four managers → Default subordinates: no target
- AHB-to-APB bridge → Fast APB blocks: APB
- AHB-to-APB bridge → Asynchronous bridge: APB
tools/soc/ap_soc/rtl/ap_soc_fabric.sv and the generated decoders in tools/soc/ap_soc/gen/rtl/; facts 27.7.
New Words
| Word | Meaning |
|---|---|
| Fabric | The decoders, arbiters, bridges and default subordinates that carry transfers from managers to targets. |
| Route | One manager reaching one target through the fabric, for one kind of access. |
| Route matrix | A table of managers against targets: each cell is a route to test. |
| Window | The range of addresses one target owns: a base and a size. |
| Hole | An address no target owns. It must answer ERROR. |
| Default subordinate | The fabric's own responder for holes: it answers every transfer with ERROR. |
| Decoder | Logic that names the target owning an address; ap_soc's is generated from map.json. |
| Latency | Cycles from the cycle an address phase is taken to the cycle its data phase ends. |
The Smallest Example: A Window Too Small
A decoder tests each address against each window: address AND mask equals base. A wrong mask makes a window smaller or larger than the map says. Here is a map of three windows and one bug.
| Window | Base | Size in the map | Right mask | Bug: mask | Last word that still decodes |
|---|---|---|---|---|---|
| SRAM | 0x8000_0000 | 64 KiB | 0xFFFF_0000 | 0xFFFF_F000 | right: 0x8000_FFFC; bug: 0x8000_0FFC |
The example below runs this decoder against eight addresses.
With the bug, 0x8000_0000 still decodes to SRAM, and so does every address in the first 4 KiB. A test that writes and reads near the base passes. Only an address near the top shows the lost 60 KiB: it goes to no target and answers ERROR.
The Rules
Rule 1: Test the fabric as a design of its own.
Block benches cannot see routes, holes, arbitration or bridges. Give the fabric its own plan, checks and coverage.
Rule 2: Read the map as a test list.
Every window is a route to try; every gap is a hole that must answer ERROR. Generate the list from the map.
Rule 3: Visit both ends of every window.
A window decoded too small passes at its base and fails at its top. A window too large shows in the hole above it.
Rule 4: Prove a route with a value only its target holds.
An OKAY says some target answered. A value written and read back, or a value only one register holds, says which.
Rule 5: Try every manager that can reach a target.
Each manager has its own port, decoder and default subordinate. One manager's route proves nothing about another's.
Rule 6: Check the answer of every hole, and the cost of each answer.
A hole must answer ERROR, at once. A hole that answers OKAY looks to software like a register that holds 0.
Sources for These Rules
Interconnect verification as its own task, with routes from every master to every slave: MEHTA-DV 14.1 and 14.2. Stimulus first directed, then concurrent: MEHTA-DV 14.3.
The fabric of ap_soc, the manager order, the default subordinate per manager and the costs of an error: facts 27.7. The decoders are generated by tools/soc/ap_soc/fabric-gen.mjs from map.json.
The E3 gate taught rule 3 (plan §3.10, stage E3). A window decoded too small showed only once routes visited the top of every window.
An address no subordinate owns must get ERROR from a default subordinate: AMBA AHB, IHI 0033C 4.2.1.
The Lab: One Access to Each Kind of Target
The seat made one access to each kind of target on ap_soc, and to each kind of hole. The bench's sample window recorded its port, so each transfer's latency can be read straight off.
core r 00000000 00000000 00000000 00000000 0 1
core r 02000000 00000000 00000001 00000000 0 1
core r 0c000004 00000000 00000007 00000000 0 1
core w 80003000 0c0ffee0 ffffffff 00000000 0 1
core r 80003000 00000000 ffffffff 0c0ffee0 0 1
core r 10004000 00000000 ffffffff 2a5310c5 0 1
core r 10008004 00000000 00000040 00000040 0 1
core re 40000000 00000000 ffffffff 00000000 0 1
core re 10007000 00000000 ffffffff 00000000 0 1| Target | Address | Answer | Data | Latency (cycles) |
|---|---|---|---|---|
| Boot ROM | 0x0000_0000 | OKAY | 0x00000000 | 1 |
| ap_clint | 0x0200_0000 | OKAY | 0x00000000 | 1 |
| ap_plic | 0x0c00_0004 | OKAY | 0x00000000 | 1 |
| SRAM (write) | 0x8000_3000 | OKAY | 0x0c0ffee0 | 1 |
| SRAM (read) | 0x8000_3000 | OKAY | 0x0c0ffee0 | 1 |
| Fast APB (CHIP_ID) | 0x1000_4000 | OKAY | 0x2a5310c5 | 2 |
| Slow APB (ap_pwrctl STATUS) | 0x1000_8004 | OKAY | 0x00000040 | 11 |
| AHB hole 0x4000_0000 | 0x4000_0000 | ERROR | — | 2 |
| APB hole 0x1000_7000 | 0x1000_7000 | ERROR | — | 3 |
Recorded on ap_soc v1.5, Verilator 5.052 2026-09-05, +core=bfm. Latency: from the cycle the seat's address phase was taken to the cycle its data phase ended.
Read the latencies against the fabric. The four AHB targets answer in 1 cycle. The fast APB costs 2: the bridge adds a setup and an access cycle (rule 6). The slow APB costs 11, because the transfer crosses into clk_aon and back.
The two holes answer differently, and both correctly. The AHB hole gets the default subordinate's two-cycle ERROR: 2 cycles. The APB hole costs 3: the decoder sends it to the bridge first, and the APB multiplexor refuses it there.
Look again at the ROM and ap_clint rows: both answered 0. With no image loaded, the ROM holds zeros, and MSIP resets to 0. So these two rows prove a target answered, but not which one (rule 4). The SRAM row does: it reads back the value it wrote. So does CHIP_ID, a value no other register holds.
sel = '0;
if ((addr & ap_soc_map_pkg::AHB_ROM_MASK) == ap_soc_map_pkg::AHB_ROM_BASE) begin
sel[ap_soc_map_pkg::AHB_ROM] = 1'b1;
end
// ... one test per target, then:
assign sel_none = (sel == '0);The decoder is a list of mask tests, made by a script from map.json. That is why the route test is generated too: one list feeds both. A wrong row in the map then shows as a test that fails, not as a test that agrees with the bug.
This lab used one manager and one access per kind of target. The fabric's own gate at stage E3 ran the full list. It visited 40 routes: the first and last 1 KiB of each of 12 device windows, plus 16 holes and reserved pages. Each route ran from all four managers, as a read and as a write. That made 320 of 320 route tests reached, and every hole answered ERROR (rules 2, 3 and 5).
Why It Is Built This Way
Why does each manager have a default subordinate of its own? A single shared one would be a shared target. A manager that hits a hole would then wait behind another manager's transfer, and a hole could stall the chip. With one each, a hole never waits for anyone (facts 27.7).
Why generate the decoder and the test from one map? Two hand-kept copies drift apart. With one source, a change to the map changes the hardware and the test together. A reviewer then checks the map once.
Traps
The base-address trap: a route test touches the first word of each window. Every window decoded too small passes. This is the bug of the hook, and it is the commonest way a route test lies.
The OKAY trap: a test reads a register, gets 0, and calls the route proven. A route sent to the wrong target that also reads 0 passes. Use a value only the right target can give.
The one-manager trap: the route test runs from the core alone. The DMA's port has its own decoder and its own default subordinate, and nobody tried them. The first DMA job into a peripheral finds the bug in the lab.
The silent-hole trap: holes are left out because "software never goes there". A hole that answers OKAY turns a wrong pointer into wrong data, with no error anywhere.
At Scale
This section looks ahead. ap_soc has four managers and five targets.
Generated route tests
Chips with hundreds of targets generate route tests from the map that generates the fabric. They run them from every manager.
Many fabrics in a chain
Large chips chain fabrics through bridges and protocol converters. A route then crosses several decoders, and each crossing is tested end to end.
Security and protection
Fabrics add firewalls: some managers may not reach some windows. The route matrix gains cells that must answer an error for one manager and OKAY for another.
Try It
Run it: the base of SRAM decodes, the last word does not.
Fix the mask (the predict question below). Which line changes?
Which two addresses of the eight would you keep if you could keep only two?
00000000 -> ROM ok 00000ffc -> ROM ok 10000000 -> APB ok 1000fffc -> APB ok 80000000 -> SRAM ok 8000fffc -> ERROR WRONG, expected SRAM 40000000 -> ERROR ok 80010000 -> ERROR okCheck Yourself
Common Mistakes
Wrong Test only the base of each window.
A window decoded too small passes at its base.
Fix Visit the first and the last word of every window, and the hole above it.
Wrong Accept an OKAY with any data as a proven route.
The wrong target can answer OKAY too.
Fix Read back a value you wrote, or a value only that register holds.
Wrong Run the route test from the core alone.
Each manager has its own port and default subordinate.
Fix Send every manager the bench can drive down every route it can take.
Remember
- The fabric is the decoders, arbiters, bridges and default subordinates between managers and targets.
- The map is the test list: every window from every manager, both ends, and every hole.
- A route is proved by a value only its target gives back.
- On ap_soc an AHB target answers in 1 cycle, the fast APB in 2 and the slow APB in about 11. An AHB hole costs 2, an APB hole 3.