22 {no_bitstream "If set, the bitstream file will not be produced."}
23 {recreate "If set, the project will be re-created if it already exists."}
24 {no_reset "If set, runs (synthesis and implementation) won't be reset before launching them."}
25 {check_syntax "If set, the HDL syntax will be checked at the beginning of the workflow."}
26 {njobs.arg 4 "Number of jobs. Default: 4"}
27 {ext_path.arg "" "Sets the absolute path for the external libraries."}
28 {lib.arg "" "Compiled simulation library path"}
29 {synth_only "If set, only the synthesis will be performed."}
30 {impl_only "If set, only the implementation will be performed. This assumes synthesis should was already done."}
31 {simset.arg "" "Simulation sets, separated by commas, to be run."}
32 {all "List all projects, including test projects. Test projects have #test on the second line of hog.conf."}
33 {generate "For IPbus XMLs, it willk re create the VHDL address decode files."}
34 {xml_dir.arg "" "For IPbus XMLs, set the destination folder (default is ../<project_name>_xml)."}
35 {verbose "If set, launch the script in verbose mode"}
38 set usage " \[OPTIONS\] <directive> <project>\n The most common <directive> values are CREATE (or C), WORKFLOW (or W), SIMULATE (or S).
40 ** Directives (case insensitive):
41 - CREATE or C: Create the project, replacing it if already existing.
42 - WORKFLOW or W: Launches the complete workflow, creates the project if not existing.
43 - CREATEWORKFLOW or CW: Creates the project -even if existing- and launches the complete workflow.
44 - SIMULATE or S: Simulate the project, creating it if not existing.
45 - IMPLEMENT: Runs the implementation only, the project must already exist and be synthesised.
46 - SYNTHESIS: Runs the synthesis only, creates the project if not existing.
47 - LIST or L: Only list all the projects
48 - XML or X: Copy, check or create IPbus XMLs
51 set tcl_path [
file normalize "[
file dirname [
info script]]"]
52 source $tcl_path/hog.tcl
53 source $tcl_path/create_project.tcl
57 set argv $quartus(args)
60 Msg Debug "s: $::argv0 a: $argv"
62 lassign [
InitLauncher $::argv0 $tcl_path $parameters $usage $argv] directive project project_name group_name repo_path old_path bin_dir top_path commands_path cmd ide list_of_options
63 array set options $list_of_options
65 Msg Debug "Returned by InitLauncher: $project $project_name $group_name $repo_path $old_path $bin_dir $top_path $commands_path $cmd"
68 append usage "\n** Options:"
71 set do_implementation 0
set do_synthesis 0
set do_bitstream 0
set do_create 0
set do_compile 0
set do_simulation 0
set recreate 0
set reset 1
set do_ipbus_xml 0
set list_all 2
73 set default_commands {
80 \^I(MPL(EMENT(ATION)?)?)?$ {
81 set do_implementation 1
86 \^SYNT(H(ESIS(E)?)?)? {
91 \^S(IM(ULAT(ION|E)?)?)?$ {
97 set do_implementation 1
103 \^(CREATEWORKFLOW|CW)$ {
104 set do_implementation 1
117 Msg Status "ERROR: Unknown directive $directive.\n\n[cmdline::usage $parameters $usage]"
124 Msg Debug "Looking for a $directive in : $default_commands $custom_commands"
125 switch -regexp -- $directive "$default_commands $custom_commands"
127 if { $options(all) == 1 } {
135 Msg Status "\n\nPossible projects are:"
139 }
elseif {$cmd == -2} {
141 Msg Status "ERROR: You must specify a project with directive $directive.\n\n[
cmdline::usage $parameters $usage]"
142 Msg Status "\n Possible projects are:"
147 }
elseif {$cmd == 0} {
149 Msg Info "$::argv0 was launched from the IDE."
155 if {$do_ipbus_xml == 1} {
156 Msg Info "Handling IPbus XMLs for $project_name..."
159 set proj_dir $repo_path/Top/$project_name
161 if { $options(generate) == 1 } {
167 if { $options(xml_dir) != "" } {
168 set xml_dst $options(xml_dir)
170 set xml_dst "../$project\_xml"
171 Msg Info "Using default destination $xml_dst..."
174 if {[
llength [glob -nocomplain $proj_dir/list/*.ipb]] > 0 } {
175 if {![
file exists $xml_dst]} {
176 Msg Info "$xml_dst directory not found, creating it..."
180 Msg Error "No .ipb files found in $proj_dir/list/"
185 set sha [
lindex $ret 13]
186 set hex_ver [
lindex $ret 14]
189 CopyIPbusXMLs $proj_dir $repo_path $xml_dst $ver $sha 1 $xml_gen
198 Msg Info "Launching command: $cmd..."
201 set ret [
catch {
exec which $ide}]
203 Msg Error "$ide not found in your system. Make sure to add $ide to your PATH enviromental variable."
207 if {[
string first libero $cmd] >= 0} {
210 set libero_script [open "launch-libero-hog.sh" w]
211 puts $libero_script "#!/bin/sh"
212 puts $libero_script $cmd
214 set cmd "sh launch-libero-hog.sh"
219 set ret [
catch {
exec -ignorestderr {*}$cmd >@ stdout} result]
222 Msg Error "IDE returned an error state."
228 if {[
string first libero $cmd] >= 0} {
229 file delete "launch-libero-hog.sh"
240 if {[
info exists env(HOG_TCLLIB_PATH)]} {
241 lappend auto_path $env(HOG_TCLLIB_PATH)
243 puts "ERROR: To run Hog with Microsemi Libero SoC or Lattice Diamond, you need to define the HOG_TCLLIB_PATH variable."
248 if {[
catch {
package require cmdline} ERROR] || [
catch {
package require struct::matrix} ERROR]} {
249 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'"
253 set run_folder [
file normalize "$repo_path/Projects/$project_name/$project.runs/"]
255 set run_folder [
file normalize "$repo_path/Projects/$project_name/"]
263 set project_path [
file normalize "$repo_path/Projects/$project_name/"]
266 if { $options(no_bitstream) == 1 } {
271 if { $options(recreate) == 1 } {
275 if { $options(synth_only) == 1} {
276 set do_implementation 0
283 if { $options(impl_only) == 1} {
284 set do_implementation 1
292 if { $options(no_reset) == 1 } {
296 if { $options(check_syntax) == 1 } {
300 if { $do_simulation == 1 } {
301 set simsets $options(simset)
304 if { $options(ext_path) != ""} {
305 set ext_path $options(ext_path)
308 if {$options(lib)!= ""} {
309 set lib_path [
file normalize $options(lib)]
311 if {[
info exists env(HOG_SIMULATION_LIB_PATH)]} {
312 set lib_path $env(HOG_SIMULATION_LIB_PATH)
314 if {[
file exists "$repo_path/SimulationLib"]} {
315 set lib_path [
file normalize "$repo_path/SimulationLib"]
324 if { $options(verbose) == 1 } {
325 variable ::DEBUG_MODE 1
336 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ppr]
339 set project_file [
file normalize $repo_path/Projects/$project_name/$project.xpr]
341 if { [
catch {
package require ::quartus::project} ERROR] } {
342 Msg Error "$ERROR\n Can not find package ::quartus::project"
346 Msg Info "Loaded package ::quartus::project"
349 set project_file "$project_path/$project.qpf"
351 set project_file [
file normalize $repo_path/Projects/$project_name/$project.prjx]
354 set project_file [
file normalize $repo_path/Projects/$project_name/$project.ldf]
357 if {[
file exists $project_file]} {
358 Msg Info "Found project file $project_file for $project_name."
361 Msg Info "Project file not found for $project_name."
365 if {($proj_found == 0 || $recreate == 1) && ($do_synthesis == 1 || $do_create == 1)} {
366 Msg Info "Creating (possibly replacing) the project $project_name..."
367 lassign [
GetConfFiles $repo_path/Top/$project_name] conf sim pre post
369 if {[
file exists $conf]} {
371 CreateProject -simlib_path $lib_path $project_name $repo_path
373 Msg Error "Project $project_name is incomplete: no hog.conf file found, please create one..."
376 Msg Info "Opening existing project file $project_file..."
378 file mkdir "$repo_path/Projects/$project_name/$project.gen/sources_1"
385 if { $check_syntax == 1 } {
386 Msg Info "Checking syntax for project $project_name..."
391 if {$do_synthesis == 1} {
392 LaunchSynthesis $reset $do_create $run_folder $project_name $repo_path $ext_path $options(njobs)
395 if {$do_implementation == 1 } {
396 LaunchImplementation $reset $do_create $run_folder $project_name $repo_path $options(njobs) $do_bitstream
400 if {$do_bitstream == 1 && ![
IsXilinx] } {
404 if {$do_simulation == 1} {