From be424633c1d72ac0a4a8b76146f818c12b0fcf13 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 4 Feb 2016 15:26:42 -0800 Subject: [PATCH 1/2] Improve ParamaterizedBundle.cloneType()'s error messages Without this it's really hard to read the IllegalArgumentException that you get if you subclass ParamaterizedBundle and don't define a matching cloneType(). --- junctions/src/main/scala/util.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/junctions/src/main/scala/util.scala b/junctions/src/main/scala/util.scala index 865d63b5..28d5a470 100644 --- a/junctions/src/main/scala/util.scala +++ b/junctions/src/main/scala/util.scala @@ -8,7 +8,17 @@ object bigIntPow2 { } class ParameterizedBundle(implicit p: Parameters) extends Bundle { - override def cloneType = this.getClass.getConstructors.head.newInstance(p).asInstanceOf[this.type] + override def cloneType = { + try { + this.getClass.getConstructors.head.newInstance(p).asInstanceOf[this.type] + } catch { + case e: java.lang.IllegalArgumentException => + throwException("Unable to use ParamaterizedBundle.cloneType on " + + this.getClass + ", probably because " + this.getClass + + "() takes more than one argument. Consider overriding " + + "cloneType() on " + this.getClass, e) + } + } } class HellaFlowQueue[T <: Data](val entries: Int)(data: => T) extends Module { From 62257e0b0472e4fb2efb6b6adc28096cd6fabd18 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 4 Feb 2016 15:28:46 -0800 Subject: [PATCH 2/2] Uncomment MemSerializedIO.cloneType() Not sure why this was commented, but when I build this against Chisel3 it fails without this override. --- junctions/src/main/scala/memserdes.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/junctions/src/main/scala/memserdes.scala b/junctions/src/main/scala/memserdes.scala index 52abf3c3..b66e5150 100644 --- a/junctions/src/main/scala/memserdes.scala +++ b/junctions/src/main/scala/memserdes.scala @@ -57,7 +57,7 @@ class MemPipeIO(implicit p: Parameters) extends ParameterizedBundle()(p) { class MemSerializedIO(w: Int)(implicit p: Parameters) extends ParameterizedBundle()(p) { val req = Decoupled(Bits(width = w)) val resp = Valid(Bits(width = w)).flip - //override def cloneType = new MemSerializedIO(w)(p).asInstanceOf[this.type] + override def cloneType = new MemSerializedIO(w)(p).asInstanceOf[this.type] } class MemSerdes(w: Int)(implicit p: Parameters) extends MIFModule