1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
/* Mapping of csr addresses to their names. */
val cast csr_name : csreg -> string
function csr_name(csr) = {
match (csr) {
/* user trap setup */
0x000 => "ustatus",
0x004 => "uie",
0x005 => "utvec",
/* user trap handling */
0x040 => "uscratch",
0x041 => "uepc",
0x042 => "ucause",
0x043 => "utval",
0x044 => "uip",
/* user floating-point context */
0x001 => "fflags",
0x002 => "frm",
0x003 => "fcsr",
/* counter/timers */
0xC00 => "cycle",
0xC01 => "time",
0xC02 => "instret",
0xC80 => "cycleh",
0xC81 => "timeh",
0xC82 => "instreth",
/* TODO: other hpm counters */
/* supervisor trap setup */
0x100 => "sstatus",
0x102 => "sedeleg",
0x103 => "sideleg",
0x104 => "sie",
0x105 => "stvec",
0x106 => "scounteren",
/* supervisor trap handling */
0x140 => "sscratch",
0x141 => "sepc",
0x142 => "scause",
0x143 => "stval",
0x144 => "sip",
/* supervisor protection and translation */
0x180 => "satp",
/* machine information registers */
0xF11 => "mvendorid",
0xF12 => "marchid",
0xF13 => "mimpid",
0xF14 => "mhartid",
/* machine trap setup */
0x300 => "mstatus",
0x301 => "misa",
0x302 => "medeleg",
0x303 => "mideleg",
0x304 => "mie",
0x305 => "mtvec",
0x306 => "mcounteren",
/* machine trap handling */
0x340 => "mscratch",
0x341 => "mepc",
0x342 => "mcause",
0x343 => "mtval",
0x344 => "mip",
0x3A0 => "pmpcfg0",
0x3B0 => "pmpaddr0",
/* TODO: machine protection and translation */
/* machine counters/timers */
0xB00 => "mcycle",
0xB02 => "minstret",
0xB80 => "mcycleh",
0xB82 => "minstreth",
/* TODO: other hpm counters and events */
/* trigger/debug */
0x7a0 => "tselect",
_ => "UNKNOWN"
}
}
mapping csr_name_map : csreg <-> string = {
/* user trap setup */
0x000 <-> "ustatus",
0x004 <-> "uie",
0x005 <-> "utvec",
/* user trap handling */
0x040 <-> "uscratch",
0x041 <-> "uepc",
0x042 <-> "ucause",
0x043 <-> "utval",
0x044 <-> "uip",
/* user floating-point context */
0x001 <-> "fflags",
0x002 <-> "frm",
0x003 <-> "fcsr",
/* counter/timers */
0xC00 <-> "cycle",
0xC01 <-> "time",
0xC02 <-> "instret",
0xC80 <-> "cycleh",
0xC81 <-> "timeh",
0xC82 <-> "instreth",
/* TODO: other hpm counters */
/* supervisor trap setup */
0x100 <-> "sstatus",
0x102 <-> "sedeleg",
0x103 <-> "sideleg",
0x104 <-> "sie",
0x105 <-> "stvec",
0x106 <-> "scounteren",
/* supervisor trap handling */
0x140 <-> "sscratch",
0x141 <-> "sepc",
0x142 <-> "scause",
0x143 <-> "stval",
0x144 <-> "sip",
/* supervisor protection and translation */
0x180 <-> "satp",
/* machine information registers */
0xF11 <-> "mvendorid",
0xF12 <-> "marchid",
0xF13 <-> "mimpid",
0xF14 <-> "mhartid",
/* machine trap setup */
0x300 <-> "mstatus",
0x301 <-> "misa",
0x302 <-> "medeleg",
0x303 <-> "mideleg",
0x304 <-> "mie",
0x305 <-> "mtvec",
0x306 <-> "mcounteren",
/* machine trap handling */
0x340 <-> "mscratch",
0x341 <-> "mepc",
0x342 <-> "mcause",
0x343 <-> "mtval",
0x344 <-> "mip",
/* machine protection and translation */
0x3A0 <-> "pmpcfg0",
0x3A1 <-> "pmpcfg1",
0x3A2 <-> "pmpcfg2",
0x3A3 <-> "pmpcfg3",
0x3B0 <-> "pmpaddr0",
0x3B1 <-> "pmpaddr1",
0x3B2 <-> "pmpaddr2",
0x3B3 <-> "pmpaddr3",
0x3B4 <-> "pmpaddr4",
0x3B5 <-> "pmpaddr5",
0x3B6 <-> "pmpaddr6",
0x3B7 <-> "pmpaddr7",
0x3B8 <-> "pmpaddr8",
0x3B9 <-> "pmpaddr9",
0x3BA <-> "pmpaddr10",
0x3BB <-> "pmpaddr11",
0x3BC <-> "pmpaddr12",
0x3BD <-> "pmpaddr13",
0x3BE <-> "pmpaddr14",
0x3BF <-> "pmpaddr15",
/* machine counters/timers */
0xB00 <-> "mcycle",
0xB02 <-> "minstret",
0xB80 <-> "mcycleh",
0xB82 <-> "minstreth",
/* TODO: other hpm counters and events */
/* trigger/debug */
0x7a0 <-> "tselect",
0x7a1 <-> "tdata1",
0x7a2 <-> "tdata2",
0x7a3 <-> "tdata3"
/* numeric fallback */
/* reg <-> hex_bits_12(reg) */
}
|