proteus-core / proteus

The SpinalHDL design of the Proteus core, an extensible RISC-V core.
MIT License
39 stars 9 forks source link

Fixed a bug where MULH would not work as expected. #9

Open robbevandevelde opened 4 months ago

robbevandevelde commented 4 months ago

This issue affects the MULH instruction when multiplying large negative numbers. The issue is that the whole 33-bit multiplicant gets copied, which is incorrect while using negative numbers.

This fix allows large negative numbers to be multiplied by each other in a correct manner. By not copying the whole 33 bit multiplicant but limiting it to 32 bits the issue is resolved.

This change is made to the MulDiv.scala file in the plugins folder.

The RISC-V tests ran with make -C tests CORE=riscv.CoreExtMem still returns All tests passed

This issue was not caught by the RISC-V tests because it only affects these high, negative numbers, which are not tested in the test suite.