Skip to content

Commit f28f06e

Browse files
authored
Merge pull request #2841 from verilog-to-routing/vtr+synlig
Synlig, new system-verilog tool integration
2 parents 7829f79 + 418d782 commit f28f06e

File tree

20 files changed

+747
-92
lines changed

20 files changed

+747
-92
lines changed

.github/workflows/nightly_test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ 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: "-DSYNLIG_SYSTEMVERILOG=ON", extra_pkgs: ""}
6969
- {test: "odin_reg_strong", cores: "16", options: "", cmake: "-DWITH_ODIN=ON", extra_pkgs: ""}
70-
- {test: "parmys_reg_strong", cores: "16", options: "", cmake: "-DYOSYS_F4PGA_PLUGINS=OFF", extra_pkgs: ""}
70+
- {test: "parmys_reg_strong", cores: "16", options: "", cmake: "-DSYNLIG_SYSTEMVERILOG=ON", extra_pkgs: ""}
7171

7272
env:
7373
DEBIAN_FRONTEND: "noninteractive"

.gitpod.Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ RUN apt-get update \
3030
python-lxml \
3131
qt5-default \
3232
wget \
33+
default-jre \
3334
&& apt-get clean \
3435
&& rm -rf /var/lib/apt/lists/*
3536

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ option(ODIN_SANITIZE "Enable building odin with sanitize flags" OFF)
6060

6161
# Allow the user to enable building Yosys
6262
option(WITH_PARMYS "Enable Yosys as elaborator and parmys-plugin as partial mapper" ON)
63-
option(YOSYS_F4PGA_PLUGINS "Enable building and installing Yosys SystemVerilog and UHDM plugins" OFF)
63+
option(SYNLIG_SYSTEMVERILOG "Enable building and installing Synlig SystemVerilog and UHDM plugins" OFF)
6464

6565
set(VTR_VERSION_MAJOR 9)
6666
set(VTR_VERSION_MINOR 0)
@@ -453,7 +453,7 @@ if(${WITH_ODIN})
453453
endif()
454454

455455
# handle cmake params to compile Yosys SystemVerilog/UHDM plugins
456-
if(${YOSYS_F4PGA_PLUGINS})
456+
if(${SYNLIG_SYSTEMVERILOG})
457457
# avoid compiling plugins in case the Parmys frontend is not active
458458
if(NOT ${WITH_PARMYS})
459459
message(SEND_ERROR "Utilizing SystemVerilog/UHDM plugins requires activating Parmys frontend. Please set WITH_PARMYS.")

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN apt-get update -qq \
1515
&& apt-get -y install --no-install-recommends \
1616
wget \
1717
ninja-build \
18+
default-jre \
1819
libeigen3-dev \
1920
libtbb-dev \
2021
python3-pip \

doc/src/parmys/quickstart.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ To build the VTR flow with the Parmys front-end you may use the VTR Makefile wra
3737

3838
.. note::
3939

40-
Compiling the VTR flow with the ``-DYOSYS_F4PGA_PLUGINS=ON`` flag is required to build and install Yosys SystemVerilog and UHDM plugins.
41-
Using this compile flag, the `Yosys-F4PGA-Plugins <https://github.com/chipsalliance/yosys-f4pga-plugins>`_ and `Surelog <https://github.com/chipsalliance/Surelog>`_ repositories are cloned in the ``$VTR_ROOT/libs/EXTERNAL`` directory and then will be compiled and added as external plugins to the Parmys front-end.
40+
Compiling the VTR flow with the ``-DSynlig_SystemVerilog=ON`` flag is required to build and install Synlig SystemVerilog and UHDM plugins.
41+
Using this compile flag, the `Synlig_SystemVerilog <https://github.com/chipsalliance/synlig>`_ repository is cloned and installed in the ``$VTR_ROOT/build/bin`` directory and then will be compiled and added as external tool to the Parmys front-end.
4242

4343
Basic Usage
4444
-----------

doc/src/vtr/run_vtr_flow.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ The parser for these runs is considered the Yosys conventional Verilog/SystemVer
7373

7474
.. code-block:: bash
7575
76-
# Using the Yosys-SystemVerilog plugin if installed, otherwise the Yosys conventional Verilog parser
76+
# Using the Synlig System_Verilog tool if installed, otherwise the Yosys conventional Verilog parser
7777
./run_vtr_flow <path/to/SystemVerilog/File> <path/to/arch/file> -parser system-verilog
7878
7979
# Using the Surelog plugin if installed, otherwise failure on the unsupported file type
8080
./run_vtr_flow <path/to/UHDM/File> <path/to/arch/file> -parser surelog
8181
8282
Running the default VTR flow using the Parmys standalone front-end.
83-
The Yosys HDL parser is considered as Yosys-SystemVerilog plugin (i.e., ``read_systemverilog``) and Yosys UHDM plugin (i.e., ``read_uhdm``), respectively.
84-
Utilizing Yosys plugins requires passing the ``-DYOSYS_F4PGA_PLUGINS=ON`` compile flag to build and install the plugins for the Parmys front-end.
83+
The Synlig HDL parser supports the (i.e., ``read_systemverilog``) and (i.e., ``read_uhdm``) commands. It utilizes Surelog for SystemVerilog 2017 processing and Yosys for synthesis.
84+
Enable Synlig tool with the ``-DSYNLIG_SYSTEMVERILOG=ON`` compile flag for the Parmys front-end.
8585

8686
.. code-block:: bash
8787

install_apt_packages.sh

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ sudo apt-get install -y \
3434
libboost-system-dev \
3535
libboost-python-dev \
3636
libboost-filesystem-dev \
37+
default-jre \
3738
zlib1g-dev
3839

3940
# Required to build the documentation

libs/EXTERNAL/CMakeLists.txt

+85-58
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(ExternalProject)
2+
include(ProcessorCount)
23

34
#Manually synchronized external libraries
45
add_subdirectory(libpugixml)
@@ -9,8 +10,17 @@ add_subdirectory(libsdcparse)
910
add_subdirectory(libblifparse)
1011
add_subdirectory(libtatum)
1112
add_subdirectory(libcatch2)
13+
#add_subdirectory(synlig)
1214
#add_subdirectory(parmys)
1315

16+
#Proc numbers
17+
ProcessorCount(PROCESSOR_COUNT)
18+
19+
if(PROCESSOR_COUNT EQUAL 0)
20+
# Fallback to 1 if the processor count cannot be determined
21+
set(PROCESSOR_COUNT 1)
22+
endif()
23+
1424
#VPR_USE_SERVER is initialized in the root CMakeLists
1525
#compile sockpp only if server mode is enabled
1626
if (VPR_USE_SERVER)
@@ -27,8 +37,9 @@ endif ()
2737

2838
# The VTR root CMakeFile initializes the WITH_PARMYS
2939
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})
40+
41+
if (${SYNLIG_SYSTEMVERILOG})
42+
3243
set(SURELOG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Surelog)
3344
set(SURELOG_BINARY_DIR ${SURELOG_SOURCE_DIR}/build)
3445
set(YOSYS_F4PGA_PLUGINS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yosys-f4pga-plugins)
@@ -62,74 +73,90 @@ if (${WITH_PARMYS})
6273
LOG_OUTPUT_ON_FAILURE ON
6374

6475
# dependency
65-
DEPENDS yosys
76+
DEPENDS yosys
6677
)
6778

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
79+
# Synlig integration (manages Surelog and UHDM internally)
80+
81+
# Synlig integration (manages Surelog and UHDM internally)
82+
set(SYNLIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/synlig)
83+
84+
# Clone Synlig repository and ensure submodules are synced before building
85+
ExternalProject_Add(synlig
86+
PREFIX "synlig"
87+
88+
# Clone the Synlig repository
89+
GIT_REPOSITORY https://github.com/chipsalliance/synlig.git
90+
GIT_TAG main
91+
GIT_PROGRESS TRUE
92+
GIT_SHALLOW TRUE
93+
94+
# Set source and build directories
95+
SOURCE_DIR "${SYNLIG_SOURCE_DIR}"
96+
BUILD_IN_SOURCE FALSE
97+
INSTALL_DIR " "
98+
99+
# Sync submodules after cloning
100+
101+
102+
UPDATE_COMMAND git submodule update --init --recursive third_party/surelog
103+
WORKING_DIRECTORY ${SYNLIG_SOURCE_DIR}
104+
105+
BUILD_COMMAND ${MAKE_PROGRAM} -C ${SYNLIG_SOURCE_DIR} install DESTDIR=${CMAKE_BINARY_DIR}/bin/synlig_install -j${PROCESSOR_COUNT}
106+
INSTALL_COMMAND ""
107+
CONFIGURE_COMMAND ""
108+
109+
# Pass necessary paths and set environment variables
110+
CMAKE_CACHE_ARGS
111+
"-DCMAKE_BUILD_TYPE:STRING=Release"
112+
"-DSURELOG_PATH=${CMAKE_BINARY_DIR}/surelog"
113+
"-DYOSYS_PATH=${CMAKE_BINARY_DIR}/yosys"
114+
"-DUHDM_INSTALL_DIR=${CMAKE_BINARY_DIR}"
115+
"-DBUILD_DIR=${CMAKE_BINARY_DIR}/synlig-build"
116+
"-DEXPORT_PATH=${CMAKE_BINARY_DIR}/synlig_install/usr/local/bin:$ENV{PATH}"
117+
118+
LOG_BUILD ON
119+
LOG_UPDATE ON
120+
LOG_INSTALL ON
121+
LOG_CONFIGURE OFF
122+
LOG_OUTPUT_ON_FAILURE ON
123+
124+
# Ensure dependencies like Yosys are built first
125+
DEPENDS yosys # Ensure submodule sync runs before synlig build
126+
)
97127

98-
# dependency
99-
DEPENDS surelog yosys
100-
)
101128
endif ()
102-
103129
endif ()
104130

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)
109131

110-
# Enable option overrides via variables
111-
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
132+
if (${VTR_ENABLE_CAPNPROTO})
133+
# Override default policy for capnproto (CMake policy version 3.1)
134+
# Enable new IPO variables
135+
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
112136

113-
# Re-enable CXX extensions for capnproto.
114-
set(CMAKE_CXX_EXTENSIONS ON)
137+
# Enable option overrides via variables
138+
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
115139

116-
# Disable capnproto tests
117-
set(BUILD_TESTING OFF)
140+
# Re-enable CXX extensions for capnproto.
141+
set(CMAKE_CXX_EXTENSIONS ON)
118142

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 ()
143+
# Disable capnproto tests
144+
set(BUILD_TESTING OFF)
124145

125-
add_subdirectory(capnproto EXCLUDE_FROM_ALL)
146+
#Since capnproto is an externally developed library/tool, we suppress all compiler warnings
147+
CHECK_CXX_COMPILER_FLAG("-w" CXX_COMPILER_SUPPORTS_-w)
148+
if (CXX_COMPILER_SUPPORTS_-w)
149+
add_compile_options("-w")
150+
endif ()
126151

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-
)
152+
add_subdirectory(capnproto EXCLUDE_FROM_ALL)
153+
154+
#Some capnproto kj headers (e.g. filesystem.h) generate warnings, treat them as system headers to suppress warnings
155+
#We suppress them here since we include the capnproto sub-tree as is and do not modify its CMakeLists.txts
156+
target_include_directories(kj SYSTEM INTERFACE
157+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/capnproto/c++/src>
158+
$<INSTALL_INTERFACE:include>
159+
)
133160
endif ()
134161

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

vtr_flow/benchmarks/system_verilog/f4pga/README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,14 @@ This folder contains the `button_controller`, `pulse_width_led` and `timer` benc
44
The benchmarks are directly copied to avoid dealing with a significant amount of code by adding the F4PGA repository as a subtree to the VTR repository.
55
The primary purpose of these benchmarks is to utilize them in VTR GitHub CI tests to continuously monitor the functionality of the Yosys SystemVerilog and UHDM plugins.
66

7-
For more information please see the ['ChipsAlliance/F4PGA'](https://github.com/chipsalliance/f4pga) Github repository.
7+
For more information please see the ['ChipsAlliance/F4PGA'](https://github.com/chipsalliance/f4pga) Github repository.
8+
9+
## SystemVerilog File Flattening with `make_sv_flattened.py`
10+
11+
The current SystemVerilog tool, **Synlig**, cannot process multiple files as input (e.g., a top module and its dependencies). To address this limitation, use the script `make_sv_flattened.py` to flatten the files into a single SystemVerilog file. This will convert any design with dependencies into one flattened SystemVerilog file, ensuring compatibility with Synlig.
12+
13+
### Instructions:
14+
1. Ensure the `make_sv_flattened.py` script is located in the folder where your SystemVerilog files (e.g., the top module and its dependencies) are gathered.
15+
2. Run the `make_sv_flattened.py` script on the gathered files in that folder.
16+
3. The script will output a single flattened SystemVerilog file, ready for use with Synlig.
17+

0 commit comments

Comments
 (0)