diff options
author | Patrick Lehmann <Patrick.Lehmann@tu-dresden.de> | 2016-06-22 19:18:55 +0200 |
---|---|---|
committer | Patrick Lehmann <Patrick.Lehmann@tu-dresden.de> | 2016-06-22 19:18:55 +0200 |
commit | e4e537afc5ba96e8732e86a213d566922f8c553a (patch) | |
tree | b164cb0b7ed287499dbdd8cb1c5466f0da10089e /libraries | |
parent | 0c1c22053f3372a7d0b185c7c44f83799f0b08e5 (diff) | |
download | ghdl-e4e537afc5ba96e8732e86a213d566922f8c553a.tar.gz ghdl-e4e537afc5ba96e8732e86a213d566922f8c553a.tar.bz2 ghdl-e4e537afc5ba96e8732e86a213d566922f8c553a.zip |
Reworked vendor library compile scripts for Windows.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/vendors/compile-altera.ps1 | 808 | ||||
-rwxr-xr-x | libraries/vendors/compile-altera.sh | 4 | ||||
-rw-r--r-- | libraries/vendors/compile-osvvm.ps1 | 130 | ||||
-rw-r--r-- | libraries/vendors/compile-vunit.ps1 | 183 | ||||
-rw-r--r-- | libraries/vendors/compile-xilinx-ise.ps1 | 312 | ||||
-rw-r--r-- | libraries/vendors/compile-xilinx-vivado.ps1 | 272 | ||||
-rw-r--r-- | libraries/vendors/config.psm1 | 83 | ||||
-rw-r--r-- | libraries/vendors/shared.psm1 | 322 | ||||
-rw-r--r-- | libraries/vendors/shared.sh | 4 |
9 files changed, 1139 insertions, 979 deletions
diff --git a/libraries/vendors/compile-altera.ps1 b/libraries/vendors/compile-altera.ps1 index aaf9786a9..2f703e527 100644 --- a/libraries/vendors/compile-altera.ps1 +++ b/libraries/vendors/compile-altera.ps1 @@ -3,11 +3,11 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Script: Script to compile the simulation libraries from Altera -# Quartus-II for GHDL on Windows -# # Authors: Patrick Lehmann # +# PowerShell Script: Script to compile the simulation libraries from Altera +# Quartus for GHDL on Windows +# # Description: # ------------------------------------ # This is a PowerShell script (executable) which: @@ -15,7 +15,7 @@ # - compiles all Altera Quartus-II simulation libraries and packages # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -53,6 +53,9 @@ # [CmdletBinding()] param( + # Show the embedded help page(s) + [switch]$Help = $false, + # Compile all libraries and packages. [switch]$All = $false, @@ -74,41 +77,43 @@ param( # Unknown device library [switch]$Nanometer = $false, + # Clean up directory before analyzing. + [switch]$Clean = $false, + # Set VHDL Standard to '93 [switch]$VHDL93 = $false, # Set VHDL Standard to '08 [switch]$VHDL2008 = $false, - # Clean up directory before analyzing. - [switch]$Clean = $false, - # Skip warning messages. (Show errors only.) [switch]$SuppressWarnings = $false, # Halt on errors [switch]$HaltOnError = $false, - # Show the embedded help page(s) - [switch]$Help = $false + # Set vendor library source directory + [string]$Source = "", + # Set output directory name + [string]$Output = "", + # Set GHDL executable + [string]$GHDL = "" ) -if ($Help) -{ Get-Help $MYINVOCATION.InvocationName -Detailed - return -} - # --------------------------------------------- # save working directory -$WorkingDir = Get-Location +$WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -Import-Module $PSScriptRoot\shared.psm1 +Import-Module $PSScriptRoot\config.psm1 -ArgumentList "AlteraQuartus" +Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Altera Quartus", "$WorkingDir") -# extract data from configuration -$SourceDir = $InstallationDirectory["AlteraQuartusII"] + "\quartus\eda\sim_lib" -$DestinationDir = $DestinationDirectory["Altera"] +# Display help if no command was selected +$Help = $Help -or (-not ($All -or $Altera -or $Max -or $Cyclone -or $Arria -or $Stratix -or $Nanometer)) -if ($All -eq $true) +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($All) { $Altera = $true $Max = $true $Cyclone = $true @@ -117,564 +122,419 @@ if ($All -eq $true) $Nanometer = $true } -if ($VHDL93 -eq $true) -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" -} -elseif ($VHDL2008 -eq $true) -{ $VHDLStandard = "08" - $VHDLFlavor = "standard" -} -else -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" +function Get-AlteraQuartusDirectory +{ if (Test-Path env:QUARTUS_ROOTDIR) + { return $QUARTUS_ROOTDIR + "\" + (Get-VendorToolSourceDirectory) } + else + { $EnvSourceDir = "" + foreach ($Drive in Get-DriveInfo) + { $Path = $Drive.Name + "Altera" + if (Test-Path $Path -PathType Container) + { foreach ($Major in 17..13) + { foreach ($Minor in 3..0) + { $Dir = $Path + "\" + $Major + "." + $Minor + "\quartus" + if (Test-Path $Dir -PathType Container) + { $EnvSourceDir = $Dir + "\" + (Get-VendorToolSourceDirectory) + return $EnvSourceDir + } + } + } + } + } + } } + +$SourceDirectory = Get-SourceDirectory $Source (Get-AlteraQuartusDirectory) +$DestinationDirectory = Get-DestinationDirectory $Output +$GHDLBinary = Get-GHDLBinary $GHDL + +# create "Altera" directory and change to it +New-DestinationDirectory $DestinationDirectory +cd $DestinationDirectory -$StopCompiling = $false -$ErrorCount = 0 + +$VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables $VHDL93 $VHDL2008 # define global GHDL Options -$GlobalOptions = ("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard") +$GHDLOptions = @("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard", "-P$DestinationDirectory") -# create "Altera" directory and change to it -Write-Host "Creating vendor directory: '$DestinationDir'" -ForegroundColor Yellow -mkdir $DestinationDir -ErrorAction SilentlyContinue | Out-Null -cd $DestinationDir +# extract data from configuration +# $SourceDir = $InstallationDirectory["AlteraQuartus"] + "\quartus\eda\sim_lib" -# Cleanup +$StopCompiling = $false +$ErrorCount = 0 + +# Cleanup directories # ============================================================================== if ($Clean) -{ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow +{ Write-Host "[ERROR]: '-Clean' is not implemented!" + Exit-CompileScript -1 + + Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow rm *.cf } + # Altera standard libraries # ============================================================================== # compile lpm library if ((-not $StopCompiling) -and $Altera) -{ Write-Host "Compiling library 'lpm' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\220pack.vhd", - "$SourceDir\220model.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=lpm " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "lpm" + $Files = @( + "220pack.vhd", + "220model.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile sgate library if ((-not $StopCompiling) -and $Altera) -{ Write-Host "Compiling library 'sgate' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\sgate_pack.vhd", - "$SourceDir\sgate.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=sgate " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "sgate" + $Files = @( + "sgate_pack.vhd", + "sgate.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile altera library if ((-not $StopCompiling) -and $Altera) -{ Write-Host "Compiling library 'altera' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\altera_europa_support_lib.vhd", - "$SourceDir\altera_primitives_components.vhd", - "$SourceDir\altera_primitives.vhd", - "$SourceDir\altera_standard_functions.vhd", - "$SourceDir\altera_syn_attributes.vhd", - "$SourceDir\alt_dspbuilder_package.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=altera " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "altera" + $Files = @( + "altera_europa_support_lib.vhd", + "altera_primitives_components.vhd", + "altera_primitives.vhd", + "altera_standard_functions.vhd", + "altera_syn_attributes.vhd", + "alt_dspbuilder_package.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile altera_mf library if ((-not $StopCompiling) -and $Altera) -{ Write-Host "Compiling library 'altera_mf' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\altera_mf_components.vhd", - "$SourceDir\altera_mf.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=altera_mf " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "altera_mf" + $Files = @( + "altera_mf_components.vhd", + "altera_mf.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile altera_lnsim library if ((-not $StopCompiling) -and $Altera) -{ Write-Host "Compiling library 'altera_lnsim' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - & ghdl.exe $OPTIONS --work=altera_lnsim $SourceDir\altera_lnsim_components.vhd - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=altera_lnsim " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "altera_lnsim" + $Files = @( + "altera_lnsim_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # Altera device libraries # ============================================================================== # compile max library if ((-not $StopCompiling) -and $Max) -{ Write-Host "Compiling library 'max' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\max_atoms.vhd", - "$SourceDir\max_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=max " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "max" + $Files = @( + "max_atoms.vhd", + "max_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile maxii library if ((-not $StopCompiling) -and $Max) -{ Write-Host "Compiling library 'maxii' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\maxii_atoms.vhd", - "$SourceDir\maxii_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=maxii " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "maxii" + $Files = @( + "maxii_atoms.vhd", + "maxii_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile maxv library if ((-not $StopCompiling) -and $Max) -{ Write-Host "Compiling library 'maxv' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\maxv_atoms.vhd", - "$SourceDir\maxv_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=maxv " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "maxv" + $Files = @( + "maxv_atoms.vhd", + "maxv_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriaii library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriaii' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriaii_atoms.vhd", - "$SourceDir\arriaii_components.vhd", - "$SourceDir\arriaii_hssi_components.vhd", - "$SourceDir\arriaii_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriaii " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriaii" + $Files = @( + "arriaii_atoms.vhd", + "arriaii_components.vhd", + "arriaii_hssi_components.vhd", + "arriaii_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriaii_pcie_hip library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriaii_pcie_hip' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriaii_pcie_hip_components.vhd", - "$SourceDir\arriaii_pcie_hip_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriaii_pcie_hip " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriaii_pcie_hip" + $Files = @( + "arriaii_pcie_hip_components.vhd", + "arriaii_pcie_hip_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriaiigz library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriaiigz' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriaiigz_atoms.vhd", - "$SourceDir\arriaiigz_components.vhd", - "$SourceDir\arriaiigz_hssi_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriaiigz " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriaiigz" + $Files = @( + "arriaiigz_atoms.vhd", + "arriaiigz_components.vhd", + "arriaiigz_hssi_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriav library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriav' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriav_atoms.vhd", - "$SourceDir\arriav_components.vhd", - "$SourceDir\arriav_hssi_components.vhd", - "$SourceDir\arriav_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriav " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriav" + $Files = @( + "arriav_atoms.vhd", + "arriav_components.vhd", + "arriav_hssi_components.vhd", + "arriav_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriavgz library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriavgz' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriavgz_atoms.vhd", - "$SourceDir\arriavgz_components.vhd", - "$SourceDir\arriavgz_hssi_components.vhd", - "$SourceDir\arriavgz_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriavgz " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriavgz" + $Files = @( + "arriavgz_atoms.vhd", + "arriavgz_components.vhd", + "arriavgz_hssi_components.vhd", + "arriavgz_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile arriavgz_pcie_hip library if ((-not $StopCompiling) -and $Arria) -{ Write-Host "Compiling library 'arriavgz_pcie_hip' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\arriavgz_pcie_hip_components.vhd", - "$SourceDir\arriavgz_pcie_hip_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=arriavgz_pcie_hip " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "arriavgz_pcie_hip" + $Files = @( + "arriavgz_pcie_hip_components.vhd", + "arriavgz_pcie_hip_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile cycloneiv library if ((-not $StopCompiling) -and $Cyclone) -{ Write-Host "Compiling library 'cycloneiv' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\cycloneiv_atoms.vhd", - "$SourceDir\cycloneiv_components.vhd", - "$SourceDir\cycloneiv_hssi_components.vhd", - "$SourceDir\cycloneiv_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=cycloneiv " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "cycloneiv" + $Files = @( + "cycloneiv_atoms.vhd", + "cycloneiv_components.vhd", + "cycloneiv_hssi_components.vhd", + "cycloneiv_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile cycloneiv_pcie_hip library if ((-not $StopCompiling) -and $Cyclone) -{ Write-Host "Compiling library 'cycloneiv_pcie_hip' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\cycloneiv_pcie_hip_components.vhd", - "$SourceDir\cycloneiv_pcie_hip_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=cycloneiv_pcie_hip " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "cycloneiv_pcie_hip" + $Files = @( + "cycloneiv_pcie_hip_components.vhd", + "cycloneiv_pcie_hip_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile cycloneive library if ((-not $StopCompiling) -and $Cyclone) -{ Write-Host "Compiling library 'cycloneive' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\cycloneive_atoms.vhd", - "$SourceDir\cycloneive_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=cycloneive " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "cycloneive" + $Files = @( + "cycloneive_atoms.vhd", + "cycloneive_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile cyclonev library if ((-not $StopCompiling) -and $Cyclone) -{ Write-Host "Compiling library 'cyclonev' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\cyclonev_atoms.vhd", - "$SourceDir\cyclonev_components.vhd", - "$SourceDir\cyclonev_hssi_components.vhd", - "$SourceDir\cyclonev_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=cyclonev " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "cyclonev" + $Files = @( + "cyclonev_atoms.vhd", + "cyclonev_components.vhd", + "cyclonev_hssi_components.vhd", + "cyclonev_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile stratixiv library if ((-not $StopCompiling) -and $Stratix) -{ Write-Host "Compiling library 'stratixiv' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\stratixiv_atoms.vhd", - "$SourceDir\stratixiv_components.vhd", - "$SourceDir\stratixiv_hssi_components.vhd", - "$SourceDir\stratixiv_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=stratixiv " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "stratixiv" + $Files = @( + "stratixiv_atoms.vhd", + "stratixiv_components.vhd", + "stratixiv_hssi_components.vhd", + "stratixiv_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile stratixiv_pcie_hip library if ((-not $StopCompiling) -and $Stratix) -{ Write-Host "Compiling library 'stratixiv_pcie_hip' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\stratixiv_pcie_hip_components.vhd", - "$SourceDir\stratixiv_pcie_hip_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=stratixiv_pcie_hip " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "stratixiv_pcie_hip" + $Files = @( + "stratixiv_pcie_hip_components.vhd", + "stratixiv_pcie_hip_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile stratixv library if ((-not $StopCompiling) -and $Stratix) -{ Write-Host "Compiling library 'stratixv' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\stratixv_atoms.vhd", - "$SourceDir\stratixv_components.vhd", - "$SourceDir\stratixv_hssi_components.vhd", - "$SourceDir\stratixv_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=stratixv " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "stratixv" + $Files = @( + "stratixv_atoms.vhd", + "stratixv_components.vhd", + "stratixv_hssi_components.vhd", + "stratixv_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile stratixv_pcie_hip library if ((-not $StopCompiling) -and $Stratix) -{ Write-Host "Compiling library 'stratixv_pcie_hip' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\stratixv_pcie_hip_components.vhd", - "$SourceDir\stratixv_pcie_hip_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=stratixv_pcie_hip " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "stratixv_pcie_hip" + $Files = @( + "stratixv_pcie_hip_components.vhd", + "stratixv_pcie_hip_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile fiftyfivenm library if ((-not $StopCompiling) -and $Nanometer) -{ Write-Host "Compiling library 'fiftyfivenm' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\fiftyfivenm_atoms.vhd", - "$SourceDir\fiftyfivenm_components.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=fiftyfivenm " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "fiftyfivenm" + $Files = @( + "fiftyfivenm_atoms.vhd", + "fiftyfivenm_components.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile twentynm library if ((-not $StopCompiling) -and $Nanometer) -{ Write-Host "Compiling library 'twentynm' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Files = ( - "$SourceDir\twentynm_atoms.vhd", - "$SourceDir\twentynm_components.vhd", - "$SourceDir\twentynm_hip_components.vhd", - "$SourceDir\twentynm_hip_atoms.vhd", - "$SourceDir\twentynm_hssi_components.vhd", - "$SourceDir\twentynm_hssi_atoms.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing file '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=twentynm " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "twentynm" + $Files = @( + "twentynm_atoms.vhd", + "twentynm_components.vhd", + "twentynm_hip_components.vhd", + "twentynm_hip_atoms.vhd", + "twentynm_hssi_components.vhd", + "twentynm_hssi_atoms.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } Write-Host "--------------------------------------------------------------------------------" @@ -684,10 +544,4 @@ if ($ErrorCount -gt 0) else { Write-Host "[SUCCESSFUL]" -ForegroundColor Green } -# unload PowerShell modules -Remove-Module shared -Remove-Module config - -# restore working directory -cd $WorkingDir - +Exit-CompileScript diff --git a/libraries/vendors/compile-altera.sh b/libraries/vendors/compile-altera.sh index 1b20d417e..e943dac3a 100755 --- a/libraries/vendors/compile-altera.sh +++ b/libraries/vendors/compile-altera.sh @@ -7,7 +7,7 @@ # Authors: Patrick Lehmann # # Bash Script: Script to compile the simulation libraries from Altera -# Quartus-II for GHDL on Linux +# Quartus for GHDL on Linux # # Description: # ------------------------------------ @@ -247,7 +247,7 @@ GHDL_PARAMS+=(--ieee=$VHDLFlavor --std=$VHDLStandard -P$DestinationDirectory) STOPCOMPILING=0 ERRORCOUNT=0 -# Cleanup directory +# Cleanup directories # ============================================================================== if [ "$CLEAN" == "TRUE" ]; then echo 1>&2 -e "${COLORED_ERROR} '--clean' is not implemented!" diff --git a/libraries/vendors/compile-osvvm.ps1 b/libraries/vendors/compile-osvvm.ps1 index c8c643db9..470fcf6aa 100644 --- a/libraries/vendors/compile-osvvm.ps1 +++ b/libraries/vendors/compile-osvvm.ps1 @@ -3,10 +3,10 @@ # kate: tab-width 2; replace-tabs off; indent-width 2;
#
# ==============================================================================
-# PowerShell Script: Script to compile the OSVVM library for GHDL on Windows
-#
# Authors: Patrick Lehmann
#
+# PowerShell Script: Script to compile the OSVVM library for GHDL on Windows
+#
# Description:
# ------------------------------------
# This is a PowerShell script (executable) which:
@@ -14,7 +14,7 @@ # - compiles all OSVVM packages
#
# ==============================================================================
-# Copyright (C) 2015 Patrick Lehmann
+# Copyright (C) 2015-2016 Patrick Lehmann
#
# GHDL is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -42,9 +42,15 @@ #
[CmdletBinding()]
param(
+ # Show the embedded help page(s)
+ [switch]$Help = $false,
+
# Compile all libraries and packages.
[switch]$All = $true,
+ # Compile all OSVVM packages.
+ [switch]$OSVVM = $true,
+
# Clean up directory before analyzing.
[switch]$Clean = $false,
@@ -53,85 +59,95 @@ param( # Halt on errors
[switch]$HaltOnError = $false,
- # Show the embedded help page(s)
- [switch]$Help = $false
+ # Set vendor library source directory
+ [string]$Source = "",
+ # Set output directory name
+ [string]$Output = "",
+ # Set GHDL executable
+ [string]$GHDL = ""
)
-if ($Help)
-{ Get-Help $MYINVOCATION.InvocationName -Detailed
- return
-}
-
# ---------------------------------------------
# save working directory
-$WorkingDir = Get-Location
+$WorkingDir = Get-Location
# load modules from GHDL's 'vendors' library directory
-Import-Module $PSScriptRoot\config.psm1
-Import-Module $PSScriptRoot\shared.psm1
+Import-Module $PSScriptRoot\config.psm1 -ArgumentList "OSVVM"
+Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("OSVVM", "$WorkingDir")
-# extract data from configuration
-$SourceDir = $InstallationDirectory["OSVVM"]
-$DestinationDir = $DestinationDirectory["OSVVM"]
+# Display help if no command was selected
+$Help = $Help -or (-not ($All -or $OSVVM))
-if ($All -eq $true)
-{ # nothing to configure
+if ($Help)
+{ Get-Help $MYINVOCATION.InvocationName -Detailed
+ Exit-CompileScript
+}
+if ($All)
+{ $OSVVM = $true
}
-$ErrorCount = 0
+
+$SourceDirectory = Get-SourceDirectory $Source ""
+$DestinationDirectory = Get-DestinationDirectory $Output
+$GHDLBinary = Get-GHDLBinary $GHDL
+
+# create "Altera" directory and change to it
+New-DestinationDirectory $DestinationDirectory
+cd $DestinationDirectory
+
+
+$VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables
# define global GHDL Options
-$GlobalOptions = ("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--no-vital-checks", "--std=08")
+$GHDLOptions = @("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard", "-P$DestinationDirectory")
+
+# extract data from configuration
+# $SourceDir = $InstallationDirectory["AlteraQuartus"] + "\quartus\eda\sim_lib"
-# create "osvvm" directory and change to it
-Write-Host "Creating vendor directory: '$DestinationDir'" -ForegroundColor Yellow
-mkdir $DestinationDir -ErrorAction SilentlyContinue | Out-Null
-cd $DestinationDir
+$ErrorCount = 0
-# Cleanup
+# Cleanup directories
# ==============================================================================
if ($Clean)
-{ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow
+{ Write-Host "[ERROR]: '-Clean' is not implemented!"
+ Exit-CompileScript -1
+
+ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow
rm *.cf
}
+
+# OSVVM packages
+# ==============================================================================
# compile osvvm library
-Write-Host "Compiling library 'osvvm' ..." -ForegroundColor Yellow
-$Options = $GlobalOptions
-$Files = (
- "$SourceDir\NamePkg.vhd",
- "$SourceDir\OsvvmGlobalPkg.vhd",
- "$SourceDir\TextUtilPkg.vhd",
- "$SourceDir\TranscriptPkg.vhd",
- "$SourceDir\AlertLogPkg.vhd",
- "$SourceDir\MemoryPkg.vhd",
- "$SourceDir\MessagePkg.vhd",
- "$SourceDir\SortListPkg_int.vhd",
- "$SourceDir\RandomBasePkg.vhd",
- "$SourceDir\RandomPkg.vhd",
- "$SourceDir\CoveragePkg.vhd",
- "$SourceDir\OsvvmContext.vhd")
-foreach ($File in $Files)
-{ Write-Host "Analyzing package '$File'" -ForegroundColor Cyan
- $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=osvvm " + $File + " 2>&1"
- $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings
- if ($LastExitCode -ne 0)
- { $ErrorCount += 1
- if ($HaltOnError)
- { break }
- }
+if ((-not $StopCompiling) -and $OSVVM)
+{ $Library = "osvvm"
+ $Files = @(
+ "NamePkg.vhd",
+ "OsvvmGlobalPkg.vhd",
+ "TextUtilPkg.vhd",
+ "TranscriptPkg.vhd",
+ "AlertLogPkg.vhd",
+ "MemoryPkg.vhd",
+ "MessagePkg.vhd",
+ "SortListPkg_int.vhd",
+ "RandomBasePkg.vhd",
+ "RandomPkg.vhd",
+ "CoveragePkg.vhd",
+ "OsvvmContext.vhd"
+ )
+ $SourceFiles = $Files | % { "$SourceDirectory\$_" }
+
+ $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError
+ $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0)
}
Write-Host "--------------------------------------------------------------------------------"
-Write-Host "Compiling OSVVM library " -NoNewline
+Write-Host "Compiling OSVVM packages " -NoNewline
if ($ErrorCount -gt 0)
{ Write-Host "[FAILED]" -ForegroundColor Red }
else
{ Write-Host "[SUCCESSFUL]" -ForegroundColor Green }
-# unload PowerShell modules
-Remove-Module shared
-Remove-Module config
-
-# restore working directory
-cd $WorkingDir
+Exit-CompileScript
diff --git a/libraries/vendors/compile-vunit.ps1 b/libraries/vendors/compile-vunit.ps1 index e2230fded..75bf97cd5 100644 --- a/libraries/vendors/compile-vunit.ps1 +++ b/libraries/vendors/compile-vunit.ps1 @@ -3,10 +3,10 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Script: Script to compile the VUnit library for GHDL on Windows -# # Authors: Patrick Lehmann # +# PowerShell Script: Script to compile the VUnit library for GHDL on Windows +# # Description: # ------------------------------------ # This is a PowerShell script (executable) which: @@ -14,7 +14,7 @@ # - compiles all VUnit packages # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -42,9 +42,15 @@ # [CmdletBinding()] param( + # Show the embedded help page(s) + [switch]$Help = $false, + # Compile all packages. [switch]$All = $true, + # Compile all VUnit packages. + [switch]$VUnit = $true, + # Clean up directory before analyzing. [switch]$Clean = $false, @@ -53,112 +59,121 @@ param( # Halt on errors [switch]$HaltOnError = $false, - # Show the embedded help page(s) - [switch]$Help = $false + # Set vendor library source directory + [string]$Source = "", + # Set output directory name + [string]$Output = "", + # Set GHDL executable + [string]$GHDL = "" ) -if ($Help) -{ Get-Help $MYINVOCATION.InvocationName -Detailed - return -} - # --------------------------------------------- # save working directory -$WorkingDir = Get-Location +$WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -Import-Module $PSScriptRoot\shared.psm1 +Import-Module $PSScriptRoot\config.psm1 -ArgumentList "VUnit" +Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("VUnit", "$WorkingDir") -# extract data from configuration -$SourceDir = $InstallationDirectory["VUnit"] -$DestinationDir = $DestinationDirectory["VUnit"] +# Display help if no command was selected +$Help = $Help -or (-not ($All -or $VUnit)) -if ($All -eq $true) -{ # nothing to configure +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($All) +{ $VUnit = $true } -$ErrorCount = 0 + +$SourceDirectory = Get-SourceDirectory $Source "" +$DestinationDirectory = Get-DestinationDirectory $Output +$GHDLBinary = Get-GHDLBinary $GHDL + +# create "Altera" directory and change to it +New-DestinationDirectory $DestinationDirectory +cd $DestinationDirectory + + +$VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables # define global GHDL Options -$GlobalOptions = ("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--no-vital-checks", "--std=08") +$GHDLOptions = @("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard", "-P$DestinationDirectory") + +# extract data from configuration +# $SourceDir = $InstallationDirectory["AlteraQuartus"] + "\quartus\eda\sim_lib" -# create "vunit" directory and change to it -Write-Host "Creating vendor directory: '$DestinationDir'" -ForegroundColor Yellow -mkdir $DestinationDir -ErrorAction SilentlyContinue | Out-Null -cd $DestinationDir +$ErrorCount = 0 -# Cleanup +# Cleanup directories # ============================================================================== if ($Clean) -{ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow +{ Write-Host "[ERROR]: '-Clean' is not implemented!" + Exit-CompileScript -1 + + Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow rm *.cf } + +# VUnit packages +# ============================================================================== # compile vunit_lib library -Write-Host "Compiling library 'vunit_lib' ..." -ForegroundColor Yellow -$Options = $GlobalOptions -$Files = ( - "$SourceDir\vunit\vhdl\run\src\stop_api.vhd", - "$SourceDir\vunit\vhdl\vhdl\src\lib\std\textio.vhd", - "$SourceDir\vunit\vhdl\vhdl\src\lang\lang.vhd", - "$SourceDir\vunit\vhdl\com\src\com_types.vhd", - "$SourceDir\vunit\vhdl\run\src\stop_body_2008.vhd", - "$SourceDir\vunit\vhdl\com\src\com_api.vhd", - "$SourceDir\vunit\vhdl\string_ops\src\string_ops.vhd", - "$SourceDir\vunit\vhdl\path\src\path.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_types.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_formatting.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_special_types200x.vhd", - "$SourceDir\vunit\vhdl\array\src\array_pkg.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_base_api.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_base.vhd", - "$SourceDir\vunit\vhdl\logging\src\log_api.vhd", - "$SourceDir\vunit\vhdl\logging\src\log.vhd", - "$SourceDir\vunit\vhdl\check\src\check_types.vhd", - "$SourceDir\vunit\vhdl\check\src\check_special_types200x.vhd", - "$SourceDir\vunit\vhdl\check\src\check_base_api.vhd", - "$SourceDir\vunit\vhdl\check\src\check_base.vhd", - "$SourceDir\vunit\vhdl\check\src\check_api.vhd", - "$SourceDir\vunit\vhdl\check\src\check.vhd", - "$SourceDir\vunit\vhdl\dictionary\src\dictionary.vhd", - "$SourceDir\vunit\vhdl\run\src\run_types.vhd", - "$SourceDir\vunit\vhdl\run\src\run_special_types200x.vhd", - "$SourceDir\vunit\vhdl\run\src\run_base_api.vhd", - "$SourceDir\vunit\vhdl\run\src\run_base.vhd", - "$SourceDir\vunit\vhdl\run\src\run_api.vhd", - "$SourceDir\vunit\vhdl\run\src\run.vhd", - "$SourceDir\vunit\vhdl\vunit_run_context.vhd", - "$SourceDir\vunit\vhdl\vunit_context.vhd", - "$SourceDir\vunit\vhdl\com\src\com_std_codec_builder.vhd", - "$SourceDir\vunit\vhdl\com\src\com_debug_codec_builder.vhd", - "$SourceDir\vunit\vhdl\com\src\com_string.vhd", - "$SourceDir\vunit\vhdl\com\src\com_codec_api.vhd", - "$SourceDir\vunit\vhdl\com\src\com_codec.vhd", - "$SourceDir\vunit\vhdl\com\src\com.vhd", - "$SourceDir\vunit\vhdl\com\src\com_context.vhd") -foreach ($File in $Files) -{ Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=vunit_lib " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { break } - } +if ((-not $StopCompiling) -and $VUnit) +{ $Library = "vunit_lib" + $Files = @( + "run\src\stop_api.vhd", + "vhdl\src\lib\std\textio.vhd", + "vhdl\src\lang\lang.vhd", + "com\src\com_types.vhd", + "run\src\stop_body_2008.vhd", + "com\src\com_api.vhd", + "string_ops\src\string_ops.vhd", + "path\src\path.vhd", + "logging\src\log_types.vhd", + "logging\src\log_formatting.vhd", + "logging\src\log_special_types200x.vhd", + "array\src\array_pkg.vhd", + "logging\src\log_base_api.vhd", + "logging\src\log_base.vhd", + "logging\src\log_api.vhd", + "logging\src\log.vhd", + "check\src\check_types.vhd", + "check\src\check_special_types200x.vhd", + "check\src\check_base_api.vhd", + "check\src\check_base.vhd", + "check\src\check_api.vhd", + "check\src\check.vhd", + "dictionary\src\dictionary.vhd", + "run\src\run_types.vhd", + "run\src\run_special_types200x.vhd", + "run\src\run_base_api.vhd", + "run\src\run_base.vhd", + "run\src\run_api.vhd", + "run\src\run.vhd", + "vunit_run_context.vhd", + "vunit_context.vhd", + "com\src\com_std_codec_builder.vhd", + "com\src\com_debug_codec_builder.vhd", + "com\src\com_string.vhd", + "com\src\com_codec_api.vhd", + "com\src\com_codec.vhd", + "com\src\com.vhd", + "com\src\com_context.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } Write-Host "--------------------------------------------------------------------------------" -Write-Host "Compiling VUnit library " -NoNewline +Write-Host "Compiling VUnit packages " -NoNewline if ($ErrorCount -gt 0) { Write-Host "[FAILED]" -ForegroundColor Red } else { Write-Host "[SUCCESSFUL]" -ForegroundColor Green } -# unload PowerShell modules -Remove-Module shared -Remove-Module config - -# restore working directory -cd $WorkingDir - +Exit-CompileScript diff --git a/libraries/vendors/compile-xilinx-ise.ps1 b/libraries/vendors/compile-xilinx-ise.ps1 index 610210f6c..fce3de9e3 100644 --- a/libraries/vendors/compile-xilinx-ise.ps1 +++ b/libraries/vendors/compile-xilinx-ise.ps1 @@ -3,11 +3,11 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== +# Authors: Patrick Lehmann +# # PowerShell Script: Script to compile the simulation libraries from Xilinx ISE # for GHDL on Windows # -# Authors: Patrick Lehmann -# # Description: # ------------------------------------ # This is a PowerShell script (executable) which: @@ -15,7 +15,7 @@ # - compiles all Xilinx ISE simulation libraries and packages # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -46,6 +46,9 @@ # [CmdletBinding()] param( + # Show the embedded help page(s) + [switch]$Help = $false, + # Compile all libraries and packages. [switch]$All = $false, @@ -61,21 +64,25 @@ param( # Compile the Xilinx secureip library. [switch]$SecureIP = $false, + # Clean up directory before analyzing. + [switch]$Clean = $false, + # Set VHDL Standard to '93 [switch]$VHDL93 = $false, # Set VHDL Standard to '08 [switch]$VHDL2008 = $false, - # Clean up directory before analyzing. - [switch]$Clean = $false, - # Skip warning messages. (Show errors only.) [switch]$SuppressWarnings = $false, # Halt on errors [switch]$HaltOnError = $false, - # Show the embedded help page(s) - [switch]$Help = $false + # Set vendor library source directory + [string]$Source = "", + # Set output directory name + [string]$Output = "", + # Set GHDL executable + [string]$GHDL = "" ) if ($Help) @@ -85,236 +92,178 @@ if ($Help) # --------------------------------------------- # save working directory -$WorkingDir = Get-Location +$WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -Import-Module $PSScriptRoot\shared.psm1 +Import-Module $PSScriptRoot\config.psm1 -ArgumentList "XilinxISE" +Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Xilinx ISE", "$WorkingDir") -# extract data from configuration -$SourceDir = $InstallationDirectory["XilinxISE"] + "\ISE_DS\ISE\vhdl\src" -$DestinationDir = $DestinationDirectory["XilinxISE"] +# Display help if no command was selected +$Help = $Help -or (-not ($All -or $Unisim -or $Simprim -or $Unimacro)) -if (-not $All) -{ $All = $false } -elseif ($All -eq $true) +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($All) { $Unisim = $true $Simprim = $true $Unimacro = $true $SecureIP = $true } -if ($VHDL93 -eq $true) -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" - $DestinationDir += ".v93" +function Get-XilinxISEDirectory +{ if (Test-Path env:XILINX) + { return $XILINX + "\" + (Get-VendorToolSourceDirectory) } + else + { $EnvSourceDir = "" + foreach ($Drive in Get-DriveInfo) + { $Path = $Drive.Name + "Xilinx" + if (Test-Path $Path -PathType Container) + { foreach ($Major in 14..12) + { foreach ($Minor in 7..1) + { $Dir = $Path + "\" + $Major + "." + $Minor + "\ISE_DS" + if (Test-Path $Dir -PathType Container) + { $EnvSourceDir = $Dir + "\" + (Get-VendorToolSourceDirectory) + return $EnvSourceDir + } + } + } + } + } + } } -elseif ($VHDL2008 -eq $true) -{ $VHDLStandard = "08" - $VHDLFlavor = "standard" - $DestinationDir += ".v08" - Write-Host "Not all Xilinx primitives are VHDL-2008 compatible! Setting HaltOnError to FALSE." -ForegroundColor Red + +$SourceDirectory = Get-SourceDirectory $Source (Get-XilinxISEDirectory) +$DestinationDirectory = Get-DestinationDirectory $Output +$GHDLBinary = Get-GHDLBinary $GHDL + +# create "Altera" directory and change to it +New-DestinationDirectory $DestinationDirectory +cd $DestinationDirectory + +if ($VHDL2008) +{ Write-Host "Not all Xilinx primitives are VHDL-2008 compatible! Setting HaltOnError to FALSE." -ForegroundColor Red $HaltOnError = $false } -else -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" - $DestinationDir += ".v93" -} +$VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables $VHDL93 $VHDL2008 + +# define global GHDL Options +$GHDLOptions = @("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard", "-P$DestinationDirectory") + +# extract data from configuration +# $SourceDir = $InstallationDirectory["AlteraQuartus"] + "\quartus\eda\sim_lib" $StopCompiling = $false $ErrorCount = 0 -# define global GHDL Options -$GlobalOptions = ("-a", "-fexplicit", "-frelaxed-rules", "--no-vital-checks", "--warn-binding", "--mb-comments") - -# create "Xilinx" directory and change to it -Write-Host "Creating vendor directory: '$DestinationDir'" -ForegroundColor Yellow -mkdir $DestinationDir -ErrorAction SilentlyContinue | Out-Null -cd $DestinationDir -# Cleanup +# Cleanup directories # ============================================================================== if ($Clean) -{ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow +{ Write-Host "[ERROR]: '-Clean' is not implemented!" + Exit-CompileScript -1 + + Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow rm *.cf } -# Library UNISIM + +# Library UniSim # ============================================================================== # compile unisim packages if ((-not $StopCompiling) -and $Unisim) -{ Write-Host "Compiling library 'unisim' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = ( - "$SourceDir\unisims\unisim_VPKG.vhd", - "$SourceDir\unisims\unisim_VCOMP.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unisim " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "unisim" + $Files = @( + "unisims\unisim_VPKG.vhd", + "unisims\unisim_VCOMP.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unisim primitives if ((-not $StopCompiling) -and $Unisim) -{ $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unisims\primitive\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unisim " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "unisim" + $SourceFiles = dir "$SourceDirectory\unisims\primitive\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unisim secureip primitives if ((-not $StopCompiling) -and $Unisim -and $SecureIP) -{ Write-Host "Compiling library secureip primitives ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unisims\secureip\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=secureip " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - # break - } - } - } +{ $Library = "secureip" + $SourceFiles = dir "$SourceDirectory\unisims\secureip\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # Library UNIMACRO # ============================================================================== # compile unimacro packages if ((-not $StopCompiling) -and $Unimacro) -{ Write-Host "Compiling library 'unimacro' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" +{ $Library = "unimacro" $Files = @( - "$SourceDir\unimacro\unimacro_VCOMP.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unimacro " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } + "unimacro\unimacro_VCOMP.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unimacro macros if ((-not $StopCompiling) -and $Unimacro) -{ $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unimacro\*_MACRO.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unimacro " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "unimacro" + $SourceFiles = dir "$SourceDirectory\unimacro\*_MACRO.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # Library SIMPRIM # ============================================================================== # compile simprim packages if ((-not $StopCompiling) -and $Simprim) -{ Write-Host "Compiling library 'simprim' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" +{ $Library = "simprim" $Files = ( - "$SourceDir\simprims\simprim_Vpackage.vhd", - "$SourceDir\simprims\simprim_Vcomponents.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=simprim " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } + "simprims\simprim_Vpackage.vhd", + "simprims\simprim_Vcomponents.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile simprim primitives if ((-not $StopCompiling) -and $Simprim) -{ Write-Host "Compiling library 'simprim' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\simprims\primitive\other\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=simprim " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - # break - } - } - } +{ $Library = "simprim" + $SourceFiles = dir "$SourceDirectory\simprims\primitive\other\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile simprim secureip primitives if ((-not $StopCompiling) -and $Simprim -and $SecureIP) -{ Write-Host "Compiling secureip primitives ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\simprims\secureip\other\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=simprim " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - # break - } - } - } +{ $Library = "secureip" + $SourceFiles = dir "$SourceDirectory\simprims\secureip\other\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } Write-Host "--------------------------------------------------------------------------------" @@ -324,9 +273,4 @@ if ($ErrorCount -gt 0) else { Write-Host "[SUCCESSFUL]" -ForegroundColor Green } -# unload PowerShell modules -Remove-Module shared -Remove-Module config - -# restore working directory -cd $WorkingDir +Exit-CompileScript diff --git a/libraries/vendors/compile-xilinx-vivado.ps1 b/libraries/vendors/compile-xilinx-vivado.ps1 index 8628b278f..ff135315e 100644 --- a/libraries/vendors/compile-xilinx-vivado.ps1 +++ b/libraries/vendors/compile-xilinx-vivado.ps1 @@ -3,11 +3,11 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== +# Authors: Patrick Lehmann +# # PowerShell Script: Script to compile the simulation libraries from Xilinx # Vivado for GHDL on Windows # -# Authors: Patrick Lehmann -# # Description: # ------------------------------------ # This is a PowerShell script (executable) which: @@ -15,7 +15,7 @@ # - compiles all Xilinx Vivado simulation libraries and packages # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -45,6 +45,9 @@ # [CmdletBinding()] param( + # Show the embedded help page(s) + [switch]$Help = $false, + # Compile all libraries and packages. [switch]$All = $false, @@ -57,218 +60,177 @@ param( # Compile the Xilinx secureip library. [switch]$SecureIP = $false, + # Clean up directory before analyzing. + [switch]$Clean = $false, + # Set VHDL Standard to '93 [switch]$VHDL93 = $false, # Set VHDL Standard to '08 [switch]$VHDL2008 = $false, - # Clean up directory before analyzing. - [switch]$Clean = $false, - # Skip warning messages. (Show errors only.) [switch]$SuppressWarnings = $false, # Halt on errors [switch]$HaltOnError = $false, - # Show the embedded help page(s) - [switch]$Help = $false + # Set vendor library source directory + [string]$Source = "", + # Set output directory name + [string]$Output = "", + # Set GHDL executable + [string]$GHDL = "" ) -if ($Help) -{ Get-Help $MYINVOCATION.InvocationName -Detailed - return -} - # --------------------------------------------- # save working directory -$WorkingDir = Get-Location +$WorkingDir = Get-Location # load modules from GHDL's 'vendors' library directory -Import-Module $PSScriptRoot\config.psm1 -Import-Module $PSScriptRoot\shared.psm1 +Import-Module $PSScriptRoot\config.psm1 -ArgumentList "XilinxVivado" +Import-Module $PSScriptRoot\shared.psm1 -ArgumentList @("Xilinx Vivado", "$WorkingDir") -# extract data from configuration -$SourceDir = $InstallationDirectory["XilinxVivado"] + "\data\vhdl\src" -$DestinationDir = $DestinationDirectory["XilinxVivado"] +# Display help if no command was selected +$Help = $Help -or (-not ($All -or $Unisim -or $Simprim -or $Unimacro)) -if ($All -eq $true) +if ($Help) +{ Get-Help $MYINVOCATION.InvocationName -Detailed + Exit-CompileScript +} +if ($All) { $Unisim = $true $Simprim = $true $Unimacro = $true $SecureIP = $true } -if ($VHDL93 -eq $true) -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" - $DestinationDir += ".v93" +function Get-XilinxVivadoDirectory +{ if (Test-Path env:XILINX_VIVADO) + { return $XILINX_VIVADO + "\" + (Get-VendorToolSourceDirectory) } + else + { $EnvSourceDir = "" + foreach ($Drive in Get-DriveInfo) + { $Path = $Drive.Name + "Xilinx\Vivado" + if (Test-Path $Path -PathType Container) + { foreach ($Major in 2018..2014) + { foreach ($Minor in 4..1) + { $Dir = $Path + "\" + $Major + "." + $Minor + if (Test-Path $Dir -PathType Container) + { $EnvSourceDir = $Dir + "\" + (Get-VendorToolSourceDirectory) + return $EnvSourceDir + } + } + } + } + } + } } -elseif ($VHDL2008 -eq $true) -{ $VHDLStandard = "08" - $VHDLFlavor = "standard" - $DestinationDir += ".v08" - Write-Host "Not all Xilinx primitives are VHDL-2008 compatible! Setting HaltOnError to FALSE." -ForegroundColor Red + +$SourceDirectory = Get-SourceDirectory $Source (Get-XilinxVivadoDirectory) +$DestinationDirectory = Get-DestinationDirectory $Output +$GHDLBinary = Get-GHDLBinary $GHDL + +# create "Altera" directory and change to it +New-DestinationDirectory $DestinationDirectory +cd $DestinationDirectory + +if ($VHDL2008) +{ Write-Host "Not all Xilinx primitives are VHDL-2008 compatible! Setting HaltOnError to FALSE." -ForegroundColor Red $HaltOnError = $false } -else -{ $VHDLStandard = "93c" - $VHDLFlavor = "synopsys" - $DestinationDir += ".v93" -} +$VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables $VHDL93 $VHDL2008 + +# define global GHDL Options +$GHDLOptions = @("-a", "-fexplicit", "-frelaxed-rules", "--mb-comments", "--warn-binding", "--ieee=$VHDLFlavor", "--no-vital-checks", "--std=$VHDLStandard", "-P$DestinationDirectory") + +# extract data from configuration +# $SourceDir = $InstallationDirectory["AlteraQuartus"] + "\quartus\eda\sim_lib" $StopCompiling = $false $ErrorCount = 0 -# define global GHDL Options -$GlobalOptions = ("-a", "-fexplicit", "-frelaxed-rules", "--warn-binding", "--mb-comments") - -# create "Vivado" directory and change to it -Write-Host "Creating vendor directory: '$DestinationDir'" -ForegroundColor Yellow -mkdir $DestinationDir -ErrorAction SilentlyContinue | Out-Null -cd $DestinationDir -# Cleanup +# Cleanup directories # ============================================================================== if ($Clean) -{ Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow +{ Write-Host "[ERROR]: '-Clean' is not implemented!" + Exit-CompileScript -1 + + Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow rm *.cf } + # Library UNISIM # ============================================================================== # compile unisim packages if ((-not $StopCompiling) -and $Unisim) -{ Write-Host "Compiling library 'unisim' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--no-vital-checks" - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = ( - "$SourceDir\unisims\unisim_VPKG.vhd", - "$SourceDir\unisims\unisim_VCOMP.vhd", - "$SourceDir\unisims\retarget_VCOMP.vhd", - "$SourceDir\unisims\unisim_retarget_VCOMP.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unisim " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "unisim" + $Files = @( + "unisims\unisim_VPKG.vhd", + "unisims\unisim_VCOMP.vhd", + "unisims\retarget_VCOMP.vhd", + "unisims\unisim_retarget_VCOMP.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unisim primitives if ((-not $StopCompiling) -and $Unisim) -{ $Options = $GlobalOptions - $Options += "--no-vital-checks" - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unisims\primitive\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unisim " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "unisim" + $SourceFiles = dir "$SourceDirectory\unisims\primitive\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unisim retarget primitives if ((-not $StopCompiling) -and $Unisim) -{ $Options = $GlobalOptions - $Options += "--no-vital-checks" - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unisims\retarget\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing retarget primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unisim " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - # break - } - } - } +{ $Library = "unisim" + $SourceFiles = dir "$SourceDirectory\unisims\retarget\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unisim secureip primitives if ((-not $StopCompiling) -and $Unisim -and $SecureIP) -{ Write-Host "Compiling library secureip primitives ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unisims\secureip\*.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=secureip " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } +{ $Library = "secureip" + $SourceFiles = dir "$SourceDirectory\unisims\secureip\*.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # Library UNIMACRO # ============================================================================== # compile unimacro packages if ((-not $StopCompiling) -and $Unimacro) -{ Write-Host "Compiling library 'unimacro' ..." -ForegroundColor Yellow - $Options = $GlobalOptions - $Options += "--no-vital-checks" - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" +{ $Library = "unimacro" $Files = @( - "$SourceDir\unimacro\unimacro_VCOMP.vhd") - foreach ($File in $Files) - { Write-Host "Analyzing package '$File'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unimacro " + $File + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - break - } - } - } + "unimacro\unimacro_VCOMP.vhd" + ) + $SourceFiles = $Files | % { "$SourceDirectory\$_" } + + $ErrorCount += 0 + Start-PackageCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # compile unimacro macros if ((-not $StopCompiling) -and $Unimacro) -{ $Options = $GlobalOptions - $Options += "--no-vital-checks" - $Options += "--ieee=$VHDLFlavor" - $Options += "--std=$VHDLStandard" - $Files = dir "$SourceDir\unimacro\*_MACRO.vhd*" - foreach ($File in $Files) - { Write-Host "Analyzing primitive '$($File.FullName)'" -ForegroundColor Cyan - $InvokeExpr = "ghdl.exe " + ($Options -join " ") + " --work=unimacro " + $File.FullName + " 2>&1" - $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings - if ($LastExitCode -ne 0) - { $ErrorCount += 1 - if ($HaltOnError) - { $StopCompiling = $true - # break - } - } - } +{ $Library = "unimacro" + $SourceFiles = dir "$SourceDirectory\unimacro\*_MACRO.vhd*" + + $ErrorCount += 0 + Start-PrimitiveCompilation $GHDLBinary $GHDLOptions $DestinationDirectory $Library $VHDLVersion $SourceFiles $HaltOnError + $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) } # Library UNIFAST @@ -282,10 +244,4 @@ if ($ErrorCount -gt 0) else { Write-Host "[SUCCESSFUL]" -ForegroundColor Green } -# unload PowerShell modules -Remove-Module shared -Remove-Module config - -# restore working directory -cd $WorkingDir - +Exit-CompileScript diff --git a/libraries/vendors/config.psm1 b/libraries/vendors/config.psm1 index 3c228f3b1..778687e96 100644 --- a/libraries/vendors/config.psm1 +++ b/libraries/vendors/config.psm1 @@ -3,17 +3,17 @@ # kate: tab-width 2; replace-tabs off; indent-width 2; # # ============================================================================== -# PowerShell Module: Configurable directories to local installed tools -# # Authors: Patrick Lehmann # +# PowerShell Module: Configurable directories to local installed tools +# # Description: # ------------------------------------ # This PowerShell module exports variables containing the users local tool # environment. # # ============================================================================== -# Copyright (C) 2015 Patrick Lehmann +# Copyright (C) 2015-2016 Patrick Lehmann # # GHDL is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -31,23 +31,76 @@ # 02111-1307, USA. # ============================================================================== # +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$VendorToolName +) + +$Module_VendorToolName = $VendorToolName + # Configure your tools here. Use absolute paths, without trailing directory # delimiter. Empty strings indicate not installed tools -$InstallationDirectory = @{ - "AlteraQuartusII" = "C:\Altera\15.1"; - "XilinxISE" = "C:\Xilinx\14.7"; - "XilinxVivado" = "C:\Xilinx\Vivado\2016.1"; - "OSVVM" = "D:\git\PoC\lib\osvvm"; - "VUnit" = "D:\git\PoC\lib\vunit" +$InstallationDirectories = @{ + "AlteraQuartus" = "" # "C:\Altera\15.1\quartus"; + "LatticeDiamond" = "" # "C:\Lattice\Diamond\3.7_x64" + "XilinxISE" = "" # "C:\Xilinx\14.7\ISE_DS"; + "XilinxVivado" = "" # "C:\Xilinx\Vivado\2016.1"; + "OSVVM" = "" # "C:\git\GitHub\osvvm"; + "VUnit" = "" # "C:\git\GitHub\vunit" +} + +$SourceDirectories = @{ + "AlteraQuartus" = "eda\sim_lib"; + "LatticeDiamond" = "cae_library\simulation\vhdl" + "XilinxISE" = "ISE\vhdl\src"; + "XilinxVivado" = "data\vhdl\src"; + "OSVVM" = "."; + "VUnit" = "vunit\vhdl" } -$DestinationDirectory = @{ - "Altera" = "altera"; +$DestinationDirectories = @{ + "AlteraQuartus" = "altera"; + "LatticeDiamond" = "lattice"; "XilinxISE" = "xilinx-ise"; "XilinxVivado" = "xilinx-vivado"; - "OSVVM" = "osvvm"; - "VUnit" = "vunit" + "OSVVM" = "."; + "VUnit" = "." +} + + +function Get-VendorToolInstallationDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + #> + return $InstallationDirectories[$Module_VendorToolName] +} + +function Get-VendorToolSourceDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + #> + return $SourceDirectories[$Module_VendorToolName] +} + +function Get-VendorToolDestinationDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + #> + return $DestinationDirectories[$Module_VendorToolName] } -Export-ModuleMember -Variable 'InstallationDirectory' -Export-ModuleMember -Variable 'DestinationDirectory' +Export-ModuleMember -Function 'Get-VendorToolInstallationDirectory' +Export-ModuleMember -Function 'Get-VendorToolSourceDirectory' +Export-ModuleMember -Function 'Get-VendorToolDestinationDirectory' diff --git a/libraries/vendors/shared.psm1 b/libraries/vendors/shared.psm1 index 9685f1f00..97a196fd3 100644 --- a/libraries/vendors/shared.psm1 +++ b/libraries/vendors/shared.psm1 @@ -31,6 +31,315 @@ # Software Foundation, 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # ============================================================================== + +[CmdletBinding()] +param( + [Parameter(Mandatory=$true)][string]$VendorToolName, + [Parameter(Mandatory=$true)][string]$WorkingDir +) + +$Module_VendorToolName = $VendorToolName +$Module_WorkingDir = $WorkingDir + +function Exit-CompileScript +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER ExitCode + ExitCode of this script run + #> + [CmdletBinding()] + param( + [int]$ExitCode = 0 + ) + + cd $Module_WorkingDir + + # unload modules + Remove-Module config + Remove-Module shared + + if ($ExitCode -eq 0) + { exit 0 } + else + { Write-Host "[DEBUG]: HARD EXIT" -ForegroundColor Cyan + exit $ExitCode + } +} + +function Get-SourceDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Source + Undocumented + .PARAMETER EnvSource + Undocumented + #> + [CmdletBinding()] + param( + [string]$Source, + [string]$EnvSource + ) + + if ($Source -ne "") + { $SourceDirectory = $Source } # TODO: remove trailing backslashes + elseif ($EnvSource -ne "") + { $SourceDirectory = $EnvSource } + else + { $SourceDirectory = (Get-VendorToolInstallationDirectory) + "\" + (Get-VendorToolSourceDirectory) } + + if ($SourceDirectory -eq "") + { Write-Host "[ERROR]: $Module_VendorToolName is not configured in '$ScriptDir\config.psm1'." -ForegroundColor Red + Write-Host " Use adv. options '-Source' and '-Output' or configure 'config.psm1'." -ForegroundColor Red + Exit-CompileScript -1 + } + elseif (-not (Test-Path $SourceDirectory -PathType Container)) + { Write-Host "[ERROR]: Path '$SourceDirectory' does not exist." -ForegroundColor Red + Exit-CompileScript -1 + } + + return Convert-Path (Resolve-Path $SourceDirectory) +} + +function Get-DestinationDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER Output + Undocumented + #> + [CmdletBinding()] + param( + [string]$Output + ) + if ($Output -ne "") + { $DestinationDirectory = $Output } # TODO: remove trailing backslashes + else + { $DestinationDirectory = Get-VendorToolDestinationDirectory } + + if ($DestinationDirectory -eq "") + { Write-Host "[ERROR]: $Module_VendorToolName is not configured in '$ScriptDir\config.psm1'." -ForegroundColor Red + Write-Host " Use adv. options '-Source' and '-Output' or configure 'config.psm1'." -ForegroundColor Red + Exit-CompileScript -1 + } + + # if ($DestinationDirectory.IsAbsolute()) + # { $DestinationDirectory = "$Module_WorkingDir\$DestinationDirectory" } + + return $DestinationDirectory +} + +function Get-GHDLBinary +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER GHDL + Undocumented + #> + [CmdletBinding()] + param( + [string]$GHDL + ) + + if ($GHDL -ne "") + { $GHDLBinary = $GHDL } + elseif (Test-Path env:GHDL) + { $GHDLBinary = $env:GHDL } + else + { $GHDLBinary = "ghdl.exe" } + + if (-not (Test-Path $GHDLBinary -PathType Leaf)) + { Write-Host "Use adv. options '-GHDL' to set the GHDL executable." -ForegroundColor Red + Exit-CompileScript -1 + } + + return $GHDLBinary +} + + +function Get-VHDLVariables +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER VHDL93 + Undocumented + .PARAMETER VHDL2008 + Undocumented + #> + [CmdletBinding()] + param( + [bool]$VHDL93 = $false, + [bool]$VHDL2008 = $true + ) + + if ($VHDL93) + { $VHDLVersion = "v93" + $VHDLStandard = "93c" + $VHDLFlavor = "synopsys" + } + elseif ($VHDL2008) + { $VHDLVersion = "v08" + $VHDLStandard = "08" + $VHDLFlavor = "standard" + } + else + { $VHDLVersion = "v93" + $VHDLStandard = "93c" + $VHDLFlavor = "synopsys" + } + return $VHDLVersion,$VHDLStandard,$VHDLFlavor +} + +function New-DestinationDirectory +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER DestinationDirectory + Undocumented + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$DestinationDirectory + ) + + if (Test-Path $DestinationDirectory -PathType Container) + { Write-Host "Vendor directory '$DestinationDirectory' already exists." -ForegroundColor Yellow } + elseif (Test-Path $DestinationDirectory -PathType Leaf) + { Write-Host "[ERROR]: Vendor directory '$DestinationDirectory' already exists as a file." -ForegroundColor Red + Exit-CompileScript -1 + } + else + { Write-Host "Creating vendor directory: '$DestinationDirectory'." -ForegroundColor Yellow + mkdir "$DestinationDirectory" -ErrorAction SilentlyContinue | Out-Null + } +} + +function Start-PackageCompilation +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER GHDLBinary + Undocumented + .PARAMETER GHDLOptions + Undocumented + .PARAMETER Library + Undocumented + .PARAMETER SourceFiles + Undocumented + .PARAMETER HaltOnError + Undocumented + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$GHDLBinary, + [Parameter(Mandatory=$true)][string[]]$GHDLOptions, + [Parameter(Mandatory=$true)][string]$DestinationDirectory, + [Parameter(Mandatory=$true)][string]$Library, + [Parameter(Mandatory=$true)][string]$VHDLVersion, + [Parameter(Mandatory=$true)][string[]]$SourceFiles, + [Parameter(Mandatory=$true)][bool]$HaltOnError + ) + $LibraryDirectory="$DestinationDirectory/$Library/$VHDLVersion" + mkdir $LibraryDirectory -ErrorAction SilentlyContinue | Out-Null + echo $LibraryDirectory + cd $LibraryDirectory + Write-Host "Compiling library '$Library' ..." -ForegroundColor Yellow + $ErrorCount = 0 + foreach ($File in $SourceFiles) + { Write-Host "Analyzing package file '$File'" -ForegroundColor Cyan + $InvokeExpr = "$GHDLBinary " + ($GHDLOptions -join " ") + " --work=$Library " + $File + " 2>&1" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { break } + } + } + + cd $DestinationDirectory + # return $ErrorCount +} + +function Start-PrimitiveCompilation +{ <# + .SYNOPSIS + Undocumented + + .DESCRIPTION + Undocumented + + .PARAMETER GHDLBinary + Undocumented + .PARAMETER GHDLOptions + Undocumented + .PARAMETER Library + Undocumented + .PARAMETER SourceFiles + Undocumented + .PARAMETER HaltOnError + Undocumented + #> + [CmdletBinding()] + param( + [Parameter(Mandatory=$true)][string]$GHDLBinary, + [Parameter(Mandatory=$true)][string[]]$GHDLOptions, + [Parameter(Mandatory=$true)][string]$DestinationDirectory, + [Parameter(Mandatory=$true)][string]$Library, + [Parameter(Mandatory=$true)][string]$VHDLVersion, + [Parameter(Mandatory=$true)][string[]]$SourceFiles, + [Parameter(Mandatory=$true)][bool]$HaltOnError + ) + $LibraryDirectory="$DestinationDirectory/$Library/$VHDLVersion" + mkdir $LibraryDirectory -ErrorAction SilentlyContinue | Out-Null + echo $LibraryDirectory + cd $LibraryDirectory + Write-Host "Compiling library '$Library' ..." -ForegroundColor Yellow + $ErrorCount = 0 + foreach ($File in $SourceFiles) + { Write-Host "Analyzing primitive file '$File'" -ForegroundColor Cyan + $InvokeExpr = "$GHDLBinary " + ($GHDLOptions -join " ") + " --work=$Library " + $File + " 2>&1" + $ErrorRecordFound = Invoke-Expression $InvokeExpr | Restore-NativeCommandStream | Write-ColoredGHDLLine $SuppressWarnings + if ($LastExitCode -ne 0) + { $ErrorCount += 1 + if ($HaltOnError) + { break } + } + } + + cd $DestinationDirectory + # return $ErrorCount +} + + function Restore-NativeCommandStream { <# .SYNOPSIS @@ -131,5 +440,18 @@ function Write-ColoredGHDLLine { $ErrorRecordFound } } +Export-ModuleMember -Function 'Exit-CompileScript' + +Export-ModuleMember -Function 'Get-SourceDirectory' +Export-ModuleMember -Function 'Get-DestinationDirectory' +Export-ModuleMember -Function 'Get-GHDLBinary' + +Export-ModuleMember -Function 'Get-VHDLVariables' + +Export-ModuleMember -Function 'New-DestinationDirectory' +Export-ModuleMember -Function 'Start-PackageCompilation' +Export-ModuleMember -Function 'Start-PrimitiveCompilation' + + Export-ModuleMember -Function 'Restore-NativeCommandStream' Export-ModuleMember -Function 'Write-ColoredGHDLLine' diff --git a/libraries/vendors/shared.sh b/libraries/vendors/shared.sh index 586e17010..0193223e5 100644 --- a/libraries/vendors/shared.sh +++ b/libraries/vendors/shared.sh @@ -75,7 +75,7 @@ SetupDirectories() { fi if [ -z $SourceDirectory ] || [ -z $DestinationDirectory ]; then - echo 1>&2 -e "${COLORED_ERROR} $Name is not configured in '$ScriptDir/config.sh'${ANSI_NOCOLOR}" + echo 1>&2 -e "${COLORED_ERROR} $Name is not configured in '$ScriptDir/config.sh'.${ANSI_NOCOLOR}" echo 1>&2 -e " Use adv. options '--src' and '--out' or configure 'config.sh'." exit -1 elif [ ! -d $SourceDirectory ]; then @@ -130,7 +130,7 @@ CreateDestinationDirectory() { echo 1>&2 -e "${COLORED_ERROR} Vendor directory '$DestinationDirectory' already exists as a file.${ANSI_NOCOLOR}" exit -1 else - echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDirectory'${ANSI_NOCOLOR}" + echo -e "${ANSI_YELLOW}Creating vendor directory: '$DestinationDirectory'.${ANSI_NOCOLOR}" mkdir -p "$DestinationDirectory" fi } |