22 set default_commands {
25 Msg Status "\n** The projects in this repository are:"
26 ListProjects $repo_path $list_all
30 # DESCRIPTION: List the projects in the repository. To show hidden projects use the -all option
31 # OPTIONS: all, verbose
38 # DESCRIPTION: Display this help message or specific help for each directive
46 # DESCRIPTION: Create the project, replace it if already existing.
47 # OPTIONS: ext_path.arg, lib.arg, vivado_only, verbose
50 \^I(MPL(EMENT(ATION)?)?)?$ {#
51 set do_implementation 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
59 \^SYNT(H(ESIS(E)?)?)? {#
63 # DESCRIPTION: Run synthesis only, create the project if not existing.
64 # OPTIONS: check_syntax, ext_path.arg, njobs.arg, recreate, verbose
67 \^S(IM(ULAT(ION|E)?)?)?$ {#
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
76 set do_implementation 1
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
86 \^(CREATEWORKFLOW|CW)?$ {#
87 set do_implementation 1
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
98 \^(CHECKSYNTAX|CS)?$ {#proj
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
108 # DESCRIPTION: Copy, check or create the IPbus XMLs for the project.
109 # OPTIONS: dst_dir.arg, generate, verbose
113 set do_list_file_parse 1
115 # DESCRIPTION: Print Hog list file contents in a tree-like fashon.
119 \^(CHECKYAML|YML)?$ {
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.
133 # DESCRIPTION: Add Hog buttons to the Vivado GUI, to check and recreate Hog list and configuration files.
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
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
154 # NAME: RTL or RTLANALYSIS
155 # DESCRIPTION: Elaborate the RTL analysis report for the chosen project.
156 # OPTIONS: check_syntax, recreate, verbose
161 # NAME: SIGASI or SIG
162 # DESCRIPTION: Create a .csv file to be used in Sigasi.
167 if {$directive != ""} {
168 set NO_DIRECTIVE_FOUND 1
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"}
208 set tcl_path [
file normalize "[
file dirname [
info script]]"]
209 source $tcl_path/hog.tcl
210 source $tcl_path/create_project.tcl
215 set argv $quartus(args)
221 set commands_path [
file normalize "$tcl_path/../../hog-commands/"]
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
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"
232 if {$options(ext_path) != ""} {
233 set ext_path $options(ext_path)
238 if {$options(verbose) == 1} {
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
257 set do_list_file_parse 0
258 set do_check_yaml_ref 0
260 set do_check_list_files 0
264 set NO_DIRECTIVE_FOUND 0
265 Msg Debug "Looking for a $directive in : $default_commands"
266 switch -regexp -- $directive $default_commands
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]
277 Msg Info "Launching command: $cmd..."
280 set ret [
catch {
exec which $ide}]
282 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
286 if {[
string first libero $cmd] >= 0} {
289 set libero_script [open "launch-libero-hog.sh" w]
290 puts $libero_script "#!/bin/sh"
291 puts $libero_script $cmd
293 set cmd "sh launch-libero-hog.sh"
296 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
299 Msg Error "IDE returned an error state."
305 if {[
string first libero $cmd] >= 0} {
306 file delete "launch-libero-hog.sh"
312 eval [dict get $custom_commands $directive SCRIPT]
314 set no_exit [dict get $custom_commands $directive NO_EXIT]
320 Msg Info "No directive found, pre ide exiting..."
321 Msg Status "ERROR: Unknown directive $directive.\n\n"
327 if {$options(all) == 1} {
333 if {$options(dst_dir) == "" && ($do_ipbus_xml == 1 || $do_check_list_files == 1) && $project != ""} {
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
342 set dst_dir [
file normalize "$repo_path/bin/$group_name/$project\-$describe"]
347 Msg Status "\n\nPossible projects are:"
351 }
elseif {$cmd == -2} {
353 Msg Status "ERROR: You must specify a project with directive $directive."
355 Msg Status "Possible projects are:"
358 }
elseif {$cmd == 0} {
360 Msg Info "$::argv0 was launched from the IDE."
372 if {$do_ipbus_xml == 1} {
373 Msg Info "Handling IPbus XMLs for $project_name..."
375 set proj_dir $repo_path/Top/$project_name
377 if {$options(generate) == 1} {
384 set xml_dst "$dst_dir/xml"
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..."
393 Msg Error "No .ipb files found in $proj_dir/list/"
398 set sha [
lindex $ret 13]
399 set hex_ver [
lindex $ret 14]
402 CopyIPbusXMLs $proj_dir $repo_path $xml_dst $ver $sha 1 $xml_gen
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
416 if {$do_sigasi == 1} {
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]
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"
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"
448 if {$do_buttons == 1} {
449 Msg Info "Adding Hog buttons to Vivado bar (will use the vivado currently in PATH)..."
451 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/add_hog_custom_button.tcl"
454 if {$do_compile_lib == 1} {
455 if {$project eq ""} {
456 Msg Error "You need to specify a simulator as first argument."
459 set simulator $project
460 Msg Info "Selecting $simulator simulator..."
462 if {$options(dst_dir) != ""} {
463 set output_dir $options(dst_dir)
465 Msg Info "No destination directory defined. Using default: SimulationLib/"
466 set output_dir "SimulationLib"
470 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/compile_simlib.tcl -tclargs -simulator $simulator -output_dir $output_dir"
474 if {$do_simulation == 1} {
476 set ghdl_simsets [
GetSimSets $project_name $repo_path "$options(simset)" 1]
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
483 LaunchGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
484 # dict unset simsets_dict $simset_name
486 set ide_simsets [
GetSimSets $project_name $repo_path $options(simset) 0 1]
488 if {[dict size $ide_simsets] == 0} {
490 Msg Info "All simulations have been run, exiting..."
503 Msg Info "Launching command: $cmd..."
506 set ret [
catch {
exec which $ide}]
508 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
512 if {[
string first libero $cmd] >= 0} {
515 set libero_script [open "launch-libero-hog.sh" w]
516 puts $libero_script "#!/bin/sh"
517 puts $libero_script $cmd
519 set cmd "sh launch-libero-hog.sh"
522 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
525 Msg Error "IDE returned an error state."
531 if {[
string first libero $cmd] >= 0} {
532 file delete "launch-libero-hog.sh"
544 if {[
info exists env(HOG_TCLLIB_PATH)]} {
545 lappend auto_path $env(HOG_TCLLIB_PATH)
547 puts "ERROR: To run Hog with Microsemi Libero SoC or Lattice Diamond,\
548 you need to define the HOG_TCLLIB_PATH variable."
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'"
558 set run_folder [
file normalize "$repo_path/Projects/$project_name/$project.runs/"]
560 set run_folder [
file normalize "$repo_path/Projects/$project_name/"]
564 set project_path [
file normalize "$repo_path/Projects/$project_name/"]
569 set ide_name [
lindex [regexp -all -inline {\S+} $ide_name_and_ver] 0]
571 if {$options(no_bitstream) == 1} {
576 if {$options(recreate) == 1} {
580 if {$options(synth_only) == 1} {
581 set do_implementation 0
588 if {$options(impl_only) == 1} {
589 set do_implementation 1
597 if {$options(vitis_only) == 1 || $ide_name eq "vitis_classic"} {
599 set do_implementation 0
606 if {$options(bitstream_only) == 1} {
607 set do_bitstream_only 1
609 set do_implementation 0
614 set do_bitstream_only 0
617 if {$options(vivado_only) == 1} {
621 if {$options(no_reset) == 1} {
625 if {$options(check_syntax) == 1} {
626 set do_check_syntax 1
629 if {$options(scripts_only) == 1} {
633 if {$options(compile_only) == 1} {
639 if {$options(lib) != ""} {
640 set lib_path [
file normalize $options(lib)]
642 if {[
info exists env(HOG_SIMULATION_LIB_PATH)]} {
643 set lib_path $env(HOG_SIMULATION_LIB_PATH)
645 if {[
file exists "$repo_path/SimulationLib"]} {
646 set lib_path [
file normalize "$repo_path/SimulationLib"]
654 Msg Info "Number of jobs set to $options(njobs)."
662 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ppr]
665 set project_file [
file normalize $repo_path/Projects/$project_name/$project.xpr]
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"
671 if {[
catch {
package require ::quartus::project} ERROR]} {
672 Msg Error "$ERROR\n Can not find package ::quartus::project"
676 Msg Info "Loaded package ::quartus::project"
679 set project_file "$project_path/$project.qpf"
681 set project_file [
file normalize $repo_path/Projects/$project_name/$project.prjx]
684 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ldf]
687 if {[
file exists $project_file]} {
688 Msg Info "Found project file $project_file for $project_name."
691 Msg Info "Project file not found for $project_name."
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
700 if {[
file exists $conf]} {
702 if {$options(vivado_only) == 1} {
703 CreateProject -simlib_path $lib_path -xsa $options(xsa) -vivado_only $project_name $repo_path
705 CreateProject -simlib_path $lib_path -xsa $options(xsa) $project_name $repo_path
707 Msg Info "Done creating project $project_name."
709 Msg Error "Project $project_name is incomplete: no hog.conf file found, please create one..."
712 Msg Info "Opening existing project file $project_file..."
714 file mkdir "$repo_path/Projects/$project_name/$project.gen/sources_1"
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
729 if {$do_check_syntax == 1} {
730 Msg Info "Checking syntax for project $project_name..."
740 if {$do_vitis_build == 1} {
744 set xsct_cmd "xsct $tcl_path/launch.tcl W -vitis_only $project_name"
745 set ret [
catch {
exec -ignorestderr {*}$xsct_cmd >@ stdout} result]
747 Msg Error "xsct (vitis classic) returned an error state."
753 if {$do_synthesis == 1} {
754 LaunchSynthesis $do_reset $do_create $run_folder $project_name $repo_path $ext_path $options(njobs)
757 if {$do_implementation == 1} {
758 LaunchImplementation $do_reset $do_create $run_folder $project_name $repo_path $options(njobs) $do_bitstream
761 if {$do_bitstream_only == 1 && [
IsXilinx]} {
763 }
elseif {$do_bitstream_only == 1 && ![
IsXilinx]} {
764 Msg Error "Bitstream only option is not supported for this IDE."
767 if {$do_bitstream == 1 && ![
IsXilinx]} {
771 if {$do_simulation == 1} {
773 set simsets [
GetSimSets $project_name $repo_path $options(simset)]
774 LaunchSimulation $project_name $lib_path $simsets $repo_path $scripts_only $compile_only
778 if {$do_check_list_files} {
779 Msg Info "Running list file checker..."
787 set argv0 check_list_files
788 if {$ext_path ne ""} {
789 set argv [list "-ext_path" "$ext_path" "-outDir" "$dst_dir" "-pedantic"]
791 set argv [list "-outDir" "$dst_dir" "-pedantic"]
794 source $tcl_path/utils/check_list_files.tcl