Skip to content

synth: add INFER_CLKGATES_MIN_NET_SIZE and INFER_CLKGATES_EXCLUDE - #4821

Open
oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:infer-clkgates-min-net-size-exclude
Open

oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:infer-clkgates-min-net-size-exclude

Conversation

@oharboe

@oharboe oharboe commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Builds on INFER_CLKGATES (#4425) and POS_CLKGATE_AND_PORTS/NEG_CLKGATE_AND_PORTS (#4448) with two controls over which flip-flops it gates.

Before: INFER_CLKGATES=1 gates every group of flip-flops that share a clock and an enable, however small, in every module. A clock gating cell for a handful of flops costs more than the enable muxes it removes, and a module whose enable logic is timing-critical is better left ungated. On asap7, ICG* is always in DONT_USE_CELLS, so the ICGs that inference inserts cannot be sized by OpenROAD.

Now:

  • INFER_CLKGATES_MIN_NET_SIZE passes -min_net_size to yosys' clockgate: smaller groups keep their enable flip-flops.
  • INFER_CLKGATES_EXCLUDE takes yosys module name patterns that clockgate leaves out of its selection (* <pattern> %d ...). Only modules that still exist at inference can be excluded, i.e. with SYNTH_HIERARCHICAL or SYNTH_KEEP_MODULES.
  • asap7 keeps ICG* in DONT_USE_CELLS unless INFER_CLKGATES=1.

Both variables are unset by default and only take effect with INFER_CLKGATES=1; a flow that sets neither is unchanged. variables.yaml, variables.json and FlowVariables.md (regenerated) document them.

Demo, asap7/aes synthesis (yosys 0.64), ICG instances in 1_2_yosys.v:

settings clockgate call (liberty args omitted) ICGs
INFER_CLKGATES=1 clockgate 3
+ INFER_CLKGATES_MIN_NET_SIZE=64 clockgate -min_net_size 64 1
INFER_CLKGATES=1 SYNTH_KEEP_MODULES=aes_key_expand_128 clockgate 3, in aes_cipher_top
+ INFER_CLKGATES_EXCLUDE=aes_key_expand_128 clockgate * aes_key_expand_128 %d 3, in aes_cipher_top
+ INFER_CLKGATES_EXCLUDE=aes_cipher_top clockgate * aes_cipher_top %d 0

Without INFER_CLKGATES the abc call carries -dont_use ICG* as before; with it, ICG* is gone from the list.

yamlfix, generate-variables-docs.py, tclint and tclfmt are clean.

Open points for review:

  • The liberty selection path does not pass DONT_USE_CELLS to clockgate (as before this PR); the asap7 change makes that moot there.
  • yosys' clockgate skips flip-flops whose synchronous reset has priority over the enable, so those stay ungated. Gating them needs the reset ORed into the ICG enable, which is a yosys change, not part of this PR.

🤖 Generated with Claude Code

INFER_CLKGATES gates every group of flip-flops sharing a clock and an
enable, however small, and in every module. A clock gating cell for a
handful of flops costs more than the enable muxes it removes, and a
module whose enable logic is timing-critical is better left ungated.

INFER_CLKGATES_MIN_NET_SIZE passes -min_net_size to yosys' clockgate, so
smaller groups keep their enable flip-flops. INFER_CLKGATES_EXCLUDE
takes module name patterns that clockgate leaves out of its selection;
only modules still present at inference (SYNTH_HIERARCHICAL,
SYNTH_KEEP_MODULES) can be excluded. Both are unset by default and only
take effect with INFER_CLKGATES=1.

On asap7, ICG* stays in DONT_USE_CELLS unless INFER_CLKGATES=1, so the
clock gating cells that inference inserts can be sized by OpenROAD.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two new configuration variables, INFER_CLKGATES_EXCLUDE and INFER_CLKGATES_MIN_NET_SIZE, to allow fine-grained control over clock gating inference in Yosys. It updates the documentation, variable definitions, and synthesis scripts to support these variables. Additionally, the ASAP7 platform configuration is updated to conditionally allow the use of integrated clock gating (ICG) cells when clock gate inference is enabled. Feedback on the changes suggests a more robust way to parse the space-separated INFER_CLKGATES_EXCLUDE variable in Tcl to prevent parsing errors when patterns contain special characters like brackets.

Comment thread flow/scripts/synth.tcl Resolved
variables.json is unused and The-OpenROAD-Project#4805 deletes it; editing it here only
causes conflicts. variables.yaml carries the change.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
oharboe requested a review from jhkim-pii November 11, 2026 06:22
@openroad-ci

openroad-ci commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit e39c673 · Jenkins build #2 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

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