cnlohr / mini-rv32ima

A tiny C header-only risc-v emulator.
MIT License
1.67k stars 137 forks source link

Customizing allowed instruction set? #36

Open GlaireDaggers opened 1 year ago

GlaireDaggers commented 1 year ago

Hello!

I am looking into this project in the context of making an arguably somewhat esoteric "fantasy console" that tries as hard as possible to be a realistic PSX-style game console and would run on an emulated RISC-V core w/ memory mapped peripherals, etc, and wanted to avoid having to write the core emulator myself.

Ideally, I would like to opt for a very minimal rv32em instruction set, which is what I have built my GCC toolchain to target. Of course a full rv32ima core would run such instructions just fine, but I'd like to restrict the allowed registers & instruction set for added challenge. Is there a good way for me to accomplish this, should I just fork and trim out what I don't need, etc.?

GlaireDaggers commented 1 year ago

Actually, reading through the source, maybe it would be enough for me to just define my own MINIRV32_CUSTOM_INTERNALS? So that perhaps I could write a replacement REG/REGSET that just masks the register number to fit the x0-x15 range? That still leaves atomics but honestly I'm not sure how much I care about restricting those.