Last time I went through junk in the basement I found old ZX spectrum.This was the time I got the great idea. Have the ZX spectrum implemented in FPGA. So after a bit of searching I found ZXgate project. This is exactly the project I have been looking for. It implements the peripherals of ZX Spectrum, just have to add CPU and some external parts.

In meantime, while I was gathering information. I received a LCD screen from a broken notebook. 17inch TFT LCD screen with resolution of 1024×768 and 18bit colors. Calculated refresh rate 60 Hz. This looked like great opportunity to learn something new, and to create something cool. I decided to use the LCD as ZX spectrum display.

As for the hardware part I had this SparkFun’s Spartan 3 breakout board. 500k gate FPGA that should be big enough most home made projects. This board as such is without any external RAM and Flash ROM, except for the SPI Flash.

I needed to design RAM board that goes with the FPGA breakout board. One of the cheapest SRAM available from Farnell is AS7C3256 – 32kx8 10ns SRAM. I decided to go with 2 chips. 64k doesn’t seem much these days, but is plenty for ZX Spectrum. 64k is the size of Z80 address space.

The IO board was inspired by ZXgate’s zxio board. The original design was using through-hole parts and contained one Reset button, Composite out (B/W only), PS/2 keyboard and Tape connection. I have redesigned it to SMD parts and also added speaker, 2 LEDs and NMI button.

The last board contains LVDS transmitter from TI – SN65LVDS84. This is the key component that sends data to my TFT LCD panel. I am not sure (and not experienced enough) whether the FPGA would be able to drive the LVDS on its own.

If someone is interested in the board designs I have them in eagle format,

The ZXgate project ran by it’s own without any major modifications. I just didn’t like the idea of having external ROM for the Spectrum. I have placed the ROM code in the BRAM of the FPGA, and preloaded the BRAM with the correct data.

After deploying of the VHDL I saw Sinclair copyright. Really great feeling If you ask :-). But the computer behaved strangely – it died after ~5 seconds. After reprogramming of the FPGA same behavior repeated. It turned out to be result of my fight with the FpgaPlanner tool and I forgot to enable pull-ups on the buttons – duh.

Next step was to add the LCD panel controller. The LCD controller is pretty straight-forward once you understand what “DE-mode” is. It turns out that current LCDs don’t need two H/V sync signals and have just one signal – Data Enable. You still need to over-scan the screen by ~300pixels horizontally and ~100lines vertically, but over-scanning means to just keep clock running. DE signal it high only when pixel data is sent to the screen (low when off-screen).

Nice thing about 1024×768 screen is that ZX spectrum’s screen (256×192) fits there 4 times. So each pixel is displayed as 4×4 dot. The border is not displayed on the LCD, as it does not display anything valuable, except for the loading curtain.

The whole screen generator consists of 2 counters – horizontal and vertical and some logic that copies data from the Vram to screen. Both counters are used in address generation. Actual data is transfered even when off-screen, but the LCD panel ignores them.

I have replaced the VRAM and ARAM (video and attribute ram) with Dual port RAM. This way the ZX spectrum works uninterrupted and my display routine works on it’s own.
The result looks something like this:
FPGA setup
The FPGA board with the extension boards attached:

There are still many improvements to be done. I plan to store some applications to the SPI Flash that holds FPGA configuration. The FPGA needs about 250k bytes for it’s configuration and the SPI Flash size is ~2MB. Lot of space wasted.
I might reuse the loading menu from SpecyBoot. This project aims to add Ethernet connection to spectrum and uses nice menu to browse the network repository. Of course I will not add network logic to the FPGA as I want the system to be portable.
If you are interested watch for updates, I will post updated when some time is left.

ISE project can be downloaded HERE
Missing ROMs HERE
I am really not sure by the licenses. If there is something wrong with sharing source I should not have, please contact me, and I will remove the offending material asap.