Skip to content

Commit

Permalink
fix(LoadQueueReplay): fix enq mask generate when redirect (#3884)
Browse files Browse the repository at this point in the history
* Bug descriptions:
When an instruction first enq LoadQueueReplay and needs to be
redirected, the EnqMask generation does not take this situation into
account, then incorrectly updating the age matrix.

* Bug fix
use newEnqueue to generate EnqMask
  • Loading branch information
cz4e authored Nov 18, 2024
1 parent c49ebec commit 3e2285d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class LoadQueueReplay(implicit p: Parameters) extends XSModule
val needEnqueue = VecInit((0 until LoadPipelineWidth).map(w => {
canEnqueue(w) && !cancelEnq(w) && needReplay(w) && !hasExceptions(w)
}))
val newEnqueue = Wire(Vec(LoadPipelineWidth, Bool()))
val canFreeVec = VecInit((0 until LoadPipelineWidth).map(w => {
canEnqueue(w) && loadReplay(w) && (!needReplay(w) || hasExceptions(w))
}))
Expand Down Expand Up @@ -381,7 +382,7 @@ class LoadQueueReplay(implicit p: Parameters) extends XSModule
val needCancel = Wire(Vec(LoadQueueReplaySize, Bool()))
// generate enq mask
val enqIndexOH = Wire(Vec(LoadPipelineWidth, UInt(LoadQueueReplaySize.W)))
val s0_loadEnqFireMask = io.enq.map(x => x.fire && !x.bits.isLoadReplay && x.bits.rep_info.need_rep).zip(enqIndexOH).map(x => Mux(x._1, x._2, 0.U))
val s0_loadEnqFireMask = newEnqueue.zip(enqIndexOH).map(x => Mux(x._1, x._2, 0.U))
val s0_remLoadEnqFireVec = s0_loadEnqFireMask.map(x => VecInit((0 until LoadPipelineWidth).map(rem => getRemBits(x)(rem))))
val s0_remEnqSelVec = Seq.tabulate(LoadPipelineWidth)(w => VecInit(s0_remLoadEnqFireVec.map(x => x(w))))

Expand Down Expand Up @@ -603,9 +604,10 @@ class LoadQueueReplay(implicit p: Parameters) extends XSModule
assert(freeList.io.canAllocate.reduce(_ || _) || !io.enq.map(_.valid).reduce(_ || _), s"LoadQueueReplay Overflow")

// Allocate logic
val newEnqueue = (0 until LoadPipelineWidth).map(i => {
needEnqueue(i) && !io.enq(i).bits.isLoadReplay
})
needEnqueue.zip(newEnqueue).zip(io.enq).map {
case ((needEnq, newEnq), enq) =>
newEnq := needEnq && !enq.bits.isLoadReplay
}

for ((enq, w) <- io.enq.zipWithIndex) {
vaddrModule.io.wen(w) := false.B
Expand Down

0 comments on commit 3e2285d

Please sign in to comment.