From f51a2d793a67cdd7466f101ab20bbf25ab062f96 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 12 Feb 2025 14:18:02 +0100 Subject: [PATCH] CMake: initial work --- CMakeLists.txt | 43 ++++++++++++++++ backends/edif/CMakeLists.txt | 7 +++ backends/rtlil/CMakeLists.txt | 8 +++ frontends/aiger/CMakeLists.txt | 8 +++ frontends/aiger2/CMakeLists.txt | 7 +++ frontends/ast/CMakeLists.txt | 13 +++++ frontends/blif/CMakeLists.txt | 8 +++ frontends/json/CMakeLists.txt | 7 +++ frontends/liberty/CMakeLists.txt | 7 +++ frontends/rpc/CMakeLists.txt | 7 +++ frontends/rtlil/CMakeLists.txt | 16 ++++++ frontends/verific/CMakeLists.txt | 8 +++ frontends/verilog/CMakeLists.txt | 46 +++++++++++++++++ kernel/CMakeLists.txt | 85 ++++++++++++++++++++++++++++++++ kernel/version.cc.in | 1 + libs/CMakeLists.txt | 66 +++++++++++++++++++++++++ passes/cmds/CMakeLists.txt | 56 +++++++++++++++++++++ passes/techmap/CMakeLists.txt | 7 +++ techlibs/common/CMakeLists.txt | 30 +++++++++++ 19 files changed, 430 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 backends/edif/CMakeLists.txt create mode 100644 backends/rtlil/CMakeLists.txt create mode 100644 frontends/aiger/CMakeLists.txt create mode 100644 frontends/aiger2/CMakeLists.txt create mode 100644 frontends/ast/CMakeLists.txt create mode 100644 frontends/blif/CMakeLists.txt create mode 100644 frontends/json/CMakeLists.txt create mode 100644 frontends/liberty/CMakeLists.txt create mode 100644 frontends/rpc/CMakeLists.txt create mode 100644 frontends/rtlil/CMakeLists.txt create mode 100644 frontends/verific/CMakeLists.txt create mode 100644 frontends/verilog/CMakeLists.txt create mode 100644 kernel/CMakeLists.txt create mode 100644 kernel/version.cc.in create mode 100644 libs/CMakeLists.txt create mode 100644 passes/cmds/CMakeLists.txt create mode 100644 passes/techmap/CMakeLists.txt create mode 100644 techlibs/common/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..e622ea5db --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.13) +project(yosys LANGUAGES CXX C) +set(YOSYS_VER "0.50+1") + +include(CheckCXXCompilerFlag) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) + +find_package(FLEX 2.6 REQUIRED) +find_package(BISON 3.0 REQUIRED) +find_package(Python3 3.5 REQUIRED COMPONENTS Interpreter) + +add_executable(yosys) +#target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +#target_include_directories(yosys PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +#target_compile_definitions(yosys PRIVATE _YOSYS_) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) +add_compile_definitions(_YOSYS_) + +add_subdirectory(kernel) +add_subdirectory(libs) +add_subdirectory(frontends/aiger) +add_subdirectory(frontends/aiger2) +add_subdirectory(frontends/ast) +add_subdirectory(frontends/blif) +add_subdirectory(frontends/json) +add_subdirectory(frontends/liberty) +add_subdirectory(frontends/rpc) +add_subdirectory(frontends/rtlil) +add_subdirectory(frontends/verilog) +add_subdirectory(backends/rtlil) +add_subdirectory(backends/edif) +add_subdirectory(passes/cmds) +add_subdirectory(passes/techmap) +add_subdirectory(techlibs/common) + +target_link_libraries(yosys PRIVATE z) diff --git a/backends/edif/CMakeLists.txt b/backends/edif/CMakeLists.txt new file mode 100644 index 000000000..1a45ad060 --- /dev/null +++ b/backends/edif/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_backends_edif INTERFACE) + +target_sources(yosys_backends_edif INTERFACE + edif.cc +) + +target_link_libraries(yosys PRIVATE yosys_backends_edif) diff --git a/backends/rtlil/CMakeLists.txt b/backends/rtlil/CMakeLists.txt new file mode 100644 index 000000000..8f352e0f4 --- /dev/null +++ b/backends/rtlil/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(yosys_backends_rtlil INTERFACE) + +target_sources(yosys_backends_rtlil INTERFACE + rtlil_backend.cc + rtlil_backend.h +) + +target_link_libraries(yosys PRIVATE yosys_backends_rtlil) diff --git a/frontends/aiger/CMakeLists.txt b/frontends/aiger/CMakeLists.txt new file mode 100644 index 000000000..1198dac91 --- /dev/null +++ b/frontends/aiger/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(yosys_frontends_aiger INTERFACE) + +target_sources(yosys_frontends_aiger INTERFACE + aigerparse.cc + aigerparse.h +) + +target_link_libraries(yosys PRIVATE yosys_frontends_aiger) diff --git a/frontends/aiger2/CMakeLists.txt b/frontends/aiger2/CMakeLists.txt new file mode 100644 index 000000000..ddc09a0c2 --- /dev/null +++ b/frontends/aiger2/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_frontends_aiger2 INTERFACE) + +target_sources(yosys_frontends_aiger2 INTERFACE + xaiger.cc +) + +target_link_libraries(yosys PRIVATE yosys_frontends_aiger2) diff --git a/frontends/ast/CMakeLists.txt b/frontends/ast/CMakeLists.txt new file mode 100644 index 000000000..4d5993bd0 --- /dev/null +++ b/frontends/ast/CMakeLists.txt @@ -0,0 +1,13 @@ +add_library(yosys_frontends_ast INTERFACE) + +target_sources(yosys_frontends_ast INTERFACE + ast_binding.cc + ast_binding.h + ast.cc + ast.h + dpicall.cc + genrtlil.cc + simplify.cc +) + +target_link_libraries(yosys PRIVATE yosys_frontends_ast) diff --git a/frontends/blif/CMakeLists.txt b/frontends/blif/CMakeLists.txt new file mode 100644 index 000000000..2af85e340 --- /dev/null +++ b/frontends/blif/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(yosys_frontends_blif INTERFACE) + +target_sources(yosys_frontends_blif INTERFACE + blifparse.cc + blifparse.h +) + +target_link_libraries(yosys PRIVATE yosys_frontends_blif) diff --git a/frontends/json/CMakeLists.txt b/frontends/json/CMakeLists.txt new file mode 100644 index 000000000..c74bc5611 --- /dev/null +++ b/frontends/json/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_frontends_json INTERFACE) + +target_sources(yosys_frontends_json INTERFACE + jsonparse.cc +) + +target_link_libraries(yosys PRIVATE yosys_frontends_json) diff --git a/frontends/liberty/CMakeLists.txt b/frontends/liberty/CMakeLists.txt new file mode 100644 index 000000000..15bbf6179 --- /dev/null +++ b/frontends/liberty/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_frontends_liberty INTERFACE) + +target_sources(yosys_frontends_liberty INTERFACE + liberty.cc +) + +target_link_libraries(yosys PRIVATE yosys_frontends_liberty) diff --git a/frontends/rpc/CMakeLists.txt b/frontends/rpc/CMakeLists.txt new file mode 100644 index 000000000..a8c566df6 --- /dev/null +++ b/frontends/rpc/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_frontends_rpc INTERFACE) + +target_sources(yosys_frontends_rpc INTERFACE + rpc_frontend.cc +) + +target_link_libraries(yosys PRIVATE yosys_frontends_rpc) diff --git a/frontends/rtlil/CMakeLists.txt b/frontends/rtlil/CMakeLists.txt new file mode 100644 index 000000000..612a56ccd --- /dev/null +++ b/frontends/rtlil/CMakeLists.txt @@ -0,0 +1,16 @@ +flex_target(RTLIL_LEXER "rtlil_lexer.l" "${CMAKE_CURRENT_BINARY_DIR}/rtlil_lexer.cc") +bison_target(RTLIL_PARSER "rtlil_parser.y" "${CMAKE_CURRENT_BINARY_DIR}/rtlil_parser.tab.cc" DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/rtlil_parser.tab.hh" COMPILE_FLAGS "-d -r all") + +add_library(yosys_frontends_rtlil INTERFACE) +target_sources(yosys_frontends_rtlil INTERFACE + rtlil_frontend.cc +) + +add_library(yosys_frontends_rtlil_gen OBJECT + #${CMAKE_CURRENT_BINARY_DIR}/rtlil_lexer.cc + #${CMAKE_CURRENT_BINARY_DIR}/rtlil_parser.tab.cc + #${CMAKE_CURRENT_BINARY_DIR}/rtlil_parser.tab.hh + ${FLEX_RTLIL_LEXER_OUTPUTS} + ${BISON_RTLIL_PARSER_OUTPUTS} +) +target_link_libraries(yosys PRIVATE yosys_frontends_rtlil yosys_frontends_rtlil_gen) diff --git a/frontends/verific/CMakeLists.txt b/frontends/verific/CMakeLists.txt new file mode 100644 index 000000000..1198dac91 --- /dev/null +++ b/frontends/verific/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(yosys_frontends_aiger INTERFACE) + +target_sources(yosys_frontends_aiger INTERFACE + aigerparse.cc + aigerparse.h +) + +target_link_libraries(yosys PRIVATE yosys_frontends_aiger) diff --git a/frontends/verilog/CMakeLists.txt b/frontends/verilog/CMakeLists.txt new file mode 100644 index 000000000..b4126c51a --- /dev/null +++ b/frontends/verilog/CMakeLists.txt @@ -0,0 +1,46 @@ +#add_custom_command( +# COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} +# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc ${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.hh +# COMMAND ${BISON_EXECUTABLE} +# -Wall -Werror +# -o verilog_parser.tab.cc +# -d -r all +# ${CMAKE_CURRENT_SOURCE_DIR}/verilog_parser.y +# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/verilog_parser.y +# COMMENT "Generating frontends/verilog/verilog_parser.tab.cc" +# VERBATIM +# COMMAND_EXPAND_LISTS +#) +# +#add_custom_command( +# COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR} +# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.cc +# COMMAND ${FLEX_EXECUTABLE} +# --outfile=verilog_lexer.cc +# ${CMAKE_CURRENT_SOURCE_DIR}/verilog_lexer.l +# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/verilog_lexer.l +# COMMENT "Generating frontends/verilog/verilog_lexer.cc" +# VERBATIM +# COMMAND_EXPAND_LISTS +#) + +flex_target(VERILOG_LEXER "verilog_lexer.l" "${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.cc") +bison_target(VERILOG_PARSER "verilog_parser.y" "${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc" DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.hh" COMPILE_FLAGS "-Wall -Werror -d -r all") + +add_library(yosys_frontends_verilog INTERFACE) +target_sources(yosys_frontends_verilog INTERFACE + const2ast.cc + preproc.cc + preproc.h + verilog_frontend.cc + verilog_frontend.h +) + +add_library(yosys_frontends_verilog_gen OBJECT + ${FLEX_VERILOG_LEXER_OUTPUTS} + ${BISON_VERILOG_PARSER_OUTPUTS} + #${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.cc + #${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc + #${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.hh +) +target_link_libraries(yosys PRIVATE yosys_frontends_verilog yosys_frontends_verilog_gen) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt new file mode 100644 index 000000000..9e2cc835a --- /dev/null +++ b/kernel/CMakeLists.txt @@ -0,0 +1,85 @@ +add_library(yosys_kernel INTERFACE) + +#if(CMAKE_PROJECT_VERSION_PATCH GREATER 0) +# set(YOSYS_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}+${CMAKE_PROJECT_VERSION_PATCH}") +#else() +# set(YOSYS_VERSION "${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}") +#endif() + +find_package(Git) +if(Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --short=9 HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE CURRENT_GIT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + set(YOSYS_GIT_VERSION "git sha1 ${CURRENT_GIT_VERSION}, ") +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.cc.in ${CMAKE_CURRENT_BINARY_DIR}/version.cc) + +target_sources(yosys_kernel INTERFACE + 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 + driver.cc + drivertools.cc + drivertools.h + ff.cc + ff.h + ffinit.h + ffmerge.cc + ffmerge.h + fmt.cc + fmt.h + fstdata.cc + fstdata.h + functional.cc + functional.h + hashlib.h + json.cc + json.h + log.cc + log.h + macc.h + mem.cc + mem.h + modtools.h + qcsat.cc + qcsat.h + register.cc + register.h + rtlil.cc + rtlil.h + satgen.cc + satgen.h + scopeinfo.cc + scopeinfo.h + sexpr.cc + sexpr.h + sigtools.h + tclapi.cc + timinginfo.h + topo_scc.h + utils.h + ${CMAKE_CURRENT_BINARY_DIR}/version.cc + yosys.cc + yosys_common.h + yosys.h + yw.cc + yw.h +) + +target_link_libraries(yosys PRIVATE yosys_kernel) diff --git a/kernel/version.cc.in b/kernel/version.cc.in new file mode 100644 index 000000000..adcdd6c54 --- /dev/null +++ b/kernel/version.cc.in @@ -0,0 +1 @@ +namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str="Yosys @YOSYS_VER@ (@YOSYS_GIT_VERSION@@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@)"; } diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt new file mode 100644 index 000000000..f1d80af87 --- /dev/null +++ b/libs/CMakeLists.txt @@ -0,0 +1,66 @@ +add_library(yosys_libs INTERFACE) + +target_sources(yosys_libs INTERFACE + bigint/BigInteger.cc + bigint/BigInteger.hh + bigint/BigIntegerAlgorithms.cc + bigint/BigIntegerAlgorithms.hh + bigint/BigIntegerLibrary.hh + bigint/BigIntegerUtils.cc + bigint/BigIntegerUtils.hh + bigint/BigUnsigned.cc + bigint/BigUnsigned.hh + bigint/BigUnsignedInABase.cc + bigint/BigUnsignedInABase.hh + bigint/NumberlikeArray.hh + + sha1/sha1.cpp + sha1/sha1.h + + json11/json11.cpp + json11/json11.hpp + + ezsat/ezsat.cc + ezsat/ezsat.h + ezsat/ezminisat.cc + ezsat/ezminisat.h + + minisat/Alg.h + minisat/Alloc.h + minisat/Dimacs.h + minisat/Heap.h + minisat/IntMap.h + minisat/IntTypes.h + minisat/Map.h + minisat/Options.cc + minisat/Options.h + minisat/ParseUtils.h + minisat/Queue.h + minisat/Rnd.h + minisat/SimpSolver.cc + minisat/SimpSolver.h + minisat/Solver.cc + minisat/Solver.h + minisat/SolverTypes.h + minisat/Sort.h + minisat/System.cc + minisat/System.h + minisat/Vec.h + minisat/XAlloc.h + + fst/config.h + fst/fastlz.cc + fst/fastlz.h + fst/fstapi.cc + fst/fstapi.h + fst/fst_win_unistd.h + fst/lz4.cc + fst/lz4.h + + subcircuit/subcircuit.cc + subcircuit/subcircuit.h + + cxxopts/include/cxxopts.hpp +) + +target_link_libraries(yosys PRIVATE yosys_libs) diff --git a/passes/cmds/CMakeLists.txt b/passes/cmds/CMakeLists.txt new file mode 100644 index 000000000..8945bd1d1 --- /dev/null +++ b/passes/cmds/CMakeLists.txt @@ -0,0 +1,56 @@ +add_library(yosys_passes_cmds INTERFACE) + +target_sources(yosys_passes_cmds INTERFACE + add.cc + autoname.cc + blackbox.cc + box_derive.cc + bugpoint.cc + check.cc + chformal.cc + chtype.cc + clean_zerowidth.cc + connect.cc + connwrappers.cc + copy.cc + cover.cc + delete.cc + design.cc + dft_tag.cc + edgetypes.cc + example_dt.cc + exec.cc + future.cc + glift.cc + internal_stats.cc + logcmd.cc + logger.cc + ltp.cc + plugin.cc + portarcs.cc + portlist.cc + printattrs.cc + rename.cc + scatter.cc + scc.cc + scratchpad.cc + select.cc + setattr.cc + setenv.cc + setundef.cc + show.cc + splice.cc + splitcells.cc + splitnets.cc + sta.cc + stat.cc + tee.cc + torder.cc + trace.cc + viz.cc + wrapcell.cc + write_file.cc + xprop.cc +) + +target_link_libraries(yosys PRIVATE yosys_passes_cmds) diff --git a/passes/techmap/CMakeLists.txt b/passes/techmap/CMakeLists.txt new file mode 100644 index 000000000..006cd8f9c --- /dev/null +++ b/passes/techmap/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(yosys_passes_techmap INTERFACE) + +target_sources(yosys_passes_techmap INTERFACE + libparse.cc +) + +target_link_libraries(yosys PRIVATE yosys_passes_techmap) diff --git a/techlibs/common/CMakeLists.txt b/techlibs/common/CMakeLists.txt new file mode 100644 index 000000000..3dea1b840 --- /dev/null +++ b/techlibs/common/CMakeLists.txt @@ -0,0 +1,30 @@ +add_library(yosys_techlib_common INTERFACE) + +add_custom_command( + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/techlibs/common + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_CURRENT_SOURCE_DIR}/simlib.v > ${CMAKE_CURRENT_BINARY_DIR}/simlib_help.inc + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_CURRENT_SOURCE_DIR}/simlib.v + OUTPUT simlib_help.inc + COMMENT "Generating techlibs/common/simlib_help.inc..." +) +add_custom_command( + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/techlibs/common + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_CURRENT_SOURCE_DIR}/simcells.v > ${CMAKE_CURRENT_BINARY_DIR}/simcells_help.inc + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cellhelp.py ${CMAKE_CURRENT_SOURCE_DIR}/simcells.v + OUTPUT simcells_help.inc + COMMENT "Generating techlibs/common/simcells_help.inc..." +) + +add_custom_target(yosys_techlib_common_gen DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/simlib_help.inc + ${CMAKE_CURRENT_BINARY_DIR}/simcells_help.inc +) + +target_sources(yosys_techlib_common INTERFACE + synth.cc + prep.cc +) + +add_dependencies(yosys_techlib_common yosys_techlib_common_gen) + +target_link_libraries(yosys PRIVATE yosys_techlib_common) \ No newline at end of file