65C02 Plus ATmega4809 Equals Colin Maykish's VR65C02, a Functional Two-Chip Computer
An AVR emulates RAM, ROM, and IO devices for a real 65C02 running at a blazing 183 kHz.
Colin Maykish's weekend experiment resulted in a two-chip, eight-bit computer, the VR65C02. This minimal build features an actual 65C02 microprocessor and an eight-bit ATmega4809 AVR microcontroller (MCU). The 65C02 is the computer's CPU, running 6502-native code, while the AVR effectively emulates the RAM, ROM, and I/O devices.
The Microchip ATmega4809 is the same AVR MCU used in the updated Arduino Nano Every. The megaAVR processor has six kilobytes of RAM, 48 kilobytes of flash, and up to 31 dedicated GPIOs in the 40-pin DIP variant.
Building code to run on the VR65C02 is straightforward. The first step is assembling or compiling the 65C02 code into a binary file. Maykish provides a Python script that converts the binary into a C-header file that an Arduino sketch uses to compile and upload code to the AVR.
The ATmega4809 emulates RAM, ROM, and the 65C02's bus control signals. The RAM and ROM are essentially large arrays in the 4809's 6 KB of RAM. An Arduino sketch simulates all the bus cycles used by the physical 65C02. Two of the AVR's GPIO pins provide a pass-through UART, and four pins are accessible by the 65C02.
Emulating devices like RAM and ROM in the 20 MHz eight-bit microcontroller does come with a few trade-offs. Most notable is the 65C02's maximum clock speed. The CPU outputs two copies of its clock. Using one of those copies, PHI2, Maykish measured an effective clock speed of 183 kHz.
Looking ahead, there are possibilities for enhancing the VR65C02. For example, repurposing a couple of the ATmega4809 GPIOs to function as chip selects could enable the 65C02 to transfer data to an external RAM, boosting the computer's clock speed. Another intriguing option is to build a computer based on the ATmega4809's 48-pin QFP variant. However, one of the reasons Maykish selected this MCU is the simplicity of building the hardware with a 40-pin DIP!
The build script, Arduino sketch, and Python utility are available in the VR65C02 GitHub repository. That repo also contains an excellent write-up detailing the interaction between the AVR and 65C02. Additional information is available on this project page.