z80replacement · a Z80 CPU replacement with an FPGA

Bus interface

pins, level translators, high-impedance states, bus timing

Status, 29 November 2026: nobody has built this module yet. The first sample run of 2 boards comes soon. Wait until the project has tested these boards before you send an order or a build request to a factory.

Repository file: docs/bus_interface.md

This file describes how the module connects to the 5 V Z80 bus: the pins, the level translators, the high-impedance states and the bus timing.

Pins

The module uses the standard Z80 DIP-40 pinout.

Pin Signal Direction (module view) High-impedance on BUSACK
1–5 A11–A15 output yes
6 CLK input —
7, 8, 9, 10, 12, 13, 14, 15 D4, D3, D5, D6, D2, D7, D0, D1 bidirectional yes
11 +5V power —
16 /INT input —
17 /NMI input —
18 /HALT output no
19 /MREQ output yes
20 /IORQ output yes
21 /RD output yes
22 /WR output yes
23 /BUSACK output no
24 /WAIT input —
25 /BUSREQ input —
26 /RESET input —
27 /M1 output no
28 /RFSH output no
29 GND power —
30–40 A0–A10 output yes

Totals: 20 outputs that go to high impedance, 4 outputs that the module always drives, 8 bidirectional data lines and 6 inputs.

Logic levels

The Z84C00 has TTL-level inputs: VIH is 2.2 V minimum and VIL is 0.8 V maximum. The CLK input is the exception, because the Z84C00 needs a CMOS level on CLK. Other chips on a Z80 bus can have TTL-level outputs. An NMOS Z80 PIO or SIO, or a 74LS part, can give a logic 1 of only 2.4 V.

Thus the module needs:

  • inputs that accept a 2.0 V logic 1, the TTL level
  • outputs that go to 5 V, so that 74HC loads also see a valid logic 1 (74HC VIH is 3.5 V at 5 V supply)
  • an FPGA side at 3.3 V, because the ECP5 I/O pins are not 5 V tolerant

Why not the SN74LVC8T245

The SN74LVC8T245 is the usual dual-supply translator. The TI data sheet gives VIH as 0.7 × VCC at 4.5 V to 5.5 V. That is 3.15 V to 3.85 V. A 2.4 V TTL logic 1 is below this limit. Thus the SN74LVC8T245 does not read a TTL output reliably.

The automatic-direction translators (TXB0108, TXS0108E) are also not suitable. They cannot drive a bus with pull-up resistors and many loads, and they cannot go to high impedance per cycle.

The selected part: SN74LVC4245A

The SN74LVC4245A (TI) and the 74LVC4245A (Nexperia) are octal transceivers with a 5 V A port and a 3.3 V B port. Data from the TI data sheet SCAS375K (May 2026):

Item Value
A port (5 V) VIH / VIL 2.0 V / 0.8 V, TTL level
B port (3.3 V) VIH / VIL 2.0 V / 0.8 V
A port output current ±24 mA, output swings to VCCA
Propagation delay, CL = 50 pF 6.7 ns maximum, A to B and B to A
Output enable time 10 ns maximum
Power-off behavior Ioff. If either supply is below 100 mV, all outputs are in high impedance.
Control inputs (DIR, /OE) referenced to VCCA, TTL level, so a 3.3 V FPGA output drives them
Packages TI: TSSOP-24 (7.8 mm × 6.4 mm), SSOP-24, SOIC-24. Nexperia: DHVQFN24 (SOT815-1, 3.5 mm × 5.5 mm)

Two manufacturers make the part, so the part has a second source. The Nexperia DHVQFN24 package is the preferred package because of the board area.

Translator groups

Each translator has one DIR pin and one /OE pin for all 8 bits. Thus each group must contain signals that change direction and go to high impedance together.

Part Signals DIR /OE
U10 A0–A7 FPGA pin ADIR (normally toward the bus, ADIR low) FPGA pin /AOE
U11 A8–A15 ADIR /AOE
U12 D0–D7 FPGA pin DDIR, changes per bus cycle FPGA pin /DOE
U13 /MREQ, /IORQ, /RD, /WR, 4 spare fixed toward the bus (DIR to GND) FPGA pin /COE
U14 /M1, /RFSH, /HALT, /BUSACK, 4 spare fixed toward the bus (DIR to GND) FPGA pin /SOE
U15 /RESET, /WAIT, /INT, /NMI, /BUSREQ, 3 spare fixed toward the FPGA (DIR to 5 V) enabled (/OE to GND)
U16 CLK Schmitt-trigger buffer with a 5 V-tolerant input at 3.3 V, for example 74LVC1G17 —

CAUTION: On the 74LVC4245A, DIR low sends the B port (the FPGA side) to the A port (the bus), and DIR high sends A to B (TI SCAS375, function table). Thus the FPGA drives ADIR and DDIR low to drive the bus.

ADIR lets the FPGA read the address bus while another device has control of the bus. A real Z80 cannot do this. The function is for a later bus monitor and costs only one pin.

CLK has a Schmitt-trigger buffer of its own. Noise on CLK gives extra clock edges, and extra clock edges corrupt the CPU state.

Spare inputs connect to GND or VCC, as the data sheet requires.

A later step can replace U10 and U11 with one SN74LVC164245 (two 8-bit halves, each with its own DIR and /OE) if the board area makes this necessary. Check the thresholds of that part first.

Power-up and configuration

The ECP5 needs some time to load its configuration from flash. Until the configuration is done, the module must look like a Z80 in reset:

  • A 10 kΩ pull-up to 3.3 V on each /OE pin keeps U10 to U14 in high impedance while the FPGA pins float.
  • A 10 kΩ pull-up to 5 V holds each output of U13 and U14 inactive while the translators are in high impedance.
  • The FPGA holds the CPU core in reset until the configuration is done and the bus /RESET is high.
  • The Ioff function of the translators keeps the bus free if the 3.3 V supply fails.

A real Z80 drives its control outputs high during reset. The pull-ups give the same result while the FPGA has no configuration.

Bus timing

Clock

The external CLK is the clock of the bus logic. CLK goes through U16 to a primary clock input of the ECP5. The CPU core advances one T-state on each rising edge of CLK. A pin stage, clocked on both edges of CLK, sets each output on the correct half T-state.

This method has these properties:

  • No PLL is on the CLK path. CLK can stop, run slowly or step one cycle at a time, as with a static CMOS Z80. Single-step clock circuits operate.
  • The timing of each output follows CLK, not an internal oscillator. The delay from the CLK pin to an output pin has three parts: U16, the FPGA clock network and output, and the translator.
  • The SRAM controller uses the separate 25 MHz oscillator (clk25), so that the SRAM timing does not depend on CLK. The SRAM needs no refresh. History: the DDR3L controller used a separate oscillator, because DRAM refresh must continue when CLK stops.

Edges to reproduce

The pin stage must reproduce the edges of the Z80 bus cycles. This table comes from the Z80 CPU User Manual (UM0080). bus_timing.md has the version checked against the Z84C00 product specification PS0178, with the parameter numbers. Use that version for the RTL.

Cycle Edges
M1 (opcode fetch) Address and /M1 at T1 rising. /MREQ and /RD low at T1 falling. Data read at T3 rising. Refresh address, /RFSH low at T3 rising. /MREQ low at T3 falling, high at T4 falling.
Memory read /MREQ and /RD low at T1 falling. Data read at T3 falling.
Memory write /MREQ low at T1 falling. Data out from T1 falling. /WR low at T2 falling, high at T3 falling.
I/O read and write /IORQ and /RD or /WR low at T2 rising. One automatic wait state (TW). Data read at T3 falling.
Interrupt acknowledge /M1 with /IORQ in place of /MREQ, two automatic wait states, vector read from the data bus.
/WAIT Read at T2 falling and at each TW falling.
/INT, /NMI Read at the rising edge of the last T-state of an instruction. /NMI is edge-triggered and latched.
/BUSREQ Read at the rising edge of the last T-state of each M-cycle. /BUSACK goes low at the next rising edge.
/RESET Must be low for at least 3 clock cycles.

The z80fpga core already produces the cycle lengths, the refresh address, WAIT stretching and the interrupt acknowledge. Its strobes change on whole T-states. The pin stage adds the half T-state edges (pin_stage.md).

Phase 1 found four changes that the core needed for a real bus: status outputs, a later data latch for memory and I/O reads, /BUSREQ, and the interrupt acknowledge of the real part. z80fpga now has all four. See bus_timing.md.

Timing budget

The required range ends at 10 MHz: 100 ns per T-state, 50 ns per half T-state. The goal is 20 MHz (Z84C0020): 50 ns per T-state, 25 ns per half T-state. See clock_speeds.md.

  • Only the pin stage has paths from one CLK edge to the opposite edge. Keep these paths register to register.
  • The core has a full T-state for each path. z80fpga routes the core at 27.9 MHz to 29.5 MHz on an LFE5U-25F, so a full 50 ns T-state has margin.
  • Each signal goes through one translator, 6.7 ns maximum, plus the FPGA input or output delay. CLK goes through U16 before it reaches the FPGA.

bus_timing.md compares each Z84C00 AC parameter (address delay, strobe delays, data setup and hold) with the module delay. Calculate the table again when the LPF file has the pin locations.

Data bus direction

U12 drives the bus only during a write cycle and during the time that a real Z80 drives data. The output enable time (10 ns maximum) is part of the timing table.

The gateware holds /DOE low after the configuration and changes DDIR and the FPGA data outputs on the same clock edge. Thus, at each change of direction, the FPGA and U12 can both drive the 3.3 V data lines for a few nanoseconds. This overlap causes a small current pulse, not damage. /DOE is a separate FPGA pin on the board, so a later gateware can turn /DOE off for one clock edge around each change of DDIR, with no change to the board.

Internal memory cycles

When the module serves a memory cycle from internal memory, the bus interface does not assert /MREQ and /RD on the bus for that address. The address bus, /M1 and /RFSH still change as on a real Z80. Thus external refresh logic and bus monitors see the normal sequence. The cycle length does not change, so software timing loops stay correct. See memory.md.

Source of this page: web/ and docs/ in the z80replacement repository. Hardware: CERN-OHL-S-2.0. Other files: GPL-3.0-or-later.