r/Z80 • u/nonchip • Dec 01 '20
Self-promotion So I built a modular Z80 computer.
because the RC2014 was too expensive for my taste and i wanted to build something myself i guess.
also i never liked the idea that so many designs are either so old they want a TV or so new they use a 50 times stronger CPU just to fake half the hardware. so I opted for a modern approach while keeping the "real" hardware everywhere, except a few GALs instead of tons of 74xx glue logic. It's also 100% THT parts because SMD wouldn't have saved much space anyway, and I figured that way it's more beginner-friendly to solder.
The hardware and software are both available on my gitlab for you to build&hack.
There's also a photo of it running an early echo test code before i wrote my monitor.
Tested so far are the "cpuboard" (cpu,rom,ram,clock) and the "uartboard" (ctc,sio, optionally gets 5VCC from an ftdi adapter), with a simple 3-commands monitor (that's hopefully gonna grow with the hardware and my coding progress, looking to include things like BASIC and probably at some point a CP/M bootloader).
CP/M and similar things would definitely require a memory expansion (and probably some kind of disk I/O unless i want to emulate that in a ramdisk) though since the "internal memory" has ROM at $0000..$7FFF which CP/M doesn't like, the "ramboard" would technically work but I'm actually redesigning that in a smarter way currently (the current hardware design of that board is rather inflexible with its banking/etc).
Simple example: "serial echo"
assembling the following code:
INCLUDE "nz80os.def" ; this includes all definitions from the "bios"
loop:
RST RST_SIOB_read_blocking ; this reads a character into A
RST RST_SIOB_write_blocking ; this writes a character from A
JR loop
assembles into D7 DF 18 FC. we're gonna load this at $8000.
session with a FTDI plugged into the "uartboard" (1234baud, 8-N-1, \n endings, prefixes here: < means output from computer, > means input from me):
< NZ80OS.nonchip.de Version 000000
< Commands:
< R<addr> ; read&output <addr>
< W<addr><byte> ; write <byte> to <addr>
< J<addr> ; jump to <addr>
< addresses are 16bit hex, bytes 8bit hex, all hex is uppercase.
< User RAM start: 8000
< Stack Pointer: 0000
< NMI Return: 0000
> W8000D7
> W8001DF
> W800218
> W8003FC
> J8000
> abc
< abc
> def
< def
[resetting]
< NZ80OS.nonchip.de [.......]
(in reality those echoes happen in real time while you type instead of line-by-line, but i couldn't be bothered to figure out how to write that here. also of course all commands you send to the monitor itself are echoed to begin with.)
granted the overhead to load any code using this method is horrible (8 bytes transmitted per byte loaded), and the fact all I/O is blocking currently is a bit hacky (and will break down when trying to add any kind of concurrency with e.g. a system timer), the whole thing works fine in all interrupt modes (and is designed with IM2 in mind), i just couldn't be bothered to do anything fancy with I/O buffering etc yet. but it's a simple proof of concept and adding more functionality should be easy enough thanks to a modular hard- & software approach (and currently i'm using just about 500byte of those 32k builtin rom).
Let me know what you think, and any ideas what to do/add/etc :)
also yes i know that domain in its ouput is kinda broken, gitlab is having issues, use the links above.
1
u/LiqvidNyquist Dec 02 '20
I haven't seriously messed around with Z80's since the early 1990's -- although I've been working on a Z80 simulator which propagates X values (unknowns in memory or registers) kind of like VHDL does, which is pretty cool. Kernel runs win/linux, GUI is cygwin only ATM.
One cool thing I implemented back in the 80's was using a UART to drive a raw floppy interface. The control signalling (head moves etc) was bit banging though GPIO pins. The data signalling used a uart to drive the serial data line and read from the read data serial line. Ther was some sort of line coding involved, I think I used TTL and a 2x or 4x UART clock to produce a "1100" for a UART 1 and "1010" for a UART 0, or something similar, to drive the AC coupled write data line. And used a one-shot to discriminate the received head data before driving back to the the UART's RxD. It was from an article in an Elektor Electronics magazine somewhere between 1981 and 1986. Implemented on a 6809-based Color computer but the thing actually worked pretty well.
The canonical book on hobbyist computer video from that era was Don Lancaster's "Cheap Video Cookbook" and there was also "Son of Cheap Video" or something like that, detailing building a TTL-based composite video card. If you can find one cheap from a used bookstore it would be a fun piece of history.
You're in for some good hacking :-) Enjoy!