The idea: one chip, three buses
Inside a system on a chip, the CPU, the DMA engines, the memory controller and dozens of small peripherals all talk over on-chip buses. Most chips use Arm's AMBA family (Advanced Microcontroller Bus Architecture). Its specifications are free, so the same bus works for IP blocks from many vendors. The side that starts a transfer is the manager and the side that answers is the subordinate (older documents say master and slave; APB says requester and completer).
The three buses trade speed for simplicity:
- AXI has five separate channels. Reads and writes run at the same time, and many transactions can be in flight.
- AHB has one address path and one data path. It overlaps the address of the next beat with the data of the current beat.
- APB does one transfer at a time, with at least two cycles each. It needs very few gates and little power, which suits registers that are touched rarely.
The canvas draws every signal clock by clock on a timing diagram. One column is one cycle of a 100 MHz clock (10 ns). A cycle Tk lies between two rising edges, and every transfer happens on the rising edge that ends a cycle. Green means "taken on this edge"; orange means "offered, but waiting". The real Arm signal names are used throughout.
The VALID/READY handshake
Every AXI channel uses the same two wires. The source raises VALID when it puts a payload on the channel. The destination raises READY when it can take one. The transfer happens on a rising clock edge where both are 1. Either side can slow the other down, and nothing else is needed for flow control.
Three rules keep it safe. Once VALID is 1, the source must keep it at 1 and keep the payload steady until the transfer happens. The source must not wait for READY before it raises VALID (if both sides waited for each other, nothing would ever move). The destination may wait for VALID before it raises READY.
An AXI write burst: AW, W and B
A write uses three channels. AW carries the address and the burst shape once. W carries the data beats. B carries one response back. The burst shape is set by three signals:
| Signal | Meaning | In the demo |
|---|---|---|
AWLEN | number of beats minus 1 (up to 256 beats for INCR) | 3, so 4 beats |
AWSIZE | bytes per beat = 2AWSIZE | 2, so 4 bytes |
AWBURST | FIXED (same address), INCR (next address), WRAP (wraps at a boundary, for cache lines) | INCR: 0x1000, 0x1004, 0x1008, 0x100C |
The last W beat has WLAST = 1. The subordinate sends BRESP (OKAY, or SLVERR / DECERR for errors) only after it has the last beat. In Demo: AXI write, a burst of 4 beats AW goes in T1, the beats in T2 to T5 and B in T6: 6 cycles, 60 ns. In Demo: the subordinate adds a wait state the memory holds WREADY at 0 when beat 2 arrives. The CPU must keep WDATA = 0x33 on the bus, unchanged, for one more cycle, and the write takes 7 cycles.
An AXI read, and IDs
A read uses AR for the address and R for the data. On R the subordinate is the source, so it drives RVALID and the CPU drives RREADY. A subordinate that is not ready simply keeps RVALID at 0. The last beat has RLAST = 1, and there is no B: the data is the answer. Demo: AXI read burst takes 6 cycles: AR in T1, one cycle while the memory reads, then 4 beats in T3 to T6.
Every transaction carries an ID (AWID, ARID), and every response repeats it (BID, RID). A manager may send a new request before the old one is answered. Responses with different IDs may come back in any order; responses with the same ID stay in order. In Demo: two reads with IDs the CPU asks for 0x1000 (ID 0, its DRAM row must be opened) and then for 0x3000 (ID 1, the row is open). R carries RID 1, 1, 0, 0: ID 1 is done in T5, two cycles before ID 0 in T7. With one ID for both, ID 1 would have waited behind ID 0. Why opening a DRAM row is slow is the subject of DRAM Timing.
AHB: address and data phases overlap
AHB has one set of address wires and one set of data wires. Each beat has an address phase (one cycle with HADDR, HTRANS, HWRITE, HBURST) followed by a data phase (HWDATA for a write, HRDATA for a read). The data phase of beat n runs at the same time as the address phase of beat n + 1. That is the pipeline.
| HTRANS | Meaning |
|---|---|
| IDLE | no transfer |
| BUSY | inside a burst, but the manager is not ready for the next beat; no transfer |
| NONSEQ | the first beat of a burst, or a single transfer |
| SEQ | the next beat of the burst; its address follows from the one before |
The subordinate pulls HREADY low to stretch a data phase. Because the pipeline is shared, the manager must then also hold the next address. Demo: AHB INCR4 writes 4 words in 5 cycles: NONSEQ in T1, SEQ in T2 to T4 with the data one cycle behind, and the last data with HTRANS = IDLE in T5. With HREADY low for one cycle it takes 6. In Demo: the manager inserts BUSY the CPU shows BUSY with the next address 0x2008 in T3, the data phase of that BUSY cycle moves nothing, and the burst also takes 6 cycles.
APB through a bridge
A UART, timer or GPIO block is reached through an AXI-to-APB bridge. The bridge is an AXI subordinate on one side and the APB requester on the other. Every APB transfer has two phases:
- SETUP, one cycle:
PSEL = 1,PENABLE = 0, withPADDR,PWRITEand, for a write,PWDATA. - ACCESS:
PENABLE = 1, everything else held, until the completer answersPREADY = 1. A read's data is onPRDATAin that cycle.
So an APB transfer takes at least 2 cycles, and the next one cannot start until it ends. In Demo: APB write through the bridge the CPU sends AW and W together in T1, the bridge does SETUP in T2, the UART keeps PREADY at 0 in T3, takes 0x41 into TXDATA at the end of T4, and the bridge sends B in T5: 5 cycles, of which the APB part is 3. An error is reported with PSLVERR, which the bridge turns into SLVERR on B or R.
The three buses compared
| APB | AHB | AXI | |
|---|---|---|---|
| Paths | one, no pipeline | address and data, pipelined | 5 channels: AW, W, B, AR, R |
| Flow control | PREADY | HREADY | VALID/READY on each channel |
| Bursts | no | HBURST: SINGLE, INCR, INCR4/8/16, WRAP4/8/16 | AxLEN + AxBURST, address sent once |
| Read and write at once | no | no | yes |
| Several in flight, out of order | no | no | yes, by ID |
| Typical use | peripheral registers | small microcontrollers | CPUs, DMA, memory, GPUs |
The AXI numbers above are for one burst on its own. A real manager sends the next AW while the current W beats are still moving, so a long stream of bursts keeps W busy every cycle. How many managers can use the bus at once is a question of the interconnect: a shared bus, a crossbar or a network on chip, compared on On-Chip Interconnect. A DMA engine is a second AXI manager, as on the DMA page. For a bus between chips, with two wires and no clock per word, see the I2C bus. Networks that link whole computers are on Interconnect Topologies.
See also Asynchronous FIFO: Gray Pointers Across Two Clock Domains for the FIFO that bus bridges use to cross between clock domains.
See also a FIR filter accelerator, which is driven through AXI4-Lite register writes and moves its data with AXI4 bursts.
What the page leaves out
- Write strobes (
WSTRB,PSTRB, byte lanes),AxSIZEother than 4 bytes, unaligned and narrow transfers, and the 4 KB boundary that a burst may not cross. - AXI cache, protection and QoS signals (
AxCACHE,AxPROT,AxQOS), exclusive access (AxLOCK), AXI5 and ACE / CHI cache coherence. - Write data that goes before its address, write interleaving, and how an interconnect routes and reorders IDs between many managers and subordinates.
- AHB
HRESPerrors,HSIZE,HPROT, WRAP bursts, multi-layer AHB, and how an AHB arbiter chose a master in older AHB. - Separate clocks: here ACLK = HCLK = PCLK. A real APB bus often runs slower than AXI, and the bridge crosses clock domains.