emu8051
emu8051 copied to clipboard
AVR port of emu8051
I want to be able to have an ATmega328P emulating an AT89C2051.
So here is the experimental branch that makes it possible. And that is the why I started #20 (fixed sized integers)
It is obviously not for merging. yet.. 😉
For the AVR port, I plan to make codeMem
pointing to FLASH, which could be uploaded via TX/RX thanks to a bootloader.
Enabling 8051 programming with the Arduino IDE and bring back that glory from its past 🤣
Btw, I do know it is totally pointless. But where would be the fun if not...
It's not entirely pointless =) people are using microcontrollers to masquerade as other parts all the time..
I just posted the pin mapping I'd like to reuse.
Copying over the relevant parts:
Pin Mapping
We need to assign pins. I'm trying to keep the functionality the same, even if it means to move bits around when programming.
A major difference is we assign a specific PIN to RST for the 8051, so we can reset the emulated 8051 without resetting the AVR.
8051 | AVR | Function |
---|---|---|
RST | PB2 | RST 51 |
XTAL1 | PB6 | OSC1 |
XTAL2 | PB7 | OSC2 |
P3.0 | PD0 | RX |
P3.1 | PD1 | TX |
P3.2 | PD2 | INT0 |
P3.3 | PD3 | INT1 |
P3.4 | PD4 | T0 |
P3.5 | PD5 | T1 |
P3.7 | PD3 | |
P1.0 | PD6 | AIN0 |
P1.1 | PD7 | AIN1 |
P1.2 | PB0 | |
P1.3 | PB1 | |
P1.4 | PC0 | |
P1.5 | PC1 | |
P1.6 | PC2 | |
P1.7 | PC3 | |
none | PC4 | SLOW |
Finally, I'm thinking about reusing a GPIO (PC4/SLOW) to signal that the emulation is lagging from realtime. The idea being that emulator should be running at a precise clock divider from the main clock. Prescaling as much as needed to cope with the emulation tax, and also adding as much delay as needed on the fast instructions.
If there is an instruction that is expensive to emulate, I'm planning to "borrow" delay cycles from the following fast instructions in order to be accurate on average. And have the SLOW pin to signal that 'borrowing' state while active.