Skip to content

Commit

Permalink
Merge pull request #306 from slaclab/ESCORE-851
Browse files Browse the repository at this point in the history
Vivado: adding ability to bypass bit and/or xsa copy
  • Loading branch information
ruck314 authored Dec 11, 2023
2 parents 2242a22 + 2516409 commit 004c852
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 33 deletions.
36 changes: 34 additions & 2 deletions system_vivado.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,46 @@ ifndef REPORT_QOR
export REPORT_QOR = 0
endif

ifndef GZIP_BUILD_IMAGE
export GZIP_BUILD_IMAGE = 0
##############################################################################

ifndef GEN_BIT_IMAGE
export GEN_BIT_IMAGE = 1
endif

ifndef GEN_BIT_IMAGE_GZIP
export GEN_BIT_IMAGE_GZIP = 0
endif

ifndef GEN_BIN_IMAGE
export GEN_BIN_IMAGE = 0
endif

ifndef GEN_BIN_IMAGE_GZIP
export GEN_BIN_IMAGE_GZIP = 0
endif

ifndef GEN_PDI_IMAGE
export GEN_PDI_IMAGE = 1
endif

ifndef GEN_PDI_IMAGE_GZIP
export GEN_PDI_IMAGE_GZIP = 0
endif

ifndef GEN_MCS_IMAGE
export GEN_MCS_IMAGE = 1
endif

ifndef GEN_MCS_IMAGE_GZIP
export GEN_MCS_IMAGE_GZIP = 0
endif

ifndef GEN_XSA_IMAGE
export GEN_XSA_IMAGE = 0
endif

##############################################################################

ifndef RECONFIG_CHECKPOINT
export RECONFIG_CHECKPOINT = 0
export RECONFIG_STATIC_HASH = 0
Expand Down
47 changes: 27 additions & 20 deletions vivado/proc/output_files.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,39 @@ proc CreateFpgaBit { } {
set topModule [file rootname [file tail [glob -dir ${IMPL_DIR} *.bit]]]

# Copy the .BIT file to image directory
exec cp -f ${IMPL_DIR}/${topModule}.bit ${imagePath}.bit
puts "Bit file copied to ${imagePath}.bit"

# Check if gzip-ing the image files
if { $::env(GZIP_BUILD_IMAGE) != 0 } {
if { $::env(GEN_BIT_IMAGE) != 0 } {
exec cp -f ${IMPL_DIR}/${topModule}.bit ${imagePath}.bit
puts "Bit file copied to ${imagePath}.bit"
}
if { $::env(GEN_BIT_IMAGE_GZIP) != 0 } {
exec gzip -c -f -9 ${IMPL_DIR}/${topModule}.bit > ${imagePath}.bit.gz
puts "Bit file copied to ${imagePath}.bit.gz"
}

# Copy the .BIN file to image directory
if { $::env(GEN_BIN_IMAGE) != 0 } {
exec cp -f ${IMPL_DIR}/${topModule}.bin ${imagePath}.bin
if { $::env(GZIP_BUILD_IMAGE) != 0 } {
exec gzip -c -f -9 ${IMPL_DIR}/${topModule}.bin > ${imagePath}.bin.gz
}
puts "Bin file copied to ${imagePath}.bin"
}
if { $::env(GEN_BIN_IMAGE_GZIP) != 0 } {
exec gzip -c -f -9 ${IMPL_DIR}/${topModule}.bin > ${imagePath}.bin.gz
puts "Bin file copied to ${imagePath}.bin.gz"
}

# Copy the .ltx file (if it exists)
CopyLtxFile

# Check for Vivado 2019.2 (or newer)
if { [VersionCompare 2019.2] >= 0 } {
# Try to generate the .XSA file
set src_rc [catch { write_hw_platform -fixed -force -include_bit -file ${imagePath}.xsa } _RESULT]
if { $::env(GEN_XSA_IMAGE) != 0 } {
# Check for Vivado 2019.2 (or newer)
if { [VersionCompare 2019.2] >= 0 } {
# Try to generate the .XSA file
set src_rc [catch { write_hw_platform -fixed -force -include_bit -file ${imagePath}.xsa } _RESULT]

# Else Vivado 2019.1 (or older)
} else {
# Try to generate the .HDF file
write_hwdef -force -file ${imagePath}.hdf
# Else Vivado 2019.1 (or older)
} else {
# Try to generate the .HDF file
write_hwdef -force -file ${imagePath}.hdf
}
}

# Create the MCS file (if target/vivado/promgen.tcl exists)
Expand All @@ -67,12 +72,14 @@ proc CreateVersalOutputs { } {
set topModule [file rootname [file tail [glob -dir ${IMPL_DIR} *.pdi]]]

# Copy the .pdi file to image directory
exec cp -f ${IMPL_DIR}/${topModule}.pdi ${imagePath}.pdi
puts "PDI file copied to ${imagePath}.pdi"

if { $::env(GEN_PDI_IMAGE) != 0 } {
exec cp -f ${IMPL_DIR}/${topModule}.pdi ${imagePath}.pdi
puts "PDI file copied to ${imagePath}.pdi"
}
# Check if gzip-ing the image files
if { $::env(GZIP_BUILD_IMAGE) != 0 } {
if { $::env(GEN_PDI_IMAGE_GZIP) != 0 } {
exec gzip -c -f -9 ${IMPL_DIR}/${topModule}.pdi > ${imagePath}.pdi.gz
puts "PDI file copied to ${imagePath}.pdi.gz"
}

# Copy the .ltx file (if it exists)
Expand Down
29 changes: 18 additions & 11 deletions vivado/promgen.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,36 @@ if { ${loaddata} != "" } {
if { ${inteface} == "SPIx8" } {

# Copy the images from build tree to source tree
exec cp -f ${outputFilePri} ${imagesFilePri}
exec cp -f ${outputFileSec} ${imagesFileSec}
puts "PROM file copied to ${imagesFilePri}"
puts "PROM file copied to ${imagesFileSec}"
if { $::env(GEN_MCS_IMAGE) != 0 } {
exec cp -f ${outputFilePri} ${imagesFilePri}
puts "PROM file copied to ${imagesFilePri}"
exec cp -f ${outputFileSec} ${imagesFileSec}
puts "PROM file copied to ${imagesFileSec}"
}

# Check if gzip-ing the image files
if { $::env(GZIP_BUILD_IMAGE) != 0 } {
if { $::env(GEN_MCS_IMAGE_GZIP) != 0 } {
# Create a compressed version of the image files
exec gzip -c -f -9 ${imagesFilePri} > ${imagesFilePri}.gz
exec gzip -c -f -9 ${imagesFileSec} > ${imagesFileSec}.gz
exec gzip -c -f -9 ${outputFilePri} > ${imagesFilePri}.gz
puts "PROM file copied to ${imagesFilePri}.gz"
exec gzip -c -f -9 ${outputFileSec} > ${imagesFileSec}.gz
puts "PROM file copied to ${imagesFileSec}.gz"
}

# Else single file PROM format
} else {

# Copy the image from build tree to source tree
exec cp -f ${outputFile} ${imagesFile}
puts "PROM file copied to ${imagesFile}"
if { $::env(GEN_MCS_IMAGE) != 0 } {
exec cp -f ${outputFile} ${imagesFile}
puts "PROM file copied to ${imagesFile}"
}

# Check if gzip-ing the image files
if { $::env(GZIP_BUILD_IMAGE) != 0 } {
if { $::env(GEN_MCS_IMAGE_GZIP) != 0 } {
# Create a compressed version of the image file
exec gzip -c -f -9 ${imagesFile} > ${imagesFile}.gz
exec gzip -c -f -9 ${outputFile} > ${imagesFile}.gz
puts "PROM file copied to ${imagesFile}.gz"
}

}

0 comments on commit 004c852

Please sign in to comment.