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 Msg Status "ERROR: Unknown directive $directive.\n\n"
186 {no_bitstream "If set, the bitstream file will not be produced."}
187 {recreate "If set, the project will be re-created if it already exists."}
188 {no_reset "If set, runs (synthesis and implementation) won't be reset before launching them."}
189 {check_syntax "If set, the HDL syntax will be checked at the beginning of the workflow."}
190 {njobs.arg 4 "Number of jobs. Default: 4"}
191 {ext_path.arg "" "Sets the absolute path for the external libraries."}
192 {lib.arg "" "Simulation library path, compiled or to be compiled"}
193 {synth_only "If set, only the synthesis will be performed."}
194 {impl_only "If set, only the implementation will be performed. This assumes synthesis was already done."}
195 {scripts_only "If set, the simulation scripts will be generated, but the simulation will not be run."}
196 {compile_only "If set, the simulation libraries will be compiled, but not run."}
197 {bitstream_only "If set, only the bitstream will be produced. This assumes implementation was already done. For a Vivado-Vitis\
198 project this command can be used to generate the boot artifacts including the ELF file(s) without running the\
199 full Vivado workflow."}
200 {vivado_only "If set, and project is vivado-vitis, vitis project will not be created."}
201 {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."}
202 {xsa.arg "" "If set, and project is vivado-vitis, use this xsa for creating platforms without a defined hw."}
203 {simset.arg "" "Simulation sets, separated by commas, to be run."}
204 {all "List all projects, including test projects. Test projects have #test on the second line of hog.conf."}
205 {generate "For IPbus XMLs, it will re create the VHDL address decode files."}
206 {dst_dir.arg "" "For reports, IPbus XMLs, set the destination folder (default is in the ./bin folder)."}
207 {verbose "If set, launch the script in verbose mode"}
210 set tcl_path [
file normalize "[
file dirname [
info script]]"]
211 source $tcl_path/hog.tcl
212 source $tcl_path/create_project.tcl
217 set argv $quartus(args)
222 set commands_path [
file normalize "$tcl_path/../../hog-commands/"]
228 lassign [
InitLauncher $::argv0 $tcl_path $parameters $default_commands $argv $custom_usage] \
229 directive project project_name group_name repo_path old_path bin_dir top_path usage short_usage cmd ide list_of_options
231 array set options $list_of_options
232 Msg Debug "Returned by InitLauncher: \
233 $project $project_name $group_name $repo_path $old_path $bin_dir $top_path $cmd"
236 if {$options(ext_path) != ""} {
237 set ext_path $options(ext_path)
242 if {$options(verbose) == 1} {
252 set do_implementation 0
set do_synthesis 0
set do_bitstream 0
253 set do_create 0
set do_compile 0
set do_simulation 0
set recreate 0
254 set do_reset 1
set do_list_all 2
set do_check_syntax 0
set do_vitis_build 0
255 set scripts_only 0
set compile_only 0
261 set do_list_file_parse 0
262 set do_check_yaml_ref 0
264 set do_check_list_files 0
268 Msg Debug "Looking for a $directive in : $default_commands $custom_commands"
269 switch -regexp -- $directive "$default_commands $custom_commands"
271 if {$options(all) == 1} {
277 if {$options(dst_dir) == "" && ($do_ipbus_xml == 1 || $do_check_list_files == 1) && $project != ""} {
279 lassign [
GetRepoVersions [
file normalize $repo_path/Top/$group_name/$project] \
280 $repo_path $ext_path] commit version hog_hash hog_ver top_hash top_ver libs hashes vers \
281 cons_ver cons_hash ext_names ext_hashes xml_hash xml_ver user_ip_repos \
282 user_ip_hashes user_ip_vers
286 set dst_dir [
file normalize "$repo_path/bin/$group_name/$project\-$describe"]
291 Msg Status "\n\nPossible projects are:"
295 }
elseif {$cmd == -2} {
297 Msg Status "ERROR: You must specify a project with directive $directive."
299 Msg Status "Possible projects are:"
302 }
elseif {$cmd == 0} {
304 Msg Info "$::argv0 was launched from the IDE."
316 if {$do_ipbus_xml == 1} {
317 Msg Info "Handling IPbus XMLs for $project_name..."
319 set proj_dir $repo_path/Top/$project_name
321 if {$options(generate) == 1} {
328 set xml_dst "$dst_dir/xml"
331 if {[
llength [glob -nocomplain $proj_dir/list/*.ipb]] > 0} {
332 if {![
file exists $xml_dst]} {
333 Msg Info "$xml_dst directory not found, creating it..."
337 Msg Error "No .ipb files found in $proj_dir/list/"
342 set sha [
lindex $ret 13]
343 set hex_ver [
lindex $ret 14]
346 CopyIPbusXMLs $proj_dir $repo_path $xml_dst $ver $sha 1 $xml_gen
351 if {$do_list_file_parse == 1} {
352 set proj_dir $repo_path/Top/$project_name
353 set proj_list_dir $repo_path/Top/$project_name/list
354 GetHogFiles -print_log -list_files {.src,.con,.sim,.ext,.ipb} $proj_list_dir $repo_path
360 if {$do_check_yaml_ref == 1} {
361 Msg Info "Checking if \"ref\" in .gitlab-ci.yml actually matches the included yml file in Hog submodule"
366 if {$do_buttons == 1} {
367 Msg Info "Adding Hog buttons to Vivado bar (will use the vivado currently in PATH)..."
369 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/add_hog_custom_button.tcl"
372 if {$do_compile_lib == 1} {
373 if {$project eq ""} {
374 Msg Error "You need to specify a simulator as first argument."
377 set simulator $project
378 Msg Info "Selecting $simulator simulator..."
380 if {$options(dst_dir) != ""} {
381 set output_dir $options(dst_dir)
383 Msg Info "No destination directory defined. Using default: SimulationLib/"
384 set output_dir "SimulationLib"
388 set cmd "vivado -mode batch -notrace -source $repo_path/Hog/Tcl/utils/compile_simlib.tcl -tclargs -simulator $simulator -output_dir $output_dir"
392 if {$do_simulation == 1} {
394 set ghdl_simsets [
GetSimSets $project_name $repo_path "$options(simset)" 1]
396 dict for {simset_name simset_dict} $ghdl_simsets {
397 if {$ghdl_import == 0} {
398 ImportGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
401 LaunchGHDL $project_name $repo_path $simset_name $simset_dict $ext_path
402 # dict unset simsets_dict $simset_name
404 set ide_simsets [
GetSimSets $project_name $repo_path $options(simset) 0 1]
406 if {[dict size $ide_simsets] == 0} {
408 Msg Info "All simulations have been run, exiting..."
421 Msg Info "Launching command: $cmd..."
424 set ret [
catch {
exec which $ide}]
426 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
430 if {[
string first libero $cmd] >= 0} {
433 set libero_script [open "launch-libero-hog.sh" w]
434 puts $libero_script "#!/bin/sh"
435 puts $libero_script $cmd
437 set cmd "sh launch-libero-hog.sh"
440 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
443 Msg Error "IDE returned an error state."
449 if {[
string first libero $cmd] >= 0} {
450 file delete "launch-libero-hog.sh"
462 if {[
info exists env(HOG_TCLLIB_PATH)]} {
463 lappend auto_path $env(HOG_TCLLIB_PATH)
465 puts "ERROR: To run Hog with Microsemi Libero SoC or Lattice Diamond,\
466 you need to define the HOG_TCLLIB_PATH variable."
471 if {[
catch {
package require cmdline} ERROR] || [
catch {
package require struct::matrix} ERROR]} {
472 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'"
476 set run_folder [
file normalize "$repo_path/Projects/$project_name/$project.runs/"]
478 set run_folder [
file normalize "$repo_path/Projects/$project_name/"]
482 set project_path [
file normalize "$repo_path/Projects/$project_name/"]
487 set ide_name [
lindex [regexp -all -inline {\S+} $ide_name_and_ver] 0]
489 if {$options(no_bitstream) == 1} {
494 if {$options(recreate) == 1} {
498 if {$options(synth_only) == 1} {
499 set do_implementation 0
506 if {$options(impl_only) == 1} {
507 set do_implementation 1
515 if {$options(vitis_only) == 1 || $ide_name eq "vitis_classic"} {
517 set do_implementation 0
524 if {$options(bitstream_only) == 1} {
525 set do_bitstream_only 1
527 set do_implementation 0
532 set do_bitstream_only 0
535 if {$options(vivado_only) == 1} {
539 if {$options(no_reset) == 1} {
543 if {$options(check_syntax) == 1} {
544 set do_check_syntax 1
547 if {$options(scripts_only) == 1} {
551 if {$options(compile_only) == 1} {
557 if {$options(lib) != ""} {
558 set lib_path [
file normalize $options(lib)]
560 if {[
info exists env(HOG_SIMULATION_LIB_PATH)]} {
561 set lib_path $env(HOG_SIMULATION_LIB_PATH)
563 if {[
file exists "$repo_path/SimulationLib"]} {
564 set lib_path [
file normalize "$repo_path/SimulationLib"]
572 Msg Info "Number of jobs set to $options(njobs)."
580 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ppr]
583 set project_file [
file normalize $repo_path/Projects/$project_name/$project.xpr]
586 set project_file [
file normalize $repo_path/Projects/$project_name/vitis_classic/.metadata/]
587 Msg Info "Setting project file for Vitis Classic project $project_name to $project_file"
589 if {[
catch {
package require ::quartus::project} ERROR]} {
590 Msg Error "$ERROR\n Can not find package ::quartus::project"
594 Msg Info "Loaded package ::quartus::project"
597 set project_file "$project_path/$project.qpf"
599 set project_file [
file normalize $repo_path/Projects/$project_name/$project.prjx]
602 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ldf]
605 if {[
file exists $project_file]} {
606 Msg Info "Found project file $project_file for $project_name."
609 Msg Info "Project file not found for $project_name."
613 if {($proj_found == 0 || $recreate == 1)} {
614 Msg Info "Creating (possibly replacing) the project $project_name..."
615 Msg Debug "launch.tcl: calling GetConfFiles with $repo_path/Top/$project_name"
616 lassign [
GetConfFiles $repo_path/Top/$project_name] conf sim pre post
618 if {[
file exists $conf]} {
620 if {$options(vivado_only) == 1} {
621 CreateProject -simlib_path $lib_path -xsa $options(xsa) -vivado_only $project_name $repo_path
623 CreateProject -simlib_path $lib_path -xsa $options(xsa) $project_name $repo_path
625 Msg Info "Done creating project $project_name."
627 Msg Error "Project $project_name is incomplete: no hog.conf file found, please create one..."
630 Msg Info "Opening existing project file $project_file..."
632 file mkdir "$repo_path/Projects/$project_name/$project.gen/sources_1"
636 set vitis_workspace [
file normalize $repo_path/Projects/$project_name/vitis_classic/]
637 Msg Info "Setting workspace to $vitis_workspace"
638 setws $vitis_workspace
647 if {$do_check_syntax == 1} {
648 Msg Info "Checking syntax for project $project_name..."
658 if {$do_vitis_build == 1} {
662 set xsct_cmd "xsct $tcl_path/launch.tcl W -vitis_only $project_name"
663 set ret [
catch {
exec -ignorestderr {*}$xsct_cmd >@ stdout} result]
665 Msg Error "xsct (vitis classic) returned an error state."
671 if {$do_synthesis == 1} {
672 LaunchSynthesis $do_reset $do_create $run_folder $project_name $repo_path $ext_path $options(njobs)
675 if {$do_implementation == 1} {
676 LaunchImplementation $do_reset $do_create $run_folder $project_name $repo_path $options(njobs) $do_bitstream
679 if {$do_bitstream_only == 1 && [
IsXilinx]} {
681 }
elseif {$do_bitstream_only == 1 && ![
IsXilinx]} {
682 Msg Error "Bitstream only option is not supported for this IDE."
685 if {$do_bitstream == 1 && ![
IsXilinx]} {
689 if {$do_simulation == 1} {
691 set simsets [
GetSimSets $project_name $repo_path $options(simset)]
692 LaunchSimulation $project_name $lib_path $simsets $repo_path $scripts_only $compile_only
696 if {$do_check_list_files} {
697 Msg Info "Running list file checker..."
705 set argv0 check_list_files
706 if {$ext_path ne ""} {
707 set argv [list "-ext_path" "$ext_path" "-outDir" "$dst_dir" "-pedantic"]
709 set argv [list "-outDir" "$dst_dir" "-pedantic"]
712 source $tcl_path/utils/check_list_files.tcl
717 Msg Info "Creating Sigasi file for $project..."
720 set csv_name "${project}_sigasi_sim.csv"
722 Msg Info "Generating IP targets for simulations..."
723 foreach ip [get_ips] {
724 set targets [list_targets [get_files [
file tail [get_property IP_FILE $ip]]]]
725 if {[lsearch -exact $targets simulation] >= 0} {
726 generate_target simulation $ip
728 Msg Warning "IP $ip is not a simulation target, skipping..."
733 set source_files [get_files -filter {(FILE_TYPE == VHDL || FILE_TYPE == "VHDL 2008" || FILE_TYPE == "VHDL 2019" || FILE_TYPE == VERILOG || FILE_TYPE == SYSTEMVERILOG) && USED_IN_SIMULATION == 1 }]
734 if {$options(dst_dir) == ""} {
735 set dst_path "$repo_path"
737 set dst_path $repo_path/$options(dst_dir)
738 if {![
file exists $dst_path]} {
739 Msg Info "Creating $dst_path..."
744 Msg Info "Creating sigasi csv file for simulation $dst_path/$csv_name..."
745 set csv_file [open $dst_path/$csv_name w]
747 foreach source_file $source_files {
748 puts $csv_file [
concat [get_property LIBRARY $source_file] "," $source_file]
753 set csv_name "${project}_sigasi_synth.csv"
754 Msg Info "Generating IP targets for synthesis..."
755 foreach ip [get_ips] {
756 generate_target synthesis $ip
759 set source_files [get_files -filter {(FILE_TYPE == VHDL || FILE_TYPE == "VHDL 2008" || FILE_TYPE == "VHDL 2019" || FILE_TYPE == VERILOG || FILE_TYPE == SYSTEMVERILOG) && USED_IN_SYNTHESIS == 1 }]
760 Msg Info "Creating sigasi csv file for synthesis $dst_path/$csv_name..."
761 set csv_file [open $dst_path/$csv_name w]
762 foreach source_file $source_files {
763 puts $csv_file [
concat [get_property LIBRARY $source_file] "," $source_file]