CSRRWI

CSR Read/Write Immediate

CSRRWI rd, csr, uimm

Updates a CSR using a 5-bit unsigned immediate (zimm) instead of a register.

Details

CSRRWI atomically reads CSR csr into rd, then writes the zero-extended 5-bit immediate to the CSR. If rd is x0, the read is skipped.

Pseudocode Operation

t = CSRs[csr]; CSRs[csr] = zext(uimm); R[rd] = t;

Example

CSRRWI x0, 0x001, 0

Encoding

Binary Layout
csr
31:20
uimm
101
19:17
rd
16:12
1110011
11:5
 
Format I-Type
Opcode 0x73
Extension Zicsr

Operands

  • rd
    Destination register (integer)
  • csr
    CSR Address
  • uimm
    5-bit Unsigned Imm