Skip to content

Commit 90e180b

Browse files
committed
Fully implemented yosys-slang as a plugin for yosys
1 parent efb1d87 commit 90e180b

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

libs/EXTERNAL/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,17 @@ if (${WITH_PARMYS})
9191
COMMAND ${GIT_EXECUTABLE} submodule foreach --recursive git\ submodule\ update\ --init
9292
WORKING_DIRECTORY ${SLANG_SRC_DIR}
9393
)
94+
set(SLANG_FE "${SLANG_SRC_DIR}/src/slang_frontend.cc")
9495
ExternalProject_Add(
9596
yosys-slang
9697
SOURCE_DIR ${SLANG_SRC_DIR}
9798
BINARY_DIR ${SLANG_BUILD_DIR}
9899

100+
PATCH_COMMAND
101+
${CMAKE_COMMAND} -E echo "Patching slang_frontend.cc to disable UndrivenPass" &&
102+
${CMAKE_COMMAND} -DIN=${SLANG_FE} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch_slang.cmake
103+
104+
99105
CONFIGURE_COMMAND
100106
${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release
101107
-DYOSYS_CONFIG=${YOSYS_CONFIG_EXECUTABLE}

libs/EXTERNAL/patch_slang.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if(NOT DEFINED IN)
2+
message(FATAL_ERROR "patch_slang.cmake: IN (SLANG_FE) variable not set.")
3+
endif()
4+
file(READ "${IN}" SLANG_FRONTEND_CONTENTS)
5+
string(REPLACE "call(design, \"undriven\");" "// call(design, \"undriven\");" SLANG_PATCHED "${SLANG_FRONTEND_CONTENTS}")
6+
if(NOT SLANG_FRONTEND_CONTENTS STREQUAL SLANG_PATCHED)
7+
message(STATUS "Patching slang_frontend.cc to disable UndrivenPass")
8+
file(WRITE "${IN}" "${SLANG_PATCHED}")
9+
endif()

vtr_flow/misc/yosys/synthesis.tcl

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
yosys -import
2-
2+
#puts "Files in here: [glob -nocomplain *]"
33
plugin -i parmys
4-
plugin -i slang
5-
yosys -import
64

75
read_verilog -nomem2reg +/parmys/vtr_primitives.v
86
setattr -mod -set keep_hierarchy 1 single_port_ram
97
setattr -mod -set keep_hierarchy 1 dual_port_ram
8+
setattr -mod -set keep 1 dual_port_ram
9+
10+
plugin -i slang
11+
yosys -import
1012

1113
# synlig path error handling
1214
if {[catch {set synlig $::env(synlig_exe_path)} err]} {
@@ -25,10 +27,6 @@ if {[catch {set synlig $::env(synlig_exe_path)} err]} {
2527
# output file: ZZZ
2628

2729
parmys_arch -a QQQ
28-
if {$env(PARSER) == "slang" } {
29-
puts "Using yosys-slang read_slang command"
30-
read_slang XXX
31-
}
3230

3331
#if {$env(PARSER) == "surelog" } {
3432
# puts "Using Synlig read_uhdm command"
@@ -37,8 +35,35 @@ if {$env(PARSER) == "slang" } {
3735
#} elseif {$env(PARSER) == "system-verilog" } {
3836
# puts "Using Synlig read_systemverilog "
3937
# exec $synlig -p "read_systemverilog XXX"
40-
# }
41-
elseif {$env(PARSER) == "default" } {
38+
# }
39+
40+
if {$env(PARSER) == "slang" } {
41+
# Create a file list containing the name(s) of file(s)
42+
# to read together with read_slang
43+
set sv_files {}
44+
set v_files {}
45+
set readfile [file join [pwd] "filelist.txt"]
46+
set fh [open $readfile "w"]
47+
foreach f {XXX} {
48+
set ext [string tolower [file extension $f]]
49+
switch -- $ext {
50+
.sv {
51+
lappend $sv_files $f
52+
puts $fh $f
53+
}
54+
.v {
55+
error "Use default parser to parse .v files."
56+
}
57+
}
58+
}
59+
close $fh
60+
if {[llength $sv_files] > 0} {
61+
#puts "Using Yosys read_slang command"
62+
#read_slang -C $readfile
63+
}
64+
puts "Using Yosys read_slang command"
65+
read_slang -C $readfile
66+
} elseif {$env(PARSER) == "default" } {
4267
puts "Using Yosys read_verilog command"
4368
read_verilog -sv -nolatches XXX
4469
} else {
@@ -81,7 +106,8 @@ opt -full
81106
if {$env(PARSER) == "default" || $env(PARSER) == "slang"} {
82107
# For Verilog, use -nopass for a simpler, faster flow
83108
parmys -a QQQ -nopass -c CCC YYY
84-
} #elseif {$env(PARSER) == "slang"} {
109+
}
110+
#elseif {$env(PARSER) == "slang"} {
85111
# For Slang, run additional passes to handle complexity
86112
# parmys -a QQQ -c CCC YYY
87113
#}

0 commit comments

Comments
 (0)