Close

New Beginnings

A project log for Z80 Computer

An attempt to build a Z80 computer capable of running CP/M

techavtechav 02/14/2016 at 18:399 Comments

Well, I did it. I ordered my first custom circuit boards. I laid out a prototyping board with an ISA bus card edge, sent it to dirtypcbs, and after a month of impatiently checking the mailbox, they arrived.

New boards!

Temporary 2-slot testing backplane

I ended up with eleven boards. After I've built a few and done some testing, my plan is to order a second set of boards to use as a backplane. I'm thinking around five card slots per backplane board, with right-angle headers on the ends to link them together. Until then, I've soldered a couple slots onto cheap China special protoboards, and one slot built as a breadboard adapter.

As for the computer design itself, I decided to keep the buffers on the address and data bus since I'm going with the card-based approach and have a full set of Z80 peripherals to experiment with. And after quite a bit of going back-and-forth on the matter, I've decided to go with convention for the Z80 and use the low byte of the address bus as the IO address, leaving the high byte as an optional parameter byte. This will give the full 255 possible IO devices (instead of just sixteen as in my previous design), and give up to 8 bits for device parameters (such as A/B and C/D select on the SCC, PIO, etc). I'm using a design I first saw [Jan Verhoeven] use for selecting I/O devices: 8 DIP switches set the address of the IO card, and the card address is compared to the address bus with a 74'688 equality comparator.

Testing chip layout

I've started building with the CPU board. It will have the Z80 itself; the oscillator and clock divider; logic for /MEMR, /IOR, etc; a flags register used for selecting memory banks, along with logic for selecting the register as IO device $FF; and the data/address bus buffers. It has been quite a task, taking over two weeks of soldering so far. I'm working from a logic/chip diagram I drew inspired by the infamous diagram of the original Macintosh.

Testing the clock

At this point I'm nearly finished with wiring the CPU card (with only the low byte of the address bus to the buffer unsoldered, because it will cover some other connections). I began testing with the clock generator, since everything else hinges on it working properly, and it gave me problems on the last design. I started with a basic Pierce Oscillator design, tested it by itself, and it seemed to be working. Next step was to add in the divider, for which I'm using a 74'93 counter. At this point, the oscillator was no longer working.

This is the problem I had with the clock last time. I have much to learn about designing and building a suitable oscillator. Since the Pierce design gave me so much trouble before, I switched to another design, with a list of several to try. An hour of desoldering (and delaminating) and resoldering, and I had my next oscillator ready to test.

This one seemed to be working great. A crude Arduino frequency counter showed the primary oscillator running around 4MHz and the divided rate right around 2MHz, and both fairly stable. A little faster than I expected from my 3.6864MHz crystal, but I figured that was just a measurement inaccuracy. Content with operation thus far, I began packing up for the night. This is when I realized that for my last tests, the crystal wasn't even in place. I used female machine headers for the crystal so I could swap it out if need be, and when I went to test, simply forgot to put it back in.

The mysterious oscillator

Like I said, I have much to learn about oscillator design. I have no idea why I was able to get a fairly stable oscillator without the crystal, or why it was even remotely close to the frequency I was looking for. And even more confusing to me, I tested it with several crystals rated between 1MHz and 16MHz, and while I they would have an effect on the oscillation frequency, it was random and had nothing to do with the crystal frequency—the 16MHz crystal actually dropped it down to 1MHz!

All the same, so long as it's moderately stable, I'm ok with it. The divider should square it off to an acceptable 50% duty cycle, so it should work just fine for the Z80. For the accuracy the SCC demands, I'll just use the crystal directly connected to its own internal clock generator instead of running it off system clock. Still though, I wish I understood what was going on.

Discussions

K.C. Lee wrote 02/17/2016 at 12:12 point

FYI: might want to read up on propagation delay and rise/fall time for the 40106 part at 5V from datasheet - section 11. Dynamic characteristics. 

http://www.nxp.com/documents/data_sheet/HEF40106B.pdf

It is a very very slow part built a long time ago.   You are looking at it barely passing a logic signal ~280ns which is 5MHz or so at 5V.

  Are you sure? yes | no

techav wrote 02/17/2016 at 19:35 point

Interesting. I had gone with the 40106 because it was listed for the oscillator in my old Z80/8080/8085 book and I had several on hand. I'll have to see if I have any better inverters.

  Are you sure? yes | no

Eric Hertz wrote 02/18/2016 at 02:36 point

ECL for the win ;)

  Are you sure? yes | no

K.C. Lee wrote 02/17/2016 at 06:06 point

A crystal oscillator can be built using a single CMOS inverter, feedback resistor, 2 load capacitors and a crystal.  I would recommend using the 74HC series instead of the old 4000 parts.

http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=szza043&fileType=pdf

Some crystals above 20MHz are actually 3rd harmonics (limited by geometry on the resonant frequency), but that's well above the Z80 clock speeds.  :)

  Are you sure? yes | no

Eric Hertz wrote 02/17/2016 at 06:34 point

Nice, that looks to be quite informative.

  Are you sure? yes | no

[deleted]

[this comment has been deleted]

techav wrote 02/17/2016 at 05:20 point

I left the boards public on dirtypcbs, so you can order a set of ±10 for US$25

http://dirtypcbs.com/view.php?share=15433&accesskey=c7732035f7f133e09f8a264676de9261

  Are you sure? yes | no

Eric Hertz wrote 02/17/2016 at 05:09 point

Hah, those moments are... something. Definitely had moments like that.

  Are you sure? yes | no

techav wrote 02/17/2016 at 05:21 point

This project is almost entirely moments like that. I really don't know what I'm doing ... But hey I'm learning, and that's the whole point.

  Are you sure? yes | no