Skip to content

Commit 6e1e785

Browse files
committed
first try to purge out ClockGroup
1 parent 2af9fe6 commit 6e1e785

File tree

10 files changed

+44
-61
lines changed

10 files changed

+44
-61
lines changed

src/main/scala/subsystem/Attachable.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ trait LazyScopeWithParameters extends LazyScope { this: LazyModule =>
2121
implicit val p: Parameters
2222
}
2323

24+
/** provide [[anyLocationMap]] to store Locations. */
25+
trait HasLocations { this: LazyModule =>
26+
val anyLocationMap = LocationMap.empty[Any]
27+
}
28+
2429
/** Layers of hierarchy with this trait contain attachment points for neworks of power, clock, reset, and interrupt resources */
2530
trait HasPRCILocations extends LazyScopeWithParameters { this: LazyModule =>
26-
val allClockGroupsNode: ClockGroupNode
2731
val ibus: InterruptBusWrapper
28-
val anyLocationMap = LocationMap.empty[Any]
2932
}
3033

3134
/** Layers of hierarchy with this trait contain attachment points for TileLink interfaces */
32-
trait HasTileLinkLocations extends HasPRCILocations { this: LazyModule =>
35+
trait HasTileLinkLocations extends HasLocations with LazyScope { this: LazyModule =>
3336
val busContextName: String
3437
val tlBusWrapperLocationMap = LocationMap.empty[TLBusWrapper]
3538
def locateTLBusWrapper(location: Location[TLBusWrapper]): TLBusWrapper = locateTLBusWrapper(location.name)
@@ -38,19 +41,19 @@ trait HasTileLinkLocations extends HasPRCILocations { this: LazyModule =>
3841

3942
/** Subclasses of this trait have the ability to instantiate things inside a context that has TL attachement locations */
4043
trait CanInstantiateWithinContextThatHasTileLinkLocations {
41-
def instantiate(context: HasTileLinkLocations)(implicit p: Parameters): Unit
44+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule)(implicit p: Parameters): Unit
4245
}
4346

4447
/** Subclasses of this trait have the ability to connect things inside a context that has TL attachement locations */
4548
trait CanConnectWithinContextThatHasTileLinkLocations {
46-
def connect(context: HasTileLinkLocations)(implicit p: Parameters): Unit
49+
def connect(context: HasTileLinkLocations with HasPRCILocations with LazyModule)(implicit p: Parameters): Unit
4750
}
4851

4952
/** Attachable things provide a standard interface by which other things may attach themselves to this target.
5053
* Right now the trait is mostly for backwards compatibility, and in case it eventually becomes valuable
5154
* to be able to define additional resources available to agents trying to attach themselves, other than
5255
* what is being made available via the LocationMaps in trait HasTileLinkLocations.
5356
*/
54-
trait Attachable extends HasTileLinkLocations { this: LazyModule =>
57+
trait Attachable extends HasTileLinkLocations with HasPRCILocations { this: LazyModule =>
5558
def locateTLBusWrapper(location: TLBusWrapperLocation): TLBusWrapper = locateTLBusWrapper(location.name)
5659
}

src/main/scala/subsystem/BankedCoherenceParams.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ case class CoherenceManagerWrapperParams(
4444
extends HasTLBusParams
4545
with TLBusWrapperInstantiationLike
4646
{
47-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): CoherenceManagerWrapper = {
47+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): CoherenceManagerWrapper = {
4848
val cmWrapper = LazyModule(new CoherenceManagerWrapper(this, context))
4949
cmWrapper.suggestName(loc.name + "_wrapper")
5050
cmWrapper.halt.foreach { context.anyLocationMap += loc.halt(_) }
@@ -53,7 +53,7 @@ case class CoherenceManagerWrapperParams(
5353
}
5454
}
5555

56-
class CoherenceManagerWrapper(params: CoherenceManagerWrapperParams, context: HasTileLinkLocations)(implicit p: Parameters) extends TLBusWrapper(params, params.name) {
56+
class CoherenceManagerWrapper(params: CoherenceManagerWrapperParams, context: HasTileLinkLocations with HasPRCILocations with LazyModule)(implicit p: Parameters) extends TLBusWrapper(params, params.name) {
5757
val (tempIn, tempOut, halt) = params.coherenceManager(context)
5858

5959
private val coherent_jbar = LazyModule(new TLJbar)
@@ -68,7 +68,7 @@ class CoherenceManagerWrapper(params: CoherenceManagerWrapperParams, context: Ha
6868
}
6969

7070
object CoherenceManagerWrapper {
71-
type CoherenceManagerInstantiationFn = HasTileLinkLocations => (TLInwardNode, TLOutwardNode, Option[IntOutwardNode])
71+
type CoherenceManagerInstantiationFn = HasTileLinkLocations with HasPRCILocations with LazyModule => (TLInwardNode, TLOutwardNode, Option[IntOutwardNode])
7272

7373
def broadcastManagerFn(
7474
name: String,

src/main/scala/subsystem/BaseSubsystem.scala

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import freechips.rocketchip.prci._
1010
import freechips.rocketchip.tilelink.TLBusWrapper
1111
import freechips.rocketchip.util._
1212

13-
case object SubsystemDriveClockGroupsFromIO extends Field[Boolean](true)
13+
case object SubsystemDriveClockFromIO extends Field[Boolean](true)
1414
case class TLNetworkTopologyLocated(where: HierarchicalLocation) extends Field[Seq[CanInstantiateWithinContextThatHasTileLinkLocations with CanConnectWithinContextThatHasTileLinkLocations]]
1515
case class TLManagerViewpointLocated(where: HierarchicalLocation) extends Field[Location[TLBusWrapper]](SBUS)
1616

@@ -54,26 +54,16 @@ case object SubsystemResetSchemeKey extends Field[SubsystemResetScheme](ResetSyn
5454
*/
5555
trait HasConfigurablePRCILocations { this: HasPRCILocations =>
5656
val ibus = LazyModule(new InterruptBusWrapper)
57-
val allClockGroupsNode = ClockGroupIdentityNode()
58-
val io_clocks = if (p(SubsystemDriveClockGroupsFromIO)) {
59-
val aggregator = ClockGroupAggregator()
60-
val source = ClockGroupSourceNode(Seq(ClockGroupSourceParameters()))
61-
allClockGroupsNode :*= aggregator := source
62-
Some(InModuleBody {
63-
val elements = source.out.map(_._1.member.elements).flatten
64-
val io = IO(Flipped(RecordMap(elements.map { case (name, data) =>
65-
name -> data.cloneType
66-
}:_*)))
67-
elements.foreach { case (name, data) => io(name).foreach { data := _ } }
68-
io
69-
})
70-
} else {
71-
None
57+
val prciClockNode = ClockAdapterNode()
58+
val io_clocks = Option.when(p(SubsystemDriveClockFromIO)){
59+
val source = ClockSourceNode(Seq(ClockSourceParameters()))
60+
prciClockNode :*= source
61+
InModuleBody(source.makeIOs())
7262
}
7363
}
7464

7565
/** Look up the topology configuration for the TL buses located within this layer of the hierarchy */
76-
trait HasConfigurableTLNetworkTopology { this: HasTileLinkLocations =>
66+
trait HasConfigurableTLNetworkTopology extends LazyModule { this: HasTileLinkLocations with HasPRCILocations =>
7767
val location: HierarchicalLocation
7868

7969
// Calling these functions populates tlBusWrapperLocationMap and connects the locations to each other.
@@ -93,13 +83,14 @@ abstract class BaseSubsystem(val location: HierarchicalLocation = InSubsystem)
9383
with HasDTS
9484
with Attachable
9585
with HasConfigurablePRCILocations
86+
with HasPRCILocations
9687
with HasConfigurableTLNetworkTopology
9788
{
9889
override val module: BaseSubsystemModuleImp[BaseSubsystem]
9990

10091
val busContextName = "subsystem"
10192

102-
viewpointBus.clockGroupNode := allClockGroupsNode
93+
viewpointBus.clockNode := prciClockNode
10394

10495
// TODO: Preserve legacy implicit-clock behavior for IBUS for now. If binding
10596
// a PLIC to the CBUS, ensure it is synchronously coupled to the SBUS.

src/main/scala/subsystem/Cluster.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ class Cluster(
4141
lazy val clusterId = thisClusterParams.clusterId
4242
lazy val location = InCluster(clusterId)
4343

44-
lazy val allClockGroupsNode = ClockGroupIdentityNode()
44+
// lazy val allClockGroupsNode = ClockGroupIdentityNode()
4545

4646
val csbus = tlBusWrapperLocationMap(CSBUS(clusterId)) // like the sbus in the base subsystem
4747
val ccbus = tlBusWrapperLocationMap(CCBUS(clusterId)) // like the cbus in the base subsystem
4848
val cmbus = tlBusWrapperLocationMap.lift(CMBUS(clusterId)).getOrElse(csbus)
4949

50-
csbus.clockGroupNode := allClockGroupsNode
51-
ccbus.clockGroupNode := allClockGroupsNode
50+
// csbus.clockGroupNode := allClockGroupsNode
51+
// ccbus.clockGroupNode := allClockGroupsNode
5252

5353
val slaveNode = ccbus.inwardNode
5454
val masterNode = cmbus.outwardNode
@@ -169,7 +169,7 @@ trait CanAttachCluster {
169169

170170
def connectPRC(domain: ClusterPRCIDomain, context: ClusterContextType): Unit = {
171171
implicit val p = context.p
172-
domain.element.allClockGroupsNode :*= context.allClockGroupsNode
172+
// domain.element.allClockGroupsNode :*= context.allClockGroupsNode
173173
domain {
174174
domain.element_reset_domain.clockNode := crossingParams.resetCrossingType.injectClockNode := domain.clockNode
175175
}

src/main/scala/subsystem/FrontBus.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ case class FrontBusParams(
1818
with HasBuiltInDeviceParams
1919
with TLBusWrapperInstantiationLike
2020
{
21-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): FrontBus = {
21+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): FrontBus = {
2222
val fbus = LazyModule(new FrontBus(this, loc.name))
2323
fbus.suggestName(loc.name)
2424
context.tlBusWrapperLocationMap += (loc -> fbus)

src/main/scala/subsystem/HasTiles.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ trait CanAttachTile {
278278
case _: RationalCrossing => domain.clockNode := tlBusToGetClockDriverFrom.clockNode
279279
case _: AsynchronousCrossing => {
280280
val tileClockGroup = ClockGroup()
281-
tileClockGroup := context.allClockGroupsNode
281+
// tileClockGroup := context.allClockGroupsNode
282282
domain.clockNode := tileClockGroup
283283
}
284284
})

src/main/scala/subsystem/MemoryBus.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ case class MemoryBusParams(
2121
with HasRegionReplicatorParams
2222
with TLBusWrapperInstantiationLike
2323
{
24-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): MemoryBus = {
24+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): MemoryBus = {
2525
val mbus = LazyModule(new MemoryBus(this, loc.name))
2626
mbus.suggestName(loc.name)
2727
context.tlBusWrapperLocationMap += (loc -> mbus)

src/main/scala/subsystem/PeripheryBus.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ case class PeripheryBusParams(
2727
with HasRegionReplicatorParams
2828
with TLBusWrapperInstantiationLike
2929
{
30-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): PeripheryBus = {
30+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): PeripheryBus = {
3131
val pbus = LazyModule(new PeripheryBus(this, loc.name))
3232
pbus.suggestName(loc.name)
3333
context.tlBusWrapperLocationMap += (loc -> pbus)

src/main/scala/subsystem/SystemBus.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ case class SystemBusParams(
2020
with HasBuiltInDeviceParams
2121
with TLBusWrapperInstantiationLike
2222
{
23-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): SystemBus = {
23+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): SystemBus = {
2424
val sbus = LazyModule(new SystemBus(this, loc.name))
2525
sbus.suggestName(loc.name)
2626
context.tlBusWrapperLocationMap += (loc -> sbus)

src/main/scala/tilelink/BusWrapper.scala

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,13 @@ abstract class TLBusWrapper(params: HasTLBusParams, val busName: String)(implici
3636
with HasTLBusParams
3737
with CanHaveBuiltInDevices
3838
{
39-
private val clockGroupAggregator = LazyModule(new ClockGroupAggregator(busName){ override def shouldBeInlined = true }).suggestName(busName + "_clock_groups")
40-
private val clockGroup = LazyModule(new ClockGroup(busName){ override def shouldBeInlined = true })
41-
val clockGroupNode = clockGroupAggregator.node // other bus clock groups attach here
42-
val clockNode = clockGroup.node
43-
val fixedClockNode = FixedClockBroadcast(fixedClockOpt) // device clocks attach here
39+
val clockNode = ClockAdapterNode() // device clocks attach here
40+
val fixedClockNode = FixedClockBroadcast(fixedClockOpt)
4441
private val clockSinkNode = ClockSinkNode(List(ClockSinkParameters(take = fixedClockOpt)))
4542

46-
clockGroup.node := clockGroupAggregator.node
47-
fixedClockNode := clockGroup.node // first member of group is always domain's own clock
43+
fixedClockNode := clockNode
4844
clockSinkNode := fixedClockNode
4945

50-
InModuleBody {
51-
// make sure the above connections work properly because mismatched-by-name signals will just be ignored.
52-
(clockGroup.node.edges.in zip clockGroupAggregator.node.edges.out).zipWithIndex map { case ((in: ClockGroupEdgeParameters , out: ClockGroupEdgeParameters), i) =>
53-
require(in.members.keys == out.members.keys, s"clockGroup := clockGroupAggregator not working as you expect for index ${i}, becuase clockGroup has ${in.members.keys} and clockGroupAggregator has ${out.members.keys}")
54-
}
55-
}
56-
5746
def clockBundle = clockSinkNode.in.head._1
5847
def beatBytes = params.beatBytes
5948
def blockBytes = params.blockBytes
@@ -94,23 +83,23 @@ abstract class TLBusWrapper(params: HasTLBusParams, val busName: String)(implici
9483
def coupleFrom[T](name: String)(gen: TLInwardNode => T): T =
9584
from(name) { gen(inwardNode :*=* TLNameNode("tl")) }
9685

97-
def crossToBus(bus: TLBusWrapper, xType: ClockCrossingType, allClockGroupNode: ClockGroupEphemeralNode): NoHandle = {
98-
bus.clockGroupNode := asyncMux(xType, allClockGroupNode, this.clockGroupNode)
86+
def crossToBus(bus: TLBusWrapper, xType: ClockCrossingType, asyncClockNode: ClockEphemeralNode): NoHandle = {
87+
bus.clockNode := asyncMux(xType, asyncClockNode, this.clockNode)
9988
coupleTo(s"bus_named_${bus.busName}") {
10089
bus.crossInHelper(xType) :*= TLWidthWidget(beatBytes) :*= _
10190
}
10291
}
10392

104-
def crossFromBus(bus: TLBusWrapper, xType: ClockCrossingType, allClockGroupNode: ClockGroupEphemeralNode): NoHandle = {
105-
bus.clockGroupNode := asyncMux(xType, allClockGroupNode, this.clockGroupNode)
93+
def crossFromBus(bus: TLBusWrapper, xType: ClockCrossingType, asyncClockNode: ClockEphemeralNode): NoHandle = {
94+
this.clockNode := asyncMux(xType, asyncClockNode, bus.clockNode)
10695
coupleFrom(s"bus_named_${bus.busName}") {
10796
_ :=* TLWidthWidget(bus.beatBytes) :=* bus.crossOutHelper(xType)
10897
}
10998
}
11099
}
111100

112101
trait TLBusWrapperInstantiationLike {
113-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): TLBusWrapper
102+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): TLBusWrapper
114103
}
115104

116105
trait TLBusWrapperConnectionLike {
@@ -183,8 +172,8 @@ class TLBusWrapperConnection
183172
val masterTLBus = context.locateTLBusWrapper(master)
184173
val slaveTLBus = context.locateTLBusWrapper(slave)
185174
def bindClocks(implicit p: Parameters) = driveClockFromMaster match {
186-
case Some(true) => slaveTLBus.clockGroupNode := asyncMux(xType, context.allClockGroupsNode, masterTLBus.clockGroupNode)
187-
case Some(false) => masterTLBus.clockGroupNode := asyncMux(xType, context.allClockGroupsNode, slaveTLBus.clockGroupNode)
175+
case Some(true) => slaveTLBus.clockNode := asyncMux(xType, masterTLBus.clockNode, masterTLBus.clockNode)
176+
case Some(false) => masterTLBus.clockNode := asyncMux(xType, slaveTLBus.clockNode, slaveTLBus.clockNode)
188177
case None =>
189178
}
190179
def bindTLNodes(implicit p: Parameters) = nodeBinding match {
@@ -214,10 +203,10 @@ class TLBusWrapperTopology(
214203
) extends CanInstantiateWithinContextThatHasTileLinkLocations
215204
with CanConnectWithinContextThatHasTileLinkLocations
216205
{
217-
def instantiate(context: HasTileLinkLocations)(implicit p: Parameters): Unit = {
206+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule)(implicit p: Parameters): Unit = {
218207
instantiations.foreach { case (loc, params) => context { params.instantiate(context, loc) } }
219208
}
220-
def connect(context: HasTileLinkLocations)(implicit p: Parameters): Unit = {
209+
def connect(context: HasTileLinkLocations with HasPRCILocations with LazyModule)(implicit p: Parameters): Unit = {
221210
connections.foreach { case (master, slave, params) => context { params.connect(context, master, slave) } }
222211
}
223212
}
@@ -244,7 +233,7 @@ case class AddressAdjusterWrapperParams(
244233
with TLBusWrapperInstantiationLike
245234
{
246235
val dtsFrequency = None
247-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): AddressAdjusterWrapper = {
236+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): AddressAdjusterWrapper = {
248237
val aaWrapper = LazyModule(new AddressAdjusterWrapper(this, context.busContextName + "_" + loc.name))
249238
aaWrapper.suggestName(context.busContextName + "_" + loc.name + "_wrapper")
250239
context.tlBusWrapperLocationMap += (loc -> aaWrapper)
@@ -274,7 +263,7 @@ case class TLJBarWrapperParams(
274263
with TLBusWrapperInstantiationLike
275264
{
276265
val dtsFrequency = None
277-
def instantiate(context: HasTileLinkLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): TLJBarWrapper = {
266+
def instantiate(context: HasTileLinkLocations with HasPRCILocations with LazyModule, loc: Location[TLBusWrapper])(implicit p: Parameters): TLJBarWrapper = {
278267
val jbarWrapper = LazyModule(new TLJBarWrapper(this, context.busContextName + "_" + loc.name))
279268
jbarWrapper.suggestName(context.busContextName + "_" + loc.name + "_wrapper")
280269
context.tlBusWrapperLocationMap += (loc -> jbarWrapper)

0 commit comments

Comments
 (0)