From 65d7d70507cc007a66d5e876a2246b4aa6d784c5 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 14 Nov 2025 15:31:45 +0100 Subject: [PATCH 1/8] driver: move IdString collection to yosys_shutdown --- kernel/driver.cc | 1 - kernel/yosys.cc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/driver.cc b/kernel/driver.cc index d8b104117..726e25302 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -158,7 +158,6 @@ extern "C" { void yosys_atexit() { - RTLIL::OwningIdString::collect_garbage(false); #if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE) if (!yosys_history_file.empty()) { #if defined(YOSYS_ENABLE_READLINE) diff --git a/kernel/yosys.cc b/kernel/yosys.cc index bf59302f8..4e4abed20 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -260,6 +260,7 @@ void yosys_shutdown() delete yosys_design; yosys_design = NULL; + RTLIL::OwningIdString::collect_garbage(); for (auto f : log_files) if (f != stderr) From c497b3b24c4168659288be344c6548163f604a45 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 14 Nov 2025 15:32:10 +0100 Subject: [PATCH 2/8] Revert "rtlil: make tracing optional in IdString garbage collection" This reverts commit 8c76f93fcef412605d0ef01e7987a903be6c9e99. --- kernel/rtlil.cc | 9 ++++----- kernel/rtlil.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index ee53afe41..d18a709c9 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -246,15 +246,14 @@ struct IdStringCollector { int64_t RTLIL::OwningIdString::gc_ns; int RTLIL::OwningIdString::gc_count; -void RTLIL::OwningIdString::collect_garbage(bool trace) +void RTLIL::OwningIdString::collect_garbage() { int64_t start = PerformanceTimer::query(); #ifndef YOSYS_NO_IDS_REFCNT IdStringCollector collector; - if (trace) - for (auto &[idx, design] : *RTLIL::Design::get_all_designs()) { - collector.trace(*design); - } + for (auto &[idx, design] : *RTLIL::Design::get_all_designs()) { + collector.trace(*design); + } int size = GetSize(global_id_storage_); for (int i = static_cast(StaticId::STATIC_ID_END); i < size; ++i) { RTLIL::IdString::Storage &storage = global_id_storage_.at(i); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 6098d916b..584c4e11b 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -574,7 +574,7 @@ struct RTLIL::OwningIdString : public RTLIL::IdString { } // Collect all non-owning references. - static void collect_garbage(bool trace = true); + static void collect_garbage(); static int64_t garbage_collection_ns() { return gc_ns; } static int garbage_collection_count() { return gc_count; } From f47540b950d3b3b1f10831effafa77f7e9f33d8b Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 14 Nov 2025 15:40:14 +0100 Subject: [PATCH 3/8] techlibs: remove cells.lib --- techlibs/common/Makefile.inc | 1 - techlibs/common/cells.lib | 108 ----------------------------------- 2 files changed, 109 deletions(-) delete mode 100644 techlibs/common/cells.lib diff --git a/techlibs/common/Makefile.inc b/techlibs/common/Makefile.inc index e76d70a1a..22b119800 100644 --- a/techlibs/common/Makefile.inc +++ b/techlibs/common/Makefile.inc @@ -28,7 +28,6 @@ $(eval $(call add_share_file,share,techlibs/common/adff2dff.v)) $(eval $(call add_share_file,share,techlibs/common/dff2ff.v)) $(eval $(call add_share_file,share,techlibs/common/gate2lut.v)) $(eval $(call add_share_file,share,techlibs/common/cmp2lut.v)) -$(eval $(call add_share_file,share,techlibs/common/cells.lib)) $(eval $(call add_share_file,share,techlibs/common/mul2dsp.v)) $(eval $(call add_share_file,share,techlibs/common/abc9_model.v)) $(eval $(call add_share_file,share,techlibs/common/abc9_map.v)) diff --git a/techlibs/common/cells.lib b/techlibs/common/cells.lib deleted file mode 100644 index eb89036d7..000000000 --- a/techlibs/common/cells.lib +++ /dev/null @@ -1,108 +0,0 @@ -library(yosys_cells) { - cell(DFF_N) { - ff(IQ, IQN) { - clocked_on: "!C"; - next_state: "D"; - } - pin(D) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_P) { - ff(IQ, IQN) { - clocked_on: "C"; - next_state: "D"; - } - pin(D) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_NN0) { - ff(IQ, IQN) { - clocked_on: "!C"; - next_state: "D"; - clear: "!R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_NN1) { - ff(IQ, IQN) { - clocked_on: "!C"; - next_state: "D"; - preset: "!R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_NP0) { - ff(IQ, IQN) { - clocked_on: "!C"; - next_state: "D"; - clear: "R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_NP1) { - ff(IQ, IQN) { - clocked_on: "!C"; - next_state: "D"; - preset: "R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_PN0) { - ff(IQ, IQN) { - clocked_on: "C"; - next_state: "D"; - clear: "!R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_PN1) { - ff(IQ, IQN) { - clocked_on: "C"; - next_state: "D"; - preset: "!R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_PP0) { - ff(IQ, IQN) { - clocked_on: "C"; - next_state: "D"; - clear: "R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } - cell(DFF_PP1) { - ff(IQ, IQN) { - clocked_on: "C"; - next_state: "D"; - preset: "R"; - } - pin(D) { direction: input; } - pin(R) { direction: input; } - pin(C) { direction: input; clock: true; } - pin(Q) { direction: output; function: "IQ"; } - } -} From 677bf21947d80eb341f15109392d7f65e6ed2589 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 15 Nov 2025 00:23:54 +0000 Subject: [PATCH 4/8] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1016e3d13..b040cf39f 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.59+44 +YOSYS_VER := 0.59+54 YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1) YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2 | cut -d'+' -f1) YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'+' -f2) From 261a0ae9e13a0b05c430d0666f4933f14d7f573d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 17 Nov 2025 09:14:51 +0000 Subject: [PATCH 5/8] Implement at() methods on SigSpec so that SigSpec::bits().at() continues to work as it did Fixes a regression caused by commit 745222fa3bf2ac570935ffd044c86fa2eb12d123, which caused some third-party code to fail to build, e.g.: https://github.com/google/heir/blob/5d7aa035c6e42394cd4dd45faca0b0933af89950/lib/Transforms/YosysOptimizer/RTLILImporter.cpp#L229 --- kernel/rtlil.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 584c4e11b..a8e43fe1d 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1726,6 +1726,8 @@ public: operator std::vector() const; operator std::vector() const { return to_sigbit_vector(); } const RTLIL::SigBit &at(int offset, const RTLIL::SigBit &defval) { return offset < size() ? (*this)[offset] : defval; } + RTLIL::SigBit& at(int offset) { return (*this)[offset]; } + RTLIL::SigBit at(int offset) const { return (*this)[offset]; } [[nodiscard]] Hasher hash_into(Hasher h) const { Hasher::hash_t val; From b870693393db0842ed5b00623809397fbad3fc7c Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 17 Nov 2025 09:11:15 +0000 Subject: [PATCH 6/8] Fix reset_auto_counter_id to correctly detect _NNN_ patterns This fixes a regression caused by commit c4c389fdd71f9dfc653d64789437084fd091f21e. --- backends/verilog/verilog_backend.cc | 10 +++++----- tests/verilog/reset_auto_counter.ys | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 tests/verilog/reset_auto_counter.ys diff --git a/backends/verilog/verilog_backend.cc b/backends/verilog/verilog_backend.cc index 67ff1f808..8d77160fd 100644 --- a/backends/verilog/verilog_backend.cc +++ b/backends/verilog/verilog_backend.cc @@ -116,21 +116,21 @@ void reset_auto_counter_id(RTLIL::IdString id, bool may_rename) if (*it == '$' && may_rename && !norename) auto_name_map[id] = auto_name_counter++; - if (*it != '\\' || *it != '_' || (it + 1) == it_end) + if (*it != '\\' || (it + 1) == it_end || *(it + 1) != '_' || (it + 2) == it_end) return; + std::string s; it += 2; - auto start = it; while (it != it_end) { char ch = *it; if (ch == '_' && (it + 1) == it_end) - continue; + break; if (ch < '0' || ch > '9') return; + s.push_back(ch); + ++it; } - std::string s; - std::copy(start, it_end, std::back_inserter(s)); int num = atoi(s.c_str()); if (num >= auto_name_offset) auto_name_offset = num + 1; diff --git a/tests/verilog/reset_auto_counter.ys b/tests/verilog/reset_auto_counter.ys new file mode 100644 index 000000000..c9756cbac --- /dev/null +++ b/tests/verilog/reset_auto_counter.ys @@ -0,0 +1,17 @@ +read_verilog -sv < Date: Mon, 17 Nov 2025 13:35:38 +0100 Subject: [PATCH 7/8] ignore generated file --- tests/verilog/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/verilog/.gitignore b/tests/verilog/.gitignore index d3e8690d5..b16ed0890 100644 --- a/tests/verilog/.gitignore +++ b/tests/verilog/.gitignore @@ -1,6 +1,7 @@ /const_arst.v /const_sr.v /doubleslash.v +/reset_auto_counter.v /roundtrip_proc_1.v /roundtrip_proc_2.v /assign_to_reg.v From 9aa2dde7efb2edb75f35f01d5b0b6ded1d638ba3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 00:24:34 +0000 Subject: [PATCH 8/8] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b040cf39f..6984ba5f1 100644 --- a/Makefile +++ b/Makefile @@ -161,7 +161,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.59+54 +YOSYS_VER := 0.59+62 YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1) YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2 | cut -d'+' -f1) YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'+' -f2)