Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/scala/nutcore/backend/fu/CSR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,10 @@ class CSR(implicit val p: NutCoreConfig) extends NutCoreModule with HasCSRConst{
dmemAddrMisalignedAddr := lsuAddr
}

when(hasInstrPageFault || hasLoadPageFault || hasStorePageFault){
// Only the selected trap may update a trap-value CSR. Interrupts win.
val raiseIntr = io.cfIn.intrVec.asUInt.orR

when(!raiseIntr && (hasInstrPageFault || hasLoadPageFault || hasStorePageFault)){
val tval = Mux(hasInstrPageFault, Mux(io.cfIn.crossPageIPFFix, SignExt((io.cfIn.pc + 2.U)(VAddrBits-1,0), XLEN), SignExt(io.cfIn.pc(VAddrBits-1,0), XLEN)), SignExt(dmemPagefaultAddr, XLEN))
val pfCause = Mux(hasInstrPageFault, instrPageFault.U, Mux(hasLoadPageFault, loadPageFault.U, storePageFault.U))
val pfDelegS = medeleg(pfCause) && (privilegeMode < ModeM)
Expand All @@ -605,7 +608,7 @@ class CSR(implicit val p: NutCoreConfig) extends NutCoreModule with HasCSRConst{
Debug("[PF] %d: ipf %b tval %x := addr %x pc %x privilegeMode %x\n", GTimer(), hasInstrPageFault, tval, SignExt(dmemPagefaultAddr, XLEN), io.cfIn.pc, privilegeMode)
}

when(hasLoadAddrMisaligned || hasStoreAddrMisaligned)
when(!raiseIntr && (hasLoadAddrMisaligned || hasStoreAddrMisaligned))
{
val misalignTval = SignExt(dmemAddrMisalignedAddr, XLEN)
val maCause = Mux(hasLoadAddrMisaligned, loadAddrMisaligned.U, storeAddrMisaligned.U)
Expand Down Expand Up @@ -650,7 +653,6 @@ class CSR(implicit val p: NutCoreConfig) extends NutCoreModule with HasCSRConst{

val intrNO = IntPriority.foldRight(0.U)((i: Int, sum: UInt) => Mux(io.cfIn.intrVec(i), i.U, sum))
// val intrNO = PriorityEncoder(io.cfIn.intrVec)
val raiseIntr = io.cfIn.intrVec.asUInt.orR

// exceptions

Expand Down