2016-08-02 01:05:24 +02:00
|
|
|
package groundtest
|
2015-10-27 05:37:35 +01:00
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import rocket._
|
2016-06-28 22:15:56 +02:00
|
|
|
import uncore.tilelink._
|
2016-11-22 20:50:41 +01:00
|
|
|
import uncore.util.CacheName
|
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._
|
2015-10-27 05:37:35 +01:00
|
|
|
import scala.util.Random
|
2016-06-14 01:17:11 +02:00
|
|
|
import scala.collection.mutable.ListBuffer
|
2016-09-14 05:22:20 +02:00
|
|
|
import util.ParameterizedBundle
|
2016-11-18 23:05:14 +01:00
|
|
|
import config._
|
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
|
|
|
|
2016-07-08 20:40:01 +02:00
|
|
|
case class GroundTestTileSettings(
|
2016-08-16 08:08:55 +02:00
|
|
|
uncached: Int = 0, cached: Int = 0, ptw: Int = 0, maxXacts: Int = 1)
|
2016-07-08 20:40:01 +02:00
|
|
|
case object GroundTestKey extends Field[Seq[GroundTestTileSettings]]
|
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
|
2016-09-02 09:05:40 +02:00
|
|
|
val tileSettings = p(GroundTestKey)(p(TileId))
|
2016-07-08 20:40:01 +02:00
|
|
|
val nUncached = tileSettings.uncached
|
|
|
|
val nCached = tileSettings.cached
|
|
|
|
val nPTW = tileSettings.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)
|
|
|
|
}
|
|
|
|
|
2015-11-19 05:53:36 +01:00
|
|
|
class DummyPTW(n: Int)(implicit p: Parameters) extends CoreModule()(p) {
|
|
|
|
val io = new Bundle {
|
|
|
|
val requestors = Vec(n, new TLBPTWIO).flip
|
|
|
|
}
|
|
|
|
|
|
|
|
val req_arb = Module(new RRArbiter(new PTWReq, n))
|
|
|
|
req_arb.io.in <> io.requestors.map(_.req)
|
|
|
|
req_arb.io.out.ready := Bool(true)
|
|
|
|
|
|
|
|
def vpn_to_ppn(vpn: UInt): UInt = vpn(ppnBits - 1, 0)
|
|
|
|
|
|
|
|
class QueueChannel extends ParameterizedBundle()(p) {
|
|
|
|
val ppn = UInt(width = ppnBits)
|
|
|
|
val chosen = UInt(width = log2Up(n))
|
|
|
|
}
|
|
|
|
|
|
|
|
val s1_ppn = vpn_to_ppn(req_arb.io.out.bits.addr)
|
|
|
|
val s2_ppn = RegEnable(s1_ppn, req_arb.io.out.valid)
|
|
|
|
val s2_chosen = RegEnable(req_arb.io.chosen, req_arb.io.out.valid)
|
|
|
|
val s2_valid = Reg(next = req_arb.io.out.valid)
|
|
|
|
|
|
|
|
val s2_resp = Wire(new PTWResp)
|
|
|
|
s2_resp.pte.ppn := s2_ppn
|
|
|
|
s2_resp.pte.reserved_for_software := UInt(0)
|
2016-01-20 20:39:40 +01:00
|
|
|
s2_resp.pte.d := Bool(true)
|
2016-07-06 12:20:41 +02:00
|
|
|
s2_resp.pte.a := Bool(false)
|
|
|
|
s2_resp.pte.g := Bool(false)
|
|
|
|
s2_resp.pte.u := Bool(true)
|
|
|
|
s2_resp.pte.r := Bool(true)
|
|
|
|
s2_resp.pte.w := Bool(true)
|
|
|
|
s2_resp.pte.x := Bool(false)
|
2015-11-19 05:53:36 +01:00
|
|
|
s2_resp.pte.v := Bool(true)
|
|
|
|
|
|
|
|
io.requestors.zipWithIndex.foreach { case (requestor, i) =>
|
|
|
|
requestor.resp.valid := s2_valid && s2_chosen === UInt(i)
|
|
|
|
requestor.resp.bits := s2_resp
|
|
|
|
requestor.status.vm := UInt("b01000")
|
2016-03-15 01:55:19 +01:00
|
|
|
requestor.status.prv := UInt(PRV.S)
|
2016-08-30 23:43:00 +02:00
|
|
|
requestor.status.debug := Bool(false)
|
|
|
|
requestor.status.mprv := Bool(true)
|
|
|
|
requestor.status.mpp := UInt(0)
|
|
|
|
requestor.ptbr.asid := UInt(0)
|
|
|
|
requestor.ptbr.ppn := UInt(0)
|
2016-03-23 03:59:58 +01:00
|
|
|
requestor.invalidate := Bool(false)
|
2015-11-19 05:53:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-11-11 00:56:42 +01:00
|
|
|
class GroundTestTile(implicit val p: Parameters) extends LazyModule with HasGroundTestParameters {
|
2016-11-21 21:19:33 +01:00
|
|
|
val dcacheParams = p.alterPartial {
|
|
|
|
case CacheName => CacheName("L1D")
|
|
|
|
case rocket.TLCacheEdge => cachedOut.edgesOut(0)
|
|
|
|
}
|
2016-10-27 07:28:40 +02:00
|
|
|
val slave = None
|
2016-11-11 00:56:42 +01:00
|
|
|
val dcache = HellaCache(p(DCacheKey))(dcacheParams)
|
|
|
|
val ucLegacy = LazyModule(new TLLegacy()(p))
|
|
|
|
|
2016-11-15 03:09:17 +01:00
|
|
|
val cachedOut = TLOutputNode()
|
|
|
|
val uncachedOut = TLOutputNode()
|
|
|
|
cachedOut := dcache.node
|
2016-11-17 02:05:53 +01:00
|
|
|
uncachedOut := TLHintHandler()(ucLegacy.node)
|
2016-11-15 03:09:17 +01:00
|
|
|
val masterNodes = List(cachedOut, uncachedOut)
|
|
|
|
|
2016-11-11 00:56:42 +01:00
|
|
|
lazy val module = new LazyModuleImp(this) {
|
|
|
|
val io = new Bundle {
|
2016-11-15 03:09:17 +01:00
|
|
|
val cached = cachedOut.bundleOut
|
|
|
|
val uncached = uncachedOut.bundleOut
|
2016-10-27 04:02:04 +02:00
|
|
|
val success = Bool(OUTPUT)
|
|
|
|
}
|
2015-10-27 05:37:35 +01:00
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
val test = p(BuildGroundTest)(dcacheParams)
|
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
|
|
|
|
2016-10-27 04:02:04 +02:00
|
|
|
if (nCached > 0) {
|
|
|
|
val dcacheArb = Module(new HellaCacheArbiter(nCached)(dcacheParams))
|
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) =>
|
|
|
|
val dcacheIF = Module(new SimpleHellaCacheIF()(dcacheParams))
|
|
|
|
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) {
|
2016-11-21 21:19:33 +01:00
|
|
|
val ptw = Module(new DummyPTW(ptwPorts.size)(dcacheParams))
|
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
|
|
|
}
|