Skip to content

Commit

Permalink
fix(csr): add difftest of mhpmevent overflow to diff csr mhpmeventn
Browse files Browse the repository at this point in the history
* Count overflow only from hardware incrementes of counter registers
* Through XiangShan->difftest->NEMU, to make NEMU get mhpmevent.of
  • Loading branch information
sinceforYy committed Oct 25, 2024
1 parent c32a7e4 commit 9106a61
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/scala/xiangshan/backend/fu/NewCSR/NewCSR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ class NewCSR(implicit val p: Parameters) extends Module
// perf
val addrInPerfCnt = (wenLegal || ren) && (
(addr >= CSRs.mcycle.U) && (addr <= CSRs.mhpmcounter31.U) ||
(addr === mcountinhibit.addr.U) ||
(addr >= CSRs.cycle.U) && (addr <= CSRs.hpmcounter31.U) ||
Cat(aiaSkipCSRs.map(_.addr.U === addr)).orR
)
Expand Down Expand Up @@ -1416,6 +1415,13 @@ class NewCSR(implicit val p: Parameters) extends Module
diffNonRegInterruptPendingEvent.platformIRPVstip := sstcIRGen.o.VSTIP
diffNonRegInterruptPendingEvent.localCounterOverflowInterruptReq := mip.regOut.LCOFIP.asBool

val diffMhpmeventOverflowEvent = DifftestModule(new DiffMhpmeventOverflowEvent)
diffMhpmeventOverflowEvent.coreid := hartId
diffMhpmeventOverflowEvent.valid := Cat(mhpmevents.zipWithIndex.map{ case (event, i) =>
!ofFromPerfCntVec(i) && RegNext(ofFromPerfCntVec(i)) || ofFromPerfCntVec(i) && !RegNext(ofFromPerfCntVec(i))
}).orR
diffMhpmeventOverflowEvent.mhpmeventOverflow := VecInit(mhpmevents.map(_.regOut.asInstanceOf[MhpmeventBundle].OF.asBool)).asUInt

}
}

Expand Down

0 comments on commit 9106a61

Please sign in to comment.