1
0
rocket-chip/src/main/scala/rocket/tile.scala

137 lines
4.7 KiB
Scala
Raw Normal View History

2014-09-13 03:06:41 +02:00
// See LICENSE for license details.
package rocket
import Chisel._
2016-10-27 04:02:04 +02:00
import diplomacy._
import uncore.tilelink._
2016-10-27 04:02:04 +02:00
import uncore.tilelink2._
import uncore.agents._
import uncore.converters._
import uncore.devices._
import util._
2015-10-22 03:18:32 +02:00
import cde.{Parameters, Field}
2016-11-11 00:56:42 +01:00
import scala.collection.mutable.ListBuffer
2015-12-02 02:54:56 +01:00
case object BuildRoCC extends Field[Seq[RoccParameters]]
case object TileId extends Field[Int]
2015-12-02 02:54:56 +01:00
case class RoccParameters(
opcodes: OpcodeSet,
generator: Parameters => RoCC,
nMemChannels: Int = 0,
2016-02-25 07:39:00 +01:00
nPTWPorts : Int = 0,
useFPU: Boolean = false)
2016-11-11 00:56:42 +01:00
class RocketTile(implicit p: Parameters) extends LazyModule {
val dcacheParams = p.alterPartial({ case CacheName => "L1D" })
2016-11-11 00:56:42 +01:00
val icacheParams = p.alterPartial({ case CacheName => "L1I" })
2016-11-11 00:56:42 +01:00
val slaveNode = if (p(DataScratchpadSize) == 0) None else Some(TLInputNode())
2016-10-27 04:54:47 +02:00
val scratch = if (p(DataScratchpadSize) == 0) None else Some(LazyModule(new ScratchpadSlavePort()(dcacheParams)))
2016-11-11 00:56:42 +01:00
val dcache = HellaCache(p(DCacheKey))(dcacheParams)
val ucLegacy = LazyModule(new TLLegacy()(p))
(slaveNode zip scratch) foreach { case (node, lm) => lm.node := TLFragmenter(p(XLen)/8, p(CacheBlockBytes))(node) }
lazy val module = new LazyModuleImp(this) {
val io = new Bundle {
val cached = dcache.node.bundleOut
val uncached = ucLegacy.node.bundleOut
val slave = slaveNode.map(_.bundleIn)
val hartid = UInt(INPUT, p(XLen))
val interrupts = new TileInterrupts().asInput
val resetVector = UInt(INPUT, p(XLen))
}
2016-10-27 04:54:47 +02:00
2016-10-27 04:02:04 +02:00
val buildRocc = p(BuildRoCC)
val usingRocc = !buildRocc.isEmpty
val nRocc = buildRocc.size
val nFPUPorts = buildRocc.filter(_.useFPU).size
val core = Module(new Rocket)
2016-11-11 00:56:42 +01:00
val icache = Module(new Frontend()(icacheParams))
val ptwPorts = ListBuffer(icache.io.ptw, dcache.module.io.ptw)
val dcPorts = ListBuffer(core.io.dmem)
val uncachedArbPorts = ListBuffer(icache.io.mem)
2016-10-27 04:02:04 +02:00
core.io.interrupts := io.interrupts
core.io.hartid := io.hartid
icache.io.cpu <> core.io.imem
icache.io.resetVector := io.resetVector
val fpuOpt = p(FPUKey).map(cfg => Module(new FPU(cfg)))
fpuOpt.foreach(fpu => core.io.fpu <> fpu.io)
if (usingRocc) {
val respArb = Module(new RRArbiter(new RoCCResponse, nRocc))
core.io.rocc.resp <> respArb.io.out
val roccOpcodes = buildRocc.map(_.opcodes)
val cmdRouter = Module(new RoccCommandRouter(roccOpcodes))
cmdRouter.io.in <> core.io.rocc.cmd
val roccs = buildRocc.zipWithIndex.map { case (accelParams, i) =>
val rocc = accelParams.generator(p.alterPartial({
case RoccNMemChannels => accelParams.nMemChannels
case RoccNPTWPorts => accelParams.nPTWPorts
}))
val dcIF = Module(new SimpleHellaCacheIF()(dcacheParams))
rocc.io.cmd <> cmdRouter.io.out(i)
rocc.io.exception := core.io.rocc.exception
dcIF.io.requestor <> rocc.io.mem
dcPorts += dcIF.io.cache
uncachedArbPorts += rocc.io.autl
rocc
}
if (nFPUPorts > 0) {
fpuOpt.foreach { fpu =>
val fpArb = Module(new InOrderArbiter(new FPInput, new FPResult, nFPUPorts))
val fp_roccs = roccs.zip(buildRocc)
.filter { case (_, params) => params.useFPU }
.map { case (rocc, _) => rocc.io }
fpArb.io.in_req <> fp_roccs.map(_.fpu_req)
fp_roccs.zip(fpArb.io.in_resp).foreach {
case (rocc, fpu_resp) => rocc.fpu_resp <> fpu_resp
}
fpu.io.cp_req <> fpArb.io.out_req
fpArb.io.out_resp <> fpu.io.cp_resp
}
2015-12-01 19:22:31 +01:00
}
2016-10-27 04:02:04 +02:00
core.io.rocc.busy := cmdRouter.io.busy || roccs.map(_.io.busy).reduce(_ || _)
core.io.rocc.interrupt := roccs.map(_.io.interrupt).reduce(_ || _)
respArb.io.in <> roccs.map(rocc => Queue(rocc.io.resp))
2016-10-27 04:02:04 +02:00
ptwPorts ++= roccs.flatMap(_.io.ptw)
2016-11-11 00:56:42 +01:00
uncachedArbPorts ++= roccs.flatMap(_.io.utl) // TODO no difference between io.autl and io.utl for now
2016-10-27 04:02:04 +02:00
}
2016-10-27 04:02:04 +02:00
val uncachedArb = Module(new ClientUncachedTileLinkIOArbiter(uncachedArbPorts.size))
uncachedArb.io.in <> uncachedArbPorts
2016-11-11 00:56:42 +01:00
ucLegacy.module.io.legacy <> uncachedArb.io.out
2016-10-27 04:02:04 +02:00
if (p(UseVM)) {
val ptw = Module(new PTW(ptwPorts.size)(dcacheParams))
ptw.io.requestor <> ptwPorts
ptw.io.mem +=: dcPorts
core.io.ptw <> ptw.io.dpath
}
2016-10-27 04:54:47 +02:00
scratch.foreach { lm => lm.module.io.dmem +=: dcPorts }
2016-10-27 04:02:04 +02:00
require(dcPorts.size == core.dcacheArbPorts)
val dcArb = Module(new HellaCacheArbiter(dcPorts.size)(dcacheParams))
dcArb.io.requestor <> dcPorts
2016-11-11 00:56:42 +01:00
dcache.module.io.cpu <> dcArb.io.mem
2016-10-27 04:02:04 +02:00
if (nFPUPorts == 0) {
fpuOpt.foreach { fpu =>
fpu.io.cp_req.valid := Bool(false)
fpu.io.cp_resp.ready := Bool(false)
}
}
}
}