29 set tcl_path [
file normalize "[
file dirname [
info script]]/.."]
30 source $tcl_path/hog.tcl
34 set repo_path "$tcl_path/../.."
39 set proj_file [get_property DIRECTORY [current_project]]
40 set work_path [get_property DIRECTORY [get_runs impl_1]]
42 set proj_file [get_property parent.project_path [current_project]]
43 set work_path $old_path
45 set proj_dir [
file normalize [
file dirname $proj_file]]
46 set proj_name [
file rootname [
file tail $proj_file]]
47 set run_dir [
file normalize "$work_path/.."]
48 set top_name [get_property top [current_fileset]]
52 set proj_name [
lindex $quartus(args) 1]
53 set proj_dir $old_path
56 set proj_file $old_path/[
file tail $old_path].xpr
57 Msg CriticalWarning "You seem to be running locally on tclsh, so this is a debug, the project file will be set to $proj_file and was derived from the path you launched this script from: $old_path. If you want this script to work properly in debug mode, please launch it from the top folder of one project, for example Repo/Projects/fpga1/ or Repo/Top/fpga1/"
60 set group_name [
GetGroupName $proj_dir "$tcl_path/../.."]
61 Msg Info "Evaluating Git sha for $proj_name..."
62 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] sha
65 Msg Info "Git describe set to: $describe"
67 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
69 set bin_dir [
file normalize "$repo_path/bin"]
70 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
74 Msg Info "Evaluating last git SHA in which $proj_name was modified..."
79 if {[
file exists $dst_dir/diff_presynthesis.txt]} {
80 set fp [open "$dst_dir/diff_presynthesis.txt" r]
81 set file_data [read $fp]
83 if {$file_data != ""} {
84 Msg CriticalWarning "Git working directory [
pwd] not clean, git commit hash be set to 0."
85 set commit_usr "0000000"
88 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
91 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] commit version
95 set maxThreads [
GetMaxThreads [
file normalize ./Top/$group_name/$proj_name]]
96 if {$maxThreads != 1} {
97 Msg CriticalWarning "Multithreading enabled. Number of threads: $maxThreads"
98 set commit_usr "0000000"
100 set commit_usr $commit
104 if {[
file exists $dst_dir/diff_list_and_conf.txt]} {
105 set fp [open "$dst_dir/diff_list_and_conf.txt" r]
106 set file_data [read $fp]
108 if {$file_data != ""} {
109 Msg CriticalWarning "List files and project properties not clean, git commit hash be set to 0."
110 set commit_usr "0000000"
115 Msg Info "The git SHA value $commit will be embedded in the binary file."
121 set props [get_property "STEPS.BITGEN.ARGS.MORE OPTIONS" [get_runs impl_1]]
123 regsub -all {\{|\}} $props "" props
124 set PART [get_property part [current_project]]
126 if {[
string first "xc5v" $PART] != -1 || [
string first "xc6v" $PART] != -1 || [
string first "xc7" $PART] != -1} {
127 set props "$props -g usr_access:0x[
format %08X 0x$commit] -g userid:0x[
format %08X 0x$commit_usr]"
129 set props "$props -g userid:0x[
format %08X 0x$commit_usr]"
131 set_property -name {steps.bitgen.args.More Options} -value $props -objects [get_runs impl_1]
133 if {[
IsVersal [get_property PART [current_design]]]} {
134 Msg Info "This design uses a Versal chip, USERID does not exist."
136 set_property BITSTREAM.CONFIG.USERID $commit [current_design]
138 set_property BITSTREAM.CONFIG.USR_ACCESS $commit_usr [current_design]
142 project_open $proj_name -current_revision
144 set_global_assignment -name USE_CHECKSUM_AS_USERCODE OFF
145 set_global_assignment -name STRATIX_JTAG_USER_CODE $commit
151 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
152 if {[
file exists $user_post_implementation_file]} {
153 Msg Info "Sourcing user post_implementation file $user_post_implementation_file"
154 source $user_post_implementation_file
162 Msg Info "Evaluating Git sha for $proj_name..."
163 lassign [
GetRepoVersions [
file normalize ./Top/$group_name/$proj_name] $repo_path] sha
166 Msg Info "Git describe set to: $describe"
168 set ts [
clock format [
clock seconds] -format {%Y-%m-%d-%H-%M}]
170 set dst_dir [
file normalize "$bin_dir/$group_name/$proj_name\-$describe"]
171 Msg Info "Creating $dst_dir..."
175 set confDict [dict create]
177 if {[
file exists "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]} {
178 set confDict [
ReadConf "$tcl_path/../../Top/$group_name/$proj_name/hog.conf"]
179 set full_diff_log [
DictGet [
DictGet $confDict "hog"] "FULL_DIFF_LOG" 0]
182 Msg Info "Evaluating differences with last commit..."
183 set found_uncommitted 0
185 set diff_stat [
Git "diff --stat"]
187 set found_uncommitted 1
188 Msg Warning "Found non committed changes:"
189 if {$full_diff_log} {
192 Msg Status "$diff_stat"
194 set fp [open "$dst_dir/diff_postimplementation.txt" w+]
199 if {$found_uncommitted == 0} {
200 Msg Info "No uncommitted changes found."
204 file mkdir $dst_dir/reports
206 report_utilization -hierarchical -hierarchical_percentages -file $dst_dir/reports/hierarchical_utilization.txt
211 set reps [glob -nocomplain "$run_dir/*/*{.syr,.srp,.mrp,.map,.twr,.drc,.bgn,_routed.par,_routed_pad.txt,_routed.unroutes}"]
213 set reps [glob -nocomplain "$run_dir/*/*.rpt"]
215 if {[
file exists [
lindex $reps 0]]} {
216 file copy -force {*}$reps $dst_dir/reports
217 if {[
file exists [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]]} {
218 set utilization_file [
file normalize $dst_dir/utilization.txt]
219 set report_file [glob -nocomplain "$dst_dir/reports/${top_name}_utilization_placed.rpt"]
220 if {$group_name != ""} {
227 Msg Warning "No reports found in $run_dir subfolders"
231 set logs [glob -nocomplain "$run_dir/*/runme.log"]
233 set run_name [
file tail [
file dirname $log]]
234 file copy -force $log $dst_dir/reports/$run_name.log
240 set user_post_implementation_file "./Top/$group_name/$proj_name/post-implementation.tcl"
241 if {[
file exists $user_post_implementation_file]} {
242 Msg Info "Sourcing user post-implementation file $user_post_implementation_file"
243 source $user_post_implementation_file