2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-09-01 00:53:25 +02:00
|
|
|
|
2017-07-07 19:48:16 +02:00
|
|
|
package freechips.rocketchip.tilelink
|
2016-09-01 00:53:25 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2016-09-05 02:03:10 +02:00
|
|
|
import chisel3.internal.sourceinfo.SourceInfo
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.config.Parameters
|
|
|
|
import freechips.rocketchip.diplomacy._
|
2016-10-13 06:11:32 +02:00
|
|
|
import scala.math.{min,max}
|
2016-09-01 00:53:25 +02:00
|
|
|
|
2017-08-29 19:36:46 +02:00
|
|
|
class TLBufferNode (
|
|
|
|
a: BufferParams,
|
|
|
|
b: BufferParams,
|
|
|
|
c: BufferParams,
|
|
|
|
d: BufferParams,
|
|
|
|
e: BufferParams)(implicit p: Parameters) extends TLAdapterNode(
|
|
|
|
clientFn = { p => p.copy(minLatency = p.minLatency + b.latency + c.latency) },
|
|
|
|
managerFn = { p => p.copy(minLatency = p.minLatency + a.latency + d.latency) }
|
|
|
|
) {
|
|
|
|
override lazy val nodedebugstring = s"a:${a.toString}, b:${b.toString}, c:${c.toString}, d:${d.toString}, e:${e.toString}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-14 03:55:27 +01:00
|
|
|
class TLBuffer(
|
2017-03-16 23:19:36 +01:00
|
|
|
a: BufferParams,
|
|
|
|
b: BufferParams,
|
|
|
|
c: BufferParams,
|
|
|
|
d: BufferParams,
|
|
|
|
e: BufferParams)(implicit p: Parameters) extends LazyModule
|
2017-03-14 03:55:27 +01:00
|
|
|
{
|
2017-03-16 23:19:36 +01:00
|
|
|
def this(ace: BufferParams, bd: BufferParams)(implicit p: Parameters) = this(ace, bd, ace, bd, ace)
|
|
|
|
def this(abcde: BufferParams)(implicit p: Parameters) = this(abcde, abcde)
|
|
|
|
def this()(implicit p: Parameters) = this(BufferParams.default)
|
2016-09-22 03:00:57 +02:00
|
|
|
|
2017-08-29 19:36:46 +02:00
|
|
|
val node = new TLBufferNode(a, b, c, d, e)
|
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
|
|
|
|
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-06-14 22:45:12 +02:00
|
|
|
out.a <> a(in .a)
|
|
|
|
in .d <> 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-06-14 22:45:12 +02:00
|
|
|
in .b <> b(out.b)
|
|
|
|
out.c <> c(in .c)
|
|
|
|
out.e <> 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-16 23:19:36 +01:00
|
|
|
def apply() (x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(BufferParams.default)(x)
|
|
|
|
def apply(abcde: BufferParams) (x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(abcde, abcde)(x)
|
|
|
|
def apply(ace: BufferParams, bd: BufferParams)(x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = apply(ace, bd, ace, bd, ace)(x)
|
2017-03-14 03:55:27 +01:00
|
|
|
def apply(
|
2017-03-16 23:19:36 +01:00
|
|
|
a: BufferParams,
|
|
|
|
b: BufferParams,
|
|
|
|
c: BufferParams,
|
|
|
|
d: BufferParams,
|
|
|
|
e: BufferParams)(x: TLOutwardNode)(implicit p: Parameters, sourceInfo: SourceInfo): TLOutwardNode = {
|
2017-03-14 03:55:27 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|