From 9e8857934388da81484f0ed778dab969bf9ad4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Sun, 8 Mar 2026 21:53:50 +0100 Subject: [PATCH 1/3] [slang] Automatically blackbox macros from ADDITIONAL_LIBS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using the slang HDL frontend, macros defined in ADDITIONAL_LIBS liberty files were not automatically blackboxed. If the same module had a competing Verilog definition in the source files, slang would elaborate the Verilog version instead of using the liberty view. Fix by extracting cell names from ADDITIONAL_LIBS and passing them as --blackboxed-module arguments to slang, making the behavior consistent with the builtin Verilog frontend. Tested: asap7/uart with a fake ADDITIONAL_LIBS containing uart_tx: Confirmed slang blackboxes uart_tx from the liberty file instead of elaborating it from the Verilog source. asap7/cva6 (which uses slang and ADDITIONAL_LIBS with fakeram macros that also have .sv definitions in VERILOG_FILES): make DESIGN_CONFIG=designs/asap7/cva6/config.mk do-yosys-canonicalize Passes in ~5s with no errors. asap7/uart without ADDITIONAL_LIBS: Normal synthesis still passes (no regression). Fixes #3849 Co-Authored-By: Claude Opus 4.6 Signed-off-by: Øyvind Harboe --- flow/scripts/synth_preamble.tcl | 10 ++++++++++ flow/scripts/util.tcl | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/flow/scripts/synth_preamble.tcl b/flow/scripts/synth_preamble.tcl index d8f98c8f69..1ef2f2b4bf 100644 --- a/flow/scripts/synth_preamble.tcl +++ b/flow/scripts/synth_preamble.tcl @@ -63,6 +63,16 @@ proc read_design_sources { } { lappend slang_args -G "$key=$value" } + # Automatically blackbox macros from ADDITIONAL_LIBS so that + # any competing Verilog definitions in the source files are + # ignored in favor of the liberty view, consistent with the + # behavior of the builtin Verilog frontend. + if { [env_var_exists_and_non_empty ADDITIONAL_LIBS] } { + foreach m [get_liberty_cell_names $::env(ADDITIONAL_LIBS)] { + lappend slang_args --blackboxed-module "$m" + } + } + # Apply module blackboxing based on module names as they appear # in the input, that is before any module name mangling done # by elaboration and synthesis diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index af92dbe0c2..112b78239d 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -1,3 +1,18 @@ +# Extract cell names from liberty files by parsing "cell(...)" declarations +proc get_liberty_cell_names { lib_files } { + set cell_names [list] + foreach lib $lib_files { + set fid [open $lib r] + while { [gets $fid line] >= 0 } { + if { [regexp {^\s*cell\s*\(\s*"?([^")\s]+)"?\s*\)} $line -> cell_name] } { + lappend cell_names $cell_name + } + } + close $fid + } + return $cell_names +} + proc log_cmd { cmd args } { # log the command, escape arguments with spaces set log_cmd "$cmd[join [lmap arg $args { format " %s" [expr { [string match {* *} $arg] ? "\"$arg\"" : "$arg" }] }] ""]" ;# tclint-disable-line line-length From e3959503eb3bfd5868095d062d7c88d27b9be01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 10 Mar 2026 17:36:47 +0100 Subject: [PATCH 2/3] synth: Ask yosys for cell names rather than .lib parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Povišer --- flow/scripts/synth_preamble.tcl | 2 +- flow/scripts/util.tcl | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/flow/scripts/synth_preamble.tcl b/flow/scripts/synth_preamble.tcl index 1ef2f2b4bf..3edee2d454 100644 --- a/flow/scripts/synth_preamble.tcl +++ b/flow/scripts/synth_preamble.tcl @@ -68,7 +68,7 @@ proc read_design_sources { } { # ignored in favor of the liberty view, consistent with the # behavior of the builtin Verilog frontend. if { [env_var_exists_and_non_empty ADDITIONAL_LIBS] } { - foreach m [get_liberty_cell_names $::env(ADDITIONAL_LIBS)] { + foreach m [get_liberty_cell_names] { lappend slang_args --blackboxed-module "$m" } } diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index 112b78239d..e309cedad3 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -1,16 +1,6 @@ -# Extract cell names from liberty files by parsing "cell(...)" declarations -proc get_liberty_cell_names { lib_files } { - set cell_names [list] - foreach lib $lib_files { - set fid [open $lib r] - while { [gets $fid line] >= 0 } { - if { [regexp {^\s*cell\s*\(\s*"?([^")\s]+)"?\s*\)} $line -> cell_name] } { - lappend cell_names $cell_name - } - } - close $fid - } - return $cell_names +# Extract cell names +proc get_liberty_cell_names { } { + return [tee -q -s result.string select -list-mod =A:liberty_cell] } proc log_cmd { cmd args } { From 90ab6ed2c24ebbac4654bd38ba81e40802613c89 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 11 Mar 2026 07:55:46 +0000 Subject: [PATCH 3/3] flow: update rules Signed-off-by: github-actions[bot] --- flow/designs/asap7/aes-block/rules-base.json | 2 +- flow/designs/nangate45/ariane133/rules-base.json | 2 +- flow/designs/nangate45/bp_fe_top/rules-base.json | 2 +- .../designs/nangate45/bp_multi_top/rules-base.json | 2 +- .../nangate45/mempool_group/rules-base.json | 14 +++++++------- flow/designs/nangate45/tinyRocket/rules-base.json | 2 +- flow/designs/sky130hd/chameleon/rules-base.json | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/flow/designs/asap7/aes-block/rules-base.json b/flow/designs/asap7/aes-block/rules-base.json index 45208f8afe..012f81c8e0 100644 --- a/flow/designs/asap7/aes-block/rules-base.json +++ b/flow/designs/asap7/aes-block/rules-base.json @@ -99,4 +99,4 @@ "value": 7206, "compare": "<=" } -} +} \ No newline at end of file diff --git a/flow/designs/nangate45/ariane133/rules-base.json b/flow/designs/nangate45/ariane133/rules-base.json index 8e5071431f..6ad8080e09 100644 --- a/flow/designs/nangate45/ariane133/rules-base.json +++ b/flow/designs/nangate45/ariane133/rules-base.json @@ -99,4 +99,4 @@ "value": 840911, "compare": "<=" } -} +} \ No newline at end of file diff --git a/flow/designs/nangate45/bp_fe_top/rules-base.json b/flow/designs/nangate45/bp_fe_top/rules-base.json index c4be1ed899..87db27968c 100644 --- a/flow/designs/nangate45/bp_fe_top/rules-base.json +++ b/flow/designs/nangate45/bp_fe_top/rules-base.json @@ -99,4 +99,4 @@ "value": 247483, "compare": "<=" } -} +} \ No newline at end of file diff --git a/flow/designs/nangate45/bp_multi_top/rules-base.json b/flow/designs/nangate45/bp_multi_top/rules-base.json index 763b6d62f4..56e5c9c67e 100644 --- a/flow/designs/nangate45/bp_multi_top/rules-base.json +++ b/flow/designs/nangate45/bp_multi_top/rules-base.json @@ -99,4 +99,4 @@ "value": 587157, "compare": "<=" } -} +} \ No newline at end of file diff --git a/flow/designs/nangate45/mempool_group/rules-base.json b/flow/designs/nangate45/mempool_group/rules-base.json index 48e089a5f2..aa57c0f78e 100644 --- a/flow/designs/nangate45/mempool_group/rules-base.json +++ b/flow/designs/nangate45/mempool_group/rules-base.json @@ -1,6 +1,6 @@ { "synth__design__instance__area__stdcell": { - "value": 271098.37, + "value": 424000.0, "compare": "<=" }, "constraints__clocks__count": { @@ -8,11 +8,11 @@ "compare": "==" }, "placeopt__design__instance__area": { - "value": 295108, + "value": 451188, "compare": "<=" }, "placeopt__design__instance__count__stdcell": { - "value": 163160, + "value": 198708, "compare": "<=" }, "detailedplace__design__violations": { @@ -32,7 +32,7 @@ "compare": ">=" }, "cts__timing__setup__tns": { - "value": -10300.0, + "value": -11900.0, "compare": ">=" }, "cts__timing__hold__ws": { @@ -52,7 +52,7 @@ "compare": ">=" }, "globalroute__timing__setup__tns": { - "value": -11100.0, + "value": -14200.0, "compare": ">=" }, "globalroute__timing__hold__ws": { @@ -64,7 +64,7 @@ "compare": ">=" }, "detailedroute__route__wirelength": { - "value": 4029078, + "value": 5795200, "compare": "<=" }, "detailedroute__route__drc_errors": { @@ -96,7 +96,7 @@ "compare": ">=" }, "finish__design__instance__area": { - "value": 303227, + "value": 461696, "compare": "<=" } } \ No newline at end of file diff --git a/flow/designs/nangate45/tinyRocket/rules-base.json b/flow/designs/nangate45/tinyRocket/rules-base.json index fcffced277..49b0eefcca 100644 --- a/flow/designs/nangate45/tinyRocket/rules-base.json +++ b/flow/designs/nangate45/tinyRocket/rules-base.json @@ -99,4 +99,4 @@ "value": 62486, "compare": "<=" } -} +} \ No newline at end of file diff --git a/flow/designs/sky130hd/chameleon/rules-base.json b/flow/designs/sky130hd/chameleon/rules-base.json index 6511dac5ba..3f105102ea 100644 --- a/flow/designs/sky130hd/chameleon/rules-base.json +++ b/flow/designs/sky130hd/chameleon/rules-base.json @@ -99,4 +99,4 @@ "value": 6493440, "compare": "<=" } -} +} \ No newline at end of file