1
0

subsystem: even more general coupler methods

This commit is contained in:
Henry Cook 2018-02-23 12:50:51 -08:00
parent 5b1d72c776
commit 5725e17969
4 changed files with 55 additions and 92 deletions

View File

@ -21,21 +21,18 @@ class FrontBus(params: FrontBusParams, val crossing: SubsystemClockCrossing = Sy
(name: Option[String] = None, buffers: Int = 1) (name: Option[String] = None, buffers: Int = 1)
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] = (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("port" named name) { from("port" named name) { fixFrom(TLFIFOFixer.all, buffers) :=* gen }
val nodes = TLFIFOFixer(TLFIFOFixer.all) +: TLBuffer.chain(buffers)
inwardNode :=* nodes.reduce(_ :=* _) :=* gen
}
} }
def fromMasterNode(name: Option[String] = None, buffers: Int = 1)(gen: TLOutwardNode) { def fromMasterNode(name: Option[String] = None, buffers: Int = 1)(gen: TLOutwardNode) {
from("master" named name) { bufferFrom(buffers) :=* gen } from("master" named name) { fixFrom(TLFIFOFixer.all, buffers) :=* gen }
} }
def fromMaster[D,U,E,B <: Data] def fromMaster[D,U,E,B <: Data]
(name: Option[String] = None, buffers: Int = 1) (name: Option[String] = None, buffers: Int = 1)
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] = (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("master" named name) { bufferFrom(buffers) :=* gen } from("master" named name) { fixFrom(TLFIFOFixer.all, buffers) :=* gen }
} }
def fromCoherentChip(gen: => TLNode): TLInwardNode = { def fromCoherentChip(gen: => TLNode): TLInwardNode = {

View File

@ -21,94 +21,73 @@ class PeripheryBus(params: PeripheryBusParams, val crossing: SubsystemClockCross
with HasTLXbarPhy with HasTLXbarPhy
with HasCrossing { with HasCrossing {
def toSlave[D,U,E,B <: Data]( def toSlave[D,U,E,B <: Data]
name: Option[String] = None, (name: Option[String] = None, buffer: BufferParams = BufferParams.none)
buffer: BufferParams = BufferParams.none) (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
(gen: => NodeHandle[ TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,
D,U,E,B] = TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("slave" named name) { gen :*= bufferTo(buffer) } to("slave" named name) { gen :*= bufferTo(buffer) }
} }
def toVariableWidthSlaveNode( def toVariableWidthSlaveNode(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(node: TLInwardNode) { toVariableWidthSlaveNodeOption(name, buffer)(Some(node)) }
name: Option[String] = None,
buffer: BufferParams = BufferParams.none) def toVariableWidthSlaveNodeOption(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(node: Option[TLInwardNode]) {
(gen: TLInwardNode) { node foreach { n => to("slave" named name) { n :*= fragmentTo(buffer) } }
to("slave" named name) {
gen :*= fragmentTo(params.beatBytes, params.blockBytes, buffer)
}
} }
def toVariableWidthSlave[D,U,E,B <: Data]( def toVariableWidthSlave[D,U,E,B <: Data]
name: Option[String] = None, (name: Option[String] = None, buffer: BufferParams = BufferParams.none)
buffer: BufferParams = BufferParams.none) (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
(gen: => NodeHandle[ TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle, to("slave" named name) { gen :*= fragmentTo(buffer) }
D,U,E,B] = TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("slave" named name) {
gen :*= fragmentTo(params.beatBytes, params.blockBytes, buffer)
}
} }
def toFixedWidthSlaveNode( def toFixedWidthSlaveNode(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(gen: TLInwardNode) {
name: Option[String] = None,
buffer: BufferParams = BufferParams.none)
(gen: TLInwardNode) {
to("slave" named name) { gen :*= fixedWidthTo(buffer) } to("slave" named name) { gen :*= fixedWidthTo(buffer) }
} }
def toFixedWidthSlave[D,U,E,B <: Data]( def toFixedWidthSlave[D,U,E,B <: Data]
name: Option[String] = None, (name: Option[String] = None, buffer: BufferParams = BufferParams.none)
buffer: BufferParams = BufferParams.none) (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
(gen: => NodeHandle[ TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,
D,U,E,B] = TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("slave" named name) { gen :*= fixedWidthTo(buffer) } to("slave" named name) { gen :*= fixedWidthTo(buffer) }
} }
def toFixedWidthSingleBeatSlaveNode( def toFixedWidthSingleBeatSlaveNode
widthBytes: Int, (widthBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
name: Option[String] = None,
buffer: BufferParams = BufferParams.none)
(gen: TLInwardNode) { (gen: TLInwardNode) {
to("slave" named name) { to("slave" named name) {
gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer) gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer)
} }
} }
def toFixedWidthSingleBeatSlave[D,U,E,B <: Data]( def toFixedWidthSingleBeatSlave[D,U,E,B <: Data]
widthBytes: Int, (widthBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
name: Option[String] = None, (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
buffer: BufferParams = BufferParams.none) TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
(gen: => NodeHandle[
TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,
D,U,E,B] = TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("slave" named name) { to("slave" named name) {
gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer) gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer)
} }
} }
def toLargeBurstSlave( def toLargeBurstSlave[D,U,E,B <: Data]
maxXferBytes: Int, (maxXferBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
name: Option[String] = None, (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
buffer: BufferParams = BufferParams.none) TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
(gen: => TLNode): TLOutwardNode = {
to("slave" named name) { to("slave" named name) {
gen :*= fragmentTo(params.beatBytes, maxXferBytes, buffer) gen :*= fragmentTo(params.beatBytes, maxXferBytes, buffer)
} }
} }
def toFixedWidthPort[D,U,E,B <: Data]( def toFixedWidthPort[D,U,E,B <: Data]
name: Option[String] = None, (name: Option[String] = None, buffer: BufferParams = BufferParams.none)
buffer: BufferParams = BufferParams.none) (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B]): OutwardNodeHandle[D,U,E,B] = { TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("port" named name) { gen := fixedWidthTo(buffer) } to("port" named name) { gen := fixedWidthTo(buffer) }
} }
def fromSystemBus( def fromSystemBus
arithmetic: Boolean = true, (arithmetic: Boolean = true, buffer: BufferParams = BufferParams.default)
buffer: BufferParams = BufferParams.default)
(gen: => TLOutwardNode) { (gen: => TLOutwardNode) {
from("sbus") { from("sbus") {
(inwardNode (inwardNode
@ -118,17 +97,16 @@ class PeripheryBus(params: PeripheryBusParams, val crossing: SubsystemClockCross
} }
} }
def fromOtherMaster( def fromOtherMaster[D,U,E,B <: Data]
name: Option[String] = None, (name: Option[String] = None, buffer: BufferParams = BufferParams.none)
buffer: BufferParams = BufferParams.none) (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
(gen: => TLNode): TLInwardNode = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("master" named name) { bufferFrom(buffer) :=* gen } from("master" named name) { bufferFrom(buffer) :=* gen }
} }
def toTile( def toTile
name: Option[String] = None, (name: Option[String] = None, buffers: Int = 0)
buffers: Int = 0)
(gen: => TLNode): TLOutwardNode = { (gen: => TLNode): TLOutwardNode = {
to("tile" named name) { FlipRendering { implicit p => to("tile" named name) { FlipRendering { implicit p =>
gen :*= bufferTo(buffers) gen :*= bufferTo(buffers)

View File

@ -18,6 +18,9 @@ class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWr
private val master_splitter = LazyModule(new TLSplitter) private val master_splitter = LazyModule(new TLSplitter)
inwardNode :=* master_splitter.node inwardNode :=* master_splitter.node
protected def fixFromThenSplit(policy: TLFIFOFixer.Policy, buffers: Int): TLInwardNode =
master_splitter.node :=* TLBuffer.chain(buffers).foldLeft(TLFIFOFixer(policy))(_ :=* _)
def busView = master_splitter.node.edges.in.head def busView = master_splitter.node.edges.in.head
def toPeripheryBus(buffer: BufferParams = BufferParams.none) def toPeripheryBus(buffer: BufferParams = BufferParams.none)
@ -59,9 +62,7 @@ class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWr
(name: Option[String] = None, buffer: BufferParams = BufferParams.default) (name: Option[String] = None, buffer: BufferParams = BufferParams.default)
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] = (gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = { TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
to("slave" named name) { to("slave" named name) { gen :*= fragmentTo(buffer) }
gen :*= TLFragmenter(params.beatBytes, params.blockBytes) :*= bufferTo(buffer)
}
} }
def fromFrontBus(gen: => TLNode): TLInwardNode = { def fromFrontBus(gen: => TLNode): TLInwardNode = {
@ -72,8 +73,7 @@ class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWr
(name: Option[String], buffers: Int = 0, cork: Option[Boolean] = None) (name: Option[String], buffers: Int = 0, cork: Option[Boolean] = None)
(gen: => TLNode): TLInwardNode = { (gen: => TLNode): TLInwardNode = {
from("tile" named name) { from("tile" named name) {
(List(master_splitter.node, TLFIFOFixer(TLFIFOFixer.allUncacheable)) ++ TLBuffer.chain(buffers)) fixFromThenSplit(TLFIFOFixer.allUncacheable, buffers) :=* gen
.reduce(_ :=* _) :=* gen
} }
} }
@ -88,34 +88,20 @@ class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWr
(name: Option[String] = None, buffers: Int = 0) (name: Option[String] = None, buffers: Int = 0)
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] = (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("port" named name) { from("port" named name) { fixFromThenSplit(TLFIFOFixer.all, buffers) :=* gen }
(List(
master_splitter.node,
TLFIFOFixer(TLFIFOFixer.all)) ++
TLBuffer.chain(buffers)).reduce(_ :=* _) :=* gen
}
} }
def fromCoherentMaster[D,U,E,B <: Data] def fromCoherentMaster[D,U,E,B <: Data]
(name: Option[String] = None, buffers: Int = 0) (name: Option[String] = None, buffers: Int = 0)
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] = (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("coherent_master" named name) { from("coherent_master" named name) { fixFrom(TLFIFOFixer.all, buffers) :=* gen }
(inwardNode
:=* TLBuffer.chain(buffers).foldLeft(TLFIFOFixer(TLFIFOFixer.all))(_ :=* _)
:=* gen)
}
} }
def fromMaster[D,U,E,B <: Data] def fromMaster[D,U,E,B <: Data]
(name: Option[String] = None, buffers: Int = 0) (name: Option[String] = None, buffers: Int = 0)
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] = (gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = { TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
from("master" named name) { from("master" named name) { fixFromThenSplit(TLFIFOFixer.all, buffers) :=* gen }
(master_splitter.node
:=* TLFIFOFixer(TLFIFOFixer.all)
:=* TLBuffer.chain(buffers).reduce(_ :=* _)
:=* gen)
}
} }
} }

View File

@ -35,6 +35,9 @@ abstract class TLBusWrapper(params: HasTLBusParams, val busName: String)(implici
protected def bufferFrom(buffers: Int): TLInwardNode = protected def bufferFrom(buffers: Int): TLInwardNode =
TLBuffer.chain(buffers).foldLeft(inwardNode)(_ :=* _) TLBuffer.chain(buffers).foldLeft(inwardNode)(_ :=* _)
protected def fixFrom(policy: TLFIFOFixer.Policy, buffers: Int): TLInwardNode =
inwardNode :=* TLBuffer.chain(buffers).foldLeft(TLFIFOFixer(policy))(_ :=* _)
protected def bufferTo(buffer: BufferParams): TLOutwardNode = protected def bufferTo(buffer: BufferParams): TLOutwardNode =
TLBuffer(buffer) :*= delayNode :*= outwardNode TLBuffer(buffer) :*= delayNode :*= outwardNode
@ -50,7 +53,6 @@ abstract class TLBusWrapper(params: HasTLBusParams, val busName: String)(implici
protected def fragmentTo(minSize: Int, maxSize: Int, buffer: BufferParams): TLOutwardNode = protected def fragmentTo(minSize: Int, maxSize: Int, buffer: BufferParams): TLOutwardNode =
TLFragmenter(minSize, maxSize) :*= bufferTo(buffer) TLFragmenter(minSize, maxSize) :*= bufferTo(buffer)
protected def delayNode(implicit p: Parameters): TLNode = { protected def delayNode(implicit p: Parameters): TLNode = {
val delayProb = p(TLBusDelayProbability) val delayProb = p(TLBusDelayProbability)
if (delayProb > 0.0) { if (delayProb > 0.0) {