I'm trying to have a variable-sized array based on a Module Paramete (example below). When the size PARAM is non-zero, the code works as intended.
class HWModule (PARAM : Int) extends Module{
val my_Vec = RegInit(Vec(Seq.fill(PARAM)(0.U(32.W))))
if (PARAM > 0){
for (i <- 0 until PARAM -1){
my_Vec(i) := i.U //Example Code
}
}
}
However, when I try to have PARAM = 0, it stops working. I've tried using Patter Matching (How do I write to a conditional output) to solve the problem, but I get the following error messages (and similar ones):
Equals does not take parameters
Expression does not convert to assignment because receiver is not assignable.
My goal is to be able to remove certain portions of code when PARAM = 0, while also allowing to variable-sized instantiation of Vecs, Regs, Wires, etc. If anyone could point me to a good solution or information about it, I would appreciate it.
Thank you, Miguel Silva