mhpmcounter4

Machine Hardware Performance Counter 4

Programmable hardware performance counter.

The hpmcounter4 CSR is a read-only shadow of this CSR. Access to hpmcounter4 is controlled with mcounteren.HPM4 , scounteren.HPM4 , and hcounteren.HPM4 as follows:

mcounteren.HPM4

scounteren.HPM4

hcounteren.HPM4

hpmcounter4 behavior

S-mode

U-mode

VS-mode

VU-mode

0

-

-

IllegalInstruction

IllegalInstruction

IllegalInstruction

IllegalInstruction

1

0

0

read-only

IllegalInstruction

VirtualInstruction

VirtualInstruction

1

1

0

read-only

read-only

VirtualInstruction

VirtualInstruction

1

0

1

read-only

IllegalInstruction

read-only

VirtualInstruction

1

1

1

read-only

read-only

read-only

read-only

Attributes

CSR Address

0xb04

Defining extension

(Sm && HPM_COUNTER_EN[4] == true)

Length

64-bit

Privilege Mode

M

Format

mhpmcounter4 format
Figure 1. mhpmcounter4 format

Field Summary

Name Location Type Reset Value

COUNT

63:0

RW-H

UNDEFINED_LEGAL

Fields

COUNT

Location

mhpmcounter4[63:0]

Description

Performance counter for event selected in mhpmevent4.EVENT.

+ Increments every time event occurs unless:

+ * mcountinhibit.HPM4 or its alias scountinhibit.HPM4 is set * mhpmevent4.MINH is set and the current privilege level is M * mhpmevent4.SINH or its alias hpmevent4.SINH is set and the current privilege level is (H)S * mhpmevent4.UINH or its alias hpmevent4.UINH is set and the current privilege level is U * mhpmevent4.VSINH or its alias hpmevent4.VSINH is set and the current privilege level is VS * mhpmevent4.VUINH or its alias hpmevent4.VUINH is set and the current privilege level is VU

+

Unimplemented performance counter. Must be read-only 0 (access does not cause trap).

Type

RW-H

Read-Write with Hardware update

Field is writable by software. Any value that fits in the field is acceptable. Hardware also updates the field without an explicit software write.

Reset value

UNDEFINED_LEGAL

Software read

This CSR may return a value that is different from what is stored in hardware.

  • Pruned

  • Original

return read_hpm_counter(4);
if (HPM_COUNTER_EN[4]) {
  return read_hpm_counter(4);
} else {
  return 0;
}