Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 61 additions & 33 deletions StartUp.tcl
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
# File Name: StartUp.tcl
# Purpose: Scripts for running simulations
# Revision: OSVVM MODELS STANDARD VERSION
#
# Maintainer: Jim Lewis email: jim@synthworks.com
# Contributor(s):
# Jim Lewis email: jim@synthworks.com
#
#
# Maintainer: Jim Lewis email: jim@synthworks.com
# Contributor(s):
# Jim Lewis email: jim@synthworks.com
#
# Description
# Tcl procedures to configure and adapt the OSVVM simulator
# Tcl procedures to configure and adapt the OSVVM simulator
# scripting methodology for a particular project.
# As part of its tasks, it runs OSVVM scripts that define
# procedures use in the OSVVM scripting methodology.
#
# Developed by:
# SynthWorks Design Inc.
#
# Developed by:
# SynthWorks Design Inc.
# VHDL Training Classes
# OSVVM Methodology and Model Library
# 11898 SW 128th Ave. Tigard, Or 97223
# http://www.SynthWorks.com
#
#
# Revision History:
# Date Version Description
# 07/2024 2024.07 Added detection for Siemen's Visualizer
# 05/2022 2022.05 Refactored StartUp.tcl to move items
# 02/2026 2026.01 Added VHDL Language Support .toml file generation for VS Code
# 07/2024 2024.07 Added detection for Siemen's Visualizer
# 05/2022 2022.05 Refactored StartUp.tcl to move items
# shared by all StartUp scripts to StartUpShared.tcl
# 01/2022 2022.01 New StartUp algorithm for detecting ActiveHDL's VSimSA.
# 10/2021 2021.10 Loads YAML utilities when YAML library available: OsvvmYamlSupport.tcl, NoYamlPackage.tcl
# Loads LocalScriptDefaults.tcl if it is in the OsvvmScriptDirectory. This is a optional user settings file.
# LocalScriptsDefaults.tcl is not provided by OSVVM so your local settings will not be overwritten.
# 2/2021 2021.02 Refactored.
# - Tool now determined in here (was in ToolConfiguration.tcl).
# LocalScriptsDefaults.tcl is not provided by OSVVM so your local settings will not be overwritten.
# 2/2021 2021.02 Refactored.
# - Tool now determined in here (was in ToolConfiguration.tcl).
# - Simplifies ActiveHDL startup
# - Initial tool settings now in VendorScripts_*.tcl (was in ToolConfiguration.tcl)
# - Added: Default settings now in OsvvmScriptDefaults.tcl (was here)
# - Removed: ToolConfiguration.tcl (now in StartUp.tcl and VendorScripts_*.tcl)
# - Initial tool settings now in VendorScripts_*.tcl (was in ToolConfiguration.tcl)
# - Added: Default settings now in OsvvmScriptDefaults.tcl (was here)
# - Removed: ToolConfiguration.tcl (now in StartUp.tcl and VendorScripts_*.tcl)
# 7/2020 2020.07 Refactored tool execution for simpler vendor customization
# 2/2020 2020.02 Moved tool determination to outer layer
# 1/2020 2020.01 Updated Licenses to Apache
# 2/2019 Beta Project descriptors in .pro which execute
# 2/2019 Beta Project descriptors in .pro which execute
# 11/2018 Alpha Project descriptors in .files and .dirs files
# as TCL scripts in conjunction with the library
# as TCL scripts in conjunction with the library
# procedures
#
#
# This file is part of OSVVM.
#
# Copyright (c) 2018 - 2022 by SynthWorks Design Inc.
#
#
# Copyright (c) 2018 - 2022 by SynthWorks Design Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# https://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -65,8 +66,8 @@ namespace eval ::osvvm {
# Default OsvvmScriptDirectory setup - revised for ActiveHDL VSimSA
variable OsvvmScriptDirectory [file dirname [file normalize [info script]]]
variable OsvvmInitialized "false"
#

#
# Determine simulator from name of executable and settings
# Primarily this only applies to simulators that run from a GUI
#
Expand All @@ -75,22 +76,22 @@ namespace eval ::osvvm {

if {[info exists ::env(OSVVM_TOOL)]} {
variable ScriptBaseName $::env(OSVVM_TOOL)

} elseif {[info exists aldec]} {
variable ToolFamily [lindex [split [vsim -version]] 2]
if {$ToolFamily eq "Riviera-PRO"} {
if {$ToolFamily eq "Riviera-PRO"} {
variable ScriptBaseName "RivieraPro"

} elseif {[string match -nocase $ToolExecutableName "vsimsa"]} {
if {![info exists ScriptBaseName]} {
set OsvvmScriptDirectory [file dirname [string trim $argv0 ?{}?]]
}
}
variable ScriptBaseName "VSimSA"

} else {
variable ScriptBaseName "ActiveHDL"
}

} elseif {$ToolExecutableName eq "vish" || $ToolExecutableName eq "vsimk"} {
variable ScriptBaseName "Siemens"

Expand All @@ -111,11 +112,11 @@ namespace eval ::osvvm {
# variable ScriptBaseName $::env(OSVVM_TOOL)
# }
# }

} elseif {$ToolExecutableName eq "hdlclient"} {
# variable ScriptBaseName "Visualizer"
variable ScriptBaseName "Questa"

} elseif {[string match -nocase $ToolExecutableName "vivado"]} {
variable ScriptBaseName "Vivado"

Expand All @@ -133,3 +134,30 @@ source ${::osvvm::OsvvmScriptDirectory}/StartUpShared.tcl
set ::osvvm::OsvvmInitialized "true"

puts -nonewline "" ; # suppress printing of true from above line

# -----------------------------------------------------------------------------
# Public command: Generate .vhdl_ls.toml from an OSVVM build
# Usage:
# GenerateVhdlLsToml $OsvvmLibraries
# -----------------------------------------------------------------------------
proc GenerateVhdlLsToml {FileToBuild} {
source $::OsvvmLibraries/Scripts/VendorScripts_GenerateVhdlLsToml.tcl

variable ::osvvm::firstTimeTomlOpened
variable ::osvvm::tomlFilePath

# Reset state
set firstTimeTomlOpened 0

# Remove previous file if it exists
if {[file exists $tomlFilePath]} {
file delete -force $tomlFilePath
}

# Trigger OSVVM library analysis (this calls vendor_analyze_vhdl)
build $FileToBuild

puts "Generated $tomlFilePath for VHDL LS"

StartUp
}
141 changes: 141 additions & 0 deletions VendorScripts_GenerateVhdlLsToml.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# File Name: VendorScripts_GenerateVhdlLsToml.tcl
# Purpose: Script for adding language support in VS Code via VHDL LS
# Revision: OSVVM MODELS STANDARD VERSION
#
# Maintainer: Jim Lewis email: jim@synthworks.com
# Contributor(s):
# Jim Lewis email: jim@synthworks.com
#
# Description:
# Tcl procedures for autonomous integration of new VHDL libraries
# in VS Code using the VHDL LS extension, following OSVVM methodology.
#
# Developed by:
# SynthWorks Design Inc.
# VHDL Training Classes
# OSVVM Methodology and Model Library
# 11898 SW 128th Ave. Tigard, Or 97223
# http://www.SynthWorks.com
#
# Revision History:
# Date Version Description
# 02/2026 2026.01 Script created.
#
#
# This file is part of OSVVM.
#
# Copyright (c) 2018 - 2026 by SynthWorks Design Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

namespace eval ::osvvm {
# -------------------------------------------------------------------------
# Namespace Variables
# -------------------------------------------------------------------------
variable firstTimeTomlOpened 0
variable tomlFilePath [file join [pwd] ".vhdl_ls.toml"]

# -------------------------------------------------------------------------
# Helper Procedure: Remove Last Bracket in .toml file
# -------------------------------------------------------------------------
proc toml_rmLastBracket {filePath} {
if {![file exists $filePath]} {
return 0
}

set file [open $filePath r]
set lines [split [read $file] "\n"]
close $file

# Remove last two lines (closing bracket)
set lines [lrange $lines 0 end-2]
set file [open $filePath w]
puts $file [join $lines "\n"]

close $file
}
# -------------------------------------------------------------------------
# Helper Procedure: Check if current library is same as last library in .toml
# -------------------------------------------------------------------------
proc toml_isCurrentLibrary {libraryName} {
variable tomlFilePath

if {![file exists $tomlFilePath]} {
return 0
}

set currentLibrary ""
set file [open $tomlFilePath r]

while {[gets $file line] >= 0} {
if {[regexp {\[libraries\.([a-zA-Z0-9_]+)\]} $line -> lib]} {
set currentLibrary $lib
}
}

close $file

return [expr {[string compare $currentLibrary $libraryName] == 0}]
}
# -------------------------------------------------------------------------
# Main Procedure: Generate VHDL LS .toml entry for a library
# -------------------------------------------------------------------------
proc vendor_analyze_vhdl {LibraryName FileName args} {
variable firstTimeTomlOpened
variable tomlFilePath

set normalizedFile [file normalize $FileName]
set formattedFilePath [format "\t'%s'," $normalizedFile]

if {$firstTimeTomlOpened == 0} {
# First time creating the file
set file [open $tomlFilePath w]

puts $file "\[libraries.$LibraryName\]"
puts $file "files = \["
puts $file $formattedFilePath
puts $file "\]"

close $file

set firstTimeTomlOpened 1
} else {
set isSameLibrary [toml_isCurrentLibrary $LibraryName]

# Remove closing bracket to append new files
toml_rmLastBracket $tomlFilePath
set file [open $tomlFilePath a]

if {!$isSameLibrary} {
# Start new library section
puts $file "\]"
puts $file "\[libraries.$LibraryName\]"
puts $file "files = \["
}

# Add file entry
puts $file $formattedFilePath
puts $file "\]"
close $file
}
}
# -------------------------------------------------------------------------
# Placeholder for Verilog (Not needed yet)
# -------------------------------------------------------------------------
proc vendor_analyze_verilog {libraryName fileName args} {
# No implementation required
}
# end namespace ::osvvm
}
# =============================================================================