YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.5k stars 895 forks source link

Add `splitfanout` pass #4741

Open akashlevy opened 1 week ago

akashlevy commented 1 week ago

What are the reasons/motivation for this change?

This PR adds a splitfanout pass that splits cells with fanout > 1 into copies, each with fanout 1. It is effectively the opposite of opt_merge and is useful for (1) enabling optimizations that cannot work when there is fanout, (2) splitting high fanout cells/nets that might cause problems in PD.

The pass can operate on selections and has a -limit flag to selectively operate on cells with fanout < specified limit. It does not operate on "bit-split" cells (word-level cells where different bits of the word have different/non-contiguous destinations), so splitcells should be run first if fanout splitting is desired for such cells.

Explain how this is achieved.

The pass works by building a database of drivers and loads, then operating in reverse topological order on selected cells. It checks that each cell is not "bit-split", then makes a copy to drive each load. The original cell is used to drive the final load.

If applicable, please suggest to reviewers how they can test the change.