2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-09-14 01:04:46 +02:00
|
|
|
|
2017-07-07 19:48:16 +02:00
|
|
|
package freechips.rocketchip.tilelink
|
2016-09-14 01:04:46 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.config.Parameters
|
|
|
|
import freechips.rocketchip.diplomacy._
|
|
|
|
import freechips.rocketchip.util._
|
2017-10-26 02:47:09 +02:00
|
|
|
import freechips.rocketchip.coreplex.{CrossingWrapper, AsynchronousCrossing}
|
2016-09-14 01:04:46 +02:00
|
|
|
|
2016-12-02 02:46:52 +01:00
|
|
|
class TLAsyncCrossingSource(sync: Int = 3)(implicit p: Parameters) extends LazyModule
|
2016-09-14 01:04:46 +02:00
|
|
|
{
|
2017-01-24 02:54:27 +01:00
|
|
|
val node = TLAsyncSourceNode(sync)
|
2016-09-14 01:04:46 +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)) =>
|
2016-10-07 23:05:34 +02:00
|
|
|
val sink_reset_n = out.a.sink_reset_n
|
2017-01-18 03:52:16 +01:00
|
|
|
val bce = edgeIn.manager.anySupportAcquireB && edgeIn.client.anySupportProbe
|
2016-09-30 02:32:18 +02:00
|
|
|
val depth = edgeOut.manager.depth
|
2016-09-14 01:04:46 +02:00
|
|
|
|
2016-10-05 07:28:56 +02:00
|
|
|
out.a <> ToAsyncBundle(in.a, depth, sync)
|
|
|
|
in.d <> FromAsyncBundle(out.d, sync)
|
2016-09-30 02:32:18 +02:00
|
|
|
|
|
|
|
if (bce) {
|
2016-10-05 07:28:56 +02:00
|
|
|
in.b <> FromAsyncBundle(out.b, sync)
|
|
|
|
out.c <> ToAsyncBundle(in.c, depth, sync)
|
|
|
|
out.e <> ToAsyncBundle(in.e, depth, sync)
|
2016-09-14 01:04:46 +02:00
|
|
|
} else {
|
|
|
|
in.b.valid := Bool(false)
|
|
|
|
in.c.ready := Bool(true)
|
|
|
|
in.e.ready := Bool(true)
|
2016-09-30 02:32:18 +02:00
|
|
|
out.b.ridx := UInt(0)
|
|
|
|
out.c.widx := UInt(0)
|
|
|
|
out.e.widx := UInt(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-02 02:46:52 +01:00
|
|
|
class TLAsyncCrossingSink(depth: Int = 8, sync: Int = 3)(implicit p: Parameters) extends LazyModule
|
2016-09-30 02:32:18 +02:00
|
|
|
{
|
2017-01-24 02:54:27 +01:00
|
|
|
val node = TLAsyncSinkNode(depth, sync)
|
2016-09-30 02:32:18 +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)) =>
|
2016-10-07 23:05:34 +02:00
|
|
|
val source_reset_n = in.a.source_reset_n
|
2017-01-18 03:52:16 +01:00
|
|
|
val bce = edgeOut.manager.anySupportAcquireB && edgeOut.client.anySupportProbe
|
2016-09-30 02:32:18 +02:00
|
|
|
|
2016-10-05 07:28:56 +02:00
|
|
|
out.a <> FromAsyncBundle(in.a, sync)
|
|
|
|
in.d <> ToAsyncBundle(out.d, depth, sync)
|
2016-09-30 02:32:18 +02:00
|
|
|
|
|
|
|
if (bce) {
|
2016-10-05 07:28:56 +02:00
|
|
|
in.b <> ToAsyncBundle(out.b, depth, sync)
|
|
|
|
out.c <> FromAsyncBundle(in.c, sync)
|
|
|
|
out.e <> FromAsyncBundle(in.e, sync)
|
2016-09-30 02:32:18 +02:00
|
|
|
} else {
|
|
|
|
in.b.widx := UInt(0)
|
|
|
|
in.c.ridx := UInt(0)
|
|
|
|
in.e.ridx := UInt(0)
|
2016-09-14 01:04:46 +02:00
|
|
|
out.b.ready := Bool(true)
|
|
|
|
out.c.valid := Bool(false)
|
|
|
|
out.e.valid := Bool(false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-29 00:11:05 +02:00
|
|
|
|
2016-09-30 10:48:47 +02:00
|
|
|
object TLAsyncCrossingSource
|
|
|
|
{
|
2017-10-27 09:45:21 +02:00
|
|
|
def apply(sync: Int = 3)(implicit p: Parameters) = LazyModule(new TLAsyncCrossingSource(sync)).node
|
2016-09-30 10:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
object TLAsyncCrossingSink
|
|
|
|
{
|
2017-10-27 09:45:21 +02:00
|
|
|
def apply(depth: Int = 8, sync: Int = 3)(implicit p: Parameters) = LazyModule(new TLAsyncCrossingSink(depth, sync)).node
|
2016-09-30 10:48:47 +02:00
|
|
|
}
|
|
|
|
|
2017-10-26 22:03:22 +02:00
|
|
|
@deprecated("TLAsyncCrossing is fragile. Use TLAsyncCrossingSource and TLAsyncCrossingSink", "rocket-chip 1.2")
|
2016-12-02 02:46:52 +01:00
|
|
|
class TLAsyncCrossing(depth: Int = 8, sync: Int = 3)(implicit p: Parameters) extends LazyModule
|
2016-09-30 02:32:18 +02:00
|
|
|
{
|
|
|
|
val source = LazyModule(new TLAsyncCrossingSource(sync))
|
|
|
|
val sink = LazyModule(new TLAsyncCrossingSink(depth, sync))
|
2017-09-23 09:04:50 +02:00
|
|
|
val node = NodeHandle(source.node, sink.node)
|
2016-09-30 02:32:18 +02:00
|
|
|
|
2017-09-23 01:55:12 +02:00
|
|
|
sink.node := source.node
|
2016-09-30 02:32:18 +02:00
|
|
|
|
|
|
|
lazy val module = new LazyModuleImp(this) {
|
2017-09-14 03:06:03 +02:00
|
|
|
val io = IO(new Bundle {
|
2016-09-30 02:32:18 +02:00
|
|
|
val in_clock = Clock(INPUT)
|
|
|
|
val in_reset = Bool(INPUT)
|
|
|
|
val out_clock = Clock(INPUT)
|
|
|
|
val out_reset = Bool(INPUT)
|
2017-09-14 03:06:03 +02:00
|
|
|
})
|
2016-09-30 02:32:18 +02:00
|
|
|
|
|
|
|
source.module.clock := io.in_clock
|
|
|
|
source.module.reset := io.in_reset
|
|
|
|
sink.module.clock := io.out_clock
|
|
|
|
sink.module.reset := io.out_reset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-29 00:11:05 +02:00
|
|
|
/** Synthesizeable unit tests */
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.unittest._
|
2016-09-29 00:11:05 +02:00
|
|
|
|
2017-05-17 20:56:01 +02:00
|
|
|
class TLRAMAsyncCrossing(txns: Int)(implicit p: Parameters) extends LazyModule {
|
2017-04-13 20:51:10 +02:00
|
|
|
val model = LazyModule(new TLRAMModel("AsyncCrossing"))
|
2017-05-17 20:56:01 +02:00
|
|
|
val fuzz = LazyModule(new TLFuzzer(txns))
|
2017-10-26 02:47:09 +02:00
|
|
|
val island = LazyModule(new CrossingWrapper(AsynchronousCrossing(8)))
|
|
|
|
val ram = island { LazyModule(new TLRAM(AddressSet(0x0, 0x3ff))) }
|
2016-09-29 00:11:05 +02:00
|
|
|
|
2017-10-27 10:13:19 +02:00
|
|
|
ram.node := island.crossTLIn := TLFragmenter(4, 256) := TLDelayer(0.1) := model.node := fuzz.node
|
2016-09-29 00:11:05 +02:00
|
|
|
|
2017-09-14 03:06:03 +02:00
|
|
|
lazy val module = new LazyModuleImp(this) with UnitTestModule {
|
2016-09-29 00:11:05 +02:00
|
|
|
io.finished := fuzz.module.io.finished
|
|
|
|
|
|
|
|
// Shove the RAM into another clock domain
|
2017-07-07 19:48:16 +02:00
|
|
|
val clocks = Module(new Pow2ClockDivider(2))
|
2017-10-26 02:47:09 +02:00
|
|
|
island.module.clock := clocks.io.clock_out
|
2016-09-29 00:11:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 20:56:01 +02:00
|
|
|
class TLRAMAsyncCrossingTest(txns: Int = 5000, timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) {
|
|
|
|
io.finished := Module(LazyModule(new TLRAMAsyncCrossing(txns)).module).io.finished
|
2016-09-29 00:11:05 +02:00
|
|
|
}
|