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