From ec618c020c8298de04a7908b61cf588c0cb61d57 Mon Sep 17 00:00:00 2001 From: "Amir.A" Date: Sun, 8 Dec 2024 11:22:51 -0400 Subject: [PATCH] synlig, new system verilog tool integration [build system + tcl + parmys + paths updated] --- .github/workflows/nightly_test.yml | 4 +- libs/EXTERNAL/CMakeLists.txt | 134 ++++++++++-------- vtr_flow/misc/yosys/synthesis.tcl | 36 +++-- .../scripts/python_libs/vtr/parmys/parmys.py | 6 + vtr_flow/scripts/python_libs/vtr/paths.py | 4 + 5 files changed, 113 insertions(+), 71 deletions(-) diff --git a/.github/workflows/nightly_test.yml b/.github/workflows/nightly_test.yml index a57c502e0d3..5f5e2864e35 100644 --- a/.github/workflows/nightly_test.yml +++ b/.github/workflows/nightly_test.yml @@ -41,7 +41,7 @@ jobs: # Prevents from running on forks where no custom runners are available if: ${{ github.repository_owner == 'verilog-to-routing' }} - timeout-minutes: 420 + timeout-minutes: 700 #420 container: ubuntu:jammy @@ -65,7 +65,7 @@ jobs: - {test: "vtr_reg_strong", cores: "16", options: "", cmake: "-DVTR_ASSERT_LEVEL=3", extra_pkgs: "libeigen3-dev"} - {test: "vtr_reg_strong_odin", cores: "16", options: "", cmake: "-DVTR_ASSERT_LEVEL=3 -DWITH_ODIN=ON", extra_pkgs: "libeigen3-dev"} - {test: "vtr_reg_strong_odin", cores: "16", options: "-skip_qor", cmake: "-DVTR_ASSERT_LEVEL=3 -DVTR_ENABLE_SANITIZE=ON -DWITH_ODIN=ON", extra_pkgs: "libeigen3-dev"} - # - {test: "vtr_reg_system_verilog", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=ON", extra_pkgs: ""} # Test turned off -> F4PGA conflicts with Yosys (version 42) + - {test: "vtr_reg_system_verilog", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=ON", extra_pkgs: ""} # Test turned off -> F4PGA conflicts with Yosys (version 42) - {test: "odin_reg_strong", cores: "16", options: "", cmake: "-DWITH_ODIN=ON", extra_pkgs: ""} - {test: "parmys_reg_strong", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=OFF", extra_pkgs: ""} diff --git a/libs/EXTERNAL/CMakeLists.txt b/libs/EXTERNAL/CMakeLists.txt index a60c48958eb..230924e278f 100644 --- a/libs/EXTERNAL/CMakeLists.txt +++ b/libs/EXTERNAL/CMakeLists.txt @@ -27,9 +27,10 @@ endif () # The VTR root CMakeFile initializes the WITH_PARMYS if (${WITH_PARMYS}) - # building Surelog and UHDM in a custom target to avoid any target conflict with VTR targets - if (${YOSYS_F4PGA_PLUGINS}) - set(SURELOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Surelog) + + if (${WITH_PARMYS}) + +set(SURELOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Surelog) set(SURELOG_BINARY_DIR ${SURELOG_SOURCE_DIR}/build) set(YOSYS_F4PGA_PLUGINS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yosys-f4pga-plugins) @@ -65,71 +66,86 @@ if (${WITH_PARMYS}) DEPENDS yosys ) - ExternalProject_Add(f4pga-plugins - # root directory for the Yosys-F4PGA-Plugins project - PREFIX "f4pga-plugins" - - GIT_REPOSITORY https://github.com/chipsalliance/yosys-f4pga-plugins.git - GIT_TAG v1.20230808 - GIT_PROGRESS TRUE - GIT_SHALLOW TRUE - - # setting source, build and install directories - SOURCE_DIR "${YOSYS_F4PGA_PLUGINS_SOURCE_DIR}" - BUILD_IN_SOURCE FALSE - INSTALL_DIR "" - - INSTALL_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND ${MAKE_PROGRAM} -C ${YOSYS_F4PGA_PLUGINS_SOURCE_DIR} - PATH=${CMAKE_BINARY_DIR}/bin/:$ENV{PATH} - UHDM_INSTALL_DIR=${CMAKE_BINARY_DIR} - BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/f4pga-plugins/$(NAME) # NAME will be resolved by yosys-f4pga-plugins Make - YOSYS_PATH=${CMAKE_BINARY_DIR} - install -j${CUSTOM_BUILD_PARALLEL_LEVEL} - - # redirect logs to a logfile - LOG_BUILD ON - LOG_UPDATE ON - LOG_INSTALL ON - LOG_CONFIGURE OFF - LOG_OUTPUT_ON_FAILURE ON - - # dependency - DEPENDS surelog yosys - ) + # Synlig integration (manages Surelog and UHDM internally) + + # Synlig integration (manages Surelog and UHDM internally) + set(SYNLIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/synlig) + + # Clone Synlig repository and ensure submodules are synced before building + ExternalProject_Add(synlig + PREFIX "synlig" + + # Clone the Synlig repository + GIT_REPOSITORY https://github.com/chipsalliance/synlig.git + GIT_TAG main + GIT_PROGRESS TRUE + GIT_SHALLOW TRUE + + # Set source and build directories + SOURCE_DIR "${SYNLIG_SOURCE_DIR}" + BUILD_IN_SOURCE FALSE + INSTALL_DIR " " + + # Sync submodules after cloning + UPDATE_COMMAND git submodule update --init --recursive third_party/surelog + WORKING_DIRECTORY ${SYNLIG_SOURCE_DIR} + + + BUILD_COMMAND ${MAKE_PROGRAM} -C ${SYNLIG_SOURCE_DIR} install DESTDIR=${CMAKE_BINARY_DIR}/bin/synlig_install -j$(nproc)#${CUSTOM_BUILD_PARALLEL_LEVEL} + INSTALL_COMMAND "" + CONFIGURE_COMMAND "" + + # Pass necessary paths and set environment variables + CMAKE_CACHE_ARGS + "-DCMAKE_BUILD_TYPE:STRING=Release" + "-DSURELOG_PATH=${CMAKE_BINARY_DIR}/surelog" + "-DYOSYS_PATH=${CMAKE_BINARY_DIR}/yosys" + "-DUHDM_INSTALL_DIR=${CMAKE_BINARY_DIR}" + "-DBUILD_DIR=${CMAKE_BINARY_DIR}/synlig-build" + "-DEXPORT_PATH=${CMAKE_BINARY_DIR}/synlig_install/usr/local/bin:$ENV{PATH}" + + LOG_BUILD ON + LOG_UPDATE ON + LOG_INSTALL ON + LOG_CONFIGURE OFF + LOG_OUTPUT_ON_FAILURE ON + + # Ensure dependencies like Yosys are built first + DEPENDS yosys # Ensure submodule sync runs before synlig build + ) + + endif () endif () -endif () -if (${VTR_ENABLE_CAPNPROTO}) - # Override default policy for capnproto (CMake policy version 3.1) - # Enable new IPO variables - set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) + if (${VTR_ENABLE_CAPNPROTO}) + # Override default policy for capnproto (CMake policy version 3.1) + # Enable new IPO variables + set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) - # Enable option overrides via variables - set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + # Enable option overrides via variables + set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - # Re-enable CXX extensions for capnproto. - set(CMAKE_CXX_EXTENSIONS ON) + # Re-enable CXX extensions for capnproto. + set(CMAKE_CXX_EXTENSIONS ON) - # Disable capnproto tests - set(BUILD_TESTING OFF) + # Disable capnproto tests + set(BUILD_TESTING OFF) - #Since capnproto is an externally developed library/tool, we suppress all compiler warnings - CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w) - if (CXX_COMPILER_SUPPORTS_-w) - add_compile_options("-w") - endif () + #Since capnproto is an externally developed library/tool, we suppress all compiler warnings + CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w) + if (CXX_COMPILER_SUPPORTS_-w) + add_compile_options("-w") + endif () - add_subdirectory(capnproto EXCLUDE_FROM_ALL) + add_subdirectory(capnproto EXCLUDE_FROM_ALL) - #Some capnproto kj headers (e.g. filesystem.h) generate warnings, treat them as system headers to suppress warnings - #We suppress them here since we include the capnproto sub-tree as is and do not modify its CMakeLists.txts - target_include_directories(kj SYSTEM INTERFACE - $ - $ - ) + #Some capnproto kj headers (e.g. filesystem.h) generate warnings, treat them as system headers to suppress warnings + #We suppress them here since we include the capnproto sub-tree as is and do not modify its CMakeLists.txts + target_include_directories(kj SYSTEM INTERFACE + $ + $ + ) endif () # Some catch2 headers generate warnings, so treat them as system headers to suppress warnings diff --git a/vtr_flow/misc/yosys/synthesis.tcl b/vtr_flow/misc/yosys/synthesis.tcl index 5015d587055..48bdfc83825 100644 --- a/vtr_flow/misc/yosys/synthesis.tcl +++ b/vtr_flow/misc/yosys/synthesis.tcl @@ -7,6 +7,7 @@ read_verilog -nomem2reg +/parmys/vtr_primitives.v setattr -mod -set keep_hierarchy 1 single_port_ram setattr -mod -set keep_hierarchy 1 dual_port_ram +set synlig $::env(synlig_exe_path) puts "Using parmys as partial mapper" # arch file: QQQ @@ -18,15 +19,15 @@ puts "Using parmys as partial mapper" parmys_arch -a QQQ if {$env(PARSER) == "surelog" } { - puts "Using Yosys read_uhdm command" - plugin -i systemverilog - yosys -import - read_uhdm XXX + puts "Using Synlig read_uhdm command" + + exec $synlig -p "read_uhdm XXX" + } elseif {$env(PARSER) == "system-verilog" } { - puts "Using Yosys read_systemverilog command" - plugin -i systemverilog - yosys -import - read_systemverilog XXX + puts "Using Synlig read_systemverilog command" + + exec $synlig -p "read_systemverilog XXX" + } elseif {$env(PARSER) == "default" } { puts "Using Yosys read_verilog command" read_verilog -sv -nolatches XXX @@ -66,7 +67,23 @@ techmap -map +/parmys/aldffe2dff.v opt -full -parmys -a QQQ -nopass -c CCC YYY +#parmys -a QQQ -nopass -c CCC YYY +#parmys -a QQQ -c CCC YYY +#memory -nomap +#flatten + + +# Separate opt for Parmys execution(verilog or system-verilog) +if {$env(PARSER) == "default"} { + puts "Running Parmys with disables additional passes " + parmys -a QQQ -nopass -c CCC YYY + +} elseif {$env(PARSER) == "system-verilog" || $env(PARSER) == "surelog"} { + puts "Running Parmys with Additional Passes Resolve Conflicts" + parmys -a QQQ -c CCC YYY + memory -nomap + flatten +} opt -full @@ -75,7 +92,6 @@ opt -fast dffunmap opt -fast -noff - #autoname stat diff --git a/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py b/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py index cef45626828..e074aa21e85 100644 --- a/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py +++ b/vtr_flow/scripts/python_libs/vtr/parmys/parmys.py @@ -232,6 +232,12 @@ def run( odin_config_full_path, ) + # Set the synlig exe script path in the environment variable(handle if it is not set or system-verilog OFF) + try: + os.environ["synlig_exe_path"] = str(vtr.paths.synlig_exe_path) + except Exception as e: + os.environ["synlig_exe_path"] = "/dummy/path" + # set the parser if parmys_args["parser"] in YOSYS_PARSERS: os.environ["PARSER"] = parmys_args["parser"] diff --git a/vtr_flow/scripts/python_libs/vtr/paths.py b/vtr_flow/scripts/python_libs/vtr/paths.py index 2df9317c81c..5f0888c328f 100644 --- a/vtr_flow/scripts/python_libs/vtr/paths.py +++ b/vtr_flow/scripts/python_libs/vtr/paths.py @@ -22,6 +22,10 @@ yosys_tcl_path = vtr_flow_path / "misc" / "yosys" yosys_script_path = yosys_tcl_path / "synthesis.tcl" +# Synlig paths +synlig_path = root_path/"build"/"bin"/"synlig_install" +synlig_exe_path = synlig_path / "usr"/"local"/"bin"/"synlig" + # PARMYS paths parmys_path = root_path / "parmys" parmys_verify_path = parmys_path / "verify_parmys.sh"