Specifying Verilog module names

175 views
Skip to first unread message

Øyvind Harboe

unread,
Mar 29, 2021, 4:01:32 AM3/29/21
to chisel-users
Is there a way to specify the Verilog module names?

Good names make it easier to navigate the Verilog in downstream tools.



Cheers,

waleed....@iiu.edu.pk

unread,
Mar 29, 2021, 5:19:54 AM3/29/21
to chisel-users
You can do it through annotation by mapping the module name-in-chisel to your desired module name-in-verilog
Try something like

import chisel3.experimental.{annotate, ChiselAnnotation}
annotate(new ChiselAnnotation { def toFirrtl = CustomRename(Map("Queue", "QueueWithBetterName")) })

Maybe this would help

Øyvind Harboe

unread,
Mar 31, 2021, 10:28:14 AM3/31/21
to chisel-users
This looks promising, but I wasn't able to guess all the import needed for CustomRename

Where would I start reading docs on this?

Jack Koenig

unread,
Mar 31, 2021, 2:23:33 PM3/31/21
to chisel...@googlegroups.com
I'm not sure what exactly Waleed is referring to, but for modules that you write, you can override desiredName to influence the Verilog module naming: https://www.chisel-lang.org/chisel3/docs/explanations/naming#set-a-module-name

It's generally a good idea to use parameters in naming common modules (to avoid collisions and thus numerical suffix instability).

--
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/01900616-c827-4f32-9b8c-61f0d496ad00n%40googlegroups.com.

Øyvind Harboe

unread,
Apr 1, 2021, 3:54:57 AM4/1/21
to chisel-users
Thanks!

I want to name the Verilog based upon parameter names to the module.

However, the documentation says "If you want to specify the module’s name (not the instance name of a module)"

It's unclear to me what the difference between module name and instance name is.

What are the requirements for instance names?

Is it enough that that a combination of parameters generates a unique name and always the same name for the same parameters?

Non-sequitor: google can see these pages, but apparently there's not a lot of links to them...  I should have read these docs before obviously.



Jack Koenig

unread,
Apr 1, 2021, 6:45:33 PM4/1/21
to chisel...@googlegroups.com
The previous section in that doc talks about how to set the instance name (although does not include an example): https://www.chisel-lang.org/chisel3/docs/explanations/naming#suggest-a-signals-name-or-the-instance-name-of-a-module

The instance name is the name of the Module within its parent

class MyModule extends Module {
  ...

  val myQueue = Module(new Queue(...))
}

myQueue is the instance name of a module who's module name is Queue (probably with some _# suffix due to collisions).

The docs could be a little more clear on these distinctions, if you have any thoughts/suggestions, feel free to PR some changes https://github.com/chipsalliance/chisel3/blob/master/docs/src/explanations/naming.md and we can discuss on the PR

Øyvind Harboe

unread,
Apr 2, 2021, 2:14:06 AM4/2/21
to chisel...@googlegroups.com
Aha!

I think about "instance name" as an identifier name.

Scala uses identifier too, it seems like "identifier" is the term of art for any language I quickly checked.  Looks like Verilog too uses identifier.



To me it would be clearer if the documentation talked about setting the name of the identifier of wires, registers and modules in Verilog.

It would also be helpful with a reference to Verilog language documentation site where users can bottom out on Verilog terminology, etc.





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/pouP3Fr3LxQ/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_R_WDZx9_j5Vm5qhOxKacJN88MVtAweJuHntLms0v7HGg%40mail.gmail.com.


--
Øyvind Harboe
+4791786146
Reply all
Reply to author
Forward
0 new messages