Mercurial > emacs
comparison lisp/progmodes/verilog-mode.el @ 87903:5d58981e6690
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1006
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 22 Jan 2008 23:53:46 +0000 |
parents | 107ccd98fa12 606faa750dd7 |
children | 5c60e04e322f |
comparison
equal
deleted
inserted
replaced
87902:2080d155f7aa | 87903:5d58981e6690 |
---|---|
9 ;; AUTO features, signal, modsig; by: Wilson Snyder | 9 ;; AUTO features, signal, modsig; by: Wilson Snyder |
10 ;; (wsnyder@wsnyder.org) | 10 ;; (wsnyder@wsnyder.org) |
11 ;; http://www.veripool.com | 11 ;; http://www.veripool.com |
12 ;; Keywords: languages | 12 ;; Keywords: languages |
13 | 13 |
14 ;; This code supports Emacs 21.1 and later | |
15 ;; And XEmacs 21.1 and later | |
16 ;; Please do not make changes that break Emacs 21. Thanks! | |
17 ;; | |
18 ;; | |
19 | |
14 ;; This file is part of GNU Emacs. | 20 ;; This file is part of GNU Emacs. |
15 | 21 |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | 22 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17 ;; it under the terms of the GNU General Public License as published by | 23 ;; it under the terms of the GNU General Public License as published by |
18 ;; the Free Software Foundation; either version 3, or (at your option) | 24 ;; the Free Software Foundation; either version 3, or (at your option) |
28 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 34 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
29 ;; Boston, MA 02110-1301, USA. | 35 ;; Boston, MA 02110-1301, USA. |
30 | 36 |
31 ;;; Commentary: | 37 ;;; Commentary: |
32 | 38 |
33 ;; This mode borrows heavily from the Pascal-mode and the cc-mode of emacs | 39 ;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs |
34 | 40 |
35 ;; USAGE | 41 ;; USAGE |
36 ;; ===== | 42 ;; ===== |
37 | 43 |
38 ;; A major mode for editing Verilog HDL source code. When you have | 44 ;; A major mode for editing Verilog HDL source code. When you have |
39 ;; entered Verilog mode, you may get more info by pressing C-h m. You | 45 ;; entered Verilog mode, you may get more info by pressing C-h m. You |
40 ;; may also get online help describing various functions by: C-h f | 46 ;; may also get online help describing various functions by: C-h f |
41 ;; <Name of function you want described> | 47 ;; <Name of function you want described> |
42 | 48 |
43 ;; KNOWN BUGS / BUG REPORTS | 49 ;; KNOWN BUGS / BUG REPORTS |
44 ;; ======================= | 50 ;; ======================= |
45 | 51 |
46 ;; Verilog is a rapidly evolving language, and hence this mode is | 52 ;; Verilog is a rapidly evolving language, and hence this mode is |
47 ;; under continuous development. Hence this is beta code, and likely | 53 ;; under continuous development. Hence this is beta code, and likely |
48 ;; has bugs. Please report any and all bugs to me at mac@verilog.com. | 54 ;; has bugs. Please report any and all bugs to me at mac@verilog.com. |
49 ;; Please use verilog-submit-bug-report to submit a report; type C-c | 55 ;; Please use verilog-submit-bug-report to submit a report; type C-c |
50 ;; C-b to invoke this and as a result I will have a much easier time | 56 ;; C-b to invoke this and as a result I will have a much easier time |
51 ;; of reproducing the bug you find, and hence fixing it. | 57 ;; of reproducing the bug you find, and hence fixing it. |
52 | 58 |
53 ;; INSTALLING THE MODE | 59 ;; INSTALLING THE MODE |
54 ;; =================== | 60 ;; =================== |
55 | 61 |
56 ;; An older version of this mode may be already installed as a part of | 62 ;; An older version of this mode may be already installed as a part of |
57 ;; your environment, and one method of updating would be to update | 63 ;; your environment, and one method of updating would be to update |
58 ;; your emacs environment. Sometimes this is difficult for local | 64 ;; your Emacs environment. Sometimes this is difficult for local |
59 ;; political/control reasons, and hence you can always install a | 65 ;; political/control reasons, and hence you can always install a |
60 ;; private copy (or even a shared copy) which overrides the system | 66 ;; private copy (or even a shared copy) which overrides the system |
61 ;; default. | 67 ;; default. |
62 | 68 |
63 ;; You can get step by step help in installing this file by going to | 69 ;; You can get step by step help in installing this file by going to |
72 ; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist)) | 78 ; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist)) |
73 ; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist)) | 79 ; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist)) |
74 | 80 |
75 ;; If you want to customize Verilog mode to fit your needs better, | 81 ;; If you want to customize Verilog mode to fit your needs better, |
76 ;; you may add these lines (the values of the variables presented | 82 ;; you may add these lines (the values of the variables presented |
77 ;; here are the defaults). Note also that if you use an emacs that | 83 ;; here are the defaults). Note also that if you use an Emacs that |
78 ;; supports custom, it's probably better to use the custom menu to | 84 ;; supports custom, it's probably better to use the custom menu to |
79 ;; edit these. | 85 ;; edit these. |
80 ;; | 86 ;; |
81 ;; Be sure to examine at the help for verilog-auto, and the other | 87 ;; Be sure to examine at the help for verilog-auto, and the other |
82 ;; verilog-auto-* functions for some major coding time savers. | 88 ;; verilog-auto-* functions for some major coding time savers. |
100 ; ) | 106 ; ) |
101 | 107 |
102 ;; | 108 ;; |
103 | 109 |
104 ;;; History: | 110 ;;; History: |
105 ;; | 111 ;; |
106 ;; | 112 ;; See commit history at http://www.veripool.com/verilog-mode.html |
113 ;; (This section is required to appease checkdoc.) | |
114 | |
107 ;;; Code: | 115 ;;; Code: |
108 | 116 |
109 ;; This variable will always hold the version number of the mode | 117 ;; This variable will always hold the version number of the mode |
110 (defconst verilog-mode-version "377" | 118 (defconst verilog-mode-version "383" |
111 "Version of this verilog mode.") | 119 "Version of this verilog mode.") |
112 (defconst verilog-mode-release-date "2007-12-07" | 120 (defconst verilog-mode-release-date "2008-01-07-GNU" |
113 "Version of this verilog mode.") | 121 "Release date of this verilog mode.") |
122 (defconst verilog-mode-release-emacs t | |
123 "If non-nil, this version of verilog mode was released with Emacs itself.") | |
114 | 124 |
115 (defun verilog-version () | 125 (defun verilog-version () |
116 "Inform caller of the version of this file." | 126 "Inform caller of the version of this file." |
117 (interactive) | 127 (interactive) |
118 (message "Using verilog-mode version %s" verilog-mode-version)) | 128 (message "Using verilog-mode version %s" verilog-mode-version)) |
119 | 129 |
120 ;; Insure we have certain packages, and deal with it if we don't | 130 ;; Insure we have certain packages, and deal with it if we don't |
131 ;; Be sure to note which Emacs flavor and version added each feature. | |
121 (eval-when-compile | 132 (eval-when-compile |
133 ;; The below were disabled when GNU Emacs 22 was released; | |
134 ;; perhaps some still need to be there to support Emacs 21. | |
122 (when (featurep 'xemacs) | 135 (when (featurep 'xemacs) |
123 (condition-case nil | 136 (condition-case nil |
124 (require 'easymenu) | 137 (require 'easymenu) |
125 (error nil)) | 138 (error nil)) |
126 (condition-case nil | 139 (condition-case nil |
179 (match-beginning num) (match-end num)))) | 192 (match-beginning num) (match-end num)))) |
180 (set-text-properties 0 (length result) nil result) | 193 (set-text-properties 0 (length result) nil result) |
181 result) | 194 result) |
182 (buffer-substring-no-properties (match-beginning num) | 195 (buffer-substring-no-properties (match-beginning num) |
183 (match-end num) | 196 (match-end num) |
184 (current-buffer) | 197 (current-buffer))))) |
185 ))))) | 198 ) |
186 (error nil)) | 199 (error nil)) |
187 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) | 200 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
188 nil ;; We've got what we needed | 201 nil ;; We've got what we needed |
189 ;; We have the old custom-library, hack around it! | 202 ;; We have the old custom-library, hack around it! |
190 (defmacro defgroup (&rest args) nil) | 203 (defmacro defgroup (&rest args) nil) |
208 ))) | 221 ))) |
209 | 222 |
210 ;; Provide a regular expression optimization routine, using regexp-opt | 223 ;; Provide a regular expression optimization routine, using regexp-opt |
211 ;; if provided by the user's elisp libraries | 224 ;; if provided by the user's elisp libraries |
212 (eval-and-compile | 225 (eval-and-compile |
226 ;; The below were disabled when GNU Emacs 22 was released; | |
227 ;; perhaps some still need to be there to support Emacs 21. | |
213 (if (featurep 'xemacs) | 228 (if (featurep 'xemacs) |
214 (if (fboundp 'regexp-opt) | 229 (if (fboundp 'regexp-opt) |
215 ;; regexp-opt is defined, does it take 3 or 2 arguments? | 230 ;; regexp-opt is defined, does it take 3 or 2 arguments? |
216 (if (fboundp 'function-max-args) | 231 (if (fboundp 'function-max-args) |
217 (let ((args (function-max-args `regexp-opt))) | 232 (let ((args (function-max-args `regexp-opt))) |
220 (condition-case nil ; Hide this defun from emacses | 235 (condition-case nil ; Hide this defun from emacses |
221 ;with just a two input regexp | 236 ;with just a two input regexp |
222 (defun verilog-regexp-opt (a b) | 237 (defun verilog-regexp-opt (a b) |
223 "Deal with differing number of required arguments for `regexp-opt'. | 238 "Deal with differing number of required arguments for `regexp-opt'. |
224 Call 'regexp-opt' on A and B." | 239 Call 'regexp-opt' on A and B." |
225 (regexp-opt a b 't) | 240 (regexp-opt a b 't)) |
226 ) | |
227 (error nil)) | 241 (error nil)) |
228 ) | 242 ) |
229 ((eq args 2) ;; It takes 2 | 243 ((eq args 2) ;; It takes 2 |
230 (defun verilog-regexp-opt (a b) | 244 (defun verilog-regexp-opt (a b) |
231 "Call 'regexp-opt' on A and B." | 245 "Call 'regexp-opt' on A and B." |
259 "Link to customize fonts used for Verilog." | 273 "Link to customize fonts used for Verilog." |
260 (interactive) | 274 (interactive) |
261 (if (fboundp 'customize-apropos) | 275 (if (fboundp 'customize-apropos) |
262 (customize-apropos "font-lock-*" 'faces))) | 276 (customize-apropos "font-lock-*" 'faces))) |
263 | 277 |
278 (defun verilog-booleanp (value) | |
279 "Return t if VALUE is boolean. | |
280 This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs. | |
281 This function may be removed when Emacs 21 is no longer supported." | |
282 (or (equal value t) (equal value nil))) | |
283 | |
264 (defgroup verilog-mode nil | 284 (defgroup verilog-mode nil |
265 "Facilitates easy editing of Verilog source text" | 285 "Facilitates easy editing of Verilog source text" |
266 :group 'languages) | 286 :group 'languages) |
267 | 287 |
268 ; (defgroup verilog-mode-fonts nil | 288 ; (defgroup verilog-mode-fonts nil |
288 Depending on the `verilog-set-compile-command', this may be invoked when | 308 Depending on the `verilog-set-compile-command', this may be invoked when |
289 you type \\[compile]. When the compile completes, \\[next-error] will take | 309 you type \\[compile]. When the compile completes, \\[next-error] will take |
290 you to the next lint error." | 310 you to the next lint error." |
291 :type 'string | 311 :type 'string |
292 :group 'verilog-mode-actions) | 312 :group 'verilog-mode-actions) |
313 ;; We don't mark it safe, as it's used as a shell command | |
293 | 314 |
294 (defcustom verilog-coverage | 315 (defcustom verilog-coverage |
295 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" | 316 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" |
296 "*Program and arguments to use to annotate for coverage verilog source. | 317 "*Program and arguments to use to annotate for coverage verilog source. |
297 Depending on the `verilog-set-compile-command', this may be invoked when | 318 Depending on the `verilog-set-compile-command', this may be invoked when |
298 you type \\[compile]. When the compile completes, \\[next-error] will take | 319 you type \\[compile]. When the compile completes, \\[next-error] will take |
299 you to the next lint error." | 320 you to the next lint error." |
300 :type 'string | 321 :type 'string |
301 :group 'verilog-mode-actions) | 322 :group 'verilog-mode-actions) |
323 ;; We don't mark it safe, as it's used as a shell command | |
302 | 324 |
303 (defcustom verilog-simulator | 325 (defcustom verilog-simulator |
304 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" | 326 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" |
305 "*Program and arguments to use to interpret verilog source. | 327 "*Program and arguments to use to interpret verilog source. |
306 Depending on the `verilog-set-compile-command', this may be invoked when | 328 Depending on the `verilog-set-compile-command', this may be invoked when |
307 you type \\[compile]. When the compile completes, \\[next-error] will take | 329 you type \\[compile]. When the compile completes, \\[next-error] will take |
308 you to the next lint error." | 330 you to the next lint error." |
309 :type 'string | 331 :type 'string |
310 :group 'verilog-mode-actions) | 332 :group 'verilog-mode-actions) |
333 ;; We don't mark it safe, as it's used as a shell command | |
311 | 334 |
312 (defcustom verilog-compiler | 335 (defcustom verilog-compiler |
313 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" | 336 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" |
314 "*Program and arguments to use to compile verilog source. | 337 "*Program and arguments to use to compile verilog source. |
315 Depending on the `verilog-set-compile-command', this may be invoked when | 338 Depending on the `verilog-set-compile-command', this may be invoked when |
316 you type \\[compile]. When the compile completes, \\[next-error] will take | 339 you type \\[compile]. When the compile completes, \\[next-error] will take |
317 you to the next lint error." | 340 you to the next lint error." |
318 :type 'string | 341 :type 'string |
319 :group 'verilog-mode-actions) | 342 :group 'verilog-mode-actions) |
343 ;; We don't mark it safe, as it's used as a shell command | |
320 | 344 |
321 (defvar verilog-tool 'verilog-linter | 345 (defvar verilog-tool 'verilog-linter |
322 "Which tool to use for building compiler-command. | 346 "Which tool to use for building compiler-command. |
323 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | 347 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or |
324 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | 348 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" |
334 | 358 |
335 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | 359 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu |
336 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." | 360 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." |
337 :type 'boolean | 361 :type 'boolean |
338 :group 'verilog-mode-indent) | 362 :group 'verilog-mode-indent) |
363 ;; Note we don't use :safe, as that would break on Emacsen before 22.0. | |
364 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp) | |
339 | 365 |
340 (defcustom verilog-indent-level 3 | 366 (defcustom verilog-indent-level 3 |
341 "*Indentation of Verilog statements with respect to containing block." | 367 "*Indentation of Verilog statements with respect to containing block." |
342 :group 'verilog-mode-indent | 368 :group 'verilog-mode-indent |
343 :type 'integer) | 369 :type 'integer) |
370 (put 'verilog-indent-level 'safe-local-variable 'integerp) | |
344 | 371 |
345 (defcustom verilog-indent-level-module 3 | 372 (defcustom verilog-indent-level-module 3 |
346 "*Indentation of Module level Verilog statements. (eg always, initial) | 373 "*Indentation of Module level Verilog statements. (eg always, initial) |
347 Set to 0 to get initial and always statements lined up on the left side of | 374 Set to 0 to get initial and always statements lined up on the left side of |
348 your screen." | 375 your screen." |
349 :group 'verilog-mode-indent | 376 :group 'verilog-mode-indent |
350 :type 'integer) | 377 :type 'integer) |
378 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) | |
351 | 379 |
352 (defcustom verilog-indent-level-declaration 3 | 380 (defcustom verilog-indent-level-declaration 3 |
353 "*Indentation of declarations with respect to containing block. | 381 "*Indentation of declarations with respect to containing block. |
354 Set to 0 to get them list right under containing block." | 382 Set to 0 to get them list right under containing block." |
355 :group 'verilog-mode-indent | 383 :group 'verilog-mode-indent |
356 :type 'integer) | 384 :type 'integer) |
385 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) | |
357 | 386 |
358 (defcustom verilog-indent-declaration-macros nil | 387 (defcustom verilog-indent-declaration-macros nil |
359 "*How to treat macro expansions in a declaration. | 388 "*How to treat macro expansions in a declaration. |
360 If nil, indent as: | 389 If nil, indent as: |
361 input [31:0] a; | 390 input [31:0] a; |
365 input [31:0] a; | 394 input [31:0] a; |
366 input `CP ; | 395 input `CP ; |
367 output c;" | 396 output c;" |
368 :group 'verilog-mode-indent | 397 :group 'verilog-mode-indent |
369 :type 'boolean) | 398 :type 'boolean) |
399 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp) | |
370 | 400 |
371 (defcustom verilog-indent-lists t | 401 (defcustom verilog-indent-lists t |
372 "*How to treat indenting items in a list. | 402 "*How to treat indenting items in a list. |
373 If t (the default), indent as: | 403 If t (the default), indent as: |
374 always @( posedge a or | 404 always @( posedge a or |
377 If nil, treat as: | 407 If nil, treat as: |
378 always @( posedge a or | 408 always @( posedge a or |
379 reset ) begin" | 409 reset ) begin" |
380 :group 'verilog-mode-indent | 410 :group 'verilog-mode-indent |
381 :type 'boolean) | 411 :type 'boolean) |
412 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp) | |
382 | 413 |
383 (defcustom verilog-indent-level-behavioral 3 | 414 (defcustom verilog-indent-level-behavioral 3 |
384 "*Absolute indentation of first begin in a task or function block. | 415 "*Absolute indentation of first begin in a task or function block. |
385 Set to 0 to get such code to start at the left side of the screen." | 416 Set to 0 to get such code to start at the left side of the screen." |
386 :group 'verilog-mode-indent | 417 :group 'verilog-mode-indent |
387 :type 'integer) | 418 :type 'integer) |
419 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) | |
388 | 420 |
389 (defcustom verilog-indent-level-directive 1 | 421 (defcustom verilog-indent-level-directive 1 |
390 "*Indentation to add to each level of `ifdef declarations. | 422 "*Indentation to add to each level of `ifdef declarations. |
391 Set to 0 to have all directives start at the left side of the screen." | 423 Set to 0 to have all directives start at the left side of the screen." |
392 :group 'verilog-mode-indent | 424 :group 'verilog-mode-indent |
393 :type 'integer) | 425 :type 'integer) |
426 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) | |
394 | 427 |
395 (defcustom verilog-cexp-indent 2 | 428 (defcustom verilog-cexp-indent 2 |
396 "*Indentation of Verilog statements split across lines." | 429 "*Indentation of Verilog statements split across lines." |
397 :group 'verilog-mode-indent | 430 :group 'verilog-mode-indent |
398 :type 'integer) | 431 :type 'integer) |
432 (put 'verilog-cexp-indent 'safe-local-variable 'integerp) | |
399 | 433 |
400 (defcustom verilog-case-indent 2 | 434 (defcustom verilog-case-indent 2 |
401 "*Indentation for case statements." | 435 "*Indentation for case statements." |
402 :group 'verilog-mode-indent | 436 :group 'verilog-mode-indent |
403 :type 'integer) | 437 :type 'integer) |
438 (put 'verilog-case-indent 'safe-local-variable 'integerp) | |
404 | 439 |
405 (defcustom verilog-auto-newline t | 440 (defcustom verilog-auto-newline t |
406 "*True means automatically newline after semicolons." | 441 "*True means automatically newline after semicolons." |
407 :group 'verilog-mode-indent | 442 :group 'verilog-mode-indent |
408 :type 'boolean) | 443 :type 'boolean) |
444 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp) | |
409 | 445 |
410 (defcustom verilog-auto-indent-on-newline t | 446 (defcustom verilog-auto-indent-on-newline t |
411 "*True means automatically indent line after newline." | 447 "*True means automatically indent line after newline." |
412 :group 'verilog-mode-indent | 448 :group 'verilog-mode-indent |
413 :type 'boolean) | 449 :type 'boolean) |
450 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp) | |
414 | 451 |
415 (defcustom verilog-tab-always-indent t | 452 (defcustom verilog-tab-always-indent t |
416 "*True means TAB should always re-indent the current line. | 453 "*True means TAB should always re-indent the current line. |
417 Nil means TAB will only reindent when at the beginning of the line." | 454 Nil means TAB will only reindent when at the beginning of the line." |
418 :group 'verilog-mode-indent | 455 :group 'verilog-mode-indent |
419 :type 'boolean) | 456 :type 'boolean) |
457 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp) | |
420 | 458 |
421 (defcustom verilog-tab-to-comment nil | 459 (defcustom verilog-tab-to-comment nil |
422 "*True means TAB moves to the right hand column in preparation for a comment." | 460 "*True means TAB moves to the right hand column in preparation for a comment." |
423 :group 'verilog-mode-actions | 461 :group 'verilog-mode-actions |
424 :type 'boolean) | 462 :type 'boolean) |
463 (put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp) | |
425 | 464 |
426 (defcustom verilog-indent-begin-after-if t | 465 (defcustom verilog-indent-begin-after-if t |
427 "*If true, indent begin statements following if, else, while, for and repeat. | 466 "*If true, indent begin statements following if, else, while, for and repeat. |
428 Otherwise, line them up." | 467 Otherwise, line them up." |
429 :group 'verilog-mode-indent | 468 :group 'verilog-mode-indent |
430 :type 'boolean ) | 469 :type 'boolean) |
470 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp) | |
431 | 471 |
432 | 472 |
433 (defcustom verilog-align-ifelse nil | 473 (defcustom verilog-align-ifelse nil |
434 "*If true, align `else' under matching `if'. | 474 "*If true, align `else' under matching `if'. |
435 Otherwise else is lined up with first character on line holding matching if." | 475 Otherwise else is lined up with first character on line holding matching if." |
436 :group 'verilog-mode-indent | 476 :group 'verilog-mode-indent |
437 :type 'boolean ) | 477 :type 'boolean) |
478 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp) | |
438 | 479 |
439 (defcustom verilog-minimum-comment-distance 10 | 480 (defcustom verilog-minimum-comment-distance 10 |
440 "*Minimum distance (in lines) between begin and end required before a comment. | 481 "*Minimum distance (in lines) between begin and end required before a comment. |
441 Setting this variable to zero results in every end acquiring a comment; the | 482 Setting this variable to zero results in every end acquiring a comment; the |
442 default avoids too many redundant comments in tight quarters" | 483 default avoids too many redundant comments in tight quarters" |
443 :group 'verilog-mode-indent | 484 :group 'verilog-mode-indent |
444 :type 'integer) | 485 :type 'integer) |
486 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) | |
445 | 487 |
446 (defcustom verilog-auto-lineup '(declaration) | 488 (defcustom verilog-auto-lineup '(declaration) |
447 "*Algorithm for lining up statements on multiple lines. | 489 "*Algorithm for lining up statements on multiple lines. |
448 | 490 |
449 If this list contains the symbol 'all', then all line ups described below | 491 If this list contains the symbol 'all', then all line ups described below |
479 ; b : a = 4; | 521 ; b : a = 4; |
480 ; endcase | 522 ; endcase |
481 ; | 523 ; |
482 | 524 |
483 :group 'verilog-mode-indent | 525 :group 'verilog-mode-indent |
484 :type 'list ) | 526 :type 'list) |
527 (put 'verilog-auto-lineup 'safe-local-variable 'listp) | |
485 | 528 |
486 (defcustom verilog-highlight-p1800-keywords nil | 529 (defcustom verilog-highlight-p1800-keywords nil |
487 "*If true highlight words newly reserved by IEEE-1800 in | 530 "*True means highlight words newly reserved by IEEE-1800. |
488 verilog-font-lock-p1800-face in order to gently suggest changing where | 531 These will appear in `verilog-font-lock-p1800-face' in order to gently |
489 these words are used as variables to something else. Nil means highlight | 532 suggest changing where these words are used as variables to something else. |
490 these words as appropriate for the SystemVerilog IEEE-1800 standard. Note | 533 Nil means highlight these words as appropriate for the SystemVerilog |
491 that changing this will require restarting emacs to see the effect as font | 534 IEEE-1800 standard. Note that changing this will require restarting Emacs |
492 color choices are cached by emacs" | 535 to see the effect as font color choices are cached by Emacs" |
493 :group 'verilog-mode-indent | 536 :group 'verilog-mode-indent |
494 :type 'boolean) | 537 :type 'boolean) |
538 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp) | |
495 | 539 |
496 (defcustom verilog-auto-endcomments t | 540 (defcustom verilog-auto-endcomments t |
497 "*True means insert a comment /* ... */ after 'end's. | 541 "*True means insert a comment /* ... */ after 'end's. |
498 The name of the function or case will be set between the braces." | 542 The name of the function or case will be set between the braces." |
499 :group 'verilog-mode-actions | 543 :group 'verilog-mode-actions |
500 :type 'boolean ) | 544 :type 'boolean) |
545 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) | |
501 | 546 |
502 (defcustom verilog-auto-read-includes nil | 547 (defcustom verilog-auto-read-includes nil |
503 "*True means to automatically read includes before AUTOs. | 548 "*True means to automatically read includes before AUTOs. |
504 This will do a `verilog-read-defines' and `verilog-read-includes' before | 549 This will do a `verilog-read-defines' and `verilog-read-includes' before |
505 each AUTO expansion. This makes it easier to embed defines and includes, | 550 each AUTO expansion. This makes it easier to embed defines and includes, |
506 but can result in very slow reading times if there are many or large | 551 but can result in very slow reading times if there are many or large |
507 include files." | 552 include files." |
508 :group 'verilog-mode-actions | 553 :group 'verilog-mode-actions |
509 :type 'boolean ) | 554 :type 'boolean) |
555 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp) | |
510 | 556 |
511 (defcustom verilog-auto-save-policy nil | 557 (defcustom verilog-auto-save-policy nil |
512 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | 558 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. |
513 A value of `force' will always do a \\[verilog-auto] automatically if | 559 A value of `force' will always do a \\[verilog-auto] automatically if |
514 needed on every save. A value of `detect' will do \\[verilog-auto] | 560 needed on every save. A value of `detect' will do \\[verilog-auto] |
525 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | 571 "*Non-nil indicates to expand a SystemVerilog .* instance ports. |
526 They will be expanded in the same way as if there was a AUTOINST in the | 572 They will be expanded in the same way as if there was a AUTOINST in the |
527 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." | 573 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." |
528 :group 'verilog-mode-actions | 574 :group 'verilog-mode-actions |
529 :type 'boolean) | 575 :type 'boolean) |
576 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp) | |
530 | 577 |
531 (defcustom verilog-auto-star-save nil | 578 (defcustom verilog-auto-star-save nil |
532 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. | 579 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. |
533 Nil indicates direct connections will be removed before saving. Only | 580 Nil indicates direct connections will be removed before saving. Only |
534 meaningful to those created due to `verilog-auto-star-expand' being set. | 581 meaningful to those created due to `verilog-auto-star-expand' being set. |
535 | 582 |
536 Instead of setting this, you may want to use /*AUTOINST*/, which will | 583 Instead of setting this, you may want to use /*AUTOINST*/, which will |
537 always be saved." | 584 always be saved." |
538 :group 'verilog-mode-actions | 585 :group 'verilog-mode-actions |
539 :type 'boolean) | 586 :type 'boolean) |
587 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp) | |
540 | 588 |
541 (defvar verilog-auto-update-tick nil | 589 (defvar verilog-auto-update-tick nil |
542 "Modification tick at which autos were last performed.") | 590 "Modification tick at which autos were last performed.") |
543 | 591 |
544 (defvar verilog-auto-last-file-locals nil | 592 (defvar verilog-auto-last-file-locals nil |
622 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | 670 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) |
623 ; Leda | 671 ; Leda |
624 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | 672 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) |
625 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) | 673 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) |
626 ) | 674 ) |
627 "*Keywords to also highlight in Verilog *compilation* buffers." | 675 "*Keywords to also highlight in Verilog *compilation* buffers.") |
628 ) | |
629 | 676 |
630 (defcustom verilog-library-flags '("") | 677 (defcustom verilog-library-flags '("") |
631 "*List of standard Verilog arguments to use for /*AUTOINST*/. | 678 "*List of standard Verilog arguments to use for /*AUTOINST*/. |
632 These arguments are used to find files for `verilog-auto', and match | 679 These arguments are used to find files for `verilog-auto', and match |
633 the flags accepted by a standard Verilog-XL simulator. | 680 the flags accepted by a standard Verilog-XL simulator. |
654 have problems, use \\[find-alternate-file] RET to have these take effect. | 701 have problems, use \\[find-alternate-file] RET to have these take effect. |
655 | 702 |
656 See also the variables mentioned above." | 703 See also the variables mentioned above." |
657 :group 'verilog-mode-auto | 704 :group 'verilog-mode-auto |
658 :type '(repeat string)) | 705 :type '(repeat string)) |
706 (put 'verilog-library-flags 'safe-local-variable 'listp) | |
659 | 707 |
660 (defcustom verilog-library-directories '(".") | 708 (defcustom verilog-library-directories '(".") |
661 "*List of directories when looking for files for /*AUTOINST*/. | 709 "*List of directories when looking for files for /*AUTOINST*/. |
662 The directory may be relative to the current file, or absolute. | 710 The directory may be relative to the current file, or absolute. |
663 Environment variables are also expanded in the directory names. | 711 Environment variables are also expanded in the directory names. |
676 | 724 |
677 See also `verilog-library-flags', `verilog-library-files' | 725 See also `verilog-library-flags', `verilog-library-files' |
678 and `verilog-library-extensions'." | 726 and `verilog-library-extensions'." |
679 :group 'verilog-mode-auto | 727 :group 'verilog-mode-auto |
680 :type '(repeat file)) | 728 :type '(repeat file)) |
729 (put 'verilog-library-directories 'safe-local-variable 'listp) | |
681 | 730 |
682 (defcustom verilog-library-files '() | 731 (defcustom verilog-library-files '() |
683 "*List of files to search for modules when looking for AUTOINST files. | 732 "*List of files to search for modules. |
733 AUTOINST will use this when it needs to resolve a module name. | |
684 This is a complete path, usually to a technology file with many standard | 734 This is a complete path, usually to a technology file with many standard |
685 cells defined in it. | 735 cells defined in it. |
686 | 736 |
687 You might want these defined in each file; put at the *END* of your file | 737 You might want these defined in each file; put at the *END* of your file |
688 something like: | 738 something like: |
696 have problems, use \\[find-alternate-file] RET to have these take effect. | 746 have problems, use \\[find-alternate-file] RET to have these take effect. |
697 | 747 |
698 See also `verilog-library-flags', `verilog-library-directories'." | 748 See also `verilog-library-flags', `verilog-library-directories'." |
699 :group 'verilog-mode-auto | 749 :group 'verilog-mode-auto |
700 :type '(repeat directory)) | 750 :type '(repeat directory)) |
751 (put 'verilog-library-files 'safe-local-variable 'listp) | |
701 | 752 |
702 (defcustom verilog-library-extensions '(".v") | 753 (defcustom verilog-library-extensions '(".v") |
703 "*List of extensions to use when looking for files for /*AUTOINST*/. | 754 "*List of extensions to use when looking for files for /*AUTOINST*/. |
704 See also `verilog-library-flags', `verilog-library-directories'." | 755 See also `verilog-library-flags', `verilog-library-directories'." |
705 :type '(repeat string) | 756 :type '(repeat string) |
706 :group 'verilog-mode-auto) | 757 :group 'verilog-mode-auto) |
758 (put 'verilog-library-extensions 'safe-local-variable 'listp) | |
707 | 759 |
708 (defcustom verilog-active-low-regexp nil | 760 (defcustom verilog-active-low-regexp nil |
709 "*If set, treat signals matching this regexp as active low. | 761 "*If set, treat signals matching this regexp as active low. |
710 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | 762 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, |
711 you will probably also need `verilog-auto-reset-widths' set." | 763 you will probably also need `verilog-auto-reset-widths' set." |
712 :group 'verilog-mode-auto | 764 :group 'verilog-mode-auto |
713 :type 'string) | 765 :type 'string) |
766 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) | |
714 | 767 |
715 (defcustom verilog-auto-sense-include-inputs nil | 768 (defcustom verilog-auto-sense-include-inputs nil |
716 "*If true, AUTOSENSE should include all inputs. | 769 "*If true, AUTOSENSE should include all inputs. |
717 If nil, only inputs that are NOT output signals in the same block are | 770 If nil, only inputs that are NOT output signals in the same block are |
718 included." | 771 included." |
719 :type 'boolean | 772 :group 'verilog-mode-auto |
720 :group 'verilog-mode-auto) | 773 :type 'boolean) |
774 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp) | |
721 | 775 |
722 (defcustom verilog-auto-sense-defines-constant nil | 776 (defcustom verilog-auto-sense-defines-constant nil |
723 "*If true, AUTOSENSE should assume all defines represent constants. | 777 "*If true, AUTOSENSE should assume all defines represent constants. |
724 When true, the defines will not be included in sensitivity lists. To | 778 When true, the defines will not be included in sensitivity lists. To |
725 maintain compatibility with other sites, this should be set at the bottom | 779 maintain compatibility with other sites, this should be set at the bottom |
726 of each verilog file that requires it, rather than being set globally." | 780 of each verilog file that requires it, rather than being set globally." |
727 :type 'boolean | 781 :group 'verilog-mode-auto |
728 :group 'verilog-mode-auto) | 782 :type 'boolean) |
783 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) | |
729 | 784 |
730 (defcustom verilog-auto-reset-widths t | 785 (defcustom verilog-auto-reset-widths t |
731 "*If true, AUTORESET should determine the width of signals. | 786 "*If true, AUTORESET should determine the width of signals. |
732 This is then used to set the width of the zero (32'h0 for example). This | 787 This is then used to set the width of the zero (32'h0 for example). This |
733 is required by some lint tools that aren't smart enough to ignore widths of | 788 is required by some lint tools that aren't smart enough to ignore widths of |
734 the constant zero. This may result in ugly code when parameters determine | 789 the constant zero. This may result in ugly code when parameters determine |
735 the MSB or LSB of a signal inside a AUTORESET." | 790 the MSB or LSB of a signal inside a AUTORESET." |
736 :type 'boolean | 791 :type 'boolean |
737 :group 'verilog-mode-auto) | 792 :group 'verilog-mode-auto) |
793 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp) | |
738 | 794 |
739 (defcustom verilog-assignment-delay "" | 795 (defcustom verilog-assignment-delay "" |
740 "*Text used for delays in delayed assignments. Add a trailing space if set." | 796 "*Text used for delays in delayed assignments. Add a trailing space if set." |
741 :type 'string | 797 :group 'verilog-mode-auto |
742 :group 'verilog-mode-auto) | 798 :type 'string) |
799 (put 'verilog-assignment-delay 'safe-local-variable 'stringp) | |
743 | 800 |
744 (defcustom verilog-auto-inst-vector t | 801 (defcustom verilog-auto-inst-vector t |
745 "*If true, when creating default ports with AUTOINST, use bus subscripts. | 802 "*If true, when creating default ports with AUTOINST, use bus subscripts. |
746 If nil, skip the subscript when it matches the entire bus as declared in | 803 If nil, skip the subscript when it matches the entire bus as declared in |
747 the module (AUTOWIRE signals always are subscripted, you must manually | 804 the module (AUTOWIRE signals always are subscripted, you must manually |
748 declare the wire to have the subscripts removed.) Nil may speed up some | 805 declare the wire to have the subscripts removed.) Nil may speed up some |
749 simulators, but is less general and harder to read, so avoid." | 806 simulators, but is less general and harder to read, so avoid." |
750 :group 'verilog-mode-auto | 807 :group 'verilog-mode-auto |
751 :type 'boolean ) | 808 :type 'boolean) |
809 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp) | |
752 | 810 |
753 (defcustom verilog-auto-inst-template-numbers nil | 811 (defcustom verilog-auto-inst-template-numbers nil |
754 "*If true, when creating templated ports with AUTOINST, add a comment. | 812 "*If true, when creating templated ports with AUTOINST, add a comment. |
755 The comment will add the line number of the template that was used for that | 813 The comment will add the line number of the template that was used for that |
756 port declaration. Setting this aids in debugging, but nil is suggested for | 814 port declaration. Setting this aids in debugging, but nil is suggested for |
757 regular use to prevent large numbers of merge conflicts." | 815 regular use to prevent large numbers of merge conflicts." |
758 :group 'verilog-mode-auto | 816 :group 'verilog-mode-auto |
759 :type 'boolean ) | 817 :type 'boolean) |
818 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) | |
760 | 819 |
761 (defvar verilog-auto-inst-column 40 | 820 (defvar verilog-auto-inst-column 40 |
762 "Column number for first part of auto-inst.") | 821 "Column number for first part of auto-inst.") |
763 | 822 |
764 (defcustom verilog-auto-input-ignore-regexp nil | 823 (defcustom verilog-auto-input-ignore-regexp nil |
765 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | 824 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. |
766 See the \\[verilog-faq] for examples on using this." | 825 See the \\[verilog-faq] for examples on using this." |
767 :group 'verilog-mode-auto | 826 :group 'verilog-mode-auto |
768 :type 'string ) | 827 :type 'string) |
828 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) | |
769 | 829 |
770 (defcustom verilog-auto-inout-ignore-regexp nil | 830 (defcustom verilog-auto-inout-ignore-regexp nil |
771 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | 831 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. |
772 See the \\[verilog-faq] for examples on using this." | 832 See the \\[verilog-faq] for examples on using this." |
773 :group 'verilog-mode-auto | 833 :group 'verilog-mode-auto |
774 :type 'string ) | 834 :type 'string) |
835 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) | |
775 | 836 |
776 (defcustom verilog-auto-output-ignore-regexp nil | 837 (defcustom verilog-auto-output-ignore-regexp nil |
777 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | 838 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. |
778 See the \\[verilog-faq] for examples on using this." | 839 See the \\[verilog-faq] for examples on using this." |
779 :group 'verilog-mode-auto | 840 :group 'verilog-mode-auto |
780 :type 'string ) | 841 :type 'string) |
842 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) | |
781 | 843 |
782 (defcustom verilog-auto-unused-ignore-regexp nil | 844 (defcustom verilog-auto-unused-ignore-regexp nil |
783 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | 845 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. |
784 See the \\[verilog-faq] for examples on using this." | 846 See the \\[verilog-faq] for examples on using this." |
785 :group 'verilog-mode-auto | 847 :group 'verilog-mode-auto |
786 :type 'string ) | 848 :type 'string) |
849 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) | |
787 | 850 |
788 (defcustom verilog-typedef-regexp nil | 851 (defcustom verilog-typedef-regexp nil |
789 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | 852 "*If non-nil, regular expression that matches Verilog-2001 typedef names. |
790 For example, \"_t$\" matches typedefs named with _t, as in the C language." | 853 For example, \"_t$\" matches typedefs named with _t, as in the C language." |
791 :group 'verilog-mode-auto | 854 :group 'verilog-mode-auto |
792 :type 'string ) | 855 :type 'string) |
856 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) | |
793 | 857 |
794 (defcustom verilog-mode-hook 'verilog-set-compile-command | 858 (defcustom verilog-mode-hook 'verilog-set-compile-command |
795 "*Hook (List of functions) run after verilog mode is loaded." | 859 "*Hook (List of functions) run after verilog mode is loaded." |
796 :type 'hook | 860 :type 'hook |
797 :group 'verilog-mode) | 861 :group 'verilog-mode) |
798 | 862 |
799 (defcustom verilog-auto-hook nil | 863 (defcustom verilog-auto-hook nil |
800 "*Hook run after `verilog-mode' updates AUTOs." | 864 "*Hook run after `verilog-mode' updates AUTOs." |
801 :type 'hook | 865 :group 'verilog-mode-auto |
802 :group 'verilog-mode-auto) | 866 :type 'hook) |
803 | 867 |
804 (defcustom verilog-before-auto-hook nil | 868 (defcustom verilog-before-auto-hook nil |
805 "*Hook run before `verilog-mode' updates AUTOs." | 869 "*Hook run before `verilog-mode' updates AUTOs." |
806 :type 'hook | 870 :group 'verilog-mode-auto |
807 :group 'verilog-mode-auto) | 871 :type 'hook) |
808 | 872 |
809 (defcustom verilog-delete-auto-hook nil | 873 (defcustom verilog-delete-auto-hook nil |
810 "*Hook run after `verilog-mode' deletes AUTOs." | 874 "*Hook run after `verilog-mode' deletes AUTOs." |
811 :type 'hook | 875 :group 'verilog-mode-auto |
812 :group 'verilog-mode-auto) | 876 :type 'hook) |
813 | 877 |
814 (defcustom verilog-before-delete-auto-hook nil | 878 (defcustom verilog-before-delete-auto-hook nil |
815 "*Hook run before `verilog-mode' deletes AUTOs." | 879 "*Hook run before `verilog-mode' deletes AUTOs." |
816 :type 'hook | 880 :group 'verilog-mode-auto |
817 :group 'verilog-mode-auto) | 881 :type 'hook) |
818 | 882 |
819 (defcustom verilog-getopt-flags-hook nil | 883 (defcustom verilog-getopt-flags-hook nil |
820 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists." | 884 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists." |
821 :type 'hook | 885 :group 'verilog-mode-auto |
822 :group 'verilog-mode-auto) | 886 :type 'hook) |
823 | 887 |
824 (defcustom verilog-before-getopt-flags-hook nil | 888 (defcustom verilog-before-getopt-flags-hook nil |
825 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists." | 889 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists." |
826 :type 'hook | 890 :group 'verilog-mode-auto |
827 :group 'verilog-mode-auto) | 891 :type 'hook) |
828 | 892 |
829 (defvar verilog-imenu-generic-expression | 893 (defvar verilog-imenu-generic-expression |
830 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | 894 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) |
831 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) | 895 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) |
832 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.") | 896 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.") |
841 format (e.g. 09/17/1997) is not supported.") | 905 format (e.g. 09/17/1997) is not supported.") |
842 | 906 |
843 (defvar verilog-company nil | 907 (defvar verilog-company nil |
844 "*Default name of Company for verilog header. | 908 "*Default name of Company for verilog header. |
845 If set will become buffer local.") | 909 If set will become buffer local.") |
846 | |
847 (make-variable-buffer-local 'verilog-company) | 910 (make-variable-buffer-local 'verilog-company) |
848 | 911 |
849 (defvar verilog-project nil | 912 (defvar verilog-project nil |
850 "*Default name of Project for verilog header. | 913 "*Default name of Project for verilog header. |
851 If set will become buffer local.") | 914 If set will become buffer local.") |
852 | |
853 (make-variable-buffer-local 'verilog-project) | 915 (make-variable-buffer-local 'verilog-project) |
854 | 916 |
855 (defvar verilog-mode-map | 917 (defvar verilog-mode-map |
856 (let ((map (make-sparse-keymap))) | 918 (let ((map (make-sparse-keymap))) |
857 (define-key map ";" 'electric-verilog-semi) | 919 (define-key map ";" 'electric-verilog-semi) |
869 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) | 931 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) |
870 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) | 932 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) |
871 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | 933 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) |
872 (define-key map "\M-\t" 'verilog-complete-word) | 934 (define-key map "\M-\t" 'verilog-complete-word) |
873 (define-key map "\M-?" 'verilog-show-completions) | 935 (define-key map "\M-?" 'verilog-show-completions) |
874 (define-key map [(meta control h)] 'verilog-mark-defun) | |
875 (define-key map "\C-c\`" 'verilog-lint-off) | 936 (define-key map "\C-c\`" 'verilog-lint-off) |
876 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | 937 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) |
877 (define-key map "\C-c\C-r" 'verilog-label-be) | 938 (define-key map "\C-c\C-r" 'verilog-label-be) |
878 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) | 939 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) |
879 (define-key map "\C-c=" 'verilog-pretty-expr) | 940 (define-key map "\C-c=" 'verilog-pretty-expr) |
880 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) | 941 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) |
881 (define-key map "\M-*" 'verilog-star-comment) | 942 (define-key map "\M-*" 'verilog-star-comment) |
882 (define-key map "\C-c\C-c" 'verilog-comment-region) | 943 (define-key map "\C-c\C-c" 'verilog-comment-region) |
883 (define-key map "\C-c\C-u" 'verilog-uncomment-region) | 944 (define-key map "\C-c\C-u" 'verilog-uncomment-region) |
884 (define-key map "\M-\C-a" 'verilog-beg-of-defun) | 945 (when (featurep 'xemacs) |
885 (define-key map "\M-\C-e" 'verilog-end-of-defun) | 946 (define-key map [(meta control h)] 'verilog-mark-defun) |
947 (define-key map "\M-\C-a" 'verilog-beg-of-defun) | |
948 (define-key map "\M-\C-e" 'verilog-end-of-defun)) | |
886 (define-key map "\C-c\C-d" 'verilog-goto-defun) | 949 (define-key map "\C-c\C-d" 'verilog-goto-defun) |
887 (define-key map "\C-c\C-k" 'verilog-delete-auto) | 950 (define-key map "\C-c\C-k" 'verilog-delete-auto) |
888 (define-key map "\C-c\C-a" 'verilog-auto) | 951 (define-key map "\C-c\C-a" 'verilog-auto) |
889 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) | 952 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) |
890 (define-key map "\C-c\C-z" 'verilog-inject-auto) | 953 (define-key map "\C-c\C-z" 'verilog-inject-auto) |
893 map) | 956 map) |
894 "Keymap used in Verilog mode.") | 957 "Keymap used in Verilog mode.") |
895 | 958 |
896 ;; menus | 959 ;; menus |
897 (defvar verilog-xemacs-menu | 960 (defvar verilog-xemacs-menu |
898 '("Verilog" | 961 `("Verilog" |
899 ("Choose Compilation Action" | 962 ("Choose Compilation Action" |
900 ["None" | 963 ["None" |
901 (progn | 964 (progn |
902 (setq verilog-tool nil) | 965 (setq verilog-tool nil) |
903 (verilog-set-compile-command)) | 966 (verilog-set-compile-command)) |
927 (verilog-set-compile-command)) | 990 (verilog-set-compile-command)) |
928 :style radio | 991 :style radio |
929 :selected (equal verilog-tool `verilog-compiler)] | 992 :selected (equal verilog-tool `verilog-compiler)] |
930 ) | 993 ) |
931 ("Move" | 994 ("Move" |
932 ["Beginning of function" verilog-beg-of-defun t] | 995 ,(if (featurep 'xemacs) |
933 ["End of function" verilog-end-of-defun t] | 996 (progn |
934 ["Mark function" verilog-mark-defun t] | 997 ["Beginning of function" verilog-beg-of-defun t] |
998 ["End of function" verilog-end-of-defun t] | |
999 ["Mark function" verilog-mark-defun t]) | |
1000 ["Beginning of function" beginning-of-defun t] | |
1001 ["End of function" end-of-defun t] | |
1002 ["Mark function" mark-defun t]) | |
1003 | |
935 ["Goto function/module" verilog-goto-defun t] | 1004 ["Goto function/module" verilog-goto-defun t] |
936 ["Move to beginning of block" electric-verilog-backward-sexp t] | 1005 ["Move to beginning of block" electric-verilog-backward-sexp t] |
937 ["Move to end of block" electric-verilog-forward-sexp t] | 1006 ["Move to end of block" electric-verilog-forward-sexp t] |
938 ) | 1007 ) |
939 ("Comments" | 1008 ("Comments" |
1023 ["Repeat" verilog-sk-repeat t] | 1092 ["Repeat" verilog-sk-repeat t] |
1024 ["Case" verilog-sk-case t] | 1093 ["Case" verilog-sk-case t] |
1025 ["Casex" verilog-sk-casex t] | 1094 ["Casex" verilog-sk-casex t] |
1026 ["Casez" verilog-sk-casez t] | 1095 ["Casez" verilog-sk-casez t] |
1027 ) | 1096 ) |
1028 "Menu for statement templates in Verilog." | 1097 "Menu for statement templates in Verilog.") |
1029 ) | |
1030 | 1098 |
1031 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode" | 1099 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode" |
1032 verilog-xemacs-menu) | 1100 verilog-xemacs-menu) |
1033 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." | 1101 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." |
1034 verilog-statement-menu) | 1102 verilog-statement-menu) |
1070 (and (verilog-skip-forward-comment-or-string) | 1138 (and (verilog-skip-forward-comment-or-string) |
1071 (progn | 1139 (progn |
1072 (store-match-data '(nil nil)) | 1140 (store-match-data '(nil nil)) |
1073 (if BOUND | 1141 (if BOUND |
1074 (< (point) BOUND) | 1142 (< (point) BOUND) |
1075 t) | 1143 t))))) |
1076 )))) | |
1077 (match-end 0)) | 1144 (match-end 0)) |
1078 | 1145 |
1079 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) | 1146 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
1080 ; checkdoc-params: (REGEXP BOUND NOERROR) | 1147 ; checkdoc-params: (REGEXP BOUND NOERROR) |
1081 "Like `re-search-backward', but skips over match in comments or strings." | 1148 "Like `re-search-backward', but skips over match in comments or strings." |
1085 (and (verilog-skip-backward-comment-or-string) | 1152 (and (verilog-skip-backward-comment-or-string) |
1086 (progn | 1153 (progn |
1087 (store-match-data '(nil nil)) | 1154 (store-match-data '(nil nil)) |
1088 (if BOUND | 1155 (if BOUND |
1089 (> (point) BOUND) | 1156 (> (point) BOUND) |
1090 t) | 1157 t))))) |
1091 )))) | |
1092 (match-end 0)) | 1158 (match-end 0)) |
1093 | 1159 |
1094 (defsubst verilog-re-search-forward-quick (regexp bound noerror) | 1160 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
1095 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, | 1161 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, |
1096 but trashes match data and is faster for REGEXP that doesn't match often. | 1162 but trashes match data and is faster for REGEXP that doesn't match often. |
1127 (point))) | 1193 (point))) |
1128 | 1194 |
1129 (defsubst verilog-within-string () | 1195 (defsubst verilog-within-string () |
1130 (save-excursion | 1196 (save-excursion |
1131 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) | 1197 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) |
1198 | |
1199 (defvar compile-command) | |
1132 | 1200 |
1133 ;; compilation program | 1201 ;; compilation program |
1134 (defun verilog-set-compile-command () | 1202 (defun verilog-set-compile-command () |
1135 "Function to compute shell command to compile verilog. | 1203 "Function to compute shell command to compile verilog. |
1136 | 1204 |
1199 (default-value 'compilation-error-regexp-alist))) | 1267 (default-value 'compilation-error-regexp-alist))) |
1200 ;; Could be buffer local at this point; maybe also in let; change all three | 1268 ;; Could be buffer local at this point; maybe also in let; change all three |
1201 (setq compilation-error-regexp-alist | 1269 (setq compilation-error-regexp-alist |
1202 (default-value 'compilation-error-regexp-alist)) | 1270 (default-value 'compilation-error-regexp-alist)) |
1203 (set (make-local-variable 'compilation-error-regexp-alist) | 1271 (set (make-local-variable 'compilation-error-regexp-alist) |
1204 (default-value 'compilation-error-regexp-alist)) | 1272 (default-value 'compilation-error-regexp-alist))))) |
1205 ))) | |
1206 | 1273 |
1207 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) | 1274 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) |
1208 | 1275 |
1209 (defconst verilog-directive-re | 1276 (defconst verilog-directive-re |
1210 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | 1277 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" |
1328 "endinterface" | 1395 "endinterface" |
1329 "endpackage" | 1396 "endpackage" |
1330 "endprogram" | 1397 "endprogram" |
1331 "endsequence" | 1398 "endsequence" |
1332 "endclocking" | 1399 "endclocking" |
1333 ) | 1400 )))) |
1334 ))) | |
1335 | 1401 |
1336 | 1402 |
1337 (defconst verilog-endcomment-reason-re | 1403 (defconst verilog-endcomment-reason-re |
1338 ;; Parenthesis indicate type of keyword found | 1404 ;; Parenthesis indicate type of keyword found |
1339 (concat | 1405 (concat |
1653 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | 1719 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" |
1654 "wire" "with" "within" "wor" "xnor" "xor" | 1720 "wire" "with" "within" "wor" "xnor" "xor" |
1655 ) | 1721 ) |
1656 "List of Verilog keywords.") | 1722 "List of Verilog keywords.") |
1657 | 1723 |
1658 | |
1659 (defconst verilog-emacs-features | |
1660 ;; Documentation at the bottom | |
1661 (let ((major (and (boundp 'emacs-major-version) | |
1662 emacs-major-version)) | |
1663 (minor (and (boundp 'emacs-minor-version) | |
1664 emacs-minor-version)) | |
1665 flavor comments flock-syntax) | |
1666 ;; figure out version numbers if not already discovered | |
1667 (and (or (not major) (not minor)) | |
1668 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) | |
1669 (setq major (string-to-number (substring emacs-version | |
1670 (match-beginning 1) | |
1671 (match-end 1))) | |
1672 minor (string-to-number (substring emacs-version | |
1673 (match-beginning 2) | |
1674 (match-end 2))))) | |
1675 (if (not (and major minor)) | |
1676 (error "Cannot figure out the major and minor version numbers")) | |
1677 ;; calculate the major version | |
1678 (cond | |
1679 ((= major 4) (setq major 'v18)) ;Epoch 4 | |
1680 ((= major 18) (setq major 'v18)) ;Emacs 18 | |
1681 ((= major 19) (setq major 'v19 ;Emacs 19 | |
1682 flavor (if (or (string-match "Lucid" emacs-version) | |
1683 (string-match "XEmacs" emacs-version)) | |
1684 'XEmacs 'FSF))) | |
1685 ((> major 19) (setq major 'v20 | |
1686 flavor (if (or (string-match "Lucid" emacs-version) | |
1687 (string-match "XEmacs" emacs-version)) | |
1688 'XEmacs 'FSF))) | |
1689 ;; I don't know | |
1690 (t (error "Cannot recognize major version number: %s" major))) | |
1691 ;; XEmacs 19 uses 8-bit modify-syntax-entry flags, as do all | |
1692 ;; patched Emacs 19, Emacs 18, Epoch 4's. Only Emacs 19 uses a | |
1693 ;; 1-bit flag. Let's be as smart as we can about figuring this | |
1694 ;; out. | |
1695 (if (or (eq major 'v20) (eq major 'v19)) | |
1696 (let ((table (copy-syntax-table))) | |
1697 (modify-syntax-entry ?a ". 12345678" table) | |
1698 (cond | |
1699 ;; XEmacs pre 20 and Emacs pre 19.30 use vectors for syntax tables. | |
1700 ((vectorp table) | |
1701 (if (= (logand (lsh (aref table ?a) -16) 255) 255) | |
1702 (setq comments '8-bit) | |
1703 (setq comments '1-bit))) | |
1704 ;; XEmacs 20 is known to be 8-bit | |
1705 ((eq flavor 'XEmacs) (setq comments '8-bit)) | |
1706 ;; Emacs 19.30 and beyond are known to be 1-bit | |
1707 ((eq flavor 'FSF) (setq comments '1-bit)) | |
1708 ;; Don't know what this is | |
1709 (t (error "Couldn't figure out syntax table format")) | |
1710 )) | |
1711 ;; Emacs 18 has no support for dual comments | |
1712 (setq comments 'no-dual-comments)) | |
1713 ;; determine whether to use old or new font lock syntax | |
1714 ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise | |
1715 ;; look for version > 19.30 | |
1716 (setq flock-syntax | |
1717 (if (or (equal comments '8-bit) | |
1718 (equal major 'v20) | |
1719 (and (equal major 'v19) (> minor 30))) | |
1720 'flock-syntax-after-1930 | |
1721 'flock-syntax-before-1930)) | |
1722 ;; lets do some minimal sanity checking. | |
1723 (if (or | |
1724 ;; Emacs before 19.6 had bugs | |
1725 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6)) | |
1726 ;; Emacs 19 before 19.21 has known bugs | |
1727 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21)) | |
1728 ) | |
1729 (with-output-to-temp-buffer "*verilog-mode warnings*" | |
1730 (print (format | |
1731 "The version of Emacs that you are running, %s, | |
1732 has known bugs in its syntax parsing routines which will affect the | |
1733 performance of verilog-mode. You should strongly consider upgrading to the | |
1734 latest available version. verilog-mode may continue to work, after a | |
1735 fashion, but strange indentation errors could be encountered." | |
1736 emacs-version)))) | |
1737 ;; Emacs 18, with no patch is not too good | |
1738 (if (and (eq major 'v18) (eq comments 'no-dual-comments)) | |
1739 (with-output-to-temp-buffer "*verilog-mode warnings*" | |
1740 (print (format | |
1741 "The version of Emacs 18 you are running, %s, | |
1742 has known deficiencies in its ability to handle the dual verilog | |
1743 \(and C++) comments, (e.g. the // and /* */ comments). This will | |
1744 not be much of a problem for you if you only use the /* */ comments, | |
1745 but you really should strongly consider upgrading to one of the latest | |
1746 Emacs 19's. In Emacs 18, you may also experience performance degradations. | |
1747 Emacs 19 has some new built-in routines which will speed things up for you. | |
1748 Because of these inherent problems, verilog-mode is not supported | |
1749 on emacs-18." | |
1750 emacs-version)))) | |
1751 ;; Emacs 18 with the syntax patches are no longer supported | |
1752 (if (and (eq major 'v18) (not (eq comments 'no-dual-comments))) | |
1753 (with-output-to-temp-buffer "*verilog-mode warnings*" | |
1754 (print (format | |
1755 "You are running a syntax patched Emacs 18 variant. While this should | |
1756 work for you, you may want to consider upgrading to Emacs 19. | |
1757 The syntax patches are no longer supported either for verilog-mode.")))) | |
1758 (list major comments flock-syntax)) | |
1759 "A list of features extant in the Emacs you are using. | |
1760 There are many flavors of Emacs out there, each with different | |
1761 features supporting those needed by `verilog-mode'. Here's the current | |
1762 supported list, along with the values for this variable: | |
1763 | |
1764 Vanilla Emacs 18/Epoch 4: (v18 no-dual-comments flock-syntax-before-1930) | |
1765 Emacs 18/Epoch 4 (patch2): (v18 8-bit flock-syntax-after-1930) | |
1766 XEmacs (formerly Lucid) 19: (v19 8-bit flock-syntax-after-1930) | |
1767 XEmacs 20: (v20 8-bit flock-syntax-after-1930) | |
1768 Emacs 19.1-19.30: (v19 8-bit flock-syntax-before-1930) | |
1769 Emacs 19.31-19.xx: (v19 8-bit flock-syntax-after-1930) | |
1770 Emacs20 : (v20 1-bit flock-syntax-after-1930).") | |
1771 | |
1772 (defconst verilog-comment-start-regexp "//\\|/\\*" | 1724 (defconst verilog-comment-start-regexp "//\\|/\\*" |
1773 "Dual comment value for `comment-start-regexp'.") | 1725 "Dual comment value for `comment-start-regexp'.") |
1774 | 1726 |
1775 (defun verilog-populate-syntax-table (table) | 1727 (defvar verilog-mode-syntax-table |
1776 "Populate the syntax TABLE." | 1728 (let ((table (make-syntax-table))) |
1777 (modify-syntax-entry ?\\ "\\" table) | 1729 ;; Populate the syntax TABLE. |
1778 (modify-syntax-entry ?+ "." table) | 1730 (modify-syntax-entry ?\\ "\\" table) |
1779 (modify-syntax-entry ?- "." table) | 1731 (modify-syntax-entry ?+ "." table) |
1780 (modify-syntax-entry ?= "." table) | 1732 (modify-syntax-entry ?- "." table) |
1781 (modify-syntax-entry ?% "." table) | 1733 (modify-syntax-entry ?= "." table) |
1782 (modify-syntax-entry ?< "." table) | 1734 (modify-syntax-entry ?% "." table) |
1783 (modify-syntax-entry ?> "." table) | 1735 (modify-syntax-entry ?< "." table) |
1784 (modify-syntax-entry ?& "." table) | 1736 (modify-syntax-entry ?> "." table) |
1785 (modify-syntax-entry ?| "." table) | 1737 (modify-syntax-entry ?& "." table) |
1786 (modify-syntax-entry ?` "w" table) | 1738 (modify-syntax-entry ?| "." table) |
1787 (modify-syntax-entry ?_ "w" table) | 1739 (modify-syntax-entry ?` "w" table) |
1788 (modify-syntax-entry ?\' "." table) | 1740 (modify-syntax-entry ?_ "w" table) |
1789 ) | 1741 (modify-syntax-entry ?\' "." table) |
1790 | 1742 |
1791 (defun verilog-setup-dual-comments (table) | 1743 ;; Set up TABLE to handle block and line style comments. |
1792 "Set up TABLE to handle block and line style comments." | 1744 (if (featurep 'xemacs) |
1793 (cond | 1745 (progn |
1794 ((memq '8-bit verilog-emacs-features) | 1746 ;; XEmacs (formerly Lucid) has the best implementation |
1795 ;; XEmacs (formerly Lucid) has the best implementation | 1747 (modify-syntax-entry ?/ ". 1456" table) |
1796 (modify-syntax-entry ?/ ". 1456" table) | 1748 (modify-syntax-entry ?* ". 23" table) |
1797 (modify-syntax-entry ?* ". 23" table) | 1749 (modify-syntax-entry ?\n "> b" table)) |
1798 (modify-syntax-entry ?\n "> b" table) | 1750 ;; Emacs 19 does things differently, but we can work with it |
1799 ) | 1751 (modify-syntax-entry ?/ ". 124b" table) |
1800 ((memq '1-bit verilog-emacs-features) | 1752 (modify-syntax-entry ?* ". 23" table) |
1801 ;; Emacs 19 does things differently, but we can work with it | 1753 (modify-syntax-entry ?\n "> b" table)) |
1802 (modify-syntax-entry ?/ ". 124b" table) | 1754 table) |
1803 (modify-syntax-entry ?* ". 23" table) | |
1804 (modify-syntax-entry ?\n "> b" table) | |
1805 ) | |
1806 )) | |
1807 | |
1808 (defvar verilog-mode-syntax-table nil | |
1809 "Syntax table used in `verilog-mode' buffers.") | 1755 "Syntax table used in `verilog-mode' buffers.") |
1810 | 1756 |
1811 (defvar verilog-font-lock-keywords nil | 1757 (defvar verilog-font-lock-keywords nil |
1812 "Default highlighting for Verilog mode.") | 1758 "Default highlighting for Verilog mode.") |
1813 | 1759 |
1959 'verilog-font-lock-p1800-face) | 1905 'verilog-font-lock-p1800-face) |
1960 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | 1906 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") |
1961 'font-lock-type-face)) | 1907 'font-lock-type-face)) |
1962 ;; Fontify Verilog-AMS keywords | 1908 ;; Fontify Verilog-AMS keywords |
1963 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | 1909 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") |
1964 'verilog-font-lock-ams-face) | 1910 'verilog-font-lock-ams-face))) |
1965 )) | |
1966 | 1911 |
1967 (setq verilog-font-lock-keywords-1 | 1912 (setq verilog-font-lock-keywords-1 |
1968 (append verilog-font-lock-keywords | 1913 (append verilog-font-lock-keywords |
1969 (list | 1914 (list |
1970 ;; Fontify module definitions | 1915 ;; Fontify module definitions |
1974 '(3 font-lock-function-name-face 'prepend)) | 1919 '(3 font-lock-function-name-face 'prepend)) |
1975 ;; Fontify function definitions | 1920 ;; Fontify function definitions |
1976 (list | 1921 (list |
1977 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | 1922 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) |
1978 '(1 font-lock-keyword-face) | 1923 '(1 font-lock-keyword-face) |
1979 '(3 font-lock-reference-face prepend) | 1924 '(3 font-lock-reference-face prepend)) |
1980 ) | |
1981 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" | 1925 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
1982 (1 font-lock-keyword-face) | 1926 (1 font-lock-keyword-face) |
1983 (2 font-lock-reference-face append) | 1927 (2 font-lock-reference-face append)) |
1984 ) | |
1985 '("\\<function\\>\\s-+\\(\\sw+\\)" | 1928 '("\\<function\\>\\s-+\\(\\sw+\\)" |
1986 1 'font-lock-reference-face append) | 1929 1 'font-lock-reference-face append)))) |
1987 ))) | |
1988 | 1930 |
1989 (setq verilog-font-lock-keywords-2 | 1931 (setq verilog-font-lock-keywords-2 |
1990 (append verilog-font-lock-keywords-1 | 1932 (append verilog-font-lock-keywords-1 |
1991 (list | 1933 (list |
1992 ;; Fontify pragmas | 1934 ;; Fontify pragmas |
2000 ;; Fontify delays/numbers | 1942 ;; Fontify delays/numbers |
2001 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | 1943 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" |
2002 0 font-lock-type-face append) | 1944 0 font-lock-type-face append) |
2003 ;; Fontify instantiation names | 1945 ;; Fontify instantiation names |
2004 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | 1946 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) |
2005 | |
2006 ))) | 1947 ))) |
2007 | 1948 |
2008 (setq verilog-font-lock-keywords-3 | 1949 (setq verilog-font-lock-keywords-3 |
2009 (append verilog-font-lock-keywords-2 | 1950 (append verilog-font-lock-keywords-2 |
2010 (when verilog-highlight-translate-off | 1951 (when verilog-highlight-translate-off |
2013 '(verilog-match-translate-off | 1954 '(verilog-match-translate-off |
2014 (0 'verilog-font-lock-translate-off-face prepend)) | 1955 (0 'verilog-font-lock-translate-off-face prepend)) |
2015 ))))) | 1956 ))))) |
2016 | 1957 |
2017 | 1958 |
2018 | |
2019 (defun verilog-inside-comment-p () | 1959 (defun verilog-inside-comment-p () |
2020 "Check if point inside a nested comment." | 1960 "Check if point inside a nested comment." |
2021 (save-excursion | 1961 (save-excursion |
2022 (let ((st-point (point)) hitbeg) | 1962 (let ((st-point (point)) hitbeg) |
2023 (or (search-backward "//" (verilog-get-beg-of-line) t) | 1963 (or (search-backward "//" (verilog-get-beg-of-line) t) |
2024 (if (progn | 1964 (if (progn |
2025 ;; This is for tricky case //*, we keep searching if /* is | 1965 ;; This is for tricky case //*, we keep searching if /* |
2026 ;; proceeded by // on same line. | 1966 ;; is proceeded by // on same line. |
2027 (while | 1967 (while |
2028 (and (setq hitbeg (search-backward "/*" nil t)) | 1968 (and (setq hitbeg (search-backward "/*" nil t)) |
2029 (progn | 1969 (progn |
2030 (forward-char 1) | 1970 (forward-char 1) |
2031 (search-backward "//" (verilog-get-beg-of-line) t)))) | 1971 (search-backward "//" (verilog-get-beg-of-line) t)))) |
2046 | 1986 |
2047 (defun electric-verilog-backward-sexp () | 1987 (defun electric-verilog-backward-sexp () |
2048 "Move backward over a sexp." | 1988 "Move backward over a sexp." |
2049 (interactive) | 1989 (interactive) |
2050 ;; before that see if we are in a comment | 1990 ;; before that see if we are in a comment |
2051 (verilog-backward-sexp) | 1991 (verilog-backward-sexp)) |
2052 ) | 1992 |
2053 (defun electric-verilog-forward-sexp () | 1993 (defun electric-verilog-forward-sexp () |
2054 "Move backward over a sexp." | 1994 "Move backward over a sexp." |
2055 (interactive) | 1995 (interactive) |
2056 ;; before that see if we are in a comment | 1996 ;; before that see if we are in a comment |
2057 (verilog-forward-sexp) | 1997 (verilog-forward-sexp)) |
2058 ) | 1998 |
2059 ;;;used by hs-minor-mode | 1999 ;;;used by hs-minor-mode |
2060 (defun verilog-forward-sexp-function (arg) | 2000 (defun verilog-forward-sexp-function (arg) |
2061 (if (< arg 0) | 2001 (if (< arg 0) |
2062 (verilog-backward-sexp) | 2002 (verilog-backward-sexp) |
2063 (verilog-forward-sexp))) | 2003 (verilog-forward-sexp))) |
2065 | 2005 |
2066 (defun verilog-backward-sexp () | 2006 (defun verilog-backward-sexp () |
2067 (let ((reg) | 2007 (let ((reg) |
2068 (elsec 1) | 2008 (elsec 1) |
2069 (found nil) | 2009 (found nil) |
2070 (st (point)) | 2010 (st (point))) |
2071 ) | |
2072 (if (not (looking-at "\\<")) | 2011 (if (not (looking-at "\\<")) |
2073 (forward-word -1)) | 2012 (forward-word -1)) |
2074 (cond | 2013 (cond |
2075 ((verilog-skip-backward-comment-or-string) | 2014 ((verilog-skip-backward-comment-or-string)) |
2076 ) | |
2077 ((looking-at "\\<else\\>") | 2015 ((looking-at "\\<else\\>") |
2078 (setq reg (concat | 2016 (setq reg (concat |
2079 verilog-end-block-re | 2017 verilog-end-block-re |
2080 "\\|\\(\\<else\\>\\)" | 2018 "\\|\\(\\<else\\>\\)" |
2081 "\\|\\(\\<if\\>\\)" | 2019 "\\|\\(\\<if\\>\\)")) |
2082 )) | |
2083 (while (and (not found) | 2020 (while (and (not found) |
2084 (verilog-re-search-backward reg nil 'move)) | 2021 (verilog-re-search-backward reg nil 'move)) |
2085 (cond | 2022 (cond |
2086 ((match-end 1) ; matched verilog-end-block-re | 2023 ((match-end 1) ; matched verilog-end-block-re |
2087 ; try to leap back to matching outward block by striding across | 2024 ; try to leap back to matching outward block by striding across |
2092 (setq elsec (1+ elsec))) | 2029 (setq elsec (1+ elsec))) |
2093 ((match-end 3) ; found it | 2030 ((match-end 3) ; found it |
2094 (setq elsec (1- elsec)) | 2031 (setq elsec (1- elsec)) |
2095 (if (= 0 elsec) | 2032 (if (= 0 elsec) |
2096 ;; Now previous line describes syntax | 2033 ;; Now previous line describes syntax |
2097 (setq found 't) | 2034 (setq found 't)))))) |
2098 )) | |
2099 ) | |
2100 ) | |
2101 ) | |
2102 ((looking-at verilog-end-block-re) | 2035 ((looking-at verilog-end-block-re) |
2103 (verilog-leap-to-head)) | 2036 (verilog-leap-to-head)) |
2104 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | 2037 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") |
2105 (cond | 2038 (cond |
2106 ((match-end 1) | 2039 ((match-end 1) |
2118 (t | 2051 (t |
2119 (goto-char st) | 2052 (goto-char st) |
2120 (backward-sexp 1)))) | 2053 (backward-sexp 1)))) |
2121 (t | 2054 (t |
2122 (goto-char st) | 2055 (goto-char st) |
2123 (backward-sexp)) | 2056 (backward-sexp))))) |
2124 ) ;; cond | |
2125 )) | |
2126 | 2057 |
2127 (defun verilog-forward-sexp () | 2058 (defun verilog-forward-sexp () |
2128 (let ((reg) | 2059 (let ((reg) |
2129 (md 2) | 2060 (md 2) |
2130 (st (point))) | 2061 (st (point))) |
2131 (if (not (looking-at "\\<")) | 2062 (if (not (looking-at "\\<")) |
2132 (forward-word -1)) | 2063 (forward-word -1)) |
2133 (cond | 2064 (cond |
2134 ((verilog-skip-forward-comment-or-string) | 2065 ((verilog-skip-forward-comment-or-string) |
2135 (verilog-forward-syntactic-ws) | 2066 (verilog-forward-syntactic-ws)) |
2136 ) | |
2137 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking | 2067 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking |
2138 (cond | 2068 (cond |
2139 ((match-end 1) ; end | 2069 ((match-end 1) ; end |
2140 ;; Search forward for matching begin | 2070 ;; Search forward for matching begin |
2141 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | 2071 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) |
2142 ((match-end 2) ; endcase | 2072 ((match-end 2) ; endcase |
2143 ;; Search forward for matching case | 2073 ;; Search forward for matching case |
2144 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ) | 2074 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) |
2145 ) | |
2146 ((match-end 3) ; join | 2075 ((match-end 3) ; join |
2147 ;; Search forward for matching fork | 2076 ;; Search forward for matching fork |
2148 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | 2077 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) |
2149 ((match-end 4) ; endclass | 2078 ((match-end 4) ; endclass |
2150 ;; Search forward for matching class | 2079 ;; Search forward for matching class |
2171 ;; Search forward for matching property | 2100 ;; Search forward for matching property |
2172 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | 2101 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) |
2173 ((match-end 12) ; endsequence | 2102 ((match-end 12) ; endsequence |
2174 ;; Search forward for matching sequence | 2103 ;; Search forward for matching sequence |
2175 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | 2104 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) |
2176 (setq md 3) ; 3 to get to endsequence in the reg above | 2105 (setq md 3)) ; 3 to get to endsequence in the reg above |
2177 ) | |
2178 ((match-end 13) ; endclocking | 2106 ((match-end 13) ; endclocking |
2179 ;; Search forward for matching clocking | 2107 ;; Search forward for matching clocking |
2180 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" )) | 2108 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) |
2181 ) | |
2182 (if (forward-word 1) | 2109 (if (forward-word 1) |
2183 (catch 'skip | 2110 (catch 'skip |
2184 (let ((nest 1)) | 2111 (let ((nest 1)) |
2185 (while (verilog-re-search-forward reg nil 'move) | 2112 (while (verilog-re-search-forward reg nil 'move) |
2186 (cond | 2113 (cond |
2187 ((match-end md) ; the closer in reg, so we are climbing out | 2114 ((match-end md) ; the closer in reg, so we are climbing out |
2188 (setq nest (1- nest)) | 2115 (setq nest (1- nest)) |
2189 (if (= 0 nest) ; we are out! | 2116 (if (= 0 nest) ; we are out! |
2190 (throw 'skip 1))) | 2117 (throw 'skip 1))) |
2191 ((match-end 1) ; the opener in reg, so we are deeper now | 2118 ((match-end 1) ; the opener in reg, so we are deeper now |
2192 (setq nest (1+ nest))))) | 2119 (setq nest (1+ nest))))))))) |
2193 ))) | |
2194 ) | |
2195 ((looking-at (concat | 2120 ((looking-at (concat |
2196 "\\(\\<\\(macro\\)?module\\>\\)\\|" | 2121 "\\(\\<\\(macro\\)?module\\>\\)\\|" |
2197 "\\(\\<primitive\\>\\)\\|" | 2122 "\\(\\<primitive\\>\\)\\|" |
2198 "\\(\\<class\\>\\)\\|" | 2123 "\\(\\<class\\>\\)\\|" |
2199 "\\(\\<program\\>\\)\\|" | 2124 "\\(\\<program\\>\\)\\|" |
2219 (forward-sexp 1))))) | 2144 (forward-sexp 1))))) |
2220 (t | 2145 (t |
2221 (goto-char st) | 2146 (goto-char st) |
2222 (if (= (following-char) ?\) ) | 2147 (if (= (following-char) ?\) ) |
2223 (forward-char 1) | 2148 (forward-char 1) |
2224 (forward-sexp 1))) | 2149 (forward-sexp 1)))))) |
2225 ) ;; cond | |
2226 )) | |
2227 | 2150 |
2228 (defun verilog-declaration-beg () | 2151 (defun verilog-declaration-beg () |
2229 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | 2152 (verilog-re-search-backward verilog-declaration-re (bobp) t)) |
2230 | 2153 |
2231 (defun verilog-font-lock-init () | 2154 (defun verilog-font-lock-init () |
2236 (append verilog-font-lock-keywords-2 | 2159 (append verilog-font-lock-keywords-2 |
2237 (when verilog-highlight-translate-off | 2160 (when verilog-highlight-translate-off |
2238 (list | 2161 (list |
2239 ;; Fontify things in translate off regions | 2162 ;; Fontify things in translate off regions |
2240 '(verilog-match-translate-off | 2163 '(verilog-match-translate-off |
2241 (0 'verilog-font-lock-translate-off-face prepend)) | 2164 (0 'verilog-font-lock-translate-off-face prepend)))))) |
2242 )))) | |
2243 (put 'verilog-mode 'font-lock-defaults | 2165 (put 'verilog-mode 'font-lock-defaults |
2244 '((verilog-font-lock-keywords | 2166 '((verilog-font-lock-keywords |
2245 verilog-font-lock-keywords-1 | 2167 verilog-font-lock-keywords-1 |
2246 verilog-font-lock-keywords-2 | 2168 verilog-font-lock-keywords-2 |
2247 verilog-font-lock-keywords-3) | 2169 verilog-font-lock-keywords-3) |
2251 ;; Function to move to beginning of reasonable region to highlight | 2173 ;; Function to move to beginning of reasonable region to highlight |
2252 verilog-beg-of-defun))) | 2174 verilog-beg-of-defun))) |
2253 | 2175 |
2254 ;; initialize fontification for Verilog Mode | 2176 ;; initialize fontification for Verilog Mode |
2255 (verilog-font-lock-init) | 2177 (verilog-font-lock-init) |
2256 ;; start up message | 2178 |
2257 (defconst verilog-startup-message-lines | |
2258 '("Please use \\[verilog-submit-bug-report] to report bugs." | |
2259 "Visit http://www.verilog.com to check for updates" | |
2260 )) | |
2261 (defvar verilog-startup-message-displayed t) | |
2262 (defun verilog-display-startup-message () | |
2263 (if (not verilog-startup-message-displayed) | |
2264 (if (sit-for 5) | |
2265 (let ((lines verilog-startup-message-lines)) | |
2266 (message "verilog-mode version %s, released %s; type \\[describe-mode] for help" | |
2267 verilog-mode-version verilog-mode-release-date) | |
2268 (setq verilog-startup-message-displayed t) | |
2269 (while (and (sit-for 4) lines) | |
2270 (message (substitute-command-keys (car lines))) | |
2271 (setq lines (cdr lines))))) | |
2272 (message ""))) | |
2273 ;; | 2179 ;; |
2274 ;; | 2180 ;; |
2275 ;; Mode | 2181 ;; Mode |
2276 ;; | 2182 ;; |
2277 (defvar verilog-which-tool 1) | 2183 (defvar verilog-which-tool 1) |
2407 (kill-all-local-variables) | 2313 (kill-all-local-variables) |
2408 (use-local-map verilog-mode-map) | 2314 (use-local-map verilog-mode-map) |
2409 (setq major-mode 'verilog-mode) | 2315 (setq major-mode 'verilog-mode) |
2410 (setq mode-name "Verilog") | 2316 (setq mode-name "Verilog") |
2411 (setq local-abbrev-table verilog-mode-abbrev-table) | 2317 (setq local-abbrev-table verilog-mode-abbrev-table) |
2412 (setq verilog-mode-syntax-table (make-syntax-table)) | 2318 (set (make-local-variable 'beginning-of-defun-function) |
2413 (verilog-populate-syntax-table verilog-mode-syntax-table) | |
2414 (set (make-local-variable 'beginning-of-defun-function) | |
2415 'verilog-beg-of-defun) | 2319 'verilog-beg-of-defun) |
2416 (set (make-local-variable 'end-of-defun-function) | 2320 (set (make-local-variable 'end-of-defun-function) |
2417 'verilog-end-of-defun) | 2321 'verilog-end-of-defun) |
2418 ;; add extra comment syntax | |
2419 (verilog-setup-dual-comments verilog-mode-syntax-table) | |
2420 (set-syntax-table verilog-mode-syntax-table) | 2322 (set-syntax-table verilog-mode-syntax-table) |
2421 (make-local-variable 'indent-line-function) | 2323 (make-local-variable 'indent-line-function) |
2422 (setq indent-line-function 'verilog-indent-line-relative) | 2324 (setq indent-line-function 'verilog-indent-line-relative) |
2423 (setq comment-indent-function 'verilog-comment-indent) | 2325 (setq comment-indent-function 'verilog-comment-indent) |
2424 (make-local-variable 'parse-sexp-ignore-comments) | 2326 (make-local-variable 'parse-sexp-ignore-comments) |
2442 (when (featurep 'xemacs) | 2344 (when (featurep 'xemacs) |
2443 (when (and current-menubar | 2345 (when (and current-menubar |
2444 (not (assoc "Verilog" current-menubar))) | 2346 (not (assoc "Verilog" current-menubar))) |
2445 ;; (set-buffer-menubar (copy-sequence current-menubar)) | 2347 ;; (set-buffer-menubar (copy-sequence current-menubar)) |
2446 (add-submenu nil verilog-xemacs-menu) | 2348 (add-submenu nil verilog-xemacs-menu) |
2447 (add-submenu nil verilog-stmt-menu) | 2349 (add-submenu nil verilog-stmt-menu))) |
2448 )) | 2350 |
2449 ;; Stuff for GNU emacs | 2351 ;; Stuff for GNU emacs |
2450 (set (make-local-variable 'font-lock-defaults) | 2352 (set (make-local-variable 'font-lock-defaults) |
2451 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 | 2353 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 |
2452 verilog-font-lock-keywords-2 | 2354 verilog-font-lock-keywords-2 |
2453 verilog-font-lock-keywords-3) | 2355 verilog-font-lock-keywords-3) |
2470 (unless (assq 'verilog-mode hs-special-modes-alist) | 2372 (unless (assq 'verilog-mode hs-special-modes-alist) |
2471 (setq hs-special-modes-alist | 2373 (setq hs-special-modes-alist |
2472 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil | 2374 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil |
2473 verilog-forward-sexp-function) | 2375 verilog-forward-sexp-function) |
2474 hs-special-modes-alist))) | 2376 hs-special-modes-alist))) |
2475 ;; Display version splash information. | |
2476 (verilog-display-startup-message) | |
2477 | 2377 |
2478 ;; Stuff for autos | 2378 ;; Stuff for autos |
2479 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | 2379 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local |
2480 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them | 2380 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them |
2481 ;; (verilog-getopt-flags) | 2381 ;; (verilog-getopt-flags) |
2525 (newline)) | 2425 (newline)) |
2526 nil) | 2426 nil) |
2527 (progn | 2427 (progn |
2528 (end-of-line) | 2428 (end-of-line) |
2529 (delete-horizontal-space) | 2429 (delete-horizontal-space) |
2530 't | 2430 't))) |
2531 ) | |
2532 ) | |
2533 ) | |
2534 ;; see if we should line up assignments | 2431 ;; see if we should line up assignments |
2535 (progn | 2432 (progn |
2536 (if (or (memq 'all verilog-auto-lineup) | 2433 (if (or (memq 'all verilog-auto-lineup) |
2537 (memq 'assignments verilog-auto-lineup)) | 2434 (memq 'assignments verilog-auto-lineup)) |
2538 (verilog-pretty-expr) | 2435 (verilog-pretty-expr)) |
2539 ) | 2436 (newline)) |
2540 (newline) | 2437 (forward-line 1)) |
2541 ) | |
2542 (forward-line 1) | |
2543 ) | |
2544 ;; Indent next line | 2438 ;; Indent next line |
2545 (if verilog-auto-indent-on-newline | 2439 (if verilog-auto-indent-on-newline |
2546 (verilog-indent-line)) | 2440 (verilog-indent-line))) |
2547 ) | |
2548 (t | 2441 (t |
2549 (newline)) | 2442 (newline))))) |
2550 ))) | |
2551 | 2443 |
2552 (defun electric-verilog-terminate-and-indent () | 2444 (defun electric-verilog-terminate-and-indent () |
2553 "Insert a newline and indent for the next statement." | 2445 "Insert a newline and indent for the next statement." |
2554 (interactive) | 2446 (interactive) |
2555 (electric-verilog-terminate-line 1)) | 2447 (electric-verilog-terminate-line 1)) |
2563 (verilog-in-escaped-name-p)) | 2455 (verilog-in-escaped-name-p)) |
2564 () | 2456 () |
2565 (save-excursion | 2457 (save-excursion |
2566 (beginning-of-line) | 2458 (beginning-of-line) |
2567 (verilog-forward-ws&directives) | 2459 (verilog-forward-ws&directives) |
2568 (verilog-indent-line) | 2460 (verilog-indent-line)) |
2569 ) | |
2570 (if (and verilog-auto-newline | 2461 (if (and verilog-auto-newline |
2571 (not (verilog-parenthesis-depth))) | 2462 (not (verilog-parenthesis-depth))) |
2572 (electric-verilog-terminate-line)))) | 2463 (electric-verilog-terminate-line)))) |
2573 | 2464 |
2574 (defun electric-verilog-semi-with-comment () | 2465 (defun electric-verilog-semi-with-comment () |
2646 ; kill existing comment | 2537 ; kill existing comment |
2647 (beginning-of-line) | 2538 (beginning-of-line) |
2648 (re-search-forward comment-start-skip oldpnt 'move) | 2539 (re-search-forward comment-start-skip oldpnt 'move) |
2649 (goto-char (match-beginning 0)) | 2540 (goto-char (match-beginning 0)) |
2650 (skip-chars-backward " \t") | 2541 (skip-chars-backward " \t") |
2651 (kill-region (point) oldpnt) | 2542 (kill-region (point) oldpnt)))))) |
2652 )))) | |
2653 ) | |
2654 (progn (insert "\t")))) | 2543 (progn (insert "\t")))) |
2655 | 2544 |
2656 | 2545 |
2657 | 2546 |
2658 ;; | 2547 ;; |
2688 (insert " */")) | 2577 (insert " */")) |
2689 (newline) | 2578 (newline) |
2690 (insert " * ")) | 2579 (insert " * ")) |
2691 | 2580 |
2692 (defun verilog-insert-1 (fmt max) | 2581 (defun verilog-insert-1 (fmt max) |
2693 "Insert integers 0 to MAX-1 according to format string FMT. | 2582 "Use format string FMT to insert integers 0 to MAX - 1. |
2694 Inserts one integer per line, at the current column. Stops early | 2583 Inserts one integer per line, at the current column. Stops early |
2695 if it reaches the end of the buffer." | 2584 if it reaches the end of the buffer." |
2696 (let ((col (current-column)) | 2585 (let ((col (current-column)) |
2697 (n 0)) | 2586 (n 0)) |
2698 (save-excursion | 2587 (save-excursion |
2722 a = b a[ 5] = b | 2611 a = b a[ 5] = b |
2723 a = b a[ 6] = b | 2612 a = b a[ 6] = b |
2724 a = b a[ 7] = b | 2613 a = b a[ 7] = b |
2725 a = b a[ 8] = b" | 2614 a = b a[ 8] = b" |
2726 | 2615 |
2727 (interactive "NMAX? ") | 2616 (interactive "NMAX: ") |
2728 (verilog-insert-1 "[%3d]" max)) | 2617 (verilog-insert-1 "[%3d]" max)) |
2729 | 2618 |
2730 (defun verilog-generate-numbers (max) | 2619 (defun verilog-generate-numbers (max) |
2731 "Insert a set of generated numbers into a rectangle. | 2620 "Insert a set of generated numbers into a rectangle. |
2732 The upper left corner is defined by point. The numbers are padded to three | 2621 The upper left corner is defined by point. The numbers are padded to three |
2742 buf buf buf buf005 | 2631 buf buf buf buf005 |
2743 buf buf buf buf006 | 2632 buf buf buf buf006 |
2744 buf buf buf buf007 | 2633 buf buf buf buf007 |
2745 buf buf buf buf008" | 2634 buf buf buf buf008" |
2746 | 2635 |
2747 (interactive "NMAX? ") | 2636 (interactive "NMAX: ") |
2748 (verilog-insert-1 "%3.3d" max)) | 2637 (verilog-insert-1 "%3.3d" max)) |
2749 | 2638 |
2750 (defun verilog-mark-defun () | 2639 (defun verilog-mark-defun () |
2751 "Mark the current verilog function (or procedure). | 2640 "Mark the current verilog function (or procedure). |
2752 This puts the mark at the end, and point at the beginning." | 2641 This puts the mark at the end, and point at the beginning." |
2753 (interactive) | 2642 (interactive) |
2754 (push-mark (point)) | 2643 (when (featurep 'xemacs) |
2755 (verilog-end-of-defun) | 2644 (push-mark (point)) |
2756 (push-mark (point)) | 2645 (verilog-end-of-defun) |
2757 (verilog-beg-of-defun) | 2646 (push-mark (point)) |
2758 (if (fboundp 'zmacs-activate-region) | 2647 (verilog-beg-of-defun) |
2759 (zmacs-activate-region))) | 2648 (if (fboundp 'zmacs-activate-region) |
2649 (zmacs-activate-region)))) | |
2760 | 2650 |
2761 (defun verilog-comment-region (start end) | 2651 (defun verilog-comment-region (start end) |
2762 ; checkdoc-params: (start end) | 2652 ; checkdoc-params: (start end) |
2763 "Put the region into a Verilog comment. | 2653 "Put the region into a Verilog comment. |
2764 The comments that are in this area are \"deformed\": | 2654 The comments that are in this area are \"deformed\": |
2790 (while (re-search-backward "\\*/" start t) | 2680 (while (re-search-backward "\\*/" start t) |
2791 (replace-match "*-/" t t))) | 2681 (replace-match "*-/" t t))) |
2792 (save-excursion | 2682 (save-excursion |
2793 (let ((s+1 (1+ start))) | 2683 (let ((s+1 (1+ start))) |
2794 (while (re-search-backward "/\\*" s+1 t) | 2684 (while (re-search-backward "/\\*" s+1 t) |
2795 (replace-match "/-*" t t)))) | 2685 (replace-match "/-*" t t)))))) |
2796 )) | |
2797 | 2686 |
2798 (defun verilog-uncomment-region () | 2687 (defun verilog-uncomment-region () |
2799 "Uncomment a commented area; change deformed comments back to normal. | 2688 "Uncomment a commented area; change deformed comments back to normal. |
2800 This command does nothing if the pointer is not in a commented | 2689 This command does nothing if the pointer is not in a commented |
2801 area. See also `verilog-comment-region'." | 2690 area. See also `verilog-comment-region'." |
2867 (b (progn | 2756 (b (progn |
2868 (verilog-beg-of-defun) | 2757 (verilog-beg-of-defun) |
2869 (point-marker))) | 2758 (point-marker))) |
2870 (e (progn | 2759 (e (progn |
2871 (verilog-end-of-defun) | 2760 (verilog-end-of-defun) |
2872 (point-marker))) | 2761 (point-marker)))) |
2873 ) | |
2874 (goto-char (marker-position b)) | 2762 (goto-char (marker-position b)) |
2875 (if (> (- e b) 200) | 2763 (if (> (- e b) 200) |
2876 (message "Relabeling module...")) | 2764 (message "Relabeling module...")) |
2877 (while (and | 2765 (while (and |
2878 (> (marker-position e) (point)) | 2766 (> (marker-position e) (point)) |
2883 nil 'move)) | 2771 nil 'move)) |
2884 (goto-char (match-beginning 0)) | 2772 (goto-char (match-beginning 0)) |
2885 (let ((indent-str (verilog-indent-line))) | 2773 (let ((indent-str (verilog-indent-line))) |
2886 (verilog-set-auto-endcomments indent-str 't) | 2774 (verilog-set-auto-endcomments indent-str 't) |
2887 (end-of-line) | 2775 (end-of-line) |
2888 (delete-horizontal-space) | 2776 (delete-horizontal-space)) |
2889 ) | |
2890 (setq cnt (1+ cnt)) | 2777 (setq cnt (1+ cnt)) |
2891 (if (= 9 (% cnt 10)) | 2778 (if (= 9 (% cnt 10)) |
2892 (message "%d..." cnt)) | 2779 (message "%d..." cnt))) |
2893 ) | |
2894 (goto-char oldpos) | 2780 (goto-char oldpos) |
2895 (if (or | 2781 (if (or |
2896 (> (- e b) 200) | 2782 (> (- e b) 200) |
2897 (> cnt 20)) | 2783 (> cnt 20)) |
2898 (message "%d lines auto commented" cnt)) | 2784 (message "%d lines auto commented" cnt)))) |
2899 )) | |
2900 | 2785 |
2901 (defun verilog-beg-of-statement () | 2786 (defun verilog-beg-of-statement () |
2902 "Move backward to beginning of statement." | 2787 "Move backward to beginning of statement." |
2903 (interactive) | 2788 (interactive) |
2904 ;; Move back token by token until we see the end | 2789 ;; Move back token by token until we see the end |
2917 (forward-word -1))) | 2802 (forward-word -1))) |
2918 (and | 2803 (and |
2919 (looking-at verilog-extended-complete-re) | 2804 (looking-at verilog-extended-complete-re) |
2920 (not (save-excursion | 2805 (not (save-excursion |
2921 (verilog-backward-token) | 2806 (verilog-backward-token) |
2922 (looking-at verilog-extended-complete-re))) | 2807 (looking-at verilog-extended-complete-re)))) |
2923 ) | |
2924 (looking-at verilog-basic-complete-re) | 2808 (looking-at verilog-basic-complete-re) |
2925 (save-excursion | 2809 (save-excursion |
2926 (verilog-backward-token) | 2810 (verilog-backward-token) |
2927 (or | 2811 (or |
2928 (looking-at verilog-end-block-re) | 2812 (looking-at verilog-end-block-re) |
2929 (looking-at verilog-preprocessor-re))) | 2813 (looking-at verilog-preprocessor-re))))) |
2930 )) | |
2931 (verilog-backward-syntactic-ws) | 2814 (verilog-backward-syntactic-ws) |
2932 (verilog-backward-token)) | 2815 (verilog-backward-token)) |
2933 ;; Now point is where the previous line ended. | 2816 ;; Now point is where the previous line ended. |
2934 (verilog-forward-syntactic-ws)) | 2817 (verilog-forward-syntactic-ws)) |
2935 | 2818 |
3009 ((match-end 2) | 2892 ((match-end 2) |
3010 (if (= nest 1) | 2893 (if (= nest 1) |
3011 (throw 'found 1)) | 2894 (throw 'found 1)) |
3012 (setq nest (1- nest))) | 2895 (setq nest (1- nest))) |
3013 (t | 2896 (t |
3014 (throw 'found (= nest 0))) | 2897 (throw 'found (= nest 0))))))) |
3015 )))) | |
3016 nil))) | 2898 nil))) |
2899 | |
3017 (defun verilog-in-struct-region-p () | 2900 (defun verilog-in-struct-region-p () |
3018 "Return TRUE if in a struct region; | 2901 "Return TRUE if in a struct region; |
3019 more specifically, in a list after a struct|union keyword" | 2902 more specifically, in a list after a struct|union keyword" |
3020 (interactive) | 2903 (interactive) |
3021 (save-excursion | 2904 (save-excursion |
3022 (let* ((state (parse-partial-sexp (point-min) (point))) | 2905 (let* ((state (parse-partial-sexp (point-min) (point))) |
3023 (depth (nth 0 state))) | 2906 (depth (nth 0 state))) |
3024 (if depth | 2907 (if depth |
3025 (progn (backward-up-list depth) | 2908 (progn (backward-up-list depth) |
3026 (verilog-beg-of-statement) | 2909 (verilog-beg-of-statement) |
3027 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>") | 2910 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
3028 ) | |
3029 ) | |
3030 ) | |
3031 ) | |
3032 ) | |
3033 | 2911 |
3034 (defun verilog-in-generate-region-p () | 2912 (defun verilog-in-generate-region-p () |
3035 "Return TRUE if in a generate region; | 2913 "Return TRUE if in a generate region; |
3036 more specifically, after a generate and before an endgenerate" | 2914 more specifically, after a generate and before an endgenerate" |
3037 (interactive) | 2915 (interactive) |
3038 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | 2916 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) |
3039 (nest 1) | 2917 (nest 1)) |
3040 ) | |
3041 (save-excursion | 2918 (save-excursion |
3042 (while (and | 2919 (while (and |
3043 (/= nest 0) | 2920 (/= nest 0) |
3044 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) | 2921 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) |
3045 (cond | 2922 (cond |
3046 ((match-end 1) ; generate | 2923 ((match-end 1) ; generate |
3047 (setq nest (1- nest))) | 2924 (setq nest (1- nest))) |
3048 ((match-end 2) ; endgenerate | 2925 ((match-end 2) ; endgenerate |
3049 (setq nest (1+ nest))) | 2926 (setq nest (1+ nest))))))) |
3050 )) | |
3051 )) | |
3052 (= nest 0) )) ; return nest | 2927 (= nest 0) )) ; return nest |
3053 | 2928 |
3054 (defun verilog-in-fork-region-p () | 2929 (defun verilog-in-fork-region-p () |
3055 "Return true if between a fork and join." | 2930 "Return true if between a fork and join." |
3056 (interactive) | 2931 (interactive) |
3057 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | 2932 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) |
3058 (nest 1) | 2933 (nest 1)) |
3059 ) | |
3060 (save-excursion | 2934 (save-excursion |
3061 (while (and | 2935 (while (and |
3062 (/= nest 0) | 2936 (/= nest 0) |
3063 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | 2937 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) |
3064 (cond | 2938 (cond |
3065 ((match-end 1) ; fork | 2939 ((match-end 1) ; fork |
3066 (setq nest (1- nest))) | 2940 (setq nest (1- nest))) |
3067 ((match-end 2) ; join | 2941 ((match-end 2) ; join |
3068 (setq nest (1+ nest))) | 2942 (setq nest (1+ nest))))))) |
3069 )) | |
3070 )) | |
3071 (= nest 0) )) ; return nest | 2943 (= nest 0) )) ; return nest |
3072 | 2944 |
3073 (defun verilog-backward-case-item (lim) | 2945 (defun verilog-backward-case-item (lim) |
3074 "Skip backward to nearest enclosing case item. | 2946 "Skip backward to nearest enclosing case item. |
3075 Limit search to point LIM." | 2947 Limit search to point LIM." |
3097 (error "%s: unbalanced [" (verilog-point-text)))) | 2969 (error "%s: unbalanced [" (verilog-point-text)))) |
3098 ((match-end 2) ;; ] | 2970 ((match-end 2) ;; ] |
3099 (setq colon (1- colon))) | 2971 (setq colon (1- colon))) |
3100 | 2972 |
3101 ((match-end 3) ;; : | 2973 ((match-end 3) ;; : |
3102 (setq colon (1+ colon))) | 2974 (setq colon (1+ colon))))) |
3103 )) | |
3104 ;; Skip back to beginning of case item | 2975 ;; Skip back to beginning of case item |
3105 (skip-chars-backward "\t ") | 2976 (skip-chars-backward "\t ") |
3106 (verilog-skip-backward-comment-or-string) | 2977 (verilog-skip-backward-comment-or-string) |
3107 (setq e (point)) | 2978 (setq e (point)) |
3108 (setq b | 2979 (setq b |
3121 (verilog-forward-ws&directives))) | 2992 (verilog-forward-ws&directives))) |
3122 (point)) | 2993 (point)) |
3123 (t | 2994 (t |
3124 (goto-char (match-end 0)) | 2995 (goto-char (match-end 0)) |
3125 (verilog-forward-ws&directives) | 2996 (verilog-forward-ws&directives) |
3126 (point)) | 2997 (point)))) |
3127 )) | 2998 (error "Malformed case item")))) |
3128 (error "Malformed case item") | |
3129 ))) | |
3130 (setq str (buffer-substring b e)) | 2999 (setq str (buffer-substring b e)) |
3131 (if | 3000 (if |
3132 (setq e | 3001 (setq e |
3133 (string-match | 3002 (string-match |
3134 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | 3003 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) |
3176 (not (save-excursion | 3045 (not (save-excursion |
3177 (end-of-line) | 3046 (end-of-line) |
3178 (search-backward "//" (verilog-get-beg-of-line) t))))) | 3047 (search-backward "//" (verilog-get-beg-of-line) t))))) |
3179 (let ((nest 1) b e | 3048 (let ((nest 1) b e |
3180 m | 3049 m |
3181 (else (if (match-end 2) "!" " ")) | 3050 (else (if (match-end 2) "!" " "))) |
3182 ) | |
3183 (end-of-line) | 3051 (end-of-line) |
3184 (if kill-existing-comment | 3052 (if kill-existing-comment |
3185 (verilog-kill-existing-comment)) | 3053 (verilog-kill-existing-comment)) |
3186 (delete-horizontal-space) | 3054 (delete-horizontal-space) |
3187 (save-excursion | 3055 (save-excursion |
3197 ((match-end 3) ; `if | 3065 ((match-end 3) ; `if |
3198 (setq nest (1- nest))) | 3066 (setq nest (1- nest))) |
3199 ((match-end 4) ; `ifdef | 3067 ((match-end 4) ; `ifdef |
3200 (setq nest (1- nest))) | 3068 (setq nest (1- nest))) |
3201 ((match-end 5) ; `ifndef | 3069 ((match-end 5) ; `ifndef |
3202 (setq nest (1- nest))) | 3070 (setq nest (1- nest))))) |
3203 )) | |
3204 (if (match-end 0) | 3071 (if (match-end 0) |
3205 (setq | 3072 (setq |
3206 m (buffer-substring | 3073 m (buffer-substring |
3207 (match-beginning 0) | 3074 (match-beginning 0) |
3208 (match-end 0)) | 3075 (match-end 0)) |
3210 (skip-chars-forward "^ \t") | 3077 (skip-chars-forward "^ \t") |
3211 (verilog-forward-syntactic-ws) | 3078 (verilog-forward-syntactic-ws) |
3212 (point)) | 3079 (point)) |
3213 e (progn | 3080 e (progn |
3214 (skip-chars-forward "a-zA-Z0-9_") | 3081 (skip-chars-forward "a-zA-Z0-9_") |
3215 (point) | 3082 (point))))) |
3216 )))) | |
3217 (if b | 3083 (if b |
3218 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | 3084 (if (> (count-lines (point) b) verilog-minimum-comment-distance) |
3219 (insert (concat " // " else m " " (buffer-substring b e)))) | 3085 (insert (concat " // " else m " " (buffer-substring b e)))) |
3220 (progn | 3086 (progn |
3221 (insert " // unmatched `else or `endif") | 3087 (insert " // unmatched `else or `endif") |
3222 (ding 't)) | 3088 (ding 't))))) |
3223 ))) | |
3224 | 3089 |
3225 (; Comment close case/class/function/task/module and named block | 3090 (; Comment close case/class/function/task/module and named block |
3226 (and (looking-at "\\<end") | 3091 (and (looking-at "\\<end") |
3227 (or kill-existing-comment | 3092 (or kill-existing-comment |
3228 (not (save-excursion | 3093 (not (save-excursion |
3267 (match-end 2) ;; of verilog-end-block-ordered-re | 3132 (match-end 2) ;; of verilog-end-block-ordered-re |
3268 (let ((str " // UNMATCHED !!") | 3133 (let ((str " // UNMATCHED !!") |
3269 (err 't) | 3134 (err 't) |
3270 (here (point)) | 3135 (here (point)) |
3271 there | 3136 there |
3272 cntx | 3137 cntx) |
3273 ) | |
3274 (save-excursion | 3138 (save-excursion |
3275 (verilog-leap-to-head) | 3139 (verilog-leap-to-head) |
3276 (setq there (point)) | 3140 (setq there (point)) |
3277 (if (not (match-end 0)) | 3141 (if (not (match-end 0)) |
3278 (progn | 3142 (progn |
3280 (end-of-line) | 3144 (end-of-line) |
3281 (if kill-existing-comment | 3145 (if kill-existing-comment |
3282 (verilog-kill-existing-comment)) | 3146 (verilog-kill-existing-comment)) |
3283 (delete-horizontal-space) | 3147 (delete-horizontal-space) |
3284 (insert str) | 3148 (insert str) |
3285 (ding 't) | 3149 (ding 't)) |
3286 ) | |
3287 (let ((lim | 3150 (let ((lim |
3288 (save-excursion (verilog-beg-of-defun) (point))) | 3151 (save-excursion (verilog-beg-of-defun) (point))) |
3289 (here (point)) | 3152 (here (point))) |
3290 ) | |
3291 (cond | 3153 (cond |
3292 (;-- handle named block differently | 3154 (;-- handle named block differently |
3293 (looking-at verilog-named-block-re) | 3155 (looking-at verilog-named-block-re) |
3294 (search-forward ":") | 3156 (search-forward ":") |
3295 (setq there (point)) | 3157 (setq there (point)) |
3334 (setq str "")))) | 3196 (setq str "")))) |
3335 | 3197 |
3336 (;- else | 3198 (;- else |
3337 (match-end 4) | 3199 (match-end 4) |
3338 (let ((nest 0) | 3200 (let ((nest 0) |
3339 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)") | 3201 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
3340 ) | |
3341 (catch 'skip | 3202 (catch 'skip |
3342 (while (verilog-re-search-backward reg nil 'move) | 3203 (while (verilog-re-search-backward reg nil 'move) |
3343 (cond | 3204 (cond |
3344 ((match-end 1) ; begin | 3205 ((match-end 1) ; begin |
3345 (setq nest (1- nest))) | 3206 (setq nest (1- nest))) |
3351 (goto-char (match-end 0)) | 3212 (goto-char (match-end 0)) |
3352 (setq there (point)) | 3213 (setq there (point)) |
3353 (setq err nil) | 3214 (setq err nil) |
3354 (setq str (verilog-get-expr)) | 3215 (setq str (verilog-get-expr)) |
3355 (setq str (concat " // else: !if" str )) | 3216 (setq str (concat " // else: !if" str )) |
3356 (throw 'skip 1)) | 3217 (throw 'skip 1))))))))) |
3357 ))) | |
3358 )))) | |
3359 | 3218 |
3360 (;- end else | 3219 (;- end else |
3361 (match-end 5) | 3220 (match-end 5) |
3362 (goto-char there) | 3221 (goto-char there) |
3363 (let ((nest 0) | 3222 (let ((nest 0) |
3364 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)") | 3223 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
3365 ) | |
3366 (catch 'skip | 3224 (catch 'skip |
3367 (while (verilog-re-search-backward reg nil 'move) | 3225 (while (verilog-re-search-backward reg nil 'move) |
3368 (cond | 3226 (cond |
3369 ((match-end 1) ; begin | 3227 ((match-end 1) ; begin |
3370 (setq nest (1- nest))) | 3228 (setq nest (1- nest))) |
3376 (goto-char (match-end 0)) | 3234 (goto-char (match-end 0)) |
3377 (setq there (point)) | 3235 (setq there (point)) |
3378 (setq err nil) | 3236 (setq err nil) |
3379 (setq str (verilog-get-expr)) | 3237 (setq str (verilog-get-expr)) |
3380 (setq str (concat " // else: !if" str )) | 3238 (setq str (concat " // else: !if" str )) |
3381 (throw 'skip 1)) | 3239 (throw 'skip 1))))))))) |
3382 ))) | |
3383 )))) | |
3384 | 3240 |
3385 (;- task/function/initial et cetera | 3241 (;- task/function/initial et cetera |
3386 t | 3242 t |
3387 (match-end 0) | 3243 (match-end 0) |
3388 (goto-char (match-end 0)) | 3244 (goto-char (match-end 0)) |
3390 (setq err nil) | 3246 (setq err nil) |
3391 (setq str (verilog-get-expr)) | 3247 (setq str (verilog-get-expr)) |
3392 (setq str (concat " // " cntx str ))) | 3248 (setq str (concat " // " cntx str ))) |
3393 | 3249 |
3394 (;-- otherwise... | 3250 (;-- otherwise... |
3395 (setq str " // auto-endcomment confused ")) | 3251 (setq str " // auto-endcomment confused ")))) |
3396 )) | |
3397 | 3252 |
3398 ((and | 3253 ((and |
3399 (verilog-in-case-region-p) ;-- handle case item differently | 3254 (verilog-in-case-region-p) ;-- handle case item differently |
3400 (progn | 3255 (progn |
3401 (setq there (point)) | 3256 (setq there (point)) |
3429 )))) | 3284 )))) |
3430 (;- this is endclass, which can be nested | 3285 (;- this is endclass, which can be nested |
3431 (match-end 11) ;; of verilog-end-block-ordered-re | 3286 (match-end 11) ;; of verilog-end-block-ordered-re |
3432 ;;(goto-char there) | 3287 ;;(goto-char there) |
3433 (let ((nest 0) | 3288 (let ((nest 0) |
3434 ( reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") | 3289 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
3435 string | 3290 string) |
3436 ) | |
3437 (save-excursion | 3291 (save-excursion |
3438 (catch 'skip | 3292 (catch 'skip |
3439 (while (verilog-re-search-backward reg nil 'move) | 3293 (while (verilog-re-search-backward reg nil 'move) |
3440 (cond | 3294 (cond |
3441 ((match-end 3) ; endclass | 3295 ((match-end 3) ; endclass |
3461 (point))) | 3315 (point))) |
3462 (setq string (buffer-substring b e))) | 3316 (setq string (buffer-substring b e))) |
3463 (throw 'skip 1)))) | 3317 (throw 'skip 1)))) |
3464 )))) | 3318 )))) |
3465 (end-of-line) | 3319 (end-of-line) |
3466 (insert (concat " // " string ))) | 3320 (insert (concat " // " string )))) |
3467 ) | |
3468 | 3321 |
3469 (;- this is end{function,generate,task,module,primitive,table,generate} | 3322 (;- this is end{function,generate,task,module,primitive,table,generate} |
3470 ;- which can not be nested. | 3323 ;- which can not be nested. |
3471 t | 3324 t |
3472 (let (string reg (width nil)) | 3325 (let (string reg (width nil)) |
3477 (delete-horizontal-space) | 3330 (delete-horizontal-space) |
3478 (backward-sexp) | 3331 (backward-sexp) |
3479 (cond | 3332 (cond |
3480 ((match-end 5) ;; of verilog-end-block-ordered-re | 3333 ((match-end 5) ;; of verilog-end-block-ordered-re |
3481 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | 3334 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") |
3482 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?") | 3335 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")) |
3483 ) | |
3484 ((match-end 6) ;; of verilog-end-block-ordered-re | 3336 ((match-end 6) ;; of verilog-end-block-ordered-re |
3485 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | 3337 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) |
3486 ((match-end 7) ;; of verilog-end-block-ordered-re | 3338 ((match-end 7) ;; of verilog-end-block-ordered-re |
3487 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | 3339 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) |
3488 ((match-end 8) ;; of verilog-end-block-ordered-re | 3340 ((match-end 8) ;; of verilog-end-block-ordered-re |
3500 ((match-end 14) ;; of verilog-end-block-ordered-re | 3352 ((match-end 14) ;; of verilog-end-block-ordered-re |
3501 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 3353 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
3502 ((match-end 15) ;; of verilog-end-block-ordered-re | 3354 ((match-end 15) ;; of verilog-end-block-ordered-re |
3503 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | 3355 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) |
3504 | 3356 |
3505 (t (error "Problem in verilog-set-auto-endcomments")) | 3357 (t (error "Problem in verilog-set-auto-endcomments"))) |
3506 ) | |
3507 (let (b e) | 3358 (let (b e) |
3508 (save-excursion | 3359 (save-excursion |
3509 (verilog-re-search-backward reg nil 'move) | 3360 (verilog-re-search-backward reg nil 'move) |
3510 (cond | 3361 (cond |
3511 ((match-end 1) | 3362 ((match-end 1) |
3513 (skip-chars-forward "^ \t") | 3364 (skip-chars-forward "^ \t") |
3514 (verilog-forward-ws&directives) | 3365 (verilog-forward-ws&directives) |
3515 (if (and width (looking-at width)) | 3366 (if (and width (looking-at width)) |
3516 (progn | 3367 (progn |
3517 (goto-char (match-end 0)) | 3368 (goto-char (match-end 0)) |
3518 (verilog-forward-ws&directives) | 3369 (verilog-forward-ws&directives))) |
3519 )) | |
3520 (point)) | 3370 (point)) |
3521 e (progn | 3371 e (progn |
3522 (skip-chars-forward "a-zA-Z0-9_") | 3372 (skip-chars-forward "a-zA-Z0-9_") |
3523 (point))) | 3373 (point))) |
3524 (setq string (buffer-substring b e))) | 3374 (setq string (buffer-substring b e))) |
3575 (point)) | 3425 (point)) |
3576 ((looking-at "/[/\\*]") | 3426 ((looking-at "/[/\\*]") |
3577 b) | 3427 b) |
3578 ('t | 3428 ('t |
3579 (skip-chars-forward "^: \t\n\f") | 3429 (skip-chars-forward "^: \t\n\f") |
3580 (point) | 3430 (point))))) |
3581 )))) | |
3582 (str (buffer-substring b e))) | 3431 (str (buffer-substring b e))) |
3583 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | 3432 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) |
3584 (setq str (concat (substring str 0 e) "..."))) | 3433 (setq str (concat (substring str 0 e) "..."))) |
3585 str)) | 3434 str)) |
3586 | 3435 |
3599 (end-of-line) (point))))) | 3448 (end-of-line) (point))))) |
3600 (if (string-match | 3449 (if (string-match |
3601 (concat "\\(.*\\)" | 3450 (concat "\\(.*\\)" |
3602 (regexp-quote bra) | 3451 (regexp-quote bra) |
3603 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" | 3452 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
3604 (regexp-quote ket) | 3453 (regexp-quote ket) |
3605 "\\(.*\\)$") signal-string) | 3454 "\\(.*\\)$") signal-string) |
3606 (let* ((sig-head (match-string 1 signal-string)) | 3455 (let* ((sig-head (match-string 1 signal-string)) |
3607 (vec-start (string-to-number (match-string 2 signal-string))) | 3456 (vec-start (string-to-number (match-string 2 signal-string))) |
3608 (vec-end (if (= (match-beginning 3) (match-end 3)) | 3457 (vec-end (if (= (match-beginning 3) (match-end 3)) |
3609 vec-start | 3458 vec-start |
3610 (string-to-number | 3459 (string-to-number |
3763 (insert (concat " " code))))) | 3612 (insert (concat " " code))))) |
3764 (t | 3613 (t |
3765 ))) | 3614 ))) |
3766 ((verilog-in-star-comment-p) | 3615 ((verilog-in-star-comment-p) |
3767 (re-search-backward "/\*") | 3616 (re-search-backward "/\*") |
3768 (insert (format " // surefire lint_off_line %6s" code )) | 3617 (insert (format " // surefire lint_off_line %6s" code ))) |
3769 ) | |
3770 (t | 3618 (t |
3771 (insert (format " // surefire lint_off_line %6s" code )) | 3619 (insert (format " // surefire lint_off_line %6s" code )) |
3772 ))))))))) | 3620 ))))))))) |
3773 | 3621 |
3774 (defun verilog-verilint-off () | 3622 (defun verilog-verilint-off () |
3821 (setq enable-local-eval t) | 3669 (setq enable-local-eval t) |
3822 ;; Make sure any sub-files we read get proper mode | 3670 ;; Make sure any sub-files we read get proper mode |
3823 (setq default-major-mode `verilog-mode) | 3671 (setq default-major-mode `verilog-mode) |
3824 ;; Ditto files already read in | 3672 ;; Ditto files already read in |
3825 (mapc (lambda (buf) | 3673 (mapc (lambda (buf) |
3826 (when (buffer-file-name buf) | 3674 (when (buffer-file-name buf) |
3827 (save-excursion | 3675 (save-excursion |
3828 (set-buffer buf) | 3676 (set-buffer buf) |
3829 (verilog-mode)))) | 3677 (verilog-mode)))) |
3830 (buffer-list)) | 3678 (buffer-list)) |
3831 ;; Process the files | 3679 ;; Process the files |
3832 (mapcar '(lambda (buf) | 3680 (mapcar '(lambda (buf) |
3833 (when (buffer-file-name buf) | 3681 (when (buffer-file-name buf) |
3834 (save-excursion | 3682 (save-excursion |
3835 (if (not (file-exists-p (buffer-file-name buf))) | 3683 (if (not (file-exists-p (buffer-file-name buf))) |
3941 (if (and | 3789 (if (and |
3942 verilog-indent-lists | 3790 verilog-indent-lists |
3943 (not (verilog-in-coverage)) | 3791 (not (verilog-in-coverage)) |
3944 (verilog-in-paren)) | 3792 (verilog-in-paren)) |
3945 (progn (setq par 1) | 3793 (progn (setq par 1) |
3946 (throw 'nesting 'block)) | 3794 (throw 'nesting 'block))) |
3947 ) | |
3948 | 3795 |
3949 ;; See if we are continuing a previous line | 3796 ;; See if we are continuing a previous line |
3950 (while t | 3797 (while t |
3951 ;; trap out if we crawl off the top of the buffer | 3798 ;; trap out if we crawl off the top of the buffer |
3952 (if (bobp) (throw 'nesting 'cpp)) | 3799 (if (bobp) (throw 'nesting 'cpp)) |
4024 ((match-end 11) ; class | 3871 ((match-end 11) ; class |
4025 ;; Search back for matching class | 3872 ;; Search back for matching class |
4026 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | 3873 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) |
4027 ((match-end 12) ; covergroup | 3874 ((match-end 12) ; covergroup |
4028 ;; Search back for matching covergroup | 3875 ;; Search back for matching covergroup |
4029 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | 3876 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
4030 ) | |
4031 (catch 'skip | 3877 (catch 'skip |
4032 (while (verilog-re-search-backward reg nil 'move) | 3878 (while (verilog-re-search-backward reg nil 'move) |
4033 (cond | 3879 (cond |
4034 ((match-end 1) ; begin | 3880 ((match-end 1) ; begin |
4035 (setq nest (1- nest)) | 3881 (setq nest (1- nest)) |
4036 (if (= 0 nest) | 3882 (if (= 0 nest) |
4037 (throw 'skip 1))) | 3883 (throw 'skip 1))) |
4038 ((match-end 2) ; end | 3884 ((match-end 2) ; end |
4039 (setq nest (1+ nest))))) | 3885 (setq nest (1+ nest))))) |
4040 ) | 3886 ))))))) |
4041 )) | 3887 (throw 'nesting (verilog-calc-1))) |
4042 )))) | |
4043 (throw 'nesting (verilog-calc-1)) | |
4044 ) | |
4045 );; catch nesting | 3888 );; catch nesting |
4046 );; type | 3889 );; type |
4047 ) | 3890 ) |
4048 ;; Return type of block and indent level. | 3891 ;; Return type of block and indent level. |
4049 (if (not type) | 3892 (if (not type) |
4056 ((eq type 'statement) | 3899 ((eq type 'statement) |
4057 (list type (current-column))) | 3900 (list type (current-column))) |
4058 ((eq type 'defun) | 3901 ((eq type 'defun) |
4059 (list type 0)) | 3902 (list type 0)) |
4060 (t | 3903 (t |
4061 (list type (verilog-current-indent-level))))) | 3904 (list type (verilog-current-indent-level)))))))) |
4062 ))) | 3905 |
4063 (defun verilog-wai () | 3906 (defun verilog-wai () |
4064 "Show matching nesting block for debugging." | 3907 "Show matching nesting block for debugging." |
4065 (interactive) | 3908 (interactive) |
4066 (save-excursion | 3909 (save-excursion |
4067 (let ((nesting (verilog-calc-1))) | 3910 (let ((nesting (verilog-calc-1))) |
4071 (catch 'nesting | 3914 (catch 'nesting |
4072 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) | 3915 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) |
4073 (cond | 3916 (cond |
4074 ((equal (char-after) ?\{) | 3917 ((equal (char-after) ?\{) |
4075 (if (verilog-at-constraint-p) | 3918 (if (verilog-at-constraint-p) |
4076 (throw 'nesting 'block) | 3919 (throw 'nesting 'block))) |
4077 )) | |
4078 ((equal (char-after) ?\}) | 3920 ((equal (char-after) ?\}) |
4079 | 3921 |
4080 (let ((there (verilog-at-close-constraint-p))) | 3922 (let ((there (verilog-at-close-constraint-p))) |
4081 (if there (goto-char there)))) | 3923 (if there (goto-char there)))) |
4082 | 3924 |
4131 (defun verilog-calculate-indent-directive () | 3973 (defun verilog-calculate-indent-directive () |
4132 "Return indentation level for directive. | 3974 "Return indentation level for directive. |
4133 For speed, the searcher looks at the last directive, not the indent | 3975 For speed, the searcher looks at the last directive, not the indent |
4134 of the appropriate enclosing block." | 3976 of the appropriate enclosing block." |
4135 (let ((base -1) ;; Indent of the line that determines our indentation | 3977 (let ((base -1) ;; Indent of the line that determines our indentation |
4136 (ind 0) ;; Relative offset caused by other directives (like `endif on same line as `else) | 3978 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) |
4137 ) | |
4138 ;; Start at current location, scan back for another directive | 3979 ;; Start at current location, scan back for another directive |
4139 | 3980 |
4140 (save-excursion | 3981 (save-excursion |
4141 (beginning-of-line) | 3982 (beginning-of-line) |
4142 (while (and (< base 0) | 3983 (while (and (< base 0) |
4143 (verilog-re-search-backward verilog-directive-re nil t)) | 3984 (verilog-re-search-backward verilog-directive-re nil t)) |
4144 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | 3985 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) |
4145 (setq base (current-indentation)) | 3986 (setq base (current-indentation)))) |
4146 )) | |
4147 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL | 3987 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
4148 (setq ind (- ind verilog-indent-level-directive))) | 3988 (setq ind (- ind verilog-indent-level-directive))) |
4149 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | 3989 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL |
4150 (setq ind (+ ind verilog-indent-level-directive))) | 3990 (setq ind (+ ind verilog-indent-level-directive))) |
4151 ((looking-at verilog-directive-begin) | 3991 ((looking-at verilog-directive-begin) |
4221 ((looking-at "\\<endsequence\\>") | 4061 ((looking-at "\\<endsequence\\>") |
4222 ;; 12: Search back for matching sequence | 4062 ;; 12: Search back for matching sequence |
4223 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | 4063 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) |
4224 ((looking-at "\\<endclocking\\>") | 4064 ((looking-at "\\<endclocking\\>") |
4225 ;; 12: Search back for matching clocking | 4065 ;; 12: Search back for matching clocking |
4226 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" )) | 4066 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
4227 ) | |
4228 (if reg | 4067 (if reg |
4229 (catch 'skip | 4068 (catch 'skip |
4230 (let (sreg) | 4069 (let (sreg) |
4231 (while (verilog-re-search-backward reg nil 'move) | 4070 (while (verilog-re-search-backward reg nil 'move) |
4232 (cond | 4071 (cond |
4266 (setq continued nil) | 4105 (setq continued nil) |
4267 (while (and continued | 4106 (while (and continued |
4268 (save-excursion | 4107 (save-excursion |
4269 (skip-chars-backward " \t") | 4108 (skip-chars-backward " \t") |
4270 (not (bolp)))) | 4109 (not (bolp)))) |
4271 (setq continued (verilog-backward-token)) | 4110 (setq continued (verilog-backward-token))))) |
4272 ) ;; while | |
4273 )) | |
4274 (setq continued nil)) | 4111 (setq continued nil)) |
4275 continued)) | 4112 continued)) |
4276 | 4113 |
4277 (defun verilog-backward-token () | 4114 (defun verilog-backward-token () |
4278 "Step backward token, returning true if we are now at an end of line token." | 4115 "Step backward token, returning true if we are now at an end of line token." |
4287 (; If a "}" is prefixed by a ";", then this is a complete statement | 4124 (; If a "}" is prefixed by a ";", then this is a complete statement |
4288 ; i.e.: constraint foo { a = b; } | 4125 ; i.e.: constraint foo { a = b; } |
4289 (= (preceding-char) ?\}) | 4126 (= (preceding-char) ?\}) |
4290 (progn | 4127 (progn |
4291 (backward-char) | 4128 (backward-char) |
4292 (verilog-at-close-constraint-p)) | 4129 (verilog-at-close-constraint-p))) |
4293 ) | |
4294 (;-- constraint foo { a = b } | 4130 (;-- constraint foo { a = b } |
4295 ; is a complete statement. *sigh* | 4131 ; is a complete statement. *sigh* |
4296 (= (preceding-char) ?\{) | 4132 (= (preceding-char) ?\{) |
4297 (progn | 4133 (progn |
4298 (backward-char) | 4134 (backward-char) |
4299 (not (verilog-at-constraint-p))) | 4135 (not (verilog-at-constraint-p)))) |
4300 ) | |
4301 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete | 4136 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4302 ; also could be simply '@(foo)' | 4137 ; also could be simply '@(foo)' |
4303 ; or foo u1 #(a=8) | 4138 ; or foo u1 #(a=8) |
4304 ; (b, ... which ISN'T complete | 4139 ; (b, ... which ISN'T complete |
4305 ;;;; Do we need this??? | 4140 ;;;; Do we need this??? |
4320 (backward-char) | 4155 (backward-char) |
4321 (save-excursion | 4156 (save-excursion |
4322 (verilog-backward-token) | 4157 (verilog-backward-token) |
4323 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | 4158 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) |
4324 ((= (preceding-char) ?\#) | 4159 ((= (preceding-char) ?\#) |
4325 (backward-char) | 4160 (backward-char)) |
4326 ) | 4161 (t t))))))) |
4327 (t t)) | |
4328 ))))) | |
4329 | 4162 |
4330 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | 4163 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete |
4331 t | 4164 t |
4332 (forward-word -1) | 4165 (forward-word -1) |
4333 (cond | 4166 (cond |
4344 (backward-char) | 4177 (backward-char) |
4345 (verilog-backward-syntactic-ws) | 4178 (verilog-backward-syntactic-ws) |
4346 (backward-sexp) | 4179 (backward-sexp) |
4347 (if (looking-at verilog-nameable-item-re ) | 4180 (if (looking-at verilog-nameable-item-re ) |
4348 nil | 4181 nil |
4349 t) | 4182 t)) |
4350 ) | |
4351 ((= (preceding-char) ?\#) | 4183 ((= (preceding-char) ?\#) |
4352 (backward-char) | 4184 (backward-char) |
4353 t) | 4185 t) |
4354 ((= (preceding-char) ?\`) | 4186 ((= (preceding-char) ?\`) |
4355 (backward-char) | 4187 (backward-char) |
4356 t) | 4188 t) |
4357 | 4189 |
4358 (t | 4190 (t |
4359 (goto-char back) | 4191 (goto-char back) |
4360 t) | 4192 t)))))))) |
4361 ))))))) | |
4362 | 4193 |
4363 (defun verilog-backward-syntactic-ws (&optional bound) | 4194 (defun verilog-backward-syntactic-ws (&optional bound) |
4364 "Backward skip over syntactic whitespace for Emacs 19. | 4195 "Backward skip over syntactic whitespace for Emacs 19. |
4365 Optional BOUND limits search." | 4196 Optional BOUND limits search." |
4366 (save-restriction | 4197 (save-restriction |
4368 (if (< bound (point)) | 4199 (if (< bound (point)) |
4369 (progn | 4200 (progn |
4370 (narrow-to-region bound (point)) | 4201 (narrow-to-region bound (point)) |
4371 (while (/= here (point)) | 4202 (while (/= here (point)) |
4372 (setq here (point)) | 4203 (setq here (point)) |
4373 (verilog-skip-backward-comments) | 4204 (verilog-skip-backward-comments)))))) |
4374 ))) | |
4375 )) | |
4376 t) | 4205 t) |
4377 | 4206 |
4378 (defun verilog-forward-syntactic-ws (&optional bound) | 4207 (defun verilog-forward-syntactic-ws (&optional bound) |
4379 "Forward skip over syntactic whitespace for Emacs 19. | 4208 "Forward skip over syntactic whitespace for Emacs 19. |
4380 Optional BOUND limits search." | 4209 Optional BOUND limits search." |
4381 (save-restriction | 4210 (save-restriction |
4382 (let* ((bound (or bound (point-max))) | 4211 (let* ((bound (or bound (point-max))) |
4383 (here bound) | 4212 (here bound)) |
4384 ) | |
4385 (if (> bound (point)) | 4213 (if (> bound (point)) |
4386 (progn | 4214 (progn |
4387 (narrow-to-region (point) bound) | 4215 (narrow-to-region (point) bound) |
4388 (while (/= here (point)) | 4216 (while (/= here (point)) |
4389 (setq here (point)) | 4217 (setq here (point)) |
4390 (forward-comment (buffer-size)) | 4218 (forward-comment (buffer-size)))))))) |
4391 ))) | |
4392 ))) | |
4393 | 4219 |
4394 (defun verilog-backward-ws&directives (&optional bound) | 4220 (defun verilog-backward-ws&directives (&optional bound) |
4395 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | 4221 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. |
4396 Optional BOUND limits search." | 4222 Optional BOUND limits search." |
4397 (save-restriction | 4223 (save-restriction |
4421 (verilog-back-to-start-translate-off (point-min))) | 4247 (verilog-back-to-start-translate-off (point-min))) |
4422 ((looking-at verilog-directive-re-1) | 4248 ((looking-at verilog-directive-re-1) |
4423 (point)) | 4249 (point)) |
4424 (t | 4250 (t |
4425 nil)))) | 4251 nil)))) |
4426 (if p (goto-char p)) | 4252 (if p (goto-char p)))))))) |
4427 ))) | |
4428 ))) | |
4429 | 4253 |
4430 (defun verilog-forward-ws&directives (&optional bound) | 4254 (defun verilog-forward-ws&directives (&optional bound) |
4431 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | 4255 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. |
4432 Optional BOUND limits search." | 4256 Optional BOUND limits search." |
4433 (save-restriction | 4257 (save-restriction |
4434 (let* ((bound (or bound (point-max))) | 4258 (let* ((bound (or bound (point-max))) |
4435 (here bound) | 4259 (here bound) |
4436 jump | 4260 jump) |
4437 ) | |
4438 (if (> bound (point)) | 4261 (if (> bound (point)) |
4439 (progn | 4262 (progn |
4440 (let ((state | 4263 (let ((state |
4441 (save-excursion | 4264 (save-excursion |
4442 (parse-partial-sexp (point-min) (point))))) | 4265 (parse-partial-sexp (point-min) (point))))) |
4453 (save-excursion | 4276 (save-excursion |
4454 (beginning-of-line) | 4277 (beginning-of-line) |
4455 (if (looking-at verilog-directive-re-1) | 4278 (if (looking-at verilog-directive-re-1) |
4456 (setq jump t))) | 4279 (setq jump t))) |
4457 (if jump | 4280 (if jump |
4458 (beginning-of-line 2)) | 4281 (beginning-of-line 2)))))))) |
4459 ))) | |
4460 ))) | |
4461 | 4282 |
4462 (defun verilog-in-comment-p () | 4283 (defun verilog-in-comment-p () |
4463 "Return true if in a star or // comment." | 4284 "Return true if in a star or // comment." |
4464 (let ((state | 4285 (let ((state |
4465 (save-excursion | 4286 (save-excursion |
4535 (and | 4356 (and |
4536 (equal (char-after) ?\{) | 4357 (equal (char-after) ?\{) |
4537 (forward-list) | 4358 (forward-list) |
4538 (progn (backward-char 1) | 4359 (progn (backward-char 1) |
4539 (verilog-backward-ws&directives) | 4360 (verilog-backward-ws&directives) |
4540 (equal (char-before) ?\;)) | 4361 (equal (char-before) ?\;)))) |
4541 )) | |
4542 ;; maybe | 4362 ;; maybe |
4543 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | 4363 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) |
4544 ;; not | 4364 ;; not |
4545 nil | 4365 nil)) |
4546 ) | |
4547 ) | |
4548 | 4366 |
4549 (defun verilog-parenthesis-depth () | 4367 (defun verilog-parenthesis-depth () |
4550 "Return non zero if in parenthetical-expression." | 4368 "Return non zero if in parenthetical-expression." |
4551 (save-excursion | 4369 (save-excursion |
4552 (nth 1 (parse-partial-sexp (point-min) (point))))) | 4370 (nth 1 (parse-partial-sexp (point-min) (point))))) |
4606 (search-backward "/*") | 4424 (search-backward "/*") |
4607 (skip-chars-backward " \t\n\f") | 4425 (skip-chars-backward " \t\n\f") |
4608 t) | 4426 t) |
4609 ((and (not (bobp)) | 4427 ((and (not (bobp)) |
4610 (= (char-before) ?\/) | 4428 (= (char-before) ?\/) |
4611 (= (char-before (1- (point))) ?\*) | 4429 (= (char-before (1- (point))) ?\*)) |
4612 ) | |
4613 (goto-char (- (point) 2)) | 4430 (goto-char (- (point) 2)) |
4614 t) | 4431 t) |
4615 (t | 4432 (t |
4616 (skip-chars-backward " \t\n\f") | 4433 (skip-chars-backward " \t\n\f") |
4617 nil))))))) | 4434 nil))))))) |
4648 ((verilog-continued-line) | 4465 ((verilog-continued-line) |
4649 (let ((sp1 (point))) | 4466 (let ((sp1 (point))) |
4650 (if (verilog-continued-line) | 4467 (if (verilog-continued-line) |
4651 (progn | 4468 (progn |
4652 (goto-char sp) | 4469 (goto-char sp) |
4653 (setq | 4470 (setq indent-str |
4654 indent-str (list 'statement (verilog-current-indent-level)))) | 4471 (list 'statement (verilog-current-indent-level)))) |
4655 (goto-char sp1) | 4472 (goto-char sp1) |
4656 (setq indent-str (list 'block (verilog-current-indent-level))))) | 4473 (setq indent-str (list 'block (verilog-current-indent-level))))) |
4657 (goto-char sp)) | 4474 (goto-char sp)) |
4658 ((goto-char sp) | 4475 ((goto-char sp) |
4659 (setq indent-str (verilog-calculate-indent)))) | 4476 (setq indent-str (verilog-calculate-indent)))) |
4699 (skip-chars-forward " \t"))) | 4516 (skip-chars-forward " \t"))) |
4700 ((= (following-char) ?\[) | 4517 ((= (following-char) ?\[) |
4701 (progn | 4518 (progn |
4702 (forward-char 1) | 4519 (forward-char 1) |
4703 (backward-up-list -1) | 4520 (backward-up-list -1) |
4704 (skip-chars-forward " \t"))) | 4521 (skip-chars-forward " \t")))) |
4705 ) | |
4706 (current-column)) | 4522 (current-column)) |
4707 (progn | 4523 (progn |
4708 (goto-char fst) | 4524 (goto-char fst) |
4709 (+ (current-column) verilog-cexp-indent)) | 4525 (+ (current-column) verilog-cexp-indent)))))) |
4710 )))) | |
4711 (goto-char here) | 4526 (goto-char here) |
4712 (indent-line-to val)) | 4527 (indent-line-to val))) |
4713 ) | |
4714 ((= (preceding-char) ?\) ) | 4528 ((= (preceding-char) ?\) ) |
4715 (goto-char here) | 4529 (goto-char here) |
4716 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | 4530 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) |
4717 (indent-line-to val))) | 4531 (indent-line-to val))) |
4718 (t | 4532 (t |
4722 (if (and (< (point) here) | 4536 (if (and (< (point) here) |
4723 (verilog-re-search-forward "=[ \\t]*" here 'move)) | 4537 (verilog-re-search-forward "=[ \\t]*" here 'move)) |
4724 (setq val (current-column)) | 4538 (setq val (current-column)) |
4725 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | 4539 (setq val (eval (cdr (assoc type verilog-indent-alist))))) |
4726 (goto-char here) | 4540 (goto-char here) |
4727 (indent-line-to val))) | 4541 (indent-line-to val)))))) |
4728 ))) | |
4729 | 4542 |
4730 (; handle inside parenthetical expressions | 4543 (; handle inside parenthetical expressions |
4731 (eq type 'cparenexp) | 4544 (eq type 'cparenexp) |
4732 (let ((val (save-excursion | 4545 (let ((val (save-excursion |
4733 (backward-up-list 1) | 4546 (backward-up-list 1) |
4735 (skip-chars-forward " \t") | 4548 (skip-chars-forward " \t") |
4736 (current-column)))) | 4549 (current-column)))) |
4737 (indent-line-to val) | 4550 (indent-line-to val) |
4738 (if (and (not (verilog-in-struct-region-p)) | 4551 (if (and (not (verilog-in-struct-region-p)) |
4739 (looking-at verilog-declaration-re)) | 4552 (looking-at verilog-declaration-re)) |
4740 (verilog-indent-declaration ind)) | 4553 (verilog-indent-declaration ind)))) |
4741 )) | |
4742 | 4554 |
4743 (;-- Handle the ends | 4555 (;-- Handle the ends |
4744 (or | 4556 (or |
4745 (looking-at verilog-end-block-re ) | 4557 (looking-at verilog-end-block-re ) |
4746 (verilog-at-close-constraint-p)) | 4558 (verilog-at-close-constraint-p)) |
4772 (verilog-indent-declaration ind)) | 4584 (verilog-indent-declaration ind)) |
4773 | 4585 |
4774 (;-- Everything else | 4586 (;-- Everything else |
4775 t | 4587 t |
4776 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | 4588 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) |
4777 (indent-line-to val))) | 4589 (indent-line-to val)))) |
4778 ) | 4590 |
4779 (if (looking-at "[ \t]+$") | 4591 (if (looking-at "[ \t]+$") |
4780 (skip-chars-forward " \t")) | 4592 (skip-chars-forward " \t")) |
4781 indent-str ; Return indent data | 4593 indent-str ; Return indent data |
4782 )) | 4594 )) |
4783 | 4595 |
4821 (comment-column | 4633 (comment-column |
4822 comment-column ) | 4634 comment-column ) |
4823 (t | 4635 (t |
4824 (save-excursion | 4636 (save-excursion |
4825 (re-search-backward "//" nil t) | 4637 (re-search-backward "//" nil t) |
4826 (current-column))) | 4638 (current-column)))))) |
4827 ))) | |
4828 (indent-line-to stcol) | 4639 (indent-line-to stcol) |
4829 stcol)) | 4640 stcol)) |
4830 | 4641 |
4831 (defun verilog-more-comment () | 4642 (defun verilog-more-comment () |
4832 "Make more comment lines like the previous." | 4643 "Make more comment lines like the previous." |
4841 (comment-column | 4652 (comment-column |
4842 comment-column ) | 4653 comment-column ) |
4843 (t | 4654 (t |
4844 (save-excursion | 4655 (save-excursion |
4845 (re-search-backward "//" nil t) | 4656 (re-search-backward "//" nil t) |
4846 (current-column))) | 4657 (current-column)))))) |
4847 ))) | |
4848 (progn | 4658 (progn |
4849 (indent-to stcol) | 4659 (indent-to stcol) |
4850 (if (and star | 4660 (if (and star |
4851 (save-excursion | 4661 (save-excursion |
4852 (forward-line -1) | 4662 (forward-line -1) |
4910 (base-ind | 4720 (base-ind |
4911 (progn | 4721 (progn |
4912 (goto-char start) | 4722 (goto-char start) |
4913 (verilog-do-indent (verilog-calculate-indent)) | 4723 (verilog-do-indent (verilog-calculate-indent)) |
4914 (verilog-forward-ws&directives) | 4724 (verilog-forward-ws&directives) |
4915 (current-column))) | 4725 (current-column)))) |
4916 ) | |
4917 (goto-char end) | 4726 (goto-char end) |
4918 (goto-char start) | 4727 (goto-char start) |
4919 (if (> (- end start) 100) | 4728 (if (> (- end start) 100) |
4920 (message "Lining up declarations..(please stand by)")) | 4729 (message "Lining up declarations..(please stand by)")) |
4921 ;; Get the beginning of line indent first | 4730 ;; Get the beginning of line indent first |
4925 ( (save-excursion (skip-chars-backward " \t") | 4734 ( (save-excursion (skip-chars-backward " \t") |
4926 (bolp)) | 4735 (bolp)) |
4927 (verilog-forward-ws&directives) | 4736 (verilog-forward-ws&directives) |
4928 (indent-line-to base-ind) | 4737 (indent-line-to base-ind) |
4929 (verilog-forward-ws&directives) | 4738 (verilog-forward-ws&directives) |
4930 (verilog-re-search-forward "[ \t\n\f]" e 'move) | 4739 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
4931 ) | |
4932 (t | 4740 (t |
4933 (just-one-space) | 4741 (just-one-space) |
4934 (verilog-re-search-forward "[ \t\n\f]" e 'move) | 4742 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
4935 ) | 4743 ;;(forward-line) |
4936 ) | |
4937 ) | 4744 ) |
4938 ;;(forward-line)) | |
4939 ;; Now find biggest prefix | 4745 ;; Now find biggest prefix |
4940 (setq ind (verilog-get-lineup-indent start edpos)) | 4746 (setq ind (verilog-get-lineup-indent start edpos)) |
4941 ;; Now indent each line. | 4747 ;; Now indent each line. |
4942 (goto-char start) | 4748 (goto-char start) |
4943 (while (progn (setq e (marker-position edpos)) | 4749 (while (progn (setq e (marker-position edpos)) |
4958 (goto-char (marker-position m1)) | 4764 (goto-char (marker-position m1)) |
4959 (just-one-space) | 4765 (just-one-space) |
4960 (indent-to ind)) | 4766 (indent-to ind)) |
4961 (progn | 4767 (progn |
4962 (just-one-space) | 4768 (just-one-space) |
4963 (indent-to ind)) | 4769 (indent-to ind))))) |
4964 ))) | |
4965 ((verilog-continued-line-1 start) | 4770 ((verilog-continued-line-1 start) |
4966 (goto-char e) | 4771 (goto-char e) |
4967 (indent-line-to ind)) | 4772 (indent-line-to ind)) |
4968 (t ; Must be comment or white space | 4773 (t ; Must be comment or white space |
4969 (goto-char e) | 4774 (goto-char e) |
4970 (verilog-forward-ws&directives) | 4775 (verilog-forward-ws&directives) |
4971 (forward-line -1)) | 4776 (forward-line -1))) |
4972 ) | |
4973 (forward-line 1)) | 4777 (forward-line 1)) |
4974 (message ""))))) | 4778 (message ""))))) |
4975 | 4779 |
4976 (defun verilog-pretty-expr (&optional myre) | 4780 (defun verilog-pretty-expr (&optional myre) |
4977 "Line up expressions around point." | 4781 "Line up expressions around point, or optional regexp MYRE." |
4978 (interactive "sRegular Expression: ((<|:)?=) ") | 4782 (interactive "sRegular Expression: ((<|:)?=) ") |
4979 (save-excursion | 4783 (save-excursion |
4980 (if (or (eq myre nil) | 4784 (if (or (eq myre nil) |
4981 (string-equal myre "")) | 4785 (string-equal myre "")) |
4982 (setq myre "\\(<\\|:\\)?=")) | 4786 (setq myre "\\(<\\|:\\)?=")) |
4993 (setq e (point)) | 4797 (setq e (point)) |
4994 (verilog-backward-syntactic-ws) | 4798 (verilog-backward-syntactic-ws) |
4995 (beginning-of-line) | 4799 (beginning-of-line) |
4996 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg))) | 4800 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg))) |
4997 (looking-at myre) | 4801 (looking-at myre) |
4998 (not (bobp)) | 4802 (not (bobp))) |
4999 ) | |
5000 (setq e (point)) | 4803 (setq e (point)) |
5001 (verilog-backward-syntactic-ws) | 4804 (verilog-backward-syntactic-ws) |
5002 (beginning-of-line) | 4805 (beginning-of-line) |
5003 ) ;Ack, need to grok `define | 4806 ) ;Ack, need to grok `define |
5004 e)) | 4807 e)) |
5013 (concat "^\\s-*" verilog-complete-reg))) | 4816 (concat "^\\s-*" verilog-complete-reg))) |
5014 (looking-at myre)) | 4817 (looking-at myre)) |
5015 (end-of-line) | 4818 (end-of-line) |
5016 (setq e (point)) | 4819 (setq e (point)) |
5017 (verilog-forward-syntactic-ws) | 4820 (verilog-forward-syntactic-ws) |
5018 (beginning-of-line) | 4821 (beginning-of-line)) |
5019 ) | |
5020 e)) | 4822 e)) |
5021 (edpos (set-marker (make-marker) end)) | 4823 (edpos (set-marker (make-marker) end)) |
5022 (ind) | 4824 (ind)) |
5023 ) | |
5024 (goto-char start) | 4825 (goto-char start) |
5025 (verilog-do-indent (verilog-calculate-indent)) | 4826 (verilog-do-indent (verilog-calculate-indent)) |
5026 (if (> (- end start) 100) | 4827 (if (> (- end start) 100) |
5027 (message "Lining up expressions..(please stand by)")) | 4828 (message "Lining up expressions..(please stand by)")) |
5028 | 4829 |
5029 ;; Set indent to minimum throughout region | 4830 ;; Set indent to minimum throughout region |
5030 (while (< (point) (marker-position edpos)) | 4831 (while (< (point) (marker-position edpos)) |
5031 (beginning-of-line) | 4832 (beginning-of-line) |
5032 (verilog-just-one-space myre) | 4833 (verilog-just-one-space myre) |
5033 (end-of-line) | 4834 (end-of-line) |
5034 (verilog-forward-syntactic-ws) | 4835 (verilog-forward-syntactic-ws)) |
5035 ) | |
5036 | 4836 |
5037 ;; Now find biggest prefix | 4837 ;; Now find biggest prefix |
5038 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) | 4838 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) |
5039 | 4839 |
5040 ;; Now indent each line. | 4840 ;; Now indent each line. |
5047 (cond | 4847 (cond |
5048 ((looking-at myre) | 4848 ((looking-at myre) |
5049 (goto-char (match-end 1)) | 4849 (goto-char (match-end 1)) |
5050 (if (eq (char-after) ?=) | 4850 (if (eq (char-after) ?=) |
5051 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = | 4851 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = |
5052 (indent-to ind) | 4852 (indent-to ind))) |
5053 ) | |
5054 ) | |
5055 ((verilog-continued-line-1 start) | 4853 ((verilog-continued-line-1 start) |
5056 (goto-char e) | 4854 (goto-char e) |
5057 (indent-line-to ind)) | 4855 (indent-line-to ind)) |
5058 (t ; Must be comment or white space | 4856 (t ; Must be comment or white space |
5059 (goto-char e) | 4857 (goto-char e) |
5060 (verilog-forward-ws&directives) | 4858 (verilog-forward-ws&directives) |
5061 (forward-line -1)) | 4859 (forward-line -1))) |
5062 ) | |
5063 (forward-line 1)) | 4860 (forward-line 1)) |
5064 (message "") | 4861 (message ""))))) |
5065 )))) | |
5066 | 4862 |
5067 (defun verilog-just-one-space (myre) | 4863 (defun verilog-just-one-space (myre) |
5068 "Remove extra spaces around regular expression MYRE." | 4864 "Remove extra spaces around regular expression MYRE." |
5069 (interactive) | 4865 (interactive) |
5070 (if (and (not(looking-at verilog-complete-reg)) | 4866 (if (and (not(looking-at verilog-complete-reg)) |
5071 (looking-at myre)) | 4867 (looking-at myre)) |
5072 (let ((p1 (match-end 1)) | 4868 (let ((p1 (match-end 1)) |
5073 (p2 (match-end 2))) | 4869 (p2 (match-end 2))) |
5074 (progn | 4870 (progn |
5075 (goto-char p2) | 4871 (goto-char p2) |
5076 (if (looking-at "\\s-") (just-one-space) ) | 4872 (if (looking-at "\\s-") (just-one-space)) |
5077 (goto-char p1) | 4873 (goto-char p1) |
5078 (forward-char -1) | 4874 (forward-char -1) |
5079 (if (looking-at "\\s-") (just-one-space)) | 4875 (if (looking-at "\\s-") (just-one-space))))) |
5080 ) | |
5081 )) | |
5082 (message "")) | 4876 (message "")) |
5083 | 4877 |
5084 (defun verilog-indent-declaration (baseind) | 4878 (defun verilog-indent-declaration (baseind) |
5085 "Indent current lines as declaration. | 4879 "Indent current lines as declaration. |
5086 Line up the variable names based on previous declaration's indentation. | 4880 Line up the variable names based on previous declaration's indentation. |
5091 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | 4885 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) |
5092 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | 4886 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) |
5093 (point))) | 4887 (point))) |
5094 (ind) | 4888 (ind) |
5095 (val) | 4889 (val) |
5096 (m1 (make-marker)) | 4890 (m1 (make-marker))) |
5097 ) | |
5098 (setq val | 4891 (setq val |
5099 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) | 4892 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
5100 (indent-line-to val) | 4893 (indent-line-to val) |
5101 | 4894 |
5102 ;; Use previous declaration (in this module) as template. | 4895 ;; Use previous declaration (in this module) as template. |
5123 (progn | 4916 (progn |
5124 (forward-char -1) | 4917 (forward-char -1) |
5125 (just-one-space) | 4918 (just-one-space) |
5126 (goto-char (marker-position m1)) | 4919 (goto-char (marker-position m1)) |
5127 (just-one-space) | 4920 (just-one-space) |
5128 (indent-to ind) | 4921 (indent-to ind)) |
5129 ) | |
5130 (if (/= (current-column) ind) | 4922 (if (/= (current-column) ind) |
5131 (progn | 4923 (progn |
5132 (just-one-space) | 4924 (just-one-space) |
5133 (indent-to ind)) | 4925 (indent-to ind))))) |
5134 ))) | |
5135 (if (looking-at verilog-declaration-re-2-no-macro) | 4926 (if (looking-at verilog-declaration-re-2-no-macro) |
5136 (let ((p (match-end 0))) | 4927 (let ((p (match-end 0))) |
5137 (set-marker m1 p) | 4928 (set-marker m1 p) |
5138 (if (verilog-re-search-forward "[[`#]" p 'move) | 4929 (if (verilog-re-search-forward "[[`#]" p 'move) |
5139 (progn | 4930 (progn |
5360 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | 5151 (setq match (buffer-substring (match-beginning 0) (match-end 0))) |
5361 (if (string-match (concat "\\<" verilog-str) match) | 5152 (if (string-match (concat "\\<" verilog-str) match) |
5362 (if (or (null verilog-pred) | 5153 (if (or (null verilog-pred) |
5363 (funcall verilog-pred match)) | 5154 (funcall verilog-pred match)) |
5364 (setq verilog-all (cons match verilog-all))))) | 5155 (setq verilog-all (cons match verilog-all))))) |
5365 (forward-line 1) | 5156 (forward-line 1))) |
5366 ) | 5157 verilog-all) |
5367 ) | |
5368 verilog-all | |
5369 ) | |
5370 | 5158 |
5371 (defun verilog-type-completion () | 5159 (defun verilog-type-completion () |
5372 "Calculate all possible completions for types." | 5160 "Calculate all possible completions for types." |
5373 (let ((start (point)) | 5161 (let ((start (point)) |
5374 goon) | 5162 goon) |
5661 (re-search-forward (verilog-build-defun-re label t) nil t))) | 5449 (re-search-forward (verilog-build-defun-re label t) nil t))) |
5662 (when pt | 5450 (when pt |
5663 (goto-char pt) | 5451 (goto-char pt) |
5664 (beginning-of-line)) | 5452 (beginning-of-line)) |
5665 pt) | 5453 pt) |
5666 (verilog-goto-defun-file label) | 5454 (verilog-goto-defun-file label)))) |
5667 ))) | |
5668 | 5455 |
5669 ;; Eliminate compile warning | 5456 ;; Eliminate compile warning |
5670 (eval-when-compile | 5457 (eval-when-compile |
5671 (if (not (boundp 'occur-pos-list)) | 5458 (if (not (boundp 'occur-pos-list)) |
5672 (defvar occur-pos-list nil "Backward compatibility occur positions."))) | 5459 (defvar occur-pos-list nil "Backward compatibility occur positions."))) |
5678 (linenum 1) | 5465 (linenum 1) |
5679 (nlines 0) | 5466 (nlines 0) |
5680 (first 1) | 5467 (first 1) |
5681 (prevpos (point-min)) | 5468 (prevpos (point-min)) |
5682 (final-context-start (make-marker)) | 5469 (final-context-start (make-marker)) |
5683 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)") | 5470 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
5684 ) | |
5685 (with-output-to-temp-buffer "*Occur*" | 5471 (with-output-to-temp-buffer "*Occur*" |
5686 (save-excursion | 5472 (save-excursion |
5687 (message (format "Searching for %s ..." regexp)) | 5473 (message (format "Searching for %s ..." regexp)) |
5688 ;; Find next match, but give up if prev match was at end of buffer. | 5474 ;; Find next match, but give up if prev match was at end of buffer. |
5689 (while (and (not (= prevpos (point-max))) | 5475 (while (and (not (= prevpos (point-max))) |
5852 (search-forward "<company>") | 5638 (search-forward "<company>") |
5853 (replace-match string t t) | 5639 (replace-match string t t) |
5854 (search-forward "<company>") | 5640 (search-forward "<company>") |
5855 (replace-match string t t) | 5641 (replace-match string t t) |
5856 (search-backward "<description>") | 5642 (search-backward "<description>") |
5857 (replace-match "" t t) | 5643 (replace-match "" t t)))) |
5858 ))) | |
5859 | 5644 |
5860 ;; verilog-header Uses the verilog-insert-date function | 5645 ;; verilog-header Uses the verilog-insert-date function |
5861 | 5646 |
5862 (defun verilog-insert-date () | 5647 (defun verilog-insert-date () |
5863 "Insert date from the system." | 5648 "Insert date from the system." |
5992 sv-enum (verilog-sig-enum sig) | 5777 sv-enum (verilog-sig-enum sig) |
5993 sv-signed (verilog-sig-signed sig) | 5778 sv-signed (verilog-sig-signed sig) |
5994 sv-type (verilog-sig-type sig) | 5779 sv-type (verilog-sig-type sig) |
5995 sv-multidim (verilog-sig-multidim sig) | 5780 sv-multidim (verilog-sig-multidim sig) |
5996 combo "" | 5781 combo "" |
5997 buswarn "" | 5782 buswarn "")) |
5998 )) | |
5999 ;; Extract bus details | 5783 ;; Extract bus details |
6000 (setq bus (verilog-sig-bits sig)) | 5784 (setq bus (verilog-sig-bits sig)) |
6001 (cond ((and bus | 5785 (cond ((and bus |
6002 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) | 5786 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) |
6003 (setq highbit (string-to-number (match-string 1 bus)) | 5787 (setq highbit (string-to-number (match-string 1 bus)) |
6041 (list sv-name | 5825 (list sv-name |
6042 (or sv-busstring | 5826 (or sv-busstring |
6043 (if sv-highbit | 5827 (if sv-highbit |
6044 (concat "[" (int-to-string sv-highbit) ":" | 5828 (concat "[" (int-to-string sv-highbit) ":" |
6045 (int-to-string sv-lowbit) "]"))) | 5829 (int-to-string sv-lowbit) "]"))) |
6046 (concat sv-comment combo buswarn) | 5830 (concat sv-comment combo buswarn) |
6047 sv-memory sv-enum sv-signed sv-type sv-multidim) | 5831 sv-memory sv-enum sv-signed sv-type sv-multidim) |
6048 out-list) | 5832 out-list) |
6049 sv-name nil))) | 5833 sv-name nil)))) |
6050 ) | |
6051 ;; | 5834 ;; |
6052 out-list)) | 5835 out-list)) |
6053 | 5836 |
6054 (defun verilog-sig-tieoff (sig &optional no-width) | 5837 (defun verilog-sig-tieoff (sig &optional no-width) |
6055 "Return tieoff expression for given SIGNAL, with appropriate width. | 5838 "Return tieoff expression for given SIG, with appropriate width. |
6056 Ignore width if optional NO-WIDTH is set." | 5839 Ignore width if optional NO-WIDTH is set." |
6057 (let* ((width (if no-width nil (verilog-sig-width sig)))) | 5840 (let* ((width (if no-width nil (verilog-sig-width sig)))) |
6058 (concat | 5841 (concat |
6059 (if (and verilog-active-low-regexp | 5842 (if (and verilog-active-low-regexp |
6060 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | 5843 (string-match verilog-active-low-regexp (verilog-sig-name sig))) |
6187 ((looking-at "[})]") | 5970 ((looking-at "[})]") |
6188 (setq paren (1- paren)) | 5971 (setq paren (1- paren)) |
6189 (forward-char 1) | 5972 (forward-char 1) |
6190 (when (< paren sig-paren) | 5973 (when (< paren sig-paren) |
6191 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list | 5974 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list |
6192 t) | 5975 t)))) |
6193 ))) | |
6194 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") | 5976 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
6195 (goto-char (match-end 0)) | 5977 (goto-char (match-end 0)) |
6196 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | 5978 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) |
6197 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | 5979 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) |
6198 (vec ;; Multidimensional | 5980 (vec ;; Multidimensional |
6270 (nreverse sigs-in) | 6052 (nreverse sigs-in) |
6271 (nreverse sigs-wire) | 6053 (nreverse sigs-wire) |
6272 (nreverse sigs-reg) | 6054 (nreverse sigs-reg) |
6273 (nreverse sigs-assign) | 6055 (nreverse sigs-assign) |
6274 (nreverse sigs-const) | 6056 (nreverse sigs-const) |
6275 (nreverse sigs-gparam) | 6057 (nreverse sigs-gparam))))) |
6276 )))) | 6058 |
6277 | 6059 (eval-when-compile |
6278 (defvar sigs-in) ; Prevent compile warning | 6060 ;; Prevent compile warnings; these are let's, not globals |
6279 (defvar sigs-inout) ; Prevent compile warning | 6061 ;; Do not remove the eval-when-compile |
6280 (defvar sigs-out) ; Prevent compile warning | 6062 ;; - we want a error when we are debugging this code if they are refed. |
6063 (defvar sigs-in) | |
6064 (defvar sigs-inout) | |
6065 (defvar sigs-out)) | |
6281 | 6066 |
6282 | 6067 |
6283 (defsubst verilog-modi-get-decls (modi) | 6068 (defsubst verilog-modi-get-decls (modi) |
6284 (verilog-modi-cache-results modi 'verilog-read-decls)) | 6069 (verilog-modi-cache-results modi 'verilog-read-decls)) |
6285 | 6070 |
6522 (let* ((beg-pt (prog1 (point) | 6307 (let* ((beg-pt (prog1 (point) |
6523 (forward-sexp 1))) ;; Closing paren | 6308 (forward-sexp 1))) ;; Closing paren |
6524 (end-pt (point))) | 6309 (end-pt (point))) |
6525 (eval-region beg-pt end-pt nil))))) | 6310 (eval-region beg-pt end-pt nil))))) |
6526 | 6311 |
6527 ;; These are passed in a let, not global | 6312 (eval-when-compile |
6528 (defvar got-sig) | 6313 ;; Prevent compile warnings; these are let's, not globals |
6529 (defvar got-rvalue) | 6314 ;; Do not remove the eval-when-compile |
6530 (defvar uses-delayed) | 6315 ;; - we want a error when we are debugging this code if they are refed. |
6316 (defvar sigs-in) | |
6317 (defvar sigs-out) | |
6318 (defvar got-sig) | |
6319 (defvar got-rvalue) | |
6320 (defvar uses-delayed) | |
6321 (defvar vector-skip-list)) | |
6531 | 6322 |
6532 (defun verilog-read-always-signals-recurse | 6323 (defun verilog-read-always-signals-recurse |
6533 (exit-keywd rvalue ignore-next) | 6324 (exit-keywd rvalue ignore-next) |
6534 "Recursive routine for parentheses/bracket matching. | 6325 "Recursive routine for parentheses/bracket matching. |
6535 EXIT-KEYWD is expression to stop at, nil if top level. | 6326 EXIT-KEYWD is expression to stop at, nil if top level. |
6651 sig-tolk t))) | 6442 sig-tolk t))) |
6652 (skip-chars-forward "a-zA-Z0-9$_.%`")) | 6443 (skip-chars-forward "a-zA-Z0-9$_.%`")) |
6653 (t | 6444 (t |
6654 (forward-char 1))) | 6445 (forward-char 1))) |
6655 ;; End of non-comment token | 6446 ;; End of non-comment token |
6656 (setq last-keywd keywd) | 6447 (setq last-keywd keywd))) |
6657 )) | |
6658 (skip-syntax-forward " ")) | 6448 (skip-syntax-forward " ")) |
6659 ;; Append the final pending signal | 6449 ;; Append the final pending signal |
6660 (when got-sig | 6450 (when got-sig |
6661 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | 6451 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) |
6662 (setq sigs-out (cons got-sig sigs-out))) | 6452 (setq sigs-out (cons got-sig sigs-out))) |
6698 ;;(if (looking-at "^\\(.+\\)$") | 6488 ;;(if (looking-at "^\\(.+\\)$") |
6699 (let ((module (match-string 1)) | 6489 (let ((module (match-string 1)) |
6700 (instant (match-string 2))) | 6490 (instant (match-string 2))) |
6701 (if (not (member module verilog-keywords)) | 6491 (if (not (member module verilog-keywords)) |
6702 (setq instants-list (cons (list module instant) instants-list))))) | 6492 (setq instants-list (cons (list module instant) instants-list))))) |
6703 (forward-line 1) | 6493 (forward-line 1))) |
6704 )) | |
6705 instants-list)) | 6494 instants-list)) |
6706 | 6495 |
6707 | 6496 |
6708 (defun verilog-read-auto-template (module) | 6497 (defun verilog-read-auto-template (module) |
6709 "Look for a auto_template for the instantiation of the given MODULE. | 6498 "Look for a auto_template for the instantiation of the given MODULE. |
6774 (or (search-forward "*/") | 6563 (or (search-forward "*/") |
6775 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | 6564 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) |
6776 (t | 6565 (t |
6777 (error "%s: AUTO_TEMPLATE parsing error: %s" | 6566 (error "%s: AUTO_TEMPLATE parsing error: %s" |
6778 (verilog-point-text) | 6567 (verilog-point-text) |
6779 (progn (looking-at ".*$") (match-string 0)))) | 6568 (progn (looking-at ".*$") (match-string 0)))))) |
6780 )) | |
6781 ;; Return | 6569 ;; Return |
6782 (vector tpl-regexp | 6570 (vector tpl-regexp |
6783 (list tpl-sig-list tpl-wild-list))) | 6571 (list tpl-sig-list tpl-wild-list))) |
6784 ;; If no template found | 6572 ;; If no template found |
6785 (t (vector tpl-regexp nil)))))) | 6573 (t (vector tpl-regexp nil)))))) |
6797 (if (equal defvalue "") "1" defvalue))) | 6585 (if (equal defvalue "") "1" defvalue))) |
6798 (if enumname | 6586 (if enumname |
6799 (let ((enumvar (intern (concat "venum-" enumname)))) | 6587 (let ((enumvar (intern (concat "venum-" enumname)))) |
6800 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | 6588 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) |
6801 (make-variable-buffer-local enumvar) | 6589 (make-variable-buffer-local enumvar) |
6802 (add-to-list enumvar defname))) | 6590 (add-to-list enumvar defname))))) |
6803 )) | |
6804 | 6591 |
6805 (defun verilog-read-defines (&optional filename recurse subcall) | 6592 (defun verilog-read-defines (&optional filename recurse subcall) |
6806 "Read `defines and parameters for the current file, or optional FILENAME. | 6593 "Read `defines and parameters for the current file, or optional FILENAME. |
6807 If the filename is provided, `verilog-library-flags' will be used to | 6594 If the filename is provided, `verilog-library-flags' will be used to |
6808 resolve it. If optional RECURSE is non-nil, recurse through `includes. | 6595 resolve it. If optional RECURSE is non-nil, recurse through `includes. |
6882 (verilog-set-define var val origbuf enumname)) | 6669 (verilog-set-define var val origbuf enumname)) |
6883 (forward-comment 999) | 6670 (forward-comment 999) |
6884 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | 6671 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") |
6885 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) | 6672 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) |
6886 (goto-char (match-end 0)) | 6673 (goto-char (match-end 0)) |
6887 (forward-comment 999)))) | 6674 (forward-comment 999))))))) |
6888 ))) | |
6889 | 6675 |
6890 (defun verilog-read-includes () | 6676 (defun verilog-read-includes () |
6891 "Read `includes for the current file. | 6677 "Read `includes for the current file. |
6892 This will find all of the `includes which are at the beginning of lines, | 6678 This will find all of the `includes which are at the beginning of lines, |
6893 ignoring any ifdefs or multiline comments around them. | 6679 ignoring any ifdefs or multiline comments around them. |
6948 (goto-char (match-end 0)) | 6734 (goto-char (match-end 0)) |
6949 (setq keywd (match-string-no-properties 1)) | 6735 (setq keywd (match-string-no-properties 1)) |
6950 (or (member keywd verilog-keywords) | 6736 (or (member keywd verilog-keywords) |
6951 (member keywd sigs-all) | 6737 (member keywd sigs-all) |
6952 (setq sigs-all (cons keywd sigs-all)))) | 6738 (setq sigs-all (cons keywd sigs-all)))) |
6953 (t (forward-char 1))) | 6739 (t (forward-char 1)))) |
6954 ) | |
6955 ;; Return list | 6740 ;; Return list |
6956 sigs-all))) | 6741 sigs-all))) |
6957 | 6742 |
6958 ;; | 6743 ;; |
6959 ;; Argument file parsing | 6744 ;; Argument file parsing |
7017 (verilog-add-list-unique `verilog-library-directories arg)) | 6802 (verilog-add-list-unique `verilog-library-directories arg)) |
7018 ;; Filename | 6803 ;; Filename |
7019 ((string-match "^[^-+]" arg) | 6804 ((string-match "^[^-+]" arg) |
7020 (verilog-add-list-unique `verilog-library-files arg)) | 6805 (verilog-add-list-unique `verilog-library-files arg)) |
7021 ;; Default - ignore; no warning | 6806 ;; Default - ignore; no warning |
7022 ) | 6807 )))) |
7023 ) | |
7024 ) | |
7025 ) | |
7026 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) | 6808 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
7027 | 6809 |
7028 (defun verilog-getopt-file (filename) | 6810 (defun verilog-getopt-file (filename) |
7029 "Read verilog options from the specified FILENAME." | 6811 "Read verilog options from the specified FILENAME." |
7030 (save-excursion | 6812 (save-excursion |
7094 | 6876 |
7095 (defun verilog-is-number (symbol) | 6877 (defun verilog-is-number (symbol) |
7096 "Return true if SYMBOL is number-like." | 6878 "Return true if SYMBOL is number-like." |
7097 (or (string-match "^[0-9 \t:]+$" symbol) | 6879 (or (string-match "^[0-9 \t:]+$" symbol) |
7098 (string-match "^[---]*[0-9]+$" symbol) | 6880 (string-match "^[---]*[0-9]+$" symbol) |
7099 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol) | 6881 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
7100 )) | |
7101 | 6882 |
7102 (defun verilog-symbol-detick (symbol wing-it) | 6883 (defun verilog-symbol-detick (symbol wing-it) |
7103 "Return a expanded SYMBOL name without any defines. | 6884 "Return a expanded SYMBOL name without any defines. |
7104 If the variable vh-{symbol} is defined, return that value. | 6885 If the variable vh-{symbol} is defined, return that value. |
7105 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | 6886 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." |
7183 (directory-files root t pattern nil))) | 6964 (directory-files root t pattern nil))) |
7184 (while dirfiles | 6965 (while dirfiles |
7185 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) | 6966 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) |
7186 dirfiles (cdr dirfiles)) | 6967 dirfiles (cdr dirfiles)) |
7187 (if (file-directory-p dirfile) | 6968 (if (file-directory-p dirfile) |
7188 (setq dirlist (cons dirfile dirlist)))) | 6969 (setq dirlist (cons dirfile dirlist))))) |
7189 ) | |
7190 ;; Defaults | 6970 ;; Defaults |
7191 (t | 6971 (t |
7192 (if (file-directory-p dirname) | 6972 (if (file-directory-p dirname) |
7193 (setq dirlist (cons dirname dirlist)))) | 6973 (setq dirlist (cons dirname dirlist)))))) |
7194 )) | |
7195 dirlist)) | 6974 dirlist)) |
7196 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | 6975 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) |
7197 | 6976 |
7198 (defun verilog-library-filenames (filename current &optional check-ext) | 6977 (defun verilog-library-filenames (filename current &optional check-ext) |
7199 "Return a search path to find the given FILENAME name. | 6978 "Return a search path to find the given FILENAME name. |
7293 (if (not (equal module realmod)) | 7072 (if (not (equal module realmod)) |
7294 (concat " (Expanded macro to " realmod ")") | 7073 (concat " (Expanded macro to " realmod ")") |
7295 "") | 7074 "") |
7296 "\n Check the verilog-library-directories variable." | 7075 "\n Check the verilog-library-directories variable." |
7297 "\n I looked in (if not listed, doesn't exist):\n\t" | 7076 "\n I looked in (if not listed, doesn't exist):\n\t" |
7298 (mapconcat 'concat orig-filenames "\n\t"))))) | 7077 (mapconcat 'concat orig-filenames "\n\t")))))) |
7299 ) | |
7300 (setq verilog-modi-lookup-last-mod module | 7078 (setq verilog-modi-lookup-last-mod module |
7301 verilog-modi-lookup-last-current current | 7079 verilog-modi-lookup-last-current current |
7302 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | 7080 verilog-modi-lookup-last-tick (buffer-modified-tick))))) |
7303 verilog-modi-lookup-last-modi | 7081 verilog-modi-lookup-last-modi)) |
7304 )) | |
7305 | 7082 |
7306 (defsubst verilog-modi-name (modi) | 7083 (defsubst verilog-modi-name (modi) |
7307 (aref modi 0)) | 7084 (aref modi 0)) |
7308 (defsubst verilog-modi-file-or-buffer (modi) | 7085 (defsubst verilog-modi-file-or-buffer (modi) |
7309 (aref modi 1)) | 7086 (aref modi 1)) |
7368 (setq verilog-modi-cache-list | 7145 (setq verilog-modi-cache-list |
7369 (cons (list (list (verilog-modi-name modi) function) | 7146 (cons (list (list (verilog-modi-name modi) function) |
7370 (buffer-modified-tick) | 7147 (buffer-modified-tick) |
7371 (visited-file-modtime) | 7148 (visited-file-modtime) |
7372 func-returns) | 7149 func-returns) |
7373 verilog-modi-cache-list))) | 7150 verilog-modi-cache-list))))) |
7374 )) | |
7375 ;; | 7151 ;; |
7376 func-returns)) | 7152 func-returns)) |
7377 | 7153 |
7378 (defun verilog-modi-cache-add (modi function element sig-list) | 7154 (defun verilog-modi-cache-add (modi function element sig-list) |
7379 "Add function return results to the module cache. | 7155 "Add function return results to the module cache. |
7481 (goto-char (match-beginning 0)) | 7257 (goto-char (match-beginning 0)) |
7482 (verilog-inside-comment-p))) | 7258 (verilog-inside-comment-p))) |
7483 (funcall func)))) | 7259 (funcall func)))) |
7484 | 7260 |
7485 (defun verilog-insert-one-definition (sig type indent-pt) | 7261 (defun verilog-insert-one-definition (sig type indent-pt) |
7486 "Print out a definition for SIGNAL of the given TYPE, | 7262 "Print out a definition for SIG of the given TYPE, |
7487 with appropriate INDENT-PT indentation." | 7263 with appropriate INDENT-PT indentation." |
7488 (indent-to indent-pt) | 7264 (indent-to indent-pt) |
7489 (insert type) | 7265 (insert type) |
7490 (when (verilog-sig-signed sig) | 7266 (when (verilog-sig-signed sig) |
7491 (insert " " (verilog-sig-signed sig))) | 7267 (insert " " (verilog-sig-signed sig))) |
7592 (int-to-string | 7368 (int-to-string |
7593 (1+ (abs (- (string-to-number (match-string 1 range-exp)) | 7369 (1+ (abs (- (string-to-number (match-string 1 range-exp)) |
7594 (string-to-number (match-string 2 range-exp))))))) | 7370 (string-to-number (match-string 2 range-exp))))))) |
7595 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) | 7371 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) |
7596 (concat "(1+(" (match-string 1 range-exp) ")" | 7372 (concat "(1+(" (match-string 1 range-exp) ")" |
7597 (if (equal "0" (match-string 2 range-exp)) | 7373 (if (equal "0" (match-string 2 range-exp)) |
7598 ;; Don't bother with -(0) | 7374 "" ;; Don't bother with -(0) |
7599 "" | |
7600 (concat "-(" (match-string 2 range-exp) ")")) | 7375 (concat "-(" (match-string 2 range-exp) ")")) |
7601 ")")) | 7376 ")")) |
7602 (t nil))))) | 7377 (t nil))))) |
7603 ;;(verilog-make-width-expression "`A:`B") | 7378 ;;(verilog-make-width-expression "`A:`B") |
7604 | 7379 |
7619 (looking-at "\\s-*// Beginning") | 7394 (looking-at "\\s-*// Beginning") |
7620 (search-forward "// End of automatic" nil t)) | 7395 (search-forward "// End of automatic" nil t)) |
7621 ;; End exists | 7396 ;; End exists |
7622 (end-of-line) | 7397 (end-of-line) |
7623 (delete-region pt (point)) | 7398 (delete-region pt (point)) |
7624 (forward-line 1)) | 7399 (forward-line 1)))) |
7625 )) | |
7626 | 7400 |
7627 (defun verilog-forward-close-paren () | 7401 (defun verilog-forward-close-paren () |
7628 "Find the close parenthesis that match the current point, | 7402 "Find the close parenthesis that match the current point, |
7629 ignore other close parenthesis with matching open parens" | 7403 ignore other close parenthesis with matching open parens" |
7630 (let ((parens 1)) | 7404 (let ((parens 1)) |
7895 (verilog-auto)) | 7669 (verilog-auto)) |
7896 (t | 7670 (t |
7897 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | 7671 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") |
7898 (verilog-auto)) | 7672 (verilog-auto)) |
7899 ;; Don't ask again if didn't update | 7673 ;; Don't ask again if didn't update |
7900 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | 7674 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
7901 )) | |
7902 (when (not verilog-auto-star-save) | 7675 (when (not verilog-auto-star-save) |
7903 (verilog-delete-auto-star-implicit)) | 7676 (verilog-delete-auto-star-implicit)) |
7904 nil) ;; Always return nil -- we don't write the file ourselves | 7677 nil) ;; Always return nil -- we don't write the file ourselves |
7905 | 7678 |
7906 (defun verilog-auto-read-locals () | 7679 (defun verilog-auto-read-locals () |
8006 "// Inputs" | 7779 "// Inputs" |
8007 verilog-indent-level-declaration) | 7780 verilog-indent-level-declaration) |
8008 (verilog-repair-close-comma) | 7781 (verilog-repair-close-comma) |
8009 (unless (eq (char-before) ?/ ) | 7782 (unless (eq (char-before) ?/ ) |
8010 (insert "\n")) | 7783 (insert "\n")) |
8011 (indent-to verilog-indent-level-declaration) | 7784 (indent-to verilog-indent-level-declaration)))) |
8012 ))) | |
8013 | 7785 |
8014 (defun verilog-auto-inst-port-map (port-st) | 7786 (defun verilog-auto-inst-port-map (port-st) |
8015 nil) | 7787 nil) |
8016 | 7788 |
8017 (defvar vector-skip-list nil) ; Prevent compile warning | |
8018 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7789 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8019 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7790 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8020 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7791 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8021 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7792 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8022 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7793 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8023 | 7794 |
8024 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) | 7795 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) |
8025 "Print out a instantiation connection for this PORT-ST. | 7796 "Print out a instantiation connection for this PORT-ST. |
8026 Insert to INDENT-PT, use template TPL-LIST. | 7797 Insert to INDENT-PT, use template TPL-LIST. |
8027 @ are instantiation numbers, replaced with TPL-NUM. | 7798 @ are instantiation numbers, replaced with TPL-NUM. |
8028 @\"(expression @)\" are evaluated, with @ as a variable." | 7799 @\"(expression @)\" are evaluated, with @ as a variable. |
7800 If FOR-STAR add comment it is a .* expansion." | |
8029 (let* ((port (verilog-sig-name port-st)) | 7801 (let* ((port (verilog-sig-name port-st)) |
8030 (tpl-ass (or (assoc port (car tpl-list)) | 7802 (tpl-ass (or (assoc port (car tpl-list)) |
8031 (verilog-auto-inst-port-map port-st))) | 7803 (verilog-auto-inst-port-map port-st))) |
8032 ;; vl-* are documented for user use | 7804 ;; vl-* are documented for user use |
8033 (vl-name (verilog-sig-name port-st)) | 7805 (vl-name (verilog-sig-name port-st)) |
8070 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | 7842 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) |
8071 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | 7843 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) |
8072 (prin1 (eval (car (read-from-string expr))) | 7844 (prin1 (eval (car (read-from-string expr))) |
8073 (lambda (ch) ()))))) | 7845 (lambda (ch) ()))))) |
8074 (if (numberp value) (setq value (number-to-string value))) | 7846 (if (numberp value) (setq value (number-to-string value))) |
8075 value | 7847 value)) |
8076 )) | |
8077 (substring tpl-net (match-end 0)))))) | 7848 (substring tpl-net (match-end 0)))))) |
8078 ;; Replace @ and [] magic variables in final output | 7849 ;; Replace @ and [] magic variables in final output |
8079 (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net)) | 7850 (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net)) |
8080 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net)) | 7851 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
8081 ) | |
8082 (indent-to indent-pt) | 7852 (indent-to indent-pt) |
8083 (insert "." port) | 7853 (insert "." port) |
8084 (indent-to verilog-auto-inst-column) | 7854 (indent-to verilog-auto-inst-column) |
8085 (insert "(" tpl-net "),") | 7855 (insert "(" tpl-net "),") |
8086 (cond (tpl-ass | 7856 (cond (tpl-ass |
8460 (search-forward "\n") ;; Added by inst-port | 8230 (search-forward "\n") ;; Added by inst-port |
8461 (delete-backward-char 1) | 8231 (delete-backward-char 1) |
8462 (if (search-forward ")" nil t) ;; From user, moved up a line | 8232 (if (search-forward ")" nil t) ;; From user, moved up a line |
8463 (delete-backward-char 1)) | 8233 (delete-backward-char 1)) |
8464 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it | 8234 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it |
8465 (delete-backward-char 1)) | 8235 (delete-backward-char 1))))))))) |
8466 ))) | |
8467 )))) | |
8468 | 8236 |
8469 (defun verilog-auto-inst-param () | 8237 (defun verilog-auto-inst-param () |
8470 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | 8238 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. |
8471 Replace the parameter connections to an instantiation with ones | 8239 Replace the parameter connections to an instantiation with ones |
8472 automatically derived from the module header of the instantiated netlist. | 8240 automatically derived from the module header of the instantiated netlist. |
8564 (delete-char 1) | 8332 (delete-char 1) |
8565 (insert ")") | 8333 (insert ")") |
8566 (search-forward "\n") ;; Added by inst-port | 8334 (search-forward "\n") ;; Added by inst-port |
8567 (delete-backward-char 1) | 8335 (delete-backward-char 1) |
8568 (if (search-forward ")" nil t) ;; From user, moved up a line | 8336 (if (search-forward ")" nil t) ;; From user, moved up a line |
8569 (delete-backward-char 1)) | 8337 (delete-backward-char 1))))))))) |
8570 ))) | |
8571 )))) | |
8572 | 8338 |
8573 (defun verilog-auto-reg () | 8339 (defun verilog-auto-reg () |
8574 "Expand AUTOREG statements, as part of \\[verilog-auto]. | 8340 "Expand AUTOREG statements, as part of \\[verilog-auto]. |
8575 Make reg statements for any output that isn't already declared, | 8341 Make reg statements for any output that isn't already declared, |
8576 and isn't a wire output from a block. | 8342 and isn't a wire output from a block. |
8610 (verilog-modi-get-regs modi) | 8376 (verilog-modi-get-regs modi) |
8611 (verilog-modi-get-assigns modi) | 8377 (verilog-modi-get-assigns modi) |
8612 (verilog-modi-get-consts modi) | 8378 (verilog-modi-get-consts modi) |
8613 (verilog-modi-get-gparams modi) | 8379 (verilog-modi-get-gparams modi) |
8614 (verilog-modi-get-sub-outputs modi) | 8380 (verilog-modi-get-sub-outputs modi) |
8615 (verilog-modi-get-sub-inouts modi) | 8381 (verilog-modi-get-sub-inouts modi))))) |
8616 )))) | |
8617 (forward-line 1) | 8382 (forward-line 1) |
8618 (when sig-list | 8383 (when sig-list |
8619 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | 8384 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") |
8620 (verilog-insert-definition sig-list "reg" indent-pt nil) | 8385 (verilog-insert-definition sig-list "reg" indent-pt nil) |
8621 (verilog-modi-cache-add-regs modi sig-list) | 8386 (verilog-modi-cache-add-regs modi sig-list) |
8622 (verilog-insert-indent "// End of automatics\n")) | 8387 (verilog-insert-indent "// End of automatics\n"))))) |
8623 ))) | |
8624 | 8388 |
8625 (defun verilog-auto-reg-input () | 8389 (defun verilog-auto-reg-input () |
8626 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | 8390 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. |
8627 Make reg statements instantiation inputs that aren't already declared. | 8391 Make reg statements instantiation inputs that aren't already declared. |
8628 This is useful for making a top level shell for testing the module that is | 8392 This is useful for making a top level shell for testing the module that is |
8663 (modi (verilog-modi-current)) | 8427 (modi (verilog-modi-current)) |
8664 (sig-list (verilog-signals-combine-bus | 8428 (sig-list (verilog-signals-combine-bus |
8665 (verilog-signals-not-in | 8429 (verilog-signals-not-in |
8666 (append (verilog-modi-get-sub-inputs modi) | 8430 (append (verilog-modi-get-sub-inputs modi) |
8667 (verilog-modi-get-sub-inouts modi)) | 8431 (verilog-modi-get-sub-inouts modi)) |
8668 (verilog-modi-get-signals modi) | 8432 (verilog-modi-get-signals modi))))) |
8669 )))) | |
8670 (forward-line 1) | 8433 (forward-line 1) |
8671 (when sig-list | 8434 (when sig-list |
8672 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | 8435 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") |
8673 (verilog-insert-definition sig-list "reg" indent-pt nil) | 8436 (verilog-insert-definition sig-list "reg" indent-pt nil) |
8674 (verilog-modi-cache-add-regs modi sig-list) | 8437 (verilog-modi-cache-add-regs modi sig-list) |
8675 (verilog-insert-indent "// End of automatics\n")) | 8438 (verilog-insert-indent "// End of automatics\n"))))) |
8676 ))) | |
8677 | 8439 |
8678 (defun verilog-auto-wire () | 8440 (defun verilog-auto-wire () |
8679 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | 8441 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. |
8680 Make wire statements for instantiations outputs that aren't | 8442 Make wire statements for instantiations outputs that aren't |
8681 already declared. | 8443 already declared. |
8724 (modi (verilog-modi-current)) | 8486 (modi (verilog-modi-current)) |
8725 (sig-list (verilog-signals-combine-bus | 8487 (sig-list (verilog-signals-combine-bus |
8726 (verilog-signals-not-in | 8488 (verilog-signals-not-in |
8727 (append (verilog-modi-get-sub-outputs modi) | 8489 (append (verilog-modi-get-sub-outputs modi) |
8728 (verilog-modi-get-sub-inouts modi)) | 8490 (verilog-modi-get-sub-inouts modi)) |
8729 (verilog-modi-get-signals modi) | 8491 (verilog-modi-get-signals modi))))) |
8730 )))) | |
8731 (forward-line 1) | 8492 (forward-line 1) |
8732 (when sig-list | 8493 (when sig-list |
8733 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | 8494 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") |
8734 (verilog-insert-definition sig-list "wire" indent-pt nil) | 8495 (verilog-insert-definition sig-list "wire" indent-pt nil) |
8735 (verilog-modi-cache-add-wires modi sig-list) | 8496 (verilog-modi-cache-add-wires modi sig-list) |
8737 (when nil ;; Too slow on huge modules, plus makes everyone's module change | 8498 (when nil ;; Too slow on huge modules, plus makes everyone's module change |
8738 (beginning-of-line) | 8499 (beginning-of-line) |
8739 (setq pnt (point)) | 8500 (setq pnt (point)) |
8740 (verilog-pretty-declarations) | 8501 (verilog-pretty-declarations) |
8741 (goto-char pnt) | 8502 (goto-char pnt) |
8742 (verilog-pretty-expr "//"))) | 8503 (verilog-pretty-expr "//")))))) |
8743 ))) | |
8744 | 8504 |
8745 (defun verilog-auto-output () | 8505 (defun verilog-auto-output () |
8746 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. | 8506 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. |
8747 Make output statements for any output signal from an /*AUTOINST*/ that | 8507 Make output statements for any output signal from an /*AUTOINST*/ that |
8748 isn't a input to another AUTOINST. This is useful for modules which | 8508 isn't a input to another AUTOINST. This is useful for modules which |
8791 (sig-list (verilog-signals-not-in | 8551 (sig-list (verilog-signals-not-in |
8792 (verilog-modi-get-sub-outputs modi) | 8552 (verilog-modi-get-sub-outputs modi) |
8793 (append (verilog-modi-get-outputs modi) | 8553 (append (verilog-modi-get-outputs modi) |
8794 (verilog-modi-get-inouts modi) | 8554 (verilog-modi-get-inouts modi) |
8795 (verilog-modi-get-sub-inputs modi) | 8555 (verilog-modi-get-sub-inputs modi) |
8796 (verilog-modi-get-sub-inouts modi) | 8556 (verilog-modi-get-sub-inouts modi))))) |
8797 )))) | |
8798 (setq sig-list (verilog-signals-not-matching-regexp | 8557 (setq sig-list (verilog-signals-not-matching-regexp |
8799 sig-list verilog-auto-output-ignore-regexp)) | 8558 sig-list verilog-auto-output-ignore-regexp)) |
8800 (forward-line 1) | 8559 (forward-line 1) |
8801 (when v2k (verilog-repair-open-comma)) | 8560 (when v2k (verilog-repair-open-comma)) |
8802 (when sig-list | 8561 (when sig-list |
8803 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | 8562 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") |
8804 (verilog-insert-definition sig-list "output" indent-pt v2k) | 8563 (verilog-insert-definition sig-list "output" indent-pt v2k) |
8805 (verilog-modi-cache-add-outputs modi sig-list) | 8564 (verilog-modi-cache-add-outputs modi sig-list) |
8806 (verilog-insert-indent "// End of automatics\n")) | 8565 (verilog-insert-indent "// End of automatics\n")) |
8807 (when v2k (verilog-repair-close-comma)) | 8566 (when v2k (verilog-repair-close-comma))))) |
8808 ))) | |
8809 | 8567 |
8810 (defun verilog-auto-output-every () | 8568 (defun verilog-auto-output-every () |
8811 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | 8569 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. |
8812 Make output statements for any signals that aren't primary inputs or | 8570 Make output statements for any signals that aren't primary inputs or |
8813 outputs already. This makes every signal in the design a output. This is | 8571 outputs already. This makes every signal in the design a output. This is |
8845 (v2k (verilog-in-paren)) | 8603 (v2k (verilog-in-paren)) |
8846 (modi (verilog-modi-current)) | 8604 (modi (verilog-modi-current)) |
8847 (sig-list (verilog-signals-combine-bus | 8605 (sig-list (verilog-signals-combine-bus |
8848 (verilog-signals-not-in | 8606 (verilog-signals-not-in |
8849 (verilog-modi-get-signals modi) | 8607 (verilog-modi-get-signals modi) |
8850 (verilog-modi-get-ports modi) | 8608 (verilog-modi-get-ports modi))))) |
8851 )))) | |
8852 (forward-line 1) | 8609 (forward-line 1) |
8853 (when v2k (verilog-repair-open-comma)) | 8610 (when v2k (verilog-repair-open-comma)) |
8854 (when sig-list | 8611 (when sig-list |
8855 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | 8612 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") |
8856 (verilog-insert-definition sig-list "output" indent-pt v2k) | 8613 (verilog-insert-definition sig-list "output" indent-pt v2k) |
8857 (verilog-modi-cache-add-outputs modi sig-list) | 8614 (verilog-modi-cache-add-outputs modi sig-list) |
8858 (verilog-insert-indent "// End of automatics\n")) | 8615 (verilog-insert-indent "// End of automatics\n")) |
8859 (when v2k (verilog-repair-close-comma)) | 8616 (when v2k (verilog-repair-close-comma))))) |
8860 ))) | |
8861 | 8617 |
8862 (defun verilog-auto-input () | 8618 (defun verilog-auto-input () |
8863 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. | 8619 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. |
8864 Make input statements for any input signal into an /*AUTOINST*/ that | 8620 Make input statements for any input signal into an /*AUTOINST*/ that |
8865 isn't declared elsewhere inside the module. This is useful for modules which | 8621 isn't declared elsewhere inside the module. This is useful for modules which |
8911 (verilog-modi-get-wires modi) | 8667 (verilog-modi-get-wires modi) |
8912 (verilog-modi-get-regs modi) | 8668 (verilog-modi-get-regs modi) |
8913 (verilog-modi-get-consts modi) | 8669 (verilog-modi-get-consts modi) |
8914 (verilog-modi-get-gparams modi) | 8670 (verilog-modi-get-gparams modi) |
8915 (verilog-modi-get-sub-outputs modi) | 8671 (verilog-modi-get-sub-outputs modi) |
8916 (verilog-modi-get-sub-inouts modi) | 8672 (verilog-modi-get-sub-inouts modi))))) |
8917 )))) | |
8918 (setq sig-list (verilog-signals-not-matching-regexp | 8673 (setq sig-list (verilog-signals-not-matching-regexp |
8919 sig-list verilog-auto-input-ignore-regexp)) | 8674 sig-list verilog-auto-input-ignore-regexp)) |
8920 (forward-line 1) | 8675 (forward-line 1) |
8921 (when v2k (verilog-repair-open-comma)) | 8676 (when v2k (verilog-repair-open-comma)) |
8922 (when sig-list | 8677 (when sig-list |
8923 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | 8678 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") |
8924 (verilog-insert-definition sig-list "input" indent-pt v2k) | 8679 (verilog-insert-definition sig-list "input" indent-pt v2k) |
8925 (verilog-modi-cache-add-inputs modi sig-list) | 8680 (verilog-modi-cache-add-inputs modi sig-list) |
8926 (verilog-insert-indent "// End of automatics\n")) | 8681 (verilog-insert-indent "// End of automatics\n")) |
8927 (when v2k (verilog-repair-close-comma)) | 8682 (when v2k (verilog-repair-close-comma))))) |
8928 ))) | |
8929 | 8683 |
8930 (defun verilog-auto-inout () | 8684 (defun verilog-auto-inout () |
8931 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. | 8685 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. |
8932 Make inout statements for any inout signal in an /*AUTOINST*/ that | 8686 Make inout statements for any inout signal in an /*AUTOINST*/ that |
8933 isn't declared elsewhere inside the module. | 8687 isn't declared elsewhere inside the module. |
8976 (verilog-modi-get-sub-inouts modi) | 8730 (verilog-modi-get-sub-inouts modi) |
8977 (append (verilog-modi-get-outputs modi) | 8731 (append (verilog-modi-get-outputs modi) |
8978 (verilog-modi-get-inouts modi) | 8732 (verilog-modi-get-inouts modi) |
8979 (verilog-modi-get-inputs modi) | 8733 (verilog-modi-get-inputs modi) |
8980 (verilog-modi-get-sub-inputs modi) | 8734 (verilog-modi-get-sub-inputs modi) |
8981 (verilog-modi-get-sub-outputs modi) | 8735 (verilog-modi-get-sub-outputs modi))))) |
8982 )))) | |
8983 (setq sig-list (verilog-signals-not-matching-regexp | 8736 (setq sig-list (verilog-signals-not-matching-regexp |
8984 sig-list verilog-auto-inout-ignore-regexp)) | 8737 sig-list verilog-auto-inout-ignore-regexp)) |
8985 (forward-line 1) | 8738 (forward-line 1) |
8986 (when v2k (verilog-repair-open-comma)) | 8739 (when v2k (verilog-repair-open-comma)) |
8987 (when sig-list | 8740 (when sig-list |
8988 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | 8741 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") |
8989 (verilog-insert-definition sig-list "inout" indent-pt v2k) | 8742 (verilog-insert-definition sig-list "inout" indent-pt v2k) |
8990 (verilog-modi-cache-add-inouts modi sig-list) | 8743 (verilog-modi-cache-add-inouts modi sig-list) |
8991 (verilog-insert-indent "// End of automatics\n")) | 8744 (verilog-insert-indent "// End of automatics\n")) |
8992 (when v2k (verilog-repair-close-comma)) | 8745 (when v2k (verilog-repair-close-comma))))) |
8993 ))) | |
8994 | 8746 |
8995 (defun verilog-auto-inout-module () | 8747 (defun verilog-auto-inout-module () |
8996 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. | 8748 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. |
8997 Take input/output/inout statements from the specified module and insert | 8749 Take input/output/inout statements from the specified module and insert |
8998 into the current module. This is useful for making null templates and | 8750 into the current module. This is useful for making null templates and |
9060 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | 8812 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) |
9061 (verilog-modi-cache-add-inputs modi sig-list-i) | 8813 (verilog-modi-cache-add-inputs modi sig-list-i) |
9062 (verilog-modi-cache-add-outputs modi sig-list-o) | 8814 (verilog-modi-cache-add-outputs modi sig-list-o) |
9063 (verilog-modi-cache-add-inouts modi sig-list-io) | 8815 (verilog-modi-cache-add-inouts modi sig-list-io) |
9064 (verilog-insert-indent "// End of automatics\n")) | 8816 (verilog-insert-indent "// End of automatics\n")) |
9065 (when v2k (verilog-repair-close-comma)) | 8817 (when v2k (verilog-repair-close-comma))))))) |
9066 ))))) | |
9067 | 8818 |
9068 (defun verilog-auto-sense-sigs (modi presense-sigs) | 8819 (defun verilog-auto-sense-sigs (modi presense-sigs) |
9069 "Return list of signals for current AUTOSENSE block." | 8820 "Return list of signals for current AUTOSENSE block." |
9070 (let* ((sigss (verilog-read-always-signals)) | 8821 (let* ((sigss (verilog-read-always-signals)) |
9071 (sig-list (verilog-signals-not-params | 8822 (sig-list (verilog-signals-not-params |
9162 (indent-to indent-pt) | 8913 (indent-to indent-pt) |
9163 (if not-first (insert "or "))) | 8914 (if not-first (insert "or "))) |
9164 (not-first (insert " or "))) | 8915 (not-first (insert " or "))) |
9165 (insert (verilog-sig-name (car sig-list))) | 8916 (insert (verilog-sig-name (car sig-list))) |
9166 (setq sig-list (cdr sig-list) | 8917 (setq sig-list (cdr sig-list) |
9167 not-first t)) | 8918 not-first t))))) |
9168 ))) | |
9169 | 8919 |
9170 (defun verilog-auto-reset () | 8920 (defun verilog-auto-reset () |
9171 "Expand AUTORESET statements, as part of \\[verilog-auto]. | 8921 "Expand AUTORESET statements, as part of \\[verilog-auto]. |
9172 Replace the /*AUTORESET*/ comment with code to initialize all | 8922 Replace the /*AUTORESET*/ comment with code to initialize all |
9173 registers set elsewhere in the always block. | 8923 registers set elsewhere in the always block. |
9258 assignment-str | 9008 assignment-str |
9259 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | 9009 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) |
9260 ";\n") | 9010 ";\n") |
9261 (indent-to indent-pt) | 9011 (indent-to indent-pt) |
9262 (setq sig-list (cdr sig-list)))) | 9012 (setq sig-list (cdr sig-list)))) |
9263 (insert "// End of automatics")) | 9013 (insert "// End of automatics"))))) |
9264 ))) | |
9265 | 9014 |
9266 (defun verilog-auto-tieoff () | 9015 (defun verilog-auto-tieoff () |
9267 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | 9016 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. |
9268 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | 9017 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output |
9269 signals to deasserted. | 9018 signals to deasserted. |
9314 (verilog-modi-get-regs modi) | 9063 (verilog-modi-get-regs modi) |
9315 (verilog-modi-get-assigns modi) | 9064 (verilog-modi-get-assigns modi) |
9316 (verilog-modi-get-consts modi) | 9065 (verilog-modi-get-consts modi) |
9317 (verilog-modi-get-gparams modi) | 9066 (verilog-modi-get-gparams modi) |
9318 (verilog-modi-get-sub-outputs modi) | 9067 (verilog-modi-get-sub-outputs modi) |
9319 (verilog-modi-get-sub-inouts modi) | 9068 (verilog-modi-get-sub-inouts modi))))) |
9320 )))) | |
9321 (when sig-list | 9069 (when sig-list |
9322 (forward-line 1) | 9070 (forward-line 1) |
9323 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | 9071 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") |
9324 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | 9072 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) |
9325 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list | 9073 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list |
9328 (verilog-insert-one-definition sig "wire" indent-pt) | 9076 (verilog-insert-one-definition sig "wire" indent-pt) |
9329 (indent-to (max 48 (+ indent-pt 40))) | 9077 (indent-to (max 48 (+ indent-pt 40))) |
9330 (insert "= " (verilog-sig-tieoff sig) | 9078 (insert "= " (verilog-sig-tieoff sig) |
9331 ";\n") | 9079 ";\n") |
9332 (setq sig-list (cdr sig-list)))) | 9080 (setq sig-list (cdr sig-list)))) |
9333 (verilog-insert-indent "// End of automatics\n") | 9081 (verilog-insert-indent "// End of automatics\n"))))) |
9334 )))) | |
9335 | 9082 |
9336 (defun verilog-auto-unused () | 9083 (defun verilog-auto-unused () |
9337 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | 9084 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. |
9338 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | 9085 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused |
9339 input and inout signals. | 9086 input and inout signals. |
9393 (modi (verilog-modi-current)) | 9140 (modi (verilog-modi-current)) |
9394 (sig-list (verilog-signals-not-in | 9141 (sig-list (verilog-signals-not-in |
9395 (append (verilog-modi-get-inputs modi) | 9142 (append (verilog-modi-get-inputs modi) |
9396 (verilog-modi-get-inouts modi)) | 9143 (verilog-modi-get-inouts modi)) |
9397 (append (verilog-modi-get-sub-inputs modi) | 9144 (append (verilog-modi-get-sub-inputs modi) |
9398 (verilog-modi-get-sub-inouts modi) | 9145 (verilog-modi-get-sub-inouts modi))))) |
9399 )))) | |
9400 (setq sig-list (verilog-signals-not-matching-regexp | 9146 (setq sig-list (verilog-signals-not-matching-regexp |
9401 sig-list verilog-auto-unused-ignore-regexp)) | 9147 sig-list verilog-auto-unused-ignore-regexp)) |
9402 (when sig-list | 9148 (when sig-list |
9403 (forward-line 1) | 9149 (forward-line 1) |
9404 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | 9150 (verilog-insert-indent "// Beginning of automatic unused inputs\n") |
9406 (while sig-list | 9152 (while sig-list |
9407 (let ((sig (car sig-list))) | 9153 (let ((sig (car sig-list))) |
9408 (indent-to indent-pt) | 9154 (indent-to indent-pt) |
9409 (insert (verilog-sig-name sig) ",\n") | 9155 (insert (verilog-sig-name sig) ",\n") |
9410 (setq sig-list (cdr sig-list)))) | 9156 (setq sig-list (cdr sig-list)))) |
9411 (verilog-insert-indent "// End of automatics\n") | 9157 (verilog-insert-indent "// End of automatics\n"))))) |
9412 )))) | |
9413 | 9158 |
9414 (defun verilog-enum-ascii (signm elim-regexp) | 9159 (defun verilog-enum-ascii (signm elim-regexp) |
9415 "Convert a enum name SIGNM to a ascii string for insertion. | 9160 "Convert a enum name SIGNM to a ascii string for insertion. |
9416 Remove user provided prefix ELIM-REGEXP." | 9161 Remove user provided prefix ELIM-REGEXP." |
9417 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | 9162 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) |
9541 ;; | 9286 ;; |
9542 (setq indent-pt (- indent-pt verilog-case-indent)) | 9287 (setq indent-pt (- indent-pt verilog-case-indent)) |
9543 (verilog-insert-indent "endcase\n") | 9288 (verilog-insert-indent "endcase\n") |
9544 (setq indent-pt (- indent-pt verilog-indent-level)) | 9289 (setq indent-pt (- indent-pt verilog-indent-level)) |
9545 (verilog-insert-indent "end\n" | 9290 (verilog-insert-indent "end\n" |
9546 "// End of automatics\n") | 9291 "// End of automatics\n")))) |
9547 ))) | |
9548 | 9292 |
9549 (defun verilog-auto-templated-rel () | 9293 (defun verilog-auto-templated-rel () |
9550 "Replace Templated relative line numbers with absolute line numbers. | 9294 "Replace Templated relative line numbers with absolute line numbers. |
9551 Internal use only. This hacks around the line numbers in AUTOINST Templates | 9295 Internal use only. This hacks around the line numbers in AUTOINST Templates |
9552 being different from the final output's line numbering." | 9296 being different from the final output's line numbering." |
9692 ;; After we've created all new variables | 9436 ;; After we've created all new variables |
9693 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) | 9437 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) |
9694 ;; Must be after all inputs outputs are generated | 9438 ;; Must be after all inputs outputs are generated |
9695 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) | 9439 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) |
9696 ;; Fix line numbers (comments only) | 9440 ;; Fix line numbers (comments only) |
9697 (verilog-auto-templated-rel) | 9441 (verilog-auto-templated-rel)) |
9698 ) | |
9699 ;; | 9442 ;; |
9700 (run-hooks 'verilog-auto-hook) | 9443 (run-hooks 'verilog-auto-hook) |
9701 ;; | 9444 ;; |
9702 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | 9445 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) |
9703 ;; | 9446 ;; |
9707 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | 9450 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) |
9708 (t (unless noninteractive (message "Updating AUTOs...done"))))) | 9451 (t (unless noninteractive (message "Updating AUTOs...done"))))) |
9709 ;; Unwind forms | 9452 ;; Unwind forms |
9710 (progn | 9453 (progn |
9711 ;; Restore font-lock | 9454 ;; Restore font-lock |
9712 (when fontlocked (font-lock-mode t))) | 9455 (when fontlocked (font-lock-mode t)))))) |
9713 ))) | |
9714 | 9456 |
9715 | 9457 |
9716 ;; | 9458 ;; |
9717 ;; Skeleton based code insertion | 9459 ;; Skeleton based code insertion |
9718 ;; | 9460 ;; |
9719 (defvar verilog-template-map | 9461 (defvar verilog-template-map |
9720 (let ((map (make-sparse-keymap))) | 9462 (let ((map (make-sparse-keymap))) |
9721 (define-key map "a" 'verilog-sk-always) | 9463 (define-key map "a" 'verilog-sk-always) |
9722 (define-key map "b" 'verilog-sk-begin) | 9464 (define-key map "b" 'verilog-sk-begin) |
9723 (define-key map "c" 'verilog-sk-case) | 9465 (define-key map "c" 'verilog-sk-case) |
9724 (define-key map "f" 'verilog-sk-for) | 9466 (define-key map "f" 'verilog-sk-for) |
9983 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) | 9725 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
9984 | 9726 |
9985 (defun verilog-sk-define-signal () | 9727 (defun verilog-sk-define-signal () |
9986 "Insert a definition of signal under point at top of module." | 9728 "Insert a definition of signal under point at top of module." |
9987 (interactive "*") | 9729 (interactive "*") |
9988 (let* ( | 9730 (let* ((sig-re "[a-zA-Z0-9_]*") |
9989 (sig-re "[a-zA-Z0-9_]*") | |
9990 (v1 (buffer-substring | 9731 (v1 (buffer-substring |
9991 (save-excursion | 9732 (save-excursion |
9992 (skip-chars-backward sig-re) | 9733 (skip-chars-backward sig-re) |
9993 (point)) | 9734 (point)) |
9994 (save-excursion | 9735 (save-excursion |
9995 (skip-chars-forward sig-re) | 9736 (skip-chars-forward sig-re) |
9996 (point)))) | 9737 (point))))) |
9997 ) | |
9998 (if (not (member v1 verilog-keywords)) | 9738 (if (not (member v1 verilog-keywords)) |
9999 (save-excursion | 9739 (save-excursion |
10000 (setq verilog-sk-signal v1) | 9740 (setq verilog-sk-signal v1) |
10001 (verilog-beg-of-defun) | 9741 (verilog-beg-of-defun) |
10002 (verilog-end-of-statement) | 9742 (verilog-end-of-statement) |
10003 (verilog-forward-syntactic-ws) | 9743 (verilog-forward-syntactic-ws) |
10004 (verilog-sk-def-reg) | 9744 (verilog-sk-def-reg) |
10005 (message "signal at point is %s" v1)) | 9745 (message "signal at point is %s" v1)) |
10006 (message "object at point (%s) is a keyword" v1)) | 9746 (message "object at point (%s) is a keyword" v1)))) |
10007 ) | |
10008 ) | |
10009 | |
10010 | 9747 |
10011 (define-skeleton verilog-sk-wire | 9748 (define-skeleton verilog-sk-wire |
10012 "Insert a wire definition." | 9749 "Insert a wire definition." |
10013 () | 9750 () |
10014 > "wire [" (verilog-sk-datadef)) | 9751 > "wire [" (verilog-sk-datadef)) |
10107 | 9844 |
10108 (defconst verilog-include-file-regexp | 9845 (defconst verilog-include-file-regexp |
10109 "^`include\\s-+\"\\([^\n\"]*\\)\"" | 9846 "^`include\\s-+\"\\([^\n\"]*\\)\"" |
10110 "Regexp that matches the include file.") | 9847 "Regexp that matches the include file.") |
10111 | 9848 |
10112 (defvar verilog-mode-mouse-map | 9849 (defvar verilog-mode-mouse-map |
10113 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map | 9850 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
10114 (set-keymap-parent map verilog-mode-map) | 9851 (set-keymap-parent map verilog-mode-map) |
10115 ;; mouse button bindings | 9852 ;; mouse button bindings |
10116 (define-key map "\r" 'verilog-load-file-at-point) | 9853 (define-key map "\r" 'verilog-load-file-at-point) |
10117 (if (featurep 'xemacs) | 9854 (if (featurep 'xemacs) |
10187 (find-file (car (verilog-library-filenames | 9924 (find-file (car (verilog-library-filenames |
10188 (match-string 1) (buffer-file-name)))) | 9925 (match-string 1) (buffer-file-name)))) |
10189 (progn | 9926 (progn |
10190 (message | 9927 (message |
10191 "File '%s' isn't readable, use shift-mouse2 to paste in this field" | 9928 "File '%s' isn't readable, use shift-mouse2 to paste in this field" |
10192 (match-string 1)))) | 9929 (match-string 1))))))) |
10193 ))) | |
10194 | 9930 |
10195 ;; ffap isn't useable for verilog mode. It uses library paths. | 9931 ;; ffap isn't useable for verilog mode. It uses library paths. |
10196 ;; so define this function to do more or less the same as ffap | 9932 ;; so define this function to do more or less the same as ffap |
10197 ;; but first resolve filename... | 9933 ;; but first resolve filename... |
10198 (defun verilog-load-file-at-point () | 9934 (defun verilog-load-file-at-point () |
10206 (car (verilog-library-filenames | 9942 (car (verilog-library-filenames |
10207 (match-string 1) (buffer-file-name))) | 9943 (match-string 1) (buffer-file-name))) |
10208 (file-readable-p (car (verilog-library-filenames | 9944 (file-readable-p (car (verilog-library-filenames |
10209 (match-string 1) (buffer-file-name))))) | 9945 (match-string 1) (buffer-file-name))))) |
10210 (find-file (car (verilog-library-filenames | 9946 (find-file (car (verilog-library-filenames |
10211 (match-string 1) (buffer-file-name)))))) | 9947 (match-string 1) (buffer-file-name)))))))) |
10212 )) | |
10213 | 9948 |
10214 | 9949 |
10215 ;; | 9950 ;; |
10216 ;; Bug reporting | 9951 ;; Bug reporting |
10217 ;; | 9952 ;; |
10228 (princ "\n") | 9963 (princ "\n") |
10229 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | 9964 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") |
10230 (princ "\n"))) | 9965 (princ "\n"))) |
10231 | 9966 |
10232 (autoload 'reporter-submit-bug-report "reporter") | 9967 (autoload 'reporter-submit-bug-report "reporter") |
9968 (defvar reporter-prompt-for-summary-p) | |
10233 | 9969 |
10234 (defun verilog-submit-bug-report () | 9970 (defun verilog-submit-bug-report () |
10235 "Submit via mail a bug report on verilog-mode.el." | 9971 "Submit via mail a bug report on verilog-mode.el." |
10236 (interactive) | 9972 (interactive) |
10237 (let ((reporter-prompt-for-summary-p t)) | 9973 (let ((reporter-prompt-for-summary-p t)) |