Skip to content

Commit

Permalink
tilelink: enhance TLBusWrapper with connectivity and topology case cl…
Browse files Browse the repository at this point in the history
…asses
  • Loading branch information
hcook committed Apr 16, 2020
1 parent e7b9aa7 commit c1f6fbc
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/main/scala/tilelink/BusWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Chisel._
import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.prci._
import freechips.rocketchip.subsystem._ // TODO this class should be moved to package subsystem
import freechips.rocketchip.util._

/** Specifies widths of various attachement points in the SoC */
Expand Down Expand Up @@ -86,6 +87,61 @@ abstract class TLBusWrapper(params: HasTLBusParams, val busName: String)(implici
}
}

trait TLBusWrapperInstantiationLike {

This comment has been minimized.

Copy link
@DecodeTheEncoded

DecodeTheEncoded Nov 18, 2020

i feel confused about the naming convention here, why there is the like suffix? I googled a lot, and found some similar stuff like Traversable and Traversablelike, seems that Traversablelike is the template trait for the Traversable, https://stackoverflow.com/questions/4599937/what-is-the-difference-between-a-trait-and-a-template-trait I seached the wholed rockectchip project, but cannt find any TLBusWrapperInstantiation class. So, just wanna know what does the suffix mean.
Also, TLBusWrapperConnectionLike has a corresponding TLBusWrapperConnection class

def instantiate(context: HasLocations, loc: Location[TLBusWrapper])(implicit p: Parameters): TLBusWrapper
}

trait TLBusWrapperConnectionLike {
val xType: ClockCrossingType
def inject(implicit p: Parameters): TLNode = TLNameNode("temp")
def connect(context: HasLocations, from: Location[TLBusWrapper], to: Location[TLBusWrapper])(implicit p: Parameters): Unit
}

case class TLBusWrapperCrossToConnection
(xType: ClockCrossingType)
(nodeView: (TLBusWrapper, Parameters) => TLInwardNode = { case(w, p) => w.crossInHelper(xType)(p) },
inject: Parameters => TLNode = { _ => TLNameNode("temp") })
extends TLBusWrapperConnectionLike
{
def connect(context: HasLocations, from: Location[TLBusWrapper], to: Location[TLBusWrapper])(implicit p: Parameters): Unit = {
val masterTLBus = context.locateTLBusWrapper(from)
val slaveTLBus = context.locateTLBusWrapper(to)
slaveTLBus.clockGroupNode := asyncMux(xType, context.asyncClockGroupsNode, masterTLBus.clockGroupNode)
masterTLBus.coupleTo(s"bus_named_${masterTLBus.busName}") {
nodeView(slaveTLBus,p) :*= TLWidthWidget(masterTLBus.beatBytes) :*= inject(p) :*= _
// TODO does BankBinder injection need to be (_ :=* bb :*= _)
}
}
}

case class TLBusWrapperCrossFromConnection
(xType: ClockCrossingType)
(nodeView: (TLBusWrapper, Parameters) => TLOutwardNode = { case(w, p) => w.crossOutHelper(xType)(p) },
inject: Parameters => TLNode = { _ => TLNameNode("temp") })
extends TLBusWrapperConnectionLike
{
def connect(context: HasLocations, from: Location[TLBusWrapper], to: Location[TLBusWrapper])(implicit p: Parameters): Unit = FlipRendering { implicit p =>
val masterTLBus = context.locateTLBusWrapper(to)
val slaveTLBus = context.locateTLBusWrapper(from)
masterTLBus.clockGroupNode := asyncMux(xType, context.asyncClockGroupsNode, slaveTLBus.clockGroupNode)
slaveTLBus.coupleFrom(s"bus_named_${masterTLBus.busName}") {
_ :=* inject(p) :=* TLWidthWidget(masterTLBus.beatBytes) :=* nodeView(masterTLBus, p)
}
}
}

class TLBusWrapperTopology(
val instantiations: Seq[(Location[TLBusWrapper], TLBusWrapperInstantiationLike)],
val connections: Seq[(Location[TLBusWrapper], Location[TLBusWrapper], TLBusWrapperConnectionLike)]
) extends CanInstantiateWithinContext with CanConnectWithinContext {
def instantiate(context: HasLocations)(implicit p: Parameters): Unit = {
instantiations.foreach { case (loc, params) => params.instantiate(context, loc) }
}
def connect(context: HasLocations)(implicit p: Parameters): Unit = {
connections.foreach { case (from, to, params) => params.connect(context, from, to) }
}
}

trait CanAttachTLSlaves extends HasTLBusParams { this: TLBusWrapper =>
def toSlave[D,U,E,B <: Data]
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
Expand Down

0 comments on commit c1f6fbc

Please sign in to comment.