-
Notifications
You must be signed in to change notification settings - Fork 422
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
Changes from all commits
4f8abac
efb1d87
90e180b
c1c2a5d
7c4c868
0152c36
f7ae912
81b7ee4
ce26e71
d2ffe14
172758b
0b1d2c0
9b51cbc
8d8d683
2d107fb
3cf1050
3fbe39f
56b7a7d
9383300
b842759
1d7a5cb
7f6749c
ff0795c
a4090df
09d5e6f
787af05
341a972
0cda1bf
6d7abd0
3bcef9a
ddd28fa
88d2b5c
d447f4a
42c7d0e
dfe45d2
5c78ad6
ceb49e1
52431fb
3b2c0a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
|
||
|
@@ -10,7 +12,6 @@ add_subdirectory(libsdcparse) | |
add_subdirectory(libblifparse) | ||
add_subdirectory(libtatum) | ||
add_subdirectory(libcatch2) | ||
#add_subdirectory(synlig) | ||
#add_subdirectory(parmys) | ||
|
||
#Proc numbers | ||
|
@@ -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} | ||
) | ||
|
||
|
@@ -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}) | ||
AlexandreSinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 () | ||
|
||
|
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) | ||
AlexandreSinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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() |
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 | ||
} |
Uh oh!
There was an error while loading. Please reload this page.