Skip to content

Commit

Permalink
Merge pull request #333 from slaclab/loadZipIpCore-update
Browse files Browse the repository at this point in the history
Updates to the loadZipIpCore TCL proc
  • Loading branch information
ruck314 authored Nov 12, 2024
2 parents 81571f2 + 47bc886 commit 1569f9a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
4 changes: 4 additions & 0 deletions vivado/gui.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ if { [isVersal] } {
# Call the user script
SourceTclFile ${VIVADO_DIR}/gui.tcl

# Attempt to upgrade before opening GUI
upgrade_ip [get_ips]
export_ip_user_files -of_objects [get_ips] -no_script -sync -force -quiet

# Bug fix work around for Vivado due to post script changes
if { [CheckSynth] == true } {
set_property NEEDS_REFRESH 0 [get_runs impl_1]
Expand Down
78 changes: 70 additions & 8 deletions vivado/proc/code_loading.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,72 @@ proc loadConstraints args {
}
}

## Function to check if the component.xml is different for new user ZIP IP core
## Returns True if they are different of IP not loaded yet
proc checkComponentXml { newIpPath repoPath } {
# Define paths for the existing and new component.xml files
set ipName [file rootname [file tail $newIpPath]]
set oldComponentPath "${repoPath}/${ipName}/component.xml"
set tempComponentPath "$::env(OUT_DIR)/component.xml"

# Check if the old component.xml exists in the repository
if { ![file exists $oldComponentPath] } {
# Return TRUE if the old component.xml does not exist
return true
}

# Check if the ZIP file exists
if { ![file exists $newIpPath] } {
puts "\n\n\n\n\n********************************************************"
puts "checkComponentXml: ZIP file does not exist at $newIpPath"
puts "********************************************************\n\n\n\n\n"
exit -1
}

# Try extracting component.xml from the ZIP file
if {[catch {exec unzip -p $newIpPath component.xml > $tempComponentPath} result]} {
puts "\n\n\n\n\n********************************************************"
puts "checkComponentXml: Failed to extract component.xml from ZIP file. Details: $result"
puts "********************************************************\n\n\n\n\n"
exit -1
}

# Verify the extracted file exists
if { ![file exists $tempComponentPath] } {
puts "\n\n\n\n\n********************************************************"
puts "checkComponentXml: component.xml could not be found in the extracted ZIP content"
puts "********************************************************\n\n\n\n\n"
exit -1
}

# Read both files for comparison
set oldFile [open $oldComponentPath]
set oldContent [read $oldFile]
close $oldFile

set newFile [open $tempComponentPath]
set newContent [read $newFile]
close $newFile

# Clean up the temporary file
file delete $tempComponentPath

# Compare the content of both files
if { $oldContent ne $newContent } {

# Delete the old content
exec rm -rf ${repoPath}/${ipName}
update_ip_catalog -rebuild -scan_changes

# Return TRUE if files are different
return true

}

# Return FALSE if files are identical
return false
}

## Function to load ZIP IP cores
proc loadZipIpCore args {
set options {
Expand Down Expand Up @@ -486,10 +552,8 @@ proc loadZipIpCore args {
set fileExt [file extension $params(path)]
if { ${fileExt} eq {.zip} ||
${fileExt} eq {.ZIP} } {
# Check if directory doesn't exist yet
set strip [file rootname [file tail $params(path)]]
set dirPath "$params(repo_path)/${strip}"
if { [file isdirectory [file rootname ${dirPath}]] == 0 } {
# Check the component.xml file
if { [checkComponentXml $params(path) $params(repo_path)] } {
# Add achieved .zip to repo path
update_ip_catalog -add_ip $params(path) -repo_path $params(repo_path)
}
Expand Down Expand Up @@ -518,10 +582,8 @@ proc loadZipIpCore args {
if { ${list} != "" } {
# Load all the constraint files
foreach pntr ${list} {
# Check if directory doesn't exist yet
set strip [file rootname [file tail ${pntr}]]
set dirPath "$params(repo_path)/${strip}"
if { [file isdirectory [file rootname ${dirPath}]] == 0 } {
# Check the component.xml file
if { [checkComponentXml ${pntr} $params(repo_path)] } {
# Add achieved .zip to repo path
update_ip_catalog -add_ip ${pntr} -repo_path $params(repo_path)
}
Expand Down
1 change: 1 addition & 0 deletions vivado/proc/ip_management.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ proc BuildIpCores { } {

# Attempt to upgrade before building IP cores
upgrade_ip [get_ips]
export_ip_user_files -of_objects [get_ips] -no_script -sync -force -quiet

# Check if the target project has IP cores
if { [get_ips] != "" } {
Expand Down

0 comments on commit 1569f9a

Please sign in to comment.