1
0

coreplex: leverage improved := composition

This commit is contained in:
Wesley W. Terpstra 2017-10-25 02:27:01 -07:00
parent e894d64bca
commit 8c5e8dd071
6 changed files with 16 additions and 56 deletions

View File

@ -24,9 +24,7 @@ trait HasCrossingHelper extends LazyScope
val out = x.node.parentsOut.exists(_ eq this) // is the crossing exiting the wrapper? val out = x.node.parentsOut.exists(_ eq this) // is the crossing exiting the wrapper?
crossing match { crossing match {
case SynchronousCrossing(params) => { case SynchronousCrossing(params) => {
// !!! Why does star resolution fail for tile with no slave devices? this { TLBuffer(params)(x.node) }
// this { TLBuffer(params)(x.node) }
x.node
} }
case RationalCrossing(direction) => { case RationalCrossing(direction) => {
def sourceGen = LazyModule(new TLRationalCrossingSource) def sourceGen = LazyModule(new TLRationalCrossingSource)

View File

@ -37,15 +37,12 @@ class PeripheryBus(params: PeripheryBusParams)(implicit p: Parameters) extends T
atomics.node atomics.node
} }
def toTile( def toTile(name: Option[String] = None)(gen: Parameters => TLInwardNode) {
adapt: TLOutwardNode => TLOutwardNode,
to: TLInwardNode,
name: Option[String] = None) {
this { this {
LazyScope(s"${busName}ToTile${name.getOrElse("")}") { LazyScope(s"${busName}ToTile${name.getOrElse("")}") {
SinkCardinality { implicit p => SinkCardinality { implicit p =>
FlipRendering { implicit p => FlipRendering { implicit p =>
to :*= adapt(outwardNode) gen(p) :*= outwardNode
} }
} }
} }

View File

@ -28,18 +28,11 @@ case class TileMasterPortParams(
.map(BasicBusBlockerParams(_, coreplex.pbus.beatBytes, coreplex.sbus.beatBytes, deadlock = true)) .map(BasicBusBlockerParams(_, coreplex.pbus.beatBytes, coreplex.sbus.beatBytes, deadlock = true))
.map(bp => LazyModule(new BasicBusBlocker(bp))) .map(bp => LazyModule(new BasicBusBlocker(bp)))
val tile_master_fixer = LazyModule(new TLFIFOFixer(TLFIFOFixer.allUncacheable)) val tile_master_fixer = LazyModule(new TLFIFOFixer(TLFIFOFixer.allUncacheable))
val tile_master_buffer = LazyModule(new TLBufferChain(addBuffers))
val node: Option[TLNode] = TLNodeChain(List(
Some(tile_master_buffer.node),
Some(tile_master_fixer.node),
tile_master_blocker.map(_.node),
tile_master_cork.map(_.node)).flatten)
tile_master_blocker.foreach { _.controlNode := coreplex.pbus.toVariableWidthSlaves } tile_master_blocker.foreach { _.controlNode := coreplex.pbus.toVariableWidthSlaves }
node.foreach { _ :=* masterNode } (Seq(tile_master_fixer.node) ++ TLBuffer.chain(addBuffers)
++ tile_master_blocker.map(_.node) ++ tile_master_cork.map(_.node))
node.getOrElse(masterNode) .foldRight(masterNode)(_ :=* _)
} }
} }
@ -48,22 +41,16 @@ case class TileSlavePortParams(
blockerCtrlAddr: Option[BigInt] = None) { blockerCtrlAddr: Option[BigInt] = None) {
def adapt(coreplex: HasPeripheryBus) def adapt(coreplex: HasPeripheryBus)
(masterNode: TLOutwardNode) (slaveNode: TLInwardNode)
(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = { (implicit p: Parameters, sourceInfo: SourceInfo): TLInwardNode = {
val tile_slave_blocker = val tile_slave_blocker =
blockerCtrlAddr blockerCtrlAddr
.map(BasicBusBlockerParams(_, coreplex.pbus.beatBytes, coreplex.sbus.beatBytes)) .map(BasicBusBlockerParams(_, coreplex.pbus.beatBytes, coreplex.sbus.beatBytes))
.map(bp => LazyModule(new BasicBusBlocker(bp))) .map(bp => LazyModule(new BasicBusBlocker(bp)))
val tile_slave_buffer = LazyModule(new TLBufferChain(addBuffers))
val node: Option[TLNode] = TLNodeChain(List(
Some(tile_slave_buffer.node),
tile_slave_blocker.map(_.node)).flatten)
tile_slave_blocker.foreach { _.controlNode := coreplex.pbus.toVariableWidthSlaves } tile_slave_blocker.foreach { _.controlNode := coreplex.pbus.toVariableWidthSlaves }
node.foreach { _ :*= masterNode } (TLBuffer.chain(addBuffers) ++ tile_slave_blocker.map(_.node))
.foldLeft(slaveNode)(_ :*= _)
node.getOrElse(masterNode)
} }
} }
@ -116,18 +103,10 @@ trait HasRocketTiles extends HasTiles
).suggestName(tp.name) ).suggestName(tp.name)
// Connect the master ports of the tile to the system bus // Connect the master ports of the tile to the system bus
sbus.fromTile( sbus.fromTile(tp.name) { implicit p => crossing.master.adapt(this)(wrapper.cross(wrapper.masterNode)) }
adapt = {x: TLOutwardNode => wrapper.cross(x) } andThen
crossing.master.adapt(this) _,
from = wrapper.masterNode,
name = tp.name)
// Connect the slave ports of the tile to the periphery bus // Connect the slave ports of the tile to the periphery bus
pbus.toTile( pbus.toTile(tp.name) { implicit p => crossing.slave.adapt(this)(wrapper.slaveNode) } // !!! wrapper.cross
adapt = {x: TLOutwardNode => wrapper.cross(x) } compose
crossing.slave.adapt(this) _,
to = wrapper.slaveNode,
name = tp.name)
// Handle all the different types of interrupts crossing to or from the tile: // Handle all the different types of interrupts crossing to or from the tile:
// 1. Debug interrupt is definitely asynchronous in all cases. // 1. Debug interrupt is definitely asynchronous in all cases.

View File

@ -52,14 +52,11 @@ class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWr
def fromFrontBus: TLInwardNode = master_splitter.node def fromFrontBus: TLInwardNode = master_splitter.node
def fromTile( def fromTile(name: Option[String])(gen: Parameters => TLOutwardNode) {
adapt: TLOutwardNode => TLOutwardNode,
from: TLOutwardNode,
name: Option[String] = None) {
this { this {
LazyScope(s"${busName}FromTile${name.getOrElse("")}") { LazyScope(s"${busName}FromTile${name.getOrElse("")}") {
SourceCardinality { implicit p => SourceCardinality { implicit p =>
master_splitter.node :=* adapt(from) master_splitter.node :=* gen(p)
} }
} }
} }

View File

@ -26,9 +26,7 @@ class GroundTestCoreplex(implicit p: Parameters) extends BaseCoreplex
)} )}
tiles.flatMap(_.dcacheOpt).foreach { dc => tiles.flatMap(_.dcacheOpt).foreach { dc =>
sbus.fromTile( sbus.fromTile(None) { implicit p => TileMasterPortParams(addBuffers = 1).adapt(this)(dc.node) }
adapt = TileMasterPortParams(addBuffers = 1).adapt(this) _,
from = dc.node)
} }
val pbusRAM = LazyModule(new TLRAM(AddressSet(testRamAddr, 0xffff), true, false, pbus.beatBytes)) val pbusRAM = LazyModule(new TLRAM(AddressSet(testRamAddr, 0xffff), true, false, pbus.beatBytes))

View File

@ -79,18 +79,9 @@ object TLBuffer
} }
} }
object TLNodeChain {
def apply(nodes: Seq[TLNode])(implicit p: Parameters): Option[TLNode] = if(nodes.size > 0) {
(nodes.init zip nodes.tail) foreach { case (prev, next) => next :=? prev }
Some(NodeHandle(nodes.head, nodes.last))
} else {
None
}
}
class TLBufferChain(depth: Int)(implicit p: Parameters) extends SimpleLazyModule { class TLBufferChain(depth: Int)(implicit p: Parameters) extends SimpleLazyModule {
val buf_chain = List.fill(depth)(LazyModule(new TLBuffer(BufferParams.default))) val buf_chain = List.fill(depth)(LazyModule(new TLBuffer(BufferParams.default)))
val node = TLNodeChain(buf_chain.map(_.node)).getOrElse(TLIdentityNode()) val node = buf_chain.map(_.node:TLNode).reduceOption(_ :=? _).getOrElse(TLIdentityNode())
} }
object TLBufferChain object TLBufferChain