GlennSmith wrote:
Hi and a happy new year to all.
Does anyone have a SIMPLE hardware circuit for implementing single-step with the 6502? I need to do this entirely in hardware, not a hybrid version like found on the KIM-1.
Thanks, in advance, for any help.
Regards,
Glenn Smith
I've never built one, but I can't imagine it being terribly hard. The 6502 has a pin called _SYNC, which goes low when fetching an opcode. When single-stepping, I envision it should be possible to drive the RDY line low when _SYNC goes low. That will indefinitely delay the processor until RDY goes high again.
The single-step circuit sounds to be little more complex than an AND-gate and a 7474-type flip-flop. _SYNC's falling edge (must be edge triggered!) clears the flip-flop, causing its Q output to go low. The Q output is AND'ed with the RDY signal that would otherwise go to the processor. If you just tie RDY low in your circuit, then you can dispense with the AND gate.
A button that you can press can hook up to a resetable, one-shot multivibrator (what a lovely name for what basically is a switch debouncer), which is responsible for setting the flip flop. That brings Q high again, thus letting RDY go high, allowing the chip to continue on to the next instruction.
Note that I haven't verified this, nor built this. But this circuit, or something very much like it, ought to work. This will allow the CPU to execute single instructions under your (hardware) control.
NB: The 65816 has two signals called VPA and VDA. When those two signals are both asserted at the same time, that indicates an opcode fetch (e.g., _SYNC := VPA NAND VDA) for the purposes of this circuit). Thus, it's also possible to do with the 816.
NB2: sorry for the edit, but I was smoking crack when I first wrote this post. The 6502 and 65816's RDY signals are active HIGH, not active low. Thus, most of my logic was reversed. I've corrected that above. I've also corrected the discrepencies between _VPA/_VDA and VPA/VDA.