Skip to content

Commit b5fb283

Browse files
committed
yosys: refactor, simplify and comment
1 parent 983dc3c commit b5fb283

File tree

8 files changed

+126
-172
lines changed

8 files changed

+126
-172
lines changed

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ vsim: vsim/compile_rtl.tcl $(SW_HEX)
7474
cd vsim; $(VSIM) +binary="$(realpath $(SW_HEX))" -gui tb_croc_soc $(VSIM_ARGS)
7575

7676
## Simulate netlist using Questasim/Modelsim/vsim
77-
vsim-yosys: vsim/compile_netlist.tcl $(SW_HEX) yosys/out/croc_yosys_debug.v
77+
vsim-yosys: vsim/compile_netlist.tcl $(SW_HEX) yosys/out/croc_chip_yosys_debug.v
7878
rm -rf vsim/work
7979
cd vsim; $(VSIM) -c -do "source compile_netlist.tcl; source compile_tech.tcl; exit"
8080
cd vsim; $(VSIM) -gui tb_croc_soc $(VSIM_ARGS)
@@ -101,12 +101,11 @@ verilator: verilator/obj_dir/Vtb_croc_soc
101101
####################
102102
# Open Source Flow #
103103
####################
104+
# Bender manages the different IPs and can be used to generate file-lists for synthesis
104105
TOP_DESIGN ?= croc_chip
105106
DUT_DESIGN ?= croc_soc
106107
BENDER_TARGETS ?= asic ihp13 rtl synthesis
107108
SV_DEFINES ?= VERILATOR SYNTHESIS COMMON_CELLS_ASSERTS_OFF
108-
PICKLE_OUT ?= $(PROJ_DIR)/pickle
109-
SV_FLIST ?= $(PROJ_DIR)/croc.flist
110109

111110
## Generate croc.flist used to read design in yosys
112111
yosys-flist: Bender.lock Bender.yml rtl/*/Bender.yml

yosys/project-synth.mk

Lines changed: 0 additions & 39 deletions
This file was deleted.

yosys/scripts/abc-opt.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ print_stats
1414
# strash can fix some yosys-convertion edge-cases, good idea to run first
1515
strash
1616

17-
rec_start3 {REC_AIG}
17+
rec_start3 src/lazy_man_synth_library.aig
1818

1919
# main optimization iteration:
2020
alias &opt_iter "&st; &if -y -K 6; &syn2; &if -K 6; &st; &b"

yosys/scripts/init_tech.tcl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@
55
# Authors:
66
# - Philippe Sauter <phsauter@iis.ee.ethz.ch>
77

8-
# get environment variables
9-
set yosys_dir [file dirname [file dirname [info script]]]
10-
set root_dir [file dirname $yosys_dir]
8+
# All paths relative to yosys/
119

12-
if {[file exists "$root_dir/cockpit.log"]} {
10+
if {[file exists "../technology"]} {
1311
puts "0. Executing init_tech: load technology from ETHZ DZ cockpit"
14-
set pdk_dir "$root_dir/technology"
12+
set pdk_dir "../technology"
1513
set pdk_cells_lib ${pdk_dir}/lib
1614
set pdk_sram_lib ${pdk_dir}/lib
1715
set pdk_io_lib ${pdk_dir}/lib
1816
} else {
1917
puts "0. Executing init_tech: load technology from Github PDK"
2018
if {![info exists pdk_dir]} {
21-
set pdk_dir "$root_dir/ihp13/pdk"
19+
set pdk_dir "../ihp13/pdk"
2220
}
2321
set pdk_cells_lib ${pdk_dir}/ihp-sg13g2/libs.ref/sg13g2_stdcell/lib
2422
set pdk_sram_lib ${pdk_dir}/ihp-sg13g2/libs.ref/sg13g2_sram/lib
2523
set pdk_io_lib ${pdk_dir}/ihp-sg13g2/libs.ref/sg13g2_io/lib
2624
}
2725

2826
set tech_cells [list "$pdk_cells_lib/sg13g2_stdcell_typ_1p20V_25C.lib"]
29-
set tech_macros [glob -nocomplain -directory $pdk_sram_lib *_typ_1p20V_25C.lib]
27+
set tech_macros [glob -directory $pdk_sram_lib *_typ_1p20V_25C.lib]
3028
lappend tech_macros "$pdk_io_lib/sg13g2_io_typ_1p2V_3p3V_25C.lib"
3129

3230
# for hilomap

yosys/scripts/yosys_common.tcl

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,22 @@
55
# Authors:
66
# - Philippe Sauter <phsauter@iis.ee.ethz.ch>
77

8-
# Common setup used for all yosys scripts
8+
# Preparation for the synthesis flow
9+
# A common setup to provide some functionality and define variables
910

1011
# list of global variables that may be used
12+
# define with scheme: <local-var> { <ENVVAR> <fallback> }
1113
set variables {
12-
vlog_files { VLOG_FILES "" }
13-
sv_flist { SV_FLIST "" }
14-
top_design { TOP_DESIGN "" }
15-
hier_depth { HIER_DEPTH 0 }
16-
period_ps { YOSYS_TARGET_PERIOD_PS 5000 }
17-
proj_name { PROJ_NAME "" }
18-
build_dir { BUILD "[set dir [pwd]]/out" }
19-
work_dir { WORK "[set dir [pwd]]/WORK" }
20-
report_dir { REPORTS "[set dir [pwd]]/report" }
21-
netlist { NETLIST "" }
14+
sv_flist { SV_FLIST "../croc.flist" }
15+
top_design { TOP_DESIGN "croc_chip" }
16+
period_ps { PERIOD_PS 10000 }
17+
out_dir { OUT out }
18+
tmp_dir { TMP tmp }
19+
rep_dir { REPORTS reports }
2220
}
2321

24-
# either use env-var or default to fallback
25-
foreach var [dict keys $variables] {
26-
set values [dict get $variables $var]
27-
set env_var [lindex $values 0]
28-
set fallback [lindex $values 1]
29-
30-
if {[info exists ::env($env_var)]} {
31-
puts "using: $var= '$::env($env_var)'"
32-
set $var $::env($env_var)
33-
} else {
34-
puts "using: '$var= $fallback'"
35-
set $var $fallback
36-
}
37-
}
38-
39-
if {[string eq $netlist ""]} {
40-
set netlist ${build_dir}/${top_design}_netlist.v
41-
}
4222

23+
# check if an env-var exists and is non-empty
4324
proc envVarValid {var_name} {
4425
if { [info exists ::env($var_name)]} {
4526
if {$::env($var_name) != "0" && $::env($var_name) ne ""} {
@@ -49,14 +30,26 @@ proc envVarValid {var_name} {
4930
return 0
5031
}
5132

33+
# If the ENVVAR is valid use it, otherwise use fallback
34+
foreach var [dict keys $variables] {
35+
set values [dict get $variables $var]
36+
set env_var [lindex $values 0]
37+
set fallback [lindex $values 1]
38+
39+
if {[envVarValid $env_var]} {
40+
puts "using: $var= '$::env($env_var)'"
41+
set $var $::env($env_var)
42+
}
43+
}
44+
45+
# process ABC script and write to temporary directory
5246
proc processAbcScript {abc_script} {
53-
global work_dir period_ps
47+
global tmp_dir
5448
set src_dir [file join [file dirname [info script]] ../src]
55-
set abc_out_path $work_dir/[file tail $abc_script]
49+
set abc_out_path $tmp_dir/[file tail $abc_script]
5650

5751
set raw [read -nonewline [open $abc_script r]]
58-
set abc_script_delay [string map -nocase [list "{D}" [subst "-D $period_ps"]] $raw]
59-
set abc_script_recaig [string map -nocase [list "{REC_AIG}" [subst "$src_dir/rec6Lib_final_filtered3_recanon_basilisk.aig"]] $abc_script_delay]
52+
set abc_script_recaig [string map -nocase [list "{REC_AIG}" [subst "$src_dir/lazy_man_synth_library.aig"]] $raw]
6053
set abc_out [open $abc_out_path w]
6154
puts -nonewline $abc_out $abc_script_recaig
6255

0 commit comments

Comments
 (0)