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

A system on a chip: the CPU and a DMA engine are AXI managers on an AXI interconnect. The interconnect connects to a DRAM memory controller and an SRAM, and to an AXI-to-APB bridge. Behind the bridge, the UART, a timer and GPIO sit on the APB bus. The fast side is drawn on the left, the slow low-power side on the right
Fast managers and memory share AXI; slow peripherals sit on APB behind one bridge.

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.

Three small timing diagrams of VALID, READY and the payload. Left: VALID rises first, READY rises one cycle later, the transfer happens at the edge where both are high, and the payload stays the same while waiting. Middle: READY is high first, VALID rises, and the transfer happens at the next edge. Right: both rise in the same cycle and the transfer happens at the end of that cycle
Whoever comes first waits; the payload moves on the first edge where VALID and READY are both 1.

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:

SignalMeaningIn the demo
AWLENnumber of beats minus 1 (up to 256 beats for INCR)3, so 4 beats
AWSIZEbytes per beat = 2AWSIZE2, so 4 bytes
AWBURSTFIXED (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.

HTRANSMeaning
IDLEno transfer
BUSYinside a burst, but the manager is not ready for the next beat; no transfer
NONSEQthe first beat of a burst, or a single transfer
SEQthe 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:

  1. SETUP, one cycle: PSEL = 1, PENABLE = 0, with PADDR, PWRITE and, for a write, PWDATA.
  2. ACCESS: PENABLE = 1, everything else held, until the completer answers PREADY = 1. A read's data is on PRDATA in 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

Three bars on a time axis of clock cycles for writing 4 words with no wait states. APB: four transfers of SETUP plus ACCESS, 8 cycles. AHB: NONSEQ and three SEQ address phases with data phases one cycle behind, 5 cycles. AXI: one AW, four W beats and one B, 6 cycles, and the next burst's AW could already overlap
Moving 4 words with no waits: APB 8 cycles, AHB 5, AXI 6, and AXI can overlap the next burst on top.
APBAHBAXI
Pathsone, no pipelineaddress and data, pipelined5 channels: AW, W, B, AR, R
Flow controlPREADYHREADYVALID/READY on each channel
BurstsnoHBURST: SINGLE, INCR, INCR4/8/16, WRAP4/8/16AxLEN + AxBURST, address sent once
Read and write at oncenonoyes
Several in flight, out of ordernonoyes, by ID
Typical useperipheral registerssmall microcontrollersCPUs, 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), AxSIZE other 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 HRESP errors, 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.

On the mind map

Open the Computer Architecture mind mapComputerArchitectureAbstraction and numbers: layers and bit patternsAbstraction and numbersCombinational logic: output depends only on inputsCombinational logicSequential logic: state held by a clockSequential logicMIPS software: how C becomes machine wordsMIPS softwareThe processor: datapath plus controlThe processorPipelines and parallelism: more instructions at oncePipelines and parallelismMemory and I/O: small fast near, big slow farMemory and I/OMemory arraysMemory arraysdecoder picks wordline, bitlines readCPU cacheCPU cachetag, index, offset; hit or missCache address breakdownCache address breakdownsets = lines/ways; tag = rest of addressCache Write PoliciesCache Write PoliciesWrite-back sends dirty lines at evictionLoop tiling and interchangeLoop tiling and interchangeWalk rows; tile so reused data fitsMemory hierarchyMemory hierarchyAMAT = hit time + miss rate × penaltyDRAM timingDRAM timingopen row is fast, row change is slowMESI and false sharingMESI and false sharinga write invalidates other copiesVirtual memoryVirtual memoryTLB caches the page tableEmbedded I/OEmbedded I/Odevices are addresses; poll or interruptMCU startup to mainMCU startup to mainCopy .data, zero .bss, then mainButton debounce FSMButton debounce FSMTwo equal 10 ms samples = one pressI2C BusI2C BusWired-AND bus: ACK, stretch, arbitrateUSB enumerationUSB enumerationAddress 0, descriptors, SET_CONFIGURATIONCAN bus arbitrationCAN bus arbitrationDominant 0 wins: lowest ID sends unharmedModbus RTU and TCPModbus RTU and TCPone master asks; bad CRC means silenceTDMA time-triggered busTDMA time-triggered busFixed slots; FTA drops extremes, averagesAMBA AXI, AHB, APBVALID and READY both 1 on the edgePCIe TLPsPCIe TLPsRequests by address, completions by IDBus vs Crossbar vs NoCBus vs Crossbar vs NoCBus: one at a time; NoC: links in parallelADC and PWMADC and PWMSAR = binary search; duty = OC1RS/(PR2+1)PID ControlPID ControlI removes error; clamp stops windupOpen the Computer Architecture mind mapComputer Architecturesmall fast near, big slow farMemory and I/OMemory arraysMemory arraysdecoder picks wordline, bitlines readCPU cacheCPU cachetag, index, offset; hit or missCache address breakdownCache address breakdownsets = lines/ways; tag = rest of addressCache Write PoliciesCache Write PoliciesWrite-back sends dirty lines at evictionLoop tiling and interchangeLoop tiling and interchangeWalk rows; tile so reused data fitsMemory hierarchyMemory hierarchyAMAT = hit time + miss rate × penaltyDRAM timingDRAM timingopen row is fast, row change is slowMESI and false sharingMESI and false sharinga write invalidates other copiesVirtual memoryVirtual memoryTLB caches the page tableEmbedded I/OEmbedded I/Odevices are addresses; poll or interruptMCU startup to mainMCU startup to mainCopy .data, zero .bss, then mainButton debounce FSMButton debounce FSMTwo equal 10 ms samples = one pressI2C BusI2C BusWired-AND bus: ACK, stretch, arbitrateUSB enumerationUSB enumerationAddress 0, descriptors, SET_CONFIGURATIONCAN bus arbitrationCAN bus arbitrationDominant 0 wins: lowest ID sends unharmedModbus RTU and TCPModbus RTU and TCPone master asks; bad CRC means silenceTDMA time-triggered busTDMA time-triggered busFixed slots; FTA drops extremes, averagesAMBA AXI, AHB, APBVALID and READY both 1 on the edgePCIe TLPsPCIe TLPsRequests by address, completions by IDBus vs Crossbar vs NoCBus vs Crossbar vs NoCBus: one at a time; NoC: links in parallelADC and PWMADC and PWMSAR = binary search; duty = OC1RS/(PR2+1)PID ControlPID ControlI removes error; clamp stops windup
This page on the Computer Architecture mind map · 79 pages in 7 branches · open it to see the whole map and test yourself in recall mode.