The Z80 is one of those old CPUs that is both obtainable and easy to work with — at least in some versions. [Doctor Volt] put together what may be the simplest possible setups to get a working Z80 system. He has the processor, of course. But everything else — clock, memory, and power — are from an Arduino Mega 2560. You could argue that’s two chips, but the board actually has several chips on it. On the other hand, you could probably pull off the same stunt with a bare ATMega 2560.
We’ve seen this done before, but usually with a few more support chips. If you are a purist, [Doctor Volt] also has some Z80 and CP/M experiments where the Arduino only acts as a disk drive for the computer and there are only two support chips. There are three videos for both projects that you can see below.
We were struck by how simple the first project was, though. Around 100 lines of source code is all it takes, and some of those are comments. The Arduino even provides the system memory (1K of it) and you initialize it by changing the memory.h file and reloading the Arduino.
The code does a bit of setup for interrupts and the clock and then just spins. The Arduino gets an interrupt on a CPU read and a different interrupt on a CPU write. All memory reads draw out of the simulated 1K RAM and memory writes go there, as well. The write code also can detect an I/O port write and sends that data to the Arduino serial port. It doesn’t appear to matter what I/O port you write to.
This reminded us of one of our favorite cheap Z80 projects. That board uses an ATMega32A in a similar way but also has external RAM. If you add a few EEPROMs to act as disk drives, it sits somewhere in the middle of the two computers from [Doctor Volt]. With so few parts, it is easy to get these 8-bit wonders in fairly small spaces.
Heard about mechanical switches? Maybe add a resistor to avoid some bounce. That’s what I had available in school to drive a Z80.
To avoid bounce, you would need at least a resistor and a capacitor. Unless the input pin of the switch circuit has a large stray capacitance, I guess.
Yes, and capacitors. Still less components than on an Arduino.
CMOS Z80’s are still in production. The Z84C020 is available in DIP40 and is a 20 MHz Z80
So, and this is probably a dumb question, could you pull out the CPU in say a ZX81 or ZX Spectrum and “upgrade” it with the faster processor?
I’m guessing there would be issues with other components as I think they all share the same clocksource. But in theory?
Yes you can. As the z80 is a fully static design, you can switch the clock speed on the fly. Although you have to switch it synchronized, to prevent clock jitter (which would affect the hsync/vsync, and so the display synchronization).
Check this page: http://www.user.dccnet.com/wrigter/index_files/turbo.htm
Yes, you can. As the Z80 is a fully static design, you can switch clock speeds on the fly. You just have to take care of synchronizing the switching to prevent clock jitter. As that would affect the hsync/vsync timing and cause the display to not synchronize correctly with the tv.
Here’s a way to double the clock speed of the Z80: http://www.user.dccnet.com/wrigter/index_files/turbo.htm
It would run at the original clock speed unless you have memory space set aside that let it run at full speed. In the end, it is a waste of effort as video generation is tied to the memory cycles.
I’m not sure how memory space enters into it, but yes the ZX stuff used the CPU for a lot so your video would probably be off along with keyboard scanning and anything else timing sensitive (e.g., cassette port).
The onboard DRAM and ROM are the limiting factor for (slow) access time and you would need wait states added. If you want to have faster memory, they have to be *outside* of these address space so that the slow chips aren’t selected. Pretty much all “accelerator” card do that.
The whole Zx81 is a pain in the butt, so you are much better off re-implement the whole thing in FPGA or just ditch it for some better designed hardware.
Arduino tries to pretend itself as memory and other peripherals in these 2-4 chips systems. The problem you will see is that the Arduino can’t keep with feeding the faster Z80 and become the bottleneck.
As for faster Z80, Rabbit Semconductor was making something similar, but not full binary compatible. Sadly they were acquired by digi and only selling boards and modules. I saw some 200MHz Rabbit 6000 modules on their website.
But do the newer ones have the undocumented instructions? (Like treating IX/IY as 4 more 8-bit registers IXh IXl IYh IYl, or the funny shift-left-with-1.) You dealt with these slow limited processors by wringing every last trick out of them you could find. I know some of the advanced Z80 descendants didn’t: Z280 finally got a multiply and more memory, but couldn’t see a IXh or IXl.
Cool, another nice post that takes me way back to those sentimental eras, thanks :-)
Wrote quite a few programs for embedded Z80 setups including my WAIT (pre Curtin University) Ba EE project 1982 “EFI with transmission control” on a 1972 ford escort. Ie the center console held an S100 prototype board with the CPU, glue logic and a to d and and an 8 digit segment readout which also simulated the 4 cylinder engine by up/down boxes lol.
Inputs, pump and injectors off a VW Kombi. The Z80 nmi switched out the optional onboard rom CP/M to service injector firing with AFM input in background. To load from a floppy needed to have the engine off doh. It mostly worked, well long enough to pass the engineering project unit. Financed it myself and refused the $50 subsidy as back then it assigned copyright to the department, ugh they didn’t like that one bit, threat of legal wtf.
Btw. Exploited the 16 bit z80 parallel output mode despite it being an 8 bit bus, no one else did it and it’s not an undocumented instruction either – worked just fine, details buried in the instruction mode operation, it’s a nice trick rather unconventional decoding issue though ;-) Ask if interested :-)
Also bought a few “Superbrains” from USA, dual z80 cpu white fibreglass desktops with b/w screens dual floppy to run Pascal mt+, basic and Osborne accounting packages for clients. Good experience, wrote sizable amount of os drivers for Winchester hard disks. Heaps of projects in data base even asked to do sizable lotto analysis for well well paying client, weird.
Great experiences, these days can fairly easily emulate the Z80 on any CPU of last 20 years a heck of a lot faster than the 8Mhz max latest z80 though mine only ran at 4Mhz. I recall something like avocet was around that time, prob been updated a heap by now.
Cheers
> Btw. Exploited the 16 bit z80 parallel output mode despite it being an 8 bit bus, no one else did it and it’s not an undocumented instruction either – worked just fine, details buried in the instruction mode operation, it’s a nice trick rather unconventional decoding issue though ;-) Ask if interested :-)
Yes, please more about unconventional ways
G’day Bert,
The unconventional part is only the decoding. The z80 instruction set offers the BC registers expressed as a single 16 bit wide operation on the address bus onwon some output instructions with 8bit data on the data lines.
So if you want to do 16 bit parallel output then put the data in the BC registers with the output address on the data lines and decode that, ie swap around the decoding method. Just need to factor in the different delays from the standard output and it works fine :-)
Not many places back then that could use comparatively high speed 16 bit out other than DACs but, of some use on waveform generation as a cheapie way eg from eprom or fft filter to BC registers to DAC, may E a dead simple custom waveform generator…
Wow! This brings back memories. Building an 8085 computer was my senior project. It had 27128 eprom and 26128 static RAM. It was all wire-wrapped together and we had to write the operating system from scratch! I’m amazed that you can now download a IDE for free. Back in the late 80’s that would have cost thousands of dollars!
Motorola were pretty generous with software tools in that era I believe. Though an honest to goodness “IDE” wouldn’t have helped you much unless you had a Vax in the garage.
“Great experiences, these days can fairly easily emulate the Z80 on any CPU of last 20 years a heck of a lot faster than the 8Mhz max latest z80 though mine only ran at 4Mhz. I recall something like avocet was around that time, prob been updated a heap by now.”
Probably throw in another decade, because the 90s went from 3 or 4 times as fast to 30+ times as fast emulation, and maybe another half decade because 68020 and 286 could do double speed Z80 emulation.
I did a lot of cross development for the 6805 using Avocet assembler on a Quasar QDP100 with a Televideo 910 terminal. Two 8″ floppies! We thought we would never need more than those boxes.
As for the 16-bit I/O, was that the repeated input/output instructions? Seems like I recall that.
Hi All,
Can do 16 bit wide output in one cycle with modded io decode, info here:-
https://hackaday.com/2020/07/17/a-z80-board-with-very-few-parts/#comment-6268242
PS save name select when writing comments stopped working on Lenovo android tablet, cheers
You can make a real minimalist Z80 with a Z80, a ‘138 octal decoder, a 27xx eprom, a 6116 8 bit widex2k RAM and a 8250 for the serial port and an 8255 for GPIO parallel ports access. That was sort of the standard “single board micro” in the 80s. Wirewrapped, soldered, etc. a bunch of them. You could probably ditch the 8250 and do software UART if you’ve got some code laying around for it. And you’ll need a EPROM eraser.
I built essential that on a STDBUS wirewrap card many many years ago.
Sounds a bit like a microbee trying to return from the dead :) just add the 6845.
This is not the first Arduino Mega Z80 pairing. Goran Devic did it back in 2014 https://baltazarstudios.com/arduino-zilog-z80/
no Arduino version https://github.com/Kris-Sekula/mgh80