1
0

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().
This commit is contained in:
Palmer Dabbelt 2016-02-04 15:26:42 -08:00
parent 60d9291cb5
commit be424633c1

View File

@ -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 {