So, a few weeks ago I was looking at my ATMega1284, which has 16k of onboard RAM, and wondered if it would be possible to emulate a 65C02 system with it. I started with the idea of using the Flash for 32k of ROM and the most of the 16k of RAM for RAM. That proved difficult to implement as RAM and Flash are accessed differently. I ended up using just the RAM, with the emulator seeing 8k of RAM ($0000-$1FFF) and 7.5k of ROM ($E200-$FFFF). I strategically placed the IO page at $E100 which makes address decoding really simple.
So far, I have a 65C02 engine functioning, minus decimal mode and the WDC SMBx, RMBx, BBRx, & BBSx codes. I also have the AVR's serial port being emulated as a simple 6551. The data register is at $E100 and the status register is at $E101, with the TDRE and RDRF flags working. The baud rate is fixed and the handshaking is ignored, writes to the command and control registers have no effect.
To test it, I took the stock SBC-2 OS, remapped the ACIA to $E100, removed the init code for the 6522's, and loaded it in the emulated ROM.
After some debugging of the emulator, the SBC-2 OS is running perfectly. I can even use the U command to do an xmodem file transfer to RAM.
I am running the AVR at 24MHz and getting about 1.4MHz speed from the 6502 engine. This is in part due to some inefficient avr register usage on my part. I plan to optimize the code with a goal of 2 MHz or more. I am currently counting 6502 cycles but am not using it to throttle the engine.
Some interesting side benefits will include being able to activate a debugging mode that will dump register states after each opcode is completed down the serial port to help track down bugs. I will also add support to download via xmodem a new ROM image for testing OS code as well as user code.
As it is, it's a single chip (plus oscillator and RS-232 driver) 6502 system. For about $20, you could buy the parts and breadboard it up and be running in about 30 minutes! If you have a 5v TTL-RS-232 to USB adapter, then you could have it in about 10 minutes.
I am considering opening up $E000-$E0FF to to the AVR port pins, providing an 8 bit data bus, 8 bit address bus, and emulated PHI2 & R/W so external IO devices can be added easily. That is just in the maybe stage.
While working on my engine, I was searching the web and came across this site:
https://sites.google.com/site/retroelec/homeIt uses an ATMega162, external RAM, and a few descrete logic chips to provide video, keyboard, sound, SD storage, and a 6502 emulator. I found it very well designed and implemented.
That's enough rambling for now...
Daryl
_________________
Please visit my website ->
https://sbc.rictor.org/