Skip to content

Commit f433b4a

Browse files
committed
Added support for OSVVM_SETTINGS_DIR environment variable
1 parent 643af06 commit f433b4a

File tree

1 file changed

+83
-30
lines changed

1 file changed

+83
-30
lines changed

StartUpShared.tcl

Lines changed: 83 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
#
5757

5858
namespace eval ::osvvm {
59+
60+
# --------------------------------
61+
# Set OsvvmScriptDirectory if it is not already set
62+
# --------------------------------
5963
# Usage of SCRIPT_DIR is deprecated.
6064
if {![info exists OsvvmScriptDirectory]} {
6165
# if a calling script uses SCRIPT_DIR, this supports backward compatibility
@@ -69,24 +73,37 @@ namespace eval ::osvvm {
6973

7074
variable OsvvmLibraries $::osvvm::OsvvmHomeDirectory
7175

72-
# Load Base OSVVM Project Scripts and Vendor Specific Scripts
73-
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsCreateYamlReports.tcl
74-
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsCore.tcl
75-
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsFileCreate.tcl
76+
# --------------------------------
77+
# Load OSVVM Core API
78+
# --------------------------------
79+
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsCreateYamlReports.tcl ;# Helpers for creating YAML files
80+
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsCore.tcl ;# OSVVM Core API
81+
source ${::osvvm::OsvvmScriptDirectory}/OsvvmScriptsFileCreate.tcl ;# OSVVM API for file creation
82+
83+
# --------------------------------
84+
# Vendor personalization of OSVVM API
85+
# --------------------------------
7686
namespace eval ::osvvm {
7787
source ${::osvvm::OsvvmScriptDirectory}/VendorScripts_${::osvvm::ScriptBaseName}.tcl
7888
}
7989

80-
# Load OSVVM YAML support if yaml support available
81-
# Could be made conditional for only simulators
90+
# --------------------------------
91+
# Scripts to convert OSVVM Yaml outputs to HTML and XML files
92+
# --------------------------------
8293
if {[catch {package require yaml}]} {
8394
source ${::osvvm::OsvvmScriptDirectory}/StartUpYamlMockReports.tcl
8495
} else {
8596
source ${::osvvm::OsvvmScriptDirectory}/StartUpYamlLoadReports.tcl
8697
}
8798

99+
# --------------------------------
100+
# Convert tool generated log files to HTML, ...
101+
# --------------------------------
88102
source ${::osvvm::OsvvmScriptDirectory}/Log2Osvvm.tcl
89103

104+
# --------------------------------
105+
# CoSim API additions
106+
# --------------------------------
90107
if {[file exists ${::osvvm::OsvvmScriptDirectory}/../CoSim]} {
91108
source ${::osvvm::OsvvmScriptDirectory}/../CoSim/Scripts/MakeVproc.tcl
92109
}
@@ -95,49 +112,85 @@ if {[file exists ${::osvvm::OsvvmScriptDirectory}/../CoSim]} {
95112
# Import any procedure exported by previous OSVVM scripts
96113
namespace import ::osvvm::*
97114

98-
# Load OsvvmSettings*.tcl
99115
# --------------------------------
100-
# First OsvvmSettingsDefault.tcl
101-
# Second OsvvmSettingsLocal.tcl - for user/project to update - excluded from project
102-
# Third OsvvmSettingsLocal_<vendor_or_tool>.tcl - Simulator specific defaults
103-
# Final OsvvmSettingsRequired.tcl to Finalize Settings
104-
#
105-
# First OsvvmSettingsDefault.tcl
116+
# Get Directory for User Settings
117+
# --------------------------------
118+
if {[info exists ::env(OSVVM_SETTINGS_DIR)]} {
119+
# file join supports either relative or absolute paths
120+
variable ::osvvm::OsvvmUserSettingsDirectory [file join $::osvvm::OsvvmScriptDirectory $::env(OSVVM_SETTINGS_DIR)]
121+
if {![file isdirectory $::osvvm::OsvvmUserSettingsDirectory]} {
122+
puts "ScriptError: OSVVM_SETTINGS_DIR not a directory: $::env(OSVVM_SETTINGS_DIR)"
123+
variable ::osvvm::OsvvmUserSettingsDirectory $::osvvm::OsvvmScriptDirectory
124+
}
125+
} elseif {[file isdirectory $OsvvmLibraries/../OsvvmSettings] } {
126+
variable ::osvvm::OsvvmUserSettingsDirectory [file $OsvvmLibraries/../OsvvmSettings]
127+
} else {
128+
variable ::osvvm::OsvvmUserSettingsDirectory $::osvvm::OsvvmScriptDirectory
129+
}
130+
131+
# --------------------------------
132+
# Settings: OsvvmSettings*.tcl
133+
# --------------------------------
134+
# Settings First: OSVVM Default Settings
106135
source ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsDefault.tcl
107-
# Second OsvvmSettingsLocal.tcl - for user/project to update - excluded from project
108-
if {[file exists ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsLocal.tcl]} {
136+
137+
# Settings Second: OSVVM User/Project Customizations - not required
138+
if {[file exists ${::osvvm::OsvvmUserSettingsDirectory}/OsvvmSettingsLocal.tcl]} {
139+
# Found in OSVVM_SETTINGS_DIR
140+
source ${::osvvm::OsvvmUserSettingsDirectory}/OsvvmSettingsLocal.tcl
141+
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsLocal.tcl]} {
142+
# Deprecated. Found in Scripts Directory - backward compatible
109143
source ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsLocal.tcl
110144
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalScriptDefaults.tcl]} {
111-
# Deprecated: only try to load if OsvvmSettingsLocal.tcl does not exist
145+
# Deprecated: Uses old name - backward compatible
112146
source ${::osvvm::OsvvmScriptDirectory}/LocalScriptDefaults.tcl
113147
}
114148

115-
# Third OsvvmSettingsLocal_<vendor_or_tool>.tcl - Simulator specific defaults
116-
if {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalScriptDefaults_${::osvvm::ScriptBaseName}.tcl]} {
149+
# Settings Third OSVVM User Simulator specific defaults - not required
150+
if {[file exists ${::osvvm::OsvvmUserSettingsDirectory}/OsvvmSettingsLocal_${::osvvm::ScriptBaseName}.tcl]} {
151+
# Found in OSVVM_SETTINGS_DIR
152+
source ${::osvvm::OsvvmUserSettingsDirectory}/OsvvmSettingsLocal_${::osvvm::ScriptBaseName}.tcl
153+
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsLocal_${::osvvm::ScriptBaseName}.tcl]} {
154+
# Deprecated. Found in Scripts Directory - backward compatible
155+
source ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsLocal_${::osvvm::ScriptBaseName}.tcl
156+
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalScriptDefaults_${::osvvm::ScriptBaseName}.tcl]} {
157+
# Deprecated: Uses old name - backward compatible
117158
source ${::osvvm::OsvvmScriptDirectory}/LocalScriptDefaults_${::osvvm::ScriptBaseName}.tcl
118159
}
119-
# Final OsvvmSettingsRequired.tcl to Finalize Settings
160+
161+
# Settings Final OSVVM Finalize Settings - builds names that are dependent on other names
120162
source ${::osvvm::OsvvmScriptDirectory}/OsvvmSettingsRequired.tcl
121163

122164

123-
# Set OSVVM Script Defaults - defaults may call scripts
165+
# --------------------------------
166+
# CallBacks & Error Handlers: Callback*.tcl
167+
# --------------------------------
168+
# Callbacks First: OSVVM Default CallBacks
124169
source ${::osvvm::OsvvmScriptDirectory}/CallbackDefaults.tcl
125-
# Override common actions here
126-
# While intended for call back feature, can be used to replace any
127-
# previously defined procedure
128-
if {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks.tcl]} {
170+
171+
# Callbacks Second: OSVVM User/Project Customizations - not required
172+
if {[file exists ${::osvvm::OsvvmUserSettingsDirectory}/LocalCallbacks.tcl]} {
173+
# Found in OSVVM_SETTINGS_DIR
174+
source ${::osvvm::OsvvmUserSettingsDirectory}/LocalCallbacks.tcl
175+
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks.tcl]} {
176+
# Deprecated. Found in Scripts Directory - backward compatible
129177
source ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks.tcl
130178
}
131-
# Override simulator specific actions here
132-
# While intended for call back feature, can be used to replace any
133-
# previously defined procedure - such as vendor_SetCoverageAnalyzeDefaults
134-
if {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks_${::osvvm::ScriptBaseName}.tcl]} {
179+
180+
181+
# Callback Third: OSVVM User Simulator specific defaults - not required
182+
if {[file exists ${::osvvm::OsvvmUserSettingsDirectory}/LocalCallbacks_${::osvvm::ScriptBaseName}.tcl]} {
183+
# Found in OSVVM_SETTINGS_DIR
184+
source ${::osvvm::OsvvmUserSettingsDirectory}/LocalCallbacks_${::osvvm::ScriptBaseName}.tcl
185+
} elseif {[file exists ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks_${::osvvm::ScriptBaseName}.tcl]} {
186+
# Deprecated. Found in Scripts Directory - backward compatible
135187
source ${::osvvm::OsvvmScriptDirectory}/LocalCallbacks_${::osvvm::ScriptBaseName}.tcl
136188
}
137189

138-
#
190+
191+
# --------------------------------
139192
# If the tee scripts load, mark them as available
140-
#
193+
# --------------------------------
141194
if {[catch {source ${::osvvm::OsvvmScriptDirectory}/tee.tcl}]} {
142195
variable ::osvvm::GotTee false
143196
} else {

0 commit comments

Comments
 (0)