From 7ada09f8e6236abbeda8ba901f448b60e1aaec2f Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Wed, 21 Oct 2026 19:03:26 +0000 Subject: [PATCH 01/16] Read binary liberty files from a cache shared by all designs Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 4 +++ flow/Makefile | 17 +++++++++++ flow/scripts/read_liberty.tcl | 4 +-- flow/scripts/util.tcl | 34 ++++++++++++++++++++++ flow/scripts/variables.json | 14 ++++++++++ flow/scripts/variables.yaml | 23 +++++++++++++++ flow/scripts/write_binary_libs.tcl | 45 ++++++++++++++++++++++++++++++ 7 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 flow/scripts/write_binary_libs.tcl diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index ad4c27dd67..0626b68f83 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,6 +105,7 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| +| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | @@ -327,6 +328,7 @@ configuration file. | TIE_SEPARATION| Distance separating tie high/low instances from the load.| 0| | TNS_END_PERCENT| Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all violating endpoints by default (reduce to 5% for runtime). Specifies how many percent of violating paths to fix [0-100]. Worst path will always be fixed.| 100| | UNSET_ABC9_BOX_CELLS| List of cells to unset the abc9_box attribute on| | +| USE_BINARY_LIBS| Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth, the flow converts every library missing from BINARY_LIBS_DIR. Set to 0 when the flow should read LIB_FILES as given, for example when bazel-orfs provides the binary libraries itself.| 1| | USE_FILL| Whether to perform metal density filling.| 0| | VERILOG_DEFINES| Preprocessor defines passed to the language frontend. Example: `-D HPDCACHE_ASSERT_OFF`| | | VERILOG_FILES| The path to the design Verilog/SystemVerilog files providing a description of modules.| | @@ -630,12 +632,14 @@ configuration file. ## All stages variables - [ASAP7_USE_VT](#ASAP7_USE_VT) +- [BINARY_LIBS_DIR](#BINARY_LIBS_DIR) - [CORNERS](#CORNERS) - [KEEP_VARS](#KEEP_VARS) - [NUM_CORES](#NUM_CORES) - [OPENROAD_HIERARCHICAL](#OPENROAD_HIERARCHICAL) - [SWAP_ARITH_OPERATORS](#SWAP_ARITH_OPERATORS) - [SYNTH_WRAPPED_OPERATORS](#SYNTH_WRAPPED_OPERATORS) +- [USE_BINARY_LIBS](#USE_BINARY_LIBS) - [WRITE_ODB_AND_SDC_EACH_STAGE](#WRITE_ODB_AND_SDC_EACH_STAGE) ## generate_abstract variables diff --git a/flow/Makefile b/flow/Makefile index 759e13578d..ecb9e97d83 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -292,6 +292,23 @@ $(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil: $(RESULTS_DIR)/memories.json $(OBJECTS_DIR)/klayout.lyt: $(RESULTS_DIR)/memories.json endif +# OpenROAD stages read binary liberty (.blib) files from a cache shared by +# all designs, see scripts/write_binary_libs.tcl. Yosys reads the text libraries. +ifeq ($(USE_BINARY_LIBS),1) +.PHONY: binary-libs do-binary-libs +binary-libs: do-binary-libs +do-binary-libs: + @mkdir -p $(LOG_DIR) + $(RUN_CMD) --log $(abspath $(LOG_DIR)/write_binary_libs.log) --tee -- $(OPENROAD_CMD) $(SCRIPTS_DIR)/write_binary_libs.tcl + +# Order-only, so filling the cache never reruns the flow. +$(RESULTS_DIR)/1_synth.odb: | do-binary-libs +endif + +.PHONY: clean_binary_libs +clean_binary_libs: + rm -rf $(if $(strip $(BINARY_LIBS_DIR)),$(BINARY_LIBS_DIR),$(error BINARY_LIBS_DIR is empty)) + .PHONY: do-yosys do-yosys: yosys-dependencies $(SCRIPTS_DIR)/synth.sh $(SYNTH_SCRIPT) $(LOG_DIR)/1_2_yosys.log diff --git a/flow/scripts/read_liberty.tcl b/flow/scripts/read_liberty.tcl index 1c013611dd..60816842ff 100644 --- a/flow/scripts/read_liberty.tcl +++ b/flow/scripts/read_liberty.tcl @@ -5,7 +5,7 @@ if { [env_var_exists_and_non_empty CORNERS] } { foreach corner $::env(CORNERS) { set LIBKEY "[string toupper $corner]_LIB_FILES" foreach libFile $::env($LIBKEY) { - log_cmd read_liberty -corner $corner $libFile + log_cmd read_liberty -corner $corner [lib_file_to_read $libFile] } unset LIBKEY } @@ -13,7 +13,7 @@ if { [env_var_exists_and_non_empty CORNERS] } { } else { ## no corner foreach libFile $::env(LIB_FILES) { - log_cmd read_liberty $libFile + log_cmd read_liberty [lib_file_to_read $libFile] } } diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index 231a5b2c0e..bfa98694be 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -468,3 +468,37 @@ proc source_step_tcl { hook_type step_name } { set env_var "${hook_type}_${step_name}_TCL" source_env_var_if_exists $env_var } + +# Entry of lib_file in the binary liberty (.blib) cache. The name carries the +# library's path, size and modification time, so a changed library gets a new +# entry. Libraries the flow generates are cached per run. +proc binary_lib_path { lib_file } { + set source [file normalize $lib_file] + set root $::env(BINARY_LIBS_DIR) + foreach dir {objects results} { + set flow_dir [file normalize [file join $::env(WORK_HOME) $dir]] + if { [string first "$flow_dir/" $source] == 0 } { + set root [file join $::env(OBJECTS_DIR) binary_libs] + break + } + } + set name "[file tail $source]@[file size $source]-[file mtime $source].blib" + return [file join [file normalize $root] [string trimleft [file dirname $source] /] $name] +} + +# The cached .blib for lib_file, or lib_file when the .blib is missing or unusable +proc lib_file_to_read { lib_file } { + if { ![env_var_equals USE_BINARY_LIBS 1] || ![file exists $lib_file] } { + return $lib_file + } + set blib [binary_lib_path $lib_file] + if { ![file exists $blib] } { + utl::warn FLW 26 "$blib not found, reading $lib_file." + return $lib_file + } + if { [catch { liberty_binary_info $blib } msg] } { + utl::warn FLW 27 "$blib is unusable, reading $lib_file: $msg" + return $lib_file + } + return $blib +} diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index fd9391ddf3..be816da90c 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -81,6 +81,13 @@ "place" ] }, + "BINARY_LIBS_DIR": { + "default": "$(WORK_HOME)/objects/binary_libs", + "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", + "stages": [ + "All stages" + ] + }, "BLOCKS": { "description": "Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.\n" }, @@ -1502,6 +1509,13 @@ "synth" ] }, + "USE_BINARY_LIBS": { + "default": 1, + "description": "Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth, the flow converts every library missing from BINARY_LIBS_DIR. Set to 0 when the flow should read LIB_FILES as given, for example when bazel-orfs provides the binary libraries itself.\n", + "stages": [ + "All stages" + ] + }, "USE_FILL": { "default": 0, "description": "Whether to perform metal density filling.\n" diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index f5ad07cabb..09f3d10748 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -168,6 +168,29 @@ LIB_FILES: A Liberty file of the standard cell library with PVT characterization, input and output characteristics, timing and power definitions for each cell. +BINARY_LIBS_DIR: + description: > + Directory of the binary liberty (.blib) cache the OpenROAD stages read + instead of the text libraries. Every design that uses the directory + shares it, so set it in the environment or settings.mk, not in a + design's config.mk; ORFS clones that set the same directory share their + .blib files. `make binary-libs` fills it with the current design's + libraries and `make clean_binary_libs` deletes it. Libraries the flow + generates, such as BLOCKS abstracts, are cached per run in + $(OBJECTS_DIR)/binary_libs. + default: $(WORK_HOME)/objects/binary_libs + stages: + - All stages +USE_BINARY_LIBS: + description: > + Read binary liberty (.blib) files in the OpenROAD stages instead of + parsing the text libraries. Before 1_synth, the flow converts every + library missing from BINARY_LIBS_DIR. Set to 0 when the flow should + read LIB_FILES as given, for example when bazel-orfs provides the + binary libraries itself. + default: 1 + stages: + - All stages LIB_MODEL: description: > Selects between NLDM and CCS timing models for the ASAP7 platform. diff --git a/flow/scripts/write_binary_libs.tcl b/flow/scripts/write_binary_libs.tcl new file mode 100644 index 0000000000..425fe08c83 --- /dev/null +++ b/flow/scripts/write_binary_libs.tcl @@ -0,0 +1,45 @@ +# Fill the binary liberty (.blib) cache with the libraries the OpenROAD stages read +source $::env(SCRIPTS_DIR)/util.tcl + +set lib_files {} +if { [env_var_exists_and_non_empty CORNERS] } { + foreach corner $::env(CORNERS) { + lappend lib_files {*}$::env([string toupper $corner]_LIB_FILES) + } +} else { + lappend lib_files {*}$::env(LIB_FILES) +} + +set written 0 +set cached 0 +array set seen {} +foreach lib_file $lib_files { + # Libraries the flow has not generated yet are converted on a later run + if { ![file exists $lib_file] } { + continue + } + set blib [binary_lib_path $lib_file] + if { [info exists seen($blib)] } { + continue + } + set seen($blib) 1 + if { [file exists $blib] && ![catch { liberty_binary_info $blib }] } { + incr cached + continue + } + # Publish with a rename, so concurrent flows never read a partial file + set tmp "$blib.tmp.[info hostname].[pid]" + if { + [catch { + file mkdir [file dirname $blib] + log_cmd write_liberty_binary $lib_file $tmp + file rename -force $tmp $blib + } msg] + } { + file delete -force $tmp + utl::warn FLW 28 "Could not write $blib: $msg" + continue + } + incr written +} +puts "Binary liberty files: $written written, $cached already cached" From 510d23a2fc7564fbba2e863a6f36dbdef0653132 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Wed, 21 Oct 2026 21:53:54 +0000 Subject: [PATCH 02/16] Store binary liberty files in one folder per platform Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 2 +- flow/scripts/util.tcl | 16 ++++++++++------ flow/scripts/variables.json | 2 +- flow/scripts/variables.yaml | 4 +++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 0626b68f83..88260aedce 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,7 +105,7 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| -| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| +| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index bfa98694be..c8e5bd2bb9 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -469,12 +469,13 @@ proc source_step_tcl { hook_type step_name } { source_env_var_if_exists $env_var } -# Entry of lib_file in the binary liberty (.blib) cache. The name carries the -# library's path, size and modification time, so a changed library gets a new -# entry. Libraries the flow generates are cached per run. +# Entry of lib_file in the binary liberty (.blib) cache: +# /@--.blib, so a changed library gets +# a new entry and same-named libraries from different directories don't +# collide. Libraries the flow generates are cached per run. proc binary_lib_path { lib_file } { set source [file normalize $lib_file] - set root $::env(BINARY_LIBS_DIR) + set root [file join $::env(BINARY_LIBS_DIR) $::env(PLATFORM)] foreach dir {objects results} { set flow_dir [file normalize [file join $::env(WORK_HOME) $dir]] if { [string first "$flow_dir/" $source] == 0 } { @@ -482,8 +483,11 @@ proc binary_lib_path { lib_file } { break } } - set name "[file tail $source]@[file size $source]-[file mtime $source].blib" - return [file join [file normalize $root] [string trimleft [file dirname $source] /] $name] + set name [file tail $source] + regsub {\.gz$} $name "" name + set name [file rootname $name] + set dir_hash [format %08x [zlib crc32 [file dirname $source] 0]] + return [file join $root "$name@[file size $source]-[file mtime $source]-$dir_hash.blib"] } # The cached .blib for lib_file, or lib_file when the .blib is missing or unusable diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index be816da90c..9ce508d126 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -83,7 +83,7 @@ }, "BINARY_LIBS_DIR": { "default": "$(WORK_HOME)/objects/binary_libs", - "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", + "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", "stages": [ "All stages" ] diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 09f3d10748..d4ffea8017 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -171,7 +171,9 @@ LIB_FILES: BINARY_LIBS_DIR: description: > Directory of the binary liberty (.blib) cache the OpenROAD stages read - instead of the text libraries. Every design that uses the directory + instead of the text libraries, stored as + /@--.blib so that a changed + library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's From d41a3c7a49e32c6b74af5915219be485c3b04708 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 23 Oct 2026 01:59:53 +0000 Subject: [PATCH 03/16] use latest openroad Signed-off-by: Eder Monteiro --- tools/OpenROAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/OpenROAD b/tools/OpenROAD index bc739caf43..b9ec64c305 160000 --- a/tools/OpenROAD +++ b/tools/OpenROAD @@ -1 +1 @@ -Subproject commit bc739caf43047bfc2e225fe10dd968d672b617f8 +Subproject commit b9ec64c305c40780d6534494bdb152794aabdc6a From 47cf4c8b471283125c84d0c1738aa3650a2f50d0 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 23 Oct 2026 02:20:58 +0000 Subject: [PATCH 04/16] Cache binary libs of the design's own libraries per run Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 2 +- flow/scripts/util.tcl | 13 +++++++++---- flow/scripts/variables.json | 2 +- flow/scripts/variables.yaml | 6 +++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 0e6bc9a95f..caad108cfa 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,7 +105,7 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| -| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| +| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries in the design's directory (DESIGN_DIR) and libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index c8e5bd2bb9..fb0b8e1e82 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -472,13 +472,18 @@ proc source_step_tcl { hook_type step_name } { # Entry of lib_file in the binary liberty (.blib) cache: # /@--.blib, so a changed library gets # a new entry and same-named libraries from different directories don't -# collide. Libraries the flow generates are cached per run. +# collide. Libraries in the design's directory and those the flow generates +# are cached per run. proc binary_lib_path { lib_file } { set source [file normalize $lib_file] set root [file join $::env(BINARY_LIBS_DIR) $::env(PLATFORM)] - foreach dir {objects results} { - set flow_dir [file normalize [file join $::env(WORK_HOME) $dir]] - if { [string first "$flow_dir/" $source] == 0 } { + set run_dirs [list \ + [file join $::env(WORK_HOME) objects] [file join $::env(WORK_HOME) results]] + if { [env_var_exists_and_non_empty DESIGN_DIR] } { + lappend run_dirs $::env(DESIGN_DIR) + } + foreach dir $run_dirs { + if { [string first "[file normalize $dir]/" $source] == 0 } { set root [file join $::env(OBJECTS_DIR) binary_libs] break } diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 0e899a53e4..b6904fe51b 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -83,7 +83,7 @@ }, "BINARY_LIBS_DIR": { "default": "$(WORK_HOME)/objects/binary_libs", - "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", + "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries in the design's directory (DESIGN_DIR) and libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", "stages": [ "All stages" ] diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 169dfa6506..c795811535 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -177,9 +177,9 @@ BINARY_LIBS_DIR: shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's - libraries and `make clean_binary_libs` deletes it. Libraries the flow - generates, such as BLOCKS abstracts, are cached per run in - $(OBJECTS_DIR)/binary_libs. + libraries and `make clean_binary_libs` deletes it. Libraries in the + design's directory (DESIGN_DIR) and libraries the flow generates, such + as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs. default: $(WORK_HOME)/objects/binary_libs stages: - All stages From fd5d8a280d58bfc104f33f7099e354d4e845e4fa Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 23 Oct 2026 02:38:56 +0000 Subject: [PATCH 05/16] Describe the binary liberty variables as the cache now works Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 4 ++-- flow/scripts/variables.json | 4 ++-- flow/scripts/variables.yaml | 26 ++++++++++++-------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index caad108cfa..1f5bb8e5e9 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,7 +105,7 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| -| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries in the design's directory (DESIGN_DIR) and libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.| $(WORK_HOME)/objects/binary_libs| +| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | @@ -328,7 +328,7 @@ configuration file. | TIE_SEPARATION| Distance separating tie high/low instances from the load.| 0| | TNS_END_PERCENT| Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all violating endpoints by default (reduce to 5% for runtime). Specifies how many percent of violating paths to fix [0-100]. Worst path will always be fixed.| 100| | UNSET_ABC9_BOX_CELLS| List of cells to unset the abc9_box attribute on| | -| USE_BINARY_LIBS| Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth, the flow converts every library missing from BINARY_LIBS_DIR. Set to 0 when the flow should read LIB_FILES as given, for example when bazel-orfs provides the binary libraries itself.| 1| +| USE_BINARY_LIBS| Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own. A missing or unusable .blib is read from the text library with a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, for example when bazel-orfs provides binary libraries itself.| 1| | USE_FILL| Whether to perform metal density filling.| 0| | VERILOG_DEFINES| Preprocessor defines passed to the language frontend. Example: `-D HPDCACHE_ASSERT_OFF`| | | VERILOG_FILES| The path to the design Verilog/SystemVerilog files providing a description of modules.| | diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index b6904fe51b..572c1fc795 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -83,7 +83,7 @@ }, "BINARY_LIBS_DIR": { "default": "$(WORK_HOME)/objects/binary_libs", - "description": "Directory of the binary liberty (.blib) cache the OpenROAD stages read instead of the text libraries, stored as /@--.blib so that a changed library gets a new entry. Every design that uses the directory shares it, so set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make binary-libs` fills it with the current design's libraries and `make clean_binary_libs` deletes it. Libraries in the design's directory (DESIGN_DIR) and libraries the flow generates, such as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs.\n", + "description": "Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.\n", "stages": [ "All stages" ] @@ -1511,7 +1511,7 @@ }, "USE_BINARY_LIBS": { "default": 1, - "description": "Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth, the flow converts every library missing from BINARY_LIBS_DIR. Set to 0 when the flow should read LIB_FILES as given, for example when bazel-orfs provides the binary libraries itself.\n", + "description": "Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own. A missing or unusable .blib is read from the text library with a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, for example when bazel-orfs provides binary libraries itself.\n", "stages": [ "All stages" ] diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index c795811535..6361e03d81 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -170,26 +170,24 @@ LIB_FILES: cell. BINARY_LIBS_DIR: description: > - Directory of the binary liberty (.blib) cache the OpenROAD stages read - instead of the text libraries, stored as - /@--.blib so that a changed - library gets a new entry. Every design that uses the directory - shares it, so set it in the environment or settings.mk, not in a - design's config.mk; ORFS clones that set the same directory share their - .blib files. `make binary-libs` fills it with the current design's - libraries and `make clean_binary_libs` deletes it. Libraries in the - design's directory (DESIGN_DIR) and libraries the flow generates, such - as BLOCKS abstracts, are cached per run in $(OBJECTS_DIR)/binary_libs. + Directory of the binary liberty (.blib) cache shared by the designs of + each platform, as `/@--.blib` + so that a changed library gets a new entry. Libraries in DESIGN_DIR and + libraries the flow generates are cached per run in + `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or + settings.mk, not in a design's config.mk; ORFS clones that set the same + directory share their .blib files. `make clean_binary_libs` deletes it. default: $(WORK_HOME)/objects/binary_libs stages: - All stages USE_BINARY_LIBS: description: > Read binary liberty (.blib) files in the OpenROAD stages instead of - parsing the text libraries. Before 1_synth, the flow converts every - library missing from BINARY_LIBS_DIR. Set to 0 when the flow should - read LIB_FILES as given, for example when bazel-orfs provides the - binary libraries itself. + parsing the text libraries. Before 1_synth the flow converts every + library that has no cached .blib, which `make binary-libs` also does on + its own. A missing or unusable .blib is read from the text library with + a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, + for example when bazel-orfs provides binary libraries itself. default: 1 stages: - All stages From b59119ddc55c65920d5fa114306efcaa2c38a8a4 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 23 Oct 2026 11:14:03 +0000 Subject: [PATCH 06/16] Report the most recently written log as the last log Signed-off-by: Eder Monteiro --- flow/util/genReport.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flow/util/genReport.py b/flow/util/genReport.py index 52ec6115dd..cf70e628bc 100755 --- a/flow/util/genReport.py +++ b/flow/util/genReport.py @@ -299,13 +299,15 @@ def write_summary(): # check if design ran to completion without errors or warnings d["log_errors"] = list() d["log_warnings"] = list() - d["last_log"] = "" + d["last_log"] = max( + (name for name in files if name.endswith(".log")), + key=lambda name: os.path.getmtime(os.path.join(log_dir, name)), + default="", + ) for name_ in sorted(files): temp_e, temp_w = parse_messages(os.path.join(log_dir, name_)) d["log_errors"] += temp_e d["log_warnings"] += temp_w - if name_.endswith(".log"): - d["last_log"] = name_ d["finished"] = any(name in files for name in LAST_EXPECTED_LOG) # check if metrics generation had issues From 95f03da3e05afcdc9ef730d5d8c6a408fc6733f8 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Fri, 23 Oct 2026 19:23:58 +0000 Subject: [PATCH 07/16] Drop USE_BINARY_LIBS and read libraries without a usable .blib as given Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 4 +--- flow/Makefile | 11 ++++++----- flow/scripts/util.tcl | 31 ++++++++++++++++-------------- flow/scripts/variables.json | 9 +-------- flow/scripts/variables.yaml | 21 +++++++------------- flow/scripts/write_binary_libs.tcl | 4 ++-- 6 files changed, 34 insertions(+), 46 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 1f5bb8e5e9..d5907c1a31 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,7 +105,7 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| -| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.| $(WORK_HOME)/objects/binary_libs| +| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own, and the OpenROAD stages read the .blib files instead of parsing the text libraries. A library with no usable .blib is read as given. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | @@ -328,7 +328,6 @@ configuration file. | TIE_SEPARATION| Distance separating tie high/low instances from the load.| 0| | TNS_END_PERCENT| Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all violating endpoints by default (reduce to 5% for runtime). Specifies how many percent of violating paths to fix [0-100]. Worst path will always be fixed.| 100| | UNSET_ABC9_BOX_CELLS| List of cells to unset the abc9_box attribute on| | -| USE_BINARY_LIBS| Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own. A missing or unusable .blib is read from the text library with a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, for example when bazel-orfs provides binary libraries itself.| 1| | USE_FILL| Whether to perform metal density filling.| 0| | VERILOG_DEFINES| Preprocessor defines passed to the language frontend. Example: `-D HPDCACHE_ASSERT_OFF`| | | VERILOG_FILES| The path to the design Verilog/SystemVerilog files providing a description of modules.| | @@ -640,7 +639,6 @@ configuration file. - [OPENROAD_HIERARCHICAL](#OPENROAD_HIERARCHICAL) - [SWAP_ARITH_OPERATORS](#SWAP_ARITH_OPERATORS) - [SYNTH_WRAPPED_OPERATORS](#SYNTH_WRAPPED_OPERATORS) -- [USE_BINARY_LIBS](#USE_BINARY_LIBS) - [WRITE_ODB_AND_SDC_EACH_STAGE](#WRITE_ODB_AND_SDC_EACH_STAGE) ## generate_abstract variables diff --git a/flow/Makefile b/flow/Makefile index ecb9e97d83..a8fc438f3c 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -294,16 +294,17 @@ endif # OpenROAD stages read binary liberty (.blib) files from a cache shared by # all designs, see scripts/write_binary_libs.tcl. Yosys reads the text libraries. -ifeq ($(USE_BINARY_LIBS),1) -.PHONY: binary-libs do-binary-libs -binary-libs: do-binary-libs +.PHONY: binary-libs +binary-libs: + $(UNSET_AND_MAKE) do-binary-libs + +.PHONY: do-binary-libs do-binary-libs: @mkdir -p $(LOG_DIR) $(RUN_CMD) --log $(abspath $(LOG_DIR)/write_binary_libs.log) --tee -- $(OPENROAD_CMD) $(SCRIPTS_DIR)/write_binary_libs.tcl # Order-only, so filling the cache never reruns the flow. -$(RESULTS_DIR)/1_synth.odb: | do-binary-libs -endif +$(RESULTS_DIR)/1_synth.odb: | binary-libs .PHONY: clean_binary_libs clean_binary_libs: diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index fb0b8e1e82..0bece1d8de 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -477,11 +477,8 @@ proc source_step_tcl { hook_type step_name } { proc binary_lib_path { lib_file } { set source [file normalize $lib_file] set root [file join $::env(BINARY_LIBS_DIR) $::env(PLATFORM)] - set run_dirs [list \ + set run_dirs [list $::env(DESIGN_DIR) \ [file join $::env(WORK_HOME) objects] [file join $::env(WORK_HOME) results]] - if { [env_var_exists_and_non_empty DESIGN_DIR] } { - lappend run_dirs $::env(DESIGN_DIR) - } foreach dir $run_dirs { if { [string first "[file normalize $dir]/" $source] == 0 } { set root [file join $::env(OBJECTS_DIR) binary_libs] @@ -495,19 +492,25 @@ proc binary_lib_path { lib_file } { return [file join $root "$name@[file size $source]-[file mtime $source]-$dir_hash.blib"] } -# The cached .blib for lib_file, or lib_file when the .blib is missing or unusable +# Whether this OpenROAD reads blib. An entry missing or written by another +# version is expected, so its error is not reported. +proc binary_lib_usable { blib } { + suppress_message STA 1900 + suppress_message STA 1902 + set usable [expr { ![catch { liberty_binary_info $blib }] }] + unsuppress_message STA 1900 + unsuppress_message STA 1902 + return $usable +} + +# The cached .blib for lib_file, or lib_file when there is no usable .blib proc lib_file_to_read { lib_file } { - if { ![env_var_equals USE_BINARY_LIBS 1] || ![file exists $lib_file] } { + if { ![file exists $lib_file] } { return $lib_file } set blib [binary_lib_path $lib_file] - if { ![file exists $blib] } { - utl::warn FLW 26 "$blib not found, reading $lib_file." - return $lib_file - } - if { [catch { liberty_binary_info $blib } msg] } { - utl::warn FLW 27 "$blib is unusable, reading $lib_file: $msg" - return $lib_file + if { [binary_lib_usable $blib] } { + return $blib } - return $blib + return $lib_file } diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 572c1fc795..85a4bd279f 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -83,7 +83,7 @@ }, "BINARY_LIBS_DIR": { "default": "$(WORK_HOME)/objects/binary_libs", - "description": "Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.\n", + "description": "Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own, and the OpenROAD stages read the .blib files instead of parsing the text libraries. A library with no usable .blib is read as given. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.\n", "stages": [ "All stages" ] @@ -1509,13 +1509,6 @@ "synth" ] }, - "USE_BINARY_LIBS": { - "default": 1, - "description": "Read binary liberty (.blib) files in the OpenROAD stages instead of parsing the text libraries. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own. A missing or unusable .blib is read from the text library with a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, for example when bazel-orfs provides binary libraries itself.\n", - "stages": [ - "All stages" - ] - }, "USE_FILL": { "default": 0, "description": "Whether to perform metal density filling.\n" diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 6361e03d81..3f269d4884 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -174,23 +174,16 @@ BINARY_LIBS_DIR: each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in - `$(OBJECTS_DIR)/binary_libs` instead. Set it in the environment or - settings.mk, not in a design's config.mk; ORFS clones that set the same - directory share their .blib files. `make clean_binary_libs` deletes it. + `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts + every library that has no cached .blib, which `make binary-libs` also + does on its own, and the OpenROAD stages read the .blib files instead of + parsing the text libraries. A library with no usable .blib is read as + given. Set it in the environment or settings.mk, not in a design's + config.mk; ORFS clones that set the same directory share their .blib + files. `make clean_binary_libs` deletes it. default: $(WORK_HOME)/objects/binary_libs stages: - All stages -USE_BINARY_LIBS: - description: > - Read binary liberty (.blib) files in the OpenROAD stages instead of - parsing the text libraries. Before 1_synth the flow converts every - library that has no cached .blib, which `make binary-libs` also does on - its own. A missing or unusable .blib is read from the text library with - a warning. Set to 0 to read LIB_FILES and `_LIB_FILES` as given, - for example when bazel-orfs provides binary libraries itself. - default: 1 - stages: - - All stages LIB_MODEL: description: > Selects between NLDM and CCS timing models for the ASAP7 platform. diff --git a/flow/scripts/write_binary_libs.tcl b/flow/scripts/write_binary_libs.tcl index 425fe08c83..efb694258f 100644 --- a/flow/scripts/write_binary_libs.tcl +++ b/flow/scripts/write_binary_libs.tcl @@ -23,7 +23,7 @@ foreach lib_file $lib_files { continue } set seen($blib) 1 - if { [file exists $blib] && ![catch { liberty_binary_info $blib }] } { + if { [binary_lib_usable $blib] } { incr cached continue } @@ -37,7 +37,7 @@ foreach lib_file $lib_files { } msg] } { file delete -force $tmp - utl::warn FLW 28 "Could not write $blib: $msg" + puts "Could not write $blib: $msg" continue } incr written From 22c63071227ca1f7175b32bfc9a5396dfbc9ee45 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Mon, 26 Oct 2026 20:18:44 +0000 Subject: [PATCH 08/16] Keep the OpenROAD version master pins Signed-off-by: Eder Monteiro --- tools/OpenROAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/OpenROAD b/tools/OpenROAD index b9ec64c305..bc739caf43 160000 --- a/tools/OpenROAD +++ b/tools/OpenROAD @@ -1 +1 @@ -Subproject commit b9ec64c305c40780d6534494bdb152794aabdc6a +Subproject commit bc739caf43047bfc2e225fe10dd968d672b617f8 From 56f8167134af8591cf01b53c76754fd0eca9ac0d Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Mon, 26 Oct 2026 20:22:34 +0000 Subject: [PATCH 09/16] Keep the .blib cache in objects/ and convert only when a library changes Signed-off-by: Eder Monteiro --- docs/user/FlowVariables.md | 2 -- flow/Makefile | 12 ++++++++---- flow/scripts/util.tcl | 16 ++++++++-------- flow/scripts/variables.json | 7 ------- flow/scripts/variables.yaml | 16 ---------------- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 65aea7c51b..8d32a9d6ad 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -105,7 +105,6 @@ configuration file. | ASAP7_USE_VT| A space separated list of VT options to use with the ASAP7 standard cell library: RVT, LVT, SLVT.| RVT| | AUTO_MEMORIES| Experimental. When set to 1, memories that yosys infers in the RTL (`$mem_v2` cells, module boundary only) are detected pre-synthesis, inventoried in `$(RESULTS_DIR)/memories.json`, and — when idiomatic as an SRAM macro — given generated .lib/.lef views under `$(RESULTS_DIR)/memories/`. Synthesis blackboxes those modules and all later stages read the generated views, so an existing design gets macro-based results without a memory compiler. Supported for the asap7 platform only. See docs/user/AutoMemories.md.| 0| | BALANCE_ROWS| Balance rows during placement.| 0| -| BINARY_LIBS_DIR| Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own, and the OpenROAD stages read the .blib files instead of parsing the text libraries. A library with no usable .blib is read as given. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.| $(WORK_HOME)/objects/binary_libs| | BLOCKS| Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.| | | BUFFER_PORTS_ARGS| Specify arguments to the buffer_ports call during placement. Only used if DONT_BUFFER_PORTS=0.| | | CACHED_REPORTS| List of pre-existing report files to copy into the reports directory before synthesis. Used when reusing prior synthesis results with SYNTH_NETLIST_FILES.| | @@ -636,7 +635,6 @@ configuration file. ## All stages variables - [ASAP7_USE_VT](#ASAP7_USE_VT) -- [BINARY_LIBS_DIR](#BINARY_LIBS_DIR) - [CORNERS](#CORNERS) - [KEEP_VARS](#KEEP_VARS) - [NUM_CORES](#NUM_CORES) diff --git a/flow/Makefile b/flow/Makefile index a8fc438f3c..6fbaa656c2 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -293,7 +293,8 @@ $(OBJECTS_DIR)/klayout.lyt: $(RESULTS_DIR)/memories.json endif # OpenROAD stages read binary liberty (.blib) files from a cache shared by -# all designs, see scripts/write_binary_libs.tcl. Yosys reads the text libraries. +# all designs in $(WORK_HOME)/objects/binary_libs, see +# scripts/write_binary_libs.tcl. Yosys reads the text libraries. .PHONY: binary-libs binary-libs: $(UNSET_AND_MAKE) do-binary-libs @@ -303,12 +304,15 @@ do-binary-libs: @mkdir -p $(LOG_DIR) $(RUN_CMD) --log $(abspath $(LOG_DIR)/write_binary_libs.log) --tee -- $(OPENROAD_CMD) $(SCRIPTS_DIR)/write_binary_libs.tcl -# Order-only, so filling the cache never reruns the flow. -$(RESULTS_DIR)/1_synth.odb: | binary-libs +$(LOG_DIR)/write_binary_libs.log: $(LIB_FILES) + $(UNSET_AND_MAKE) do-binary-libs + +# Order-only, so converting never reruns the flow. +$(RESULTS_DIR)/1_synth.odb: | $(LOG_DIR)/write_binary_libs.log .PHONY: clean_binary_libs clean_binary_libs: - rm -rf $(if $(strip $(BINARY_LIBS_DIR)),$(BINARY_LIBS_DIR),$(error BINARY_LIBS_DIR is empty)) + rm -rf $(WORK_HOME)/objects/binary_libs .PHONY: do-yosys do-yosys: yosys-dependencies diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index daf00f2049..465bb567ee 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -505,16 +505,16 @@ proc synth_verilog_files { } { return $copies } -# Entry of lib_file in the binary liberty (.blib) cache: -# /@--.blib, so a changed library gets -# a new entry and same-named libraries from different directories don't -# collide. Libraries in the design's directory and those the flow generates -# are cached per run. +# Entry of lib_file in the binary liberty (.blib) cache shared by all designs: +# objects/binary_libs//@--.blib, so a +# changed library gets a new entry and same-named libraries from different +# directories don't collide. Libraries in the design's directory and those the +# flow generates are cached per run. proc binary_lib_path { lib_file } { set source [file normalize $lib_file] - set root [file join $::env(BINARY_LIBS_DIR) $::env(PLATFORM)] - set run_dirs [list $::env(DESIGN_DIR) \ - [file join $::env(WORK_HOME) objects] [file join $::env(WORK_HOME) results]] + set objects [file join $::env(WORK_HOME) objects] + set root [file join $objects binary_libs $::env(PLATFORM)] + set run_dirs [list $::env(DESIGN_DIR) $objects [file join $::env(WORK_HOME) results]] foreach dir $run_dirs { if { [string first "[file normalize $dir]/" $source] == 0 } { set root [file join $::env(OBJECTS_DIR) binary_libs] diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 6adbc381e0..2810d1ec80 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -81,13 +81,6 @@ "place" ] }, - "BINARY_LIBS_DIR": { - "default": "$(WORK_HOME)/objects/binary_libs", - "description": "Directory of the binary liberty (.blib) cache shared by the designs of each platform, as `/@--.blib` so that a changed library gets a new entry. Libraries in DESIGN_DIR and libraries the flow generates are cached per run in `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts every library that has no cached .blib, which `make binary-libs` also does on its own, and the OpenROAD stages read the .blib files instead of parsing the text libraries. A library with no usable .blib is read as given. Set it in the environment or settings.mk, not in a design's config.mk; ORFS clones that set the same directory share their .blib files. `make clean_binary_libs` deletes it.\n", - "stages": [ - "All stages" - ] - }, "BLOCKS": { "description": "Blocks used as hard macros in a hierarchical flow. Do note that you have to specify block-specific inputs file in the directory mentioned by Makefile.\n" }, diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index f75fc0f1f8..4d71623a35 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -168,22 +168,6 @@ LIB_FILES: A Liberty file of the standard cell library with PVT characterization, input and output characteristics, timing and power definitions for each cell. -BINARY_LIBS_DIR: - description: > - Directory of the binary liberty (.blib) cache shared by the designs of - each platform, as `/@--.blib` - so that a changed library gets a new entry. Libraries in DESIGN_DIR and - libraries the flow generates are cached per run in - `$(OBJECTS_DIR)/binary_libs` instead. Before 1_synth the flow converts - every library that has no cached .blib, which `make binary-libs` also - does on its own, and the OpenROAD stages read the .blib files instead of - parsing the text libraries. A library with no usable .blib is read as - given. Set it in the environment or settings.mk, not in a design's - config.mk; ORFS clones that set the same directory share their .blib - files. `make clean_binary_libs` deletes it. - default: $(WORK_HOME)/objects/binary_libs - stages: - - All stages LIB_MODEL: description: > Selects between NLDM and CCS timing models for the ASAP7 platform. From a01e937baca724a3085b9f4b19451ee9040bb88e Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Mon, 26 Oct 2026 20:26:12 +0000 Subject: [PATCH 10/16] Read the libraries without checking that they exist, as the Tcl contract asks Signed-off-by: Eder Monteiro --- flow/scripts/util.tcl | 3 --- flow/scripts/write_binary_libs.tcl | 4 ---- 2 files changed, 7 deletions(-) diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index 465bb567ee..1443319064 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -541,9 +541,6 @@ proc binary_lib_usable { blib } { # The cached .blib for lib_file, or lib_file when there is no usable .blib proc lib_file_to_read { lib_file } { - if { ![file exists $lib_file] } { - return $lib_file - } set blib [binary_lib_path $lib_file] if { [binary_lib_usable $blib] } { return $blib diff --git a/flow/scripts/write_binary_libs.tcl b/flow/scripts/write_binary_libs.tcl index efb694258f..c52f668e3a 100644 --- a/flow/scripts/write_binary_libs.tcl +++ b/flow/scripts/write_binary_libs.tcl @@ -14,10 +14,6 @@ set written 0 set cached 0 array set seen {} foreach lib_file $lib_files { - # Libraries the flow has not generated yet are converted on a later run - if { ![file exists $lib_file] } { - continue - } set blib [binary_lib_path $lib_file] if { [info exists seen($blib)] } { continue From baf96edc7916fa2e350a01dcda8f019d134b013f Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Tue, 27 Oct 2026 14:15:09 +0000 Subject: [PATCH 11/16] use latest openroad Signed-off-by: Eder Monteiro --- tools/OpenROAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/OpenROAD b/tools/OpenROAD index bc739caf43..c0637abc7d 160000 --- a/tools/OpenROAD +++ b/tools/OpenROAD @@ -1 +1 @@ -Subproject commit bc739caf43047bfc2e225fe10dd968d672b617f8 +Subproject commit c0637abc7dd25f29f000a79af2e182c0a3aad5ea From 8c0a9b83d5b710c5b99d9e3a665a413d5167f0d8 Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Tue, 27 Oct 2026 19:15:50 +0000 Subject: [PATCH 12/16] Stop the run when a .blib can't be written, and retry it on the next make Signed-off-by: Eder Monteiro --- flow/Makefile | 5 ++++- flow/scripts/write_binary_libs.tcl | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flow/Makefile b/flow/Makefile index 6fbaa656c2..3a42a9044d 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -302,8 +302,11 @@ binary-libs: .PHONY: do-binary-libs do-binary-libs: @mkdir -p $(LOG_DIR) - $(RUN_CMD) --log $(abspath $(LOG_DIR)/write_binary_libs.log) --tee -- $(OPENROAD_CMD) $(SCRIPTS_DIR)/write_binary_libs.tcl + $(RUN_CMD) --log $(abspath $(LOG_DIR)/write_binary_libs.tmp.log) --tee -- $(OPENROAD_CMD) $(SCRIPTS_DIR)/write_binary_libs.tcl + mv $(LOG_DIR)/write_binary_libs.tmp.log $(LOG_DIR)/write_binary_libs.log +# do-binary-libs renames its log into place only when it succeeds, so a +# failed conversion runs again. $(LOG_DIR)/write_binary_libs.log: $(LIB_FILES) $(UNSET_AND_MAKE) do-binary-libs diff --git a/flow/scripts/write_binary_libs.tcl b/flow/scripts/write_binary_libs.tcl index c52f668e3a..a663fdc10a 100644 --- a/flow/scripts/write_binary_libs.tcl +++ b/flow/scripts/write_binary_libs.tcl @@ -33,8 +33,7 @@ foreach lib_file $lib_files { } msg] } { file delete -force $tmp - puts "Could not write $blib: $msg" - continue + error "Could not write $blib: $msg" } incr written } From 4850570cc42e90498b8d7a10421a6957ac5b80bc Mon Sep 17 00:00:00 2001 From: Eder Monteiro Date: Tue, 27 Oct 2026 20:42:20 +0000 Subject: [PATCH 13/16] Convert the libraries again when a corner library changes Signed-off-by: Eder Monteiro --- flow/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flow/Makefile b/flow/Makefile index 3a42a9044d..46c8c79bd0 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -307,7 +307,8 @@ do-binary-libs: # do-binary-libs renames its log into place only when it succeeds, so a # failed conversion runs again. -$(LOG_DIR)/write_binary_libs.log: $(LIB_FILES) +$(LOG_DIR)/write_binary_libs.log: $(LIB_FILES) \ + $(foreach corner,$(shell echo $(CORNERS) | tr '[:lower:]' '[:upper:]'),$($(corner)_LIB_FILES)) $(UNSET_AND_MAKE) do-binary-libs # Order-only, so converting never reruns the flow. From 38b1fcb4618d9e2b0af0b549766f14b19387737f Mon Sep 17 00:00:00 2001 From: Jonas Gava Date: Wed, 4 Nov 2026 12:05:18 +0000 Subject: [PATCH 14/16] update OR submodule Signed-off-by: Jonas Gava --- tools/OpenROAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/OpenROAD b/tools/OpenROAD index c0637abc7d..f131605002 160000 --- a/tools/OpenROAD +++ b/tools/OpenROAD @@ -1 +1 @@ -Subproject commit c0637abc7dd25f29f000a79af2e182c0a3aad5ea +Subproject commit f131605002c80444f79b18e95e0c7cb657ec024d From b9690c21147ea523ef58baaf47bee7d74f72384b Mon Sep 17 00:00:00 2001 From: Jonas Gava Date: Wed, 4 Nov 2026 12:57:33 +0000 Subject: [PATCH 15/16] Keep the OpenROAD version master pins Signed-off-by: Jonas Gava --- tools/OpenROAD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/OpenROAD b/tools/OpenROAD index f131605002..f3d27840b6 160000 --- a/tools/OpenROAD +++ b/tools/OpenROAD @@ -1 +1 @@ -Subproject commit f131605002c80444f79b18e95e0c7cb657ec024d +Subproject commit f3d27840b65a9571a808a19b06dc0b93b9d4423d From 892ef05a4ca387a1d2da42878a10ee31a5883cc8 Mon Sep 17 00:00:00 2001 From: Jonas Gava Date: Thu, 5 Nov 2026 00:06:03 +0000 Subject: [PATCH 16/16] Convert the libraries again after clean_all or clean_binary_libs Signed-off-by: Jonas Gava --- flow/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flow/Makefile b/flow/Makefile index 46c8c79bd0..11e28f8878 100644 --- a/flow/Makefile +++ b/flow/Makefile @@ -306,7 +306,8 @@ do-binary-libs: mv $(LOG_DIR)/write_binary_libs.tmp.log $(LOG_DIR)/write_binary_libs.log # do-binary-libs renames its log into place only when it succeeds, so a -# failed conversion runs again. +# failed conversion runs again. clean_all and clean_binary_libs delete the +# log with the cache it records, so the next make fills the cache again. $(LOG_DIR)/write_binary_libs.log: $(LIB_FILES) \ $(foreach corner,$(shell echo $(CORNERS) | tr '[:lower:]' '[:upper:]'),$($(corner)_LIB_FILES)) $(UNSET_AND_MAKE) do-binary-libs @@ -317,6 +318,7 @@ $(RESULTS_DIR)/1_synth.odb: | $(LOG_DIR)/write_binary_libs.log .PHONY: clean_binary_libs clean_binary_libs: rm -rf $(WORK_HOME)/objects/binary_libs + rm -f $(LOG_DIR)/write_binary_libs.log .PHONY: do-yosys do-yosys: yosys-dependencies @@ -878,6 +880,7 @@ clean: .PHONY: clean_all clean_all: clean_synth clean_floorplan clean_place clean_cts clean_route clean_finish clean_metadata clean_abstract rm -rf $(OBJECTS_DIR) + rm -f $(LOG_DIR)/write_binary_libs*.log .PHONY: nuke nuke: clean_test clean_issues