Initial public project cleanup
This commit is contained in:
commit
2034b04519
95 files changed
+16583
No files matched your search
@@ -0,0 +1,94 @@
|
||||
set script_dir [file normalize [file dirname [info script]]]
|
||||
set project_root [file normalize [file join $script_dir ".." ".."]]
|
||||
set hls_root [file normalize [file join $project_root "hls_cnn"]]
|
||||
set vivado_root [file normalize [file join $hls_root "vivado"]]
|
||||
set ip_repo [file normalize [file join $hls_root "build" "hls_qcnn_hls" "solution1" "impl" "ip"]]
|
||||
|
||||
file mkdir $vivado_root
|
||||
|
||||
set part_name "xc7z020clg400-1"
|
||||
set project_name "hls_qcnn_pynq_z2"
|
||||
create_project -force $project_name $vivado_root -part $part_name
|
||||
|
||||
set_property target_language Verilog [current_project]
|
||||
set_property ip_repo_paths [list $ip_repo] [current_project]
|
||||
update_ip_catalog
|
||||
|
||||
create_bd_design "hls_qcnn_bd"
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:processing_system7:5.5 processing_system7_0
|
||||
apply_bd_automation -rule xilinx.com:bd_rule:processing_system7 -config {make_external "FIXED_IO, DDR" apply_board_preset "0" Master "Disable" Slave "Disable"} [get_bd_cells processing_system7_0]
|
||||
|
||||
set_property -dict [list \
|
||||
CONFIG.PCW_USE_S_AXI_HP0 {1} \
|
||||
CONFIG.PCW_USE_M_AXI_GP0 {1} \
|
||||
CONFIG.PCW_FPGA0_PERIPHERAL_FREQMHZ {100.0} \
|
||||
] [get_bd_cells processing_system7_0]
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:hls:hls_qcnn_accel:1.0 hls_qcnn_accel_0
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:proc_sys_reset:5.0 rst_ps7_0_100M
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:axi_interconnect:2.1 axi_lite_interconnect_0
|
||||
set_property CONFIG.NUM_MI {1} [get_bd_cells axi_lite_interconnect_0]
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:axi_interconnect:2.1 axi_mem_interconnect_0
|
||||
set_property CONFIG.NUM_SI {5} [get_bd_cells axi_mem_interconnect_0]
|
||||
set_property CONFIG.NUM_MI {1} [get_bd_cells axi_mem_interconnect_0]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins processing_system7_0/M_AXI_GP0_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins processing_system7_0/S_AXI_HP0_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins hls_qcnn_accel_0/ap_clk]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins rst_ps7_0_100M/slowest_sync_clk]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/S00_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/M00_ACLK]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/ACLK]
|
||||
for {set i 0} {$i < 5} {incr i} {
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/S0${i}_ACLK]
|
||||
}
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/M00_ACLK]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_RESET0_N] [get_bd_pins rst_ps7_0_100M/ext_reset_in]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins hls_qcnn_accel_0/ap_rst_n]
|
||||
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/interconnect_aresetn] [get_bd_pins axi_lite_interconnect_0/ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_lite_interconnect_0/S00_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_lite_interconnect_0/M00_ARESETN]
|
||||
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/interconnect_aresetn] [get_bd_pins axi_mem_interconnect_0/ARESETN]
|
||||
for {set i 0} {$i < 5} {incr i} {
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_mem_interconnect_0/S0${i}_ARESETN]
|
||||
}
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_mem_interconnect_0/M00_ARESETN]
|
||||
|
||||
connect_bd_intf_net [get_bd_intf_pins processing_system7_0/M_AXI_GP0] [get_bd_intf_pins axi_lite_interconnect_0/S00_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_lite_interconnect_0/M00_AXI] [get_bd_intf_pins hls_qcnn_accel_0/s_axi_control]
|
||||
|
||||
connect_bd_intf_net [get_bd_intf_pins hls_qcnn_accel_0/m_axi_gmem0] [get_bd_intf_pins axi_mem_interconnect_0/S00_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins hls_qcnn_accel_0/m_axi_gmem1] [get_bd_intf_pins axi_mem_interconnect_0/S01_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins hls_qcnn_accel_0/m_axi_gmem2] [get_bd_intf_pins axi_mem_interconnect_0/S02_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins hls_qcnn_accel_0/m_axi_gmem3] [get_bd_intf_pins axi_mem_interconnect_0/S03_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins hls_qcnn_accel_0/m_axi_gmem4] [get_bd_intf_pins axi_mem_interconnect_0/S04_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_mem_interconnect_0/M00_AXI] [get_bd_intf_pins processing_system7_0/S_AXI_HP0]
|
||||
|
||||
assign_bd_address
|
||||
validate_bd_design
|
||||
save_bd_design
|
||||
|
||||
make_wrapper -files [get_files [file join $vivado_root $project_name.srcs sources_1 bd hls_qcnn_bd hls_qcnn_bd.bd]] -top
|
||||
add_files -norecurse [file join $vivado_root $project_name.gen sources_1 bd hls_qcnn_bd hdl hls_qcnn_bd_wrapper.v]
|
||||
update_compile_order -fileset sources_1
|
||||
|
||||
launch_runs synth_1 -jobs 4
|
||||
wait_on_run synth_1
|
||||
launch_runs impl_1 -to_step write_bitstream -jobs 4
|
||||
wait_on_run impl_1
|
||||
|
||||
set output_dir [file normalize [file join $hls_root "output"]]
|
||||
file mkdir $output_dir
|
||||
file copy -force [file join $vivado_root $project_name.runs impl_1 hls_qcnn_bd_wrapper.bit] [file join $output_dir hls_qcnn.bit]
|
||||
file copy -force [file join $vivado_root $project_name.gen sources_1 bd hls_qcnn_bd hw_handoff hls_qcnn_bd.hwh] [file join $output_dir hls_qcnn.hwh]
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,103 @@
|
||||
set script_dir [file normalize [file dirname [info script]]]
|
||||
set project_root [file normalize [file join $script_dir ".." ".."]]
|
||||
set hls_root [file normalize [file join $project_root "hls_cnn"]]
|
||||
set vivado_root [file normalize [file join $hls_root "vivado"]]
|
||||
set ip_repo [file normalize [file join $hls_root "build" "tiny_cnn_hls" "solution1" "impl" "ip"]]
|
||||
|
||||
file mkdir $vivado_root
|
||||
|
||||
set part_name "xc7z020clg400-1"
|
||||
set project_name "tiny_cnn_pynq_z2"
|
||||
create_project -force $project_name $vivado_root -part $part_name
|
||||
|
||||
set_property target_language Verilog [current_project]
|
||||
set_property ip_repo_paths [list $ip_repo] [current_project]
|
||||
update_ip_catalog
|
||||
|
||||
create_bd_design "tiny_cnn_bd"
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:processing_system7:5.5 processing_system7_0
|
||||
apply_bd_automation -rule xilinx.com:bd_rule:processing_system7 -config {make_external "FIXED_IO, DDR" apply_board_preset "0" Master "Disable" Slave "Disable"} [get_bd_cells processing_system7_0]
|
||||
|
||||
set_property -dict [list \
|
||||
CONFIG.PCW_USE_S_AXI_HP0 {1} \
|
||||
CONFIG.PCW_USE_M_AXI_GP0 {1} \
|
||||
CONFIG.PCW_FPGA0_PERIPHERAL_FREQMHZ {100.0} \
|
||||
] [get_bd_cells processing_system7_0]
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:axi_dma:7.1 axi_dma_0
|
||||
set_property -dict [list \
|
||||
CONFIG.c_include_sg {0} \
|
||||
CONFIG.c_sg_include_stscntrl_strm {0} \
|
||||
CONFIG.c_include_mm2s {1} \
|
||||
CONFIG.c_include_s2mm {1} \
|
||||
CONFIG.c_m_axis_mm2s_tdata_width {32} \
|
||||
CONFIG.c_s_axis_s2mm_tdata_width {32} \
|
||||
] [get_bd_cells axi_dma_0]
|
||||
|
||||
create_bd_cell -type ip -vlnv xilinx.com:hls:tiny_cnn_accel:1.0 tiny_cnn_accel_0
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:proc_sys_reset:5.0 rst_ps7_0_100M
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:axi_interconnect:2.1 axi_lite_interconnect_0
|
||||
set_property CONFIG.NUM_MI {2} [get_bd_cells axi_lite_interconnect_0]
|
||||
create_bd_cell -type ip -vlnv xilinx.com:ip:axi_interconnect:2.1 axi_mem_interconnect_0
|
||||
set_property CONFIG.NUM_SI {2} [get_bd_cells axi_mem_interconnect_0]
|
||||
set_property CONFIG.NUM_MI {1} [get_bd_cells axi_mem_interconnect_0]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_dma_0/s_axi_lite_aclk]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_dma_0/m_axi_mm2s_aclk]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_dma_0/m_axi_s2mm_aclk]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins processing_system7_0/M_AXI_GP0_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins processing_system7_0/S_AXI_HP0_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins tiny_cnn_accel_0/ap_clk]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/S00_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/M00_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_lite_interconnect_0/M01_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/S00_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/S01_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins axi_mem_interconnect_0/M00_ACLK]
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_CLK0] [get_bd_pins rst_ps7_0_100M/slowest_sync_clk]
|
||||
|
||||
connect_bd_net [get_bd_pins processing_system7_0/FCLK_RESET0_N] [get_bd_pins rst_ps7_0_100M/ext_reset_in]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_dma_0/axi_resetn]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins tiny_cnn_accel_0/ap_rst_n]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/interconnect_aresetn] [get_bd_pins axi_lite_interconnect_0/ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_lite_interconnect_0/S00_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_lite_interconnect_0/M00_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_lite_interconnect_0/M01_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/interconnect_aresetn] [get_bd_pins axi_mem_interconnect_0/ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_mem_interconnect_0/S00_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_mem_interconnect_0/S01_ARESETN]
|
||||
connect_bd_net [get_bd_pins rst_ps7_0_100M/peripheral_aresetn] [get_bd_pins axi_mem_interconnect_0/M00_ARESETN]
|
||||
|
||||
connect_bd_intf_net [get_bd_intf_pins processing_system7_0/M_AXI_GP0] [get_bd_intf_pins axi_lite_interconnect_0/S00_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_lite_interconnect_0/M00_AXI] [get_bd_intf_pins axi_dma_0/S_AXI_LITE]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_lite_interconnect_0/M01_AXI] [get_bd_intf_pins tiny_cnn_accel_0/s_axi_control]
|
||||
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_dma_0/M_AXIS_MM2S] [get_bd_intf_pins tiny_cnn_accel_0/input_stream]
|
||||
connect_bd_intf_net [get_bd_intf_pins tiny_cnn_accel_0/output_stream] [get_bd_intf_pins axi_dma_0/S_AXIS_S2MM]
|
||||
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_dma_0/M_AXI_MM2S] [get_bd_intf_pins axi_mem_interconnect_0/S00_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_dma_0/M_AXI_S2MM] [get_bd_intf_pins axi_mem_interconnect_0/S01_AXI]
|
||||
connect_bd_intf_net [get_bd_intf_pins axi_mem_interconnect_0/M00_AXI] [get_bd_intf_pins processing_system7_0/S_AXI_HP0]
|
||||
|
||||
assign_bd_address
|
||||
validate_bd_design
|
||||
save_bd_design
|
||||
|
||||
make_wrapper -files [get_files [file join $vivado_root $project_name.srcs sources_1 bd tiny_cnn_bd tiny_cnn_bd.bd]] -top
|
||||
add_files -norecurse [file join $vivado_root $project_name.gen sources_1 bd tiny_cnn_bd hdl tiny_cnn_bd_wrapper.v]
|
||||
update_compile_order -fileset sources_1
|
||||
|
||||
launch_runs synth_1 -jobs 4
|
||||
wait_on_run synth_1
|
||||
launch_runs impl_1 -to_step write_bitstream -jobs 4
|
||||
wait_on_run impl_1
|
||||
|
||||
set output_dir [file normalize [file join $hls_root "output"]]
|
||||
file mkdir $output_dir
|
||||
file copy -force [file join $vivado_root $project_name.runs impl_1 tiny_cnn_bd_wrapper.bit] [file join $output_dir tiny_cnn.bit]
|
||||
file copy -force [file join $vivado_root $project_name.gen sources_1 bd tiny_cnn_bd hw_handoff tiny_cnn_bd.hwh] [file join $output_dir tiny_cnn.hwh]
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,59 @@
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$IpDir,
|
||||
|
||||
[string]$VivadoBat = "F:\ZYNQ_\Vivado\2020.2\bin\vivado.bat",
|
||||
|
||||
[int]$Revision = 1,
|
||||
|
||||
[string]$ArchiveName = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ipDirPath = [System.IO.Path]::GetFullPath($IpDir)
|
||||
$runIppack = Join-Path $ipDirPath "run_ippack.tcl"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $ipDirPath -PathType Container)) {
|
||||
throw "IP directory not found: $ipDirPath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $runIppack -PathType Leaf)) {
|
||||
throw "run_ippack.tcl not found: $runIppack"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $VivadoBat -PathType Leaf)) {
|
||||
throw "Vivado not found: $VivadoBat"
|
||||
}
|
||||
|
||||
$text = Get-Content -LiteralPath $runIppack -Raw
|
||||
$patched = $text -replace 'set Revision\s+"[0-9]+"', "set Revision `"$Revision`""
|
||||
if ($patched -eq $text -and $text -notmatch "set Revision\s+`"$Revision`"") {
|
||||
throw "Could not patch Revision in: $runIppack"
|
||||
}
|
||||
|
||||
Set-Content -LiteralPath $runIppack -Value $patched -Encoding ASCII
|
||||
|
||||
Push-Location $ipDirPath
|
||||
try {
|
||||
& $VivadoBat -mode batch -source $runIppack
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Vivado IP packager failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
$componentXml = Join-Path $ipDirPath "component.xml"
|
||||
if (-not (Test-Path -LiteralPath $componentXml -PathType Leaf)) {
|
||||
throw "IP packaging did not create component.xml"
|
||||
}
|
||||
|
||||
if ($ArchiveName -ne "") {
|
||||
$zip = Join-Path $ipDirPath $ArchiveName
|
||||
if (-not (Test-Path -LiteralPath $zip -PathType Leaf)) {
|
||||
Write-Warning "Expected IP archive was not found: $zip"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Patched and packaged HLS IP:"
|
||||
Write-Host " $componentXml"
|
||||
@@ -0,0 +1,40 @@
|
||||
set script_dir [file normalize [file dirname [info script]]]
|
||||
set project_root [file normalize [file join $script_dir ".." ".."]]
|
||||
set hls_root [file normalize [file join $project_root "hls_cnn"]]
|
||||
set build_root [file normalize [file join $hls_root "build"]]
|
||||
set ip_repo [file normalize [file join $hls_root "ip_repo"]]
|
||||
|
||||
file mkdir $build_root
|
||||
file mkdir $ip_repo
|
||||
|
||||
cd $build_root
|
||||
open_project -reset "tiny_cnn_hls"
|
||||
set_top tiny_cnn_accel
|
||||
add_files [file join $hls_root "src" "tiny_cnn_accel.cpp"] -cflags "-I[file join $hls_root include] -I[file join $hls_root src]"
|
||||
add_files -tb [file join $hls_root "tb" "tiny_cnn_tb.cpp"] -cflags "-I[file join $hls_root include] -I[file join $hls_root src]"
|
||||
|
||||
open_solution -reset "solution1"
|
||||
set_part {xc7z020clg400-1}
|
||||
create_clock -period 10 -name default
|
||||
|
||||
csim_design
|
||||
csynth_design
|
||||
|
||||
# Vivado/Vitis HLS 2020.2 creates a date-based IP core_revision. On current
|
||||
# dates that value can exceed what the 2020.2 IP packager accepts. Keep the
|
||||
# generated run_ippack.tcl even if export_design fails; the Windows wrapper
|
||||
# patches the revision and re-runs Vivado IP packaging.
|
||||
set export_status [catch {
|
||||
export_design -format ip_catalog -rtl verilog -description "TinyCNN HLS accelerator" -vendor "xilinx.com" -library "hls" -version "1.0" -output [file join $ip_repo "tiny_cnn_accel.zip"]
|
||||
} export_msg]
|
||||
|
||||
if {$export_status != 0} {
|
||||
puts "WARNING: export_design failed: $export_msg"
|
||||
set ippack_tcl [file join $build_root "tiny_cnn_hls" "solution1" "impl" "ip" "run_ippack.tcl"]
|
||||
if {![file exists $ippack_tcl]} {
|
||||
error "export_design failed before run_ippack.tcl was generated"
|
||||
}
|
||||
puts "WARNING: continuing after export_design failure; wrapper will patch and package IP"
|
||||
}
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,36 @@
|
||||
set script_dir [file normalize [file dirname [info script]]]
|
||||
set project_root [file normalize [file join $script_dir ".." ".."]]
|
||||
set hls_root [file normalize [file join $project_root "hls_cnn"]]
|
||||
set build_root [file normalize [file join $hls_root "build"]]
|
||||
set ip_repo [file normalize [file join $hls_root "ip_repo"]]
|
||||
|
||||
file mkdir $build_root
|
||||
file mkdir $ip_repo
|
||||
|
||||
cd $build_root
|
||||
open_project -reset "hls_qcnn_hls"
|
||||
set_top hls_qcnn_accel
|
||||
add_files [file join $hls_root "src" "hls_qcnn_accel.cpp"] -cflags "-I[file join $hls_root include] -I[file join $hls_root src]"
|
||||
add_files -tb [file join $hls_root "tb" "hls_qcnn_tb.cpp"] -cflags "-I[file join $hls_root include] -I[file join $hls_root src]"
|
||||
|
||||
open_solution -reset "solution1"
|
||||
set_part {xc7z020clg400-1}
|
||||
create_clock -period 10 -name default
|
||||
|
||||
csim_design
|
||||
csynth_design
|
||||
|
||||
set export_status [catch {
|
||||
export_design -format ip_catalog -rtl verilog -description "HLS-QCNN DDR accelerator" -vendor "xilinx.com" -library "hls" -version "1.0" -output [file join $ip_repo "hls_qcnn_accel.zip"]
|
||||
} export_msg]
|
||||
|
||||
if {$export_status != 0} {
|
||||
puts "WARNING: export_design failed: $export_msg"
|
||||
set ippack_tcl [file join $build_root "hls_qcnn_hls" "solution1" "impl" "ip" "run_ippack.tcl"]
|
||||
if {![file exists $ippack_tcl]} {
|
||||
error "export_design failed before run_ippack.tcl was generated"
|
||||
}
|
||||
puts "WARNING: continuing after export_design failure; wrapper will patch and package IP"
|
||||
}
|
||||
|
||||
exit
|
||||
@@ -0,0 +1,75 @@
|
||||
param(
|
||||
[string]$SourceHlsDir,
|
||||
[string]$WorkRoot = "C:\hls_qcnn_work",
|
||||
[string]$HlsBat = "F:\ZYNQ_\Vitis_HLS\2020.2\bin\vitis_hls.bat",
|
||||
[string]$VivadoBat = "F:\ZYNQ_\Vivado\2020.2\bin\vivado.bat"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Copy-TreeItem {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Source,
|
||||
[Parameter(Mandatory = $true)][string]$Destination
|
||||
)
|
||||
if (Test-Path -LiteralPath $Source) {
|
||||
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
$sourcePath = [System.IO.Path]::GetFullPath($SourceHlsDir)
|
||||
$workRootPath = [System.IO.Path]::GetFullPath($WorkRoot)
|
||||
$workHlsDir = Join-Path $workRootPath "hls_cnn"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourcePath -PathType Container)) {
|
||||
throw "Source HLS directory not found: $sourcePath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $HlsBat -PathType Leaf)) {
|
||||
throw "Vitis HLS not found: $HlsBat"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $VivadoBat -PathType Leaf)) {
|
||||
throw "Vivado not found: $VivadoBat"
|
||||
}
|
||||
if ($workRootPath -notmatch '^[A-Za-z]:\\hls_qcnn_work$') {
|
||||
throw "Refusing to use unexpected work root: $workRootPath"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $workRootPath | Out-Null
|
||||
if (Test-Path -LiteralPath $workHlsDir) {
|
||||
Remove-Item -LiteralPath $workHlsDir -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $workHlsDir | Out-Null
|
||||
|
||||
foreach ($dir in @("include", "scripts", "src", "tb")) {
|
||||
Copy-TreeItem -Source (Join-Path $sourcePath $dir) -Destination $workHlsDir
|
||||
}
|
||||
|
||||
Write-Host "Running HLS-QCNN Vitis HLS in ASCII work directory:"
|
||||
Write-Host " $workHlsDir"
|
||||
& $HlsBat -f (Join-Path $workHlsDir "scripts\run_hls_qcnn.tcl")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Vitis HLS failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
$ipDir = Join-Path $workHlsDir "build\hls_qcnn_hls\solution1\impl\ip"
|
||||
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $workHlsDir "scripts\patch_and_pack_ip.ps1") -IpDir $ipDir -VivadoBat $VivadoBat -Revision 1 -ArchiveName "xilinx_com_hls_hls_qcnn_accel_1_0.zip"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "IP patch/package step failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
foreach ($dir in @("build", "ip_repo")) {
|
||||
$from = Join-Path $workHlsDir $dir
|
||||
if (Test-Path -LiteralPath $from) {
|
||||
Copy-TreeItem -Source $from -Destination $sourcePath
|
||||
}
|
||||
}
|
||||
|
||||
$zip = Join-Path $ipDir "xilinx_com_hls_hls_qcnn_accel_1_0.zip"
|
||||
if (Test-Path -LiteralPath $zip) {
|
||||
$repoDir = Join-Path $sourcePath "ip_repo"
|
||||
New-Item -ItemType Directory -Force -Path $repoDir | Out-Null
|
||||
Copy-Item -LiteralPath $zip -Destination (Join-Path $repoDir "hls_qcnn_accel.zip") -Force
|
||||
}
|
||||
|
||||
Write-Host "HLS-QCNN build completed. Generated IP directory:"
|
||||
Write-Host " $(Join-Path $sourcePath 'build\hls_qcnn_hls\solution1\impl\ip')"
|
||||
@@ -0,0 +1,78 @@
|
||||
param(
|
||||
[string]$SourceHlsDir,
|
||||
[string]$WorkRoot = "C:\hls_tiny_cnn_work",
|
||||
[string]$HlsBat = "F:\ZYNQ_\Vitis_HLS\2020.2\bin\vitis_hls.bat",
|
||||
[string]$VivadoBat = "F:\ZYNQ_\Vivado\2020.2\bin\vivado.bat"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Copy-TreeItem {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Source,
|
||||
[Parameter(Mandatory = $true)][string]$Destination
|
||||
)
|
||||
if (Test-Path -LiteralPath $Source) {
|
||||
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
$sourcePath = [System.IO.Path]::GetFullPath($SourceHlsDir)
|
||||
$workRootPath = [System.IO.Path]::GetFullPath($WorkRoot)
|
||||
$workHlsDir = Join-Path $workRootPath "hls_cnn"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourcePath -PathType Container)) {
|
||||
throw "Source HLS directory not found: $sourcePath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $HlsBat -PathType Leaf)) {
|
||||
throw "Vitis HLS not found: $HlsBat"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $VivadoBat -PathType Leaf)) {
|
||||
throw "Vivado not found: $VivadoBat"
|
||||
}
|
||||
if ($workRootPath -notmatch '^[A-Za-z]:\\hls_tiny_cnn_work$') {
|
||||
throw "Refusing to use unexpected work root: $workRootPath"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $workRootPath | Out-Null
|
||||
if (Test-Path -LiteralPath $workHlsDir) {
|
||||
Remove-Item -LiteralPath $workHlsDir -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $workHlsDir | Out-Null
|
||||
|
||||
foreach ($dir in @("include", "scripts", "src", "tb")) {
|
||||
Copy-TreeItem -Source (Join-Path $sourcePath $dir) -Destination $workHlsDir
|
||||
}
|
||||
foreach ($file in @("README.md", "export_weights.py")) {
|
||||
Copy-TreeItem -Source (Join-Path $sourcePath $file) -Destination $workHlsDir
|
||||
}
|
||||
|
||||
Write-Host "Running Vitis HLS in ASCII work directory:"
|
||||
Write-Host " $workHlsDir"
|
||||
& $HlsBat -f (Join-Path $workHlsDir "scripts\run_hls.tcl")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Vitis HLS failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
$ipDir = Join-Path $workHlsDir "build\tiny_cnn_hls\solution1\impl\ip"
|
||||
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File (Join-Path $workHlsDir "scripts\patch_and_pack_ip.ps1") -IpDir $ipDir -VivadoBat $VivadoBat -Revision 1 -ArchiveName "xilinx_com_hls_tiny_cnn_accel_1_0.zip"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "IP patch/package step failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
foreach ($dir in @("build", "ip_repo")) {
|
||||
$from = Join-Path $workHlsDir $dir
|
||||
if (Test-Path -LiteralPath $from) {
|
||||
Copy-TreeItem -Source $from -Destination $sourcePath
|
||||
}
|
||||
}
|
||||
|
||||
$zip = Join-Path $ipDir "xilinx_com_hls_tiny_cnn_accel_1_0.zip"
|
||||
if (Test-Path -LiteralPath $zip) {
|
||||
$repoDir = Join-Path $sourcePath "ip_repo"
|
||||
New-Item -ItemType Directory -Force -Path $repoDir | Out-Null
|
||||
Copy-Item -LiteralPath $zip -Destination (Join-Path $repoDir "tiny_cnn_accel.zip") -Force
|
||||
}
|
||||
|
||||
Write-Host "HLS build completed. Generated IP directory:"
|
||||
Write-Host " $(Join-Path $sourcePath 'build\tiny_cnn_hls\solution1\impl\ip')"
|
||||
@@ -0,0 +1,87 @@
|
||||
param(
|
||||
[string]$SourceHlsDir,
|
||||
[string]$WorkRoot = "C:\hls_qcnn_work",
|
||||
[string]$VivadoBat = "F:\ZYNQ_\Vivado\2020.2\bin\vivado.bat"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Copy-TreeItem {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Source,
|
||||
[Parameter(Mandatory = $true)][string]$Destination
|
||||
)
|
||||
if (Test-Path -LiteralPath $Source) {
|
||||
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
$sourcePath = [System.IO.Path]::GetFullPath($SourceHlsDir)
|
||||
$workRootPath = [System.IO.Path]::GetFullPath($WorkRoot)
|
||||
$workHlsDir = Join-Path $workRootPath "hls_cnn"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourcePath -PathType Container)) {
|
||||
throw "Source HLS directory not found: $sourcePath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $VivadoBat -PathType Leaf)) {
|
||||
throw "Vivado not found: $VivadoBat"
|
||||
}
|
||||
if ($workRootPath -notmatch '^[A-Za-z]:\\hls_qcnn_work$') {
|
||||
throw "Refusing to use unexpected work root: $workRootPath"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $workRootPath | Out-Null
|
||||
if (-not (Test-Path -LiteralPath $workHlsDir -PathType Container)) {
|
||||
New-Item -ItemType Directory -Force -Path $workHlsDir | Out-Null
|
||||
}
|
||||
|
||||
foreach ($dir in @("build", "include", "scripts", "src", "tb", "ip_repo")) {
|
||||
$from = Join-Path $sourcePath $dir
|
||||
if (Test-Path -LiteralPath $from) {
|
||||
$to = Join-Path $workHlsDir $dir
|
||||
if (Test-Path -LiteralPath $to) {
|
||||
Remove-Item -LiteralPath $to -Recurse -Force
|
||||
}
|
||||
Copy-TreeItem -Source $from -Destination $workHlsDir
|
||||
}
|
||||
}
|
||||
|
||||
$ipComponent = Join-Path $workHlsDir "build\hls_qcnn_hls\solution1\impl\ip\component.xml"
|
||||
if (-not (Test-Path -LiteralPath $ipComponent -PathType Leaf)) {
|
||||
throw "Packaged HLS-QCNN IP not found. Run hls_cnn\run_hls_qcnn.bat first. Missing: $ipComponent"
|
||||
}
|
||||
|
||||
Write-Host "Running HLS-QCNN Vivado in ASCII work directory:"
|
||||
Write-Host " $workHlsDir"
|
||||
& $VivadoBat -mode batch -source (Join-Path $workHlsDir "scripts\create_hls_qcnn_vivado_project.tcl")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Vivado failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
$sourceVivado = Join-Path $sourcePath "vivado"
|
||||
$sourceOutput = Join-Path $sourcePath "output"
|
||||
New-Item -ItemType Directory -Force -Path $sourceVivado | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path $sourceOutput | Out-Null
|
||||
|
||||
Get-ChildItem -LiteralPath (Join-Path $workHlsDir "vivado") -Filter "hls_qcnn_pynq_z2*" | ForEach-Object {
|
||||
$destination = Join-Path $sourceVivado $_.Name
|
||||
if (Test-Path -LiteralPath $destination) {
|
||||
Remove-Item -LiteralPath $destination -Recurse -Force
|
||||
}
|
||||
Copy-TreeItem -Source $_.FullName -Destination $sourceVivado
|
||||
}
|
||||
Copy-Item -LiteralPath (Join-Path $workHlsDir "output\hls_qcnn.bit") -Destination (Join-Path $sourceOutput "hls_qcnn.bit") -Force
|
||||
Copy-Item -LiteralPath (Join-Path $workHlsDir "output\hls_qcnn.hwh") -Destination (Join-Path $sourceOutput "hls_qcnn.hwh") -Force
|
||||
|
||||
$bit = Join-Path $sourceOutput "hls_qcnn.bit"
|
||||
$hwh = Join-Path $sourceOutput "hls_qcnn.hwh"
|
||||
if (-not (Test-Path -LiteralPath $bit -PathType Leaf)) {
|
||||
throw "Bitstream was not copied back: $bit"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $hwh -PathType Leaf)) {
|
||||
throw "HWH was not copied back: $hwh"
|
||||
}
|
||||
|
||||
Write-Host "HLS-QCNN Vivado build completed:"
|
||||
Write-Host " $bit"
|
||||
Write-Host " $hwh"
|
||||
@@ -0,0 +1,83 @@
|
||||
param(
|
||||
[string]$SourceHlsDir,
|
||||
[string]$WorkRoot = "C:\hls_tiny_cnn_work",
|
||||
[string]$VivadoBat = "F:\ZYNQ_\Vivado\2020.2\bin\vivado.bat"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Copy-TreeItem {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Source,
|
||||
[Parameter(Mandatory = $true)][string]$Destination
|
||||
)
|
||||
if (Test-Path -LiteralPath $Source) {
|
||||
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
$sourcePath = [System.IO.Path]::GetFullPath($SourceHlsDir)
|
||||
$workRootPath = [System.IO.Path]::GetFullPath($WorkRoot)
|
||||
$workHlsDir = Join-Path $workRootPath "hls_cnn"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $sourcePath -PathType Container)) {
|
||||
throw "Source HLS directory not found: $sourcePath"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $VivadoBat -PathType Leaf)) {
|
||||
throw "Vivado not found: $VivadoBat"
|
||||
}
|
||||
if ($workRootPath -notmatch '^[A-Za-z]:\\hls_tiny_cnn_work$') {
|
||||
throw "Refusing to use unexpected work root: $workRootPath"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $workRootPath | Out-Null
|
||||
if (-not (Test-Path -LiteralPath $workHlsDir -PathType Container)) {
|
||||
New-Item -ItemType Directory -Force -Path $workHlsDir | Out-Null
|
||||
}
|
||||
|
||||
foreach ($dir in @("build", "include", "scripts", "src", "tb", "ip_repo")) {
|
||||
$from = Join-Path $sourcePath $dir
|
||||
if (Test-Path -LiteralPath $from) {
|
||||
$to = Join-Path $workHlsDir $dir
|
||||
if (Test-Path -LiteralPath $to) {
|
||||
Remove-Item -LiteralPath $to -Recurse -Force
|
||||
}
|
||||
Copy-TreeItem -Source $from -Destination $workHlsDir
|
||||
}
|
||||
}
|
||||
|
||||
$ipComponent = Join-Path $workHlsDir "build\tiny_cnn_hls\solution1\impl\ip\component.xml"
|
||||
if (-not (Test-Path -LiteralPath $ipComponent -PathType Leaf)) {
|
||||
throw "Packaged HLS IP not found. Run hls_cnn\run_hls.bat first. Missing: $ipComponent"
|
||||
}
|
||||
|
||||
Write-Host "Running Vivado in ASCII work directory:"
|
||||
Write-Host " $workHlsDir"
|
||||
& $VivadoBat -mode batch -source (Join-Path $workHlsDir "scripts\create_vivado_project.tcl")
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Vivado failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
foreach ($dir in @("vivado", "output")) {
|
||||
$from = Join-Path $workHlsDir $dir
|
||||
if (Test-Path -LiteralPath $from) {
|
||||
$to = Join-Path $sourcePath $dir
|
||||
if (Test-Path -LiteralPath $to) {
|
||||
Remove-Item -LiteralPath $to -Recurse -Force
|
||||
}
|
||||
Copy-TreeItem -Source $from -Destination $sourcePath
|
||||
}
|
||||
}
|
||||
|
||||
$bit = Join-Path $sourcePath "output\tiny_cnn.bit"
|
||||
$hwh = Join-Path $sourcePath "output\tiny_cnn.hwh"
|
||||
if (-not (Test-Path -LiteralPath $bit -PathType Leaf)) {
|
||||
throw "Bitstream was not copied back: $bit"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $hwh -PathType Leaf)) {
|
||||
throw "HWH was not copied back: $hwh"
|
||||
}
|
||||
|
||||
Write-Host "Vivado build completed:"
|
||||
Write-Host " $bit"
|
||||
Write-Host " $hwh"
|
||||
Reference in new issue
Block a user