Home/Instructions/Carry-Less Multiply
CLMUL

RISC-V CLMUL Instruction Details

Instruction ManualR-type

RV32/RV64 Zbc/Zbkc carry-less multiply, returning low XLEN bits of the 2*XLEN-bit product.

Instruction Syntax

clmul rd, rs1, rs2

RV32/RV64 Zbc or Zbkc 1.0; syntax clmul rd, rs1, rs2, with no rs3 or immediate.

32-bit R-type: funct7=0000101, funct3=001, opcode=0110011; register fields select x0–x31.

Select shifted rs1 terms with set rs2 bits and combine with XOR; select full-product bits XLEN-1:0. Sources use old XLEN-bit patterns; x0 reads zero and discards writes.

ZbcZbkcBit ManipulationCrypto

Instruction Behavior

clmul performs GF(2) carry-less multiplication and returns the low XLEN bits.

CLMUL Decode & Execute Animation

This model shows ISA-visible GF(2) XOR partial products; it does not model integer carries, a pipeline, or a cryptographic protocol.

Execution context
32-bit encoding fields
31..25
funct7
0000101
24..20
rs2
01100
19..15
rs1
01011
14..12
funct3
001
11..7
rd
01010
6..0
opcode
0110011
Execution data path

funct7=0000101, funct3=001

x10 <- pending

Quick Understanding & Search Notes

clmul performs GF(2) carry-less multiplication and returns the low XLEN bits.

RV32/RV64: Zbc/Zbkc 1.0; read two XLEN-bit integer-register patterns and combine partial products with XOR.
Select low XLEN bits from the full 2*XLEN-bit carry-less product, without polynomial modular reduction.
x0 reads as zero and discards writes; overlapping source and destination registers use the pre-writeback sources.

Common Usage Scenarios

Bit Manipulation

RV32 Zbc/Zbkc, x11=0xB and x12=0xD: partial products 0xB XOR 0x2C XOR 0x58=0x7F; clmul writes x10=0x7F.

Pre-Use Checklist

Syntax Check
  • RV32/RV64 Zbc or Zbkc 1.0; syntax clmul rd, rs1, rs2, with no rs3 or immediate.
  • 32-bit R-type: funct7=0000101, funct3=001, opcode=0110011; register fields select x0–x31.
Semantic Check
  • Select shifted rs1 terms with set rs2 bits and combine with XOR; select full-product bits XLEN-1:0. Sources use old XLEN-bit patterns; x0 reads zero and discards writes.

Pitfalls / Common Confusions

Carry-less multiplication combines partial products with XOR and does not propagate integer carries.

FAQ

Does clmul access memory?

It does not access data memory. It reads two integer registers and delivers the selected product bits to rd; rd=x0 discards the result.

Does clmul interpret signed numbers?

It treats XLEN-bit patterns as polynomial operands for carry-less multiplication, without signed-integer multiplication semantics; partial products combine with XOR.