CSR Bit Fields

RISC-V mcountinhibit CSR Register

Address 0x320Privilege MachineAccess RW / 32Machine counters and performance-monitoring CSRs

mcountinhibit controls whether machine counters such as cycle and instret are allowed to increment.

Field Map

Understand mcountinhibit By Bit Fields

5 key fields
0

CY

WARL

Inhibits mcycle counting; meaningful only for implemented counters.

CY (bit 0) — Inhibits mcycle counting; meaningful only for implemented counters.

What This Field Controls

  • - Inhibits mcycle counting; meaningful only for implemented counters.

Common Values

0Increment enabled

mcycle is not inhibited by this bit.

1Increment inhibited

mcycle incrementing is inhibited; this is meaningful only for implemented counters.

1

reserved

reserved

Reserved; there is no machine-level time counter.

reserved (bit 1) — Reserved; there is no machine-level time counter.

What This Field Controls

  • - Reserved; there is no machine-level time counter.

Common Values

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

2

IR

WARL

Inhibits minstret counting; meaningful only for implemented counters.

IR (bit 2) — Inhibits minstret counting; meaningful only for implemented counters.

What This Field Controls

  • - Inhibits minstret counting; meaningful only for implemented counters.

Common Values

0Increment enabled

minstret is not inhibited by this bit.

1Increment inhibited

minstret incrementing is inhibited; this is meaningful only for implemented counters.

31:3

HPMn

WARL

Inhibits corresponding mhpmcounter3..31 counting; meaningful only for implemented HPM counters.

HPMn (bits 31:3) — Inhibits corresponding mhpmcounter3..31 counting; meaningful only for implemented HPM counters.

What This Field Controls

  • - Inhibits corresponding mhpmcounter3..31 counting; meaningful only for implemented HPM counters.

Common Values

0Increment enabled

The corresponding mhpmcounter3-31 counter is not inhibited by this bit.

1Increment inhibited

Incrementing of the corresponding mhpmcounter3-31 counter is inhibited; this is meaningful only for implemented counters.

63:32

Reserved/RO0 (RV64)

RO0

mcountinhibit is a 32-bit register; in the RV64 CSR view, bits 63:32 are outside that 32-bit counter-inhibit bitmap and read as zero.

Reserved/RO0 (RV64) (bits 63:32) — mcountinhibit is a 32-bit register; in the RV64 CSR view, bits 63:32 are outside that 32-bit counter-inhibit bitmap and read as zero.

What This Field Controls

  • - mcountinhibit is a 32-bit register; in the RV64 CSR view, bits 63:32 are outside that 32-bit counter-inhibit bitmap and read as zero.

Common Values

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

Official Basis & Search Notes

mcountinhibit is a 32-bit machine WARL CSR at 0x320. It inhibits incrementing per counter without changing lower-privilege access control.

mcountinhibit address, lowest access privilege, and access class are checked against the official CSR table: 0x320, Machine, RW.
It is a 32-bit WARL CSR whose CY, IR, and HPMn bits inhibit corresponding counter increments; if the register is not implemented, hardware behaves as if it were zero.
Bit 1 is reserved; do not treat mcountinhibit as an XLEN-wide ordinary integer field.

What To Check First When Reading This CSR

  • - If the implementation does not provide mcountinhibit, hardware behaves as if the register were zero; a privilege below Machine cannot directly access this Machine CSR.
  • - Use address 0x320 and the lowest access privilege (Machine) to decide whether software may read it directly.
  • - Do not assume fixed values for reserved, WARL, or WLRL bits; interpret the value according to the specification and implementation.

Risk Checks Before Writing

  • - Preserve bits that are not being changed so reserved or implementation-defined fields are not written with invalid values.
  • - If harts share mcycle, mcountinhibit.CY can also be shared, so writes are visible to those harts.

Put It Back Into A Real Flow

1

During initialization or the relevant privileged flow, software reads mcountinhibit to observe the current state.

2

Modify only the target fields while preserving all other bits.

3

Read the counter or mcountinhibit after the write to verify that the target counter stops or resumes incrementing as intended.

FAQ

Can mcountinhibit be accessed from any privilege level?

Do not decide from the CSR name alone. The official CSR address encoding and tables define the lowest access privilege; mcountinhibit is a Machine CSR. If it is not implemented, the specification requires hardware to behave as if it were zero.

What is easiest to miss when writing mcountinhibit?

Do not overwrite the whole CSR as if it were an ordinary integer. Modify only target fields, preserve unchanged bits, and follow the specification for WARL, WLRL, WPRI, or reserved fields.