mret

Machine Exception Return

This instruction is defined by:

Encoding

svg

Synopsis

Returns from an exception in M-mode.

Access

M

HS

U

VS

VU

Always

Never

Never

Never

Never

Decode Variables

idl

Execution

if (true && CSR[mstatus].MPP != 2'b11) {
  CSR[mstatus].MPRV = 0;
}
CSR[mstatus].MIE = CSR[mstatus].MPIE;
CSR[mstatus].MPIE = 1;
if (CSR[mstatus].MPP == 2'b00) {
  set_mode(PrivilegeMode::U);
} else if (CSR[mstatus].MPP == 2'b01) {
  set_mode(PrivilegeMode::S);
} else if (CSR[mstatus].MPP == 2'b11) {
  set_mode(PrivilegeMode::M);
}
CSR[mstatus].MPP = 2'b00;
$pc = $bits(CSR[mepc]);
idl