-
Notifications
You must be signed in to change notification settings - Fork 337
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 a BindOp #8384
[FIRRTL] Add a BindOp #8384
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with the approach. I have a question about efficient verification.
lib/Dialect/FIRRTL/FIRRTLOps.cpp
Outdated
if (!inst.getDoNotPrint()) | ||
return emitError("Referenced instance isn't marked as doNotPrint"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
pairs with a `firrtl.instance` which tracks all information except the | ||
emission point for the bind. | ||
|
||
See `sv.bind` for the system verilog equivalent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the PR include a note that this is only used to aid in lowering and for allow for tracking of where a SystemVerilog bind op will be located (in what file). Essentially, include some of the great PR text here about the motivation for this.
return emitError() << "target " << ref << " is not marked doNotPrint"; | ||
|
||
return success(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great.
Currently, FIRRTL instances may be marked as "lowerToBind", which is then lowered to a HW instance marked "doNotPrint", along with a bind op in the global scope. This PR adds a bind op to FIRRTL, which in conjunction with the "doNotPrint" flag on FIRRTL instances, allows us to choose precisely where the bind operation goes, rather than having lowerToHW choose for us.
The PR adds a firrtl.bind op. This new bind op is lowered directly to an sv.bind op in LowerToHW.
Today, we create binds by marking firrtl.instance ops as "lowerToBind", which cues LowerToHW to create an SV BindOp for us in the top-level scope, once the marked instance has been lowered to hw.
The reason for a bind op in the FIRRTL dialect, is so that FIRRTL passes can choose the placement of the bind op, such as under an sv.ifdef or emit.file op (which is required for the lowering of bound-in layerblocks). The sv.bind op can only target hw.modules ops, while this new firrtl.bind op targets firrtl.module ops. There are no plans to add bind statements to the FIRRTL surface language. This is just an intermediate lowering for layers.