Webcentive RISC-V Reference

mcycle

Machine cycle counter

Address
0xB00
Group
Machine-level CSRs
Privilege
MRW (privileged spec CSR listing, Machine Counter/Timers)
Access
read/write; lowest privilege M (machine)
Address range
Standard read/write
Name in riscv-unified-db
Machine Cycle Counter

Privileged spec: Machine cycle counter

Description

Counts the number of clock cycles executed by the processor core on which the hart is running. The counter has 64-bit precision on all RV32 and RV64 harts.

The mcycle CSR may be shared between harts on the same core, in which case writes to mcycle will be visible to those harts. The platform should provide a mechanism to indicate which harts share an mcycle CSR.

From riscv-unified-db, reformatted.

Fields

FieldBitsTypeDescription
COUNT63-0RW-RH

Cycle counter.

When Zicntr is implemented:

Aliased as cycle.COUNT.

Increments every cycle unless:

  • mcountinhibit.CY (when Smcdeleg is implemented: or its alias scountinhibit.CY) is set

When Smcntrpmf is implemented:

  • mcyclecfg.MINH is set and the current privilege level is M

When S is implemented:

  • mcyclecfg.SINH (when Ssccfg is implemented: or its alias cyclecfg.SINH) is set and the current privilege level is (H)S

When U is implemented:

  • mcyclecfg.UINH (when Ssccfg is implemented: or its alias cyclecfg.UINH) is set and the current privilege level is U

When H is implemented:

  • mcyclecfg.VSINH (when Ssccfg is implemented: or its alias cyclecfg.VSINH) is set and the current privilege level is VS
  • mcyclecfg.VUINH (when Ssccfg is implemented: or its alias cyclecfg.VUINH) is set and the current privilege level is VU

Fields from riscv-unified-db; field types computed by IDL functions there are not shown.

Specification and related pages