1
0
mirror of https://github.com/pConst/basic_verilog.git synced 2025-01-14 06:42:54 +08:00

Updated TCL scripts

This commit is contained in:
Konstantin Pavlov 2019-07-28 12:26:13 +03:00
parent c77026f2bf
commit 7f1454e6f7
3 changed files with 74 additions and 5 deletions

View File

@ -13,6 +13,54 @@
# set_global_assignment -name POST_FLOW_SCRIPT_FILE "quartus_sh:post_flow.tcl"
#===============================================================================
# Printing current SOF version
post_message "=== VERSION ======================================================"
set data 0
set ver 0
set ver_hi 0
set ver_lo 0
#file mkdir "./DEBUG"
set ver_filename "./DEBUG/version.bin"
# reading version
if { [file exists $ver_filename] } {
set file [open $ver_filename "r"]
fconfigure $file -translation binary
set data [read $file 2]
binary scan $data H4 ver
set ver 0x${ver}
close $file
}
set ver_hi [expr $ver / 256 ]
set ver_lo [expr $ver % 256 ]
post_message [ join [ list "Current project version: " [format %d $ver] ] "" ]
post_message [ join [ list "Version HIGH byte: 0x" [format %02x $ver_hi] ] "" ]
post_message [ join [ list "Version LOW byte: 0x" [format %02x $ver_lo] ] "" ]
#===============================================================================
# copying sof file to archieve
post_message "=== SOF ARCHIEVE ================================================="
set sof_dir "./OUTPUT/"
set sof_arch_dir "./SOF_ARCHIEVE/"
set sof_filename [join [list [lindex $argv 2] ".sof"] ""]
set new_sof_filename [join [list [lindex $argv 2] "_v" [format %02x $ver_hi] [format %02x $ver_lo] ".sof"] ""]
if { [file exists ${sof_dir}${sof_filename}] } {
if { [file exists $sof_arch_dir] } {
post_message "Copying existing .sof file to archieve directory"
file copy ${sof_dir}${sof_filename} ${sof_arch_dir}
post_message "Adding version identifier to archieved .sof file"
file rename ${sof_arch_dir}${sof_filename} ${sof_arch_dir}${new_sof_filename}
}
}
# if { [file exists ${sof_dir}${sof_filename}] } {
# post_message "Adding version identifier to existing .sof file"
# file rename ${sof_dir}${sof_filename} ${sof_dir}${new_sof_filename}
# }
#===============================================================================
# Set warning on implicit nets declaration
post_message "=== ERRORS ======================================================="
@ -129,6 +177,3 @@ while { $ms_t >= 60 } {
post_message "----------------------------------"
post_message [ join [ list "TOTAL: " [format "%02d:%02d:%02d" $hs_t $ms_t $ss_t]] "" ]

View File

@ -8,12 +8,18 @@
# Stores version in binary format in "version.bin" file
# Exports updated "version.vh" define file every time compilation begins
#
# Script generates "./SOURCE/version.vh" header that could bу included into the
# project. Definitions from that file, like version number, or random seed value
# are accessible from your application logic
#
# Script requires following QSF assignment
# set_global_assignment -name PRE_FLOW_SCRIPT_FILE "quartus_sh:project_version.tcl"
# set_global_assignment -name VERILOG_FILE version.vh
post_message "=== PROJECT VERSION =============================================="
#===============================================================================
# Incrementing and printing current SOF version
post_message "=== VERSION ======================================================"
set data 0
set ver 0
set ver_hi 0
@ -44,6 +50,14 @@ post_message [ join [ list "Current project version: " [format %d $ver ] ] "" ]
post_message [ join [ list "Version HIGH byte: 0x" [format %02x $ver_hi ] ] "" ]
post_message [ join [ list "Version LOW byte: 0x" [format %02x $ver_lo ] ] "" ]
# generating random value that changes every new compilation
set rand_hi [expr {int(rand()*4294967296)}]
set rand_lo [expr {int(rand()*4294967296)}]
post_message [ join [ list "Random seed: 0x" \
[format %04x $rand_hi ] \
[format %04x $rand_lo ] ] "" ]
# writing new version
set file [open $ver_filename "w"]
fconfigure $file -translation binary
@ -63,5 +77,10 @@ puts $file "// Project version is auto-incremented every time compilation begins
puts $file ""
puts $file [ join [ list "`define VERSION_HIGH 8'h" [format %02x $ver_hi ] ] "" ]
puts $file [ join [ list "`define VERSION_LOW 8'h" [format %02x $ver_lo ]] "" ]
puts $file ""
puts $file [ join [ list "`define RAND_SEED 64'h" \
[format %04x $rand_hi ] \
[format %04x $rand_lo ] ] "" ]
puts $file ""
close $file

View File

@ -39,8 +39,13 @@ proc rd { a i } {
master_read_32 $claim_path 0x00 1
}
# pause next operations for N milliseconds
proc sleep { N } {
after [expr {int($N * 1000)}]
after [expr {int($N)}]
}
proc random_int {} {
return [expr {int(rand()*4294967296)}]
}
puts "INIT DONE"