2017-07-23 17:31:04 +02:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
|
|
|
package freechips.rocketchip.tilelink
|
|
|
|
|
|
|
|
import Chisel._
|
2017-08-08 01:43:06 +02:00
|
|
|
import freechips.rocketchip.config.{Field, Parameters}
|
2017-07-23 17:31:04 +02:00
|
|
|
import freechips.rocketchip.diplomacy._
|
2017-08-08 01:43:06 +02:00
|
|
|
|
2017-09-09 03:33:44 +02:00
|
|
|
case object TLBusDelayProbability extends Field[Double](0.0)
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
/** Specifies widths of various attachement points in the SoC */
|
|
|
|
trait TLBusParams {
|
|
|
|
val beatBytes: Int
|
|
|
|
val blockBytes: Int
|
|
|
|
val masterBuffering: BufferParams
|
|
|
|
val slaveBuffering: BufferParams
|
|
|
|
|
|
|
|
def beatBits: Int = beatBytes * 8
|
|
|
|
def blockBits: Int = blockBytes * 8
|
|
|
|
def blockBeats: Int = blockBytes / beatBytes
|
|
|
|
def blockOffset: Int = log2Up(blockBytes)
|
|
|
|
}
|
|
|
|
|
2017-09-26 23:58:18 +02:00
|
|
|
abstract class TLBusWrapper(params: TLBusParams, val busName: String)(implicit p: Parameters)
|
|
|
|
extends SimpleLazyModule with LazyScope with TLBusParams {
|
2017-08-31 01:21:08 +02:00
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
val beatBytes = params.beatBytes
|
|
|
|
val blockBytes = params.blockBytes
|
|
|
|
val masterBuffering = params.masterBuffering
|
|
|
|
val slaveBuffering = params.slaveBuffering
|
|
|
|
require(blockBytes % beatBytes == 0)
|
2017-08-08 01:43:06 +02:00
|
|
|
private val delayProb = p(TLBusDelayProbability)
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-08 02:30:24 +02:00
|
|
|
protected val xbar = LazyModule(new TLXbar)
|
2017-08-31 01:21:08 +02:00
|
|
|
xbar.suggestName(busName)
|
2017-08-31 02:57:52 +02:00
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
private val master_buffer = LazyModule(new TLBuffer(masterBuffering))
|
2017-08-31 01:21:08 +02:00
|
|
|
master_buffer.suggestName(s"${busName}_master_TLBuffer")
|
2017-07-23 17:31:04 +02:00
|
|
|
private val slave_buffer = LazyModule(new TLBuffer(slaveBuffering))
|
2017-08-31 01:21:08 +02:00
|
|
|
slave_buffer.suggestName(s"${busName}_slave_TLBuffer")
|
2017-07-23 17:31:04 +02:00
|
|
|
private val slave_frag = LazyModule(new TLFragmenter(beatBytes, blockBytes))
|
2017-08-31 01:21:08 +02:00
|
|
|
slave_frag.suggestName(s"${busName}_slave_TLFragmenter")
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
private val slave_ww = LazyModule(new TLWidthWidget(beatBytes))
|
2017-08-31 01:21:08 +02:00
|
|
|
slave_ww.suggestName(s"${busName}_slave_TLWidthWidget")
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-08 02:36:07 +02:00
|
|
|
private val delayedNode = if (delayProb > 0.0) {
|
|
|
|
val firstDelay = LazyModule(new TLDelayer(delayProb))
|
|
|
|
val flowDelay = LazyModule(new TLBuffer(BufferParams.flow))
|
|
|
|
val secondDelay = LazyModule(new TLDelayer(delayProb))
|
|
|
|
firstDelay.node :*= xbar.node
|
|
|
|
flowDelay.node :*= firstDelay.node
|
|
|
|
secondDelay.node :*= flowDelay.node
|
|
|
|
secondDelay.node
|
|
|
|
} else {
|
|
|
|
xbar.node
|
|
|
|
}
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
xbar.node :=* master_buffer.node
|
2017-08-08 02:36:07 +02:00
|
|
|
slave_buffer.node :*= delayedNode
|
2017-07-23 17:31:04 +02:00
|
|
|
slave_frag.node :*= slave_buffer.node
|
|
|
|
slave_ww.node :*= slave_buffer.node
|
|
|
|
|
2017-08-08 02:36:07 +02:00
|
|
|
protected def outwardNode: TLOutwardNode = delayedNode
|
2017-07-23 17:31:04 +02:00
|
|
|
protected def outwardBufNode: TLOutwardNode = slave_buffer.node
|
|
|
|
protected def outwardFragNode: TLOutwardNode = slave_frag.node
|
|
|
|
protected def outwardWWNode: TLOutwardNode = slave_ww.node
|
|
|
|
protected def inwardNode: TLInwardNode = xbar.node
|
|
|
|
protected def inwardBufNode: TLInwardNode = master_buffer.node
|
|
|
|
|
|
|
|
def bufferFromMasters: TLInwardNode = inwardBufNode
|
|
|
|
|
|
|
|
def bufferToSlaves: TLOutwardNode = outwardBufNode
|
|
|
|
|
2017-12-02 03:28:37 +01:00
|
|
|
def toSyncSlaves(name: Option[String] = None, addBuffers: Int = 0): TLOutwardNode = {
|
|
|
|
TLBuffer.chain(addBuffers).foldRight(outwardBufNode)(_ :*= _)
|
2017-09-06 23:42:47 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
def toVariableWidthSlaves: TLOutwardNode = outwardFragNode
|
|
|
|
|
|
|
|
def toFixedWidthSlaves: TLOutwardNode = outwardWWNode
|
|
|
|
|
|
|
|
def toFixedWidthPorts: TLOutwardNode = outwardWWNode // TODO, do/don't buffer here; knowing we will after the necessary port conversions
|
|
|
|
|
|
|
|
}
|