Skip to content

Commit 35d15ce

Browse files
committed
[Infra]: change Yosys standalone synthesis script format to tcl
Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent f725f36 commit 35d15ce

File tree

5 files changed

+40
-35
lines changed

5 files changed

+40
-35
lines changed

doc/src/yosys/dev_guide.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ How to add new changes?
3232
-----------------------
3333

3434
The Yosys synthesis commands, including the generic synthesis and additional VTR specific configurations, are provided
35-
in `synthesis.ys <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.ys>`_. To make changes in the overall Yosys synthesis flow, the `synthesis.ys <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.ys>`_
36-
script is perhaps the first file developers may require to change.
35+
in `synthesis.tcl <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.tcl>`_. To make changes in the overall Yosys synthesis flow, the `synthesis.tcl <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/synthesis.tcl>`_
36+
script is perhaps the first file developers may be required to change.
3737

3838
Moreover, the `yosys_models.v <https://github.com/verilog-to-routing/vtr-verilog-to-routing/blob/master/vtr_flow/misc/yosyslib/yosys_models.v>`_ file includes the required definitions for Yosys to how it should infer implicit
3939
memories and instantiate arithmetic operations, such as addition, subtraction, and multiplication. Therefore, to alter these

doc/src/yosys/structure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Structure of Yosys Synthesis Files and the Yosys External Library Library
1818
│ ├── multiply.v
1919
│ ├── single_port_ram.v
2020
│ ├── spram_rename.v
21-
│ ├── synthesis.ys
21+
│ ├── synthesis.tcl
2222
│ └── yosys_models.v
2323
└── libs
2424
└── EXTERNAL

vtr_flow/misc/yosyslib/synthesis.ys renamed to vtr_flow/misc/yosyslib/synthesis.tcl

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#################################################################
2-
# Yosys synthesis script, including generic 'synth' commands, #
3-
# in addition to techmap asynchronous FFs and VTR hard blocks. #
2+
# Yosys synthesis script, including generic 'synth' commands, #
3+
# in addition to techmap asynchronous FFs and VTR hard blocks. #
44
# Once the VTR flow runs with the Yosys front-end, Yosys #
5-
# synthesizes the input design using the following commands. #
6-
# #
7-
# NOTE: the script is adapted from the one Eddie Hung proposed #
8-
# for VTR-to-Bitstream[1]. However, a few minor changes to make #
9-
# it adaptable with the current VTR flow have been made. #
10-
# #
11-
# [1] http://eddiehung.github.io/vtb.html #
12-
# #
13-
# Author: Eddie Hung #
14-
# Co-author: Seyed Alireza Damghani ([email protected]) #
5+
# synthesizes the input design using the following commands. #
6+
# #
7+
# NOTE: the script is adapted from the one Eddie Hung proposed #
8+
# for VTR-to-Bitstream[1]. However, a few minor changes to make #
9+
# it adaptable with the current VTR flow have been made. #
10+
# #
11+
# [1] http://eddiehung.github.io/vtb.html #
12+
# #
13+
# Author: Eddie Hung #
14+
# Co-author: Seyed Alireza Damghani ([email protected]) #
1515
#################################################################
16+
yosys -import
1617

1718
# XXX (input circuit) is replaced with filename by the run_vtr_flow script
1819
read_verilog -sv -nolatches XXX
@@ -23,7 +24,7 @@ read_verilog -sv -nolatches XXX
2324
# directory for any definitions to modules it doesn't know
2425
# about, such as hand-instantiated (not inferred) memories
2526
hierarchy -check -auto-top -libdir .
26-
proc
27+
procs
2728

2829
# Check that there are no combinational loops
2930
scc -select
@@ -50,7 +51,7 @@ techmap -map +/adff2dff.v
5051
techmap -map TTT/../../../ODIN_II/techlib/adffe2dff.v
5152

5253
# Map multipliers, DSPs, and add/subtracts according to yosys_models.v
53-
techmap -map YYY */t:$mul */t:$mem */t:$sub */t:$add
54+
techmap -map YYY */t:\$mul */t:\$mem */t:\$sub */t:\$add
5455
opt -fast -full
5556

5657
memory_map
@@ -67,15 +68,19 @@ opt -fast
6768
# as blackboxes
6869
read_verilog -lib TTT/adder.v
6970
read_verilog -lib TTT/multiply.v
70-
read_verilog -lib SSS #(SSS) will be replaced by single_port_ram.v by python script
71-
read_verilog -lib DDD #(DDD) will be replaced by dual_port_ram.v by python script
71+
#(SSS) will be replaced by single_port_ram.v by python script
72+
read_verilog -lib SSS
73+
#(DDD) will be replaced by dual_port_ram.v by python script
74+
read_verilog -lib DDD
7275

7376
# Rename singlePortRam to single_port_ram
74-
# Rename dualPortRam to dualZ_port_ram
77+
# Rename dualPortRam to dual_port_ram
7578
# rename function of Yosys not work here
7679
# since it may outcome hierarchy error
77-
read_verilog SSR #(SSR) will be replaced by spram_rename.v by python script
78-
read_verilog DDR #(DDR) will be replaced by dpram_rename.v by python script
80+
#(SSR) will be replaced by spram_rename.v by python script
81+
read_verilog SSR
82+
#(DDR) will be replaced by dpram_rename.v by python script
83+
read_verilog DDR
7984

8085
# Flatten the netlist
8186
flatten

vtr_flow/scripts/python_libs/vtr/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# YOSYS paths
2020
yosys_exe_path = root_path / "libs" / "EXTERNAL" / "libyosys" / "yosys"
2121
yosys_lib_path = vtr_flow_path / "misc" / "yosyslib"
22-
yosys_script_path = yosys_lib_path / "synthesis.ys"
22+
yosys_script_path = yosys_lib_path / "synthesis.tcl"
2323

2424
# ABC paths
2525
abc_path = root_path / "abc"

vtr_flow/scripts/python_libs/vtr/yosys/yosys.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def init_script_file(
7070
yosys_script_full_path,
7171
{
7272
"XXX": circuit_list[0],
73-
"YYY": "./" + YOSYS_LIB_FILES["YSMDL"],
74-
"SSS": "./" + YOSYS_LIB_FILES["SPRAM"],
75-
"DDD": "./" + YOSYS_LIB_FILES["DPRAM"],
76-
"SSR": "./" + YOSYS_LIB_FILES["SPRAMR"],
77-
"DDR": "./" + YOSYS_LIB_FILES["DPRAMR"],
73+
"YYY": yosys_models_full_path,
74+
"SSS": yosys_spram_full_path,
75+
"DDD": yosys_dpram_full_path,
76+
"SSR": yosys_spram_rename_full_path,
77+
"DDR": yosys_dpram_rename_full_path,
7878
"TTT": str(vtr.paths.yosys_lib_path),
7979
"ZZZ": output_netlist,
8080
},
@@ -165,14 +165,14 @@ def run(
165165
yosys_base_script = str(Path(yosys_script).resolve())
166166

167167
# Copy the script file
168-
yosys_script = "synthesis.ys"
168+
yosys_script = "synthesis.tcl"
169169
yosys_script_full_path = str(temp_dir / yosys_script)
170170
shutil.copyfile(yosys_base_script, yosys_script_full_path)
171171

172172
# Copy the yosys models file
173173
yosys_models = YOSYS_LIB_FILES["YSMDL"]
174174
yosys_base_models = str(vtr.paths.yosys_lib_path / YOSYS_LIB_FILES["YSMDL"])
175-
yosys_models_full_path = str(temp_dir / yosys_models)
175+
yosys_models_full_path = str(vtr.paths.scripts_path / temp_dir / yosys_models)
176176
shutil.copyfile(yosys_base_models, yosys_models_full_path)
177177

178178
# Copy the VTR memory blocks file
@@ -184,10 +184,10 @@ def run(
184184
yosys_base_dpram = str(vtr.paths.yosys_lib_path / YOSYS_LIB_FILES["DPRAM"])
185185
yosys_base_spram_rename = str(vtr.paths.yosys_lib_path / YOSYS_LIB_FILES["SPRAMR"])
186186
yosys_base_dpram_rename = str(vtr.paths.yosys_lib_path / YOSYS_LIB_FILES["DPRAMR"])
187-
yosys_spram_full_path = str(temp_dir / yosys_spram)
188-
yosys_dpram_full_path = str(temp_dir / yosys_dpram)
189-
yosys_spram_rename_full_path = str(temp_dir / yosys_spram_rename)
190-
yosys_dpram_rename_full_path = str(temp_dir / yosys_dpram_rename)
187+
yosys_spram_full_path = str(vtr.paths.scripts_path / temp_dir / yosys_spram)
188+
yosys_dpram_full_path = str(vtr.paths.scripts_path / temp_dir / yosys_dpram)
189+
yosys_spram_rename_full_path = str(vtr.paths.scripts_path / temp_dir / yosys_spram_rename)
190+
yosys_dpram_rename_full_path = str(vtr.paths.scripts_path / temp_dir / yosys_dpram_rename)
191191
shutil.copyfile(yosys_base_spram, yosys_spram_full_path)
192192
shutil.copyfile(yosys_base_dpram, yosys_dpram_full_path)
193193
shutil.copyfile(yosys_base_spram_rename, yosys_spram_rename_full_path)
@@ -220,7 +220,7 @@ def run(
220220
else:
221221
pass
222222

223-
cmd += ["-s", yosys_script]
223+
cmd += ["-c", yosys_script]
224224

225225
command_runner.run_system_command(
226226
cmd, temp_dir=temp_dir, log_filename=log_filename, indent_depth=1

0 commit comments

Comments
 (0)