Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/user/FlowVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ configuration file.
| <a name="SKIP_VT_SWAP"></a>SKIP_VT_SWAP| Do not perform VT swap to improve QoR (default: do VT swap).| |
| <a name="SLEW_MARGIN"></a>SLEW_MARGIN| Specifies a slew margin when fixing max slew violations. This option allows you to overfix.| |
| <a name="SWAP_ARITH_OPERATORS"></a>SWAP_ARITH_OPERATORS| Improve timing QoR by swapping ALU and MULT arithmetic operators.| 0|
| <a name="SYNTH_ABC_PARTITION"></a>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|
| <a name="SYNTH_ARGS"></a>SYNTH_ARGS| Optional synthesis variables for yosys.| |
| <a name="SYNTH_BLACKBOXES"></a>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.| |
| <a name="SYNTH_CANONICALIZE_TCL"></a>SYNTH_CANONICALIZE_TCL| Specifies a Tcl script with commands to run as part of the synth canonicalize step.| |
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion flow/scripts/synth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
68 changes: 68 additions & 0 deletions flow/scripts/synth_abc_partition.tcl
Original file line number Diff line number Diff line change
@@ -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]
Comment on lines +18 to +21

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.

medium

Normalizing $top and $cell by stripping any leading backslash before computing the substring range makes the cell name extraction much more robust against different naming formats in Yosys/RTLIL.

  set top $::env(DESIGN_NAME)
  regsub {^\\} $top {} top_norm
  set groups [dict create]
  foreach cell [tee -q -s result.string select -list "$top/t:*" "$top/t:\\$*" %d] {
    regsub {^\\} $cell {} cell_norm
    set name [string range $cell_norm [string length "$top_norm/"] 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 "<n> objects."
set n 0
regexp {[0-9]+} [tee -q -s result.string select -count \
@abc_partition_group %ci1 %cie* "$top/t:\$_*" %i] n
Comment on lines +43 to +44

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.

medium

Initializing n to 0 before running regexp ensures that n is always defined and does not retain a stale value if the regular expression fails to match.

    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

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.

medium

Initializing left to 0 before running regexp prevents it from retaining a stale value from a previous iteration of the loop if the regular expression fails to match.

    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
}
8 changes: 8 additions & 0 deletions flow/scripts/variables.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions flow/scripts/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +1085 to +1087

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.

medium

Adding type: int to the variable definition ensures proper type validation and consistent documentation generation.

  stages:
    - synth
  default: 0
  type: int

ABC_SCRIPT:
description: |
Replaces the ABC script synthesis runs, so that a design can vendor and
Expand Down