mepc
Machine Exception Program Counter
Written with the PC of an instruction on an exception or interrupt taken in M-mode.
Also controls where the hart jumps on an exception return from M-mode.
Attributes
Defining Extension |
|
---|---|
CSR Address |
0x341 |
Length |
32 when CSR[misa].MXL == 0 64 when CSR[misa].MXL == 1 |
Privilege Mode |
M |
Format
This CSR format changes dynamically.
Figure 1. mepc Format when CSR[misa].MXL == 0
Figure 2. mepc Format when CSR[misa].MXL == 1
Field Summary
Name | Location | Type | Reset Value |
---|---|---|---|
* 31:0 when CSR[misa].MXL == 0 * 63:0 when CSR[misa].MXL == 1 |
RW-RH |
0 |
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:
PC = return csr_value.PC & ~64'b1;
Software read
This CSR may return a value that is different from what is stored in hardware.
if (implemented?(ExtensionName::C) && CSR[misa].C == 1'b1) {
return CSR[mepc].PC & ~64'b1;
} else {
return CSR[mepc].PC;
}