CSR Bit Fields

RISC-V hpmcounter12 CSR Register

Address 0xC0CPrivilege User (also accessible at higher privilege)Access RO / XLEN (upper 32 bits in hpmcounter12h on RV32)User counters and performance-monitoring CSRs

hpmcounter12 is a Zihpm unprivileged hardware performance-counter CSR. When implemented and accessible, it provides the count for a platform-selected performance event.

Field Map

Understand hpmcounter12 By Bit Fields

1 key fields
XLEN-1:0

VALUE

RO

The readable XLEN-bit view of the corresponding performance counter. On RV32 this CSR reads the low 32 bits and hpmcounter12h reads bits 63-32; the implemented counter count, width, and counted events are platform-specific.

VALUE (bits XLEN-1:0) — The readable XLEN-bit view of the corresponding performance counter. On RV32 this CSR reads the low 32 bits and hpmcounter12h reads bits 63-32; the implemented counter count, width, and counted events are platform-specific.

What This Field Controls

  • - The readable XLEN-bit view of the corresponding performance counter. On RV32 this CSR reads the low 32 bits and hpmcounter12h reads bits 63-32; the implemented counter count, width, and counted 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

hpmcounter12 is a read-only Zihpm user performance counter. Its event and implemented width are platform-specific, and user access can be limited by counter-enable CSRs.

hpmcounter12 is the standard user-level read-only CSR at 0xC0C.
Zihpm depends on Zicsr and provides up to 29 additional unprivileged 64-bit performance counters.
On RV32, hpmcounter12 reads the low 32 bits and hpmcounter12h reads the upper 32 bits.
An unimplemented counter may trap or return a constant; the counted event and counter count and width are platform-specific.

What To Check First When Reading This CSR

  • - Zihpm depends on Zicsr; hpmcounter12 is one of up to 29 unprivileged hardware performance counters.
  • - On privileged platforms, lower-privilege access can be controlled by counter-enable CSRs; disabled access causes an illegal-instruction exception.
  • - An unimplemented counter may raise an illegal-instruction exception or return a constant value; a misconfigured event selection may also make the counter return a constant value.

Risk Checks Before Writing

  • - hpmcounter12 is read-only; an attempt to write a read-only CSR raises an illegal-instruction exception.

Put It Back Into A Real Flow

1

Confirm Zihpm, counter implementation, and access permission.

2

Read hpmcounter12; on RV32 also read hpmcounter12h when a full 64-bit value is needed.

3

On privileged RISC-V platforms, interpret the result for the event selected by the corresponding mhpmevent12; other execution environments may provide alternative event-configuration mechanisms.

FAQ

Is hpmcounter12 always implemented and readable?

No. The implemented counter count is platform-specific; accessing an unimplemented counter may raise an illegal-instruction exception or return a constant. On privileged platforms, counter-enable CSRs can also prohibit lower-privilege access.

How are the upper 32 bits of hpmcounter12 read on RV32?

Use hpmcounter12h: hpmcounter12 reads the low 32 bits and hpmcounter12h reads bits 63-32 of the same counter.