← r0mheat z80 lessons: all projects

Z80 buses, clock and pinout

The CPU uses address, data and control signals to communicate with memory and devices.

ADDRESS · DATA · CONTROL

A bus is a group of electrical lines that carries related information. The address bus selects a location. The data bus carries a byte. Control signals say what kind of transfer is happening and when devices should respond.

Inside the CPU

Open the architecture diagram to inspect the CPU blocks at a larger size. Select a labeled part to read its role.

Use the zoom buttons or drag the diagram after zooming in.

Interactive Z80 architecture

Click or focus a label in the diagram to inspect that CPU part. Use +/− to zoom and drag to pan.

Select a label to see its role.

100%
Z80 CPU architecture A simplified diagram of the Z80 instruction control, register bank, arithmetic logic unit, and address, data, and control buses. Z80 Architecture InstructionRegister InstructionDecoder ControlLogic Register bank BC BC DE DE HL HL Shadow set BC′ · DE′ · HL′ Fast register exchange with EXX Address registers IX IY PC SP Arithmetic and logic A F ALU Arithmetic · logic · flags Internal Data Bus 8 Bit Memory and I/O devices Address Bus 16 Bit Control Bus A15–A0 select 1 of 65,536 byte addresses. D7–D0 carry one byte in either direction. Control signals coordinate each memory or I/O cycle.

Three groups of signals

Bus or signalWidth / directionJob
Address A15–A016 bits, CPU outputsSelects a memory or I/O address. A 16-bit memory address can select 0000h–FFFFh: 65,536 byte locations.
Data D7–D08 bits, bidirectionalCarries one byte from memory or a device to the CPU, or from the CPU to them.
ControlSeveral individual linesSignals read, write, memory, I/O, opcode fetch, refresh, interrupt, wait and bus control.
CLKInput to CPUSets the timing reference. One clock period is one T-state. Instructions take a number of T-states.

The address does not travel on the data bus. A 16-bit address and an 8-bit data byte use separate pins.

Watch instructions use the clock

Choose an operation. Step or run through its clock periods. One clock period is one T-state.

LD A,(HL)PC fetches opcode 7Eh, then the CPU reads 2Ah from memory address 8000h into A.

Ready · 0 of 7 T-states
Address bus—
Data bus—
Control—
CPU statePC 0100h · A 00h

Press Step to advance one clock period.

With no WAIT states, this instruction takes 7 T-states: 4 for the opcode-fetch M1 cycle and 3 for the memory read. At 4 MHz, that is 1.75 μs.

The animation separates decode from bus timing to make each part clear. Real hardware overlaps some internal work. I/O cycles include one automatic wait state.

Follow a memory read

  1. PC contains 0100h, so the CPU puts 0100h on A15–A0.
  2. The CPU marks a memory read: MREQ and RD are asserted.
  3. Memory places the byte at 0100h on D7–D0.
  4. The CPU reads the opcode, advances PC and continues the instruction cycle.

A normal NOP takes 4 T-states. At a 4 MHz clock, one T-state is 0.25 microseconds and 4 T-states take 1 microsecond. Other instructions need different numbers of T-states.

Follow a memory write

Suppose HL contains 8000h and A contains 2Ah. An instruction such as LD (HL),A puts 8000h on the address bus and 2Ah on the data bus. It asserts MREQ and WR. Memory stores 2Ah at address 8000h.

The data bus changes direction: memory drives it during a read, and the CPU drives it during a write.

Read the Z80 pinout

Open the pinout to inspect it at a larger size. Select a signal name to highlight its pin and read its job.

The small bubbles mark active-low control pins. Address and data labels are clickable too.

Interactive Z80 pinout

Click or focus a pin label. Use +/− to zoom, then drag the diagram to pan.

Select a pin label to see its role.

100%
M1MREQIORQWRRDREFSHHALTWAITINTNMIRESETBUSRQBUSAK CLKVccGND 2719202221281824161726252361129 3031323334353637383940123451415128791013 A0A1A2A3A4A5A6A7A8A9A10A11A12A13A14A15D0D1D2D3D4D5D6D7 2.0" 0.6" 0.1" 0.5"

Principal pins

Pin groupExamplesWhat to remember
AddressA0–A15One 16-bit address is presented for each memory or I/O transfer.
DataD0–D7Eight bits move in either direction.
Memory and I/OMREQ, IORQSelect memory cycles or I/O cycles.
Read and writeRD, WRTell the selected device which direction to transfer data.
Opcode and refreshM1, RFSHM1 identifies an opcode-fetch cycle. RFSH marks a dynamic-memory refresh cycle.
Timing and waitCLK, WAITCLK times the CPU. WAIT can extend a cycle when a device is not ready.
InterruptsINT, NMIRequest service from the CPU. NMI cannot be disabled by the normal interrupt-enable control.
Bus controlBUSRQ, BUSAKAllow another device to request and take control of the buses.
OtherRESET, HALT, VCC, GNDReset initializes the CPU; HALT reports a halted state; VCC and GND power the chip.

A bar over a signal name means active-low: the signal is asserted near 0 volts. The diagram uses bubbles for active-low pins.