Experiments with the Z80 CPU

A few months ago, I purchased a Z80 CPU and some other useful DIP Chips, having learnt that not only did hobbyists still build complex circuits with such chips, but there were still available to buy (although I doubt for much longer). My plan was to build a primitive ‘computer’ with it, but I have not exactly felt the joys of breadboarding hundreds of connections yet…

However, every 2 months or so, I work on this project for a few hours on a weekend, and I thought I should write a little about my struggles and achievments, if only to serve as a reference for my future tinkerings.

First Step

At first, in order to test the Z80, and figure out how I was going to put this together, I used a new Arduino Mega, which has enough pins to interface with the address and data buses of the Z80. Thanks to some help from others who wrote some arduino scripts, I managed to get the Z80 stepping through some NOPs, and the arduino to be able to recognise the data requests.

Adding memory and serial

I didn’t want to provide the program via the arduino, but wanted the arduino to program an EEPROM chip, and then set the Z80 off. The wiring was fairly simple; I mainly followed this blog which has served me well, and with a little fiddling, was able to plug in everything to my breadboards.

Programming

Now was time to write the arduino code to program the chip. I started off with some more primitive script, which has now been lost somewhere. My current script features some arduino code which can read and write to the eeprom/ram chip, code to start and stop the CPU, and it pipes the serial from computer to Z80 while the CPU is running. I also wrote a python script to communicate with the arduino, and which has a rudimentary Tkinter interface to load binaries from a file onto the EEPROM.

I have not yet been bothered to find and download a windows Z80 assembler, so at the moment am using an online one. This is not ideal but works perfectly for my currently limited programs.

Switching to RAM

Having decided to try out my RAM chip now, instead of doing the sensible thing and wiring a RAM chip into the higher addresses, I replaced the ROM chip with RAM. This means that I need to reprogram every time it loses power, but I can play around with more complex programs without doing any breadboarding. I did spend an hour wondering why it was not working until I realised that I had missed an entire connection.[1] But at the moment, it can manipulate the RAM, and use the stack to call functions (again, thanks to this source)

Next Steps

At some point, I’d like to hook up a few output devices, perhaps first a set of LEDs, as well as increase the memory available to me (at the moment, I have only connected 256 bytes worth).

I hope someone may have found this interesting/helpful. I’ll add some pictures soon…


  1. The ROM, being read-only, clearly did not require the read/write select signal whereas the RAM does.