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) = {
|
|
|
|
TLFragmenter(widthBytes, params.blockBytes)(outwardWWNode)
|
|
|
|
}
|
|
|
|
|
|
|
|
def toLargeBurstSlave(maxXferBytes: Int) = {
|
|
|
|
TLFragmenter(params.beatBytes, maxXferBytes)(outwardBufNode)
|
|
|
|
}
|
|
|
|
|
|
|
|
val fromSystemBus: TLInwardNode = {
|
|
|
|
val atomics = LazyModule(new TLAtomicAutomata(arithmetic = params.arithmetic))
|
|
|
|
inwardBufNode := atomics.node
|
|
|
|
atomics.node
|
|
|
|
}
|
2017-10-23 18:39:01 +02:00
|
|
|
|
|
|
|
def toTile(
|
|
|
|
adapt: TLOutwardNode => TLOutwardNode,
|
|
|
|
to: TLInwardNode,
|
|
|
|
name: Option[String] = None) {
|
|
|
|
this {
|
|
|
|
LazyScope(s"${busName}ToTile${name.getOrElse("")}") {
|
|
|
|
SinkCardinality { implicit p =>
|
|
|
|
FlipRendering { implicit p =>
|
|
|
|
to :*= adapt(outwardNode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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-09-05 22:33:34 +02:00
|
|
|
pbus.fromSystemBus := sbus.toPeripheryBus()
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|