c.bnez

Branch if NOT Equal Zero

This instruction is defined by:

Encoding

svg

Synopsis

C.BEQZ performs conditional control transfers. The offset is sign-extended and added to the pc to form the branch target address. It can therefore target a ±256 B range. C.BEQZ takes the branch if the value in register rs1' is NOT zero. It expands to beq rs1, x0, offset.

Access

M

HS

U

VS

VU

Always

Always

Always

Always

Always

Decode Variables

Bits<8> imm = {$encoding[12], $encoding[6:5], $encoding[2], $encoding[11:10], $encoding[4:3]};
Bits<3> rs1 = $encoding[9:7];

Execution

  • Pruned, XLEN == 64

  • Original

if (X[rs1] != 0) {
  jump($pc + imm);
}
if (implemented?(ExtensionName::C) && (CSR[misa].C == 1'b0)) {
  raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
if (X[rs1] != 0) {
  jump($pc + imm);
}

Exceptions

This instruction may result in the following synchronous exceptions:

  • InstructionAddressMisaligned