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

csrrc

T1 riscv system insn
Atomic Read and Clear 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

The CSRRC (Atomic Read and Clear Bits in CSR) instruction 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 cleared in the CSR. Any bit that is high in xs1 will cause the corresponding bit to be cleared in the CSR, if that CSR bit is writable.

Syntax / Encoding

csrrc xd, csr, xs1 | xxxxxxxxxxxxxxxxx011xxxxx1110011 (mask=0x0000707f match=0x00003073)

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
32RVxxxxxxxxxxxxxxxxx011xxxxx11100110x0000707f / 0x00003073

Operands

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

Reference Notes

The CSRRC (Atomic Read and Clear Bits in CSR) instruction 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 cleared in the CSR. Any bit that is high in `xs1` will
cause the corresponding bit to be cleared in the CSR, if that CSR bit is writable.

For CSRRC, if `xs1=x0`, then the instruction will not write to the CSR at all, and so shall
not cause any of the side effects that might otherwise occur on a CSR write, nor raise illegal-
instruction exceptions on accesses to read-only CSRs. CSRRC always reads the addressed CSR and
cause any read side effects regardless of `xs1` and `xd` fields.
Note that if `xs1` specifies a register other than `x0`, and that register holds a zero value,
the instruction will not action any attendant per-field side effects, but will action any
side effects caused by writing to the entire CSR.