Skip to content

Conversation

@Max-astro
Copy link
Contributor

This implementation is based on a tree-balancing algorithm described in this paper: "https://ieeexplore.ieee.org/abstract/document/6105357".

Here is an easy-to-understand example (Which has been added as a test case):
image

The reference algorithm has two stages, "Covering" and "Tree-balancing," divided into maximum-and-cover and aig-balance-variadic passes.

A typical usage is: circt-synth %s --maximum-and-cover --aig-balance-variadic --cse. The maximum-and-cover pass should be always applied before the aig-balance-variadic pass.

@Max-astro Max-astro changed the title Implemented AIG node balancing algorithm [circt-synthe] Implemented AIG node balancing algorithm Feb 21, 2025
@Max-astro Max-astro changed the title [circt-synthe] Implemented AIG node balancing algorithm [circt-synth] Implemented AIG node balancing algorithm Feb 21, 2025
@Max-astro Max-astro marked this pull request as draft February 21, 2025 02:45
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

Looks really great! Thank you for working on this!! It's really nice to separate the balancing into two separate passes. What do you think replacing the existing LowerVariadic pass with your BlanceVariadic pass? I think it makes sense to me always run if it's always beneficial

@Max-astro
Copy link
Contributor Author

I appreciate your feedback and suggestions. Thank you for taking the time to share your review!

What do you think replacing the existing LowerVariadic pass with your BlanceVariadic pass? I think it makes sense to me always run if it's always beneficial

The BlanceVariadic pass needs to calculate each node's depth during lowering, it might have runtime issues when the input design has very deep combinational logic. In those kinds of cases, using the existing LowerVariadic will be a good solution to get a usable result in less time. So, I think we should keep the LowerVariadic pass in case anyone has this kind of need.

@Max-astro Max-astro marked this pull request as ready for review February 22, 2025 14:04
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

Looks great, let me test this on a larger design to see if it works!

@uenoku
Copy link
Member

uenoku commented Oct 13, 2025

I'm terribly sorry for updating so so late. I will rebase and merge MaxCover pass in this PR separately. I cherry-picked changes/test cases related to balance pass in #9086 to merge existing LowerVariadic pass to basically do the balancing.

@Max-astro
Copy link
Contributor Author

I'm terribly sorry for updating so so late. I will rebase and merge MaxCover pass in this PR separately. I cherry-picked changes/test cases related to balance pass in #9086 to merge existing LowerVariadic pass to basically do the balancing.

That's fine, and I'm glad to see my implementation can be integrated into the Circt project. Will see what I can do next.
And BTW, should I close this PR?

uenoku added a commit that referenced this pull request Oct 14, 2025
This implementation is based on a tree-balancing algorithm described in
this paper: "https://ieeexplore.ieee.org/abstract/document/6105357".

Rebased from #8262.

Co-authored-by: Max Zhou <[email protected]>
uenoku added a commit that referenced this pull request Oct 14, 2025
This implementation is based on a tree-balancing algorithm described in
this paper: "https://ieeexplore.ieee.org/abstract/document/6105357".

Rebased from #8262.

Co-authored-by: Max Zhou <[email protected]>
@uenoku uenoku force-pushed the aig branch 2 times, most recently from 9f0ac86 to 4207ed7 Compare October 14, 2025 08:31
@uenoku
Copy link
Member

uenoku commented Oct 14, 2025

Tat's fine, and I'm glad to see my implementation can be integrated into the Circt project.

I really appreciate your help and sorry again for my delay. I opened #9090 to check CI passes. I can just merge #9090 or I can force-push the commit (under your name) to this PR and merge from this PR if you prefer that.

@Max-astro
Copy link
Contributor Author

Tat's fine, and I'm glad to see my implementation can be integrated into the Circt project.

I really appreciate your help and sorry again for my delay. I opened #9090 to check CI passes. I can just merge #9090 or I can force-push the commit to this PR and merge from this PR if you prefer that.

Merging the new PR seems more straightforward. That's totally OK with me, and I'll close this PR later.

uenoku added a commit that referenced this pull request Oct 14, 2025
This implementation is based on a tree-balancing algorithm described in section 3.1 in the paper: "Delay Optimization Using SOP Balancing, ICCAD 2011".

This pass performs maximum AND-cover optimization by collapsing single-fanout and-inverter ops into their users, reducing the depth of And-Inverter Graphs, combined with the lower variadic pass. The pass is integrated into the circt-synth optimization pipeline. 

Rebased from #8262.
Co-authored-by: Max Zhou <[email protected]>
@uenoku
Copy link
Member

uenoku commented Oct 14, 2025

Thanks, merged by ed501a8.

@Max-astro Max-astro closed this Oct 14, 2025
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.

2 participants