18

I've recently got hold of an old Zilog Z80 microprocessor and I know how to clock and test it. I do not however know how to connect RAM, I/O ports, control switches (for programming instructions into ram) or a display for output. I cannot seem to find any basic or any complete tutorials online about the simplest Z80 computer you can build. I do have some electrical knowledge, enough to read and follow a schematic.

How can I connect the microprocessor other hardware components?

  • Welcome to Retrocomputing Stack Exchange. I would recommend that you read the site's tour and have a look at some existing questions to get a feel for the site. – wizzwizz4 Jan 10 '17 at 19:13
  • 2
    Recommendation questions are only allowed sometimes...never officially...but it depends on the phase of the moon, day of week and last month's PowerBall numbers. Otherwise, AtarAge is actually a pretty good place. They have a lot of knowledgeable Z80 guys over there. If you want to try a 65C02 processor, the folks at 6502.org can't be beat. – cbmeeks Jan 10 '17 at 19:29
  • Related on EE Stack Exchange: How do I build a computer with a Z80 microprocessor? – JAL Jan 10 '17 at 19:30
  • 2
    Build Your Own Z80 Computer by Steve Ciarcia was the de facto resource back in 1981 and has been made available online for free with permission from the original copyright holders. – JAL Jan 10 '17 at 19:31
25

The MK 3880 Mostek CPU Technical manual (it's the Z80 implementation from Mostek) has a section called "Hardware implementation examples" which may help you.

Besides, the Thomas Scherrer Z80-Family Official Support Page has a section devoted to circuit schematics based upon the Z80 processor.

If you are in Facebook, there is a group devoted to share knowledge about system design on the Z80 called Z80 DIY/Homebrew Computers & Projects.

The simplest schematic I can think of, uses:

  • A Z80
  • A ROM chip (actually, EEPROM chip)
  • A RAM chip (actually, SRAM chip)
  • An 8-bit latch which will store data written to a specific I/O port
  • A 8-bit transceiver which supplies 8 bit input data when read from a specific I/O port
  • Some logic gates for decoding purposes

You have first to define your memory map: the Z80 starts executing from address 0000h after powerup or reset, so it's usual to place the ROM memory mapped to lower addresses. Say your ROM is a 32KB chip (27256 for example). It will be mapped from address 0000h to address 7FFFh. RAM can map the remainder of the address space, from address 8000h to address FFFFh. A 62256 SRAM chip can do the job.

Note that, as I/O address space is separated from memory address space, you don't have to open a gap into the memory address space in order to accomodate I/O devices. They can share addresses with memory and there won't be collisions between both because memory will only be asserted when MREQ is low, and I/O devices will be asserted when IORQ is low.

Dividing the memory space into two 32KB regions allows for a very easy decoding. Address line A15 will be used for that: if it is low and there is a memory bus cycle executing, then ROM is selected. If it is high and a memory bus cycle is executing, then RAM is selected.

Normally, chip select pins on ROMs and RAMs chips are enabled low, so we will need some logic gates to generate chip selects according to this memory map. Take A15 and OR it with MREQ. The output can be used as CS for the 27256 chip (ROM).

Take A15, negate it with an inverter and OR it with MREQ. The output can be used as CS for the 62256 chip (RAM).

The 27256 chip also uses an OE pin to output data into the bus. Just connect it to the RD pin on the Z80. Do the same with the OE pin on the 62256 chip and connect it to the RD pin on the Z80. Last, wire the WE pin from the 62256 chip to the WR pin on the Z80, so the RAM will be put into write mode only when it is selected AND there is a write bus cycle executing.

I/O devices are used the same. For a very simple design, we will use lazy decoding, using only A0 to select between an input I/O device and an output I/O device. When A0 is low, the input device is selected and with A1 high, the output device is selected. Thus, even numbered I/O ports will access the input device and odd numbered I/O ports, the output device.

Take A0 and OR it with IORQ and with RD (3-input OR gate). The output will be the select signal for the transceiver that will act as input device. Take A0 again, negate it, and OR it with IORQ and with WR (3-input OR gate). The output will be the load enable signal for the latch.

Note that, when decoding I/O devices, use both IORQ signal and WR and RD signals. Don't decode just IORQ, as the INTA bus cycle also asserts IORQ, and this may confuse the I/O logic by thinking that an I/O bus cycle is executing. The INTA cycle asserts both IORQ and M1, but not RD nor WR.

The outputs from the latch can go to eigth LED's. Each LED will have a 330 ohm limiting resistor to GND, and connected, anode to each output from the latch and cathode, to the resistor.

The inputs on the transceiver can be pulled up to +5V using a 4.7K resistor array. Reading the input device with nothing connected to its input will read $FF.

The following picture is an almost-complete schematic of a minimal Z80 system. It misses some decoupling capacitors here and there, and logic gate power supplies should be connected. Also, inputs from unused logic gates should be tied to GND so you can use either LS or HCT chips (I would recommend to use HCT chips because they impose a very small load to the Z80 output pins, which being a NMOS device, have a small fanout. In fact, a proper Z80 based design should buffer all output pins). Besides, it lacks a circuit to supply a proper clock signal, but I think the main idea is there. I have changed the output device to drive a seven segment display instead of eigth discrete LEDs.

Minimal Z80 circuit

A small program to demonstrate this system could be as this (it doesn't even need RAM in order to work, just ROM and both I/O devices). To use it, plug one end of a piece of wire to GND and touch with the other end each of the eight input pads of the pin header connected to the input device. The number (0 to 7) of the pad contacted is showed on the LED display and stays there until you touch another pin.

PINHEADER      equ 0
DISPLAY        equ 1

; Bit of B register to build digits from 0 to 7
; Bit 7 is always 0 for this example
;         0
;       -----
;      |     |
;    5 |  6  | 1
;       -----
;      |     |
;    4 |     | 2
;       -----
;         3
                org 0000h

Start           di

                xor a
                out (DISPLAY),a      ;clear display

Again           in a,(PINHEADER)     ;read pins

                ld b,00111111b       ;prepare to display 0
                bit 0,a              ;is pin 0 grounded?
                jr z,Found           ;if so, go ahead and display 0

                ld b,00000110b       ;prepare to display 1
                bit 1,a              ;is pin 1 grounded?
                jr z,Found           ;if so, go ahead and display 1

                ld b,01011011b       ;and so on...
                bit 2,a
                jr z,Found

                ld b,01001111b
                bit 3,a
                jr z,Found

                ld b,00110110b
                bit 4,a
                jr z,Found

                ld b,01101101b
                bit 5,a
                jr z,Found

                ld b,01111101b
                bit 6,a
                jr z,Found

                ld b,00000111b
                bit 7,a
                jr z,Found

                jr Again

Found           ld a,b
                out (DISPLAY),a
                jr Again
5

IMHO, the easiest way to make that lonely Z80 into something you can play with is to hitch it to an Arduino. The Arduino can generate the clock, control the data lines, operate some of the control signals.

With a setup like that, you can free-run the Z80 to see if it's working correctly, and watch its other signals to see what's going on. Speed may be an issue.

With a CMOS z80 and an Arduino with enough pins (a Mega or similar) you can slow the Z80 clock down to a few dozen Hz, use the Arduino to monitor the address lines on the Z80, and simulate RAM/ROM for the Z80.

Once that works, you can hand-assemble programs, load them into simulated RAM, and watch the Z80 run them in real time (with a slow enough Z80 clock.)

I've done this. It was actually one of those really cool computing moments watching the Z80 go through its paces executing tiny, simple programs. It's also the final project in this book: https://www.amazon.com/Junk-Box-Arduino-Projects-Electronics/dp/1484214269

Full disclosure: I wrote that book.

-JRS

  • 1
    This doesn't look like an advertisement for your book. That's hard to do; I congratulate you on that. This looks like a really fun project; if only I had a Z80... – wizzwizz4 Mar 12 '17 at 9:21
  • I guess relevant: the Z80 uses static memory for its registers. So it has no minimum clock speed. That's not universally true of CPUs, even of its generation. – Tommy Mar 14 '17 at 1:46
  • @wizzwizz4 Thanks. You can buy them at mouser in 6Mhz-20Mhz CMOS flavors. – Jim Strickland Mar 15 '17 at 5:56
  • The original Zilog Z80 was "static by design", but had to be operated with a system clock of at least 100 kHz, if I remember correctly. So choosing the CMOS flavor seems to be important for "heavy underclocking". – Ralf Kleberhoff Aug 4 '17 at 16:32
  • Regarding the minimum clock speed on the Z80 - you are right about the original (NMOS) Z80 not being able to slow the clock right down to zero. See Ken Sheriff's excellent page about reverse engineering the Z80 chip, point [7] under Notes and references. The CMOS version (now ubiquitous) can have it's clock stopped completely. – DaveBoltman Dec 9 '18 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.