1
0

refactor how groundtests are configured

This commit is contained in:
Howard Mao 2016-07-08 11:40:01 -07:00
parent f62c74b82a
commit 850fa092a4
3 changed files with 34 additions and 30 deletions

View File

@ -9,15 +9,21 @@ import rocket._
import scala.util.Random import scala.util.Random
import cde.{Parameters, Field} import cde.{Parameters, Field}
case object MaxGenerateRequests extends Field[Int] case class GeneratorParameters(
case object GeneratorStartAddress extends Field[BigInt] maxRequests: Int,
startAddress: BigInt)
case object GeneratorKey extends Field[GeneratorParameters]
trait HasGeneratorParameters extends HasGroundTestParameters { trait HasGeneratorParameters extends HasGroundTestParameters {
implicit val p: Parameters 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 genTimeout = 8192
val maxRequests = p(MaxGenerateRequests) val maxRequests = genParams.maxRequests
val startAddress = p(GeneratorStartAddress) val startAddress = genParams.startAddress
val genWordBits = 32 val genWordBits = 32
val genWordBytes = genWordBits / 8 val genWordBytes = genWordBits / 8
val wordOffset = log2Up(genWordBytes) val wordOffset = log2Up(genWordBytes)
@ -167,18 +173,20 @@ class HellaCacheGenerator(id: Int)
s"Received incorrect data in cached generator ${id}") 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 { 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 cached = List.tabulate(nCached) { i =>
val realId = id * totalGens + i val realId = idStart + i
Module(new HellaCacheGenerator(realId)) Module(new HellaCacheGenerator(realId))
} }
val uncached = List.tabulate(nUncached) { i => val uncached = List.tabulate(nUncached) { i =>
val realId = id * totalGens + nCached + i val realId = idStart + nCached + i
Module(new UncachedTileLinkGenerator(realId)) Module(new UncachedTileLinkGenerator(realId))
} }

View File

@ -8,20 +8,21 @@ import scala.util.Random
import scala.collection.mutable.ListBuffer import scala.collection.mutable.ListBuffer
import cde.{Parameters, Field} import cde.{Parameters, Field}
case object BuildGroundTest extends Field[(Int, Parameters) => GroundTest] case object BuildGroundTest extends Field[Parameters => GroundTest]
case object GroundTestMaxXacts extends Field[Int]
case object GroundTestCSRs extends Field[Seq[Int]]
case object TohostAddr extends Field[BigInt]
case object GroundTestCachedClients extends Field[Int] case class GroundTestTileSettings(
case object GroundTestUncachedClients extends Field[Int] uncached: Int = 0, cached: Int = 0, ptw: Int = 0,
case object GroundTestNPTW extends Field[Int] maxXacts: Int = 1, csrs: Int = 0)
case object GroundTestKey extends Field[Seq[GroundTestTileSettings]]
case object GroundTestId extends Field[Int]
trait HasGroundTestParameters extends HasAddrMapParameters { trait HasGroundTestParameters extends HasAddrMapParameters {
implicit val p: Parameters implicit val p: Parameters
val nUncached = p(GroundTestUncachedClients) val tileId = p(GroundTestId)
val nCached = p(GroundTestCachedClients) val tileSettings = p(GroundTestKey)(tileId)
val nPTW = p(GroundTestNPTW) val nUncached = tileSettings.uncached
val nCached = tileSettings.cached
val nPTW = tileSettings.ptw
val memStart = addrMap("mem").start val memStart = addrMap("mem").start
val memStartBlock = memStart >> p(CacheBlockOffsetBits) val memStartBlock = memStart >> p(CacheBlockOffsetBits)
} }
@ -81,12 +82,12 @@ abstract class GroundTest(implicit val p: Parameters) extends Module
val io = new GroundTestIO val io = new GroundTestIO
} }
class GroundTestTile(id: Int, resetSignal: Bool) class GroundTestTile(resetSignal: Bool)
(implicit val p: Parameters) (implicit val p: Parameters)
extends Tile(resetSignal = resetSignal)(p) extends Tile(resetSignal = resetSignal)(p)
with HasGroundTestParameters { with HasGroundTestParameters {
val test = p(BuildGroundTest)(id, dcacheParams) val test = p(BuildGroundTest)(dcacheParams)
val ptwPorts = ListBuffer.empty ++= test.io.ptw val ptwPorts = ListBuffer.empty ++= test.io.ptw
val memPorts = ListBuffer.empty ++= test.io.mem val memPorts = ListBuffer.empty ++= test.io.mem
@ -112,12 +113,7 @@ class GroundTestTile(id: Int, resetSignal: Bool)
ptwPorts += dcache_io.ptw ptwPorts += dcache_io.ptw
} }
// Only Tile 0 needs to write tohost when (test.io.finished) { stop() }
if (id == 0) {
when (test.io.finished) {
stop()
}
}
if (ptwPorts.size > 0) { if (ptwPorts.size > 0) {
val ptw = Module(new DummyPTW(ptwPorts.size)) val ptw = Module(new DummyPTW(ptwPorts.size))

View File

@ -61,7 +61,7 @@ trait HasTraceGenParams {
implicit val p: Parameters implicit val p: Parameters
val numGens = p(NTiles) val numGens = p(NTiles)
val numBitsInId = log2Up(numGens) val numBitsInId = log2Up(numGens)
val numReqsPerGen = p(MaxGenerateRequests) val numReqsPerGen = p(GeneratorKey).maxRequests
val memRespTimeout = 8192 val memRespTimeout = 8192
val numBitsInWord = p(WordBits) val numBitsInWord = p(WordBits)
val numBytesInWord = numBitsInWord / 8 val numBytesInWord = numBitsInWord / 8
@ -546,10 +546,10 @@ class TraceGenerator(id: Int)
// Trace-generator wrapper // Trace-generator wrapper
// ======================= // =======================
class GroundTestTraceGenerator(id: Int)(implicit p: Parameters) class GroundTestTraceGenerator(implicit p: Parameters)
extends GroundTest()(p) with HasTraceGenParams { 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.cache.head <> traceGen.io.mem
io.finished := traceGen.io.finished io.finished := traceGen.io.finished