-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathaf_run.tcl
334 lines (301 loc) · 11.1 KB
/
af_run.tcl
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
set ALTA_SUPRA true
set sh_continue_on_error false
set sh_echo_on_source true
set sh_quiet_on_source true
set cc_critical_as_fatal true
set rt_incremental_route true
set ta_report_auto 1
set ta_report_auto_constraints $ta_report_auto
if { ! [info exists RESULT_DIR] } {
set RESULT_DIR "."
} elseif { ! [info exists alta_work] } {
set alta_work "${RESULT_DIR}/alta_db"
}
if { ! [info exists DEVICE] } {
set DEVICE "AG1280Q48"
}
if { [info exists DESIGN] && ! [info exists TOP_MODULE] } {
set TOP_MODULE "$DESIGN"
}
if { ! [info exists DESIGN] } {
set DESIGN "Blink_AG1280"
}
if { ! [info exists TOP_MODULE] } {
set TOP_MODULE "Blink_AG1280"
}
if { ! [info exists IP_FILES] } {
set IP_FILES {"E:/echo/git/github/xjtuecho/AgmPill/hdl/Blink_AG1280/PLL.ip" }
}
if { ! [info exists VE_FILE] } {
set VE_FILE ""
}
if { ! [info exists TIMING_DERATE] } {
set TIMING_DERATE 1.000000
}
if { [info exists NO_ROUTE] && $NO_ROUTE } {
set no_route "-no_route"
} else {
set no_route ""
}
if { ! [info exists RETRY] } { set RETRY 0 }
if { ! [info exists SEED ] } { set SEED 666 }
set seed_rand ""
if { $SEED == 0 } { set seed_rand "-seed_rand" }
if { [info exists QUARTUS_SDC] } {
set sdc_remove_quartus_column_name $QUARTUS_SDC
}
if { ! [info exists ORG_PLACE] } { set ORG_PLACE false }
if { ! [info exists MODE] } { set MODE "QUARTUS" }
if { ! [info exists FLOW] } { set FLOW "ALL" }
if { $FLOW == "PROBE" } {
if { ! [info exists PROBE_FORCE] } { set PROBE_FORCE false }
if { ! [info exists PREFIX] } { set PREFIX "probe_" }
}
if { ! [info exists PREFIX] } {
set RESULT $DESIGN
} else {
set RESULT $PREFIX$DESIGN
}
if { $FLOW == "GEN" || $FLOW == "PACK" || $FLOW == "LOAD" } { set no_route "-no_route" }
set RUN "run"
if { $FLOW == "CHECK" } {
set RUN "check"
} elseif { $FLOW == "PROBE" } {
set RUN "probe"
} elseif { $FLOW == "GEN" } {
set RUN "gen"
}
if { ! [info exists alta_logs] } {
set alta_logs "${RESULT_DIR}/alta_logs"
}
file mkdir $alta_logs
alta::begin_log_cmd "$alta_logs/${RUN}.log" "$alta_logs/${RUN}.err"
alta::tcl_whisper "Cmd : [alta::prog_path] [alta::prog_version]([alta::prog_subversion])\n"
alta::tcl_whisper "Args : [string map {\{ \" \} \"} $tcl_cmd_args]\n"
set_seed_rand $SEED
set ar_timing_derate ${TIMING_DERATE}
date_time
if { [file exists "./${DESIGN}.pre.asf"] } {
alta::tcl_highlight "Using pre-ASF file ${DESIGN}.pre.asf.\n"
source "./${DESIGN}.pre.asf"
}
eval "load_architect ${no_route} -type ${DEVICE} 1 1 1000 1000"
foreach ip_file $IP_FILES { read_ip $ip_file; }
set LOAD_DB false
set LOAD_PLACE false
set LOAD_ROUTE false
if { $FLOW == "LOAD" || $FLOW == "CHECK" || $FLOW == "PROBE" } {
set LOAD_DB true
set LOAD_PLACE true
set LOAD_ROUTE true
} elseif { $FLOW == "R" || $FLOW == "ROUTE" } {
set LOAD_DB true
set LOAD_PLACE true
}
set ORIGINAL_QSF ""
set ORIGINAL_PIN ""
#################################################################################
if { $FLOW == "GEN" } {
if { ! [info exists CONFIG_BITS] } {
set CONFIG_BITS "${RESULT_DIR}/${DESIGN}.bin"
}
if { [llength $CONFIG_BITS] > 1 } {
if { ! [info exists BOOT_BINARY] } {
set BOOT_BINARY "${RESULT_DIR}/${DESIGN}_boot.bin"
}
if { ! [info exists CONFIG_ADDRESSES] } {
set CONFIG_ADDRESSES ""
}
generate_binary -master $BOOT_BINARY -inputs $CONFIG_BITS -address $CONFIG_ADDRESSES
} else {
set CONFIG_ROOT [file rootname [lindex $CONFIG_BITS 0]]
set SLAVE_RBF "${CONFIG_ROOT}_slave.rbf"
set MASTER_BINARY "${CONFIG_ROOT}_master.bin"
if { [file exists [lindex $CONFIG_BITS 0]] } {
generate_binary -slave $SLAVE_RBF -inputs [lindex $CONFIG_BITS 0] -reverse
generate_binary -master $MASTER_BINARY -inputs [lindex $CONFIG_BITS 0]
}
if { ! [info exists BOOT_BINARY] } {
set BOOT_BINARY $MASTER_BINARY
}
}
set PRG_FILE [file rootname $BOOT_BINARY].prg
set AS_FILE [file rootname $BOOT_BINARY]_as.prg
generate_programming_file $BOOT_BINARY -erase $ERASE \
-program $PROGRAM -verify $VERIFY -offset $OFFSET \
-prg $PRG_FILE -as $AS_FILE
exit
}
if { $LOAD_DB } {
load_db -top ${TOP_MODULE}
set sdc "./${DESIGN}.adc"
if { ! [file exists $sdc] } { set sdc "./${DESIGN}.sdc"; }
if { [file exists $sdc] } { read_sdc $sdc; }
} elseif { $MODE == "QUARTUS" } {
set verilog ${DESIGN}.vo
set is_migrated false
if { ! [file exists $verilog] } {
set verilog "./simulation/modelsim/${DESIGN}.vo"
set is_migrated true
}
if { ! [file exists $verilog] } {
error "Can not find design verilog file $verilog"
}
alta::tcl_highlight "Using design verilog file $verilog.\n"
set ret [read_design -top ${TOP_MODULE} -ve $VE_FILE -qsf $ORIGINAL_QSF $verilog -hierachy 1]
if { !$ret } { exit -1; }
set sdc "./${DESIGN}.adc"
if { ! [file exists $sdc] } { set sdc "./${DESIGN}.sdc"; }
if { ! [file exists $sdc] } {
alta::tcl_warn "Can not find design SDC file $sdc"
} else {
alta::tcl_highlight "Using design SDC file $sdc.\n"
read_sdc $sdc
}
} elseif { $MODE == "SYNPLICITY" || $MODE == "NATIVE" } {
set db_gclk_assignment_level 2
set verilog ${DESIGN}.vqm
set is_migrated false
if { ! [file exists $verilog] } {
error "Can not find design verilog file $verilog"
}
set sdc "./${DESIGN}.adc"
if { ! [file exists $sdc] } { set sdc "./${DESIGN}.sdc"; }
alta::tcl_highlight "Using design verilog file $verilog.\n"
if { ! [file exists $sdc] } {
alta::tcl_warn "Can not find design SDC file $sdc"
set ret [read_design_and_pack -sdc $sdc -top ${TOP_MODULE} $verilog]
} else {
alta::tcl_highlight "Using design SDC file $sdc.\n"
set ret [read_design_and_pack -top ${TOP_MODULE} $verilog]
}
if { !$ret } { exit -1; }
} else {
error "Unsupported mode $MODE"
}
if { $FLOW == "PACK" } { exit }
if { [info exists FITTING] } {
if { $FITTING == "Auto" } { set FITTING auto; }
set_mode -fitting $FITTING
}
if { [info exists FITTER] } {
if { $FITTER == "Auto" } {
if { $MODE == "QUARTUS" } { set FITTER hybrid; } else { set FITTER full; }
}
if { $MODE == "SYNPLICITY" || $MODE == "NATIVE" } { set FITTER full; }
set_mode -fitter $FITTER
}
if { [info exists EFFORT] } { set_mode -effort $EFFORT; }
if { [info exists SKEW ] } { set_mode -skew $SKEW ; }
if { [info exists SKOPE ] } { set_mode -skope $SKOPE ; }
if { [info exists HOLDX ] } { set_mode -holdx $HOLDX; }
if { [info exists TUNING] } { set_mode -tuning $TUNING; }
if { [info exists TARGET] } { set_mode -target $TARGET; }
if { [info exists PRESET] } { set_mode -preset $PRESET; }
if { [info exists ADJUST] } { set pl_criticality_wadjust $ADJUST; }
set alta_aqf $::alta_work/alta.aqf
if { $LOAD_DB } {
# Empty
} elseif { false } {
if { [file exists $VE_FILE] } {
set ORIGINAL_PIN ""
} elseif { ! [file exists $ORIGINAL_PIN] } {
if { $is_migrated } {
error "Can not find design PIN file $ORIGINAL_PIN, please compile design first"
}
set ORIGINAL_PIN ""
}
if { [file exists $ORIGINAL_QSF] } {
alta::convert_quartus_settings_cmd $ORIGINAL_QSF $ORIGINAL_PIN $alta_aqf
} elseif { $is_migrated } {
error "Can not find design exported QSF file $ORIGINAL_QSF, please export assigments first"
}
}
if { [file exists "$alta_aqf"] } {
alta::tcl_highlight "Using AQF file $alta_aqf.\n"
source "$alta_aqf"
}
if { [file exists "./${DESIGN}.asf"] } {
alta::tcl_highlight "Using ASF file ${DESIGN}.asf.\n"
source "./${DESIGN}.asf"
}
if { $FLOW == "PROBE" } {
set ret [place_pseudo -user_io -place_io -place_pll -place_gclk]
if { !$ret } { exit -1 }
set force ""
if { [info exists PROBE_FORCE] && $PROBE_FORCE } { set force "-force" }
eval "probe_design -froms {${PROBE_FROMS}} -tos {${PROBE_TOS}} ${force}"
} elseif { $FLOW == "CHECK" } {
set ret [place_pseudo -user_io -place_io -place_pll -place_gclk]
if { !$ret } { exit -1 }
if { [file exists "./${DESIGN}.chk"] } {
alta::tcl_highlight "Using CHK file ${DESIGN}.chk.\n"
source "./${DESIGN}.chk"
place_design -dry
check_design -rule led_guide
} else {
error "Can not find design CHECK file ${DESIGN}.chk"
}
} else {
set ret [place_pseudo -user_io -place_io -place_pll -place_gclk -warn_io]
if { !$ret } { exit -1 }
set org_place ""
set load_place ""
set load_route ""
set quiet ""
if { $ORG_PLACE } { set org_place "-org_place" ; }
if { $LOAD_PLACE } { set load_place "-load_place"; }
if { $LOAD_ROUTE } { set load_route "-load_route"; }
eval "place_and_route_design $org_place $load_place $load_route \
-retry $RETRY $seed_rand $quiet"
}
date_time
if { $FLOW != "CHECK" } {
if { $FLOW != "PROBE" } {
#report_timing -verbose 1 -file $::alta_work/timing.rpt.gz
report_timing -verbose 2 -setup -file $::alta_work/setup.rpt.gz
report_timing -verbose 2 -setup -brief -file $::alta_work/setup_summary.rpt.gz
report_timing -verbose 2 -hold -file $::alta_work/hold.rpt.gz
report_timing -verbose 2 -hold -brief -file $::alta_work/hold_summary.rpt.gz
set ta_report_auto_constraints 0
report_timing -fmax -file $::alta_work/fmax.rpt
report_timing -xfer -file $::alta_work/xfer.rpt
set ta_report_auto_constraints $ta_report_auto
#set ta_coverage_limit "0.95 0.90"
set ta_dump_uncovered 1
report_timing -verbose 1 -coverage >! $::alta_work/coverage.rpt.gz
#unset ta_coverage_limit
unset ta_dump_uncovered
if { ! [info exists rt_report_timing_fast] } {
set rt_report_timing_fast false
}
if { $rt_report_timing_fast } {
set_timing_corner fast
route_delay -quiet
report_timing -verbose 2 -setup -file $::alta_work/setup_fast.rpt.gz
report_timing -verbose 2 -setup -brief -file $::alta_work/setup_fast_summary.rpt.gz
report_timing -verbose 2 -hold -file $::alta_work/hold_fast.rpt.gz
report_timing -verbose 2 -hold -brief -file $::alta_work/hold_fast_summary.rpt.gz
set ta_report_auto_constraints 0
report_timing -fmax -file $::alta_work/fmax_fast.rpt
report_timing -xfer -file $::alta_work/xfer_fast.rpt
set ta_report_auto_constraints $ta_report_auto
}
write_routed_design "${RESULT_DIR}/${RESULT}_routed.v"
}
bitgen normal -prg "${RESULT_DIR}/${RESULT}.prg" -bin "${RESULT_DIR}/${RESULT}.bin"
bitgen sram -prg "${RESULT_DIR}/${RESULT}_sram.prg"
bitgen download -bin "${RESULT_DIR}/${RESULT}.bin" -svf "${RESULT_DIR}/${RESULT}_download.svf"
generate_binary -slave "${RESULT_DIR}/${RESULT}_slave.rbf" \
-inputs "${RESULT_DIR}/${RESULT}.bin" -reverse
generate_binary -master "${RESULT_DIR}/${RESULT}_master.bin" \
-inputs "${RESULT_DIR}/${RESULT}.bin"
generate_programming_file "${RESULT_DIR}/${RESULT}_master.bin" -prg "${RESULT_DIR}/${RESULT}_master.prg" \
-as "${RESULT_DIR}/${RESULT}_master_as.prg" -hybrid "${RESULT_DIR}/${RESULT}_hybrid.prg"
}
if { [file exists "./${DESIGN}.post.asf"] } {
alta::tcl_highlight "Using post-ASF file ${DESIGN}.post.asf.\n"
source "./${DESIGN}.post.asf"
}
date_time
exit