Skip to content

Commit ec618c0

Browse files
committed
synlig, new system verilog tool integration [build system + tcl + parmys + paths updated]
1 parent ce706d5 commit ec618c0

File tree

5 files changed

+113
-71
lines changed

5 files changed

+113
-71
lines changed

.github/workflows/nightly_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
# Prevents from running on forks where no custom runners are available
4242
if: ${{ github.repository_owner == 'verilog-to-routing' }}
4343

44-
timeout-minutes: 420
44+
timeout-minutes: 700 #420
4545

4646
container: ubuntu:jammy
4747

@@ -65,7 +65,7 @@ jobs:
6565
- {test: "vtr_reg_strong", cores: "16", options: "", cmake: "-DVTR_ASSERT_LEVEL=3", extra_pkgs: "libeigen3-dev"}
6666
- {test: "vtr_reg_strong_odin", cores: "16", options: "", cmake: "-DVTR_ASSERT_LEVEL=3 -DWITH_ODIN=ON", extra_pkgs: "libeigen3-dev"}
6767
- {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"}
68-
# - {test: "vtr_reg_system_verilog", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=ON", extra_pkgs: ""} # Test turned off -> F4PGA conflicts with Yosys (version 42)
68+
- {test: "vtr_reg_system_verilog", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=ON", extra_pkgs: ""} # Test turned off -> F4PGA conflicts with Yosys (version 42)
6969
- {test: "odin_reg_strong", cores: "16", options: "", cmake: "-DWITH_ODIN=ON", extra_pkgs: ""}
7070
- {test: "parmys_reg_strong", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=OFF", extra_pkgs: ""}
7171

libs/EXTERNAL/CMakeLists.txt

Lines changed: 75 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ endif ()
2727

2828
# The VTR root CMakeFile initializes the WITH_PARMYS
2929
if (${WITH_PARMYS})
30-
# building Surelog and UHDM in a custom target to avoid any target conflict with VTR targets
31-
if (${YOSYS_F4PGA_PLUGINS})
32-
set(SURELOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Surelog)
30+
31+
if (${WITH_PARMYS})
32+
33+
set(SURELOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Surelog)
3334
set(SURELOG_BINARY_DIR ${SURELOG_SOURCE_DIR}/build)
3435
set(YOSYS_F4PGA_PLUGINS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yosys-f4pga-plugins)
3536

@@ -65,71 +66,86 @@ if (${WITH_PARMYS})
6566
DEPENDS yosys
6667
)
6768

68-
ExternalProject_Add(f4pga-plugins
69-
# root directory for the Yosys-F4PGA-Plugins project
70-
PREFIX "f4pga-plugins"
71-
72-
GIT_REPOSITORY https://github.com/chipsalliance/yosys-f4pga-plugins.git
73-
GIT_TAG v1.20230808
74-
GIT_PROGRESS TRUE
75-
GIT_SHALLOW TRUE
76-
77-
# setting source, build and install directories
78-
SOURCE_DIR "${YOSYS_F4PGA_PLUGINS_SOURCE_DIR}"
79-
BUILD_IN_SOURCE FALSE
80-
INSTALL_DIR ""
81-
82-
INSTALL_COMMAND ""
83-
CONFIGURE_COMMAND ""
84-
BUILD_COMMAND ${MAKE_PROGRAM} -C ${YOSYS_F4PGA_PLUGINS_SOURCE_DIR}
85-
PATH=${CMAKE_BINARY_DIR}/bin/:$ENV{PATH}
86-
UHDM_INSTALL_DIR=${CMAKE_BINARY_DIR}
87-
BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR}/f4pga-plugins/$(NAME) # NAME will be resolved by yosys-f4pga-plugins Make
88-
YOSYS_PATH=${CMAKE_BINARY_DIR}
89-
install -j${CUSTOM_BUILD_PARALLEL_LEVEL}
90-
91-
# redirect logs to a logfile
92-
LOG_BUILD ON
93-
LOG_UPDATE ON
94-
LOG_INSTALL ON
95-
LOG_CONFIGURE OFF
96-
LOG_OUTPUT_ON_FAILURE ON
97-
98-
# dependency
99-
DEPENDS surelog yosys
100-
)
69+
# Synlig integration (manages Surelog and UHDM internally)
70+
71+
# Synlig integration (manages Surelog and UHDM internally)
72+
set(SYNLIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/synlig)
73+
74+
# Clone Synlig repository and ensure submodules are synced before building
75+
ExternalProject_Add(synlig
76+
PREFIX "synlig"
77+
78+
# Clone the Synlig repository
79+
GIT_REPOSITORY https://github.com/chipsalliance/synlig.git
80+
GIT_TAG main
81+
GIT_PROGRESS TRUE
82+
GIT_SHALLOW TRUE
83+
84+
# Set source and build directories
85+
SOURCE_DIR "${SYNLIG_SOURCE_DIR}"
86+
BUILD_IN_SOURCE FALSE
87+
INSTALL_DIR " "
88+
89+
# Sync submodules after cloning
90+
UPDATE_COMMAND git submodule update --init --recursive third_party/surelog
91+
WORKING_DIRECTORY ${SYNLIG_SOURCE_DIR}
92+
93+
94+
BUILD_COMMAND ${MAKE_PROGRAM} -C ${SYNLIG_SOURCE_DIR} install DESTDIR=${CMAKE_BINARY_DIR}/bin/synlig_install -j$(nproc)#${CUSTOM_BUILD_PARALLEL_LEVEL}
95+
INSTALL_COMMAND ""
96+
CONFIGURE_COMMAND ""
97+
98+
# Pass necessary paths and set environment variables
99+
CMAKE_CACHE_ARGS
100+
"-DCMAKE_BUILD_TYPE:STRING=Release"
101+
"-DSURELOG_PATH=${CMAKE_BINARY_DIR}/surelog"
102+
"-DYOSYS_PATH=${CMAKE_BINARY_DIR}/yosys"
103+
"-DUHDM_INSTALL_DIR=${CMAKE_BINARY_DIR}"
104+
"-DBUILD_DIR=${CMAKE_BINARY_DIR}/synlig-build"
105+
"-DEXPORT_PATH=${CMAKE_BINARY_DIR}/synlig_install/usr/local/bin:$ENV{PATH}"
106+
107+
LOG_BUILD ON
108+
LOG_UPDATE ON
109+
LOG_INSTALL ON
110+
LOG_CONFIGURE OFF
111+
LOG_OUTPUT_ON_FAILURE ON
112+
113+
# Ensure dependencies like Yosys are built first
114+
DEPENDS yosys # Ensure submodule sync runs before synlig build
115+
)
116+
117+
endif ()
101118
endif ()
102119

103-
endif ()
104120

105-
if (${VTR_ENABLE_CAPNPROTO})
106-
# Override default policy for capnproto (CMake policy version 3.1)
107-
# Enable new IPO variables
108-
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
121+
if (${VTR_ENABLE_CAPNPROTO})
122+
# Override default policy for capnproto (CMake policy version 3.1)
123+
# Enable new IPO variables
124+
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
109125

110-
# Enable option overrides via variables
111-
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
126+
# Enable option overrides via variables
127+
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
112128

113-
# Re-enable CXX extensions for capnproto.
114-
set(CMAKE_CXX_EXTENSIONS ON)
129+
# Re-enable CXX extensions for capnproto.
130+
set(CMAKE_CXX_EXTENSIONS ON)
115131

116-
# Disable capnproto tests
117-
set(BUILD_TESTING OFF)
132+
# Disable capnproto tests
133+
set(BUILD_TESTING OFF)
118134

119-
#Since capnproto is an externally developed library/tool, we suppress all compiler warnings
120-
CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w)
121-
if (CXX_COMPILER_SUPPORTS_-w)
122-
add_compile_options("-w")
123-
endif ()
135+
#Since capnproto is an externally developed library/tool, we suppress all compiler warnings
136+
CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w)
137+
if (CXX_COMPILER_SUPPORTS_-w)
138+
add_compile_options("-w")
139+
endif ()
124140

125-
add_subdirectory(capnproto EXCLUDE_FROM_ALL)
141+
add_subdirectory(capnproto EXCLUDE_FROM_ALL)
126142

127-
#Some capnproto kj headers (e.g. filesystem.h) generate warnings, treat them as system headers to suppress warnings
128-
#We suppress them here since we include the capnproto sub-tree as is and do not modify its CMakeLists.txts
129-
target_include_directories(kj SYSTEM INTERFACE
130-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/capnproto/c++/src>
131-
$<INSTALL_INTERFACE:include>
132-
)
143+
#Some capnproto kj headers (e.g. filesystem.h) generate warnings, treat them as system headers to suppress warnings
144+
#We suppress them here since we include the capnproto sub-tree as is and do not modify its CMakeLists.txts
145+
target_include_directories(kj SYSTEM INTERFACE
146+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/capnproto/c++/src>
147+
$<INSTALL_INTERFACE:include>
148+
)
133149
endif ()
134150

135151
# Some catch2 headers generate warnings, so treat them as system headers to suppress warnings

vtr_flow/misc/yosys/synthesis.tcl

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ read_verilog -nomem2reg +/parmys/vtr_primitives.v
77
setattr -mod -set keep_hierarchy 1 single_port_ram
88
setattr -mod -set keep_hierarchy 1 dual_port_ram
99

10+
set synlig $::env(synlig_exe_path)
1011
puts "Using parmys as partial mapper"
1112

1213
# arch file: QQQ
@@ -18,15 +19,15 @@ puts "Using parmys as partial mapper"
1819
parmys_arch -a QQQ
1920

2021
if {$env(PARSER) == "surelog" } {
21-
puts "Using Yosys read_uhdm command"
22-
plugin -i systemverilog
23-
yosys -import
24-
read_uhdm XXX
22+
puts "Using Synlig read_uhdm command"
23+
24+
exec $synlig -p "read_uhdm XXX"
25+
2526
} elseif {$env(PARSER) == "system-verilog" } {
26-
puts "Using Yosys read_systemverilog command"
27-
plugin -i systemverilog
28-
yosys -import
29-
read_systemverilog XXX
27+
puts "Using Synlig read_systemverilog command"
28+
29+
exec $synlig -p "read_systemverilog XXX"
30+
3031
} elseif {$env(PARSER) == "default" } {
3132
puts "Using Yosys read_verilog command"
3233
read_verilog -sv -nolatches XXX
@@ -66,7 +67,23 @@ techmap -map +/parmys/aldffe2dff.v
6667

6768
opt -full
6869

69-
parmys -a QQQ -nopass -c CCC YYY
70+
#parmys -a QQQ -nopass -c CCC YYY
71+
#parmys -a QQQ -c CCC YYY
72+
#memory -nomap
73+
#flatten
74+
75+
76+
# Separate opt for Parmys execution(verilog or system-verilog)
77+
if {$env(PARSER) == "default"} {
78+
puts "Running Parmys with disables additional passes "
79+
parmys -a QQQ -nopass -c CCC YYY
80+
81+
} elseif {$env(PARSER) == "system-verilog" || $env(PARSER) == "surelog"} {
82+
puts "Running Parmys with Additional Passes Resolve Conflicts"
83+
parmys -a QQQ -c CCC YYY
84+
memory -nomap
85+
flatten
86+
}
7087

7188
opt -full
7289

@@ -75,7 +92,6 @@ opt -fast
7592

7693
dffunmap
7794
opt -fast -noff
78-
7995
#autoname
8096

8197
stat

vtr_flow/scripts/python_libs/vtr/parmys/parmys.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ def run(
232232
odin_config_full_path,
233233
)
234234

235+
# Set the synlig exe script path in the environment variable(handle if it is not set or system-verilog OFF)
236+
try:
237+
os.environ["synlig_exe_path"] = str(vtr.paths.synlig_exe_path)
238+
except Exception as e:
239+
os.environ["synlig_exe_path"] = "/dummy/path"
240+
235241
# set the parser
236242
if parmys_args["parser"] in YOSYS_PARSERS:
237243
os.environ["PARSER"] = parmys_args["parser"]

vtr_flow/scripts/python_libs/vtr/paths.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
yosys_tcl_path = vtr_flow_path / "misc" / "yosys"
2323
yosys_script_path = yosys_tcl_path / "synthesis.tcl"
2424

25+
# Synlig paths
26+
synlig_path = root_path/"build"/"bin"/"synlig_install"
27+
synlig_exe_path = synlig_path / "usr"/"local"/"bin"/"synlig"
28+
2529
# PARMYS paths
2630
parmys_path = root_path / "parmys"
2731
parmys_verify_path = parmys_path / "verify_parmys.sh"

0 commit comments

Comments
 (0)