beqi
Branch if equal immediate
This instruction is defined by:
Synopsis
Branch to PC + offset if the value in register xs1 is equal to the XLEN-bit comparison constant decoded from cimm.
The cimm field is not sign-extended: cimm == 0 encodes the value -1, and cimm values 1 through 31 encode the corresponding positive integer values.
Raise a MisalignedAddress exception if the branch is taken and PC + offset is
misaligned.
Decode Variables
signed Bits<13> offset = sext({$encoding[31], $encoding[7], $encoding[30:25], $encoding[11:8], 1'd0}, 13);
Bits<5> cimm = $encoding[24:20];
Bits<5> xs1 = $encoding[19:15];
Execution
-
Pruned, XLEN == 64
-
Original
XReg lhs = X[xs1];
XReg rhs = (cimm == 0) ? 64'hffffffffffffffff : cimm;
if (lhs == rhs) {
jump_halfword($pc + $signed(offset));
}
XReg lhs = X[xs1];
XReg rhs = (cimm == 0) ? {MXLEN{1'b1}} : cimm;
if (lhs == rhs) {
jump_halfword($pc + $signed(offset));
}