| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- # Activate the local Prod2U P4 verification toolchain for this PowerShell session.
- # This script does not modify the system PATH, registry, user profile, or repository.
- [CmdletBinding()]
- param(
- [string]$ToolchainRoot
- )
- $ToolchainBase = Join-Path $HOME "CodexToolchains\CPLD"
- if ([string]::IsNullOrWhiteSpace($ToolchainRoot)) {
- $ToolchainRoot = Join-Path $ToolchainBase "oss-cad-suite\latest"
- } else {
- $ToolchainRoot = [System.IO.Path]::GetFullPath($ToolchainRoot)
- }
- $CocotbPython = Join-Path $ToolchainBase "venvs\prod2u-p4-actuator-trace-cocotb-venv\Scripts\python.exe"
- $ToolchainBin = Join-Path $ToolchainRoot "bin"
- $ToolchainLib = Join-Path $ToolchainRoot "lib"
- $VerilatorRoot = Join-Path $ToolchainRoot "share\verilator"
- $ToolchainShimDir = Join-Path $PSScriptRoot "toolchain_shims"
- $VerilatorShim = Join-Path $ToolchainShimDir "verilator.ps1"
- $VerilatorNative = @(
- (Join-Path $ToolchainBin "verilator_bin.exe")
- (Join-Path $ToolchainBin "verilator.exe")
- ) | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } | Select-Object -First 1
- $Smtbmc = Join-Path $ToolchainRoot "bin\yosys-smtbmc.exe.exe"
- if (-not (Test-Path -LiteralPath $ToolchainBin -PathType Container)) {
- throw "Verification toolchain bin directory is missing: $ToolchainBin"
- }
- if (-not $VerilatorNative) {
- throw "Verification toolchain does not contain a native Verilator executable; refusing to expose the extensionless wrapper: $ToolchainBin"
- }
- if (-not (Test-Path -LiteralPath $VerilatorShim -PathType Leaf)) {
- throw "Verification toolchain shim is missing: $VerilatorShim"
- }
- $env:PROD2U_P4_TOOLCHAIN_ROOT = $ToolchainRoot
- $env:OSS_CAD_SUITE_ROOT = $ToolchainRoot
- $env:PROD2U_P4_COCOTB_PYTHON = $CocotbPython
- if (Test-Path -LiteralPath $VerilatorRoot) {
- $env:VERILATOR_ROOT = $VerilatorRoot
- }
- # The suite's extensionless Perl wrapper opens Windows' app chooser.
- $env:VERILATOR = $VerilatorNative
- Set-Alias -Name verilator -Value $VerilatorNative -Scope Global -Force
- if (Test-Path -LiteralPath $Smtbmc) {
- $env:SMTBMC = $Smtbmc
- }
- if (Test-Path -LiteralPath $ToolchainBin) {
- $pathParts = $env:PATH -split ";"
- if ($pathParts -notcontains $ToolchainBin) {
- $env:PATH = "$ToolchainBin;$env:PATH"
- }
- }
- if (Test-Path -LiteralPath $ToolchainLib) {
- $pathParts = $env:PATH -split ";"
- if ($pathParts -notcontains $ToolchainLib) {
- $env:PATH = "$ToolchainLib;$env:PATH"
- }
- }
- $pathParts = @($env:PATH -split ";" | Where-Object { $_ -and $_ -ne $ToolchainShimDir })
- $env:PATH = (@($ToolchainShimDir) + $pathParts) -join ";"
- Write-Host "Prod2U P4 verification toolchain variables set for current PowerShell session."
- Write-Host "PROD2U_P4_TOOLCHAIN_ROOT=$env:PROD2U_P4_TOOLCHAIN_ROOT"
- Write-Host "PROD2U_P4_COCOTB_PYTHON=$env:PROD2U_P4_COCOTB_PYTHON"
- Write-Host "VERILATOR=$env:VERILATOR"
|