1 # ============================================================================== 2 # Authors: 3 # Patrick Lehmann 4 # 5 # ============================================================================== 6 # Copyright (C) 2017-2021 Patrick Lehmann - Boetzingen, Germany 7 # Copyright (C) 2015-2016 Patrick Lehmann - Dresden, Germany 8 # 9 # This program is free software: you can redistribute it and/or modify 10 # it under the terms of the GNU General Public License as published by 11 # the Free Software Foundation, either version 2 of the License, or 12 # (at your option) any later version. 13 # 14 # This program is distributed in the hope that it will be useful, 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 # GNU General Public License for more details. 18 # 19 # You should have received a copy of the GNU General Public License 20 # along with this program. If not, see <gnu.org/licenses>. 21 # ============================================================================== 22 23 # .SYNOPSIS 24 # Script to compile the UVVM libraries and verification models for GHDL on Windows. 25 # 26 # .DESCRIPTION 27 # This CmdLet: 28 # (1) creates a subdirectory in the current working directory 29 # (2) compiles all UVVM packages 30 # 31 [CmdletBinding()] 32 param( 33 # Show the embedded help page(s). 34 [switch]$Help = $false, 35 36 # Compile all packages. 37 [switch]$All = $false, 38 39 # Compile all UVVM packages. 40 [switch]$UVVM = $false, 41 # Compile all UVVM Utility packages. 42 [switch]$UVVM_Utilities = $false, 43 # Compile all UVVM VVC Framework packages. 44 [switch]$UVVM_VVC_Framework = $false, 45 # Compile all UVVM Verification IPs (VIPs). 46 [switch]$UVVM_VIP = $false, 47 # Compile VIP: Avalon Memory Mapped 48 [switch]$UVVM_VIP_Avalon_MM = $false, 49 # Compile VIP: Avalon Stream 50 [switch]$UVVM_VIP_Avalon_ST = $false, 51 # Compile VIP: AXI 52 [switch]$UVVM_VIP_AXI = $false, 53 # Compile VIP: AXI-Lite 54 [switch]$UVVM_VIP_AXI_Lite = $false, 55 # Compile VIP: AXI-Stream 56 [switch]$UVVM_VIP_AXI_Stream = $false, 57 # Compile VIP: Clock Generator 58 [switch]$UVVM_VIP_Clock_Generator = $false, 59 # Compile VIP: Error Injection 60 [switch]$UVVM_VIP_Error_Injection = $false, 61 # Compile VIP: Ethernet 62 [switch]$UVVM_VIP_Ethernet = $false, 63 # Compile VIP: GMII 64 [switch]$UVVM_VIP_GMII = $false, 65 # Compile VIP: GPIO 66 [switch]$UVVM_VIP_GPIO = $false, 67 # Compile VIP: HVVC to VVC Bridge 68 [switch]$UVVM_VIP_HVVC2VVC = $false, 69 # Compile VIP: I2C 70 [switch]$UVVM_VIP_I2C = $false, 71 # Compile VIP: RGMII 72 [switch]$UVVM_VIP_RGMII = $false, 73 # Compile VIP: SBI (Simple Byte Interface) 74 [switch]$UVVM_VIP_SBI = $false, 75 # Compile VIP: Scoreboard 76 [switch]$UVVM_VIP_Scoreboard = $false, 77 # Compile VIP: Specifaction Coverage 78 [switch]$UVVM_VIP_Spec_Cov = $false, 79 # Compile VIP: SPI 80 [switch]$UVVM_VIP_SPI = $false, 81 # Compile VIP: UART 82 [switch]$UVVM_VIP_UART = $false, 83 84 # Clean up directory before analyzing. 85 [switch]$Clean = $false, 86 87 #Skip warning messages. (Show errors only.) 88 [switch]$SuppressWarnings = $false, 89 # Halt on errors. 90 [switch]$HaltOnError = $false, 91 92 # Set vendor library source directory. 93 [string]$Source = "", 94 # Set output directory name. 95 [string]$Output = "", 96 # Set GHDL binary directory. 97 [string]$GHDL = "" 98 ) 99 100 # --------------------------------------------- 101 # save working directory 102 $WorkingDir = Get-Location 103 104 # set default values 105 $EnableDebug = [bool]$PSCmdlet.MyInvocation.BoundParameters["Debug"] 106 $EnableVerbose = [bool]$PSCmdlet.MyInvocation.BoundParameters["Verbose"] -or $EnableDebug 107 108 # load modules from GHDL's 'vendors' library directory 109 $EnableVerbose -and (Write-Host "Loading modules..." -ForegroundColor Gray ) | Out-Null 110 $EnableDebug -and (Write-Host " Import-Module $PSScriptRoot\config.psm1 -Verbose:`$$false -Debug:`$$false -ArgumentList `"UVVM`"" -ForegroundColor DarkGray ) | Out-Null 111 Import-Module $PSScriptRoot\config.psm1 -Verbose:$false -ArgumentList "UVVM" 112 $EnableDebug -and (Write-Host " Import-Module $PSScriptRoot\shared.psm1 -Verbose:`$$false -Debug:`$$false -ArgumentList @(`"UVVM`", `"$WorkingDir`")" -ForegroundColor DarkGray ) | Out-Null 113 Import-Module $PSScriptRoot\shared.psm1 -Verbose:$false -ArgumentList @("UVVM", "$WorkingDir") 114 115 # Display help if no command was selected 116 if ($Help -or (-not ($All -or $Clean -or 117 ($UVVM -or ($UVVM_Utilities -or $UVVM_VVC_Framework)) -or 118 ($UVVM_VIP -or ($UVVM_VIP_Avalon_MM -or $UVVM_VIP_Avalon_ST -or $UVVM_VIP_AXI -or $UVVM_VIP_AXI_Lite -or 119 $UVVM_VIP_AXI_Stream -or $UVVM_VIP_Clock_Generator -or $UVVM_VIP_Error_Injection -or 120 $UVVM_VIP_Ethernet -or $UVVM_VIP_GMII -or $UVVM_VIP_GPIO -or $UVVM_VIP_HVVC2VVC -or 121 $UVVM_VIP_I2C -or $UVVM_VIP_RGMII -or $UVVM_VIP_SBI -or $UVVM_VIP_Scoreboard -or 122 $UVVM_VIP_Spec_Cov -or $UVVM_VIP_SPI -or $UVVM_VIP_UART)) 123 ))) 124 { Get-Help $MYINVOCATION.MyCommand.Path -Detailed 125 Exit-CompileScript 126 } 127 128 if ($All) 129 { $UVVM = $true 130 $UVVM_VIP = $true 131 } 132 if ($UVVM) 133 { $UVVM_Utilities = $true 134 $UVVM_VVC_Framework = $true 135 } 136 if ($UVVM_VIP) 137 { $UVVM_VIP_Avalon_MM = $true 138 $UVVM_VIP_Avalon_ST = $true 139 $UVVM_VIP_AXI = $true 140 $UVVM_VIP_AXI_Lite = $true 141 $UVVM_VIP_AXI_Stream = $true 142 $UVVM_VIP_Clock_Generator = $true 143 $UVVM_VIP_Error_Injection = $true 144 $UVVM_VIP_Ethernet = $true 145 $UVVM_VIP_GMII = $true 146 $UVVM_VIP_GPIO = $true 147 $UVVM_VIP_HVVC2VVC = $true 148 $UVVM_VIP_I2C = $true 149 $UVVM_VIP_RGMII = $true 150 $UVVM_VIP_SBI = $true 151 $UVVM_VIP_Scoreboard = $true 152 $UVVM_VIP_Spec_Cov = $true 153 $UVVM_VIP_SPI = $true 154 $UVVM_VIP_UART = $true 155 } 156 157 158 $SourceDirectory = Get-SourceDirectory $Source "" 159 $DestinationDirectory = Get-DestinationDirectory $Output 160 $GHDLBinary = Get-GHDLBinary $GHDL 161 162 # create "uvvm" directory and change to it 163 New-DestinationDirectory $DestinationDirectory 164 cd $DestinationDirectory 165 166 167 $VHDLVersion,$VHDLStandard,$VHDLFlavor = Get-VHDLVariables 168 169 # define global GHDL Options 170 $Analyze_Parameters = @( 171 "--mb-comments", 172 "-Wbinding", 173 "-fexplicit", 174 "-Wno-shared" # UVVM specific 175 ) 176 if (-not $EnableDebug) 177 { $Analyze_Parameters += @( 178 "-Wno-hide" 179 ) 180 } 181 if (-not ($EnableVerbose -or $EnableDebug)) 182 { $Analyze_Parameters += @( 183 "-Wno-others", 184 "-Wno-static" 185 ) 186 } 187 $Analyze_Parameters += @( 188 "--ieee=$VHDLFlavor", 189 "--no-vital-checks", 190 "--std=$VHDLStandard", 191 "-frelaxed", 192 "-P$DestinationDirectory" 193 ) 194 195 196 $StopCompiling = $false 197 $ErrorCount = 0 198 199 # Cleanup directories 200 # ============================================================================== 201 if ($Clean) 202 { Write-Host "[ERROR]: '-Clean' is not implemented!" -ForegroundColor Red 203 Exit-CompileScript -1 204 205 Write-Host "Cleaning up vendor directory ..." -ForegroundColor Yellow 206 rm *.cf 207 } 208 209 Write-Host "Reading VIP compile order files..." -ForegroundColor Cyan 210 $VIP_Files = [ordered]@{} 211 foreach ($VIPName in (Get-Content "$SourceDirectory\script\component_list.txt")) 212 { if ($VIPName.StartsWith("uvvm")) 213 { $VIPVariable = $VIPName.Substring(5).ToUpper() 214 $VIPVariable = $VIPVariable.Replace("UTIL", "Utilities") 215 } 216 elseif ($VIPName.StartsWith("bitvis")) 217 { $VIPVariable = $VIPName.Substring(7).ToUpper() 218 $VIPVariable = $VIPVariable.Replace("AXILITE", "AXI_LITE") 219 $VIPVariable = $VIPVariable.Replace("AXISTREAM", "AXI_STREAM") 220 $VIPVariable = $VIPVariable.Replace("HVVC_TO_VVC_BRIDGE", "HVVC2VVC") 221 } 222 $VIPVariable = "UVVM_$VIPVariable" 223 224 $EnableVerbose -and (Write-Host " Found VIP: $VIPName" -ForegroundColor Gray ) | Out-Null 225 $EnableDebug -and (Write-Host " Reading compile order from '$SourceDirectory\$VIPName\script\compile_order.txt'" -ForegroundColor DarkGray ) | Out-Null 226 227 $VIPFiles = @() 228 $CompileOrder = Get-Content "$SourceDirectory\$VIPName\script\compile_order.txt" 229 foreach ($Line in $CompileOrder) 230 { $Line = $Line.Trim() 231 if ($Line -eq "") 232 { continue } 233 elseif ($Line.StartsWith("#")) 234 { if ($Line.StartsWith("# library ")) 235 { $VIPName = $Line.Substring(10) } 236 else 237 { Write-Host "Unknown parser instruction in compile order file." -ForegroundColor Yellow } 238 } 239 else 240 { $Path = Resolve-Path "$SourceDirectory\$VIPName\script\$Line" 241 $VIPFiles += $Path 242 } 243 } 244 245 if ($EnableDebug) 246 { Write-Host " VHDL Library name: $VIPName" -ForegroundColor DarkGray 247 foreach ($File in $VIPFiles) 248 { Write-Host " $File" -ForegroundColor DarkGray } 249 } 250 251 $VIP_Files[$VIPName] = @{ 252 "Variable" = $VIPVariable; 253 "Library" = $VIPName; 254 "Files" = $VIPFiles 255 } 256 } 257 258 259 # UVVM packages 260 # ============================================================================== 261 foreach ($vip in $VIP_Files.Keys) 262 { if ((-not $StopCompiling) -and (Get-Variable $VIP_Files[$vip]["Variable"] -ValueOnly)) 263 { $Library = $VIP_Files[$vip]["Library"] 264 $SourceFiles = $VIP_Files[$vip]["Files"] 265 266 $ErrorCount += Start-PackageCompilation $GHDLBinary $Analyze_Parameters $DestinationDirectory $Library $VHDLVersion $SourceFiles $SuppressWarnings $HaltOnError -Verbose:$EnableVerbose -Debug:$EnableDebug 267 $StopCompiling = $HaltOnError -and ($ErrorCount -ne 0) 268 } 269 } 270 271 Write-Host "--------------------------------------------------------------------------------" 272 Write-Host "Compiling UVVM packages " -NoNewline 273 if ($ErrorCount -gt 0) 274 { Write-Host "[FAILED]" -ForegroundColor Red 275 Exit-CompileScript 1 276 } 277 else 278 { Write-Host "[SUCCESSFUL]" -ForegroundColor Green 279 Exit-CompileScript 280 } 281