0

I'm a bit confused with how the immediate of UJ-Types are decoded / encoded.

Chapter 2.3 of https://content.riscv.org/wp-content/uploads/2016/06/riscv-spec-v2.1.pdf got me slightly more confused than I was before.

For example, I'd like to decode the instruction 0300006f which I know is of type UJ.

Any help would be appreciated.

Sam
  • 31
  • 1

1 Answers1

0

Figured it out.

The immediate is 20 bits. Namely, bits 31 to 12 in the scrambled order: imm[20|10:1|11|19:12]. This is left shifted by 1 and sign extended to obtain the immediate.

Sam
  • 31
  • 1
  • I have asked a similar question a while ago, you can see the question and the answer here http://stackoverflow.com/questions/39427092/risc-v-immediate-encoding-variants – Ammar Kurd Nov 06 '16 at 14:55