Hog v9.71.0
launch.tcl
Go to the documentation of this file.
1 #!/usr/bin/env tclsh
2 # @file
3 # Copyright 2018-2025 The University of Birmingham
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 # Launch Xilinx Vivado or ISE implementation and possibly write bitstream in text mode
19 
20 
21 
22 set default_commands {
23 
24  \^L(IST)?$ {
25  Msg Status "\n** The projects in this repository are:"
26  ListProjects $repo_path $list_all
27  Msg Status "\n"
28  exit 0
29  # NAME*: LIST or L
30  # DESCRIPTION: List the projects in the repository. To show hidden projects use the -all option
31  # OPTIONS: all, verbose
32  }
33 
34  \^H(ELP)?$ {
35  puts "$usage"
36  exit 0
37  # NAME: HELP or H
38  # DESCRIPTION: Display this help message or specific help for each directive
39  # OPTIONS:
40  }
41 
42  \^C(REATE)?$ {#
43  set do_create 1
44  set recreate 1
45  # NAME*: CREATE or C
46  # DESCRIPTION: Create the project, replace it if already existing.
47  # OPTIONS: ext_path.arg, lib.arg, vivado_only, verbose
48  }
49 
50  \^I(MPL(EMENT(ATION)?)?)?$ {#
51  set do_implementation 1
52  set do_bitstream 1
53  set do_compile 1
54  # NAME: IMPLEMENTATION or I
55  # DESCRIPTION: Runs only the implementation, the project must already exist and be synthesised.
56  # OPTIONS: check_syntax, ext_path.arg, njobs.arg, no_bitstream, no_reset, recreate, verbose
57  }
58 
59  \^SYNT(H(ESIS(E)?)?)? {#
60  set do_synthesis 1
61  set do_compile 1
62  # NAME: SYNTH
63  # DESCRIPTION: Run synthesis only, create the project if not existing.
64  # OPTIONS: check_syntax, ext_path.arg, njobs.arg, recreate, verbose
65  }
66 
67  \^S(IM(ULAT(ION|E)?)?)?$ {#
68  set do_simulation 1
69  set do_create 1
70  # NAME*: SIMULATION or S
71  # DESCRIPTION: Simulate the project, creating it if not existing, unless it is a GHDL simulation.
72  # OPTIONS: check_syntax, compile_only, ext_path.arg, lib.arg, recreate, scripts_only, simset.arg, verbose
73  }
74 
75  \^W(ORK(FLOW)?)?$ {#
76  set do_implementation 1
77  set do_synthesis 1
78  set do_bitstream 1
79  set do_compile 1
80  set do_vitis_build 0
81  # NAME*: WORKFLOW or W
82  # DESCRIPTION: Runs the full workflow, creates the project if not existing.
83  # OPTIONS: check_syntax, ext_path.arg, impl_only, bitstream_only, njobs.arg, no_bitstream, recreate, synth_only, vitis_only, xsa.arg verbose
84  }
85 
86  \^(CREATEWORKFLOW|CW)?$ {#
87  set do_implementation 1
88  set do_synthesis 1
89  set do_bitstream 1
90  set do_compile 1
91  set recreate 1
92  set do_vitis_build 0
93  # NAME: CREATEWORKFLOW or CW
94  # DESCRIPTION: Creates the project -even if existing- and launches the complete workflow.
95  # OPTIONS: check_syntax, ext_path.arg, njobs.arg, no_bitstream, synth_only, vivado_only, vitis_only, xsa.arg verbose
96  }
97 
98  \^(CHECKSYNTAX|CS)?$ {#proj
99  set do_check_syntax 1
100  # NAME: CECHSYNTAX or CS
101  # DESCRIPTION: Check the syntax of the project. Only for Vivado, Quartus and Libero projects.
102  # OPTIONS: ext_path.arg, recreate, verbose
103  }
104 
105  \^X(ML)?$ {#proj
106  set do_ipbus_xml 1
107  # NAME: XML or X
108  # DESCRIPTION: Copy, check or create the IPbus XMLs for the project.
109  # OPTIONS: dst_dir.arg, generate, verbose
110  }
111 
112  \^V(IEW)?$ {#proj
113  set do_list_file_parse 1
114  # NAME*: VIEW or V
115  # DESCRIPTION: Print Hog list file contents in a tree-like fashon.
116  # OPTIONS: verbose
117  }
118 
119  \^(CHECKYAML|YML)?$ {
120  set min_n_of_args -1
121  set max_n_of_args 1
122  set do_check_yaml_ref 1
123  # NAME: CHECKYML or YML
124  # DESCRIPTION: Check that the ref to Hog repository in the .gitlab-ci.yml file, matches the one in Hog submodule.
125  # OPTIONS: verbose
126  }
127 
128  \^B(UTTONS)?$ {
129  set min_n_of_args -1
130  set max_n_of_args 1
131  set do_buttons 1
132  # NAME: BUTTONS or B
133  # DESCRIPTION: Add Hog buttons to the Vivado GUI, to check and recreate Hog list and configuration files.
134  # OPTIONS: verbose
135  }
136 
137  \^(CHECKLIST|CL)?$ {#proj
138  set do_check_list_files 1
139  # NAME: CHECKLIST or CL
140  # DESCRIPTION: Check that list and configuration files on disk match what is on the project.
141  # OPTIONS: ext_path.arg, verbose
142  }
143 
144  \^COMPSIM(LIB)?$ {
145  set do_compile_lib 1
146  set argument_is_no_project 1
147  # NAME: COMPSIMLIB or COMPSIM
148  # DESCRIPTION: Compiles the simulation library for the chosen simulator with Vivado.
149  # OPTIONS: dst_dir.arg, verbose
150  }
151 
152  \^RTL(ANALYSIS)?$ {#
153  set do_rtl 1
154  # NAME: RTL or RTLANALYSIS
155  # DESCRIPTION: Elaborate the RTL analysis report for the chosen project.
156  # OPTIONS: check_syntax, recreate, verbose
157  }
158 
159  \^SIG(ASI)?$ {#
160  set do_sigasi 1
161  # NAME: SIGASI or SIG
162  # DESCRIPTION: Create a .csv file to be used in Sigasi.
163  # OPTIONS: verbose
164  }
165 
166  default {
167  if {$directive != ""} {
168  set NO_DIRECTIVE_FOUND 1
169  } else {
170  puts "$usage"
171  exit 0
172  }
173  }
174 }
175 
176 # Add this bit above!
177 # \^NEW_DIRECTIVE?$ {
178 # set do_new_directive 1
179 # }
180 
181 
182 #parsing command options
183 set parameters {
184  {no_bitstream "If set, the bitstream file will not be produced."}
185  {recreate "If set, the project will be re-created if it already exists."}
186  {no_reset "If set, runs (synthesis and implementation) won't be reset before launching them."}
187  {check_syntax "If set, the HDL syntax will be checked at the beginning of the workflow."}
188  {njobs.arg 4 "Number of jobs. Default: 4"}
189  {ext_path.arg "" "Sets the absolute path for the external libraries."}
190  {lib.arg "" "Simulation library path, compiled or to be compiled"}
191  {synth_only "If set, only the synthesis will be performed."}
192  {impl_only "If set, only the implementation will be performed. This assumes synthesis was already done."}
193  {scripts_only "If set, the simulation scripts will be generated, but the simulation will not be run."}
194  {compile_only "If set, the simulation libraries will be compiled, but not run."}
195  {bitstream_only "If set, only the bitstream will be produced. This assumes implementation was already done. For a Vivado-Vitis\
196  project this command can be used to generate the boot artifacts including the ELF file(s) without running the\
197  full Vivado workflow."}
198  {vivado_only "If set, and project is vivado-vitis, vitis project will not be created."}
199  {vitis_only "If set, and project is vivado-vitis create only vitis project. If an xsa is not given, a pre-synth xsa will be created."}
200  {xsa.arg "" "If set, and project is vivado-vitis, use this xsa for creating platforms without a defined hw."}
201  {simset.arg "" "Simulation sets, separated by commas, to be run."}
202  {all "List all projects, including test projects. Test projects have #test on the second line of hog.conf."}
203  {generate "For IPbus XMLs, it will re create the VHDL address decode files."}
204  {dst_dir.arg "" "For reports, IPbus XMLs, set the destination folder (default is in the ./bin folder)."}
205  {verbose "If set, launch the script in verbose mode"}
206 }
207 
208 set tcl_path [file normalize "[file dirname [info script]]"]
209 source $tcl_path/hog.tcl
210 source $tcl_path/create_project.tcl
211 
212 # Quartus needs extra packages and treats the argv in a different way
213 if {[IsQuartus]} {
214  load_package report
215  set argv $quartus(args)
216 }
217 
218 # Msg Debug "s: $::argv0 a: $argv"
219 
220 ### CUSTOM COMMANDS ###
221 set commands_path [file normalize "$tcl_path/../../hog-commands/"]
222 set custom_commands [GetCustomCommands $parameters $commands_path ]
223 
224 lassign [InitLauncher $::argv0 $tcl_path $parameters $default_commands $argv $custom_commands] \
225 directive project project_name group_name repo_path old_path bin_dir top_path usage short_usage cmd ide list_of_options
226 
227 array set options $list_of_options
228 Msg Debug "Returned by InitLauncher: \
229 $project $project_name $group_name $repo_path $old_path $bin_dir $top_path $cmd"
230 
231 set ext_path ""
232 if {$options(ext_path) != ""} {
233  set ext_path $options(ext_path)
234 }
235 set simlib_path ""
236 
237 
238 if {$options(verbose) == 1} {
239  setDebugMode 1
240 }
241 # printDebugMode
242 # Msg Info "Number of jobs set to $options(njobs)."
243 
244 
245 
246 ######## DEFAULTS #########
247 set do_rtl 0
248 set do_implementation 0; set do_synthesis 0; set do_bitstream 0
249 set do_create 0; set do_compile 0; set do_simulation 0; set recreate 0
250 set do_reset 1; set do_list_all 2; set do_check_syntax 0; set do_vitis_build 0;
251 set scripts_only 0; set compile_only 0
252 ### Hog stand-alone directives ###
253 # The following directives are used WITHOUT ever calling the IDE, they are run in tclsh
254 # A place holder called new_directive can be followed to add new commands
255 
256 set do_ipbus_xml 0
257 set do_list_file_parse 0
258 set do_check_yaml_ref 0
259 set do_buttons 0
260 set do_check_list_files 0
261 set do_compile_lib 0
262 set do_sigasi 0
263 
264 set NO_DIRECTIVE_FOUND 0
265 Msg Debug "Looking for a $directive in : $default_commands"
266 switch -regexp -- $directive $default_commands
267 
268 if {$NO_DIRECTIVE_FOUND == 1} {
269  Msg Debug "No directive found in default commands, looking in custom commands..."
270  if {[string length $custom_commands] > 0 && [dict exists $custom_commands $directive]} {
271  Msg Debug "Directive $directive found in custom commands."
272  if {$cmd == "custom_tcl"} {
273  eval [dict get $custom_commands $directive SCRIPT]
274  exit
275  } else {
276  if {[IsTclsh]} {
277  Msg Info "Launching command: $cmd..."
278 
279  # Check if the IDE is actually in the path...
280  set ret [catch {exec which $ide}]
281  if {$ret != 0} {
282  Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
283  exit $ret
284  }
285 
286  if {[string first libero $cmd] >= 0} {
287  # The SCRIPT_ARGS: flag of libero makes tcl crazy...
288  # Let's pipe the command into a shell script and remove it later
289  set libero_script [open "launch-libero-hog.sh" w]
290  puts $libero_script "#!/bin/sh"
291  puts $libero_script $cmd
292  close $libero_script
293  set cmd "sh launch-libero-hog.sh"
294  }
295 
296  set ret [catch {exec -ignorestderr {*}$cmd >@ stdout} result]
297 
298  if {$ret != 0} {
299  Msg Error "IDE returned an error state."
300  } else {
301  Msg Info "All done."
302  exit 0
303  }
304 
305  if {[string first libero $cmd] >= 0} {
306  file delete "launch-libero-hog.sh"
307  }
308 
309  exit $ret
310  }
311 
312  eval [dict get $custom_commands $directive SCRIPT]
313 
314  set no_exit [dict get $custom_commands $directive NO_EXIT]
315  if {$no_exit == 0} {
316  exit
317  }
318  }
319  } else {
320  Msg Info "No directive found, pre ide exiting..."
321  Msg Status "ERROR: Unknown directive $directive.\n\n"
322  puts $usage
323  exit
324  }
325 }
326 
327 if {$options(all) == 1} {
328  set do_list_all 1
329 } else {
330  set do_list_all 2
331 }
332 
333 if {$options(dst_dir) == "" && ($do_ipbus_xml == 1 || $do_check_list_files == 1) && $project != ""} {
334  # Getting all the versions and SHAs of the repository
335  lassign [GetRepoVersions [file normalize $repo_path/Top/$group_name/$project] \
336  $repo_path $ext_path] commit version hog_hash hog_ver top_hash top_ver libs hashes vers \
337  cons_ver cons_hash ext_names ext_hashes xml_hash xml_ver user_ip_repos \
338  user_ip_hashes user_ip_vers
339  cd $repo_path
340 
341  set describe [GetHogDescribe $commit $repo_path]
342  set dst_dir [file normalize "$repo_path/bin/$group_name/$project\-$describe"]
343 }
344 
345 if {$cmd == -1} {
346  #This is if the project was not found
347  Msg Status "\n\nPossible projects are:"
348  ListProjects $repo_path $do_list_all
349  Msg Status "\n"
350  exit 1
351 } elseif {$cmd == -2} {
352  # Project not given but needed
353  Msg Status "ERROR: You must specify a project with directive $directive."
354  # \n\n[cmdline::usage $parameters $usage]"
355  Msg Status "Possible projects are:"
356  ListProjects $repo_path $do_list_all
357  exit 1
358 } elseif {$cmd == 0} {
359  #This script was launched within the IDE,: Vivado, Quartus, etc
360  Msg Info "$::argv0 was launched from the IDE."
361 } else {
362  # This script was launched with Tclsh, we need to check the arguments
363  # and if everything is right launch the IDE on this script and return
364 
365 
366 
367 
368  #### Directives to be handled in tclsh should be here ###
369  ### IMPORTANT: Each if block should either end with "exit 0" or
370  ### set both $ide and $cmd to be executed when this script is run again
371 
372  if {$do_ipbus_xml == 1} {
373  Msg Info "Handling IPbus XMLs for $project_name..."
374 
375  set proj_dir $repo_path/Top/$project_name
376 
377  if {$options(generate) == 1} {
378  set xml_gen 1
379  } else {
380  set xml_gen 0
381  }
382 
383 
384  set xml_dst "$dst_dir/xml"
385 
386 
387  if {[llength [glob -nocomplain $proj_dir/list/*.ipb]] > 0} {
388  if {![file exists $xml_dst]} {
389  Msg Info "$xml_dst directory not found, creating it..."
390  file mkdir $xml_dst
391  }
392  } else {
393  Msg Error "No .ipb files found in $proj_dir/list/"
394  exit
395  }
396 
397  set ret [GetRepoVersions $proj_dir $repo_path ""]
398  set sha [lindex $ret 13]
399  set hex_ver [lindex $ret 14]
400 
401  set ver [HexVersionToString $hex_ver]
402  CopyIPbusXMLs $proj_dir $repo_path $xml_dst $ver $sha 1 $xml_gen
403 
404  exit 0
405  }
406 
407  if {$do_list_file_parse == 1} {
408  set proj_dir $repo_path/Top/$project_name
409  set proj_list_dir $repo_path/Top/$project_name/list
410  GetHogFiles -print_log -list_files {.src,.con,.sim,.ext,.ipb} $proj_list_dir $repo_path
411  Msg Status " "
412  Msg Info "All Done."
413  exit 0
414  }
415 
416  if {$do_sigasi == 1} {
417  cd $repo_path
418  Msg Info "Creating Sigasi CSV files for project $project_name..."
419  set proj_dir $repo_path/Top/$project_name
420  set proj_list_dir $repo_path/Top/$project_name/list
421  set project [file tail $project_name]
422  lassign [GetHogFiles -list_files {.src} $proj_list_dir $repo_path] libraries
423  set csv_file [open "sigasi_$project.csv" w]
424  foreach lib $libraries {
425  set source_files [DictGet $libraries $lib]
426  foreach source_file $source_files {
427  if {[file extension $source_file] == ".vhd" ||
428  [file extension $source_file] == ".vhdl" ||
429  [file extension $source_file] == ".sv" ||
430  [file extension $source_file] == ".v" } {
431  puts $csv_file [ concat [file rootname $lib] "," $source_file ]
432  }
433  }
434  }
435  close $csv_file
436  Msg Info "Sigasi CSV file created: sigasi_$project.csv"
437  Msg Info "You can use the python script provided by Sigasi to convert the generated csv file into a Sigasi project."
438  Msg Info "More info at: https://www.sigasi.com/knowledge/how_tos/generating-sigasi-project-vivado-project/#2-generate-the-sigasi-project-files-from-the-csv-file"
439  exit 0
440  }
441 
442  if {$do_check_yaml_ref == 1} {
443  Msg Info "Checking if \"ref\" in .gitlab-ci.yml actually matches the included yml file in Hog submodule"
444  CheckYmlRef $repo_path false
445  exit 0
446  }
447 
448  if {$do_buttons == 1} {
449  Msg Info "Adding Hog buttons to Vivado bar (will use the vivado currently in PATH)..."
450  set ide vivado
451  set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/add_hog_custom_button.tcl"
452  }
453 
454  if {$do_compile_lib == 1} {
455  if {$project eq ""} {
456  Msg Error "You need to specify a simulator as first argument."
457  exit 1
458  } else {
459  set simulator $project
460  Msg Info "Selecting $simulator simulator..."
461  }
462  if {$options(dst_dir) != ""} {
463  set output_dir $options(dst_dir)
464  } else {
465  Msg Info "No destination directory defined. Using default: SimulationLib/"
466  set output_dir "SimulationLib"
467  }
468 
469  set ide vivado
470  set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/compile_simlib.tcl -tclargs -simulator $simulator -output_dir $output_dir"
471  }
472 
473  set simsets ""
474  if {$do_simulation == 1} {
475  # Get all simsets in the project that run with GHDL
476  set ghdl_simsets [GetSimSets $project_name $repo_path "$options(simset)" 1]
477  set ghdl_import 0
478  dict for {simset_name simset_dict} $ghdl_simsets {
479  if {$ghdl_import == 0} {
480  ImportGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
481  set ghdl_import 1
482  }
483  LaunchGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
484  # dict unset simsets_dict $simset_name
485  }
486  set ide_simsets [GetSimSets $project_name $repo_path $options(simset) 0 1]
487 
488  if {[dict size $ide_simsets] == 0} {
489  # All simulations have been run, exiting
490  Msg Info "All simulations have been run, exiting..."
491  exit 0
492  }
493  }
494 
495  # if {$do_new_directive ==1 } {
496  #
497  # # Do things here
498  #
499  # exit 0
500  #}
501 
502  #### END of tclsh commands ####
503  Msg Info "Launching command: $cmd..."
504 
505  # Check if the IDE is actually in the path...
506  set ret [catch {exec which $ide}]
507  if {$ret != 0} {
508  Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
509  exit $ret
510  }
511 
512  if {[string first libero $cmd] >= 0} {
513  # The SCRIPT_ARGS: flag of libero makes tcl crazy...
514  # Let's pipe the command into a shell script and remove it later
515  set libero_script [open "launch-libero-hog.sh" w]
516  puts $libero_script "#!/bin/sh"
517  puts $libero_script $cmd
518  close $libero_script
519  set cmd "sh launch-libero-hog.sh"
520  }
521 
522  set ret [catch {exec -ignorestderr {*}$cmd >@ stdout} result]
523 
524  if {$ret != 0} {
525  Msg Error "IDE returned an error state."
526  } else {
527  Msg Info "All done."
528  exit 0
529  }
530 
531  if {[string first libero $cmd] >= 0} {
532  file delete "launch-libero-hog.sh"
533  }
534 
535  exit $ret
536 }
537 
538 #After this line, we are in the IDE
539 ##################################################################################
540 
541 
542 # We need to Import tcllib if we are using Libero
543 if {[IsLibero] || [IsDiamond]} {
544  if {[info exists env(HOG_TCLLIB_PATH)]} {
545  lappend auto_path $env(HOG_TCLLIB_PATH)
546  } else {
547  puts "ERROR: To run Hog with Microsemi Libero SoC or Lattice Diamond,\
548  you need to define the HOG_TCLLIB_PATH variable."
549  return
550  }
551 }
552 
553 if {[catch {package require cmdline} ERROR] || [catch {package require struct::matrix} ERROR]} {
554  puts "$ERROR\n Tcllib not found. If you are running this script on tclsh for debuggin purpose ONLY, you can fix this by installing 'tcllib'"
555  exit 1
556 }
557 
558 set run_folder [file normalize "$repo_path/Projects/$project_name/$project.runs/"]
559 if {[IsLibero]} {
560  set run_folder [file normalize "$repo_path/Projects/$project_name/"]
561 }
562 
563 # Only for quartus, not used otherwise
564 set project_path [file normalize "$repo_path/Projects/$project_name/"]
565 
566 # Get IDE name from project config file
567 set proj_conf [ProjectExists $project_name $repo_path]
568 set ide_name_and_ver [string tolower [GetIDEFromConf $proj_conf]]
569 set ide_name [lindex [regexp -all -inline {\S+} $ide_name_and_ver] 0]
570 
571 if {$options(no_bitstream) == 1} {
572  set do_bitstream 0
573  set do_compile 0
574 }
575 
576 if {$options(recreate) == 1} {
577  set recreate 1
578 }
579 
580 if {$options(synth_only) == 1} {
581  set do_implementation 0
582  set do_synthesis 1
583  set do_bitstream 0
584  set do_create 1
585  set do_compile 1
586 }
587 
588 if {$options(impl_only) == 1} {
589  set do_implementation 1
590  set do_synthesis 0
591  set do_bitstream 0
592  set do_create 0
593  set do_compile 1
594 }
595 
596 
597 if {$options(vitis_only) == 1 || $ide_name eq "vitis_classic"} {
598  set do_vitis_build 1
599  set do_implementation 0
600  set do_synthesis 0
601  set do_bitstream 0
602  set do_create 0
603  set do_compile 0
604 }
605 
606 if {$options(bitstream_only) == 1} {
607  set do_bitstream_only 1
608  set do_bitstream 0
609  set do_implementation 0
610  set do_synthesis 0
611  set do_create 0
612  set do_compile 0
613 } else {
614  set do_bitstream_only 0
615 }
616 
617 if {$options(vivado_only) == 1} {
618  set do_vitis_build 0
619 }
620 
621 if {$options(no_reset) == 1} {
622  set do_reset 0
623 }
624 
625 if {$options(check_syntax) == 1} {
626  set do_check_syntax 1
627 }
628 
629 if {$options(scripts_only) == 1} {
630  set scripts_only 1
631 }
632 
633 if {$options(compile_only) == 1} {
634  set compile_only 1
635 }
636 
637 
638 
639 if {$options(lib) != ""} {
640  set lib_path [file normalize $options(lib)]
641 } else {
642  if {[info exists env(HOG_SIMULATION_LIB_PATH)]} {
643  set lib_path $env(HOG_SIMULATION_LIB_PATH)
644  } else {
645  if {[file exists "$repo_path/SimulationLib"]} {
646  set lib_path [file normalize "$repo_path/SimulationLib"]
647  } else {
648  set lib_path ""
649  }
650  }
651 }
652 
653 
654 Msg Info "Number of jobs set to $options(njobs)."
655 
656 ############## Quartus ########################
657 set argv ""
658 
659 ############# CREATE or OPEN project ############
660 if {[IsISE]} {
661  cd $tcl_path
662  set project_file [file normalize $repo_path/Projects/$project_name/$project.ppr]
663 } elseif {[IsVivado]} {
664  cd $tcl_path
665  set project_file [file normalize $repo_path/Projects/$project_name/$project.xpr]
666 } elseif {[IsVitisClassic]} {
667  cd $tcl_path
668  set project_file [file normalize $repo_path/Projects/$project_name/vitis_classic/.metadata/]
669  Msg Info "Setting project file for Vitis Classic project $project_name to $project_file"
670 } elseif {[IsQuartus]} {
671  if {[catch {package require ::quartus::project} ERROR]} {
672  Msg Error "$ERROR\n Can not find package ::quartus::project"
673  cd $old_path
674  return 1
675  } else {
676  Msg Info "Loaded package ::quartus::project"
677  load_package flow
678  }
679  set project_file "$project_path/$project.qpf"
680 } elseif {[IsLibero]} {
681  set project_file [file normalize $repo_path/Projects/$project_name/$project.prjx]
682 } elseif {[IsDiamond]} {
683  sys_install version
684  set project_file [file normalize $repo_path/Projects/$project_name/$project.ldf]
685 }
686 
687 if {[file exists $project_file]} {
688  Msg Info "Found project file $project_file for $project_name."
689  set proj_found 1
690 } else {
691  Msg Info "Project file not found for $project_name."
692  set proj_found 0
693 }
694 
695 if {($proj_found == 0 || $recreate == 1)} {
696  Msg Info "Creating (possibly replacing) the project $project_name..."
697  Msg Debug "launch.tcl: calling GetConfFiles with $repo_path/Top/$project_name"
698  lassign [GetConfFiles $repo_path/Top/$project_name] conf sim pre post
699 
700  if {[file exists $conf]} {
701  # Still not sure of the difference between project and project_name
702  if {$options(vivado_only) == 1} {
703  CreateProject -simlib_path $lib_path -xsa $options(xsa) -vivado_only $project_name $repo_path
704  } else {
705  CreateProject -simlib_path $lib_path -xsa $options(xsa) $project_name $repo_path
706  }
707  Msg Info "Done creating project $project_name."
708  } else {
709  Msg Error "Project $project_name is incomplete: no hog.conf file found, please create one..."
710  }
711 } else {
712  Msg Info "Opening existing project file $project_file..."
713  if {[IsXilinx]} {
714  file mkdir "$repo_path/Projects/$project_name/$project.gen/sources_1"
715  }
716 
717  if {[IsVitisClassic]} {
718  set vitis_workspace [file normalize $repo_path/Projects/$project_name/vitis_classic/]
719  Msg Info "Setting workspace to $vitis_workspace"
720  setws $vitis_workspace
721 
722  } else {
723  OpenProject $project_file $repo_path
724  }
725 }
726 
727 
728 ########## CHECK SYNTAX ###########
729 if {$do_check_syntax == 1} {
730  Msg Info "Checking syntax for project $project_name..."
731  CheckSyntax $project_name $repo_path $project_file
732 }
733 
734 
735 ######### RTL ANALYSIS ########
736 if {$do_rtl == 1} {
738 }
739 
740 if {$do_vitis_build == 1} {
741  if {[IsVitisClassic]} {
742  LaunchVitisBuild $project_name $repo_path
743  } else {
744  set xsct_cmd "xsct $tcl_path/launch.tcl W -vitis_only $project_name"
745  set ret [catch {exec -ignorestderr {*}$xsct_cmd >@ stdout} result]
746  if {$ret != 0} {
747  Msg Error "xsct (vitis classic) returned an error state."
748  }
749  }
750 }
751 
752 ######### LaunchSynthesis ########
753 if {$do_synthesis == 1} {
754  LaunchSynthesis $do_reset $do_create $run_folder $project_name $repo_path $ext_path $options(njobs)
755 }
756 
757 if {$do_implementation == 1} {
758  LaunchImplementation $do_reset $do_create $run_folder $project_name $repo_path $options(njobs) $do_bitstream
759 }
760 
761 if {$do_bitstream_only == 1 && [IsXilinx]} {
762  GenerateBitstreamOnly $project_name $repo_path
763 } elseif {$do_bitstream_only == 1 && ![IsXilinx]} {
764  Msg Error "Bitstream only option is not supported for this IDE."
765 }
766 
767 if {$do_bitstream == 1 && ![IsXilinx]} {
768  GenerateBitstream $run_folder $repo_path $options(njobs)
769 }
770 
771 if {$do_simulation == 1} {
772  # set simsets $options(simset)
773  set simsets [GetSimSets $project_name $repo_path $options(simset)]
774  LaunchSimulation $project_name $lib_path $simsets $repo_path $scripts_only $compile_only
775 }
776 
777 
778 if {$do_check_list_files} {
779  Msg Info "Running list file checker..."
780 
781  #if {![file exists $dst_dir]} {
782  # Msg Info "$dst_dir directory not found, creating it..."
783  # file mkdir $dst_dir
784  # }
785 
786 
787  set argv0 check_list_files
788  if {$ext_path ne ""} {
789  set argv [list "-ext_path" "$ext_path" "-outDir" "$dst_dir" "-pedantic"]
790  } else {
791  set argv [list "-outDir" "$dst_dir" "-pedantic"]
792  }
793 
794  source $tcl_path/utils/check_list_files.tcl
795 }
796 ## CLOSE Project
798 
799 Msg Info "All done."
800 cd $old_path