aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-01-05 10:23:26 +0000
committerDan Nicolaescu2008-01-05 10:23:26 +0000
commit7ea26faf0ca59347269550b107297be20dea49bd (patch)
tree835b8efb8ac317cf6bd1003db2ba4197268bc57b
parentd58107b04c1bbc16817d2c15a4771d361d74efe7 (diff)
downloademacs-7ea26faf0ca59347269550b107297be20dea49bd.tar.gz
emacs-7ea26faf0ca59347269550b107297be20dea49bd.zip
* progmodes/verilog-mode.el (top-level): Don't require compile.
(compilation-error-regexp-alist, compilation-last-buffer): Define for compiler. (verilog-insert-1): New function. (verilog-insert-indices, verilog-generate-numbers): Doc fixes. Use verilog-insert-1. (verilog-surelint-off): Use next-error-last-buffer if bound. Check compile buffer is live. * progmodes/verilog-mode.el: Replace all instances of string-to-int with string-to-number, insert-string with insert, and read-input with read-string. (top-level): No need to require imenu, reporter, dinotrace, vc, font-lock when compiling. Always require compile. Relegate remaining compatibility cruft to XEmacs. Don't require font-lock. (verilog-version): Remove superfluous concat. (dinotrace-unannotate-all, zmacs-activate-region, customize-apropos): No need to define. (verilog-regexp-opt): On Emacs, just make it an alias for regexp-opt. (verilog-font-lock-keywords, verilog-font-lock-keywords-1) (verilog-font-lock-keywords-2, verilog-font-lock-keywords-3) (verilog-startup-message-displayed): These are variables, not constants. (verilog-batch-execute-func, verilog-auto-inst) (verilog-auto-inst-param): Use mapc rather than mapcar. (sigs-in, sigs-inout, sigs-out): Define for compiler rather than actually defining. (verilog-modi-get-decls, verilog-modi-get-sub-decls) (verilog-modi-get-outputs, verilog-modi-get-inouts) (verilog-modi-get-inputs, verilog-modi-get-wires) (verilog-modi-get-regs, verilog-modi-get-assigns) (verilog-modi-get-consts, verilog-modi-get-gparams) (verilog-modi-get-sub-outputs, verilog-modi-get-sub-inouts) (verilog-modi-get-sub-inputs): Move inline functions earlier in the file. (sigs-in, sigs-out): Don't declare multiple times. (got-sig, got-rvalue, uses-delayed): Define for compiler with just `defvar'. (verilog-auto): Call dinotrace-unannotate-all only if bound. (verilog-module-inside-filename-p): No need to wrap fboundp test in condition-case. (reporter-submit-bug-report): Autoload it. (verilog-mark-defun): Call zmacs-activate-region only if bound. (verilog-font-customize): Call customize-apropos only if bound. (verilog-getopt-flags, verilog-auto-reeval-locals): Use make-local-variable rather than make-variable-buffer-local. (verilog-company, verilog-project, verilog-modi-cache-list): Move make-variable-buffer-local calls to top-level. (font-lock-defaults-alist): Don't define it. (verilog-need-fld): Remove. (verilog-font-lock-init): Don't set font-lock-defaults-alist. (verilog-mode): Only call make-local-hook on XEmacs. Set font-lock-defaults rather than using verilog-font-lock-init.
-rw-r--r--lisp/progmodes/verilog-mode.el824
1 files changed, 410 insertions, 414 deletions
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 2d34d9d599a..7533d4dd49e 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -115,164 +115,135 @@
115(defun verilog-version () 115(defun verilog-version ()
116 "Inform caller of the version of this file." 116 "Inform caller of the version of this file."
117 (interactive) 117 (interactive)
118 (message (concat "Using verilog-mode version " verilog-mode-version) )) 118 (message "Using verilog-mode version %s" verilog-mode-version))
119 119
120;; Insure we have certain packages, and deal with it if we don't 120;; Insure we have certain packages, and deal with it if we don't
121(eval-when-compile 121(eval-when-compile
122 (condition-case nil 122 (when (featurep 'xemacs)
123 (require 'imenu) 123 (condition-case nil
124 (error nil)) 124 (require 'easymenu)
125 (condition-case nil 125 (error nil))
126 (require 'reporter) 126 (condition-case nil
127 (error nil)) 127 (require 'regexp-opt)
128 (condition-case nil 128 (error nil))
129 (require 'easymenu) 129 ;; Bug in 19.28 through 19.30 skeleton.el, not provided.
130 (error nil)) 130 (condition-case nil
131 (condition-case nil 131 (load "skeleton")
132 (require 'regexp-opt) 132 (error nil))
133 (error nil)) 133 (condition-case nil
134 (condition-case nil 134 (if (fboundp 'when)
135 (load "skeleton") ;; bug in 19.28 through 19.30 skeleton.el, not provided. 135 nil ;; fab
136 (error nil)) 136 (defmacro when (cond &rest body)
137 (condition-case nil 137 (list 'if cond (cons 'progn body))))
138 (require 'vc) 138 (error nil))
139 (error nil)) 139 (condition-case nil
140 (condition-case nil 140 (if (fboundp 'unless)
141 (if (fboundp 'when) 141 nil ;; fab
142 nil ;; fab 142 (defmacro unless (cond &rest body)
143 (defmacro when (cond &rest body) 143 (cons 'if (cons cond (cons nil body)))))
144 (list 'if cond (cons 'progn body)))) 144 (error nil))
145 (error nil)) 145 (condition-case nil
146 (condition-case nil 146 (if (fboundp 'store-match-data)
147 (if (fboundp 'unless) 147 nil ;; fab
148 nil ;; fab 148 (defmacro store-match-data (&rest args) nil))
149 (defmacro unless (cond &rest body) 149 (error nil))
150 (cons 'if (cons cond (cons nil body))))) 150 (condition-case nil
151 (error nil)) 151 (if (boundp 'current-menubar)
152 (condition-case nil 152 nil ;; great
153 (if (fboundp 'store-match-data) 153 (progn
154 nil ;; fab 154 (defmacro add-submenu (&rest args) nil))
155 (defmacro store-match-data (&rest args) nil)) 155 )
156 (error nil)) 156 (error nil))
157 (if (featurep 'xemacs) 157 (condition-case nil
158 (condition-case nil 158 (if (fboundp 'char-before)
159 (if (boundp 'current-menubar) 159 nil ;; great
160 nil ;; great 160 (defmacro char-before (&rest body)
161 (progn 161 (char-after (1- (point)))))
162 (defmacro add-submenu (&rest args) nil)) 162 (error nil))
163 ) 163 (condition-case nil
164 (error nil))) 164 (require 'custom)
165 (condition-case nil 165 (error nil))
166 (if (fboundp 'zmacs-activate-region) 166 (condition-case nil
167 nil ;; great 167 (if (fboundp 'match-string-no-properties)
168 (defmacro zmacs-activate-region (&rest args) nil)) 168 nil ;; great
169 (error nil)) 169 (defsubst match-string-no-properties (num &optional string)
170 (condition-case nil 170 "Return string of text matched by last search, without text properties.
171 (if (fboundp 'char-before)
172 nil ;; great
173 (defmacro char-before (&rest body)
174 (char-after (1- (point)))))
175 (error nil))
176 ;; Requires to define variables that would be "free" warnings
177 (condition-case nil
178 (require 'font-lock)
179 (error nil))
180 (condition-case nil
181 (require 'compile)
182 (error nil))
183 (condition-case nil
184 (require 'custom)
185 (error nil))
186 (condition-case nil
187 (require 'dinotrace)
188 (error nil))
189 (condition-case nil
190 (if (fboundp 'dinotrace-unannotate-all)
191 nil ;; great
192 (defun dinotrace-unannotate-all (&rest args) nil))
193 (error nil))
194 (condition-case nil
195 (if (fboundp 'customize-apropos)
196 nil ;; great
197 (defun customize-apropos (&rest args) nil))
198 (error nil))
199 (condition-case nil
200 (if (fboundp 'match-string-no-properties)
201 nil ;; great
202 (defsubst match-string-no-properties (num &optional string)
203 "Return string of text matched by last search, without text properties.
204NUM specifies which parenthesized expression in the last regexp. 171NUM specifies which parenthesized expression in the last regexp.
205 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. 172 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
206Zero means the entire text matched by the whole regexp or whole string. 173Zero means the entire text matched by the whole regexp or whole string.
207STRING should be given if the last search was by `string-match' on STRING." 174STRING should be given if the last search was by `string-match' on STRING."
208 (if (match-beginning num) 175 (if (match-beginning num)
209 (if string 176 (if string
210 (let ((result 177 (let ((result
211 (substring string (match-beginning num) (match-end num)))) 178 (substring string
212 (set-text-properties 0 (length result) nil result) 179 (match-beginning num) (match-end num))))
213 result) 180 (set-text-properties 0 (length result) nil result)
214 (buffer-substring-no-properties (match-beginning num) 181 result)
215 (match-end num) 182 (buffer-substring-no-properties (match-beginning num)
216 (current-buffer) 183 (match-end num)
217 ))))) 184 (current-buffer)
218 (error nil)) 185 )))))
219 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) 186 (error nil))
220 nil ;; We've got what we needed 187 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
221 ;; We have the old custom-library, hack around it! 188 nil ;; We've got what we needed
222 (defmacro defgroup (&rest args) nil) 189 ;; We have the old custom-library, hack around it!
223 (defmacro customize (&rest args) 190 (defmacro defgroup (&rest args) nil)
224 (message "Sorry, Customize is not available with this version of emacs")) 191 (defmacro customize (&rest args)
225 (defmacro defcustom (var value doc &rest args) 192 (message
226 `(defvar ,var ,value ,doc)) 193 "Sorry, Customize is not available with this version of emacs"))
227 ) 194 (defmacro defcustom (var value doc &rest args)
228 (if (fboundp 'defface) 195 `(defvar ,var ,value ,doc))
229 nil ; great! 196 )
230 (defmacro defface (var values doc &rest args) 197 (if (fboundp 'defface)
231 `(make-face ,var)) 198 nil ; great!
232 ) 199 (defmacro defface (var values doc &rest args)
200 `(make-face ,var))
201 )
233 202
234 (if (and (featurep 'custom) (fboundp 'customize-group)) 203 (if (and (featurep 'custom) (fboundp 'customize-group))
235 nil ;; We've got what we needed 204 nil ;; We've got what we needed
236 ;; We have an intermediate custom-library, hack around it! 205 ;; We have an intermediate custom-library, hack around it!
237 (defmacro customize-group (var &rest args) 206 (defmacro customize-group (var &rest args)
238 `(customize ,var)) 207 `(customize ,var))
239 ) 208 )))
240 209
241 )
242;; Provide a regular expression optimization routine, using regexp-opt 210;; Provide a regular expression optimization routine, using regexp-opt
243;; if provided by the user's elisp libraries 211;; if provided by the user's elisp libraries
244(eval-and-compile 212(eval-and-compile
245 (if (fboundp 'regexp-opt) 213 (if (featurep 'xemacs)
246 ;; regexp-opt is defined, does it take 3 or 2 arguments? 214 (if (fboundp 'regexp-opt)
247 (if (fboundp 'function-max-args) 215 ;; regexp-opt is defined, does it take 3 or 2 arguments?
248 (let ((args (function-max-args `regexp-opt))) 216 (if (fboundp 'function-max-args)
249 (cond 217 (let ((args (function-max-args `regexp-opt)))
250 ((eq args 3) ;; It takes 3 218 (cond
251 (condition-case nil ; Hide this defun from emacses 219 ((eq args 3) ;; It takes 3
220 (condition-case nil ; Hide this defun from emacses
252 ;with just a two input regexp 221 ;with just a two input regexp
253 (defun verilog-regexp-opt (a b) 222 (defun verilog-regexp-opt (a b)
254 "Deal with differing number of required arguments for `regexp-opt'. 223 "Deal with differing number of required arguments for `regexp-opt'.
255 Call 'regexp-opt' on A and B." 224 Call 'regexp-opt' on A and B."
256 (regexp-opt a b 't) 225 (regexp-opt a b 't)
257 ) 226 )
258 (error nil)) 227 (error nil))
259 ) 228 )
260 ((eq args 2) ;; It takes 2 229 ((eq args 2) ;; It takes 2
261 (defun verilog-regexp-opt (a b) 230 (defun verilog-regexp-opt (a b)
262 "Call 'regexp-opt' on A and B." 231 "Call 'regexp-opt' on A and B."
263 (regexp-opt a b)) 232 (regexp-opt a b))
264 ) 233 )
265 (t nil))) 234 (t nil)))
266 ;; We can't tell; assume it takes 2 235 ;; We can't tell; assume it takes 2
267 (defun verilog-regexp-opt (a b) 236 (defun verilog-regexp-opt (a b)
268 "Call 'regexp-opt' on A and B." 237 "Call 'regexp-opt' on A and B."
269 (regexp-opt a b)) 238 (regexp-opt a b))
270 ) 239 )
271 ;; There is no regexp-opt, provide our own 240 ;; There is no regexp-opt, provide our own
272 (defun verilog-regexp-opt (strings &optional paren shy) 241 (defun verilog-regexp-opt (strings &optional paren shy)
273 (let ((open (if paren "\\(" "")) (close (if paren "\\)" ""))) 242 (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
274 (concat open (mapconcat 'regexp-quote strings "\\|") close))) 243 (concat open (mapconcat 'regexp-quote strings "\\|") close)))
275 )) 244 )
245 ;; Emacs.
246 (defalias 'verilog-regexp-opt 'regexp-opt)))
276 247
277(eval-when-compile 248(eval-when-compile
278 (defun verilog-regexp-words (a) 249 (defun verilog-regexp-words (a)
@@ -287,7 +258,8 @@ STRING should be given if the last search was by `string-match' on STRING."
287(defun verilog-font-customize () 258(defun verilog-font-customize ()
288 "Link to customize fonts used for Verilog." 259 "Link to customize fonts used for Verilog."
289 (interactive) 260 (interactive)
290 (customize-apropos "font-lock-*" 'faces)) 261 (if (fboundp 'customize-apropos)
262 (customize-apropos "font-lock-*" 'faces)))
291 263
292(defgroup verilog-mode nil 264(defgroup verilog-mode nil
293 "Facilitates easy editing of Verilog source text" 265 "Facilitates easy editing of Verilog source text"
@@ -872,10 +844,14 @@ format (e.g. 09/17/1997) is not supported.")
872 "*Default name of Company for verilog header. 844 "*Default name of Company for verilog header.
873If set will become buffer local.") 845If set will become buffer local.")
874 846
847(make-variable-buffer-local 'verilog-company)
848
875(defvar verilog-project nil 849(defvar verilog-project nil
876 "*Default name of Project for verilog header. 850 "*Default name of Project for verilog header.
877If set will become buffer local.") 851If set will become buffer local.")
878 852
853(make-variable-buffer-local 'verilog-project)
854
879(defvar verilog-mode-map 855(defvar verilog-mode-map
880 (let ((map (make-sparse-keymap))) 856 (let ((map (make-sparse-keymap)))
881 (define-key map ";" 'electric-verilog-semi) 857 (define-key map ";" 'electric-verilog-semi)
@@ -1208,9 +1184,13 @@ without the directory portion, will be substituted."
1208 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) 1184 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name))
1209 t t compile-command)))) 1185 t t compile-command))))
1210 1186
1187;; Following code only gets called from compilation-mode-hook.
1188(defvar compilation-error-regexp-alist)
1189
1211(defun verilog-error-regexp-add () 1190(defun verilog-error-regexp-add ()
1212 "Add the messages to the `compilation-error-regexp-alist'. 1191 "Add the messages to the `compilation-error-regexp-alist'.
1213Called by `compilation-mode-hook'. This allows \\[next-error] to find the errors." 1192Called by `compilation-mode-hook'. This allows \\[next-error] to
1193find the errors."
1214 (if (not verilog-error-regexp-add-didit) 1194 (if (not verilog-error-regexp-add-didit)
1215 (progn 1195 (progn
1216 (setq verilog-error-regexp-add-didit t) 1196 (setq verilog-error-regexp-add-didit t)
@@ -1218,7 +1198,8 @@ Called by `compilation-mode-hook'. This allows \\[next-error] to find the error
1218 (append verilog-error-regexp 1198 (append verilog-error-regexp
1219 (default-value 'compilation-error-regexp-alist))) 1199 (default-value 'compilation-error-regexp-alist)))
1220 ;; Could be buffer local at this point; maybe also in let; change all three 1200 ;; Could be buffer local at this point; maybe also in let; change all three
1221 (setq compilation-error-regexp-alist (default-value 'compilation-error-regexp-alist)) 1201 (setq compilation-error-regexp-alist
1202 (default-value 'compilation-error-regexp-alist))
1222 (set (make-local-variable 'compilation-error-regexp-alist) 1203 (set (make-local-variable 'compilation-error-regexp-alist)
1223 (default-value 'compilation-error-regexp-alist)) 1204 (default-value 'compilation-error-regexp-alist))
1224 ))) 1205 )))
@@ -1685,10 +1666,10 @@ Called by `compilation-mode-hook'. This allows \\[next-error] to find the error
1685 ;; figure out version numbers if not already discovered 1666 ;; figure out version numbers if not already discovered
1686 (and (or (not major) (not minor)) 1667 (and (or (not major) (not minor))
1687 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) 1668 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version)
1688 (setq major (string-to-int (substring emacs-version 1669 (setq major (string-to-number (substring emacs-version
1689 (match-beginning 1) 1670 (match-beginning 1)
1690 (match-end 1))) 1671 (match-end 1)))
1691 minor (string-to-int (substring emacs-version 1672 minor (string-to-number (substring emacs-version
1692 (match-beginning 2) 1673 (match-beginning 2)
1693 (match-end 2))))) 1674 (match-end 2)))))
1694 (if (not (and major minor)) 1675 (if (not (and major minor))
@@ -1827,17 +1808,17 @@ supported list, along with the values for this variable:
1827(defvar verilog-mode-syntax-table nil 1808(defvar verilog-mode-syntax-table nil
1828 "Syntax table used in `verilog-mode' buffers.") 1809 "Syntax table used in `verilog-mode' buffers.")
1829 1810
1830(defconst verilog-font-lock-keywords nil 1811(defvar verilog-font-lock-keywords nil
1831 "Default highlighting for Verilog mode.") 1812 "Default highlighting for Verilog mode.")
1832 1813
1833(defconst verilog-font-lock-keywords-1 nil 1814(defvar verilog-font-lock-keywords-1 nil
1834 "Subdued level highlighting for Verilog mode.") 1815 "Subdued level highlighting for Verilog mode.")
1835 1816
1836(defconst verilog-font-lock-keywords-2 nil 1817(defvar verilog-font-lock-keywords-2 nil
1837 "Medium level highlighting for Verilog mode. 1818 "Medium level highlighting for Verilog mode.
1838See also `verilog-font-lock-extra-types'.") 1819See also `verilog-font-lock-extra-types'.")
1839 1820
1840(defconst verilog-font-lock-keywords-3 nil 1821(defvar verilog-font-lock-keywords-3 nil
1841 "Gaudy level highlighting for Verilog mode. 1822 "Gaudy level highlighting for Verilog mode.
1842See also `verilog-font-lock-extra-types'.") 1823See also `verilog-font-lock-extra-types'.")
1843(defvar verilog-font-lock-translate-off-face 1824(defvar verilog-font-lock-translate-off-face
@@ -2029,10 +2010,9 @@ See also `verilog-font-lock-extra-types'.")
2029 (when verilog-highlight-translate-off 2010 (when verilog-highlight-translate-off
2030 (list 2011 (list
2031 ;; Fontify things in translate off regions 2012 ;; Fontify things in translate off regions
2032 '(verilog-match-translate-off (0 'verilog-font-lock-translate-off-face prepend)) 2013 '(verilog-match-translate-off
2033 ))) 2014 (0 'verilog-font-lock-translate-off-face prepend))
2034 ) 2015 )))))
2035 )
2036 2016
2037 2017
2038 2018
@@ -2042,9 +2022,13 @@ See also `verilog-font-lock-extra-types'.")
2042 (let ((st-point (point)) hitbeg) 2022 (let ((st-point (point)) hitbeg)
2043 (or (search-backward "//" (verilog-get-beg-of-line) t) 2023 (or (search-backward "//" (verilog-get-beg-of-line) t)
2044 (if (progn 2024 (if (progn
2045 ;; This is for tricky case //*, we keep searching if /* is proceeded by // on same line 2025 ;; This is for tricky case //*, we keep searching if /* is
2046 (while (and (setq hitbeg (search-backward "/*" nil t)) 2026 ;; proceeded by // on same line.
2047 (progn (forward-char 1) (search-backward "//" (verilog-get-beg-of-line) t)))) 2027 (while
2028 (and (setq hitbeg (search-backward "/*" nil t))
2029 (progn
2030 (forward-char 1)
2031 (search-backward "//" (verilog-get-beg-of-line) t))))
2048 hitbeg) 2032 hitbeg)
2049 (not (search-forward "*/" st-point t))))))) 2033 (not (search-forward "*/" st-point t)))))))
2050 2034
@@ -2244,10 +2228,6 @@ Use filename, if current buffer being edited shorten to just buffer name."
2244(defun verilog-declaration-beg () 2228(defun verilog-declaration-beg ()
2245 (verilog-re-search-backward verilog-declaration-re (bobp) t)) 2229 (verilog-re-search-backward verilog-declaration-re (bobp) t))
2246 2230
2247(require 'font-lock)
2248(defvar verilog-need-fld 1)
2249(defvar font-lock-defaults-alist nil) ;In case we are XEmacs
2250
2251(defun verilog-font-lock-init () 2231(defun verilog-font-lock-init ()
2252 "Initialize fontification." 2232 "Initialize fontification."
2253 ;; highlight keywords and standardized types, attributes, enumeration 2233 ;; highlight keywords and standardized types, attributes, enumeration
@@ -2257,38 +2237,19 @@ Use filename, if current buffer being edited shorten to just buffer name."
2257 (when verilog-highlight-translate-off 2237 (when verilog-highlight-translate-off
2258 (list 2238 (list
2259 ;; Fontify things in translate off regions 2239 ;; Fontify things in translate off regions
2260 '(verilog-match-translate-off (0 'verilog-font-lock-translate-off-face prepend)) 2240 '(verilog-match-translate-off
2261 )) 2241 (0 'verilog-font-lock-translate-off-face prepend))
2262 ) 2242 ))))
2263 )
2264 (put 'verilog-mode 'font-lock-defaults 2243 (put 'verilog-mode 'font-lock-defaults
2265 '((verilog-font-lock-keywords 2244 '((verilog-font-lock-keywords
2266 verilog-font-lock-keywords-1 2245 verilog-font-lock-keywords-1
2267 verilog-font-lock-keywords-2 2246 verilog-font-lock-keywords-2
2268 verilog-font-lock-keywords-3 2247 verilog-font-lock-keywords-3)
2269 ) 2248 nil ; nil means highlight strings & comments as well as keywords
2270 nil ;; nil means highlight strings & comments as well as keywords 2249 nil ; nil means keywords must match case
2271 nil ;; nil means keywords must match case 2250 nil ; syntax table handled elsewhere
2272 nil ;; syntax table handled elsewhere 2251 ;; Function to move to beginning of reasonable region to highlight
2273 verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight 2252 verilog-beg-of-defun)))
2274 ))
2275 (if verilog-need-fld
2276 (let ((verilog-mode-defaults
2277 '((verilog-font-lock-keywords
2278 verilog-font-lock-keywords-1
2279 verilog-font-lock-keywords-2
2280 verilog-font-lock-keywords-3
2281 )
2282 nil ;; nil means highlight strings & comments as well as keywords
2283 nil ;; nil means keywords must match case
2284 nil ;; syntax table handled elsewhere
2285 verilog-beg-of-defun ;; function to move to beginning of reasonable region to highlight
2286 )))
2287 (setq font-lock-defaults-alist
2288 (append
2289 font-lock-defaults-alist
2290 (list (cons 'verilog-mode verilog-mode-defaults))))
2291 (setq verilog-need-fld 0))))
2292 2253
2293;; initialize fontification for Verilog Mode 2254;; initialize fontification for Verilog Mode
2294(verilog-font-lock-init) 2255(verilog-font-lock-init)
@@ -2297,7 +2258,7 @@ Use filename, if current buffer being edited shorten to just buffer name."
2297 '("Please use \\[verilog-submit-bug-report] to report bugs." 2258 '("Please use \\[verilog-submit-bug-report] to report bugs."
2298 "Visit http://www.verilog.com to check for updates" 2259 "Visit http://www.verilog.com to check for updates"
2299 )) 2260 ))
2300(defconst verilog-startup-message-displayed t) 2261(defvar verilog-startup-message-displayed t)
2301(defun verilog-display-startup-message () 2262(defun verilog-display-startup-message ()
2302 (if (not verilog-startup-message-displayed) 2263 (if (not verilog-startup-message-displayed)
2303 (if (sit-for 5) 2264 (if (sit-for 5)
@@ -2486,15 +2447,20 @@ Key bindings specific to `verilog-mode-map' are:
2486 (add-submenu nil verilog-stmt-menu) 2447 (add-submenu nil verilog-stmt-menu)
2487 )) 2448 ))
2488 ;; Stuff for GNU emacs 2449 ;; Stuff for GNU emacs
2489 (make-local-variable 'font-lock-defaults) 2450 (set (make-local-variable 'font-lock-defaults)
2451 '((verilog-font-lock-keywords verilog-font-lock-keywords-1
2452 verilog-font-lock-keywords-2
2453 verilog-font-lock-keywords-3)
2454 nil nil nil verilog-beg-of-defun))
2490 ;;------------------------------------------------------------ 2455 ;;------------------------------------------------------------
2491 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el) 2456 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el)
2492 ;; all buffer local: 2457 ;; all buffer local:
2493 (make-local-hook 'font-lock-mode-hook) 2458 (when (featurep 'xemacs)
2494 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20 2459 (make-local-hook 'font-lock-mode-hook)
2460 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
2461 (make-local-hook 'after-change-functions))
2495 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t) 2462 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
2496 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20 2463 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20
2497 (make-local-hook 'after-change-functions)
2498 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) 2464 (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
2499 2465
2500 ;; Tell imenu how to handle verilog. 2466 ;; Tell imenu how to handle verilog.
@@ -2535,7 +2501,7 @@ With optional ARG, remove existing end of line comments."
2535 (newline)) 2501 (newline))
2536 (progn 2502 (progn
2537 (newline) 2503 (newline)
2538 (insert-string "// ") 2504 (insert "// ")
2539 (beginning-of-line))) 2505 (beginning-of-line)))
2540 (verilog-indent-line)) 2506 (verilog-indent-line))
2541 ((nth 4 state) ; Inside any comment (hence /**/) 2507 ((nth 4 state) ; Inside any comment (hence /**/)
@@ -2723,13 +2689,30 @@ To call this from the command line, see \\[verilog-batch-indent]."
2723 (newline) 2689 (newline)
2724 (insert " * ")) 2690 (insert " * "))
2725 2691
2726(defun verilog-insert-indices (MAX) 2692(defun verilog-insert-1 (fmt max)
2727 "Insert a set of indices at into the rectangle. 2693 "Insert integers 0 to MAX-1 according to format string FMT.
2728The upper left corner is defined by the current point. Indices always 2694Inserts one integer per line, at the current column. Stops early
2729begin with 0 and extend to the MAX - 1. If no prefix arg is given, the 2695if it reaches the end of the buffer."
2730user is prompted for a value. The indices are surrounded by square brackets 2696 (let ((col (current-column))
2731\[]. For example, the following code with the point located after the first 2697 (n 0))
2732'a' gives: 2698 (save-excursion
2699 (while (< n max)
2700 (insert (format fmt n))
2701 (forward-line 1)
2702 ;; Note that this function does not bother to check for lines
2703 ;; shorter than col.
2704 (if (eobp)
2705 (setq n max)
2706 (setq n (1+ n))
2707 (move-to-column col))))))
2708
2709(defun verilog-insert-indices (max)
2710 "Insert a set of indices into a rectangle.
2711The upper left corner is defined by point. Indices begin with 0
2712and extend to the MAX - 1. If no prefix arg is given, the user
2713is prompted for a value. The indices are surrounded by square
2714brackets \[]. For example, the following code with the point
2715located after the first 'a' gives:
2733 2716
2734 a = b a[ 0] = b 2717 a = b a[ 0] = b
2735 a = b a[ 1] = b 2718 a = b a[ 1] = b
@@ -2741,41 +2724,28 @@ user is prompted for a value. The indices are surrounded by square brackets
2741 a = b a[ 7] = b 2724 a = b a[ 7] = b
2742 a = b a[ 8] = b" 2725 a = b a[ 8] = b"
2743 2726
2744 (interactive "NMAX?") 2727 (interactive "NMAX? ")
2745 (save-excursion 2728 (verilog-insert-1 "[%3d]" max))
2746 (let ((n 0))
2747 (while (< n MAX)
2748 (save-excursion
2749 (insert (format "[%3d]" n)))
2750 (next-line 1)
2751 (setq n (1+ n))))))
2752 2729
2753 2730(defun verilog-generate-numbers (max)
2754(defun verilog-generate-numbers (MAX)
2755 "Insert a set of generated numbers into a rectangle. 2731 "Insert a set of generated numbers into a rectangle.
2756The upper left corner is defined by point. The numbers are padded to three 2732The upper left corner is defined by point. The numbers are padded to three
2757digits, starting with 000 and extending to (MAX - 1). If no prefix argument 2733digits, starting with 000 and extending to (MAX - 1). If no prefix argument
2758is supplied, then the user is prompted for the MAX number. consider the 2734is supplied, then the user is prompted for the MAX number. Consider the
2759following code fragment: 2735following code fragment:
2760 2736
2761 buf buf buf buf000 2737 buf buf buf buf000
2762 buf buf buf buf001 2738 buf buf buf buf001
2763 buf buf buf buf002 2739 buf buf buf buf002
2764 buf buf buf buf003 2740 buf buf buf buf003
2765 buf buf ==> insert-indices ==> buf buf004 2741 buf buf ==> generate-numbers ==> buf buf004
2766 buf buf buf buf005 2742 buf buf buf buf005
2767 buf buf buf buf006 2743 buf buf buf buf006
2768 buf buf buf buf007 2744 buf buf buf buf007
2769 buf buf buf buf008" 2745 buf buf buf buf008"
2770 2746
2771 (interactive "NMAX?") 2747 (interactive "NMAX? ")
2772 (save-excursion 2748 (verilog-insert-1 "%3.3d" max))
2773 (let ((n 0))
2774 (while (< n MAX)
2775 (save-excursion
2776 (insert (format "%3.3d" n)))
2777 (next-line 1)
2778 (setq n (1+ n))))))
2779 2749
2780(defun verilog-mark-defun () 2750(defun verilog-mark-defun ()
2781 "Mark the current verilog function (or procedure). 2751 "Mark the current verilog function (or procedure).
@@ -2785,7 +2755,8 @@ This puts the mark at the end, and point at the beginning."
2785 (verilog-end-of-defun) 2755 (verilog-end-of-defun)
2786 (push-mark (point)) 2756 (push-mark (point))
2787 (verilog-beg-of-defun) 2757 (verilog-beg-of-defun)
2788 (zmacs-activate-region)) 2758 (if (fboundp 'zmacs-activate-region)
2759 (zmacs-activate-region)))
2789 2760
2790(defun verilog-comment-region (start end) 2761(defun verilog-comment-region (start end)
2791 ; checkdoc-params: (start end) 2762 ; checkdoc-params: (start end)
@@ -3272,8 +3243,7 @@ Insert `// NAME ' if this line ends a function, task, module, primitive or inter
3272 (cond 3243 (cond
3273 ((looking-at "\\<randcase\\>") 3244 ((looking-at "\\<randcase\\>")
3274 (setq str "randcase") 3245 (setq str "randcase")
3275 (setq err nil) 3246 (setq err nil))
3276 )
3277 ((match-end 0) 3247 ((match-end 0)
3278 (goto-char (match-end 1)) 3248 (goto-char (match-end 1))
3279 (if nil 3249 (if nil
@@ -3291,8 +3261,7 @@ Insert `// NAME ' if this line ends a function, task, module, primitive or inter
3291 (verilog-kill-existing-comment)) 3261 (verilog-kill-existing-comment))
3292 (delete-horizontal-space) 3262 (delete-horizontal-space)
3293 (insert (concat " // " str )) 3263 (insert (concat " // " str ))
3294 (if err (ding 't)) 3264 (if err (ding 't))))
3295 ))
3296 3265
3297 (;- This is a begin..end block 3266 (;- This is a begin..end block
3298 (match-end 2) ;; of verilog-end-block-ordered-re 3267 (match-end 2) ;; of verilog-end-block-ordered-re
@@ -3628,19 +3597,25 @@ Useful for creating tri's and other expanded fields."
3628 (let ((signal-string (buffer-substring (point) 3597 (let ((signal-string (buffer-substring (point)
3629 (progn 3598 (progn
3630 (end-of-line) (point))))) 3599 (end-of-line) (point)))))
3631 (if (string-match (concat "\\(.*\\)" 3600 (if (string-match
3632 (regexp-quote bra) 3601 (concat "\\(.*\\)"
3633 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" 3602 (regexp-quote bra)
3603 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)"
3634 (regexp-quote ket) 3604 (regexp-quote ket)
3635 "\\(.*\\)$") signal-string) 3605 "\\(.*\\)$") signal-string)
3636 (let* ((sig-head (match-string 1 signal-string)) 3606 (let* ((sig-head (match-string 1 signal-string))
3637 (vec-start (string-to-int (match-string 2 signal-string))) 3607 (vec-start (string-to-number (match-string 2 signal-string)))
3638 (vec-end (if (= (match-beginning 3) (match-end 3)) 3608 (vec-end (if (= (match-beginning 3) (match-end 3))
3639 vec-start 3609 vec-start
3640 (string-to-int (substring signal-string (1+ (match-beginning 3)) (match-end 3))))) 3610 (string-to-number
3641 (vec-range (if (= (match-beginning 4) (match-end 4)) 3611 (substring signal-string (1+ (match-beginning 3))
3642 1 3612 (match-end 3)))))
3643 (string-to-int (substring signal-string (+ 2 (match-beginning 4)) (match-end 4))))) 3613 (vec-range
3614 (if (= (match-beginning 4) (match-end 4))
3615 1
3616 (string-to-number
3617 (substring signal-string (+ 2 (match-beginning 4))
3618 (match-end 4)))))
3644 (sig-tail (match-string 5 signal-string)) 3619 (sig-tail (match-string 5 signal-string))
3645 vec) 3620 vec)
3646 ;; Decode vectors 3621 ;; Decode vectors
@@ -3663,7 +3638,8 @@ Useful for creating tri's and other expanded fields."
3663 ;; 3638 ;;
3664 ;; Expand vector 3639 ;; Expand vector
3665 (while vec 3640 (while vec
3666 (insert (concat sig-head bra (int-to-string (car vec)) ket sig-tail "\n")) 3641 (insert (concat sig-head bra
3642 (int-to-string (car vec)) ket sig-tail "\n"))
3667 (setq vec (cdr vec))) 3643 (setq vec (cdr vec)))
3668 (delete-char -1) 3644 (delete-char -1)
3669 ;; 3645 ;;
@@ -3727,6 +3703,8 @@ See \\[verilog-surelint-off] and \\[verilog-verilint-off]."
3727 (verilog-verilint-off)) 3703 (verilog-verilint-off))
3728 (t (error "Linter name not set"))))) 3704 (t (error "Linter name not set")))))
3729 3705
3706(defvar compilation-last-buffer)
3707
3730(defun verilog-surelint-off () 3708(defun verilog-surelint-off ()
3731 "Convert a SureLint warning line into a disable statement. 3709 "Convert a SureLint warning line into a disable statement.
3732Run from Verilog source window; assumes there is a *compile* buffer 3710Run from Verilog source window; assumes there is a *compile* buffer
@@ -3737,56 +3715,61 @@ For example:
3737becomes: 3715becomes:
3738 // surefire lint_line_off UDDONX" 3716 // surefire lint_line_off UDDONX"
3739 (interactive) 3717 (interactive)
3740 (save-excursion 3718 (let ((buff (if (boundp 'next-error-last-buffer)
3741 (switch-to-buffer compilation-last-buffer) 3719 next-error-last-buffer
3742 (beginning-of-line) 3720 compilation-last-buffer)))
3743 (when 3721 (when (buffer-live-p buff)
3744 (looking-at "\\(INFO\\|WARNING\\|ERROR\\) \\[[^-]+-\\([^]]+\\)\\]: \\([^,]+\\), line \\([0-9]+\\): \\(.*\\)$") 3722 ;; FIXME with-current-buffer?
3745 (let* ((code (match-string 2)) 3723 (save-excursion
3746 (file (match-string 3)) 3724 (switch-to-buffer buff)
3747 (line (match-string 4)) 3725 (beginning-of-line)
3748 (buffer (get-file-buffer file)) 3726 (when
3749 dir filename) 3727 (looking-at "\\(INFO\\|WARNING\\|ERROR\\) \\[[^-]+-\\([^]]+\\)\\]: \\([^,]+\\), line \\([0-9]+\\): \\(.*\\)$")
3750 (unless buffer 3728 (let* ((code (match-string 2))
3751 (progn 3729 (file (match-string 3))
3752 (setq buffer 3730 (line (match-string 4))
3753 (and (file-exists-p file) 3731 (buffer (get-file-buffer file))
3754 (find-file-noselect file))) 3732 dir filename)
3755 (or buffer 3733 (unless buffer
3756 (let* ((pop-up-windows t)) 3734 (progn
3757 (let ((name (expand-file-name 3735 (setq buffer
3758 (read-file-name 3736 (and (file-exists-p file)
3759 (format "Find this error in: (default %s) " 3737 (find-file-noselect file)))
3760 file) 3738 (or buffer
3761 dir file t)))) 3739 (let* ((pop-up-windows t))
3762 (if (file-directory-p name) 3740 (let ((name (expand-file-name
3763 (setq name (expand-file-name filename name))) 3741 (read-file-name
3764 (setq buffer 3742 (format "Find this error in: (default %s) "
3765 (and (file-exists-p name) 3743 file)
3766 (find-file-noselect name)))))))) 3744 dir file t))))
3767 (switch-to-buffer buffer) 3745 (if (file-directory-p name)
3768 (goto-line (string-to-number line)) 3746 (setq name (expand-file-name filename name)))
3769 (end-of-line) 3747 (setq buffer
3770 (catch 'already 3748 (and (file-exists-p name)
3771 (cond 3749 (find-file-noselect name))))))))
3772 ((verilog-in-slash-comment-p) 3750 (switch-to-buffer buffer)
3773 (re-search-backward "//") 3751 (goto-line (string-to-number line))
3774 (cond 3752 (end-of-line)
3775 ((looking-at "// surefire lint_off_line ") 3753 (catch 'already
3776 (goto-char (match-end 0)) 3754 (cond
3777 (let ((lim (save-excursion (end-of-line) (point)))) 3755 ((verilog-in-slash-comment-p)
3778 (if (re-search-forward code lim 'move) 3756 (re-search-backward "//")
3779 (throw 'already t) 3757 (cond
3780 (insert-string (concat " " code))))) 3758 ((looking-at "// surefire lint_off_line ")
3781 (t 3759 (goto-char (match-end 0))
3782 ))) 3760 (let ((lim (save-excursion (end-of-line) (point))))
3783 ((verilog-in-star-comment-p) 3761 (if (re-search-forward code lim 'move)
3784 (re-search-backward "/\*") 3762 (throw 'already t)
3785 (insert-string (format " // surefire lint_off_line %6s" code )) 3763 (insert (concat " " code)))))
3786 ) 3764 (t
3787 (t 3765 )))
3788 (insert-string (format " // surefire lint_off_line %6s" code )) 3766 ((verilog-in-star-comment-p)
3789 ))))))) 3767 (re-search-backward "/\*")
3768 (insert (format " // surefire lint_off_line %6s" code ))
3769 )
3770 (t
3771 (insert (format " // surefire lint_off_line %6s" code ))
3772 )))))))))
3790 3773
3791(defun verilog-verilint-off () 3774(defun verilog-verilint-off ()
3792 "Convert a Verilint warning line into a disable statement. 3775 "Convert a Verilint warning line into a disable statement.
@@ -3839,18 +3822,19 @@ This lets programs calling batch mode to easily extract error messages."
3839 ;; Make sure any sub-files we read get proper mode 3822 ;; Make sure any sub-files we read get proper mode
3840 (setq default-major-mode `verilog-mode) 3823 (setq default-major-mode `verilog-mode)
3841 ;; Ditto files already read in 3824 ;; Ditto files already read in
3842 (mapcar '(lambda (buf) 3825 (mapc (lambda (buf)
3843 (when (buffer-file-name buf) 3826 (when (buffer-file-name buf)
3844 (save-excursion 3827 (save-excursion
3845 (set-buffer buf) 3828 (set-buffer buf)
3846 (verilog-mode)))) 3829 (verilog-mode))))
3847 (buffer-list)) 3830 (buffer-list))
3848 ;; Process the files 3831 ;; Process the files
3849 (mapcar '(lambda (buf) 3832 (mapcar '(lambda (buf)
3850 (when (buffer-file-name buf) 3833 (when (buffer-file-name buf)
3851 (save-excursion 3834 (save-excursion
3852 (if (not (file-exists-p (buffer-file-name buf))) 3835 (if (not (file-exists-p (buffer-file-name buf)))
3853 (error (concat "File not found: " (buffer-file-name buf)))) 3836 (error
3837 (concat "File not found: " (buffer-file-name buf))))
3854 (message (concat "Processing " (buffer-file-name buf))) 3838 (message (concat "Processing " (buffer-file-name buf)))
3855 (set-buffer buf) 3839 (set-buffer buf)
3856 (funcall funref) 3840 (funcall funref)
@@ -4121,8 +4105,7 @@ type. Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
4121 (save-excursion 4105 (save-excursion
4122 (verilog-beg-of-statement) 4106 (verilog-beg-of-statement)
4123 (if (= (point) here) 4107 (if (= (point) here)
4124 (throw 'nesting 'block)) 4108 (throw 'nesting 'block)))))
4125 )))
4126 (t (throw 'nesting 'block)))) 4109 (t (throw 'nesting 'block))))
4127 4110
4128 ((looking-at verilog-end-block-re) 4111 ((looking-at verilog-end-block-re)
@@ -4142,11 +4125,8 @@ type. Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
4142 (throw 'nesting 'cpp)) 4125 (throw 'nesting 'cpp))
4143 4126
4144 ((bobp) 4127 ((bobp)
4145 (throw 'nesting 'cpp)) 4128 (throw 'nesting 'cpp))))
4146 )) 4129 (throw 'nesting 'cpp)))
4147 (throw 'nesting 'cpp)
4148 )
4149 )
4150 4130
4151(defun verilog-calculate-indent-directive () 4131(defun verilog-calculate-indent-directive ()
4152 "Return indentation level for directive. 4132 "Return indentation level for directive.
@@ -4668,8 +4648,10 @@ Only look at a few lines to determine indent level."
4668 ((verilog-continued-line) 4648 ((verilog-continued-line)
4669 (let ((sp1 (point))) 4649 (let ((sp1 (point)))
4670 (if (verilog-continued-line) 4650 (if (verilog-continued-line)
4671 (progn (goto-char sp) 4651 (progn
4672 (setq indent-str (list 'statement (verilog-current-indent-level)))) 4652 (goto-char sp)
4653 (setq
4654 indent-str (list 'statement (verilog-current-indent-level))))
4673 (goto-char sp1) 4655 (goto-char sp1)
4674 (setq indent-str (list 'block (verilog-current-indent-level))))) 4656 (setq indent-str (list 'block (verilog-current-indent-level)))))
4675 (goto-char sp)) 4657 (goto-char sp))
@@ -5027,7 +5009,8 @@ ARG is ignored, for `comment-indent-function' compatibility."
5027 (setq e (point)) ;Might be on last line 5009 (setq e (point)) ;Might be on last line
5028 (verilog-forward-syntactic-ws) 5010 (verilog-forward-syntactic-ws)
5029 (beginning-of-line) 5011 (beginning-of-line)
5030 (while (and (not(looking-at (concat "^\\s-*" verilog-complete-reg))) 5012 (while (and (not (looking-at
5013 (concat "^\\s-*" verilog-complete-reg)))
5031 (looking-at myre)) 5014 (looking-at myre))
5032 (end-of-line) 5015 (end-of-line)
5033 (setq e (point)) 5016 (setq e (point))
@@ -5112,7 +5095,8 @@ BASEIND is the base indent to offset everything."
5112 (val) 5095 (val)
5113 (m1 (make-marker)) 5096 (m1 (make-marker))
5114 ) 5097 )
5115 (setq val (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) 5098 (setq val
5099 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
5116 (indent-line-to val) 5100 (indent-line-to val)
5117 5101
5118 ;; Use previous declaration (in this module) as template. 5102 ;; Use previous declaration (in this module) as template.
@@ -5127,7 +5111,9 @@ BASEIND is the base indent to offset everything."
5127 (skip-chars-forward " \t") 5111 (skip-chars-forward " \t")
5128 (setq ind (current-column)) 5112 (setq ind (current-column))
5129 (goto-char pos) 5113 (goto-char pos)
5130 (setq val (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) 5114 (setq val
5115 (+ baseind
5116 (eval (cdr (assoc 'declaration verilog-indent-alist)))))
5131 (indent-line-to val) 5117 (indent-line-to val)
5132 (if (and verilog-indent-declaration-macros 5118 (if (and verilog-indent-declaration-macros
5133 (looking-at verilog-declaration-re-2-macro)) 5119 (looking-at verilog-declaration-re-2-macro))
@@ -5159,14 +5145,8 @@ BASEIND is the base indent to offset everything."
5159 (if (/= (current-column) ind) 5145 (if (/= (current-column) ind)
5160 (progn 5146 (progn
5161 (just-one-space) 5147 (just-one-space)
5162 (indent-to ind)) 5148 (indent-to ind))))))))))
5163 ))) 5149 (goto-char pos)))
5164 )))
5165 )
5166 )
5167 (goto-char pos)
5168 )
5169 )
5170 5150
5171(defun verilog-get-lineup-indent (b edpos) 5151(defun verilog-get-lineup-indent (b edpos)
5172 "Return the indent level that will line up several lines within the region. 5152 "Return the indent level that will line up several lines within the region.
@@ -5677,7 +5657,8 @@ If search fails, other files are checked based on
5677 (progn 5657 (progn
5678 (save-excursion 5658 (save-excursion
5679 (goto-char (point-min)) 5659 (goto-char (point-min))
5680 (setq pt (re-search-forward (verilog-build-defun-re label t) nil t))) 5660 (setq pt
5661 (re-search-forward (verilog-build-defun-re label t) nil t)))
5681 (when pt 5662 (when pt
5682 (goto-char pt) 5663 (goto-char pt)
5683 (beginning-of-line)) 5664 (beginning-of-line))
@@ -5861,12 +5842,10 @@ Bound search by LIMIT. Adapted from
5861 (search-forward "<title>") 5842 (search-forward "<title>")
5862 (replace-match string t t) 5843 (replace-match string t t)
5863 (setq string (read-string "project: " verilog-project)) 5844 (setq string (read-string "project: " verilog-project))
5864 (make-variable-buffer-local 'verilog-project)
5865 (setq verilog-project string) 5845 (setq verilog-project string)
5866 (search-forward "<project>") 5846 (search-forward "<project>")
5867 (replace-match string t t) 5847 (replace-match string t t)
5868 (setq string (read-string "Company: " verilog-company)) 5848 (setq string (read-string "Company: " verilog-company))
5869 (make-variable-buffer-local 'verilog-company)
5870 (setq verilog-company string) 5849 (setq verilog-company string)
5871 (search-forward "<company>") 5850 (search-forward "<company>")
5872 (replace-match string t t) 5851 (replace-match string t t)
@@ -6021,10 +6000,11 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
6021 (setq bus (verilog-sig-bits sig)) 6000 (setq bus (verilog-sig-bits sig))
6022 (cond ((and bus 6001 (cond ((and bus
6023 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) 6002 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus)
6024 (setq highbit (string-to-int (match-string 1 bus)) 6003 (setq highbit (string-to-number (match-string 1 bus))
6025 lowbit (string-to-int (match-string 2 bus)))) 6004 lowbit (string-to-number
6005 (match-string 2 bus))))
6026 (and (string-match "\\[\\([0-9]+\\)\\]" bus) 6006 (and (string-match "\\[\\([0-9]+\\)\\]" bus)
6027 (setq highbit (string-to-int (match-string 1 bus)) 6007 (setq highbit (string-to-number (match-string 1 bus))
6028 lowbit highbit)))) 6008 lowbit highbit))))
6029 ;; Combine bits in bus 6009 ;; Combine bits in bus
6030 (if sv-highbit 6010 (if sv-highbit
@@ -6040,7 +6020,8 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
6040 (setq sig (car in-list)) 6020 (setq sig (car in-list))
6041 (cond ((and sig (equal sv-name (verilog-sig-name sig))) 6021 (cond ((and sig (equal sv-name (verilog-sig-name sig)))
6042 ;; Combine with this signal 6022 ;; Combine with this signal
6043 (when (and sv-busstring (not (equal sv-busstring (verilog-sig-bits sig)))) 6023 (when (and sv-busstring
6024 (not (equal sv-busstring (verilog-sig-bits sig))))
6044 (when nil ;; Debugging 6025 (when nil ;; Debugging
6045 (message (concat "Warning, can't merge into single bus " 6026 (message (concat "Warning, can't merge into single bus "
6046 sv-name bus 6027 sv-name bus
@@ -6056,10 +6037,12 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
6056 ;; Note sig may also be nil for the last signal in the list 6037 ;; Note sig may also be nil for the last signal in the list
6057 (t 6038 (t
6058 (setq out-list 6039 (setq out-list
6059 (cons (list sv-name 6040 (cons
6060 (or sv-busstring 6041 (list sv-name
6061 (if sv-highbit 6042 (or sv-busstring
6062 (concat "[" (int-to-string sv-highbit) ":" (int-to-string sv-lowbit) "]"))) 6043 (if sv-highbit
6044 (concat "[" (int-to-string sv-highbit) ":"
6045 (int-to-string sv-lowbit) "]")))
6063 (concat sv-comment combo buswarn) 6046 (concat sv-comment combo buswarn)
6064 sv-memory sv-enum sv-signed sv-type sv-multidim) 6047 sv-memory sv-enum sv-signed sv-type sv-multidim)
6065 out-list) 6048 out-list)
@@ -6292,9 +6275,44 @@ Return a array of [outputs inouts inputs wire reg assign const]."
6292 (nreverse sigs-gparam) 6275 (nreverse sigs-gparam)
6293 )))) 6276 ))))
6294 6277
6295(defvar sigs-in nil) ; Prevent compile warning 6278(defvar sigs-in) ; Prevent compile warning
6296(defvar sigs-inout nil) ; Prevent compile warning 6279(defvar sigs-inout) ; Prevent compile warning
6297(defvar sigs-out nil) ; Prevent compile warning 6280(defvar sigs-out) ; Prevent compile warning
6281
6282
6283(defsubst verilog-modi-get-decls (modi)
6284 (verilog-modi-cache-results modi 'verilog-read-decls))
6285
6286(defsubst verilog-modi-get-sub-decls (modi)
6287 (verilog-modi-cache-results modi 'verilog-read-sub-decls))
6288
6289
6290;; Signal reading for given module
6291;; Note these all take modi's - as returned from the
6292;; verilog-modi-current function.
6293(defsubst verilog-modi-get-outputs (modi)
6294 (aref (verilog-modi-get-decls modi) 0))
6295(defsubst verilog-modi-get-inouts (modi)
6296 (aref (verilog-modi-get-decls modi) 1))
6297(defsubst verilog-modi-get-inputs (modi)
6298 (aref (verilog-modi-get-decls modi) 2))
6299(defsubst verilog-modi-get-wires (modi)
6300 (aref (verilog-modi-get-decls modi) 3))
6301(defsubst verilog-modi-get-regs (modi)
6302 (aref (verilog-modi-get-decls modi) 4))
6303(defsubst verilog-modi-get-assigns (modi)
6304 (aref (verilog-modi-get-decls modi) 5))
6305(defsubst verilog-modi-get-consts (modi)
6306 (aref (verilog-modi-get-decls modi) 6))
6307(defsubst verilog-modi-get-gparams (modi)
6308 (aref (verilog-modi-get-decls modi) 7))
6309(defsubst verilog-modi-get-sub-outputs (modi)
6310 (aref (verilog-modi-get-sub-decls modi) 0))
6311(defsubst verilog-modi-get-sub-inouts (modi)
6312 (aref (verilog-modi-get-sub-decls modi) 1))
6313(defsubst verilog-modi-get-sub-inputs (modi)
6314 (aref (verilog-modi-get-sub-decls modi) 2))
6315
6298 6316
6299(defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim) 6317(defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim)
6300 "For verilog-read-sub-decls-line, add a signal." 6318 "For verilog-read-sub-decls-line, add a signal."
@@ -6506,11 +6524,10 @@ For example if declare A A (.B(SIG)) then B will be included in the list."
6506 (end-pt (point))) 6524 (end-pt (point)))
6507 (eval-region beg-pt end-pt nil))))) 6525 (eval-region beg-pt end-pt nil)))))
6508 6526
6509(eval-when-compile 6527;; These are passed in a let, not global
6510 ;; These are passed in a let, not global 6528(defvar got-sig)
6511 (if (not (boundp 'sigs-in)) 6529(defvar got-rvalue)
6512 (defvar sigs-in nil) (defvar sigs-out nil) 6530(defvar uses-delayed)
6513 (defvar got-sig nil) (defvar got-rvalue nil) (defvar uses-delayed nil)))
6514 6531
6515(defun verilog-read-always-signals-recurse 6532(defun verilog-read-always-signals-recurse
6516 (exit-keywd rvalue ignore-next) 6533 (exit-keywd rvalue ignore-next)
@@ -7033,10 +7050,10 @@ Some macros and such are also found and included. For dinotrace.el"
7033 "Convert `verilog-library-flags' into standard library variables." 7050 "Convert `verilog-library-flags' into standard library variables."
7034 ;; If the flags are local, then all the outputs should be local also 7051 ;; If the flags are local, then all the outputs should be local also
7035 (when (local-variable-p `verilog-library-flags (current-buffer)) 7052 (when (local-variable-p `verilog-library-flags (current-buffer))
7036 (make-variable-buffer-local 'verilog-library-extensions) 7053 (mapc 'make-local-variable '(verilog-library-extensions
7037 (make-variable-buffer-local 'verilog-library-directories) 7054 verilog-library-directories
7038 (make-variable-buffer-local 'verilog-library-files) 7055 verilog-library-files
7039 (make-variable-buffer-local 'verilog-library-flags)) 7056 verilog-library-flags)))
7040 ;; Allow user to customize 7057 ;; Allow user to customize
7041 (run-hooks 'verilog-before-getopt-flags-hook) 7058 (run-hooks 'verilog-before-getopt-flags-hook)
7042 ;; Process arguments 7059 ;; Process arguments
@@ -7061,11 +7078,8 @@ unless it is already a member of the variable's list"
7061 "Return point if MODULE is specified inside FILENAME, else nil. 7078 "Return point if MODULE is specified inside FILENAME, else nil.
7062Allows version control to check out the file if need be." 7079Allows version control to check out the file if need be."
7063 (and (or (file-exists-p filename) 7080 (and (or (file-exists-p filename)
7064 (and 7081 (and (fboundp 'vc-backend)
7065 (condition-case nil 7082 (vc-backend filename)))
7066 (fboundp 'vc-backend)
7067 (error nil))
7068 (vc-backend filename)))
7069 (let (pt) 7083 (let (pt)
7070 (save-excursion 7084 (save-excursion
7071 (set-buffer (find-file-noselect filename)) 7085 (set-buffer (find-file-noselect filename))
@@ -7224,6 +7238,8 @@ variables to build the path."
7224For speeding up verilog-modi-get-* commands. 7238For speeding up verilog-modi-get-* commands.
7225Buffer-local.") 7239Buffer-local.")
7226 7240
7241(make-variable-buffer-local 'verilog-modi-cache-list)
7242
7227(defvar verilog-modi-cache-preserve-tick nil 7243(defvar verilog-modi-cache-preserve-tick nil
7228 "Modification tick after which the cache is still considered valid. 7244 "Modification tick after which the cache is still considered valid.
7229Use verilog-preserve-cache's to set") 7245Use verilog-preserve-cache's to set")
@@ -7349,7 +7365,6 @@ Cache the output of function so next call may have faster access."
7349 (setq func-returns (funcall function)) 7365 (setq func-returns (funcall function))
7350 (when fontlocked (font-lock-mode t))) 7366 (when fontlocked (font-lock-mode t)))
7351 ;; Cache for next time 7367 ;; Cache for next time
7352 (make-variable-buffer-local 'verilog-modi-cache-list)
7353 (setq verilog-modi-cache-list 7368 (setq verilog-modi-cache-list
7354 (cons (list (list (verilog-modi-name modi) function) 7369 (cons (list (list (verilog-modi-name modi) function)
7355 (buffer-modified-tick) 7370 (buffer-modified-tick)
@@ -7384,37 +7399,6 @@ and invalidating the cache."
7384 (verilog-modi-cache-preserve-buffer (current-buffer))) 7399 (verilog-modi-cache-preserve-buffer (current-buffer)))
7385 (progn ,@body))) 7400 (progn ,@body)))
7386 7401
7387(defsubst verilog-modi-get-decls (modi)
7388 (verilog-modi-cache-results modi 'verilog-read-decls))
7389
7390(defsubst verilog-modi-get-sub-decls (modi)
7391 (verilog-modi-cache-results modi 'verilog-read-sub-decls))
7392
7393;; Signal reading for given module
7394;; Note these all take modi's - as returned from the verilog-modi-current function
7395(defsubst verilog-modi-get-outputs (modi)
7396 (aref (verilog-modi-get-decls modi) 0))
7397(defsubst verilog-modi-get-inouts (modi)
7398 (aref (verilog-modi-get-decls modi) 1))
7399(defsubst verilog-modi-get-inputs (modi)
7400 (aref (verilog-modi-get-decls modi) 2))
7401(defsubst verilog-modi-get-wires (modi)
7402 (aref (verilog-modi-get-decls modi) 3))
7403(defsubst verilog-modi-get-regs (modi)
7404 (aref (verilog-modi-get-decls modi) 4))
7405(defsubst verilog-modi-get-assigns (modi)
7406 (aref (verilog-modi-get-decls modi) 5))
7407(defsubst verilog-modi-get-consts (modi)
7408 (aref (verilog-modi-get-decls modi) 6))
7409(defsubst verilog-modi-get-gparams (modi)
7410 (aref (verilog-modi-get-decls modi) 7))
7411(defsubst verilog-modi-get-sub-outputs (modi)
7412 (aref (verilog-modi-get-sub-decls modi) 0))
7413(defsubst verilog-modi-get-sub-inouts (modi)
7414 (aref (verilog-modi-get-sub-decls modi) 1))
7415(defsubst verilog-modi-get-sub-inputs (modi)
7416 (aref (verilog-modi-get-sub-decls modi) 2))
7417
7418 7402
7419(defun verilog-signals-matching-enum (in-list enum) 7403(defun verilog-signals-matching-enum (in-list enum)
7420 "Return all signals in IN-LIST matching the given ENUM." 7404 "Return all signals in IN-LIST matching the given ENUM."
@@ -7603,13 +7587,15 @@ This repairs those mis-inserted by a AUTOARG."
7603 (setq range-exp (match-string 1 range-exp))) 7587 (setq range-exp (match-string 1 range-exp)))
7604 (cond ((not range-exp) 7588 (cond ((not range-exp)
7605 "1") 7589 "1")
7606 ((string-match "^\\s *\\([0-9]+\\)\\s *:\\s *\\([0-9]+\\)\\s *$" range-exp) 7590 ((string-match "^\\s *\\([0-9]+\\)\\s *:\\s *\\([0-9]+\\)\\s *$"
7607 (int-to-string (1+ (abs (- (string-to-int (match-string 1 range-exp)) 7591 range-exp)
7608 (string-to-int (match-string 2 range-exp))))))) 7592 (int-to-string
7593 (1+ (abs (- (string-to-number (match-string 1 range-exp))
7594 (string-to-number (match-string 2 range-exp)))))))
7609 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) 7595 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp)
7610 (concat "(1+(" (match-string 1 range-exp) 7596 (concat "(1+(" (match-string 1 range-exp) ")"
7611 ")" 7597 (if (equal "0" (match-string 2 range-exp))
7612 (if (equal "0" (match-string 2 range-exp)) ;; Don't bother with -(0) 7598 ;; Don't bother with -(0)
7613 "" 7599 ""
7614 (concat "-(" (match-string 2 range-exp) ")")) 7600 (concat "-(" (match-string 2 range-exp) ")"))
7615 ")")) 7601 ")"))
@@ -7928,7 +7914,7 @@ Typing \\[verilog-inject-auto] will make this into:
7928(defun verilog-auto-reeval-locals (&optional force) 7914(defun verilog-auto-reeval-locals (&optional force)
7929 "Read file local variable segment at bottom of file if it has changed. 7915 "Read file local variable segment at bottom of file if it has changed.
7930If FORCE, always reread it." 7916If FORCE, always reread it."
7931 (make-variable-buffer-local 'verilog-auto-last-file-locals) 7917 (make-local-variable 'verilog-auto-last-file-locals)
7932 (let ((curlocal (verilog-auto-read-locals))) 7918 (let ((curlocal (verilog-auto-read-locals)))
7933 (when (or force (not (equal verilog-auto-last-file-locals curlocal))) 7919 (when (or force (not (equal verilog-auto-last-file-locals curlocal)))
7934 (setq verilog-auto-last-file-locals curlocal) 7920 (setq verilog-auto-last-file-locals curlocal)
@@ -8435,10 +8421,12 @@ Lisp Templates:
8435 (when sig-list 8421 (when sig-list
8436 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 8422 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8437 (indent-to indent-pt) 8423 (indent-to indent-pt)
8438 (insert "// Outputs\n") ;; Note these are searched for in verilog-read-sub-decls 8424 ;; Note these are searched for in verilog-read-sub-decls.
8439 (mapcar (function (lambda (port) 8425 (insert "// Outputs\n")
8440 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star))) 8426 (mapc (lambda (port)
8441 sig-list))) 8427 (verilog-auto-inst-port port indent-pt
8428 tpl-list tpl-num for-star))
8429 sig-list)))
8442 (let ((sig-list (verilog-signals-not-in 8430 (let ((sig-list (verilog-signals-not-in
8443 (verilog-modi-get-inouts submodi) 8431 (verilog-modi-get-inouts submodi)
8444 skip-pins)) 8432 skip-pins))
@@ -8447,9 +8435,10 @@ Lisp Templates:
8447 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 8435 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8448 (indent-to indent-pt) 8436 (indent-to indent-pt)
8449 (insert "// Inouts\n") 8437 (insert "// Inouts\n")
8450 (mapcar (function (lambda (port) 8438 (mapc (lambda (port)
8451 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star))) 8439 (verilog-auto-inst-port port indent-pt
8452 sig-list))) 8440 tpl-list tpl-num for-star))
8441 sig-list)))
8453 (let ((sig-list (verilog-signals-not-in 8442 (let ((sig-list (verilog-signals-not-in
8454 (verilog-modi-get-inputs submodi) 8443 (verilog-modi-get-inputs submodi)
8455 skip-pins)) 8444 skip-pins))
@@ -8458,9 +8447,10 @@ Lisp Templates:
8458 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 8447 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8459 (indent-to indent-pt) 8448 (indent-to indent-pt)
8460 (insert "// Inputs\n") 8449 (insert "// Inputs\n")
8461 (mapcar (function (lambda (port) 8450 (mapc (lambda (port)
8462 (verilog-auto-inst-port port indent-pt tpl-list tpl-num for-star))) 8451 (verilog-auto-inst-port port indent-pt
8463 sig-list))) 8452 tpl-list tpl-num for-star))
8453 sig-list)))
8464 ;; Kill extra semi 8454 ;; Kill extra semi
8465 (save-excursion 8455 (save-excursion
8466 (cond (did-first 8456 (cond (did-first
@@ -8561,10 +8551,12 @@ Templates:
8561 (when sig-list 8551 (when sig-list
8562 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 8552 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
8563 (indent-to indent-pt) 8553 (indent-to indent-pt)
8564 (insert "// Parameters\n") ;; Note these are searched for in verilog-read-sub-decls 8554 ;; Note these are searched for in verilog-read-sub-decls.
8565 (mapcar (function (lambda (port) 8555 (insert "// Parameters\n")
8566 (verilog-auto-inst-port port indent-pt tpl-list tpl-num nil))) 8556 (mapc (lambda (port)
8567 sig-list))) 8557 (verilog-auto-inst-port port indent-pt
8558 tpl-list tpl-num nil))
8559 sig-list)))
8568 ;; Kill extra semi 8560 ;; Kill extra semi
8569 (save-excursion 8561 (save-excursion
8570 (cond (did-first 8562 (cond (did-first
@@ -9563,16 +9555,18 @@ being different from the final output's line numbering."
9563 (goto-char (point-min)) 9555 (goto-char (point-min))
9564 (while (search-forward "AUTO_TEMPLATE" nil t) 9556 (while (search-forward "AUTO_TEMPLATE" nil t)
9565 (setq templateno (1+ templateno)) 9557 (setq templateno (1+ templateno))
9566 (setq template-line (cons (count-lines (point-min) (point)) template-line))) 9558 (setq template-line
9559 (cons (count-lines (point-min) (point)) template-line)))
9567 (setq template-line (nreverse template-line)) 9560 (setq template-line (nreverse template-line))
9568 ;; Replace T# L# with absolute line number 9561 ;; Replace T# L# with absolute line number
9569 (goto-char (point-min)) 9562 (goto-char (point-min))
9570 (while (re-search-forward " Templated T\\([0-9]+\\) L\\([0-9]+\\)" nil t) 9563 (while (re-search-forward " Templated T\\([0-9]+\\) L\\([0-9]+\\)" nil t)
9571 (replace-match (concat " Templated " 9564 (replace-match
9572 (int-to-string (+ (nth (string-to-int (match-string 1)) 9565 (concat " Templated "
9573 template-line) 9566 (int-to-string (+ (nth (string-to-number (match-string 1))
9574 (string-to-int (match-string 2))))) 9567 template-line)
9575 t t)))) 9568 (string-to-number (match-string 2)))))
9569 t t))))
9576 9570
9577 9571
9578;; 9572;;
@@ -9636,7 +9630,7 @@ If you have bugs with these autos, try contacting the AUTOAUTHOR
9636Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com." 9630Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com."
9637 (interactive) 9631 (interactive)
9638 (unless noninteractive (message "Updating AUTOs...")) 9632 (unless noninteractive (message "Updating AUTOs..."))
9639 (if (featurep 'dinotrace) 9633 (if (fboundp 'dinotrace-unannotate-all)
9640 (dinotrace-unannotate-all)) 9634 (dinotrace-unannotate-all))
9641 (let ((oldbuf (if (not (buffer-modified-p)) 9635 (let ((oldbuf (if (not (buffer-modified-p))
9642 (buffer-string))) 9636 (buffer-string)))
@@ -9790,7 +9784,7 @@ Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com."
9790(defvar verilog-sk-reset nil) 9784(defvar verilog-sk-reset nil)
9791(defun verilog-sk-prompt-reset () 9785(defun verilog-sk-prompt-reset ()
9792 "Prompt for the name of a state machine reset." 9786 "Prompt for the name of a state machine reset."
9793 (setq verilog-sk-reset (read-input "name of reset: " "rst"))) 9787 (setq verilog-sk-reset (read-string "name of reset: " "rst")))
9794 9788
9795 9789
9796(define-skeleton verilog-sk-prompt-state-selector 9790(define-skeleton verilog-sk-prompt-state-selector
@@ -10235,6 +10229,8 @@ Files are checked based on `verilog-library-directories'."
10235 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") 10229 (princ "To submit a bug, use M-x verilog-submit-bug-report\n")
10236 (princ "\n"))) 10230 (princ "\n")))
10237 10231
10232(autoload 'reporter-submit-bug-report "reporter")
10233
10238(defun verilog-submit-bug-report () 10234(defun verilog-submit-bug-report ()
10239 "Submit via mail a bug report on verilog-mode.el." 10235 "Submit via mail a bug report on verilog-mode.el."
10240 (interactive) 10236 (interactive)