-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2327 from chipsalliance/config-topology
Make TLBusWrappers' topology a configurable Field
- Loading branch information
Showing
17 changed files
with
548 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.subsystem | ||
|
||
import scala.language.dynamics | ||
import freechips.rocketchip.config.Parameters | ||
import freechips.rocketchip.diplomacy.{LazyModule, LazyScope} | ||
import freechips.rocketchip.diplomaticobjectmodel.HasLogicalTreeNode | ||
import freechips.rocketchip.prci.ClockGroupEphemeralNode | ||
import freechips.rocketchip.tilelink.TLBusWrapper | ||
import freechips.rocketchip.util.{Location, LocationMap} | ||
|
||
/** These traits are intended to make it possible to configure to which | ||
* buses optional devices are attached, even after a subsystem has been instantiated. | ||
* Consider them experimental for now. | ||
*/ | ||
|
||
/** More nodes can be added to subclasses of this after they have been instantiated, | ||
* and the implicit context-dependent Parameters object is available. | ||
* These qualities comprise the fundamental capabilities of dynamic configurability. | ||
*/ | ||
trait LazyScopeWithParameters extends LazyScope { this: LazyModule => | ||
implicit val p: Parameters | ||
} | ||
|
||
/** Layers of hierarchy with this trait will be represented as objects in the Object Model */ | ||
trait HasLogicalHierarchy extends LazyScopeWithParameters with HasLogicalTreeNode { this: LazyModule => } | ||
|
||
/** Layers of hierarchy with this trait contain attachment points for neworks of power, clock, reset, and interrupt resources */ | ||
trait HasPRCILocations extends HasLogicalHierarchy { this: LazyModule => | ||
implicit val asyncClockGroupsNode: ClockGroupEphemeralNode | ||
val ibus: InterruptBusWrapper | ||
val anyLocationMap = LocationMap.empty[Any] | ||
} | ||
|
||
/** Layers of hierarchy with this trait contain attachment points for TileLink interfaces */ | ||
trait HasTileLinkLocations extends HasPRCILocations { this: LazyModule => | ||
val tlBusWrapperLocationMap = LocationMap.empty[TLBusWrapper] | ||
def locateTLBusWrapper(location: Location[TLBusWrapper]): TLBusWrapper = locateTLBusWrapper(location.name) | ||
def locateTLBusWrapper(name: String): TLBusWrapper = tlBusWrapperLocationMap(Location[TLBusWrapper](name)) | ||
} | ||
|
||
/** Subclasses of this trait have the ability to instantiate things inside a context that has TL attachement locations */ | ||
trait CanInstantiateWithinContextThatHasTileLinkLocations { | ||
def instantiate(context: HasTileLinkLocations)(implicit p: Parameters): Unit | ||
} | ||
|
||
/** Subclasses of this trait have the ability to connect things inside a context that has TL attachement locations */ | ||
trait CanConnectWithinContextThatHasTileLinkLocations { | ||
def connect(context: HasTileLinkLocations)(implicit p: Parameters): Unit | ||
} | ||
|
||
/** Attachable things provide a standard interface by which other things may attach themselves to this target. | ||
* Right now the trait is mostly for backwards compatibility, and in case it eventually becomes valuable | ||
* to be able to define additional resources available to agents trying to attach themselves, other than | ||
* what is being made available via the LocationMaps in trait HasTileLinkLocations. | ||
*/ | ||
trait Attachable extends HasTileLinkLocations { this: LazyModule => | ||
def locateTLBusWrapper(location: TLBusWrapperLocation): TLBusWrapper = locateTLBusWrapper(location.name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// See LICENSE.SiFive for license details. | ||
|
||
package freechips.rocketchip.subsystem | ||
|
||
import chisel3.util.isPow2 | ||
import freechips.rocketchip.config._ | ||
import freechips.rocketchip.devices.tilelink.BuiltInDevices | ||
import freechips.rocketchip.diplomacy._ | ||
import freechips.rocketchip.interrupts._ | ||
import freechips.rocketchip.tilelink._ | ||
import freechips.rocketchip.util._ | ||
import CoherenceManagerWrapper._ | ||
|
||
/** Global cache coherence granularity, which applies to all caches, for now. */ | ||
case object CacheBlockBytes extends Field[Int](64) | ||
|
||
/** L2 Broadcast Hub configuration */ | ||
case object BroadcastKey extends Field(BroadcastParams()) | ||
|
||
case class BroadcastParams( | ||
nTrackers: Int = 4, | ||
bufferless: Boolean = false) | ||
|
||
/** L2 memory subsystem configuration */ | ||
case object BankedL2Key extends Field(BankedL2Params()) | ||
|
||
case class BankedL2Params( | ||
nBanks: Int = 1, | ||
coherenceManager: CoherenceManagerInstantiationFn = broadcastManager | ||
) { | ||
require (isPow2(nBanks) || nBanks == 0) | ||
} | ||
|
||
case class CoherenceManagerWrapperParams( | ||
blockBytes: Int, | ||
beatBytes: Int, | ||
nBanks: Int, | ||
name: String) | ||
(val coherenceManager: CoherenceManagerInstantiationFn) | ||
extends HasTLBusParams | ||
with TLBusWrapperInstantiationLike | ||
{ | ||
val dtsFrequency = None | ||
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): CoherenceManagerWrapper = { | ||
val cmWrapper = LazyModule(new CoherenceManagerWrapper(this, context)) | ||
cmWrapper.suggestName(loc.name + "_wrapper") | ||
cmWrapper.halt.foreach { context.anyLocationMap += loc.halt(_) } | ||
context.tlBusWrapperLocationMap += (loc -> cmWrapper) | ||
cmWrapper | ||
} | ||
} | ||
|
||
class CoherenceManagerWrapper(params: CoherenceManagerWrapperParams, context: HasTileLinkLocations)(implicit p: Parameters) extends TLBusWrapper(params, params.name) { | ||
val (tempIn, tempOut, halt) = params.coherenceManager(context) | ||
|
||
// TODO could remove temp if we could get access to .edges from InwardNodeHandle | ||
val viewNode = TLIdentityNode() | ||
def busView: TLEdge = viewNode.edges.out.head | ||
val inwardNode = tempIn :*= viewNode | ||
val builtInDevices = BuiltInDevices.none | ||
|
||
private def banked(node: TLOutwardNode): TLOutwardNode = | ||
if (params.nBanks == 0) node else { TLTempNode() :=* BankBinder(params.nBanks, params.blockBytes) :*= node } | ||
val outwardNode = banked(tempOut) | ||
} | ||
|
||
object CoherenceManagerWrapper { | ||
type CoherenceManagerInstantiationFn = HasTileLinkLocations => (TLInwardNode, TLOutwardNode, Option[IntOutwardNode]) | ||
|
||
val broadcastManager: CoherenceManagerInstantiationFn = { context => | ||
implicit val p = context.p | ||
val BroadcastParams(nTrackers, bufferless) = p(BroadcastKey) | ||
val bh = LazyModule(new TLBroadcast(p(CacheBlockBytes), nTrackers, bufferless)) | ||
val ss = TLSourceShrinker(nTrackers) | ||
ss :*= bh.node | ||
(bh.node, ss, None) | ||
} | ||
|
||
val incoherentManager: CoherenceManagerInstantiationFn = { _ => | ||
val node = TLNameNode("no_coherence_manager") | ||
(node, node, None) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.