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 THE
24
; 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>
32
(include-book "../loader/descriptions")
33
(include-book "../loader/inject-comments")
34
(include-book "../util/print")
35
(local (include-book "../util/arithmetic"))
40
; When the user clicks on a particular location, we want to display a nice
41
; page that essentially shows something like this:
43
; module mod ( ... ); } "startline"
45
; ... } "hidden before context" (HBC)
47
; wire w; } "before" context (BC)
50
; assign w = ... ; } "goal line"
52
; assign v = ... ; } "after context" (AC)
55
; ... } "hidden after context" (HAC)
57
; endmodule } "lastline"
60
(define vl-find-description-for-loc ((loc vl-location-p)
61
(x vl-descriptionlist-p))
62
:returns (desc (iff (vl-description-p desc)
64
;; Find the first module that contains the desired location.
67
((vl-location-between-p loc
68
(vl-description->minloc (car x))
69
(vl-description->maxloc (car x)))
70
(vl-description-fix (car x)))
72
(vl-find-description-for-loc loc (cdr x)))))
75
(define vls-showloc-print-bc (contents start goal &key (ps 'ps))
76
;; Assumes the starting line has already been printed
77
:guard (and (stringp contents)
80
;; The before-context is everything between start and goal, exclusive.
81
(b* ((bc-start (+ 1 start))
83
(bc-nlines (+ 1 (- goal bc-start))))
86
;; There's no before context at all, so there's nothing to print.
90
;; The before-context is pretty small, so don't hide any of it.
92
(vl-println-markup "<div id=\"showloc_bc\">")
93
(vl-print (str::strlines bc-start bc-stop contents))
94
(vl-println-markup "</div>")))
97
;; The before-context is pretty large.
99
(vl-println-markup " <a id=\"showloc_hbc_link\" href=\"javascript:void(0)\" onclick=\"showloc_hbc()\">...</a>")
100
(vl-println-markup "<div id=\"showloc_hbc\" style=\"display: none\">")
101
(vl-print (str::strlines bc-start (- bc-stop 4) contents))
102
(vl-println-markup "</div>") ;
103
(vl-println-markup "<div id=\"showloc_bc\">")
104
(vl-print (str::strlines (- bc-stop 3) bc-stop contents))
105
(vl-println-markup "</div>"))))))
107
(define vls-showloc-print-ac (contents goal end &key (ps 'ps))
108
;; Assumes everything up through and including the goal line have already
110
:guard (and (stringp contents)
113
;; The after-context is everything between goal and end, exclusive.
114
(b* ((ac-start (+ goal 1))
116
(ac-nlines (+ 1 (- end ac-start))))
118
((< ac-stop ac-start)
119
;; No after-context, so nothing to print
123
;; The before-context is pretty small, so don't hide any of it.
125
(vl-println-markup "<div id=\"showloc_ac\">")
126
(vl-print (str::strlines ac-start ac-stop contents))
127
(vl-println-markup "</div>")))
130
;; The before-context is pretty large.
132
(vl-println-markup "<div id=\"showloc_ac\">")
133
(vl-print (str::strlines ac-start (+ ac-start 3) contents))
134
(vl-println-markup "</div>")
135
(vl-println-markup "<a id=\"showloc_hac_link\" href=\"javascript:void(0)\" onClick=\"showloc_hac()\">...</a>")
136
(vl-println-markup "<div id=\"showloc_hac\" style=\"display: none\">")
137
(vl-print (str::strlines (+ ac-start 4) ac-stop contents))
138
(vl-println-markup "</div>")
141
(define vls-showloc-print-goal (line col &key (ps 'ps))
142
:guard (and (stringp line)
145
(vl-println-markup "<div id=\"showloc_goal\">")
146
(vl-println-markup "<a name=\"hac_goal\">")
147
(let ((len (length line)))
149
;; Really this is an error, there's no such column on the goal line.
150
;; We'll just print whatever the line is.
153
(vl-print (subseq line 0 col))
154
(vl-print-markup "<span class=\"showloc_goalcol\">")
155
(vl-print (char line col))
156
(vl-print-markup "</span>")
157
(vl-println (subseq line (+ col 1) nil)))))
158
(vl-println-markup "</a>")
159
(vl-println-markup "</div>")))
161
(define vls-showloc-print (contents min max line col &key (ps 'ps))
162
:guard (and (stringp contents)
170
(vl-ps-seq (vl-println-markup "<div id=\"showloc_start\">")
171
(vl-println (str::strline min contents))
172
(vl-println-markup "</div>")))
173
(vls-showloc-print-bc contents min line)
174
(vls-showloc-print-goal (str::strline line contents) col)
175
(vls-showloc-print-ac contents line max)
178
(vl-ps-seq (vl-println-markup "<div id=\"showloc_end\">")
179
(vl-println (str::strline max contents))
180
(vl-println-markup "</div>")))))