Skip to content

Commit e315a27

Browse files
authored
Bump DiffTest for TopIO and DiffPhyRegState (#242)
* fpga_diff: expose extra IO with difftest createTopIOs * feat(difftest): replace ArchReg and Writeback with PhyRegState This change refactors Difftest interfaces, replacing the previous ArchReg and WriteBack with PhyRegState and ArchRenameTable. Note when PhyReg size equals ArchReg, RenameTable can be skipped. By default, Difftest still extracts PhyReg and RenameTable into ArchReg on the hardware side, so that the extra multi-read area is accounted for within Difftest. When acceleration is enabled, this extraction is deferred to the software side, eliminating the extra hardware area overhead.
1 parent d223222 commit e315a27

File tree

8 files changed

+20
-31
lines changed

8 files changed

+20
-31
lines changed

src/main/scala/nutcore/RF.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ trait HasRegFileParameter {
2929
class RegFile extends HasRegFileParameter with HasNutCoreParameter {
3030
val rf = Mem(NRReg, UInt(XLEN.W))
3131
def read(addr: UInt) : UInt = Mux(addr === 0.U, 0.U, rf(addr))
32+
def read_all: Seq[UInt] = Seq(0.U) ++ (1 until NRReg).map { idx => rf(idx) }
3233
def write(addr: UInt, data: UInt) = { rf(addr) := data(XLEN-1,0) }
3334
}
3435

src/main/scala/nutcore/backend/ooo/Backend.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,9 @@ class Backend_ooo(implicit val p: NutCoreConfig) extends NutCoreModule with HasR
640640
BoringUtils.addSource(!io.in(0).valid, "perfCntCondMdpNoInst")
641641

642642
if (!p.FPGAPlatform || p.FPGADifftest) {
643-
val difftest = DifftestModule(new DiffArchIntRegState)
644-
difftest.coreid := 0.U // TODO
645-
difftest.value := VecInit((0 to NRReg-1).map(i => rf.read(i.U)))
643+
val difftest = DifftestModule(new DiffPhyIntRegState(NRReg)) // Size = NRREG, use as ArchIntReg
644+
difftest.coreid := 0.U
645+
difftest.value := VecInit(rf.read_all)
646646
}
647647

648648
if (!p.FPGAPlatform || p.FPGADifftest) {

src/main/scala/nutcore/backend/ooo/ROB.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,6 @@ class ROB(implicit val p: NutCoreConfig) extends NutCoreModule with HasInstrType
510510
difftest_commit.fpwen := false.B
511511
difftest_commit.wdest := io.wb(i).rfDest
512512
difftest_commit.wpdest := io.wb(i).rfDest
513-
514-
val difftest_wb = DifftestModule(new DiffIntWriteback, delay = 1)
515-
difftest_wb.coreid := 0.U
516-
difftest_wb.valid := io.wb(i).rfWen && io.wb(i).rfDest =/= 0.U
517-
difftest_wb.address := io.wb(i).rfDest
518-
difftest_wb.data := io.wb(i).rfData
519513
}
520514
} else {
521515
BoringUtils.addSource(retireATerm, "ilaWBUvalid")

src/main/scala/nutcore/backend/seq/ISU.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class ISU(implicit val p: NutCoreConfig) extends NutCoreModule with HasRegFilePa
9999
BoringUtils.addSource(WireInit(io.out.fire), "perfCntCondISUIssue")
100100

101101
if (!p.FPGAPlatform || p.FPGADifftest) {
102-
val difftest = DifftestModule(new DiffArchIntRegState)
103-
difftest.coreid := 0.U // TODO
104-
difftest.value := VecInit((0 to NRReg-1).map(i => rf.read(i.U)))
102+
val difftest = DifftestModule(new DiffPhyIntRegState(NRReg)) // Size = NRREG, use as ArchIntReg
103+
difftest.coreid := 0.U
104+
difftest.value := VecInit(rf.read_all)
105105
}
106106
}

src/main/scala/nutcore/backend/seq/WBU.scala

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/**************************************************************************************
22
* Copyright (c) 2020 Institute of Computing Technology, CAS
33
* Copyright (c) 2020 University of Chinese Academy of Sciences
4-
*
4+
*
55
* NutShell is licensed under Mulan PSL v2.
6-
* You can use this software according to the terms and conditions of the Mulan PSL v2.
6+
* You can use this software according to the terms and conditions of the Mulan PSL v2.
77
* You may obtain a copy of Mulan PSL v2 at:
8-
* http://license.coscl.org.cn/MulanPSL2
9-
*
10-
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
11-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
12-
* FIT FOR A PARTICULAR PURPOSE.
8+
* http://license.coscl.org.cn/MulanPSL2
9+
*
10+
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
11+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
12+
* FIT FOR A PARTICULAR PURPOSE.
1313
*
14-
* See the Mulan PSL v2 for more details.
14+
* See the Mulan PSL v2 for more details.
1515
***************************************************************************************/
1616

1717
package nutcore
@@ -57,12 +57,6 @@ class WBU(implicit val p: NutCoreConfig) extends NutCoreModule{
5757
difftest_commit.fpwen := false.B
5858
difftest_commit.wdest := io.wb.rfDest
5959
difftest_commit.wpdest := io.wb.rfDest
60-
61-
val difftest_wb = DifftestModule(new DiffIntWriteback, delay = 1)
62-
difftest_wb.coreid := 0.U
63-
difftest_wb.valid := io.wb.rfWen && io.wb.rfDest =/= 0.U
64-
difftest_wb.address := io.wb.rfDest
65-
difftest_wb.data := io.wb.rfData
6660
} else {
6761
BoringUtils.addSource(io.in.valid, "ilaWBUvalid")
6862
BoringUtils.addSource(io.in.bits.decode.cf.pc, "ilaWBUpc")

src/main/scala/sim/NutShellSim.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class NutShellSim extends Module with HasDiffTestInterfaces {
4545

4646
val uart = IO(new UARTIO)
4747
uart <> mmio.io.uart
48-
override def connectTopIOs(difftest: DifftestTopIO): Unit = {
48+
override def connectTopIOs(difftest: DifftestTopIO): Seq[Data] = {
4949
difftest.uart <> uart
50+
Seq.empty
5051
}
5152
}

src/test/scala/TopMain.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ class Top extends Module {
3939
class FpgaDiffTop extends NutShell()(NutCoreConfig(FPGADifftest = true)) with HasDiffTestInterfaces {
4040
override def desiredName: String = "NutShell"
4141
override def cpuName: Option[String] = Some("NutShell")
42-
override def connectTopIOs(difftest: DifftestTopIO): Unit = {
43-
val io = IO(chiselTypeOf(this.io))
44-
io <> this.io
42+
override def connectTopIOs(difftest: DifftestTopIO): Seq[Data] = {
43+
Seq(io)
4544
}
4645
}
4746

0 commit comments

Comments
 (0)