Single Step Instruction Circuit

IMG_8870

While debugging you may find you would like to step through each instruction executed to assure that the function of your system is correct. Instead of cycling the clock over and over to get through each instruction with a single-step clock circuit, a new circuit can be built to receive a de-bounced button press, and then execute one instruction at the speed the Z80 is set to run at. This requires a single-step instruction circuit. To build such a circuit we will be exploiting two control signals on the Z80, WAIT (Pin 24) and M1 (Pin 27).

M1 is an output control signal that goes low each time an instruction is fetched. WAIT is an input control signal that is sampled a short time after the instruction fetch, and when activated suspends the operation of the Z80. To allow only one instruction to execute at a time a D-flip-flop and one-shot are used. First, two NAND gates (74LS00) are used to de-bounce a momentary SPDT push button. The button press signal activates the D-flip-flop (74LS74) triggering the WAIT line to become high, and the Z80 to leave the WAIT condition to run an instruction. After this instruction is run the one-shot is triggered by the next M1 signal which is prompted by the instruction fetch. The one-shot’s output resets the D-flip-flop back which activates the WAIT signal to pause the Z80’s operation. The final toggle button adds a NAND gate and a toggle switch for toggling between an instruction stepping mode, and standard running mode. The finished single-step instruction circuit can be seen below. This circuit is a modified version of the circuit outlined in Figure 4.5 of “Build Your Own Z80 Computer” by Steve Ciarcia which I also display below. Instead of using the 74LS121 as a monostable multivibrator (one-shot) I have opted to use the 555 timer to cut down on the amount of different parts needed. Also, I opt for 10K resistors instead of 4.7K to standardize the components needed.

BYOC Figure 4.5

[Build your Own Z80 Computer Figure 4.5]

I have tested the operation of this single-step instruction circuit, and the results can be seen in the pictures below. To easily see the output of my Z80 system I  have developed an 8-bit LED driver. This board accepts VCC, GND, and eight signal lines to display the contents of the bus or control signals visually. Below I have also included a gallery of pictures to show where the hardware is currently, and the eagle files for the single-step instruction circuit.

All Files from this project can be downloaded from my GitHub Repository,

Z80 Project Repository

This slideshow requires JavaScript.

About Matt Cook

Computer Engineer
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

9 Responses to Single Step Instruction Circuit

  1. Dave says:

    Hi,
    what capacitors did you use around the 555?
    regards
    Dave

    • Matt Cook says:

      10nF and 47uF as per the schematic above. The 10nF is ceramic and 47uF is electrolytic.

      • Dave says:

        Hi Matthew, thanks a lot for the reply.
        Not really having much of a clue what I am doing and not understanding the selection criteria, I used a 47uF tantalum. I’m not sure how critical it is, but the circuit seems to work fine. I have only done some limited testing with it, but if you are interested, you can see where it is applied at the website link I entered with this reply.
        regards
        Dave

      • Matt Cook says:

        I am sorry. The above schematic is actually wrong. In my laziness I replicated the 555 as an oscillator instead of a one-shot. This website will tell you how a one-shot can be realized. Link

  2. Dave says:

    Hi Matthew, thanks for the update, the only difference seems to be to use two electrolytics of the same value (0.01uF, other than that, the circuit is the same. Is that right?

    • Matt Cook says:

      Yup, other than that the circuit is identical. Just 10nF (0.01uF) where you see the two capacitors. Will change this soon so it causes no more confusion. Look up the 555 timer in mono-stable mode (one of its operating configurations) and you will find a lot of information about how to choose capacitors, and how to produce accurate output periods. For this purpose it is not critical however so I am sure there is a wide range that the capacitors could vary with. My only concern with the schematic I referenced is that pin 4 (reset) is tied to the input pulse from ‘M1’ (Z80 Pin 27). You see, when ‘M1’ goes low the output of the 555 one-shot should go high, but since this is tied to pin 4 (reset) of the 555 this should also reset the output of the one-shot (555). When the output goes high from the one-shot it is fed to the NAND gate. The NAND gate’s inputs are tied so when the one-shot fires it will produce a logical ‘LOW’ on the NAND gate’s output which is fed to the D-flip-flop’s Active-Low Clear pin. The logical ‘LOW’ produced by the NAND should clear out the flip-flop, and the cycle should continue. I think because of propagation delay within the 555, the schematic still works since the one-shot fires AND resets at the same time. It may not work in every 555 chip. I will experiment with the difference in operation if Reset (pin 4) is tied to VCC versus tied to the input pin (pin 2).

      Also, What link were you talking about because I don’t see it posted above.

      • Dave says:

        Hi Matthew, I meant the website link that I entered when I made my reply. You can get to it if you click on my name.

  3. Dave says:

    Hi Matthew, thanks a lot for the very detailed explanation. I will swap out the 47uF for another 10uF (ceramic) with RESET still tied to /M1 and try it out on my working MTX again and let you know.

  4. Dave says:

    Hi Matthew, thanks for the e-mail, that reminded me that I never followed up on this post. So, just for completeness on the blog, I can confirm that I have now replaced the 47uF cap with another 10nF, and the circuit appears to be working as expected. Thanks again for the info.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s