Skip to content

Commit

Permalink
NewCSR: fix bug, shouldn't handle traping to other Mode anymore when …
Browse files Browse the repository at this point in the history
…hart traps to DebugMode
  • Loading branch information
wissygh committed Jul 29, 2024
1 parent f533cba commit 0718b40
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/scala/xiangshan/backend/fu/NewCSR/NewCSR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class NewCSR(implicit val p: Parameters) extends Module
trapHandleMod.io.in.vstvec := vstvec.regOut

val entryPrivState = trapHandleMod.io.out.entryPrivState
val entryDebugMode = Wire(Bool())

// PMP
val pmpEntryMod = Module(new PMPEntryHandleModule)
Expand Down Expand Up @@ -587,9 +588,9 @@ class NewCSR(implicit val p: Parameters) extends Module
println(mod.dumpFields)
}

trapEntryMEvent .valid := hasTrap && entryPrivState.isModeM
trapEntryHSEvent.valid := hasTrap && entryPrivState.isModeHS
trapEntryVSEvent.valid := hasTrap && entryPrivState.isModeVS
trapEntryMEvent .valid := hasTrap && entryPrivState.isModeM && !entryDebugMode
trapEntryHSEvent.valid := hasTrap && entryPrivState.isModeHS && !entryDebugMode
trapEntryVSEvent.valid := hasTrap && entryPrivState.isModeVS && !entryDebugMode

Seq(trapEntryMEvent, trapEntryHSEvent, trapEntryVSEvent, trapEntryDEvent).foreach { eMod =>
eMod.in match {
Expand Down Expand Up @@ -858,7 +859,9 @@ class NewCSR(implicit val p: Parameters) extends Module
debugMod.io.in.tdata2Update := tdata2Update
debugMod.io.in.tdata1Wdata := wdata

trapEntryDEvent.valid := debugMod.io.out.hasDebugTrap && !debugMode
entryDebugMode := debugMod.io.out.hasDebugTrap && !debugMode

trapEntryDEvent.valid := entryDebugMode
trapEntryDEvent.in.hasDebugIntr := debugMod.io.out.hasDebugIntr
trapEntryDEvent.in.debugMode := debugMode
trapEntryDEvent.in.hasTrap := hasTrap
Expand Down

0 comments on commit 0718b40

Please sign in to comment.