[chisel/scala] Create an array of Modules
What I want to do
I have a class (parts) that I created and that inherits from Module.
I want to place multiple instances (components) of this class in a circuit.
What I tried
I tried to create an array using Vec, but it didn't work.
When I write code like this, the following compilation error occurs:
class MyParts extends Module{
val io = IO(・・・)
}
val parts:Vec[Module] = VecInit(Seq.fill(3)(Module(new MyParts)))
overloaded method apply with alternatives:
[error] [T <: chisel3.Data](elt0: T, elts: T*): chisel3.Vec[T] <and>
[error] [T <: chisel3.Data](elts: Seq[T]): chisel3.Vec[T]
[error] cannot be applied to (Seq[MyParts])
Solution
In the end, Vec is not necessary, just use Seq.
val parts = Seq.fill(3)(Module(new MyParts))
At first, I misunderstood that "Seq cannot have chisel hardware as an element, so I need to use Vec for that."
In fact, "In Seq, chisel types cannot be used as indexes to access array elements." ( Reference ) is accurate.
Recent Posts
See AllPhenomenon There is an array Check whether the index variable is within the size of the array, and access the element only if it is...
Overview When communicating data using a Queue, the following operations are possible: Queue.io.enq.valid: When set to false, data will...
What I want to do There are multiple similar units Most of processes are the same, only some differences. Select an appropriate unit...
Comments