From 17d45796a688b5a48caee40c76c7b8af69a8e031 Mon Sep 17 00:00:00 2001 From: "N. Engelhardt" Date: Wed, 15 Jan 2025 15:25:35 +0100 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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'