@@ -7,18 +7,24 @@ bitfield ccsr : xlenbits = {
7
7
e : 0 /* enable */
8
8
}
9
9
10
- register mccsr : ccsr
11
- register sccsr : ccsr
10
+ register sccsr : ccsr /* mccsr aliases sccsr */
12
11
register uccsr : ccsr
13
12
14
13
/* access to CCSRs */
15
14
16
- // for now, use a single privilege-independent legalizer
17
- function legalize_ccsr(c : ccsr, v : xlenbits) -> ccsr = {
15
+ function legalize_uccsr(c : ccsr, v : xlenbits) -> ccsr = {
16
+ // There are no defined bits in UCCSR, so ignore v
17
+
18
+ /* For now these bits are not really supported so hardwired to true */
19
+ let c = update_d(c, 0b1);
20
+ let c = update_e(c, 0b1);
21
+ c
22
+ }
23
+
24
+ function legalize_sccsr(c : ccsr, v : xlenbits) -> ccsr = {
18
25
// write only the defined bits, leaving the other bits untouched
19
- // Technically, WPRI does not need a legalizer, since software is
20
- // assumed to legalize; so we could remove this function.
21
26
let v = Mk_ccsr(v);
27
+
22
28
/* For now these bits are not really supported so hardwired to true */
23
29
let c = update_d(c, 0b1);
24
30
let c = update_e(c, 0b1);
@@ -32,11 +38,11 @@ function legalize_ccsr(c : ccsr, v : xlenbits) -> ccsr = {
32
38
33
39
function clause ext_read_CSR (0x8C0) = Some(uccsr.bits())
34
40
function clause ext_read_CSR (0x9C0) = Some(sccsr.bits())
35
- function clause ext_read_CSR (0xBC0) = Some(mccsr .bits())
41
+ function clause ext_read_CSR (0xBC0) = Some(sccsr .bits())
36
42
37
- function clause ext_write_CSR (0x8C0, value) = { uccsr = legalize_ccsr (uccsr, value); Some(uccsr.bits()) }
38
- function clause ext_write_CSR (0x9C0, value) = { sccsr = legalize_ccsr (sccsr, value); Some(sccsr.bits()) }
39
- function clause ext_write_CSR (0xBC0, value) = { mccsr = legalize_ccsr(mccsr , value); Some(mccsr .bits()) }
43
+ function clause ext_write_CSR (0x8C0, value) = { uccsr = legalize_uccsr (uccsr, value); Some(uccsr.bits()) }
44
+ function clause ext_write_CSR (0x9C0, value) = { sccsr = legalize_sccsr (sccsr, value); Some(sccsr.bits()) }
45
+ function clause ext_write_CSR (0xBC0, value) = { sccsr = legalize_sccsr(sccsr , value); Some(sccsr .bits()) }
40
46
41
47
function clause ext_is_CSR_defined (0x8C0, p) = haveUsrMode() // uccsr
42
48
function clause ext_is_CSR_defined (0x9C0, p) = haveSupMode() & (p == Machine | p == Supervisor) // sccsr
0 commit comments