sext.h
Sign-extend halfword
This instruction is defined by:
Synopsis
This instruction sign-extends the least-significant halfword in the source to XLEN by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits.
Execution
-
Pruned, XLEN == 64
-
Original
if ((%%LINK%csr_field;misa.B;CSR[misa].B%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
X[rd] = {{48{X[rs1][15]}}, X[rs1][15:0]};
if (%%LINK%func;implemented?;implemented?%%(ExtensionName::B) && (%%LINK%csr_field;misa.B;CSR[misa].B%% == 1'b0)) {
%%LINK%func;raise;raise%%(ExceptionCode::IllegalInstruction, %%LINK%func;mode;mode%%(), $encoding);
}
if (%%LINK%func;xlen;xlen%%() == 32) {
X[rd] = {{16{X[rs1][15]}}, X[rs1][15:0]};
} else if (%%LINK%func;xlen;xlen%%() == 64) {
X[rd] = {{48{X[rs1][15]}}, X[rs1][15:0]};
}