Skip to content

Commit a77866c

Browse files
oharboeclaude
andcommitted
[slang] Automatically blackbox macros from ADDITIONAL_LIBS
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 The-OpenROAD-Project#3849 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5101376 commit a77866c

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎flow/scripts/synth_preamble.tcl‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ proc read_design_sources { } {
6363
lappend slang_args -G "$key=$value"
6464
}
6565

66+
# Automatically blackbox macros from ADDITIONAL_LIBS so that
67+
# any competing Verilog definitions in the source files are
68+
# ignored in favor of the liberty view, consistent with the
69+
# behavior of the builtin Verilog frontend.
70+
if { [env_var_exists_and_non_empty ADDITIONAL_LIBS] } {
71+
foreach m [get_liberty_cell_names $::env(ADDITIONAL_LIBS)] {
72+
lappend slang_args --blackboxed-module "$m"
73+
}
74+
}
75+
6676
# Apply module blackboxing based on module names as they appear
6777
# in the input, that is before any module name mangling done
6878
# by elaboration and synthesis

‎flow/scripts/util.tcl‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Extract cell names from liberty files by parsing "cell(...)" declarations
2+
proc get_liberty_cell_names { lib_files } {
3+
set cell_names [list]
4+
foreach lib $lib_files {
5+
set fid [open $lib r]
6+
while { [gets $fid line] >= 0 } {
7+
if { [regexp {^\s*cell\s*\(\s*"?([^")\s]+)"?\s*\)} $line -> cell_name] } {
8+
lappend cell_names $cell_name
9+
}
10+
}
11+
close $fid
12+
}
13+
return $cell_names
14+
}
15+
116
proc log_cmd { cmd args } {
217
# log the command, escape arguments with spaces
318
set log_cmd "$cmd[join [lmap arg $args { format " %s" [expr { [string match {* *} $arg] ? "\"$arg\"" : "$arg" }] }] ""]" ;# tclint-disable-line line-length

0 commit comments

Comments
 (0)