6502 -> 65816
What is it?This project tells you how you to make a very small module that enables you to replace a 6502 with a 65816. Except desoldering your 6502 (if needed at all), no other soldering on the original board is needed.
Updates in 2023:
- Version 3: I expanded the board with extra RAM and ROM.
- Version 4: another expansion, a PC ISA slot
The (dis)advantages of replacing your 6502I received emails with questions like: "I replaced my 6502 with 4 MHz 65816 but my system didn't become faster, how can?", "How can I address 16 MB now?" and "Some programs crash my computer, how can?" So, before you start to grasp your soldering iron, ask yourself: "Do I need this modification?"
First answer: Replacing a 1 MHz 6502 with a 4 MHz 65816 does not mean that the system suddenly becomes four times faster: a 65816 is as fast as the clock it is fed with!
I have studied the specs of the 65816 to see if it did optimize some opcodes. But IMHO it didn't so IMHO it is as fast as a 6502. So no gain here.
Second answer: The 65816 is capable of addressing 16 MB. But it needs extra hardware to be able to do so. And I'm very sure that a regular 6502 system does not have this hardware on board. Therefore such a system won't be able to address memory or I/O above the 64 KB barrier. Version 3 and 4 solve this problem.
Third answer: The 65816 has more opcodes. And the new ones replace some so called "illegal" opcodes. Running programs using these illegal opcodes will get you into trouble sooner or later.
- except not to being able to run original illegal opcodes, none AFAIK.
- You are able to learn how to use the extra features and opcodes of the 65816 on a system you're familiar with.
- once familiar with the 65816, you can think about expanding your system with some extra hardware so it can use all the features of the 65816; version 3 or 4 for example.
The storyIn 1985 I could lay my hands on a 65816 processor. During my first experiments to replace the 6502 of a VIC-20 with this CPU, it broke down :( Using my debugger I found out that the JNE instruction didn't branch anymore.
In 1997 I could lay my hands on several 65816's for peanuts. So after 12 years I could resume my experiments. This resulted in a small module that you simply put in the place of the original 6502.
The differencesThe main differences between both processors are:
Pin 65816 6502 --- ------- -------- 1 VP GROUND 3 ABORT CLK1 5 ML NC 7 VPA SYNC 35 E NC 36 BE NC 38 M/X SO 39 VDA CLK2The 65816 lacks the CLK1 and CLK2 clock signals so we have to provide them ourselves. That's where two 74F04 inverters come in view.
ABORT and BE are 816-specific inputs and only need a pull-up resistor. These resistors enable you to use these inputs later. If you are sure you don't need them, just omit the resistors and connect these inputs directly to +5V (pin 8) when the resistors are mentioned during the construction.
The 65816 lacks the SYNC output but if needed, it can be generated by using a 74LS08 AND gate. VPA and VDA should be its inputs and the output will be the needed SYNC signal. AFAIK the only system using SYNC is the KIM-1 and the Elector Junior.
The 65816 also lacks the SO input. The only 6502 systems that I know of using the SO input are the Commodore drives with only one CPU like the 1541 and 2031LP.
The DIY moduleYou only need:
- 2 40-pins IC sockets
- one 74F04
- two 10K-resistors
- some nonflexible wire
- and a 65816 of course
- Cut pin 2, 8, 10 and 12 of the 74F04. These outputs are not needed.
- Cut pin 3 to 7 as well but not too short, leave some 3 mm free.
- Cut pin 1, 3, 5, 7, 35, 36, 38 and 39 of the R-socket, just the bottom small part!
- Lay the R-socket on its back and lay the 74F04 on its back between the pins of the socket so that pin 14 of the 04 is near pin 8 of the socket and pin 7 of the 74F04 near pin 40 of the socket. Place the 74F04 with its pins 8/14 close to pins of the socket. You'll need the space on the other side later.
- Connect pin 14 of the 74F04 with pin 8 of the R-socket. Do the same with 13 and 7, 11 and 5, and 9 and 3. These connections are needed to create a stable mechanical connection with the socket.
- Bend pin 1 of the 74F04 to the middle of the IC.
- Solder a wire to pin 7 of the 74F04 and connect it with pin 21 of the socket. Bend the wire so that it can be soldered to pin 1 of the 74F04 as well.
- Use a wire to connect pin 3 of the 74F04 with pin 37 of the socket.
- Solder a wire of 3 cm long in the HOLES of pin 1, 3, 7 and 39 of the SECOND socket. (The V-socket in my case)
- First bend the wires flat on the socket.
- Then bend the wire of pin 1 so that it pops up alongside pin 7 of the 74F04 if you place the first socket on top of the second.
- Bend the wire of pin 3 of the V-socket so that it pops up between pin 4 and 5 of the 74F04.
- Bend the wire of pin 39 of the V-socket so that it pops up between pin 6 of the 74F04 and the plastic carrier of the R-socket. (this why you needed the space mentioned above)
- Bend the wire of pin 7 of the V-socket so that it lays alongside the wire going to pin 21 of the R-socket.
- Place the R-socket on top of the V-socket and solder the pins to each other. This can be difficult using a V-socket. You'll need a fine solder tip for this work and a lot of patience.
- Solder the wires to the pins of the 74F04:
1 -> 7 3 -> 4 AND 5 (!) 39 -> 6 7 -> wire towards 21 (this connects SYNC to GND)
- Solder a 10K resistor on the outside of the R-socket between pin 8 and pin 3.
- Solder a resistor to pin 36 and connect the other end to the wire leading towards pin 8.
- Place the 65816 in the R-socket and you're ready to use it.
Version 1: the PCB
Using the complete 16 MB rangeThe next line is a left-over of the original page but still valid: please see 65SC816.
In 2023 I started to expand this idea but I started with the Commodore 64. Here I created four versions but I only turned version 1, equivalent to the above version, and version 4 into a PCB. I also created two versions for the VIC-20: version three and four.
FYI: I cannot make an equivalent of version 2 for the C64 because the onboard port of the 6510 is involved, something the 6502 has not.
Version 2Version 3 and 4 are the 6502 equivalents of version 3 and 4 for the 6510. Version 2 is a typical Commodore 64 thing and could not be transformed into a 6502 version. Therefore I skipped it.
I created Version 4 for the 6502 out of the one for the VIC-20 and then downgraded it to version 3. The reason: I never created the PCB of version 3 and this was less work than starting from scratch. But just forget this practical detail for the moment.
This version makes use of the 65816's capabilities to address more than the 64 KB of memory or I/O that the 6501 or 6502 can address. In this case I will only go up to 1 MB instead of the maximum of 16 MB. Reason: one big ROM and one big RAM IC of 512 KB each is enough for me personal. But still I wanted even more: an ISA bus, see version four. So no PCB for this version for the C64. But then why for the 6502?
This version can be built in other computers equipped with a 6502. I certainly wanted an ISA bus in my VIC-20 and in other 6502 machines but I can imagine that other users don't share this idea. And the question remains, will the PCB of version 4 fit at all? So I decided to create at least version 3 for the 6502 as well; a lot of extra RAM and ROM cannot hurt.
To be able to address this 1 MB, we have to create the address lines A16..19 first. The 65816 multiplexes these lines with the data lines: when PHI0 is (L), the data bus outputs the address lines A16..23 and when PHI0 is (H), it outputs or reads the data. The address lines are latched using a 74ALS573, IC9, that is clocked by PHI1 (see later).
The 65816 will start up in 6502 mode which means that all actions will take place in Bank 0 for the moment. This simply means that the original system has to reside here. But how does the this system knows it resides in Bank 0? Simply, it doesn't and how should it? But every time the 65816 has business to do with any other bank than Bank 0, we will use a trick: buffers make the original system think the CPU is reading address $FFFF. The GAL, IC4, checks whether Bank 0 is selected i.e. all address lines A16..19 are (L), or not. The moment another bank is selected, the GAL disables the buffers IC1, IC2A, IC7 and IC8. The pull-up resistors makes the system think address $FFFF is accessed for a read and we are done.
I want to connect a 512 KB SRAM and a 512 KB FlashRAM. I will loose 64 KB of one of them because I need Bank 0 for the original system. I still haven't made one decision yet: a bit more of RAM or a bit more of ROM? But using a GAL, whatever decision I make, I always can change my mind without touching a solder iron.
What I really missed in the C64 is a way to halt it. I cannot use the DMA pin at the expansion port because negating this pin not only halts the 6510, but also tristates it. So I added jumper JP2 which gives a mean to feed an external signal. I cannot know if the RDY signal of the original system is used so I decided to keep it. If it is not needed, it won't hurt.
When negating RDY of a 6502 or 6510, the CPU halts (unless it is writing). The 65816 halts as well, even during a write cycle. But it also stops providing the address lines A16..23 and that means we have to stop PHI1 for IC9 as well. But don't worry, the GAL takes care of that as well. For the technical details, please see: this page.
If you miss the two 74F04 inverters of version 1, the GAL takes care of that also. I used two left over inputs and outputs to create a possible delay. "Possible" because that is a matter of programming the GAL. I even went so far to put a resistor and a capacitor between an output and input to create an artificial delay, if really needed.
Version 3: the PCB
Version 4 is version 3 plus a PC ISA slot. This enables the user to attach a lot of PC 8-bit cards. I have a lot of them so therefore for me it is very interesting.
The ISA bus:
- My design doesn't support DMA so all DMA related pins of the ISA bus are left unconnected.
- BALE is a weird duck. I have asked around but nobody could point me to a card using that signal. If it is meant for 74373 or 74573 latches to latch the presented address, in this case +5V will do the trick as well.
- AEN is only needed when DMA is used. We don't support DMA so we tie it to Ground.
- RESET is the reset signal for the ISA bus. But because it is active (H), it is inverted first using IC23F.
- IOCHK is the active (L) NMI signal coming from the ISA bus. Jumper JP1 gives us the choice to connect this signal to NMI or not.
- IOCHKRDY is the RDY equivalent of the ISA bus. I mixed it with the other RDY related signals using 3-input AND gate IC22A. In version 3 this used to be a 2-input AND gate.
- The ISA bus has six interrupt outputs, all active (H) and not an Open Collector output. Six 7406 Open Collector inverters convert it to "one" output. Jumper JP6 enables us to tie the result to the IRQ input of the 65816, or not. A 74LS541 8-bit buffer is used to watch the individual INT pins.
As there are only 6 pins used, I connected a 4-pin header to the last pins of the 541. Two resistors pull them high. By placing jumpers you can pull the pins (L). They can be used for what ever mini-I/O you have in mind.
The power supplyI don't think the system's original power supply can support the board plus ISA bus including a card so I added the connector as used by the IBM PC for the power supply. How you are going to use it (or not) is completely up to you.
Version 4: the PCB
You can email me here.