Skip to content

Commit

Permalink
Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
akashlevy committed Jan 21, 2025
2 parents a1c3c98 + da5c20d commit c58a50f
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-build-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 libnsl-dev libbz2-dev libdwarf-dev libelf-dev elfutils libdw-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 libnsl-dev libdwarf-dev libelf-dev elfutils libdw-dev
- name: Install macOS Dependencies
if: runner.os == 'macOS'
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ jobs:
- ubuntu-latest
compiler:
# oldest supported
- 'clang-14'
- 'clang-10'
- 'gcc-10'
# newest, make sure to update maximum standard step to match
- 'clang-18'
- 'clang-19'
- 'gcc-13'
include:
# 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
Expand Down Expand Up @@ -72,7 +69,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
Expand Down
2 changes: 1 addition & 1 deletion COPYING
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License

Copyright (C) 2012 - 2020 Claire Xenia Wolf <[email protected]>
Copyright (C) 2012 - 2025 Claire Xenia Wolf <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ ifeq ($(OS), Haiku)
CXXFLAGS += -D_DEFAULT_SOURCE
endif

YOSYS_VER := 0.48+77
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
Expand Down
23 changes: 23 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@
# 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/source/",
}

# 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"]
Expand Down
19 changes: 15 additions & 4 deletions docs/source/yosys_internals/hashing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(const T& obj)``, corresponding to ``hash_top_ops<T>::hash(obj)``,
the default implementation of which is ``hash_ops<T>::hash_into(Hasher(), obj)``.
``run_hash<T>(const T& obj)``, corresponding to ``hash_ops<T>::hash(obj)``,
the default implementation of which uses ``hash_ops<T>::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.
Expand All @@ -121,8 +121,14 @@ size containers like ``std::vector<U>`` 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<RTLIL::SigBit>`` is implemented in ``kernel/rtlil.h``.
h;``.

The ``hash_ops<T>::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<T>::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<RTLIL::SigBit>::hash(...)`` is implemented in ``kernel/rtlil.h``.

Porting plugins from the legacy interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion frontends/verific/verific.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,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()) {
Expand Down
46 changes: 22 additions & 24 deletions kernel/hashlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,9 @@ namespace legacy {
}
};

/**
* Hash a type with an accumulator in a record or array context
*/
template<typename T>
struct hash_ops;

/**
* Hash a single instance in isolation.
* Can have explicit specialization, but the default redirects to hash_ops
*/
template<typename T>
struct hash_top_ops;

inline unsigned int mkhash_xorshift(unsigned int a) {
if (sizeof(a) == 4) {
a ^= a << 13;
Expand Down Expand Up @@ -147,15 +137,14 @@ class HasherDJB32 {

using Hasher = HasherDJB32;

template<typename T>
struct hash_top_ops {
static inline bool cmp(const T &a, const T &b) {
return hash_ops<T>::cmp(a, b);
}
static inline Hasher hash(const T &a) {
return hash_ops<T>::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 = hash_into(a, h); \
return h; \
}

template<typename T>
struct hash_ops {
Expand Down Expand Up @@ -183,6 +172,7 @@ struct hash_ops {
return a.hash_into(h);
}
}
HASH_TOP_LOOP_FST (const T &a) HASH_TOP_LOOP_SND
};

template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> {
Expand All @@ -194,6 +184,7 @@ template<typename P, typename Q> struct hash_ops<std::pair<P, Q>> {
h = hash_ops<Q>::hash_into(a.second, h);
return h;
}
HASH_TOP_LOOP_FST (std::pair<P, Q> a) HASH_TOP_LOOP_SND
};

template<typename... T> struct hash_ops<std::tuple<T...>> {
Expand All @@ -211,6 +202,7 @@ template<typename... T> struct hash_ops<std::tuple<T...>> {
h = element_ops_t::hash_into(std::get<I>(a), h);
return h;
}
HASH_TOP_LOOP_FST (std::tuple<T...> a) HASH_TOP_LOOP_SND
};

template<typename T> struct hash_ops<std::vector<T>> {
Expand All @@ -223,6 +215,7 @@ template<typename T> struct hash_ops<std::vector<T>> {
h.eat(k);
return h;
}
HASH_TOP_LOOP_FST (std::vector<T> a) HASH_TOP_LOOP_SND
};

template<typename T, size_t N> struct hash_ops<std::array<T, N>> {
Expand All @@ -234,6 +227,7 @@ template<typename T, size_t N> struct hash_ops<std::array<T, N>> {
h = hash_ops<T>::hash_into(k, h);
return h;
}
HASH_TOP_LOOP_FST (std::array<T, N> a) HASH_TOP_LOOP_SND
};

struct hash_cstr_ops {
Expand All @@ -245,6 +239,7 @@ struct hash_cstr_ops {
h.hash32(*(a++));
return h;
}
HASH_TOP_LOOP_FST (const char *a) HASH_TOP_LOOP_SND
};

template <> struct hash_ops<char*> : hash_cstr_ops {};
Expand All @@ -256,6 +251,7 @@ struct hash_ptr_ops {
[[nodiscard]] static inline Hasher hash_into(const void *a, Hasher h) {
return hash_ops<uintptr_t>::hash_into((uintptr_t)a, h);
}
HASH_TOP_LOOP_FST (const void *a) HASH_TOP_LOOP_SND
};

struct hash_obj_ops {
Expand All @@ -270,6 +266,8 @@ struct hash_obj_ops {
h.eat(0);
return h;
}
template<typename T>
HASH_TOP_LOOP_FST (const T *a) HASH_TOP_LOOP_SND
};
/**
* If you find yourself using this function, think hard
Expand All @@ -280,7 +278,7 @@ struct hash_obj_ops {
template<typename T>
[[nodiscard]]
Hasher::hash_t run_hash(const T& obj) {
return hash_top_ops<T>::hash(obj).yield();
return hash_ops<T>::hash(obj).yield();
}

/** Refer to docs/source/yosys_internals/hashing.rst */
Expand Down Expand Up @@ -352,10 +350,10 @@ inline unsigned int hashtable_size(unsigned int min_size)
throw std::length_error("hash table exceeded maximum size.");
}

template<typename K, typename T, typename OPS = hash_top_ops<K>> class dict;
template<typename K, int offset = 0, typename OPS = hash_top_ops<K>> class idict;
template<typename K, typename OPS = hash_top_ops<K>> class pool;
template<typename K, typename OPS = hash_top_ops<K>> class mfp;
template<typename K, typename T, typename OPS = hash_ops<K>> class dict;
template<typename K, int offset = 0, typename OPS = hash_ops<K>> class idict;
template<typename K, typename OPS = hash_ops<K>> class pool;
template<typename K, typename OPS = hash_ops<K>> class mfp;

template<typename K, typename T, typename OPS>
class dict {
Expand Down
2 changes: 1 addition & 1 deletion kernel/register.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> |\n");
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <[email protected]> |\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");
Expand Down
14 changes: 10 additions & 4 deletions kernel/rtlil.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,16 @@ struct RTLIL::IdString

namespace hashlib {
template <>
struct hash_top_ops<RTLIL::IdString> {
struct hash_ops<RTLIL::IdString> {
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);
}
};
};

Expand Down Expand Up @@ -926,13 +929,16 @@ struct RTLIL::SigBit

namespace hashlib {
template <>
struct hash_top_ops<RTLIL::SigBit> {
struct hash_ops<RTLIL::SigBit> {
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);
}
};
};

Expand Down
17 changes: 12 additions & 5 deletions kernel/scopeinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,14 @@ template<typename O>
std::vector<IdString> parse_hdlname(const O* object)
{
std::vector<IdString> 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();
path.push_back(object->name);
}
return path;
}

Expand All @@ -351,17 +353,22 @@ std::pair<std::vector<IdString>, IdString> parse_scopename(const O* object)
{
std::vector<IdString> 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};
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/yosys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void yosys_banner()
log("\n");
log(" /----------------------------------------------------------------------------\\\n");
log(" | yosys -- Yosys Open SYnthesis Suite |\n");
log(" | Copyright (C) 2012 - 2024 Claire Xenia Wolf <[email protected]> |\n");
log(" | Copyright (C) 2012 - 2025 Claire Xenia Wolf <[email protected]> |\n");
log(" | Distributed under an ISC-like license, type \"license\" to see terms |\n");
log(" \\----------------------------------------------------------------------------/\n");
log(" %s\n", yosys_version_str);
Expand Down
1 change: 1 addition & 0 deletions libs/json11/json11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstdint>
#include <limits>

namespace json11 {
Expand Down
Loading

0 comments on commit c58a50f

Please sign in to comment.