From b678c238e45cd49d233edc9c885ba8a169d1ce59 Mon Sep 17 00:00:00 2001 From: nella Date: Fri, 10 Jul 2026 12:44:34 +0200 Subject: [PATCH 01/10] Include build datetime in scl cache hash. --- kernel/version.cc.in | 1 + kernel/yosys.h | 1 + passes/techmap/liberty_cache.h | 3 +++ 3 files changed, 5 insertions(+) diff --git a/kernel/version.cc.in b/kernel/version.cc.in index b6d1139d6..399f67cec 100644 --- a/kernel/version.cc.in +++ b/kernel/version.cc.in @@ -1,4 +1,5 @@ namespace Yosys { const char *yosys_version_str = "@YOSYS_BUILD_INFO@"; const char *yosys_git_hash_str = "@YOSYS_CHECKOUT_INFO@"; + const char *yosys_build_datetime_str = __DATE__ " " __TIME__; } diff --git a/kernel/yosys.h b/kernel/yosys.h index 9f5a16a9c..fd33a4767 100644 --- a/kernel/yosys.h +++ b/kernel/yosys.h @@ -82,6 +82,7 @@ extern std::set yosys_input_files, yosys_output_files; // from kernel/version_*.o (cc source generated from Makefile) extern const char *yosys_version_str; extern const char *yosys_git_hash_str; +extern const char *yosys_build_datetime_str; const char* yosys_maybe_version(); // from passes/cmds/design.cc diff --git a/passes/techmap/liberty_cache.h b/passes/techmap/liberty_cache.h index 01a7bf395..0498cf8a1 100644 --- a/passes/techmap/liberty_cache.h +++ b/passes/techmap/liberty_cache.h @@ -49,6 +49,9 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector Date: Fri, 10 Jul 2026 14:51:58 +0200 Subject: [PATCH 02/10] Reformat scl cache. --- passes/techmap/liberty_cache.h | 1 - 1 file changed, 1 deletion(-) diff --git a/passes/techmap/liberty_cache.h b/passes/techmap/liberty_cache.h index 0498cf8a1..baab8f8be 100644 --- a/passes/techmap/liberty_cache.h +++ b/passes/techmap/liberty_cache.h @@ -50,7 +50,6 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector Date: Fri, 10 Jul 2026 14:52:06 +0200 Subject: [PATCH 03/10] Add scl caching test. --- tests/liberty/scl_cache.ys | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/liberty/scl_cache.ys diff --git a/tests/liberty/scl_cache.ys b/tests/liberty/scl_cache.ys new file mode 100644 index 000000000..85fbae839 --- /dev/null +++ b/tests/liberty/scl_cache.ys @@ -0,0 +1,7 @@ +read_verilog small.v +synth -top small +abc -liberty normal.lib + +logger -expect log "using cached merged SCL" 1 +abc -liberty normal.lib +logger -check-expected From 30ba4328e728d2d5e2981378557b1b688722404c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 13 Jul 2026 15:26:00 +0200 Subject: [PATCH 04/10] Use system libs when available --- frontends/CMakeLists.txt | 4 ++- frontends/slang/CMakeLists.txt | 1 - libs/CMakeLists.txt | 55 +++++++++++++++++++++------------- libs/slang | 2 +- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/frontends/CMakeLists.txt b/frontends/CMakeLists.txt index 6e6eda488..983fa2fd9 100644 --- a/frontends/CMakeLists.txt +++ b/frontends/CMakeLists.txt @@ -6,6 +6,8 @@ add_subdirectory(json) add_subdirectory(liberty) add_subdirectory(rpc) add_subdirectory(rtlil) -add_subdirectory(slang) +if (NOT YOSYS_WITHOUT_SLANG) + add_subdirectory(slang) +endif() add_subdirectory(verific) add_subdirectory(verilog) diff --git a/frontends/slang/CMakeLists.txt b/frontends/slang/CMakeLists.txt index dae714de9..83bf98573 100644 --- a/frontends/slang/CMakeLists.txt +++ b/frontends/slang/CMakeLists.txt @@ -35,5 +35,4 @@ yosys_frontend(slang ${CMAKE_CURRENT_BINARY_DIR} LIBRARIES $<${YOSYS_ENABLE_SLANG}:slang::slang> - fmt::fmt ) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 5ea08ef9d..385425af2 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -12,28 +12,43 @@ block() include(FetchContent) set(FETCHCONTENT_FULLY_DISCONNECTED ON) - option(FMT_INSTALL OFF) - FetchContent_Declare( - fmt - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt - ) - FetchContent_MakeAvailable(fmt) + find_package(fmt 12.2 QUIET) + if(fmt_FOUND) + set(SLANG_USE_SYSTEM_FMT ON) + else() + option(FMT_INSTALL OFF) + FetchContent_Declare( + fmt + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt + ) + FetchContent_MakeAvailable(fmt) + endif() - FetchContent_Declare( - tomlplusplus - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tomlplusplus - ) - FetchContent_MakeAvailable(tomlplusplus) + find_package(tomlplusplus 3.4 QUIET) + if(tomlplusplus_FOUND) + set(SLANG_USE_SYSTEM_TOMLPLUSPLUS ON) + else() + FetchContent_Declare( + tomlplusplus + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tomlplusplus + ) + FetchContent_MakeAvailable(tomlplusplus) + endif() - FetchContent_Declare( - boost_regex - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost_regex - SOURCE_SUBDIR _no_build_ - ) - FetchContent_MakeAvailable(boost_regex) + find_package(Boost 1.87.0 CONFIG QUIET) + if(Boost_FOUND) + set(SLANG_USE_SYSTEM_BOOST ON) + else() + FetchContent_Declare( + boost_regex + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/boost_regex + SOURCE_SUBDIR _no_build_ + ) + FetchContent_MakeAvailable(boost_regex) + endif() if (NOT YOSYS_WITHOUT_SLANG) set(SLANG_USE_MIMALLOC OFF) diff --git a/libs/slang b/libs/slang index 617575096..8acc660a2 160000 --- a/libs/slang +++ b/libs/slang @@ -1 +1 @@ -Subproject commit 6175750969f17289695f94be5105f6006c82eb61 +Subproject commit 8acc660a20b70de48ecec1c7471863e6f4b3ae6f From 3541e31457ca400ac4e8cb50aafe2114644e6334 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 13 Jul 2026 16:50:06 +0200 Subject: [PATCH 05/10] Add option to use bundled libs --- .github/workflows/test-build.yml | 2 +- CMakeLists.txt | 2 ++ libs/CMakeLists.txt | 12 +++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 33205aa83..566aad3c7 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -93,7 +93,7 @@ jobs: shell: bash run: | rm -rf build - cmake -B build . -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DYOSYS_COMPILER_LAUNCHER=ccache + cmake -B build . -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DYOSYS_COMPILER_LAUNCHER=ccache -DYOSYS_USE_BUNDLED_LIBS=ON cmake --build build -j$procs ctest --test-dir build/tests/unit diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3766fd7..3745ea0fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,8 @@ option(YOSYS_WITHOUT_SLANG "Disable Slang integration" OFF) option(YOSYS_WITHOUT_TCL "Disable Tcl integration" OFF) option(YOSYS_WITH_PYTHON "Enable Python integration" OFF) +option(YOSYS_USE_BUNDLED_LIBS "Use bundled third-party libraries" OFF) + set(YOSYS_VERIFIC_DIR "" CACHE FILEPATH "Path to the Verific source code (empty to disable)") set(YOSYS_VERIFIC_COMPONENTS "" CACHE STRING "List of Verific components to link (empty for autodetect)") diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 385425af2..cb81b3af2 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -12,7 +12,9 @@ block() include(FetchContent) set(FETCHCONTENT_FULLY_DISCONNECTED ON) - find_package(fmt 12.2 QUIET) + if(NOT YOSYS_USE_BUNDLED_LIBS) + find_package(fmt 12.2 QUIET) + endif() if(fmt_FOUND) set(SLANG_USE_SYSTEM_FMT ON) else() @@ -25,7 +27,9 @@ block() FetchContent_MakeAvailable(fmt) endif() - find_package(tomlplusplus 3.4 QUIET) + if(NOT YOSYS_USE_BUNDLED_LIBS) + find_package(tomlplusplus 3.4 QUIET) + endif() if(tomlplusplus_FOUND) set(SLANG_USE_SYSTEM_TOMLPLUSPLUS ON) else() @@ -37,7 +41,9 @@ block() FetchContent_MakeAvailable(tomlplusplus) endif() - find_package(Boost 1.87.0 CONFIG QUIET) + if(NOT YOSYS_USE_BUNDLED_LIBS) + find_package(Boost 1.87.0 CONFIG QUIET) + endif() if(Boost_FOUND) set(SLANG_USE_SYSTEM_BOOST ON) else() From 332ea782eb1a87196ea3bc08cd60f0db7f088250 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 14 Jul 2026 15:01:31 +0200 Subject: [PATCH 06/10] dfflibmap: fix resetval clobber --- passes/techmap/dfflibmap.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/passes/techmap/dfflibmap.cc b/passes/techmap/dfflibmap.cc index e8fc6fc12..b2caae460 100644 --- a/passes/techmap/dfflibmap.cc +++ b/passes/techmap/dfflibmap.cc @@ -272,17 +272,18 @@ static void find_cell(std::vector cells, IdString cell_type, if (!parse_next_state(cell, ff->find("next_state"), cell_next_pin, cell_next_pol, cell_enable_pin, cell_enable_pol) || (has_enable && (cell_enable_pin.empty() || cell_enable_pol != enapol))) continue; + bool cell_rstval = rstval; if (has_reset && !cell_next_pol) { // next_state is negated // we later propagate this inversion to the output, // which requires the negation of the reset value - rstval = !rstval; + cell_rstval = !rstval; } - if (has_reset && rstval == false) { + if (has_reset && cell_rstval == false) { if (!parse_pin(cell, ff->find("clear"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; } - if (has_reset && rstval == true) { + if (has_reset && cell_rstval == true) { if (!parse_pin(cell, ff->find("preset"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; } From eb96123030b253590009e56784876bd5b0da752d Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 14 Jul 2026 18:02:02 +0200 Subject: [PATCH 07/10] dfflibmap: add regression test for resetval clobber --- tests/techmap/dfflibmap_resetval_clobber.lib | 52 ++++++++++++++++++++ tests/techmap/dfflibmap_resetval_clobber.ys | 13 +++++ 2 files changed, 65 insertions(+) create mode 100644 tests/techmap/dfflibmap_resetval_clobber.lib create mode 100644 tests/techmap/dfflibmap_resetval_clobber.ys diff --git a/tests/techmap/dfflibmap_resetval_clobber.lib b/tests/techmap/dfflibmap_resetval_clobber.lib new file mode 100644 index 000000000..dcf4e4402 --- /dev/null +++ b/tests/techmap/dfflibmap_resetval_clobber.lib @@ -0,0 +1,52 @@ +library(test) { + cell (bad_dff) { + area : 1; + ff("IQ", "IQN") { + next_state : "!D"; // Look here + clocked_on : "CLK"; + preset : "!RST"; // Look here + } + pin(D) { + direction : input; + } + pin(CLK) { + direction : input; + } + pin(RST) { + direction : input; + } + pin(Q) { + direction: output; + function : "IQ"; + } + pin(QN) { + direction: output; + function : "IQN"; + } + } + cell (good_dff) { + area : 1; + ff("IQ", "IQN") { + next_state : "D"; // Look here + clocked_on : "CLK"; + clear : "RST"; // Look here + } + pin(D) { + direction : input; + } + pin(CLK) { + direction : input; + } + pin(RST) { + direction : input; + } + pin(Q) { + direction: output; + function : "IQ"; + } + pin(QN) { + direction: output; + function : "IQN"; + } + } +} diff --git a/tests/techmap/dfflibmap_resetval_clobber.ys b/tests/techmap/dfflibmap_resetval_clobber.ys new file mode 100644 index 000000000..aacf40f6c --- /dev/null +++ b/tests/techmap/dfflibmap_resetval_clobber.ys @@ -0,0 +1,13 @@ +read_verilog -icells < Date: Wed, 15 Jul 2026 08:24:46 +0200 Subject: [PATCH 08/10] Update sv-elab to 3dddccd --- frontends/slang/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontends/slang/lib b/frontends/slang/lib index 2caaaefa8..3dddccd47 160000 --- a/frontends/slang/lib +++ b/frontends/slang/lib @@ -1 +1 @@ -Subproject commit 2caaaefa831a1d548a681268ccf3eea925ca1312 +Subproject commit 3dddccd478618d68f8a5e160fb4b5783c4da35d4 From 6fa68497342842583bd20b9128aca494ab229fb1 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 15 Jul 2026 08:54:10 +0200 Subject: [PATCH 09/10] codeql: do not generate reports for 3rd party code --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 708f6e4ac..2c4d36a83 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -34,7 +34,7 @@ jobs: echo 'set(CMAKE_C_COMPILER clang CACHE STRING "")' >> Configuration.cmake echo 'set(CMAKE_CXX_COMPILER clang++ CACHE STRING "")' >> Configuration.cmake - cmake -C Configuration.cmake -B build . + cmake -C Configuration.cmake -B build . -DYOSYS_WITHOUT_ABC=ON -DYOSYS_WITHOUT_SLANG=ON cmake --build build -j6 - name: Perform CodeQL Analysis From 63457de80e3d355175a33c57ef2731fa9557f136 Mon Sep 17 00:00:00 2001 From: Johan Olby Date: Wed, 15 Jul 2026 16:21:07 +0200 Subject: [PATCH 10/10] mul2dsp: normalize operand order Move the operand commute that puts the wider operand on A ahead of the min-width checks. Checking the min-widths first made an asymmetric rule (DSP_A_MINWIDTH != DSP_B_MINWIDTH) match only products that already had the wider operand on A; a product in the other order was rejected before the normalization. --- techlibs/common/mul2dsp.v | 26 ++++++++++++----------- tests/techmap/mul2dsp_asymmetric.ys | 32 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 tests/techmap/mul2dsp_asymmetric.ys diff --git a/techlibs/common/mul2dsp.v b/techlibs/common/mul2dsp.v index 4ac03cad4..be0172dc9 100644 --- a/techlibs/common/mul2dsp.v +++ b/techlibs/common/mul2dsp.v @@ -68,6 +68,20 @@ module _80_mul (A, B, Y); generate if (0) begin end + // Normalize operand order (wider operand on A) to simplify asymmetric + // rules (DSP_A_MINWIDTH != DSP_B_MINWIDTH) below. + else if (_TECHMAP_CELLTYPE_ == "$mul" && A_WIDTH < B_WIDTH) + \$mul #( + .A_SIGNED(B_SIGNED), + .B_SIGNED(A_SIGNED), + .A_WIDTH(B_WIDTH), + .B_WIDTH(A_WIDTH), + .Y_WIDTH(Y_WIDTH) + ) _TECHMAP_REPLACE_ ( + .A(B), + .B(A), + .Y(Y) + ); `ifdef DSP_A_MINWIDTH else if (A_WIDTH < `DSP_A_MINWIDTH) wire _TECHMAP_FAIL_ = 1; @@ -94,18 +108,6 @@ module _80_mul (A, B, Y); .Y(Y) ); `endif - else if (_TECHMAP_CELLTYPE_ == "$mul" && A_WIDTH < B_WIDTH) - \$mul #( - .A_SIGNED(B_SIGNED), - .B_SIGNED(A_SIGNED), - .A_WIDTH(B_WIDTH), - .B_WIDTH(A_WIDTH), - .Y_WIDTH(Y_WIDTH) - ) _TECHMAP_REPLACE_ ( - .A(B), - .B(A), - .Y(Y) - ); else begin wire [1023:0] _TECHMAP_DO_ = "proc; clean"; diff --git a/tests/techmap/mul2dsp_asymmetric.ys b/tests/techmap/mul2dsp_asymmetric.ys new file mode 100644 index 000000000..216d68e7f --- /dev/null +++ b/tests/techmap/mul2dsp_asymmetric.ys @@ -0,0 +1,32 @@ +# Test operand-order normalization: a 4x13 product with an asymmetric rule +# (A_MIN=10, B_MIN=4) fails in this order (A=4 < A_MIN) but maps to one DSP +# cell once the wide operand is normalized onto A. + +read_verilog <