2016-09-30 10:49:46 +02:00
|
|
|
// See LICENSE for license details.
|
|
|
|
|
|
|
|
package uncore.tilelink2
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import chisel3.internal.sourceinfo.SourceInfo
|
|
|
|
|
2016-09-30 13:54:40 +02:00
|
|
|
class TLIsolation(f: (Bool, UInt) => UInt) extends LazyModule
|
2016-09-30 10:49:46 +02:00
|
|
|
{
|
|
|
|
val node = TLAsyncIdentityNode()
|
|
|
|
|
|
|
|
lazy val module = new LazyModuleImp(this) {
|
|
|
|
val io = new Bundle {
|
|
|
|
val in = node.bundleIn
|
|
|
|
val out = node.bundleOut
|
2016-09-30 13:54:40 +02:00
|
|
|
val iso = Bool(INPUT)
|
2016-09-30 10:49:46 +02:00
|
|
|
}
|
|
|
|
|
2016-09-30 13:54:40 +02:00
|
|
|
def ISO[T <: Data](x: T): T = x.fromBits(f(io.iso, x.asUInt))
|
2016-09-30 10:49:46 +02:00
|
|
|
|
|
|
|
((io.in zip io.out) zip (node.edgesIn zip node.edgesOut)) foreach { case ((in, out), (edgeIn, edgeOut)) =>
|
|
|
|
|
|
|
|
out.a.mem := ISO(in.a.mem)
|
|
|
|
out.a.widx := ISO(in.a.widx)
|
|
|
|
in.a.ridx := ISO(out.a.ridx)
|
|
|
|
out.d.ridx := ISO(in.d.ridx)
|
|
|
|
in.d.widx := ISO(out.d.widx)
|
|
|
|
in.d.mem := ISO(out.d.mem)
|
|
|
|
|
|
|
|
if (edgeOut.manager.base.anySupportAcquire && edgeOut.client.base.anySupportProbe) {
|
|
|
|
in.b.widx := ISO(out.b.widx)
|
|
|
|
in.c.ridx := ISO(out.c.ridx)
|
|
|
|
in.e.ridx := ISO(out.e.ridx)
|
|
|
|
out.b.ridx := ISO(in.b.ridx)
|
|
|
|
out.c.widx := ISO(in.c.widx)
|
|
|
|
out.e.widx := ISO(in.e.widx)
|
|
|
|
in.b.mem := ISO(out.b.mem)
|
|
|
|
out.c.mem := ISO(in.c.mem)
|
|
|
|
out.e.mem := ISO(in.e.mem)
|
|
|
|
} else {
|
|
|
|
in.b.widx := UInt(0)
|
|
|
|
in.c.ridx := UInt(0)
|
|
|
|
in.e.ridx := UInt(0)
|
|
|
|
out.b.ridx := UInt(0)
|
|
|
|
out.c.widx := UInt(0)
|
|
|
|
out.e.widx := UInt(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
object TLIsolation
|
|
|
|
{
|
|
|
|
// applied to the TL source node; y.node := TLIsolation()(x.node)
|
|
|
|
// f should insert an isolation gate between the input UInt and its result
|
2016-09-30 13:54:40 +02:00
|
|
|
def apply(f: (Bool, UInt) => UInt)(x: TLAsyncOutwardNode)(implicit sourceInfo: SourceInfo): (TLAsyncOutwardNode, () => Bool) = {
|
2016-09-30 10:49:46 +02:00
|
|
|
val iso = LazyModule(new TLIsolation(f))
|
|
|
|
iso.node := x
|
2016-09-30 13:54:40 +02:00
|
|
|
(iso.node, () => iso.module.io.iso)
|
2016-09-30 10:49:46 +02:00
|
|
|
}
|
|
|
|
}
|