Skip to content

Commit

Permalink
Fix #112 mstatus.tw
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Jul 3, 2024
1 parent 298e5ea commit 31e9db6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/scala/naxriscv/execute/EnvCallPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ class EnvCallPlugin(val euId : String)(var rescheduleAt : Int = 0) extends Plugi
import stage._
import s._

setup.reschedule.valid := isValid && (EBREAK || ECALL || XRET || FENCE_I || FLUSH_DATA || FENCE_VMA)
setup.reschedule.valid := isValid && (
EBREAK || ECALL || XRET || FENCE_I || FLUSH_DATA || FENCE_VMA ||
WFI && priv.logic.machine.mstatus.tw && !priv.isMachine()
)
setup.reschedule.robId := ROB.ID
setup.reschedule.tval := B(PC).andMask(EBREAK) //That's what spike do
setup.reschedule.skipCommit := EBREAK || ECALL
Expand Down Expand Up @@ -109,6 +112,9 @@ class EnvCallPlugin(val euId : String)(var rescheduleAt : Int = 0) extends Plugi
trap setWhen(priv.getPrivilege() === 1 && priv.logic.machine.mstatus.tvm)
trap setWhen(priv.getPrivilege() === 0)
}
if (priv.p.withUser) when(WFI) {
trap := True
}

when(trap){
setup.reschedule.cause := CSR.MCAUSE_ENUM.ILLEGAL_INSTRUCTION
Expand Down

0 comments on commit 31e9db6

Please sign in to comment.