Skip to content

Commit

Permalink
fix(dbltrp): fix sdt/dte interaction logic
Browse files Browse the repository at this point in the history
  * menvcfg.DTE only control Smode dbltrp. Thus mstatus.sdt will not
    control by DTE.
  * as sstatus is alias of mstatus, when menvcfg.DTE close write
    sstatus.sdt cannot lead to shadow write of mstatus.sdt. As a result,
    we add wmask of sdt, when write source is from alias write.
    While vsstatus is not alias of any other CSR fields, so origin logic
    is correct.
  • Loading branch information
lewislzh committed Nov 28, 2024
1 parent 4d585d2 commit 0e245bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/scala/xiangshan/backend/fu/NewCSR/MachineLevel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ class MstatusModule(implicit override val p: Parameters) extends CSRModule("MSta
}
// when DTE is zero, SDT field is read-only zero(write any, read zero, side effect of write 1 is block)
val writeSDT = Wire(Bool())
writeSDT := Mux(this.menvcfg.DTE.asBool, (w.wdataFields.SDT && w.wen) || (wAliasSstatus.wdataFields.SDT && wAliasSstatus.wen), 0.U)
when (!this.menvcfg.DTE) {
regOut.SDT := false.B
writeSDT := (w.wdataFields.SDT && w.wen) || (this.menvcfg.DTE.asBool && wAliasSstatus.wdataFields.SDT && wAliasSstatus.wen)
when (!this.menvcfg.DTE.asBool && wAliasSstatus.wdataFields.SDT && wAliasSstatus.wen ) {
reg.SDT := reg.SDT
}
// SDT and SIE is the same as MDT and MIE
when (writeSDT) {
Expand All @@ -511,6 +511,7 @@ class MstatusModule(implicit override val p: Parameters) extends CSRModule("MSta
// read connection
mstatus :|= regOut
sstatus := mstatus
sstatus.SDT := regOut.SDT && menvcfg.DTE
rdata := mstatus.asUInt
sstatusRdata := sstatus.asUInt
}
Expand Down

0 comments on commit 0e245bc

Please sign in to comment.