From 850fa092a41ceaab9db81a8e4935af744e5a1b27 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Fri, 8 Jul 2016 11:40:01 -0700 Subject: [PATCH] refactor how groundtests are configured --- groundtest/src/main/scala/generator.scala | 26 +++++++++++------- groundtest/src/main/scala/tile.scala | 32 ++++++++++------------- groundtest/src/main/scala/tracegen.scala | 6 ++--- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/groundtest/src/main/scala/generator.scala b/groundtest/src/main/scala/generator.scala index 258fe4c2..84aad6a5 100644 --- a/groundtest/src/main/scala/generator.scala +++ b/groundtest/src/main/scala/generator.scala @@ -9,15 +9,21 @@ import rocket._ import scala.util.Random import cde.{Parameters, Field} -case object MaxGenerateRequests extends Field[Int] -case object GeneratorStartAddress extends Field[BigInt] +case class GeneratorParameters( + maxRequests: Int, + startAddress: BigInt) +case object GeneratorKey extends Field[GeneratorParameters] trait HasGeneratorParameters extends HasGroundTestParameters { implicit val p: Parameters - val nGens = p(NTiles) * (nUncached + nCached) + + val genParams = p(GeneratorKey) + val nGens = p(GroundTestKey).map( + cs => cs.uncached + cs.cached).reduce(_ + _) val genTimeout = 8192 - val maxRequests = p(MaxGenerateRequests) - val startAddress = p(GeneratorStartAddress) + val maxRequests = genParams.maxRequests + val startAddress = genParams.startAddress + val genWordBits = 32 val genWordBytes = genWordBits / 8 val wordOffset = log2Up(genWordBytes) @@ -167,18 +173,20 @@ class HellaCacheGenerator(id: Int) s"Received incorrect data in cached generator ${id}") } -class GeneratorTest(id: Int)(implicit p: Parameters) +class GeneratorTest(implicit p: Parameters) extends GroundTest()(p) with HasGeneratorParameters { - val totalGens = nUncached + nCached + val idStart = p(GroundTestKey).take(tileId) + .map(settings => settings.cached + settings.uncached) + .foldLeft(0)(_ + _) val cached = List.tabulate(nCached) { i => - val realId = id * totalGens + i + val realId = idStart + i Module(new HellaCacheGenerator(realId)) } val uncached = List.tabulate(nUncached) { i => - val realId = id * totalGens + nCached + i + val realId = idStart + nCached + i Module(new UncachedTileLinkGenerator(realId)) } diff --git a/groundtest/src/main/scala/tile.scala b/groundtest/src/main/scala/tile.scala index 5f3e6a68..e2203f7a 100644 --- a/groundtest/src/main/scala/tile.scala +++ b/groundtest/src/main/scala/tile.scala @@ -8,20 +8,21 @@ import scala.util.Random import scala.collection.mutable.ListBuffer import cde.{Parameters, Field} -case object BuildGroundTest extends Field[(Int, Parameters) => GroundTest] -case object GroundTestMaxXacts extends Field[Int] -case object GroundTestCSRs extends Field[Seq[Int]] -case object TohostAddr extends Field[BigInt] +case object BuildGroundTest extends Field[Parameters => GroundTest] -case object GroundTestCachedClients extends Field[Int] -case object GroundTestUncachedClients extends Field[Int] -case object GroundTestNPTW extends Field[Int] +case class GroundTestTileSettings( + uncached: Int = 0, cached: Int = 0, ptw: Int = 0, + maxXacts: Int = 1, csrs: Int = 0) +case object GroundTestKey extends Field[Seq[GroundTestTileSettings]] +case object GroundTestId extends Field[Int] trait HasGroundTestParameters extends HasAddrMapParameters { implicit val p: Parameters - val nUncached = p(GroundTestUncachedClients) - val nCached = p(GroundTestCachedClients) - val nPTW = p(GroundTestNPTW) + val tileId = p(GroundTestId) + val tileSettings = p(GroundTestKey)(tileId) + val nUncached = tileSettings.uncached + val nCached = tileSettings.cached + val nPTW = tileSettings.ptw val memStart = addrMap("mem").start val memStartBlock = memStart >> p(CacheBlockOffsetBits) } @@ -81,12 +82,12 @@ abstract class GroundTest(implicit val p: Parameters) extends Module val io = new GroundTestIO } -class GroundTestTile(id: Int, resetSignal: Bool) +class GroundTestTile(resetSignal: Bool) (implicit val p: Parameters) extends Tile(resetSignal = resetSignal)(p) with HasGroundTestParameters { - val test = p(BuildGroundTest)(id, dcacheParams) + val test = p(BuildGroundTest)(dcacheParams) val ptwPorts = ListBuffer.empty ++= test.io.ptw val memPorts = ListBuffer.empty ++= test.io.mem @@ -112,12 +113,7 @@ class GroundTestTile(id: Int, resetSignal: Bool) ptwPorts += dcache_io.ptw } - // Only Tile 0 needs to write tohost - if (id == 0) { - when (test.io.finished) { - stop() - } - } + when (test.io.finished) { stop() } if (ptwPorts.size > 0) { val ptw = Module(new DummyPTW(ptwPorts.size)) diff --git a/groundtest/src/main/scala/tracegen.scala b/groundtest/src/main/scala/tracegen.scala index 73faefe9..ca42f580 100644 --- a/groundtest/src/main/scala/tracegen.scala +++ b/groundtest/src/main/scala/tracegen.scala @@ -61,7 +61,7 @@ trait HasTraceGenParams { implicit val p: Parameters val numGens = p(NTiles) val numBitsInId = log2Up(numGens) - val numReqsPerGen = p(MaxGenerateRequests) + val numReqsPerGen = p(GeneratorKey).maxRequests val memRespTimeout = 8192 val numBitsInWord = p(WordBits) val numBytesInWord = numBitsInWord / 8 @@ -546,10 +546,10 @@ class TraceGenerator(id: Int) // Trace-generator wrapper // ======================= -class GroundTestTraceGenerator(id: Int)(implicit p: Parameters) +class GroundTestTraceGenerator(implicit p: Parameters) extends GroundTest()(p) with HasTraceGenParams { - val traceGen = Module(new TraceGenerator(id)) + val traceGen = Module(new TraceGenerator(p(GroundTestId))) io.cache.head <> traceGen.io.mem io.finished := traceGen.io.finished