Skip to content

Commit df13598

Browse files
klin02ngc7331
andcommitted
fix(difftest): add masked RefillEvent, disable for now
After #3051, we have supported low-power read (read only 5 out of 8 8B-banks) in ICacheDataArray, and in V3, it was further modified to dynamically compute the mask based on the taken branch location. Though, previous DiffRefillEvent does not support masked comparison, instead it checks entire 512bit, so it will fail if we enable checks on cacheid >=3 (OpenXiangShan/difftest#712). As we're refactoring ICache recently, we need this check to ensure the refactored code is working properly. This commit removes unused idtfr and introduces masked refill-check for Difftest, where each mask bit controls comparison of 8B data. However, as the newly added masked Refill fails CI, we disable it for now, and wait for later fixup. Co-authored-by: ngc7331 <[email protected]>
1 parent 52f391f commit df13598

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

src/main/scala/xiangshan/cache/dcache/mainpipe/MissQueue.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ class MissQueue(edge: TLEdgeOut, reqNum: Int)(implicit p: Parameters) extends DC
13241324
difftest.valid := io.refill_to_ldq.valid && io.refill_to_ldq.bits.hasdata && io.refill_to_ldq.bits.refill_done
13251325
difftest.addr := io.refill_to_ldq.bits.addr
13261326
difftest.data := io.refill_to_ldq.bits.data_raw.asTypeOf(difftest.data)
1327-
difftest.idtfr := DontCare
1327+
difftest.mask := VecInit.fill(difftest.mask.getWidth)(true.B).asUInt
13281328
}
13291329

13301330
// Perf count

src/main/scala/xiangshan/cache/mmu/L2TLB.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ class L2TLBImp(outer: L2TLB)(implicit p: Parameters) extends PtwModule(outer) wi
553553
difftest.valid := cache.io.refill.valid
554554
difftest.addr := difftest_ptw_addr(RegEnable(mem.d.bits.source, mem.d.valid))
555555
difftest.data := refill_data.asTypeOf(difftest.data)
556-
difftest.idtfr := DontCare
556+
difftest.mask := VecInit.fill(difftest.mask.getWidth)(true.B).asUInt
557557
}
558558

559559
if (env.EnableDifftest) {

src/main/scala/xiangshan/frontend/icache/ICacheMainPipe.scala

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -456,26 +456,28 @@ class ICacheMainPipe(implicit p: Parameters) extends ICacheModule
456456

457457
/* *** difftest refill check *** */
458458
if (env.EnableDifftest) {
459-
val discard = toIfu.bits.exception.hasException || toIfu.bits.pmpMmio || Pbmt.isUncache(toIfu.bits.itlbPbmt)
460-
val blkPaddrAll =
461-
VecInit(s1_vAddr.map(va => (getPAddrFromPTag(va, s1_pTag)(PAddrBits - 1, blockOffBits) << blockOffBits).asUInt))
462-
(0 until DataBanks).foreach { i =>
463-
val diffMainPipeOut = DifftestModule(new DiffRefillEvent, dontCare = true)
464-
diffMainPipeOut.coreid := io.hartId
465-
diffMainPipeOut.index := (3 + i).U
466-
467-
val bankSel = getBankSel(s1_offset, s1_blkEndOffset, s1_doubleline).map(_.asUInt).reduce(_ | _)
468-
val lineSel = getLineSel(s1_offset)
469-
470-
diffMainPipeOut.valid := s1_fire && bankSel(i).asBool && !discard
471-
diffMainPipeOut.addr := Mux(
472-
lineSel(i),
473-
blkPaddrAll(1) + (i.U << log2Ceil(blockBytes / DataBanks)).asUInt,
474-
blkPaddrAll(0) + (i.U << log2Ceil(blockBytes / DataBanks)).asUInt
475-
)
476-
477-
diffMainPipeOut.data := s1_datas(i).asTypeOf(diffMainPipeOut.data)
478-
diffMainPipeOut.idtfr := DontCare
459+
val bankSel = getBankSel(s1_offset, s1_blkEndOffset, s1_doubleline)
460+
461+
// do difftest for each fetched cache line
462+
s1_vAddr.zipWithIndex.foreach { case (va, i) =>
463+
val difftest = DifftestModule(new DiffRefillEvent, dontCare = true)
464+
difftest.coreid := io.hartId
465+
difftest.index := (3 + i).U // magic number 3/4: ICache MainPipe refill test
466+
467+
difftest.valid := false.B
468+
// difftest.valid := s1_fire && !(
469+
// toIfu.bits.exception.hasException ||
470+
// toIfu.bits.pmpMmio ||
471+
// Pbmt.isUncache(toIfu.bits.itlbPbmt)
472+
// )
473+
difftest.addr := Cat(getBlkAddrFromPTag(va, s1_pTag), 0.U(blockOffBits.W))
474+
difftest.data := s1_datas.asTypeOf(difftest.data)
475+
// NOTE: each mask bit controls (512bit / difftest.mask.getWidth) (currently 64bit) comparison
476+
// this only works for DataBanks <= difftest.mask.getWidth (and isPow2)
477+
difftest.mask := VecInit((0 until difftest.mask.getWidth).map { j =>
478+
// the i-th mask locates in (i / (difftest.mask.getWidth / DataBanks)) bank
479+
bankSel(i)(j / (difftest.mask.getWidth / DataBanks))
480+
}).asUInt
479481
}
480482
}
481483
}

src/main/scala/xiangshan/frontend/icache/ICacheMissUnit.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@ class ICacheMissUnit(edge: TLEdgeOut)(implicit p: Parameters) extends ICacheModu
332332
difftest.valid := writeSramValid
333333
difftest.addr := Cat(mshrResp.blkPAddr, 0.U(blockOffBits.W))
334334
difftest.data := respDataReg.asTypeOf(difftest.data)
335-
difftest.idtfr := DontCare
335+
difftest.mask := VecInit.fill(difftest.mask.getWidth)(true.B).asUInt
336336
}
337337
}

0 commit comments

Comments
 (0)