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._
|
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,
|
2017-09-12 08:33:44 +02:00
|
|
|
e: BufferParams)(implicit valName: ValName) extends TLAdapterNode(
|
2017-08-29 19:36:46 +02:00
|
|
|
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) {
|
2017-09-14 03:06:03 +02:00
|
|
|
(node.in zip node.out) foreach { case ((in, edgeIn), (out, 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
|
|
|
|
{
|
2017-10-27 09:45:21 +02:00
|
|
|
def apply() (implicit p: Parameters): TLNode = apply(BufferParams.default)
|
|
|
|
def apply(abcde: BufferParams) (implicit p: Parameters): TLNode = apply(abcde, abcde)
|
|
|
|
def apply(ace: BufferParams, bd: BufferParams)(implicit p: Parameters): TLNode = apply(ace, bd, ace, bd, ace)
|
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,
|
2017-12-01 20:27:54 +01:00
|
|
|
e: BufferParams)(implicit p: Parameters): TLNode =
|
|
|
|
{
|
|
|
|
val buffer = LazyModule(new TLBuffer(a, b, c, d, e))
|
|
|
|
buffer.node
|
|
|
|
}
|
2017-10-25 08:34:16 +02:00
|
|
|
|
|
|
|
def chain(depth: Int, name: Option[String] = None)(implicit p: Parameters): Seq[TLNode] = {
|
|
|
|
val buffers = Seq.fill(depth) { LazyModule(new TLBuffer()) }
|
|
|
|
name.foreach { n => buffers.zipWithIndex.foreach { case (b, i) => b.suggestName(s"${n}_${i}") } }
|
|
|
|
buffers.map(_.node)
|
|
|
|
}
|
2016-09-01 01:45:18 +02:00
|
|
|
}
|