Skip to content

Commit

Permalink
synlig, new system verilog tool integration [build system + tcl + par…
Browse files Browse the repository at this point in the history
…mys + paths updated]
  • Loading branch information
amirarjmand93 committed Dec 8, 2024
1 parent ce706d5 commit ec618c0
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nightly_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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: ""}

Expand Down
134 changes: 75 additions & 59 deletions libs/EXTERNAL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/capnproto/c++/src>
$<INSTALL_INTERFACE:include>
)
#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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/capnproto/c++/src>
$<INSTALL_INTERFACE:include>
)
endif ()

# Some catch2 headers generate warnings, so treat them as system headers to suppress warnings
Expand Down
36 changes: 26 additions & 10 deletions vtr_flow/misc/yosys/synthesis.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -75,7 +92,6 @@ opt -fast

dffunmap
opt -fast -noff

#autoname

stat
Expand Down
6 changes: 6 additions & 0 deletions vtr_flow/scripts/python_libs/vtr/parmys/parmys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions vtr_flow/scripts/python_libs/vtr/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ec618c0

Please sign in to comment.