From 7d4ebeebc085c6440b4a6eed13010f19eaaf7283 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 18 Jun 2026 12:43:18 +0200 Subject: [PATCH 1/5] Add slang submodules --- .gitmodules | 9 +++++++++ frontends/slang/lib | 1 + libs/fmt | 1 + libs/slang | 1 + 4 files changed, 12 insertions(+) create mode 160000 frontends/slang/lib create mode 160000 libs/fmt create mode 160000 libs/slang diff --git a/.gitmodules b/.gitmodules index 9f18be11e..e8f7ee3c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,12 @@ [submodule "cxxopts"] path = libs/cxxopts url = https://github.com/jarro2783/cxxopts +[submodule "slang"] + path = libs/slang + url = https://github.com/MikePopoloski/slang +[submodule "fmt"] + path = libs/fmt + url = https://github.com/fmtlib/fmt +[submodule "yosys-slang"] + path = frontends/slang/lib + url = https://github.com/povik/yosys-slang diff --git a/frontends/slang/lib b/frontends/slang/lib new file mode 160000 index 000000000..325153096 --- /dev/null +++ b/frontends/slang/lib @@ -0,0 +1 @@ +Subproject commit 3251530961e0e8a8054098c9bb8376474958944a diff --git a/libs/fmt b/libs/fmt new file mode 160000 index 000000000..553ec11ec --- /dev/null +++ b/libs/fmt @@ -0,0 +1 @@ +Subproject commit 553ec11ec06fbe0beebfbb45f9dc3c9eabd83d28 diff --git a/libs/slang b/libs/slang new file mode 160000 index 000000000..f04e81565 --- /dev/null +++ b/libs/slang @@ -0,0 +1 @@ +Subproject commit f04e81565793c768b747a8fd058f3e7aeceee1b5 From fd2d0ab0f46f168ec228d5ca0631f5322cd56156 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 18 Jun 2026 12:45:15 +0200 Subject: [PATCH 2/5] Add CMake scripts to build libraries and read_slang frontend --- frontends/CMakeLists.txt | 1 + frontends/slang/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++++ libs/CMakeLists.txt | 13 ++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 frontends/slang/CMakeLists.txt diff --git a/frontends/CMakeLists.txt b/frontends/CMakeLists.txt index cc4c02d88..6e6eda488 100644 --- a/frontends/CMakeLists.txt +++ b/frontends/CMakeLists.txt @@ -6,5 +6,6 @@ add_subdirectory(json) add_subdirectory(liberty) add_subdirectory(rpc) add_subdirectory(rtlil) +add_subdirectory(slang) add_subdirectory(verific) add_subdirectory(verilog) diff --git a/frontends/slang/CMakeLists.txt b/frontends/slang/CMakeLists.txt new file mode 100644 index 000000000..da50e2494 --- /dev/null +++ b/frontends/slang/CMakeLists.txt @@ -0,0 +1,37 @@ +include(lib/cmake/GitRevision.cmake) +git_rev_parse(YOSYS_SLANG_REVISION ${CMAKE_CURRENT_SOURCE_DIR}/lib) +git_rev_parse(SLANG_REVISION ${PROJECT_SOURCE_DIR}/libs/slang) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/src/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) + +yosys_frontend(slang + lib/src/abort_helpers.cc + lib/src/addressing.cc + lib/src/async_pattern.cc + lib/src/async_pattern.h + lib/src/blackboxes.cc + lib/src/builder.cc + lib/src/cases.cc + lib/src/cases.h + lib/src/diag.cc + lib/src/diag.h + lib/src/initialization.cc + lib/src/lvalue.cc + lib/src/memory.h + lib/src/naming.cc + lib/src/procedural.cc + lib/src/slang_frontend.cc + lib/src/slang_frontend.h + lib/src/statements.h + lib/src/sva.cc + lib/src/variables.cc + lib/src/variables.h + ${CMAKE_CURRENT_BINARY_DIR}/version.h + INCLUDE_DIRS + ${CMAKE_CURRENT_BINARY_DIR} + LIBRARIES + slang::slang + fmt::fmt +) + +# TODO: remove next line when warnings/errors are fixed +set_target_properties(yosys_read_slang PROPERTIES YOSYS_IS_ABC ON) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index ae13387c0..6e09fbc3e 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -7,3 +7,16 @@ add_subdirectory(json11) add_subdirectory(minisat) add_subdirectory(sha1) add_subdirectory(subcircuit) +set(_old_BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}") +set(BUILD_SHARED_LIBS OFF) +include(FetchContent) +option(FMT_INSTALL OFF) +FetchContent_Declare( + fmt + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt +) +FetchContent_MakeAvailable(fmt) +set(SLANG_USE_MIMALLOC OFF) +add_subdirectory(slang) +set(BUILD_SHARED_LIBS "${_old_BUILD_SHARED_LIBS}") From ad139b7118474fdecf1afb4c2684929ce417f167 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 18 Jun 2026 12:57:10 +0200 Subject: [PATCH 3/5] Add option to build without slang --- CMakeLists.txt | 2 ++ frontends/slang/CMakeLists.txt | 4 +++- libs/CMakeLists.txt | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a37b52ebe..dad7277f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ option(YOSYS_WITHOUT_ZLIB "Disable zlib integration" OFF) option(YOSYS_WITHOUT_LIBFFI "Disable libffi integration" OFF) option(YOSYS_WITHOUT_READLINE "Disable readline integration" OFF) option(YOSYS_WITHOUT_EDITLINE "Disable editline integration" OFF) +option(YOSYS_WITHOUT_SLANG "Disable Slang integration" OFF) option(YOSYS_WITHOUT_TCL "Disable Tcl integration" OFF) option(YOSYS_WITH_PYTHON "Enable Python integration" OFF) @@ -308,6 +309,7 @@ condition(YOSYS_ENABLE_EDITLINE editline_FOUND AND NOT YOSYS_WITHOUT_EDITLINE AN condition(YOSYS_ENABLE_TCL tcl_FOUND AND libtommath_FOUND AND NOT YOSYS_WITHOUT_TCL) condition(YOSYS_ENABLE_PYTHON Python3Devel_FOUND AND PyosysEnv_FOUND AND YOSYS_WITH_PYTHON) condition(YOSYS_ENABLE_VERIFIC YOSYS_VERIFIC_DIR AND zlib_FOUND) +condition(YOSYS_ENABLE_SLANG NOT YOSYS_WITHOUT_SLANG) # Describe dependencies and features # CMake 4.0 would let us use proper conditions, but that's too new for now. diff --git a/frontends/slang/CMakeLists.txt b/frontends/slang/CMakeLists.txt index da50e2494..850b8d26f 100644 --- a/frontends/slang/CMakeLists.txt +++ b/frontends/slang/CMakeLists.txt @@ -26,10 +26,12 @@ yosys_frontend(slang lib/src/variables.cc lib/src/variables.h ${CMAKE_CURRENT_BINARY_DIR}/version.h + ENABLE_IF + YOSYS_ENABLE_SLANG INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} LIBRARIES - slang::slang + $<${YOSYS_ENABLE_SLANG}:slang::slang> fmt::fmt ) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 6e09fbc3e..126635687 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -17,6 +17,8 @@ FetchContent_Declare( SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt ) FetchContent_MakeAvailable(fmt) -set(SLANG_USE_MIMALLOC OFF) -add_subdirectory(slang) +if (NOT YOSYS_WITHOUT_SLANG) + set(SLANG_USE_MIMALLOC OFF) + add_subdirectory(slang) +endif() set(BUILD_SHARED_LIBS "${_old_BUILD_SHARED_LIBS}") From a4f51373202de22a1c5876fecbbeb6828980168d Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 18 Jun 2026 13:05:49 +0200 Subject: [PATCH 4/5] Bump minimal clang to 16 --- .github/workflows/test-compile.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/test-compile.yml b/.github/workflows/test-compile.yml index 3093e8dfd..b950aa1c0 100644 --- a/.github/workflows/test-compile.yml +++ b/.github/workflows/test-compile.yml @@ -43,7 +43,7 @@ jobs: - ubuntu-latest compiler: # oldest supported - - 'clang-14' + - 'clang-16' - 'gcc-11' # newest, make sure to update maximum standard step to match - 'clang-22' @@ -73,7 +73,6 @@ jobs: uses: aminya/setup-cpp@v1 with: compiler: ${{ matrix.compiler }} - gcc: ${{ (matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang-14') && '12' || '' }} - name: Tool versions shell: bash @@ -81,11 +80,6 @@ jobs: $CC --version $CXX --version - - name: Fix clang-14 toolchain - if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang-14' - run: | - echo 'CXXFLAGS=--gcc-toolchain=/usr -isystem /usr/include/c++/12 -isystem /usr/include/x86_64-linux-gnu/c++/12' >> $GITHUB_ENV - # minimum standard - name: Build C++20 shell: bash From b6c57ce9bf4b0735b0e3a39dc842fe69a096c172 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 18 Jun 2026 14:54:14 +0200 Subject: [PATCH 5/5] Use block() to isolate cmake variables --- libs/CMakeLists.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 126635687..8a9bb22ed 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -7,18 +7,18 @@ add_subdirectory(json11) add_subdirectory(minisat) add_subdirectory(sha1) add_subdirectory(subcircuit) -set(_old_BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS}") -set(BUILD_SHARED_LIBS OFF) -include(FetchContent) -option(FMT_INSTALL OFF) -FetchContent_Declare( - fmt - EXCLUDE_FROM_ALL - SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt -) -FetchContent_MakeAvailable(fmt) -if (NOT YOSYS_WITHOUT_SLANG) - set(SLANG_USE_MIMALLOC OFF) - add_subdirectory(slang) -endif() -set(BUILD_SHARED_LIBS "${_old_BUILD_SHARED_LIBS}") +block() + set(BUILD_SHARED_LIBS OFF) + include(FetchContent) + option(FMT_INSTALL OFF) + FetchContent_Declare( + fmt + EXCLUDE_FROM_ALL + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt + ) + FetchContent_MakeAvailable(fmt) + if (NOT YOSYS_WITHOUT_SLANG) + set(SLANG_USE_MIMALLOC OFF) + add_subdirectory(slang) + endif() +endblock()