23 set default_commands {
26 Msg Status "\n** The projects in this repository are:"
27 ListProjects $repo_path $list_all
31 # DESCRIPTION: List the projects in the repository. To show hidden projects use the -all option
32 # OPTIONS: all, verbose
39 # DESCRIPTION: Display this help message or specific help for each directive
45 # NAME: CHECKCIENV or CIE
46 # DESCRIPTION: Check that the common environment variables needed for Hog-CI are set
50 \^(CHECKPROJENV|CPE)?$ {#
51 set do_checkproj_env 1
52 # NAME: CHECKPROJENV or CPE
53 # DESCRIPTION: Check that the environment variables needed for Hog-CI to run the chosen project are set and point to valid paths
57 \^(CHECKPROJVER|CPV)?$ {#
58 set do_checkproj_ver 1
59 # NAME: CHECKPROJVER or CPV
60 # DESCRIPTION: Check the project version just before creating the HDL project in Create_Project stage. \
61 The CI job will SKIP the project pipeline, if it the project has not been modified with respect to the target branch.
62 # OPTIONS: ext_path.arg, simcheck, verbose
69 # DESCRIPTION: Create the project, replace it if already existing.
70 # OPTIONS: ext_path.arg, lib.arg, vivado_only, verbose
73 \^I(MPL(EMENT(ATION)?)?)?$ {#
74 set do_implementation 1
77 # NAME: IMPLEMENTATION or I
78 # DESCRIPTION: Runs only the implementation, the project must already exist and be synthesised.
79 # OPTIONS: check_syntax, ext_path.arg, njobs.arg, no_bitstream, no_reset, recreate, verbose
82 \^SYNT(H(ESIS(E)?)?)? {#
86 # DESCRIPTION: Run synthesis only, create the project if not existing.
87 # OPTIONS: check_syntax, ext_path.arg, njobs.arg, recreate, verbose
90 \^S(IM(ULAT(ION|E)?)?)?$ {#
93 # NAME*: SIMULATION or S
94 # DESCRIPTION: Simulate the project, creating it if not existing, unless it is a GHDL simulation.
95 # OPTIONS: check_syntax, compile_only, ext_path.arg, lib.arg, recreate, scripts_only, simset.arg, verbose
99 set do_implementation 1
104 # NAME*: WORKFLOW or W
105 # DESCRIPTION: Runs the full workflow, creates the project if not existing.
106 # OPTIONS: bitstream_only, check_syntax, ext_path.arg, impl_only, njobs.arg, no_bitstream, recreate, synth_only, verbose, vitis_only, xsa.arg
109 \^(CREATEWORKFLOW|CW)?$ {#
110 set do_implementation 1
116 # NAME: CREATEWORKFLOW or CW
117 # DESCRIPTION: Creates the project -even if existing- and launches the complete workflow.
118 # OPTIONS: check_syntax, ext_path.arg, njobs.arg, no_bitstream, synth_only, verbose, vivado_only, vitis_only, xsa.arg
121 \^(CHECKSYNTAX|CS)?$ {#proj
122 set do_check_syntax 1
123 # NAME: CHECKSYNTAX or CS
124 # DESCRIPTION: Check the syntax of the project. Only for Vivado, Quartus and Libero projects.
125 # OPTIONS: ext_path.arg, recreate, verbose
128 ^(IPB(US)?)|(X(ML)?)$ {#proj
131 # DESCRIPTION: Copy, check or create the IPbus XMLs for the project.
132 # OPTIONS: dst_dir.arg, generate, verbose
136 set do_list_file_parse 1
138 # DESCRIPTION: Print Hog list file contents in a tree-like fashon.
142 \^(CHECKYAML|YML)?$ {
145 set do_check_yaml_ref 1
146 # NAME: CHECKYML or YML
147 # DESCRIPTION: Check that the ref to Hog repository in the .gitlab-ci.yml file, matches the one in Hog submodule.
156 # DESCRIPTION: Add Hog buttons to the Vivado GUI, to check and recreate Hog list and configuration files.
160 \^(CHECKLIST|CL)?$ {#proj
161 set do_check_list_files 1
162 # NAME: CHECKLIST or CL
163 # DESCRIPTION: Check that list and configuration files on disk match what is on the project.
164 # OPTIONS: ext_path.arg, verbose
169 set argument_is_no_project 1
170 # NAME: COMPSIMLIB or COMPSIM
171 # DESCRIPTION: Compiles the simulation library for the chosen simulator with Vivado.
172 # OPTIONS: dst_dir.arg, verbose
177 # NAME: RTL or RTLANALYSIS
178 # DESCRIPTION: Elaborate the RTL analysis report for the chosen project.
179 # OPTIONS: check_syntax, recreate, verbose
184 # NAME: SIGASI or SIG
185 # DESCRIPTION: Create a .csv file to be used in Sigasi.
192 # DESCRIPTION: Print the design hierarchy for the chosen project.
193 # OPTIONS: compile_order, ext_path.arg, ignore.arg, include_gen_prods, include_ieee, light, output.arg, top.arg, verbose
197 if {$directive != ""} {
198 set NO_DIRECTIVE_FOUND 1
214 {no_bitstream "If set, the bitstream file will not be produced."}
215 {recreate "If set, the project will be re-created if it already exists."}
216 {no_reset "If set, runs (synthesis and implementation) won't be reset before launching them."}
217 {check_syntax "If set, the HDL syntax will be checked at the beginning of the workflow."}
218 {njobs.arg 4 "Number of jobs. Default: 4"}
219 {ext_path.arg "" "Sets the absolute path for the external libraries."}
220 {lib.arg "" "Simulation library path, compiled or to be compiled"}
221 {synth_only "If set, only the synthesis will be performed."}
222 {impl_only "If set, only the implementation will be performed. This assumes synthesis was already done."}
223 {scripts_only "If set, the simulation scripts will be generated, but the simulation will not be run."}
224 {compile_only "If set, the simulation libraries will be compiled, but not run."}
225 {bitstream_only "If set, only the bitstream will be produced. This assumes implementation was already done. For a Vivado-Vitis\
226 project this command can be used to generate the boot artifacts including the ELF file(s) without running the\
227 full Vivado workflow."}
228 {vivado_only "If set, and project is vivado-vitis, vitis project will not be created."}
229 {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."}
230 {xsa.arg "" "If set, and project is vivado-vitis, use this xsa for creating platforms without a defined hw."}
231 {simset.arg "" "Simulation sets, separated by commas, to be run."}
232 {all "List all projects, including test projects. Test projects have #test on the second line of hog.conf."}
233 {generate "For IPbus XMLs, it will re create the VHDL address decode files."}
234 {dst_dir.arg "" "For reports, IPbus XMLs, set the destination folder (default is in the ./bin folder)."}
235 {output.arg "" "For tree hierarchy mode, set the output file (default is console)."}
236 {top.arg "" "For tree hierarchy mode, set the top module (default is the top module defined in hog.conf)."}
237 {ignore.arg "" "For tree hierarchy mode, filter's the printed hierarchy to exclude modules that match the given string."}
238 {include_ieee "" "For tree hierarchy mode, include IEEE/STD libraries in the printed hierarchy. (Default 0)"}
239 {include_gen_prods "" "For tree hierarchy mode, include IP generated products in the printed hierarchy. (Default 0)"}
240 {compile_order "" "For tree hierarchy mode, prints compile order instead of hierarchy."}
241 {verbose "If set, launch the script in verbose mode"}
242 {light "For tree hierarchy mode, print a light version of the hierarchy (without file paths)."}
243 {simcheck "If set, checks also the version of the simulation files."}
246 set tcl_path [
file normalize "[
file dirname [
info script]]"]
247 source $tcl_path/hog.tcl
248 source $tcl_path/create_project.tcl
253 set argv $quartus(args)
259 set commands_path [
file normalize "$tcl_path/../../hog-commands/"]
262 lassign [
InitLauncher $::argv0 $tcl_path $parameters $default_commands $argv $custom_commands] \
263 directive project project_name group_name repo_path old_path bin_dir top_path usage short_usage cmd ide list_of_options
265 array set options $list_of_options
267 if {$options(verbose) == 1} {
270 Msg Debug "Returned by InitLauncher: \n\
271 - project: $project \n\
272 - project_name $project_name \n\
273 - group_name $group_name \n\
274 - repo_path $repo_path \n\
275 - old_path $old_path \n\
276 - bin_dir $bin_dir \n\
277 - top_path $top_path \n\
281 if {$options(ext_path) != ""} {
282 set ext_path $options(ext_path)
291 if {$options(output) != ""} {
292 set output_path $options(output)
295 set light_hierarchy $options(light)
296 set ignored_hierarchy $options(ignore)
297 set top_module $options(top)
298 set compile_order $options(compile_order)
299 set include_ieee $options(include_ieee)
300 set include_gen_prods $options(include_gen_prods)
304 set do_checkproj_env 0
set do_check_ci_env 0
set do_checkproj_ver 0
305 set do_implementation 0
set do_synthesis 0
set do_bitstream 0
306 set do_create 0
set do_compile 0
set do_simulation 0
set recreate 0
307 set do_reset 1
set do_list_all 2
set do_check_syntax 0
set do_vitis_build 0
308 set scripts_only 0
set compile_only 0
314 set do_list_file_parse 0
315 set do_check_yaml_ref 0
317 set do_check_list_files 0
322 set NO_DIRECTIVE_FOUND 0
323 Msg Debug "Looking for a $directive in : $default_commands"
324 switch -regexp -- $directive $default_commands
326 if {$NO_DIRECTIVE_FOUND == 1} {
327 Msg Debug "No directive found in default commands, looking in custom commands..."
328 if {[
string length $custom_commands] > 0 && [dict exists $custom_commands $directive]} {
329 Msg Debug "Directive $directive found in custom commands."
330 if {$cmd == "custom_tcl"} {
331 eval [dict get $custom_commands $directive SCRIPT]
335 Msg Info "Launching command: $cmd..."
338 set ret [
catch {
exec which $ide}]
340 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
344 if {[
string first libero $cmd] >= 0} {
347 set libero_script [open "launch-libero-hog.sh" w]
348 puts $libero_script "#!/bin/sh"
349 puts $libero_script $cmd
351 set cmd "sh launch-libero-hog.sh"
354 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
357 Msg Error "IDE returned an error state."
363 if {[
string first libero $cmd] >= 0} {
364 file delete "launch-libero-hog.sh"
370 eval [dict get $custom_commands $directive SCRIPT]
372 set no_exit [dict get $custom_commands $directive NO_EXIT]
378 Msg Info "No directive found, pre ide exiting..."
379 Msg Status "ERROR: Unknown directive $directive.\n\n"
385 if {$options(all) == 1} {
391 if {$options(dst_dir) == "" && ($do_ipbus_xml == 1 || $do_check_list_files == 1) && $project != ""} {
393 lassign [
GetRepoVersions [
file normalize $repo_path/Top/$group_name/$project] \
394 $repo_path $ext_path] commit version hog_hash hog_ver top_hash top_ver libs hashes vers \
395 cons_ver cons_hash ext_names ext_hashes xml_hash xml_ver user_ip_repos \
396 user_ip_hashes user_ip_vers
400 set dst_dir [
file normalize "$repo_path/bin/$group_name/$project\-$describe"]
405 Msg Status "\n\nPossible projects are:"
409 }
elseif {$cmd == -2} {
411 Msg Status "ERROR: You must specify a project with directive $directive."
413 Msg Status "Possible projects are:"
416 }
elseif {$cmd == 0} {
418 Msg Info "$::argv0 was launched from the IDE."
425 if {$do_checkproj_env == 1} {
430 if {$do_check_ci_env == 1} {
436 if {$do_ipbus_xml == 1} {
437 Msg Info "Handling IPbus XMLs for $project_name..."
439 set proj_dir $repo_path/Top/$project_name
441 if {$options(generate) == 1} {
447 if {$options(dst_dir) != ""} {
448 set dst_dir $options(dst_dir)
450 set xml_dst "$dst_dir/xml"
453 if {[
llength [glob -nocomplain $proj_dir/list/*.ipb]] > 0} {
454 if {![
file exists $xml_dst]} {
455 Msg Info "$xml_dst directory not found, creating it..."
459 Msg Error "No .ipb files found in $proj_dir/list/"
464 set sha [
lindex $ret 13]
465 set hex_ver [
lindex $ret 14]
468 CopyIPbusXMLs $proj_dir $repo_path $xml_dst $ver $sha 1 $xml_gen
473 if {$do_list_file_parse == 1} {
474 set proj_dir $repo_path/Top/$project_name
475 set proj_list_dir $repo_path/Top/$project_name/list
476 GetHogFiles -print_log -list_files {.src,.con,.sim,.ext,.ipb} $proj_list_dir $repo_path
482 if {$do_hierarchy == 1} {
483 source $tcl_path/utils/hierarchy.tcl
484 set proj_dir $repo_path/Top/$project_name
485 set proj_list_dir $repo_path/Top/$project_name/list
487 -list_files ".src,.ext" $proj_list_dir $repo_path]\
488 listLibraries listProperties listSrcSets
489 Hierarchy $listProperties $listLibraries $repo_path $output_path $compile_order \
490 $light_hierarchy $top_module $ignored_hierarchy $include_ieee $include_gen_prods
493 if {$do_sigasi == 1} {
495 Msg Info "Creating Sigasi CSV files for project $project_name..."
496 set proj_dir $repo_path/Top/$project_name
497 set proj_list_dir $repo_path/Top/$project_name/list
498 set project [
file tail $project_name]
499 lassign [
GetHogFiles -list_files {.src} $proj_list_dir $repo_path] libraries
500 set csv_file [open "sigasi_$project.csv" w]
501 foreach lib $libraries {
502 set source_files [
DictGet $libraries $lib]
503 foreach source_file $source_files {
504 if {[
file extension $source_file] == ".vhd" ||
505 [
file extension $source_file] == ".vhdl" ||
506 [
file extension $source_file] == ".sv" ||
507 [
file extension $source_file] == ".v" } {
508 puts $csv_file [
concat [
file rootname $lib] "," $source_file]
513 Msg Info "Sigasi CSV file created: sigasi_$project.csv"
514 Msg Info "You can use the python script provided by Sigasi to convert the generated csv file into a Sigasi project."
515 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"
519 if {$do_check_yaml_ref == 1} {
520 Msg Info "Checking if \"ref\" in .gitlab-ci.yml actually matches the included yml file in Hog submodule"
525 if {$do_buttons == 1} {
526 Msg Info "Adding Hog buttons to Vivado bar (will use the vivado currently in PATH)..."
528 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/add_hog_custom_button.tcl"
531 if {$do_compile_lib == 1} {
532 if {$project eq ""} {
533 Msg Error "You need to specify a simulator as first argument."
536 set simulator $project
537 Msg Info "Selecting $simulator simulator..."
539 if {$options(dst_dir) != ""} {
540 set output_dir $options(dst_dir)
542 Msg Info "No destination directory defined. Using default: SimulationLib/"
543 set output_dir "SimulationLib"
547 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/compile_simlib.tcl -tclargs -simulator $simulator -output_dir $output_dir"
551 if {$do_simulation == 1} {
553 set ghdl_simsets [
GetSimSets $project_name $repo_path "$options(simset)" 1]
555 dict for {simset_name simset_dict} $ghdl_simsets {
556 if {$ghdl_import == 0} {
557 ImportGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
560 LaunchGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
561 # dict unset simsets_dict $simset_name
563 set ide_simsets [
GetSimSets $project_name $repo_path $options(simset) 0 1]
565 if {[dict size $ide_simsets] == 0} {
567 Msg Info "All simulations have been run, exiting..."
580 Msg Info "Launching command: $cmd..."
583 set ret [
catch {
exec which $ide}]
585 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
589 if {[
string first libero $cmd] >= 0} {
592 set libero_script [open "launch-libero-hog.sh" w]
593 puts $libero_script "#!/bin/sh"
594 puts $libero_script $cmd
596 set cmd "sh launch-libero-hog.sh"
599 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
602 Msg Error "IDE returned an error state."
608 if {[
string first libero $cmd] >= 0} {
609 file delete "launch-libero-hog.sh"
621 if {[
info exists env(HOG_TCLLIB_PATH)]} {
622 lappend auto_path $env(HOG_TCLLIB_PATH)
624 puts "ERROR: To run Hog with Microsemi Libero SoC or Lattice Diamond,\
625 you need to define the HOG_TCLLIB_PATH variable."
630 if {[
catch {
package require cmdline} ERROR] || [
catch {
package require struct::matrix} ERROR]} {
631 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'"
636 if {$do_checkproj_ver == 1} {
637 CheckProjVer $repo_path $project_name $options(simcheck) $options(ext_path)
641 set run_folder [
file normalize "$repo_path/Projects/$project_name/$project.runs/"]
643 set run_folder [
file normalize "$repo_path/Projects/$project_name/"]
647 set project_path [
file normalize "$repo_path/Projects/$project_name/"]
652 set ide_name [
lindex [regexp -all -inline {\S+} $ide_name_and_ver] 0]
654 if {$options(no_bitstream) == 1} {
659 if {$options(recreate) == 1} {
663 if {$options(synth_only) == 1} {
664 set do_implementation 0
671 if {$options(impl_only) == 1} {
672 set do_implementation 1
679 if {$options(vitis_only) == 1 || $ide_name eq "vitis_classic"} {
681 set do_implementation 0
688 if {$options(bitstream_only) == 1} {
689 set do_bitstream_only 1
691 set do_implementation 0
696 set do_bitstream_only 0
699 if {$options(vivado_only) == 1} {
703 if {$options(no_reset) == 1} {
707 if {$options(check_syntax) == 1} {
708 set do_check_syntax 1
711 if {$options(scripts_only) == 1} {
715 if {$options(compile_only) == 1} {
721 if {$options(lib) != ""} {
722 set lib_path [
file normalize $options(lib)]
724 if {[
info exists env(HOG_SIMULATION_LIB_PATH)]} {
725 set lib_path $env(HOG_SIMULATION_LIB_PATH)
727 if {[
file exists "$repo_path/SimulationLib"]} {
728 set lib_path [
file normalize "$repo_path/SimulationLib"]
736 Msg Info "Number of jobs set to $options(njobs)."
744 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ppr]
747 set project_file [
file normalize $repo_path/Projects/$project_name/$project.xpr]
750 set project_file [
file normalize $repo_path/Projects/$project_name/vitis_classic/.metadata/]
751 Msg Info "Setting project file for Vitis Classic project $project_name to $project_file"
753 if {[
catch {
package require ::quartus::project} ERROR]} {
754 Msg Error "$ERROR\n Can not find package ::quartus::project"
758 Msg Info "Loaded package ::quartus::project"
761 set project_file "$project_path/$project.qpf"
763 set project_file [
file normalize $repo_path/Projects/$project_name/$project.prjx]
766 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ldf]
769 if {[
file exists $project_file]} {
770 Msg Info "Found project file $project_file for $project_name."
773 Msg Info "Project file not found for $project_name."
777 if {($proj_found == 0 || $recreate == 1)} {
778 Msg Info "Creating (possibly replacing) the project $project_name..."
779 Msg Debug "launch.tcl: calling GetConfFiles with $repo_path/Top/$project_name"
780 lassign [
GetConfFiles $repo_path/Top/$project_name] conf sim pre post
782 if {[
file exists $conf]} {
784 if {$options(vivado_only) == 1} {
785 CreateProject -simlib_path $lib_path -xsa $options(xsa) -vivado_only $project_name $repo_path
787 CreateProject -simlib_path $lib_path -xsa $options(xsa) $project_name $repo_path
789 Msg Info "Done creating project $project_name."
791 Msg Error "Project $project_name is incomplete: no hog.conf file found, please create one..."
794 Msg Info "Opening existing project file $project_file..."
796 file mkdir "$repo_path/Projects/$project_name/$project.gen/sources_1"
800 set vitis_workspace [
file normalize $repo_path/Projects/$project_name/vitis_classic/]
801 Msg Info "Setting workspace to $vitis_workspace"
802 setws $vitis_workspace
810 if {$do_check_syntax == 1} {
811 Msg Info "Checking syntax for project $project_name..."
820 if {$do_vitis_build == 1} {
824 set xsct_cmd "xsct $tcl_path/launch.tcl W -vitis_only $project_name"
825 set ret [
catch {
exec -ignorestderr {*}$xsct_cmd >@ stdout} result]
827 Msg Error "xsct (vitis classic) returned an error state."
833 if {$do_synthesis == 1} {
834 LaunchSynthesis $do_reset $do_create $run_folder $project_name $repo_path $ext_path $options(njobs)
837 if {$do_implementation == 1} {
838 LaunchImplementation $do_reset $do_create $run_folder $project_name $repo_path $options(njobs) $do_bitstream
841 if {$do_bitstream_only == 1 && [
IsXilinx]} {
843 }
elseif {$do_bitstream_only == 1 && ![
IsXilinx]} {
844 Msg Error "Bitstream only option is not supported for this IDE."
847 if {$do_bitstream == 1 && ![
IsXilinx]} {
851 if {$do_simulation == 1} {
853 set simsets [
GetSimSets $project_name $repo_path $options(simset)]
854 LaunchSimulation $project_name $lib_path $simsets $repo_path $scripts_only $compile_only
858 if {$do_check_list_files} {
859 Msg Info "Running list file checker..."
867 set argv0 check_list_files
868 if {$ext_path ne ""} {
869 set argv [list "-ext_path" "$ext_path" "-outDir" "$dst_dir" "-pedantic"]
871 set argv [list "-outDir" "$dst_dir" "-pedantic"]
874 source $tcl_path/utils/check_list_files.tcl