30 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
31 source $tcl_path/hog.tcl
36 if {[
info exists env(HOG_TCLLIB_PATH)]} {
37 lappend auto_path $env(HOG_TCLLIB_PATH)
39 puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
47 set proj_dir [get_property DIRECTORY [current_project]]
48 set proj_file $proj_dir/[
file tail $proj_dir].prr
49 set work_path [get_property DIRECTORY [get_runs impl_1]]
51 set proj_file [get_property parent.project_path [current_project]]
52 set work_path $old_path
54 set proj_dir [
file normalize [
file dirname $proj_file]]
55 set proj_name [
file rootname [
file tail $proj_file]]
56 set run_dir [
file normalize "$work_path/.."]
57 set top_name [get_property top [current_fileset]]
60 set proj_name [
lindex $quartus(args) 1]
61 set proj_dir $old_path
63 set proj_dir [
file normalize "[
pwd]/.."]
64 set proj_name [
file tail $proj_dir]
65 set project $proj_name
68 set proj_file $old_path/[
file tail $old_path].xpr
69 Msg CriticalWarning "You seem to be running locally on tclsh, so this is a debug message. \
70 The project file will be set to $proj_file and was derived from the path you launched this script from: $old_path. \
71 If you want this script to work properly in debug mode, please launch it from the top folder of one project, \
72 for example Repo/Projects/fpga1/ or Repo/Top/fpga1/"
75 set group_name [
GetGroupName $proj_dir "$tcl_path/../.."]
79 set repo_path "$tcl_path/../.."
81 Msg Info "Evaluating Hog describe for $proj_name..."
82 set describe [
GetHogDescribe [
file normalize ./Top/$group_name/$proj_name] $repo_path]
83 Msg Info "Git describe set to: $describe"
85 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
87 set bin_dir [
file normalize "$repo_path/bin"]
88 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
91 Msg Info "Evaluating last git SHA in which $proj_name was modified..."
96 if {[
file exists $dst_dir/diff_presynthesis.txt]} {
97 set fp [open "$dst_dir/diff_presynthesis.txt" r]
98 set file_data [read $fp]
100 if {$file_data != ""} {
101 Msg CriticalWarning "Git working directory [
pwd] not clean, git commit hash be set to 0."
102 set commit_usr "0000000"
105 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
108 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
112 set maxThreads [
GetMaxThreads [
file normalize ./Top/$group_name/$proj_name]]
113 if {$maxThreads != 1} {
114 Msg Warning "Multithreading enabled. Number of threads: $maxThreads"
115 set commit_usr "0000000"
117 set commit_usr $commit
121 if {[
file exists $dst_dir/diff_list_and_conf.txt]} {
122 set fp [open "$dst_dir/diff_list_and_conf.txt" r]
123 set file_data [read $fp]
125 if {$file_data != ""} {
126 Msg CriticalWarning "List files and project properties not clean, git commit hash be set to 0."
127 set commit_usr "0000000"
132 Msg Info "The git SHA value $commit will be embedded in the binary file."
138 set props [get_property "STEPS.BITGEN.ARGS.MORE OPTIONS" [get_runs impl_1]]
140 regsub -all {\{|\}} $props "" props
141 set PART [get_property part [current_project]]
143 if {[
string first "xc5v" $PART] != -1 || [
string first "xc6v" $PART] != -1 || [
string first "xc7" $PART] != -1} {
144 set props "$props -g usr_access:0x[
format %08X 0x$commit] -g userid:0x[
format %08X 0x$commit_usr]"
146 set props "$props -g userid:0x[
format %08X 0x$commit_usr]"
148 set_property -name {steps.bitgen.args.More Options} -value $props -objects [get_runs impl_1]
150 if {[
IsVersal [get_property PART [current_design]]]} {
151 Msg Info "This design uses a Versal chip, USERID does not exist."
153 set_property BITSTREAM.CONFIG.USERID $commit [current_design]
155 set_property BITSTREAM.CONFIG.USR_ACCESS $commit_usr [current_design]
159 project_open $proj_name -current_revision
161 set_global_assignment -name USE_CHECKSUM_AS_USERCODE OFF
162 set_global_assignment -name STRATIX_JTAG_USER_CODE $commit
168 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
169 if {[
file exists $user_post_implementation_file]} {
170 Msg Info "Sourcing user post_implementation file $user_post_implementation_file"
171 source $user_post_implementation_file
178 Msg Info "Evaluating Hog describe for $proj_name..."
179 set describe [
GetHogDescribe [
file normalize ./Top/$group_name/$proj_name] $repo_path]
180 Msg Info "Git describe set to: $describe"
182 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
184 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
185 Msg Info "Creating $dst_dir..."
189 set confDict [dict create]
191 if {[
file exists "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]} {
192 set confDict [
ReadConf "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]
193 set full_diff_log [
DictGet [
DictGet $confDict "hog"] "FULL_DIFF_LOG" 0]
196 Msg Info "Evaluating differences with last commit..."
197 set found_uncommitted 0
199 set diff_stat [
Git "diff --stat"]
201 set found_uncommitted 1
202 Msg Warning "Found non committed changes:"
203 if {$full_diff_log} {
206 Msg Status "$diff_stat"
208 set fp [open "$dst_dir/diff_postimplementation.txt" w+]
213 if {$found_uncommitted == 0} {
214 Msg Info "No uncommitted changes found."
218 file mkdir $dst_dir/reports
222 report_utilization -hierarchical -hierarchical_percentages -file $dst_dir/reports/hierarchical_utilization.txt
226 set reps [glob -nocomplain "$run_dir/*/*{.syr,.srp,.mrp,.map,.twr,.drc,.bgn,_routed.par,_routed_pad.txt,_routed.unroutes}"]
228 set reps [glob -nocomplain "$run_dir/*/*.rpt"]
231 if {[
file exists [
lindex $reps 0]]} {
232 file copy -force {*}$reps $dst_dir/reports
233 if {[
file exists [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]]} {
234 set utilization_file [
file normalize $dst_dir/utilization.txt]
235 set report_file [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]
236 if {$group_name != ""} {
243 Msg Warning "No reports found in $run_dir subfolders"
247 set logs [glob -nocomplain "$run_dir/*/runme.log"]
249 set run_name [
file tail [
file dirname $log]]
250 file copy -force $log $dst_dir/reports/$run_name.log
254 if {[
info exists env(HOG_SAVE_DCP)] && ($env(HOG_SAVE_DCP) == 1 || $env(HOG_SAVE_DCP) == 3)} {
255 set dcp_dir [
file normalize "$repo_path/DCPs/$group_name/$proj_name/impl_dcp"]
257 set dcps [glob -nocomplain "$run_dir/impl*/*.dcp"]
258 if {[
file exists [
lindex $dcps 0]]} {
259 file copy -force {*}$dcps $dcp_dir
265 set logs [glob -nocomplain "$proj_dir/Implementation0/*.log"]
267 if {[
file exists [
lindex $logs 0]]} {
268 file copy -force {*}$logs $dst_dir/reports
270 Msg Warning "No .log reports found in $proj_dir/Implementation0 subfolders"
274 set areas [glob -nocomplain "$proj_dir/Implementation0/*.arearep"]
276 if {[
file exists [
lindex $areas 0]]} {
277 file copy -force {*}$areas $dst_dir/reports
279 Msg Warning "No .arearep reports found in $proj_dir/Implementation0 subfolders"
283 set t_reps [glob -nocomplain "$proj_dir/Implementation0/*.twr"]
285 if {[
file exists [
lindex $t_reps 0]]} {
286 file copy -force {*}$t_reps $dst_dir/reports
288 Msg Warning "No .twr reports found in $proj_dir/Implementation0 subfolders"
292 set m_reps [glob -nocomplain "$proj_dir/Implementation0/*.mrp"]
294 if {[
file exists [
lindex $m_reps 0]]} {
295 file copy -force {*}$m_reps $dst_dir/reports
297 Msg Warning "No .mrp reports found in $proj_dir/Implementation0 subfolders"
301 set par_reps [glob -nocomplain "$proj_dir/Implementation0/*.par"]
303 if {[
file exists [
lindex $par_reps 0]]} {
304 file copy -force {*}$par_reps $dst_dir/reports
306 Msg Warning "No .par reports found in $proj_dir/Implementation0 subfolders"
312 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
313 if {[
file exists $user_post_implementation_file]} {
314 Msg Info "Sourcing user post-implementation file $user_post_implementation_file"
315 source $user_post_implementation_file