Project Snail: 65C02 Crawling At 62.5kHz
Posted: Thu Feb 11, 2021 3:06 pm
After three days of experimenting, I have a W65C02 running NOP opcodes. I have achieved this without using a multi-meter or oscilloscope. Indeed, I used a 15W soldering iron, two pairs of pliers, two breadboards, four prototyping boards of no more than 5cm*7cm, telco wire found in street, plumbing solder, about 100 LEDs (really) and a fake Arduino as an LED tester but primarily used as a USB power connector. It runs (crawls?) from a USD2 18650 lithium battery and 5V boost circuit. It uses a 16MHz ceramic resonator connected to one NAND gate and - for testing - uses chains of binary counters and indicator lights of my own devising. I call this Project Snail for many reasons:
The following day, I removed most of the counter chips from the breadboard and allocated the space for a W65C02. People buying bootleg 6502s are missing the experience of unpacking the genu-wine article. It does not have the gaudy in-your-face branding of Intel but the packaging has an understated class which is rarely mentioned on the 6502 forum.
The following description is not a good example of the art. The following is a "don't touch it - it's doing something" example of the art. My first attempt at getting NOPs was to wire power and ground. I then wired various control signals directly to power. (I know this is definitely wrong but, sometimes, it helps to actually do it wrong and confirm it for yourself. The alternative is to live on superstition and rumor.) I set opcode $69 (ADC#) rather than the standard $EA (NOP) due to the dead cycle which causes NOPping to progress through address-space at half the expected speed. I placed indicator lights on high address lines and powered up. Unfortunately, nothing worked. In particular, my debug boards, constructed a mere day before, both appeared to stop working. There was working power. There was a working oscillator. The first eight bits of the chain of binary counters worked. However, nothing beyond that appeared to work. Well, that's unlikely and that part of the reason why I made multiple debug boards.
I quickly resolved the first problem. I had inadvertently made a chain of eight 4 bit counters. 16Mhz divided by 2^32 will tick very slowly and superficially appears not to work. Placing the 2^24 divider further upstream restored the slightly slower than 1Hz blink of an indicator light. However, I did not obtain a matching blink from the 2^8 division of two counter chips followed by the 2^16 division of a 6502 program counter. At this point, I thought that maybe all that stuff about pull-up resistors might be relevant. After searching through my meager spares I found a 10k resistor. Just one. This led to an idea which should definitely make the experts wince. I connected the control lines on the left side (NMI, IRQ, RDY) via one common pull-up resistor. As I was moving the reset wire on the live circuit, it started working! I initially thought that it was due to mains hum and it only worked when my fingers provided capacitance.
The current configuration (which should not be replicated) has RES, NMI, IRQ and RDY all tied high via one common resistor. BE and SO are tied directly to power. There is no reset circuit. The oscillator is intermittent. I know this is terrible but it is steadily improving. It is also apparent that a lack of components is the limiting factor. Regardless, the current configuration has been sufficient to confirm that $69 (ADC#) cycles through the address-space and double speed compared to $EA (NOP) because the immediate instruction doesn't have a dead cycle.
Obviously, the circuit requires an oscillator module and a reset module. For reset, I purchased a Maxim MCP101, as used in the Gigatron design. Perhaps I should have purchased a Dallas Semiconductors DS1813, although given the heritage of Dallas and Maxim, they are possibly the same thing.
I also require a simple mechanism to get more than 8 bits of program into the system. Therefore, I am concurrently pursuing a computer with no ROM and a computer with no RAM. I intend to keep a NOP opcode behind a 74HC245 or similar. In addition to providing debug, it is also a hook for NOP slide video generation. This can be used concurrently with a hook in the binary counter debug board which can be used for clock stretching.
I enclose a draft circuit diagram which differs significantly from implementation and neither are good examples. I usually publish more formal diagrams but I've been too busy implementing. I hope that a doodle in the style of Forrest Mims, Garth Wilson and Donald Alcock is sufficient.
I end with a message to the lurkers and newbies. So far, my efforts with 6502 hardware are approximately the slowest and least reliable ever mentioned on the 6502 forum. Your oscillator might be a little slower. Your soldering might be a little worse. You might take an extra day or two to get this far. Maybe you get stuck somewhere. However, one thing is quite certain. If you have six pull-up resistors around the value of 2.7-3.3k, a reset thing, an oscillator module and a 6502 from a reputable source then you'll be ahead of me on your first attempt.
- All the good names, like Kestrel, Foenix and Ruby are taken.
- I should have made this a long time ago.
- It runs at 16MHz divided by 256 (62.5kHz) and this may be further reduced if I have to use one the toy USD20 20kHz oscilloscopes.
- It may be expanded to include an optical boot disk. In this case, it'll have a round thing on its back.
- I spent six hours making indicator lights. This was a good re-introduction to soldering after a long absence.
- I spent two hours stripping wire and making chains of binary counters on a breadboard.
- I spent less than five minutes fixing an oscillator circuit.
- I spent a further three hours soldering binary counters to prototype boards.
- I spent about five minutes making variations of oscillator circuits.
- I spent about 15 minutes wondering if I destroyed a W65C02. (Answer: no.)
The following day, I removed most of the counter chips from the breadboard and allocated the space for a W65C02. People buying bootleg 6502s are missing the experience of unpacking the genu-wine article. It does not have the gaudy in-your-face branding of Intel but the packaging has an understated class which is rarely mentioned on the 6502 forum.
The following description is not a good example of the art. The following is a "don't touch it - it's doing something" example of the art. My first attempt at getting NOPs was to wire power and ground. I then wired various control signals directly to power. (I know this is definitely wrong but, sometimes, it helps to actually do it wrong and confirm it for yourself. The alternative is to live on superstition and rumor.) I set opcode $69 (ADC#) rather than the standard $EA (NOP) due to the dead cycle which causes NOPping to progress through address-space at half the expected speed. I placed indicator lights on high address lines and powered up. Unfortunately, nothing worked. In particular, my debug boards, constructed a mere day before, both appeared to stop working. There was working power. There was a working oscillator. The first eight bits of the chain of binary counters worked. However, nothing beyond that appeared to work. Well, that's unlikely and that part of the reason why I made multiple debug boards.
I quickly resolved the first problem. I had inadvertently made a chain of eight 4 bit counters. 16Mhz divided by 2^32 will tick very slowly and superficially appears not to work. Placing the 2^24 divider further upstream restored the slightly slower than 1Hz blink of an indicator light. However, I did not obtain a matching blink from the 2^8 division of two counter chips followed by the 2^16 division of a 6502 program counter. At this point, I thought that maybe all that stuff about pull-up resistors might be relevant. After searching through my meager spares I found a 10k resistor. Just one. This led to an idea which should definitely make the experts wince. I connected the control lines on the left side (NMI, IRQ, RDY) via one common pull-up resistor. As I was moving the reset wire on the live circuit, it started working! I initially thought that it was due to mains hum and it only worked when my fingers provided capacitance.
The current configuration (which should not be replicated) has RES, NMI, IRQ and RDY all tied high via one common resistor. BE and SO are tied directly to power. There is no reset circuit. The oscillator is intermittent. I know this is terrible but it is steadily improving. It is also apparent that a lack of components is the limiting factor. Regardless, the current configuration has been sufficient to confirm that $69 (ADC#) cycles through the address-space and double speed compared to $EA (NOP) because the immediate instruction doesn't have a dead cycle.
Obviously, the circuit requires an oscillator module and a reset module. For reset, I purchased a Maxim MCP101, as used in the Gigatron design. Perhaps I should have purchased a Dallas Semiconductors DS1813, although given the heritage of Dallas and Maxim, they are possibly the same thing.
I also require a simple mechanism to get more than 8 bits of program into the system. Therefore, I am concurrently pursuing a computer with no ROM and a computer with no RAM. I intend to keep a NOP opcode behind a 74HC245 or similar. In addition to providing debug, it is also a hook for NOP slide video generation. This can be used concurrently with a hook in the binary counter debug board which can be used for clock stretching.
I enclose a draft circuit diagram which differs significantly from implementation and neither are good examples. I usually publish more formal diagrams but I've been too busy implementing. I hope that a doodle in the style of Forrest Mims, Garth Wilson and Donald Alcock is sufficient.
I end with a message to the lurkers and newbies. So far, my efforts with 6502 hardware are approximately the slowest and least reliable ever mentioned on the 6502 forum. Your oscillator might be a little slower. Your soldering might be a little worse. You might take an extra day or two to get this far. Maybe you get stuck somewhere. However, one thing is quite certain. If you have six pull-up resistors around the value of 2.7-3.3k, a reset thing, an oscillator module and a 6502 from a reputable source then you'll be ahead of me on your first attempt.