Skip to content

Commit

Permalink
Rename staticHartId to tileId
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryz123 committed Sep 26, 2023
1 parent c8d29f6 commit 91a14ee
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 80 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/groundtest/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,18 @@ class GroundTestBaseConfig extends Config(

class WithTraceGen(
n: Int = 2,
overrideIdOffset: Option[Int] = None,
overrideMemOffset: Option[BigInt] = None)(
params: Seq[DCacheParams] = List.fill(n){ DCacheParams(nSets = 16, nWays = 1) },
nReqs: Int = 8192
) extends Config((site, here, up) => {
case TilesLocated(InSubsystem) => {
val prev = up(TilesLocated(InSubsystem), site)
val idOffset = overrideIdOffset.getOrElse(prev.size)
val idOffset = up(NumTiles)
val memOffset: BigInt = overrideMemOffset.orElse(site(ExtMem).map(_.master.base)).getOrElse(0x0L)
params.zipWithIndex.map { case (dcp, i) =>
TraceGenTileAttachParams(
tileParams = TraceGenParams(
hartId = i + idOffset,
tileId = i + idOffset,
dcache = Some(dcp),
wordBits = site(XLen),
addrBits = 32,
Expand All @@ -68,4 +67,5 @@ class WithTraceGen(
)
} ++ prev
}
case NumTiles => up(NumTiles) + n
})
6 changes: 3 additions & 3 deletions src/main/scala/groundtest/TraceGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ case class TraceGenParams(
memStart: BigInt, //p(ExtMem).base
numGens: Int,
dcache: Option[DCacheParams] = Some(DCacheParams()),
hartId: Int = 0
tileId: Int = 0
) extends InstantiableTileParams[TraceGenTile] with GroundTestTileParams
{
def instantiate(crossing: ElementCrossingParamsLike, lookup: LookupByHartIdImpl)(implicit p: Parameters): TraceGenTile = {
new TraceGenTile(this, crossing, lookup)
}
val blockerCtrlAddr = None
val name = s"tracegen_$hartId"
val name = s"tracegen_$tileId"
val clockSinkParams = ClockSinkParameters()
}

Expand Down Expand Up @@ -643,5 +643,5 @@ class TraceGenTileModuleImp(outer: TraceGenTile) extends GroundTestTileModuleImp
status.timeout.bits := 0.U
status.error.valid := false.B

assert(!tracegen.io.timeout, s"TraceGen tile ${outer.tileParams.hartId}: request timed out")
assert(!tracegen.io.timeout, s"TraceGen tile ${outer.tileParams.tileId}: request timed out")
}
6 changes: 3 additions & 3 deletions src/main/scala/rocket/Frontend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class FrontendIO(implicit p: Parameters) extends CoreBundle()(p) {
val progress = Output(Bool())
}

class Frontend(val icacheParams: ICacheParams, staticIdForMetadataUseOnly: Int)(implicit p: Parameters) extends LazyModule {
class Frontend(val icacheParams: ICacheParams, tileId: Int)(implicit p: Parameters) extends LazyModule {
lazy val module = new FrontendModule(this)
val icache = LazyModule(new ICache(icacheParams, staticIdForMetadataUseOnly))
val icache = LazyModule(new ICache(icacheParams, tileId))
val masterNode = icache.masterNode
val slaveNode = icache.slaveNode
val resetVectorSinkNode = BundleBridgeSink[UInt](Some(() => UInt(masterNode.edges.out.head.bundle.addressBits.W)))
Expand Down Expand Up @@ -383,7 +383,7 @@ class FrontendModule(outer: Frontend) extends LazyModuleImp(outer)
/** Mix-ins for constructing tiles that have an ICache-based pipeline frontend */
trait HasICacheFrontend extends CanHavePTW { this: BaseTile =>
val module: HasICacheFrontendModule
val frontend = LazyModule(new Frontend(tileParams.icache.get, staticIdForMetadataUseOnly))
val frontend = LazyModule(new Frontend(tileParams.icache.get, tileId))
tlMasterXbar.node := TLWidthWidget(tileParams.icache.get.rowBits/8) := frontend.masterNode
connectTLSlave(frontend.slaveNode, tileParams.core.fetchBytes)
frontend.icache.hartIdSinkNodeOpt.foreach { _ := hartIdNexusNode }
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/rocket/HellaCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,17 @@ class HellaCacheIO(implicit p: Parameters) extends CoreBundle()(p) {

/** Base classes for Diplomatic TL2 HellaCaches */

abstract class HellaCache(staticIdForMetadataUseOnly: Int)(implicit p: Parameters) extends LazyModule
abstract class HellaCache(tileId: Int)(implicit p: Parameters) extends LazyModule
with HasNonDiplomaticTileParameters {
protected val cfg = tileParams.dcache.get

protected def cacheClientParameters = cfg.scratch.map(x => Seq()).getOrElse(Seq(TLMasterParameters.v1(
name = s"Core ${staticIdForMetadataUseOnly} DCache",
name = s"Core ${tileId} DCache",
sourceId = IdRange(0, 1 max cfg.nMSHRs),
supportsProbe = TransferSizes(cfg.blockBytes, cfg.blockBytes))))

protected def mmioClientParameters = Seq(TLMasterParameters.v1(
name = s"Core ${staticIdForMetadataUseOnly} DCache MMIO",
name = s"Core ${tileId} DCache MMIO",
sourceId = IdRange(firstMMIO, firstMMIO + cfg.nMMIOs),
requestFifo = true))

Expand Down Expand Up @@ -254,9 +254,9 @@ case object BuildHellaCache extends Field[BaseTile => Parameters => HellaCache](
object HellaCacheFactory {
def apply(tile: BaseTile)(p: Parameters): HellaCache = {
if (tile.tileParams.dcache.get.nMSHRs == 0)
new DCache(tile.staticIdForMetadataUseOnly, tile.crossing)(p)
new DCache(tile.tileId, tile.crossing)(p)
else
new NonBlockingDCache(tile.staticIdForMetadataUseOnly)(p)
new NonBlockingDCache(tile.tileId)(p)
}
}

Expand Down
26 changes: 10 additions & 16 deletions src/main/scala/subsystem/Cluster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ class Cluster(
lazy val location = InCluster(clusterId)

val clockGroupNode = ClockGroupAggregator()
println(p(TLNetworkTopologyLocated(InCluster(0))))
println(p(TLNetworkTopologyLocated(InCluster(1))))
println(thisClusterParams)
println(clusterId)
println(location)
println(tlBusWrapperLocationMap)
val csbus = tlBusWrapperLocationMap(CSBUS(clusterId)) // like the sbus in the base subsystem
val ccbus = tlBusWrapperLocationMap(CCBUS(clusterId)) // like the cbus in the base subsystem

Expand All @@ -60,16 +54,16 @@ class Cluster(
ibus.clockNode := csbus.fixedClockNode
implicit val asyncClockGroupsNode = p(AsyncClockGroupsKey)()

lazy val msipNodes = totalHartIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val meipNodes = totalHartIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val seipNodes = totalHartIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val tileToPlicNodes = totalHartIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val debugNodes = totalHartIdList.map { i => (i, IntSyncIdentityNode()) }.toMap
lazy val nmiNodes = totalTiles.filter(_.tileParams.core.useNMI).map { t => (t.hartId, BundleBridgeIdentityNode[NMI]()) }.toMap
lazy val tileHartIdNodes = totalHartIdList.map { i => (i, BundleBridgeIdentityNode[UInt]()) }.toMap
lazy val tileResetVectorNodes = totalHartIdList.map { i => (i, BundleBridgeIdentityNode[UInt]()) }.toMap
lazy val traceCoreNodes = totalHartIdList.map { i => (i, BundleBridgeIdentityNode[TraceCoreInterface]()) }.toMap
lazy val traceNodes = totalHartIdList.map { i => (i, BundleBridgeIdentityNode[TraceBundle]()) }.toMap
lazy val msipNodes = totalTileIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val meipNodes = totalTileIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val seipNodes = totalTileIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val tileToPlicNodes = totalTileIdList.map { i => (i, IntIdentityNode()) }.toMap
lazy val debugNodes = totalTileIdList.map { i => (i, IntSyncIdentityNode()) }.toMap
lazy val nmiNodes = totalTiles.filter(_.tileParams.core.useNMI).map { t => (t.tileId, BundleBridgeIdentityNode[NMI]()) }.toMap
lazy val tileHartIdNodes = totalTileIdList.map { i => (i, BundleBridgeIdentityNode[UInt]()) }.toMap
lazy val tileResetVectorNodes = totalTileIdList.map { i => (i, BundleBridgeIdentityNode[UInt]()) }.toMap
lazy val traceCoreNodes = totalTileIdList.map { i => (i, BundleBridgeIdentityNode[TraceCoreInterface]()) }.toMap
lazy val traceNodes = totalTileIdList.map { i => (i, BundleBridgeIdentityNode[TraceBundle]()) }.toMap

// TODO fix: shouldn't need to connect dummy notifications
tileHaltXbarNode := NullIntSource()
Expand Down
34 changes: 19 additions & 15 deletions src/main/scala/subsystem/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class BaseSubsystemConfig extends Config ((site, here, up) => {
case PgLevels => if (site(XLen) == 64) 3 /* Sv39 */ else 2 /* Sv32 */
case XLen => 64 // Applies to all cores
case MaxHartIdBits => log2Up((site(PossibleTileLocations).flatMap(loc => site(TilesLocated(loc)))
.map(_.tileParams.hartId) :+ 0).max+1)
.map(_.tileParams.tileId) :+ 0).max+1)
// Interconnect parameters
case SystemBusKey => SystemBusParams(
beatBytes = site(XLen)/8,
Expand Down Expand Up @@ -91,13 +91,12 @@ class WithCoherentBusTopology extends Config((site, here, up) => {

class WithNBigCores(
n: Int,
overrideIdOffset: Option[Int] = None,
crossing: RocketCrossingParams = RocketCrossingParams(),
location: HierarchicalLocation = InSubsystem
) extends Config((site, here, up) => {
case TilesLocated(`location`) => {
val prev = up(TilesLocated(location), site)
val idOffset = overrideIdOffset.getOrElse(prev.size)
val idOffset = up(NumTiles)
val big = RocketTileParams(
core = RocketCoreParams(mulDiv = Some(MulDivParams(
mulUnroll = 8,
Expand All @@ -111,20 +110,21 @@ class WithNBigCores(
rowBits = site(SystemBusKey).beatBits,
blockBytes = site(CacheBlockBytes))))
List.tabulate(n)(i => RocketTileAttachParams(
big.copy(hartId = i + idOffset),
big.copy(tileId = i + idOffset),
crossing
)) ++ prev
}
case NumTiles => up(NumTiles) + n
})

class WithNMedCores(
n: Int,
overrideIdOffset: Option[Int] = None,
crossing: RocketCrossingParams = RocketCrossingParams()
crossing: RocketCrossingParams = RocketCrossingParams(),
location: HierarchicalLocation = InSubsystem
) extends Config((site, here, up) => {
case TilesLocated(InSubsystem) => {
val prev = up(TilesLocated(InSubsystem), site)
val idOffset = overrideIdOffset.getOrElse(prev.size)
case TilesLocated(`location`) => {
val prev = up(TilesLocated(location), site)
val idOffset = up(NumTiles)
val med = RocketTileParams(
core = RocketCoreParams(fpu = None),
btb = None,
Expand All @@ -144,20 +144,21 @@ class WithNMedCores(
nTLBWays = 4,
blockBytes = site(CacheBlockBytes))))
List.tabulate(n)(i => RocketTileAttachParams(
med.copy(hartId = i + idOffset),
med.copy(tileId = i + idOffset),
crossing
)) ++ prev
}
case NumTiles => up(NumTiles) + n
})

class WithNSmallCores(
n: Int,
overrideIdOffset: Option[Int] = None,
crossing: RocketCrossingParams = RocketCrossingParams()
crossing: RocketCrossingParams = RocketCrossingParams(),
location: HierarchicalLocation = InSubsystem
) extends Config((site, here, up) => {
case TilesLocated(InSubsystem) => {
val prev = up(TilesLocated(InSubsystem), site)
val idOffset = overrideIdOffset.getOrElse(prev.size)
val idOffset = up(NumTiles)
val small = RocketTileParams(
core = RocketCoreParams(useVM = false, fpu = None),
btb = None,
Expand All @@ -177,10 +178,11 @@ class WithNSmallCores(
nTLBWays = 4,
blockBytes = site(CacheBlockBytes))))
List.tabulate(n)(i => RocketTileAttachParams(
small.copy(hartId = i + idOffset),
small.copy(tileId = i + idOffset),
crossing
)) ++ prev
}
case NumTiles => up(NumTiles) + n
})

class With1TinyCore extends Config((site, here, up) => {
Expand Down Expand Up @@ -216,6 +218,8 @@ class With1TinyCore extends Config((site, here, up) => {
master = ElementMasterPortParams())
))
}
case NumTiles => 1
case ClustersLocated(_) => Nil
})

class WithCluster(
Expand Down Expand Up @@ -679,7 +683,7 @@ class WithCloneRocketTiles(n: Int = 1, cloneHart: Int = 0, overrideIdOffset: Opt
val tileAttachParams = prev(cloneHart).asInstanceOf[RocketTileAttachParams]
(0 until n).map { i =>
CloneTileAttachParams(cloneHart, tileAttachParams.copy(
tileParams = tileAttachParams.tileParams.copy(hartId = i + idOffset)
tileParams = tileAttachParams.tileParams.copy(tileId = i + idOffset)
))
} ++ prev
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/scala/subsystem/HasElements.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ trait InstantiatesElements { this: LazyModule with Attachable =>
* Note that these ids, which are often used as the tiles' default hartid input,
* may or may not be those actually reflected at runtime in e.g. the $mhartid CSR
*/
val tileAttachParams: Seq[CanAttachTile] = p(TilesLocated(location)).sortBy(_.tileParams.hartId)
val tileAttachParams: Seq[CanAttachTile] = p(TilesLocated(location)).sortBy(_.tileParams.tileId)
val tileParams: Seq[TileParams] = tileAttachParams.map(_.tileParams)
val tileCrossingTypes: Seq[ClockCrossingType] = tileAttachParams.map(_.crossingParams.crossingType)

Expand All @@ -79,17 +79,17 @@ trait InstantiatesElements { this: LazyModule with Attachable =>

val element_prci_domains: Seq[ElementPRCIDomain[_]] = tile_prci_domains ++ cluster_prci_domains

val leafTiles: Seq[BaseTile] = tile_prci_domains.map(_.element.asInstanceOf[BaseTile]).sortBy(_.hartId)
val totalTiles: Seq[BaseTile] = (leafTiles ++ cluster_prci_domains.map(_.element.asInstanceOf[Cluster].totalTiles).flatten).sortBy(_.hartId)
val leafTiles: Seq[BaseTile] = tile_prci_domains.map(_.element.asInstanceOf[BaseTile]).sortBy(_.tileId)
val totalTiles: Seq[BaseTile] = (leafTiles ++ cluster_prci_domains.map(_.element.asInstanceOf[Cluster].totalTiles).flatten).sortBy(_.tileId)

// Helper functions for accessing certain parameters that are popular to refer to in subsystem code
def nLeafTiles: Int = leafTiles.size
def nTotalTiles: Int = totalTiles.size
def leafHartIdList: Seq[Int] = leafTiles.map(_.hartId)
def totalHartIdList: Seq[Int] = totalTiles.map(_.hartId)
def leafTileIdList: Seq[Int] = leafTiles.map(_.tileId)
def totalTileIdList: Seq[Int] = totalTiles.map(_.tileId)
def localIntCounts: Seq[Int] = totalTiles.map(_.tileParams.core.nLocalInterrupts)

require(totalHartIdList.distinct.size == totalTiles.size, s"Every tile must be statically assigned a unique id, but got:\n${totalHartIdList}")
require(totalTileIdList.distinct.size == totalTiles.size, s"Every tile must be statically assigned a unique id, but got:\n${totalTileIdList}")
}

/** HasTiles instantiates and also connects a Config-urable sequence of tiles of any type to subsystem interconnect resources. */
Expand Down Expand Up @@ -201,7 +201,7 @@ trait HasElementsRootContext
node := debugOpt.map(_.intnode).getOrElse(IntSyncCrossingSource() := NullIntSource())
}

val nmiHarts = totalTiles.filter(_.tileParams.core.useNMI).map(_.hartId)
val nmiHarts = totalTiles.filter(_.tileParams.core.useNMI).map(_.tileId)
val nmiIONodes = nmiHarts.map { i => (i, BundleBridgeSource[NMI]()) }.toMap
val nmiNodes: Map[Int, BundleBridgeNode[NMI]] = nmiIONodes.map { case (i, n) =>
(i, BundleBridgeEphemeralNode[NMI]() := n)
Expand Down
25 changes: 14 additions & 11 deletions src/main/scala/subsystem/HasTiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ case class TilesLocated(loc: HierarchicalLocation) extends Field[Seq[CanAttachTi
/** List of HierarchicalLocations which might contain a Tile */
case object PossibleTileLocations extends Field[Seq[HierarchicalLocation]](Nil)

/** For determining static tile id */
case object NumTiles extends Field[Int](0)

/** Whether to add timing-closure registers along the path of the hart id
* as it propagates through the subsystem and into the tile.
*
Expand Down Expand Up @@ -68,7 +71,7 @@ trait HasTileInputConstants { this: LazyModule with Attachable with Instantiates
val tileHartIdNexusNode = LazyModule(new BundleBridgeNexus[UInt](
inputFn = BundleBridgeNexus.orReduction[UInt](registered = p(InsertTimingClosureRegistersOnHartIds)) _,
outputFn = (prefix: UInt, n: Int) => Seq.tabulate(n) { i =>
val y = dontTouch(prefix | totalHartIdList(i).U(p(MaxHartIdBits).W)) // dontTouch to keep constant prop from breaking tile dedup
val y = dontTouch(prefix | totalTileIdList(i).U(p(MaxHartIdBits).W)) // dontTouch to keep constant prop from breaking tile dedup
if (p(InsertTimingClosureRegistersOnHartIds)) BundleBridgeNexus.safeRegNext(y) else y
},
default = Some(() => 0.U(p(MaxHartIdBits).W)),
Expand Down Expand Up @@ -199,38 +202,38 @@ trait CanAttachTile {

// 1. Debug interrupt is definitely asynchronous in all cases.
domain.element.intInwardNode := domain { IntSyncAsyncCrossingSink(3) } :=
context.debugNodes(domain.element.hartId)
context.debugNodes(domain.element.tileId)

// 2. The CLINT and PLIC output interrupts are synchronous to the TileLink bus clock,
// so might need to be synchronized depending on the Tile's crossing type.

// From CLINT: "msip" and "mtip"
domain.crossIntIn(crossingParams.crossingType, domain.element.intInwardNode) :=
context.msipNodes(domain.element.hartId)
context.msipNodes(domain.element.tileId)

// From PLIC: "meip"
domain.crossIntIn(crossingParams.crossingType, domain.element.intInwardNode) :=
context.meipNodes(domain.element.hartId)
context.meipNodes(domain.element.tileId)

// From PLIC: "seip" (only if supervisor mode is enabled)
if (domain.element.tileParams.core.hasSupervisorMode) {
domain.crossIntIn(crossingParams.crossingType, domain.element.intInwardNode) :=
context.seipNodes(domain.element.hartId)
context.seipNodes(domain.element.tileId)
}

// 3. Local Interrupts ("lip") are required to already be synchronous to the Tile's clock.
// (they are connected to domain.element.intInwardNode in a seperate trait)

// 4. Interrupts coming out of the tile are sent to the PLIC,
// so might need to be synchronized depending on the Tile's crossing type.
context.tileToPlicNodes.get(domain.element.hartId).foreach { node =>
context.tileToPlicNodes.get(domain.element.tileId).foreach { node =>
FlipRendering { implicit p => domain.element.intOutwardNode.foreach { out =>
node :*= domain.crossIntOut(crossingParams.crossingType, out)
}}
}

// 5. Connect NMI inputs to the tile. These inputs are synchronous to the respective core_clock.
domain.element.nmiNode.foreach(_ := context.nmiNodes(domain.element.hartId))
domain.element.nmiNode.foreach(_ := context.nmiNodes(domain.element.tileId))
}

/** Notifications of tile status are connected to be broadcast without needing to be clock-crossed. */
Expand All @@ -247,8 +250,8 @@ trait CanAttachTile {
def connectInputConstants(domain: TilePRCIDomain[TileType], context: TileContextType): Unit = {
implicit val p = context.p
val tlBusToGetPrefixFrom = context.locateTLBusWrapper(crossingParams.mmioBaseAddressPrefixWhere)
domain.element.hartIdNode := context.tileHartIdNodes(domain.element.hartId)
domain.element.resetVectorNode := context.tileResetVectorNodes(domain.element.hartId)
domain.element.hartIdNode := context.tileHartIdNodes(domain.element.tileId)
domain.element.resetVectorNode := context.tileResetVectorNodes(domain.element.tileId)
tlBusToGetPrefixFrom.prefixNode.foreach { domain.element.mmioAddressPrefixNode := _ }
}

Expand Down Expand Up @@ -281,10 +284,10 @@ trait CanAttachTile {
implicit val p = context.p
val traceNexusNode = BundleBridgeBlockDuringReset[TraceBundle](
resetCrossingType = crossingParams.resetCrossingType)
context.traceNodes(domain.element.hartId) := traceNexusNode := domain.element.traceNode
context.traceNodes(domain.element.tileId) := traceNexusNode := domain.element.traceNode
val traceCoreNexusNode = BundleBridgeBlockDuringReset[TraceCoreInterface](
resetCrossingType = crossingParams.resetCrossingType)
context.traceCoreNodes(domain.element.hartId) :*= traceCoreNexusNode := domain.element.traceCoreNode
context.traceCoreNodes(domain.element.tileId) :*= traceCoreNexusNode := domain.element.traceCoreNode
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/system/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DualChannelConfig extends Config(new WithNMemoryChannels(2) ++ new Default
class EightChannelConfig extends Config(new WithNMemoryChannels(8) ++ new DefaultConfig)

class ClusterConfig extends Config(
new WithNBigCores(2, location=InCluster(0), overrideIdOffset=Some(1), crossing=RocketCrossingParams(
new WithNBigCores(2, location=InCluster(0), crossing=RocketCrossingParams(
master=ElementMasterPortParams(where=CSBUS(0)),
slave=ElementSlavePortParams(blockerCtrlWhere=CCBUS(0), where=CCBUS(0)),
mmioBaseAddressPrefixWhere=CCBUS(0),
Expand Down
Loading

0 comments on commit 91a14ee

Please sign in to comment.