Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIRRTL] Add doNotPrint flag to InstanceOp #8331

Merged
merged 1 commit into from
Apr 2, 2025

Conversation

rwy7
Copy link
Contributor

@rwy7 rwy7 commented Mar 19, 2025

This flag acts the same as doNotPrint in hardware. When lowering an instance to the hw dialect, copy the doNotPrint attribute over.

I am preparing to add a bind op to the firrtl dialect (not the frontend language), which will pair with this flag. My goal is to allow lower-layers to place the bind op for layerblocks into the body of a bind file, which is represented by an emit.file op.

@rwy7 rwy7 added the FIRRTL Involving the `firrtl` dialect label Mar 19, 2025
@rwy7 rwy7 force-pushed the instance-do-not-print branch from 6a58a2a to 4eb67c4 Compare March 20, 2025 14:14
This flag acts the same as doNotPrint in hardware. When lowering an instance to
the hw dialect, copy the doNotPrint attribute over.
@rwy7 rwy7 force-pushed the instance-do-not-print branch from 4eb67c4 to e2f927b Compare March 20, 2025 14:40
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is practical.

However, doNotPrint feels a little weak. Specifically, what does this mean if there is no bind op? Will this just cause the instance to not show up in Verilog and won't that allow for the creation of illegal circuits?

Would one of the following be a better way to model this?

  • There is a dedicated bind instance op which takes a symbol/inner symbol that must resolve to op in an emit region. This lookup would likely hing on the ability to do nested symbol lookups into the emit.file:
emit.file "bind.sv" sym @Bind {
  firrtl.bind @a
}

firrtl.module @Foo {
  firrtl.instance.bind bar @Bar() {bindLocation = @Bind::a}
}
  • The referencing in the above is inversed to allow for the firrtl.bind to refer to the firrtl.instance.bind. This may be hard as it looks like emit.file has a symbol table and would therefore need to opt into inner symbol tables to make this work.

Could you elaborate a bit on what the full solution would look like?

Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the offline discussion of where this is going. This will give us finer control over where the bind op is going to live which is what we need.

In the follow-on that adds a firrtl.bind, as long as this removes lowerToBind, this makes sense to me.

@rwy7 rwy7 merged commit f1386fc into llvm:main Apr 2, 2025
5 checks passed
@rwy7 rwy7 deleted the instance-do-not-print branch April 2, 2025 16:18
@rwy7
Copy link
Contributor Author

rwy7 commented Apr 2, 2025

Opened an issue to track the work for "removing lowerToBind": #8386
The PR to add a bind op is here: #8384

I'll remove the lowerToBind flag in a later PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIRRTL Involving the `firrtl` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants