diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md
index 8d32a9d6ad..1653e499dc 100644
--- a/docs/user/FlowVariables.md
+++ b/docs/user/FlowVariables.md
@@ -294,6 +294,7 @@ configuration file.
| SKIP_VT_SWAP| Do not perform VT swap to improve QoR (default: do VT swap).| |
| SLEW_MARGIN| Specifies a slew margin when fixing max slew violations. This option allows you to overfix.| |
| SWAP_ARITH_OPERATORS| Improve timing QoR by swapping ALU and MULT arithmetic operators.| 0|
+| SYNTH_ABC_PARTITION| Map the top module with one abc call per register group instead of one for the whole module. abc maps each call against that call's own critical path and sees neither the SDC (clocks, false paths) nor the arrival times at cells mapped before it, such as extract_fa's adders. When that critical path is the wrong one, the real cones are area-recovered into slow structures; separate calls limit this to one group. Flops are grouped by name; the value is the minimum cone size, in cells, for a group to get its own call. 0 disables. Ignored when SYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS is set.| 0|
| SYNTH_ARGS| Optional synthesis variables for yosys.| |
| SYNTH_BLACKBOXES| List of cells treated as a black box by Yosys. With Bazel, this can be used to run synthesis in parallel for the large modules of the design. Non-existant modules are ignored silently, useful when listing modules statically, even if modules come and go dynamically.| |
| SYNTH_CANONICALIZE_TCL| Specifies a Tcl script with commands to run as part of the synth canonicalize step.| |
@@ -364,6 +365,7 @@ configuration file.
- [SDC_FILE](#SDC_FILE)
- [SEC_CHECK](#SEC_CHECK)
- [SKIP_REPORT_METRICS](#SKIP_REPORT_METRICS)
+- [SYNTH_ABC_PARTITION](#SYNTH_ABC_PARTITION)
- [SYNTH_ARGS](#SYNTH_ARGS)
- [SYNTH_BLACKBOXES](#SYNTH_BLACKBOXES)
- [SYNTH_CANONICALIZE_TCL](#SYNTH_CANONICALIZE_TCL)
diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl
index aa4d3afb6c..e8c95933c5 100644
--- a/flow/scripts/synth.tcl
+++ b/flow/scripts/synth.tcl
@@ -282,7 +282,12 @@ if {
![env_var_equals SYNTH_WRAPPED_OPERATORS 1] &&
![env_var_equals SWAP_ARITH_OPERATORS 1]
} {
- log_cmd abc {*}$abc_args
+ if { [env_var_exists_and_non_empty SYNTH_ABC_PARTITION] && $::env(SYNTH_ABC_PARTITION) > 0 } {
+ source $::env(SCRIPTS_DIR)/synth_abc_partition.tcl
+ synth_abc_partition $abc_args $::env(SYNTH_ABC_PARTITION)
+ } else {
+ log_cmd abc {*}$abc_args
+ }
} else {
# Not dead code: abc_new mistakes the "-script" in /OpenROAD-flow-scripts/...
# paths for a given -script and drops its default (YosysHQ/yosys#6320).
diff --git a/flow/scripts/synth_abc_partition.tcl b/flow/scripts/synth_abc_partition.tcl
new file mode 100644
index 0000000000..e4d9fd2e75
--- /dev/null
+++ b/flow/scripts/synth_abc_partition.tcl
@@ -0,0 +1,68 @@
+# Technology mapping with one abc call per register group
+# (SYNTH_ABC_PARTITION).
+#
+# abc maps a netlist against a single delay target, the netlist's own
+# critical path, and recovers area on every cone that is faster than that.
+# It sees no SDC and no arrival times at cells mapped before it (extract_fa's
+# adders), so that critical path can be a false path, or shorter than the
+# real one; the real cones are then rebuilt smaller and slower. Mapping each
+# register group separately gives every group its own critical path.
+#
+# Flops (liberty cells after dfflibmap) are grouped by name with bit indices
+# and the "$_DFF..." suffix removed. A group's cone is the still-unmapped
+# combinational fan-in of its flops' inputs. Groups are mapped largest cone
+# first; logic shared by several groups goes to the first group that
+# reaches it. Groups with fewer than min_cells unmapped cells, and anything
+# left over, are mapped by one final abc call.
+proc synth_abc_partition { abc_args min_cells } {
+ set top $::env(DESIGN_NAME)
+ set groups [dict create]
+ foreach cell [tee -q -s result.string select -list "$top/t:*" "$top/t:\$*" %d] {
+ set name [string range $cell [string length "$top/"] end]
+ regsub {\$_.*$} $name {} key
+ regsub -all {\[[0-9]+\]} $key {} key
+ if { $key ne "" } {
+ dict incr groups $key
+ }
+ }
+
+ # '?' stands for the '[' or '$' after the base name; groups whose name
+ # extends this one (acc vs. acc_next) are removed from the selection.
+ set keys [dict keys $groups]
+ set sized {}
+ foreach key $keys {
+ set sel [list "$top/$key?*"]
+ foreach other $keys {
+ if { $other ne $key && [string match "$key*" $other] } {
+ lappend sel "$top/$other?*" %d
+ }
+ }
+ select -set abc_partition_group {*}$sel
+ # select -count returns " objects."
+ set n 0
+ regexp {[0-9]+} [tee -q -s result.string select -count \
+ @abc_partition_group %ci1 %cie* "$top/t:\$_*" %i] n
+ lappend sized [list $key $n $sel]
+ }
+
+ set i 0
+ foreach group [lsort -integer -decreasing -index 1 $sized] {
+ lassign $group key n sel
+ if { $n < $min_cells } {
+ continue
+ }
+ select -set abc_partition_group {*}$sel
+ select -set abc_partition_cone \
+ @abc_partition_group %ci1 %cie* "$top/t:\$_*" %i
+ set left 0
+ regexp {[0-9]+} [tee -q -s result.string select -count @abc_partition_cone] left
+ if { $left < $min_cells } {
+ continue
+ }
+ puts "abc partition [incr i]: $key, $left cells"
+ log_cmd abc {*}$abc_args @abc_partition_cone
+ }
+ puts "abc partition: remaining logic"
+ log_cmd abc {*}$abc_args "t:\$_*"
+ select -clear
+}
diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json
index 2810d1ec80..7feb0c4518 100644
--- a/flow/scripts/variables.json
+++ b/flow/scripts/variables.json
@@ -1286,6 +1286,14 @@
],
"tunable": 1
},
+ "SYNTH_ABC_PARTITION": {
+ "default": 0,
+ "description": "Map the top module with one abc call per register group instead of one\nfor the whole module. abc maps each call against that call's own\ncritical path and sees neither the SDC (clocks, false paths) nor the\narrival times at cells mapped before it, such as extract_fa's adders.\nWhen that critical path is the wrong one, the real cones are\narea-recovered into slow structures; separate calls limit this to one\ngroup. Flops are grouped by name; the value is the minimum cone size,\nin cells, for a group to get its own call. 0 disables. Ignored when\nSYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS is set.\n",
+ "stages": [
+ "synth"
+ ],
+ "type": "int"
+ },
"SYNTH_ARGS": {
"description": "Optional synthesis variables for yosys.\n",
"stages": [
diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml
index 4d71623a35..26acccb09d 100644
--- a/flow/scripts/variables.yaml
+++ b/flow/scripts/variables.yaml
@@ -1070,6 +1070,21 @@ ABC_AREA:
stages:
- synth
default: 0
+SYNTH_ABC_PARTITION:
+ description: |
+ Map the top module with one abc call per register group instead of one
+ for the whole module. abc maps each call against that call's own
+ critical path and sees neither the SDC (clocks, false paths) nor the
+ arrival times at cells mapped before it, such as extract_fa's adders.
+ When that critical path is the wrong one, the real cones are
+ area-recovered into slow structures; separate calls limit this to one
+ group. Flops are grouped by name; the value is the minimum cone size,
+ in cells, for a group to get its own call. 0 disables. Ignored when
+ SYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS is set.
+ type: int
+ stages:
+ - synth
+ default: 0
ABC_SCRIPT:
description: |
Replaces the ABC script synthesis runs, so that a design can vendor and