@@ -8,16 +8,76 @@ address: 0x301
88writable : true
99priv_mode : M
1010length : MXLEN
11- description : Reports the XLEN and "major" extensions supported by the ISA.
1211definedBy : Sm
12+ prose :
13+ Overview :
14+ - type : informative
15+ text : |
16+ `misa` reports the base register size in M-mode and the set of single-letter
17+ extensions supported by the hart.
18+ - type : informative
19+ text : |
20+ The entire register may be read-only-0 in an implementation.
21+ If `misa` is read-only-0, discovery of `misa` information should be provided through
22+ non-standard mechanisms.
1323fields :
1424 MXL :
1525 location_rv32 : 31-30
1626 location_rv64 : 63-62
17- description : XLEN in M-mode.
27+ synopsys : |
28+ When `misa` is implemented, `misa.MXL` encodes the native base integer ISA width in M-mode,
29+ called `MXLEN`, as follows:
30+
31+ |===
32+ | MXL | MXLEN
33+
34+ | 1 | 32
35+ | 2 | 64
36+ |===
37+
38+ Other values are reserved.
39+ rules :
40+ - type : must
41+ id : csr-misa.mxl-value-rv32
42+ text : |
43+ `misa.MXL` must be read-only-1
44+ when() : return MISA_CSR_IMPLEMENTED && MXLEN == 32;
45+ - type : must
46+ id : csr-misa.mxl-value-rv64
47+ text : |
48+ `misa.MXL` must be read-only-2
49+ when() : return MISA_CSR_IMPLEMENTED && MXLEN == 64;
50+ - type : must
51+ id : csr-misa.mxl-value-not-implemented
52+ text : |
53+ `misa.MXL` must be read-only-0
54+ when() : return !MISA_CSR_IMPLEMENTED;
55+ prose :
56+ - type : informative
57+ text : |
58+ XLEN is never greater than MXLEN, but XLEN might be smaller than MXLEN in less-privileged
59+ modes.
60+
61+ - type : informative
62+ text : |
63+ The base width can be quickly ascertained using branches on the sign of the returned `misa`
64+ value, and possibly a shift left by one and a second branch on the sign.
65+ These checks can be written in assembly code without knowing the register width (MXLEN)
66+ of the hart.
67+ The base width is given by MXLEN=2MXL+4.
68+
69+ The base width can also be found if `misa` is zero, by placing the immediate 4 in a
70+ register, then shifting the register left by 31 bits at a time.
71+ If zero after one shift, then the hart is RV32.
72+ If zero after two shifts, then the hart is RV64, else RV128.
1873 type : RO
1974 reset_value() : |
20- return (MXLEN == 32) ? 2'b01 : 2'b10;
75+ if (MISA_CSR_IMPLEMENTED) {
76+ return (MXLEN == 32) ? 2'b01 : 2'b10;
77+ } else {
78+ return 0;
79+ }
80+
2181 A :
2282 location : 0
2383 description : |
@@ -30,18 +90,60 @@ fields:
3090 reset_value() : |
3191 return implemented?(ExtensionName::A) ? 1 : 0;
3292 definedBy : A
93+
3394 B :
3495 location : 1
35- description : |
96+ synopsis : |
3697 Indicates support for the `B` (bitmanip) extension.
98+ rules :
99+ - type : must
100+ id : csr-misa.b-reset-set
101+ text : |
102+ When all of `Zba`, `Zbb`, and `Zbs` are implemented, bit 1 of the `misa` CSR (`misa.B`) MUST reset to 1.
103+ when() : return MISA_CSR_IMPLEMENTED;
104+
105+ - type : must
106+ id : csr-misa.b-reset-clear
107+ text : |
108+ When at least one of `Zba`, `Zbb`, and `Zbs` are not implemented, `misa.B` MUST be read-only-0.
109+ when() : return MISA_CSR_IMPLEMENTED;
110+
111+ - type : may
112+ id : csr-misa.b-mutable
113+ text : |
114+ If parameter `MUTABLE_MISA_B` is true, the `misa.B` bit is writable.
115+ when() : return MISA_CSR_IMPLEMENTED;
116+
117+ - type : must
118+ id : csr-misa.b-clear-effect
119+ text : |
120+ Decoding an instruction from `Zba`, `Zbb`, or `Zbs` when `misa.B` is clear causes an
121+ `IllegalInstruction`.
122+ when() : return MISA_CSR_IMPLEMENTED && !nonconforming_extensions_implemented?();
123+
124+ - type : must
125+ id : csr-misa.b-clear-effect-non-conforming
126+ text : |
127+ Decoding an instruction from `Zba`, `Zbb`, or `Zbs` will either
128+ cause an `IllegalInstruction` trap or execute a non-conforming instruction if
129+ a non-conforming extension is supported that has an overlapping instruction with one from
130+ `Zba`, `Zbb`, or `Zbs`.
131+ when() : return MISA_CSR_IMPLEMENTED && nonconforming_extensions_implemented?();
37132
38- [when,"MUTABLE_MISA_B == true"]
39- Writing 0 to this field will cause all bitmanip instructions to raise an `IllegalInstruction` exception.
40133 type() : |
41- return (implemented?(ExtensionName::B) && MUTABLE_MISA_B) ? CsrFieldType::RW : CsrFieldType::RO;
134+ if (MISA_CSR_IMPLEMENTED) {
135+ return (implemented?(ExtensionName::B) && MUTABLE_MISA_B) ? CsrFieldType::RW : CsrFieldType::RO;
136+ } else {
137+ return CsrFieldType::RO;
138+ }
42139 reset_value() : |
43- return implemented?(ExtensionName::B) ? 1 : 0;
140+ if (MISA_CSR_IMPLEMENTED) {
141+ return implemented?(ExtensionName::B) ? 1 : 0;
142+ } else {
143+ return 0;
144+ }
44145 definedBy : B
146+
45147 C :
46148 location : 2
47149 description : |
0 commit comments