z80replacement · a Z80 CPU replacement with an FPGA
USB-C and power
USB-C, isolation and the power rails
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/usb_power.md
Two power domains
The module has two power domains with a digital isolator between them.
| Domain | Supply | Contents |
|---|---|---|
| Z80 side | +5V from DIP pin 11, GND from DIP pin 29 | Level translators, FPGA, SRAM, flash, regulators, the Z80 side of the isolator |
| USB side | VBUS and GND of the USB-C connector | USB-C connector, ESD protection, 3.3 V LDO, USB microcontroller, the USB side of the isolator |
By default, no copper connects the two domains (R8). A computer on the USB cable thus does not connect its ground to the ground of the Z80 system, and a ground loop cannot occur.
USB side
| Function | Part (candidate) | Note |
|---|---|---|
| Connector | 16-pin USB 2.0 Type-C receptacle | At one short end of the module. See mechanical.md. |
| CC resistors | 5.1 kΩ on CC1 and CC2 | The module is a USB sink. |
| ESD protection | 2-line USB ESD diode array | On D+ and D−. |
| Regulator | 3.3 V LDO from VBUS | Supplies only the USB side, less than 50 mA. |
| USB microcontroller | Raspberry Pi RP2354A | RP2350 with 2 MB of flash in the package, QFN-60 (7 mm × 7 mm). Needs a 12 MHz clock: a 12 MHz oscillator drives XIN (cost.md). |
| Isolator | Two 4-channel digital isolators in QSOP-16: Skyworks Si8641BB-B-IU (3 forward, 1 reverse) and Si8642EB-B-IU (2 forward, 2 reverse, default output high). TI ISO7741 and ISO7742 are alternatives. | 150 Mbit/s, 13 ns maximum delay at 3.3 V. board_pins.md gives the pins and the channels. |
The RP2354A firmware uses the Raspberry Pi pico-sdk (BSD 3-clause).
One connector, one composite USB device
The module has one USB-C connector. The RP2354A is one USB device with three functions. USB calls such a device a composite device. The host computer sees a JTAG adapter and two USB serial ports on the same cable.
The Nexys A7 board does the same with an FTDI FT2232H: channel A is the JTAG adapter, and channel B is the USB serial port for the console. The z80fpga debug unit uses channel A, so the console and the debugger operate at the same time. A chip with only one channel cannot do this. The Icepi Zero board has an FT231X. On Windows, the FT231X operates as the programmer or as the serial port, not as both at the same time.
| USB interface | Class | Function | Host program |
|---|---|---|---|
| 0 | Vendor-specific, DirtyJTAG protocol | JTAG adapter for the ECP5 | openFPGALoader |
| 1 and 2 | CDC ACM, with an interface association descriptor | Console port: the console UART in the FPGA | A terminal program |
| 3 and 4 | CDC ACM, with an interface association descriptor | Debug port: the z80fpga debug unit, and the ROM and RAM loader | z80dbg_bridge.py in serial mode, and the loader tool |
The JTAG function must be interface 0, with the OUT endpoint 0x01 and the
IN endpoint 0x82. The DirtyJTAG driver of openFPGALoader (dirtyJtag.cpp)
claims interface 0 and uses these two endpoints. pico-dirtyJtag already
does the DirtyJTAG protocol on the RP2040, and the firmware can start from
pico-dirtyJtag.
openFPGALoader also has a CMSIS-DAP driver. The CMSIS-DAP v2 driver finds the bulk interface by itself, on any interface number. Use CMSIS-DAP only if the firmware gets JTAG support for CMSIS-DAP. The DirtyJTAG protocol is the first choice.
USB IDs and drivers
- The firmware starts with the DirtyJTAG IDs, VID 0x1209 and PID 0xC0CA.
openFPGALoader then finds the module without options. Before the first
release, request a PID for the module from pid.codes. With that PID,
openFPGALoader needs the options
--vidand--pid, or a cable entry in openFPGALoader. - Windows, macOS and Linux have a built-in driver for CDC ACM.
- The firmware has Microsoft OS 2.0 descriptors with the compatible ID WINUSB for interface 0. Windows then attaches the WinUSB driver to the JTAG function, and openFPGALoader can open the JTAG function through libusb. Zadig is not necessary.
- Linux needs a udev rule that gives users access to the device.
The debug port
On the Nexys A7, the debug unit uses the Xilinx user register USER3
(BSCANE2). The ECP5 also has user registers: the JTAGG primitive gives
the instructions ER1 and ER2. The FPGA design puts the 10-bit link
register of dbg_jtag_link.sv on ER1, with the same byte protocol. Refer
to docs/debug_unit.md in z80fpga. Only the primitive changes.
The firmware does the JTAG scans. The firmware reads bytes from the debug port, shifts each byte into ER1, and sends the bytes from the FPGA back to the debug port. Thus:
- The host programs see a serial port.
z80dbg_bridge.pyalready has a serial mode, so the host does not need a JTAG driver for the debug unit. - The debug unit and the loader do not need isolator channels. They use the four JTAG channels.
- The loader uses the memory write commands of the debug unit, or a second register on ER2.
GDB and udb80 use the debug port through the GDB bridge of z80fpga. debugger.md gives the path, the rules for the firmware and the parts that the module must add.
The firmware must share the JTAG pins between interface 0 and the debug port. While openFPGALoader uses interface 0, the firmware stops the ER1 scans and keeps the bytes of the debug port. After openFPGALoader loads a new configuration, the firmware waits for DONE and then starts the scans again.
The console
The console UART is in the FPGA. The Z80 reads and writes the UART through I/O ports, for example as a 68B50 ACIA at the RC2014 address. The serial data crosses the isolator to the RP2354A, and the computer shows the data on the console port. Thus the module has a console when the module operates alone, with no serial board in the Z80 system.
- The I/O address of the UART is a setting of the FPGA design.
- A setting turns the UART off. Use this setting when the Z80 system has a serial board at the same address.
- The link to the RP2354A operates at 115200 baud on the 25 MHz clock of the FPGA. console.md gives the registers and the tests.
The RP2354A gets its power from the USB cable. Thus the two serial ports are available when the Z80 system is off. The firmware can then tell the user that the Z80 side has no power.
Signals through the isolator
| Signal | Direction | Isolator | Use |
|---|---|---|---|
| TCK, TMS, TDI | USB side to FPGA | Si8641, forward channels | ECP5 JTAG, for openFPGALoader and for the debug port |
| TDO | FPGA to USB side | Si8641, reverse channel | ECP5 JTAG |
| UART TX | USB side to FPGA | Si8642, forward channel | Console input |
| /CORE_RESET | USB side to FPGA | Si8642, forward channel | Holds the CPU core in reset during a load. Does not drive the bus /RESET. |
| UART RX | FPGA to USB side | Si8642, reverse channel | Console output |
| DONE | FPGA to USB side | Si8642, reverse channel | Tells the firmware that the FPGA has a configuration. |
board_pins.md gives the GPIO, the isolator channel and the ECP5 ball of each signal.
The eight signals use all eight channels of the two isolators. A separate loader UART would need two more channels. The debug port on ER1 makes these channels unnecessary.
openFPGALoader writes the ECP5 configuration flash through the ECP5 JTAG port. Thus the isolator needs only the four JTAG signals for FPGA updates.
The Z80 side must have power during a load, because the FPGA and the flash are on the Z80 side. If the Z80 system is off, the firmware reports that the FPGA does not answer.
When one side has no power
When the input side of a channel has no power, the isolator output goes to a default state. The part number sets the default state:
- Si8641BA and Si8642BA: low.
- Si8642EA and Si8642EB, and the standard TI ISO7741 and ISO7742: high.
- TI ISO7741F and ISO7742F: low.
The module uses the Si8641BB-B-IU (U3) and the Si8642EB-B-IU (U4). The Si8642EB has the same default state as the Si8642EA, and has an isolation rating of 2.5 kV. bom_stock.md gives the reason for the change.
CAUTION: DO NOT USE THE Si8642BA FOR U4. With no USB cable, the USB side of the isolators has no power. The Si8642BA then sends a low /CORE_RESET, and the CPU core stays in reset. board_pins.md gives the details.
With these parts, TDO is low, and DONE is high, when the Z80 side is off. A high DONE is also the state of a configured FPGA. Thus DONE alone does not show that the Z80 side has power.
The firmware first reads the IDCODE of the ECP5. If all bits of the IDCODE are 0, or all bits are 1, the Z80 side has no power. A valid IDCODE is never all 0 or all 1: bit 0 of an IDCODE is always 1. Thus this test operates with either default state.
JTAG clock
The JTAG signals go through the isolator two times: TCK goes to the FPGA, and TDO comes back. The FPGA changes TDO on the falling edge of TCK. The firmware samples TDO on the next rising edge, half a TCK period later. Half a period must be longer than two isolator propagation delays plus the TDO delay of the ECP5. If that sum is 50 ns, TCK must stay below 10 MHz.
The Si8641 and Si8642 have a delay of 13 ns maximum at 3.3 V, so two delays are 26 ns maximum.
Calculate the sum from the data sheets before you set the TCK of the firmware.
Load times
USB full speed (12 Mbit/s) gives approximately 1 MB/s for bulk data. The debug port is slower, because each byte needs one 10-bit scan of ER1 and the TAP state changes. At TCK 10 MHz, the debug port gives approximately 0.5 MB/s.
| Data | Size | Time on the debug port |
|---|---|---|
| RomWBW ROM image | 512 KB | 1 to 2 s |
| All SRAM (full version) | 2 MB | 4 to 8 s |
History: until 9 November 2026 the full version had 256 MB of DDR3L, and a load of all the DDR3L took 5 to 10 minutes. With the 2 MB of SRAM, a load of all the memory is short. If a faster load is necessary, the loader can use a wider register on ER2, so that one scan moves 4 bytes or more. Measure the times on the first board and put the values in this file.
Alternatives that the design does not use
- Two USB-C connectors. The module is 25.34 mm wide, and one USB-C receptacle is approximately 9 mm × 7.5 mm. A second connector needs the other short end of the module and a second isolation path. The user also needs two cables.
- A USB hub chip with two USB devices. A hub adds a hub chip, its crystal and a second USB device chip. A composite device gives the same functions with one chip.
- An FTDI FT2232H in place of the RP2354A. The FT2232H is a fixed function chip in a 9 mm × 9 mm package, and the FT2232H needs an EEPROM. Its USB high speed (480 Mbit/s) does not make a load faster, because the data still goes through the isolator on JTAG. The FT2232H also cannot read the CC voltage for the power option (R9).
Z80 side
| Rail | Source | Loads |
|---|---|---|
| 5 V | DIP pin 11 | Translator A ports, input of the regulators |
| 3.3 V | Buck converter from 5 V | FPGA VCCIO of all banks, including banks 3 and 6 (the SRAM balls), the SRAM U5 (VDD), flash, translator B ports, Z80 side of the isolator |
| 2.5 V | LDO from 3.3 V | ECP5 VCCAUX |
| 1.1 V | Buck converter from 5 V | ECP5 core (VCC) |
| Oscillator | 25 MHz (X1), 2.0 mm × 1.6 mm | SRAM controller (clock clk25, no PLL) and housekeeping logic |
The board has no 1.35 V rail and no 0.675 V rail since 9 November 2026. Until then, a 1.35 V buck converter (U20 with L3) supplied the DDR3L VDD and VDDQ and the FPGA VCCIO of the DDR3L banks. A VREF divider made 0.675 V for the DDR3L VREF. The SRAM (VDD 2.2 V to 3.6 V) uses the 3.3 V rail. Banks 3 and 6 are now 3.3 V banks. The design uses no VREF ball. Thus the board has one buck converter less (U20) and its load is gone from the 5 V input. Estimate the loads again with the Lattice power calculator for the new design, and then measure on the first board.
Before the schematic, read the Lattice ECP5 hardware checklist for the power-up order, the decoupling and the VCCAUX requirements.
Current from the Z80 socket
A CMOS Z84C00 takes a few tens of milliamperes. An NMOS Z80 takes up to about 200 mA. The module will take more than a CMOS Z80. Estimate the current from the Lattice power calculator, then measure the current on the first board. Put both values in this file. A system with a weak 5 V supply can need a larger supply.
Option: power the Z80 system from USB (R9)
Two solder jumpers make this option. JP1 is on the bottom side and JP2 is on the top side, at the USB-C end (mechanical.md):
| Jumper | Default | When closed |
|---|---|---|
| JP1 | open | Connects VBUS to the Z80 +5V through a load switch with reverse current blocking and a current limit |
| JP2 | open | Connects the USB ground to the Z80 ground |
WARNING: WHEN YOU CLOSE JP1 AND JP2, THE USB CABLE IS NOT ISOLATED. The ground of the computer then connects to the ground of the Z80 system.
The reverse current blocking prevents current from the Z80 supply into the USB host if both supplies operate at the same time.
In this section, "R9" is the requirement R9 of requirements.md. The board has no part with this name. The jumpers are JP1 and JP2, and the eFuse is U22 (TPS259470A).
Control of the eFuse by the firmware
The RP2354A drives the enable pin of U22 (EFUSE_EN, GPIO 12). A 100 kΩ pull-down on the board holds EFUSE_EN low while the GPIO is an input, which is the state after a reset. The enable threshold of the TPS25947 is 1.2 V (rising) and 1.09 V (falling). A GPIO high level of 3.3 V turns the eFuse on. A low level or the pull-down turns the eFuse off.
The firmware uses this policy (firmware.md, "eFuse"):
- The eFuse is off at reset, and the firmware drives EFUSE_EN low at the start. The firmware never turns the eFuse on by itself.
- The host turns the eFuse on and off with a USB command and reads its state, including the level of EFUSE_FLT_N.
- The firmware accepts the request E0H (on and off) only with
wValue0 or 1,wIndex0 and no data stage. All other forms of E0H get a STALL and change nothing. - An on command while the eFuse is on with no fault changes nothing. EFUSE_EN gets no pulse, so the supply of the Z80 system stays on.
- The safe mode does not change the state of the eFuse. The safe mode needs power on the Z80 side, and an eFuse that goes off there would remove the power of the FPGA. The fault check also runs during the safe mode, so a fault of 20 ms turns the eFuse off there too.
- The firmware turns the eFuse off when EFUSE_FLT_N stays low for 20 ms. The TPS259470A is the auto-retry variant. It pulls FLT low during a current limit, on reverse current and on thermal shutdown, and it tries to turn on again after 110 ms. The firmware does not wait for that retry. The eFuse stays off until the host gives a new command.
The firmware does not turn the eFuse on at power-up, because the owner must decide. With JP1 closed and a host system that has its own 5 V supply, two supplies meet at the Z80 +5V rail. The eFuse blocks the reverse current, but the two supplies can still share the load in a way that the owner does not want. Turn the eFuse on only when the Z80 system has no supply of its own.
The firmware does not yet read the CC voltage. A USB-C sink with 5.1 kΩ CC resistors gets the default USB current, 500 mA for USB 2.0. A USB-C source can advertise 1.5 A or 3.0 A on the CC line. Today the host user must know that the source gives enough current before the user turns the eFuse on. The ADC check of CC1 and CC2 (GPIO 26 and 27) is a future change. A small RC2014 system can operate from 1.5 A. A large system with many boards can need more current than USB gives.
Known limits
- The eFuse stays on when the host suspends the USB port, and when the firmware stops. The firmware has no watchdog.
- The firmware does not read CC1 and CC2.
- The USB descriptor declares 500 mA. The current limit of the eFuse is 1.5 A. Thus the eFuse does not hold the current to the value that the descriptor declares.
- A firmware update with try before you buy
(recovery.md, level 1) starts the new image with the
eFuse off. When the Z80 side has power only through the eFuse, the FPGA
then has no power and gives no IDCODE. The host must send the on
command again immediately after the new image starts. The image keeps
itself only after a valid IDCODE for 1 s (
TBYB_HOLD_USinfirmware/src/tbyb.h), and the boot ROM resets the chip after 16.7 s. Without the on command in time, the boot ROM goes back to the old image.
Source of this page: web/ and docs/ in the
z80replacement repository. Hardware: CERN-OHL-S-2.0. Other files: GPL-3.0-or-later.