Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVR port of emu8051 #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

steveschnepp
Copy link
Contributor

@steveschnepp steveschnepp commented Aug 31, 2022

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 🤣

@steveschnepp
Copy link
Contributor Author

Btw, I do know it is totally pointless. But where would be the fun if not...

@jarikomppa
Copy link
Owner

It's not entirely pointless =) people are using microcontrollers to masquerade as other parts all the time..

@steveschnepp
Copy link
Contributor Author

steveschnepp commented Sep 4, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants