AMBA APB · Module 1
Typical APB SoC Architecture
Where APB sits in a real SoC — downstream of the AXI/AHB bridge, fanning out to peripherals through a one-hot decode and return mux.
You now understand why APB exists, where it sits in the family, how its two-phase transfer differs from the fast buses, why it is minimal, and what it really does — register access. This chapter assembles those ideas into the standard structure of an APB subsystem in a real SoC: a bridge from the fast bus, an address decoder that turns one shared PADDR into a one-hot PSEL, and a fan-out of peripheral register banks sharing one set of common signals. This is the shape you will recognize in essentially every chip.
1. What problem is being solved?
Two concrete problems: how does a fast-bus access reach a slow peripheral, and how do many peripherals share one cheap bus — solved by a bridge and a decoder respectively.
An APB subsystem has three parts:
- The bridge — the seam between the fast bus (AHB or AXI) and APB. It accepts a fast-bus transaction, runs the corresponding two-phase APB transfer (SETUP then ACCESS), waits on
PREADY, and returns the result upstream. It is the only block that sees both protocols. - The address decoder — APB peripherals share one set of common signals (
PADDR,PWRITE,PWDATA,PENABLE), broadcast to all of them. The decoder examinesPADDRand asserts exactly onePSEL, the addressed peripheral's select, so only that peripheral responds. It also multiplexes the selected subordinate'sPRDATAandPREADYback toward the bridge. - The peripheral fan-out — the subordinates (UART, timers, GPIO), each receiving the broadcast common signals plus their own dedicated
PSEL, each driving its ownPRDATAandPREADY. Each is the minimal register bank from the previous chapter.
The defining idea is broadcast-the-common-signals, select-with-one-hot-PSEL, mux-the-return — the entire topology of an APB bus.
2. Why existing buses were not the right fit
The subsystem is structured as a bridge plus a shared-and-decoded bus — not a direct connection and not a crossbar — because each alternative is wrong for the control plane.
A direct connection of the fast bus to the peripherals is impossible: the fast bus and APB speak different protocols at different speeds. A processor on the fast bus expects pipelined or decoupled behavior; APB can only do its self-contained two-phase transfer, one at a time. So the bridge must stand between them, accepting the fast-side transaction, driving the APB SETUP and ACCESS cycles, waiting on PREADY, and only then completing upstream — holding the upstream transaction without stalling unrelated fast-bus traffic.
A crossbar (every master a private path to every peripheral) is overkill for the control plane: peripheral traffic is sparse and one-at-a-time, so the parallelism a crossbar buys is wasted, and its area is large. Instead APB broadcasts one PADDR (and the other common signals) to all subordinates and selects one with a one-hot PSEL — one shared bus, one decoder, N single-bit selects. That is dramatically cheaper than a crossbar, and exactly right for traffic that never needs two peripherals accessed at once. The bridge and decoder together turn a fast-bus access into a targeted register access on a shared, cheap bus — the whole job of an APB subsystem.
3. APB mental model
The model: APB is a party line, and PSEL is the name you call to get one listener to answer.
Picture an old shared telephone line where everyone hears every call, but each household has a distinct ring. The common signals (PADDR, PWRITE, PWDATA, PENABLE) are the conversation, heard by everyone. PSEL is the ring: the decoder rings exactly one household (asserts one select), and only that household picks up. The others hear the conversation but stay silent because they were not rung. When the answering household speaks back (PRDATA, PREADY), the return multiplexer makes the bridge hear the right household.
The model makes the properties intuitive:
- Broadcast is cheap. Putting the conversation on a shared line costs one set of wires, not one per household — why APB broadcasts and selects with
PSELinstead of a private bus per subordinate. - One-hot keeps it correct. Exactly one household is rung, so exactly one answers — no collisions. If the decoder asserted two selects, two subordinates would drive the return at once: a bug. One-hot discipline prevents it.
- An unrung line is silent. Dial a number no one answers to (an unmapped address) and no household picks up. A well-designed bridge completes the transfer harmlessly — typically returning zero — so the caller is not left waiting forever (no bus hang).
4. Real SoC placement & hardware context
In RTL, the decoder and return mux are small and almost mechanical. Here is the canonical shape for a three-peripheral subsystem — one shared PADDR/PSEL in, a dedicated select out per subordinate, and the return paths in:
// APB address decode + return mux — the heart of an APB subsystem.
// One PSEL per subordinate (one-hot), and the selected subordinate's
// PRDATA/PREADY routed back toward the bridge/manager.
module apb_decode #(
parameter int DATA_W = 32
)(
input logic [31:0] paddr, // shared address from the bridge
input logic psel, // bridge has a live transfer to route
// one dedicated select per subordinate (one-hot)
output logic psel_uart,
output logic psel_timer,
output logic psel_gpio,
// return paths driven by each subordinate
input logic [DATA_W-1:0] prdata_uart, prdata_timer, prdata_gpio,
input logic pready_uart, pready_timer, pready_gpio,
// muxed result back toward the manager
output logic [DATA_W-1:0] prdata,
output logic pready
);The address map is a set of constants — each peripheral owns a page of the address space, picked out by a field of PADDR. The selects are pure combinational decode, gated by psel so nothing is selected when the bridge has no transfer:
// Each peripheral owns a 4 KB window; address bits [15:12] pick which one.
localparam logic [3:0] UART_PAGE = 4'h0; // 0x...0xxx
localparam logic [3:0] TIMER_PAGE = 4'h1; // 0x...1xxx
localparam logic [3:0] GPIO_PAGE = 4'h2; // 0x...2xxx
wire [3:0] page = paddr[15:12];
// One-hot select: only the addressed subordinate sees PSEL asserted, and
// only while the bridge is actually driving a transfer (psel).
assign psel_uart = psel & (page == UART_PAGE);
assign psel_timer = psel & (page == TIMER_PAGE);
assign psel_gpio = psel & (page == GPIO_PAGE);The return mux selects the addressed subordinate's read data and ready. Crucially, the default arm handles an unmapped address — completing the transfer with a benign value so a stray access cannot hang the bus:
// Return mux: route the selected subordinate's PRDATA/PREADY back. The
// default arm makes an unmapped access complete harmlessly instead of
// hanging — no subordinate would drive PREADY otherwise.
always_comb begin
unique case (page)
UART_PAGE: begin prdata = prdata_uart; pready = pready_uart; end
TIMER_PAGE: begin prdata = prdata_timer; pready = pready_timer; end
GPIO_PAGE: begin prdata = prdata_gpio; pready = pready_gpio; end
default: begin prdata = '0; pready = 1'b1; end
endcase
end
endmoduleCombined with the minimal subordinate from the previous chapter and a bridge, that is a working APB subsystem — small logic hosting a chip's entire peripheral fan-out.
At the whole-chip level, the APB subsystem is always the leaf tier, reached through a bridge. The path from a processor to a peripheral register is a chain: the CPU issues a load/store to a peripheral's address; the main interconnect (AXI on a large chip, AHB on a small one) decodes it and routes it to the APB bridge; the bridge runs the slow two-phase APB transfer and waits on PREADY; the addressed register is read or written, and on a read the data returns along the same chain. The upper tiers vary with chip scale; the APB leaf does not — only the bridge's upstream protocol changes. This makes the APB subsystem a self-similar block you can drop beneath any interconnect.
5. Engineering tradeoffs
The subsystem's structure embodies several clean tradeoffs.
| Choice | Upside | Cost / caveat |
|---|---|---|
Shared broadcast + one-hot PSEL | Cheap — one bus, one decoder, N selects (vs a crossbar) | Serial: one subordinate accessed at a time (right for control traffic) |
| One bridge for the whole fan-out | Simple; contains the slow world | All peripheral accesses serialize through it (fine — traffic is sparse; very large chips use several APB buses) |
default arm on unmapped addresses | Robust — no bus hang on a stray access | A few extra gates (always worth it) |
| Generous, aligned address windows | Trivial decode (compare a few high bits); room per peripheral | Consumes address space (usually the right trade) |
The throughline: the APB subsystem optimizes for cheap, robust, sparse register access across a large fan-out — shared signals and one-hot select for cheapness, a single contained bridge for simplicity, and a default arm for robustness. Every choice matches the control-plane traffic it carries.
6. Common RTL / architecture mistakes
7. Interview framing
Interviewers use the subsystem to test whether you can assemble the pieces into a working structure and reason about its failure modes — the difference between knowing the signals and knowing the system.
The strong answer describes the three-part structure — bridge, decoder, fan-out — and the broadcast / one-hot-PSEL / mux-the-return topology, then volunteers the two robustness points: that PSEL must be one-hot (or contention results) and that the decoder needs a default for unmapped addresses (or the bus hangs). Tracing a single store from CPU through the bridge and decoder to a subordinate's ACCESS-phase capture demonstrates end-to-end fluency. What interviewers are really probing is how it is built and how it breaks — overlapping windows cause PSEL contention; a missing default hangs the bus — which is exactly the integration-level competence the question is built to find.
8. Q&A
9. Practice
- Draw the subsystem. Sketch a bridge, decoder, and three subordinates, and label which signals are broadcast and which are per-subordinate.
- Decode an address. Given the page map in the SystemVerilog above, state which
PSELis asserted for address0x4000_1010, and which register offset within that peripheral it targets. - Trace a store. Walk a CPU store to a GPIO register through the chain: interconnect, bridge SETUP/ACCESS, decoder one-hot select, subordinate capture, return.
- Break the map. Describe two address-map mistakes (a missing default and an overlap) and the exact failure each produces.
10. Key takeaways
- An APB subsystem is bridge + decoder + peripheral fan-out. The bridge translates the fast-bus transaction into the two-phase APB transfer; the decoder selects the target; the subordinates are minimal register banks.
- The topology is broadcast, one-hot
PSEL, mux-the-return. Common signals are shared across all subordinates; a single decoder asserts exactly onePSEL; the return path multiplexes the selected subordinate'sPRDATA/PREADY. PSELmust be one-hot. Overlapping windows that assert two selects cause contention on the shared return signals — prevent it with a clean map and a one-hot assertion.- The decoder needs a default for unmapped addresses. Otherwise no
PREADYis driven and the bus hangs; the default arm completes a stray access safely, like a default slave. - APB is always the leaf tier, reached through one bridge. The fast tiers above vary with chip scale; the subsystem's internal structure does not — only the bridge's upstream protocol does.
- The subsystem is small, self-similar, and universal. Recognize this block and you can read the peripheral subsystem of almost any SoC — and you know where to look (the address map and the bridge's
PREADYhandling) when a peripheral access misbehaves.