@@ -9,6 +9,7 @@ import chisel3.experimental.BundleLiterals._
99import chisel3 .experimental .VecLiterals ._
1010import org .chipsalliance .cde .config .Parameters
1111import org .chipsalliance .diplomacy .lazymodule .{LazyModule , LazyModuleImp }
12+ import freechips .rocketchip .diplomacy .{IdRange , TransferSizes }
1213import freechips .rocketchip .tile .TileKey
1314import freechips .rocketchip .tilelink ._
1415import freechips .rocketchip .diplomacy .{IdRange , AddressSet }
@@ -20,13 +21,15 @@ import scala.collection.mutable.ArrayBuffer
2021/** Testbench for Muon with the test signals */
2122class MuonCoreTestbench (implicit p : Parameters ) extends LazyModule {
2223 val coreTop = LazyModule (new MuonCoreTop ()(p.alterMap(Map (
23- // FIXME : this should be unnecessary with WithMuonCores(headless = true)
24+ // @cleanup : this should be unnecessary with WithMuonCores(headless = true)
2425 TileKey -> DummyTileParams
2526 ))))
2627 val xbar = TLXbar ()
2728 val fakeGmem = TLRAM (
28- address = AddressSet (0x0 , 1024 * 1024 * 16 - 1 ), // TODO: don't hardcode; 1MB region for each warp
29- beatBytes = p(MuonKey ).archLen / 8
29+ // address = AddressSet(0x0, (BigInt(1) << p(MuonKey).archLen) - 1),
30+ address = AddressSet (0x0 , 0x1000 - 1 ),
31+ beatBytes = p(MuonKey ).archLen / 8 ,
32+ devName = Some (" gmem" )
3033 )
3134
3235 // see doc in MuonLSUTestbench for TLBuffer
@@ -40,6 +43,7 @@ class MuonCoreTestbench(implicit p: Parameters) extends LazyModule {
4043 val io = IO (new Bundle {
4144 val finished = Bool ()
4245 })
46+
4347 io.finished := coreTop.module.io.finished
4448 }
4549}
@@ -178,23 +182,21 @@ class MuonLSUTestbench(implicit p: Parameters) extends LazyModule {
178182 }
179183}
180184
181- /** DUT module for core-standalone testbench */
185+ /** DUT module for core-standalone testbench.
186+ * Hooks up a MuonCore with a Rust instruction memory model, and exposes a TL
187+ * node for its global memory interface. */
182188class MuonCoreTop (implicit p : Parameters ) extends LazyModule with HasCoreParameters {
183189 val sourceIdsPerLane = 1 << lsuDerived.sourceIdBits
184190
185191 // every core lane is a separate TL client
186- def masterParams = (lane : Int ) => {
187- val sourceId = IdRange (0 , sourceIdsPerLane)
188- TLMasterParameters .v1(
189- name = f " lsu-gmem-lane $lane" ,
190- sourceId = sourceId,
191- requestFifo = false
192- )
193- }
194192 val lsuNodes = Seq .tabulate(muonParams.lsu.numLsuLanes) { lane =>
195193 TLClientNode (Seq (
196194 TLMasterPortParameters .v1(
197- Seq (masterParams(lane))
195+ Seq (TLMasterParameters .v1(
196+ name = f " lsu-gmem-lane $lane" ,
197+ sourceId = IdRange (0 , sourceIdsPerLane),
198+ requestFifo = false
199+ ))
198200 )
199201 ))
200202 }
@@ -206,16 +208,16 @@ class MuonCoreTop(implicit p: Parameters) extends LazyModule with HasCoreParamet
206208 })
207209
208210 val core = Module (new MuonCore ()(p))
209- core.io.imem.resp.valid := false .B
210- core.io.imem.resp.bits := DontCare
211- core.io.imem.req.ready := false .B
212211
213- // mem <> lsuAdapter
212+ val imem = Module (new CyclotronInstMem )
213+ core.io.imem <> imem.io.imem
214+
214215 MuonMemTL .multiConnectTL(
215216 core.io.dmem.req,
216217 core.io.dmem.resp,
217218 lsuNodes
218219 )
220+
219221 // tie off shared mem
220222 core.io.smem.req.foreach(_.ready := false .B )
221223 core.io.smem.resp.foreach(_.valid := false .B )
@@ -1019,6 +1021,50 @@ with HasBlackBoxResource with HasCoreParameters {
10191021 addResource(" /csrc/Cyclotron.cc" )
10201022}
10211023
1024+ class CyclotronInstMem (implicit p : Parameters ) extends CoreModule {
1025+ val io = IO (new Bundle {
1026+ val imem = Flipped (new InstMemIO )
1027+ })
1028+
1029+ val bbox = Module (new CyclotronInstMemBlackBox )
1030+ bbox.io.clock := clock
1031+ bbox.io.reset := reset.asBool
1032+
1033+ io.imem.req.ready := true .B
1034+ bbox.io.req.valid := io.imem.req.valid
1035+ bbox.io.req.bits.tag := io.imem.req.bits.tag
1036+ bbox.io.req.bits.pc := io.imem.req.bits.address
1037+
1038+ io.imem.resp.valid := bbox.io.resp.valid
1039+ io.imem.resp.bits.tag := bbox.io.resp.bits.tag
1040+ io.imem.resp.bits.data := bbox.io.resp.bits.inst
1041+ io.imem.resp.bits.metadata := DontCare
1042+
1043+ class CyclotronInstMemBlackBox (implicit val p : Parameters )
1044+ extends BlackBox (Map (
1045+ " ARCH_LEN" -> p(MuonKey ).archLen,
1046+ " INST_BITS" -> p(MuonKey ).instBits,
1047+ " IMEM_TAG_BITS" -> p(MuonKey ).l0iReqTagBits
1048+ )) with HasBlackBoxResource with HasCoreParameters {
1049+ val io = IO (new Bundle {
1050+ val clock = Input (Clock ())
1051+ val reset = Input (Bool ())
1052+ val req = Flipped (Valid (new Bundle {
1053+ val tag = UInt (imemTagBits.W )
1054+ val pc = pcT
1055+ }))
1056+ val resp = Valid (new Bundle {
1057+ val tag = UInt (imemTagBits.W )
1058+ val inst = instT
1059+ })
1060+ })
1061+
1062+ addResource(" /vsrc/CyclotronInstMem.v" )
1063+ addResource(" /vsrc/Cyclotron.vh" )
1064+ addResource(" /csrc/Cyclotron.cc" )
1065+ }
1066+ }
1067+
10221068/** If `tick` is true, advance cyclotron sim by one tick inside the difftest
10231069 * logic. Set to false when some other module does the tick, e.g.
10241070 * separate cyclotron frontend */
0 commit comments