2017-07-23 17:31:04 +02:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
2018-01-12 21:29:27 +01:00
|
|
|
package freechips.rocketchip.subsystem
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import freechips.rocketchip.config.{Field, Parameters}
|
|
|
|
import freechips.rocketchip.diplomacy._
|
|
|
|
import freechips.rocketchip.tilelink._
|
2018-02-21 02:09:30 +01:00
|
|
|
import freechips.rocketchip.util._
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
case class PeripheryBusParams(
|
|
|
|
beatBytes: Int,
|
|
|
|
blockBytes: Int,
|
2018-02-23 22:51:31 +01:00
|
|
|
arithmeticAtomics: Boolean = true,
|
|
|
|
sbusCrossingType: SubsystemClockCrossing = SynchronousCrossing(), // relative to sbus
|
2017-07-25 09:55:55 +02:00
|
|
|
frequency: BigInt = BigInt(100000000) // 100 MHz as default bus frequency
|
2018-02-15 23:01:49 +01:00
|
|
|
) extends HasTLBusParams
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-09-09 03:33:44 +02:00
|
|
|
case object PeripheryBusKey extends Field[PeripheryBusParams]
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2018-02-23 22:51:31 +01:00
|
|
|
class PeripheryBus(params: PeripheryBusParams)
|
2018-02-21 02:09:30 +01:00
|
|
|
(implicit p: Parameters) extends TLBusWrapper(params, "periphery_bus")
|
2018-02-15 23:01:49 +01:00
|
|
|
with HasTLXbarPhy
|
|
|
|
with HasCrossing {
|
2018-02-23 22:51:31 +01:00
|
|
|
val crossing = params.sbusCrossingType
|
2018-02-15 23:01:49 +01:00
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toSlave[D,U,E,B <: Data]
|
|
|
|
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
2018-02-21 02:09:30 +01:00
|
|
|
to("slave" named name) { gen :*= bufferTo(buffer) }
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toVariableWidthSlaveNode(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(node: TLInwardNode) { toVariableWidthSlaveNodeOption(name, buffer)(Some(node)) }
|
|
|
|
|
|
|
|
def toVariableWidthSlaveNodeOption(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(node: Option[TLInwardNode]) {
|
|
|
|
node foreach { n => to("slave" named name) { n :*= fragmentTo(buffer) } }
|
2018-02-23 08:45:21 +01:00
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toVariableWidthSlave[D,U,E,B <: Data]
|
|
|
|
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
|
|
|
to("slave" named name) { gen :*= fragmentTo(buffer) }
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toFixedWidthSlaveNode(name: Option[String] = None, buffer: BufferParams = BufferParams.none)(gen: TLInwardNode) {
|
2018-02-23 08:45:21 +01:00
|
|
|
to("slave" named name) { gen :*= fixedWidthTo(buffer) }
|
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toFixedWidthSlave[D,U,E,B <: Data]
|
|
|
|
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
2018-02-21 02:09:30 +01:00
|
|
|
to("slave" named name) { gen :*= fixedWidthTo(buffer) }
|
2018-02-15 23:01:49 +01:00
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toFixedWidthSingleBeatSlaveNode
|
|
|
|
(widthBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
2018-02-23 08:45:21 +01:00
|
|
|
(gen: TLInwardNode) {
|
|
|
|
to("slave" named name) {
|
|
|
|
gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toFixedWidthSingleBeatSlave[D,U,E,B <: Data]
|
|
|
|
(widthBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
2018-02-21 02:09:30 +01:00
|
|
|
to("slave" named name) {
|
2018-02-15 23:01:49 +01:00
|
|
|
gen :*= TLFragmenter(widthBytes, params.blockBytes) :*= fixedWidthTo(buffer)
|
|
|
|
}
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
2017-10-23 18:39:01 +02:00
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toLargeBurstSlave[D,U,E,B <: Data]
|
|
|
|
(maxXferBytes: Int, name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
2018-02-21 02:09:30 +01:00
|
|
|
to("slave" named name) {
|
2018-02-15 23:01:49 +01:00
|
|
|
gen :*= fragmentTo(params.beatBytes, maxXferBytes, buffer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toFixedWidthPort[D,U,E,B <: Data]
|
|
|
|
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[TLClientPortParameters,TLManagerPortParameters,TLEdgeIn,TLBundle,D,U,E,B] =
|
|
|
|
TLIdentity.gen): OutwardNodeHandle[D,U,E,B] = {
|
2018-02-22 03:22:06 +01:00
|
|
|
to("port" named name) { gen := fixedWidthTo(buffer) }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-23 22:51:31 +01:00
|
|
|
def fromSystemBus(gen: => TLOutwardNode) {
|
2018-02-21 02:09:30 +01:00
|
|
|
from("sbus") {
|
2018-02-15 23:01:49 +01:00
|
|
|
(inwardNode
|
2018-02-23 22:51:31 +01:00
|
|
|
:*= TLBuffer(BufferParams.default)
|
|
|
|
:*= TLAtomicAutomata(arithmetic = params.arithmeticAtomics)
|
2018-02-15 23:01:49 +01:00
|
|
|
:*= gen)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def fromOtherMaster[D,U,E,B <: Data]
|
|
|
|
(name: Option[String] = None, buffer: BufferParams = BufferParams.none)
|
|
|
|
(gen: => NodeHandle[D,U,E,B,TLClientPortParameters,TLManagerPortParameters,TLEdgeOut,TLBundle] =
|
|
|
|
TLIdentity.gen): InwardNodeHandle[D,U,E,B] = {
|
2018-02-23 08:45:21 +01:00
|
|
|
from("master" named name) { bufferFrom(buffer) :=* gen }
|
2018-02-15 23:01:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-23 21:50:51 +01:00
|
|
|
def toTile
|
|
|
|
(name: Option[String] = None, buffers: Int = 0)
|
2018-02-17 00:58:55 +01:00
|
|
|
(gen: => TLNode): TLOutwardNode = {
|
2018-02-23 08:45:21 +01:00
|
|
|
to("tile" named name) { FlipRendering { implicit p =>
|
|
|
|
gen :*= bufferTo(buffers)
|
|
|
|
}}
|
2017-10-23 18:39:01 +02:00
|
|
|
}
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|