Skip to content

Commit

Permalink
fix(st-ld forward): modify misaligned forward fault detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Anzooooo committed Dec 13, 2024
1 parent f346d72 commit 9d13bcf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class LoadQueueReplay(implicit p: Parameters) extends XSModule
for (i <- 0 until LoadQueueReplaySize) {
// dequeue
// FIXME: store*Ptr is not accurate
dataNotBlockVec(i) := isNotBefore(io.stDataReadySqPtr, blockSqIdx(i)) || stDataReadyVec(blockSqIdx(i).value) || io.sqEmpty // for better timing
addrNotBlockVec(i) := isNotBefore(io.stAddrReadySqPtr, blockSqIdx(i)) || !strict(i) && stAddrReadyVec(blockSqIdx(i).value) || io.sqEmpty // for better timing
dataNotBlockVec(i) := isAfter(io.stDataReadySqPtr, blockSqIdx(i)) || stDataReadyVec(blockSqIdx(i).value) || io.sqEmpty // for better timing
addrNotBlockVec(i) := isAfter(io.stAddrReadySqPtr, blockSqIdx(i)) || !strict(i) && stAddrReadyVec(blockSqIdx(i).value) || io.sqEmpty // for better timing
// store address execute
storeAddrInSameCycleVec(i) := VecInit((0 until StorePipelineWidth).map(w => {
io.storeAddrIn(w).valid &&
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/xiangshan/mem/lsqueue/StoreQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,13 @@ class StoreQueue(implicit p: Parameters) extends XSModule
//TODO But for the time being, this is the way to ensure correctness. Such a suitable opportunity to support unaligned forward.
val unalignedMask1 = unaligned.asUInt & forwardMask1.asUInt & allocated.asUInt
val unalignedMask2 = unaligned.asUInt & forwardMask2.asUInt & allocated.asUInt
val forwardPreWithUnaligned = (unalignedMask1 | unalignedMask2).asUInt.orR

// make chisel happy
val dataInvalidMask1Reg = Wire(UInt(StoreQueueSize.W))
dataInvalidMask1Reg := RegNext(dataInvalidMask1)
dataInvalidMask1Reg := RegNext(dataInvalidMask1 | unalignedMask1)
// make chisel happy
val dataInvalidMask2Reg = Wire(UInt(StoreQueueSize.W))
dataInvalidMask2Reg := RegNext(dataInvalidMask2)
dataInvalidMask2Reg := RegNext(dataInvalidMask2 | unalignedMask2)
val dataInvalidMaskReg = dataInvalidMask1Reg | dataInvalidMask2Reg

// If SSID match, address not ready, mark it as addrInvalid
Expand All @@ -708,7 +707,7 @@ class StoreQueue(implicit p: Parameters) extends XSModule
val addrInvalidMaskReg = addrInvalidMask1Reg | addrInvalidMask2Reg

// load_s2
io.forward(i).dataInvalid := RegNext(io.forward(i).dataInvalidFast) || RegNext(forwardPreWithUnaligned)
io.forward(i).dataInvalid := RegNext(io.forward(i).dataInvalidFast)
// check if vaddr forward mismatched
io.forward(i).matchInvalid := vaddrMatchFailed

Expand Down

0 comments on commit 9d13bcf

Please sign in to comment.