I have a module like below:
class ComputationIO[T <: Data](val OperandType: T) extends Bundle {
val data = OperandType.cloneType
}
class Computation [T <: Data] (OperandType: T) extends Module {
val io = IO( new Bundle {
val in = Input(new ComputationIO(OperandType))
})
// REST OF THE CODE HERE...
}
And, I'm instantiating the Computation like below:
val compUnit = for (i <- 0 until nParal) yield {
val Comp = Module(new Computation(UInt(32.W)))
Comp
}
However, although I'm passing UInt(32.W) to the constructor, it gives me the following error:
firrtl.passes.CheckInitialization$RefNotInitializedException:Reference compUnit is not fully initialized.
[error] : compUnit.io.in.OperandType <= VOID
I can solve the problem by removing the val in the IO class and overriding the cloneType, sth like below:
class ComputationIO[T <: Data](OperandType: T) extends Bundle {
val data = OperandType.cloneType
override def cloneType = new ComputationIO(OperandType).asInstanceOf[this.type ]
}
But, I was wondering what is the problem of the first approach? The constructor has been initialized. So, the not fully initialized error doesn't make sense.
Thanks