CSR Bit Fields

RISC-V hpmcounter21 CSR Register

Address 0xC15Privilege UserAccess RO / 64 bits (RV32 accesses the upper 32 bits through hpmcounter21h)User counters and performance-monitoring CSRs

hpmcounter21 is a Zihpm user-level read-only hardware performance counter; its event, implemented count, and width are platform-specific.

Field Map

Understand hpmcounter21 By Bit Fields

1 key fields
63:0

VALUE

RO

hpmcounter21 reads the complete 64-bit count on RV64; the implemented count, width, and events are platform-specific.

VALUE (bits 63:0) — hpmcounter21 reads the complete 64-bit count on RV64; the implemented count, width, and events are platform-specific.

What This Field Controls

  • - hpmcounter21 reads the complete 64-bit count on RV64; the implemented count, width, and events are platform-specific.

Common Values

This field is better understood together with surrounding context than as a fixed memorized enumeration.

Open Official Manual
Official Basis & Search Notes

hpmcounter21 is the Zihpm user read-only counter at 0xC15. Its event, implemented count, and width are platform-specific; hpmcounter21h provides the RV32 upper 32 bits.

hpmcounter21 is URO at 0xC15 in the official CSR table and is a read-only shadow of mhpmcounter21.
Zihpm depends on Zicsr and supplies up to 29 performance counters, while the platform determines whether this counter is implemented, its width, and its event.
In S/U mode, a clear mcounteren.HPM21 causes an illegal-instruction exception on read; when scounteren is implemented, its HPM21 bit controls U-mode access.

What To Check First When Reading This CSR

  • - Confirm that Zihpm (which depends on Zicsr) and this counter are implemented. Accessing an unimplemented counter may raise an illegal-instruction exception or return a constant value.
  • - In S/U mode, reading raises an illegal-instruction exception when mcounteren.HPM21 is clear; when scounteren is implemented, its HPM21 bit also controls U-mode access.
  • - A misconfigured event-selection configuration may cause the counter to return a constant value.

Risk Checks Before Writing

  • - hpmcounter21 is a read-only shadow of mhpmcounter21; do not write this user-level CSR.

Put It Back Into A Real Flow

1

Use the execution environment interface to confirm the implemented count, width, and event configuration.

2

Check the mcounteren/scounteren permission required at the current privilege level.

3

Read hpmcounter21; RV32 also needs hpmcounter21h to obtain the full 64-bit value.

FAQ

Is hpmcounter21 always readable?

No. An unimplemented counter may raise an illegal-instruction exception or return a constant value; S/U-mode access also requires mcounteren.HPM21, and U-mode access requires scounteren.HPM21 when scounteren is implemented.

How does RV32 read the full hpmcounter21?

This CSR reads the low 32 bits; hpmcounter21h reads the upper 32 bits of the same 64-bit counter.