forked from The-OpenROAD-Project/OpenROAD-flow-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsynth.tcl
More file actions
157 lines (129 loc) · 4.79 KB
/
Copy pathsynth.tcl
File metadata and controls
157 lines (129 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
source $::env(SCRIPTS_DIR)/synth_preamble.tcl
read_checkpoint $::env(RESULTS_DIR)/1_1_yosys_canonicalize.rtlil
hierarchy -check -top $::env(DESIGN_NAME)
if { [env_var_equals SYNTH_GUT 1] } {
# /deletes all cells at the top level, which will quickly optimize away
# everything else, including macros.
delete $::env(DESIGN_NAME)/c:*
}
if { [env_var_exists_and_non_empty SYNTH_KEEP_MODULES] } {
foreach module $::env(SYNTH_KEEP_MODULES) {
select -module $module
setattr -mod -set keep_hierarchy 1
select -clear
}
}
if { [env_var_exists_and_non_empty SYNTH_HIER_SEPARATOR] } {
scratchpad -set flatten.separator $::env(SYNTH_HIER_SEPARATOR)
}
set synth_full_args [env_var_or_empty SYNTH_ARGS]
if { [env_var_exists_and_non_empty SYNTH_OPERATIONS_ARGS] } {
set synth_full_args [concat $synth_full_args $::env(SYNTH_OPERATIONS_ARGS)]
} else {
set synth_full_args [concat $synth_full_args \
"-extra-map $::env(FLOW_HOME)/platforms/common/lcu_kogge_stone.v"]
}
if { ![env_var_equals SYNTH_HIERARCHICAL 1] } {
# Perform standard coarse-level synthesis script, flatten right away
synth -flatten -run :fine {*}$synth_full_args
} else {
# Perform standard coarse-level synthesis script,
# defer flattening until we have decided what hierarchy to keep
synth -run :fine
if { [env_var_exists_and_non_empty SYNTH_MINIMUM_KEEP_SIZE] } {
set ungroup_threshold $::env(SYNTH_MINIMUM_KEEP_SIZE)
puts "Keep modules above estimated size of $ungroup_threshold gate equivalents"
convert_liberty_areas
keep_hierarchy -min_cost $ungroup_threshold
} else {
keep_hierarchy
}
# Re-run coarse-level script, this time do pass -flatten
synth -flatten -run coarse:fine {*}$synth_full_args
}
json -o $::env(RESULTS_DIR)/mem.json
# Run report and check here so as to fail early if this synthesis run is doomed
exec -- $::env(PYTHON_EXE) $::env(SCRIPTS_DIR)/mem_dump.py \
--max-bits $::env(SYNTH_MEMORY_MAX_BITS) $::env(RESULTS_DIR)/mem.json
if {
[env_var_exists_and_non_empty SYNTH_WRAPPED_OPERATORS] ||
[env_var_exists_and_non_empty SWAP_ARITH_OPERATORS]
} {
source $::env(SCRIPTS_DIR)/synth_wrap_operators.tcl
} else {
synth -top $::env(DESIGN_NAME) -run fine: {*}$synth_full_args
}
# Get rid of indigestibles
chformal -remove
delete t:\$print
# rename registers to have the verilog register name in its name
# of the form \regName$_DFF_P_. We should fix yosys to make it the reg name.
# At least this is predictable.
renames -wire
# Optimize the design
opt -purge
# Technology mapping of adders
if { [env_var_exists_and_non_empty ADDER_MAP_FILE] } {
# extract the full adders
extract_fa
# map full adders
techmap -map $::env(ADDER_MAP_FILE)
techmap
# Quick optimization
opt -fast -purge
}
# Technology mapping of latches
if { [env_var_exists_and_non_empty LATCH_MAP_FILE] } {
techmap -map $::env(LATCH_MAP_FILE)
}
set dfflibmap_args ""
foreach cell $::env(DONT_USE_CELLS) {
lappend dfflibmap_args -dont_use $cell
}
# Technology mapping of flip-flops
# dfflibmap only supports one liberty file
if { [env_var_exists_and_non_empty DFF_LIB_FILE] } {
dfflibmap -liberty $::env(DFF_LIB_FILE) {*}$dfflibmap_args
} else {
dfflibmap -liberty $::env(DONT_USE_SC_LIB) {*}$dfflibmap_args
}
opt
# Replace undef values with defined constants
setundef -zero
if { ![env_var_exists_and_non_empty SYNTH_WRAPPED_OPERATORS] } {
log_cmd abc {*}$abc_args
} else {
scratchpad -set abc9.script scripts/abc_speed_gia_only.script
# crop out -script from arguments
set abc_args [lrange $abc_args 2 end]
log_cmd abc_new {*}$abc_args
delete {t:$specify*}
}
# Splitting nets resolves unwanted compound assign statements in netlist (assign {..} = {..})
splitnets
# Remove unused cells and wires
opt_clean -purge
# Technology mapping of constant hi- and/or lo-drivers
hilomap -singleton \
-hicell {*}$::env(TIEHI_CELL_AND_PORT) \
-locell {*}$::env(TIELO_CELL_AND_PORT)
# Insert buffer cells for pass through wires
insbuf -buf {*}$::env(MIN_BUF_CELL_AND_PORTS)
# Reports
tee -o $::env(REPORTS_DIR)/synth_check.txt check
tee -o $::env(REPORTS_DIR)/synth_stat.txt stat {*}$stat_libs
# check the design is composed exclusively of target cells, and check for other problems
if { ![env_var_exists_and_non_empty SYNTH_WRAPPED_OPERATORS] } {
check -assert -mapped
} else {
# Wrapped operator synthesis leaves around $buf cells which `check -mapped`
# gets confused by, once Yosys#4931 is merged we can remove this branch and
# always run `check -assert -mapped`
check -assert
}
# Write synthesized design
write_verilog -nohex -nodec $::env(RESULTS_DIR)/1_2_yosys.v
# One day a more sophisticated synthesis will write out a modified
# .sdc file after synthesis. For now, just copy the input .sdc file,
# making synthesis more consistent with other stages.
log_cmd exec cp $::env(SDC_FILE) $::env(RESULTS_DIR)/1_synth.sdc