~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/centaur/vl/server/public/display.js

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// VL Verilog Toolkit
 
2
// Copyright (C) 2008-2014 Centaur Technology
 
3
//
 
4
// Contact:
 
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/
 
8
//
 
9
// License: (An MIT/X11-style license)
 
10
//
 
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:
 
17
//
 
18
//   The above copyright notice and this permission notice shall be included in
 
19
//   all copies or substantial portions of the Software.
 
20
//
 
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.
 
28
//
 
29
// Original author: Jared Davis <jared@centtech.com>
 
30
 
 
31
$(document).ready(function() { connect(onConnected); });
 
32
 
 
33
var ORIGNAME = getParameterByName("origname"); // Originally case-insensitive.  Gets corrected by onConnected.
 
34
 
 
35
if (!ORIGNAME) {
 
36
    window.alert("No origname to display?")
 
37
}
 
38
 
 
39
var SUMMARY = false;
 
40
function onConnected()
 
41
{
 
42
    log("Connected");
 
43
    toolbar_init();
 
44
    log("Toolbar initialized.");
 
45
 
 
46
    vlsGetJson({ url: "/vls-get-summary",
 
47
                 data: {origname:ORIGNAME},
 
48
                 success: function(summary)
 
49
                 {
 
50
                     log("Got summaries.");
 
51
                     if (summary == "NIL") {
 
52
                         $("#sourcecode").html(ORIGNAME + " not found.");
 
53
                         return;
 
54
                     }
 
55
                     SUMMARY = summary;
 
56
                     ORIGNAME = SUMMARY[":NAME"];
 
57
                     loadEverythingElse();
 
58
                 }});
 
59
}
 
60
 
 
61
function loadEverythingElse()
 
62
{
 
63
    log("Loading everything else.");
 
64
    $("#banner").html(ORIGNAME);
 
65
 
 
66
    var desc = "";
 
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/>";
 
72
    desc += "<small>";
 
73
    desc += "<a href=\"javascript:void(0)\" onclick=\"showLoc('" + file + "', " + line + ", " + col + ")\">";
 
74
    desc += file + ":" + line + ":" + col;
 
75
    desc += "</small>";
 
76
    $("#desctype").html(desc);
 
77
 
 
78
    log("Type is " + type);
 
79
 
 
80
    // Add the port table/IOs button only for modules
 
81
    if (type == ":VL-MODULE")
 
82
    {
 
83
        var btn = "";
 
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>'/>";
 
86
        btn += "</a> ";
 
87
        $("#disptools").append(btn);
 
88
    }
 
89
 
 
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")
 
97
    {
 
98
        var btn = "";
 
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>'/>";
 
101
        btn += "</a> "
 
102
        $("#disptools").append(btn);
 
103
    }
 
104
 
 
105
    installParsedSource();
 
106
    installHierarchy();
 
107
    installWarnings();
 
108
}
 
109
 
 
110
 
 
111
function makeModuleList(id, names)
 
112
{
 
113
    log("makeModuleList(" + id + ") with " + names.length + " names");
 
114
 
 
115
    var ret = "";
 
116
    var max = 8;
 
117
    if (names.length <= max)
 
118
    {
 
119
        // Short enough list that there is no need to elide it.
 
120
        for(var i = 0; i < names.length; ++i) {
 
121
            var name = names[i];
 
122
            ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a>";
 
123
            if (i == names.length - 2) {
 
124
                ret += " and ";
 
125
            }
 
126
            else if (i != names.length - 1) {
 
127
                ret += ", ";
 
128
            }
 
129
        }
 
130
        return ret;
 
131
    }
 
132
 
 
133
    // Otherwise we have a long list, let's elide it and make it expandable.
 
134
    for(var i = 0; i < max; ++i) {
 
135
        var name = names[i];
 
136
        ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a> ";
 
137
        if (i != names.length - 1) {
 
138
            ret += ", ";
 
139
        }
 
140
    }
 
141
 
 
142
    ret += "<span id='elide_" + id + "'>";
 
143
    ret += " and ";
 
144
    ret += "<a class=\"expandelided\" href=\"javascript:void(0)\" onclick=\"expandElidedModuleList('" + id + "')\">";
 
145
    ret += (names.length - max);
 
146
    ret += " more";
 
147
    ret += "</a>";
 
148
    ret += "</span>";
 
149
 
 
150
    ret += "<span id='show_" + id + "' style='display:none;'>";
 
151
    for(var i = max; i < names.length; ++i) {
 
152
        var name = names[i];
 
153
        ret += "<a href=\"javascript:void(0)\" onclick=\"showModule('" + name + "')\">" + name + "</a>";
 
154
        if (i == names.length - 2) {
 
155
            ret += " and ";
 
156
        }
 
157
        else if (i != names.length - 1) {
 
158
            ret += ", ";
 
159
        }
 
160
    }
 
161
    ret += "</span>";
 
162
 
 
163
    return ret;
 
164
}
 
165
 
 
166
function expandElidedModuleList(id) {
 
167
    $("#elide_" + id).hide();
 
168
    $("#show_" + id).show();
 
169
}
 
170
 
 
171
function installHierarchy()
 
172
{
 
173
    // Build Parents ("Used by") and Children ("Used in") Lists, if applicable.
 
174
    var hier = "";
 
175
    hier += "<span id='hier_parents'></span>";
 
176
    hier += "<span id='hier_children'></span>";
 
177
    $("#hierarchy").html(hier);
 
178
 
 
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");
 
186
                         return;
 
187
                     }
 
188
                     var ret = "<p>Used by ";
 
189
                     ret += makeModuleList('parents', parents);
 
190
                     ret += ".</p>";
 
191
                     $("#hier_parents").append(ret);
 
192
                 }});
 
193
 
 
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).");
 
201
                         return;
 
202
                     }
 
203
                     var ret = "<p>Uses ";
 
204
                     ret += makeModuleList('children', children);
 
205
                     ret += ".</p>";
 
206
                     $("#hier_children").append(ret);
 
207
                 }});
 
208
}
 
209
 
 
210
// function warningTypesSummary(wtypes) {
 
211
//     // Wtypes is a hash that binds type -> count
 
212
//     var tuples = [];
 
213
//     for(var key in wtypes) tuples.push([key, wtypes[key]]);
 
214
//     tuples.sort(function(a,b) {
 
215
//      count1 = a[1];
 
216
//      count2 = b[1];
 
217
//      return (count1 < count2) ? -1
 
218
//              : (count2 < count1) ? 1
 
219
//           : 0;
 
220
//     });
 
221
 
 
222
// }
 
223
 
 
224
function warningToItem(w) {
 
225
    var ret = "";
 
226
    ret += "<li class='vl_warning'>";
 
227
    if (w.fatalp)
 
228
        ret += "<span class='vl_fatal_warning_type' title=\"From " + htmlEncode(w.fn) + "\">";
 
229
    else
 
230
        ret += "<span class='vl_nonfatal_warning_type' title=\"From " + htmlEncode(w.fn) + "\">";
 
231
    ret += htmlEncode(w.type);
 
232
    ret += "</span><br/>";
 
233
    ret += w.html;
 
234
    ret += "</li>";
 
235
    return ret;
 
236
}
 
237
 
 
238
function expandElidedWarnings() {
 
239
    $("#elided_warnings").hide();
 
240
    $("#full_warnings").show();
 
241
}
 
242
 
 
243
function collapseWarnings() {
 
244
    $("#elided_warnings").show();
 
245
    $("#full_warnings").hide();
 
246
}
 
247
 
 
248
function closeExtraStuff() {
 
249
    $("#extrastuff").hide();
 
250
}
 
251
 
 
252
function installWarnings()
 
253
{
 
254
    vlsGetJson({ url: "/vls-get-warnings",
 
255
                 data: {origname:ORIGNAME},
 
256
                 success: function(warnings)
 
257
                 {
 
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++) {
 
261
                         var w = warnings[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");
 
267
                     }
 
268
 
 
269
                     if (warnings.length == 0) {
 
270
                         // Seems nicer not to say anything at all.
 
271
                         log("Not showing empty warnings " + JSON.stringify(warnings));
 
272
                         return;
 
273
                     }
 
274
 
 
275
                     // Partition into fatal versus nonfatal warnings.
 
276
                     var fatal = [];
 
277
                     var nonfatal = [];
 
278
                     for(var i = 0; i < warnings.length; i++) {
 
279
                         var w = warnings[i];
 
280
                         if (w.fatalp)
 
281
                             fatal.push(w);
 
282
                         else
 
283
                             nonfatal.push(w);
 
284
                     }
 
285
 
 
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; });
 
288
 
 
289
                     var acc = "";
 
290
                     acc += "<a href=\"javascript:void(0)\" onClick=\"closeExtraStuff()\">";
 
291
                     acc += "<img src='images/close_small.png' align='right'/>";
 
292
                     acc += "</a>";
 
293
 
 
294
                     acc += "<p class='warninghead' align='left'>Warnings &mdash; " + fatal.length + " fatal, " + nonfatal.length + " nonfatal</p>";
 
295
 
 
296
                     var all = fatal.concat(nonfatal);
 
297
                     var cutoff = 3;
 
298
 
 
299
                     if (all.length < cutoff)
 
300
                     {
 
301
                         acc += "<ul class='vl_warning_list'>";
 
302
                         for(var i = 0;i < all.length; ++i)
 
303
                             acc += warningToItem(all[i]);
 
304
                         acc += "</ul>";
 
305
                     }
 
306
 
 
307
                     else
 
308
                     {
 
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]);
 
312
 
 
313
                         acc += "<p class='vl_warning_more'>";
 
314
                         acc += "<a class=\"expandelided\" href=\"javascript:void(0)\" onclick=\"collapseWarnings()\">";
 
315
                         acc += "show fewer";
 
316
                         acc += "</a>";
 
317
                         acc += "</p>";
 
318
 
 
319
                         for(var i = cutoff;i < all.length; ++i)
 
320
                             acc += warningToItem(all[i]);
 
321
 
 
322
                         acc += "</ul>";
 
323
 
 
324
                         acc += "<ul class='vl_warning_list' id='elided_warnings'>";
 
325
                         for(var i = 0;i < cutoff; ++i)
 
326
                             acc += warningToItem(all[i]);
 
327
 
 
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";
 
331
                         acc += "</a>";
 
332
                         acc += "</li>";
 
333
 
 
334
                         acc += "</ul>";
 
335
                     }
 
336
 
 
337
                     $("#warnings").html(acc);
 
338
                 }});
 
339
}
 
340
 
 
341
var SHOWING = "";
 
342
 
 
343
function installParsedSource()
 
344
{
 
345
    vlsGetHtml({ url: "/vls-get-origsrc",
 
346
                 data: {origname:ORIGNAME},
 
347
                 success: function(data) {
 
348
                     $("#sourcecode").html(data);
 
349
                     SHOWING = "parsed";
 
350
                 }});
 
351
}
 
352
 
 
353
function installRawSource()
 
354
{
 
355
    vlsGetHtml({ url: "/vls-get-plainsrc",
 
356
                 data: {origname:ORIGNAME},
 
357
                 success: function(data)
 
358
                 {
 
359
                     $("#sourcecode").html("<pre>" + htmlEncode(data) + "</pre>");
 
360
                     SHOWING = "raw";
 
361
                 }});
 
362
}
 
363
 
 
364
function toggleMarkup()
 
365
{
 
366
    if (SHOWING != "raw") {
 
367
        installRawSource();
 
368
    }
 
369
    else {
 
370
        installParsedSource();
 
371
    }
 
372
}
 
373
 
 
374
 
 
375
function makePortTable()
 
376
{
 
377
    var url = "porttable.html?"
 
378
                  + "&base=" + BASE
 
379
                  + "&model=" + MODEL
 
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);
 
384
    win.focus();
 
385
}
 
386
 
 
387
function showModule(name)
 
388
{
 
389
    var page = "display.html?"
 
390
                    + "&base=" + BASE
 
391
                    + "&model=" + MODEL
 
392
                    + "&origname=" + name;
 
393
    if (window.opener == null)
 
394
        location.href = page;
 
395
    else
 
396
        window.opener.location.href = page;
 
397
}
 
398
 
 
399
 
 
400
function showWireExt(mod,wire) {
 
401
    var url = "describe.html?"
 
402
                  + "&base=" + BASE
 
403
                  + "&model=" + MODEL
 
404
                  + "&origname=" + mod
 
405
                  + "&what=" + wire;
 
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);
 
409
    win.focus();
 
410
    return false;
 
411
}
 
412
 
 
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);
 
417
//    win.focus();
 
418
    showWireExt(ORIGNAME, wire);
 
419
}
 
420
 
 
421
 
 
422