32
32
(include-book "preprocessor/defines")
33
(local (include-book "../util/arithmetic"))
34
(local (include-book "../util/osets"))
36
(local (defthm string-listp-of-remove-equal
37
(implies (force (string-listp x))
38
(string-listp (remove-equal a x)))))
40
(local (defthm string-listp-of-remove-duplicates-equal
41
(implies (force (string-listp x))
42
(string-listp (remove-duplicates-equal x)))))
34
44
(define mintime-p (x)
96
106
(search-path string-listp
97
107
"A list of directories to search (in order) for descriptions
98
108
in @('start-modnames') that were in the @('start-files'),
99
and for <see topic=\"@(url vl-modulelist-missing)\">missing
100
modules</see>. This is similar to \"library directories\"
101
in tools like Verilog-XL and NCVerilog.")
109
and for missing modules. This is similar to \"library
110
directories\" in tools like Verilog-XL and NCVerilog.")
103
112
(search-exts string-listp
141
150
(defconst *vl-default-loadconfig*
142
151
(make-vl-loadconfig))
153
(local (xdoc::set-default-parents vl-loadconfig-clean))
156
(define vl-clean-search-extension ((searchext stringp))
157
:short "Normalize search extensions so that they don't have leading dots."
158
:long "<p>This is a DWIM feature so that we can just do the right thing
159
regardless of whether you say the search extensions are, e.g., @('\".sv\"') or
160
just @('\"sv\"').</p>"
161
:returns (new-searchext stringp :rule-classes :type-prescription)
162
(b* ((searchext (string-fix searchext))
163
(len (length searchext))
164
((when (and (< 0 len)
165
(eql (char searchext 0) #\.)))
166
(subseq searchext 1 nil)))
169
(assert! (equal (vl-clean-search-extension "sv") "sv"))
170
(assert! (equal (vl-clean-search-extension ".sv") "sv")))
172
(defprojection vl-clean-search-extensions-aux ((x string-listp))
173
:returns (new-x string-listp)
174
(vl-clean-search-extension x))
176
(define vl-clean-search-extensions ((search-exts string-listp))
177
:returns (search-exts string-listp)
178
(remove-duplicates-equal (remove-equal "" (vl-clean-search-extensions-aux search-exts)))
180
(assert! (equal (vl-clean-search-extensions '("v" "v" ".v" "sv")) '("v" "sv")))
181
(assert! (equal (vl-clean-search-extensions '(".v" "v")) '("v")))
182
(assert! (equal (vl-clean-search-extensions '(".sv" "v" "sv" "v")) '("sv" "v"))))
184
(define vl-loadconfig-clean
185
:parents (vl-loadconfig)
186
:short "Normalize a load configuration to avoid, e.g., redundant search paths
188
((config vl-loadconfig-p))
189
:returns (new-config vl-loadconfig-p)
190
:long "<p>We clean up the load configuration in a couple of ways. This is
191
partially an optimization that will help us to avoid looking in the same
192
directories multiple times. It also helps to prevent spurious \"ambiguous
193
load\" warnings that could arise if someone gives the same search extensions
195
(b* (((vl-loadconfig config)))
196
(change-vl-loadconfig config
197
;; Don't sort start-files in case the user wants to process
198
;; them multiple times.
199
:start-names (mergesort config.start-names)
200
;; We use remove-duplicates-equal instead of
201
;; mergesort, even though it is generally slow,
202
;; because it preserves the original order, which
203
;; matters for priority-ordered search paths/exts.
204
:search-path (remove-duplicates-equal config.search-path)
205
:search-exts (vl-clean-search-extensions config.search-exts)
206
:include-dirs (remove-duplicates-equal config.include-dirs))))