c.j

Jump

This instruction is defined by:

Encoding

svg

Synopsis

C.J performs an unconditional control transfer. The offset is sign-extended and added to the pc to form the jump target address. C.J can therefore target a ±2 KiB range. It expands to jal x0, offset.

Access

M

HS

U

VS

VU

Always

Always

Always

Always

Always

Decode Variables

signed Bits<12> imm = sext({$encoding[12], $encoding[8], $encoding[10:9], $encoding[6], $encoding[7], $encoding[2], $encoding[11], $encoding[5:3], 1'd0});

Execution

  • Pruned, XLEN == 64

  • Original

if ((%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
  %%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
%%LINK%func;jump;jump%%($pc + $signed(imm));
if (%%LINK%func;implemented?;implemented?%%(ExtensionName::C) && (%%LINK%csr_field;misa.C;CSR[misa].C%% == 1'b0)) {
  %%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
%%LINK%func;jump;jump%%($pc + $signed(imm));

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction

  • InstructionAddressMisaligned