c.addi

Add a sign-extended non-zero immediate

This instruction is defined by:

Encoding

svg

Synopsis

C.ADDI adds the non-zero sign-extended 6-bit immediate to the value in register xd then writes the result to xd. C.ADDI expands into addi xd, xd, imm. C.ADDI is only valid when xd ≠ x0 and imm ≠ 0. The code points with xd=x0 encode the C.NOP instruction; the remaining code points with imm=0 encode HINTs.

Access

M HS U VS VU

Always

Always

Always

Always

Always

Decode Variables

Bits<6> imm = {$encoding[12], $encoding[6:2]};
Bits<5> xd = $encoding[11:7];

Execution

  • Pruned, XLEN == 64

  • Original

if (implemented?(ExtensionName::C) && (misa.C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[xd] = X[xd] + $signed(imm);
if (implemented?(ExtensionName::C) && (misa.C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[xd] = X[xd] + $signed(imm);

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction