Skip to content

Commit b45a89f

Browse files
Add CSR YAML files for Smcntrpmf: mcyclecfg and minstretcfg (#595)
Implement CSR YAMLs : - MCYCLECFG - MINSTRETCFG Closes #568
1 parent 6ecca9c commit b45a89f

File tree

4 files changed

+255
-0
lines changed

4 files changed

+255
-0
lines changed

arch/csr/Smcntrpmf/mcyclecfg.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
$schema: csr_schema.json#
3+
kind: csr
4+
name: mcyclecfg
5+
long_name: Machine Cycle Counter Configuration
6+
address: 0x321
7+
priv_mode: M
8+
length: 64
9+
definedBy: Smcntrpmf
10+
description: |
11+
The `mcyclecfg` CSR is a 64-bit machine-level register that configures privilege
12+
mode filtering for the cycle counter. Each inhibit bit (xINH) suppresses
13+
counting of events in the corresponding privilege mode when set.
14+
15+
| Field | Description |
16+
|---------|---------------------------------------------------------|
17+
| MINH | If set, then counting of events in M-mode is inhibited. |
18+
| SINH | If set, then counting of events in S/HS-mode is inhibited. |
19+
| UINH | If set, then counting of events in U-mode is inhibited. |
20+
| VSINH | If set, then counting of events in VS-mode is inhibited. |
21+
| VUINH | If set, then counting of events in VU-mode is inhibited. |
22+
23+
When all xINH bits are zero, event counting is enabled in all modes.
24+
25+
For each bit in 61:58, if the associated privilege mode is not implemented,
26+
the bit is read-only zero.
27+
28+
Bit 63 is hardwired to 0, as these counters do not generate overflow interrupts.
29+
30+
Bits [57:0] are reserved (WPRI) and read as zero.
31+
32+
For RV32, the upper 32 bits of `mcyclecfg` are accessed via `mcyclecfgh` (CSR 0x721).
33+
34+
Note: Although CSR address 0x320 would have been a more natural choice,
35+
it is already allocated to `mcountinhibit`.
36+
37+
fields:
38+
MINH:
39+
location: 62
40+
base: 64
41+
type: RW
42+
definedBy: M
43+
description: If set, then counting of events in M-mode is inhibited.
44+
reset_value: UNDEFINED_LEGAL
45+
46+
SINH:
47+
location: 61
48+
base: 64
49+
type: RW
50+
definedBy: S
51+
description: If set, then counting of events in S/HS-mode is inhibited.
52+
reset_value: UNDEFINED_LEGAL
53+
54+
UINH:
55+
location: 60
56+
base: 64
57+
type: RW
58+
definedBy: U
59+
description: If set, then counting of events in U-mode is inhibited.
60+
reset_value: UNDEFINED_LEGAL
61+
62+
VSINH:
63+
location: 59
64+
base: 64
65+
type: RW
66+
definedBy: H
67+
description: If set, then counting of events in VS-mode is inhibited.
68+
reset_value: UNDEFINED_LEGAL
69+
70+
VUINH:
71+
location: 58
72+
base: 64
73+
type: RW
74+
definedBy: H
75+
description: If set, then counting of events in VU-mode is inhibited.
76+
reset_value: UNDEFINED_LEGAL

arch/csr/Smcntrpmf/mcyclecfgh.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
$schema: csr_schema.json#
3+
kind: csr
4+
name: mcyclecfgh
5+
long_name: Machine Cycle Counter Configuration High
6+
address: 0x721
7+
priv_mode: M
8+
length: 32
9+
definedBy: Smcntrpmf
10+
description: |
11+
Upper 32 bits of the 64-bit `mcyclecfg` CSR, used for RV32 systems to access
12+
the privilege mode filtering inhibit bits.
13+
14+
fields:
15+
MINH:
16+
alias: mcyclecfg.MINH
17+
location: 30
18+
type: RW
19+
definedBy: M
20+
description: If set, then counting of events in M-mode is inhibited.
21+
reset_value: UNDEFINED_LEGAL
22+
23+
SINH:
24+
alias: mcyclecfg.SINH
25+
location: 29
26+
type: RW
27+
definedBy: S
28+
description: If set, then counting of events in S/HS-mode is inhibited.
29+
reset_value: UNDEFINED_LEGAL
30+
31+
UINH:
32+
alias: mcyclecfg.UINH
33+
location: 28
34+
type: RW
35+
definedBy: U
36+
description: If set, then counting of events in U-mode is inhibited.
37+
reset_value: UNDEFINED_LEGAL
38+
39+
VSINH:
40+
alias: mcyclecfg.VSINH
41+
location: 27
42+
type: RW
43+
definedBy: H
44+
description: If set, then counting of events in VS-mode is inhibited.
45+
reset_value: UNDEFINED_LEGAL
46+
47+
VUINH:
48+
alias: mcyclecfg.VUINH
49+
location: 26
50+
type: RW
51+
definedBy: H
52+
description: If set, then counting of events in VU-mode is inhibited.
53+
reset_value: UNDEFINED_LEGAL

arch/csr/Smcntrpmf/minstretcfg.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
$schema: csr_schema.json#
3+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
4+
kind: csr
5+
name: minstretcfg
6+
long_name: Machine Instructions-Retired Counter Configuration
7+
address: 0x322
8+
priv_mode: M
9+
length: 64
10+
definedBy: Smcntrpmf
11+
description: |
12+
The `minstretcfg` CSR is a 64-bit machine-level register that configures privilege
13+
mode filtering for the `minstret` (Machine Instructions-Retired Counter). Each inhibit bit (xINH)
14+
disables counting of retired instructions in the associated privilege mode.
15+
16+
| Field | Description |
17+
|---------|-----------------------------------------------------------|
18+
| MINH | If set, then counting of events in M-mode is inhibited. |
19+
| SINH | If set, then counting of events in S/HS-mode is inhibited. |
20+
| UINH | If set, then counting of events in U-mode is inhibited. |
21+
| VSINH | If set, then counting of events in VS-mode is inhibited. |
22+
| VUINH | If set, then counting of events in VU-mode is inhibited. |
23+
24+
When all inhibit bits are clear, instruction retirement is counted in all privilege modes.
25+
26+
For each bit in 61:58, if the associated privilege mode is not implemented, the bit is read-only zero.
27+
28+
Bit 63 (OF) always reads as zero, indicating that the counter does not generate overflow interrupts.
29+
30+
Bits [57:0] are reserved (WPRI) and read as zero; writes are ignored.
31+
32+
For RV32 systems, the upper 32 bits of `minstretcfg` are accessible via the `minstretcfgh` CSR (0x722).
33+
34+
fields:
35+
MINH:
36+
location: 62
37+
base: 64
38+
type: RW
39+
definedBy: M
40+
description: If set, then counting of events in M-mode is inhibited.
41+
reset_value: UNDEFINED_LEGAL
42+
43+
SINH:
44+
location: 61
45+
base: 64
46+
type: RW
47+
definedBy: S
48+
description: If set, then counting of events in S/HS-mode is inhibited.
49+
reset_value: UNDEFINED_LEGAL
50+
51+
UINH:
52+
location: 60
53+
base: 64
54+
type: RW
55+
definedBy: U
56+
description: If set, then counting of events in U-mode is inhibited.
57+
reset_value: UNDEFINED_LEGAL
58+
59+
VSINH:
60+
location: 59
61+
base: 64
62+
type: RW
63+
definedBy: H
64+
description: If set, then counting of events in VS-mode is inhibited.
65+
reset_value: UNDEFINED_LEGAL
66+
67+
VUINH:
68+
location: 58
69+
base: 64
70+
type: RW
71+
definedBy: H
72+
description: If set, then counting of events in VU-mode is inhibited.
73+
reset_value: UNDEFINED_LEGAL

arch/csr/Smcntrpmf/minstretcfgh.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# yaml-language-server: $schema=../../../schemas/csr_schema.json
2+
$schema: csr_schema.json#
3+
kind: csr
4+
name: minstretcfgh
5+
long_name: Machine Instructions-Retired Counter Configuration High
6+
address: 0x722
7+
priv_mode: M
8+
length: 32
9+
definedBy: Smcntrpmf
10+
description: |
11+
Upper 32 bits of the 64-bit `minstretcfg` CSR, used on RV32 systems to access
12+
privilege mode filtering inhibit bits for instruction retirement.
13+
14+
fields:
15+
MINH:
16+
alias: minstretcfg.MINH
17+
location: 30
18+
type: RW
19+
definedBy: M
20+
description: If set, then counting of events in M-mode is inhibited.
21+
reset_value: UNDEFINED_LEGAL
22+
23+
SINH:
24+
alias: minstretcfg.SINH
25+
location: 29
26+
type: RW
27+
definedBy: S
28+
description: If set, then counting of events in S/HS-mode is inhibited.
29+
reset_value: UNDEFINED_LEGAL
30+
31+
UINH:
32+
alias: minstretcfg.UINH
33+
location: 28
34+
type: RW
35+
definedBy: U
36+
description: If set, then counting of events in U-mode is inhibited.
37+
reset_value: UNDEFINED_LEGAL
38+
39+
VSINH:
40+
alias: minstretcfg.VSINH
41+
location: 27
42+
type: RW
43+
definedBy: H
44+
description: If set, then counting of events in VS-mode is inhibited.
45+
reset_value: UNDEFINED_LEGAL
46+
47+
VUINH:
48+
alias: minstretcfg.VUINH
49+
location: 26
50+
type: RW
51+
definedBy: H
52+
description: If set, then counting of events in VU-mode is inhibited.
53+
reset_value: UNDEFINED_LEGAL

0 commit comments

Comments
 (0)