z80replacement · a Z80 CPU replacement with an FPGA
Routing study
PCB technology, route lengths and timing on the real balls
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/routing_study.md
This file gives the first results of the routing study of phase 1. The study uses the placement study (mechanical.md) and the pin assignment (fpga_pinout.md). The study is not a layout yet. The KiCad board has no nets and no tracks.
NOTE: The lengths and the timing below use the balls from before the pin swap of 9 November 2026 (pcb.md, "Pin swap"). The new balls change the lengths from the FPGA to the translators and to the DDR3L. The lengths from the translators to the socket pins stay the same.
NOTE (9 November 2026): The DDR3L is not on the board any more. The user replaced the DDR3L with a 2 MB SRAM (U5, 48-ball mini BGA), because the DDR3L escape of the FPGA could not be routed. The DDR3L parts of this file are history: they stay as a record of the study.
Files
| File | Function |
|---|---|
gateware/top/make_lpf.py |
The pin assignment. Writes z80r_mg285.lpf and checks the balls against the Lattice pinout file. |
gateware/top/z80r_top.sv |
The top level on the real balls: the core and the pin stage |
gateware/top/z80r_time.sv |
A timing wrapper: one group of pins per build (mingw32-make timing) |
hardware/placement_study/route_estimate.py |
The length of each bus and DDR3L route |
Run the length estimate after make_study.py, with the Python that comes
with KiCad:
"%LOCALAPPDATA%\Programs\KiCad\10.0\bin\python.exe" route_estimate.py
PCB technology: the OrangeCrab method
The OrangeCrab r0.2.1 has the same FPGA package and a DDR3L (this module has an SRAM since 9 November 2026). Its KiCad board shows how it connects the balls:
- 6 copper layers: signals on F.Cu, In2 and B.Cu, ground planes on In1 and In4, and the split power planes on In3 (with some tracks)
- no microvias (
uvias_allowed no) - through vias between the balls: 0.15 mm drill, 0.28 mm pad
- 0.089 mm (3.5 mil) track and 0.089 mm clearance
- 0.23 mm round ball pads
A via sits in the middle of four balls. The distance from the via centre to a ball centre is 0.35 mm, so the copper clearance is 0.10 mm. One 0.089 mm track goes between two ball pads (0.27 mm gap).
The OrangeCrab connects 153 signal balls with this method, down to the fifth ring of balls from the edge. This module has 100 signal balls and 11 JTAG and configuration balls. No signal is deeper than the fourth ring:
| Ring (1 = outer) | Signal balls |
|---|---|
| 1 | 36 |
| 2 | 26 |
| 3 | 28 |
| 4 | 10 |
Thus the OrangeCrab method is sufficient for the escape of the balls.
CAUTION: THE ORANGECRAB METHOD IS NOT POSSIBLE ON THIS MODULE. A through via also has a pad on the bottom side. This module has parts on the bottom side under the two BGAs, and the vias take that area. The board is an HDI 1+4+1 board, as in the PCBWay quotation. See pcb.md.
The questions for PCBWay below were for a standard 6-layer board. Ask the same questions for the HDI board:
- 3.5 mil track and space on a 6-layer board
- 0.15 mm drill with a 0.28 mm pad (0.065 mm annular ring)
- the price of this board, against the HDI price in cost.md
Route lengths
route_estimate.py measures each route as the Manhattan distance between
the pad centres. A real route is longer. A translator counts as one point
at its centre.
Bus
The longest 5 V routes go from the socket pins at the USB-C end to the translators at the other end:
- 14 socket pins are in the USB-side area (x < 19.7 mm): A4 to A15, CLK and D4. Their 5 V routes must cross the USB-side area on the Z80 side.
- A8 to A10 (pins 38 to 40) need 41 mm to 46 mm to reach U11. A11 (pin 1) needs 40 mm.
- The 5 V routes total about 790 mm.
The CLK buffer U16 was at the far end. The CLK route was 43 mm at 5 V and 18 mm at 3.3 V. U16 is now on the bottom side next to socket pin 6, and the 5 V CLK route is 8 mm. The 3.3 V route to ball B10 is 18 mm.
The 3.3 V routes from the translators to the FPGA are 4 mm to 16 mm.
The translators are in two rows on the bottom side, under the DDR3L:
- low y, next to socket pins 1 to 20: U11 (A8–A15), U12 (D0–D7), U13 (the strobes)
- high y, next to socket pins 21 to 40: U10 (A0–A7), U15 (the inputs), U14 (the status outputs)
(10 November 2026: the footprint of the socket pins was a mirror image. Pins 1 to 20 are at high y, and pins 21 to 40 are at low y. U10 and U15 are now at low y, and U11 and U12 at high y. See pcb.md, "History: the mirrored pin numbers".)
DDR3L (history, until 9 November 2026)
The FPGA ball to DDR3L ball distances use the JEDEC x16 ball map of the 96-ball FBGA (Micron MT41K128M16). Check the map against the data sheet of the selected part.
| Group | Signals | Length | Spread |
|---|---|---|---|
| Byte lane 0 | 10 | 10.3 mm to 17.4 mm | 7.1 mm |
| Byte lane 1 | 10 | 10.1 mm to 16.8 mm | 6.6 mm |
| Address, command and CK | 25 | 14.0 mm to 26.1 mm | 12.1 mm |
All routes are shorter than 30 mm. The layout must match the lengths inside each group.
Timing on the real balls
mingw32-make timing in gateware/top/ places and routes the top level
with z80r_mg285.lpf. Each build has one group of pins. The builds use
the LFE5U-12F and the LFE5U-85F, speed grade 6, seed 1. The table gives the FPGA part of
each path, from the clock edge to the output pin, or from the input pin to
the register.
The chain totals use the method of bus_timing.md:
- An output adds 18.7 ns: U16 (5 ns), the FPGA clock input (4 ns), the output buffer (3 ns) and the translator (6.7 ns).
- An input adds 6.7 ns for the translator and subtracts 9 ns for the clock path. The result is the setup time that the module needs at the socket pin.
| Pins | Edge | FPGA, 12F to 85F | Chain total | Z84C00 limit at 10 MHz | at 20 MHz |
|---|---|---|---|---|---|
| Address | rise | 11.0 ns to 11.4 ns | about 30 ns | 65 ns (#6) | 57 ns |
| /MREQ, /RD, /WR | fall | 7.8 ns to 8.7 ns | about 27 ns | 55 ns (#8) | 40 ns |
| /MREQ, /IORQ, /RD, /WR | rise | 13.6 ns to 14.1 ns | about 33 ns | not in the table | |
| /M1, /RFSH, /HALT, /BUSACK | rise | 8.4 ns to 11.8 ns | about 31 ns | 65 ns (#19) | 45 ns |
| Data out | fall | 15.9 ns to 17.4 ns | about 36 ns | 110 ns (#53) | 75 ns |
| Translator controls | rise | 8.3 ns to 12.4 ns | about 31 ns | ||
| /WAIT, /INT, /NMI, /BUSREQ, /RESET | 2.1 ns to 3.5 ns | setup about 1 ns | 20 ns (#17) | 7.5 ns | |
| Data in, memory and I/O read | fall | 3.2 ns to 4.7 ns | setup about 2 ns | 25 ns (#25) | 12 ns |
| Data in, opcode fetch | rise | 6.7 ns to 8.1 ns | setup about 6 ns | 25 ns (#15) | 12 ns |
All pin groups meet the 10 MHz limits and the 20 MHz limits. The highest bus clock is 17.5 MHz to 20.1 MHz, depending on the build. The path that limits the bus clock is the /WAIT path inside the FPGA, as in pin_stage.md.
With the debug unit
The table above is for DEBUG = 0. The bitstream has the debug unit
(debugger.md), and mingw32-make timing now measures that
build (TDEBUG=1, the default). TDEBUG=0 measures the build without the
unit. The same method gives:
| Pins | Edge | FPGA, 12F to 85F | Chain total | Z84C00 limit at 10 MHz | at 20 MHz |
|---|---|---|---|---|---|
| Address | rise | 11.9 ns to 13.1 ns | about 32 ns | 65 ns (#6) | 57 ns |
| /MREQ, /RD, /WR | fall | 8.1 ns to 8.6 ns | about 27 ns | 55 ns (#8) | 40 ns |
| /MREQ, /IORQ, /RD, /WR | rise | 15.7 ns to 16.3 ns | about 35 ns | not in the table | |
| /M1, /RFSH, /HALT, /BUSACK | rise | 9.4 ns to 11.1 ns | about 30 ns | 65 ns (#19) | 45 ns |
| Data out | fall | 23.3 ns to 23.9 ns | about 43 ns | 110 ns (#53) | 75 ns |
| Translator controls | rise | 10.3 ns to 11.3 ns | about 30 ns | ||
| /WAIT, /INT, /NMI, /BUSREQ, /RESET | fall | 1.8 ns to 2.7 ns | setup about 0 ns | 20 ns (#17) | 7.5 ns |
| /BUSREQ and the other inputs | rise | 7.8 ns to 8.4 ns | setup about 6 ns | ||
| Data in, memory and I/O read | fall | 3.8 ns to 4.5 ns | setup about 2 ns | 25 ns (#25) | 12 ns |
| Data in, opcode fetch | rise | 6.2 ns to 7.1 ns | setup about 5 ns | 25 ns (#15) | 12 ns |
All pin groups still meet the 10 MHz limits and the 20 MHz limits. The data out path from the falling edge is 6 ns to 7 ns longer. The cause is the multiplexer of the memory port of the unit, in front of the data outputs. The input path to the rising edge is about 5 ns longer, because /BUSREQ also goes to the bus hold at a stop. The highest bus clock of the whole build is in debugger.md, "Cost".
With the overlay
Memory mode 1 (memory.md, "Mode 1 in the gateware") changes
three groups of pins: the data outputs, the translator controls and the
data inputs. The table compares two runs of mingw32-make timing on the
same day, with the debug unit. The first run is mode 0. The second run is
OVL_MAP=49155 OVL_RO=3 OVL_KB=16 (pages 0, 1, E and F, 16 KB). The
values are the FPGA part, 12F and 85F.
| Pins | Edge | Mode 0 | Mode 1 | Chain total, mode 1 | Z84C00 limit at 10 MHz | at 20 MHz |
|---|---|---|---|---|---|---|
| Data out | rise | 25.3 ns, 24.6 ns | 27.2 ns, 27.3 ns | about 46 ns | 110 ns (#53) | 75 ns |
| Data out | fall | 16.6 ns, 17.5 ns | 18.8 ns, 18.5 ns | about 38 ns | 110 ns (#53) | 75 ns |
| Translator controls | rise | 9.2 ns, 11.7 ns | 16.7 ns, 16.8 ns | about 36 ns | ||
| Translator controls | fall | 2.8 ns, 4.9 ns | 4.7 ns, 7.1 ns | about 26 ns | ||
| Data in, opcode fetch | rise | 6.5 ns, 8.8 ns | 8.3 ns, 7.4 ns | setup about 6 ns | 25 ns (#15) | 12 ns |
| Data in, memory and I/O read | fall | 5.0 ns, 6.3 ns | 4.4 ns, 3.7 ns | setup about 1 ns | 25 ns (#25) | 12 ns |
All groups still meet the 10 MHz limits and the 20 MHz limits.
- The data outputs have one more multiplexer, for the opcode of an internal fetch.
- The rising edge of the translator controls is about 6 ns longer. DDIR of the data translator now includes the start of the opcode echo, which comes from the page decode of the address. A longer DDIR at the end of a write is not a problem: a memory drives the data bus only after /RD, half a T-state after the rising edge.
- The data inputs go through the multiplexer that selects the block RAM.
The values of mode 0 are not the same as those of the table above, because each run places the design again. Compare only the values of one run.
The opcode fetch, before z80fpga 0.2.0
The first measurement gave 27 ns to 28 ns for the opcode fetch. The module then needed the opcode about 26 ns before the T3 rise, and the Z84C00 gives the memory only 25 ns at 10 MHz (#15).
The cause was the one data input of the core. With LATE_READ, the action
logic of the core reads the byte of a memory read directly from din. The
pin stage gave the core the held byte in those cycles, but the static
timing does not know the cycle type. The timing thus saw a path from the
data pins through the action logic of the core.
z80fpga 0.2.0 adds the input din_late for the byte of a late read. The
live bus on din now goes only to the opcode register and the dispatch
ROM, and the fetch path is 6.7 ns to 8.1 ns. The bus timing and the
results of the bench do not change.
Next steps
- Put nets on the placement study: the bus, the DDR3L, the translator controls and the power. Then KiCad shows the ratsnest.
- Move the address translators closer to their socket pins, if the bottom side has room. Otherwise route the 5 V address lines on an inner layer along the board edges.
- Route the escape of the FPGA with the OrangeCrab method, and the DDR3L byte lanes (history: the SRAM replaced the DDR3L on 9 November 2026, and the SRAM routes are in pcb.md). These were the most difficult routes.
- Get the PCBWay answer about the 3.5 mil and 0.15 mm via rules.
Source of this page: web/ and docs/ in the
z80replacement repository. Hardware: CERN-OHL-S-2.0. Other files: GPL-3.0-or-later.