clzw
Count leading zero bits in word
This instruction is defined by:
Synopsis
This instruction counts the number of 0’s before the first 1 starting at bit 31 and progressing to bit 0. Accordingly, if the least-significant word is 0, the output is 32, and if the most-significant bit of the word (i.e., bit 31) is a 1, the output is 0.
Execution
-
Pruned, XLEN == 64
-
Original
X[rd] = 31 - $signed(highest_set_bit(X[rs1][31:0]));
if (implemented?(ExtensionName::B) && (CSR[misa].B == 1'b0)) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
X[rd] = 31 - $signed(highest_set_bit(X[rs1][31:0]));