Skip to content

SH-2E CPU implementation#104

Open
MatusJurcak wants to merge 73 commits into
d-iii-s:masterfrom
MatusJurcak:master
Open

SH-2E CPU implementation#104
MatusJurcak wants to merge 73 commits into
d-iii-s:masterfrom
MatusJurcak:master

Conversation

@MatusJurcak

@MatusJurcak MatusJurcak commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

This pull request adds support for the SH-2E CPU to MSIM.

Main changes include:

  • Implementation of the SH-2E CPU
  • Addition of a new INTC device required for the SH-2E implementation
  • Updates to byte and word physical memory write handling
  • Option for the printer device to operate in big-endian mode
  • Tests covering all SH-2E instructions and exception handling
  • Clang format changes
  • Updated documentation for the CPU, INTC and printer

Changes added in the second batch:

  • New devices: CMT, WDT and DMAC
  • Updated documentation for the new devices
  • Basic tests covering interrupts from these devices

lbulej and others added 30 commits February 16, 2026 22:04
The array goes into BSS and will be zeroed anyway.
No need to worry about updating DEVICE_TYPE_COUNT when adding new
devices.
…g, add checks for alignment and add basic accounting
This commit makes the INTC as its own independent device and also changes the SH-2E CPU step behaviour.
Now the CPU step mimicks one step in the CPU state automaton instead of executing one instruction per step.
Added reference between SH-2E cpu and interrupt controller.
Changed the resets behaviour to be similiar to interrupt sources.
Also added some example configuration to the msim.conf file.
Comment thread src/device/cpu/superh_sh2e/cpu.h Outdated
@lbulej

lbulej commented May 27, 2026

Copy link
Copy Markdown
Member

Maybe just one final bit, I would rather see pc_next + sizeof(sh2e_insn_t) than just pc_next + 2 in the code (several places). The outcome is the same, but it says it bumps the PC by one instruction.

I know they don't do it like that even in the manual, but it's a documentation bit that does not cost anything.

Similarly for cases with pc + 4 => pc + 2 * sizeof(sh2e_insn_t).

Comment thread src/device/cpu/superh_sh2e/disasm.c Outdated
Comment thread src/device/cpu/superh_sh2e/disasm.c Outdated
Comment thread src/device/cpu/superh_sh2e/exec.c Outdated
Comment thread src/device/cpu/superh_sh2e/exec.c Outdated
Comment thread src/device/cpu/superh_sh2e/exec.c Outdated
Comment thread src/device/cpu/superh_sh2e/exec.c Outdated
@lbulej

lbulej commented Jun 10, 2026

Copy link
Copy Markdown
Member

The physmem endianness is quite intrusive, I would separate it to another PR. Things generally work in this PR, so I think the refactor can go in separately.

@MatusJurcak

Copy link
Copy Markdown
Contributor Author

I removed the last commit regarding the physmem refactor and I just left the fixes to the peripheral devices. I'll make another PR after we merge this one, as the physmem changes would also affect all the PRs that are open right now.

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.

3 participants