Skip to content

Commit b79ea28

Browse files
committed
fix(vlbusytable): fix vlbusytable update
* use nonzeroTable instead of zeroTable, because we need to assume vl is always 0 * when vleff instruction writeback, clear the bit store in nonzeroTable and vlmaxTable
1 parent d084f29 commit b79ea28

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/main/scala/xiangshan/backend/dispatch/NewDispatch.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class NewDispatch(implicit p: Parameters) extends XSModule with HasPerfEvents wi
322322
val vma = fromRename(i).bits.vpu.vma
323323
val vm = fromRename(i).bits.vpu.vm
324324
val vlIsVlmax = vlBusyTable.io_vl_read.vlReadInfo(i).is_vlmax
325-
val vlIsNonZero = !vlBusyTable.io_vl_read.vlReadInfo(i).is_zero
325+
val vlIsNonZero = vlBusyTable.io_vl_read.vlReadInfo(i).is_nonzero
326326
val ignoreTail = vlIsVlmax && (vm =/= 0.U || vma) && !isWritePartVd
327327
val ignoreWhole = (vm =/= 0.U || vma) && vta
328328
val ignoreOldVd = vlBusyTable.io.read(i).resp && vlIsNonZero && !isDependOldVd && (ignoreTail || ignoreWhole)

src/main/scala/xiangshan/backend/rename/BusyTable.scala

+12-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class BusyTableReadIO(implicit p: Parameters) extends XSBundle {
3535

3636

3737
class VlBusyTableReadIO(implicit p: Parameters) extends XSBundle {
38-
val is_zero = Output(Bool())
38+
val is_nonzero = Output(Bool())
3939
val is_vlmax = Output(Bool())
4040
}
4141

@@ -207,31 +207,33 @@ class VlBusyTable(numReadPorts: Int, numWritePorts: Int, numPhyPregs: Int, pregW
207207
var intSchdVlWbPort = p(XSCoreParamsKey).intSchdVlWbPort
208208
var vfSchdVlWbPort = p(XSCoreParamsKey).vfSchdVlWbPort
209209

210-
val zeroTableUpdate = Wire(Vec(numPhyPregs, Bool()))
210+
val nonzeroTableUpdate = Wire(Vec(numPhyPregs, Bool()))
211211
val vlmaxTableUpdate = Wire(Vec(numPhyPregs, Bool()))
212212

213213
val intVlWb = Mux(io.wbPregs(intSchdVlWbPort).valid, UIntToOH(io.wbPregs(intSchdVlWbPort).bits), 0.U)
214214
val vfVlWb = Mux(io.wbPregs(vfSchdVlWbPort).valid, UIntToOH(io.wbPregs(vfSchdVlWbPort).bits), 0.U)
215+
// when other ports write back, we cannot know the vl value, so we should set the vl table to busy
216+
val otherPortsWb = io.wbPregs.zipWithIndex.filter(x => x._2 != intSchdVlWbPort && x._2 != vfSchdVlWbPort).map(x => Mux(x._1.valid, UIntToOH(x._1.bits), 0.U)).reduce(_ | _)
215217

216-
val zeroTable = VecInit((0 until numPhyPregs).zip(zeroTableUpdate).map{ case (idx, update) =>
218+
val nonzeroTable = VecInit((0 until numPhyPregs).zip(nonzeroTableUpdate).map{ case (idx, update) =>
217219
RegEnable(update, 0.U(1.W), allocMask(idx) || ldCancelMask(idx) || intVlWb(idx) || vfVlWb(idx))
218220
}).asUInt
219221
val vlmaxTable = VecInit((0 until numPhyPregs).zip(vlmaxTableUpdate).map{ case (idx, update) =>
220222
RegEnable(update, 0.U(1.W), allocMask(idx) || ldCancelMask(idx) || intVlWb(idx) || vfVlWb(idx))
221223
}).asUInt
222224

223225

224-
zeroTableUpdate.zipWithIndex.foreach{ case (update, idx) =>
226+
nonzeroTableUpdate.zipWithIndex.foreach{ case (update, idx) =>
225227
when(intVlWb(idx)) {
226228
// int schd vl write back, check whether the vl is zero
227-
update := !io_vl_Wb.vlWriteBackInfo.vlFromIntIsZero
229+
update := io_vl_Wb.vlWriteBackInfo.vlFromIntIsZero
228230
}.elsewhen(vfVlWb(idx)) {
229231
// vf schd vl write back, check whether the vl is zero
230-
update := !io_vl_Wb.vlWriteBackInfo.vlFromVfIsZero
231-
}.elsewhen(allocMask(idx) || ldCancelMask(idx)) {
232+
update := io_vl_Wb.vlWriteBackInfo.vlFromVfIsZero
233+
}.elsewhen(otherPortsWb(idx) || allocMask(idx) || ldCancelMask(idx)) {
232234
update := true.B
233235
}.otherwise {
234-
update := zeroTable(idx)
236+
update := nonzeroTable(idx)
235237
}
236238
}
237239

@@ -242,15 +244,15 @@ class VlBusyTable(numReadPorts: Int, numWritePorts: Int, numPhyPregs: Int, pregW
242244
}.elsewhen(vfVlWb(idx)) {
243245
// vf schd vl write back, check whether the vl is vlmax
244246
update := !io_vl_Wb.vlWriteBackInfo.vlFromVfIsVlmax
245-
}.elsewhen(allocMask(idx) || ldCancelMask(idx)) {
247+
}.elsewhen(otherPortsWb(idx) || allocMask(idx) || ldCancelMask(idx)) {
246248
update := true.B
247249
}.otherwise {
248250
update := vlmaxTable(idx)
249251
}
250252
}
251253

252254
io_vl_read.vlReadInfo.zip(io.read).foreach{ case (vlRes, res) =>
253-
vlRes.is_zero := !zeroTable(res.req)
255+
vlRes.is_nonzero := !nonzeroTable(res.req)
254256
vlRes.is_vlmax := !vlmaxTable(res.req)
255257
}
256258
}

0 commit comments

Comments
 (0)