diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md
index 3f60ae138e..987c5173f6 100644
--- a/docs/user/FlowVariables.md
+++ b/docs/user/FlowVariables.md
@@ -168,7 +168,7 @@ configuration file.
| GRT_SEED| Specifies a random seed for global routing. Useful for perturbation studies.| |
| GUI_TIMING| Load timing information when opening GUI. For large designs, this can be quite time consuming. Useful to disable when investigating non-timing aspects like floorplan, placement, routing, etc.| 1|
| HOLD_SLACK_MARGIN| Specifies a time margin for the slack when fixing hold violations. This option allows you to overfix or underfix (negative value, terminate retiming before 0 or positive slack). floorplan.tcl uses min of HOLD_SLACK_MARGIN and 0 (default hold slack margin). This avoids overrepair in floorplan for hold by default, but allows skipping hold repair using a negative HOLD_SLACK_MARGIN. Exiting timing repair early is useful in exploration where the .sdc has a fixed clock period at the design's target clock period and where HOLD/SETUP_SLACK_MARGIN is used to avoid overrepair (extremely long running times) when exploring different parameter settings. When an ideal clock is used, that is before CTS, a clock insertion delay of 0 is used in timing paths. This creates a mismatch between macros that have a .lib file from after CTS, when the clock is propagated. To mitigate this, OpenSTA will use subtract the clock insertion delay of macros when calculating timing with ideal clock. Provided that min_clock_tree_path and max_clock_tree_path are in the .lib file, which is the case for macros built with OpenROAD. This is less accurate than if OpenROAD had created a placeholder clock tree for timing estimation purposes prior to CTS. There will inevitably be inaccuracies in the timing calculation prior to CTS. Use a slack margin that is low enough, even negative, to avoid overrepair. Inaccuracies in the timing prior to CTS can also lead to underrepair, but there no obvious and simple way to avoid underrapir in these cases. Overrepair can lead to excessive runtimes in repair or too much buffering being added, which can present itself as congestion of hold cells or buffer cells. Another use of SETUP/HOLD_SLACK_MARGIN is design parameter exploration when trying to find the minimum clock period for a design. The SDC_FILE for a design can be quite complicated and instead of modifying the clock period in the SDC_FILE, which can be non-trivial, the clock period can be fixed at the target frequency and the SETUP/HOLD_SLACK_MARGIN can be swept to find a plausible current minimum clock period.| 0|
-| INFER_CLKGATES| Enables Yosys clock gate inference. Uses Liberty to determine clock gating cell| 0|
+| INFER_CLKGATES| Enables Yosys clock gate inference. By default, it uses the Liberty cell definitions to determine clock gating cell. The selection can be overridden using the POS_CLKGATE_AND_PORTS and/or NEG_CLKGATE_AND_PORTS variables.| 0|
| IO_CONSTRAINTS| File path to the IO constraints .tcl file. Also used for manual placement.| |
| IO_PLACER_H| A list of metal layers on which the I/O pins are placed horizontally (top and bottom of the die).| |
| IO_PLACER_V| A list of metal layers on which the I/O pins are placed vertically (sides of the die).| |
@@ -198,6 +198,7 @@ configuration file.
| MIN_CLK_ROUTING_LAYER| The lowest metal layer name to be used for clock-net routing in global routing. Used in flow/platforms/*/fastroute.tcl as the lower bound of `set_routing_layers -clock`. Typically higher than MIN_ROUTING_LAYER so clock nets prefer the upper, lower-RC layers. No `stages:` list because floorplan.tcl also `source`s the platform fastroute.tcl.| |
| MIN_PLACE_STEP_COEF| Sets the minimum phi coefficient (pcof_min / ยต_k Lower Bound) for global placement optimization. This parameter controls the step size lower bound in the RePlAce Nesterov optimization algorithm. Lower values may improve convergence but can increase runtime. Valid range: 0.95-1.05| 0.95|
| MIN_ROUTING_LAYER| The lowest metal layer name to be used in routing.| |
+| NEG_CLKGATE_AND_PORTS| Specifies the active low enable clock gating cell and port names when used in conjunction with the INFER_CLKGATES variable. Format is "cell_name enable_port:master_clock:gated_clock"| |
| NUM_CORES| Passed to `openroad -threads $(NUM_CORES)`, defaults to numbers of cores in system as determined by system specific code in Makefile, `nproc` is tried first. OpenROAD does not limit itself to this number of cores across OpenROAD running instances, which can lead to overprovisioning in contexts such as bazel-orfs where there could be many routing, or place jobs running at the same time.| |
| OPENROAD_HIERARCHICAL| Feature toggle to enable to run OpenROAD in hierarchical mode, otherwise considered flat. Will eventually be the default and this option will be retired.| 0|
| OPT_POST_GRT_WNS| Optimize WNS after global routing by additional repair_timing that uses VT swap and wire rerouting only to minimize placement and routing disturbance| 1|
@@ -226,6 +227,7 @@ configuration file.
| POST_RESIZE_TCL| Specifies a Tcl script with commands to run after resize.| |
| POST_SYNTH_TCL| Specifies a Tcl script with commands to run after synthesis ODB generation.| |
| POST_TAPCELL_TCL| Specifies a Tcl script with commands to run after tapcell.| |
+| POS_CLKGATE_AND_PORTS| Specifies the active high enable clock gating cell and port names when used in conjunction with the INFER_CLKGATES variable. Format is "cell_name enable_port:master_clock:gated_clock"| |
| PRE_CTS_TCL| Specifies a Tcl script with commands to run before CTS.| |
| PRE_DENSITY_FILL_TCL| Specifies a Tcl script with commands to run before density fill.| |
| PRE_DETAIL_PLACE_TCL| Specifies a Tcl script with commands to run before detailed placement.| |
@@ -352,7 +354,9 @@ configuration file.
- [INFER_CLKGATES](#INFER_CLKGATES)
- [LATCH_MAP_FILE](#LATCH_MAP_FILE)
- [MIN_BUF_CELL_AND_PORTS](#MIN_BUF_CELL_AND_PORTS)
+- [NEG_CLKGATE_AND_PORTS](#NEG_CLKGATE_AND_PORTS)
- [POST_SYNTH_TCL](#POST_SYNTH_TCL)
+- [POS_CLKGATE_AND_PORTS](#POS_CLKGATE_AND_PORTS)
- [PRE_SYNTH_TCL](#PRE_SYNTH_TCL)
- [SDC_FILE](#SDC_FILE)
- [SDC_GUT](#SDC_GUT)
diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl
index c16f4e8969..14b5617e82 100644
--- a/flow/scripts/synth.tcl
+++ b/flow/scripts/synth.tcl
@@ -235,9 +235,26 @@ if { [env_var_exists_and_non_empty LATCH_MAP_FILE] } {
techmap -map $::env(LATCH_MAP_FILE)
}
-# Clock gate inference. Let yosys decide on which clock gating cell to use
+# Clock gate inference.
if { [env_var_equals INFER_CLKGATES 1] } {
- log_cmd clockgate {*}$lib_args
+ set clkgate_args {}
+ if {
+ [env_var_exists_and_non_empty POS_CLKGATE_AND_PORTS] ||
+ [env_var_exists_and_non_empty NEG_CLKGATE_AND_PORTS]
+ } {
+ if { [env_var_exists_and_non_empty POS_CLKGATE_AND_PORTS] } {
+ lappend clkgate_args "-pos"
+ lappend clkgate_args {*}$::env(POS_CLKGATE_AND_PORTS)
+ }
+ if { [env_var_exists_and_non_empty NEG_CLKGATE_AND_PORTS] } {
+ lappend clkgate_args "-neg"
+ lappend clkgate_args {*}$::env(NEG_CLKGATE_AND_PORTS)
+ }
+ } else {
+ # Let yosys decide on which clock gating cell to use
+ lappend clkgate_args {*}$lib_args
+ }
+ log_cmd clockgate {*}$clkgate_args
}
# Technology mapping of flip-flops
diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json
index 739013fcd2..2284f65417 100644
--- a/flow/scripts/variables.json
+++ b/flow/scripts/variables.json
@@ -466,7 +466,7 @@
},
"INFER_CLKGATES": {
"default": 0,
- "description": "Enables Yosys clock gate inference. Uses Liberty to determine clock gating cell\n",
+ "description": "Enables Yosys clock gate inference. By default, it uses the Liberty cell definitions to determine clock gating cell. The selection can be overridden using the POS_CLKGATE_AND_PORTS and/or NEG_CLKGATE_AND_PORTS variables.\n",
"stages": [
"synth"
]
@@ -648,6 +648,12 @@
"final"
]
},
+ "NEG_CLKGATE_AND_PORTS": {
+ "description": "Specifies the active low enable clock gating cell and port names when used in conjunction with the INFER_CLKGATES variable. Format is \"cell_name enable_port:master_clock:gated_clock\"\n",
+ "stages": [
+ "synth"
+ ]
+ },
"NUM_CORES": {
"description": "Passed to `openroad -threads $(NUM_CORES)`, defaults to numbers of cores in system as determined by system specific code in Makefile, `nproc` is tried first. OpenROAD does not limit itself to this number of cores across OpenROAD running instances, which can lead to overprovisioning in contexts such as bazel-orfs where there could be many routing, or place jobs running at the same time.\n",
"stages": [
@@ -819,6 +825,12 @@
"floorplan"
]
},
+ "POS_CLKGATE_AND_PORTS": {
+ "description": "Specifies the active high enable clock gating cell and port names when used in conjunction with the INFER_CLKGATES variable. Format is \"cell_name enable_port:master_clock:gated_clock\"\n",
+ "stages": [
+ "synth"
+ ]
+ },
"PRE_CTS_TCL": {
"description": "Specifies a Tcl script with commands to run before CTS.\n",
"stages": [
diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml
index d1d2ef277d..f0502a1735 100644
--- a/flow/scripts/variables.yaml
+++ b/flow/scripts/variables.yaml
@@ -380,11 +380,27 @@ ADDER_MAP_FILE:
stages:
- synth
INFER_CLKGATES:
- description: |
- Enables Yosys clock gate inference. Uses Liberty to determine clock gating cell
+ description: >
+ Enables Yosys clock gate inference. By default, it uses the Liberty cell
+ definitions to determine clock gating cell. The selection can be overridden
+ using the POS_CLKGATE_AND_PORTS and/or NEG_CLKGATE_AND_PORTS variables.
default: 0
stages:
- synth
+NEG_CLKGATE_AND_PORTS:
+ description: >
+ Specifies the active low enable clock gating cell and port names when used
+ in conjunction with the INFER_CLKGATES variable. Format is
+ "cell_name enable_port:master_clock:gated_clock"
+ stages:
+ - synth
+POS_CLKGATE_AND_PORTS:
+ description: >
+ Specifies the active high enable clock gating cell and port names when used
+ in conjunction with the INFER_CLKGATES variable. Format is
+ "cell_name enable_port:master_clock:gated_clock"
+ stages:
+ - synth
TIEHI_CELL_AND_PORT:
description: >
Tie high cells used in Yosys synthesis to replace a logical 1 in the