-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathOsvvmScriptsTranslate.tcl
More file actions
222 lines (189 loc) · 7.82 KB
/
Copy pathOsvvmScriptsTranslate.tcl
File metadata and controls
222 lines (189 loc) · 7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File Name: OsvvmScriptsFileCreate.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
# Markus Ferringer Patterns for error handling and callbacks, ...
#
# Description
# Tcl procedures to Autogenerate Files
#
# 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
# 1/2025 2025.01 Initial
#
#
# This file is part of OSVVM.
#
# Copyright (c) 2025 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.
#
package require fileutil
package require huddle
package require yaml
namespace eval ::osvvm {
# Declare existance as a global, but do not initialize as it will clear it
variable AnalyzeDict
variable AnalyzeOrderList
variable SimulateDict
# -------------------------------------------------
# CreateDryRunDict
#
proc CreateDryRunDict {ProFileToBuild} {
# CreateDryRunDict runs a build script in DryRunMode and
# creates dictionaries and lists of Analyze and Simulate information.
# The Analyze dictionary, ::osvvm::AnalyzeDict, has a dictionary
# for each library used. For each library there is an list of
# dictionaries that contain the file analyzed as well as language version used.
# The list, ::osvvm::AnalyzeOrderList, has a list of dictionaries
# that contain the file name, library, and vhdl version.
# The Simulation dictionary, ::osvvm::SimulateDict, has a dictionary
# for each library used. For each library there is an list of
# dictionaries that contain information passed to simulate.
#
# ProFileToBuild - Path to the pro file that build the entire design.
# WhereToCreate - Directory into which to create vhdl_ls.toml. Default = .
#
variable GenerateOsvvmReports
set SavedGenerateOsvvmReports $GenerateOsvvmReports
set GenerateOsvvmReports "false" ;# turn off reports
# initialize dictionaries to empty
variable AnalyzeDict [dict create] ;# empty dictionary
variable AnalyzeOrderList "" ;# empty list
variable SimulateDict [dict create] ;# empty dictionary
# Create AnalyzeDict and SimulateDict as a recording of
source $::OsvvmLibraries/Scripts/VendorScripts_DryRunDict.tcl
build $ProFileToBuild [BuildName CreateDryRunDict]
# if {$ScriptToRun ne ""} { $ScriptToRun }
# restore settings and tool API actions
# StartUp ;# replace source below with StartUp if features beyond VendorScripts_xxx.tcl are changed
source $::OsvvmLibraries/Scripts/VendorScripts_${::osvvm::ScriptBaseName}.tcl
set GenerateOsvvmReports $SavedGenerateOsvvmReports ;# restore reports
}
# -------------------------------------------------
# CreateVhdlLsToml for VHDL LS
#
proc CreateVhdlLsToml {ProFileToBuild {FileNameAndPath "./vhdl_ls.toml"}} {
# CreateVhdlLsToml runs a build script in DryRunMode and
# creates a vhdl_ls.toml file.
#
# ProFileToBuild - Path to the pro file that build the entire design.
# FileNameAndPath - Name of file to create. Default: ./vhdl_ls.toml
#
variable AnalyzeDict
# Create AnalyzeDict for the ProFileToBuild script
CreateDryRunDict $ProFileToBuild
set TomlFile [open [file normalize $FileNameAndPath] w]
puts $TomlFile "# Generated by OSVVM's CreateVhdlLsToml"
puts $TomlFile "\[libraries\]"
foreach key [dict keys $AnalyzeDict] {
# Print library name
set FileList [dict get $AnalyzeDict $key]
puts $TomlFile "${key}.files = \["
foreach FileDict $FileList {
puts $TomlFile " '[dict get $FileDict FileName]',"
}
puts $TomlFile "\]"
# mark things from OSVVM libraries as thrid party
}
close $TomlFile
}
proc CreateAnalyzeOrderCsv {ProFileToBuild {FileNameAndPath "./AnalyzeOrder.csv"}} {
# CreateAnalyzeOrderCsv runs a build script in DryRunMode and
# creates a AnalyzeOrder.csv file.
#
# ProFileToBuild - Path to the pro file that build the entire design.
# FileNameAndPath - Name of file to create. Default: ./AnalyzeOrder.csv
#
variable AnalyzeOrderList
# Create AnalyzeDict for the ProFileToBuild script
CreateDryRunDict $ProFileToBuild
set CsvFile [open [file normalize $FileNameAndPath] w]
# puts $CsvFile "# Generated by OSVVM's CreateAnalyzeOrderCsv"
foreach FileDict $::osvvm::AnalyzeOrderList {
if {[info exists PrintString]} {puts $CsvFile "${PrintString},"}
set PrintString [dict get $FileDict FileName]
# puts $CsvFile "[dict get $FileDict FileName],"
}
puts $CsvFile "${PrintString}"
close $CsvFile
}
proc ProToYaml {ProFileToBuild {FilePath "."}} {
# ProToYaml runs a build script in DryRunMode and
# creates a Analyze.yaml and Simulate.yaml file.
#
# ProFileToBuild - Path to the pro file that build the entire design.
# FilePath - Path to Analyze.yaml and Simulate.yaml
#
# Create AnalyzeDict and SimulateDict for the ProFileToBuild script
variable AnalyzeDict
variable SimulateDict
CreateDryRunDict $ProFileToBuild
set ProFileName [file rootname [file tail $ProFileToBuild]]
# Convert Analyze Dict to Yaml via Huddle
# {library [file {name language_ver}]}
set AnalyzeHud [huddle compile {dict * {list {dict}}} $::osvvm::AnalyzeDict]
set AnalyzeYamlFile [open [file join $FilePath "${ProFileName}_Analyze.yml"] w]
puts $AnalyzeYamlFile [yaml::huddle2yaml $AnalyzeHud]
close $AnalyzeYamlFile
# Convert Simulate Dict to Yaml via Huddle
# {library [file {name language_ver}]}
set SimulateHud [huddle compile {dict * {list {dict}}} $::osvvm::SimulateDict]
set SimulateYamlFile [open [file join $FilePath "${ProFileName}_Simulate.yml"] w]
puts $SimulateYamlFile [yaml::huddle2yaml $SimulateHud]
close $SimulateYamlFile
}
proc ProToJson {ProFileToBuild {FilePath "."}} {
# ProToJson runs a build script in DryRunMode and
# creates a Analyze.json and Simulate.json file.
#
# ProFileToBuild - Path to the pro file that build the entire design.
# FilePath - Path to Analyze.json and Simulate.json
#
# Create AnalyzeDict and SimulateDict for the ProFileToBuild script
variable AnalyzeDict
variable SimulateDict
CreateDryRunDict $ProFileToBuild
set ProFileName [file rootname [file tail $ProFileToBuild]]
# Convert Analyze Dict to Yaml via Huddle
# {library [file {name language_ver}]}
set AnalyzeHud [huddle compile {dict * {list {dict}}} $::osvvm::AnalyzeDict]
set AnalyzeJsonFile [open [file join $FilePath "${ProFileName}_Analyze.json"] w]
puts $AnalyzeJsonFile [huddle jsondump $AnalyzeHud]
close $AnalyzeJsonFile
# Convert Simulate Dict to Yaml via Huddle
# {library [file {name language_ver}]}
set SimulateHud [huddle compile {dict * {list {dict}}} $::osvvm::SimulateDict]
set SimulateJsonFile [open [file join $FilePath "${ProFileName}_Simulate.json"] w]
puts $SimulateJsonFile [huddle jsondump $SimulateHud]
close $SimulateJsonFile
}
# Don't export the following due to conflicts with Tcl built-ins
# map
namespace export CreateDryRunDict
namespace export CreateVhdlLsToml
namespace export CreateAnalyzeOrderCsv
namespace export ProToYaml
namespace export ProToJson
# end namespace ::osvvm
}