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.
| 31:24 | 23:16 | 15:8 | 7:0 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PC | |||||||||||||||||||||||||||||||
| 63:56 | 55:48 | 47:40 | 39:32 | 31:24 | 23:16 | 15:8 | 7:0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bits | Field | Alias | Description | Type | Reset |
|---|---|---|---|---|---|
| RV32 [31:0] RV64 [63:0] | PC | When a NMI / double trap is taken into M-mode, `mnepc.PC` is written with the virtual address of the instruction that was interrupted or that encountered the exception. Otherwise, `mnepc.PC` is never written by the implementation, though it may be explicitly written by software. On an exception return from M-mode NMI / double trap (from the MNRET instruction), control transfers to the virtual address read out of `mnepc.PC`. Because PCs are always halfword-aligned, bit 0 of `mnepc.PC` is always read-only 0. Because PCs are always word-aligned, bits 1:0 of `mnepc.PC` are always read-only 0. When `misa.C` is clear, bit 1 is masked to zero. Writes to bit 1 are still captured, and may be visible on the next read with `misa.C` is set. | RW-RH | UNDEFINED_LEGAL |
if (implemented?(ExtensionName::C) && CSR[misa].C == 1'b1) {
return CSR[mnepc].PC & ~64'b1;
} else {
return CSR[mnepc].PC & ~64'b11;
}Version af3eaf9+cheriot.f635218
Data from the RISC-V Unified Database, copyright RISC-V International and contributors.
CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.
This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.