From 3e2285de2d3c02299c9d405e82f9f11e00919fd0 Mon Sep 17 00:00:00 2001 From: cz4e <35756813+cz4e@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:59:54 +0800 Subject: [PATCH] fix(LoadQueueReplay): fix enq mask generate when redirect (#3884) * 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 --- .../scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala b/src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala index f8c7f8f65e..ee557cc05d 100644 --- a/src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala +++ b/src/main/scala/xiangshan/mem/lsqueue/LoadQueueReplay.scala @@ -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)) })) @@ -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)))) @@ -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