kuznia-rdzeni / coreblocks

RISC-V out-of-order core for education and research purposes
https://kuznia-rdzeni.github.io/coreblocks/
BSD 3-Clause "New" or "Revised" License
36 stars 14 forks source link

Implement full `mtval` #712

Open piotro888 opened 3 months ago

piotro888 commented 3 months ago

Implements full mtval CSR.

Required some tricks. This CSR is optional to fill for all exception types, so if some case becomes too problematic in the future, it can be set to 0.

Boom and XiangShan doesn't support setting it to instruction bytes in case of Illegal Instruction, but it was added to coreblocks at currently little cost. It is helpful, because it could speed up emulation of missing instructions (possibly in OpenSBI?) XiangShan supports setting mtval to upper half of instruction address in case of fault on misaligned instruction crossing fetch blocks, hard to tell if supported in Boom. Other cases are handled by both processors.