Skip to content

Commit 82fe870

Browse files
authored
top: Add a difftop for the fpgadiff platform (#233)
1 parent e4b5b0d commit 82fe870

File tree

10 files changed

+35
-9
lines changed

10 files changed

+35
-9
lines changed

src/main/scala/nutcore/NutCore.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ abstract class NutCoreBundle extends Bundle with HasNutCoreParameter with HasNut
6666

6767
case class NutCoreConfig (
6868
FPGAPlatform: Boolean = true,
69+
FPGADifftest: Boolean = false,
6970
EnableDebug: Boolean = Settings.get("EnableDebug"),
7071
EnhancedLog: Boolean = true
7172
)

src/main/scala/nutcore/backend/fu/CSR.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,14 @@ class CSR(implicit val p: NutCoreConfig) extends NutCoreModule with HasCSRConst{
885885
}}
886886

887887
val nutcoretrap = WireInit(false.B)
888-
if (!p.FPGAPlatform) {
888+
if (!p.FPGAPlatform || p.FPGADifftest) {
889889
BoringUtils.addSink(nutcoretrap, "nutcoretrap")
890890
} else {
891891
nutcoretrap := 0.U
892892
}
893893
def readWithScala(addr: Int): UInt = mapping(addr)._1
894894

895-
if (!p.FPGAPlatform) {
895+
if (!p.FPGAPlatform || p.FPGADifftest) {
896896
// to monitor
897897
BoringUtils.addSource(readWithScala(perfCntList("Mcycle")._1), "simCycleCnt")
898898
BoringUtils.addSource(readWithScala(perfCntList("Minstret")._1), "simInstrCnt")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,13 @@ class Backend_ooo(implicit val p: NutCoreConfig) extends NutCoreModule with HasR
639639
BoringUtils.addSource(io.in(1).valid && !instCango(1), "perfCntCondMdp2StCnt")
640640
BoringUtils.addSource(!io.in(0).valid, "perfCntCondMdpNoInst")
641641

642-
if (!p.FPGAPlatform) {
642+
if (!p.FPGAPlatform || p.FPGADifftest) {
643643
val difftest = DifftestModule(new DiffArchIntRegState)
644644
difftest.coreid := 0.U // TODO
645645
difftest.value := VecInit((0 to NRReg-1).map(i => rf.read(i.U)))
646646
}
647647

648-
if (!p.FPGAPlatform) {
648+
if (!p.FPGAPlatform || p.FPGADifftest) {
649649
val cycleCnt = WireInit(0.U(XLEN.W))
650650
val instrCnt = WireInit(0.U(XLEN.W))
651651
val nutcoretrap = WireInit(csrrs.io.out.bits.decode.ctrl.isNutCoreTrap && csrrs.io.out.valid)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class ROB(implicit val p: NutCoreConfig) extends NutCoreModule with HasInstrType
495495
BoringUtils.addSource(retireATerm, "perfCntCondMinstret")
496496
BoringUtils.addSource(retireMultiTerms, "perfCntCondMultiCommit")
497497

498-
if (!p.FPGAPlatform) {
498+
if (!p.FPGAPlatform || p.FPGADifftest) {
499499
for (i <- 0 until RetireWidth) {
500500
val difftest_commit = DifftestModule(new DiffInstrCommit(robSize * robWidth), delay = 1)
501501
difftest_commit.coreid := 0.U

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class EXU(implicit val p: NutCoreConfig) extends NutCoreModule {
129129
BoringUtils.addSource(WireInit(mdu.io.out.fire), "perfCntCondMmduInstr")
130130
BoringUtils.addSource(WireInit(csr.io.out.fire), "perfCntCondMcsrInstr")
131131

132-
if (!p.FPGAPlatform) {
132+
if (!p.FPGAPlatform || p.FPGADifftest) {
133133
val cycleCnt = WireInit(0.U(64.W))
134134
val instrCnt = WireInit(0.U(64.W))
135135
val nutcoretrap = WireInit(io.in.bits.ctrl.isNutCoreTrap && io.in.valid)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ISU(implicit val p: NutCoreConfig) extends NutCoreModule with HasRegFilePa
9898
BoringUtils.addSource(WireInit(io.out.valid && !io.out.fire), "perfCntCondMexuBusy")
9999
BoringUtils.addSource(WireInit(io.out.fire), "perfCntCondISUIssue")
100100

101-
if (!p.FPGAPlatform) {
101+
if (!p.FPGAPlatform || p.FPGADifftest) {
102102
val difftest = DifftestModule(new DiffArchIntRegState)
103103
difftest.coreid := 0.U // TODO
104104
difftest.value := VecInit((0 to NRReg-1).map(i => rf.read(i.U)))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class WBU(implicit val p: NutCoreConfig) extends NutCoreModule{
4444
BoringUtils.addSource(io.in.valid, "perfCntCondMinstret")
4545
BoringUtils.addSource(falseWire, "perfCntCondMultiCommit")
4646

47-
if (!p.FPGAPlatform) {
47+
if (!p.FPGAPlatform || p.FPGADifftest) {
4848
val difftest_commit = DifftestModule(new DiffInstrCommit, delay = 1, dontCare = true)
4949
difftest_commit.coreid := 0.U
5050
difftest_commit.index := 0.U

src/main/scala/system/NutShell.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class NutShell(implicit val p: NutCoreConfig) extends Module with HasSoCParamete
125125

126126

127127
// ILA
128-
if (p.FPGAPlatform) {
128+
if (p.FPGAPlatform && !p.FPGADifftest) {
129129
def BoringUtilsConnect(sink: UInt, id: String) = {
130130
val temp = WireInit(0.U(64.W))
131131
BoringUtils.addSink(temp, id)

src/main/scala/top/Settings.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ object Axu3cgSettings {
6464
)
6565
}
6666

67+
object FpgaDiffSettings {
68+
def apply() = Map(
69+
"FPGAPlatform" -> true,
70+
"FPGADifftest" -> true,
71+
"EnableILA" -> false,
72+
"hasPerfCnt" -> false,
73+
"NrExtIntr" -> 2,
74+
"EnableDebug" -> false
75+
)
76+
}
77+
6778
object PXIeSettings {
6879
def apply() = Map(
6980
"FPGAPlatform" -> true,

src/test/scala/TopMain.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ class Top extends Module {
3636
dontTouch(vga.io)
3737
}
3838

39+
class FpgaDiffTop extends Module {
40+
override lazy val desiredName: String = "SimTop"
41+
lazy val config = NutCoreConfig(FPGADifftest = true)
42+
val soc = Module(new NutShell()(config))
43+
val io = IO(soc.io.cloneType)
44+
soc.io <> io
45+
46+
val difftest = DifftestModule.finish("nutshell")
47+
dontTouch(soc.io)
48+
}
49+
3950
object TopMain extends App {
4051
def parseArgs(info: String, args: Array[String]): String = {
4152
var target = ""
@@ -51,6 +62,7 @@ object TopMain extends App {
5162
case "sim" => Nil
5263
case "pynq" => PynqSettings()
5364
case "axu3cg" => Axu3cgSettings()
65+
case "fpgadiff" => FpgaDiffSettings()
5466
case "PXIe" => PXIeSettings()
5567
} ) ++ ( core match {
5668
case "inorder" => InOrderSettings()
@@ -68,6 +80,8 @@ object TopMain extends App {
6880

6981
val generator = if (board == "sim") {
7082
ChiselGeneratorAnnotation(() => new SimTop)
83+
} else if (board == "fpgadiff") {
84+
ChiselGeneratorAnnotation(() => new FpgaDiffTop)
7185
}
7286
else {
7387
ChiselGeneratorAnnotation(() => new Top)

0 commit comments

Comments
 (0)