From 694d0652952b94fd5eb81d24ca56b3b450982d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Sat, 10 Oct 2026 13:12:15 +0200 Subject: [PATCH] synth: ABC_SCRIPT replaces the ABC script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ABC_SCRIPT replaces the ABC script synthesis runs, abc_speed.script or abc_area.script, so that a design can vendor and change it. It applies to the abc path only. The abc_new path, which SYNTH_WRAPPED_OPERATORS and SWAP_ARITH_OPERATORS select, maps each arithmetic operator module with the abc9_script attribute synth_wrap_operators.tcl sets on it, and every other module with the abc9.script scratchpad. An explicit -script overrides both, so it stays cropped from abc_new's arguments; passing one lost the adder architecture the operator swap chose (asap7/riscv32i setup WS -2.5 ps to -123 ps at CTS). The scratchpad abc9.script setting before abc_new stays, with a comment: abc_new installs its own default only when it sees no -script, and it looks for one by searching its arguments for the text "-script", which every /OpenROAD-flow-scripts/... liberty path contains (YosysHQ/yosys#6320). Without the line, every SWAP_ARITH_OPERATORS design fails synthesis. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Øyvind Harboe --- docs/user/FlowVariables.md | 2 ++ flow/scripts/synth.tcl | 7 ++++++- flow/scripts/synth_preamble.tcl | 5 ++++- flow/scripts/variables.json | 6 ++++++ flow/scripts/variables.yaml | 7 +++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index dfb6ab40f2..4faa3cf80c 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -93,6 +93,7 @@ configuration file. | ABC_AREA| Strategies for Yosys ABC synthesis: Area/Speed. Default ABC_SPEED.| 0| | ABC_DRIVER_CELL| Default driver cell used during ABC synthesis.| | | ABC_LOAD_IN_FF| During synthesis set_load value used.| | +| ABC_SCRIPT| Replaces the ABC script synthesis runs, so that a design can vendor and change it. Ignored when SYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS is set: abc_new then maps each arithmetic operator with its own script.| | | ABSTRACT_SOURCE| Which .odb file to use to create abstract| | | ADDER_MAP_FILE| Optional mapping file supplied to Yosys to map adders| | | ADDITIONAL_FILES| Additional files to be added to `make issue` archive.| | @@ -340,6 +341,7 @@ configuration file. - [ABC_AREA](#ABC_AREA) - [ABC_DRIVER_CELL](#ABC_DRIVER_CELL) - [ABC_LOAD_IN_FF](#ABC_LOAD_IN_FF) +- [ABC_SCRIPT](#ABC_SCRIPT) - [ADDER_MAP_FILE](#ADDER_MAP_FILE) - [ADDITIONAL_MEMORIES](#ADDITIONAL_MEMORIES) - [CACHED_REPORTS](#CACHED_REPORTS) diff --git a/flow/scripts/synth.tcl b/flow/scripts/synth.tcl index 7327312e53..aa4d3afb6c 100644 --- a/flow/scripts/synth.tcl +++ b/flow/scripts/synth.tcl @@ -284,8 +284,13 @@ if { } { 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). scratchpad -set abc9.script $::env(SCRIPTS_DIR)/abc_speed_gia_only.script - # crop out -script from arguments + # abc_new maps each arithmetic operator module with the abc9_script + # attribute synth_wrap_operators.tcl sets on it, and every other module + # with the script above. An explicit -script overrides both, so it is + # cropped from the arguments and ABC_SCRIPT does not apply here. set abc_args [lrange $abc_args 2 end] log_cmd abc_new {*}$abc_args delete {t:$specify*} diff --git a/flow/scripts/synth_preamble.tcl b/flow/scripts/synth_preamble.tcl index 53353ee46a..cc517b2e35 100644 --- a/flow/scripts/synth_preamble.tcl +++ b/flow/scripts/synth_preamble.tcl @@ -189,7 +189,10 @@ proc read_design_sources { } { } } -if { $::env(ABC_AREA) } { +if { [env_var_exists_and_non_empty ABC_SCRIPT] } { + puts "Using ABC script $::env(ABC_SCRIPT)." + set abc_script $::env(ABC_SCRIPT) +} elseif { $::env(ABC_AREA) } { puts "Using ABC area script." set abc_script $::env(SCRIPTS_DIR)/abc_area.script } else { diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 61a7b8b8e7..c79940855c 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -18,6 +18,12 @@ "synth" ] }, + "ABC_SCRIPT": { + "description": "Replaces the ABC script synthesis runs, so that a design can vendor and\nchange it. Ignored when SYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS\nis set: abc_new then maps each arithmetic operator with its own script.\n", + "stages": [ + "synth" + ] + }, "ABSTRACT_SOURCE": { "description": "Which .odb file to use to create abstract\n", "stages": [ diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 2052bd468d..ac913b71ad 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -1037,6 +1037,13 @@ ABC_AREA: stages: - synth default: 0 +ABC_SCRIPT: + description: | + Replaces the ABC script synthesis runs, so that a design can vendor and + change it. Ignored when SYNTH_WRAPPED_OPERATORS or SWAP_ARITH_OPERATORS + is set: abc_new then maps each arithmetic operator with its own script. + stages: + - synth PWR_NETS_VOLTAGES: description: | Used for IR Drop calculation.