2
// Copyright (C) 2008-2014 Centaur Technology
5
// Centaur Technology Formal Verification Group
6
// 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
7
// http://www.centtech.com/
9
// License: (An MIT/X11-style license)
11
// Permission is hereby granted, free of charge, to any person obtaining a
12
// copy of this software and associated documentation files (the "Software"),
13
// to deal in the Software without restriction, including without limitation
14
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
// and/or sell copies of the Software, and to permit persons to whom the
16
// Software is furnished to do so, subject to the following conditions:
18
// The above copyright notice and this permission notice shall be included in
19
// all copies or substantial portions of the Software.
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
// DEALINGS IN THE SOFTWARE.
29
// Original author: Jared Davis <jared@centtech.com>
31
$(document).ready(function() { connect(onConnected); });
33
var ORIGNAME = getParameterByName("origname"); // Originally case-insensitive. Gets corrected by onConnected.
36
window.alert("No origname to display?")
40
function onConnected()
44
log("Toolbar initialized.");
46
vlsGetJson({ url: "/vls-get-summary",
47
data: {origname:ORIGNAME},
48
success: function(summary)
50
log("Got summaries.");
51
if (summary == "NIL") {
52
$("#sourcecode").html(ORIGNAME + " not found.");
56
ORIGNAME = SUMMARY[":NAME"];
61
function loadEverythingElse()
63
log("Loading everything else.");
64
$("#banner").html(ORIGNAME);
67
var type = SUMMARY[":TYPE"];
68
var file = SUMMARY[":FILE"];
69
var line = SUMMARY[":LINE"];
70
var col = SUMMARY[":COL"];
71
desc += "<i>" + niceDescriptionType(type) + "</i><br/>";
73
desc += "<a href=\"javascript:void(0)\" onclick=\"showLoc('" + file + "', " + line + ", " + col + ")\">";
74
desc += file + ":" + line + ":" + col;
76
$("#desctype").html(desc);
78
log("Type is " + type);
80
// Add the port table/IOs button only for modules
81
if (type == ":VL-MODULE")
84
btn += "<a href='javascript:void(0)' onclick='makePortTable();'>";
85
btn += "<img class='toolbutton' src='images/io.png' data-powertip='<p>Printable block diagram.</p>'/>";
87
$("#disptools").append(btn);
90
// Add raw source display button only if this is a container-type thing with a start/end location.
91
if (type == ":VL-MODULE" ||
92
type == ":VL-PACKAGE" ||
93
type == ":VL-CONFIG" ||
94
type == ":VL-INTERFACE" ||
95
type == ":VL-TYPEDEF" ||
96
type == ":VL-PROGRAM")
99
btn += "<a href='javascript:void(0)' onclick='toggleMarkup();'>";
100
btn += "<img class='toolbutton' src='images/markup.png' data-powertip='<p>Switch to parsed/raw display.</p>'/>";
102
$("#disptools").append(btn);
105
installParsedSource();
111
function makeModuleList(id, names)
113
log("makeModuleList(" + id + ") with " + names.length + " names");
117
if (names.length <= max)
119
// Short enough list that there is no need to elide it.
120
for(var i = 0; i < names.length; ++i) {
122
ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a>";
123
if (i == names.length - 2) {
126
else if (i != names.length - 1) {
133
// Otherwise we have a long list, let's elide it and make it expandable.
134
for(var i = 0; i < max; ++i) {
136
ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a> ";
137
if (i != names.length - 1) {
142
ret += "<span id='elide_" + id + "'>";
144
ret += "<a class=\"expandelided\" href=\"javascript:void(0)\" onclick=\"expandElidedModuleList('" + id + "')\">";
145
ret += (names.length - max);
150
ret += "<span id='show_" + id + "' style='display:none;'>";
151
for(var i = max; i < names.length; ++i) {
153
ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a>";
154
if (i == names.length - 2) {
157
else if (i != names.length - 1) {
166
function expandElidedModuleList(id) {
167
$("#elide_" + id).hide();
168
$("#show_" + id).show();
171
function installHierarchy()
173
// Build Parents ("Used by") and Children ("Used in") Lists, if applicable.
175
hier += "<span id='hier_parents'></span>";
176
hier += "<span id='hier_children'></span>";
177
$("#hierarchy").html(hier);
179
vlsGetJson({ url: "/vls-get-parents",
180
data: {origname:ORIGNAME},
181
success: function(parents) {
182
if (parents == "NIL" || parents.length == 0) {
183
// Seems nicer just not to say anything at all.
184
log("Not showing empty parents " + JSON.stringify(parents));
185
// $("#hier_parents").html("No parents");
188
var ret = "<p>Used by ";
189
ret += makeModuleList('parents', parents);
191
$("#hier_parents").append(ret);
194
vlsGetJson({ url: "/vls-get-children",
195
data: {origname:ORIGNAME},
196
success: function(children) {
197
if (children == "NIL" || children.length == 0) {
198
// Seems nicer just not to say anything at all.
199
log("Not showing empty children " + JSON.stringify(children));
200
// $("#hier_children").html("Leaf module (no children).");
203
var ret = "<p>Uses ";
204
ret += makeModuleList('children', children);
206
$("#hier_children").append(ret);
210
// function warningTypesSummary(wtypes) {
211
// // Wtypes is a hash that binds type -> count
213
// for(var key in wtypes) tuples.push([key, wtypes[key]]);
214
// tuples.sort(function(a,b) {
217
// return (count1 < count2) ? -1
218
// : (count2 < count1) ? 1
224
function warningToItem(w) {
226
ret += "<li class='vl_warning'>";
228
ret += "<span class='vl_fatal_warning_type' title=\"From " + htmlEncode(w.fn) + "\">";
230
ret += "<span class='vl_nonfatal_warning_type' title=\"From " + htmlEncode(w.fn) + "\">";
231
ret += htmlEncode(w.type);
232
ret += "</span><br/>";
238
function expandElidedWarnings() {
239
$("#elided_warnings").hide();
240
$("#full_warnings").show();
243
function collapseWarnings() {
244
$("#elided_warnings").show();
245
$("#full_warnings").hide();
248
function closeExtraStuff() {
249
$("#extrastuff").hide();
252
function installWarnings()
254
vlsGetJson({ url: "/vls-get-warnings",
255
data: {origname:ORIGNAME},
256
success: function(warnings)
258
// Basic sanity check on server data.
259
assert(warnings.constructor === Array, "warnings not an array?");
260
for(var i = 0;i < warnings.length; i++) {
262
assert("tag" in w, "warning has no tag");
263
assert("type" in w, "warning has no type");
264
assert("fatalp" in w, "warning has no fatalp");
265
assert("html" in w, "warning has no html");
266
assert("fn" in w, "warning has no fn");
269
if (warnings.length == 0) {
270
// Seems nicer not to say anything at all.
271
log("Not showing empty warnings " + JSON.stringify(warnings));
275
// Partition into fatal versus nonfatal warnings.
278
for(var i = 0; i < warnings.length; i++) {
286
fatal.sort(function(a,b) { return (a.type < b.type) ? 1 : (a.type > b.type) ? -1 : 0; });
287
nonfatal.sort(function(a,b) { return (a.type < b.type) ? 1 : (a.type > b.type) ? -1 : 0; });
290
acc += "<a href=\"javascript:void(0)\" onClick=\"closeExtraStuff()\">";
291
acc += "<img src='images/close_small.png' align='right'/>";
294
acc += "<p class='warninghead' align='left'>Warnings — " + fatal.length + " fatal, " + nonfatal.length + " nonfatal</p>";
296
var all = fatal.concat(nonfatal);
299
if (all.length < cutoff)
301
acc += "<ul class='vl_warning_list'>";
302
for(var i = 0;i < all.length; ++i)
303
acc += warningToItem(all[i]);
309
acc += "<ul class='vl_warning_list' id='full_warnings' style='display:none'>";
310
for(var i = 0;i < cutoff; ++i)
311
acc += warningToItem(all[i]);
313
acc += "<p class='vl_warning_more'>";
314
acc += "<a class=\"expandelided\" href=\"javascript:void(0)\" onclick=\"collapseWarnings()\">";
319
for(var i = cutoff;i < all.length; ++i)
320
acc += warningToItem(all[i]);
324
acc += "<ul class='vl_warning_list' id='elided_warnings'>";
325
for(var i = 0;i < cutoff; ++i)
326
acc += warningToItem(all[i]);
328
acc += "<li class='vl_warning_more'>";
329
acc += "<br/><a class=\"expandelided\" href=\"javascript:void(0)\" onclick=\"expandElidedWarnings()\">";
330
acc += "show " + (all.length - cutoff) + " more";
337
$("#warnings").html(acc);
343
function installParsedSource()
345
vlsGetHtml({ url: "/vls-get-origsrc",
346
data: {origname:ORIGNAME},
347
success: function(data) {
348
$("#sourcecode").html(data);
353
function installRawSource()
355
vlsGetHtml({ url: "/vls-get-plainsrc",
356
data: {origname:ORIGNAME},
357
success: function(data)
359
$("#sourcecode").html("<pre>" + htmlEncode(data) + "</pre>");
364
function toggleMarkup()
366
if (SHOWING != "raw") {
370
installParsedSource();
375
function makePortTable()
377
var url = "porttable.html?"
380
+ "&origname=" + ORIGNAME;
381
//var opts = "status=0,toolbar=1,height=600,width=780,resizable=1,scrollbars=1,location=1";
382
var wname = "portTableWindow_" + ORIGNAME;
383
var win = window.open(url, wname);
387
function showModule(name)
389
var page = "display.html?"
392
+ "&origname=" + name;
393
if (window.opener == null)
394
location.href = page;
396
window.opener.location.href = page;
400
function showWireExt(mod,wire) {
401
var url = "describe.html?"
406
var opts = "status=0,toolbar=1,height=600,width=780,resizable=1,scrollbars=1,location=1";
407
var wname = "describeWindow_mod" + mod + "&what=" + wire;
408
var win = window.open(url, wname, opts);
413
function showWire(wire) {
414
// var url = "describe.pl?model=cns&base=2014-09-09-19-12&mod=rregs&trans=&what=" + name;
415
// var opts = "status=0,toolbar=1,height=500,width=700,resizable=1,scrollbars=1,location=1";
416
// var win = window.open(url, "describeWindow", opts);
418
showWireExt(ORIGNAME, wire);