Skip to content

Commit ad728b3

Browse files
committed
synth: add INFER_CLKGATES_MIN_NET_SIZE and INFER_CLKGATES_EXCLUDE
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>
1 parent ada70e0 commit ad728b3

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎docs/user/FlowVariables.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ configuration file.
171171
| <a name="GUI_TIMING"></a>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|
172172
| <a name="HOLD_SLACK_MARGIN"></a>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|
173173
| <a name="INFER_CLKGATES"></a>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|
174+
| <a name="INFER_CLKGATES_EXCLUDE"></a>INFER_CLKGATES_EXCLUDE| Space-separated Yosys module name patterns whose flip-flops INFER_CLKGATES leaves ungated, e.g. a module whose enable logic is timing-critical. Only modules that still exist at clock gate inference can be excluded, see SYNTH_HIERARCHICAL and SYNTH_KEEP_MODULES.| |
175+
| <a name="INFER_CLKGATES_MIN_NET_SIZE"></a>INFER_CLKGATES_MIN_NET_SIZE| Minimum number of flip-flops sharing a clock and enable for INFER_CLKGATES to replace their enable with a clock gating cell. Smaller groups keep their enable flip-flops. Unset gates every group.| |
174176
| <a name="IO_CONSTRAINTS"></a>IO_CONSTRAINTS| File path to the IO constraints .tcl file. Also used for manual placement.| |
175177
| <a name="IO_PLACER_H"></a>IO_PLACER_H| A list of metal layers on which the I/O pins are placed horizontally (top and bottom of the die).| |
176178
| <a name="IO_PLACER_V"></a>IO_PLACER_V| A list of metal layers on which the I/O pins are placed vertically (sides of the die).| |
@@ -362,6 +364,8 @@ configuration file.
362364
- [DFF_LIB_FILE](#DFF_LIB_FILE)
363365
- [DFF_MAP_FILE](#DFF_MAP_FILE)
364366
- [INFER_CLKGATES](#INFER_CLKGATES)
367+
- [INFER_CLKGATES_EXCLUDE](#INFER_CLKGATES_EXCLUDE)
368+
- [INFER_CLKGATES_MIN_NET_SIZE](#INFER_CLKGATES_MIN_NET_SIZE)
365369
- [LATCH_MAP_FILE](#LATCH_MAP_FILE)
366370
- [LEC_AUX_VERILOG_FILES](#LEC_AUX_VERILOG_FILES)
367371
- [LEC_CHECK](#LEC_CHECK)

‎flow/platforms/asap7/config.mk‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export WC_VOLTAGE = 0.63
2222
# Dont use cells to ease congestion
2323
# Specify at least one filler cell if none
2424
export DONT_USE_CELLS = *x1p*_ASAP7* *xp*_ASAP7*
25-
export DONT_USE_CELLS += SDF* ICG*
25+
export DONT_USE_CELLS += SDF*
26+
# INFER_CLKGATES inserts ICG cells, which OpenROAD must then be free to size
27+
ifneq ($(INFER_CLKGATES),1)
28+
export DONT_USE_CELLS += ICG*
29+
endif
2630

2731
export SYNTH_MINIMUM_KEEP_SIZE ?= 1000
2832

‎flow/scripts/synth.tcl‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@ if { [env_var_equals INFER_CLKGATES 1] } {
266266
# Let yosys decide on which clock gating cell to use
267267
lappend clkgate_args {*}$lib_args
268268
}
269+
if { [env_var_exists_and_non_empty INFER_CLKGATES_MIN_NET_SIZE] } {
270+
lappend clkgate_args -min_net_size $::env(INFER_CLKGATES_MIN_NET_SIZE)
271+
}
272+
if { [env_var_exists_and_non_empty INFER_CLKGATES_EXCLUDE] } {
273+
lappend clkgate_args *
274+
foreach pattern $::env(INFER_CLKGATES_EXCLUDE) {
275+
lappend clkgate_args $pattern %d
276+
}
277+
}
269278
log_cmd clockgate {*}$clkgate_args
270279
}
271280

‎flow/scripts/variables.json‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,18 @@
498498
"synth"
499499
]
500500
},
501+
"INFER_CLKGATES_EXCLUDE": {
502+
"description": "Space-separated Yosys module name patterns whose flip-flops INFER_CLKGATES leaves ungated, e.g. a module whose enable logic is timing-critical. Only modules that still exist at clock gate inference can be excluded, see SYNTH_HIERARCHICAL and SYNTH_KEEP_MODULES.\n",
503+
"stages": [
504+
"synth"
505+
]
506+
},
507+
"INFER_CLKGATES_MIN_NET_SIZE": {
508+
"description": "Minimum number of flip-flops sharing a clock and enable for INFER_CLKGATES to replace their enable with a clock gating cell. Smaller groups keep their enable flip-flops. Unset gates every group.\n",
509+
"stages": [
510+
"synth"
511+
]
512+
},
501513
"IO_CONSTRAINTS": {
502514
"description": "File path to the IO constraints .tcl file. Also used for manual placement.\n",
503515
"stages": [

‎flow/scripts/variables.yaml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,21 @@ INFER_CLKGATES:
456456
default: 0
457457
stages:
458458
- synth
459+
INFER_CLKGATES_EXCLUDE:
460+
description: >
461+
Space-separated Yosys module name patterns whose flip-flops
462+
INFER_CLKGATES leaves ungated, e.g. a module whose enable logic is
463+
timing-critical. Only modules that still exist at clock gate inference
464+
can be excluded, see SYNTH_HIERARCHICAL and SYNTH_KEEP_MODULES.
465+
stages:
466+
- synth
467+
INFER_CLKGATES_MIN_NET_SIZE:
468+
description: >
469+
Minimum number of flip-flops sharing a clock and enable for
470+
INFER_CLKGATES to replace their enable with a clock gating cell. Smaller
471+
groups keep their enable flip-flops. Unset gates every group.
472+
stages:
473+
- synth
459474
NEG_CLKGATE_AND_PORTS:
460475
description: >
461476
Specifies the active low enable clock gating cell and port names when used

0 commit comments

Comments
 (0)