clzw
Count leading zero bits in word
- Extension
- Zbb
- XLEN
- RV64 only
- Assembly (riscv-unified-db)
clzw xd, xs1- Length
- 32-bit
Encoding
| 3120 | 1915 | 1412 | 117 | 62 | 10 | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 011000000000 | rs1 | 001 | rd | 00110 | 11 | ||||||||||||||||||||||||||
Match 0x6000101b, mask 0xfff0707f. Source: clzw rd rs1 31..20=0x600 14..12=1 6..2=0x06 1..0=3 in riscv-opcodes/extensions/rv64_zbb.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| rs1 | 19:15 | rs1 |
| rd | 11:7 | rd |
Description
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.
Description from riscv-unified-db, reformatted.
Operation
X[xd] = 31 - $signed(highest_set_bit(X[xs1][31:0]));
Pseudocode in riscv-unified-db’s IDL, quoted unchanged.