-
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
base: main
Are you sure you want to change the base?
[FIRRTL] Add a BindOp #8384
Conversation
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.
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.
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.
Op findInnerSym(StringAttr name, Block *body) { | ||
for (auto &op : llvm::reverse(body->getOperations())) | ||
if (auto target = dyn_cast<Op>(op)) | ||
if (auto innerSym = target.getInnerSym()) | ||
if (innerSym->getSymName() == name) | ||
return target; | ||
return {}; | ||
} |
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 is very expensive.
Can this be changed to use verifyInnerRefs
so that this is done efficiently?
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.