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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429 | ###############################################################################
# Copyright (c) 2014-2024 by Altair Engineering, Inc.
# All rights reserved.
#
# Altair Engineering, Inc. makes this software available as part of the Vision
# tool platform. As long as you are a licensee of the Vision tool platform
# you may make copies of the software and modify it to be used within the
# Vision tool platform, but you must include all of this notice on any copy.
# Redistribution without written permission to any third party, with or
# without modification, is not permitted.
# Altair Engineering, Inc. does not warrant that this software is error free
# or fit for any purpose. Altair Engineering, Inc. disclaims any liability for
# all claims, expenses, losses, damages and costs any user may incur as a
# result of using, copying or modifying the software.
# =============================================================================
# @script
# This file htmlFormat.tcl is an included file of createOverview.tcl.
# It contains all procedures for printing contents to html files.
###############################################################################
#checker -scope global exclude warnRedefine
# =============================================================================
# PrintHeader - Prints the html header components to $out.
# $title appears in the title line of the browser window.
# =============================================================================
#
proc CreateOverview:PrintHeader {out title} {
set year [clock format [clock seconds] -format "%Y"]
set copy ""
append copy "Copy" "right (c) 2014-" $year " by Altair Engineering, Inc."
puts $out "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"
puts $out "<!-- $copy -->"
puts $out "<HTML>"
puts $out "<HEAD>"
puts $out "<TITLE>$title</TITLE>"
puts $out "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">"
puts $out "</HEAD>"
puts $out "<body>"
puts $out "<a name=\"Ch0\"> </a>"
puts $out "<DIV class=contents>"
}
# =============================================================================
# PrintFooter - Prints footer data to the html page.
# If $lastAnchor != "", it prints (else nothing):
# - a link to the last anchor above (<) and to the top of page
# - the $lastAnchor
# After this it prints to $out:
# - an anchor "bop" bottom of page
# - creation date of the page
# - StarVision PRO Version
# - html footer components
# =============================================================================
#
proc CreateOverview:PrintFooter {out lastAnchor} {
if {$lastAnchor != ""} {
puts $out "<a href=\"#Ch[expr {$lastAnchor - 1}]\"> < </a>\
<a href=\"#Ch0\">top of Page</a>"
puts $out "<br><br>"
puts $out "<a name=Ch$lastAnchor> </a>"
}
puts $out "<a name=bop> </a>" ;# bottom of page
puts $out "</DIV>"
puts $out "<DIV class=footer>"
puts $out [CreateOverview:GetCreationDate]
puts $out " StarVision PRO Version: [zdb version TOOL]"
puts $out "<br><br>"
puts $out "</DIV>"
puts $out "</body>"
puts $out "</HTML>"
}
# =============================================================================
# PrintPageHeadline - Prints $title as a html H1 headline
# =============================================================================
#
proc CreateOverview:PrintPageHeadline {out title} {
puts $out "<H1>$title</H1>"
}
# -----------------------------------------------------------------------------
# _printHeadline - Prints $title as a html H2 headline
# -----------------------------------------------------------------------------
#
proc CreateOverview:_printHeadline {out title} {
puts $out "<H2>$title</H2>"
}
# =============================================================================
# PrintLine - Prints $line as a regular text line with a trailing
# paragraph tag <p>
# =============================================================================
#
proc CreateOverview:PrintLine {out line} {
puts $out "$line<p>"
}
# =============================================================================
# PrintSchematics - Prints the preview schematic GIFs which have been exported
# from the GUI with links to the full view GIFs to $out
# =============================================================================
#
proc CreateOverview:PrintSchematics {out imageList} {
CreateOverview:_printHeadline $out "Schematic images (click to enlarge):"
##
# imageList contains quadruples of values:
# fullviewImageBaseName previewImageBaseName previewWidth previewHeight
#
foreach {bn bnPre width height} $imageList {
puts $out "<a href=\"img/$bn\"><img src=\"img/$bnPre\" \
alt=\"Schematic Image\" width=\"$width\" height=\"$height\"></a>"
}
puts $out "<p>"
}
# =============================================================================
# PrintPdfLink - Prints the link to the pdf file with the schematic to $out.
# The pdf file has been exported from the GUI.
# =============================================================================
#
proc CreateOverview:PrintPdfLink {out fName} {
puts $out "<a href=\"pdf/$fName\">Show schematic as PDF file.</a>"
}
# =============================================================================
# PrintUnorderedList - prints a nested unordered list in a specific format.
#
# Parameters:
# listHeading is printed as a headline
# chapterNr is used as a html anchor (target to be jumped at)
# It is incremented and given back via upvar for use as next chapter's anchor
# Use variable name without $ (upvar command)
# listToPrint is a recursive list structure for printing an unordered list with
# unordered sublists under each list element:
# listItems subList ?listItems subList? ...
# {txt href|"" ?txt href|""? ...} {listToPrint}
# The {txt href|""} pairs allow printing of txt words with|without href links.
# Example: 3 planes deep list in _genModuleDetail (# Print all instances).
# =============================================================================
#
proc CreateOverview:PrintUnorderedList {out listHeading chNr listToPrint} {
upvar 1 $chNr chapterNr
if {[llength $listToPrint] == 0} {
return
}
##
# Print the anchor for the current chapter number
#
if {$chapterNr > 0} {
puts $out "<a name=Ch$chapterNr> </a>"
}
##
# Print the headline of the list if present
#
if {[string length $listHeading] > 0} {
CreateOverview:_printHeadline $out $listHeading
}
##
# Print clickable hyperlinks for:
# < previousChapter, topOfPage, bottomOfPage, > nextChapter
#
if {$chapterNr > 0} {
puts $out "<a href=\"#Ch[expr {$chapterNr - 1}]\"> < \
</a> <a href=\"#Ch0\">top of page</a> <a href=\"#bop\">bottom\
</a> <a href=\"#Ch[expr {$chapterNr + 1}]\"> > </a>"
}
##
# Print the unordered list.
# When called recursively, it is called with an empty listHeading and
# chapterNr=0, which skips the 3 print blocks above.
#
puts $out "<ul>"
foreach {listItem subList} $listToPrint {
if {$listItem != {}} {
puts -nonewline $out "<li>"
}
foreach {txt href} $listItem {
##
# hyperlinks are created if $href != ""
#
if {$href != ""} {
puts -nonewline $out "<a href=\"$href\">"
}
puts -nonewline $out $txt
if {$href != ""} {
puts -nonewline $out "</a>"
}
}
puts $out ""
##
# Recursive call if sublist is not empty
#
if {$subList != {}} {
set dummyChNr 0
CreateOverview:PrintUnorderedList $out "" dummyChNr $subList
}
}
puts $out "</ul>"
##
# Increment the chapterNr (not for the recursive function calls)
#
if {$chapterNr > 0} {
incr chapterNr
}
}
# =============================================================================
# PrintSourceFile - Prints the source file $fname as a html formatted file
# named targetfname
# Code is written for Verilog format.
# Other formats like Spice or VHDL may follow later.
# =============================================================================
#
proc CreateOverview:PrintSourceFile {fname targetfname} {
global CreateOverview
set db $CreateOverview(db)
set odir $CreateOverview(odir)
set fileType [$db spos filetype $fname]
##
# Open the source file for reading
#
set readV [open $fname "rb"]
##
# open the html file (that will hold the html formatted code) for writing
#
set out [open [file join $odir $targetfname] "wb"]
CreateOverview:PrintHeader $out [file tail $fname]
CreateOverview:PrintPageHeadline $out "Program code of file $fname:"
##
# Find the total number of lines
# Calculate space for the largest linenumber
#
set lastLine [$db spos lineno -no $fname end]
set digitSpace [expr {int((log10($lastLine)) + 1)}]
##
# Print a back link and the total number of lines
#
puts $out "<a href=\"../index.html#bop\">go to file list</a> <p>"
puts $out "This file contains $lastLine lines of code."
puts $out "<pre><code>"
##
# Loop through all the lines and print them
#
set lineNr 0
while {![eof $readV]} {
incr lineNr
set line [gets $readV] ;#Read one line
##
# Check if another rtl file is included
#
set includedFname ""
if {[string match "`include*" [string trimleft $line]]} {
set includedFname [string trim [lindex $line 1] \"]
}
##
# Map all < > & characters to avoid browser confusion
#
set line [string map {< < > > & & \" "} $line]
##
# Write one line, beginning with a linenumber " nn" with leading spaces
# and with an anchor L_nn as target for definition references
# Add a html link to the included rtl file as needed
#
set wrLine "<a name=\"L_$lineNr\">[format %$digitSpace\d $lineNr]</a> "
if {$includedFname == ""} {
append wrLine $line
} else {
set absPath [file dirname $fname]
set linkedSourceFile [file join $absPath $includedFname]
if {![catch {$db spos filetype $linkedSourceFile} msg]} {
##
# catch returns 0 if file exists in $db (= no error)
# $msg contains answerOfCmd or errorMsg; not used.
#
set include [CreateOverview:_getSourceFname $linkedSourceFile]
append wrLine "<a href=\"$include.html\">$line</a>"
} else {
##
# $linkedSourceFile does not exist: print line without link.
#
append wrLine $line
}
}
puts $out $wrLine
}
##
# All lines have been processed; finish the page with
# a link to the file list + footer data
# Close the open files.
#
puts $out "</code></pre>"
puts $out "<a href=\"../index.html#bop\">go to file list</a><p>"
CreateOverview:PrintFooter $out ""
close $readV
close $out
}
# =============================================================================
# PrintCssFile - Creates a .css file (cascaded style sheet) for simple uniform
# formatting of the printed html pages.
# =============================================================================
#
proc CreateOverview:PrintCssFile {fname} {
global CreateOverview
##
# open the css file (that will contain the css code) for writing:
#
set sourceName [file join $CreateOverview(odir) $fname]
set out [open $sourceName "wb"]
##
# Print the css file content
#
set toYear [clock format [clock seconds] -format %Y]
set copy ""
append copy "Copy" "right (c) 2006-" $toYear " by Altair Engineering, Inc."
puts $out "/**"
puts $out " * $copy"
puts $out " * All rights reserved."
puts $out " * ============================================================"
puts $out " * Title:"
puts $out " * Global style sheet for Altair Engineering, Inc. homepage"
puts $out " * ============================================================"
puts $out " */"
puts $out "HTML \{"
puts $out " margin: 0;"
puts $out " border: 0;"
puts $out " padding: 0;"
puts $out "\}"
puts $out "HTML * \{"
puts $out " max-height: 999999px;"
puts $out "\}"
puts $out "BODY \{"
puts $out " color: #000000;"
puts $out " font-family: Arial, Helvetica, sans-serif;"
puts $out " font-size: 100%;"
puts $out " line-height: 120%;"
puts $out " margin: 0;"
puts $out "\}"
puts $out "H1 \{"
puts $out " font-weight: bold;"
puts $out " line-height: 110%;"
puts $out " color: #d4772a;"
puts $out "\}"
puts $out "H2 \{"
puts $out " border-top: 1.6pt ridge #d4772a;"
puts $out " /* T R B L */"
puts $out " margin: 1.2em 0 0.6em 0;"
puts $out " padding: 0.4em 0 0.1em 0;"
puts $out " line-height: 110%;"
puts $out " color: #d4772a;"
puts $out "\}"
puts $out "A:link \{ "
puts $out " color: #0073A5;"
puts $out "\}"
puts $out "A:visited \{ "
puts $out " color: #6f6f7f;"
puts $out "\}"
puts $out "A\[href\]:hover \{ "
puts $out " color: #d4772a;"
puts $out "\}"
puts $out ""
puts $out "HR \{ "
puts $out " border-top: 1.6pt ridge #d4772a;"
puts $out " height: 0;"
puts $out "\}"
puts $out ""
puts $out "/* ======= Page Header Contents and Footer ======="
puts $out " */"
puts $out ".head \{"
puts $out " background-color: #ffffff;"
puts $out " /* T/B L/R */"
puts $out " padding: 0 1.5em;"
puts $out " border-bottom: 2pt solid #e8e8e8;"
puts $out "\}"
puts $out ""
puts $out ".contents \{"
puts $out " background-color: #ffffff;"
puts $out " overflow: hidden;"
puts $out " /* T/B L/R */"
puts $out " padding: 1.0em 1.5em;"
puts $out "\}"
puts $out ""
puts $out ".footer \{"
puts $out " /* T/B L/R */"
puts $out " background-color: #e8e8e8;"
puts $out " padding: 1.0em 1.5em;"
puts $out "\}"
puts $out ".footer P \{"
puts $out " /* T/B L/R */"
puts $out " margin: 0.5em 0;"
puts $out " padding: 0;"
puts $out " font-size: 85%;"
puts $out " line-height: 130%;"
puts $out "\}"
close $out
}
|