Skip to content

Commit 9383300

Browse files
committed
Split the file extension checking and filelist building for yosys slang in synthesis.tcl to another .tcl (slang_filelist.tcl) to make synthesis.tcl more readable
1 parent 56b7a7d commit 9383300

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#Parameters:
2+
#
3+
# circuit_list - list of circuits passed into the flow
4+
# file_list - text file being written to that will contain
5+
# the names of circuits from circuit list.
6+
#
7+
#Function:
8+
#
9+
# Validates file extensions of input files and writes the names
10+
# of input files to the file list to be read by yosys-slang.
11+
12+
proc build_filelist { circuit_list file_list } {
13+
set fh [open $file_list "w"]
14+
foreach f $circuit_list {
15+
set ext [string tolower [file extension $f]]
16+
if {$ext == ".sv" || $ext == ".svh" || $ext == ".v" || $ext == ".vh"} {
17+
puts $fh $f
18+
} else {
19+
close $fh
20+
error "Unsupported file type. Yosys-Slang accepts .sv .svh .v .vh. File {$f}"
21+
}
22+
}
23+
close $fh
24+
}

vtr_flow/misc/yosys/synthesis.tcl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,10 @@ parmys_arch -a QQQ
3636
if {$env(PARSER) == "slang" } {
3737
# Create a file list containing the name(s) of file(s) \
3838
# to read together with read_slang
39+
source [file join [pwd] "slang_filelist.tcl"]
3940
set readfile [file join [pwd] "filelist.txt"]
40-
set fh [open $readfile "w"]
41-
foreach f {XXX} {
42-
set ext [string tolower [file extension $f]]
43-
if {$ext == ".sv" || $ext == ".svh" || $ext == ".v" || $ext == ".vh"} {
44-
puts $fh $f
45-
} else {
46-
error "Unsupported file type. Yosys-Slang accepts .sv .svh .v .vh"
47-
}
48-
}
49-
close $fh
41+
#Writing names of circuit files to file list
42+
build_filelist {XXX} $readfile
5043
puts "Using Yosys read_slang command"
5144
read_slang -C $readfile
5245
} elseif {$env(PARSER) == "default" } {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,14 @@ def run(
191191
if yosys_exec is None:
192192
yosys_exec = str(vtr.paths.yosys_exe_path)
193193

194+
yosys_helper_base_script = None
194195
if yosys_script is None:
195196
yosys_base_script = str(vtr.paths.yosys_script_path)
197+
try:
198+
yosys_slang_exec = str(vtr.paths.yosys_slang_path)
199+
yosys_helper_base_script = str(vtr.paths.yosys_helper_script_path)
200+
except KeyError:
201+
yosys_helper_base_script = None
196202
else:
197203
yosys_base_script = str(Path(yosys_script).resolve())
198204

@@ -201,6 +207,12 @@ def run(
201207
yosys_script_full_path = str(temp_dir / yosys_script)
202208
shutil.copyfile(yosys_base_script, yosys_script_full_path)
203209

210+
if yosys_helper_base_script is not None:
211+
# Copy the yosys-slang helper script file
212+
yosys_helper_script = "slang_filelist.tcl"
213+
yosys_helper_script_full_path = str(temp_dir / yosys_helper_script)
214+
shutil.copyfile(yosys_helper_base_script, yosys_helper_script_full_path)
215+
204216
# Copy the VTR memory blocks file
205217

206218
architecture_file_path = str(vtr.paths.scripts_path / architecture_file)

vtr_flow/scripts/python_libs/vtr/paths.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
yosys_exe_path = yosys_path / "yosys"
2222
yosys_tcl_path = vtr_flow_path / "misc" / "yosys"
2323
yosys_script_path = yosys_tcl_path / "synthesis.tcl"
24+
yosys_helper_script_path = yosys_tcl_path / "slang_filelist.tcl"
2425
yosys_slang_path = root_path / "build" / "share" / "yosys" / "plugins" / "slang.so"
2526

2627
# Synlig paths

0 commit comments

Comments
 (0)