To test a Z80 we need to convince it to do something useful, without actually connecting it up to an active system - ie, nothing with ROM/RAM/etc. This is actually
a whole lot easier than it sounds.
The tester works by providing the Z80 with only just enough signals to run -
- +5v and ground sources
- A valid clock source (whether hand-stepped or slow)
- Appropriate interrupt, bus arbitration and WAIT pins tied high
- Data pins tied low
- LEDs on several least-significant-bit address lines
So how does it work?
We tie certain signals in a specific direction to ensure that the Z80 is being told what to think about those signals. If we left them disconnected, because
they were input pins, they would float. This would appear as a high signal, but might cause unintended results; As such, we tie them to ensure it's doing
precisely what we want them to do.
- We tie /INT and /NMI high to tell the Z80 no interrupts are occurring.
- /WAIT is tied high so the Z80 isn't sitting waiting on some slow device (like old SRAM).
- /BUSREQ is tied high to tell the Z80 that no one is attempting to take the bus over (for example, attempting a DMA transfer.)
Now this is where the clever bit comes in. The Z80, as with pretty much all processors, has a NOP instruction - or a No Operation. A NOP does precisely nothing, but when
executed skips to the next instruction in memory. A NOP in Z80 is a $00 instruction, or all of the data lines set low. By tying all of the data lines to ground we are
faking the appearance of a continuous stream of NOPs in RAM. The Z80 will fetch an instruction, execute a NOP (ie, do nothing), and then increment the programme counter.
The Z80 will then fetch the next instruction - surprise, a NOP - and then increment the programme counter again.
This is where our LEDs between the address pins and ground come in. Because the PC is incrementally counting up, forever pulling the next instruction in memory, we can
watch the address lines count upwards in binary as they request bytes from memory. Our LEDs will count, in binary, forever... well, until we unplug the thing.
Why is this useful? Well, it firstly lets us get our feet wet in what signals do what, why they're tied in a specific way, and the basic electrical connects that are
required (Vcc, GND, decoupling caps, so on), but it also proves to us that the Z80 chip we have selected does, in fact, function. Plus, blinking lights are cool.