2016-09-22 01:54:35 +02:00
|
|
|
package coreplex
|
|
|
|
|
|
|
|
import Chisel._
|
2016-11-18 23:05:14 +01:00
|
|
|
import config._
|
2016-09-22 01:54:35 +02:00
|
|
|
import junctions._
|
2016-10-04 00:17:36 +02:00
|
|
|
import diplomacy._
|
2016-09-22 01:54:35 +02:00
|
|
|
import uncore.tilelink._
|
|
|
|
import uncore.tilelink2._
|
|
|
|
import uncore.coherence._
|
|
|
|
import uncore.agents._
|
|
|
|
import uncore.devices._
|
|
|
|
import uncore.util._
|
|
|
|
import uncore.converters._
|
|
|
|
import rocket._
|
2016-09-28 06:27:07 +02:00
|
|
|
import util._
|
2016-09-22 01:54:35 +02:00
|
|
|
|
2016-11-17 23:07:53 +01:00
|
|
|
/** Widths of various points in the SoC */
|
|
|
|
case class TLBusConfig(beatBytes: Int)
|
|
|
|
case object CBusConfig extends Field[TLBusConfig]
|
|
|
|
case object L1toL2Config extends Field[TLBusConfig]
|
|
|
|
|
2016-11-18 02:26:49 +01:00
|
|
|
/** L2 Broadcast Hub configuration */
|
|
|
|
case class BroadcastConfig(
|
|
|
|
nTrackers: Int = 4,
|
|
|
|
bufferless: Boolean = false)
|
|
|
|
case object BroadcastConfig extends Field[BroadcastConfig]
|
|
|
|
|
|
|
|
/** L2 memory subsystem configuration */
|
|
|
|
case class BankedL2Config(
|
|
|
|
nMemoryChannels: Int = 1,
|
|
|
|
nBanksPerChannel: Int = 1,
|
2016-11-23 00:12:45 +01:00
|
|
|
coherenceManager: Parameters => (TLInwardNode, TLOutwardNode) = { case p =>
|
2016-11-18 02:26:49 +01:00
|
|
|
val BroadcastConfig(nTrackers, bufferless) = p(BroadcastConfig)
|
2016-11-23 00:12:45 +01:00
|
|
|
val bh = LazyModule(new TLBroadcast(p(CacheBlockBytes), nTrackers, bufferless))
|
|
|
|
(bh.node, TLWidthWidget(p(L1toL2Config).beatBytes)(bh.node))
|
2016-11-18 02:26:49 +01:00
|
|
|
}) {
|
|
|
|
val nBanks = nMemoryChannels*nBanksPerChannel
|
|
|
|
}
|
|
|
|
case object BankedL2Config extends Field[BankedL2Config]
|
|
|
|
|
2016-09-22 01:54:35 +02:00
|
|
|
/** The file to read the BootROM contents from */
|
|
|
|
case object BootROMFile extends Field[String]
|
|
|
|
|
|
|
|
trait HasCoreplexParameters {
|
|
|
|
implicit val p: Parameters
|
2016-11-17 23:07:53 +01:00
|
|
|
lazy val cbusConfig = p(CBusConfig)
|
|
|
|
lazy val l1tol2Config = p(L1toL2Config)
|
2016-10-27 07:28:40 +02:00
|
|
|
lazy val nTiles = p(uncore.devices.NTiles)
|
|
|
|
lazy val hasSupervisor = p(rocket.UseVM)
|
2016-11-18 02:26:49 +01:00
|
|
|
lazy val l2Config = p(BankedL2Config)
|
2016-09-22 01:54:35 +02:00
|
|
|
}
|
|
|
|
|
2016-10-27 07:28:40 +02:00
|
|
|
case class CoreplexParameters(implicit val p: Parameters) extends HasCoreplexParameters
|
2016-09-22 01:54:35 +02:00
|
|
|
|
2016-10-29 03:37:24 +02:00
|
|
|
abstract class BareCoreplex(implicit val p: Parameters) extends LazyModule
|
2016-10-29 12:30:49 +02:00
|
|
|
abstract class BareCoreplexBundle[+L <: BareCoreplex](_outer: L) extends Bundle {
|
|
|
|
val outer = _outer
|
|
|
|
}
|
|
|
|
abstract class BareCoreplexModule[+L <: BareCoreplex, +B <: BareCoreplexBundle[L]](_outer: L, _io: () => B) extends LazyModuleImp(_outer) {
|
|
|
|
val outer = _outer
|
|
|
|
val io = _io ()
|
2016-10-29 03:37:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trait CoreplexNetwork extends HasCoreplexParameters {
|
2016-11-16 03:27:52 +01:00
|
|
|
val module: CoreplexNetworkModule
|
2016-10-29 03:37:24 +02:00
|
|
|
|
2016-10-27 07:28:40 +02:00
|
|
|
val l1tol2 = LazyModule(new TLXbar)
|
2016-11-17 23:07:53 +01:00
|
|
|
val l1tol2_beatBytes = l1tol2Config.beatBytes
|
2016-10-29 03:37:24 +02:00
|
|
|
val l1tol2_lineBytes = p(CacheBlockBytes)
|
|
|
|
|
|
|
|
val cbus = LazyModule(new TLXbar)
|
2016-11-17 23:07:53 +01:00
|
|
|
val cbus_beatBytes = cbusConfig.beatBytes
|
2016-10-29 03:37:24 +02:00
|
|
|
val cbus_lineBytes = l1tol2_lineBytes
|
|
|
|
|
2016-11-17 01:49:10 +01:00
|
|
|
val intBar = LazyModule(new IntXbar)
|
|
|
|
|
2016-10-29 06:20:49 +02:00
|
|
|
val mmio = TLOutputNode()
|
|
|
|
val mmioInt = IntInputNode()
|
|
|
|
|
2016-11-17 01:49:10 +01:00
|
|
|
intBar.intnode := mmioInt
|
|
|
|
|
2016-10-29 03:37:24 +02:00
|
|
|
cbus.node :=
|
|
|
|
TLAtomicAutomata(arithmetic = true)( // disable once TLB uses TL2 metadata
|
|
|
|
TLWidthWidget(l1tol2_beatBytes)(
|
|
|
|
TLBuffer()(
|
|
|
|
l1tol2.node)))
|
2016-10-29 06:20:49 +02:00
|
|
|
|
|
|
|
mmio :=
|
|
|
|
TLBuffer()(
|
|
|
|
TLWidthWidget(l1tol2_beatBytes)(
|
|
|
|
l1tol2.node))
|
2016-10-29 03:37:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trait CoreplexNetworkBundle extends HasCoreplexParameters {
|
2016-11-16 03:27:52 +01:00
|
|
|
val outer: CoreplexNetwork
|
2016-10-29 06:20:49 +02:00
|
|
|
|
2016-10-29 03:37:24 +02:00
|
|
|
implicit val p = outer.p
|
2016-10-29 06:20:49 +02:00
|
|
|
val mmio = outer.mmio.bundleOut
|
|
|
|
val interrupts = outer.mmioInt.bundleIn
|
2016-10-29 03:37:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trait CoreplexNetworkModule extends HasCoreplexParameters {
|
2016-11-16 03:27:52 +01:00
|
|
|
val outer: CoreplexNetwork
|
|
|
|
val io: CoreplexNetworkBundle
|
|
|
|
|
2016-10-29 03:37:24 +02:00
|
|
|
implicit val p = outer.p
|
2016-11-21 21:45:00 +01:00
|
|
|
|
2016-11-22 01:11:16 +01:00
|
|
|
println("\nGenerated Address Map")
|
|
|
|
for (manager <- outer.l1tol2.node.edgesIn(0).manager.managers) {
|
|
|
|
val prot = (if (manager.supportsGet) "R" else "") +
|
|
|
|
(if (manager.supportsPutFull) "W" else "") +
|
|
|
|
(if (manager.executable) "X" else "") +
|
|
|
|
(if (manager.supportsAcquire) " [C]" else "")
|
|
|
|
manager.address.foreach { a =>
|
|
|
|
println(f"\t${manager.name}%s ${a.base}%x - ${a.base+a.mask+1}%x, $prot")
|
2016-11-21 21:45:00 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-29 03:37:24 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 03:27:52 +01:00
|
|
|
trait BankedL2CoherenceManagers extends CoreplexNetwork {
|
|
|
|
val module: BankedL2CoherenceManagersModule
|
|
|
|
|
2016-11-18 02:26:49 +01:00
|
|
|
require (isPow2(l2Config.nBanksPerChannel))
|
2016-11-04 19:18:31 +01:00
|
|
|
require (isPow2(l1tol2_lineBytes))
|
2016-11-04 03:48:05 +01:00
|
|
|
|
2016-11-18 02:26:49 +01:00
|
|
|
val mem = Seq.fill(l2Config.nMemoryChannels) {
|
2016-11-04 03:48:05 +01:00
|
|
|
val bankBar = LazyModule(new TLXbar)
|
|
|
|
val output = TLOutputNode()
|
|
|
|
|
|
|
|
output := bankBar.node
|
2016-11-18 02:26:49 +01:00
|
|
|
val mask = ~BigInt((l2Config.nBanksPerChannel-1) * l1tol2_lineBytes)
|
|
|
|
for (i <- 0 until l2Config.nBanksPerChannel) {
|
2016-11-23 00:12:45 +01:00
|
|
|
val (in, out) = l2Config.coherenceManager(p)
|
2016-11-04 03:48:05 +01:00
|
|
|
in := TLFilter(AddressSet(i * l1tol2_lineBytes, mask))(l1tol2.node)
|
|
|
|
bankBar.node := out
|
|
|
|
}
|
|
|
|
|
|
|
|
output
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 03:27:52 +01:00
|
|
|
trait BankedL2CoherenceManagersBundle extends CoreplexNetworkBundle {
|
|
|
|
val outer: BankedL2CoherenceManagers
|
2016-11-04 03:48:05 +01:00
|
|
|
|
2016-11-18 02:26:49 +01:00
|
|
|
require (l2Config.nMemoryChannels <= 1, "Seq in Chisel Bundle needed to support > 1") // !!!
|
2016-11-04 20:14:28 +01:00
|
|
|
val mem = outer.mem.map(_.bundleOut).toList.headOption // .headOption should be removed !!!
|
2016-11-04 03:48:05 +01:00
|
|
|
}
|
|
|
|
|
2016-11-16 03:27:52 +01:00
|
|
|
trait BankedL2CoherenceManagersModule extends CoreplexNetworkModule {
|
|
|
|
val outer: BankedL2CoherenceManagers
|
|
|
|
val io: BankedL2CoherenceManagersBundle
|
2016-10-27 07:28:40 +02:00
|
|
|
}
|
|
|
|
|
2016-11-04 05:31:26 +01:00
|
|
|
abstract class BaseCoreplex(implicit p: Parameters) extends BareCoreplex
|
2016-10-29 03:37:24 +02:00
|
|
|
with CoreplexNetwork
|
2016-11-16 03:27:52 +01:00
|
|
|
with BankedL2CoherenceManagers {
|
2016-10-29 12:30:49 +02:00
|
|
|
override lazy val module = new BaseCoreplexModule(this, () => new BaseCoreplexBundle(this))
|
2016-10-27 07:28:40 +02:00
|
|
|
}
|
|
|
|
|
2016-10-29 12:30:49 +02:00
|
|
|
class BaseCoreplexBundle[+L <: BaseCoreplex](_outer: L) extends BareCoreplexBundle(_outer)
|
2016-10-29 03:37:24 +02:00
|
|
|
with CoreplexNetworkBundle
|
2016-11-04 05:31:26 +01:00
|
|
|
with BankedL2CoherenceManagersBundle
|
2016-10-27 07:28:40 +02:00
|
|
|
|
2016-10-29 12:30:49 +02:00
|
|
|
class BaseCoreplexModule[+L <: BaseCoreplex, +B <: BaseCoreplexBundle[L]](_outer: L, _io: () => B) extends BareCoreplexModule(_outer, _io)
|
2016-10-29 03:37:24 +02:00
|
|
|
with CoreplexNetworkModule
|
2016-11-04 05:31:26 +01:00
|
|
|
with BankedL2CoherenceManagersModule
|