From def497861b2ad2dd8594f791f99159e2f54fc934 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Wed, 21 Sep 2016 12:04:52 -0700 Subject: [PATCH] tilelink2 Bundles: add 1-way snoop bundles --- src/main/scala/uncore/tilelink2/Bundles.scala | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/main/scala/uncore/tilelink2/Bundles.scala b/src/main/scala/uncore/tilelink2/Bundles.scala index 128c5070..19fb48a8 100644 --- a/src/main/scala/uncore/tilelink2/Bundles.scala +++ b/src/main/scala/uncore/tilelink2/Bundles.scala @@ -2,8 +2,8 @@ package uncore.tilelink2 -import Chisel._ -import chisel3.util.Irrevocable +import chisel3._ +import chisel3.util._ abstract class GenericParameterizedBundle[T <: Object](val params: T) extends Bundle { @@ -12,7 +12,7 @@ abstract class GenericParameterizedBundle[T <: Object](val params: T) extends Bu this.getClass.getConstructors.head.newInstance(params).asInstanceOf[this.type] } catch { case e: java.lang.IllegalArgumentException => - throwException("Unable to use GenericParameterizedBundle.cloneType on " + + throw new Exception("Unable to use GenericParameterizedBundle.cloneType on " + this.getClass + ", probably because " + this.getClass + "() takes more than one argument. Consider overriding " + "cloneType() on " + this.getClass, e) @@ -189,3 +189,46 @@ object TLBundle { def apply(params: TLBundleParameters) = new TLBundle(params) } + +class IrrevocableSnoop[+T <: Data](gen: T) extends Bundle +{ + val ready = Bool() + val valid = Bool() + val bits = gen.asOutput + + def fire(dummy: Int = 0) = ready && valid + override def cloneType: this.type = new IrrevocableSnoop(gen).asInstanceOf[this.type] +} + +object IrrevocableSnoop +{ + def apply[T <: Data](i: IrrevocableIO[T]) = { + val out = Wire(new IrrevocableSnoop(i.bits)) + out.ready := i.ready + out.valid := i.valid + out.bits := i.bits + out + } +} + +class TLBundleSnoop(params: TLBundleParameters) extends TLBundleBase(params) +{ + val a = new IrrevocableSnoop(new TLBundleA(params)) + val b = new IrrevocableSnoop(new TLBundleB(params)) + val c = new IrrevocableSnoop(new TLBundleC(params)) + val d = new IrrevocableSnoop(new TLBundleD(params)) + val e = new IrrevocableSnoop(new TLBundleE(params)) +} + +object TLBundleSnoop +{ + def apply(x: TLBundle) = { + val out = Wire(new TLBundleSnoop(x.params)) + out.a := IrrevocableSnoop(x.a) + out.b := IrrevocableSnoop(x.b) + out.c := IrrevocableSnoop(x.c) + out.d := IrrevocableSnoop(x.d) + out.e := IrrevocableSnoop(x.e) + out + } +}