2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
// See LICENSE.Berkeley for license details.
|
|
|
|
|
2016-08-02 01:05:24 +02:00
|
|
|
package groundtest
|
2015-10-27 05:37:35 +01:00
|
|
|
|
|
|
|
import Chisel._
|
2017-02-09 22:59:09 +01:00
|
|
|
import config._
|
|
|
|
import coreplex._
|
2015-10-27 05:37:35 +01:00
|
|
|
import rocket._
|
2017-02-09 22:59:09 +01:00
|
|
|
import tile._
|
2016-06-28 22:15:56 +02:00
|
|
|
import uncore.tilelink._
|
2016-11-11 00:56:42 +01:00
|
|
|
import uncore.tilelink2._
|
2016-11-18 00:38:11 +01:00
|
|
|
import rocketchip.ExtMem
|
2016-11-11 00:56:42 +01:00
|
|
|
import diplomacy._
|
2016-09-14 05:22:20 +02:00
|
|
|
import util.ParameterizedBundle
|
2017-02-09 22:59:09 +01:00
|
|
|
|
|
|
|
import scala.collection.mutable.ListBuffer
|
2015-11-19 07:54:05 +01:00
|
|
|
|
2016-07-08 20:40:01 +02:00
|
|
|
case object BuildGroundTest extends Field[Parameters => GroundTest]
|
2015-10-27 05:37:35 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
case class GroundTestTileParams(
|
|
|
|
uncached: Int = 0,
|
|
|
|
ptw: Int = 0,
|
|
|
|
maxXacts: Int = 1,
|
|
|
|
dcache: Option[DCacheParams] = Some(DCacheParams())) extends TileParams {
|
|
|
|
val icache = None
|
|
|
|
val btb = None
|
|
|
|
val rocc = Nil
|
|
|
|
val core = rocket.RocketCoreParams() //TODO remove this
|
|
|
|
val cached = if(dcache.isDefined) 1 else 0
|
|
|
|
val dataScratchpadBytes = 0
|
|
|
|
}
|
|
|
|
case object GroundTestKey extends Field[Seq[GroundTestTileParams]]
|
2016-06-14 01:17:11 +02:00
|
|
|
|
2016-07-12 01:41:55 +02:00
|
|
|
trait HasGroundTestConstants {
|
|
|
|
val timeoutCodeBits = 4
|
|
|
|
val errorCodeBits = 4
|
|
|
|
}
|
|
|
|
|
2016-11-17 01:16:08 +01:00
|
|
|
trait HasGroundTestParameters {
|
2016-06-14 01:17:11 +02:00
|
|
|
implicit val p: Parameters
|
2017-02-09 22:59:09 +01:00
|
|
|
val tileParams = p(GroundTestKey)(p(TileId))
|
|
|
|
val nUncached = tileParams.uncached
|
|
|
|
val nCached = tileParams.cached
|
|
|
|
val nPTW = tileParams.ptw
|
2016-11-18 00:38:11 +01:00
|
|
|
val memStart = p(ExtMem).base
|
2016-06-14 01:17:11 +02:00
|
|
|
val memStartBlock = memStart >> p(CacheBlockOffsetBits)
|
|
|
|
}
|
|
|
|
|
2016-07-12 01:41:55 +02:00
|
|
|
class GroundTestStatus extends Bundle with HasGroundTestConstants {
|
|
|
|
val finished = Bool(OUTPUT)
|
|
|
|
val timeout = Valid(UInt(width = timeoutCodeBits))
|
|
|
|
val error = Valid(UInt(width = errorCodeBits))
|
|
|
|
}
|
|
|
|
|
2016-06-14 01:17:11 +02:00
|
|
|
class GroundTestIO(implicit val p: Parameters) extends ParameterizedBundle()(p)
|
|
|
|
with HasGroundTestParameters {
|
|
|
|
val cache = Vec(nCached, new HellaCacheIO)
|
|
|
|
val mem = Vec(nUncached, new ClientUncachedTileLinkIO)
|
|
|
|
val ptw = Vec(nPTW, new TLBPTWIO)
|
2016-07-12 01:41:55 +02:00
|
|
|
val status = new GroundTestStatus
|
2015-11-19 07:54:05 +01:00
|
|
|
}
|
2015-11-01 01:43:25 +01:00
|
|
|
|
2016-05-03 03:25:02 +02:00
|
|
|
abstract class GroundTest(implicit val p: Parameters) extends Module
|
2016-06-14 01:17:11 +02:00
|
|
|
with HasGroundTestParameters {
|
2015-11-19 07:54:05 +01:00
|
|
|
val io = new GroundTestIO
|
|
|
|
}
|
2015-11-01 01:43:25 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
class GroundTestTile(implicit p: Parameters) extends LazyModule
|
|
|
|
with HasGroundTestParameters {
|
2016-10-27 07:28:40 +02:00
|
|
|
val slave = None
|
2017-02-09 22:59:09 +01:00
|
|
|
val dcacheOpt = tileParams.dcache.map { dc => HellaCache(dc.nMSHRs == 0) }
|
2017-01-17 03:24:08 +01:00
|
|
|
val ucLegacy = LazyModule(new TLLegacy)
|
2016-11-11 00:56:42 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
val masterNode = TLOutputNode()
|
|
|
|
dcacheOpt.foreach { masterNode := _.node }
|
|
|
|
masterNode := TLHintHandler()(ucLegacy.node)
|
2016-11-15 03:09:17 +01:00
|
|
|
|
2016-11-11 00:56:42 +01:00
|
|
|
lazy val module = new LazyModuleImp(this) {
|
|
|
|
val io = new Bundle {
|
2017-02-09 22:59:09 +01:00
|
|
|
val out = masterNode.bundleOut
|
2016-10-27 04:02:04 +02:00
|
|
|
val success = Bool(OUTPUT)
|
|
|
|
}
|
2015-10-27 05:37:35 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
val test = p(BuildGroundTest)(p)
|
2016-08-16 07:03:03 +02:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
val ptwPorts = ListBuffer.empty ++= test.io.ptw
|
2016-11-11 00:56:42 +01:00
|
|
|
val uncachedArbPorts = ListBuffer.empty ++= test.io.mem
|
2015-11-19 05:53:36 +01:00
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
dcacheOpt foreach { dcache =>
|
|
|
|
val dcacheArb = Module(new HellaCacheArbiter(nCached))
|
2016-06-14 01:17:11 +02:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
dcacheArb.io.requestor.zip(test.io.cache).foreach {
|
|
|
|
case (requestor, cache) =>
|
2017-02-09 22:59:09 +01:00
|
|
|
val dcacheIF = Module(new SimpleHellaCacheIF())
|
2016-10-27 04:02:04 +02:00
|
|
|
dcacheIF.io.requestor <> cache
|
|
|
|
requestor <> dcacheIF.io.cache
|
|
|
|
}
|
2016-11-11 00:56:42 +01:00
|
|
|
dcache.module.io.cpu <> dcacheArb.io.mem
|
2016-06-14 01:17:11 +02:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
// SimpleHellaCacheIF leaves invalidate_lr dangling, so we wire it to false
|
2016-11-11 00:56:42 +01:00
|
|
|
dcache.module.io.cpu.invalidate_lr := Bool(false)
|
2015-10-27 05:37:35 +01:00
|
|
|
|
2016-11-11 00:56:42 +01:00
|
|
|
ptwPorts += dcache.module.io.ptw
|
2016-10-27 04:02:04 +02:00
|
|
|
}
|
2016-05-25 14:27:12 +02:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
if (ptwPorts.size > 0) {
|
2017-02-09 22:59:09 +01:00
|
|
|
val ptw = Module(new DummyPTW(ptwPorts.size))
|
2016-10-27 04:02:04 +02:00
|
|
|
ptw.io.requestors <> ptwPorts
|
|
|
|
}
|
2016-05-03 03:25:02 +02:00
|
|
|
|
2016-11-19 02:26:28 +01:00
|
|
|
if (uncachedArbPorts.isEmpty) {
|
|
|
|
ucLegacy.module.io.legacy.acquire.valid := Bool(false)
|
|
|
|
ucLegacy.module.io.legacy.grant.ready := Bool(true)
|
|
|
|
} else {
|
|
|
|
val uncachedArb = Module(new ClientUncachedTileLinkIOArbiter(uncachedArbPorts.size))
|
|
|
|
uncachedArb.io.in <> uncachedArbPorts
|
|
|
|
ucLegacy.module.io.legacy <> uncachedArb.io.out
|
|
|
|
}
|
2016-06-14 01:17:11 +02:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
io.success := test.io.status.finished
|
2016-06-14 01:17:11 +02:00
|
|
|
}
|
2015-10-27 05:37:35 +01:00
|
|
|
}
|