2017-07-23 17:31:04 +02:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
|
|
|
package freechips.rocketchip.coreplex
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import freechips.rocketchip.config.{Field, Parameters}
|
|
|
|
import freechips.rocketchip.diplomacy._
|
|
|
|
import freechips.rocketchip.tilelink._
|
|
|
|
import freechips.rocketchip.util._
|
|
|
|
|
|
|
|
case class SystemBusParams(
|
|
|
|
beatBytes: Int,
|
|
|
|
blockBytes: Int,
|
|
|
|
masterBuffering: BufferParams = BufferParams.default,
|
2017-08-26 11:47:04 +02:00
|
|
|
slaveBuffering: BufferParams = BufferParams.default
|
2017-07-23 17:31:04 +02:00
|
|
|
) extends TLBusParams
|
|
|
|
|
2017-09-09 03:33:44 +02:00
|
|
|
case object SystemBusKey extends Field[SystemBusParams]
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-31 01:21:08 +02:00
|
|
|
class SystemBus(params: SystemBusParams)(implicit p: Parameters) extends TLBusWrapper(params, "SystemBus") {
|
2017-08-08 02:30:24 +02:00
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
private val master_splitter = LazyModule(new TLSplitter) // Allows cycle-free connection to external networks
|
2017-08-31 02:57:52 +02:00
|
|
|
master_splitter.suggestName(s"${busName}_master_TLSplitter")
|
2017-07-29 09:01:26 +02:00
|
|
|
inwardNode :=* master_splitter.node
|
2017-09-15 23:44:07 +02:00
|
|
|
def busView = master_splitter.node.edges.in.head
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
protected def inwardSplitNode: TLInwardNode = master_splitter.node
|
|
|
|
protected def outwardSplitNode: TLOutwardNode = master_splitter.node
|
|
|
|
|
2017-09-06 01:41:39 +02:00
|
|
|
private val tile_fixer = LazyModule(new TLFIFOFixer(TLFIFOFixer.allUncacheable))
|
|
|
|
tile_fixer.suggestName(s"${busName}_tile_TLFIFOFixer")
|
|
|
|
master_splitter.node :=* tile_fixer.node
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
private val port_fixer = LazyModule(new TLFIFOFixer(TLFIFOFixer.all))
|
2017-08-31 01:21:08 +02:00
|
|
|
port_fixer.suggestName(s"${busName}_port_TLFIFOFixer")
|
2017-08-31 02:57:52 +02:00
|
|
|
master_splitter.node :=* port_fixer.node
|
|
|
|
|
2017-08-30 22:28:11 +02:00
|
|
|
private val pbus_fixer = LazyModule(new TLFIFOFixer(TLFIFOFixer.all))
|
2017-08-31 01:21:08 +02:00
|
|
|
pbus_fixer.suggestName(s"${busName}_pbus_TLFIFOFixer")
|
2017-08-30 22:28:11 +02:00
|
|
|
pbus_fixer.node :*= outwardWWNode
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
def toSplitSlaves: TLOutwardNode = outwardSplitNode
|
|
|
|
|
2017-09-05 22:33:34 +02:00
|
|
|
def toPeripheryBus(addBuffers: Int = 0): TLOutwardNode = {
|
2017-09-02 03:18:13 +02:00
|
|
|
val (in, out) = bufferChain(addBuffers, name = Some("pbus"))
|
2017-08-31 02:57:52 +02:00
|
|
|
in := pbus_fixer.node
|
|
|
|
out
|
|
|
|
}
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
val toMemoryBus: TLOutwardNode = outwardNode
|
|
|
|
|
2017-07-29 09:13:33 +02:00
|
|
|
val toSlave: TLOutwardNode = outwardBufNode
|
2017-07-27 20:10:34 +02:00
|
|
|
|
2017-08-24 23:35:01 +02:00
|
|
|
def fromCoherentChip: TLInwardNode = inwardNode
|
2017-07-25 06:41:17 +02:00
|
|
|
|
2017-09-06 00:02:16 +02:00
|
|
|
def fromFrontBus: TLInwardNode = master_splitter.node
|
|
|
|
|
2017-08-31 02:57:52 +02:00
|
|
|
def fromSyncTiles(params: BufferParams, addBuffers: Int = 0, name: Option[String] = None): TLInwardNode = {
|
|
|
|
val tile_buf = LazyModule(new TLBuffer(params))
|
|
|
|
name.foreach { n => tile_buf.suggestName(s"${busName}_${n}_TLBuffer") }
|
|
|
|
val (in, out) = bufferChain(addBuffers, name = name)
|
|
|
|
|
2017-09-06 01:41:39 +02:00
|
|
|
tile_fixer.node :=* out
|
|
|
|
in :=* tile_buf.node
|
2017-08-31 02:57:52 +02:00
|
|
|
tile_buf.node
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
2017-08-31 02:57:52 +02:00
|
|
|
def fromRationalTiles(dir: RationalDirection, addBuffers: Int = 0, name: Option[String] = None): TLRationalInwardNode = {
|
|
|
|
val tile_sink = LazyModule(new TLRationalCrossingSink(direction = dir))
|
2017-09-06 01:41:39 +02:00
|
|
|
name.foreach { n => tile_sink.suggestName(s"${busName}_${n}_TLRationalCrossingSink") }
|
2017-08-31 02:57:52 +02:00
|
|
|
val (in, out) = bufferChain(addBuffers, name = name)
|
|
|
|
|
2017-09-06 01:41:39 +02:00
|
|
|
tile_fixer.node :=* out
|
|
|
|
in :=* tile_sink.node
|
2017-08-31 02:57:52 +02:00
|
|
|
tile_sink.node
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
2017-08-31 02:57:52 +02:00
|
|
|
def fromAsyncTiles(depth: Int, sync: Int, addBuffers: Int = 0, name: Option[String] = None): TLAsyncInwardNode = {
|
|
|
|
val tile_sink = LazyModule(new TLAsyncCrossingSink(depth, sync))
|
|
|
|
name.foreach { n => tile_sink.suggestName(s"${busName}_${n}_TLAsyncCrossingSink") }
|
|
|
|
val (in, out) = bufferChain(addBuffers, name = name)
|
|
|
|
|
2017-09-06 01:41:39 +02:00
|
|
|
tile_fixer.node :=* out
|
|
|
|
in :=* tile_sink.node
|
2017-08-31 02:57:52 +02:00
|
|
|
tile_sink.node
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
2017-08-24 23:42:30 +02:00
|
|
|
def fromSyncPorts(params: BufferParams = BufferParams.default, name: Option[String] = None): TLInwardNode = {
|
2017-07-23 17:31:04 +02:00
|
|
|
val buffer = LazyModule(new TLBuffer(params))
|
2017-09-06 01:41:39 +02:00
|
|
|
name.foreach { n => buffer.suggestName(s"${busName}_${n}_TLBuffer") }
|
2017-07-23 17:31:04 +02:00
|
|
|
port_fixer.node :=* buffer.node
|
|
|
|
buffer.node
|
|
|
|
}
|
|
|
|
|
2017-08-24 23:42:30 +02:00
|
|
|
def fromSyncFIFOMaster(params: BufferParams = BufferParams.default, name: Option[String] = None): TLInwardNode = {
|
|
|
|
fromSyncPorts(params, name)
|
|
|
|
}
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-31 00:27:56 +02:00
|
|
|
def fromAsyncPorts(depth: Int = 8, sync: Int = 3, name : Option[String] = None): TLAsyncInwardNode = {
|
2017-07-23 17:31:04 +02:00
|
|
|
val sink = LazyModule(new TLAsyncCrossingSink(depth, sync))
|
2017-09-06 01:41:39 +02:00
|
|
|
name.foreach { n => sink.suggestName(s"${busName}_${n}_TLAsyncCrossingSink") }
|
2017-07-23 17:31:04 +02:00
|
|
|
port_fixer.node :=* sink.node
|
|
|
|
sink.node
|
|
|
|
}
|
|
|
|
|
2017-08-31 00:27:56 +02:00
|
|
|
def fromAsyncFIFOMaster(depth: Int = 8, sync: Int = 3, name: Option[String] = None): TLAsyncInwardNode = fromAsyncPorts(depth, sync, name)
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-31 00:27:56 +02:00
|
|
|
def fromRationalPorts(dir: RationalDirection, name: Option[String] = None): TLRationalInwardNode = {
|
2017-07-23 17:31:04 +02:00
|
|
|
val sink = LazyModule(new TLRationalCrossingSink(dir))
|
2017-08-31 01:21:08 +02:00
|
|
|
name.foreach{ n => sink.suggestName(s"${busName}_${n}_TLRationalCrossingSink") }
|
2017-07-23 17:31:04 +02:00
|
|
|
port_fixer.node :=* sink.node
|
|
|
|
sink.node
|
|
|
|
}
|
|
|
|
|
2017-08-31 00:27:56 +02:00
|
|
|
def fromRationalFIFOMaster(dir: RationalDirection, name: Option[String] = None): TLRationalInwardNode = fromRationalPorts(dir, name)
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Provides buses that serve as attachment points,
|
|
|
|
* for use in traits that connect individual devices or external ports.
|
|
|
|
*/
|
|
|
|
trait HasSystemBus extends HasInterruptBus {
|
2017-09-09 03:33:44 +02:00
|
|
|
private val sbusParams = p(SystemBusKey)
|
2017-07-23 17:31:04 +02:00
|
|
|
val sbusBeatBytes = sbusParams.beatBytes
|
|
|
|
|
2017-09-26 23:58:18 +02:00
|
|
|
val sbus = LazyModule(new SystemBus(sbusParams))
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-07-25 06:41:17 +02:00
|
|
|
def sharedMemoryTLEdge: TLEdge = sbus.busView
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|