APB Protocol Explained with Example
APB architecture, every signal in the interface, the three-state transfer state machine, and a complete walkthrough of a read and a write transaction.
APB is where most engineers write their first bus-functional model, because it's the simplest protocol in the AMBA family. That simplicity makes it the perfect place to learn how a "transfer state machine" and a basic handshake actually work before we add pipelining (AHB) and multi-channel complexity (AXI).
In This Article
1.APB Architecture
An APB system has exactly one APB bridge (which behaves as the single APB master) and one or more APB slaves (peripherals). The bridge sits between the higher-performance domain — typically AHB or AXI — and the APB peripherals, translating incoming transactions into the APB protocol and driving them onto the shared bus.
Because there is only ever one master, APB needs no arbitration logic at all. The bridge selects exactly one slave per transfer using a dedicated per-peripheral select signal.
2.APB Signals
| Signal | Driven By | Purpose |
|---|---|---|
| PCLK | Clock source | Common clock for the entire APB bus |
| PRESETn | Reset source | Active-low reset |
| PADDR | Bridge (master) | Transfer address |
| PSELx | Bridge (master) | Selects one specific slave (one PSEL per peripheral) |
| PENABLE | Bridge (master) | Indicates the second (ACCESS) cycle of a transfer |
| PWRITE | Bridge (master) | 1 = write, 0 = read |
| PWDATA | Bridge (master) | Write data |
| PRDATA | Slave | Read data |
| PREADY | Slave | Slave inserts wait states by holding this low |
| PSLVERR | Slave | Optional error response |
3.The Transfer State Machine
Every APB transfer moves through three states:
- IDLE — default state when there is no active transfer.
- SETUP — the bridge asserts PSELx and drives PADDR, PWRITE, and (for a write) PWDATA. This state always lasts exactly one clock cycle.
- ACCESS — on the next clock edge, PENABLE goes high while PSELx stays high. The transfer completes on the first cycle where PREADY is also high; if the slave holds PREADY low, the bus stays in ACCESS for additional wait-state cycles.
4.Write Transaction Walkthrough
If the slave needs more time, it simply holds PREADY low during ACCESS. The bridge keeps PSELx, PENABLE, PADDR, PWRITE, and PWDATA stable until PREADY finally goes high — nothing about the transfer changes during wait states, only the completion cycle shifts later.
5.Read Transaction Walkthrough
A read is structurally identical, except PWRITE is driven low in SETUP, and the slave drives valid data onto PRDATA during the ACCESS cycle in which PREADY goes high. The bridge samples PRDATA on that same edge.
6.Error Responses with PSLVERR
PSLVERR is optional in the APB specification, but when implemented, a slave asserts it during the same ACCESS cycle that PREADY goes high, to flag an invalid or unsupported access (for example, a write to a read-only register). The bridge is responsible for translating that error back up into the AXI or AHB response format on the other side of the bridge.
Recap: What We Covered Today
- APB has exactly one master (the bridge) and needs no arbitration.
- Every transfer moves through IDLE → SETUP → ACCESS; only ACCESS can be extended with wait states via PREADY.
- Reads and writes are structurally identical apart from PWRITE and which data bus (PWDATA vs PRDATA) is active.
- PSLVERR is an optional error signal asserted alongside PREADY during ACCESS.
AHB Protocol Explained: Architecture, Signals and Transfers
Tomorrow we move up a tier to AHB: master/slave architecture, address and data phase pipelining, HREADY, HRESP, and burst transfers.
Comments
Post a Comment