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

csrrs

T1 riscv system insn
Atomic Read and Set Bits in 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 read and set bits in a CSR.

Syntax / Encoding

csrrs xd, csr, xs1 | xxxxxxxxxxxxxxxxx010xxxxx1110011 (mask=0x0000707f match=0x00002073)

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
32RVxxxxxxxxxxxxxxxxx010xxxxx11100110x0000707f / 0x00002073

Operands

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

Reference Notes

Atomically read and set bits in a CSR.

Reads the value of the CSR, zero-extends the value to `XLEN` bits,
and writes it to integer register `xd`. The initial value in integer
register `xs1` is treated as a bit mask that specifies bit positions
to be set in the CSR. Any bit that is high in `xs1` will cause the
corresponding bit to be set in the CSR, if that CSR bit is writable.
Other bits in the CSR are not explicitly written.