z80replacement · a Z80 CPU replacement with an FPGA
FPGA selection
the FPGA family, and the lite and full versions
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/fpga.md
The recommendation is the Lattice ECP5 family (LFE5U) in the csfBGA285 package. The lite version and the full version use the same PCB and different FPGA densities.
What the FPGA must hold
The CPU core is the one from z80fpga. That core passes all 1,604,000 cases of the SingleStepTests suite, and the suite also compares the bus trace in every T-state. The z80fpga documents give these sizes for the core alone:
| Family | Logic | Flip-flops | Block RAM |
|---|---|---|---|
| iCE40 | 4641 LUT4 | 338 | 3 SB_RAM40_4K |
| ECP5 (LFE5U-25F) | 5303 LUT4 + 261 CCU2C (5825 LUT4 positions) | 335 | 1 DP16KD |
The module also needs a bus interface, an SRAM controller (full version), a JTAG or UART link to the USB side, and the memory map logic.
The module needs these I/O pins:
| Group | Pins |
|---|---|
| Z80 bus signals | 38 |
| Level translator controls (DIR, OE) | 5 to 8 |
| SRAM, 2M x 8 (full version): 8 data, 21 address, 3 control | 32 |
| Configuration flash (shared with the configuration pins) | 4 to 6 |
| Link to the USB side (UART and control) | 3 to 4 |
| Oscillator, LEDs | 3 |
| Total | about 88 of the 118 pins |
All pins operate at 3.3 V, and all banks are on 3.3 V. The SRAM pins are in banks 3 and 6 (fpga_pinout.md).
History: before 9 November 2026 the plan had a 16-bit DDR3L with about 49 pins. The DDR3L pins had to be in the banks that have DQS groups. Those banks operated at 1.35 V. The total was about 105 of the 118 pins. The user replaced the DDR3L with the SRAM to make the PCB routable (ddr3.md).
Candidates
| Family | Open toolchain | Remaining life | Result |
|---|---|---|---|
| Lattice ECP5 (LFE5U) | yosys, nextpnr-ecp5, Project Trellis. Mature. z80fpga runs on the Icepi Zero (LFE5U-25F) with these tools. | Lattice gives 2045 as the earliest anticipated obsolescence. | Selected. |
| Lattice iCE40UP5K | yosys, nextpnr-ice40, Project IceStorm. Mature. | 2035 in the same Lattice table. | Rejected. The core alone uses 94% of the part in z80fpga. The SG48 package has 39 I/O pins, and the bus alone needs more. |
| Gowin GW2AR-18 | yosys, nextpnr-himbaechel, Project Apicula. | No published longevity table found. | Alternative. The package holds 8 MB of SDRAM, which removes a part. The z80fpga build on this part restarts after the banner, and the cause is not known yet. nextpnr does not time block RAM inputs on this family. |
| Lattice Nexus (Certus-NX, CrossLink-NX) | yosys, nextpnr, Project Oxide. Less mature than Trellis. | 2045 in the Lattice table. | Possible later. Look at this family again if Project Oxide becomes as complete as Trellis. |
| AMD Artix-7 | openXC7 is experimental. The normal flow needs Vivado. | Long. | Rejected by R11. |
The Lattice lifetime dates come from the Lattice blog post Product Longevity You Can Count On (June 2024). Lattice calls each date the earliest anticipated obsolescence. The dates are not a supply guarantee.
The ECP5 csfBGA285 package
The csfBGA285 package (Lattice suffix MG285) is 10 mm × 10 mm with a
0.5 mm ball pitch and 118 user I/O pins. The LFE5U-12F, -25F, -45F and
-85F all come in this package. A 10 mm package fits across the 15.24 mm
width of the module. The caBGA256 package is 14 mm × 14 mm and does not
fit between the two rows of socket pins. The 85F is also not available in
caBGA256.
The 0.5 mm pitch needs HDI PCB technology: laser microvias, or vias in pads with fill and plating over the fill (VIPPO). PCBWay offers this technology. See mechanical.md.
Lite and full versions
| Lite | Full | |
|---|---|---|
| FPGA | LFE5U-12F-6MG285C | LFE5U-85F-6MG285C |
| LUT4 | about 12,000 (see the note below the table) | about 84,000 |
| Block RAM | 32 EBR, 576 Kbit (72 KB) | 208 EBR, 3744 Kbit (468 KB) |
| RAM | not fitted | 16 Mbit asynchronous SRAM (2 MB), IS61WV20488FBLL-10BLI (sram.md) |
| Internal memory | up to 32 KB in block RAM (memory mode 1, see memory.md) | 2 MB SRAM (memory mode 2 uses 1 MB), and up to about 440 KB in block RAM |
| Price of the FPGA | US$23.02 (Digi-Key) | US$69.63 (Digi-Key). LCSC listed US$41.54 for one part. |
The LFE5U-12F uses the same die as the LFE5U-25F. nextpnr thus permits about 24,000 LUT4 on the 12F, but Lattice specifies only 12,000. The percentages for the 12F in pin_stage.md and bus_timing.md use 12,000. The cost.md prices are from November 2026.
A real Z80 has no internal memory. Thus the lite version is a complete Z80 replacement when the system has its own ROM and RAM, as every RC2014 has. The internal memory is an extra.
The LFE5U-25F is a middle choice. The z80fpga Icepi Zero build uses that part with 32 KB of ROM and 64 KB of RAM in block RAM.
Items to check before the schematic
- Compare the csfBGA285 pinout files of the 12F and the 85F from Lattice. Use only balls that have the same function on all densities.
- Count the pins of each bank in this package. All banks that the design uses operate at 3.3 V. (The OrangeCrab board uses DDR3L on an LFE5U-25F in this package. This design does not use DDR3L.)
- Get current prices and stock for the 12F, 25F and 85F from two distributors and from the PCBWay parts service.
- Build the z80fpga core with the bus interface for the LFE5U-12F at speed grade 6. Read the utilization and the timing report.
Load time
The ECP5 reads its bitstream from the configuration flash U17 with the
master clock (MCLK). ecppack writes the MCLK frequency and the read
command in the bitstream. The default is 2.4 MHz and no compression. The
load time is the number of bits divided by the MCLK frequency. The Z80
host bus has no CPU during this time.
Fixed (11 November 2026): gateware/top/Makefile has two sets of
ecppack options.
BITOPTis--compress --freq 38.8 --spimode fast-read.BITOPTis only for the file that goes into the flash U17 (build/top-85k.bit).SRAMOPTis--compress.SRAMOPTis for the emergency bitstream of the safe mode (build/safe-*.bit) and forbuild/sram-85k.bit.build/sram-85k.bitis the same design for a load into the SRAM of the FPGA through JTAG (openFPGALoader).
mingw32-make bit-85k makes build/top-85k.bit and build/sram-85k.bit.
mingw32-make bit-12k makes the two files for the 12F. Override BITOPT
or SRAMOPT on the command line to change the settings.
The reason for the two sets: --spimode adds the command 79 49 to the
bitstream. The ecpdap README and ecppack.cpp of Project Trellis say that
a JTAG load into the SRAM of the FPGA can stop with this command. Until
the verification of 11 November 2026, the emergency bitstream had this
command (todo.md, item 5).
Load time of the 85F image of 8 November 2026 (old build, new options):
- default (no compression, 2.4 MHz): 1948588 bytes, 6.50 seconds
--compressonly, 2.4 MHz: 408525 bytes, 1.36 seconds--compress --freq 38.8 --spimode fast-read: 408529 bytes, 0.084 seconds
The 12F image is 227135 bytes compressed, 0.047 seconds at 38.8 MHz. The tolerance of the MCLK is 15 to 20 percent, so a slow clock gives about 1.2 times these times.
Each time is the data transfer only: bits divided by frequency. The power-on time and the initialization time of the ECP5 come before the data transfer, and they are not in these numbers. The times are not measured: nobody has built the board.
Reasons for the settings:
--freq 38.8is the highest value ofecppackunder 50 MHz. The W25Q128JV accepts 50 MHz for the read command 03H at 3.3 V. For 0BH it accepts 133 MHz. The next value, 62.0 MHz, is too close to the limit with the MCLK tolerance. FLASH_CLK is a track of about 15 mm (14.98 mm on the board of the third round) with no series resistor. The track is short for a clock of 39 MHz. R47 (1 kilohm, to +3V3) is the pull-up resistor of FLASH_CLK since the third board round (todo.md, item 5).--spimode fast-readmakes the ECP5 use the command 0BH with one data line. The dual and quad modes need more flash balls as data lines and the QE bit, and they save little at 38.8 MHz.--compressmakes the file 4.8 times smaller. The load through JTAG accepts a compressed file:firmware/src/djtag.csends the bits of the file from openFPGALoader unchanged, and the ECP5 decompresses them. For a load into the SRAM of the FPGA through JTAG, usebuild/sram-85k.bit, which has no SPI mode command. For a write of the flash U17, usebuild/top-85k.bit.- Check on the first board: the time from power-up to DONE, and a read of the flash with the same clock.
Source of this page: web/ and docs/ in the
z80replacement repository. Hardware: CERN-OHL-S-2.0. Other files: GPL-3.0-or-later.