31 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
32 source $tcl_path/hog.tcl
37 if {[
info exists env(HOG_TCLLIB_PATH)]} {
38 lappend auto_path $env(HOG_TCLLIB_PATH)
40 puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
48 set proj_dir [get_property DIRECTORY [current_project]]
49 set proj_file $proj_dir/[
file tail $proj_dir].prr
50 set work_path [get_property DIRECTORY [get_runs impl_1]]
52 set proj_file [get_property parent.project_path [current_project]]
53 set work_path $old_path
55 set proj_dir [
file normalize [
file dirname $proj_file]]
56 set proj_name [
file rootname [
file tail $proj_file]]
57 set run_dir [
file normalize "$work_path/.."]
58 set top_name [get_property top [current_fileset]]
61 set proj_name [
lindex $quartus(args) 1]
62 set proj_dir $old_path
64 set proj_dir [
file normalize "[
pwd]/.."]
65 set proj_name [
file tail $proj_dir]
66 set project $proj_name
69 set proj_file $old_path/[
file tail $old_path].xpr
70 Msg CriticalWarning "You seem to be running locally on tclsh, so this is a debug message. \
71 The project file will be set to $proj_file and was derived from the path you launched this script from: $old_path. \
72 If you want this script to work properly in debug mode, please launch it from the top folder of one project, \
73 for example Repo/Projects/fpga1/ or Repo/Top/fpga1/"
76 set group_name [
GetGroupName $proj_dir "$tcl_path/../.."]
80 set repo_path "$tcl_path/../.."
82 Msg Info "Evaluating Hog describe for $proj_name..."
83 set describe [
GetHogDescribe [
file normalize ./Top/$group_name/$proj_name] $repo_path]
84 Msg Info "Git describe set to: $describe"
86 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
88 set bin_dir [
file normalize "$repo_path/bin"]
89 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
92 Msg Info "Evaluating last git SHA in which $proj_name was modified..."
97 if {[
file exists $dst_dir/diff_presynthesis.txt]} {
98 set fp [open "$dst_dir/diff_presynthesis.txt" r]
99 set file_data [read $fp]
101 if {$file_data != ""} {
102 Msg CriticalWarning "Git working directory [
pwd] not clean, git commit hash be set to 0."
103 set commit_usr "0000000"
106 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
109 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
113 set maxThreads [
GetMaxThreads [
file normalize ./Top/$group_name/$proj_name]]
114 if {$maxThreads != 1} {
115 Msg Warning "Multithreading enabled. Number of threads: $maxThreads"
116 set commit_usr "0000000"
118 set commit_usr $commit
122 if {[
file exists $dst_dir/diff_list_and_conf.txt]} {
123 set fp [open "$dst_dir/diff_list_and_conf.txt" r]
124 set file_data [read $fp]
126 if {$file_data != ""} {
127 Msg CriticalWarning "List files and project properties not clean, git commit hash be set to 0."
128 set commit_usr "0000000"
133 Msg Info "The git SHA value $commit will be embedded in the binary file."
139 set props [get_property "STEPS.BITGEN.ARGS.MORE OPTIONS" [get_runs impl_1]]
141 regsub -all {\{|\}} $props "" props
142 set PART [get_property part [current_project]]
144 if {[
string first "xc5v" $PART] != -1 || [
string first "xc6v" $PART] != -1 || [
string first "xc7" $PART] != -1} {
145 set props "$props -g usr_access:0x[
format %08X 0x$commit] -g userid:0x[
format %08X 0x$commit_usr]"
147 set props "$props -g userid:0x[
format %08X 0x$commit_usr]"
149 set_property -name {steps.bitgen.args.More Options} -value $props -objects [get_runs impl_1]
151 if {[
IsVersal [get_property PART [current_design]]]} {
152 Msg Info "This design uses a Versal chip, USERID does not exist."
154 set_property BITSTREAM.CONFIG.USERID $commit [current_design]
156 set_property BITSTREAM.CONFIG.USR_ACCESS $commit_usr [current_design]
160 project_open $proj_name -current_revision
162 set_global_assignment -name USE_CHECKSUM_AS_USERCODE OFF
163 set_global_assignment -name STRATIX_JTAG_USER_CODE $commit
169 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
170 if {[
file exists $user_post_implementation_file]} {
171 Msg Info "Sourcing user post_implementation file $user_post_implementation_file"
172 source $user_post_implementation_file
179 Msg Info "Evaluating Hog describe for $proj_name..."
180 set describe [
GetHogDescribe [
file normalize ./Top/$group_name/$proj_name] $repo_path]
181 Msg Info "Git describe set to: $describe"
183 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
185 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
186 Msg Info "Creating $dst_dir..."
190 set confDict [dict create]
192 if {[
file exists "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]} {
193 set confDict [
ReadConf "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]
194 set full_diff_log [
DictGet [
DictGet $confDict "hog"] "FULL_DIFF_LOG" 0]
197 Msg Info "Evaluating differences with last commit..."
198 set found_uncommitted 0
200 set diff_stat [
Git "diff --stat"]
202 set found_uncommitted 1
203 Msg Warning "Found non committed changes:"
204 if {$full_diff_log} {
207 Msg Status "$diff_stat"
209 set fp [open "$dst_dir/diff_postimplementation.txt" w+]
214 if {$found_uncommitted == 0} {
215 Msg Info "No uncommitted changes found."
219 file mkdir $dst_dir/reports
223 report_utilization -hierarchical -hierarchical_percentages -file $dst_dir/reports/hierarchical_utilization.txt
227 set reps [glob -nocomplain "$run_dir/*/*{.syr,.srp,.mrp,.map,.twr,.drc,.bgn,_routed.par,_routed_pad.txt,_routed.unroutes}"]
229 set reps [glob -nocomplain "$run_dir/*/*.rpt"]
232 if {[
file exists [
lindex $reps 0]]} {
233 file copy -force {*}$reps $dst_dir/reports
234 if {[
file exists [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]]} {
235 set utilization_file [
file normalize $dst_dir/utilization.txt]
236 set report_file [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]
237 if {$group_name != ""} {
244 Msg Warning "No reports found in $run_dir subfolders"
248 set logs [glob -nocomplain "$run_dir/*/runme.log"]
250 set run_name [
file tail [
file dirname $log]]
251 file copy -force $log $dst_dir/reports/$run_name.log
255 if {[
info exists env(HOG_SAVE_DCP)] && ($env(HOG_SAVE_DCP) == 1 || $env(HOG_SAVE_DCP) == 3)} {
256 set dcp_dir [
file normalize "$repo_path/DCPs/$group_name/$proj_name/impl_dcp"]
258 set dcps [glob -nocomplain "$run_dir/impl*/*.dcp"]
259 if {[
file exists [
lindex $dcps 0]]} {
260 file copy -force {*}$dcps $dcp_dir
266 set logs [glob -nocomplain "$proj_dir/Implementation0/*.log"]
268 if {[
file exists [
lindex $logs 0]]} {
269 file copy -force {*}$logs $dst_dir/reports
271 Msg Warning "No .log reports found in $proj_dir/Implementation0 subfolders"
275 set areas [glob -nocomplain "$proj_dir/Implementation0/*.arearep"]
277 if {[
file exists [
lindex $areas 0]]} {
278 file copy -force {*}$areas $dst_dir/reports
280 Msg Warning "No .arearep reports found in $proj_dir/Implementation0 subfolders"
284 set t_reps [glob -nocomplain "$proj_dir/Implementation0/*.twr"]
286 if {[
file exists [
lindex $t_reps 0]]} {
287 file copy -force {*}$t_reps $dst_dir/reports
289 Msg Warning "No .twr reports found in $proj_dir/Implementation0 subfolders"
293 set m_reps [glob -nocomplain "$proj_dir/Implementation0/*.mrp"]
295 if {[
file exists [
lindex $m_reps 0]]} {
296 file copy -force {*}$m_reps $dst_dir/reports
298 Msg Warning "No .mrp reports found in $proj_dir/Implementation0 subfolders"
302 set par_reps [glob -nocomplain "$proj_dir/Implementation0/*.par"]
304 if {[
file exists [
lindex $par_reps 0]]} {
305 file copy -force {*}$par_reps $dst_dir/reports
307 Msg Warning "No .par reports found in $proj_dir/Implementation0 subfolders"
313 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
314 if {[
file exists $user_post_implementation_file]} {
315 Msg Info "Sourcing user post-implementation file $user_post_implementation_file"
316 source $user_post_implementation_file