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

[Transforms][circt-synth] Add HierarchicalRunner pass #8254

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Feb 18, 2025

Add a new pass that allows running passes under hierarchy. This is useful when we want to run synthesis passes only on real designs.

This implementation is based on MLIR's upstream CompositePass and Inliner utilities. The pass takes a pipeline string and runs it on modules in the design hierarchy. It supports configurable options including the pipeline to run under hierarchy, the name of the top-level module, and whether to include bound instances in the hierarchy traversal.

The implementation updates circt-synth tool with the required library dependencies and necessary dialect and pass headers.

Add a new pass that allows running passes under hierarchy. This is useful when
we want to run synthesis passes only on real designs.

This implementation is based on MLIR's upstream CompositePass and Inliner utilities.
The pass takes a pipeline string and runs it on modules in the design hierarchy.
It supports configurable options including the pipeline to run under hierarchy,
the name of the top-level module, and whether to include bound instances in
the hierarchy traversal.

The implementation updates circt-synth tool with the required library
dependencies and necessary dialect and pass headers.
Copy link
Contributor

@Max-astro Max-astro left a comment

Choose a reason for hiding this comment

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

Running different passes by module hierarchy is a valuable feature, especially when a designer wants to ungroup (inline) certain kinds of modules by some rules. It's good to know you implemented this feature. Nice job!

Comment on lines 88 to 90
auto *node = worklist.pop_back_val();
if (!node)
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious about the pop-out node. In what situation will it be nullptr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah good point. It wouldn't be possible.

for (auto *child : *node) {
auto childOp = child->getInstance();
if (!childOp ||
(!includeBoundInstances && childOp->hasAttr("doNotPrint")))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the "doNotPrint" attribute have the same semantics as "set_dont_touch" in SDC?

Copy link
Member Author

Choose a reason for hiding this comment

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

"doNotPrint" is used for instances instantiated by SystemVerilog bind. Normally they won't be instantiated in the synthesizable parts. It's not good that we are relying on this vaguely defined attribute, and we have wanted to fix (See #2231) but no effort has been made so far.

Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! Nice idea to use the instance graph to only run a bunch of passes on a specific hierarchy 👍

Just out of curiosity: have you come across any uses of this in the wild?

@uenoku
Copy link
Member Author

uenoku commented Feb 28, 2025

Thank you for the review!

Just out of curiosity: have you come across any uses of this in the wild?

It's generally necessary for circt-synth to skip verification code. Sometimes verification code has constructs that are hard to synthesize such as 32bit div/mod. Also it saves a lot of resources when targeting sub hierarchy.

@uenoku uenoku merged commit a5ad496 into main Feb 28, 2025
5 checks passed
@uenoku uenoku deleted the dev/hidetou/hier branch February 28, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants