Skip to content

Switching from Synlig to Yosys-Slang #3181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4f8abac
Added in yosys-slang as a submodule and configured it to build and in…
loglav03 Jun 26, 2025
efb1d87
Set up yosys-slang to be used as a frontend for Yosys
loglav03 Jun 27, 2025
90e180b
Fully implemented yosys-slang as a plugin for yosys
loglav03 Jul 3, 2025
c1c2a5d
Updating configs for vtr_reg_system_verilog tests. They now read in m…
loglav03 Jul 3, 2025
7c4c868
Merge branch 'master' into synlig_to_yosys_slang
loglav03 Jul 3, 2025
0152c36
Adding SystemVerilog reg test to CI
loglav03 Jul 3, 2025
f7ae912
Trying to fix issue with install dependencies for SystemVerilog Regre…
loglav03 Jul 3, 2025
81b7ee4
Fixing regression test run failures due to yosys-slang plugin being l…
loglav03 Jul 4, 2025
ce26e71
Fixing code format in python script (python.cc) and resolving conflic…
loglav03 Jul 7, 2025
d2ffe14
Further resolving conflicts with test.yml
loglav03 Jul 7, 2025
172758b
Further resolving conflicts with test.yml
loglav03 Jul 7, 2025
0b1d2c0
Merge branch 'master' into synlig_to_yosys_slang
loglav03 Jul 7, 2025
9b51cbc
Fixing line format errors in parmys.cc
loglav03 Jul 7, 2025
8d8d683
Further fixing line format/length errors in parmys.cc
loglav03 Jul 7, 2025
2d107fb
Further fixing line format/length errors in parmys.cc
loglav03 Jul 7, 2025
3cf1050
Updating parser documentation for run_vtr_flow to replace synlig/sure…
loglav03 Jul 7, 2025
3fbe39f
Cleaning up some code in synthesis.tcl
loglav03 Jul 8, 2025
56b7a7d
Further cleaning up code and adding some comments
loglav03 Jul 9, 2025
9383300
Split the file extension checking and filelist building for yosys sla…
loglav03 Jul 10, 2025
b842759
Removed commented out cmake option for SYNLING_SYSTEMVERILOG
loglav03 Jul 10, 2025
1d7a5cb
Added SystemVerilog CI test. Enabled yosys-slang by default in build …
loglav03 Jul 10, 2025
7f6749c
Disabling yosys-slang whenever parmys is disabled.
loglav03 Jul 10, 2025
ff0795c
Cleaned up compilation handling for yosys-slang when parmys is turned…
loglav03 Jul 11, 2025
a4090df
Suppressing warnings in yosys-slang and yosys
loglav03 Jul 11, 2025
09d5e6f
Attempting to further suppress warnings for yosys-slang build
loglav03 Jul 11, 2025
787af05
Attempting to further suppress warnings for yosys-slang build
loglav03 Jul 11, 2025
341a972
Added header explanation to patch_slang.cmake
loglav03 Jul 11, 2025
0cda1bf
Added koios_sv/deepfreeze.style1.sv to vtr_reg_system_verilog and cre…
loglav03 Jul 11, 2025
6d7abd0
Fixed enherited threads issue with yosys-slang build
loglav03 Jul 14, 2025
3bcef9a
Attempting to suppress warnings for slang again, and added vtr_reg_sy…
loglav03 Jul 14, 2025
ddd28fa
Fixed build issue with yosys-slang not installing plugin in correct l…
loglav03 Jul 14, 2025
88d2b5c
Further attempting to suppress build warnings for yosys-slang
loglav03 Jul 14, 2025
d447f4a
Further attempting to suppress build warnings for yosys-slang
loglav03 Jul 14, 2025
42c7d0e
Further attempting to suppress build warnings for yosys-slang
loglav03 Jul 14, 2025
dfe45d2
Further attempting to suppress build warnings for yosys-slang
loglav03 Jul 14, 2025
5c78ad6
Further attempting to suppress build warnings for yosys-slang
loglav03 Jul 14, 2025
ceb49e1
Removing unused variable for yosys-slang build
loglav03 Jul 14, 2025
52431fb
Turning LOG_BUILD off for yosys-slang build to avoid cmake errors
loglav03 Jul 14, 2025
3b2c0a8
Merge branch 'master' into synlig_to_yosys_slang
AlexandreSinger Jul 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ jobs:
name: 'Strong',
suite: 'vtr_reg_strong'
},
{
name: 'SystemVerilog',
suite: 'vtr_reg_system_verilog'
},
{
name: 'Valgrind Memory',
suite: 'vtr_reg_valgrind_small'
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "libs/EXTERNAL/yosys"]
path = libs/EXTERNAL/yosys
url = https://github.com/YosysHQ/yosys.git
[submodule "libs/EXTERNAL/yosys-slang"]
path = libs/EXTERNAL/yosys-slang
url = https://github.com/povik/yosys-slang.git
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ option(ODIN_SANITIZE "Enable building odin with sanitize flags" OFF)

# Allow the user to enable building Yosys
option(WITH_PARMYS "Enable Yosys as elaborator and parmys-plugin as partial mapper" ON)
option(SYNLIG_SYSTEMVERILOG "Enable building and installing Synlig SystemVerilog and UHDM plugins" OFF)
option(SLANG_SYSTEMVERILOG "Enable building and installing Yosys-Slang plugin for parsing SystemVerilog" ON)

set(VTR_VERSION_MAJOR 9)
set(VTR_VERSION_MINOR 0)
Expand Down Expand Up @@ -437,11 +437,12 @@ if(${WITH_ODIN})
endif()
endif()

# handle cmake params to compile Yosys SystemVerilog/UHDM plugins
if(${SYNLIG_SYSTEMVERILOG})
# avoid compiling plugins in case the Parmys frontend is not active
# handle cmake params to compile yosys-slang plugin for Yosys
if(${SLANG_SYSTEMVERILOG})
# avoid compiling yosys-slang plugin in case the Parmys frontend is not active
if(NOT ${WITH_PARMYS})
message(SEND_ERROR "Utilizing SystemVerilog/UHDM plugins requires activating Parmys frontend. Please set WITH_PARMYS.")
message(WARNING "Parmys is not enabled, disabling Yosys-Slang as well.")
set(SLANG_SYSTEMVERILOG OFF)
endif()
endif()

Expand Down
4 changes: 4 additions & 0 deletions dev/vtr_test_suite_verifier/test_suites_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"name": "parmys_reg_basic",
"ignored_tasks": []
},
{
"name": "vtr_reg_system_verilog",
"ignored_tasks": []
},
{
"name": "vtr_reg_valgrind_small",
"ignored_tasks": []
Expand Down
30 changes: 16 additions & 14 deletions doc/src/vtr/run_vtr_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,12 @@ The parser for these runs is considered the Yosys conventional Verilog/SystemVer

.. code-block:: bash

# Using the Synlig System_Verilog tool if installed, otherwise the Yosys conventional Verilog parser
./run_vtr_flow <path/to/SystemVerilog/File> <path/to/arch/file> -parser system-verilog

# Using the Surelog plugin if installed, otherwise failure on the unsupported file type
./run_vtr_flow <path/to/UHDM/File> <path/to/arch/file> -parser surelog
# Using the Yosys-Slang plugin for Yosys, otherwise the Yosys conventional Verilog parser
./run_vtr_flow <path/to/SystemVerilog/File> <path/to/arch/file> -parser slang

Running the default VTR flow using the Parmys standalone front-end.
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.
Enable Synlig tool with the ``-DSYNLIG_SYSTEMVERILOG=ON`` compile flag for the Parmys front-end.
Will run the VTR flow (default configuration) with Yosys-Slang plugin for Yosys frontend using Parmys plugin as partial mapper.
The Yosys-Slang SystemVerilog parser supports the (i.e., ``read_slang``) command. Yosys-Slang builds on top of the slang library to provide comprehensive SystemVerilog support.
Enable the Yosys-Slang plugin with the ``-DSLANG_SYSTEMVERILOG=ON`` compile flag for the Parmys front-end.

.. code-block:: bash

Expand Down Expand Up @@ -260,19 +257,24 @@ Detailed Command-line Options

.. option:: -parser <PARSER>

Specify a parser for the Yosys synthesizer [default (Verilog-2005), surelog (UHDM), system-verilog].
Specify a parser for the Yosys synthesizer [default (Verilog-2005), slang (SystemVerilog)].
The script uses the default conventional Verilog parser if this argument is not used.

**Default:** default

.. note::

Universal Hardware Data Model (UHDM) is a complete modeling of the IEEE SystemVerilog Object Model with VPI Interface, Elaborator, Serialization, Visitor and Listener.
UHDM is used as a compiled interchange format in between SystemVerilog tools. Typical inputs to the UHDM flow are files with ``.v`` or ``.sv`` extensions.
The ``system-verilog`` parser, which represents the ``read_systemverilog`` command, reads SystemVerilog files directly in Yosys.
It executes Surelog with provided filenames and converts them (in memory) into UHDM file. Then, this UHDM file is converted into Yosys AST. `[Yosys-SystemVerilog] <https://github.com/antmicro/yosys-systemverilog#usage>`_
On the other hand, the ``surelog`` parser, which uses the ``read_uhdm`` Yosys command, walks the design tree and converts its nodes into Yosys AST nodes using Surelog. `[UHDM-Yosys <https://github.com/chipsalliance/UHDM-integration-tests#uhdm-yosys>`_, `Surelog] <https://github.com/chipsalliance/Surelog#surelog>`_
Yosys-Slang is a Yosys plugin that is built on top of the slang library to provide comprehensive SystemVerilog support.
It supports the ``read_slang`` command, used with the ``-C`` command-line option to read include-files from a text file containing include-file names.
It is used to read SystemVerilog files directly in Yosys.
For more information on Yosys-Slang, see `[Yosys-Slang] <https://github.com/povik/yosys-slang.git>`_

.. note::

Parmys is a Yosys plugin which provides intelligent partial mapping features (inference, binding, and hard/soft logic trade-offs) from Odin-II for Yosys. For more information on available paramters see the `Parmys <https://github.com/CAS-Atlantic/parmys-plugin.git>`_ plugin page.

.. Universal Hardware Data Model (UHDM) is a complete modeling of the IEEE SystemVerilog Object Model with VPI Interface, Elaborator, Serialization, Visitor and Listener.
.. UHDM is used as a compiled interchange format in between SystemVerilog tools. Typical inputs to the UHDM flow are files with ``.v`` or ``.sv`` extensions.
.. The ``system-verilog`` parser, which represents the ``read_systemverilog`` command, reads SystemVerilog files directly in Yosys.
.. It executes Surelog with provided filenames and converts them (in memory) into UHDM file. Then, this UHDM file is converted into Yosys AST. `[Yosys-SystemVerilog] <https://github.com/antmicro/yosys-systemverilog#usage>`_
.. On the other hand, the ``surelog`` parser, which uses the ``read_uhdm`` Yosys command, walks the design tree and converts its nodes into Yosys AST nodes using Surelog. `[UHDM-Yosys <https://github.com/chipsalliance/UHDM-integration-tests#uhdm-yosys>`_, `Surelog] <https://github.com/chipsalliance/Surelog#surelog>`_
126 changes: 42 additions & 84 deletions libs/EXTERNAL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include(ExternalProject)
include(ProcessorCount)

find_package(Git REQUIRED)

#Manually synchronized external libraries
add_subdirectory(libpugixml)

Expand All @@ -10,7 +12,6 @@ add_subdirectory(libsdcparse)
add_subdirectory(libblifparse)
add_subdirectory(libtatum)
add_subdirectory(libcatch2)
#add_subdirectory(synlig)
#add_subdirectory(parmys)

#Proc numbers
Expand Down Expand Up @@ -60,11 +61,11 @@ if (${WITH_PARMYS})

#Initialize yosys submodules
execute_process(
COMMAND git submodule update --init
COMMAND ${GIT_EXECUTABLE} submodule update --init
WORKING_DIRECTORY ${YOSYS_SRC_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule foreach --recursive git\ submodule\ update\ --init
COMMAND ${GIT_EXECUTABLE} submodule foreach --recursive ${GIT_EXECUTABLE}\ submodule\ update\ --init
WORKING_DIRECTORY ${YOSYS_SRC_DIR}
)

Expand All @@ -73,104 +74,61 @@ if (${WITH_PARMYS})
COMMAND ${MAKE_PROGRAM} -C ${YOSYS_SRC_DIR}
ENABLE_ABC=0
PREFIX=${CMAKE_BINARY_DIR}

> /dev/null 2>&1
COMMAND ${MAKE_PROGRAM}
-C ${YOSYS_SRC_DIR}
install
ENABLE_ABC=0
PREFIX=${CMAKE_BINARY_DIR}

> /dev/null 2>&1
WORKING_DIRECTORY ${YOSYS_SRC_DIR})

add_custom_target(yosys ALL DEPENDS ${YOSYS_BUILD_DIR})

if (${SYNLIG_SYSTEMVERILOG})

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)

ExternalProject_Add(surelog
# root directory for Surelog project
PREFIX "surelog"

GIT_REPOSITORY https://github.com/chipsalliance/Surelog.git
GIT_TAG v1.71
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE

# setting source, build and install directories
SOURCE_DIR "${SURELOG_SOURCE_DIR}"
BUILD_IN_SOURCE FALSE
INSTALL_DIR "${SURELOG_BINARY_DIR}"

# define Surelog cache values
CMAKE_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=Release"
"-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}"
"-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON"
"-DCMAKE_WARN_DEPRECATED:BOOL=OFF"

# redirect logs to a logfile
LOG_BUILD ON
LOG_UPDATE ON
LOG_INSTALL ON
LOG_CONFIGURE OFF
LOG_OUTPUT_ON_FAILURE ON

# dependency
DEPENDS yosys
)

# Synlig integration (manages Surelog and UHDM internally)

# Synlig integration (manages Surelog and UHDM internally)
set(SYNLIG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/synlig)
if (${SLANG_SYSTEMVERILOG})
set(SLANG_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/yosys-slang)
set(SLANG_BUILD_DIR ${CMAKE_BINARY_DIR}/yosys-slang)
#Initialize yosys-slang submodules
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init
WORKING_DIRECTORY ${SLANG_SRC_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule foreach --recursive ${GIT_EXECUTABLE}\ submodule\ update\ --init
WORKING_DIRECTORY ${SLANG_SRC_DIR}
)
set(SLANG_FE "${SLANG_SRC_DIR}/src/slang_frontend.cc")
ExternalProject_Add(
yosys-slang
SOURCE_DIR ${SLANG_SRC_DIR}
BINARY_DIR ${SLANG_BUILD_DIR}

#Disabling UndrivenPass in slang_frontend.cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some more comments here as to why we need to patch slang. Is this something that we can bring back to the slang master? Or is there something integral to VTR that causes problems?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have it patching slang to disable the UndrivenPass because it was failing benchmarks due to unsupported synchronous rules in vtr_primitives.v and wouldn't let me run any benchmark with read_slang without disabling that pass.

I believe Peter is working on this in his work to clean up benchmarks to be compatible with read_slang. So if that ends up being fixed, I'll probably be able to remove the patch step for slang. I think we can leave this in for now just so the CI is able to pass the SystemVerilog reg test.

PATCH_COMMAND
${CMAKE_COMMAND} -E echo "Patching slang_frontend.cc to disable UndrivenPass" &&
${CMAKE_COMMAND} -DIN=${SLANG_FE} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch_slang.cmake

CONFIGURE_COMMAND ""

# Sets location of yosys-config required by slang and suppresses warnings
BUILD_COMMAND
${CMAKE_COMMAND} -E env
YOSYS_PREFIX=${CMAKE_BINARY_DIR}/bin/
${MAKE_PROGRAM} -C ${SLANG_SRC_DIR}
CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-w"
install

# Clone Synlig repository and ensure submodules are synced before building
ExternalProject_Add(synlig
PREFIX "synlig"
INSTALL_COMMAND ""

# Clone the Synlig repository
GIT_REPOSITORY https://github.com/chipsalliance/synlig.git
GIT_TAG main
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
DEPENDS yosys

# 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${PROCESSOR_COUNT}
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_BUILD OFF
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 ()

Expand Down
18 changes: 18 additions & 0 deletions libs/EXTERNAL/patch_slang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Patch step for yosys-slang
#
# The variable 'IN' points to vtr_root/libs/EXTERNAL/yosys-slang/src/slang_frontend.cc
# This file contains the UndrivenPass that we want to disable
#
# This patch step finds the line where the UndrivenPass is called and comments out that line
#
# The UndrivenPass needs to be disabled due to unsupported synchronous rules in vtr_primitives.v

if(NOT DEFINED IN)
message(FATAL_ERROR "patch_slang.cmake: IN (SLANG_FE) variable not set.")
endif()
file(READ "${IN}" SLANG_FRONTEND_CONTENTS)
string(REPLACE "call(design, \"undriven\");" "// call(design, \"undriven\");" SLANG_PATCHED "${SLANG_FRONTEND_CONTENTS}")
if(NOT SLANG_FRONTEND_CONTENTS STREQUAL SLANG_PATCHED)
message(STATUS "Patching slang_frontend.cc to disable UndrivenPass")
file(WRITE "${IN}" "${SLANG_PATCHED}")
endif()
1 change: 1 addition & 0 deletions libs/EXTERNAL/yosys-slang
Submodule yosys-slang added at 76b83e
24 changes: 24 additions & 0 deletions vtr_flow/misc/yosys/slang_filelist.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#Parameters:
#
# circuit_list - list of circuits passed into the flow
# file_list - text file being written to that will contain
# the names of circuits from circuit list.
#
#Function:
#
# Validates file extensions of input files and writes the names
# of input files to the file list to be read by yosys-slang.

proc build_filelist { circuit_list file_list } {
set fh [open $file_list "w"]
foreach f $circuit_list {
set ext [string tolower [file extension $f]]
if {$ext == ".sv" || $ext == ".svh" || $ext == ".v" || $ext == ".vh"} {
puts $fh $f
} else {
close $fh
error "Unsupported file type. Yosys-Slang accepts .sv .svh .v .vh. File {$f}"
}
}
close $fh
}
Loading