riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.36k stars 826 forks source link

Supporting variable XLEN #1643

Open aswaterman opened 5 months ago

aswaterman commented 5 months ago

No one has been beating down the door requesting changeable XLEN, but since it'll probably happen eventually, I wanted to have a place to take notes on what changes need to be made. (cc @jerryz123 @scottj97)

aamartin0000 commented 4 months ago

Question about this: assuming you are on an RV64 machine (== native XLEN=64), if you change to XLEN=32, are you expecting it to produce results as if it was an RV32 machine, or will there be discrepancies? There are some RV64-only instructions-- will they be treated as illegal? There are some RV32-only instructions (e.g. scalar crypto), do these become legal?

The scenario I'm thinking of is being able to run a binary compiled for RV32, on an RV64 machine.

aswaterman commented 4 months ago

An RV64-native machine with XLEN set to 32 should behave just the same as a native RV32 machine. Now of course the machine could have some non-conforming extensions (e.g. the RV64-only ADDW instruction might be present when XLEN=32, as a non-conforming extension), but then the implementation would not be able to claim that it implements the Ssstrict extension.

aamartin0000 commented 4 months ago

Another question: does setting XLEN=32 also imply setting FLEN=32?