Search code examples
encodingriscvinstructions

Why the immediate offset in the riscv's JAL instruction has bit order changed?


The bit field is shown below

J-format

I don't see the point the of doing this re-ordering of bit-field.

Is there a special kind of manipulation when RISC-V processor is executing this instruction?


Solution

  • The purpose of the shuffling is to reduce the number of muxs involved in constructing the full sized operand from the immediates across the different instruction types.

    For example, the sign-extend bit (which drives a lot wires) is always the same (inst[31]). You can also see that imm[10] is almost always in the same place too, across I-type, S-type, B-type, and J-type instructions.