From be424633c1d72ac0a4a8b76146f818c12b0fcf13 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Thu, 4 Feb 2016 15:26:42 -0800 Subject: [PATCH] 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 {