All The Good Ones Were Taken

Z1a - The Memory and Logic Cards

Having settled on the Z180, which can address a megabyte of physical memory, I had to decide how to fill the memory map. What I settled for in the end is one megabyte of static RAM, comprised of two 512k × 8 bit chips. By default, the top 64k of this is mapped out, and the video RAM mapped in its place. The bottom 16k can also be mapped out, and replaced with one of four 16k banks of ROM.

In this case, the ROM is actually a flash memory chip in a ZIF socket. I did some breadboarding to make sure I knew how to write to flash memory:

And then put together a board for programming it:

The logic board controls the mapping of memory addresses to physical memory chips. It includes an 8-bit latch which can be written to by the CPU, to enable or disable ROM and VRAM and select a ROM bank.

With all these boards in place, I wrote my first little bit of machine code for the Z1a, a simple program to write a few white pixels to video RAM.

It didn't work.

After some prodding with a cheap PC-based logic analyser, I found the problem. At some point during PCB design, I had decided to reverse the order of the data pins on the bus, because it made the layout of the CPU board more straightforward. Despite hours of checking and re-checking, I had embarrassingly neglected to make the same change on the memory card, so the CPU was seeing each byte back-to-front. Once I inserted a noddy C program into my toolchain that reverses the bits of each byte before writing it to the flash ROM, the code ran as expected.

Next I put together a Hello World program, including a font and subroutines to clear the screen, scroll the screen, and display text in different colours. After some debugging, there it was:

To make the machine interactive, though, I needed a way to communicate with it. So I hooked up one of the Z180's built-in serial ports to a USB-serial converter, and I was able to send keystrokes and data to it from a PC. Well, mostly. Every now and again a character would be misread, and I couldn't figure out why. I even tried removing the pull-up and pull-down resistors from the unused serial ports to see if that would make any difference (it didn't).

Finally I discovered that in their ×1 clock mode, the Z180's asynchronous serial ports require data to be synchronised to a clock signal, which is very much not what I expected "asynchronous" to mean. This helpful little nugget of information isn't in the User Manual (Zilog UM005003-0703), but it is in the Product Specification (Zilog PS014005-0817, page 51).

Switching in the clock divider got serial communications working reliably, so I could download suitably converted images from the PC. Here's the first image I tested it with, a popular but controversial choice:

But this computer needed to be able to work independently of a PC, so before I could cut the cord it would need its own input/output capabilities...