Skip to content

Commit e964907

Browse files
committed
synth: Add 'wrapped operators' flow
Signed-off-by: Martin Povišer <[email protected]>
1 parent 804812e commit e964907

File tree

3 files changed

+119
-3
lines changed

3 files changed

+119
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
&st
2+
&dch
3+
&nf
4+
&st
5+
&syn2
6+
&if -g -K 6
7+
&synch2
8+
&nf
9+
&st
10+
&syn2
11+
&if -g -K 6
12+
&synch2
13+
&nf
14+
&st
15+
&syn2
16+
&if -g -K 6
17+
&synch2
18+
&nf
19+
&st
20+
&syn2
21+
&if -g -K 6
22+
&synch2
23+
&nf
24+
&st
25+
&syn2
26+
&if -g -K 6
27+
&synch2
28+
&nf

flow/scripts/synth.tcl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
3434
json -o $::env(RESULTS_DIR)/mem.json
3535
# Run report and check here so as to fail early if this synthesis run is doomed
3636
exec -- python3 $::env(SCRIPTS_DIR)/mem_dump.py --max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json
37-
synth -top $::env(DESIGN_NAME) -run fine: {*}$::env(SYNTH_FULL_ARGS)
37+
38+
if {![env_var_exists_and_non_empty NEW_OPERATOR_SYNTHESIS]} {
39+
synth -top $::env(DESIGN_NAME) -run fine: {*}$::env(SYNTH_FULL_ARGS)
40+
} else {
41+
source $::env(SCRIPTS_DIR)/synth_wrap_operators.tcl
42+
}
43+
3844
# Get rid of indigestibles
3945
chformal -remove
4046

@@ -76,7 +82,15 @@ if {[env_var_exists_and_non_empty DFF_LIB_FILE]} {
7682
}
7783
opt
7884

79-
log_cmd abc {*}$abc_args
85+
if {![env_var_exists_and_non_empty NEW_OPERATOR_SYNTHESIS]} {
86+
log_cmd abc {*}$abc_args
87+
} else {
88+
scratchpad -set abc9.script scripts/abc_speed_gia_only.script
89+
# crop out -script from arguments
90+
set abc_args [lrange $abc_args 2 end]
91+
log_cmd abc_new {*}$abc_args
92+
delete {t:$specify*}
93+
}
8094

8195
# Replace undef values with defined constants
8296
setundef -zero
@@ -104,7 +118,7 @@ tee -o $::env(REPORTS_DIR)/synth_stat.txt stat {*}$stat_libs
104118
check -assert -mapped
105119

106120
# Write synthesized design
107-
write_verilog -noexpr -nohex -nodec $::env(RESULTS_DIR)/1_1_yosys.v
121+
write_verilog -nohex -nodec $::env(RESULTS_DIR)/1_1_yosys.v
108122
# One day a more sophisticated synthesis will write out a modified
109123
# .sdc file after synthesis. For now, just copy the input .sdc file,
110124
# making synthesis more consistent with other stages.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
set deferred_cells {
2+
{
3+
\$alu
4+
ALU_{A_WIDTH}_{A_SIGNED}_{B_WIDTH}_{B_SIGNED}_{Y_WIDTH}{%unused}
5+
{HAN_CARLSON -map +/choices/han-carlson.v}
6+
{KOGGE_STONE -map +/choices/kogge-stone.v}
7+
{SKLANSKY -map +/choices/sklansky.v}
8+
{BRENT_KUNG}
9+
}
10+
{
11+
\$macc
12+
MACC_{CONFIG}_{Y_WIDTH}{%unused}
13+
{BASE -map +/choices/han-carlson.v}
14+
}
15+
}
16+
17+
techmap {*}[join [lmap cell $deferred_cells {string cat "-dont_map [lindex $cell 0]"}] " "]
18+
19+
foreach info $deferred_cells {
20+
set type [lindex $info 0]
21+
set naming_template [lindex $info 1]
22+
# default architecture and its suffix
23+
set default [lindex $info 2]
24+
set default_suffix [lindex $default 0]
25+
26+
log -header "Generating architectural options for $type"
27+
log -push
28+
29+
wrapcell \
30+
-setattr arithmetic_operator \
31+
-setattr copy_pending \
32+
-formatattr implements_operator $naming_template \
33+
-formatattr architecture $default_suffix \
34+
-formatattr source_cell $type \
35+
-name ${naming_template}_${default_suffix} \
36+
t:$type r:A_WIDTH>=10 r:Y_WIDTH>=14 %i %i
37+
38+
# make per-architecture copies of the unmapped module
39+
foreach modname [tee -q -s result.string select -list-mod A:arithmetic_operator A:copy_pending] {
40+
setattr -mod -unset copy_pending $modname
41+
42+
# iterate over non-default architectures
43+
foreach arch [lrange $info 3 end] {
44+
set suffix [lindex $arch 0]
45+
set base [rtlil::get_attr -string -mod $modname implements_operator]
46+
set newname ${base}_${suffix}
47+
yosys copy $modname $newname
48+
yosys setattr -mod -set architecture \"$suffix\" $newname
49+
}
50+
}
51+
52+
# iterate over all architectures, both the default and non-default
53+
foreach arch [lrange $info 2 end] {
54+
set suffix [lindex $arch 0]
55+
set extra_map_args [lrange $arch 1 end]
56+
57+
# inject booth before we have techmap support for it
58+
#booth A:source_cell=$type A:architecture=$suffix %i
59+
60+
# map all operator copies which were selected to have this architecture
61+
techmap -map +/techmap.v {*}$extra_map_args A:source_cell=$type A:architecture=$suffix %i
62+
}
63+
64+
log -pop
65+
}
66+
67+
opt -fast -full
68+
memory_map
69+
opt -full
70+
# Get rid of indigestibles
71+
chformal -remove
72+
setattr -mod -set abc9_script {"+&dch;&nf -R 5;"} A:arithmetic_operator
73+
setattr -mod -set abc9_box 1 A:arithmetic_operator
74+
techmap -map +/choices/han-carlson.v

0 commit comments

Comments
 (0)