Function o1vm::interpreters::riscv32im::interpreter::interpret_ujtype
source · pub fn interpret_ujtype<Env: InterpreterEnv>(
env: &mut Env,
instr: UJInstruction
)
Expand description
Interpret an UJ-type instruction. The encoding of an UJ-type instruction is as follows:
| 31 12 | 11 7 | 6 0 |
| imm[20|10:1|11|19:12] | rd | opcode |
Following the documentation found here
The interpretation of the immediate is as follow:
imm_20 = instruction[31]
imm_10_1 = instruction[30..21]
imm_11 = instruction[20]
imm_19_12 = instruction[19..12]
imm = imm_20 << 19 +
imm_19_12 << 11 +
imm_11 << 10 +
imm_10_1
# The immediate is then sign-extended. The sign-extension is in the bit imm20
imm = imm << 1