|
20 | 20 | # |
21 | 21 | # Revision History: |
22 | 22 | # Date Version Description |
23 | | -# 7/2024 2024.07 Updated LocalInclude to better restore state if it fails |
| 23 | +# 1/2025 2025.01 Added GetTimeString |
| 24 | +# 7/2024 2024.07 Updated LocalInclude to better restore state if the include fails |
24 | 25 | # Fixed settings in SetLogSignals. |
25 | 26 | # 5/2024 2024.05 Updated for refactor of Simulate2Html. Renamed in prep for breaking file into smaller chunks. |
26 | 27 | # 3/2024 2024.03 Updated CreateOsvvmScriptSettingsPkg and added FindOsvvmSettingsDirectory |
@@ -2011,7 +2012,7 @@ proc SimulateDoneMoveTestCaseFiles {} { |
2011 | 2012 | # file rename -force ${TranscriptFile} ${TranscriptDestFile} |
2012 | 2013 | file copy -force ${TranscriptFile} ${TranscriptDestFile} |
2013 | 2014 | if {[catch {file delete -force ${TranscriptFile}} err]} { |
2014 | | - puts "ScriptError: Cannot delete ${TranscriptFile}. Simulation crashed and did not close it. SimulationInteractive is $::osvvm::SimulateInteractive so cannot EndSimulation" |
| 2015 | + puts "ScriptWarning: Simulation did not close ${TranscriptFile}. Will EndSimulation to close it if SimulationInteractive is false. SimulationInteractive = $::osvvm::SimulateInteractive" |
2015 | 2016 | # end simulation to try to free locks on the file, and try to delete again - in the event the test case forgot TranscriptClose |
2016 | 2017 | if {!$::osvvm::SimulateInteractive} { |
2017 | 2018 | EndSimulation |
@@ -2111,110 +2112,17 @@ proc TimeIt {args} { |
2111 | 2112 | puts "Time: [ElapsedTimeMs $StartTimeMs]" |
2112 | 2113 | } |
2113 | 2114 |
|
2114 | | -# ------------------------------------------------- |
2115 | | -# CreateOsvvmScriptSettingsPkg |
2116 | | -# do an operation on a list of items |
2117 | | -# |
2118 | | -proc FindOsvvmSettingsDirectory {} { |
2119 | | - if {$::osvvm::SettingsAreRelativeToSimulationDirectory} { |
2120 | | - set SettingsDirectory [file join ${::osvvm::CurrentSimulationDirectory} ${::osvvm::OsvvmSettingsSubDirectory}] |
2121 | | - } else { |
2122 | | - set SettingsDirectory [file join ${::osvvm::OsvvmHomeDirectory} "osvvm" ${::osvvm::OsvvmSettingsSubDirectory}] |
2123 | | - } |
2124 | | - CreateDirectory $SettingsDirectory |
2125 | | -# set RelativeSettingsDirectory [::fileutil::relative [pwd] $SettingsDirectory] |
2126 | | -# return $RelativeSettingsDirectory |
2127 | | - # Needs to be a normalized path |
2128 | | - return $SettingsDirectory |
2129 | | -} |
2130 | | - |
2131 | | -proc CreateOsvvmScriptSettingsPkg {SettingsDirectory} { |
2132 | | - set OsvvmScriptSettingsPkgFile [file join ${SettingsDirectory} "OsvvmScriptSettingsPkg_generated.vhd"] |
2133 | | - set NewFileName [file join ${SettingsDirectory} "OsvvmScriptSettingsPkg_new.vhd"] |
2134 | | - |
2135 | | - set WriteCode [catch {set FileHandle [open $NewFileName w]} WriteErrMsg] |
2136 | | - if {$WriteCode} { |
2137 | | - puts "Not able to open OsvvmScriptSettingsPkg_generated.vhd. Using defaults instead" |
2138 | | - return "" |
2139 | | - } |
2140 | | - puts $FileHandle "-- This file is autogenerated by CreateOsvvmScriptSettingsPkg" |
2141 | | - puts $FileHandle "package body OsvvmScriptSettingsPkg is" |
2142 | | - puts $FileHandle " constant OSVVM_HOME_DIRECTORY : string := \"[file normalize ${::osvvm::OsvvmHomeDirectory}]\" ;" |
2143 | | - if {${::osvvm::OsvvmTemporaryOutputDirectory} eq ""} { |
2144 | | - puts $FileHandle " constant OSVVM_RAW_OUTPUT_DIRECTORY : string := \"\" ;" |
2145 | | - } else { |
2146 | | - puts $FileHandle " constant OSVVM_RAW_OUTPUT_DIRECTORY : string := \"${::osvvm::OsvvmTemporaryOutputDirectory}/\" ;" |
2147 | | - } |
2148 | | - if {${::osvvm::OutputBaseDirectory} eq ""} { |
2149 | | - puts $FileHandle " constant OSVVM_BASE_OUTPUT_DIRECTORY : string := \"\" ;" |
2150 | | - } else { |
2151 | | - puts $FileHandle " constant OSVVM_BASE_OUTPUT_DIRECTORY : string := \"${::osvvm::OutputBaseDirectory}/\" ;" |
2152 | | - } |
2153 | | - puts $FileHandle " constant OSVVM_BUILD_YAML_FILE : string := \"${::osvvm::OsvvmBuildYamlFile}\" ;" |
2154 | | - puts $FileHandle " constant OSVVM_TRANSCRIPT_YAML_FILE : string := \"${::osvvm::TranscriptYamlFile}\" ;" |
2155 | | - puts $FileHandle " constant OSVVM_REVISION : string := \"${::osvvm::OsvvmVersion}\" ;" |
2156 | | - puts $FileHandle " constant OSVVM_SETTINGS_REVISION : string := \"${::osvvm::OsvvmVersionCompatibility}\" ;" |
2157 | | - puts $FileHandle "end package body OsvvmScriptSettingsPkg ;" |
2158 | | - close $FileHandle |
2159 | | - if {[FileDiff $OsvvmScriptSettingsPkgFile $NewFileName]} { |
2160 | | - file rename -force $NewFileName $OsvvmScriptSettingsPkgFile |
2161 | | - } else { |
2162 | | - file delete -force $NewFileName |
2163 | | - } |
2164 | | - return $OsvvmScriptSettingsPkgFile |
2165 | | -} |
2166 | | - |
2167 | | -# AutoGenerateFile |
2168 | | -# Extract from FileName everything up to and including the pattern in the string |
2169 | | -# Write Extracted contents to NewFileName |
2170 | | -# Example call: set ErrorCode [catch {AutoGenerateFile $FileName $NewFileName "--!! Autogenerated:"} errmsg] |
2171 | | -proc AutoGenerateFile {FileName NewFileName AutoGenerateMarker} { |
2172 | | - set ReadCode [catch {set ReadFile [open $FileName r]} ReadErrMsg] |
2173 | | - if {$ReadCode} { return } |
2174 | | - set LinesOfFile [split [read $ReadFile] \n] |
2175 | | - close $ReadFile |
2176 | | - |
2177 | | - set WriteCode [catch {set WriteFile [open $NewFileName w]} WriteErrMsg] |
2178 | | - if {$WriteCode} { return } |
2179 | | - foreach OneLine $LinesOfFile { |
2180 | | - puts $WriteFile $OneLine |
2181 | | - if { [regexp ${AutoGenerateMarker} $OneLine] } { |
2182 | | - break |
2183 | | - } |
2184 | | - } |
2185 | | - close $WriteFile |
2186 | | -} |
2187 | | - |
2188 | 2115 | proc SetArgv {} { |
2189 | 2116 | set ::argv0 0 |
2190 | 2117 | set ::argv 0 |
2191 | 2118 | set ::argc 0 |
2192 | 2119 | } |
2193 | 2120 |
|
2194 | | - |
2195 | | -proc FileDiff {File1 File2} { |
2196 | | - set ReadFile1Code [catch {set FileHandle1 [open $File1 r]} ReadErrMsg] |
2197 | | - if {$ReadFile1Code} {return "true"} |
2198 | | - set LinesOfFile1 [split [read $FileHandle1] \n] |
2199 | | - close $FileHandle1 |
2200 | | - set LengthOfFile1 [llength $$LinesOfFile1] |
2201 | | - |
2202 | | - set ReadFile2Code [catch {set FileHandle2 [open $File2 r]} ReadErrMsg] |
2203 | | - if {$ReadFile2Code} {return "true"} |
2204 | | - set LinesOfFile2 [split [read $FileHandle2] \n] |
2205 | | - close $FileHandle2 |
2206 | | - set LengthOfFile2 [llength $$LinesOfFile2] |
2207 | | - |
2208 | | - if {$LengthOfFile1 != $LengthOfFile2} {return "true"} |
2209 | | - |
2210 | | - for {set i 0} {$i < $LengthOfFile1} {incr i} { |
2211 | | - if {[lindex $LinesOfFile1 $i] ne [lindex $LinesOfFile2 $i]} {return "true"} |
2212 | | - } |
2213 | | - return "false" |
| 2121 | +proc GetTimeString {} { |
| 2122 | + return [GetIsoTime [clock seconds]] |
2214 | 2123 | } |
2215 | 2124 |
|
2216 | 2125 |
|
2217 | | - |
2218 | 2126 | # Don't export the following due to conflicts with Tcl built-ins |
2219 | 2127 | # map |
2220 | 2128 |
|
@@ -2246,9 +2154,9 @@ namespace export MergeCoverage |
2246 | 2154 | namespace export OsvvmLibraryPath |
2247 | 2155 | namespace export JoinWorkingDirectory ChangeWorkingDirectory |
2248 | 2156 | namespace export EndSimulation |
2249 | | -namespace export CreateOsvvmScriptSettingsPkg FindOsvvmSettingsDirectory |
2250 | 2157 | namespace export FindLibraryPathByName CoSim |
2251 | 2158 | namespace export OpenBuildHtml |
| 2159 | +namespace export GetTimeString |
2252 | 2160 |
|
2253 | 2161 | # Exported only for tesing purposes |
2254 | 2162 | namespace export FindLibraryPath CreateLibraryPath FindExistingLibraryPath TimeIt FindIncludeFile UnsetLibraryVars |
|
0 commit comments