6.3.8 · D2Interconnects, Buses & SoC

Visual walkthrough — DMA controllers

2,096 words10 min readBack to topic

This page answers one very concrete question, from absolute zero:

When a DMA controller moves chunks of data, how long does it take — and how much of that time does it steal from the CPU?

The parent note (DMA controllers) gave you the two headline formulas for burst and cycle-stealing modes. Here we build those formulas from a blank timeline, one clock tick at a time, so you can see exactly where every number comes from.

We assume nothing. If you have never seen a "bus", a "clock cycle", or the symbol , you will by the end.


Step 1 — What a "clock cycle" is, and why we measure time in them

WHAT. A digital chip has a clock: a signal that ticks up-down-up-down forever, like a metronome. One full tick is called a clock cycle. Everything the hardware does — reading a byte, adding to an address — happens on these ticks.

WHY. We cannot measure hardware time in seconds directly, because the same design might run at different speeds. Instead we count cycles (a pure count, no units), then convert to seconds at the very end using the clock's frequency. This separates "how many steps" from "how fast each step is".

PICTURE. Below, each little box is one cycle. The clock frequency (ticks per second) sets how long a single cycle lasts in seconds. Call that duration :

So at ticks/second, one cycle lasts .

Two different things, do not confuse them: is seconds per one cycle (a conversion factor, units: seconds). Later, will be how many cycles one data transfer takes (a count, units: cycles). To get real time we multiply: .

Figure — DMA controllers

Prerequisite plumbing lives in Bus Architecture — the shared wires that data travels on.


Step 2 — What the DMA is actually moving: transfers of a fixed width

WHAT. The data to move is a block of bytes — say bytes total. But the bus doesn't move one byte at a time; it moves a fixed width of bytes at once (1, 2, or 4 bytes, chosen by the width bits in the control register). Each width-sized gulp is called one transfer.

WHY. A 32-bit-wide bus carries 4 bytes in the same single cycle it would carry 1 byte — the wires are already there. So we count transfers, not bytes. The number of transfers is:

PICTURE. Cutting a -byte block into -byte pieces gives pieces. Each piece is one trip across the bus.

Figure — DMA controllers
yes, exactly 1024 transfers.

Step 3 — The cost of ONE transfer: read, then write

WHAT. A memory-to-memory DMA transfer is really two bus actions: read the source, write the destination. On a back-to-back optimized bus these overlap into roughly one bus cycle of steady-state throughput once the pipeline is full. We call this steady per-transfer time — the number of cycles one already-warmed-up transfer consumes.

WHY. We need one honest number for "how long does the machine spend on one gulp of data, once it's warmed up?" Everything else is overhead layered on top of this. Isolating it lets us reason about the two modes separately.

PICTURE. The read puts the source address (Memory-Mapped IO-style) on the wires, grabs the data; the write puts the destination address and pushes the data out. Steady-state, each new transfer completes every cycle.

Figure — DMA controllers

Step 4 — The overhead the DMA cannot skip: arbitration

WHAT. The DMA controller does not own the bus. To use it, it must ask: it asserts a "bus request" wire and waits for the arbiter to answer with a "grant". This request→grant handshake costs a few cycles and does no data movement. Call it (arbitration).

How relates to : In burst mode we pay one bigger startup block called , which is the arbitration plus placing the very first address on the bus: roughly . So is slightly larger than (in our example cycles versus cycles). The key point: is paid once, whereas is paid per transfer.

WHY. The bus is shared between the CPU and every DMA channel (see ARM AMBA AXI arbiters). Somebody must decide who drives the wires each cycle, or two devices would fight and corrupt the data. That decision is not free.

PICTURE. Grey "wasted" cycles are arbitration; coloured cycles are real data. The whole game of choosing a transfer mode is: how often do we pay this grey tax?

Figure — DMA controllers

Step 5 — Burst mode: pay the tax ONCE

WHAT. In burst mode the DMA asks for the bus one time, then holds it and fires all transfers back-to-back before releasing. Total time (in cycles):

WHY. Because we ask only once, the setup cost is amortized — spread thin across all transfers. This is the fastest possible mode: pure data movement with a single tiny prefix.

PICTURE. One short grey block up front, then a long unbroken rainbow of data cycles.

Figure — DMA controllers

Step 6 — Cycle-stealing mode: pay the tax EVERY time

WHAT. In cycle-stealing mode the DMA asks, does one transfer, releases the bus, then asks again for the next. Every one of the transfers now carries its own arbitration cost plus the same per-transfer data cost we defined in Step 3:

WHY. By releasing the bus between transfers, the DMA lets the CPU sneak in and stay responsive (Interrupts-driven work doesn't stall). The price is that the grey tax is no longer amortized — it multiplies by .

PICTURE. Grey-colour-grey-colour, alternating forever. The CPU can grab a turn in the gaps.

Figure — DMA controllers

Step 7 — Edge & degenerate cases (never leave a gap)

WHAT. Let's stress-test the two formulas at their extremes. First a name: the Byte Count Register (BCR) is the hardware counter inside the DMA that holds how many bytes remain to move; the controller decrements it after each transfer and stops when it hits zero. So "" means "BCR started at zero — nothing queued".

CASE (nothing to move). The BCR starts at .

  • Burst: the formula gives . But a real controller inspects before it bothers to arbitrate, and short-circuits straight to "done", so in practice . The formula and the optimization agree once you read the formula as "cost given that we entered the transfer state machine"; the BCR=0 pre-check simply means we never enter it, so is never spent. No contradiction — the formula describes work done, the pre-check avoids doing any.
  • Cycle-steal: . Consistent — no transfers, no cost.

CASE (a single transfer). The two modes converge: With , burst's amortization advantage vanishes — you can't spread a one-time cost over one item.

CASE (huge transfer). The setup term becomes negligible against : So for big blocks the per-transfer cost — the slope of the timeline — is all that matters, and burst wins by the fixed ratio .

PICTURE. Two lines: time versus . Both are straight; they cross near and fan apart. The slope is the per-transfer cost; the y-intercept is the setup tax.

Figure — DMA controllers

The one-picture summary

Everything above collapses into a single timeline comparison: the same transfers, drawn twice — burst (one tax, then a clean run) versus cycle-stealing (a tax before every gulp). The area of grey is the wasted time; the coloured area is identical in both.

Figure — DMA controllers

Recall Feynman retelling — explain it to a friend

The DMA is a courier moving parcels across a shared hallway (the bus). Before entering the hallway it must ask the guard for permission — that "asking" wastes a few seconds and moves no parcels.

In burst mode the courier asks once, then sprints all parcels through without stopping. The asking-cost () is paid a single time, so with many parcels it's basically free per parcel. But the whole hallway is blocked while the courier runs — nobody else (the CPU) can pass.

In cycle-stealing mode the courier is polite: ask, carry one parcel, leave, ask again, carry the next. The CPU can slip through between trips, so everyone stays responsive — but now the "asking" () happens times, and that adds up to about four times longer for our example numbers.

The math is just: time = (one-time asking) + (number of parcels × time per parcel) for burst, versus (number of parcels × (asking + carrying)) for cycle-stealing, where "carrying one parcel" is the same in both. When there are zero parcels (BCR started at 0), both cost nothing. When there's one parcel, they're the same. When there are thousands, the slope (per-parcel cost) is everything, and burst's shallower slope wins — at the price of blocking the hallway. The whole engineering choice is: how often do you pay the guard?

Related coherence concerns when DMA writes memory the CPU has cached: see Cache Coherency.