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.

The Route Matrix of ap_soc
Manager \ targetBoot ROMap_clintap_plicBridge (APB)SRAMDefault (ERROR)
0 debugread, writeread, writeread, writeread, writeread, writeits own
1 DMAread, writeread, writeread, writeread, writeread, writeits own
2 core dataread, writeread, writeread, writeread, writeread, writeits own
3 core instructionfetch onlyfetch onlyfetch onlyfetch onlyfetch onlyits 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.

Five questions this page answers
Question
1What is the fabric of a chip, and why does it need tests of its own?
2How does a memory map become a list of routes?
3Why is an OKAY answer not proof that a route works?
4What does each kind of answer cost on ap_soc?
5Which 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.

What Counts as the FabricThe thing under test in this module: decoders, matrix, default subordinates, both bridges and the APB multiplexors. The blocks at the edges are only endpoints.
  • Manager
  • Control / FSM
  • Bus
  • Result
  • Memory
  • Peripheral
  • Control
  • Data
What Counts as the FabricThe thing under test in this module: decoders, matrix, default subordinates, both bridges and the APB multiplexors. The blocks at the edges are only endpoints. manager Four managers debug, DMA, coredata, coreinstruction control Decoders generated frommap.json bus Matrix one arbiter pertarget result Defaultsubordinates ERROR for holes memory ROM, ap_clint,ap_plic, SRAM AHB targets bus AHB-to-APBbridge setup, access peripheral Fast APB blocks UART0, GPIO, ... DMAregisters bus Asynchronousbridge to the watchdog andap_pwrctl on clk_aon addresstransfersroutesrouteno targetAPBAPB
  1. manager Four managersdebug, DMA, core data, core instruction
    • address → Decoders
    • transfers → Matrix
    • no target → Default subordinates
  2. control Decodersgenerated from map.json
  3. bus Matrixone arbiter per target
    • routes → ROM, ap_clint, ap_plic, SRAM
    • route → AHB-to-APB bridge
  4. memory ROM, ap_clint, ap_plic, SRAMAHB targets
  5. bus AHB-to-APB bridgesetup, access
    • APB → Fast APB blocks
    • APB → Asynchronous bridge
  6. result Default subordinatesERROR for holes
  7. peripheral Fast APB blocksUART0, GPIO, ... DMA registers
  8. bus Asynchronous bridgeto the watchdog and ap_pwrctl on clk_aon
  1. Decode

    Each manager's address picks one target, or none. The decoders are generated from the map.

  2. Arbitrate and route

    The matrix gives each target to one manager at a time and steers the transfer there.

  3. Refuse

    An address nobody owns goes to that manager's own default subordinate, which answers ERROR.

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

New words on this page
WordMeaning
FabricThe decoders, arbiters, bridges and default subordinates that carry transfers from managers to targets.
RouteOne manager reaching one target through the fabric, for one kind of access.
Route matrixA table of managers against targets: each cell is a route to test.
WindowThe range of addresses one target owns: a base and a size.
HoleAn address no target owns. It must answer ERROR.
Default subordinateThe fabric's own responder for holes: it answers every transfer with ERROR.
DecoderLogic that names the target owning an address; ap_soc's is generated from map.json.
LatencyCycles 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.

One window, two masks
WindowBaseSize in the mapRight maskBug: maskLast word that still decodes
SRAM0x8000_000064 KiB0xFFFF_00000xFFFF_F000right: 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

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

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

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

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

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

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

The lab's rows (record-v7-labs.mjs, section routes).
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
Each answer, and what it cost
TargetAddressAnswerDataLatency (cycles)
Boot ROM0x0000_0000OKAY0x000000001
ap_clint0x0200_0000OKAY0x000000001
ap_plic0x0c00_0004OKAY0x000000001
SRAM (write)0x8000_3000OKAY0x0c0ffee01
SRAM (read)0x8000_3000OKAY0x0c0ffee01
Fast APB (CHIP_ID)0x1000_4000OKAY0x2a5310c52
Slow APB (ap_pwrctl STATUS)0x1000_8004OKAY0x0000004011
AHB hole 0x4000_00000x4000_0000ERROR—2
APB hole 0x1000_70000x1000_7000ERROR—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.

The generated AHB decoder (tools/soc/ap_soc/gen/rtl/ap_soc_ahb_decoder.sv): one mask test per target, then "nobody" when no test matched.
    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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has four managers and five targets.

  1. Generated route tests

    Chips with hundreds of targets generate route tests from the map that generates the fabric. They run them from every manager.

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

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

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

Check Yourself

Predict the outputNow the SRAM mask is right. What is the last line printed?
// A decoder from a map of three windows, and the route test of the map: the first and last word of each window,
// and two holes. bug = 0: the SRAM window's mask is one bit too wide, so the window ends 4 KiB early.
module tb;
  function automatic string target(input bit [31:0] a);
    if ((a & 32'hffff_f000) == 32'h0000_0000) return "ROM";
    if ((a & 32'hffff_0000) == 32'h1000_0000) return "APB";
    if ((a & (0 ? 32'hffff_f000 : 32'hffff_0000)) == 32'h8000_0000) return "SRAM";
    return "ERROR";
  endfunction
  task automatic route(input bit [31:0] a, input string want);
    string got;
    got = target(a);
    if (got == want) $display("%h -> %-5s ok", a, got);
    else $display("%h -> %-5s WRONG, expected %s", a, got, want);
  endtask
  initial begin
    route(32'h0000_0000, "ROM");   route(32'h0000_0ffc, "ROM");
    route(32'h1000_0000, "APB");   route(32'h1000_fffc, "APB");
    route(32'h8000_0000, "SRAM");
    route(32'h8000_fffc, "SRAM");
    route(32'h4000_0000, "ERROR"); route(32'h8001_0000, "ERROR");
  end
endmodule
ConceptIn the lab, why did the APB hole cost one cycle more than the AHB hole?
ConceptWhy did the ROM row of the lab prove less than the SRAM row?
ConceptWhy does each manager of ap_soc have its own default subordinate?
ConceptWhat makes the fabric a design under test of its own?

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.

Practice

Report a problem with this page