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

csrrw

T1 riscv system insn
Atomic Read/Write CSR
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 swap values in the CSRs and integer registers.

Syntax / Encoding

csrrw xd, csr, xs1 | xxxxxxxxxxxxxxxxx001xxxxx1110011 (mask=0x0000707f match=0x00001073)

Cross-Chip Latency & Throughput (11 cores)

MicroarchitectureLatency (cycles)Recip. TPuopsPortsSource
Andes 45-Series111Andes45CSRllvm_sched_models
MIPS P8700 (RISC-V)111p8700ALQllvm_sched_models
SiFive 7-Series (U74)111PipeBllvm_sched_models
SiFive P670 / P600111SiFiveP600SYSllvm_sched_models
SiFive P870 / P800111SiFiveP800SYSllvm_sched_models
SpacemiT X10010.51SMTX100_IQ0llvm_sched_models
SpacemiT X60 (K1)10.51SMX60_IEUllvm_sched_models
Syntacore SCR7111—llvm_sched_models
Tenstorrent Ascalon-X111AscalonFXAllvm_sched_models
XiangShan KunMingHu111XSPipeBJU3llvm_sched_models
XiangShan NanHu111XS2MISCllvm_sched_models

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32RVxxxxxxxxxxxxxxxxx001xxxxx11100110x0000707f / 0x00001073

Operands

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

Reference Notes

Atomically swap values in the CSRs and integer registers.

Read the old value of the CSR, zero-extends the value to `XLEN` bits,
and then write it to integer register xd.
The initial value in xs1 is 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.