To pass textural information into the parameters of
system_wrapper.sv a pre-synthesis TCL script can be used. Versioning and timestamping can also be achieved using this script. Care must be taken when a build fails and a bitstream isn't generated not to leave a version/revision missing from the build history. A post-bitstream TCL script can be used to assist with the missing version/revision problem. Note there are very many ways to achieve versioning with fallback, most of which are dependant on how revision control is used with the build process and committing of source & bitstream. The approach used here shall be a product identification file containing information pertinent to a successfully created bitstream. After a successful build the product identification file along with the new bitstream could be committed into revision control. If source is committed into revision control prior to a build being undertaken a tag from the commit could be included in the product identification file & bitstream to link the build back to the version of the source used to create it.
Create an initial product identification file and edit it to include the product information fields. Note the version will be incremented during the build process so this is set to 0.0 initially ready for it becoming 1.0. The timestamp will be overwritten so this can be set to anything.
steve@Desktop:~/projects/zedboard_leds_switches$ subl fw/project.txt
- Zedboard LEDs & Switches Example Design
- SpaceWire UK
- Steve Haywood
- 0.0
- 00-Xxx-0000 - 00:00:00
Create pre-synthesis & post-bitstream TCL scripts and edit to include the required code.
steve@Desktop:~/projects/zedboard_leds_switches$ subl fw/src/script/{pre_synth.tcl,post_bit.tcl}
- #
- # File .......... pre_synth.tcl
- # Author ........ Steve Haywood
- # Version ....... 1.0
- # Date .......... 24 October 2021
- # Description ...
- # Script to read product/project information from a text file, increase
- # the version/revision, get current timestamp and set the generics/parameters
- # on the top level module.
- #
-
- # Read Product/Project Information
- set id_file [open "../../../project.txt" r]
- gets $id_file id_description
- gets $id_file id_company
- gets $id_file id_author
- gets $id_file id_version
- gets $id_file id_timestamp
- close $id_file
-
- # Increase Version
- set id_version [expr $id_version+1]
-
- # Increase Revision
- #set id_version [expr $id_version+0.1]
-
- # Get Timestamp
- set id_timestamp "[clock format [clock seconds] -format {%d-%b-%Y - %H:%M:%S}]"
-
- # Write New Product/Project Information
- set id_file [open "../../../project_new.txt" w]
- puts $id_file $id_description
- puts $id_file $id_company
- puts $id_file $id_author
- puts $id_file $id_version
- puts $id_file $id_timestamp
- close $id_file
-
- # Replace space character with its octal code
- proc space_replace {str} {
- return [string map {" " "\\040"} $str]
- }
-
- # Replace spaces in information strings
- set id_description [space_replace $id_description]
- set id_company [space_replace $id_company]
- set id_author [space_replace $id_author]
- set id_version [space_replace $id_version]
- set id_timestamp [space_replace $id_timestamp]
-
- # Set Generics/Parameters
- set_property generic " \
- id_description=\"$id_description\" \
- id_company=\"$id_company\" \
- id_author=\"$id_author\" \
- id_version=\"$id_version\" \
- id_timestamp=\"$id_timestamp\" \
- " [current_fileset]
- #
- # File .......... post_bit.tcl
- # Author ........ Steve Haywood
- # Version ....... 1.0
- # Date .......... 24 October 2021
- # Description ...
- # Script to replace 'project.txt' (Information about last version of firmware)
- # with 'project_new.txt' (Information about new version of firmware). The file
- # replace only occurs if the bitstream was generated successfully.
- #
-
- file delete ../../../project.txt
- file rename ../../../project_new.txt ../../../project.txt
Add the pre-synthesis & post-bitstream hooks into Vivado's build process by navigating
Tools »
Settings....
In the
Settings dialog select
Synthesis under
Project Settings and click the
... button across from
tcl.pre to select the pre-synthesis file.
In the
Select A Tcl Script dialog select
New script and set this to
/home/steve/projets/zedboard_leds_switches/fw/src/script/pre_synth.tcl. Click
OK to continue.
In the
Settings dialog select
Bitstream under
Project Settings and click the
... button across from
tcl.post to select the post-bitstream file.
In the
Select A Tcl Script dialog select
New script and set this to
/home/steve/projets/zedboard_leds_switches/fw/src/script/post_bit.tcl. Click
OK to continue.