mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 03:16:22 +00:00
Migrate build system to CMake
See #5895 for details. This commit does not include CI or documentation changes.
This commit is contained in:
parent
9d0cdb8551
commit
9b087b4aa7
207 changed files with 5202 additions and 2294 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -49,7 +49,9 @@
|
||||||
/tests/unit/objtest/
|
/tests/unit/objtest/
|
||||||
/tests/ystests
|
/tests/ystests
|
||||||
/build
|
/build
|
||||||
|
/build-*
|
||||||
/result
|
/result
|
||||||
|
/result-*
|
||||||
/dist
|
/dist
|
||||||
|
|
||||||
# pyosys
|
# pyosys
|
||||||
|
|
@ -86,3 +88,5 @@ __pycache__
|
||||||
/qtcreator.creator
|
/qtcreator.creator
|
||||||
/qtcreator.creator.user
|
/qtcreator.creator.user
|
||||||
/compile_commands.json
|
/compile_commands.json
|
||||||
|
/.direnv
|
||||||
|
/.envrc
|
||||||
|
|
|
||||||
515
CMakeLists.txt
Normal file
515
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,515 @@
|
||||||
|
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(rm "rm -rf")
|
||||||
|
if (WIN32)
|
||||||
|
set(rm "del /s /q")
|
||||||
|
endif()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"In-tree builds are not supported. Instead, run:\n"
|
||||||
|
"${rm} CMakeCache.txt CMakeFiles ; cmake -B build <options>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.27)
|
||||||
|
project(yosys LANGUAGES C CXX)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
include(FeatureSummary)
|
||||||
|
include(CheckPIESupported)
|
||||||
|
|
||||||
|
include(Condition)
|
||||||
|
include(CheckLibcFeatures)
|
||||||
|
include(PkgConfig)
|
||||||
|
include(PmgenCommand)
|
||||||
|
include(YosysVersion)
|
||||||
|
include(YosysInstallDirs)
|
||||||
|
include(YosysConfigScript)
|
||||||
|
include(YosysComponent)
|
||||||
|
include(YosysLinkTarget)
|
||||||
|
include(YosysAbc)
|
||||||
|
include(YosysAbcSubmodule)
|
||||||
|
include(YosysVerific)
|
||||||
|
|
||||||
|
# Build options.
|
||||||
|
set(YOSYS_COMPILER_LAUNCHER "" CACHE STRING "Compiler launcher (ccache, sccache)")
|
||||||
|
option(YOSYS_ENABLE_COVERAGE "Enable code coverage" OFF)
|
||||||
|
option(YOSYS_ENABLE_PROFILING "Enable instruction profiling" OFF)
|
||||||
|
|
||||||
|
set(YOSYS_PROGRAM_PREFIX "" CACHE STRING "Name prefix for programs, libraries, and data")
|
||||||
|
set(YOSYS_COMPONENTS "everything" CACHE STRING "List of components to build (use pass names)")
|
||||||
|
option(BUILD_SHARED_LIBS "Build libyosys as a shared library" ON)
|
||||||
|
|
||||||
|
option(YOSYS_DISABLE_THREADS "Disable threading" OFF)
|
||||||
|
set(YOSYS_ABC_EXECUTABLE "" CACHE FILEPATH
|
||||||
|
"Path to the ABC executable (empty for vendored, 'INTEGRATED-NOTFOUND' for in-process)")
|
||||||
|
option(YOSYS_WITHOUT_ABC "Disable ABC support (not recommended)" OFF)
|
||||||
|
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_TCL "Disable Tcl integration" OFF)
|
||||||
|
option(YOSYS_WITH_PYTHON "Enable Python integration" OFF)
|
||||||
|
|
||||||
|
set(YOSYS_VERIFIC_DIR "" CACHE FILEPATH "Path to the Verific source code (empty to disable)")
|
||||||
|
set(YOSYS_VERIFIC_COMPONENTS "" CACHE STRING
|
||||||
|
"List of Verific components to link (empty for autodetect)")
|
||||||
|
set(YOSYS_VERIFIC_FEATURES "" CACHE STRING
|
||||||
|
"List of Yosys Verific frontend features to enable (empty for autodetect)")
|
||||||
|
|
||||||
|
option(YOSYS_INSTALL_DRIVER "Install Yosys executable" ON)
|
||||||
|
option(YOSYS_INSTALL_LIBRARY "Install libyosys library" OFF)
|
||||||
|
cmake_dependent_option(YOSYS_INSTALL_PYTHON "Install Python extension module" OFF
|
||||||
|
YOSYS_WITH_PYTHON OFF)
|
||||||
|
set(YOSYS_INSTALL_PYTHON_SITEDIR "" CACHE STRING "Path to Python package installation directory")
|
||||||
|
|
||||||
|
option(YOSYS_ENABLE_HELP_SOURCE "Improve help text with source locations" OFF)
|
||||||
|
mark_as_advanced(YOSYS_ENABLE_HELP_SOURCE)
|
||||||
|
|
||||||
|
# Configure compiler.
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
|
||||||
|
|
||||||
|
if (YOSYS_COMPILER_LAUNCHER)
|
||||||
|
set(CMAKE_C_COMPILER_LAUNCHER "${YOSYS_COMPILER_LAUNCHER}")
|
||||||
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${YOSYS_COMPILER_LAUNCHER}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||||
|
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
check_pie_supported() # opportunistically enable PIE
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -ggdb")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -ggdb")
|
||||||
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
|
||||||
|
set(CMAKE_CXX_FLAGS_SANITIZE "-O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
|
||||||
|
if ("${SANITIZE}" MATCHES "memory")
|
||||||
|
set(CMAKE_CXX_FLAGS_SANITIZE "${CMAKE_CXX_FLAGS_SANITIZE} -fsanitize-memory-track-origins")
|
||||||
|
endif()
|
||||||
|
set(no_abc_options
|
||||||
|
"$<$<AND:$<NOT:$<BOOL:$<TARGET_PROPERTY:YOSYS_IS_ABC>>>,$<CONFIG:Sanitize>>:-fsanitize=${SANITIZE}>"
|
||||||
|
"$<$<NOT:$<BOOL:$<TARGET_PROPERTY:YOSYS_IS_ABC>>>:-Wall;-Wextra;-Werror=unused>"
|
||||||
|
)
|
||||||
|
add_compile_options("${no_abc_options}")
|
||||||
|
add_link_options("${no_abc_options}")
|
||||||
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "/Od /DEBUG")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /DEBUG")
|
||||||
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "/Os")
|
||||||
|
add_compile_options(/Zc:__cplusplus)
|
||||||
|
add_definitions(
|
||||||
|
_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
_CRT_SECURE_NO_WARNINGS
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# We have to do this because CMake adds `-DNDEBUG` in release builds by default, and there's
|
||||||
|
# no particularly good way to prevent this without also erasing optimization flags.
|
||||||
|
# If you see this message, reproduce the block above with the flags supported by your compiler.
|
||||||
|
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler is not supported")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (YOSYS_ENABLE_COVERAGE)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||||
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Code coverage is not supported on ${CMAKE_CXX_COMPILER_ID} compiler")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (YOSYS_ENABLE_PROFILING)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Instruction profiling is not supported on ${CMAKE_CXX_COMPILER_ID} compiler")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID)
|
||||||
|
message(FATAL_ERROR "C and C++ compilers must be provided by the same vendor")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||||
|
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
||||||
|
set(CMAKE_C_FLAGS_SANITIZE "${CMAKE_CXX_FLAGS_SANITIZE}")
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "WASI")
|
||||||
|
add_compile_options(
|
||||||
|
-fwasm-exceptions -mllvm -wasm-use-legacy-eh=false
|
||||||
|
-D_WASI_EMULATED_PROCESS_CLOCKS
|
||||||
|
)
|
||||||
|
add_link_options(
|
||||||
|
-fwasm-exceptions -mllvm -wasm-use-legacy-eh=false -lunwind
|
||||||
|
-lwasi-emulated-process-clocks
|
||||||
|
-Wl,--stack-first,-z,stack-size=8388608
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "16.0.0")
|
||||||
|
# GCC 15.2 sometimes refuses to construct an import directory for yosys.exe/libyosys.dll with:
|
||||||
|
# .../ld.exe: error: export ordinal too large: 67035
|
||||||
|
# The cause is unknown.
|
||||||
|
message(WARNING "MinGW GCC is supported starting with version 16.0.0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Required dependencies.
|
||||||
|
find_package(FLEX)
|
||||||
|
set_package_properties(FLEX PROPERTIES
|
||||||
|
URL "https://github.com/westes/flex"
|
||||||
|
DESCRIPTION "The Fast Lexical Analyzer"
|
||||||
|
PURPOSE "Compiling the Verilog lexer"
|
||||||
|
TYPE REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(BISON)
|
||||||
|
set_package_properties(BISON PROPERTIES
|
||||||
|
URL "https://www.gnu.org/software/bison/"
|
||||||
|
DESCRIPTION "The Yacc-compatible Parser Generator"
|
||||||
|
PURPOSE "Compiling the Verilog parser"
|
||||||
|
TYPE REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(Python3 3.7 COMPONENTS Interpreter)
|
||||||
|
set_package_properties(Python3 PROPERTIES
|
||||||
|
URL "https://www.python.org/"
|
||||||
|
DESCRIPTION "Dynamic programming language (Interpreter)"
|
||||||
|
PURPOSE "Generating data files\n Running external SMT2 solvers"
|
||||||
|
TYPE REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optional dependencies.
|
||||||
|
check_glob()
|
||||||
|
check_system()
|
||||||
|
check_popen()
|
||||||
|
find_package(Threads QUIET)
|
||||||
|
check_pthread_create()
|
||||||
|
find_package(Dlfcn QUIET)
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
set_package_properties(PkgConfig PROPERTIES
|
||||||
|
URL "https://www.freedesktop.org/wiki/Software/pkg-config/"
|
||||||
|
DESCRIPTION "Library metadata manager"
|
||||||
|
PURPOSE "Discovering dependencies"
|
||||||
|
TYPE RECOMMENDED
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_config_import(zlib)
|
||||||
|
set_package_properties(zlib PROPERTIES
|
||||||
|
URL "https://github.com/madler/zlib"
|
||||||
|
DESCRIPTION "A massively spiffy yet delicately unobtrusive compression library"
|
||||||
|
PURPOSE "Handling Gzip and FST file formats"
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_config_import(libffi)
|
||||||
|
set_package_properties(libffi PROPERTIES
|
||||||
|
URL "https://sourceware.org/libffi/"
|
||||||
|
DESCRIPTION "A Portable Foreign Function Interface Library"
|
||||||
|
PURPOSE "Implementing Verilog DPI-C"
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_config_import(editline MODULES libedit)
|
||||||
|
set_package_properties(editline PROPERTIES
|
||||||
|
URL "https://www.thrysoee.dk/editline/"
|
||||||
|
DESCRIPTION "Line editing and history library (BSD)"
|
||||||
|
PURPOSE "Enhancing the command prompt"
|
||||||
|
TYPE RECOMMENDED
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_config_import(readline)
|
||||||
|
set_package_properties(readline PROPERTIES
|
||||||
|
URL "https://tiswww.case.edu/php/chet/readline/rltop.html"
|
||||||
|
DESCRIPTION "Line editing and history library (GPL)"
|
||||||
|
PURPOSE "Enhancing the command prompt"
|
||||||
|
TYPE RECOMMENDED
|
||||||
|
)
|
||||||
|
|
||||||
|
# See https://core.tcl-lang.org/tips/doc/trunk/tip/538.md
|
||||||
|
pkg_config_import(tcl MODULES tcl)
|
||||||
|
set_package_properties(tcl PROPERTIES
|
||||||
|
URL "https://www.tcl-lang.org/"
|
||||||
|
DESCRIPTION "Dynamic programming language"
|
||||||
|
PURPOSE "Parsing SDC constraint files\n Binding Yosys API"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (tcl_FOUND)
|
||||||
|
get_target_property(tcl_options PkgConfig::tcl INTERFACE_COMPILE_OPTIONS)
|
||||||
|
if (tcl_options MATCHES "TCL_WITH_EXTERNAL_TOMMATH")
|
||||||
|
pkg_config_import(libtommath)
|
||||||
|
set_package_properties(libtommath PROPERTIES
|
||||||
|
URL "https://www.libtom.net/LibTomMath/"
|
||||||
|
DESCRIPTION "Multiple-precision integer library"
|
||||||
|
PURPOSE "Required by this build of Tcl"
|
||||||
|
TYPE REQUIRED
|
||||||
|
)
|
||||||
|
# Unfortunately the pkg-config file for Tcl includes libtommath as a private dependency,
|
||||||
|
# while it should be public since it is exposed in the public API and necessary for its use.
|
||||||
|
target_link_libraries(PkgConfig::tcl INTERFACE PkgConfig::libtommath)
|
||||||
|
else()
|
||||||
|
# Vendored within Tcl itself.
|
||||||
|
set(libtommath_FOUND TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (YOSYS_WITH_PYTHON)
|
||||||
|
find_package(Python3Embed REQUIRED)
|
||||||
|
set_property(GLOBAL PROPERTY _CMAKE_Python3Embed_REQUIRED_VERSION "== ${Python3_VERSION}")
|
||||||
|
set_package_properties(Python3Embed PROPERTIES
|
||||||
|
URL "https://www.python.org/"
|
||||||
|
DESCRIPTION "Dynamic programming language (Embedding)"
|
||||||
|
PURPOSE "Binding Yosys API"
|
||||||
|
)
|
||||||
|
|
||||||
|
find_package(PyosysEnv REQUIRED)
|
||||||
|
set_package_properties(PyosysEnv PROPERTIES
|
||||||
|
DESCRIPTION "Pyosys wrapper generator environment"
|
||||||
|
PURPOSE "Either 'uv' or 'pybind11>3,<4 cxxheaderparser'"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(GTest)
|
||||||
|
set_package_properties(GTest PROPERTIES
|
||||||
|
URL "https://google.github.io/googletest/"
|
||||||
|
DESCRIPTION "C++ testing and mocking framework by Google"
|
||||||
|
PURPOSE "Running unit tests"
|
||||||
|
TYPE RECOMMENDED
|
||||||
|
)
|
||||||
|
|
||||||
|
# Configure features based on dependency availability.
|
||||||
|
message(VERBOSE "Conditional features:")
|
||||||
|
condition(YOSYS_ENABLE_GLOB HAVE_GLOB)
|
||||||
|
condition(YOSYS_ENABLE_SPAWN HAVE_SYSTEM AND HAVE_POPEN)
|
||||||
|
condition(YOSYS_ENABLE_THREADS Threads_FOUND AND HAVE_PTHREAD_CREATE AND NOT YOSYS_DISABLE_THREADS)
|
||||||
|
condition(YOSYS_ENABLE_PLUGINS Dlfcn_FOUND)
|
||||||
|
condition(YOSYS_ENABLE_ABC NOT YOSYS_WITHOUT_ABC)
|
||||||
|
condition(YOSYS_ENABLE_ZLIB zlib_FOUND AND NOT YOSYS_WITHOUT_ZLIB)
|
||||||
|
condition(YOSYS_ENABLE_LIBFFI Dlfcn_FOUND AND libffi_FOUND AND NOT YOSYS_WITHOUT_LIBFFI)
|
||||||
|
condition(YOSYS_ENABLE_READLINE readline_FOUND AND NOT YOSYS_WITHOUT_READLINE)
|
||||||
|
condition(YOSYS_ENABLE_EDITLINE editline_FOUND AND NOT YOSYS_WITHOUT_EDITLINE AND NOT YOSYS_ENABLE_READLINE)
|
||||||
|
condition(YOSYS_ENABLE_TCL tcl_FOUND AND libtommath_FOUND AND NOT YOSYS_WITHOUT_TCL)
|
||||||
|
condition(YOSYS_ENABLE_PYTHON Python3Embed_FOUND AND PyosysEnv_FOUND AND YOSYS_WITH_PYTHON)
|
||||||
|
condition(YOSYS_ENABLE_VERIFIC YOSYS_VERIFIC_DIR AND zlib_FOUND)
|
||||||
|
|
||||||
|
# Describe dependencies and features
|
||||||
|
# CMake 4.0 would let us use proper conditions, but that's too new for now.
|
||||||
|
add_feature_info(have_glob YOSYS_ENABLE_GLOB "Glob expansion in filenames")
|
||||||
|
add_feature_info(have_spawn YOSYS_ENABLE_SPAWN "Passes that invoke external tools")
|
||||||
|
add_feature_info(have_threads YOSYS_ENABLE_THREADS "Multithreaded netlist operations")
|
||||||
|
add_feature_info(have_plugins YOSYS_ENABLE_PLUGINS "Dynamically loadable binary plugins")
|
||||||
|
add_feature_info(with_abc YOSYS_ENABLE_ABC "Production-quality logic synthesis flow")
|
||||||
|
add_feature_info(with_zlib YOSYS_ENABLE_ZLIB "Transparent Gzip decompression and FST file format support")
|
||||||
|
add_feature_info(with_libffi YOSYS_ENABLE_LIBFFI "Verilog DPI-C foreign function interface")
|
||||||
|
add_feature_info(with_readline YOSYS_ENABLE_READLINE "Using readline for prompt editing and history")
|
||||||
|
add_feature_info(with_editline YOSYS_ENABLE_EDITLINE "Using editline for prompt editing and history")
|
||||||
|
add_feature_info(with_tcl YOSYS_ENABLE_TCL "Tcl scripting and SDC parsing")
|
||||||
|
add_feature_info(with_python YOSYS_ENABLE_PYTHON "Python scripting and embedding")
|
||||||
|
add_feature_info(with_verific YOSYS_ENABLE_VERIFIC "Verific frontend integration")
|
||||||
|
message(STATUS "")
|
||||||
|
feature_summary(WHAT PACKAGES_FOUND
|
||||||
|
DEFAULT_DESCRIPTION)
|
||||||
|
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND
|
||||||
|
DEFAULT_DESCRIPTION QUIET_ON_EMPTY FATAL_ON_MISSING_REQUIRED_PACKAGES
|
||||||
|
)
|
||||||
|
feature_summary(WHAT PACKAGES_NOT_FOUND
|
||||||
|
DEFAULT_DESCRIPTION QUIET_ON_EMPTY
|
||||||
|
)
|
||||||
|
feature_summary(WHAT ENABLED_FEATURES
|
||||||
|
DEFAULT_DESCRIPTION QUIET_ON_EMPTY)
|
||||||
|
feature_summary(WHAT DISABLED_FEATURES
|
||||||
|
DEFAULT_DESCRIPTION QUIET_ON_EMPTY)
|
||||||
|
|
||||||
|
# Describe project version.
|
||||||
|
yosys_extract_version()
|
||||||
|
|
||||||
|
# Describe ABC integration.
|
||||||
|
if (YOSYS_ENABLE_ABC AND NOT YOSYS_ENABLE_SPAWN AND NOT YOSYS_ABC_EXECUTABLE STREQUAL "INTEGRATED-NOTFOUND")
|
||||||
|
message(WARNING "ABC support on this platform forces -DYOSYS_ABC_EXECUTABLE=INTEGRATED-NOTFOUND")
|
||||||
|
set(YOSYS_ABC_EXECUTABLE "INTEGRATED-NOTFOUND" CACHE FILEPATH "" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(YOSYS_LINK_ABC 0)
|
||||||
|
if (YOSYS_ENABLE_ABC)
|
||||||
|
if (NOT YOSYS_SKIP_ABC_SUBMODULE_CHECK)
|
||||||
|
yosys_check_abc_submodule()
|
||||||
|
endif()
|
||||||
|
if (YOSYS_ABC_EXECUTABLE STREQUAL "INTEGRATED-NOTFOUND")
|
||||||
|
set(YOSYS_LINK_ABC 1)
|
||||||
|
message(STATUS "Building ABC: (integrated)")
|
||||||
|
elseif (YOSYS_ABC_EXECUTABLE STREQUAL "")
|
||||||
|
set(abc_filename ${YOSYS_PROGRAM_PREFIX}yosys-abc${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
|
message(STATUS "Building ABC: ${YOSYS_INSTALL_FULL_BINDIR}/${abc_filename}")
|
||||||
|
else()
|
||||||
|
message(STATUS "External ABC: ${YOSYS_ABC_EXECUTABLE}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Ensure invalid dependencies fail at configuration time, not link time.
|
||||||
|
set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS ON)
|
||||||
|
|
||||||
|
# Pseudo-library that injects common compilation options into every Yosys component.
|
||||||
|
add_library(yosys_common INTERFACE)
|
||||||
|
target_compile_definitions(yosys_common INTERFACE
|
||||||
|
_YOSYS_
|
||||||
|
$<$<CONFIG:Debug,RelWithDebInfo>:DEBUG>
|
||||||
|
)
|
||||||
|
target_include_directories(yosys_common INTERFACE
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
if (SANITIZE)
|
||||||
|
target_compile_options(yosys_common INTERFACE
|
||||||
|
${sanitize_options}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Two pseudo-components used for dependency tracking only.
|
||||||
|
yosys_core(essentials BOOTSTRAP)
|
||||||
|
yosys_core(everything BOOTSTRAP)
|
||||||
|
|
||||||
|
# All of the source code.
|
||||||
|
add_subdirectory(libs)
|
||||||
|
add_subdirectory(kernel)
|
||||||
|
add_subdirectory(passes)
|
||||||
|
add_subdirectory(frontends)
|
||||||
|
add_subdirectory(backends)
|
||||||
|
add_subdirectory(techlibs)
|
||||||
|
if (YOSYS_ENABLE_PYTHON)
|
||||||
|
add_subdirectory(pyosys)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ABC submodule.
|
||||||
|
if (YOSYS_ENABLE_ABC)
|
||||||
|
set(YOSYS_ABC_INSTALL NO)
|
||||||
|
if (YOSYS_ABC_EXECUTABLE STREQUAL "")
|
||||||
|
set(YOSYS_ABC_INSTALL YES)
|
||||||
|
endif()
|
||||||
|
yosys_abc_target(libyosys-abc yosys-abc
|
||||||
|
INCLUDE_IN_ALL_IF ${YOSYS_ABC_INSTALL}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compute a transitive closure of enabled components.
|
||||||
|
yosys_expand_components(library_components essentials ${YOSYS_COMPONENTS})
|
||||||
|
yosys_expand_components(driver_components driver ${YOSYS_COMPONENTS})
|
||||||
|
|
||||||
|
# Main Yosys executable (compiler driver).
|
||||||
|
yosys_cxx_executable(yosys
|
||||||
|
OUTPUT_NAME yosys
|
||||||
|
INCLUDE_IN_ALL_IF ${YOSYS_INSTALL_DRIVER}
|
||||||
|
)
|
||||||
|
yosys_link_components(yosys PRIVATE ${driver_components})
|
||||||
|
set_property(TARGET yosys PROPERTY ENABLE_EXPORTS ON)
|
||||||
|
if (MINGW)
|
||||||
|
target_link_options(yosys PRIVATE LINKER:--export-all-symbols)
|
||||||
|
set_target_properties(yosys PROPERTIES
|
||||||
|
# Final name: `yosys.exe.a` (linked to explicitly)
|
||||||
|
IMPORT_PREFIX ""
|
||||||
|
IMPORT_SUFFIX ".exe.a"
|
||||||
|
)
|
||||||
|
if (YOSYS_INSTALL_DRIVER)
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/yosys.exe.a DESTINATION ${YOSYS_INSTALL_LIBDIR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_options(yosys PRIVATE -fsanitize=undefined)
|
||||||
|
|
||||||
|
# Yosys components as a library.
|
||||||
|
if (BUILD_SHARED_LIBS)
|
||||||
|
set(libyosys_type SHARED)
|
||||||
|
else()
|
||||||
|
set(libyosys_type STATIC)
|
||||||
|
endif()
|
||||||
|
yosys_cxx_library(libyosys ${libyosys_type}
|
||||||
|
OUTPUT_NAME libyosys
|
||||||
|
INCLUDE_IN_ALL_IF ${YOSYS_INSTALL_LIBRARY}
|
||||||
|
)
|
||||||
|
yosys_link_components(libyosys PRIVATE ${library_components})
|
||||||
|
add_library(Yosys::libyosys ALIAS libyosys)
|
||||||
|
if (MINGW)
|
||||||
|
set_target_properties(libyosys PROPERTIES
|
||||||
|
# Final name: `libyosys.dll.a` (linked to via `-lyosys`)
|
||||||
|
IMPORT_PREFIX ""
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Yosys data files (mainly headers and technological libraries).
|
||||||
|
if (YOSYS_INSTALL_DRIVER OR YOSYS_INSTALL_LIBRARY)
|
||||||
|
yosys_install_component_data(${library_components} DESTINATION ${YOSYS_INSTALL_DATADIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Python binary extension (for using Yosys as a Python library).
|
||||||
|
if (YOSYS_ENABLE_PYTHON)
|
||||||
|
yosys_cxx_library(pyosys SHARED
|
||||||
|
OUTPUT_NAME pyosys
|
||||||
|
INCLUDE_IN_ALL_IF ${YOSYS_INSTALL_PYTHON}
|
||||||
|
)
|
||||||
|
yosys_link_components(pyosys PRIVATE ${library_components})
|
||||||
|
|
||||||
|
if (YOSYS_INSTALL_PYTHON)
|
||||||
|
string(REPLACE "-" "_" PYOSYS_MODULE_PREFIX "${YOSYS_PROGRAM_PREFIX}")
|
||||||
|
if (YOSYS_INSTALL_PYTHON_SITEDIR STREQUAL "")
|
||||||
|
set(YOSYS_INSTALL_PYTHON_SITEDIR ${Python3_SITEARCH})
|
||||||
|
endif()
|
||||||
|
set(pyosys_install_dir ${YOSYS_INSTALL_PYTHON_SITEDIR}/${PYOSYS_MODULE_PREFIX}pyosys)
|
||||||
|
install(FILES pyosys/modinit.py
|
||||||
|
RENAME __init__.py
|
||||||
|
DESTINATION ${pyosys_install_dir}
|
||||||
|
)
|
||||||
|
install(FILES $<TARGET_FILE:pyosys>
|
||||||
|
RENAME libyosys${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||||
|
DESTINATION ${pyosys_install_dir}
|
||||||
|
)
|
||||||
|
if (YOSYS_ABC_EXECUTABLE STREQUAL "")
|
||||||
|
# If ABC is vendored it needs to be installed as a part of pyosys.
|
||||||
|
install(TARGETS yosys-abc
|
||||||
|
DESTINATION ${pyosys_install_dir}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
yosys_install_component_data(${library_components} DESTINATION ${pyosys_install_dir}/share)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Plugin build tool.
|
||||||
|
yosys_config_script(BUILD)
|
||||||
|
yosys_config_script(INSTALL)
|
||||||
|
|
||||||
|
# Tests.
|
||||||
|
add_subdirectory(tests/unit)
|
||||||
|
# TODO(cmake): other tests
|
||||||
|
|
||||||
|
# Docs.
|
||||||
|
add_custom_target(docs-prepare
|
||||||
|
COMMAND make -C ${CMAKE_SOURCE_DIR}/docs gen
|
||||||
|
BUILD_DIR=${CMAKE_BINARY_DIR}
|
||||||
|
PROGRAM_PREFIX=${YOSYS_PROGRAM_PREFIX}
|
||||||
|
YOSYS=$<TARGET_FILE:yosys>
|
||||||
|
)
|
||||||
|
foreach (format html latexpdf)
|
||||||
|
add_custom_target(docs-${format}
|
||||||
|
COMMAND make -C ${CMAKE_SOURCE_DIR}/docs ${format}
|
||||||
|
DEPENDS docs-prepare
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Utilities.
|
||||||
|
yosys_expand_components(all_components everything QUIET)
|
||||||
|
list(TRANSFORM all_components PREPEND "COMMAND;${CMAKE_COMMAND};-E;echo;" OUTPUT_VARIABLE echo_all_components)
|
||||||
|
add_custom_target(print-yosys-components
|
||||||
|
${echo_all_components}
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
math(EXPR YOSYS_VERSION_MINOR_next "${YOSYS_VERSION_MINOR} + 1")
|
||||||
|
add_custom_target(increment-minor-version
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo
|
||||||
|
"set(YOSYS_VERSION_MAJOR ${YOSYS_VERSION_MAJOR})"
|
||||||
|
> ${CMAKE_SOURCE_DIR}/cmake/YosysVersionData.cmake
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo
|
||||||
|
"set(YOSYS_VERSION_MINOR ${YOSYS_VERSION_MINOR_next})"
|
||||||
|
>> ${CMAKE_SOURCE_DIR}/cmake/YosysVersionData.cmake
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
18
backends/CMakeLists.txt
Normal file
18
backends/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
add_subdirectory(aiger)
|
||||||
|
add_subdirectory(aiger2)
|
||||||
|
add_subdirectory(blif)
|
||||||
|
add_subdirectory(btor)
|
||||||
|
add_subdirectory(cxxrtl)
|
||||||
|
add_subdirectory(edif)
|
||||||
|
add_subdirectory(firrtl)
|
||||||
|
add_subdirectory(functional)
|
||||||
|
add_subdirectory(intersynth)
|
||||||
|
add_subdirectory(jny)
|
||||||
|
add_subdirectory(json)
|
||||||
|
add_subdirectory(rtlil)
|
||||||
|
add_subdirectory(simplec)
|
||||||
|
add_subdirectory(smt2)
|
||||||
|
add_subdirectory(smv)
|
||||||
|
add_subdirectory(spice)
|
||||||
|
add_subdirectory(table)
|
||||||
|
add_subdirectory(verilog)
|
||||||
8
backends/aiger/CMakeLists.txt
Normal file
8
backends/aiger/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
yosys_backend(aiger
|
||||||
|
aiger.cc
|
||||||
|
REQUIRES
|
||||||
|
json11
|
||||||
|
)
|
||||||
|
yosys_backend(xaiger
|
||||||
|
xaiger.cc
|
||||||
|
)
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/aiger/aiger.o
|
|
||||||
OBJS += backends/aiger/xaiger.o
|
|
||||||
|
|
||||||
5
backends/aiger2/CMakeLists.txt
Normal file
5
backends/aiger2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
yosys_backend(aiger2
|
||||||
|
aiger.cc
|
||||||
|
PROVIDES
|
||||||
|
write_xaiger2
|
||||||
|
)
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
OBJS += backends/aiger2/aiger.o
|
|
||||||
3
backends/blif/CMakeLists.txt
Normal file
3
backends/blif/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(blif
|
||||||
|
blif.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/blif/blif.o
|
|
||||||
|
|
||||||
7
backends/btor/CMakeLists.txt
Normal file
7
backends/btor/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
yosys_backend(btor
|
||||||
|
btor.cc
|
||||||
|
REQUIRES
|
||||||
|
bmuxmap
|
||||||
|
demuxmap
|
||||||
|
bwmuxmap
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/btor/btor.o
|
|
||||||
|
|
||||||
19
backends/cxxrtl/CMakeLists.txt
Normal file
19
backends/cxxrtl/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
yosys_backend(cxxrtl
|
||||||
|
cxxrtl_backend.cc
|
||||||
|
DATA_DIR
|
||||||
|
include/backends/cxxrtl
|
||||||
|
DATA_FILES
|
||||||
|
runtime/README.txt
|
||||||
|
runtime/cxxrtl/cxxrtl.h
|
||||||
|
runtime/cxxrtl/cxxrtl_vcd.h
|
||||||
|
runtime/cxxrtl/cxxrtl_time.h
|
||||||
|
runtime/cxxrtl/cxxrtl_replay.h
|
||||||
|
runtime/cxxrtl/capi/cxxrtl_capi.cc
|
||||||
|
runtime/cxxrtl/capi/cxxrtl_capi.h
|
||||||
|
runtime/cxxrtl/capi/cxxrtl_capi_vcd.cc
|
||||||
|
runtime/cxxrtl/capi/cxxrtl_capi_vcd.h
|
||||||
|
REQUIRES
|
||||||
|
hierarchy
|
||||||
|
flatten
|
||||||
|
proc
|
||||||
|
)
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/cxxrtl/cxxrtl_backend.o
|
|
||||||
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/cxxrtl.h))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/cxxrtl_vcd.h))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/cxxrtl_time.h))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.cc))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi.h))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi_vcd.cc))
|
|
||||||
$(eval $(call add_include_file,backends/cxxrtl/runtime/cxxrtl/capi/cxxrtl_capi_vcd.h))
|
|
||||||
3
backends/edif/CMakeLists.txt
Normal file
3
backends/edif/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(edif
|
||||||
|
edif.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/edif/edif.o
|
|
||||||
|
|
||||||
8
backends/firrtl/CMakeLists.txt
Normal file
8
backends/firrtl/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
yosys_backend(firrtl
|
||||||
|
firrtl.cc
|
||||||
|
REQUIRES
|
||||||
|
pmuxtree
|
||||||
|
bmuxmap
|
||||||
|
demuxmap
|
||||||
|
bwmuxmap
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/firrtl/firrtl.o
|
|
||||||
|
|
||||||
12
backends/functional/CMakeLists.txt
Normal file
12
backends/functional/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
yosys_backend(functional_cxx
|
||||||
|
cxx.cc
|
||||||
|
)
|
||||||
|
yosys_backend(functional_smt2
|
||||||
|
smtlib.cc
|
||||||
|
)
|
||||||
|
yosys_backend(functional_rosette
|
||||||
|
smtlib_rosette.cc
|
||||||
|
)
|
||||||
|
yosys_test_pass(generic
|
||||||
|
test_generic.cc
|
||||||
|
)
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
OBJS += backends/functional/cxx.o
|
|
||||||
OBJS += backends/functional/smtlib.o
|
|
||||||
OBJS += backends/functional/smtlib_rosette.o
|
|
||||||
OBJS += backends/functional/test_generic.o
|
|
||||||
3
backends/intersynth/CMakeLists.txt
Normal file
3
backends/intersynth/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(intersynth
|
||||||
|
intersynth.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/intersynth/intersynth.o
|
|
||||||
|
|
||||||
5
backends/jny/CMakeLists.txt
Normal file
5
backends/jny/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
yosys_backend(jny
|
||||||
|
jny.cc
|
||||||
|
PROVIDES
|
||||||
|
jny
|
||||||
|
)
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/jny/jny.o
|
|
||||||
5
backends/json/CMakeLists.txt
Normal file
5
backends/json/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
yosys_backend(json
|
||||||
|
json.cc
|
||||||
|
PROVIDES
|
||||||
|
json
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/json/json.o
|
|
||||||
|
|
||||||
11
backends/rtlil/CMakeLists.txt
Normal file
11
backends/rtlil/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
yosys_backend(rtlil
|
||||||
|
rtlil_backend.cc
|
||||||
|
rtlil_backend.h
|
||||||
|
PROVIDES
|
||||||
|
dump
|
||||||
|
DATA_DIR
|
||||||
|
include/backends/rtlil
|
||||||
|
DATA_FILES
|
||||||
|
rtlil_backend.h
|
||||||
|
ESSENTIAL
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/rtlil/rtlil_backend.o
|
|
||||||
|
|
||||||
3
backends/simplec/CMakeLists.txt
Normal file
3
backends/simplec/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(simplec
|
||||||
|
simplec.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/simplec/simplec.o
|
|
||||||
|
|
||||||
16
backends/smt2/CMakeLists.txt
Normal file
16
backends/smt2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
yosys_backend(smt2
|
||||||
|
smt2.cc
|
||||||
|
REQUIRES
|
||||||
|
json11
|
||||||
|
DATA_DIR
|
||||||
|
python3
|
||||||
|
DATA_FILES
|
||||||
|
smtio.py
|
||||||
|
ywio.py
|
||||||
|
REQUIRES
|
||||||
|
bmuxmap
|
||||||
|
demuxmap
|
||||||
|
)
|
||||||
|
|
||||||
|
yosys_python_executable(yosys-smtbmc smtbmc.py)
|
||||||
|
yosys_python_executable(yosys-witness witness.py)
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/smt2/smt2.o
|
|
||||||
|
|
||||||
ifneq ($(CONFIG),mxe)
|
|
||||||
ifneq ($(CONFIG),emcc)
|
|
||||||
|
|
||||||
# MSYS targets support yosys-smtbmc, but require a launcher script
|
|
||||||
ifeq ($(CONFIG),$(filter $(CONFIG),msys2 msys2-64))
|
|
||||||
TARGETS += $(PROGRAM_PREFIX)yosys-smtbmc.exe $(PROGRAM_PREFIX)yosys-smtbmc-script.py
|
|
||||||
TARGETS += $(PROGRAM_PREFIX)yosys-witness.exe $(PROGRAM_PREFIX)yosys-witness-script.py
|
|
||||||
# Needed to find the Python interpreter for yosys-smtbmc scripts.
|
|
||||||
# Override if necessary, it is only used for msys2 targets.
|
|
||||||
PYTHON := $(shell cygpath -w -m $(PREFIX)/bin/python3)
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-smtbmc-script.py: backends/smt2/smtbmc.py
|
|
||||||
$(P) sed -e 's|##yosys-sys-path##|sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/$(PROGRAM_PREFIX)yosys/python3"]]|;' \
|
|
||||||
-e "s|#!/usr/bin/env python3|#!$(PYTHON)|" < $< > $@
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-witness-script.py: backends/smt2/witness.py
|
|
||||||
$(P) sed -e 's|##yosys-sys-path##|sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/$(PROGRAM_PREFIX)yosys/python3"]]|;' \
|
|
||||||
-e "s|#!/usr/bin/env python3|#!$(PYTHON)|" < $< > $@
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-smtbmc.exe: misc/launcher.c $(PROGRAM_PREFIX)yosys-smtbmc-script.py
|
|
||||||
$(P) $(CXX) -DGUI=0 -O -s -o $@ $<
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-witness.exe: misc/launcher.c $(PROGRAM_PREFIX)yosys-witness-script.py
|
|
||||||
$(P) $(CXX) -DGUI=0 -O -s -o $@ $<
|
|
||||||
# Other targets
|
|
||||||
else
|
|
||||||
TARGETS += $(PROGRAM_PREFIX)yosys-smtbmc $(PROGRAM_PREFIX)yosys-witness
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-smtbmc: backends/smt2/smtbmc.py
|
|
||||||
$(P) sed 's|##yosys-sys-path##|sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/$(PROGRAM_PREFIX)yosys/python3"]]|;' < $< > $@.new
|
|
||||||
$(Q) chmod +x $@.new
|
|
||||||
$(Q) mv $@.new $@
|
|
||||||
|
|
||||||
$(PROGRAM_PREFIX)yosys-witness: backends/smt2/witness.py
|
|
||||||
$(P) sed 's|##yosys-sys-path##|sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/$(PROGRAM_PREFIX)yosys/python3"]]|;' < $< > $@.new
|
|
||||||
$(Q) chmod +x $@.new
|
|
||||||
$(Q) mv $@.new $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(eval $(call add_share_file,share/python3,backends/smt2/smtio.py))
|
|
||||||
$(eval $(call add_share_file,share/python3,backends/smt2/ywio.py))
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
4
backends/smt2/smtbmc.py
Normal file → Executable file
4
backends/smt2/smtbmc.py
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!@PYTHON_SHEBANG@
|
||||||
#
|
#
|
||||||
# yosys -- Yosys Open SYnthesis Suite
|
# yosys -- Yosys Open SYnthesis Suite
|
||||||
#
|
#
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import os, sys, getopt, re, bisect, json
|
import os, sys, getopt, re, bisect, json
|
||||||
##yosys-sys-path##
|
sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/@YOSYS_PROGRAM_PREFIX@yosys/python3"]]
|
||||||
from smtio import SmtIo, SmtOpts, MkVcd
|
from smtio import SmtIo, SmtOpts, MkVcd
|
||||||
from ywio import ReadWitness, WriteWitness, WitnessValues
|
from ywio import ReadWitness, WriteWitness, WitnessValues
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
|
||||||
4
backends/smt2/witness.py
Normal file → Executable file
4
backends/smt2/witness.py
Normal file → Executable file
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!@PYTHON_SHEBANG@
|
||||||
#
|
#
|
||||||
# yosys -- Yosys Open SYnthesis Suite
|
# yosys -- Yosys Open SYnthesis Suite
|
||||||
#
|
#
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import os, sys, itertools, re
|
import os, sys, itertools, re
|
||||||
##yosys-sys-path##
|
sys.path += [os.path.dirname(os.path.realpath(__file__)) + p for p in ["/share/python3", "/../share/@YOSYS_PROGRAM_PREFIX@yosys/python3"]]
|
||||||
import json
|
import json
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
|
|
||||||
7
backends/smv/CMakeLists.txt
Normal file
7
backends/smv/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
yosys_backend(smv
|
||||||
|
smv.cc
|
||||||
|
REQUIRES
|
||||||
|
bmuxmap
|
||||||
|
demuxmap
|
||||||
|
bwmuxmap
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/smv/smv.o
|
|
||||||
|
|
||||||
3
backends/spice/CMakeLists.txt
Normal file
3
backends/spice/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(spice
|
||||||
|
spice.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/spice/spice.o
|
|
||||||
|
|
||||||
3
backends/table/CMakeLists.txt
Normal file
3
backends/table/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_backend(table
|
||||||
|
table.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/table/table.o
|
|
||||||
|
|
||||||
8
backends/verilog/CMakeLists.txt
Normal file
8
backends/verilog/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
yosys_backend(verilog
|
||||||
|
verilog_backend.cc
|
||||||
|
verilog_backend.h
|
||||||
|
REQUIRES
|
||||||
|
bmuxmap
|
||||||
|
demuxmap
|
||||||
|
clean_zerowidth
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += backends/verilog/verilog_backend.o
|
|
||||||
|
|
||||||
40
cmake/CheckLibcFeatures.cmake
Normal file
40
cmake/CheckLibcFeatures.cmake
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
include(CMakePushCheckState)
|
||||||
|
include(CheckSourceCompiles)
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
|
||||||
|
function(check_glob)
|
||||||
|
check_cxx_symbol_exists(glob "glob.h" HAVE_GLOB)
|
||||||
|
return (PROPAGATE HAVE_BLOB)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(check_pthread_create)
|
||||||
|
if (Threads_FOUND)
|
||||||
|
# On WASI, `pthread_create()` is always available, but always fails on triples without threading
|
||||||
|
# support. Probe for it while requesting the stub implementation to be hidden, otherwise we will
|
||||||
|
# end up always crashing at runtime on thread creation.
|
||||||
|
cmake_push_check_state(RESET)
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS -D_WASI_STRICT_PTHREAD)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
check_source_compiles(CXX [[
|
||||||
|
#include <pthread.h>
|
||||||
|
int main() {
|
||||||
|
pthread_create(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
]] HAVE_PTHREAD_CREATE)
|
||||||
|
cmake_pop_check_state()
|
||||||
|
endif()
|
||||||
|
return (PROPAGATE HAVE_PTHREAD_CREATE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(check_system)
|
||||||
|
check_cxx_symbol_exists(system "stdlib.h" HAVE_SYSTEM)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(check_popen)
|
||||||
|
check_cxx_symbol_exists(popen "stdio.h" HAVE_POPEN)
|
||||||
|
if (NOT HAVE_POPEN)
|
||||||
|
unset(HAVE_POPEN CACHE)
|
||||||
|
# https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/popen-wpopen
|
||||||
|
check_cxx_symbol_exists(_popen "stdio.h" HAVE_POPEN)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
35
cmake/Condition.cmake
Normal file
35
cmake/Condition.cmake
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# condition(<var> <expr>...)
|
||||||
|
#
|
||||||
|
# If `<expr>...` is truthful (evaluated as in `if()`) then assigns 1 to `<var>`, else assigns 0.
|
||||||
|
# The assigned value is `0`/`1` rather than `TRUE`/`FALSE` for ease of use in generator expressions.
|
||||||
|
# Note that `<expr>...` *must* be unquoted.
|
||||||
|
#
|
||||||
|
# To understand how a certain outcome is reached, reconfigure the project with `--log-level VERBOSE`.
|
||||||
|
#
|
||||||
|
# Believe it or not, CMake doesn't have this built in!
|
||||||
|
#
|
||||||
|
macro(condition var)
|
||||||
|
if (${ARGN})
|
||||||
|
set(${var} 1)
|
||||||
|
else()
|
||||||
|
set(${var} 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_debug_expr)
|
||||||
|
foreach (token ${ARGN})
|
||||||
|
if (DEFINED ${token})
|
||||||
|
if (${${token}})
|
||||||
|
list(APPEND _debug_expr "${token}:1")
|
||||||
|
else()
|
||||||
|
list(APPEND _debug_expr "${token}:0")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
list(APPEND _debug_expr "${token}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
string(JOIN " " _debug_expr ${_debug_expr})
|
||||||
|
message(VERBOSE " ${var} = ${${var}} (${_debug_expr})")
|
||||||
|
unset(_debug_expr)
|
||||||
|
endmacro()
|
||||||
24
cmake/FindDlfcn.cmake
Normal file
24
cmake/FindDlfcn.cmake
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
include(CMakePushCheckState)
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
if (WIN32 OR MSYS)
|
||||||
|
# Windows; dlopen is available via a polyfill `libs/dlfcn-win32`.
|
||||||
|
set(Dlfcn_LIBRARIES dlfcn)
|
||||||
|
else()
|
||||||
|
# Unix and Wasm; dlopen may or may not be available depending on platform.
|
||||||
|
cmake_push_check_state(RESET)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
|
||||||
|
check_cxx_symbol_exists(dlopen "dlfcn.h" HAVE_DLOPEN)
|
||||||
|
cmake_pop_check_state()
|
||||||
|
|
||||||
|
if (HAVE_DLOPEN)
|
||||||
|
add_library(dlfcn INTERFACE)
|
||||||
|
target_link_libraries(dlfcn INTERFACE ${CMAKE_DL_LIBS})
|
||||||
|
set(Dlfcn_LIBRARIES dlfcn)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(Dlfcn
|
||||||
|
REQUIRED_VARS Dlfcn_LIBRARIES
|
||||||
|
)
|
||||||
42
cmake/FindPyosysEnv.cmake
Normal file
42
cmake/FindPyosysEnv.cmake
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# We need a *third* `FindPython`-style call in this codebase because the host
|
||||||
|
# `Python3_EXECUTABLE` may not have pybind11 and cxxheaderparser installed,
|
||||||
|
# and installing it can be onerous. To work around this problem we try to detect
|
||||||
|
# whether the host interpreter has the necessary dependencies first, and if it
|
||||||
|
# does not, fall back to using `uv`.
|
||||||
|
|
||||||
|
foreach (strategy host uv fail)
|
||||||
|
if (strategy STREQUAL "host")
|
||||||
|
set(PyosysEnv_PYTHON Python3_EXECUTABLE)
|
||||||
|
elseif (strategy STREQUAL "uv")
|
||||||
|
set(PyosysEnv_PYTHON uv run --no-project --with pybind11>3,<4 --with cxxheaderparser python)
|
||||||
|
else()
|
||||||
|
set(PyosysEnv_PYTHON)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${PyosysEnv_PYTHON} -m pybind11 --includes
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
OUTPUT_VARIABLE output
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
if (result EQUAL 0)
|
||||||
|
string(REGEX REPLACE " ?-I" ";" pybind11_INCLUDE_DIR "${output}")
|
||||||
|
list(FILTER pybind11_INCLUDE_DIR INCLUDE REGEX "/pybind11/")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${PyosysEnv_PYTHON} ${CMAKE_SOURCE_DIR}/pyosys/generator.py --help
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
OUTPUT_QUIET
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
if (result EQUAL 0)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
find_package_handle_standard_args(PyosysEnv
|
||||||
|
REQUIRED_VARS PyosysEnv_PYTHON pybind11_INCLUDE_DIR
|
||||||
|
)
|
||||||
16
cmake/FindPython3Embed.cmake
Normal file
16
cmake/FindPython3Embed.cmake
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Wrapper to improve behavior of `FindPython3` during cross-compilation.
|
||||||
|
# Does not entirely fix the problem; CMake 4.0 introduces `Python_ARTIFACTS_PREFIX`, which will.
|
||||||
|
|
||||||
|
# Stash the package found status
|
||||||
|
get_property(packages_found GLOBAL PROPERTY PACKAGES_FOUND)
|
||||||
|
get_property(packages_not_found GLOBAL PROPERTY PACKAGES_NOT_FOUND)
|
||||||
|
get_property(required_version GLOBAL PROPERTY _CMAKE_Python3_REQUIRED_VERSION)
|
||||||
|
|
||||||
|
# The `EXACT` specifier prevents the situation of `FindPython3` discovering a newer libpython-dev
|
||||||
|
# than the interpreter found in the past, rejecting it because it is too new, and giving up.
|
||||||
|
find_package(Python3 EXACT ${Python3_VERSION} COMPONENTS Development.Embed)
|
||||||
|
set(Python3Embed_FOUND ${Python3_Development.Embed_FOUND})
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY PACKAGES_FOUND "${packages_found}")
|
||||||
|
set_property(GLOBAL PROPERTY PACKAGES_NOT_FOUND "${packages_not_found}")
|
||||||
|
set_property(GLOBAL PROPERTY _CMAKE_Python3_REQUIRED_VERSION "${required_version}")
|
||||||
43
cmake/PkgConfig.cmake
Normal file
43
cmake/PkgConfig.cmake
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# pkg_config_import(<package>)
|
||||||
|
#
|
||||||
|
# To use this command, `find_package(PkgConfig)` must be used beforehand, but it does
|
||||||
|
# not have to succeed. If the `PkgConfig` package is not found, all imports silently fail.
|
||||||
|
#
|
||||||
|
# Imports `<package>` as a CMake `IMPORTED` target `PkgConfig::<package>`.
|
||||||
|
# Updates the global `PACKAGES_FOUND` and `PACKAGES_NOT_FOUND` properties and defines
|
||||||
|
# the `<package>_FOUND` variable.
|
||||||
|
#
|
||||||
|
function(pkg_config_import arg_PREFIX)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1 arg "" "" "MODULES")
|
||||||
|
if (NOT arg_MODULES)
|
||||||
|
set(arg_MODULES ${arg_PREFIX})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (PkgConfig_FOUND)
|
||||||
|
# Once CMake 4.1 is available, this call should be replaced with `cmake_pkg_config()`.
|
||||||
|
pkg_check_modules(${arg_PREFIX} IMPORTED_TARGET ${arg_MODULES})
|
||||||
|
if (${arg_PREFIX}_FOUND)
|
||||||
|
# We found the pkgconfig file, but is it actually a usable package?
|
||||||
|
# The main cause of failure here would be cross-compiling, which pkg-config does not
|
||||||
|
# handle very well (especially pre-`cmake_pkg_config()`).
|
||||||
|
try_compile(is_usable
|
||||||
|
SOURCE_FROM_CONTENT "main.cc" "int main() {}"
|
||||||
|
LINK_LIBRARIES PkgConfig::${arg_PREFIX}
|
||||||
|
LOG_DESCRIPTION "Checking if PkgConfig::${arg_PREFIX} is usable"
|
||||||
|
)
|
||||||
|
if (NOT is_usable)
|
||||||
|
message(STATUS "Modules '${arg_MODULES}' unusable (bad \$PKG_CONFIG_LIBDIR?)")
|
||||||
|
set(${arg_PREFIX}_FOUND 0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (${arg_PREFIX}_FOUND)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND ${arg_PREFIX})
|
||||||
|
else()
|
||||||
|
set_property(GLOBAL APPEND PROPERTY PACKAGES_NOT_FOUND ${arg_PREFIX})
|
||||||
|
endif()
|
||||||
|
return (PROPAGATE ${arg_PREFIX}_FOUND)
|
||||||
|
endfunction()
|
||||||
60
cmake/PmgenCommand.cmake
Normal file
60
cmake/PmgenCommand.cmake
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# pmgen_command(<output>
|
||||||
|
# [<input>...]
|
||||||
|
# [PREFIX <prefix>]
|
||||||
|
# [DEBUG]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Builds `<output>_pm.h` in the current binary directory from pmgen source files `<input>`, which must have
|
||||||
|
# the `*.pmg` extension. If `<input>...` contains more than one file, `<prefix>` must be provided.
|
||||||
|
#
|
||||||
|
# Defines the following variables:
|
||||||
|
# - `PMGEN_<output>_DEFINED`: Boolean indicating whether this command was successfully invoked.
|
||||||
|
# - `PMGEN_<output>_OUTPUT`: The header file generated by `pmgen`.
|
||||||
|
#
|
||||||
|
# Usage example:
|
||||||
|
#
|
||||||
|
# pmgen_command(my_dsp
|
||||||
|
# my_dsp.pmg
|
||||||
|
# )
|
||||||
|
# yosys_pass(my_dsp
|
||||||
|
# my_dsp.cc
|
||||||
|
# ${PMGEN_my_dsp_OUTPUT}
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Usage example with multiple files:
|
||||||
|
#
|
||||||
|
# pmgen_command(my_dsp
|
||||||
|
# my_dsp_macc.pmg
|
||||||
|
# my_dsp_carry.pmg
|
||||||
|
# PREFIX
|
||||||
|
# my_dsp
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
function(pmgen_command arg_NAME)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1 arg "DEBUG" "PREFIX" "")
|
||||||
|
set(arg_INPUTS ${arg_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
|
set(pmgen_script ${CMAKE_SOURCE_DIR}/passes/pmgen/pmgen.py)
|
||||||
|
set(pmgen_output ${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}_pm.h)
|
||||||
|
cmake_path(RELATIVE_PATH pmgen_output BASE_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE pmgen_output_rel)
|
||||||
|
add_custom_command(
|
||||||
|
DEPENDS ${pmgen_script} ${arg_INPUTS}
|
||||||
|
OUTPUT ${pmgen_output}
|
||||||
|
COMMAND ${Python3_EXECUTABLE}
|
||||||
|
${pmgen_script}
|
||||||
|
"$<$<BOOL:${arg_DEBUG}>:-g>"
|
||||||
|
"$<$<BOOL:${arg_PREFIX}>:-p;${arg_PREFIX}>"
|
||||||
|
-o ${pmgen_output}
|
||||||
|
${arg_INPUTS}
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
VERBATIM
|
||||||
|
COMMENT "Compiling pattern matcher ${pmgen_output_rel}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# The usage of this command is somewhat inspired by `flex_target()` and `bison_target()`.
|
||||||
|
set(PMGEN_${arg_NAME}_DEFINED TRUE)
|
||||||
|
set(PMGEN_${arg_NAME}_OUTPUT ${pmgen_output} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
96
cmake/YosysAbc.cmake
Normal file
96
cmake/YosysAbc.cmake
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
include(CheckCompilerFlag)
|
||||||
|
|
||||||
|
define_property(TARGET PROPERTY YOSYS_IS_ABC)
|
||||||
|
|
||||||
|
function(target_safe_compile_options target scope)
|
||||||
|
foreach (lang C CXX)
|
||||||
|
foreach (flag ${ARGN})
|
||||||
|
check_compiler_flag(${lang} ${flag} HAVE_${lang}_${flag})
|
||||||
|
if (HAVE_${lang}_${flag})
|
||||||
|
target_compile_options(${target} ${scope} $<$<COMPILE_LANGUAGE:${lang}>:${flag}>)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(_yosys_abc_extract_makefile result vardecl filename)
|
||||||
|
# Parse a Makefile fragment and extracts the first matching variable assignment into
|
||||||
|
# a list of values.
|
||||||
|
file(READ ${filename} contents)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${filename})
|
||||||
|
if ("${contents}" MATCHES "${vardecl}(\\\\\n|[ \t])*(([^\\\\\n]|\\\\\n)+)")
|
||||||
|
string(REGEX REPLACE "(\\\\\n|[ \t])+" ";" ${result} "${CMAKE_MATCH_2}")
|
||||||
|
endif()
|
||||||
|
return (PROPAGATE ${result})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yosys_abc_target arg_LIBNAME arg_EXENAME)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 2 arg "" "INCLUDE_IN_ALL_IF" "")
|
||||||
|
|
||||||
|
# Instead of using either the ABC Make or CMake build system, we parse the source
|
||||||
|
# of truth: ABC's `module.make` files. This turns out to be quite trivial.
|
||||||
|
# This way, no assumptions about the environment are made, and Yosys can be compiled
|
||||||
|
# on Windows without MSYS as a result (while benefitting other platforms as well).
|
||||||
|
set(all_sources)
|
||||||
|
_yosys_abc_extract_makefile(module_files "MODULES :=" ${CMAKE_SOURCE_DIR}/abc/Makefile)
|
||||||
|
_yosys_abc_extract_makefile(module_files_cudd "MODULES \\+=" ${CMAKE_SOURCE_DIR}/abc/Makefile)
|
||||||
|
list(REMOVE_ITEM module_files "$(wildcard" "src/ext*)")
|
||||||
|
foreach (module_file ${module_files} ${module_files_cudd})
|
||||||
|
_yosys_abc_extract_makefile(module_sources "SRC \\+=" ${CMAKE_SOURCE_DIR}/abc/${module_file}/module.make)
|
||||||
|
list(APPEND all_sources ${module_sources})
|
||||||
|
endforeach()
|
||||||
|
list(TRANSFORM all_sources PREPEND abc/)
|
||||||
|
|
||||||
|
# Required to get `-DABC_NAMESPACE` below to work consistently.
|
||||||
|
set_source_files_properties(${all_sources} PROPERTIES LANGUAGE CXX)
|
||||||
|
|
||||||
|
set(main_source abc/src/base/main/main.c)
|
||||||
|
list(REMOVE_ITEM all_sources ${main_source})
|
||||||
|
|
||||||
|
find_package(Threads)
|
||||||
|
yosys_cxx_library(${arg_LIBNAME} STATIC
|
||||||
|
OUTPUT_NAME ${arg_LIBNAME}
|
||||||
|
)
|
||||||
|
target_sources(${arg_LIBNAME} PRIVATE ${all_sources})
|
||||||
|
target_include_directories(${arg_LIBNAME} PRIVATE abc/src)
|
||||||
|
target_compile_definitions(${arg_LIBNAME} PUBLIC
|
||||||
|
WIN32_NO_DLL
|
||||||
|
ABC_NAMESPACE=abc
|
||||||
|
ABC_USE_STDINT_H=1
|
||||||
|
ABC_USE_CUDD=1
|
||||||
|
ABC_NO_DYNAMIC_LINKING
|
||||||
|
$<${YOSYS_ENABLE_THREADS}:ABC_USE_PTHREADS>
|
||||||
|
$<${YOSYS_ENABLE_READLINE}:ABC_USE_READLINE>
|
||||||
|
ABC_NO_RLIMIT
|
||||||
|
)
|
||||||
|
target_safe_compile_options(${arg_LIBNAME} PRIVATE
|
||||||
|
-fpermissive
|
||||||
|
-fno-exceptions
|
||||||
|
-Wno-write-strings
|
||||||
|
-Wno-changes-meaning
|
||||||
|
-Wno-attributes
|
||||||
|
-Wno-deprecated-declarations
|
||||||
|
-Wno-deprecated-comma-subscript
|
||||||
|
-Wno-format
|
||||||
|
-Wno-constant-logical-operand
|
||||||
|
)
|
||||||
|
target_link_libraries(${arg_LIBNAME} PUBLIC
|
||||||
|
$<${YOSYS_ENABLE_THREADS}:Threads::Threads>
|
||||||
|
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
|
||||||
|
$<$<BOOL:${WIN32}>:-lshlwapi>
|
||||||
|
)
|
||||||
|
set_target_properties(${arg_LIBNAME} PROPERTIES
|
||||||
|
YOSYS_IS_ABC ON
|
||||||
|
)
|
||||||
|
|
||||||
|
yosys_cxx_executable(${arg_EXENAME}
|
||||||
|
OUTPUT_NAME ${arg_EXENAME}
|
||||||
|
INCLUDE_IN_ALL_IF "${arg_INCLUDE_IN_ALL_IF}"
|
||||||
|
)
|
||||||
|
target_sources(${arg_EXENAME} PRIVATE ${main_source})
|
||||||
|
target_include_directories(${arg_EXENAME} PRIVATE abc/src)
|
||||||
|
target_link_libraries(${arg_EXENAME} PRIVATE ${arg_LIBNAME})
|
||||||
|
set_target_properties(${arg_EXENAME} PROPERTIES
|
||||||
|
YOSYS_IS_ABC ON
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
64
cmake/YosysAbcSubmodule.cmake
Normal file
64
cmake/YosysAbcSubmodule.cmake
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# depends on YosysVersion.cmake
|
||||||
|
|
||||||
|
function(yosys_check_abc_submodule)
|
||||||
|
yosys_call_git(status)
|
||||||
|
set(yosys_status "tarball")
|
||||||
|
if (git_result EQUAL 0)
|
||||||
|
set(yosys_status "git")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
yosys_call_git(submodule status abc)
|
||||||
|
set(git_commit)
|
||||||
|
if (EXISTS "${CMAKE_SOURCE_DIR}/abc/.gitcommit")
|
||||||
|
file(READ "${CMAKE_SOURCE_DIR}/abc/.gitcommit" git_commit)
|
||||||
|
string(STRIP "${git_commit}" git_commit)
|
||||||
|
endif()
|
||||||
|
set(abc_status "none")
|
||||||
|
if (git_result EQUAL 0 AND git_output MATCHES "^ ")
|
||||||
|
set(abc_status "git")
|
||||||
|
elseif (git_result EQUAL 0 AND git_output MATCHES "^\\+")
|
||||||
|
set(abc_status "git-changed")
|
||||||
|
elseif (git_result EQUAL 0 AND git_output MATCHES "^U")
|
||||||
|
set(abc_status "git-conflict")
|
||||||
|
elseif (git_commit MATCHES "^[0-9a-fA-F]+$")
|
||||||
|
set(abc_status "tarball")
|
||||||
|
elseif (git_commit MATCHES "\\$Format:%[hH]\\$")
|
||||||
|
set(abc_status "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (abc_status STREQUAL "git" OR abc_status STREQUAL "tarball")
|
||||||
|
# Normal submodule or a tarball.
|
||||||
|
elseif (abc_status STREQUAL "git-changed")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"'abc' submodule does not match expected commit.\n"
|
||||||
|
"Run 'git submodule update' to check out the correct version.\n"
|
||||||
|
"Note: If testing a different version of ABC, call 'git commit abc' "
|
||||||
|
"in the Yosys source directory to update the expected commit.\n"
|
||||||
|
)
|
||||||
|
elseif (abc_status STREQUAL "git-conflict")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"'abc' submodule has merge conflicts.\n"
|
||||||
|
"Please resolve merge conflicts before continuing.\n"
|
||||||
|
)
|
||||||
|
elseif (abc_status STREQUAL "unknown") # OK
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Error: 'abc' is not configured as a git submodule.\n"
|
||||||
|
"To resolve this:\n"
|
||||||
|
"1. Back up your changes: Save any modifications from the 'abc' directory to another location.\n"
|
||||||
|
"2. Remove the existing 'abc' directory: Delete the 'abc' directory and all its contents.\n"
|
||||||
|
"3. Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule.\n"
|
||||||
|
"4. Reapply your changes: Move your saved changes back to the 'abc' directory, if necessary.\n"
|
||||||
|
)
|
||||||
|
elseif (yosys_status STREQUAL "git") # OK
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule.\n"
|
||||||
|
)
|
||||||
|
else() #
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"${CMAKE_SOURCE_DIR} is not configured as a git repository, and 'abc' folder is missing.\n"
|
||||||
|
"If you already have ABC, set 'ABCEXTERNAL' make variable to point to ABC executable.\n"
|
||||||
|
"Otherwise, download release archive 'yosys.tar.gz' from https://github.com/YosysHQ/yosys/releases.\n"
|
||||||
|
" ('Source code' archive does not contain submodules.)\n"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
321
cmake/YosysComponent.cmake
Normal file
321
cmake/YosysComponent.cmake
Normal file
|
|
@ -0,0 +1,321 @@
|
||||||
|
set(namespace "yosys")
|
||||||
|
|
||||||
|
# Properties internal to the component system.
|
||||||
|
define_property(TARGET PROPERTY YOSYS_COMPONENT)
|
||||||
|
define_property(TARGET PROPERTY YOSYS_PROVIDES)
|
||||||
|
define_property(TARGET PROPERTY YOSYS_REQUIRES)
|
||||||
|
define_property(TARGET PROPERTY YOSYS_DATA_FILES)
|
||||||
|
define_property(TARGET PROPERTY YOSYS_ENABLE_IF)
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_component(<prefix> <name> [INTERFACE]
|
||||||
|
# [<source>...]
|
||||||
|
# [DEFINITIONS <definition>...]
|
||||||
|
# [INCLUDE_DIRS <directory>...]
|
||||||
|
# [LIBRARIES <library>...]
|
||||||
|
# [PROVIDES <provided>...]
|
||||||
|
# [REQUIRES <required>...]
|
||||||
|
# [DATA_DIR <data_dir>]
|
||||||
|
# [DATA_FILES <data_file>...]
|
||||||
|
# [DATA_EXPLICIT [<dest_file> <src_file>]...]
|
||||||
|
# [ESSENTIAL]
|
||||||
|
# [ENABLE_IF "<condition>"]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Creates a target `yosys_<name>` (if `<prefix>` is empty) or `yosys_<prefix>_<name>` (if `<prefix>` is not empty).
|
||||||
|
# This target is an library target with some Yosys-specific behavior that simplifies partitioning the compiler
|
||||||
|
# into small pieces with explicitly defined compile-time and run-time dependency metadata. Circular dependencies
|
||||||
|
# between compilation units in different components are allowed.
|
||||||
|
#
|
||||||
|
# Parameter description:
|
||||||
|
# - `INTERFACE` should be specified for header-only libraries.
|
||||||
|
# - `<source>...` is a shortcut for `target_sources(PRIVATE)`.
|
||||||
|
# - `DEFINITIONS <definition>...` is a shortcut for `target_compile_definitions(PRIVATE)`.
|
||||||
|
# - `INCLUDE_DIRS <directory>...` is a shortcut for `target_include_directories(PRIVATE)`.
|
||||||
|
# - `LIBRARIES <library>...` is a shortcut for `target_link_libraries(PRIVATE)`.
|
||||||
|
# - `PROVIDES <provided>...` creates aliases to each `<provided>` component name.
|
||||||
|
# - `REQUIRES <required>...` ensures that if this target is linked into the Yosys binary, then every
|
||||||
|
# `<required>` component is also linked in.
|
||||||
|
# - `DATA_DIR <data_dir>` configures a base directory for installing data files; this directory
|
||||||
|
# is (relative to the root build directory or the installation prefix) `share/<data_dir>` if
|
||||||
|
# `DATA_DIR` is provided, and `share` if not.
|
||||||
|
# - `DATA_FILES <data_file>...` installs each of `<data_file>` as `share/<data_dir>/<path>/<name>`,
|
||||||
|
# where `<path>` is the directory name of `<data_file>` and `<name>` is the filename of `<data_file>`.
|
||||||
|
# - `DATA_EXPLICIT [<dest_file> <src_file>]...` installs each `<src_file>` as `share/<data_dir>/<dest_file>`.
|
||||||
|
# Where possible, `DATA_FILES` should be used instead.
|
||||||
|
# - `ESSENTIAL` ensures that this target is always linked into the Yosys binary.
|
||||||
|
# - `ENABLE_IF "<condition>"` marks the component as available only when `if(<condition>)` would run.
|
||||||
|
#
|
||||||
|
# Avoid using this function directly. Instead, use one of the wrappers below as follows:
|
||||||
|
# - to define a normal pass, use `yosys_pass(<name>)` to add a component called `<name>`.
|
||||||
|
# - to define a test pass, use `yosys_test_pass(<name>)` to add a component called `test_<name>`.
|
||||||
|
# - to define a frontend, use `yosys_frontend(<name>)` to add a component called `read_<name>`.
|
||||||
|
# - to define a backend, use `yosys_backend(<name>)` to add a component called `write_<name>`.
|
||||||
|
# - if the component sources define more than one pass, use `PROVIDES` with names of the other passes.
|
||||||
|
# - if the component uses `Pass::call()`, `Frontend::frontend_call()`, `Backend::backend_call()`, or other
|
||||||
|
# similar functions, use `REQUIRES` with names of all possibly needed passes.
|
||||||
|
# - if the component needs an essential pass, add the latter to `REQUIRES` anyway for completeness.
|
||||||
|
# - if the component subclasses a `ScriptPass`, build Yosys, then run `misc/script_pass_depends.py <pass>`
|
||||||
|
# to extract the names of all referenced passes.
|
||||||
|
# - in general, component names should be the same as corresponding pass names (as used in the REPL),
|
||||||
|
# but this is not a hard requirement and any suitable name can be used if desired.
|
||||||
|
#
|
||||||
|
function(yosys_component arg_PREFIX arg_NAME)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 2 arg
|
||||||
|
"INTERFACE;ESSENTIAL;BOOTSTRAP"
|
||||||
|
"DATA_DIR;ENABLE_IF"
|
||||||
|
"DEFINITIONS;INCLUDE_DIRS;LIBRARIES;DATA_FILES;DATA_EXPLICIT;PROVIDES;REQUIRES"
|
||||||
|
)
|
||||||
|
set(arg_SOURCES ${arg_UNPARSED_ARGUMENTS})
|
||||||
|
if ("${arg_ENABLE_IF}" STREQUAL "")
|
||||||
|
set(arg_ENABLE_IF TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (arg_PREFIX STREQUAL "")
|
||||||
|
set(component "${arg_NAME}")
|
||||||
|
else()
|
||||||
|
set(component "${arg_PREFIX}_${arg_NAME}")
|
||||||
|
endif()
|
||||||
|
set(target "${namespace}_${component}")
|
||||||
|
list(TRANSFORM arg_PROVIDES PREPEND ${namespace}_ OUTPUT_VARIABLE provides_targets)
|
||||||
|
|
||||||
|
# An OBJECT library is used to allow for circular symbol dependencies between any source files.
|
||||||
|
# Unfortunately, public dependencies between OBJECT libraries aren't handled correctly, so we have
|
||||||
|
# to do it ourselves.
|
||||||
|
if (arg_SOURCES AND NOT arg_INTERFACE)
|
||||||
|
add_library(${target} EXCLUDE_FROM_ALL OBJECT)
|
||||||
|
target_sources(${target} PRIVATE ${arg_SOURCES})
|
||||||
|
target_include_directories(${target} PRIVATE ${arg_INCLUDE_DIRS})
|
||||||
|
target_compile_definitions(${target} PRIVATE ${arg_DEFINITIONS})
|
||||||
|
target_link_libraries(${target} PUBLIC yosys_common ${arg_LIBRARIES})
|
||||||
|
foreach (alias ${provides_targets})
|
||||||
|
add_library(${alias} ALIAS ${target})
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
add_library(${target} EXCLUDE_FROM_ALL INTERFACE)
|
||||||
|
endif()
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
YOSYS_COMPONENT YES
|
||||||
|
YOSYS_PROVIDES "${arg_PROVIDES}"
|
||||||
|
YOSYS_REQUIRES "${arg_REQUIRES}"
|
||||||
|
YOSYS_DATA_FILES ""
|
||||||
|
YOSYS_ENABLE_IF "${arg_ENABLE_IF}"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(share_file_pairs)
|
||||||
|
foreach (share_file ${arg_DATA_FILES})
|
||||||
|
list(APPEND share_file_pairs ${share_file} ${share_file})
|
||||||
|
endforeach()
|
||||||
|
list(APPEND share_file_pairs ${arg_DATA_EXPLICIT})
|
||||||
|
if (share_file_pairs)
|
||||||
|
set(data_depends)
|
||||||
|
set(share_root ${CMAKE_BINARY_DIR}/share)
|
||||||
|
while (share_file_pairs)
|
||||||
|
list(LENGTH share_file_pairs share_file_unpaired)
|
||||||
|
if (share_file_unpaired EQUAL 1)
|
||||||
|
message(FATAL_ERROR "Unpaired DATA_EXPLICIT argument: ${share_file_pairs}")
|
||||||
|
endif()
|
||||||
|
list(POP_FRONT share_file_pairs dst_file src_file)
|
||||||
|
cmake_path(ABSOLUTE_PATH src_file BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
set(out_dir ${arg_DATA_DIR})
|
||||||
|
cmake_path(GET dst_file PARENT_PATH dst_parent)
|
||||||
|
cmake_path(APPEND out_dir ${dst_parent})
|
||||||
|
cmake_path(GET dst_file FILENAME dst_filename)
|
||||||
|
cmake_path(APPEND out_dir ${dst_filename} OUTPUT_VARIABLE out_file)
|
||||||
|
file(MAKE_DIRECTORY ${share_root}/${out_dir})
|
||||||
|
add_custom_command(
|
||||||
|
DEPENDS ${src_file}
|
||||||
|
OUTPUT ${share_root}/${out_file}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${share_root}/${out_file}
|
||||||
|
VERBATIM
|
||||||
|
COMMENT "Copying share/${out_file}"
|
||||||
|
)
|
||||||
|
set_property(TARGET ${target} APPEND PROPERTY YOSYS_DATA_FILES ${out_file})
|
||||||
|
list(APPEND data_depends ${share_root}/${out_file})
|
||||||
|
endwhile()
|
||||||
|
add_custom_target(${target}-data DEPENDS ${data_depends})
|
||||||
|
add_dependencies(${target} ${target}-data)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT arg_BOOTSTRAP)
|
||||||
|
set_property(TARGET yosys_everything APPEND PROPERTY YOSYS_REQUIRES ${component})
|
||||||
|
if (arg_ESSENTIAL)
|
||||||
|
set_property(TARGET yosys_essentials APPEND PROPERTY YOSYS_REQUIRES ${component})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_core(<name> [<option>...]) →
|
||||||
|
# yosys_component("" <name> [<option>...])
|
||||||
|
#
|
||||||
|
# yosys_pass(<name> [<option>...]) →
|
||||||
|
# yosys_component("" <name> [<option>...])
|
||||||
|
#
|
||||||
|
# yosys_test_pass(<name> [<option>...]) →
|
||||||
|
# yosys_component("test" <name> [<option>...])
|
||||||
|
#
|
||||||
|
# yosys_frontend(<name> [<option>...]) →
|
||||||
|
# yosys_component("frontend" <name> [<option>...])
|
||||||
|
#
|
||||||
|
# yosys_backend(<name> [<option>...]) →
|
||||||
|
# yosys_component("backend" <name> [<option>...])
|
||||||
|
#
|
||||||
|
# See `yosys_component()` for details.
|
||||||
|
#
|
||||||
|
function(yosys_core)
|
||||||
|
yosys_component("" ${ARGV})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yosys_pass)
|
||||||
|
yosys_component("" ${ARGV})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yosys_test_pass)
|
||||||
|
yosys_component(test ${ARGV})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yosys_frontend)
|
||||||
|
yosys_component(read ${ARGV})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(yosys_backend)
|
||||||
|
yosys_component(write ${ARGV})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_expand_components(<variable> <component>...)
|
||||||
|
#
|
||||||
|
# Populates `<variable>` with the list of components required for linking every `<component>`,
|
||||||
|
# sorted by pre-order traversal.
|
||||||
|
#
|
||||||
|
function(yosys_expand_components arg_OUTPUT)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1 arg "QUIET" "" "")
|
||||||
|
set(arg_COMPONENTS ${arg_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
|
function(check_components context components)
|
||||||
|
set(error 0)
|
||||||
|
foreach (component ${components})
|
||||||
|
set(target "${namespace}_${component}")
|
||||||
|
if (NOT TARGET ${target})
|
||||||
|
message(SEND_ERROR "${context}Target ${target} does not exist")
|
||||||
|
set(error 1)
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
get_target_property(target_is_component ${target} YOSYS_COMPONENT)
|
||||||
|
if (NOT target_is_component)
|
||||||
|
message(SEND_ERROR "${context}Target ${target} is not a Yosys component")
|
||||||
|
set(error 1)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
return (PROPAGATE error)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(depth_first_search component visited_components required_components)
|
||||||
|
list(APPEND visited_components ${component})
|
||||||
|
get_target_property(component_requires "${namespace}_${component}" YOSYS_REQUIRES)
|
||||||
|
check_components("In REQUIRES of ${component}: " "${component_requires}")
|
||||||
|
foreach (requirement ${component_requires})
|
||||||
|
if (NOT requirement IN_LIST visited_components)
|
||||||
|
depth_first_search(${requirement} "${visited_components}" "${required_components}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
list(APPEND required_components ${component})
|
||||||
|
return (PROPAGATE visited_components required_components)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(visited_components)
|
||||||
|
set(required_components)
|
||||||
|
check_components("" "${arg_COMPONENTS}")
|
||||||
|
foreach (component ${arg_COMPONENTS})
|
||||||
|
if (NOT component IN_LIST visited_components)
|
||||||
|
depth_first_search(${component} "${visited_components}" "${required_components}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# If `everything` is in the component list, ignore disabled dependencies, else fail the build.
|
||||||
|
set(fail_if_disabled TRUE)
|
||||||
|
if (everything IN_LIST arg_COMPONENTS)
|
||||||
|
set(fail_if_disabled FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ${required_components} are now sorted in pre-order (every component is visited before
|
||||||
|
# all of its dependents). Figure out which components are enabled and which components
|
||||||
|
# have disabled dependencies.
|
||||||
|
set(enabled_components)
|
||||||
|
if (NOT arg_QUIET)
|
||||||
|
message(TRACE "Resolving component dependencies:")
|
||||||
|
endif()
|
||||||
|
foreach (component ${required_components})
|
||||||
|
set(why_disabled "")
|
||||||
|
get_target_property(component_enable_if "${namespace}_${component}" YOSYS_ENABLE_IF)
|
||||||
|
if (${component_enable_if})
|
||||||
|
get_target_property(component_requires "${namespace}_${component}" YOSYS_REQUIRES)
|
||||||
|
foreach (requirement ${component_requires})
|
||||||
|
if (NOT requirement IN_LIST enabled_components)
|
||||||
|
set(why_disabled "dependency ${requirement}")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
set(why_disabled "condition")
|
||||||
|
endif()
|
||||||
|
if ("${why_disabled}" STREQUAL "")
|
||||||
|
list(APPEND enabled_components ${component})
|
||||||
|
if (NOT arg_QUIET)
|
||||||
|
message(TRACE " Component ${component} enabled")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if (NOT arg_QUIET)
|
||||||
|
message(TRACE " Component ${component} disabled (cause: ${why_disabled})")
|
||||||
|
endif()
|
||||||
|
if (fail_if_disabled)
|
||||||
|
message(FATAL_ERROR "Required component ${component} is disabled (cause: ${why_disabled})")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(${arg_OUTPUT} ${enabled_components})
|
||||||
|
return(PROPAGATE ${arg_OUTPUT})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_link_components(<target> {INTERFACE|PUBLIC|PRIVATE} <component>...)
|
||||||
|
#
|
||||||
|
# Link every `<component>` into `<target>`.
|
||||||
|
#
|
||||||
|
function(yosys_link_components arg_TARGET arg_SCOPE)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 2 arg "" "" "")
|
||||||
|
set(arg_COMPONENTS ${arg_UNPARSED_ARGUMENTS})
|
||||||
|
|
||||||
|
message(VERBOSE "Components for ${arg_TARGET}: ${arg_COMPONENTS}")
|
||||||
|
list(TRANSFORM arg_COMPONENTS PREPEND ${namespace}_ OUTPUT_VARIABLE linked_targets)
|
||||||
|
target_link_libraries(${arg_TARGET} ${arg_SCOPE} ${linked_targets})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_install_component_data(<component>... DESTINATION <directory>)
|
||||||
|
#
|
||||||
|
# Install data files for every `<component>` into `<directory>`.
|
||||||
|
# Equivalent to copying `${CMAKE_BINARY_DIR}/share/.` to `<directory>/.` after a clean rebuild.
|
||||||
|
#
|
||||||
|
function(yosys_install_component_data)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "DESTINATION" "")
|
||||||
|
set(arg_COMPONENTS ${arg_UNPARSED_ARGUMENTS})
|
||||||
|
if (NOT arg_DESTINATION)
|
||||||
|
message(FATAL_ERROR "Missing DESTINATION argument")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach (component ${arg_COMPONENTS})
|
||||||
|
get_target_property(data_files ${namespace}_${component} YOSYS_DATA_FILES)
|
||||||
|
foreach (data_file ${data_files})
|
||||||
|
cmake_path(GET data_file PARENT_PATH data_dir)
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/share/${data_file} DESTINATION ${arg_DESTINATION}/${data_dir})
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
60
cmake/YosysConfigScript.cmake
Normal file
60
cmake/YosysConfigScript.cmake
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_config_script({BUILD|INSTALL})
|
||||||
|
#
|
||||||
|
# Generates a `yosys-config` executable with embedded paths for in-tree builds or after installation.
|
||||||
|
#
|
||||||
|
function(yosys_config_script scope)
|
||||||
|
if (scope STREQUAL BUILD)
|
||||||
|
set(BINDIR ${CMAKE_BINARY_DIR})
|
||||||
|
set(LIBDIR ${CMAKE_BINARY_DIR})
|
||||||
|
set(DATDIR ${CMAKE_BINARY_DIR}/share)
|
||||||
|
set(suffix "")
|
||||||
|
elseif (scope STREQUAL INSTALL)
|
||||||
|
set(BINDIR ${YOSYS_INSTALL_FULL_BINDIR})
|
||||||
|
set(LIBDIR ${YOSYS_INSTALL_FULL_LIBDIR})
|
||||||
|
set(DATDIR ${YOSYS_INSTALL_FULL_DATADIR})
|
||||||
|
set(suffix ".install")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Invalid scope ${scope}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(platform_link_flags)
|
||||||
|
set(platform_libs)
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
|
set(platform_link_flags -undefined dynamic_lookup)
|
||||||
|
endif()
|
||||||
|
if (MINGW)
|
||||||
|
set(platform_libs -l:yosys.exe.a)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CXX ${CMAKE_CXX_COMPILER})
|
||||||
|
string(JOIN " " CXXFLAGS
|
||||||
|
-std=c++${CMAKE_CXX_STANDARD}
|
||||||
|
${CMAKE_CXX_FLAGS}
|
||||||
|
${CMAKE_CXX_COMPILE_OPTIONS_PIC}
|
||||||
|
-D_YOSYS_
|
||||||
|
"-DYOSYS_VER=\"${YOSYS_VERSION}\""
|
||||||
|
"-DYOSYS_MAJOR=${YOSYS_VERSION_MAJOR}"
|
||||||
|
"-DYOSYS_MINOR=${YOSYS_VERSION_MINOR}"
|
||||||
|
"-DYOSYS_COMMIT=${YOSYS_VERSION_COMMIT}"
|
||||||
|
-I${DATDIR}/include
|
||||||
|
)
|
||||||
|
string(JOIN " " LINKFLAGS
|
||||||
|
${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
|
||||||
|
-L${LIBDIR}
|
||||||
|
${platform_link_flags}
|
||||||
|
)
|
||||||
|
string(JOIN " " LIBS
|
||||||
|
${platform_libs}
|
||||||
|
)
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/misc/yosys-config.in
|
||||||
|
${YOSYS_PROGRAM_PREFIX}yosys-config${suffix}
|
||||||
|
USE_SOURCE_PERMISSIONS
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
if (scope STREQUAL INSTALL)
|
||||||
|
install(PROGRAMS ${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}yosys-config
|
||||||
|
DESTINATION ${YOSYS_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
9
cmake/YosysInstallDirs.cmake
Normal file
9
cmake/YosysInstallDirs.cmake
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
# Nothing should be installed outside of the following locations.
|
||||||
|
set(YOSYS_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
|
||||||
|
set(YOSYS_INSTALL_FULL_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
|
||||||
|
set(YOSYS_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/${YOSYS_PROGRAM_PREFIX}yosys)
|
||||||
|
set(YOSYS_INSTALL_FULL_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}/${YOSYS_PROGRAM_PREFIX}yosys)
|
||||||
|
set(YOSYS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/${YOSYS_PROGRAM_PREFIX}yosys)
|
||||||
|
set(YOSYS_INSTALL_FULL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/${YOSYS_PROGRAM_PREFIX}yosys)
|
||||||
104
cmake/YosysLinkTarget.cmake
Normal file
104
cmake/YosysLinkTarget.cmake
Normal file
|
|
@ -0,0 +1,104 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_cxx_library(<target> {SHARED|STATIC}
|
||||||
|
# OUTPUT_NAME <name>
|
||||||
|
# [INCLUDE_IN_ALL | INCLUDE_IN_ALL_IF <condition>]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Creates a libary target `<target>` with `SHARED` or `STATIC` scope called `<name>` (or `<target>` if
|
||||||
|
# not specified), placed in the root of the build directory and prefixed with `${YOSYS_PROGRAM_PREFIX}`.
|
||||||
|
# Target is built by default and installed only if `<condition>` (an `if()` expression) is true.
|
||||||
|
#
|
||||||
|
function(yosys_cxx_library arg_TARGET arg_SCOPE)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 2 arg "INCLUDE_IN_ALL" "OUTPUT_NAME;INCLUDE_IN_ALL_IF" "")
|
||||||
|
if (NOT arg_OUTPUT_NAME)
|
||||||
|
message(FATAL_ERROR "OUTPUT_NAME argument is mandatory")
|
||||||
|
endif()
|
||||||
|
set(include_in_all FALSE)
|
||||||
|
if (arg_INCLUDE_IN_ALL)
|
||||||
|
set(include_in_all TRUE)
|
||||||
|
elseif (${arg_INCLUDE_IN_ALL_IF})
|
||||||
|
set(include_in_all TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(${arg_TARGET} ${arg_SCOPE})
|
||||||
|
set_target_properties(${arg_TARGET} PROPERTIES
|
||||||
|
PREFIX "${YOSYS_PROGRAM_PREFIX}"
|
||||||
|
OUTPUT_NAME "${arg_OUTPUT_NAME}"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
if (include_in_all)
|
||||||
|
install(TARGETS ${arg_TARGET} DESTINATION ${YOSYS_INSTALL_LIBDIR})
|
||||||
|
else()
|
||||||
|
set_target_properties(${arg_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_cxx_executable(<target>
|
||||||
|
# [OUTPUT_NAME <name>]
|
||||||
|
# [INCLUDE_IN_ALL | INCLUDE_IN_ALL_IF <condition>]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# Creates an executable target `<target>` scope called `<name>` (or `<target>` if not specified), placed
|
||||||
|
# in the root of the build directory and prefixed with `${YOSYS_PROGRAM_PREFIX}`. Target is built by
|
||||||
|
# default and installed only if `INCLUDE_IN_ALL` is provided or `<condition>` (an `if()` expression) is true.
|
||||||
|
#
|
||||||
|
function(yosys_cxx_executable arg_TARGET)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1 arg "INCLUDE_IN_ALL" "OUTPUT_NAME;INCLUDE_IN_ALL_IF" "")
|
||||||
|
if (NOT arg_OUTPUT_NAME)
|
||||||
|
message(FATAL_ERROR "OUTPUT_NAME argument is mandatory")
|
||||||
|
endif()
|
||||||
|
set(include_in_all FALSE)
|
||||||
|
if (arg_INCLUDE_IN_ALL)
|
||||||
|
set(include_in_all TRUE)
|
||||||
|
elseif (${arg_INCLUDE_IN_ALL_IF})
|
||||||
|
set(include_in_all TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(${arg_TARGET})
|
||||||
|
set_target_properties(${arg_TARGET} PROPERTIES
|
||||||
|
PREFIX "${YOSYS_PROGRAM_PREFIX}"
|
||||||
|
OUTPUT_NAME "${arg_OUTPUT_NAME}"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
)
|
||||||
|
if (include_in_all)
|
||||||
|
install(TARGETS ${arg_TARGET} DESTINATION ${YOSYS_INSTALL_BINDIR})
|
||||||
|
else()
|
||||||
|
set_target_properties(${arg_TARGET} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_python_executable(<target> <source>)
|
||||||
|
#
|
||||||
|
# Installs Python script `<source>` as an executable in the standard binary directory, adding a launcher wrapper
|
||||||
|
# if the platform requires it. Inside `<source>`, several substitutions are available:
|
||||||
|
# - `@PYTHON_SHEBANG@` will be replaced with an appropriate shebang line (without the initial `#!`)
|
||||||
|
# - `@YOSYS_PROGRAM_PREFIX@` will be replaced with the program prefix
|
||||||
|
# - any other `@\w+@` tokens have unspecified behavior and must not be used
|
||||||
|
#
|
||||||
|
function(yosys_python_executable basename source)
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL MSYS)
|
||||||
|
execute_process(
|
||||||
|
COMMAND cygpath -w -m ${CMAKE_INSTALL_BINDIR}/python3
|
||||||
|
OUTPUT_VARIABLE PYTHON_SHEBANG
|
||||||
|
COMMAND_ERROR_IS_FATAL ANY
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(${basename} ${CMAKE_SOURCE_DIR}/misc/launcher.c)
|
||||||
|
target_compile_definitions(${basename} GUI=0)
|
||||||
|
install(TARGETS ${basename} DESTINATION ${YOSYS_INSTALL_BINDIR})
|
||||||
|
|
||||||
|
set(scriptname ${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}${basename}-script.py)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${source} ${scriptname} @ONLY)
|
||||||
|
install(FILES ${scriptname} DESTINATION ${YOSYS_INSTALL_BINDIR})
|
||||||
|
else()
|
||||||
|
set(PYTHON_SHEBANG "/usr/bin/env python3")
|
||||||
|
set(scriptname ${CMAKE_BINARY_DIR}/${YOSYS_PROGRAM_PREFIX}${basename}${CMAKE_EXECUTABLE_SUFFIX})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${source} ${scriptname} USE_SOURCE_PERMISSIONS @ONLY)
|
||||||
|
install(PROGRAMS ${scriptname} DESTINATION ${YOSYS_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
48
cmake/YosysVerific.cmake
Normal file
48
cmake/YosysVerific.cmake
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
if (APPLE)
|
||||||
|
set(VERIFIC_LIB_SUFFIX -mac.a)
|
||||||
|
elseif (LINUX)
|
||||||
|
set(VERIFIC_LIB_SUFFIX -linux.a)
|
||||||
|
elseif (WIN32)
|
||||||
|
set(VERIFIC_LIB_SUFFIX -windows.a)
|
||||||
|
else()
|
||||||
|
set(VERIFIC_LIB_SUFFIX -NOTFOUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# get_verific_components(<result>)
|
||||||
|
#
|
||||||
|
# Assigns variable `<result>` to a list of Verific components detected in `${YOSYS_VERIFIC_DIR}`.
|
||||||
|
#
|
||||||
|
function(get_verific_components result)
|
||||||
|
file(GLOB libraries
|
||||||
|
RELATIVE ${YOSYS_VERIFIC_DIR}
|
||||||
|
${YOSYS_VERIFIC_DIR}/*/*${VERIFIC_LIB_SUFFIX}
|
||||||
|
)
|
||||||
|
set(components)
|
||||||
|
foreach (library ${libraries})
|
||||||
|
cmake_path(GET library PARENT_PATH component)
|
||||||
|
list(APPEND components ${component})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(${result} ${components})
|
||||||
|
return(PROPAGATE ${result})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# get_verific_options(<include_dirs> <libraries> <components>...)
|
||||||
|
#
|
||||||
|
# Assigns variables `<include_dirs>` and `<libraries>` to lists required to use Verific
|
||||||
|
# `<components>`.
|
||||||
|
#
|
||||||
|
function(get_verific_options include_dirs libraries)
|
||||||
|
set(${include_dirs})
|
||||||
|
set(${libraries})
|
||||||
|
foreach (component ${ARGN})
|
||||||
|
list(APPEND ${include_dirs} ${YOSYS_VERIFIC_DIR}/${component})
|
||||||
|
list(APPEND ${libraries} ${YOSYS_VERIFIC_DIR}/${component}/${component}${VERIFIC_LIB_SUFFIX})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
return(PROPAGATE ${include_dirs} ${libraries})
|
||||||
|
endfunction()
|
||||||
162
cmake/YosysVersion.cmake
Normal file
162
cmake/YosysVersion.cmake
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_call_git(<args>...)
|
||||||
|
#
|
||||||
|
# Calls `git <args>...` in the project source directory. Never causes errors.
|
||||||
|
#
|
||||||
|
# Defines the following variables:
|
||||||
|
# - `git_result`: exit code
|
||||||
|
# - `git_output`: standard output (standard error is discarded)
|
||||||
|
#
|
||||||
|
function(yosys_call_git)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} ${ARGV}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_output
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
return(PROPAGATE git_result git_output)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_extract_version()
|
||||||
|
#
|
||||||
|
# Defines the following variables:
|
||||||
|
# - `YOSYS_VERSION_MAJOR`: major version number
|
||||||
|
# - `YOSYS_VERSION_MINOR`: minor version number
|
||||||
|
# - `YOSYS_VERSION_COMMIT`: distance since release
|
||||||
|
# - `YOSYS_VERSION`: either `<major>.<minor>+<distance>` or `<major>.<minor>+post`
|
||||||
|
# - `YOSYS_CHECKOUT_INFO`: either `<abbrev>`, `<abbrev>-dirty`, or `UNKNOWN`
|
||||||
|
# - `YOSYS_ORIGIN_INFO`: either `forge.tld/repo/user at branch` or ``
|
||||||
|
#
|
||||||
|
# For builds without git, it is possible to define `-DYOSYS_CHECKOUT_INFO=` and
|
||||||
|
# `-DYOSYS_ORIGIN_INFO=` explicitly when configuring, which will be included in log output.
|
||||||
|
#
|
||||||
|
function(yosys_extract_version)
|
||||||
|
# Version numbers are placed in an external file that can be easily rewritten.
|
||||||
|
include(YosysVersionData)
|
||||||
|
|
||||||
|
# Extract git metadata if possible.
|
||||||
|
set(git_distance "")
|
||||||
|
set(git_abbrev "")
|
||||||
|
set(git_dirty NO)
|
||||||
|
set(git_origin "")
|
||||||
|
set(git_branch "")
|
||||||
|
find_package(Git QUIET)
|
||||||
|
if (Git_FOUND)
|
||||||
|
yosys_call_git(rev-parse --git-dir)
|
||||||
|
if (git_result EQUAL 0)
|
||||||
|
set(git_dir ${git_output})
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${git_dir}/HEAD)
|
||||||
|
file(READ ${git_dir}/HEAD git_head)
|
||||||
|
if (git_head MATCHES "^ref: (.+)\n$")
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${git_dir}/${CMAKE_MATCH_1})
|
||||||
|
endif()
|
||||||
|
yosys_call_git(rev-list --count v${YOSYS_VERSION_MAJOR}.${YOSYS_VERSION_MINOR}..HEAD)
|
||||||
|
set(git_distance ${git_output})
|
||||||
|
yosys_call_git(rev-parse --short=9 HEAD)
|
||||||
|
set(git_abbrev ${git_output})
|
||||||
|
yosys_call_git(diff --exit-code --quiet)
|
||||||
|
set(git_dirty ${git_result})
|
||||||
|
yosys_call_git(config --get remote.origin.url)
|
||||||
|
set(git_origin ${git_output})
|
||||||
|
yosys_call_git(rev-parse --abbrev-ref HEAD)
|
||||||
|
set(git_branch ${git_output})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Build YOSYS_VERSION (just the version info).
|
||||||
|
set(YOSYS_VERSION "${YOSYS_VERSION_MAJOR}.${YOSYS_VERSION_MINOR}")
|
||||||
|
if (git_distance STREQUAL "")
|
||||||
|
string(APPEND YOSYS_VERSION "+post")
|
||||||
|
else()
|
||||||
|
set(YOSYS_VERSION_COMMIT ${git_distance})
|
||||||
|
if (NOT git_distance EQUAL 0)
|
||||||
|
string(APPEND YOSYS_VERSION "+${git_distance}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(STATUS "Configuring Yosys ${YOSYS_VERSION}")
|
||||||
|
|
||||||
|
if (NOT YOSYS_CHECKOUT_INFO)
|
||||||
|
# Build YOSYS_CHECKOUT_INFO (git sha1 and dirty status).
|
||||||
|
if (git_abbrev STREQUAL "")
|
||||||
|
# No git checkout, see if the tarball was created with `git archive`.
|
||||||
|
file(READ ${CMAKE_SOURCE_DIR}/.gitcommit git_abbrev)
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/.gitcommit)
|
||||||
|
string(STRIP "${git_abbrev}" git_abbrev)
|
||||||
|
if (git_abbrev MATCHES "Format:")
|
||||||
|
# No substitutions, we're out of options.
|
||||||
|
set(YOSYS_CHECKOUT_INFO UNKNOWN)
|
||||||
|
else()
|
||||||
|
# Substitutions were made, good.
|
||||||
|
set(YOSYS_CHECKOUT_INFO ${git_abbrev})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Valid git checkout, use accurate information.
|
||||||
|
set(YOSYS_CHECKOUT_INFO ${git_abbrev})
|
||||||
|
if (git_dirty)
|
||||||
|
string(APPEND YOSYS_CHECKOUT_INFO "-dirty")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT YOSYS_ORIGIN_INFO)
|
||||||
|
# Build YOSYS_ORIGIN_INFO (git repository origin and branch)
|
||||||
|
if (git_origin AND git_branch)
|
||||||
|
string(REGEX REPLACE "^https://|.git$" "" git_origin ${git_origin})
|
||||||
|
if (git_origin STREQUAL "github.com/YosysHQ/yosys" AND git_branch MATCHES "^HEAD|main|release/v.+$")
|
||||||
|
# Nothing to highlight.
|
||||||
|
set(YOSYS_ORIGIN_INFO "")
|
||||||
|
else()
|
||||||
|
# Highlight clone URL and branch.
|
||||||
|
set(YOSYS_ORIGIN_INFO "${git_origin} at ${git_branch}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (YOSYS_ORIGIN_INFO)
|
||||||
|
message(STATUS "Git commit ${YOSYS_CHECKOUT_INFO} from ${YOSYS_ORIGIN_INFO}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Git commit ${YOSYS_CHECKOUT_INFO}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
return(PROPAGATE
|
||||||
|
YOSYS_VERSION_MAJOR
|
||||||
|
YOSYS_VERSION_MINOR
|
||||||
|
YOSYS_VERSION_COMMIT
|
||||||
|
YOSYS_VERSION
|
||||||
|
YOSYS_CHECKOUT_INFO
|
||||||
|
YOSYS_ORIGIN_INFO
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Syntax:
|
||||||
|
#
|
||||||
|
# yosys_version_file(<input> <output>)
|
||||||
|
#
|
||||||
|
# Templates `<output>` file based on `<input>` with the following substitutions:
|
||||||
|
# - `@YOSYS_VERSION@`: version in `<major>.<minor>+<post>` format
|
||||||
|
# - `@YOSYS_BUILD_INFO@`: free-form build information
|
||||||
|
# (not actually entirely free-form as external software tries to parse it sometimes)
|
||||||
|
#
|
||||||
|
# Must have executed `yosys_extract_version()` first.
|
||||||
|
#
|
||||||
|
function(yosys_version_file arg_INPUT arg_OUTPUT)
|
||||||
|
set(YOSYS_BUILD_INFO "Yosys")
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " ${YOSYS_VERSION}")
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " (git sha1 ${YOSYS_CHECKOUT_INFO},")
|
||||||
|
if (CMAKE_BUILD_TYPE)
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " ${CMAKE_BUILD_TYPE},")
|
||||||
|
endif()
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " ${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " ${CMAKE_CXX_COMPILER}")
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " ${CMAKE_CXX_COMPILER_VERSION})")
|
||||||
|
if (YOSYS_ORIGIN_INFO)
|
||||||
|
string(APPEND YOSYS_BUILD_INFO " [${YOSYS_ORIGIN_INFO}]")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
configure_file(${arg_INPUT} ${arg_OUTPUT} @ONLY)
|
||||||
|
endfunction()
|
||||||
2
cmake/YosysVersionData.cmake
Normal file
2
cmake/YosysVersionData.cmake
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(YOSYS_VERSION_MAJOR 0)
|
||||||
|
set(YOSYS_VERSION_MINOR 64)
|
||||||
8
cmake/toolchain/toolchain-mingw-i686.cmake
Normal file
8
cmake/toolchain/toolchain-mingw-i686.cmake
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
8
cmake/toolchain/toolchain-mingw-x86_64.cmake
Normal file
8
cmake/toolchain/toolchain-mingw-x86_64.cmake
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
set(CMAKE_SYSTEM_NAME Windows)
|
||||||
|
|
||||||
|
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||||
|
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||||
|
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
48
cmake_Makefile_left
Normal file
48
cmake_Makefile_left
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
ifneq ($(SEED),)
|
||||||
|
SEEDOPT="-S $(SEED)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ABCEXTERNAL),)
|
||||||
|
ABCOPT="-A $(ABCEXTERNAL)"
|
||||||
|
endif
|
||||||
|
|
||||||
|
test: vanilla-test unit-test
|
||||||
|
|
||||||
|
vanilla-test: $(TARGETS) $(EXTRA_TARGETS)
|
||||||
|
@$(MAKE) -C tests vanilla-test \
|
||||||
|
$(if $(ENABLE_VERIFIC),ENABLE_VERIFIC=$(ENABLE_VERIFIC)) \
|
||||||
|
$(if $(YOSYS_NOVERIFIC),YOSYS_NOVERIFIC=$(YOSYS_NOVERIFIC)) \
|
||||||
|
SEEDOPT=$(SEEDOPT) ABCOPT=$(ABCOPT)
|
||||||
|
|
||||||
|
unit-test: libyosys.so
|
||||||
|
@$(MAKE) -f $(UNITESTPATH)/Makefile CXX="$(CXX)" CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" \
|
||||||
|
CXXFLAGS="$(CXXFLAGS)" LINKFLAGS="$(LINKFLAGS)" LIBS="$(LIBS)" ROOTPATH="$(CURDIR)"
|
||||||
|
|
||||||
|
VALGRIND ?= valgrind --error-exitcode=1 --leak-check=full --show-reachable=yes --errors-for-leak-kinds=all
|
||||||
|
|
||||||
|
vgtest: $(TARGETS) $(EXTRA_TARGETS)
|
||||||
|
$(VALGRIND) ./yosys -p 'setattr -mod -unset top; synth' $$( ls tests/simple/*.v | grep -v repwhile.v )
|
||||||
|
@echo ""
|
||||||
|
@echo " Passed \"make vgtest\"."
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
vloghtb: $(TARGETS) $(EXTRA_TARGETS)
|
||||||
|
+cd tests/vloghtb && bash run-test.sh
|
||||||
|
@echo ""
|
||||||
|
@echo " Passed \"make vloghtb\"."
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
ystests: $(TARGETS) $(EXTRA_TARGETS)
|
||||||
|
rm -rf tests/ystests
|
||||||
|
git clone https://github.com/YosysHQ/yosys-tests.git tests/ystests
|
||||||
|
+$(MAKE) PATH="$$PWD:$$PATH" -C tests/ystests
|
||||||
|
@echo ""
|
||||||
|
@echo " Finished \"make ystests\"."
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
FUNC_KERNEL := functional.cc functional.h sexpr.cc sexpr.h compute_graph.h
|
||||||
|
FUNC_INCLUDES := $(addprefix --include *,functional/* $(FUNC_KERNEL))
|
||||||
|
coverage_functional:
|
||||||
|
rm -rf coverage.info coverage_html
|
||||||
|
lcov --capture -d backends/functional -d kernel $(FUNC_INCLUDES) --no-external -o coverage.info
|
||||||
|
genhtml coverage.info --output-directory coverage_html
|
||||||
|
|
@ -252,10 +252,37 @@ images:
|
||||||
$(MAKE) -C source/_images
|
$(MAKE) -C source/_images
|
||||||
$(MAKE) -C source/_images convert
|
$(MAKE) -C source/_images convert
|
||||||
|
|
||||||
|
BUILD_DIR ?= ..
|
||||||
|
BUILD_CMD := $(BUILD_DIR)/$(PROGRAM_PREFIX)
|
||||||
|
|
||||||
|
.PHONY: extract
|
||||||
|
extract:
|
||||||
|
mkdir -p source/generated
|
||||||
|
$(BUILD_CMD)yosys -q -p 'help -dump-cmds-json source/generated/cmds.json'
|
||||||
|
$(BUILD_CMD)yosys -q -p 'help -dump-cells-json source/generated/cells.json'
|
||||||
|
|
||||||
|
cp ../passes/cmds/chformal.cc source/generated/
|
||||||
|
$(BUILD_CMD)yosys -qQT -h 'chformal' -l source/generated/chformal.log
|
||||||
|
|
||||||
|
mkdir -p source/generated/functional
|
||||||
|
cp ../backends/functional/smtlib.cc source/generated/functional/
|
||||||
|
-cd .. && diff -U 20 backends/functional/smtlib.cc backends/functional/smtlib_rosette.cc \
|
||||||
|
> docs/source/generated/functional/rosette.diff
|
||||||
|
|
||||||
|
$(BUILD_CMD)yosys --help >source/generated/yosys
|
||||||
|
$(BUILD_CMD)yosys-smtbmc --help >source/generated/yosys-smtbmc
|
||||||
|
$(BUILD_CMD)yosys-witness --help >source/generated/yosys-witness
|
||||||
|
$(BUILD_CMD)yosys-config --help >source/generated/yosys-config
|
||||||
|
-$(BUILD_CMD)yosys-filterlib --help 2>source/generated/yosys-filterlib
|
||||||
|
ifeq ($(ABCEXTERNAL),)
|
||||||
|
-$(BUILD_CMD)yosys-abc --help 2>source/generated/yosys-abc
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: gen
|
.PHONY: gen
|
||||||
gen:
|
gen:
|
||||||
$(MAKE) examples
|
$(MAKE) examples
|
||||||
$(MAKE) images
|
$(MAKE) images
|
||||||
|
$(MAKE) extract
|
||||||
|
|
||||||
.PHONY: reqs
|
.PHONY: reqs
|
||||||
reqs:
|
reqs:
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,8 @@ all: dots examples
|
||||||
dots: test1.dot my_cmd.so
|
dots: test1.dot my_cmd.so
|
||||||
examples: test0.log test1.log test2.log my_cmd.so
|
examples: test0.log test1.log test2.log my_cmd.so
|
||||||
|
|
||||||
CXXFLAGS=$(shell $(YOSYS)-config --cxxflags)
|
|
||||||
DATDIR=$(shell $(YOSYS)-config --datdir)
|
|
||||||
|
|
||||||
my_cmd.so: my_cmd.cc
|
my_cmd.so: my_cmd.cc
|
||||||
$(YOSYS)-config --exec --cxx $(subst $(DATDIR),../../../../share,$(CXXFLAGS)) --ldflags -o my_cmd.so -shared my_cmd.cc --ldlibs
|
$(YOSYS)-config --exec --cxx --cxxflags --ldflags -o my_cmd.so -shared my_cmd.cc --ldlibs
|
||||||
|
|
||||||
test0.log: my_cmd.so
|
test0.log: my_cmd.so
|
||||||
$(YOSYS) -QTl test0.log_new -m ./my_cmd.so -p 'my_cmd foo bar' -f verilog absval_ref.v
|
$(YOSYS) -QTl test0.log_new -m ./my_cmd.so -p 'my_cmd foo bar' -f verilog absval_ref.v
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
PROGRAM_PREFIX :=
|
||||||
|
|
||||||
|
YOSYS ?= ../../../../$(PROGRAM_PREFIX)yosys
|
||||||
|
|
||||||
.PHONY: all dots examples
|
.PHONY: all dots examples
|
||||||
all: dots examples
|
all: dots examples
|
||||||
dots:
|
dots:
|
||||||
|
|
@ -5,13 +9,13 @@ examples:
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: stubnets.so
|
test: stubnets.so
|
||||||
yosys -ql test1.log -m ./stubnets.so test.v -p "stubnets"
|
$(YOSYS) -ql test1.log -m ./stubnets.so test.v -p "stubnets"
|
||||||
yosys -ql test2.log -m ./stubnets.so test.v -p "opt; stubnets"
|
$(YOSYS) -ql test2.log -m ./stubnets.so test.v -p "opt; stubnets"
|
||||||
yosys -ql test3.log -m ./stubnets.so test.v -p "techmap; opt; stubnets -report_bits"
|
$(YOSYS) -ql test3.log -m ./stubnets.so test.v -p "techmap; opt; stubnets -report_bits"
|
||||||
tail test1.log test2.log test3.log
|
tail test1.log test2.log test3.log
|
||||||
|
|
||||||
stubnets.so: stubnets.cc
|
stubnets.so: stubnets.cc
|
||||||
yosys-config --exec --cxx --cxxflags --ldflags -o $@ -shared $^ --ldlibs
|
$(YOSYS)-config --exec --cxx --cxxflags --ldflags -o $@ -shared $^ --ldlibs
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Note: Set ENABLE_LIBYOSYS=1 in Makefile or Makefile.conf to build libyosys.so
|
// Note: Use `cmake -DYOSYS_INSTALL_LIBRARY=1` or build the `libyosys` target first
|
||||||
// yosys-config --exec --cxx -o demomain --cxxflags --ldflags demomain.cc -lyosys -lstdc++
|
// yosys-config --exec --cxx -o demomain --cxxflags --ldflags demomain.cc -lyosys
|
||||||
|
|
||||||
#include <kernel/yosys.h>
|
#include <kernel/yosys.h>
|
||||||
|
|
||||||
|
|
|
||||||
14
flake.lock
generated
14
flake.lock
generated
|
|
@ -5,11 +5,11 @@
|
||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1705309234,
|
"lastModified": 1731533236,
|
||||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -20,16 +20,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1708807242,
|
"lastModified": 1778869304,
|
||||||
"narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=",
|
"narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a",
|
"rev": "d233902339c02a9c334e7e593de68855ad26c4cb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
94
flake.nix
94
flake.nix
|
|
@ -1,47 +1,77 @@
|
||||||
{
|
{
|
||||||
description = "A nix flake for the Yosys synthesis suite";
|
description = "A Nix flake for the Yosys synthesis suite.";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
# This requires Nix >= 2.27.0.
|
||||||
|
self.submodules = true;
|
||||||
|
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs =
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
||||||
|
overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
yosys = final.callPackage ./nix/pkgs/yosys.nix {
|
||||||
|
src = self;
|
||||||
|
rev = (self.shortRev or self.dirtyShortRev or "unknown");
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
# TODO: don't override src when ./abc is empty
|
|
||||||
# which happens when the command used is `nix build` and not `nix build ?submodules=1`
|
yosys-clang = pkgs.yosys.override { stdenv = pkgs.clangStdenv; };
|
||||||
abc-verifier = pkgs.abc-verifier;
|
|
||||||
yosys = pkgs.clangStdenv.mkDerivation {
|
win32Pkgs = pkgs.callPackage ./nix/cross/win32.nix { };
|
||||||
name = "yosys";
|
win64Pkgs = pkgs.callPackage ./nix/cross/win64.nix { };
|
||||||
src = ./. ;
|
|
||||||
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 zlib git pkg-configUpstream llvmPackages.bintools ];
|
mkShell =
|
||||||
checkInputs = with pkgs; [ gtest ];
|
t:
|
||||||
propagatedBuildInputs = [ abc-verifier ];
|
pkgs.mkShell.override { stdenv = t.stdenv; } {
|
||||||
preConfigure = "make config-clang";
|
inputsFrom = [
|
||||||
checkTarget = "unit-test";
|
t
|
||||||
installPhase = ''
|
];
|
||||||
make install PREFIX=$out ABCEXTERNAL=yosys-abc
|
|
||||||
ln -s ${abc-verifier}/bin/abc $out/bin/yosys-abc
|
packages = with pkgs; [
|
||||||
'';
|
llvmPackages.clang-tools
|
||||||
buildPhase = ''
|
];
|
||||||
make -j$(nproc) ABCEXTERNAL=yosys-abc
|
|
||||||
'';
|
shellHook = ''
|
||||||
meta = with pkgs.lib; {
|
DRIVER_ROOT="${t.stdenv.cc}/bin"
|
||||||
description = "Yosys Open SYnthesis Suite";
|
export CLANGD_FLAGS="--query-driver $DRIVER_ROOT/$CC,$DRIVER_ROOT/$CXX"
|
||||||
homepage = "https://yosyshq.net/yosys/";
|
'';
|
||||||
license = licenses.isc;
|
|
||||||
maintainers = with maintainers; [ ];
|
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
formatter = pkgs.nixfmt-tree;
|
||||||
|
|
||||||
|
devShells = rec {
|
||||||
|
shell = mkShell yosys-clang;
|
||||||
|
shell-gcc = mkShell pkgs.yosys;
|
||||||
|
shell-win32 = mkShell win32Pkgs.yosys;
|
||||||
|
shell-win64 = mkShell win64Pkgs.yosys;
|
||||||
|
|
||||||
|
default = shell;
|
||||||
};
|
};
|
||||||
in {
|
|
||||||
packages.default = yosys;
|
packages = rec {
|
||||||
defaultPackage = yosys;
|
yosys = yosys-clang;
|
||||||
devShell = pkgs.mkShell {
|
yosys-gcc = pkgs.yosys;
|
||||||
buildInputs = with pkgs; [ clang llvmPackages.bintools gcc bison flex libffi tcl readline python3 zlib git gtest abc-verifier verilog ];
|
yosys-win32 = win32Pkgs.yosys;
|
||||||
|
yosys-win64 = win64Pkgs.yosys;
|
||||||
|
|
||||||
|
default = yosys;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
10
frontends/CMakeLists.txt
Normal file
10
frontends/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
add_subdirectory(aiger)
|
||||||
|
add_subdirectory(aiger2)
|
||||||
|
add_subdirectory(ast)
|
||||||
|
add_subdirectory(blif)
|
||||||
|
add_subdirectory(json)
|
||||||
|
add_subdirectory(liberty)
|
||||||
|
add_subdirectory(rpc)
|
||||||
|
add_subdirectory(rtlil)
|
||||||
|
add_subdirectory(verific)
|
||||||
|
add_subdirectory(verilog)
|
||||||
6
frontends/aiger/CMakeLists.txt
Normal file
6
frontends/aiger/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
yosys_frontend(aigerparse
|
||||||
|
aigerparse.cc
|
||||||
|
aigerparse.h
|
||||||
|
REQUIRES
|
||||||
|
opt_clean
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/aiger/aigerparse.o
|
|
||||||
|
|
||||||
3
frontends/aiger2/CMakeLists.txt
Normal file
3
frontends/aiger2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_frontend(xaiger2
|
||||||
|
xaiger.cc
|
||||||
|
)
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/aiger2/xaiger.o
|
|
||||||
13
frontends/ast/CMakeLists.txt
Normal file
13
frontends/ast/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
yosys_core(ast
|
||||||
|
ast_binding.cc
|
||||||
|
ast_binding.h
|
||||||
|
ast.cc
|
||||||
|
ast.h
|
||||||
|
dpicall.cc
|
||||||
|
genrtlil.cc
|
||||||
|
simplify.cc
|
||||||
|
LIBRARIES
|
||||||
|
$<${YOSYS_ENABLE_LIBFFI}:${Dlfcn_LIBRARIES};PkgConfig::libffi>
|
||||||
|
REQUIRES
|
||||||
|
sha1
|
||||||
|
)
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/ast/ast.o
|
|
||||||
OBJS += frontends/ast/simplify.o
|
|
||||||
OBJS += frontends/ast/genrtlil.o
|
|
||||||
OBJS += frontends/ast/dpicall.o
|
|
||||||
OBJS += frontends/ast/ast_binding.o
|
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_PLUGINS
|
#ifdef YOSYS_ENABLE_LIBFFI
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <ffi.h>
|
#include <ffi.h>
|
||||||
|
|
@ -149,7 +149,7 @@ std::unique_ptr<AST::AstNode> AST::dpi_call(AstSrcLocType loc, const std::string
|
||||||
|
|
||||||
YOSYS_NAMESPACE_END
|
YOSYS_NAMESPACE_END
|
||||||
|
|
||||||
#else /* YOSYS_ENABLE_PLUGINS */
|
#else /* YOSYS_ENABLE_LIBFFI */
|
||||||
|
|
||||||
YOSYS_NAMESPACE_BEGIN
|
YOSYS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
|
@ -160,5 +160,5 @@ std::unique_ptr<AST::AstNode> AST::dpi_call(AstSrcLocType, const std::string&, c
|
||||||
|
|
||||||
YOSYS_NAMESPACE_END
|
YOSYS_NAMESPACE_END
|
||||||
|
|
||||||
#endif /* YOSYS_ENABLE_PLUGINS */
|
#endif /* YOSYS_ENABLE_LIBFFI */
|
||||||
|
|
||||||
|
|
|
||||||
8
frontends/blif/CMakeLists.txt
Normal file
8
frontends/blif/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
yosys_frontend(blif
|
||||||
|
blifparse.cc
|
||||||
|
blifparse.h
|
||||||
|
DATA_DIR
|
||||||
|
include/frontends/blif
|
||||||
|
DATA_FILES
|
||||||
|
blifparse.h
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/blif/blifparse.o
|
|
||||||
|
|
||||||
3
frontends/json/CMakeLists.txt
Normal file
3
frontends/json/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_frontend(json
|
||||||
|
jsonparse.cc
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/json/jsonparse.o
|
|
||||||
|
|
||||||
5
frontends/liberty/CMakeLists.txt
Normal file
5
frontends/liberty/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
yosys_frontend(liberty
|
||||||
|
liberty.cc
|
||||||
|
REQUIRES
|
||||||
|
libparse
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/liberty/liberty.o
|
|
||||||
|
|
||||||
8
frontends/rpc/CMakeLists.txt
Normal file
8
frontends/rpc/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
yosys_frontend(rpc
|
||||||
|
rpc_frontend.cc
|
||||||
|
REQUIRES
|
||||||
|
json11
|
||||||
|
sha1
|
||||||
|
ENABLE_IF
|
||||||
|
YOSYS_ENABLE_SPAWN
|
||||||
|
)
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
ifeq ($(DISABLE_SPAWN),0)
|
|
||||||
OBJS += frontends/rpc/rpc_frontend.o
|
|
||||||
endif
|
|
||||||
3
frontends/rtlil/CMakeLists.txt
Normal file
3
frontends/rtlil/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
yosys_frontend(rtlil
|
||||||
|
rtlil_frontend.cc
|
||||||
|
)
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
OBJS += frontends/rtlil/rtlil_frontend.o
|
|
||||||
70
frontends/verific/CMakeLists.txt
Normal file
70
frontends/verific/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
if (NOT YOSYS_ENABLE_VERIFIC)
|
||||||
|
# Stub interface library.
|
||||||
|
add_library(verific INTERFACE)
|
||||||
|
set(verific_data_files)
|
||||||
|
else()
|
||||||
|
if (NOT YOSYS_VERIFIC_COMPONENTS)
|
||||||
|
get_verific_components(YOSYS_VERIFIC_COMPONENTS)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT YOSYS_VERIFIC_FEATURES)
|
||||||
|
foreach (component ${YOSYS_VERIFIC_COMPONENTS})
|
||||||
|
if (component MATCHES "^(hier_tree|vhdl|edif|extensions)$")
|
||||||
|
list(APPEND YOSYS_VERIFIC_FEATURES ${component})
|
||||||
|
elseif (component STREQUAL "verilog")
|
||||||
|
list(APPEND YOSYS_VERIFIC_FEATURES systemverilog)
|
||||||
|
elseif (component STREQUAL "synlib")
|
||||||
|
list(APPEND YOSYS_VERIFIC_FEATURES liberty)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Verific library components: ${YOSYS_VERIFIC_COMPONENTS}")
|
||||||
|
message(STATUS "Verific frontend features: ${YOSYS_VERIFIC_FEATURES}")
|
||||||
|
|
||||||
|
get_verific_options(verific_include_dirs verific_libraries ${YOSYS_VERIFIC_COMPONENTS})
|
||||||
|
add_library(verific INTERFACE)
|
||||||
|
target_include_directories(verific INTERFACE
|
||||||
|
${verific_include_dirs}
|
||||||
|
)
|
||||||
|
target_link_libraries(verific INTERFACE
|
||||||
|
$<LINK_LIBRARY:WHOLE_ARCHIVE,${verific_libraries}>
|
||||||
|
PkgConfig::zlib
|
||||||
|
)
|
||||||
|
|
||||||
|
set(verific_data_files)
|
||||||
|
if ("vhdl" IN_LIST YOSYS_VERIFIC_FEATURES)
|
||||||
|
foreach (vdb_std 1987 1993 2008 2019)
|
||||||
|
set(vdb_std_root ${YOSYS_VERIFIC_DIR}/vhdl_packages/vdbs_${vdb_std})
|
||||||
|
file(GLOB_RECURSE vdb_files RELATIVE ${vdb_std_root} ${vdb_std_root}/*)
|
||||||
|
foreach (vdb_file ${vdb_files})
|
||||||
|
list(APPEND verific_data_files
|
||||||
|
verific/vhdl_vdbs_${vdb_std}/${vdb_file}
|
||||||
|
${YOSYS_VERIFIC_DIR}/vhdl_packages/vdbs_${vdb_std}/${vdb_file}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
yosys_frontend(verific
|
||||||
|
verific.cc
|
||||||
|
verific.h
|
||||||
|
$<${YOSYS_ENABLE_VERIFIC}:verificsva.cc>
|
||||||
|
DEFINITIONS
|
||||||
|
$<$<IN_LIST:hier_tree,${YOSYS_VERIFIC_FEATURES}>:VERIFIC_HIER_TREE_SUPPORT>
|
||||||
|
$<$<IN_LIST:systemverilog,${YOSYS_VERIFIC_FEATURES}>:VERIFIC_SYSTEMVERILOG_SUPPORT>
|
||||||
|
$<$<IN_LIST:vhdl,${YOSYS_VERIFIC_FEATURES}>:VERIFIC_VHDL_SUPPORT>
|
||||||
|
$<$<IN_LIST:edif,${YOSYS_VERIFIC_FEATURES}>:VERIFIC_EDIF_SUPPORT>
|
||||||
|
$<$<IN_LIST:liberty,${YOSYS_VERIFIC_FEATURES}>:VERIFIC_LIBERTY_SUPPORT>
|
||||||
|
$<$<IN_LIST:extensions,${YOSYS_VERIFIC_FEATURES}>:YOSYSHQ_VERIFIC_EXTENSIONS>
|
||||||
|
LIBRARIES
|
||||||
|
verific
|
||||||
|
REQUIRES
|
||||||
|
sha1
|
||||||
|
read_verilog
|
||||||
|
PROVIDES
|
||||||
|
read
|
||||||
|
DATA_EXPLICIT
|
||||||
|
${verific_data_files}
|
||||||
|
)
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
|
|
||||||
OBJS += frontends/verific/verific.o
|
|
||||||
|
|
||||||
ifeq ($(ENABLE_VERIFIC),1)
|
|
||||||
|
|
||||||
OBJS += frontends/verific/verificsva.o
|
|
||||||
|
|
||||||
EXTRA_TARGETS += share/verific
|
|
||||||
|
|
||||||
share/verific:
|
|
||||||
$(P) rm -rf share/verific.new
|
|
||||||
$(Q) mkdir -p share/verific.new
|
|
||||||
ifeq ($(ENABLE_VERIFIC_VHDL),1)
|
|
||||||
$(Q) cp -r $(VERIFIC_DIR)/vhdl_packages/vdbs_1987/. share/verific.new/vhdl_vdbs_1987
|
|
||||||
$(Q) cp -r $(VERIFIC_DIR)/vhdl_packages/vdbs_1993/. share/verific.new/vhdl_vdbs_1993
|
|
||||||
$(Q) cp -r $(VERIFIC_DIR)/vhdl_packages/vdbs_2008/. share/verific.new/vhdl_vdbs_2008
|
|
||||||
$(Q) cp -r $(VERIFIC_DIR)/vhdl_packages/vdbs_2019/. share/verific.new/vhdl_vdbs_2019
|
|
||||||
endif
|
|
||||||
$(Q) chmod -R a+rX share/verific.new
|
|
||||||
$(Q) mv share/verific.new share/verific
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
43
frontends/verilog/CMakeLists.txt
Normal file
43
frontends/verilog/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
if (NOT FLEX_INCLUDE_DIRS)
|
||||||
|
set(FLEX_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/flex)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
flex_target(verilog_lexer
|
||||||
|
verilog_lexer.l
|
||||||
|
verilog_lexer.cc
|
||||||
|
)
|
||||||
|
bison_target(verilog_parser
|
||||||
|
verilog_parser.y
|
||||||
|
verilog_parser.tab.cc
|
||||||
|
# (requires CMake 4.0)
|
||||||
|
# OPTIONS
|
||||||
|
# -Wall -Werror
|
||||||
|
)
|
||||||
|
yosys_frontend(verilog
|
||||||
|
const2ast.cc
|
||||||
|
preproc.cc
|
||||||
|
preproc.h
|
||||||
|
verilog_error.cc
|
||||||
|
verilog_error.h
|
||||||
|
verilog_frontend.cc
|
||||||
|
verilog_frontend.h
|
||||||
|
verilog_lexer.h
|
||||||
|
verilog_location.h
|
||||||
|
${FLEX_verilog_lexer_OUTPUTS}
|
||||||
|
${BISON_verilog_parser_OUTPUTS}
|
||||||
|
INCLUDE_DIRS
|
||||||
|
${FLEX_INCLUDE_DIRS}
|
||||||
|
REQUIRES
|
||||||
|
sha1
|
||||||
|
ast
|
||||||
|
PROVIDES
|
||||||
|
verilog_defaults
|
||||||
|
verilog_defines
|
||||||
|
read_verilog_file_list
|
||||||
|
ESSENTIAL
|
||||||
|
)
|
||||||
|
set_source_files_properties(
|
||||||
|
${BISON_verilog_parser_OUTPUT_SOURCE}
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS -DYYMAXDEPTH=10000000
|
||||||
|
)
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
|
|
||||||
GENFILES += frontends/verilog/verilog_parser.tab.cc
|
|
||||||
GENFILES += frontends/verilog/verilog_parser.tab.hh
|
|
||||||
GENFILES += frontends/verilog/verilog_parser.output
|
|
||||||
GENFILES += frontends/verilog/verilog_lexer.cc
|
|
||||||
|
|
||||||
frontends/verilog/verilog_parser.tab.cc: frontends/verilog/verilog_parser.y
|
|
||||||
$(Q) mkdir -p $(dir $@)
|
|
||||||
$(P) $(BISON) -Wall -Werror -o $@ -d -r all -b frontends/verilog/verilog_parser $<
|
|
||||||
|
|
||||||
frontends/verilog/verilog_parser.tab.hh: frontends/verilog/verilog_parser.tab.cc
|
|
||||||
|
|
||||||
frontends/verilog/verilog_frontend.o: frontends/verilog/verilog_parser.tab.hh
|
|
||||||
frontends/verilog/preproc.o: frontends/verilog/verilog_parser.tab.hh
|
|
||||||
|
|
||||||
frontends/verilog/verilog_lexer.h: frontends/verilog/verilog_parser.tab.hh
|
|
||||||
frontends/verilog/verilog_lexer.cc: frontends/verilog/verilog_lexer.l frontends/verilog/verilog_parser.tab.cc
|
|
||||||
$(Q) mkdir -p $(dir $@)
|
|
||||||
$(P) flex -o frontends/verilog/verilog_lexer.cc $<
|
|
||||||
|
|
||||||
frontends/verilog/verilog_parser.tab.o: CXXFLAGS += -DYYMAXDEPTH=10000000
|
|
||||||
|
|
||||||
OBJS += frontends/verilog/verilog_parser.tab.o
|
|
||||||
OBJS += frontends/verilog/verilog_lexer.o
|
|
||||||
OBJS += frontends/verilog/preproc.o
|
|
||||||
OBJS += frontends/verilog/verilog_frontend.o
|
|
||||||
OBJS += frontends/verilog/verilog_error.o
|
|
||||||
OBJS += frontends/verilog/const2ast.o
|
|
||||||
|
|
||||||
186
kernel/CMakeLists.txt
Normal file
186
kernel/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,186 @@
|
||||||
|
yosys_version_file(version.cc.in version.cc)
|
||||||
|
configure_file(yosys_config.h.in yosys_config.h @ONLY)
|
||||||
|
|
||||||
|
set(cellhelp_sources)
|
||||||
|
foreach (library simlib simcells)
|
||||||
|
add_custom_command(
|
||||||
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
|
||||||
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py
|
||||||
|
${CMAKE_SOURCE_DIR}/techlibs/common/${library}.v
|
||||||
|
> ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
list(APPEND cellhelp_sources ${CMAKE_CURRENT_BINARY_DIR}/${library}_help.inc)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
yosys_core(kernel
|
||||||
|
binding.cc
|
||||||
|
binding.h
|
||||||
|
bitpattern.h
|
||||||
|
calc.cc
|
||||||
|
cellaigs.cc
|
||||||
|
cellaigs.h
|
||||||
|
celledges.cc
|
||||||
|
celledges.h
|
||||||
|
celltypes.h
|
||||||
|
compute_graph.h
|
||||||
|
consteval.h
|
||||||
|
constids.inc
|
||||||
|
cost.cc
|
||||||
|
cost.h
|
||||||
|
drivertools.cc
|
||||||
|
drivertools.h
|
||||||
|
ff.cc
|
||||||
|
ff.h
|
||||||
|
ffinit.h
|
||||||
|
ffmerge.cc
|
||||||
|
ffmerge.h
|
||||||
|
fmt.cc
|
||||||
|
fmt.h
|
||||||
|
functional.cc
|
||||||
|
functional.h
|
||||||
|
gzip.cc
|
||||||
|
gzip.h
|
||||||
|
hashlib.h
|
||||||
|
io.cc
|
||||||
|
io.h
|
||||||
|
json.cc
|
||||||
|
json.h
|
||||||
|
log.cc
|
||||||
|
log.h
|
||||||
|
$<${YOSYS_ENABLE_VERIFIC}:log_compat.cc>
|
||||||
|
log_help.cc
|
||||||
|
log_help.h
|
||||||
|
macc.h
|
||||||
|
mem.cc
|
||||||
|
mem.h
|
||||||
|
modtools.h
|
||||||
|
newcelltypes.h
|
||||||
|
pattern.h
|
||||||
|
qcsat.cc
|
||||||
|
qcsat.h
|
||||||
|
register.cc
|
||||||
|
register.h
|
||||||
|
${cellhelp_sources}
|
||||||
|
rtlil_bufnorm.cc
|
||||||
|
rtlil.cc
|
||||||
|
rtlil.h
|
||||||
|
satgen.cc
|
||||||
|
satgen.h
|
||||||
|
scopeinfo.cc
|
||||||
|
scopeinfo.h
|
||||||
|
sexpr.cc
|
||||||
|
sexpr.h
|
||||||
|
sigtools.h
|
||||||
|
tclapi.cc
|
||||||
|
threading.cc
|
||||||
|
threading.h
|
||||||
|
timinginfo.h
|
||||||
|
topo_scc.h
|
||||||
|
utils.h
|
||||||
|
version.cc
|
||||||
|
wallace_tree.h
|
||||||
|
yosys.cc
|
||||||
|
yosys_common.h
|
||||||
|
yosys_config.h
|
||||||
|
yosys.h
|
||||||
|
yw.cc
|
||||||
|
yw.h
|
||||||
|
INCLUDE_DIRS
|
||||||
|
${pybind11_INCLUDE_DIR}
|
||||||
|
LIBRARIES
|
||||||
|
cxxopts
|
||||||
|
$<${YOSYS_ENABLE_PLUGINS}:${Dlfcn_LIBRARIES}>
|
||||||
|
$<${YOSYS_ENABLE_ZLIB}:PkgConfig::zlib>
|
||||||
|
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
|
||||||
|
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
|
||||||
|
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
|
||||||
|
$<${YOSYS_ENABLE_PYTHON}:Python3::Python>
|
||||||
|
REQUIRES
|
||||||
|
bigint
|
||||||
|
ezsat
|
||||||
|
json11
|
||||||
|
sha1
|
||||||
|
PROVIDES
|
||||||
|
help
|
||||||
|
echo
|
||||||
|
license
|
||||||
|
tcl
|
||||||
|
shell
|
||||||
|
history
|
||||||
|
script
|
||||||
|
DATA_DIR
|
||||||
|
include/kernel
|
||||||
|
DATA_FILES
|
||||||
|
binding.h
|
||||||
|
bitpattern.h
|
||||||
|
cellaigs.h
|
||||||
|
celledges.h
|
||||||
|
celltypes.h
|
||||||
|
newcelltypes.h
|
||||||
|
consteval.h
|
||||||
|
constids.inc
|
||||||
|
cost.h
|
||||||
|
drivertools.h
|
||||||
|
ff.h
|
||||||
|
ffinit.h
|
||||||
|
ffmerge.h
|
||||||
|
fmt.h
|
||||||
|
gzip.h
|
||||||
|
hashlib.h
|
||||||
|
io.h
|
||||||
|
json.h
|
||||||
|
log.h
|
||||||
|
macc.h
|
||||||
|
modtools.h
|
||||||
|
mem.h
|
||||||
|
qcsat.h
|
||||||
|
register.h
|
||||||
|
rtlil.h
|
||||||
|
satgen.h
|
||||||
|
scopeinfo.h
|
||||||
|
sexpr.h
|
||||||
|
sigtools.h
|
||||||
|
threading.h
|
||||||
|
timinginfo.h
|
||||||
|
utils.h
|
||||||
|
yosys.h
|
||||||
|
yosys_common.h
|
||||||
|
yw.h
|
||||||
|
DATA_EXPLICIT
|
||||||
|
yosys_config.h ${CMAKE_CURRENT_BINARY_DIR}/yosys_config.h
|
||||||
|
ESSENTIAL
|
||||||
|
)
|
||||||
|
|
||||||
|
set(yosys_cc_definitions
|
||||||
|
"$<$<BOOL:${YOSYS_ABC_EXECUTABLE}>:ABCEXTERNAL=\"${YOSYS_ABC_EXECUTABLE}\">"
|
||||||
|
$<$<BOOL:${MSYS}>:YOSYS_WIN32_UNIX_DIR>
|
||||||
|
)
|
||||||
|
set_source_files_properties(yosys.cc PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS "${yosys_cc_definitions}"
|
||||||
|
)
|
||||||
|
|
||||||
|
yosys_core(fstdata
|
||||||
|
fstdata.cc
|
||||||
|
fstdata.h
|
||||||
|
REQUIRES
|
||||||
|
fst
|
||||||
|
DATA_DIR
|
||||||
|
include/kernel
|
||||||
|
DATA_FILES
|
||||||
|
fstdata.h
|
||||||
|
)
|
||||||
|
|
||||||
|
yosys_core(driver
|
||||||
|
driver.cc
|
||||||
|
INCLUDE_DIRS
|
||||||
|
${pybind11_INCLUDE_DIR}
|
||||||
|
LIBRARIES
|
||||||
|
$<${YOSYS_ENABLE_READLINE}:PkgConfig::readline>
|
||||||
|
$<${YOSYS_ENABLE_EDITLINE}:PkgConfig::editline>
|
||||||
|
$<${YOSYS_ENABLE_TCL}:PkgConfig::tcl>
|
||||||
|
$<${YOSYS_ENABLE_PYTHON}:Python3::Python>
|
||||||
|
REQUIRES
|
||||||
|
essentials
|
||||||
|
)
|
||||||
|
|
@ -29,7 +29,7 @@ static std::string file_base_name(std::string const & path)
|
||||||
|
|
||||||
FstData::FstData(std::string filename) : ctx(nullptr)
|
FstData::FstData(std::string filename) : ctx(nullptr)
|
||||||
{
|
{
|
||||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
#if defined(YOSYS_ENABLE_SPAWN)
|
||||||
std::string filename_trim = file_base_name(filename);
|
std::string filename_trim = file_base_name(filename);
|
||||||
if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vcd") == 0) {
|
if (filename_trim.size() > 4 && filename_trim.compare(filename_trim.size()-4, std::string::npos, ".vcd") == 0) {
|
||||||
filename_trim.erase(filename_trim.size()-4);
|
filename_trim.erase(filename_trim.size()-4);
|
||||||
|
|
@ -87,18 +87,18 @@ static void normalize_brackets(std::string &str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fstHandle FstData::getHandle(std::string name) {
|
fstHandle FstData::getHandle(std::string name) {
|
||||||
normalize_brackets(name);
|
normalize_brackets(name);
|
||||||
if (name_to_handle.find(name) != name_to_handle.end())
|
if (name_to_handle.find(name) != name_to_handle.end())
|
||||||
return name_to_handle[name];
|
return name_to_handle[name];
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
dict<int,fstHandle> FstData::getMemoryHandles(std::string name) {
|
dict<int,fstHandle> FstData::getMemoryHandles(std::string name) {
|
||||||
if (memory_to_handle.find(name) != memory_to_handle.end())
|
if (memory_to_handle.find(name) != memory_to_handle.end())
|
||||||
return memory_to_handle[name];
|
return memory_to_handle[name];
|
||||||
else
|
else
|
||||||
return dict<int,fstHandle>();
|
return dict<int,fstHandle>();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ void FstData::extractVarNames()
|
||||||
handle_to_var[h->u.var.handle] = var;
|
handle_to_var[h->u.var.handle] = var;
|
||||||
std::string clean_name;
|
std::string clean_name;
|
||||||
bool has_space = false;
|
bool has_space = false;
|
||||||
for(size_t i=0;i<strlen(h->u.var.name);i++)
|
for(size_t i=0;i<strlen(h->u.var.name);i++)
|
||||||
{
|
{
|
||||||
char c = h->u.var.name[i];
|
char c = h->u.var.name[i];
|
||||||
if(c==' ') { has_space = true; break; }
|
if(c==' ') { has_space = true; break; }
|
||||||
|
|
@ -210,7 +210,7 @@ void FstData::reconstruct_callback_attimes(uint64_t pnt_time, fstHandle pnt_faci
|
||||||
bool is_clock = false;
|
bool is_clock = false;
|
||||||
if (!all_samples) {
|
if (!all_samples) {
|
||||||
for(auto &s : clk_signals) {
|
for(auto &s : clk_signals) {
|
||||||
if (s==pnt_facidx) {
|
if (s==pnt_facidx) {
|
||||||
is_clock=true;
|
is_clock=true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
# include <sys/time.h>
|
# include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__)
|
#if defined(YOSYS_ENABLE_DLOPEN)
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -471,7 +471,7 @@ void log_pop()
|
||||||
log_flush();
|
log_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(YOSYS_ENABLE_PLUGINS)
|
#if defined(YOSYS_ENABLE_DLOPEN)
|
||||||
void log_backtrace(const char *prefix, int levels)
|
void log_backtrace(const char *prefix, int levels)
|
||||||
{
|
{
|
||||||
if (levels <= 0) return;
|
if (levels <= 0) return;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ void try_collect_garbage()
|
||||||
RTLIL::OwningIdString::collect_garbage();
|
RTLIL::OwningIdString::collect_garbage();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pass::Pass(std::string name, std::string short_help, source_location location) :
|
Pass::Pass(std::string name, std::string short_help, source_location location) :
|
||||||
pass_name(name), short_help(short_help), location(location)
|
pass_name(name), short_help(short_help), location(location)
|
||||||
{
|
{
|
||||||
next_queued_pass = first_queued_pass;
|
next_queued_pass = first_queued_pass;
|
||||||
|
|
@ -217,7 +217,7 @@ void Pass::call(RTLIL::Design *design, std::string command)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (tok[0] == '!') {
|
if (tok[0] == '!') {
|
||||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
#if defined(YOSYS_ENABLE_SPAWN)
|
||||||
cmd_buf = command.substr(command.find('!') + 1);
|
cmd_buf = command.substr(command.find('!') + 1);
|
||||||
while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
|
while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
|
||||||
cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
|
cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
|
||||||
|
|
@ -741,8 +741,8 @@ static void log_warning_flags(Pass *pass) {
|
||||||
static struct CellHelpMessages {
|
static struct CellHelpMessages {
|
||||||
dict<string, SimHelper> cell_help;
|
dict<string, SimHelper> cell_help;
|
||||||
CellHelpMessages() {
|
CellHelpMessages() {
|
||||||
#include "techlibs/common/simlib_help.inc"
|
#include "kernel/simlib_help.inc"
|
||||||
#include "techlibs/common/simcells_help.inc"
|
#include "kernel/simcells_help.inc"
|
||||||
cell_help.sort();
|
cell_help.sort();
|
||||||
}
|
}
|
||||||
bool contains(string name) { return cell_help.count(get_cell_name(name)) > 0; }
|
bool contains(string name) { return cell_help.count(get_cell_name(name)) > 0; }
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
#include "kernel/yosys_common.h"
|
||||||
|
#include "kernel/log.h"
|
||||||
|
#include "kernel/utils.h"
|
||||||
|
|
||||||
#ifdef YOSYS_ENABLE_THREADS
|
#ifdef YOSYS_ENABLE_THREADS
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "kernel/yosys_common.h"
|
|
||||||
#include "kernel/log.h"
|
|
||||||
#include "kernel/utils.h"
|
|
||||||
|
|
||||||
#ifndef YOSYS_THREADING_H
|
#ifndef YOSYS_THREADING_H
|
||||||
#define YOSYS_THREADING_H
|
#define YOSYS_THREADING_H
|
||||||
|
|
||||||
|
|
|
||||||
4
kernel/version.cc.in
Normal file
4
kernel/version.cc.in
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
namespace Yosys {
|
||||||
|
const char *yosys_version_str = "@YOSYS_BUILD_INFO@";
|
||||||
|
const char *yosys_git_hash_str = "@YOSYS_CHECKOUT_INFO@";
|
||||||
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ namespace py = pybind11;
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# if !defined(YOSYS_DISABLE_SPAWN)
|
# if defined(YOSYS_ENABLE_SPAWN)
|
||||||
# include <sys/wait.h>
|
# include <sys/wait.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -179,7 +179,7 @@ void yosys_banner()
|
||||||
log(" %s\n", yosys_maybe_version());
|
log(" %s\n", yosys_maybe_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(YOSYS_DISABLE_SPAWN)
|
#if defined(YOSYS_ENABLE_SPAWN)
|
||||||
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
int run_command(const std::string &command, std::function<void(const std::string&)> process_line)
|
||||||
{
|
{
|
||||||
if (!process_line)
|
if (!process_line)
|
||||||
|
|
@ -636,13 +636,11 @@ void init_share_dirname()
|
||||||
yosys_share_dirname = proc_share_path;
|
yosys_share_dirname = proc_share_path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# ifdef YOSYS_DATDIR
|
|
||||||
proc_share_path = YOSYS_DATDIR "/";
|
proc_share_path = YOSYS_DATDIR "/";
|
||||||
if (check_directory_exists(proc_share_path, true)) {
|
if (check_directory_exists(proc_share_path, true)) {
|
||||||
yosys_share_dirname = proc_share_path;
|
yosys_share_dirname = proc_share_path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -684,11 +682,7 @@ std::string proc_share_dirname()
|
||||||
|
|
||||||
std::string proc_program_prefix()
|
std::string proc_program_prefix()
|
||||||
{
|
{
|
||||||
std::string program_prefix;
|
return YOSYS_PROGRAM_PREFIX;
|
||||||
#ifdef YOSYS_PROGRAM_PREFIX
|
|
||||||
program_prefix = YOSYS_PROGRAM_PREFIX;
|
|
||||||
#endif
|
|
||||||
return program_prefix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fgetline(FILE *f, std::string &buffer)
|
bool fgetline(FILE *f, std::string &buffer)
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,8 @@
|
||||||
defines the Yosys Makefile would set for your build configuration.
|
defines the Yosys Makefile would set for your build configuration.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "kernel/yosys_config.h"
|
||||||
|
|
||||||
#define FRIEND_TEST(test_case_name, test_name) \
|
#define FRIEND_TEST(test_case_name, test_name) \
|
||||||
friend class test_case_name##_##test_name##_Test
|
friend class test_case_name##_##test_name##_Test
|
||||||
|
|
||||||
|
|
@ -91,6 +93,8 @@
|
||||||
# undef CONST
|
# undef CONST
|
||||||
// `wingdi.h` defines a TRANSPARENT macro that conflicts with X(TRANSPARENT) entry in kernel/constids.inc
|
// `wingdi.h` defines a TRANSPARENT macro that conflicts with X(TRANSPARENT) entry in kernel/constids.inc
|
||||||
# undef TRANSPARENT
|
# undef TRANSPARENT
|
||||||
|
// `wingdi.h` defines an ERROR macro that conflicts with `ERROR()` macro in kernel/tclapi.cc
|
||||||
|
# undef ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
|
|
|
||||||
22
kernel/yosys_config.h.in
Normal file
22
kernel/yosys_config.h.in
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef YOSYS_CONFIG_H
|
||||||
|
#define YOSYS_CONFIG_H
|
||||||
|
|
||||||
|
// Installation parameters
|
||||||
|
#define YOSYS_PROGRAM_PREFIX "@YOSYS_PROGRAM_PREFIX@"
|
||||||
|
#define YOSYS_DATDIR "@YOSYS_INSTALL_DATADIR@"
|
||||||
|
|
||||||
|
// Feature toggles
|
||||||
|
#cmakedefine YOSYS_ENABLE_GLOB
|
||||||
|
#cmakedefine YOSYS_ENABLE_SPAWN
|
||||||
|
#cmakedefine YOSYS_ENABLE_THREADS
|
||||||
|
#cmakedefine YOSYS_ENABLE_DLOPEN
|
||||||
|
#cmakedefine YOSYS_ENABLE_ZLIB
|
||||||
|
#cmakedefine YOSYS_ENABLE_PLUGINS
|
||||||
|
#cmakedefine YOSYS_ENABLE_READLINE
|
||||||
|
#cmakedefine YOSYS_ENABLE_EDITLINE
|
||||||
|
#cmakedefine YOSYS_ENABLE_TCL
|
||||||
|
#cmakedefine YOSYS_ENABLE_PYTHON
|
||||||
|
#cmakedefine YOSYS_ENABLE_VERIFIC
|
||||||
|
#cmakedefine YOSYS_ENABLE_HELP_SOURCE
|
||||||
|
|
||||||
|
#endif
|
||||||
9
libs/CMakeLists.txt
Normal file
9
libs/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
add_subdirectory(bigint)
|
||||||
|
add_subdirectory(cxxopts)
|
||||||
|
add_subdirectory(dlfcn-win32)
|
||||||
|
add_subdirectory(ezsat)
|
||||||
|
add_subdirectory(fst)
|
||||||
|
add_subdirectory(json11)
|
||||||
|
add_subdirectory(minisat)
|
||||||
|
add_subdirectory(sha1)
|
||||||
|
add_subdirectory(subcircuit)
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue