Minres / RISCV_ISA_CoreDSL

CoreDSL descriptions of the RISC-V ISA
Apache License 2.0
3 stars 11 forks source link

Incorrect sign extension behavior #6

Closed jopperm closed 2 years ago

jopperm commented 2 years ago

As reported by @wysiwyng in https://github.com/Minres/CoreDSL/issues/58, casting an unsigned value (such as an encoding field) to a signed type does not sign-extend the value (because the source type is unsigned).

https://github.com/Minres/RISCV_ISA_CoreDSL/blob/726fb8117b47714ee891f89032fb8a9ce167b1e2/RV32I.core_desc#L9-L13

(There might be other occurrences of this pattern.)

jopperm commented 2 years ago

Correct form would be:

X[rd % RFS] = (unsigned<XLEN>) ((signed) imm));