@@ -3,7 +3,7 @@ package xiangshan.backend.datapath
33import org .chipsalliance .cde .config .Parameters
44import chisel3 ._
55import chisel3 .util ._
6- import difftest .{ DiffArchFpRegState , DiffArchIntRegState , DiffArchVecRegState , DifftestModule }
6+ import difftest ._
77import freechips .rocketchip .diplomacy .{LazyModule , LazyModuleImp }
88import utility ._
99import utils .SeqUtils ._
@@ -265,38 +265,29 @@ class DataPath(implicit p: Parameters, params: BackendParams, param: SchdBlockPa
265265 io.fromPcTargetMem.fromDataPathFtqPtr := pcReadFtqPtr
266266 io.fromPcTargetMem.fromDataPathFtqOffset := pcReadFtqOffset
267267
268- private val intDiffRead : Option [( Vec [UInt ], Vec [ UInt ]) ] =
269- OptionWrapper (backendParams.basicDebugEn && param.isIntSchd, ( Wire (Vec (32 , UInt ( intSchdParams.pregIdxWidth. W ))), Wire ( Vec ( 32 , UInt (XLEN .W ) ))))
270- private val fpDiffRead : Option [( Vec [UInt ], Vec [ UInt ]) ] =
271- OptionWrapper (backendParams.basicDebugEn && param.isFpSchd, ( Wire (Vec (32 , UInt ( fpSchdParams.pregIdxWidth. W ))), Wire ( Vec ( 32 , UInt (XLEN .W ) ))))
272- private val vfDiffRead : Option [( Vec [UInt ], Vec [ UInt ]) ] =
273- OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, ( Wire (Vec (31 , UInt ( vecSchdParams.pregIdxWidth. W ))), Wire ( Vec ( 31 , UInt (VLEN .W ) ))))
274- private val v0DiffRead : Option [( Vec [UInt ], Vec [ UInt ]) ] =
275- OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, ( Wire (Vec (1 , UInt (log2Up( V0PhyRegs ). W ))), Wire ( Vec ( 1 , UInt (V0Data ().dataWidth.W ) ))))
268+ private val intDiffReadData : Option [Vec [UInt ]] =
269+ OptionWrapper (backendParams.basicDebugEn && param.isIntSchd, Wire (Vec (intSchdParams.numPregs, UInt (XLEN .W ))))
270+ private val fpDiffReadData : Option [Vec [UInt ]] =
271+ OptionWrapper (backendParams.basicDebugEn && param.isFpSchd, Wire (Vec (fpSchdParams.numPregs, UInt (XLEN .W ))))
272+ private val vfDiffReadData : Option [Vec [UInt ]] =
273+ OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, Wire (Vec (vecSchdParams.numPregs, UInt (VLEN .W ))))
274+ private val v0DiffReadData : Option [Vec [UInt ]] =
275+ OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, Wire (Vec (V0PhyRegs , UInt (V0Data ().dataWidth.W ))))
276276 private val vlDiffRead : Option [(Vec [UInt ], Vec [UInt ])] =
277277 OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, (Wire (Vec (1 , UInt (log2Up(VlPhyRegs ).W ))), Wire (Vec (1 , UInt (VlData ().dataWidth.W )))))
278278
279- private val fpDiffReadData : Option [Vec [UInt ]] =
280- OptionWrapper (backendParams.basicDebugEn && param.isFpSchd, Wire (Vec (32 , UInt (XLEN .W ))))
279+ private val vecDiffNumPregs = 2 * (V0PhyRegs + vecSchdParams.numPregs)
281280 private val vecDiffReadData : Option [Vec [UInt ]] =
282- OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, Wire (Vec (64 , UInt (64 .W )))) // v0 = Cat(Vec(1), Vec(0))
281+ OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, Wire (Vec (vecDiffNumPregs , UInt (64 .W )))) // v0 = Cat(Vec(1), Vec(0))
283282 private val vlDiffReadData : Option [UInt ] =
284283 OptionWrapper (backendParams.basicDebugEn && param.isVecSchd, Wire (UInt (VlData ().dataWidth.W )))
285284
286-
287- fpDiffReadData.foreach(_ := fpDiffRead
288- .get._2
289- .slice(0 , 32 )
290- .map(_(63 , 0 ))
291- ) // fp only used [63, 0]
292- vecDiffReadData.foreach(_ :=
293- v0DiffRead
294- .get._2
295- .slice(0 , 1 )
296- .map(x => Seq (x(63 , 0 ), x(127 , 64 ))).flatten ++
297- vfDiffRead
298- .get._2
299- .slice(0 , 31 )
285+ vecDiffReadData.foreach(_ :=
286+ v0DiffReadData
287+ .get
288+ .map(x => Seq (x(63 , 0 ), x(127 , 64 ))).flatten ++
289+ vfDiffReadData
290+ .get
300291 .map(x => Seq (x(63 , 0 ), x(127 , 64 ))).flatten
301292 )
302293 vlDiffReadData.foreach(_ := vlDiffRead
@@ -307,32 +298,44 @@ class DataPath(implicit p: Parameters, params: BackendParams, param: SchdBlockPa
307298 if (param.isIntSchd) {
308299 IntRegFileSplit (" IntRegFile" , intSchdParams.numPregs, splitNum, intRfRaddr, intRfRdata.get, intRfWen, intRfWaddr, intRfWdata,
309300 bankNum = 1 ,
310- debugReadAddr = intDiffRead.map(_._1),
311- debugReadData = intDiffRead.map(_._2)
301+ debugAllRData = intDiffReadData
312302 )
303+ if (env.AlwaysBasicDiff || env.EnableDifftest ) {
304+ // Delay of PhyRegFile should be same as RenameTable
305+ val difftest = DifftestModule (new DiffPhyIntRegState (intSchdParams.numPregs), delay = 2 )
306+ difftest.coreid := io.hartId
307+ difftest.value := intDiffReadData.get
308+ }
313309 }
314310 else if (param.isFpSchd) {
315311 FpRegFileSplit (" FpRegFile" , fpSchdParams.numPregs, splitNum, fpRfRaddr, fpRfRdata.get, fpRfWen, fpRfWaddr, fpRfWdata,
316312 bankNum = 1 ,
317- debugReadAddr = fpDiffRead.map(_._1),
318- debugReadData = fpDiffRead.map(_._2)
313+ debugAllRData = fpDiffReadData
319314 )
315+ if (env.AlwaysBasicDiff || env.EnableDifftest ) {
316+ val difftest = DifftestModule (new DiffPhyFpRegState (fpSchdParams.numPregs), delay = 2 )
317+ difftest.coreid := io.hartId
318+ difftest.value := fpDiffReadData.get
319+ }
320320 }
321321 else {
322322 VfRegFile (" VfRegFile" , vecSchdParams.numPregs, splitNum, vfRfRaddr, vfRfRdata.get, vfRfWen, vfRfWaddr, vfRfWdata,
323- debugReadAddr = vfDiffRead.map(_._1),
324- debugReadData = vfDiffRead.map(_._2)
323+ debugAllRData = vfDiffReadData
325324 )
326325 VfRegFile (" V0RegFile" , V0PhyRegs , v0RfSplitNum, v0RfRaddr, v0RfRdata.get, v0RfWen, v0RfWaddr, v0RfWdata,
327- debugReadAddr = v0DiffRead.map(_._1),
328- debugReadData = v0DiffRead.map(_._2)
326+ debugAllRData = v0DiffReadData
329327 )
330328 FpRegFile (" VlRegFile" , VlPhyRegs , vlRfRaddr, vlRfRdata.get, vlRfWen, vlRfWaddr, vlRfWdata,
331329 bankNum = 1 ,
332330 isVlRegfile = true ,
333331 debugReadAddr = vlDiffRead.map(_._1),
334332 debugReadData = vlDiffRead.map(_._2)
335333 )
334+ if (env.AlwaysBasicDiff || env.EnableDifftest ) {
335+ val difftest = DifftestModule (new DiffPhyVecRegState (vecDiffNumPregs), delay = 2 )
336+ difftest.coreid := io.hartId
337+ difftest.value := vecDiffReadData.get
338+ }
336339 }
337340
338341 intRfWaddr := io.fromIntWb.map(x => RegEnable (x.addr, x.wen)).toSeq
@@ -398,30 +401,15 @@ class DataPath(implicit p: Parameters, params: BackendParams, param: SchdBlockPa
398401 vlRfRaddr(portIdx) := 0 .U
399402 }
400403
401-
402- intDiffRead.foreach { case (addr, _) =>
403- addr := io.diffIntRat.get
404- }
405-
406- fpDiffRead.foreach { case (addr, _) =>
407- addr := io.diffFpRat.get
408- }
409-
410- vfDiffRead.foreach { case (addr, _) =>
411- addr := io.diffVecRat.get
412- }
413- v0DiffRead.foreach { case (addr, _) =>
414- addr := io.diffV0Rat.get
415- }
416404 vlDiffRead.foreach { case (addr, _) =>
417405 addr := io.diffVlRat.get
418406 }
419407
420408 println(s " [DataPath] " +
421- s " has intDiffRead: ${intDiffRead .nonEmpty}, " +
422- s " has fpDiffRead: ${fpDiffRead .nonEmpty}, " +
423- s " has vecDiffRead: ${vfDiffRead .nonEmpty}, " +
424- s " has v0DiffRead: ${v0DiffRead .nonEmpty}, " +
409+ s " has intDiffRead: ${intDiffReadData .nonEmpty}, " +
410+ s " has fpDiffRead: ${fpDiffReadData .nonEmpty}, " +
411+ s " has vecDiffRead: ${vfDiffReadData .nonEmpty}, " +
412+ s " has v0DiffRead: ${v0DiffReadData .nonEmpty}, " +
425413 s " has vlDiffRead: ${vlDiffRead.nonEmpty}" )
426414
427415 // regcache
@@ -713,25 +701,6 @@ class DataPath(implicit p: Parameters, params: BackendParams, param: SchdBlockPa
713701 }
714702 }
715703
716- if (env.AlwaysBasicDiff || env.EnableDifftest ) {
717- val delayedCnt = 2
718- if (param.isIntSchd) {
719- val difftestArchIntRegState = DifftestModule (new DiffArchIntRegState , delay = delayedCnt)
720- difftestArchIntRegState.coreid := io.hartId
721- difftestArchIntRegState.value := intDiffRead.get._2
722- }
723- if (param.isFpSchd) {
724- val difftestArchFpRegState = DifftestModule (new DiffArchFpRegState , delay = delayedCnt)
725- difftestArchFpRegState.coreid := io.hartId
726- difftestArchFpRegState.value := fpDiffReadData.get
727- }
728- if (param.isVecSchd) {
729- val difftestArchVecRegState = DifftestModule (new DiffArchVecRegState , delay = delayedCnt)
730- difftestArchVecRegState.coreid := io.hartId
731- difftestArchVecRegState.value := vecDiffReadData.get
732- }
733- }
734-
735704 val int_regcache_size = 48
736705 val int_regcache_tag = RegInit (VecInit (Seq .fill(int_regcache_size)(0 .U (intSchdParams.pregIdxWidth.W ))))
737706 val int_regcache_enqPtr = RegInit (0 .U (log2Up(int_regcache_size).W ))
@@ -980,10 +949,6 @@ class DataPathIO()(implicit p: Parameters, params: BackendParams, param: SchdBlo
980949 Output (UInt (RegCacheIdxWidth .W ))
981950 )
982951
983- val diffIntRat = if (params.basicDebugEn && param.isIntSchd) Some (Input (Vec (32 , UInt (intSchdParams.pregIdxWidth.W )))) else None
984- val diffFpRat = if (params.basicDebugEn && param.isFpSchd) Some (Input (Vec (32 , UInt (fpSchdParams.pregIdxWidth.W )))) else None
985- val diffVecRat = if (params.basicDebugEn && param.isVecSchd) Some (Input (Vec (31 , UInt (vecSchdParams.pregIdxWidth.W )))) else None
986- val diffV0Rat = if (params.basicDebugEn && param.isVecSchd) Some (Input (Vec (1 , UInt (log2Up(V0PhyRegs ).W )))) else None
987952 val diffVlRat = if (params.basicDebugEn && param.isVecSchd) Some (Input (Vec (1 , UInt (log2Up(VlPhyRegs ).W )))) else None
988953 val diffVl = if (params.basicDebugEn && param.isVecSchd) Some (Output (UInt (VlData ().dataWidth.W ))) else None
989954
0 commit comments