From 901935fbcec42cbf79594efd9cc2877810395715 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Mon, 13 Jan 2025 20:21:05 +0100 Subject: [PATCH 01/19] hashlib: merge hash_ops with hash_top_ops for plugin compat --- kernel/hashlib.h | 58 ++++++++++++++++++++++++++++-------------------- kernel/rtlil.h | 14 ++++++++---- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 4acfa7f2d..d166076d6 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -61,19 +61,9 @@ namespace legacy { } }; -/** - * Hash a type with an accumulator in a record or array context - */ template struct hash_ops; -/** - * Hash a single instance in isolation. - * Can have explicit specialization, but the default redirects to hash_ops - */ -template -struct hash_top_ops; - inline unsigned int mkhash_xorshift(unsigned int a) { if (sizeof(a) == 4) { a ^= a << 13; @@ -147,15 +137,14 @@ private: using Hasher = HasherDJB32; -template -struct hash_top_ops { - static inline bool cmp(const T &a, const T &b) { - return hash_ops::cmp(a, b); - } - static inline Hasher hash(const T &a) { - return hash_ops::hash_into(a, Hasher()); - } -}; +// Boilerplate compressor for trivially implementing +// top-level hash method with hash_into +#define HASH_TOP_LOOP_FST [[nodiscard]] static inline Hasher hash +#define HASH_TOP_LOOP_SND { \ + Hasher h; \ + h.eat(a); \ + return h; \ +} template struct hash_ops { @@ -183,6 +172,7 @@ struct hash_ops { return a.hash_into(h); } } + HASH_TOP_LOOP_FST (const T &a) HASH_TOP_LOOP_SND }; template struct hash_ops> { @@ -194,6 +184,7 @@ template struct hash_ops> { h = hash_ops::hash_into(a.second, h); return h; } + HASH_TOP_LOOP_FST (std::pair a) HASH_TOP_LOOP_SND }; template struct hash_ops> { @@ -211,6 +202,7 @@ template struct hash_ops> { h = element_ops_t::hash_into(std::get(a), h); return h; } + HASH_TOP_LOOP_FST (std::tuple a) HASH_TOP_LOOP_SND }; template struct hash_ops> { @@ -223,6 +215,7 @@ template struct hash_ops> { h.eat(k); return h; } + HASH_TOP_LOOP_FST (std::vector a) HASH_TOP_LOOP_SND }; template struct hash_ops> { @@ -234,6 +227,7 @@ template struct hash_ops> { h = hash_ops::hash_into(k, h); return h; } + HASH_TOP_LOOP_FST (std::array a) HASH_TOP_LOOP_SND }; struct hash_cstr_ops { @@ -245,6 +239,11 @@ struct hash_cstr_ops { h.hash32(*(a++)); return h; } + [[nodiscard]] static inline Hasher hash(const char *a) { + Hasher h; + h = hash_cstr_ops::hash_into(a, h); + return h; + } }; template <> struct hash_ops : hash_cstr_ops {}; @@ -256,6 +255,11 @@ struct hash_ptr_ops { [[nodiscard]] static inline Hasher hash_into(const void *a, Hasher h) { return hash_ops::hash_into((uintptr_t)a, h); } + [[nodiscard]] static inline Hasher hash(const void *a) { + Hasher h; + h = hash_ptr_ops::hash_into(a, h); + return h; + } }; struct hash_obj_ops { @@ -270,6 +274,12 @@ struct hash_obj_ops { h.eat(0); return h; } + template + [[nodiscard]] static inline Hasher hash(const T *a) { + Hasher h; + h = hash_obj_ops::hash_into(a, h); + return h; + } }; /** * If you find yourself using this function, think hard @@ -280,7 +290,7 @@ struct hash_obj_ops { template [[nodiscard]] Hasher::hash_t run_hash(const T& obj) { - return hash_top_ops::hash(obj).yield(); + return hash_ops::hash(obj).yield(); } /** Refer to docs/source/yosys_internals/hashing.rst */ @@ -352,10 +362,10 @@ inline unsigned int hashtable_size(unsigned int min_size) throw std::length_error("hash table exceeded maximum size."); } -template> class dict; -template> class idict; -template> class pool; -template> class mfp; +template> class dict; +template> class idict; +template> class pool; +template> class mfp; template class dict { diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 3d8187e78..f9cacd151 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -398,13 +398,16 @@ struct RTLIL::IdString namespace hashlib { template <> - struct hash_top_ops { + struct hash_ops { static inline bool cmp(const RTLIL::IdString &a, const RTLIL::IdString &b) { return a == b; } - static inline Hasher hash(const RTLIL::IdString id) { + [[nodiscard]] static inline Hasher hash(const RTLIL::IdString id) { return id.hash_top(); } + [[nodiscard]] static inline Hasher hash_into(const RTLIL::IdString id, Hasher h) { + return id.hash_into(h); + } }; }; @@ -920,13 +923,16 @@ struct RTLIL::SigBit namespace hashlib { template <> - struct hash_top_ops { + struct hash_ops { static inline bool cmp(const RTLIL::SigBit &a, const RTLIL::SigBit &b) { return a == b; } - static inline Hasher hash(const RTLIL::SigBit sb) { + [[nodiscard]] static inline Hasher hash(const RTLIL::SigBit sb) { return sb.hash_top(); } + [[nodiscard]] static inline Hasher hash_into(const RTLIL::SigBit sb, Hasher h) { + return sb.hash_into(h); + } }; }; From 17d45796a688b5a48caee40c76c7b8af69a8e031 Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Wed, 15 Jan 2025 15:25:35 +0100 Subject: [PATCH 02/19] ModuleHdlnameIndex: handle objects with private name and hdlname attribute --- kernel/scopeinfo.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/scopeinfo.h b/kernel/scopeinfo.h index 703dc315f..45d867b62 100644 --- a/kernel/scopeinfo.h +++ b/kernel/scopeinfo.h @@ -337,12 +337,12 @@ template std::vector parse_hdlname(const O* object) { std::vector path; - if (!object->name.isPublic()) - return path; for (auto const &item : object->get_hdlname_attribute()) path.push_back("\\" + item); - if (path.empty()) + if (path.empty() && object->name.isPublic()) path.push_back(object->name); + if (!path.empty() && !(object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract"))) + path.pop_back(); return path; } @@ -351,17 +351,22 @@ std::pair, IdString> parse_scopename(const O* object) { std::vector path; IdString trailing = object->name; - if (object->name.isPublic()) { + if (object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract")) { for (auto const &item : object->get_hdlname_attribute()) path.push_back("\\" + item); if (!path.empty()) { trailing = path.back(); path.pop_back(); } + } else if (object->has_attribute(ID::hdlname)) { + for (auto const &item : object->get_hdlname_attribute()) + path.push_back("\\" + item); + if (!path.empty()) { + path.pop_back(); + } } else { for (auto const &item : split_tokens(object->get_string_attribute(ID(scopename)), " ")) path.push_back("\\" + item); - } return {path, trailing}; } From d640157ec4b4574f5bda6a10d2f6ddec6ee09585 Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Wed, 15 Jan 2025 15:56:42 +0100 Subject: [PATCH 03/19] fix some cases of hdlname being added to objects with private names --- frontends/verific/verific.cc | 3 ++- passes/fsm/fsm_extract.cc | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index 8f1b07b10..cdd0ed802 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -1464,7 +1464,8 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::ma log("Importing module %s.\n", RTLIL::id2cstr(module->name)); } import_attributes(module->attributes, nl, nl); - module->set_string_attribute(ID::hdlname, nl->CellBaseName()); + if (module->name.isPublic()) + module->set_string_attribute(ID::hdlname, nl->CellBaseName()); module->set_string_attribute(ID(library), nl->Owner()->Owner()->Name()); #ifdef VERIFIC_VHDL_SUPPORT if (nl->IsFromVhdl()) { diff --git a/passes/fsm/fsm_extract.cc b/passes/fsm/fsm_extract.cc index 6114dd34b..17675b402 100644 --- a/passes/fsm/fsm_extract.cc +++ b/passes/fsm/fsm_extract.cc @@ -377,6 +377,10 @@ static void extract_fsm(RTLIL::Wire *wire) fsm_cell->setPort(ID::CTRL_OUT, ctrl_out); fsm_cell->parameters[ID::NAME] = RTLIL::Const(wire->name.str()); fsm_cell->attributes = wire->attributes; + if(fsm_cell->attributes.count(ID::hdlname)) { + fsm_cell->attributes[ID(scopename)] = fsm_cell->attributes[ID::hdlname]; + fsm_cell->attributes.erase(ID::hdlname); + } fsm_data.copy_to_cell(fsm_cell); // rename original state wire @@ -385,6 +389,10 @@ static void extract_fsm(RTLIL::Wire *wire) wire->attributes.erase(ID::fsm_encoding); wire->name = stringf("$fsm$oldstate%s", wire->name.c_str()); module->wires_[wire->name] = wire; + if(wire->attributes.count(ID::hdlname)) { + wire->attributes[ID(scopename)] = wire->attributes[ID::hdlname]; + wire->attributes.erase(ID::hdlname); + } // unconnect control outputs from old drivers From a5ba1d2ebafd6a3c5e65d238811f59db55414b10 Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Thu, 16 Jan 2025 12:57:08 +0100 Subject: [PATCH 04/19] fix bugs in handling last id in hdlname to scopename conversion --- kernel/scopeinfo.h | 4 +++- passes/fsm/fsm_extract.cc | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/scopeinfo.h b/kernel/scopeinfo.h index 45d867b62..3bc1a8162 100644 --- a/kernel/scopeinfo.h +++ b/kernel/scopeinfo.h @@ -341,8 +341,10 @@ std::vector parse_hdlname(const O* object) path.push_back("\\" + item); if (path.empty() && object->name.isPublic()) path.push_back(object->name); - if (!path.empty() && !(object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract"))) + if (!path.empty() && !(object->name.isPublic() || object->name.begins_with("$paramod") || object->name.begins_with("$abstract"))) { path.pop_back(); + path.push_back(object->name); + } return path; } diff --git a/passes/fsm/fsm_extract.cc b/passes/fsm/fsm_extract.cc index 17675b402..143ae7b54 100644 --- a/passes/fsm/fsm_extract.cc +++ b/passes/fsm/fsm_extract.cc @@ -378,7 +378,10 @@ static void extract_fsm(RTLIL::Wire *wire) fsm_cell->parameters[ID::NAME] = RTLIL::Const(wire->name.str()); fsm_cell->attributes = wire->attributes; if(fsm_cell->attributes.count(ID::hdlname)) { - fsm_cell->attributes[ID(scopename)] = fsm_cell->attributes[ID::hdlname]; + auto hdlname = fsm_cell->get_hdlname_attribute(); + hdlname.pop_back(); + fsm_cell->set_hdlname_attribute(hdlname); + fsm_cell->set_string_attribute(ID(scopename), fsm_cell->get_string_attribute(ID::hdlname)); fsm_cell->attributes.erase(ID::hdlname); } fsm_data.copy_to_cell(fsm_cell); @@ -390,7 +393,10 @@ static void extract_fsm(RTLIL::Wire *wire) wire->name = stringf("$fsm$oldstate%s", wire->name.c_str()); module->wires_[wire->name] = wire; if(wire->attributes.count(ID::hdlname)) { - wire->attributes[ID(scopename)] = wire->attributes[ID::hdlname]; + auto hdlname = wire->get_hdlname_attribute(); + hdlname.pop_back(); + wire->set_hdlname_attribute(hdlname); + wire->set_string_attribute(ID(scopename), wire->get_string_attribute(ID::hdlname)); wire->attributes.erase(ID::hdlname); } From fe79a77e398fab8dc962e49556eec5803aa3be74 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Thu, 16 Jan 2025 09:23:16 -0500 Subject: [PATCH 05/19] Fix undefined type error in libs/json11/json11.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under certain conditions, compilation errors out with the following message: "error: ‘uint8_t’ does not name a type" Explicitly including prevents that situation. Signed-off-by: Gabriel Somlo --- libs/json11/json11.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/json11/json11.cpp b/libs/json11/json11.cpp index 189e63881..cdd81c6a9 100644 --- a/libs/json11/json11.cpp +++ b/libs/json11/json11.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include namespace json11 { From 76d85fefac21aebde264b8bd1fe4a675ce61ee4a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Jan 2025 00:19:38 +0000 Subject: [PATCH 06/19] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 35561acd8..9a94b3f9d 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.48+77 +YOSYS_VER := 0.48+80 # Note: We arrange for .gitcommit to contain the (short) commit hash in # tarballs generated with git-archive(1) using .gitattributes. The git repo From 63074ccb895c504d7a766b199ed7fad42a54e114 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:27:10 -0700 Subject: [PATCH 07/19] add support for passing flatten -separator to flatten in synth --- techlibs/common/synth.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index 74a484d59..a1ce1ae1b 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -98,7 +98,7 @@ struct SynthPass : public ScriptPass { log("\n"); } - string top_module, fsm_opts, memory_opts, abc; + string top_module, fsm_opts, memory_opts, abc, flatten_separator; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; int lut; std::vector techmap_maps; @@ -120,6 +120,7 @@ struct SynthPass : public ScriptPass { booth = false; abc = "abc"; techmap_maps.clear(); + flatten_separator = ""; } void execute(std::vector args, RTLIL::Design *design) override @@ -154,6 +155,8 @@ struct SynthPass : public ScriptPass { } if (args[argidx] == "-flatten") { flatten = true; + if (design->scratchpad.count("flatten.separator")) + flatten_separator = design->scratchpad_get_string("flatten.separator"); continue; } if (args[argidx] == "-lut" && argidx + 1 < args.size()) { @@ -239,8 +242,12 @@ struct SynthPass : public ScriptPass { if (check_label("coarse")) { run("proc"); - if (flatten || help_mode) - run("flatten", " (if -flatten)"); + if (flatten || help_mode) { + if (!flatten_separator.empty()) + run(stringf("flatten -separator %s", flatten_separator.c_str()), " (if -flatten)"); + else + run("flatten", " (if -flatten)"); + } run("opt_expr"); run("opt_clean"); run("check"); From c4f90693aa1efe1e416dc385c0ee5e68840a5c31 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:37:56 -0700 Subject: [PATCH 08/19] Revert "add support for passing flatten -separator to flatten in synth" This reverts commit 63074ccb895c504d7a766b199ed7fad42a54e114. --- techlibs/common/synth.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index a1ce1ae1b..74a484d59 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -98,7 +98,7 @@ struct SynthPass : public ScriptPass { log("\n"); } - string top_module, fsm_opts, memory_opts, abc, flatten_separator; + string top_module, fsm_opts, memory_opts, abc; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; int lut; std::vector techmap_maps; @@ -120,7 +120,6 @@ struct SynthPass : public ScriptPass { booth = false; abc = "abc"; techmap_maps.clear(); - flatten_separator = ""; } void execute(std::vector args, RTLIL::Design *design) override @@ -155,8 +154,6 @@ struct SynthPass : public ScriptPass { } if (args[argidx] == "-flatten") { flatten = true; - if (design->scratchpad.count("flatten.separator")) - flatten_separator = design->scratchpad_get_string("flatten.separator"); continue; } if (args[argidx] == "-lut" && argidx + 1 < args.size()) { @@ -242,12 +239,8 @@ struct SynthPass : public ScriptPass { if (check_label("coarse")) { run("proc"); - if (flatten || help_mode) { - if (!flatten_separator.empty()) - run(stringf("flatten -separator %s", flatten_separator.c_str()), " (if -flatten)"); - else - run("flatten", " (if -flatten)"); - } + if (flatten || help_mode) + run("flatten", " (if -flatten)"); run("opt_expr"); run("opt_clean"); run("check"); From f0860459ac668a420915bca1628da5e634797f3a Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:45:19 -0700 Subject: [PATCH 09/19] add support for using scratchpad value for flatten.separator in flatten command --- passes/techmap/flatten.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/passes/techmap/flatten.cc b/passes/techmap/flatten.cc index 619fa4a68..3425509b1 100644 --- a/passes/techmap/flatten.cc +++ b/passes/techmap/flatten.cc @@ -357,6 +357,9 @@ struct FlattenPass : public Pass { FlattenWorker worker; + if (design->scratchpad.count("flatten.separator")) + worker.separator = design->scratchpad_get_string("flatten.separator"); + size_t argidx; for (argidx = 1; argidx < args.size(); argidx++) { if (args[argidx] == "-wb") { From 37acfce8c4da431a101b90f4aaa77476e33a6a06 Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:07:40 +1300 Subject: [PATCH 10/19] test-compile: Update oldest clang for 24.04 Oldest clang on 24.04 appears to be 16. --- .github/workflows/test-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-compile.yml b/.github/workflows/test-compile.yml index 74c3e2639..d798668b1 100644 --- a/.github/workflows/test-compile.yml +++ b/.github/workflows/test-compile.yml @@ -30,7 +30,7 @@ jobs: - ubuntu-latest compiler: # oldest supported - - 'clang-14' + - 'clang-16' - 'gcc-10' # newest, make sure to update maximum standard step to match - 'clang-18' From 2403c406fb331e9d42bd0bb5ee124276762ec58a Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:21:17 +1300 Subject: [PATCH 11/19] test-compile: Update latest clang Use clang-19 as latest --- .github/workflows/test-compile.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-compile.yml b/.github/workflows/test-compile.yml index d798668b1..2321866b7 100644 --- a/.github/workflows/test-compile.yml +++ b/.github/workflows/test-compile.yml @@ -33,7 +33,7 @@ jobs: - 'clang-16' - 'gcc-10' # newest, make sure to update maximum standard step to match - - 'clang-18' + - 'clang-19' - 'gcc-13' include: # macOS @@ -72,7 +72,7 @@ jobs: # maximum standard, only on newest compilers - name: Build C++20 - if: ${{ matrix.compiler == 'clang-18' || matrix.compiler == 'gcc-13' }} + if: ${{ matrix.compiler == 'clang-19' || matrix.compiler == 'gcc-13' }} shell: bash run: | make config-$CC_SHORT From 90b1ccf67bd57a3226d59f3d68d2597cd690c03d Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 11:57:47 +1300 Subject: [PATCH 12/19] test-compile: Set oldest clang to 10 clang-11 through clang-16 fail under 24.04, but clang-10 works, so we can move that up to the oldest supported and drop the extra target for ubuntu-20.04 --- .github/workflows/test-compile.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test-compile.yml b/.github/workflows/test-compile.yml index 2321866b7..203c20bb4 100644 --- a/.github/workflows/test-compile.yml +++ b/.github/workflows/test-compile.yml @@ -30,7 +30,7 @@ jobs: - ubuntu-latest compiler: # oldest supported - - 'clang-16' + - 'clang-10' - 'gcc-10' # newest, make sure to update maximum standard step to match - 'clang-19' @@ -39,9 +39,6 @@ jobs: # macOS - os: macos-13 compiler: 'clang' - # oldest clang not available on ubuntu-latest - - os: ubuntu-20.04 - compiler: 'clang-10' fail-fast: false steps: - name: Checkout Yosys From ab4bda8ae25714dfd6249e136a9021d4afedc278 Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:19:36 +1300 Subject: [PATCH 13/19] Docs: Fix links for view/edit source --- docs/source/conf.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8c8555b71..0e2f79a56 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,6 +11,29 @@ yosys_ver = "0.48" # select HTML theme html_theme = 'furo-ys' html_css_files = ['custom.css'] +html_theme_options: dict[str] = { + "source_repository": "https://github.com/YosysHQ/yosys/", + "source_branch": "main", + "source_directory": "docs/", +} + +# try to fix the readthedocs detection +html_context: dict[str] = { + "READTHEDOCS": True, + "display_github": True, + "github_user": "YosysHQ", + "github_repo": "yosys", + "slug": "yosys", +} + +# override source_branch if not main +git_slug = os.getenv("READTHEDOCS_VERSION_NAME") +if git_slug not in [None, "latest", "stable"]: + html_theme_options["source_branch"] = git_slug + +# edit only works on branches, not tags +if os.getenv("READTHEDOCS_VERSION_TYPE", "branch") != "branch": + html_theme_options["top_of_page_buttons"] = ["view"] # These folders are copied to the documentation's HTML output html_static_path = ['_static', "_images"] From 0c61f1a9a8a6148a7b7642d3784948411a0afb09 Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Mon, 20 Jan 2025 16:30:30 +1300 Subject: [PATCH 14/19] conf.py: Fix source_directory --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0e2f79a56..de0b9cf4d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ html_css_files = ['custom.css'] html_theme_options: dict[str] = { "source_repository": "https://github.com/YosysHQ/yosys/", "source_branch": "main", - "source_directory": "docs/", + "source_directory": "docs/source/", } # try to fix the readthedocs detection From 6b449970ef43cdae945639483e6c23177b45e8d7 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 20 Jan 2025 16:08:42 +0100 Subject: [PATCH 15/19] test-build: Fix missing bzlib.h --- .github/actions/setup-build-env/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-build-env/action.yml b/.github/actions/setup-build-env/action.yml index a2ffb8d3e..dfdcd88c0 100644 --- a/.github/actions/setup-build-env/action.yml +++ b/.github/actions/setup-build-env/action.yml @@ -8,7 +8,7 @@ runs: shell: bash run: | sudo apt-get update - sudo apt-get install gperf build-essential bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev + sudo apt-get install gperf build-essential bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev libbz2-dev - name: Install macOS Dependencies if: runner.os == 'macOS' From aa01ef3312a709a90a797beca6eb4002abf7b8df Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Mon, 20 Jan 2025 16:15:48 +0100 Subject: [PATCH 16/19] hashlib: simplify loopback. NFC --- kernel/hashlib.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index d166076d6..6e3eb32a4 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -142,7 +142,7 @@ using Hasher = HasherDJB32; #define HASH_TOP_LOOP_FST [[nodiscard]] static inline Hasher hash #define HASH_TOP_LOOP_SND { \ Hasher h; \ - h.eat(a); \ + h = hash_into(a, h); \ return h; \ } @@ -239,11 +239,7 @@ struct hash_cstr_ops { h.hash32(*(a++)); return h; } - [[nodiscard]] static inline Hasher hash(const char *a) { - Hasher h; - h = hash_cstr_ops::hash_into(a, h); - return h; - } + HASH_TOP_LOOP_FST (const char *a) HASH_TOP_LOOP_SND }; template <> struct hash_ops : hash_cstr_ops {}; @@ -255,11 +251,7 @@ struct hash_ptr_ops { [[nodiscard]] static inline Hasher hash_into(const void *a, Hasher h) { return hash_ops::hash_into((uintptr_t)a, h); } - [[nodiscard]] static inline Hasher hash(const void *a) { - Hasher h; - h = hash_ptr_ops::hash_into(a, h); - return h; - } + HASH_TOP_LOOP_FST (const void *a) HASH_TOP_LOOP_SND }; struct hash_obj_ops { @@ -275,11 +267,7 @@ struct hash_obj_ops { return h; } template - [[nodiscard]] static inline Hasher hash(const T *a) { - Hasher h; - h = hash_obj_ops::hash_into(a, h); - return h; - } + HASH_TOP_LOOP_FST (const T *a) HASH_TOP_LOOP_SND }; /** * If you find yourself using this function, think hard From a2c26a00f2b55307bea27322c68dc7321c7ebc82 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Mon, 20 Jan 2025 16:25:52 +0100 Subject: [PATCH 17/19] hashlib: document merged hash_top_ops with hash_ops --- docs/source/yosys_internals/hashing.rst | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/source/yosys_internals/hashing.rst b/docs/source/yosys_internals/hashing.rst index 338ee5fd6..c6e22c0cf 100644 --- a/docs/source/yosys_internals/hashing.rst +++ b/docs/source/yosys_internals/hashing.rst @@ -97,8 +97,8 @@ Making a type hashable Let's first take a look at the external interface on a simplified level. Generally, to get the hash for ``T obj``, you would call the utility function -``run_hash(const T& obj)``, corresponding to ``hash_top_ops::hash(obj)``, -the default implementation of which is ``hash_ops::hash_into(Hasher(), obj)``. +``run_hash(const T& obj)``, corresponding to ``hash_ops::hash(obj)``, +the default implementation of which uses ``hash_ops::hash_into(Hasher(), obj)``. ``Hasher`` is the class actually implementing the hash function, hiding its initialized internal state, and passing it out on ``hash_t yield()`` with perhaps some finalization steps. @@ -121,8 +121,14 @@ size containers like ``std::vector`` the size of the container is hashed first. That is also how implementing hashing for a custom record data type should be - unless there is strong reason to do otherwise, call ``h.eat(m)`` on the ``Hasher h`` you have received for each member in sequence and ``return -h;``. If you do have a strong reason to do so, look at how -``hash_top_ops`` is implemented in ``kernel/rtlil.h``. +h;``. + +The ``hash_ops::hash(obj)`` method is not indended to be called when +context of implementing the hashing for a record or other compound type. +When writing it, you should connect it to ``hash_ops::hash_into(Hasher h)`` +as shown below. If you have a strong reason to do so, and you have +to create a special implementation for top-level hashing, look at how +``hash_ops::hash(...)`` is implemented in ``kernel/rtlil.h``. Porting plugins from the legacy interface ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -148,6 +154,11 @@ based on the existance and value of `YS_HASHING_VERSION`. h.eat(b); return h; } + Hasher T::hash() const { + Hasher h; + h.eat(*this); + return h; + } #else #error "Unsupported hashing interface" #endif From 3f4f6c17d6fb2a9548c935a8e4c73af5fa326015 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 00:20:11 +0000 Subject: [PATCH 18/19] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9a94b3f9d..ec47685f2 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.48+80 +YOSYS_VER := 0.48+98 # Note: We arrange for .gitcommit to contain the (short) commit hash in # tarballs generated with git-archive(1) using .gitattributes. The git repo From d50849ea8395b88c8211bed6aa45b7581fd960aa Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 21 Jan 2025 08:48:29 +0100 Subject: [PATCH 19/19] Copyright year update --- COPYING | 2 +- kernel/register.cc | 2 +- kernel/yosys.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/COPYING b/COPYING index e8b123be2..2d962dddc 100644 --- a/COPYING +++ b/COPYING @@ -1,6 +1,6 @@ ISC License -Copyright (C) 2012 - 2020 Claire Xenia Wolf +Copyright (C) 2012 - 2025 Claire Xenia Wolf Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/kernel/register.cc b/kernel/register.cc index d6e765ce4..11cf5b0e4 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -1221,7 +1221,7 @@ struct LicensePass : public Pass { log(" | |\n"); log(" | yosys -- Yosys Open SYnthesis Suite |\n"); log(" | |\n"); - log(" | Copyright (C) 2012 - 2024 Claire Xenia Wolf |\n"); + log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf |\n"); log(" | |\n"); log(" | Permission to use, copy, modify, and/or distribute this software for any |\n"); log(" | purpose with or without fee is hereby granted, provided that the above |\n"); diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 7cf60f068..de25d20e2 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -141,7 +141,7 @@ void yosys_banner() log("\n"); log(" /----------------------------------------------------------------------------\\\n"); log(" | yosys -- Yosys Open SYnthesis Suite |\n"); - log(" | Copyright (C) 2012 - 2024 Claire Xenia Wolf |\n"); + log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf |\n"); log(" | Distributed under an ISC-like license, type \"license\" to see terms |\n"); log(" \\----------------------------------------------------------------------------/\n"); log(" %s\n", yosys_version_str);