21 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
22 source $tcl_path/hog.tcl
23 set repo_path [
file normalize "$tcl_path/../../"]
27 if {[
info exists env(HOG_TCLLIB_PATH)]} {
28 lappend auto_path $env(HOG_TCLLIB_PATH)
30 puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
35 if {[
info exists env(HOG_EXTERNAL_PATH)]} {
36 set ext_path $env(HOG_EXTERNAL_PATH)
37 Msg Info "Found environment variable HOG_EXTERNAL_PATH, setting path for external files to $ext_path..."
42 set bin_dir [
file normalize "$repo_path/bin"]
51 set work_path [get_property DIRECTORY [get_runs impl_1]]
54 set work_path $old_path
55 if {[
IsVersal [get_property PART [current_design]]]} {
61 set main_files [lsort [glob -nocomplain "$work_path/*.$fw_file_ext"]]
62 if {[
llength $main_files] > 1} {
65 set main_file [
file normalize [
lindex $main_files 1]]
67 set secondary_file [
file normalize [
lindex $main_files 0]]
68 set main_file_suffix "_pld"
69 set secondary_file_suffix "_boot"
70 Msg Info "Found main and secondary binary file main: [
file tail $main_file], secondary: [
file tail $secondary_file]..."
72 set top_name [regsub $main_file_suffix\$ [
file rootname [
file tail $main_file]] ""]
73 if {[
llength $main_files] > 2} {
74 Msg Warning "Multiple (more than 2) binary files found: $main_files."
77 set main_file [
file normalize [
lindex $main_files 0]]
78 set main_file_suffix ""
80 set secondary_file_suffix ""
81 set top_name [
file rootname [
file tail $main_file]]
85 set proj_name [
file tail [
file normalize $work_path/../../]]
86 set proj_dir [
file normalize "$work_path/../.."]
89 set additional_ext ".bin .ltx .bif"
91 set xml_dir [
file normalize "$work_path/../xml"]
92 set run_dir [
file normalize "$work_path/.."]
96 set proj_name [
lindex $quartus(args) 1]
98 set xml_dir [
file normalize "$repo_path/xml"]
99 set run_dir [
file normalize "$proj_dir"]
100 set name [
file rootname [
file tail [
file normalize [
pwd]]]]
102 set pof_file [
file normalize "$proj_dir/output_files/$proj_name.pof"]
104 set sof_file [
file normalize "$proj_dir/output_files/$proj_name.sof"]
106 set rbf_file [
file normalize "$proj_dir/output_files/$proj_name.rbf"]
108 set rpd_file [
file normalize "$proj_dir/output_files/$proj_name.rpd"]
110 set stp_file [
file normalize "$proj_dir/output_files/$proj_name.stp"]
112 set spf_file [
file normalize "$proj_dir/output_files/$proj_name.spf"]
116 set proj_name $project
118 set proj_dir $main_folder
119 set map_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.map"] 0]]
120 set sap_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.sap"] 0]]
121 set srd_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.srd"] 0]]
122 set srm_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.srm"] 0]]
123 set srs_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.srs"] 0]]
124 set srr_file [
file normalize [
lindex [glob -nocomplain "$proj_dir/synthesis/*.srr"] 0]]
125 set top_name [
file rootname [
file tail $srr_file]]
126 set stxt_files [glob -nocomplain "$proj_dir/synthesis/*.txt"]
127 set scsv_files [glob -nocomplain "$proj_dir/synthesis/*.csv"]
128 set slog_files [glob -nocomplain "$proj_dir/synthesis/*.log"]
129 set srpt_files [glob -nocomplain "$proj_dir/synthesis/*.rpt"]
130 set dtxt_files [glob -nocomplain "$proj_dir/designer/$top_name/*.txt"]
131 set dcsv_files [glob -nocomplain "$proj_dir/designer/$top_name/*.csv"]
132 set dlog_files [glob -nocomplain "$proj_dir/designer/$top_name/*.log"]
133 set drpt_files [glob -nocomplain "$proj_dir/designer/$top_name/*.rpt"]
134 set xml_dir [
file normalize "$repo_path/xml"]
136 set proj_dir [
file normalize "[
pwd]/.."]
137 set proj_name [
file tail $proj_dir]
138 set project $proj_name
139 set xml_dir [
file normalize "$repo_path/xml"]
140 set main_file [
file normalize "$proj_dir/Implementation0/${proj_name}_Implementation0"]
143 set work_path $old_path
144 set fw_file [
file normalize [
lindex [glob -nocomplain "$work_path/*.bit"] 0]]
145 set proj_name [
file tail [
file normalize $work_path/../../]]
146 set proj_dir [
file normalize "$work_path/../.."]
148 set top_name [
file rootname [
file tail $fw_file]]
150 set main_file [
file normalize "$work_path/$top_name.bit"]
151 set bin_file [
file normalize "$work_path/$top_name.bin"]
152 set ltx_file [
file normalize "$work_path/$top_name.ltx"]
154 set xml_dir [
file normalize "$work_path/../xml"]
155 set run_dir [
file normalize "$work_path/.."]
158 set group_name [
GetGroupName $proj_dir "$tcl_path/../.."]
162 Msg Info "Evaluating Git sha for $proj_name..."
163 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] sha
166 Msg Info "Hog describe set to: $describe"
168 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
169 set dst_xml [
file normalize "$dst_dir/xml"]
171 Msg Info "Creating $dst_dir..."
174 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
178 if {[
IsXilinx] && [
file exists $main_file]} {
179 set dst_main [
file normalize "$dst_dir/$proj_name$main_file_suffix\-$describe.$fw_file_ext"]
180 Msg Info "Copying main binary file $main_file into $dst_main..."
181 file copy -force $main_file $dst_main
182 if {$secondary_file != ""} {
183 set dst_secondary [
file normalize "$dst_dir/$proj_name$secondary_file_suffix\-$describe.$fw_file_ext"]
184 Msg Info "Copying secondary binary file $secondary_file into $dst_secondary..."
185 file copy -force $secondary_file $dst_secondary
193 lappend ltx_files "$top_name.ltx"
195 if {$main_file_suffix != ""} {
196 foreach e $additional_ext {
198 lappend new_ext $main_file_suffix$e
199 lappend new_ext $secondary_file_suffix$e
200 lappend ltx_files "$top_name$main_file_suffix.ltx"
201 lappend ltx_files "$top_name$secondary_file_suffix.ltx"
203 set additional_ext $new_ext
208 foreach l $ltx_files {
209 set ltx_file "$work_path/$l"
210 Msg Info "Writing debug probes for $ltx_file..."
211 write_debug_probes -quiet $ltx_file
214 foreach e $additional_ext {
215 set orig [
file normalize "$work_path/$top_name$e"]
216 set dst [
file normalize "$dst_dir/$proj_name\-$describe$e"]
217 if {[
file exists $work_path/$top_name$e] == 1} {
218 Msg Info "Copying $orig file into $dst..."
219 file copy -force $orig $dst
221 Msg Debug "File: $orig not found."
225 set dst_pof [
file normalize "$dst_dir/$name\-$describe.pof"]
226 set dst_sof [
file normalize "$dst_dir/$name\-$describe.sof"]
227 set dst_rbf [
file normalize "$dst_dir/$name\-$describe.rbf"]
228 set dst_rpd [
file normalize "$dst_dir/$name\-$describe.rpd"]
229 set dst_stp [
file normalize "$dst_dir/$name\-$describe.stp"]
230 set dst_spf [
file normalize "$dst_dir/$name\-$describe.spf"]
231 set dst_xml [
file normalize "$dst_dir/xml"]
233 Msg Info "Evaluating differences with last commit..."
234 set found_uncommitted 0
237 set found_uncommitted 1
238 Msg Warning "Found non committed changes:"
240 set fp [open "$dst_dir/diff_postbistream.txt" w+]
245 if {$found_uncommitted == 0} {
246 Msg Info "No uncommitted changes found."
250 if {[
file exists $pof_file]} {
251 Msg Info "Copying pof file $pof_file into $dst_pof..."
252 file copy -force $pof_file $dst_pof
254 Msg Info "No pof file found: $pof_file, that is not a problem"
258 file mkdir $dst_dir/reports
259 set reps [glob -nocomplain "$proj_dir/output_files/*.rpt"]
261 if {[
file exists [
lindex $reps 0]]} {
262 file copy -force {*}$reps $dst_dir/reports
264 Msg Warning "No reports found in $proj_dir/output_files subfolders"
268 if {[
file exists $sof_file]} {
269 Msg Info "Copying sof file $sof_file into $dst_sof..."
270 file copy -force $sof_file $dst_sof
272 Msg Info "No sof file found: $sof_file, that is not a problem"
277 if {[
file exists $rbf_file] || [
file exists $rpd_file]} {
278 if {[
file exists $rbf_file]} {
279 file copy -force $rbf_file $dst_rbf
281 if {[
file exists $rpd_file]} {
282 file copy -force $rpd_file $dst_rpd
285 Msg Info "No rbf or rpd file found: this is not a problem"
289 if {[
file exists $stp_file] || [
file exists $spf_file]} {
290 if {[
file exists $stp_file]} {
291 file copy -force $stp_file $dst_stp
293 if {[
file exists $spf_file]} {
294 file copy -force $spf_file $dst_spf
297 Msg Info "No stp or spf file found: that is not a problem"
300 set dst_map [
file normalize "$dst_dir/$project\-$describe.map"]
301 set dst_sap [
file normalize "$dst_dir/$project\-$describe.sap"]
302 set dst_srd [
file normalize "$dst_dir/$project\-$describe.srd"]
303 set dst_srm [
file normalize "$dst_dir/$project\-$describe.srm"]
304 set dst_srs [
file normalize "$dst_dir/$project\-$describe.srs"]
305 set dst_srr [
file normalize "$dst_dir/$project\-$describe.srr"]
306 set dst_rpt [
file normalize "$dst_dir/reports"]
307 set dst_xml [
file normalize "$dst_dir/xml"]
309 file mkdir $dst_dir/reports
311 if {[
file exists $map_file]} {
312 Msg Info "Copying map file $map_file into $dst_map..."
313 file copy -force $map_file $dst_map
316 if {[
file exists $sap_file]} {
317 Msg Info "Copying sap file $sap_file into $dst_sap..."
318 file copy -force $sap_file $dst_sap
321 if {[
file exists $srd_file]} {
322 Msg Info "Copying srd file $srd_file into $dst_srd..."
323 file copy -force $srd_file $dst_srd
326 if {[
file exists $srm_file]} {
327 Msg Info "Copying srm file $srm_file into $dst_srm..."
328 file copy -force $srm_file $dst_map
331 if {[
file exists $srs_file]} {
332 Msg Info "Copying srs file $srs_file into $dst_srs..."
333 file copy -force $srs_file $dst_srs
336 if {[
file exists $srr_file]} {
337 Msg Info "Copying srr file $srr_file into $dst_srr..."
338 file copy -force $srr_file $dst_srr
342 Msg Info "Copying synth txt files $stxt_files into $dst_rpt..."
343 file copy -force {*}$stxt_files $dst_rpt
344 Msg Info "Copying synth csv files $scsv_files into $dst_rpt..."
345 file copy -force {*}$scsv_files $dst_rpt
346 Msg Info "Copying synth log files $slog_files into $dst_rpt..."
347 file copy -force {*}$slog_files $dst_rpt
348 Msg Info "Copying synth rpt files $srpt_files into $dst_rpt..."
349 file copy -force {*}$srpt_files $dst_rpt
351 Msg Info "Copying impl txt files $dtxt_files into $dst_rpt..."
352 file copy -force {*}$dtxt_files $dst_rpt
353 Msg Info "Copying impl csv files $dcsv_files into $dst_rpt..."
354 file copy -force {*}$dcsv_files $dst_rpt
355 Msg Info "Copying impl log files $dlog_files into $dst_rpt..."
356 file copy -force {*}$dlog_files $dst_rpt
357 Msg Info "Copying impl rpt files $drpt_files into $dst_rpt..."
358 file copy -force {*}$drpt_files $dst_rpt
360 set dst_main [
file normalize "$dst_dir/$proj_name\-$describe.bit"]
361 Msg Info "Copying main binary file $main_file.bit into $dst_main..."
362 file copy -force $main_file.bit $dst_main
363 Msg Info "Copying binary generation log $main_file.bgn into $dst_dir/reports..."
364 file copy -force $main_file.bgn $dst_dir/reports
366 Msg CriticalWarning "Firmware binary file not found."
371 if {[
file exists $xml_dir]} {
372 Msg Info "XML directory found, copying xml files from $xml_dir to $dst_xml..."
373 if {[
file exists $dst_xml]} {
374 Msg Info "Directory $dst_xml exists, deleting it..."
375 file delete -force $dst_xml
377 file copy -force $xml_dir $dst_xml
384 set export_xsa "NONE"
385 set part [get_property part [current_project]]
389 if {[dict exists $properties "hog"]} {
390 set propDict [dict get $properties "hog"]
391 if {[dict exists $propDict "EXPORT_XSA"]} {
392 set export_xsa [dict get $propDict "EXPORT_XSA"]
396 if {$export_xsa == "NONE"} {
399 Msg Info "SoC FPGA detected (Zynq or Versal), automatically enabling XSA file creation. \
400 To disable it, add 'EXPORT_XSA = false' in the \[hog\] section of hog.conf."
405 if {[
string compare [
string tolower $export_xsa] "true"] == 0} {
408 regexp -- {Vivado v([0-9]{4}\.[0-9,A-z,_,\.]*) } [version] -> VIVADO_VERSION
409 if {[
string compare "2020.1" $VIVADO_VERSION] == 0} {
410 Msg Warning "Vivado 2020.1, a patch must be applied to Vivado to export XSA Files, c.f. https://www.xilinx.com/support/answers/75210.html"
412 set dst_xsa [
file normalize "$dst_dir/${proj_name}\-$describe.xsa"]
413 Msg Info "Generating XSA File at $dst_xsa"
417 set user_pre_platform_file "./Top/$group_name/$proj_name/pre-platform.tcl"
418 if {[
file exists $user_pre_platform_file]} {
419 Msg Info "Sourcing user pre-platform file $user_pre_platform_file"
420 source $user_pre_platform_file
424 if {$secondary_file == ""} {
425 set pdi_post_imp [
file normalize "$work_path/$top_name.pdi"]
426 set_property platform.full_pdi_file $pdi_post_imp [current_project]
427 Msg Info "XSA file will be generated for Versal with this PDI: $pdi_post_imp"
428 write_hw_platform -fixed -force -file "$dst_xsa"
430 Msg Warning "No XSA will be produced in post-bitream for segmented configuration mode. \
431 If you're running with the GUI, please type the following on the Tcl console: write_hw_platform -fixed -force -file $dst_xsa."
434 write_hw_platform -include_bit -fixed -force -file "$dst_xsa"
442 set user_post_bitstream_file "./Top/$group_name/$proj_name/post-bitstream.tcl"
443 if {[
file exists $user_post_bitstream_file]} {
444 Msg Info "Sourcing user post-bitstream file $user_post_bitstream_file"
445 source $user_post_bitstream_file