Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dbltrp): fix sdt/dte interaction logic #3955

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 8 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,13 @@ 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)
// 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.
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 +515,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
Loading