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._
|
|
|
|
|
2017-07-25 09:55:55 +02:00
|
|
|
import freechips.rocketchip.config.Field
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
case class PeripheryBusParams(
|
|
|
|
beatBytes: Int,
|
|
|
|
blockBytes: Int,
|
|
|
|
masterBuffering: BufferParams = BufferParams.default,
|
|
|
|
slaveBuffering: BufferParams = BufferParams.none,
|
2017-07-25 09:55:55 +02:00
|
|
|
arithmetic: Boolean = true,
|
|
|
|
frequency: BigInt = BigInt(100000000) // 100 MHz as default bus frequency
|
2017-07-23 17:31:04 +02:00
|
|
|
) extends TLBusParams {
|
|
|
|
}
|
|
|
|
|
2017-09-09 03:33:44 +02:00
|
|
|
case object PeripheryBusKey extends Field[PeripheryBusParams]
|
2017-07-23 17:31:04 +02:00
|
|
|
|
2017-08-31 01:21:08 +02:00
|
|
|
class PeripheryBus(params: PeripheryBusParams)(implicit p: Parameters) extends TLBusWrapper(params, "PeripheryBus") {
|
2017-08-08 02:30:24 +02:00
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
def toFixedWidthSingleBeatSlave(widthBytes: Int) = {
|
2017-10-27 10:13:19 +02:00
|
|
|
TLFragmenter(widthBytes, params.blockBytes) := outwardWWNode
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def toLargeBurstSlave(maxXferBytes: Int) = {
|
2017-10-27 10:13:19 +02:00
|
|
|
TLFragmenter(params.beatBytes, maxXferBytes) := outwardBufNode
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
val fromSystemBus: TLInwardNode = {
|
|
|
|
val atomics = LazyModule(new TLAtomicAutomata(arithmetic = params.arithmetic))
|
2017-12-01 01:34:46 +01:00
|
|
|
xbar.node :*= TLBuffer(params.masterBuffering) :*= atomics.node
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
2017-10-23 18:39:01 +02:00
|
|
|
|
2017-10-25 11:27:01 +02:00
|
|
|
def toTile(name: Option[String] = None)(gen: Parameters => TLInwardNode) {
|
2017-10-23 18:39:01 +02:00
|
|
|
this {
|
|
|
|
LazyScope(s"${busName}ToTile${name.getOrElse("")}") {
|
|
|
|
SinkCardinality { implicit p =>
|
|
|
|
FlipRendering { implicit p =>
|
2017-10-25 11:27:01 +02:00
|
|
|
gen(p) :*= outwardNode
|
2017-10-23 18:39:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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 HasPeripheryBus extends HasSystemBus {
|
2017-09-09 03:33:44 +02:00
|
|
|
private val pbusParams = p(PeripheryBusKey)
|
2017-07-23 17:31:04 +02:00
|
|
|
val pbusBeatBytes = pbusParams.beatBytes
|
|
|
|
|
2017-09-26 23:58:18 +02:00
|
|
|
val pbus = LazyModule(new PeripheryBus(pbusParams))
|
2017-07-23 17:31:04 +02:00
|
|
|
|
|
|
|
// The peripheryBus hangs off of systemBus; here we convert TL-UH -> TL-UL
|
2017-12-01 01:34:46 +01:00
|
|
|
pbus.fromSystemBus :*= sbus.toPeripheryBus()
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|