CSR Bit Fields

RISC-V hpmcounter22 CSR Register

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

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

Field Map

Understand hpmcounter22 By Bit Fields

1 key fields
63:0

VALUE

RO

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

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

What This Field Controls

  • - hpmcounter22 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

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

hpmcounter22 is URO at 0xC16 in the official CSR table and is a read-only shadow of mhpmcounter22.
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.HPM22 causes an illegal-instruction exception on read; when scounteren is implemented, its HPM22 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.HPM22 is clear; when scounteren is implemented, its HPM22 bit also controls U-mode access.
  • - A misconfigured event-selection configuration may cause the counter to return a constant value.

Risk Checks Before Writing

  • - hpmcounter22 is a read-only shadow of mhpmcounter22; 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 hpmcounter22; RV32 also needs hpmcounter22h to obtain the full 64-bit value.

FAQ

Is hpmcounter22 always readable?

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

How does RV32 read the full hpmcounter22?

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