From 47bc886dda208a5378ce1e6fac737991088da584 Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Tue, 12 Nov 2024 13:55:24 -0800 Subject: [PATCH] adding support to check if old user IP is different to new user IP --- vivado/gui.tcl | 4 ++ vivado/proc/code_loading.tcl | 78 +++++++++++++++++++++++++++++++---- vivado/proc/ip_management.tcl | 1 + 3 files changed, 75 insertions(+), 8 deletions(-) diff --git a/vivado/gui.tcl b/vivado/gui.tcl index 4fdaf5a5..654819ed 100644 --- a/vivado/gui.tcl +++ b/vivado/gui.tcl @@ -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] diff --git a/vivado/proc/code_loading.tcl b/vivado/proc/code_loading.tcl index cb512f76..54a54c77 100644 --- a/vivado/proc/code_loading.tcl +++ b/vivado/proc/code_loading.tcl @@ -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 { @@ -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) } @@ -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) } diff --git a/vivado/proc/ip_management.tcl b/vivado/proc/ip_management.tcl index 9c346c90..0114ebff 100644 --- a/vivado/proc/ip_management.tcl +++ b/vivado/proc/ip_management.tcl @@ -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] != "" } {