Skip to content

Commit

Permalink
testtop: add TestTop_L2_Standalone for slave agent interaction (OpenX…
Browse files Browse the repository at this point in the history
  • Loading branch information
wakafa1 authored Dec 26, 2022
1 parent fecdfe9 commit 25d17d5
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ test-top-l2:
mill -i HuanCun.test.runMain huancun.TestTop_L2 -td build
mv build/TestTop_L2.v build/TestTop.v

test-top-l2standalone:
mill -i HuanCun.test.runMain huancun.TestTop_L2_Standalone -td build
mv build/TestTop_L2_Standalone.v build/TestTop.v

test-top-l2l3:
mill -i HuanCun.test.runMain huancun.TestTop_L2L3 -td build
mv build/TestTop_L2L3.v build/TestTop.v
Expand Down
103 changes: 103 additions & 0 deletions src/test/scala/huancun/TestTop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,85 @@ class TestTop_L2()(implicit p: Parameters) extends LazyModule {
}
}

class TestTop_L2_Standalone()(implicit p: Parameters) extends LazyModule {

/* L1D L1D
* \ /
* L2
*/

val delayFactor = 0.5
val cacheParams = p(HCCacheParamsKey)

def createClientNode(name: String, sources: Int) = {
val masterNode = TLClientNode(Seq(
TLMasterPortParameters.v2(
masters = Seq(
TLMasterParameters.v1(
name = name,
sourceId = IdRange(0, sources),
supportsProbe = TransferSizes(cacheParams.blockBytes)
)
),
channelBytes = TLChannelBeatBytes(cacheParams.blockBytes),
minLatency = 1,
echoFields = cacheParams.echoField,
requestFields = Seq(PrefetchField(), PreferCacheField(), DirtyField(), AliasField(2)),
responseKeys = cacheParams.respKey
)
))
masterNode
}

def createManagerNode(name: String, sources: Int) = {
val xfer = TransferSizes(cacheParams.blockBytes, cacheParams.blockBytes)
val slaveNode = TLManagerNode(Seq(
TLSlavePortParameters.v1(Seq(
TLSlaveParameters.v1(
address = Seq(AddressSet(0, 0xffffL)),
regionType = RegionType.CACHED,
executable = true,
supportsAcquireT = xfer,
supportsAcquireB = xfer,
fifoId = None
)),
beatBytes = 32,
minLatency = 2,
responseFields = cacheParams.respField,
requestKeys = cacheParams.reqKey,
endSinkId = sources
))
)
slaveNode
}

val l1d_nodes = (0 until 2) map( i => createClientNode(s"l1d$i", 32))
val l1d_l2_tllog_nodes = (0 until 2) map(i => TLLogger(s"L1D_L2_$i"))
val master_nodes = l1d_nodes

val l2 = LazyModule(new HuanCun())
val xbar = TLXbar()
val l3 = createManagerNode("Fake_L3", 16)

for(i <- 0 until 2) {
xbar :=* l1d_l2_tllog_nodes(i) := TLBuffer() := l1d_nodes(i)
}

l3 :=
TLBuffer() :=
TLXbar() :=*
TLDelayer(delayFactor) :=*
l2.node :=* xbar

lazy val module = new LazyModuleImp(this){
master_nodes.zipWithIndex.foreach{
case (node, i) =>
node.makeIOs()(ValName(s"master_port_$i"))
}
l3.makeIOs()(ValName(s"slave_port"))
}
}

class TestTop_L2L3()(implicit p: Parameters) extends LazyModule {

/* L1D L1D
Expand Down Expand Up @@ -340,6 +419,30 @@ object TestTop_L2 extends App with HasRocketChipStageUtils {
}
}

object TestTop_L2_Standalone extends App with HasRocketChipStageUtils {
val config = new Config((_, _, _) => {
case HCCacheParamsKey => HCCacheParameters(
inclusive = false,
clientCaches = Seq(CacheParameters(sets = 32, ways = 8, blockGranularity = 5, name = "L2", aliasBitsOpt = Some(2))),
echoField = Seq(DirtyField()),
sramClkDivBy2 = true,
)
})
val top = DisableMonitors(p => LazyModule(new TestTop_L2_Standalone()(p)) )(config)

(new ChiselStage).execute(args, Seq(
ChiselGeneratorAnnotation(() => top.module)
))
ChiselDB.addToElaborationArtefacts
ElaborationArtefacts.files.foreach{
case (extension, contents) =>
val prefix = extension match {
case "h" | "cpp" => "chisel_db"
}
writeOutputFile("./build", s"$prefix.${extension}", contents())
}
}

object TestTop_L2L3 extends App with HasRocketChipStageUtils {
val config = new Config((_, _, _) => {
case HCCacheParamsKey => HCCacheParameters(
Expand Down

0 comments on commit 25d17d5

Please sign in to comment.