Duplicating of Modules

13 views
Skip to first unread message

Arsh G

unread,
Dec 5, 2023, 9:19:28 AM12/5/23
to chisel-users
Hi,

I'm trying to instantiate multiple instances of the same module in chisel for example

val X1   = Module(new Y(proto= ...))
val X2   = Module(new Y(proto= ...))
val X3   = Module(new Y(proto= ...))
val X4   = Module(new Y(proto= ...))
...
upto n times
I've tried mapping them to List, so
val X   = Module(new Y(proto= ...))
val Y  = (0 until n).map(x => X).toList

The chisel compiles but when I do hardware simulation I can only see one module not multiple ones in this method.

Can someone point out why this is happening, I've tried googling but of no help ? :(

Thank you


Edward Wang

unread,
Dec 5, 2023, 10:06:55 AM12/5/23
to chisel-users
Hi,


Additionally, are all the modules used? FIRRTL/CIRCT I believe will remove unused hardware elements so that might be another possibility.

Kevin Laeufer

unread,
Dec 5, 2023, 10:33:24 AM12/5/23
to chisel...@googlegroups.com
Something that might also be worth trying is:

val Y = (0 until n).map(_ => Module(new Y(proto= ...))).toList

The difference here is that this now calls the constructor n times.
The previous version was just copying the _reference_ to the module n
times. I.e., you got n references to the same module instance.

- Kevin
> --
> You received this message because you are subscribed to the Google
> Groups "chisel-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to chisel-users...@googlegroups.com
> <mailto:chisel-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/chisel-users/71a45d8a-b431-4587-a730-8567998db82dn%40googlegroups.com <https://groups.google.com/d/msgid/chisel-users/71a45d8a-b431-4587-a730-8567998db82dn%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages