c.beqz

Branch if 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 zero. It expands to beq rs1, x0, offset.

Access

M

HS

U

VS

VU

Always

Always

Always

Always

Always

Decode Variables

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

Execution

  • Pruned, XLEN == 64

  • Original

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

Exceptions

This instruction may result in the following synchronous exceptions:

  • IllegalInstruction

  • InstructionAddressMisaligned