ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 1,823 microarchs · 16,083 chips · 105 sources
Arch:
Tier:

csrrwi

T1 riscv system insn
Atomic Read/Write CSR Immediate
SourceRISC-V Official Unified Database (riscv-unified-db) (riscv_unified_db)
Reliability TierT1 — Official Specification
ISA / Silicon ScopeRV32/RV64 Zicsr
RV32 / RV64 (Ratified & Standard Extensions)
License & VersionApache-2.0 / CC-BY-4.0
main
Upstreamhttps://github.com/riscv/riscv-unified-db
Privilegeuser
ExtensionsZicsr

Summary

Atomically write CSR using a 5-bit immediate, and load the previous value into 'xd'.

Syntax / Encoding

csrrwi xd, csr, imm | xxxxxxxxxxxxxxxxx101xxxxx1110011 (mask=0x0000707f match=0x00005073)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32RVxxxxxxxxxxxxxxxxx101xxxxx11100110x0000707f / 0x00005073

Operands

NameDescription
csrbits [31:20]
immbits [19:15]
xdbits [11:7]

Reference Notes

Atomically write CSR using a 5-bit immediate, and load the previous value into 'xd'.

Read the old value of the CSR, zero-extends the value to `XLEN` bits,
and then write it to integer register xd.
The 5-bit uimm field is zero-extended and written to the CSR.
If `xd=x0`, then the instruction shall not read the CSR and shall not
cause any of the side effects that might occur on a CSR read.