2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-09-01 00:53:25 +02:00
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
|
|
|
import Chisel._
|
2016-09-05 02:03:10 +02:00
|
|
|
import chisel3.internal.sourceinfo.SourceInfo
|
2016-12-02 02:46:52 +01:00
|
|
|
import config._
|
2016-10-04 00:17:36 +02:00
|
|
|
import diplomacy._
|
2016-10-13 06:11:32 +02:00
|
|
|
import scala.math.{min,max}
|
2016-09-01 00:53:25 +02:00
|
|
|
|
2017-03-14 03:55:27 +01:00
|
|
|
case class TLBufferParams(depth: Int, flow: Boolean, pipe: Boolean)
|
2016-09-01 00:53:25 +02:00
|
|
|
{
|
2017-03-14 03:55:27 +01:00
|
|
|
require (depth >= 0)
|
|
|
|
def isDefined = depth > 0
|
|
|
|
def latency = if (isDefined && !flow) 1 else 0
|
|
|
|
}
|
|
|
|
|
|
|
|
object TLBufferParams
|
|
|
|
{
|
|
|
|
implicit def apply(depth: Int): TLBufferParams = TLBufferParams(depth, false, false)
|
|
|
|
|
|
|
|
val default = TLBufferParams(2)
|
|
|
|
val none = TLBufferParams(0)
|
|
|
|
val flow = TLBufferParams(1, true, false)
|
|
|
|
val pipe = TLBufferParams(1, false, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
class TLBuffer(
|
|
|
|
a: TLBufferParams,
|
|
|
|
b: TLBufferParams,
|
|
|
|
c: TLBufferParams,
|
|
|
|
d: TLBufferParams,
|
|
|
|
e: TLBufferParams)(implicit p: Parameters) extends LazyModule
|
|
|
|
{
|
|
|
|
def this(ace: TLBufferParams, bd: TLBufferParams)(implicit p: Parameters) = this(ace, bd, ace, bd, ace)
|
|
|
|
def this(abcde: TLBufferParams)(implicit p: Parameters) = this(abcde, abcde)
|
|
|
|
def this()(implicit p: Parameters) = this(TLBufferParams.default)
|
2016-09-22 03:00:57 +02:00
|
|
|
|
|
|
|
val node = TLAdapterNode(
|
2017-03-14 03:55:27 +01:00
|
|
|
clientFn = { p => p.copy(minLatency = p.minLatency + b.latency + c.latency) },
|
|
|
|
managerFn = { p => p.copy(minLatency = p.minLatency + a.latency + d.latency) })
|
2016-09-01 00:53:25 +02:00
|
|
|
|
2016-09-02 20:13:43 +02:00
|
|
|
lazy val module = new LazyModuleImp(this) {
|
2016-09-01 00:53:25 +02:00
|
|
|
val io = new Bundle {
|
|
|
|
val in = node.bundleIn
|
|
|
|
val out = node.bundleOut
|
|
|
|
}
|
2017-03-14 03:55:27 +01:00
|
|
|
|
|
|
|
def buffer[T <: Data](config: TLBufferParams, data: DecoupledIO[T]): DecoupledIO[T] = {
|
|
|
|
if (config.isDefined) {
|
|
|
|
Queue(data, config.depth, pipe=config.pipe, flow=config.flow)
|
|
|
|
} else {
|
|
|
|
data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-09 20:08:39 +02:00
|
|
|
((io.in zip io.out) zip (node.edgesIn zip node.edgesOut)) foreach { case ((in, out), (edgeIn, edgeOut)) =>
|
2017-03-14 03:55:27 +01:00
|
|
|
out.a <> buffer(a, in .a)
|
|
|
|
in .d <> buffer(d, out.d)
|
2016-09-09 20:08:39 +02:00
|
|
|
|
2017-01-18 03:52:16 +01:00
|
|
|
if (edgeOut.manager.anySupportAcquireB && edgeOut.client.anySupportProbe) {
|
2017-03-14 03:55:27 +01:00
|
|
|
in .b <> buffer(b, out.b)
|
|
|
|
out.c <> buffer(c, in .c)
|
|
|
|
out.e <> buffer(e, in .e)
|
2016-09-09 20:08:39 +02:00
|
|
|
} else {
|
|
|
|
in.b.valid := Bool(false)
|
|
|
|
in.c.ready := Bool(true)
|
|
|
|
in.e.ready := Bool(true)
|
|
|
|
out.b.ready := Bool(true)
|
|
|
|
out.c.valid := Bool(false)
|
|
|
|
out.e.valid := Bool(false)
|
|
|
|
}
|
2016-09-01 00:53:25 +02:00
|
|
|
}
|
2016-09-02 20:13:43 +02:00
|
|
|
}
|
2016-09-01 00:53:25 +02:00
|
|
|
}
|
2016-09-01 01:45:18 +02:00
|
|
|
|
|
|
|
object TLBuffer
|
|
|
|
{
|
2016-09-09 08:06:59 +02:00
|
|
|
// applied to the TL source node; y.node := TLBuffer(x.node)
|
2017-03-14 03:55:27 +01:00
|
|
|
def apply() (x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(TLBufferParams.default)(x)
|
|
|
|
def apply(abcde: TLBufferParams) (x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(abcde, abcde)(x)
|
|
|
|
def apply(ace: TLBufferParams, bd: TLBufferParams)(x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(ace, bd, ace, bd, ace)(x)
|
|
|
|
def apply(
|
|
|
|
a: TLBufferParams,
|
|
|
|
b: TLBufferParams,
|
|
|
|
c: TLBufferParams,
|
|
|
|
d: TLBufferParams,
|
|
|
|
e: TLBufferParams)(x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = {
|
|
|
|
val buffer = LazyModule(new TLBuffer(a, b, c, d, e))
|
2016-09-09 08:06:59 +02:00
|
|
|
buffer.node := x
|
2016-09-01 01:45:18 +02:00
|
|
|
buffer.node
|
|
|
|
}
|
|
|
|
}
|