z80replacement · a Z80 CPU replacement with an FPGA

Console ACIA

the console ACIA in the FPGA

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/console.md

The module has a console UART in the FPGA. The Z80 program uses the UART as a 68B50 ACIA at the RC2014 address. The RP2354A connects the UART to the console port of the USB-C connector (usb_power.md, "The console"). Thus the module has a console when the Z80 system has no serial board.

STATUS: SIMULATION ONLY. gateware/bus/z80r_acia.sv has the ACIA, and gateware/bus/tb_acia.sv tests the ACIA. No board test is done yet.

Z80 code can turn the ACIA off and on with the control port (z80_control.md). A removed ACIA does not hold /INT low.

Settings

The settings are parameters of z80r_top and z80r_bus.

Parameter Default Function
ACIA 1 in z80r_top, 0 in z80r_bus 1 adds the ACIA. Set 0 when the Z80 system has a serial board at the same address.
ACIA_BASE 80H The control and status port. The data port is ACIA_BASE + 1.

With the boot copy (BOOT at 1), the header of the flash image can also turn the ACIA off and set its address, with no new bitstream (memory.md, "Settings in the flash"). The header has an effect only if the bitstream has the ACIA (ACIA at 1).

The ACIA decodes address bits A7 to A1. Thus the ACIA uses only the two ports, with no mirror ports. The ACIA of an RC2014 serial board also answers at mirror ports. A program that uses a mirror port thus does not find the ACIA of the module.

Registers

Port Read Write
ACIA_BASE Status Control
ACIA_BASE + 1 Received data Transmit data

Status bits:

Bit Name Value
0 RDRF 1: a received byte waits
1 TDRE 1: the transmit FIFO has room
2 /DCD Always 0
3 /CTS Always 0
4 FE Always 0. A byte with no stop bit is lost.
5 OVRN 1: a byte was lost, because the receive FIFO was full
6 PE Always 0
7 IRQ 1: the ACIA asks for an interrupt

Control bits:

Bits Function
1, 0 11: the reset command (the 68B50 data sheet calls it "master reset"). The FIFOs become empty, and OVRN becomes 0.
4 to 2 No effect. The link is always 8 data bits, no parity, 1 stop bit.
6, 5 01: the transmit interrupt is on. Other values: off.
7 1: the receive interrupt is on

The divide bits (1 and 0, other than 11) have no effect. The baud rate of the link is always 115200.

How the ACIA operates

  • The bus does not see a cycle to the two ports. The module does not assert /IORQ, /RD or /WR for these cycles. The address is on the bus, as for other cycles.

  • The ACIA has a FIFO of 16 bytes in each direction. A read of the data port takes the oldest received byte. A read of the data port also sets OVRN to 0, as on the 68B50.

  • The interrupt request goes to the core together with /INT of the bus. The request is on in two cases:

    • The receive interrupt is on, and RDRF or OVRN is 1.
    • The transmit interrupt is on, and TDRE is 1.

    Use IM 1. The ACIA does not supply a vector for IM 2.

  • A bus /RESET makes the FIFOs empty and turns the interrupts off.

  • The serial side uses the 25 MHz clock (X1), so the baud rate does not change with the bus clock. Each byte crosses between the two clocks with a toggle and a synchronizer of two registers.

The link between the FPGA and the RP2354A has no flow control. The eight isolator channels have no free channel for RTS and CTS. Thus a byte from the computer is lost if the receive FIFO is full. The firmware sends the bytes at 115200 baud, about 11500 bytes per second.

The terminal program can set any baud rate. The firmware does not change the link for the setting.

Size

Place and route of z80r_top with the debug unit and the ACIA, seed 1: 7456 LUT4 and 959 flip-flops, 404 LUT4 and 115 flip-flops more than with no ACIA. The 25 MHz clock reaches 144 MHz to 153 MHz. The highest bus clock is 16.9 MHz to 17.7 MHz, the same range as with no ACIA.

Test

mingw32-make test in gateware/bus runs tb_acia.sv with a bus clock of 7.4 MHz, 20 MHz and 2 MHz. The bench is the RP2354A end of the link at 115200 baud. The program acia_prog.z80 does these steps:

  1. The reset command, then HELLO, CR and LF, with a poll of TDRE.
  2. The bench sends 20 bytes, and the program does not read them. Then the status is 23H (RDRF, TDRE and OVRN), the program reads 16 bytes in the correct order, and the status is then 02H.
  3. The receive interrupt (IM 1) takes 5 bytes, and the program sends the bytes back.
  4. The program sends 40 bytes as fast as TDRE permits. The transmit FIFO becomes full.

The bench also examines the bus:

  • No cycle on the bus for the two ports of the ACIA.
  • No /RD and no /WR without /MREQ or /IORQ.
  • No two drivers on the data bus.

The last line is PASS or FAIL.

Not done yet

  • A board test with the RP2354A firmware and a terminal program.
  • Mirror ports, if a program needs them.

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