-
Notifications
You must be signed in to change notification settings - Fork 789
Clock gating #7773
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
Merged
Merged
Clock gating #7773
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
211e65d
rmp: cut: Move logic cut/extractor to a new module
jbylicki cbb9e28
cgt: Clock gating
kbieganski b4e0d6a
cut: Only make MIO library once
kbieganski eb1ee9c
cgt: cut: Do not remove primary outputs
kbieganski 8d521b3
cgt: Fix Python API
kbieganski 89654a3
cgt: Add missing lib in CMakeLists
kbieganski 4ff1cfd
cgt: Only init ABC once
kbieganski 88bce45
cgt: Use `DebugScopedTimer` instead of a custom one
kbieganski 0fb495e
cgt: Wrap ABC vectors in smart pointers
kbieganski bec7768
cgt: Error on multi-bit flip flops
kbieganski c8da7f3
cgt: rmp: Move `.abc_history` Git ignore to root
kbieganski 16d0faa
cgt: Warn on unsupported clock gates
kbieganski 70f5440
cgt: Disable layering check in Bazel
kbieganski 654a5f2
cgt: Add missing test files to Bazel
kbieganski f304279
rmp: Add docs for `resynth`
kbieganski b778e55
utl: Fix formatting
kbieganski 4ad95b9
Merge remote-tracking branch 'origin/master' into cgt
kbieganski 9dfb10e
cgt: Fix iterator memory leaks
kbieganski 361115b
cgt: Do not generate unique names for nets
kbieganski c9a6bbf
cgt: Use `utl::UniqueName`
kbieganski d642179
cgt: Fix and test Tcl params
kbieganski 1a27887
cut: rmp: Link to sky130hd directory
kbieganski 8de11b0
cgt: Remove dead code
kbieganski dc0cdb2
cgt: Check debug level fewer times
kbieganski 2d2c940
Merge remote-tracking branch 'origin/master' into cgt
kbieganski 449bc46
Merge remote-tracking branch 'origin/master' into cgt
kbieganski d67780e
cgt: Export more downstream nets
kbieganski 884bde9
cgt: Check that gated nets are the same clocks
kbieganski 481aef4
Merge remote-tracking branch 'origin/master' into cgt
kbieganski c7a8700
cgt: Error on gating distinct clocks
kbieganski 9863b2c
cgt: Fix argument name
kbieganski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ TAGS | |
| Makefile | ||
| __pycache__ | ||
| venv/ | ||
| .abc_history | ||
|
|
||
| include/ord/Version.hh | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| test/results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright (c) 2025, The OpenROAD Authors | ||
|
|
||
| load("//bazel:tcl_encode_or.bzl", "tcl_encode") | ||
| load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc") | ||
|
|
||
| package( | ||
| default_visibility = ["//:__subpackages__"], | ||
| # ABC headers have duplicate declarations which cause warnings/compile errors. | ||
| # This was solved by including more specific individual headers, but those are private, so the layering check is disabled. | ||
| # features = ["layering_check"], | ||
| ) | ||
|
|
||
| cc_library( | ||
| name = "cgt", | ||
| srcs = [ | ||
| "src/ClockGating.cpp", | ||
| "src/MakeClockGating.cpp", | ||
| "src/NetworkBuilder.cpp", | ||
| ":swig", | ||
| ":tcl", | ||
| ], | ||
| hdrs = [ | ||
| "include/cgt/ClockGating.h", | ||
| "include/cgt/MakeClockGating.h", | ||
| "include/cgt/NetworkBuilder.h", | ||
| "include/cgt/RandomBits.h", | ||
| ], | ||
| includes = [ | ||
| "include", | ||
| ], | ||
| deps = [ | ||
| "//:ord", | ||
| "//src/odb", | ||
| "//src/dbSta", | ||
| "//src/sta:opensta_lib", | ||
| "//src/cut", | ||
| "//src/utl", | ||
| "@boost.stacktrace", | ||
| "@edu_berkeley_abc//:abc-lib", | ||
| "@tk_tcl//:tcl", | ||
| ], | ||
| ) | ||
|
|
||
| tcl_encode( | ||
| name = "tcl", | ||
| srcs = [ | ||
| "src/cgt.tcl", | ||
| ], | ||
| char_array_name = "cgt_tcl_inits", | ||
| namespace = "cgt", | ||
| ) | ||
|
|
||
| tcl_wrap_cc( | ||
| name = "swig", | ||
| srcs = [ | ||
| "src/cgt.i", | ||
| "//:error_swig", | ||
| ], | ||
| module = "cgt", | ||
| namespace_prefix = "cgt", | ||
| root_swig_src = "src/cgt.i", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ## SPDX-License-Identifier: BSD-3-Clause | ||
| ## Copyright (c) 2025, The OpenROAD Authors | ||
|
|
||
| add_subdirectory(src) | ||
|
|
||
| if (ENABLE_TESTS) | ||
| add_subdirectory(test) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Clock gating | ||
|
|
||
| This module provides automatic insertion of clock gates for reducing power usage. | ||
| It uses ABC for proving correctness of gating conditions. | ||
|
|
||
| The process is roughly: | ||
| 1. For each register: | ||
| a. Gather nets connected to the register via BFS (limited to 100 nets for performance, user configurable). | ||
| If it encounters a register, it doesn't go through it; it stops there and goes in different directions. | ||
| b. Check if a previously accepted gating condition can be reused; if so, add this register to that condition's list of registers. | ||
| c. Export the network gathered in (a) to ABC. | ||
| d. Check if all the nets in the exported network can form a correct gating condition using ABC. | ||
| - First, simulation with random stimuli quickly looks for counterexamples. | ||
| - Then, if no counterexample was found, a SAT solver is employed to prove that the gating condition is correct. | ||
| A clock enable condition is checked by ORing the nets, and a clock disable condition by ANDing them. | ||
| e. If the set of all nets doesn't form a correct gating condition, move on to the next register. | ||
| Otherwise: | ||
| - Check if after removing half of the nets the gating condition still works. | ||
| - If so, drop the other half of the nets. Otherwise, recurse into the other half of the nets to minimize that subset. | ||
| - Then, recurse into the first half of the nets to minimize that part. | ||
| This produces a minimal set of nets that form a gating condition (not necessarily optimal). | ||
| f. Add the minimal set of nets with the corresponding gated register to a list of accepted gating conditions. | ||
| First check if it doesn't contain it already; if it does, add the gated register to the pre-existing condition's list of registers. | ||
| 2. For each accepted gating condition with at least 10 corresponding registers (user-configurable), | ||
| insert a new clock gate that gates the corresponding registers under this condition. | ||
|
|
||
| Usage: | ||
|
|
||
| ```tcl | ||
| read_liberty path/to/pdk/cell/library.lib | ||
| read_db path/to/your/design.odb | ||
| read_sdc path/to/your/constraints.sdc | ||
|
|
||
| clock_gating | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| ```{note} | ||
| All parameters for clock gating are optional, as indicated by square brackets: `[-param param]`. | ||
| ``` | ||
|
|
||
| ### Clock gating | ||
|
|
||
| ```tcl | ||
| clock_gating | ||
| [-min_instances min_instances] | ||
| [-max_cover max_cover] | ||
| [-dump_dir dump_dir] | ||
| ``` | ||
|
|
||
| #### Options | ||
|
|
||
| | Switch Name | Description | | ||
| | ----- | ----- | | ||
| | `-min_instances` | Minimum number of instances that should be gated by a single clock gate. | | ||
| | `-max_cover` | Maximum number of initial gate condition candidate nets per instance. | | ||
| | `-dump_dir` | Directory for debug dumps. | | ||
|
|
||
| ## Example scripts | ||
|
|
||
| Example script on running `cgt` for a sample design of `aes` can be found here: | ||
|
|
||
| ``` | ||
| ./test/aes_nangate45.tcl | ||
| ``` | ||
|
|
||
| ## Regression tests | ||
|
|
||
| There are a set of regression tests in `./test`. For more information, refer to this [section](../../README.md#regression-tests). | ||
|
|
||
| Simply run the following script: | ||
|
|
||
| ```shell | ||
| ./test/regression | ||
| ``` | ||
|
|
||
| ## Limitations | ||
|
|
||
| Clock gating is currently not available for designs that contain HA and FA cells which are not supported by ABC. | ||
|
|
||
| ## FAQs | ||
|
|
||
| Check out [GitHub discussion](https://github.com/The-OpenROAD-Project/OpenROAD/discussions/categories/q-a?discussions_q=category%3AQ%26A+clock-gating) | ||
| about this tool. | ||
|
|
||
| ## References | ||
|
|
||
| 1. Aaron P. Hurst. 2008. Automatic synthesis of clock gating logic with controlled netlist perturbation. In Proceedings of the 45th annual Design Automation Conference (DAC '08). Association for Computing Machinery, New York, NY, USA, 654–657. https://doi.org/10.1145/1391469.1391637 | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.