mstatus
Machine Status
The mstatus register tracks and controls the hart’s current operating state.
Attributes
Defining Extension |
Sm, version >= Sm@1.11.0 |
|---|---|
CSR Address |
0x300 |
Length |
* 32 when CSR[misa].MXL == 0 * 64 when CSR[misa].MXL == 1 |
Privilege Mode |
M |
Format
This CSR format changes dynamically.
Field Summary
| Name | Location | Type | Reset Value |
|---|---|---|---|
* 31 when CSR[misa].MXL == 0 * 63 when CSR[misa].MXL == 1 |
[when,"(implemented?(ExtensionName::F) && HW_MSTATUS_FS_DIRTY_UPDATE != "never")"] RO-H [when,"(implemented?(ExtensionName::V) && HW_MSTATUS_VS_DIRTY_UPDATE != "never")"] RO-H [when,"else"] RO |
UNDEFINED_LEGAL |
|
42 |
RW-H |
UNDEFINED_LEGAL |
|
39 |
RW-H |
UNDEFINED_LEGAL |
|
38 |
RW-H |
0 |
|
37 |
[when,"M_MODE_ENDIANNESS == "dynamic""] RW [when,"M_MODE_ENDIANNESS != "dynamic""] RO |
UNDEFINED_LEGAL |
|
36 |
[when,"S_MODE_ENDIANNESS == "dynamic""] RW [when,"S_MODE_ENDIANNESS != "dynamic""] RO |
UNDEFINED_LEGAL |
|
35:34 |
[when,"implemented?(ExtensionName::S) && SXLEN == 3264"] RW [when,"!implemented?(ExtensionName::S) && SXLEN == 3264"] RO |
UNDEFINED_LEGAL |
|
33:32 |
[when,"UXLEN == 3264"] RW [when,"UXLEN != 3264"] RO |
UNDEFINED_LEGAL |
|
22 |
RW |
UNDEFINED_LEGAL |
|
21 |
RW |
UNDEFINED_LEGAL |
|
20 |
[when,"(CSR[misa].S == 1’b0)"] RO [when,"(CSR[misa].S != 1’b0)"] RW |
UNDEFINED_LEGAL |
|
19 |
RW |
UNDEFINED_LEGAL |
|
18 |
[when,"has_virt_mem?()"] RW [when,"!(has_virt_mem?())"] RO |
UNDEFINED_LEGAL |
|
17 |
[when,"misa.U == 1’b1"] RW-H [when,"misa.U != 1’b1"] RO |
0 |
|
16:15 |
RO |
0 |
|
14:13 |
[when,"(CSR[misa].F == 1’b1)"] RW-H [when,"(CSR[misa].S == 1’b0 && CSR[misa].F == 1’b0)"] RO [when,"else"] [when,"MSTATUS_FS_WRITABLE"] RW [when,"!(MSTATUS_FS_WRITABLE)"] RO |
UNDEFINED_LEGAL |
|
12:11 |
RW-H |
3 |
|
10:9 |
[when,"(CSR[misa].V == 1’b1)"] RW-H [when,"(CSR[misa].S == 1’b0 && CSR[misa].V == 1’b0)"] RO [when,"else"] [when,"MSTATUS_VS_WRITABLE"] RW [when,"!(MSTATUS_VS_WRITABLE)"] RO |
UNDEFINED_LEGAL |
|
8 |
RW-H |
UNDEFINED_LEGAL |
|
7 |
RW-H |
UNDEFINED_LEGAL |
|
6 |
[when,"U_MODE_ENDIANNESS == "dynamic""] RW [when,"U_MODE_ENDIANNESS != "dynamic""] RO |
UNDEFINED_LEGAL |
|
5 |
[when,"misa.S == 1’b1"] RW-H [when,"misa.S != 1’b1"] RO |
UNDEFINED_LEGAL |
|
3 |
RW-H |
0 |
|
1 |
[when,"misa.S == 1’b1"] RW-H [when,"misa.S != 1’b1"] RO |
UNDEFINED_LEGAL |
Software write
This CSR may store a value that is different from what software attempts to write.
When a software write occurs (e.g., through csrrw), the following determines the written value:
SD = csr_value.SD
MDT = csr_value.MDT
MPV = csr_value.MPV
GVA = csr_value.GVA
MBE = csr_value.MBE
SBE = csr_value.SBE
SXL = if (csr_value.SXL < csr_value.UXL) {
return UNDEFINED_LEGAL_DETERMINISTIC;
} else if (csr_value.SXL > 1) {
# SXL != [0, 1] is not defined (2 reserved for RV128, but that isn't ratified)
return UNDEFINED_LEGAL_DETERMINISTIC;
} else {
return csr_value.SXL;
}
UXL = if (csr_value.SXL < csr_value.UXL) {
return UNDEFINED_LEGAL_DETERMINISTIC;
} else if (csr_value.UXL > 1) {
# UXL != [0, 1] is not defined (2 reserved for RV128, but that isn't ratified)
return UNDEFINED_LEGAL_DETERMINISTIC;
} else {
return csr_value.UXL;
}
TSR = csr_value.TSR
TW = csr_value.TW
TVM = if (CSR[misa].S == 1'b0) {
return 0;
} else if (MSTATUS_TVM_IMPLEMENTED) {
return csr_value.TVM;
} else {
return 0;
}
MXR = csr_value.MXR
SUM = csr_value.SUM
MPRV = csr_value.MPRV
XS = csr_value.XS
FS = if (CSR[misa].F == 1'b1){
return ary_includes?<$array_size(MSTATUS_FS_LEGAL_VALUES), 2>(MSTATUS_FS_LEGAL_VALUES, csr_value.FS) ? csr_value.FS : UNDEFINED_LEGAL_DETERMINISTIC;
} else if ((CSR[misa].S == 1'b0) && (CSR[misa].F == 1'b0)) {
# must be read-only-0
return 0;
} else {
# there will be no hardware update in this case because we know the F extension isn't implemented
return ary_includes?<$array_size(MSTATUS_FS_LEGAL_VALUES), 2>(MSTATUS_FS_LEGAL_VALUES, csr_value.FS) ? csr_value.FS : UNDEFINED_LEGAL_DETERMINISTIC;
}
MPP = if (csr_value.MPP == 2'b01 && !implemented?(ExtensionName::S)) {
return UNDEFINED_LEGAL_DETERMINISTIC;
} else if (csr_value.MPP == 2'b00 && !implemented?(ExtensionName::U)) {
return UNDEFINED_LEGAL_DETERMINISTIC;
} else if (csr_value.MPP == 2'b10) {
# never a valid value
return UNDEFINED_LEGAL_DETERMINISTIC;
} else {
return csr_value.MPP;
}
VS = if (CSR[misa].V == 1'b1){
return ary_includes?<$array_size(MSTATUS_VS_LEGAL_VALUES), 2>(MSTATUS_VS_LEGAL_VALUES, csr_value.VS) ? csr_value.VS : UNDEFINED_LEGAL_DETERMINISTIC;
} else if ((CSR[misa].S == 1'b0) && (CSR[misa].V == 1'b0)) {
# must be read-only-0
return 0;
} else {
# there will be no hardware update in this case because we know the V extension isn't implemented
return ary_includes?<$array_size(MSTATUS_VS_LEGAL_VALUES), 2>(MSTATUS_VS_LEGAL_VALUES, csr_value.VS) ? csr_value.VS : UNDEFINED_LEGAL_DETERMINISTIC;
}
SPP = if (csr_value.SPP == 2'b10) {
return UNDEFINED_LEGAL_DETERMINISTIC;
} else {
return csr_value.SPP;
}
MPIE = csr_value.MPIE
UBE = csr_value.UBE
SPIE = csr_value.SPIE
MIE = csr_value.MIE
SIE = csr_value.SIE