z80replacement · a Z80 CPU replacement with an FPGA

Bus timing

Z84C00 AC timing against the module delays, and the changes to the z80fpga core

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_timing.md

This file compares the Z84C00 AC timing with the delays of the module. It also lists the changes that the z80fpga core needed before the module could drive a real Z80 bus. Phase 1 of plan.md made this file.

Source

All Z84C00 values come from the Zilog product specification PS0178 (Z8400/Z84C00 NMOS/CMOS Z80 CPU, footer PS017801-0602), AC characteristics on pages 35 and 36, and from the Z80 CPU User Manual UM0080 (UM008011-0816). Zilog's site refuses direct downloads, so the copies came from the Internet Archive:

PS0178 is a scanned document with no text layer, so all values were read from the page images. The table has some printing errors:

  • Parameter 52 has the symbol TdCf but the description "Clock Rise".
  • Parameters 29, 33, 43 and 44 do not change steadily from one speed grade to the next.

Check these values against a second revision before you depend on them.

Edges of the bus cycles

A T-state starts on a rising edge of CLK. Each T-state has its falling edge in the middle.

Cycle Signal Goes active Goes inactive
M1 (opcode fetch) /M1 after T1 rise (#19) after T3 rise (#20)
/MREQ, /RD after T1 fall (#8, #13) after T3 rise (#9, #14)
Data read at T3 rise (#15)
/RFSH after T3 rise (#21) after the rise at the end of T4 (#22)
/MREQ (refresh) after T3 fall after T4 fall (#12)
Memory read /MREQ, /RD after T1 fall (#8, #13) after T3 fall (#12, #23)
Data read at T3 fall (#25)
Memory write /MREQ after T1 fall (#8) after T3 fall (#12)
Data out after T1 fall (#53) half a T-state after /WR goes inactive
/WR after T2 fall (#30) after T3 fall (#32)
I/O read or write /IORQ, /RD, /WR after T2 rise (#27, #24, #34) after T3 fall (#28, #23, #32)
Data (read) read at T3 fall (#25)
Interrupt acknowledge /M1 after T1 rise after T3 rise
/IORQ after the fall of the first automatic wait state (#51) after T3 rise (#52)
Vector read at T3 rise (#15)
All cycles /WAIT read at T2 fall and at the fall of each wait state (#17)
/INT, /NMI read at the rise of the last T-state of an instruction (#48)
/BUSREQ read at the rise of the last T-state of each M-cycle (#38)
/BUSACK after the next rise (#40) after a fall (#41)

An I/O cycle has one automatic wait state. An interrupt acknowledge has two. During /BUSACK, the address bus, the data bus, /MREQ, /IORQ, /RD and /WR float. /M1, /RFSH, /HALT and /BUSACK do not float. /RESET must be low for at least 3 clock cycles.

Selected AC limits

Values in ns. "max" is the latest time that the Z84C00 can change a signal. "min" is a time that the system must give the Z84C00.

# Symbol Meaning 4 MHz 6 MHz 8 MHz 10 MHz 20 MHz
1 TcC clock period, min 250 162 125 100 50
6 TdCr(A) CLK rise to address valid, max 110 90 80 65 57
8 TdCf(MREQf) CLK fall to /MREQ low, max 85 70 60 55 40
13 TdCf(RDf) CLK fall to /RD low, max 95 80 70 65 40
19 TdCr(M1f) CLK rise to /M1 low, max 100 80 70 65 45
21 TdCr(RFSHf) CLK rise to /RFSH low, max 130 110 95 80 60
30 TdCf(WRf) CLK fall to /WR low, max 80 70 60 55 40
53 TdCf(D) CLK fall to data out valid, max 150 130 115 110 75
15 TsD(Cr) data setup to CLK rise (M1), min 35 30 30 25 12
25 TsD(Cf) data setup to CLK fall (M2 to M5), min 50 40 30 25 12
17 TsWAIT(Cf) /WAIT setup to CLK fall, min 70 60 50 20 7.5
38 TsBUSREQ(Cr) /BUSREQ setup to CLK rise, min 50 50 40 30 15
48 TsINTf(Cr) /INT setup to CLK rise, min 80 70 55 50 15

Delays of the module

An output of the module goes through this chain:

  1. CLK at the socket pin to the CLK buffer U16 (74LVC1G17): about 5 ns. Read the data sheet for the exact value.
  2. FPGA clock input and global clock network: about 4 ns. The 4 ns value is an estimate. nextpnr does not report this delay in the probe build.
  3. FPGA clock-to-output: from the probe build (see below).
  4. FPGA output buffer: about 3 ns, estimate.
  5. SN74LVC4245A, B to A: 6.7 ns maximum at 50 pF.

The probe build has no pin locations yet. Thus nextpnr put the I/O pins in the worst places, and the clock-to-output values are pessimistic.

Path Probe result Chain total Z84C00 limit at 10 MHz at 20 MHz
CLK rise to address valid 13.7 ns to 15.4 ns about 34 ns 65 ns (#6) 57 ns
CLK fall to /MREQ, /RD, /WR (falling-edge register) 7.4 ns to 9.2 ns about 28 ns 55 ns (#8) 40 ns

An input goes through the translator (6.7 ns maximum) and the FPGA input path (2.4 ns to 8.3 ns in the probe build). The clock path delays the sampling edge by about 9 ns, which compensates for part of the input delay. The setup time that the module needs at the socket pin is thus about 6 ns to 15 ns. The Z84C00 asks the system for 25 ns at 10 MHz (#25) and 12 ns at 20 MHz. Thus the module meets the 10 MHz limits, and 20 MHz is marginal.

routing_study.md gives the values on the real balls of the pin assignment, with z80fpga 0.2.0. All pin groups meet the 10 MHz and the 20 MHz limits there. Measure the values on the phase 2 adapter board too.

The probe build

The first timing build was a probe design. The design was the z80fpga core clocked directly from the bus CLK, with falling-edge registers for the strobes and for the data and /WAIT inputs. The core had LATE_READ and BUSREQ on (see the next section). nextpnr-ecp5 placed and routed the design on the LFE5U-12F and the LFE5U-85F, csfBGA285, speed grade 6, with three seeds each.

Item LFE5U-12F LFE5U-85F
LUT4 (TRELLIS_COMB) 6272 (52% of the 12F) 6272 (7%)
Flip-flops 363 363
Block RAM (DP16KD) 1 1
Highest bus clock 17.6 MHz to 18.0 MHz 17.4 MHz to 18.5 MHz

The path that limits the bus clock starts at /WAIT, read on the falling edge, and ends in the core at the next rising edge. This path must fit in half a T-state, as in a real Z80. The path takes 27 ns to 29 ns. At 10 MHz, half a T-state is 50 ns, so 10 MHz has a margin of about 1.7. At 20 MHz, half a T-state is 25 ns, so 20 MHz fails. A faster path for the /WAIT decision is necessary for 20 MHz.

Before the core changes, the same path took 25.35 ns and the highest bus clock was 18.5 MHz to 19.8 MHz. The path is now longer because the end of an M-cycle with /BUSREQ low stops the clock enable of the whole core. The core changes added about 300 LUT4.

The pin stage in gateware/bus/ replaces the probe design. The repository no longer has the probe design (git log -- gateware/probe shows it). For the current numbers, run mingw32-make report in gateware/bus/. See pin_stage.md.

Changes to the z80fpga core

The z80fpga core passes the SingleStepTests suite with the bus model of that suite. A real bus needs four more functions. z80fpga 0.1.0 and later versions have all four. Each function is a new parameter or a new output that is off or unused by default, so existing z80fpga boards build the same logic. The z80fpga file docs/bus_pins.md describes them for the pin stage.

1. Bus status outputs

The pin stage must know the T-state and the type of each machine cycle. Each strobe changes on a different edge in each cycle type. For example, /MREQ goes inactive at T3 rise in an M1 cycle but at T3 fall in a memory read.

The core now has these outputs:

  • bus_t: the T-state number, 1 for T1. During wait states, bus_t stays at the T-state that waits.
  • bus_cyc: the cycle type. 0 internal, 1 opcode fetch, 2 memory read, 3 memory write, 4 I/O read, 5 I/O write, 6 interrupt acknowledge, 7 NMI response.
  • bus_last: high in the last T-state of the M-cycle.

2. Data read at the falling edge

The core read the data bus at the rising edge that ends T2 (the T3 rise) in every cycle. That is correct for M1 and for the interrupt vector. For a memory read and an I/O read, the Z84C00 reads at the T3 fall, half a T-state later (#25).

With the parameter LATE_READ, the core takes the byte of a memory read or an I/O read at the end of T3. The pin stage captures the data bus at the T3 fall and holds the byte until the core takes it. The micro-op that uses the byte runs on the same edge, so the core takes DIN and WZ directly from the input on that edge.

3. /BUSREQ and /BUSACK

The core connected /BUSACK directly to /BUSREQ and did not stop. With the parameter BUSREQ, the core reads /BUSREQ at the rising edge of the last T-state of each M-cycle. If /BUSREQ is low, the core stops at the end of the M-cycle, lowers /BUSACK and sets the output bus_float. The pin stage uses bus_float to disable the translators U10 to U13. The output bus_resume shows the last T-state of the hold.

Thus the pin stage can raise /BUSACK at the falling edge, as the Z84C00 does (#41). The core continues when /BUSREQ is high again.

4. Interrupt acknowledge and NMI response

The core took the vector of an interrupt acknowledge at the end of the 3rd T-state. The Z84C00 takes the vector at the T3 rise, at the end of the 4th T-state (TW2). With the pin stage, /IORQ is low from the TW1 fall, so the old core gave the device only half a T-state. The core also did not refresh in the acknowledge and in the NMI response. Its NMI response had no /MREQ, no /RD and no wait states.

With the parameter REAL_ACK, the core takes the vector at the end of TW2 and samples /WAIT in TW2. The NMI response is an opcode fetch. Both cycles put the refresh address on the bus in T3 and T4, assert /RFSH and increment R.

Tests of the changes

  • make test-full in z80fpga stays at 0 failures with the default parameters.
  • make test-full-late runs the whole suite with LATE_READ on, with 0 failures. Two changed cores do not take DIN or WZ directly from the input. They fail JP, RET, JR, IN A,(n) and ADD A,(HL). Thus the test does see the late read.
  • sim/tb_busrq.sv in z80fpga runs one program on two cores: one with /BUSREQ high, and one with random bus requests and wait states. On every T-state, the bench checks the /BUSACK timing and the strobes. At the end, the bench compares the bus cycles, the memory and the registers.
  • sim/tb_irq.sv runs again on a core with REAL_ACK. That bench puts the vector on the bus only in TW2, and checks R.
  • The z80fpga Nexys A7 RomWBW build was built again in Vivado after each change, as the z80fpga CLAUDE.md file requires after any change to rtl/.

Differences that remain

  • The core gives the bus away at the end of each of its own M-cycles. In some instructions (for example INC BC), the core makes a separate M-cycle of the internal T-states. Thus the grant can come a few T-states earlier than on a Z84C00.
  • The core changes /HALT at the end of T4. The Z84C00 changes /HALT at the T4 fall, half a T-state earlier.

The pin stage

pin_stage.md describes the pin stage and its test bench. The test bench compares each pin with the edge table above.

The /WAIT path and 20 MHz (10 November 2026)

Measurement: make report-85k OVL_MAP=49155 OVL_RO=3 OVL_KB=16 BOOT=1 in gateware/top, seeds 1 to 5, z80fpga 0.2.1. The highest bus clock was 17.84, 18.38, 17.12, 17.53 and 17.32 MHz (mean 17.64 MHz, 7532 TRELLIS_COMB).

The path that limits the bus clock is a half-cycle path. The register wait_f (falling edge) goes through waiting, cyc_done and stall. Then it goes through the choice of the next micro-op to the registers of the core (rPC, rWZ, abus). The next rising edge ends the path. The path takes 28 ns to 29 ns. The pin stage cannot make this path shorter. A register in the pin stage adds one T-state of latency, and this is not correct (the core must see /WAIT at the rising edge after the T-state that samples it).

A change in the z80fpga core makes the path short. While waiting is high, the core only holds: it does not count tcnt, it does not latch, and it does not run an action. So the core can compute its next state as if waiting was low, and use waiting only as a hold (clock enable) of the registers. The file gateware/top/z80fpga-wait-hold.patch does this (cyc_done_n, latch_now_n, stall_n, clk_go_n). The real cyc_done and stall stay for bus_float, /BUSACK and bus_last. The bus timing does not change: the pins see the same cycles.

The patch is not yet in z80fpga. Apply the patch to a copy of z80fpga and set Z80FPGA. Result with the patch:

  • Highest bus clock, seeds 1 to 5: 21.50, 20.41, 21.20, 19.87 and 19.70 MHz (mean 20.54, minimum 19.70). TRELLIS_COMB 7752.
  • The limit is now a second half-cycle path: the byte of a late read (c_din_late, falling edge) goes through rwz_v and the address adders to rPC, rWZ or abus. The path takes about 25 ns. A change of the same kind is possible for this path, but it needs a bigger change of the core.
  • make report-85k MEM2=1: 18.07, 17.90, 18.00, 19.03 and 18.14 MHz (mean 18.23) without the patch, 26.39, 24.08, 25.63, 27.44 and 24.83 MHz (mean 25.67) with the patch.
  • Tests with the patched core: make test in gateware/bus, gateware/sram and gateware/dbg pass. The SingleStepTests with 20 vectors per opcode (run_sst.py --all -n 20 --cycles, normal and LATE_READ core) pass with 0 failures. Run make test-full and the RomWBW build in z80fpga before you take the patch into z80fpga.

Things that did not help: synth_ecp5 -abc9 and -noabc9 (same result), -noccu2 (17.56 MHz on seed 1), nextpnr --tmg-ripup (no change) and router2 with --tmg-ripup (mean 18.56 MHz). The Makefile in gateware/top has the variables SYNTH and PNR for such options.

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