Can I change the Verilog names of a Vec?

8 views
Skip to first unread message

Øyvind Harboe

unread,
Apr 1, 2021, 4:51:00 AM4/1/21
to chisel-users
If I have:

val foo = Vec(5, UInt(2.W))

can I somehow set the name of each vector entry?

io_foo_1

is less readable than:

io_foo_bar

as I have to look up in the source how 1 translates to bar while reading the Verilog. Lots of context switching and inaccessible to those who only read the Verilog.

Jack Koenig

unread,
Apr 1, 2021, 5:52:00 PM4/1/21
to chisel...@googlegroups.com
There isn't a way to set the names of Vec entries. If you want to set the names, why not just use a Bundle?

If they're all the same type, you can take advantage of multiple-declaration syntax in Scala:
class MyBundle extends Bundle {
  val a, b, c, d, e = UInt(8.W)
}

If you need more power than that, you can look at using a Record (https://www.chisel-lang.org/api/3.4.2/chisel3/Record.html). It's a power-user API so there unfortunately isn't documentation but it's like a Bundle except you implement elements and cloneType (rather than Chisel deriving them for you from the public vals)


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/3e8215c8-e56f-4def-91e5-0b26377ec2edn%40googlegroups.com.

Øyvind Harboe

unread,
Apr 1, 2021, 6:18:33 PM4/1/21
to chisel...@googlegroups.com
The Vec() in my case is used together with a Scala Enumeration.

Also, I assign sequences to the Vec(), creating  a bundle like you describe would break that and force me   to update the code everywhere if i add or remove from the enum.

So really I need the exact behavior of Vec() but to be able to use the enum name instead of the Vec() index in the Verilog.

You received this message because you are subscribed to a topic in the Google Groups "chisel-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chisel-users/V7y9mr5Um7I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chisel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chisel-users/CAFooY_T9T9LXqPv5BNJ6O%3DUHQJHvEek_p6i8Cvfbd0z%3DSRzUYA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages