wfi
Wait for interrupt
This instruction is defined by:
Synopsis
Can causes the processor to enter a low-power state until the next interrupt occurs.
<%- if ext?(:H) -%> The behavior of wfi is affected by the mstatus.TW and hstatus.VTW bits, as summarized below.
wfi behavior |
|||||
HS-mode |
U-mode |
VS-mode |
in VU-mode |
||
---|---|---|---|---|---|
0 |
0 |
Wait |
Trap (I) |
Wait |
Trap (V) |
0 |
1 |
Wait |
Trap (I) |
Trap (V) |
Trap (V) |
1 |
- |
Trap (I) |
Trap (I) |
Trap (I) |
Trap (I) |
Trap (I) - Trap with |
<%- else -%> The wfi instruction is also affected by mstatus.TW, as shown below:
wfi behavior |
||
S-mode |
U-mode |
|
---|---|---|
0 |
Wait |
Trap (I) |
1 |
Trap (I) |
Trap (I) |
Trap (I) - Trap with |
<%- end -%>
Access
M |
HS |
U |
VS |
VU |
Always |
Sometimes |
Sometimes |
Sometimes |
Sometimes |
<%- if ext?(:H) -%> The behavior of wfi is affected by the mstatus.TW and hstatus.VTW bits, as summarized below.
wfi behavior |
|||||
HS-mode |
U-mode |
VS-mode |
in VU-mode |
||
---|---|---|---|---|---|
0 |
0 |
Wait |
Trap (I) |
Wait |
Trap (V) |
0 |
1 |
Wait |
Trap (I) |
Trap (V) |
Trap (V) |
1 |
- |
Trap (I) |
Trap (I) |
Trap (I) |
Trap (I) |
Trap (I) - Trap with |
<%- else -%> The wfi instruction is also affected by mstatus.TW, as shown below:
wfi behavior |
||
S-mode |
U-mode |
|
---|---|---|
0 |
Wait |
Trap (I) |
1 |
Trap (I) |
Trap (I) |
Trap (I) - Trap with |
<%- end -%>
Execution
-
Pruned, XLEN == 64
-
Original
if ((true) && (CSR[mstatus].TW == 1'b1)) {
}
if (CSR[hstatus].VTW == 1'b0) {
} else if (CSR[hstatus].VTW == 1'b1) {
}
wfi();
if (mode() == PrivilegeMode::U) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
if ((CSR[misa].S == 1) && (CSR[mstatus].TW == 1'b1)) {
if (mode() != PrivilegeMode::M) {
raise(ExceptionCode::IllegalInstruction, mode(), $encoding);
}
}
if (CSR[misa].H == 1) {
if (CSR[hstatus].VTW == 1'b0) {
if (mode() == PrivilegeMode::VU) {
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
}
} else if (CSR[hstatus].VTW == 1'b1) {
if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) {
raise(ExceptionCode::VirtualInstruction, mode(), $encoding);
}
}
}
wfi();