|
|

楼主 |
发表于 2026-5-26 11:47:42
|
显示全部楼层
param(
# Vitis HLS batch launcher. Change this path if Vitis/Vivado is installed elsewhere.
[string]$VitisHls = "C:\Users\Administrator\Desktop\vvd\Vivado2023\Vivado2023\Vitis_HLS\2023.2\bin\vitis_hls.bat",
# Directory that stores the HLS Tcl flow and testbench files.
[string]$ProjectDir = "Vitis_Proj",
# Tcl script executed by Vitis HLS. This script creates the project, runs CSim,
# runs synthesis, and exports the IP.
[string]$FlowTcl = "full_hls_to_ip.tcl",
# PMSM inverter/motor algorithm source file used as the HLS design source.
[string]$SourceC = "Input\PMSM_Inv.c",
# Header that declares the HLS top function MM_SELFDRIVE.
[string]$SourceH = "Input\PMSM_Inv.h",
# C stimulus data file. It must define signalData[80001][6] for S0-S5.
[string]$StimulusC = "Input\signalData_tb.c",
# Golden reference CSV used by PMSM_Inv_tb.c to compare CSim results.
[string]$GoldenCsv = "Input\Goldendata\IaIbIc.csv",
# C simulation testbench. It drives MM_SELFDRIVE, writes IaIbIc_HLS.txt,
# and compares against GoldenCsv.
[string]$TestbenchC = "Vitis_Proj\PMSM_Inv_tb.c",
# Output directory for the exported Vivado IP archive export.zip.
[string]$ExportDir = "export_IP"
)
$ErrorActionPreference = "Stop"
function Assert-PathExists {
param(
[string]$Path,
[string]$Label
)
if (-not (Test-Path -LiteralPath $Path)) {
throw "$Label not found: $Path"
}
}
$workspace = Split-Path -Parent $MyInvocation.MyCommand.Path
if ([string]::IsNullOrEmpty($workspace)) {
$workspace = (Get-Location).Path
}
Set-Location -LiteralPath $workspace
Assert-PathExists -Path $VitisHls -Label "Vitis HLS executable"
Assert-PathExists -Path $SourceC -Label "Algorithm C source"
Assert-PathExists -Path $SourceH -Label "Algorithm header"
Assert-PathExists -Path $StimulusC -Label "Stimulus data C source"
Assert-PathExists -Path $GoldenCsv -Label "Golden CSV"
Assert-PathExists -Path $TestbenchC -Label "C simulation testbench"
Assert-PathExists -Path $ProjectDir -Label "Vitis project script directory"
Assert-PathExists -Path (Join-Path $ProjectDir $FlowTcl) -Label "Full HLS flow Tcl"
New-Item -ItemType Directory -Force -Path $ExportDir | Out-Null
Write-Host "Workspace : $workspace"
Write-Host "Algorithm source: $SourceC"
Write-Host "Stimulus data : $StimulusC"
Write-Host "Golden CSV : $GoldenCsv"
Write-Host "HLS project dir : $ProjectDir"
Write-Host "Export dir : $ExportDir"
Write-Host "Running Vitis HLS full flow..."
Push-Location -LiteralPath $ProjectDir
try {
& $VitisHls -f $FlowTcl
if ($LASTEXITCODE -ne 0) {
throw "Vitis HLS flow failed with exit code $LASTEXITCODE"
}
}
finally {
Pop-Location
}
$exportZip = Join-Path $ExportDir "export.zip"
Assert-PathExists -Path $exportZip -Label "Exported IP archive"
Write-Host "Flow completed successfully."
Write-Host "Exported IP: $exportZip"
|
|