Mercurial > emacs
comparison lisp/progmodes/verilog-mode.el @ 79799:57956dd69d3f
(top-level): Fix spacing.
(verilog-mode-version, verilog-mode-release-date): Update version
number.
(verilog-mode-release-emacs): New variable.
(compile-command, reporter-prompt-for-summary-p): Define for byte
compiler.
(verilog-startup-message-lines)
(verilog-startup-message-displayed)
(verilog-display-startup-message): Remove.
(verilog-highlight-p1800-keywords): Improve docstring.
(sigs-in, sigs-out, got-sig, got-rvalue, uses-delayed)
(vector-skip-list): Only defvar at compile time.
(verilog-highlight-translate-off, verilog-indent-level)
(verilog-indent-level-module, verilog-indent-level-declaration)
(verilog-indent-declaration-macros, verilog-indent-lists)
(verilog-indent-level-behavioral)
(verilog-indent-level-directive, verilog-cexp-indent)
(verilog-case-indent, verilog-auto-newline)
(verilog-auto-indent-on-newline, verilog-tab-always-indent)
(verilog-tab-to-comment, verilog-indent-begin-after-if)
(verilog-align-ifelse, verilog-minimum-comment-distance)
(verilog-auto-lineup, verilog-highlight-p1800-keywords)
(verilog-auto-endcomments, verilog-auto-read-includes)
(verilog-auto-star-expand, verilog-auto-star-save)
(verilog-library-flags, verilog-library-directories)
(verilog-library-files, verilog-library-extensions)
(verilog-active-low-regexp, verilog-auto-sense-include-inputs)
(verilog-auto-sense-defines-constant, verilog-auto-reset-widths)
(verilog-assignment-delay, verilog-auto-inst-vector)
(verilog-auto-inst-template-numbers)
(verilog-auto-input-ignore-regexp)
(verilog-auto-inout-ignore-regexp)
(verilog-auto-output-ignore-regexp)
(verilog-auto-unused-ignore-regexp, verilog-typedef-regexp): Add
safe-local-variable properties.
(verilog-statement-menu, verilog-company)
(verilog-re-search-forward, verilog-re-search-backward)
(verilog-error-regexp-add, verilog-end-block-re)
(verilog-emacs-features, verilog-populate-syntax-table)
(verilog-setup-dual-comments, verilog-type-font-keywords)
(verilog-inside-comment-p, electric-verilog-backward-sexp)
(verilog-backward-sexp, verilog-forward-sexp)
(verilog-font-lock-init, verilog-mode)
(electric-verilog-terminate-line, electric-verilog-semi)
(electric-verilog-tab, verilog-insert-1, )
(verilog-insert-indices, verilog-generate-numbers)
(verilog-comment-region, verilog-label-be)
(verilog-beg-of-statement, verilog-in-case-region-p)
(verilog-in-struct-region-p, verilog-in-generate-region-p)
(verilog-in-fork-region-p, verilog-backward-case-item)
(verilog-set-auto-endcomments, verilog-get-expr)
(verilog-expand-vector-internal, verilog-surelint-off)
(verilog-batch-execute-func, verilog-calculate-indent)
(verilog-calc-1, verilog-calculate-indent-directive)
(verilog-leap-to-head, verilog-continued-line)
(verilog-backward-token, verilog-backward-syntactic-ws)
(verilog-forward-syntactic-ws, verilog-backward-ws&directives)
(verilog-forward-ws&directives, verilog-at-constraint-p)
(verilog-skip-backward-comments, verilog-indent-line-relative)
(verilog-do-indent, verilog-indent-comment)
(verilog-more-comment, verilog-pretty-declarations)
(verilog-pretty-expr, verilog-just-one-space)
(verilog-indent-declaration, verilog-get-completion-decl)
(verilog-goto-defun, verilog-showscopes, verilog-header)
(verilog-signals-combine-bus, verilog-read-decls)
(verilog-read-always-signals-recurse, verilog-read-instants)
(verilog-read-auto-template, verilog-set-define)
(verilog-read-defines, verilog-read-signals, verilog-getopt)
(verilog-is-number, verilog-expand-dirnames)
(verilog-modi-lookup, verilog-modi-cache-results)
(verilog-insert-one-definition, verilog-make-width-expression)
(verilog-delete-autos-lined, verilog-auto-save-check)
(verilog-auto-arg, verilog-auto-inst-port, verilog-auto-inst)
(verilog-auto-inst-param, verilog-auto-reg)
(verilog-auto-reg-input, verilog-auto-wire, )
(verilog-auto-output, verilog-auto-output-every)
(verilog-auto-input, verilog-auto-inout)
(verilog-auto-inout-module, verilog-auto-sense)
(verilog-auto-reset, verilog-auto-tieoff, verilog-auto-unused)
(verilog-auto-ascii-enum, verilog-auto)
(verilog-sk-define-signal, verilog-mode-mouse-map)
(verilog-load-file-at-mouse, verilog-load-file-at-point)
(verilog-library-files): Cleanup spacing of )'s they should not be
on unique lines. Fix checkdoc warnings.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 09 Jan 2008 06:30:58 +0000 |
parents | a1342e6e097a |
children | 1fc1252447c5 |
comparison
equal
deleted
inserted
replaced
79798:b56de37b6be4 | 79799:57956dd69d3f |
---|---|
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." |
288 Depending on the `verilog-set-compile-command', this may be invoked when | 302 Depending on the `verilog-set-compile-command', this may be invoked when |
289 you type \\[compile]. When the compile completes, \\[next-error] will take | 303 you type \\[compile]. When the compile completes, \\[next-error] will take |
290 you to the next lint error." | 304 you to the next lint error." |
291 :type 'string | 305 :type 'string |
292 :group 'verilog-mode-actions) | 306 :group 'verilog-mode-actions) |
307 ;; We don't mark it safe, as it's used as a shell command | |
293 | 308 |
294 (defcustom verilog-coverage | 309 (defcustom verilog-coverage |
295 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" | 310 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" |
296 "*Program and arguments to use to annotate for coverage verilog source. | 311 "*Program and arguments to use to annotate for coverage verilog source. |
297 Depending on the `verilog-set-compile-command', this may be invoked when | 312 Depending on the `verilog-set-compile-command', this may be invoked when |
298 you type \\[compile]. When the compile completes, \\[next-error] will take | 313 you type \\[compile]. When the compile completes, \\[next-error] will take |
299 you to the next lint error." | 314 you to the next lint error." |
300 :type 'string | 315 :type 'string |
301 :group 'verilog-mode-actions) | 316 :group 'verilog-mode-actions) |
317 ;; We don't mark it safe, as it's used as a shell command | |
302 | 318 |
303 (defcustom verilog-simulator | 319 (defcustom verilog-simulator |
304 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" | 320 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" |
305 "*Program and arguments to use to interpret verilog source. | 321 "*Program and arguments to use to interpret verilog source. |
306 Depending on the `verilog-set-compile-command', this may be invoked when | 322 Depending on the `verilog-set-compile-command', this may be invoked when |
307 you type \\[compile]. When the compile completes, \\[next-error] will take | 323 you type \\[compile]. When the compile completes, \\[next-error] will take |
308 you to the next lint error." | 324 you to the next lint error." |
309 :type 'string | 325 :type 'string |
310 :group 'verilog-mode-actions) | 326 :group 'verilog-mode-actions) |
327 ;; We don't mark it safe, as it's used as a shell command | |
311 | 328 |
312 (defcustom verilog-compiler | 329 (defcustom verilog-compiler |
313 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" | 330 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" |
314 "*Program and arguments to use to compile verilog source. | 331 "*Program and arguments to use to compile verilog source. |
315 Depending on the `verilog-set-compile-command', this may be invoked when | 332 Depending on the `verilog-set-compile-command', this may be invoked when |
316 you type \\[compile]. When the compile completes, \\[next-error] will take | 333 you type \\[compile]. When the compile completes, \\[next-error] will take |
317 you to the next lint error." | 334 you to the next lint error." |
318 :type 'string | 335 :type 'string |
319 :group 'verilog-mode-actions) | 336 :group 'verilog-mode-actions) |
337 ;; We don't mark it safe, as it's used as a shell command | |
320 | 338 |
321 (defvar verilog-tool 'verilog-linter | 339 (defvar verilog-tool 'verilog-linter |
322 "Which tool to use for building compiler-command. | 340 "Which tool to use for building compiler-command. |
323 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | 341 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or |
324 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | 342 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" |
334 | 352 |
335 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | 353 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." | 354 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." |
337 :type 'boolean | 355 :type 'boolean |
338 :group 'verilog-mode-indent) | 356 :group 'verilog-mode-indent) |
357 ;; Note we don't use :safe, as that would break on Emacsen before 22.0. | |
358 (put 'verilog-highlight-translate-off 'safe-local-variable 'booleanp) | |
339 | 359 |
340 (defcustom verilog-indent-level 3 | 360 (defcustom verilog-indent-level 3 |
341 "*Indentation of Verilog statements with respect to containing block." | 361 "*Indentation of Verilog statements with respect to containing block." |
342 :group 'verilog-mode-indent | 362 :group 'verilog-mode-indent |
343 :type 'integer) | 363 :type 'integer) |
364 (put 'verilog-indent-level 'safe-local-variable 'integerp) | |
344 | 365 |
345 (defcustom verilog-indent-level-module 3 | 366 (defcustom verilog-indent-level-module 3 |
346 "*Indentation of Module level Verilog statements. (eg always, initial) | 367 "*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 | 368 Set to 0 to get initial and always statements lined up on the left side of |
348 your screen." | 369 your screen." |
349 :group 'verilog-mode-indent | 370 :group 'verilog-mode-indent |
350 :type 'integer) | 371 :type 'integer) |
372 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) | |
351 | 373 |
352 (defcustom verilog-indent-level-declaration 3 | 374 (defcustom verilog-indent-level-declaration 3 |
353 "*Indentation of declarations with respect to containing block. | 375 "*Indentation of declarations with respect to containing block. |
354 Set to 0 to get them list right under containing block." | 376 Set to 0 to get them list right under containing block." |
355 :group 'verilog-mode-indent | 377 :group 'verilog-mode-indent |
356 :type 'integer) | 378 :type 'integer) |
379 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) | |
357 | 380 |
358 (defcustom verilog-indent-declaration-macros nil | 381 (defcustom verilog-indent-declaration-macros nil |
359 "*How to treat macro expansions in a declaration. | 382 "*How to treat macro expansions in a declaration. |
360 If nil, indent as: | 383 If nil, indent as: |
361 input [31:0] a; | 384 input [31:0] a; |
365 input [31:0] a; | 388 input [31:0] a; |
366 input `CP ; | 389 input `CP ; |
367 output c;" | 390 output c;" |
368 :group 'verilog-mode-indent | 391 :group 'verilog-mode-indent |
369 :type 'boolean) | 392 :type 'boolean) |
393 (put 'verilog-indent-declaration-macros 'safe-local-variable 'booleanp) | |
370 | 394 |
371 (defcustom verilog-indent-lists t | 395 (defcustom verilog-indent-lists t |
372 "*How to treat indenting items in a list. | 396 "*How to treat indenting items in a list. |
373 If t (the default), indent as: | 397 If t (the default), indent as: |
374 always @( posedge a or | 398 always @( posedge a or |
377 If nil, treat as: | 401 If nil, treat as: |
378 always @( posedge a or | 402 always @( posedge a or |
379 reset ) begin" | 403 reset ) begin" |
380 :group 'verilog-mode-indent | 404 :group 'verilog-mode-indent |
381 :type 'boolean) | 405 :type 'boolean) |
406 (put 'verilog-indent-lists 'safe-local-variable 'booleanp) | |
382 | 407 |
383 (defcustom verilog-indent-level-behavioral 3 | 408 (defcustom verilog-indent-level-behavioral 3 |
384 "*Absolute indentation of first begin in a task or function block. | 409 "*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." | 410 Set to 0 to get such code to start at the left side of the screen." |
386 :group 'verilog-mode-indent | 411 :group 'verilog-mode-indent |
387 :type 'integer) | 412 :type 'integer) |
413 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) | |
388 | 414 |
389 (defcustom verilog-indent-level-directive 1 | 415 (defcustom verilog-indent-level-directive 1 |
390 "*Indentation to add to each level of `ifdef declarations. | 416 "*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." | 417 Set to 0 to have all directives start at the left side of the screen." |
392 :group 'verilog-mode-indent | 418 :group 'verilog-mode-indent |
393 :type 'integer) | 419 :type 'integer) |
420 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) | |
394 | 421 |
395 (defcustom verilog-cexp-indent 2 | 422 (defcustom verilog-cexp-indent 2 |
396 "*Indentation of Verilog statements split across lines." | 423 "*Indentation of Verilog statements split across lines." |
397 :group 'verilog-mode-indent | 424 :group 'verilog-mode-indent |
398 :type 'integer) | 425 :type 'integer) |
426 (put 'verilog-cexp-indent 'safe-local-variable 'integerp) | |
399 | 427 |
400 (defcustom verilog-case-indent 2 | 428 (defcustom verilog-case-indent 2 |
401 "*Indentation for case statements." | 429 "*Indentation for case statements." |
402 :group 'verilog-mode-indent | 430 :group 'verilog-mode-indent |
403 :type 'integer) | 431 :type 'integer) |
432 (put 'verilog-case-indent 'safe-local-variable 'integerp) | |
404 | 433 |
405 (defcustom verilog-auto-newline t | 434 (defcustom verilog-auto-newline t |
406 "*True means automatically newline after semicolons." | 435 "*True means automatically newline after semicolons." |
407 :group 'verilog-mode-indent | 436 :group 'verilog-mode-indent |
408 :type 'boolean) | 437 :type 'boolean) |
438 (put 'verilog-auto-newline 'safe-local-variable 'booleanp) | |
409 | 439 |
410 (defcustom verilog-auto-indent-on-newline t | 440 (defcustom verilog-auto-indent-on-newline t |
411 "*True means automatically indent line after newline." | 441 "*True means automatically indent line after newline." |
412 :group 'verilog-mode-indent | 442 :group 'verilog-mode-indent |
413 :type 'boolean) | 443 :type 'boolean) |
444 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'booleanp) | |
414 | 445 |
415 (defcustom verilog-tab-always-indent t | 446 (defcustom verilog-tab-always-indent t |
416 "*True means TAB should always re-indent the current line. | 447 "*True means TAB should always re-indent the current line. |
417 Nil means TAB will only reindent when at the beginning of the line." | 448 Nil means TAB will only reindent when at the beginning of the line." |
418 :group 'verilog-mode-indent | 449 :group 'verilog-mode-indent |
419 :type 'boolean) | 450 :type 'boolean) |
451 (put 'verilog-tab-always-indent 'safe-local-variable 'booleanp) | |
420 | 452 |
421 (defcustom verilog-tab-to-comment nil | 453 (defcustom verilog-tab-to-comment nil |
422 "*True means TAB moves to the right hand column in preparation for a comment." | 454 "*True means TAB moves to the right hand column in preparation for a comment." |
423 :group 'verilog-mode-actions | 455 :group 'verilog-mode-actions |
424 :type 'boolean) | 456 :type 'boolean) |
457 (put 'verilog-tab-to-comment 'safe-local-variable 'booleanp) | |
425 | 458 |
426 (defcustom verilog-indent-begin-after-if t | 459 (defcustom verilog-indent-begin-after-if t |
427 "*If true, indent begin statements following if, else, while, for and repeat. | 460 "*If true, indent begin statements following if, else, while, for and repeat. |
428 Otherwise, line them up." | 461 Otherwise, line them up." |
429 :group 'verilog-mode-indent | 462 :group 'verilog-mode-indent |
430 :type 'boolean ) | 463 :type 'boolean) |
464 (put 'verilog-indent-begin-after-if 'safe-local-variable 'booleanp) | |
431 | 465 |
432 | 466 |
433 (defcustom verilog-align-ifelse nil | 467 (defcustom verilog-align-ifelse nil |
434 "*If true, align `else' under matching `if'. | 468 "*If true, align `else' under matching `if'. |
435 Otherwise else is lined up with first character on line holding matching if." | 469 Otherwise else is lined up with first character on line holding matching if." |
436 :group 'verilog-mode-indent | 470 :group 'verilog-mode-indent |
437 :type 'boolean ) | 471 :type 'boolean) |
472 (put 'verilog-align-ifelse 'safe-local-variable 'booleanp) | |
438 | 473 |
439 (defcustom verilog-minimum-comment-distance 10 | 474 (defcustom verilog-minimum-comment-distance 10 |
440 "*Minimum distance (in lines) between begin and end required before a comment. | 475 "*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 | 476 Setting this variable to zero results in every end acquiring a comment; the |
442 default avoids too many redundant comments in tight quarters" | 477 default avoids too many redundant comments in tight quarters" |
443 :group 'verilog-mode-indent | 478 :group 'verilog-mode-indent |
444 :type 'integer) | 479 :type 'integer) |
480 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) | |
445 | 481 |
446 (defcustom verilog-auto-lineup '(declaration) | 482 (defcustom verilog-auto-lineup '(declaration) |
447 "*Algorithm for lining up statements on multiple lines. | 483 "*Algorithm for lining up statements on multiple lines. |
448 | 484 |
449 If this list contains the symbol 'all', then all line ups described below | 485 If this list contains the symbol 'all', then all line ups described below |
479 ; b : a = 4; | 515 ; b : a = 4; |
480 ; endcase | 516 ; endcase |
481 ; | 517 ; |
482 | 518 |
483 :group 'verilog-mode-indent | 519 :group 'verilog-mode-indent |
484 :type 'list ) | 520 :type 'list) |
521 (put 'verilog-auto-lineup 'safe-local-variable 'listp) | |
485 | 522 |
486 (defcustom verilog-highlight-p1800-keywords nil | 523 (defcustom verilog-highlight-p1800-keywords nil |
487 "*If true highlight words newly reserved by IEEE-1800 in | 524 "*True means highlight words newly reserved by IEEE-1800. |
488 verilog-font-lock-p1800-face in order to gently suggest changing where | 525 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 | 526 suggest changing where these words are used as variables to something else. |
490 these words as appropriate for the SystemVerilog IEEE-1800 standard. Note | 527 Nil means highlight these words as appropriate for the SystemVerilog |
491 that changing this will require restarting emacs to see the effect as font | 528 IEEE-1800 standard. Note that changing this will require restarting Emacs |
492 color choices are cached by emacs" | 529 to see the effect as font color choices are cached by Emacs" |
493 :group 'verilog-mode-indent | 530 :group 'verilog-mode-indent |
494 :type 'boolean) | 531 :type 'boolean) |
532 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'booleanp) | |
495 | 533 |
496 (defcustom verilog-auto-endcomments t | 534 (defcustom verilog-auto-endcomments t |
497 "*True means insert a comment /* ... */ after 'end's. | 535 "*True means insert a comment /* ... */ after 'end's. |
498 The name of the function or case will be set between the braces." | 536 The name of the function or case will be set between the braces." |
499 :group 'verilog-mode-actions | 537 :group 'verilog-mode-actions |
500 :type 'boolean ) | 538 :type 'boolean) |
539 (put 'verilog-auto-endcomments 'safe-local-variable 'booleanp) | |
501 | 540 |
502 (defcustom verilog-auto-read-includes nil | 541 (defcustom verilog-auto-read-includes nil |
503 "*True means to automatically read includes before AUTOs. | 542 "*True means to automatically read includes before AUTOs. |
504 This will do a `verilog-read-defines' and `verilog-read-includes' before | 543 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, | 544 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 | 545 but can result in very slow reading times if there are many or large |
507 include files." | 546 include files." |
508 :group 'verilog-mode-actions | 547 :group 'verilog-mode-actions |
509 :type 'boolean ) | 548 :type 'boolean) |
549 (put 'verilog-auto-read-includes 'safe-local-variable 'booleanp) | |
510 | 550 |
511 (defcustom verilog-auto-save-policy nil | 551 (defcustom verilog-auto-save-policy nil |
512 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | 552 "*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 | 553 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] | 554 needed on every save. A value of `detect' will do \\[verilog-auto] |
525 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | 565 "*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 | 566 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'." | 567 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." |
528 :group 'verilog-mode-actions | 568 :group 'verilog-mode-actions |
529 :type 'boolean) | 569 :type 'boolean) |
570 (put 'verilog-auto-star-expand 'safe-local-variable 'booleanp) | |
530 | 571 |
531 (defcustom verilog-auto-star-save nil | 572 (defcustom verilog-auto-star-save nil |
532 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. | 573 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. |
533 Nil indicates direct connections will be removed before saving. Only | 574 Nil indicates direct connections will be removed before saving. Only |
534 meaningful to those created due to `verilog-auto-star-expand' being set. | 575 meaningful to those created due to `verilog-auto-star-expand' being set. |
535 | 576 |
536 Instead of setting this, you may want to use /*AUTOINST*/, which will | 577 Instead of setting this, you may want to use /*AUTOINST*/, which will |
537 always be saved." | 578 always be saved." |
538 :group 'verilog-mode-actions | 579 :group 'verilog-mode-actions |
539 :type 'boolean) | 580 :type 'boolean) |
581 (put 'verilog-auto-star-save 'safe-local-variable 'booleanp) | |
540 | 582 |
541 (defvar verilog-auto-update-tick nil | 583 (defvar verilog-auto-update-tick nil |
542 "Modification tick at which autos were last performed.") | 584 "Modification tick at which autos were last performed.") |
543 | 585 |
544 (defvar verilog-auto-last-file-locals nil | 586 (defvar verilog-auto-last-file-locals nil |
622 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | 664 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) |
623 ; Leda | 665 ; Leda |
624 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | 666 ("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) | 667 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) |
626 ) | 668 ) |
627 "*Keywords to also highlight in Verilog *compilation* buffers." | 669 "*Keywords to also highlight in Verilog *compilation* buffers.") |
628 ) | |
629 | 670 |
630 (defcustom verilog-library-flags '("") | 671 (defcustom verilog-library-flags '("") |
631 "*List of standard Verilog arguments to use for /*AUTOINST*/. | 672 "*List of standard Verilog arguments to use for /*AUTOINST*/. |
632 These arguments are used to find files for `verilog-auto', and match | 673 These arguments are used to find files for `verilog-auto', and match |
633 the flags accepted by a standard Verilog-XL simulator. | 674 the flags accepted by a standard Verilog-XL simulator. |
654 have problems, use \\[find-alternate-file] RET to have these take effect. | 695 have problems, use \\[find-alternate-file] RET to have these take effect. |
655 | 696 |
656 See also the variables mentioned above." | 697 See also the variables mentioned above." |
657 :group 'verilog-mode-auto | 698 :group 'verilog-mode-auto |
658 :type '(repeat string)) | 699 :type '(repeat string)) |
700 (put 'verilog-library-flags 'safe-local-variable 'listp) | |
659 | 701 |
660 (defcustom verilog-library-directories '(".") | 702 (defcustom verilog-library-directories '(".") |
661 "*List of directories when looking for files for /*AUTOINST*/. | 703 "*List of directories when looking for files for /*AUTOINST*/. |
662 The directory may be relative to the current file, or absolute. | 704 The directory may be relative to the current file, or absolute. |
663 Environment variables are also expanded in the directory names. | 705 Environment variables are also expanded in the directory names. |
676 | 718 |
677 See also `verilog-library-flags', `verilog-library-files' | 719 See also `verilog-library-flags', `verilog-library-files' |
678 and `verilog-library-extensions'." | 720 and `verilog-library-extensions'." |
679 :group 'verilog-mode-auto | 721 :group 'verilog-mode-auto |
680 :type '(repeat file)) | 722 :type '(repeat file)) |
723 (put 'verilog-library-directories 'safe-local-variable 'listp) | |
681 | 724 |
682 (defcustom verilog-library-files '() | 725 (defcustom verilog-library-files '() |
683 "*List of files to search for modules when looking for AUTOINST files. | 726 "*List of files to search for modules. |
727 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 | 728 This is a complete path, usually to a technology file with many standard |
685 cells defined in it. | 729 cells defined in it. |
686 | 730 |
687 You might want these defined in each file; put at the *END* of your file | 731 You might want these defined in each file; put at the *END* of your file |
688 something like: | 732 something like: |
696 have problems, use \\[find-alternate-file] RET to have these take effect. | 740 have problems, use \\[find-alternate-file] RET to have these take effect. |
697 | 741 |
698 See also `verilog-library-flags', `verilog-library-directories'." | 742 See also `verilog-library-flags', `verilog-library-directories'." |
699 :group 'verilog-mode-auto | 743 :group 'verilog-mode-auto |
700 :type '(repeat directory)) | 744 :type '(repeat directory)) |
745 (put 'verilog-library-files 'safe-local-variable 'listp) | |
701 | 746 |
702 (defcustom verilog-library-extensions '(".v") | 747 (defcustom verilog-library-extensions '(".v") |
703 "*List of extensions to use when looking for files for /*AUTOINST*/. | 748 "*List of extensions to use when looking for files for /*AUTOINST*/. |
704 See also `verilog-library-flags', `verilog-library-directories'." | 749 See also `verilog-library-flags', `verilog-library-directories'." |
705 :type '(repeat string) | 750 :type '(repeat string) |
706 :group 'verilog-mode-auto) | 751 :group 'verilog-mode-auto) |
752 (put 'verilog-library-extensions 'safe-local-variable 'listp) | |
707 | 753 |
708 (defcustom verilog-active-low-regexp nil | 754 (defcustom verilog-active-low-regexp nil |
709 "*If set, treat signals matching this regexp as active low. | 755 "*If set, treat signals matching this regexp as active low. |
710 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | 756 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, |
711 you will probably also need `verilog-auto-reset-widths' set." | 757 you will probably also need `verilog-auto-reset-widths' set." |
712 :group 'verilog-mode-auto | 758 :group 'verilog-mode-auto |
713 :type 'string) | 759 :type 'string) |
760 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) | |
714 | 761 |
715 (defcustom verilog-auto-sense-include-inputs nil | 762 (defcustom verilog-auto-sense-include-inputs nil |
716 "*If true, AUTOSENSE should include all inputs. | 763 "*If true, AUTOSENSE should include all inputs. |
717 If nil, only inputs that are NOT output signals in the same block are | 764 If nil, only inputs that are NOT output signals in the same block are |
718 included." | 765 included." |
719 :type 'boolean | 766 :group 'verilog-mode-auto |
720 :group 'verilog-mode-auto) | 767 :type 'boolean) |
768 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'booleanp) | |
721 | 769 |
722 (defcustom verilog-auto-sense-defines-constant nil | 770 (defcustom verilog-auto-sense-defines-constant nil |
723 "*If true, AUTOSENSE should assume all defines represent constants. | 771 "*If true, AUTOSENSE should assume all defines represent constants. |
724 When true, the defines will not be included in sensitivity lists. To | 772 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 | 773 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." | 774 of each verilog file that requires it, rather than being set globally." |
727 :type 'boolean | 775 :group 'verilog-mode-auto |
728 :group 'verilog-mode-auto) | 776 :type 'boolean) |
777 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'booleanp) | |
729 | 778 |
730 (defcustom verilog-auto-reset-widths t | 779 (defcustom verilog-auto-reset-widths t |
731 "*If true, AUTORESET should determine the width of signals. | 780 "*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 | 781 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 | 782 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 | 783 the constant zero. This may result in ugly code when parameters determine |
735 the MSB or LSB of a signal inside a AUTORESET." | 784 the MSB or LSB of a signal inside a AUTORESET." |
736 :type 'boolean | 785 :type 'boolean |
737 :group 'verilog-mode-auto) | 786 :group 'verilog-mode-auto) |
787 (put 'verilog-auto-reset-widths 'safe-local-variable 'booleanp) | |
738 | 788 |
739 (defcustom verilog-assignment-delay "" | 789 (defcustom verilog-assignment-delay "" |
740 "*Text used for delays in delayed assignments. Add a trailing space if set." | 790 "*Text used for delays in delayed assignments. Add a trailing space if set." |
741 :type 'string | 791 :group 'verilog-mode-auto |
742 :group 'verilog-mode-auto) | 792 :type 'string) |
793 (put 'verilog-assignment-delay 'safe-local-variable 'stringp) | |
743 | 794 |
744 (defcustom verilog-auto-inst-vector t | 795 (defcustom verilog-auto-inst-vector t |
745 "*If true, when creating default ports with AUTOINST, use bus subscripts. | 796 "*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 | 797 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 | 798 the module (AUTOWIRE signals always are subscripted, you must manually |
748 declare the wire to have the subscripts removed.) Nil may speed up some | 799 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." | 800 simulators, but is less general and harder to read, so avoid." |
750 :group 'verilog-mode-auto | 801 :group 'verilog-mode-auto |
751 :type 'boolean ) | 802 :type 'boolean) |
803 (put 'verilog-auto-inst-vector 'safe-local-variable 'booleanp) | |
752 | 804 |
753 (defcustom verilog-auto-inst-template-numbers nil | 805 (defcustom verilog-auto-inst-template-numbers nil |
754 "*If true, when creating templated ports with AUTOINST, add a comment. | 806 "*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 | 807 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 | 808 port declaration. Setting this aids in debugging, but nil is suggested for |
757 regular use to prevent large numbers of merge conflicts." | 809 regular use to prevent large numbers of merge conflicts." |
758 :group 'verilog-mode-auto | 810 :group 'verilog-mode-auto |
759 :type 'boolean ) | 811 :type 'boolean) |
812 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'booleanp) | |
760 | 813 |
761 (defvar verilog-auto-inst-column 40 | 814 (defvar verilog-auto-inst-column 40 |
762 "Column number for first part of auto-inst.") | 815 "Column number for first part of auto-inst.") |
763 | 816 |
764 (defcustom verilog-auto-input-ignore-regexp nil | 817 (defcustom verilog-auto-input-ignore-regexp nil |
765 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | 818 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. |
766 See the \\[verilog-faq] for examples on using this." | 819 See the \\[verilog-faq] for examples on using this." |
767 :group 'verilog-mode-auto | 820 :group 'verilog-mode-auto |
768 :type 'string ) | 821 :type 'string) |
822 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) | |
769 | 823 |
770 (defcustom verilog-auto-inout-ignore-regexp nil | 824 (defcustom verilog-auto-inout-ignore-regexp nil |
771 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | 825 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. |
772 See the \\[verilog-faq] for examples on using this." | 826 See the \\[verilog-faq] for examples on using this." |
773 :group 'verilog-mode-auto | 827 :group 'verilog-mode-auto |
774 :type 'string ) | 828 :type 'string) |
829 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) | |
775 | 830 |
776 (defcustom verilog-auto-output-ignore-regexp nil | 831 (defcustom verilog-auto-output-ignore-regexp nil |
777 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | 832 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. |
778 See the \\[verilog-faq] for examples on using this." | 833 See the \\[verilog-faq] for examples on using this." |
779 :group 'verilog-mode-auto | 834 :group 'verilog-mode-auto |
780 :type 'string ) | 835 :type 'string) |
836 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) | |
781 | 837 |
782 (defcustom verilog-auto-unused-ignore-regexp nil | 838 (defcustom verilog-auto-unused-ignore-regexp nil |
783 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | 839 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. |
784 See the \\[verilog-faq] for examples on using this." | 840 See the \\[verilog-faq] for examples on using this." |
785 :group 'verilog-mode-auto | 841 :group 'verilog-mode-auto |
786 :type 'string ) | 842 :type 'string) |
843 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) | |
787 | 844 |
788 (defcustom verilog-typedef-regexp nil | 845 (defcustom verilog-typedef-regexp nil |
789 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | 846 "*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." | 847 For example, \"_t$\" matches typedefs named with _t, as in the C language." |
791 :group 'verilog-mode-auto | 848 :group 'verilog-mode-auto |
792 :type 'string ) | 849 :type 'string) |
850 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) | |
793 | 851 |
794 (defcustom verilog-mode-hook 'verilog-set-compile-command | 852 (defcustom verilog-mode-hook 'verilog-set-compile-command |
795 "*Hook (List of functions) run after verilog mode is loaded." | 853 "*Hook (List of functions) run after verilog mode is loaded." |
796 :type 'hook | 854 :type 'hook |
797 :group 'verilog-mode) | 855 :group 'verilog-mode) |
798 | 856 |
799 (defcustom verilog-auto-hook nil | 857 (defcustom verilog-auto-hook nil |
800 "*Hook run after `verilog-mode' updates AUTOs." | 858 "*Hook run after `verilog-mode' updates AUTOs." |
801 :type 'hook | 859 :group 'verilog-mode-auto |
802 :group 'verilog-mode-auto) | 860 :type 'hook) |
803 | 861 |
804 (defcustom verilog-before-auto-hook nil | 862 (defcustom verilog-before-auto-hook nil |
805 "*Hook run before `verilog-mode' updates AUTOs." | 863 "*Hook run before `verilog-mode' updates AUTOs." |
806 :type 'hook | 864 :group 'verilog-mode-auto |
807 :group 'verilog-mode-auto) | 865 :type 'hook) |
808 | 866 |
809 (defcustom verilog-delete-auto-hook nil | 867 (defcustom verilog-delete-auto-hook nil |
810 "*Hook run after `verilog-mode' deletes AUTOs." | 868 "*Hook run after `verilog-mode' deletes AUTOs." |
811 :type 'hook | 869 :group 'verilog-mode-auto |
812 :group 'verilog-mode-auto) | 870 :type 'hook) |
813 | 871 |
814 (defcustom verilog-before-delete-auto-hook nil | 872 (defcustom verilog-before-delete-auto-hook nil |
815 "*Hook run before `verilog-mode' deletes AUTOs." | 873 "*Hook run before `verilog-mode' deletes AUTOs." |
816 :type 'hook | 874 :group 'verilog-mode-auto |
817 :group 'verilog-mode-auto) | 875 :type 'hook) |
818 | 876 |
819 (defcustom verilog-getopt-flags-hook nil | 877 (defcustom verilog-getopt-flags-hook nil |
820 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists." | 878 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists." |
821 :type 'hook | 879 :group 'verilog-mode-auto |
822 :group 'verilog-mode-auto) | 880 :type 'hook) |
823 | 881 |
824 (defcustom verilog-before-getopt-flags-hook nil | 882 (defcustom verilog-before-getopt-flags-hook nil |
825 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists." | 883 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists." |
826 :type 'hook | 884 :group 'verilog-mode-auto |
827 :group 'verilog-mode-auto) | 885 :type 'hook) |
828 | 886 |
829 (defvar verilog-imenu-generic-expression | 887 (defvar verilog-imenu-generic-expression |
830 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | 888 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) |
831 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) | 889 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) |
832 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.") | 890 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.") |
841 format (e.g. 09/17/1997) is not supported.") | 899 format (e.g. 09/17/1997) is not supported.") |
842 | 900 |
843 (defvar verilog-company nil | 901 (defvar verilog-company nil |
844 "*Default name of Company for verilog header. | 902 "*Default name of Company for verilog header. |
845 If set will become buffer local.") | 903 If set will become buffer local.") |
846 | |
847 (make-variable-buffer-local 'verilog-company) | 904 (make-variable-buffer-local 'verilog-company) |
848 | 905 |
849 (defvar verilog-project nil | 906 (defvar verilog-project nil |
850 "*Default name of Project for verilog header. | 907 "*Default name of Project for verilog header. |
851 If set will become buffer local.") | 908 If set will become buffer local.") |
852 | |
853 (make-variable-buffer-local 'verilog-project) | 909 (make-variable-buffer-local 'verilog-project) |
854 | 910 |
855 (defvar verilog-mode-map | 911 (defvar verilog-mode-map |
856 (let ((map (make-sparse-keymap))) | 912 (let ((map (make-sparse-keymap))) |
857 (define-key map ";" 'electric-verilog-semi) | 913 (define-key map ";" 'electric-verilog-semi) |
1023 ["Repeat" verilog-sk-repeat t] | 1079 ["Repeat" verilog-sk-repeat t] |
1024 ["Case" verilog-sk-case t] | 1080 ["Case" verilog-sk-case t] |
1025 ["Casex" verilog-sk-casex t] | 1081 ["Casex" verilog-sk-casex t] |
1026 ["Casez" verilog-sk-casez t] | 1082 ["Casez" verilog-sk-casez t] |
1027 ) | 1083 ) |
1028 "Menu for statement templates in Verilog." | 1084 "Menu for statement templates in Verilog.") |
1029 ) | |
1030 | 1085 |
1031 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode" | 1086 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode" |
1032 verilog-xemacs-menu) | 1087 verilog-xemacs-menu) |
1033 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." | 1088 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." |
1034 verilog-statement-menu) | 1089 verilog-statement-menu) |
1070 (and (verilog-skip-forward-comment-or-string) | 1125 (and (verilog-skip-forward-comment-or-string) |
1071 (progn | 1126 (progn |
1072 (store-match-data '(nil nil)) | 1127 (store-match-data '(nil nil)) |
1073 (if BOUND | 1128 (if BOUND |
1074 (< (point) BOUND) | 1129 (< (point) BOUND) |
1075 t) | 1130 t))))) |
1076 )))) | |
1077 (match-end 0)) | 1131 (match-end 0)) |
1078 | 1132 |
1079 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) | 1133 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
1080 ; checkdoc-params: (REGEXP BOUND NOERROR) | 1134 ; checkdoc-params: (REGEXP BOUND NOERROR) |
1081 "Like `re-search-backward', but skips over match in comments or strings." | 1135 "Like `re-search-backward', but skips over match in comments or strings." |
1085 (and (verilog-skip-backward-comment-or-string) | 1139 (and (verilog-skip-backward-comment-or-string) |
1086 (progn | 1140 (progn |
1087 (store-match-data '(nil nil)) | 1141 (store-match-data '(nil nil)) |
1088 (if BOUND | 1142 (if BOUND |
1089 (> (point) BOUND) | 1143 (> (point) BOUND) |
1090 t) | 1144 t))))) |
1091 )))) | |
1092 (match-end 0)) | 1145 (match-end 0)) |
1093 | 1146 |
1094 (defsubst verilog-re-search-forward-quick (regexp bound noerror) | 1147 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
1095 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, | 1148 "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. | 1149 but trashes match data and is faster for REGEXP that doesn't match often. |
1127 (point))) | 1180 (point))) |
1128 | 1181 |
1129 (defsubst verilog-within-string () | 1182 (defsubst verilog-within-string () |
1130 (save-excursion | 1183 (save-excursion |
1131 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) | 1184 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) |
1185 | |
1186 (defvar compile-command) | |
1132 | 1187 |
1133 ;; compilation program | 1188 ;; compilation program |
1134 (defun verilog-set-compile-command () | 1189 (defun verilog-set-compile-command () |
1135 "Function to compute shell command to compile verilog. | 1190 "Function to compute shell command to compile verilog. |
1136 | 1191 |
1199 (default-value 'compilation-error-regexp-alist))) | 1254 (default-value 'compilation-error-regexp-alist))) |
1200 ;; Could be buffer local at this point; maybe also in let; change all three | 1255 ;; Could be buffer local at this point; maybe also in let; change all three |
1201 (setq compilation-error-regexp-alist | 1256 (setq compilation-error-regexp-alist |
1202 (default-value 'compilation-error-regexp-alist)) | 1257 (default-value 'compilation-error-regexp-alist)) |
1203 (set (make-local-variable 'compilation-error-regexp-alist) | 1258 (set (make-local-variable 'compilation-error-regexp-alist) |
1204 (default-value 'compilation-error-regexp-alist)) | 1259 (default-value 'compilation-error-regexp-alist))))) |
1205 ))) | |
1206 | 1260 |
1207 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) | 1261 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) |
1208 | 1262 |
1209 (defconst verilog-directive-re | 1263 (defconst verilog-directive-re |
1210 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | 1264 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" |
1328 "endinterface" | 1382 "endinterface" |
1329 "endpackage" | 1383 "endpackage" |
1330 "endprogram" | 1384 "endprogram" |
1331 "endsequence" | 1385 "endsequence" |
1332 "endclocking" | 1386 "endclocking" |
1333 ) | 1387 )))) |
1334 ))) | |
1335 | 1388 |
1336 | 1389 |
1337 (defconst verilog-endcomment-reason-re | 1390 (defconst verilog-endcomment-reason-re |
1338 ;; Parenthesis indicate type of keyword found | 1391 ;; Parenthesis indicate type of keyword found |
1339 (concat | 1392 (concat |
1665 flavor comments flock-syntax) | 1718 flavor comments flock-syntax) |
1666 ;; figure out version numbers if not already discovered | 1719 ;; figure out version numbers if not already discovered |
1667 (and (or (not major) (not minor)) | 1720 (and (or (not major) (not minor)) |
1668 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) | 1721 (string-match "\\([0-9]+\\).\\([0-9]+\\)" emacs-version) |
1669 (setq major (string-to-number (substring emacs-version | 1722 (setq major (string-to-number (substring emacs-version |
1670 (match-beginning 1) | 1723 (match-beginning 1) |
1671 (match-end 1))) | 1724 (match-end 1))) |
1672 minor (string-to-number (substring emacs-version | 1725 minor (string-to-number (substring emacs-version |
1673 (match-beginning 2) | 1726 (match-beginning 2) |
1674 (match-end 2))))) | 1727 (match-end 2))))) |
1675 (if (not (and major minor)) | 1728 (if (not (and major minor)) |
1676 (error "Cannot figure out the major and minor version numbers")) | 1729 (error "Cannot figure out the major and minor version numbers")) |
1677 ;; calculate the major version | 1730 ;; calculate the major version |
1678 (cond | 1731 (cond |
1679 ((= major 4) (setq major 'v18)) ;Epoch 4 | 1732 ((= major 4) (setq major 'v18)) ;Epoch 4 |
1704 ;; XEmacs 20 is known to be 8-bit | 1757 ;; XEmacs 20 is known to be 8-bit |
1705 ((eq flavor 'XEmacs) (setq comments '8-bit)) | 1758 ((eq flavor 'XEmacs) (setq comments '8-bit)) |
1706 ;; Emacs 19.30 and beyond are known to be 1-bit | 1759 ;; Emacs 19.30 and beyond are known to be 1-bit |
1707 ((eq flavor 'FSF) (setq comments '1-bit)) | 1760 ((eq flavor 'FSF) (setq comments '1-bit)) |
1708 ;; Don't know what this is | 1761 ;; Don't know what this is |
1709 (t (error "Couldn't figure out syntax table format")) | 1762 (t (error "Couldn't figure out syntax table format")))) |
1710 )) | |
1711 ;; Emacs 18 has no support for dual comments | 1763 ;; Emacs 18 has no support for dual comments |
1712 (setq comments 'no-dual-comments)) | 1764 (setq comments 'no-dual-comments)) |
1713 ;; determine whether to use old or new font lock syntax | 1765 ;; determine whether to use old or new font lock syntax |
1714 ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise | 1766 ;; We can assume 8-bit syntax table emacsen support new syntax, otherwise |
1715 ;; look for version > 19.30 | 1767 ;; look for version > 19.30 |
1722 ;; lets do some minimal sanity checking. | 1774 ;; lets do some minimal sanity checking. |
1723 (if (or | 1775 (if (or |
1724 ;; Emacs before 19.6 had bugs | 1776 ;; Emacs before 19.6 had bugs |
1725 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6)) | 1777 (and (eq major 'v19) (eq flavor 'XEmacs) (< minor 6)) |
1726 ;; Emacs 19 before 19.21 has known bugs | 1778 ;; Emacs 19 before 19.21 has known bugs |
1727 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21)) | 1779 (and (eq major 'v19) (eq flavor 'FSF) (< minor 21))) |
1728 ) | |
1729 (with-output-to-temp-buffer "*verilog-mode warnings*" | 1780 (with-output-to-temp-buffer "*verilog-mode warnings*" |
1730 (print (format | 1781 (print (format |
1731 "The version of Emacs that you are running, %s, | 1782 "The version of Emacs that you are running, %s, |
1732 has known bugs in its syntax parsing routines which will affect the | 1783 has known bugs in its syntax parsing routines which will affect the |
1733 performance of verilog-mode. You should strongly consider upgrading to the | 1784 performance of verilog-mode. You should strongly consider upgrading to the |
1783 (modify-syntax-entry ?> "." table) | 1834 (modify-syntax-entry ?> "." table) |
1784 (modify-syntax-entry ?& "." table) | 1835 (modify-syntax-entry ?& "." table) |
1785 (modify-syntax-entry ?| "." table) | 1836 (modify-syntax-entry ?| "." table) |
1786 (modify-syntax-entry ?` "w" table) | 1837 (modify-syntax-entry ?` "w" table) |
1787 (modify-syntax-entry ?_ "w" table) | 1838 (modify-syntax-entry ?_ "w" table) |
1788 (modify-syntax-entry ?\' "." table) | 1839 (modify-syntax-entry ?\' "." table)) |
1789 ) | |
1790 | 1840 |
1791 (defun verilog-setup-dual-comments (table) | 1841 (defun verilog-setup-dual-comments (table) |
1792 "Set up TABLE to handle block and line style comments." | 1842 "Set up TABLE to handle block and line style comments." |
1793 (cond | 1843 (cond |
1794 ((memq '8-bit verilog-emacs-features) | 1844 ((memq '8-bit verilog-emacs-features) |
1795 ;; XEmacs (formerly Lucid) has the best implementation | 1845 ;; XEmacs (formerly Lucid) has the best implementation |
1796 (modify-syntax-entry ?/ ". 1456" table) | 1846 (modify-syntax-entry ?/ ". 1456" table) |
1797 (modify-syntax-entry ?* ". 23" table) | 1847 (modify-syntax-entry ?* ". 23" table) |
1798 (modify-syntax-entry ?\n "> b" table) | 1848 (modify-syntax-entry ?\n "> b" table)) |
1799 ) | |
1800 ((memq '1-bit verilog-emacs-features) | 1849 ((memq '1-bit verilog-emacs-features) |
1801 ;; Emacs 19 does things differently, but we can work with it | 1850 ;; Emacs 19 does things differently, but we can work with it |
1802 (modify-syntax-entry ?/ ". 124b" table) | 1851 (modify-syntax-entry ?/ ". 124b" table) |
1803 (modify-syntax-entry ?* ". 23" table) | 1852 (modify-syntax-entry ?* ". 23" table) |
1804 (modify-syntax-entry ?\n "> b" table) | 1853 (modify-syntax-entry ?\n "> b" table)))) |
1805 ) | |
1806 )) | |
1807 | 1854 |
1808 (defvar verilog-mode-syntax-table nil | 1855 (defvar verilog-mode-syntax-table nil |
1809 "Syntax table used in `verilog-mode' buffers.") | 1856 "Syntax table used in `verilog-mode' buffers.") |
1810 | 1857 |
1811 (defvar verilog-font-lock-keywords nil | 1858 (defvar verilog-font-lock-keywords nil |
1959 'verilog-font-lock-p1800-face) | 2006 'verilog-font-lock-p1800-face) |
1960 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | 2007 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") |
1961 'font-lock-type-face)) | 2008 'font-lock-type-face)) |
1962 ;; Fontify Verilog-AMS keywords | 2009 ;; Fontify Verilog-AMS keywords |
1963 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | 2010 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") |
1964 'verilog-font-lock-ams-face) | 2011 'verilog-font-lock-ams-face))) |
1965 )) | |
1966 | 2012 |
1967 (setq verilog-font-lock-keywords-1 | 2013 (setq verilog-font-lock-keywords-1 |
1968 (append verilog-font-lock-keywords | 2014 (append verilog-font-lock-keywords |
1969 (list | 2015 (list |
1970 ;; Fontify module definitions | 2016 ;; Fontify module definitions |
1974 '(3 font-lock-function-name-face 'prepend)) | 2020 '(3 font-lock-function-name-face 'prepend)) |
1975 ;; Fontify function definitions | 2021 ;; Fontify function definitions |
1976 (list | 2022 (list |
1977 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | 2023 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) |
1978 '(1 font-lock-keyword-face) | 2024 '(1 font-lock-keyword-face) |
1979 '(3 font-lock-reference-face prepend) | 2025 '(3 font-lock-reference-face prepend)) |
1980 ) | |
1981 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" | 2026 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
1982 (1 font-lock-keyword-face) | 2027 (1 font-lock-keyword-face) |
1983 (2 font-lock-reference-face append) | 2028 (2 font-lock-reference-face append)) |
1984 ) | |
1985 '("\\<function\\>\\s-+\\(\\sw+\\)" | 2029 '("\\<function\\>\\s-+\\(\\sw+\\)" |
1986 1 'font-lock-reference-face append) | 2030 1 'font-lock-reference-face append)))) |
1987 ))) | |
1988 | 2031 |
1989 (setq verilog-font-lock-keywords-2 | 2032 (setq verilog-font-lock-keywords-2 |
1990 (append verilog-font-lock-keywords-1 | 2033 (append verilog-font-lock-keywords-1 |
1991 (list | 2034 (list |
1992 ;; Fontify pragmas | 2035 ;; Fontify pragmas |
2000 ;; Fontify delays/numbers | 2043 ;; Fontify delays/numbers |
2001 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | 2044 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" |
2002 0 font-lock-type-face append) | 2045 0 font-lock-type-face append) |
2003 ;; Fontify instantiation names | 2046 ;; Fontify instantiation names |
2004 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | 2047 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) |
2005 | |
2006 ))) | 2048 ))) |
2007 | 2049 |
2008 (setq verilog-font-lock-keywords-3 | 2050 (setq verilog-font-lock-keywords-3 |
2009 (append verilog-font-lock-keywords-2 | 2051 (append verilog-font-lock-keywords-2 |
2010 (when verilog-highlight-translate-off | 2052 (when verilog-highlight-translate-off |
2013 '(verilog-match-translate-off | 2055 '(verilog-match-translate-off |
2014 (0 'verilog-font-lock-translate-off-face prepend)) | 2056 (0 'verilog-font-lock-translate-off-face prepend)) |
2015 ))))) | 2057 ))))) |
2016 | 2058 |
2017 | 2059 |
2018 | |
2019 (defun verilog-inside-comment-p () | 2060 (defun verilog-inside-comment-p () |
2020 "Check if point inside a nested comment." | 2061 "Check if point inside a nested comment." |
2021 (save-excursion | 2062 (save-excursion |
2022 (let ((st-point (point)) hitbeg) | 2063 (let ((st-point (point)) hitbeg) |
2023 (or (search-backward "//" (verilog-get-beg-of-line) t) | 2064 (or (search-backward "//" (verilog-get-beg-of-line) t) |
2024 (if (progn | 2065 (if (progn |
2025 ;; This is for tricky case //*, we keep searching if /* is | 2066 ;; This is for tricky case //*, we keep searching if /* |
2026 ;; proceeded by // on same line. | 2067 ;; is proceeded by // on same line. |
2027 (while | 2068 (while |
2028 (and (setq hitbeg (search-backward "/*" nil t)) | 2069 (and (setq hitbeg (search-backward "/*" nil t)) |
2029 (progn | 2070 (progn |
2030 (forward-char 1) | 2071 (forward-char 1) |
2031 (search-backward "//" (verilog-get-beg-of-line) t)))) | 2072 (search-backward "//" (verilog-get-beg-of-line) t)))) |
2046 | 2087 |
2047 (defun electric-verilog-backward-sexp () | 2088 (defun electric-verilog-backward-sexp () |
2048 "Move backward over a sexp." | 2089 "Move backward over a sexp." |
2049 (interactive) | 2090 (interactive) |
2050 ;; before that see if we are in a comment | 2091 ;; before that see if we are in a comment |
2051 (verilog-backward-sexp) | 2092 (verilog-backward-sexp)) |
2052 ) | 2093 |
2053 (defun electric-verilog-forward-sexp () | 2094 (defun electric-verilog-forward-sexp () |
2054 "Move backward over a sexp." | 2095 "Move backward over a sexp." |
2055 (interactive) | 2096 (interactive) |
2056 ;; before that see if we are in a comment | 2097 ;; before that see if we are in a comment |
2057 (verilog-forward-sexp) | 2098 (verilog-forward-sexp)) |
2058 ) | 2099 |
2059 ;;;used by hs-minor-mode | 2100 ;;;used by hs-minor-mode |
2060 (defun verilog-forward-sexp-function (arg) | 2101 (defun verilog-forward-sexp-function (arg) |
2061 (if (< arg 0) | 2102 (if (< arg 0) |
2062 (verilog-backward-sexp) | 2103 (verilog-backward-sexp) |
2063 (verilog-forward-sexp))) | 2104 (verilog-forward-sexp))) |
2065 | 2106 |
2066 (defun verilog-backward-sexp () | 2107 (defun verilog-backward-sexp () |
2067 (let ((reg) | 2108 (let ((reg) |
2068 (elsec 1) | 2109 (elsec 1) |
2069 (found nil) | 2110 (found nil) |
2070 (st (point)) | 2111 (st (point))) |
2071 ) | |
2072 (if (not (looking-at "\\<")) | 2112 (if (not (looking-at "\\<")) |
2073 (forward-word -1)) | 2113 (forward-word -1)) |
2074 (cond | 2114 (cond |
2075 ((verilog-skip-backward-comment-or-string) | 2115 ((verilog-skip-backward-comment-or-string)) |
2076 ) | |
2077 ((looking-at "\\<else\\>") | 2116 ((looking-at "\\<else\\>") |
2078 (setq reg (concat | 2117 (setq reg (concat |
2079 verilog-end-block-re | 2118 verilog-end-block-re |
2080 "\\|\\(\\<else\\>\\)" | 2119 "\\|\\(\\<else\\>\\)" |
2081 "\\|\\(\\<if\\>\\)" | 2120 "\\|\\(\\<if\\>\\)")) |
2082 )) | |
2083 (while (and (not found) | 2121 (while (and (not found) |
2084 (verilog-re-search-backward reg nil 'move)) | 2122 (verilog-re-search-backward reg nil 'move)) |
2085 (cond | 2123 (cond |
2086 ((match-end 1) ; matched verilog-end-block-re | 2124 ((match-end 1) ; matched verilog-end-block-re |
2087 ; try to leap back to matching outward block by striding across | 2125 ; try to leap back to matching outward block by striding across |
2092 (setq elsec (1+ elsec))) | 2130 (setq elsec (1+ elsec))) |
2093 ((match-end 3) ; found it | 2131 ((match-end 3) ; found it |
2094 (setq elsec (1- elsec)) | 2132 (setq elsec (1- elsec)) |
2095 (if (= 0 elsec) | 2133 (if (= 0 elsec) |
2096 ;; Now previous line describes syntax | 2134 ;; Now previous line describes syntax |
2097 (setq found 't) | 2135 (setq found 't)))))) |
2098 )) | |
2099 ) | |
2100 ) | |
2101 ) | |
2102 ((looking-at verilog-end-block-re) | 2136 ((looking-at verilog-end-block-re) |
2103 (verilog-leap-to-head)) | 2137 (verilog-leap-to-head)) |
2104 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | 2138 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") |
2105 (cond | 2139 (cond |
2106 ((match-end 1) | 2140 ((match-end 1) |
2118 (t | 2152 (t |
2119 (goto-char st) | 2153 (goto-char st) |
2120 (backward-sexp 1)))) | 2154 (backward-sexp 1)))) |
2121 (t | 2155 (t |
2122 (goto-char st) | 2156 (goto-char st) |
2123 (backward-sexp)) | 2157 (backward-sexp))))) |
2124 ) ;; cond | |
2125 )) | |
2126 | 2158 |
2127 (defun verilog-forward-sexp () | 2159 (defun verilog-forward-sexp () |
2128 (let ((reg) | 2160 (let ((reg) |
2129 (md 2) | 2161 (md 2) |
2130 (st (point))) | 2162 (st (point))) |
2131 (if (not (looking-at "\\<")) | 2163 (if (not (looking-at "\\<")) |
2132 (forward-word -1)) | 2164 (forward-word -1)) |
2133 (cond | 2165 (cond |
2134 ((verilog-skip-forward-comment-or-string) | 2166 ((verilog-skip-forward-comment-or-string) |
2135 (verilog-forward-syntactic-ws) | 2167 (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 | 2168 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking |
2138 (cond | 2169 (cond |
2139 ((match-end 1) ; end | 2170 ((match-end 1) ; end |
2140 ;; Search forward for matching begin | 2171 ;; Search forward for matching begin |
2141 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | 2172 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) |
2142 ((match-end 2) ; endcase | 2173 ((match-end 2) ; endcase |
2143 ;; Search forward for matching case | 2174 ;; Search forward for matching case |
2144 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ) | 2175 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) |
2145 ) | |
2146 ((match-end 3) ; join | 2176 ((match-end 3) ; join |
2147 ;; Search forward for matching fork | 2177 ;; Search forward for matching fork |
2148 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | 2178 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) |
2149 ((match-end 4) ; endclass | 2179 ((match-end 4) ; endclass |
2150 ;; Search forward for matching class | 2180 ;; Search forward for matching class |
2171 ;; Search forward for matching property | 2201 ;; Search forward for matching property |
2172 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | 2202 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) |
2173 ((match-end 12) ; endsequence | 2203 ((match-end 12) ; endsequence |
2174 ;; Search forward for matching sequence | 2204 ;; Search forward for matching sequence |
2175 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | 2205 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) |
2176 (setq md 3) ; 3 to get to endsequence in the reg above | 2206 (setq md 3)) ; 3 to get to endsequence in the reg above |
2177 ) | |
2178 ((match-end 13) ; endclocking | 2207 ((match-end 13) ; endclocking |
2179 ;; Search forward for matching clocking | 2208 ;; Search forward for matching clocking |
2180 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" )) | 2209 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) |
2181 ) | |
2182 (if (forward-word 1) | 2210 (if (forward-word 1) |
2183 (catch 'skip | 2211 (catch 'skip |
2184 (let ((nest 1)) | 2212 (let ((nest 1)) |
2185 (while (verilog-re-search-forward reg nil 'move) | 2213 (while (verilog-re-search-forward reg nil 'move) |
2186 (cond | 2214 (cond |
2187 ((match-end md) ; the closer in reg, so we are climbing out | 2215 ((match-end md) ; the closer in reg, so we are climbing out |
2188 (setq nest (1- nest)) | 2216 (setq nest (1- nest)) |
2189 (if (= 0 nest) ; we are out! | 2217 (if (= 0 nest) ; we are out! |
2190 (throw 'skip 1))) | 2218 (throw 'skip 1))) |
2191 ((match-end 1) ; the opener in reg, so we are deeper now | 2219 ((match-end 1) ; the opener in reg, so we are deeper now |
2192 (setq nest (1+ nest))))) | 2220 (setq nest (1+ nest))))))))) |
2193 ))) | |
2194 ) | |
2195 ((looking-at (concat | 2221 ((looking-at (concat |
2196 "\\(\\<\\(macro\\)?module\\>\\)\\|" | 2222 "\\(\\<\\(macro\\)?module\\>\\)\\|" |
2197 "\\(\\<primitive\\>\\)\\|" | 2223 "\\(\\<primitive\\>\\)\\|" |
2198 "\\(\\<class\\>\\)\\|" | 2224 "\\(\\<class\\>\\)\\|" |
2199 "\\(\\<program\\>\\)\\|" | 2225 "\\(\\<program\\>\\)\\|" |
2219 (forward-sexp 1))))) | 2245 (forward-sexp 1))))) |
2220 (t | 2246 (t |
2221 (goto-char st) | 2247 (goto-char st) |
2222 (if (= (following-char) ?\) ) | 2248 (if (= (following-char) ?\) ) |
2223 (forward-char 1) | 2249 (forward-char 1) |
2224 (forward-sexp 1))) | 2250 (forward-sexp 1)))))) |
2225 ) ;; cond | |
2226 )) | |
2227 | 2251 |
2228 (defun verilog-declaration-beg () | 2252 (defun verilog-declaration-beg () |
2229 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | 2253 (verilog-re-search-backward verilog-declaration-re (bobp) t)) |
2230 | 2254 |
2231 (defun verilog-font-lock-init () | 2255 (defun verilog-font-lock-init () |
2236 (append verilog-font-lock-keywords-2 | 2260 (append verilog-font-lock-keywords-2 |
2237 (when verilog-highlight-translate-off | 2261 (when verilog-highlight-translate-off |
2238 (list | 2262 (list |
2239 ;; Fontify things in translate off regions | 2263 ;; Fontify things in translate off regions |
2240 '(verilog-match-translate-off | 2264 '(verilog-match-translate-off |
2241 (0 'verilog-font-lock-translate-off-face prepend)) | 2265 (0 'verilog-font-lock-translate-off-face prepend)))))) |
2242 )))) | |
2243 (put 'verilog-mode 'font-lock-defaults | 2266 (put 'verilog-mode 'font-lock-defaults |
2244 '((verilog-font-lock-keywords | 2267 '((verilog-font-lock-keywords |
2245 verilog-font-lock-keywords-1 | 2268 verilog-font-lock-keywords-1 |
2246 verilog-font-lock-keywords-2 | 2269 verilog-font-lock-keywords-2 |
2247 verilog-font-lock-keywords-3) | 2270 verilog-font-lock-keywords-3) |
2251 ;; Function to move to beginning of reasonable region to highlight | 2274 ;; Function to move to beginning of reasonable region to highlight |
2252 verilog-beg-of-defun))) | 2275 verilog-beg-of-defun))) |
2253 | 2276 |
2254 ;; initialize fontification for Verilog Mode | 2277 ;; initialize fontification for Verilog Mode |
2255 (verilog-font-lock-init) | 2278 (verilog-font-lock-init) |
2256 ;; start up message | 2279 |
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 ;; | 2280 ;; |
2274 ;; | 2281 ;; |
2275 ;; Mode | 2282 ;; Mode |
2276 ;; | 2283 ;; |
2277 (defvar verilog-which-tool 1) | 2284 (defvar verilog-which-tool 1) |
2409 (setq major-mode 'verilog-mode) | 2416 (setq major-mode 'verilog-mode) |
2410 (setq mode-name "Verilog") | 2417 (setq mode-name "Verilog") |
2411 (setq local-abbrev-table verilog-mode-abbrev-table) | 2418 (setq local-abbrev-table verilog-mode-abbrev-table) |
2412 (setq verilog-mode-syntax-table (make-syntax-table)) | 2419 (setq verilog-mode-syntax-table (make-syntax-table)) |
2413 (verilog-populate-syntax-table verilog-mode-syntax-table) | 2420 (verilog-populate-syntax-table verilog-mode-syntax-table) |
2414 (set (make-local-variable 'beginning-of-defun-function) | 2421 (set (make-local-variable 'beginning-of-defun-function) |
2415 'verilog-beg-of-defun) | 2422 'verilog-beg-of-defun) |
2416 (set (make-local-variable 'end-of-defun-function) | 2423 (set (make-local-variable 'end-of-defun-function) |
2417 'verilog-end-of-defun) | 2424 'verilog-end-of-defun) |
2418 ;; add extra comment syntax | 2425 ;; add extra comment syntax |
2419 (verilog-setup-dual-comments verilog-mode-syntax-table) | 2426 (verilog-setup-dual-comments verilog-mode-syntax-table) |
2420 (set-syntax-table verilog-mode-syntax-table) | 2427 (set-syntax-table verilog-mode-syntax-table) |
2421 (make-local-variable 'indent-line-function) | 2428 (make-local-variable 'indent-line-function) |
2442 (when (featurep 'xemacs) | 2449 (when (featurep 'xemacs) |
2443 (when (and current-menubar | 2450 (when (and current-menubar |
2444 (not (assoc "Verilog" current-menubar))) | 2451 (not (assoc "Verilog" current-menubar))) |
2445 ;; (set-buffer-menubar (copy-sequence current-menubar)) | 2452 ;; (set-buffer-menubar (copy-sequence current-menubar)) |
2446 (add-submenu nil verilog-xemacs-menu) | 2453 (add-submenu nil verilog-xemacs-menu) |
2447 (add-submenu nil verilog-stmt-menu) | 2454 (add-submenu nil verilog-stmt-menu))) |
2448 )) | 2455 |
2449 ;; Stuff for GNU emacs | 2456 ;; Stuff for GNU emacs |
2450 (set (make-local-variable 'font-lock-defaults) | 2457 (set (make-local-variable 'font-lock-defaults) |
2451 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 | 2458 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 |
2452 verilog-font-lock-keywords-2 | 2459 verilog-font-lock-keywords-2 |
2453 verilog-font-lock-keywords-3) | 2460 verilog-font-lock-keywords-3) |
2470 (unless (assq 'verilog-mode hs-special-modes-alist) | 2477 (unless (assq 'verilog-mode hs-special-modes-alist) |
2471 (setq hs-special-modes-alist | 2478 (setq hs-special-modes-alist |
2472 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil | 2479 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil |
2473 verilog-forward-sexp-function) | 2480 verilog-forward-sexp-function) |
2474 hs-special-modes-alist))) | 2481 hs-special-modes-alist))) |
2475 ;; Display version splash information. | |
2476 (verilog-display-startup-message) | |
2477 | 2482 |
2478 ;; Stuff for autos | 2483 ;; Stuff for autos |
2479 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | 2484 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local |
2480 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them | 2485 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them |
2481 ;; (verilog-getopt-flags) | 2486 ;; (verilog-getopt-flags) |
2525 (newline)) | 2530 (newline)) |
2526 nil) | 2531 nil) |
2527 (progn | 2532 (progn |
2528 (end-of-line) | 2533 (end-of-line) |
2529 (delete-horizontal-space) | 2534 (delete-horizontal-space) |
2530 't | 2535 't))) |
2531 ) | |
2532 ) | |
2533 ) | |
2534 ;; see if we should line up assignments | 2536 ;; see if we should line up assignments |
2535 (progn | 2537 (progn |
2536 (if (or (memq 'all verilog-auto-lineup) | 2538 (if (or (memq 'all verilog-auto-lineup) |
2537 (memq 'assignments verilog-auto-lineup)) | 2539 (memq 'assignments verilog-auto-lineup)) |
2538 (verilog-pretty-expr) | 2540 (verilog-pretty-expr)) |
2539 ) | 2541 (newline)) |
2540 (newline) | 2542 (forward-line 1)) |
2541 ) | |
2542 (forward-line 1) | |
2543 ) | |
2544 ;; Indent next line | 2543 ;; Indent next line |
2545 (if verilog-auto-indent-on-newline | 2544 (if verilog-auto-indent-on-newline |
2546 (verilog-indent-line)) | 2545 (verilog-indent-line))) |
2547 ) | |
2548 (t | 2546 (t |
2549 (newline)) | 2547 (newline))))) |
2550 ))) | |
2551 | 2548 |
2552 (defun electric-verilog-terminate-and-indent () | 2549 (defun electric-verilog-terminate-and-indent () |
2553 "Insert a newline and indent for the next statement." | 2550 "Insert a newline and indent for the next statement." |
2554 (interactive) | 2551 (interactive) |
2555 (electric-verilog-terminate-line 1)) | 2552 (electric-verilog-terminate-line 1)) |
2563 (verilog-in-escaped-name-p)) | 2560 (verilog-in-escaped-name-p)) |
2564 () | 2561 () |
2565 (save-excursion | 2562 (save-excursion |
2566 (beginning-of-line) | 2563 (beginning-of-line) |
2567 (verilog-forward-ws&directives) | 2564 (verilog-forward-ws&directives) |
2568 (verilog-indent-line) | 2565 (verilog-indent-line)) |
2569 ) | |
2570 (if (and verilog-auto-newline | 2566 (if (and verilog-auto-newline |
2571 (not (verilog-parenthesis-depth))) | 2567 (not (verilog-parenthesis-depth))) |
2572 (electric-verilog-terminate-line)))) | 2568 (electric-verilog-terminate-line)))) |
2573 | 2569 |
2574 (defun electric-verilog-semi-with-comment () | 2570 (defun electric-verilog-semi-with-comment () |
2646 ; kill existing comment | 2642 ; kill existing comment |
2647 (beginning-of-line) | 2643 (beginning-of-line) |
2648 (re-search-forward comment-start-skip oldpnt 'move) | 2644 (re-search-forward comment-start-skip oldpnt 'move) |
2649 (goto-char (match-beginning 0)) | 2645 (goto-char (match-beginning 0)) |
2650 (skip-chars-backward " \t") | 2646 (skip-chars-backward " \t") |
2651 (kill-region (point) oldpnt) | 2647 (kill-region (point) oldpnt)))))) |
2652 )))) | |
2653 ) | |
2654 (progn (insert "\t")))) | 2648 (progn (insert "\t")))) |
2655 | 2649 |
2656 | 2650 |
2657 | 2651 |
2658 ;; | 2652 ;; |
2688 (insert " */")) | 2682 (insert " */")) |
2689 (newline) | 2683 (newline) |
2690 (insert " * ")) | 2684 (insert " * ")) |
2691 | 2685 |
2692 (defun verilog-insert-1 (fmt max) | 2686 (defun verilog-insert-1 (fmt max) |
2693 "Insert integers 0 to MAX-1 according to format string FMT. | 2687 "Use format string FMT to insert integers 0 to MAX - 1. |
2694 Inserts one integer per line, at the current column. Stops early | 2688 Inserts one integer per line, at the current column. Stops early |
2695 if it reaches the end of the buffer." | 2689 if it reaches the end of the buffer." |
2696 (let ((col (current-column)) | 2690 (let ((col (current-column)) |
2697 (n 0)) | 2691 (n 0)) |
2698 (save-excursion | 2692 (save-excursion |
2722 a = b a[ 5] = b | 2716 a = b a[ 5] = b |
2723 a = b a[ 6] = b | 2717 a = b a[ 6] = b |
2724 a = b a[ 7] = b | 2718 a = b a[ 7] = b |
2725 a = b a[ 8] = b" | 2719 a = b a[ 8] = b" |
2726 | 2720 |
2727 (interactive "NMAX? ") | 2721 (interactive "NMAX: ") |
2728 (verilog-insert-1 "[%3d]" max)) | 2722 (verilog-insert-1 "[%3d]" max)) |
2729 | 2723 |
2730 (defun verilog-generate-numbers (max) | 2724 (defun verilog-generate-numbers (max) |
2731 "Insert a set of generated numbers into a rectangle. | 2725 "Insert a set of generated numbers into a rectangle. |
2732 The upper left corner is defined by point. The numbers are padded to three | 2726 The upper left corner is defined by point. The numbers are padded to three |
2742 buf buf buf buf005 | 2736 buf buf buf buf005 |
2743 buf buf buf buf006 | 2737 buf buf buf buf006 |
2744 buf buf buf buf007 | 2738 buf buf buf buf007 |
2745 buf buf buf buf008" | 2739 buf buf buf buf008" |
2746 | 2740 |
2747 (interactive "NMAX? ") | 2741 (interactive "NMAX: ") |
2748 (verilog-insert-1 "%3.3d" max)) | 2742 (verilog-insert-1 "%3.3d" max)) |
2749 | 2743 |
2750 (defun verilog-mark-defun () | 2744 (defun verilog-mark-defun () |
2751 "Mark the current verilog function (or procedure). | 2745 "Mark the current verilog function (or procedure). |
2752 This puts the mark at the end, and point at the beginning." | 2746 This puts the mark at the end, and point at the beginning." |
2790 (while (re-search-backward "\\*/" start t) | 2784 (while (re-search-backward "\\*/" start t) |
2791 (replace-match "*-/" t t))) | 2785 (replace-match "*-/" t t))) |
2792 (save-excursion | 2786 (save-excursion |
2793 (let ((s+1 (1+ start))) | 2787 (let ((s+1 (1+ start))) |
2794 (while (re-search-backward "/\\*" s+1 t) | 2788 (while (re-search-backward "/\\*" s+1 t) |
2795 (replace-match "/-*" t t)))) | 2789 (replace-match "/-*" t t)))))) |
2796 )) | |
2797 | 2790 |
2798 (defun verilog-uncomment-region () | 2791 (defun verilog-uncomment-region () |
2799 "Uncomment a commented area; change deformed comments back to normal. | 2792 "Uncomment a commented area; change deformed comments back to normal. |
2800 This command does nothing if the pointer is not in a commented | 2793 This command does nothing if the pointer is not in a commented |
2801 area. See also `verilog-comment-region'." | 2794 area. See also `verilog-comment-region'." |
2867 (b (progn | 2860 (b (progn |
2868 (verilog-beg-of-defun) | 2861 (verilog-beg-of-defun) |
2869 (point-marker))) | 2862 (point-marker))) |
2870 (e (progn | 2863 (e (progn |
2871 (verilog-end-of-defun) | 2864 (verilog-end-of-defun) |
2872 (point-marker))) | 2865 (point-marker)))) |
2873 ) | |
2874 (goto-char (marker-position b)) | 2866 (goto-char (marker-position b)) |
2875 (if (> (- e b) 200) | 2867 (if (> (- e b) 200) |
2876 (message "Relabeling module...")) | 2868 (message "Relabeling module...")) |
2877 (while (and | 2869 (while (and |
2878 (> (marker-position e) (point)) | 2870 (> (marker-position e) (point)) |
2883 nil 'move)) | 2875 nil 'move)) |
2884 (goto-char (match-beginning 0)) | 2876 (goto-char (match-beginning 0)) |
2885 (let ((indent-str (verilog-indent-line))) | 2877 (let ((indent-str (verilog-indent-line))) |
2886 (verilog-set-auto-endcomments indent-str 't) | 2878 (verilog-set-auto-endcomments indent-str 't) |
2887 (end-of-line) | 2879 (end-of-line) |
2888 (delete-horizontal-space) | 2880 (delete-horizontal-space)) |
2889 ) | |
2890 (setq cnt (1+ cnt)) | 2881 (setq cnt (1+ cnt)) |
2891 (if (= 9 (% cnt 10)) | 2882 (if (= 9 (% cnt 10)) |
2892 (message "%d..." cnt)) | 2883 (message "%d..." cnt))) |
2893 ) | |
2894 (goto-char oldpos) | 2884 (goto-char oldpos) |
2895 (if (or | 2885 (if (or |
2896 (> (- e b) 200) | 2886 (> (- e b) 200) |
2897 (> cnt 20)) | 2887 (> cnt 20)) |
2898 (message "%d lines auto commented" cnt)) | 2888 (message "%d lines auto commented" cnt)))) |
2899 )) | |
2900 | 2889 |
2901 (defun verilog-beg-of-statement () | 2890 (defun verilog-beg-of-statement () |
2902 "Move backward to beginning of statement." | 2891 "Move backward to beginning of statement." |
2903 (interactive) | 2892 (interactive) |
2904 ;; Move back token by token until we see the end | 2893 ;; Move back token by token until we see the end |
2917 (forward-word -1))) | 2906 (forward-word -1))) |
2918 (and | 2907 (and |
2919 (looking-at verilog-extended-complete-re) | 2908 (looking-at verilog-extended-complete-re) |
2920 (not (save-excursion | 2909 (not (save-excursion |
2921 (verilog-backward-token) | 2910 (verilog-backward-token) |
2922 (looking-at verilog-extended-complete-re))) | 2911 (looking-at verilog-extended-complete-re)))) |
2923 ) | |
2924 (looking-at verilog-basic-complete-re) | 2912 (looking-at verilog-basic-complete-re) |
2925 (save-excursion | 2913 (save-excursion |
2926 (verilog-backward-token) | 2914 (verilog-backward-token) |
2927 (or | 2915 (or |
2928 (looking-at verilog-end-block-re) | 2916 (looking-at verilog-end-block-re) |
2929 (looking-at verilog-preprocessor-re))) | 2917 (looking-at verilog-preprocessor-re))))) |
2930 )) | |
2931 (verilog-backward-syntactic-ws) | 2918 (verilog-backward-syntactic-ws) |
2932 (verilog-backward-token)) | 2919 (verilog-backward-token)) |
2933 ;; Now point is where the previous line ended. | 2920 ;; Now point is where the previous line ended. |
2934 (verilog-forward-syntactic-ws)) | 2921 (verilog-forward-syntactic-ws)) |
2935 | 2922 |
3009 ((match-end 2) | 2996 ((match-end 2) |
3010 (if (= nest 1) | 2997 (if (= nest 1) |
3011 (throw 'found 1)) | 2998 (throw 'found 1)) |
3012 (setq nest (1- nest))) | 2999 (setq nest (1- nest))) |
3013 (t | 3000 (t |
3014 (throw 'found (= nest 0))) | 3001 (throw 'found (= nest 0))))))) |
3015 )))) | |
3016 nil))) | 3002 nil))) |
3003 | |
3017 (defun verilog-in-struct-region-p () | 3004 (defun verilog-in-struct-region-p () |
3018 "Return TRUE if in a struct region; | 3005 "Return TRUE if in a struct region; |
3019 more specifically, in a list after a struct|union keyword" | 3006 more specifically, in a list after a struct|union keyword" |
3020 (interactive) | 3007 (interactive) |
3021 (save-excursion | 3008 (save-excursion |
3022 (let* ((state (parse-partial-sexp (point-min) (point))) | 3009 (let* ((state (parse-partial-sexp (point-min) (point))) |
3023 (depth (nth 0 state))) | 3010 (depth (nth 0 state))) |
3024 (if depth | 3011 (if depth |
3025 (progn (backward-up-list depth) | 3012 (progn (backward-up-list depth) |
3026 (verilog-beg-of-statement) | 3013 (verilog-beg-of-statement) |
3027 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>") | 3014 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
3028 ) | |
3029 ) | |
3030 ) | |
3031 ) | |
3032 ) | |
3033 | 3015 |
3034 (defun verilog-in-generate-region-p () | 3016 (defun verilog-in-generate-region-p () |
3035 "Return TRUE if in a generate region; | 3017 "Return TRUE if in a generate region; |
3036 more specifically, after a generate and before an endgenerate" | 3018 more specifically, after a generate and before an endgenerate" |
3037 (interactive) | 3019 (interactive) |
3038 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | 3020 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) |
3039 (nest 1) | 3021 (nest 1)) |
3040 ) | |
3041 (save-excursion | 3022 (save-excursion |
3042 (while (and | 3023 (while (and |
3043 (/= nest 0) | 3024 (/= nest 0) |
3044 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) | 3025 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) |
3045 (cond | 3026 (cond |
3046 ((match-end 1) ; generate | 3027 ((match-end 1) ; generate |
3047 (setq nest (1- nest))) | 3028 (setq nest (1- nest))) |
3048 ((match-end 2) ; endgenerate | 3029 ((match-end 2) ; endgenerate |
3049 (setq nest (1+ nest))) | 3030 (setq nest (1+ nest))))))) |
3050 )) | |
3051 )) | |
3052 (= nest 0) )) ; return nest | 3031 (= nest 0) )) ; return nest |
3053 | 3032 |
3054 (defun verilog-in-fork-region-p () | 3033 (defun verilog-in-fork-region-p () |
3055 "Return true if between a fork and join." | 3034 "Return true if between a fork and join." |
3056 (interactive) | 3035 (interactive) |
3057 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | 3036 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) |
3058 (nest 1) | 3037 (nest 1)) |
3059 ) | |
3060 (save-excursion | 3038 (save-excursion |
3061 (while (and | 3039 (while (and |
3062 (/= nest 0) | 3040 (/= nest 0) |
3063 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | 3041 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) |
3064 (cond | 3042 (cond |
3065 ((match-end 1) ; fork | 3043 ((match-end 1) ; fork |
3066 (setq nest (1- nest))) | 3044 (setq nest (1- nest))) |
3067 ((match-end 2) ; join | 3045 ((match-end 2) ; join |
3068 (setq nest (1+ nest))) | 3046 (setq nest (1+ nest))))))) |
3069 )) | |
3070 )) | |
3071 (= nest 0) )) ; return nest | 3047 (= nest 0) )) ; return nest |
3072 | 3048 |
3073 (defun verilog-backward-case-item (lim) | 3049 (defun verilog-backward-case-item (lim) |
3074 "Skip backward to nearest enclosing case item. | 3050 "Skip backward to nearest enclosing case item. |
3075 Limit search to point LIM." | 3051 Limit search to point LIM." |
3097 (error "%s: unbalanced [" (verilog-point-text)))) | 3073 (error "%s: unbalanced [" (verilog-point-text)))) |
3098 ((match-end 2) ;; ] | 3074 ((match-end 2) ;; ] |
3099 (setq colon (1- colon))) | 3075 (setq colon (1- colon))) |
3100 | 3076 |
3101 ((match-end 3) ;; : | 3077 ((match-end 3) ;; : |
3102 (setq colon (1+ colon))) | 3078 (setq colon (1+ colon))))) |
3103 )) | |
3104 ;; Skip back to beginning of case item | 3079 ;; Skip back to beginning of case item |
3105 (skip-chars-backward "\t ") | 3080 (skip-chars-backward "\t ") |
3106 (verilog-skip-backward-comment-or-string) | 3081 (verilog-skip-backward-comment-or-string) |
3107 (setq e (point)) | 3082 (setq e (point)) |
3108 (setq b | 3083 (setq b |
3121 (verilog-forward-ws&directives))) | 3096 (verilog-forward-ws&directives))) |
3122 (point)) | 3097 (point)) |
3123 (t | 3098 (t |
3124 (goto-char (match-end 0)) | 3099 (goto-char (match-end 0)) |
3125 (verilog-forward-ws&directives) | 3100 (verilog-forward-ws&directives) |
3126 (point)) | 3101 (point)))) |
3127 )) | 3102 (error "Malformed case item")))) |
3128 (error "Malformed case item") | |
3129 ))) | |
3130 (setq str (buffer-substring b e)) | 3103 (setq str (buffer-substring b e)) |
3131 (if | 3104 (if |
3132 (setq e | 3105 (setq e |
3133 (string-match | 3106 (string-match |
3134 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | 3107 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) |
3176 (not (save-excursion | 3149 (not (save-excursion |
3177 (end-of-line) | 3150 (end-of-line) |
3178 (search-backward "//" (verilog-get-beg-of-line) t))))) | 3151 (search-backward "//" (verilog-get-beg-of-line) t))))) |
3179 (let ((nest 1) b e | 3152 (let ((nest 1) b e |
3180 m | 3153 m |
3181 (else (if (match-end 2) "!" " ")) | 3154 (else (if (match-end 2) "!" " "))) |
3182 ) | |
3183 (end-of-line) | 3155 (end-of-line) |
3184 (if kill-existing-comment | 3156 (if kill-existing-comment |
3185 (verilog-kill-existing-comment)) | 3157 (verilog-kill-existing-comment)) |
3186 (delete-horizontal-space) | 3158 (delete-horizontal-space) |
3187 (save-excursion | 3159 (save-excursion |
3197 ((match-end 3) ; `if | 3169 ((match-end 3) ; `if |
3198 (setq nest (1- nest))) | 3170 (setq nest (1- nest))) |
3199 ((match-end 4) ; `ifdef | 3171 ((match-end 4) ; `ifdef |
3200 (setq nest (1- nest))) | 3172 (setq nest (1- nest))) |
3201 ((match-end 5) ; `ifndef | 3173 ((match-end 5) ; `ifndef |
3202 (setq nest (1- nest))) | 3174 (setq nest (1- nest))))) |
3203 )) | |
3204 (if (match-end 0) | 3175 (if (match-end 0) |
3205 (setq | 3176 (setq |
3206 m (buffer-substring | 3177 m (buffer-substring |
3207 (match-beginning 0) | 3178 (match-beginning 0) |
3208 (match-end 0)) | 3179 (match-end 0)) |
3210 (skip-chars-forward "^ \t") | 3181 (skip-chars-forward "^ \t") |
3211 (verilog-forward-syntactic-ws) | 3182 (verilog-forward-syntactic-ws) |
3212 (point)) | 3183 (point)) |
3213 e (progn | 3184 e (progn |
3214 (skip-chars-forward "a-zA-Z0-9_") | 3185 (skip-chars-forward "a-zA-Z0-9_") |
3215 (point) | 3186 (point))))) |
3216 )))) | |
3217 (if b | 3187 (if b |
3218 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | 3188 (if (> (count-lines (point) b) verilog-minimum-comment-distance) |
3219 (insert (concat " // " else m " " (buffer-substring b e)))) | 3189 (insert (concat " // " else m " " (buffer-substring b e)))) |
3220 (progn | 3190 (progn |
3221 (insert " // unmatched `else or `endif") | 3191 (insert " // unmatched `else or `endif") |
3222 (ding 't)) | 3192 (ding 't))))) |
3223 ))) | |
3224 | 3193 |
3225 (; Comment close case/class/function/task/module and named block | 3194 (; Comment close case/class/function/task/module and named block |
3226 (and (looking-at "\\<end") | 3195 (and (looking-at "\\<end") |
3227 (or kill-existing-comment | 3196 (or kill-existing-comment |
3228 (not (save-excursion | 3197 (not (save-excursion |
3267 (match-end 2) ;; of verilog-end-block-ordered-re | 3236 (match-end 2) ;; of verilog-end-block-ordered-re |
3268 (let ((str " // UNMATCHED !!") | 3237 (let ((str " // UNMATCHED !!") |
3269 (err 't) | 3238 (err 't) |
3270 (here (point)) | 3239 (here (point)) |
3271 there | 3240 there |
3272 cntx | 3241 cntx) |
3273 ) | |
3274 (save-excursion | 3242 (save-excursion |
3275 (verilog-leap-to-head) | 3243 (verilog-leap-to-head) |
3276 (setq there (point)) | 3244 (setq there (point)) |
3277 (if (not (match-end 0)) | 3245 (if (not (match-end 0)) |
3278 (progn | 3246 (progn |
3280 (end-of-line) | 3248 (end-of-line) |
3281 (if kill-existing-comment | 3249 (if kill-existing-comment |
3282 (verilog-kill-existing-comment)) | 3250 (verilog-kill-existing-comment)) |
3283 (delete-horizontal-space) | 3251 (delete-horizontal-space) |
3284 (insert str) | 3252 (insert str) |
3285 (ding 't) | 3253 (ding 't)) |
3286 ) | |
3287 (let ((lim | 3254 (let ((lim |
3288 (save-excursion (verilog-beg-of-defun) (point))) | 3255 (save-excursion (verilog-beg-of-defun) (point))) |
3289 (here (point)) | 3256 (here (point))) |
3290 ) | |
3291 (cond | 3257 (cond |
3292 (;-- handle named block differently | 3258 (;-- handle named block differently |
3293 (looking-at verilog-named-block-re) | 3259 (looking-at verilog-named-block-re) |
3294 (search-forward ":") | 3260 (search-forward ":") |
3295 (setq there (point)) | 3261 (setq there (point)) |
3334 (setq str "")))) | 3300 (setq str "")))) |
3335 | 3301 |
3336 (;- else | 3302 (;- else |
3337 (match-end 4) | 3303 (match-end 4) |
3338 (let ((nest 0) | 3304 (let ((nest 0) |
3339 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)") | 3305 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
3340 ) | |
3341 (catch 'skip | 3306 (catch 'skip |
3342 (while (verilog-re-search-backward reg nil 'move) | 3307 (while (verilog-re-search-backward reg nil 'move) |
3343 (cond | 3308 (cond |
3344 ((match-end 1) ; begin | 3309 ((match-end 1) ; begin |
3345 (setq nest (1- nest))) | 3310 (setq nest (1- nest))) |
3351 (goto-char (match-end 0)) | 3316 (goto-char (match-end 0)) |
3352 (setq there (point)) | 3317 (setq there (point)) |
3353 (setq err nil) | 3318 (setq err nil) |
3354 (setq str (verilog-get-expr)) | 3319 (setq str (verilog-get-expr)) |
3355 (setq str (concat " // else: !if" str )) | 3320 (setq str (concat " // else: !if" str )) |
3356 (throw 'skip 1)) | 3321 (throw 'skip 1))))))))) |
3357 ))) | |
3358 )))) | |
3359 | 3322 |
3360 (;- end else | 3323 (;- end else |
3361 (match-end 5) | 3324 (match-end 5) |
3362 (goto-char there) | 3325 (goto-char there) |
3363 (let ((nest 0) | 3326 (let ((nest 0) |
3364 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)") | 3327 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
3365 ) | |
3366 (catch 'skip | 3328 (catch 'skip |
3367 (while (verilog-re-search-backward reg nil 'move) | 3329 (while (verilog-re-search-backward reg nil 'move) |
3368 (cond | 3330 (cond |
3369 ((match-end 1) ; begin | 3331 ((match-end 1) ; begin |
3370 (setq nest (1- nest))) | 3332 (setq nest (1- nest))) |
3376 (goto-char (match-end 0)) | 3338 (goto-char (match-end 0)) |
3377 (setq there (point)) | 3339 (setq there (point)) |
3378 (setq err nil) | 3340 (setq err nil) |
3379 (setq str (verilog-get-expr)) | 3341 (setq str (verilog-get-expr)) |
3380 (setq str (concat " // else: !if" str )) | 3342 (setq str (concat " // else: !if" str )) |
3381 (throw 'skip 1)) | 3343 (throw 'skip 1))))))))) |
3382 ))) | |
3383 )))) | |
3384 | 3344 |
3385 (;- task/function/initial et cetera | 3345 (;- task/function/initial et cetera |
3386 t | 3346 t |
3387 (match-end 0) | 3347 (match-end 0) |
3388 (goto-char (match-end 0)) | 3348 (goto-char (match-end 0)) |
3390 (setq err nil) | 3350 (setq err nil) |
3391 (setq str (verilog-get-expr)) | 3351 (setq str (verilog-get-expr)) |
3392 (setq str (concat " // " cntx str ))) | 3352 (setq str (concat " // " cntx str ))) |
3393 | 3353 |
3394 (;-- otherwise... | 3354 (;-- otherwise... |
3395 (setq str " // auto-endcomment confused ")) | 3355 (setq str " // auto-endcomment confused ")))) |
3396 )) | |
3397 | 3356 |
3398 ((and | 3357 ((and |
3399 (verilog-in-case-region-p) ;-- handle case item differently | 3358 (verilog-in-case-region-p) ;-- handle case item differently |
3400 (progn | 3359 (progn |
3401 (setq there (point)) | 3360 (setq there (point)) |
3429 )))) | 3388 )))) |
3430 (;- this is endclass, which can be nested | 3389 (;- this is endclass, which can be nested |
3431 (match-end 11) ;; of verilog-end-block-ordered-re | 3390 (match-end 11) ;; of verilog-end-block-ordered-re |
3432 ;;(goto-char there) | 3391 ;;(goto-char there) |
3433 (let ((nest 0) | 3392 (let ((nest 0) |
3434 ( reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") | 3393 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
3435 string | 3394 string) |
3436 ) | |
3437 (save-excursion | 3395 (save-excursion |
3438 (catch 'skip | 3396 (catch 'skip |
3439 (while (verilog-re-search-backward reg nil 'move) | 3397 (while (verilog-re-search-backward reg nil 'move) |
3440 (cond | 3398 (cond |
3441 ((match-end 3) ; endclass | 3399 ((match-end 3) ; endclass |
3461 (point))) | 3419 (point))) |
3462 (setq string (buffer-substring b e))) | 3420 (setq string (buffer-substring b e))) |
3463 (throw 'skip 1)))) | 3421 (throw 'skip 1)))) |
3464 )))) | 3422 )))) |
3465 (end-of-line) | 3423 (end-of-line) |
3466 (insert (concat " // " string ))) | 3424 (insert (concat " // " string )))) |
3467 ) | |
3468 | 3425 |
3469 (;- this is end{function,generate,task,module,primitive,table,generate} | 3426 (;- this is end{function,generate,task,module,primitive,table,generate} |
3470 ;- which can not be nested. | 3427 ;- which can not be nested. |
3471 t | 3428 t |
3472 (let (string reg (width nil)) | 3429 (let (string reg (width nil)) |
3477 (delete-horizontal-space) | 3434 (delete-horizontal-space) |
3478 (backward-sexp) | 3435 (backward-sexp) |
3479 (cond | 3436 (cond |
3480 ((match-end 5) ;; of verilog-end-block-ordered-re | 3437 ((match-end 5) ;; of verilog-end-block-ordered-re |
3481 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | 3438 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") |
3482 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?") | 3439 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")) |
3483 ) | |
3484 ((match-end 6) ;; of verilog-end-block-ordered-re | 3440 ((match-end 6) ;; of verilog-end-block-ordered-re |
3485 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | 3441 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) |
3486 ((match-end 7) ;; of verilog-end-block-ordered-re | 3442 ((match-end 7) ;; of verilog-end-block-ordered-re |
3487 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | 3443 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) |
3488 ((match-end 8) ;; of verilog-end-block-ordered-re | 3444 ((match-end 8) ;; of verilog-end-block-ordered-re |
3500 ((match-end 14) ;; of verilog-end-block-ordered-re | 3456 ((match-end 14) ;; of verilog-end-block-ordered-re |
3501 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 3457 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
3502 ((match-end 15) ;; of verilog-end-block-ordered-re | 3458 ((match-end 15) ;; of verilog-end-block-ordered-re |
3503 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | 3459 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) |
3504 | 3460 |
3505 (t (error "Problem in verilog-set-auto-endcomments")) | 3461 (t (error "Problem in verilog-set-auto-endcomments"))) |
3506 ) | |
3507 (let (b e) | 3462 (let (b e) |
3508 (save-excursion | 3463 (save-excursion |
3509 (verilog-re-search-backward reg nil 'move) | 3464 (verilog-re-search-backward reg nil 'move) |
3510 (cond | 3465 (cond |
3511 ((match-end 1) | 3466 ((match-end 1) |
3513 (skip-chars-forward "^ \t") | 3468 (skip-chars-forward "^ \t") |
3514 (verilog-forward-ws&directives) | 3469 (verilog-forward-ws&directives) |
3515 (if (and width (looking-at width)) | 3470 (if (and width (looking-at width)) |
3516 (progn | 3471 (progn |
3517 (goto-char (match-end 0)) | 3472 (goto-char (match-end 0)) |
3518 (verilog-forward-ws&directives) | 3473 (verilog-forward-ws&directives))) |
3519 )) | |
3520 (point)) | 3474 (point)) |
3521 e (progn | 3475 e (progn |
3522 (skip-chars-forward "a-zA-Z0-9_") | 3476 (skip-chars-forward "a-zA-Z0-9_") |
3523 (point))) | 3477 (point))) |
3524 (setq string (buffer-substring b e))) | 3478 (setq string (buffer-substring b e))) |
3575 (point)) | 3529 (point)) |
3576 ((looking-at "/[/\\*]") | 3530 ((looking-at "/[/\\*]") |
3577 b) | 3531 b) |
3578 ('t | 3532 ('t |
3579 (skip-chars-forward "^: \t\n\f") | 3533 (skip-chars-forward "^: \t\n\f") |
3580 (point) | 3534 (point))))) |
3581 )))) | |
3582 (str (buffer-substring b e))) | 3535 (str (buffer-substring b e))) |
3583 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | 3536 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) |
3584 (setq str (concat (substring str 0 e) "..."))) | 3537 (setq str (concat (substring str 0 e) "..."))) |
3585 str)) | 3538 str)) |
3586 | 3539 |
3599 (end-of-line) (point))))) | 3552 (end-of-line) (point))))) |
3600 (if (string-match | 3553 (if (string-match |
3601 (concat "\\(.*\\)" | 3554 (concat "\\(.*\\)" |
3602 (regexp-quote bra) | 3555 (regexp-quote bra) |
3603 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" | 3556 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
3604 (regexp-quote ket) | 3557 (regexp-quote ket) |
3605 "\\(.*\\)$") signal-string) | 3558 "\\(.*\\)$") signal-string) |
3606 (let* ((sig-head (match-string 1 signal-string)) | 3559 (let* ((sig-head (match-string 1 signal-string)) |
3607 (vec-start (string-to-number (match-string 2 signal-string))) | 3560 (vec-start (string-to-number (match-string 2 signal-string))) |
3608 (vec-end (if (= (match-beginning 3) (match-end 3)) | 3561 (vec-end (if (= (match-beginning 3) (match-end 3)) |
3609 vec-start | 3562 vec-start |
3610 (string-to-number | 3563 (string-to-number |
3763 (insert (concat " " code))))) | 3716 (insert (concat " " code))))) |
3764 (t | 3717 (t |
3765 ))) | 3718 ))) |
3766 ((verilog-in-star-comment-p) | 3719 ((verilog-in-star-comment-p) |
3767 (re-search-backward "/\*") | 3720 (re-search-backward "/\*") |
3768 (insert (format " // surefire lint_off_line %6s" code )) | 3721 (insert (format " // surefire lint_off_line %6s" code ))) |
3769 ) | |
3770 (t | 3722 (t |
3771 (insert (format " // surefire lint_off_line %6s" code )) | 3723 (insert (format " // surefire lint_off_line %6s" code )) |
3772 ))))))))) | 3724 ))))))))) |
3773 | 3725 |
3774 (defun verilog-verilint-off () | 3726 (defun verilog-verilint-off () |
3821 (setq enable-local-eval t) | 3773 (setq enable-local-eval t) |
3822 ;; Make sure any sub-files we read get proper mode | 3774 ;; Make sure any sub-files we read get proper mode |
3823 (setq default-major-mode `verilog-mode) | 3775 (setq default-major-mode `verilog-mode) |
3824 ;; Ditto files already read in | 3776 ;; Ditto files already read in |
3825 (mapc (lambda (buf) | 3777 (mapc (lambda (buf) |
3826 (when (buffer-file-name buf) | 3778 (when (buffer-file-name buf) |
3827 (save-excursion | 3779 (save-excursion |
3828 (set-buffer buf) | 3780 (set-buffer buf) |
3829 (verilog-mode)))) | 3781 (verilog-mode)))) |
3830 (buffer-list)) | 3782 (buffer-list)) |
3831 ;; Process the files | 3783 ;; Process the files |
3832 (mapcar '(lambda (buf) | 3784 (mapcar '(lambda (buf) |
3833 (when (buffer-file-name buf) | 3785 (when (buffer-file-name buf) |
3834 (save-excursion | 3786 (save-excursion |
3835 (if (not (file-exists-p (buffer-file-name buf))) | 3787 (if (not (file-exists-p (buffer-file-name buf))) |
3941 (if (and | 3893 (if (and |
3942 verilog-indent-lists | 3894 verilog-indent-lists |
3943 (not (verilog-in-coverage)) | 3895 (not (verilog-in-coverage)) |
3944 (verilog-in-paren)) | 3896 (verilog-in-paren)) |
3945 (progn (setq par 1) | 3897 (progn (setq par 1) |
3946 (throw 'nesting 'block)) | 3898 (throw 'nesting 'block))) |
3947 ) | |
3948 | 3899 |
3949 ;; See if we are continuing a previous line | 3900 ;; See if we are continuing a previous line |
3950 (while t | 3901 (while t |
3951 ;; trap out if we crawl off the top of the buffer | 3902 ;; trap out if we crawl off the top of the buffer |
3952 (if (bobp) (throw 'nesting 'cpp)) | 3903 (if (bobp) (throw 'nesting 'cpp)) |
4024 ((match-end 11) ; class | 3975 ((match-end 11) ; class |
4025 ;; Search back for matching class | 3976 ;; Search back for matching class |
4026 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | 3977 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) |
4027 ((match-end 12) ; covergroup | 3978 ((match-end 12) ; covergroup |
4028 ;; Search back for matching covergroup | 3979 ;; Search back for matching covergroup |
4029 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | 3980 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
4030 ) | |
4031 (catch 'skip | 3981 (catch 'skip |
4032 (while (verilog-re-search-backward reg nil 'move) | 3982 (while (verilog-re-search-backward reg nil 'move) |
4033 (cond | 3983 (cond |
4034 ((match-end 1) ; begin | 3984 ((match-end 1) ; begin |
4035 (setq nest (1- nest)) | 3985 (setq nest (1- nest)) |
4036 (if (= 0 nest) | 3986 (if (= 0 nest) |
4037 (throw 'skip 1))) | 3987 (throw 'skip 1))) |
4038 ((match-end 2) ; end | 3988 ((match-end 2) ; end |
4039 (setq nest (1+ nest))))) | 3989 (setq nest (1+ nest))))) |
4040 ) | 3990 ))))))) |
4041 )) | 3991 (throw 'nesting (verilog-calc-1))) |
4042 )))) | |
4043 (throw 'nesting (verilog-calc-1)) | |
4044 ) | |
4045 );; catch nesting | 3992 );; catch nesting |
4046 );; type | 3993 );; type |
4047 ) | 3994 ) |
4048 ;; Return type of block and indent level. | 3995 ;; Return type of block and indent level. |
4049 (if (not type) | 3996 (if (not type) |
4056 ((eq type 'statement) | 4003 ((eq type 'statement) |
4057 (list type (current-column))) | 4004 (list type (current-column))) |
4058 ((eq type 'defun) | 4005 ((eq type 'defun) |
4059 (list type 0)) | 4006 (list type 0)) |
4060 (t | 4007 (t |
4061 (list type (verilog-current-indent-level))))) | 4008 (list type (verilog-current-indent-level)))))))) |
4062 ))) | 4009 |
4063 (defun verilog-wai () | 4010 (defun verilog-wai () |
4064 "Show matching nesting block for debugging." | 4011 "Show matching nesting block for debugging." |
4065 (interactive) | 4012 (interactive) |
4066 (save-excursion | 4013 (save-excursion |
4067 (let ((nesting (verilog-calc-1))) | 4014 (let ((nesting (verilog-calc-1))) |
4071 (catch 'nesting | 4018 (catch 'nesting |
4072 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) | 4019 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) |
4073 (cond | 4020 (cond |
4074 ((equal (char-after) ?\{) | 4021 ((equal (char-after) ?\{) |
4075 (if (verilog-at-constraint-p) | 4022 (if (verilog-at-constraint-p) |
4076 (throw 'nesting 'block) | 4023 (throw 'nesting 'block))) |
4077 )) | |
4078 ((equal (char-after) ?\}) | 4024 ((equal (char-after) ?\}) |
4079 | 4025 |
4080 (let ((there (verilog-at-close-constraint-p))) | 4026 (let ((there (verilog-at-close-constraint-p))) |
4081 (if there (goto-char there)))) | 4027 (if there (goto-char there)))) |
4082 | 4028 |
4131 (defun verilog-calculate-indent-directive () | 4077 (defun verilog-calculate-indent-directive () |
4132 "Return indentation level for directive. | 4078 "Return indentation level for directive. |
4133 For speed, the searcher looks at the last directive, not the indent | 4079 For speed, the searcher looks at the last directive, not the indent |
4134 of the appropriate enclosing block." | 4080 of the appropriate enclosing block." |
4135 (let ((base -1) ;; Indent of the line that determines our indentation | 4081 (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) | 4082 (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 | 4083 ;; Start at current location, scan back for another directive |
4139 | 4084 |
4140 (save-excursion | 4085 (save-excursion |
4141 (beginning-of-line) | 4086 (beginning-of-line) |
4142 (while (and (< base 0) | 4087 (while (and (< base 0) |
4143 (verilog-re-search-backward verilog-directive-re nil t)) | 4088 (verilog-re-search-backward verilog-directive-re nil t)) |
4144 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | 4089 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) |
4145 (setq base (current-indentation)) | 4090 (setq base (current-indentation)))) |
4146 )) | |
4147 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL | 4091 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
4148 (setq ind (- ind verilog-indent-level-directive))) | 4092 (setq ind (- ind verilog-indent-level-directive))) |
4149 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | 4093 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL |
4150 (setq ind (+ ind verilog-indent-level-directive))) | 4094 (setq ind (+ ind verilog-indent-level-directive))) |
4151 ((looking-at verilog-directive-begin) | 4095 ((looking-at verilog-directive-begin) |
4221 ((looking-at "\\<endsequence\\>") | 4165 ((looking-at "\\<endsequence\\>") |
4222 ;; 12: Search back for matching sequence | 4166 ;; 12: Search back for matching sequence |
4223 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | 4167 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) |
4224 ((looking-at "\\<endclocking\\>") | 4168 ((looking-at "\\<endclocking\\>") |
4225 ;; 12: Search back for matching clocking | 4169 ;; 12: Search back for matching clocking |
4226 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" )) | 4170 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
4227 ) | |
4228 (if reg | 4171 (if reg |
4229 (catch 'skip | 4172 (catch 'skip |
4230 (let (sreg) | 4173 (let (sreg) |
4231 (while (verilog-re-search-backward reg nil 'move) | 4174 (while (verilog-re-search-backward reg nil 'move) |
4232 (cond | 4175 (cond |
4266 (setq continued nil) | 4209 (setq continued nil) |
4267 (while (and continued | 4210 (while (and continued |
4268 (save-excursion | 4211 (save-excursion |
4269 (skip-chars-backward " \t") | 4212 (skip-chars-backward " \t") |
4270 (not (bolp)))) | 4213 (not (bolp)))) |
4271 (setq continued (verilog-backward-token)) | 4214 (setq continued (verilog-backward-token))))) |
4272 ) ;; while | |
4273 )) | |
4274 (setq continued nil)) | 4215 (setq continued nil)) |
4275 continued)) | 4216 continued)) |
4276 | 4217 |
4277 (defun verilog-backward-token () | 4218 (defun verilog-backward-token () |
4278 "Step backward token, returning true if we are now at an end of line token." | 4219 "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 | 4228 (; If a "}" is prefixed by a ";", then this is a complete statement |
4288 ; i.e.: constraint foo { a = b; } | 4229 ; i.e.: constraint foo { a = b; } |
4289 (= (preceding-char) ?\}) | 4230 (= (preceding-char) ?\}) |
4290 (progn | 4231 (progn |
4291 (backward-char) | 4232 (backward-char) |
4292 (verilog-at-close-constraint-p)) | 4233 (verilog-at-close-constraint-p))) |
4293 ) | |
4294 (;-- constraint foo { a = b } | 4234 (;-- constraint foo { a = b } |
4295 ; is a complete statement. *sigh* | 4235 ; is a complete statement. *sigh* |
4296 (= (preceding-char) ?\{) | 4236 (= (preceding-char) ?\{) |
4297 (progn | 4237 (progn |
4298 (backward-char) | 4238 (backward-char) |
4299 (not (verilog-at-constraint-p))) | 4239 (not (verilog-at-constraint-p)))) |
4300 ) | |
4301 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete | 4240 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4302 ; also could be simply '@(foo)' | 4241 ; also could be simply '@(foo)' |
4303 ; or foo u1 #(a=8) | 4242 ; or foo u1 #(a=8) |
4304 ; (b, ... which ISN'T complete | 4243 ; (b, ... which ISN'T complete |
4305 ;;;; Do we need this??? | 4244 ;;;; Do we need this??? |
4320 (backward-char) | 4259 (backward-char) |
4321 (save-excursion | 4260 (save-excursion |
4322 (verilog-backward-token) | 4261 (verilog-backward-token) |
4323 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | 4262 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) |
4324 ((= (preceding-char) ?\#) | 4263 ((= (preceding-char) ?\#) |
4325 (backward-char) | 4264 (backward-char)) |
4326 ) | 4265 (t t))))))) |
4327 (t t)) | |
4328 ))))) | |
4329 | 4266 |
4330 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | 4267 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete |
4331 t | 4268 t |
4332 (forward-word -1) | 4269 (forward-word -1) |
4333 (cond | 4270 (cond |
4344 (backward-char) | 4281 (backward-char) |
4345 (verilog-backward-syntactic-ws) | 4282 (verilog-backward-syntactic-ws) |
4346 (backward-sexp) | 4283 (backward-sexp) |
4347 (if (looking-at verilog-nameable-item-re ) | 4284 (if (looking-at verilog-nameable-item-re ) |
4348 nil | 4285 nil |
4349 t) | 4286 t)) |
4350 ) | |
4351 ((= (preceding-char) ?\#) | 4287 ((= (preceding-char) ?\#) |
4352 (backward-char) | 4288 (backward-char) |
4353 t) | 4289 t) |
4354 ((= (preceding-char) ?\`) | 4290 ((= (preceding-char) ?\`) |
4355 (backward-char) | 4291 (backward-char) |
4356 t) | 4292 t) |
4357 | 4293 |
4358 (t | 4294 (t |
4359 (goto-char back) | 4295 (goto-char back) |
4360 t) | 4296 t)))))))) |
4361 ))))))) | |
4362 | 4297 |
4363 (defun verilog-backward-syntactic-ws (&optional bound) | 4298 (defun verilog-backward-syntactic-ws (&optional bound) |
4364 "Backward skip over syntactic whitespace for Emacs 19. | 4299 "Backward skip over syntactic whitespace for Emacs 19. |
4365 Optional BOUND limits search." | 4300 Optional BOUND limits search." |
4366 (save-restriction | 4301 (save-restriction |
4368 (if (< bound (point)) | 4303 (if (< bound (point)) |
4369 (progn | 4304 (progn |
4370 (narrow-to-region bound (point)) | 4305 (narrow-to-region bound (point)) |
4371 (while (/= here (point)) | 4306 (while (/= here (point)) |
4372 (setq here (point)) | 4307 (setq here (point)) |
4373 (verilog-skip-backward-comments) | 4308 (verilog-skip-backward-comments)))))) |
4374 ))) | |
4375 )) | |
4376 t) | 4309 t) |
4377 | 4310 |
4378 (defun verilog-forward-syntactic-ws (&optional bound) | 4311 (defun verilog-forward-syntactic-ws (&optional bound) |
4379 "Forward skip over syntactic whitespace for Emacs 19. | 4312 "Forward skip over syntactic whitespace for Emacs 19. |
4380 Optional BOUND limits search." | 4313 Optional BOUND limits search." |
4381 (save-restriction | 4314 (save-restriction |
4382 (let* ((bound (or bound (point-max))) | 4315 (let* ((bound (or bound (point-max))) |
4383 (here bound) | 4316 (here bound)) |
4384 ) | |
4385 (if (> bound (point)) | 4317 (if (> bound (point)) |
4386 (progn | 4318 (progn |
4387 (narrow-to-region (point) bound) | 4319 (narrow-to-region (point) bound) |
4388 (while (/= here (point)) | 4320 (while (/= here (point)) |
4389 (setq here (point)) | 4321 (setq here (point)) |
4390 (forward-comment (buffer-size)) | 4322 (forward-comment (buffer-size)))))))) |
4391 ))) | |
4392 ))) | |
4393 | 4323 |
4394 (defun verilog-backward-ws&directives (&optional bound) | 4324 (defun verilog-backward-ws&directives (&optional bound) |
4395 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | 4325 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. |
4396 Optional BOUND limits search." | 4326 Optional BOUND limits search." |
4397 (save-restriction | 4327 (save-restriction |
4421 (verilog-back-to-start-translate-off (point-min))) | 4351 (verilog-back-to-start-translate-off (point-min))) |
4422 ((looking-at verilog-directive-re-1) | 4352 ((looking-at verilog-directive-re-1) |
4423 (point)) | 4353 (point)) |
4424 (t | 4354 (t |
4425 nil)))) | 4355 nil)))) |
4426 (if p (goto-char p)) | 4356 (if p (goto-char p)))))))) |
4427 ))) | |
4428 ))) | |
4429 | 4357 |
4430 (defun verilog-forward-ws&directives (&optional bound) | 4358 (defun verilog-forward-ws&directives (&optional bound) |
4431 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | 4359 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. |
4432 Optional BOUND limits search." | 4360 Optional BOUND limits search." |
4433 (save-restriction | 4361 (save-restriction |
4434 (let* ((bound (or bound (point-max))) | 4362 (let* ((bound (or bound (point-max))) |
4435 (here bound) | 4363 (here bound) |
4436 jump | 4364 jump) |
4437 ) | |
4438 (if (> bound (point)) | 4365 (if (> bound (point)) |
4439 (progn | 4366 (progn |
4440 (let ((state | 4367 (let ((state |
4441 (save-excursion | 4368 (save-excursion |
4442 (parse-partial-sexp (point-min) (point))))) | 4369 (parse-partial-sexp (point-min) (point))))) |
4453 (save-excursion | 4380 (save-excursion |
4454 (beginning-of-line) | 4381 (beginning-of-line) |
4455 (if (looking-at verilog-directive-re-1) | 4382 (if (looking-at verilog-directive-re-1) |
4456 (setq jump t))) | 4383 (setq jump t))) |
4457 (if jump | 4384 (if jump |
4458 (beginning-of-line 2)) | 4385 (beginning-of-line 2)))))))) |
4459 ))) | |
4460 ))) | |
4461 | 4386 |
4462 (defun verilog-in-comment-p () | 4387 (defun verilog-in-comment-p () |
4463 "Return true if in a star or // comment." | 4388 "Return true if in a star or // comment." |
4464 (let ((state | 4389 (let ((state |
4465 (save-excursion | 4390 (save-excursion |
4535 (and | 4460 (and |
4536 (equal (char-after) ?\{) | 4461 (equal (char-after) ?\{) |
4537 (forward-list) | 4462 (forward-list) |
4538 (progn (backward-char 1) | 4463 (progn (backward-char 1) |
4539 (verilog-backward-ws&directives) | 4464 (verilog-backward-ws&directives) |
4540 (equal (char-before) ?\;)) | 4465 (equal (char-before) ?\;)))) |
4541 )) | |
4542 ;; maybe | 4466 ;; maybe |
4543 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | 4467 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) |
4544 ;; not | 4468 ;; not |
4545 nil | 4469 nil)) |
4546 ) | |
4547 ) | |
4548 | 4470 |
4549 (defun verilog-parenthesis-depth () | 4471 (defun verilog-parenthesis-depth () |
4550 "Return non zero if in parenthetical-expression." | 4472 "Return non zero if in parenthetical-expression." |
4551 (save-excursion | 4473 (save-excursion |
4552 (nth 1 (parse-partial-sexp (point-min) (point))))) | 4474 (nth 1 (parse-partial-sexp (point-min) (point))))) |
4606 (search-backward "/*") | 4528 (search-backward "/*") |
4607 (skip-chars-backward " \t\n\f") | 4529 (skip-chars-backward " \t\n\f") |
4608 t) | 4530 t) |
4609 ((and (not (bobp)) | 4531 ((and (not (bobp)) |
4610 (= (char-before) ?\/) | 4532 (= (char-before) ?\/) |
4611 (= (char-before (1- (point))) ?\*) | 4533 (= (char-before (1- (point))) ?\*)) |
4612 ) | |
4613 (goto-char (- (point) 2)) | 4534 (goto-char (- (point) 2)) |
4614 t) | 4535 t) |
4615 (t | 4536 (t |
4616 (skip-chars-backward " \t\n\f") | 4537 (skip-chars-backward " \t\n\f") |
4617 nil))))))) | 4538 nil))))))) |
4648 ((verilog-continued-line) | 4569 ((verilog-continued-line) |
4649 (let ((sp1 (point))) | 4570 (let ((sp1 (point))) |
4650 (if (verilog-continued-line) | 4571 (if (verilog-continued-line) |
4651 (progn | 4572 (progn |
4652 (goto-char sp) | 4573 (goto-char sp) |
4653 (setq | 4574 (setq indent-str |
4654 indent-str (list 'statement (verilog-current-indent-level)))) | 4575 (list 'statement (verilog-current-indent-level)))) |
4655 (goto-char sp1) | 4576 (goto-char sp1) |
4656 (setq indent-str (list 'block (verilog-current-indent-level))))) | 4577 (setq indent-str (list 'block (verilog-current-indent-level))))) |
4657 (goto-char sp)) | 4578 (goto-char sp)) |
4658 ((goto-char sp) | 4579 ((goto-char sp) |
4659 (setq indent-str (verilog-calculate-indent)))) | 4580 (setq indent-str (verilog-calculate-indent)))) |
4699 (skip-chars-forward " \t"))) | 4620 (skip-chars-forward " \t"))) |
4700 ((= (following-char) ?\[) | 4621 ((= (following-char) ?\[) |
4701 (progn | 4622 (progn |
4702 (forward-char 1) | 4623 (forward-char 1) |
4703 (backward-up-list -1) | 4624 (backward-up-list -1) |
4704 (skip-chars-forward " \t"))) | 4625 (skip-chars-forward " \t")))) |
4705 ) | |
4706 (current-column)) | 4626 (current-column)) |
4707 (progn | 4627 (progn |
4708 (goto-char fst) | 4628 (goto-char fst) |
4709 (+ (current-column) verilog-cexp-indent)) | 4629 (+ (current-column) verilog-cexp-indent)))))) |
4710 )))) | |
4711 (goto-char here) | 4630 (goto-char here) |
4712 (indent-line-to val)) | 4631 (indent-line-to val))) |
4713 ) | |
4714 ((= (preceding-char) ?\) ) | 4632 ((= (preceding-char) ?\) ) |
4715 (goto-char here) | 4633 (goto-char here) |
4716 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | 4634 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) |
4717 (indent-line-to val))) | 4635 (indent-line-to val))) |
4718 (t | 4636 (t |
4722 (if (and (< (point) here) | 4640 (if (and (< (point) here) |
4723 (verilog-re-search-forward "=[ \\t]*" here 'move)) | 4641 (verilog-re-search-forward "=[ \\t]*" here 'move)) |
4724 (setq val (current-column)) | 4642 (setq val (current-column)) |
4725 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | 4643 (setq val (eval (cdr (assoc type verilog-indent-alist))))) |
4726 (goto-char here) | 4644 (goto-char here) |
4727 (indent-line-to val))) | 4645 (indent-line-to val)))))) |
4728 ))) | |
4729 | 4646 |
4730 (; handle inside parenthetical expressions | 4647 (; handle inside parenthetical expressions |
4731 (eq type 'cparenexp) | 4648 (eq type 'cparenexp) |
4732 (let ((val (save-excursion | 4649 (let ((val (save-excursion |
4733 (backward-up-list 1) | 4650 (backward-up-list 1) |
4735 (skip-chars-forward " \t") | 4652 (skip-chars-forward " \t") |
4736 (current-column)))) | 4653 (current-column)))) |
4737 (indent-line-to val) | 4654 (indent-line-to val) |
4738 (if (and (not (verilog-in-struct-region-p)) | 4655 (if (and (not (verilog-in-struct-region-p)) |
4739 (looking-at verilog-declaration-re)) | 4656 (looking-at verilog-declaration-re)) |
4740 (verilog-indent-declaration ind)) | 4657 (verilog-indent-declaration ind)))) |
4741 )) | |
4742 | 4658 |
4743 (;-- Handle the ends | 4659 (;-- Handle the ends |
4744 (or | 4660 (or |
4745 (looking-at verilog-end-block-re ) | 4661 (looking-at verilog-end-block-re ) |
4746 (verilog-at-close-constraint-p)) | 4662 (verilog-at-close-constraint-p)) |
4772 (verilog-indent-declaration ind)) | 4688 (verilog-indent-declaration ind)) |
4773 | 4689 |
4774 (;-- Everything else | 4690 (;-- Everything else |
4775 t | 4691 t |
4776 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | 4692 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) |
4777 (indent-line-to val))) | 4693 (indent-line-to val)))) |
4778 ) | 4694 |
4779 (if (looking-at "[ \t]+$") | 4695 (if (looking-at "[ \t]+$") |
4780 (skip-chars-forward " \t")) | 4696 (skip-chars-forward " \t")) |
4781 indent-str ; Return indent data | 4697 indent-str ; Return indent data |
4782 )) | 4698 )) |
4783 | 4699 |
4821 (comment-column | 4737 (comment-column |
4822 comment-column ) | 4738 comment-column ) |
4823 (t | 4739 (t |
4824 (save-excursion | 4740 (save-excursion |
4825 (re-search-backward "//" nil t) | 4741 (re-search-backward "//" nil t) |
4826 (current-column))) | 4742 (current-column)))))) |
4827 ))) | |
4828 (indent-line-to stcol) | 4743 (indent-line-to stcol) |
4829 stcol)) | 4744 stcol)) |
4830 | 4745 |
4831 (defun verilog-more-comment () | 4746 (defun verilog-more-comment () |
4832 "Make more comment lines like the previous." | 4747 "Make more comment lines like the previous." |
4841 (comment-column | 4756 (comment-column |
4842 comment-column ) | 4757 comment-column ) |
4843 (t | 4758 (t |
4844 (save-excursion | 4759 (save-excursion |
4845 (re-search-backward "//" nil t) | 4760 (re-search-backward "//" nil t) |
4846 (current-column))) | 4761 (current-column)))))) |
4847 ))) | |
4848 (progn | 4762 (progn |
4849 (indent-to stcol) | 4763 (indent-to stcol) |
4850 (if (and star | 4764 (if (and star |
4851 (save-excursion | 4765 (save-excursion |
4852 (forward-line -1) | 4766 (forward-line -1) |
4910 (base-ind | 4824 (base-ind |
4911 (progn | 4825 (progn |
4912 (goto-char start) | 4826 (goto-char start) |
4913 (verilog-do-indent (verilog-calculate-indent)) | 4827 (verilog-do-indent (verilog-calculate-indent)) |
4914 (verilog-forward-ws&directives) | 4828 (verilog-forward-ws&directives) |
4915 (current-column))) | 4829 (current-column)))) |
4916 ) | |
4917 (goto-char end) | 4830 (goto-char end) |
4918 (goto-char start) | 4831 (goto-char start) |
4919 (if (> (- end start) 100) | 4832 (if (> (- end start) 100) |
4920 (message "Lining up declarations..(please stand by)")) | 4833 (message "Lining up declarations..(please stand by)")) |
4921 ;; Get the beginning of line indent first | 4834 ;; Get the beginning of line indent first |
4925 ( (save-excursion (skip-chars-backward " \t") | 4838 ( (save-excursion (skip-chars-backward " \t") |
4926 (bolp)) | 4839 (bolp)) |
4927 (verilog-forward-ws&directives) | 4840 (verilog-forward-ws&directives) |
4928 (indent-line-to base-ind) | 4841 (indent-line-to base-ind) |
4929 (verilog-forward-ws&directives) | 4842 (verilog-forward-ws&directives) |
4930 (verilog-re-search-forward "[ \t\n\f]" e 'move) | 4843 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
4931 ) | |
4932 (t | 4844 (t |
4933 (just-one-space) | 4845 (just-one-space) |
4934 (verilog-re-search-forward "[ \t\n\f]" e 'move) | 4846 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
4935 ) | 4847 ;;(forward-line) |
4936 ) | |
4937 ) | 4848 ) |
4938 ;;(forward-line)) | |
4939 ;; Now find biggest prefix | 4849 ;; Now find biggest prefix |
4940 (setq ind (verilog-get-lineup-indent start edpos)) | 4850 (setq ind (verilog-get-lineup-indent start edpos)) |
4941 ;; Now indent each line. | 4851 ;; Now indent each line. |
4942 (goto-char start) | 4852 (goto-char start) |
4943 (while (progn (setq e (marker-position edpos)) | 4853 (while (progn (setq e (marker-position edpos)) |
4958 (goto-char (marker-position m1)) | 4868 (goto-char (marker-position m1)) |
4959 (just-one-space) | 4869 (just-one-space) |
4960 (indent-to ind)) | 4870 (indent-to ind)) |
4961 (progn | 4871 (progn |
4962 (just-one-space) | 4872 (just-one-space) |
4963 (indent-to ind)) | 4873 (indent-to ind))))) |
4964 ))) | |
4965 ((verilog-continued-line-1 start) | 4874 ((verilog-continued-line-1 start) |
4966 (goto-char e) | 4875 (goto-char e) |
4967 (indent-line-to ind)) | 4876 (indent-line-to ind)) |
4968 (t ; Must be comment or white space | 4877 (t ; Must be comment or white space |
4969 (goto-char e) | 4878 (goto-char e) |
4970 (verilog-forward-ws&directives) | 4879 (verilog-forward-ws&directives) |
4971 (forward-line -1)) | 4880 (forward-line -1))) |
4972 ) | |
4973 (forward-line 1)) | 4881 (forward-line 1)) |
4974 (message ""))))) | 4882 (message ""))))) |
4975 | 4883 |
4976 (defun verilog-pretty-expr (&optional myre) | 4884 (defun verilog-pretty-expr (&optional myre) |
4977 "Line up expressions around point." | 4885 "Line up expressions around point, or optional regexp MYRE." |
4978 (interactive "sRegular Expression: ((<|:)?=) ") | 4886 (interactive "sRegular Expression: ((<|:)?=) ") |
4979 (save-excursion | 4887 (save-excursion |
4980 (if (or (eq myre nil) | 4888 (if (or (eq myre nil) |
4981 (string-equal myre "")) | 4889 (string-equal myre "")) |
4982 (setq myre "\\(<\\|:\\)?=")) | 4890 (setq myre "\\(<\\|:\\)?=")) |
4993 (setq e (point)) | 4901 (setq e (point)) |
4994 (verilog-backward-syntactic-ws) | 4902 (verilog-backward-syntactic-ws) |
4995 (beginning-of-line) | 4903 (beginning-of-line) |
4996 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg))) | 4904 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg))) |
4997 (looking-at myre) | 4905 (looking-at myre) |
4998 (not (bobp)) | 4906 (not (bobp))) |
4999 ) | |
5000 (setq e (point)) | 4907 (setq e (point)) |
5001 (verilog-backward-syntactic-ws) | 4908 (verilog-backward-syntactic-ws) |
5002 (beginning-of-line) | 4909 (beginning-of-line) |
5003 ) ;Ack, need to grok `define | 4910 ) ;Ack, need to grok `define |
5004 e)) | 4911 e)) |
5013 (concat "^\\s-*" verilog-complete-reg))) | 4920 (concat "^\\s-*" verilog-complete-reg))) |
5014 (looking-at myre)) | 4921 (looking-at myre)) |
5015 (end-of-line) | 4922 (end-of-line) |
5016 (setq e (point)) | 4923 (setq e (point)) |
5017 (verilog-forward-syntactic-ws) | 4924 (verilog-forward-syntactic-ws) |
5018 (beginning-of-line) | 4925 (beginning-of-line)) |
5019 ) | |
5020 e)) | 4926 e)) |
5021 (edpos (set-marker (make-marker) end)) | 4927 (edpos (set-marker (make-marker) end)) |
5022 (ind) | 4928 (ind)) |
5023 ) | |
5024 (goto-char start) | 4929 (goto-char start) |
5025 (verilog-do-indent (verilog-calculate-indent)) | 4930 (verilog-do-indent (verilog-calculate-indent)) |
5026 (if (> (- end start) 100) | 4931 (if (> (- end start) 100) |
5027 (message "Lining up expressions..(please stand by)")) | 4932 (message "Lining up expressions..(please stand by)")) |
5028 | 4933 |
5029 ;; Set indent to minimum throughout region | 4934 ;; Set indent to minimum throughout region |
5030 (while (< (point) (marker-position edpos)) | 4935 (while (< (point) (marker-position edpos)) |
5031 (beginning-of-line) | 4936 (beginning-of-line) |
5032 (verilog-just-one-space myre) | 4937 (verilog-just-one-space myre) |
5033 (end-of-line) | 4938 (end-of-line) |
5034 (verilog-forward-syntactic-ws) | 4939 (verilog-forward-syntactic-ws)) |
5035 ) | |
5036 | 4940 |
5037 ;; Now find biggest prefix | 4941 ;; Now find biggest prefix |
5038 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) | 4942 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) |
5039 | 4943 |
5040 ;; Now indent each line. | 4944 ;; Now indent each line. |
5047 (cond | 4951 (cond |
5048 ((looking-at myre) | 4952 ((looking-at myre) |
5049 (goto-char (match-end 1)) | 4953 (goto-char (match-end 1)) |
5050 (if (eq (char-after) ?=) | 4954 (if (eq (char-after) ?=) |
5051 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = | 4955 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = |
5052 (indent-to ind) | 4956 (indent-to ind))) |
5053 ) | |
5054 ) | |
5055 ((verilog-continued-line-1 start) | 4957 ((verilog-continued-line-1 start) |
5056 (goto-char e) | 4958 (goto-char e) |
5057 (indent-line-to ind)) | 4959 (indent-line-to ind)) |
5058 (t ; Must be comment or white space | 4960 (t ; Must be comment or white space |
5059 (goto-char e) | 4961 (goto-char e) |
5060 (verilog-forward-ws&directives) | 4962 (verilog-forward-ws&directives) |
5061 (forward-line -1)) | 4963 (forward-line -1))) |
5062 ) | |
5063 (forward-line 1)) | 4964 (forward-line 1)) |
5064 (message "") | 4965 (message ""))))) |
5065 )))) | |
5066 | 4966 |
5067 (defun verilog-just-one-space (myre) | 4967 (defun verilog-just-one-space (myre) |
5068 "Remove extra spaces around regular expression MYRE." | 4968 "Remove extra spaces around regular expression MYRE." |
5069 (interactive) | 4969 (interactive) |
5070 (if (and (not(looking-at verilog-complete-reg)) | 4970 (if (and (not(looking-at verilog-complete-reg)) |
5071 (looking-at myre)) | 4971 (looking-at myre)) |
5072 (let ((p1 (match-end 1)) | 4972 (let ((p1 (match-end 1)) |
5073 (p2 (match-end 2))) | 4973 (p2 (match-end 2))) |
5074 (progn | 4974 (progn |
5075 (goto-char p2) | 4975 (goto-char p2) |
5076 (if (looking-at "\\s-") (just-one-space) ) | 4976 (if (looking-at "\\s-") (just-one-space)) |
5077 (goto-char p1) | 4977 (goto-char p1) |
5078 (forward-char -1) | 4978 (forward-char -1) |
5079 (if (looking-at "\\s-") (just-one-space)) | 4979 (if (looking-at "\\s-") (just-one-space))))) |
5080 ) | |
5081 )) | |
5082 (message "")) | 4980 (message "")) |
5083 | 4981 |
5084 (defun verilog-indent-declaration (baseind) | 4982 (defun verilog-indent-declaration (baseind) |
5085 "Indent current lines as declaration. | 4983 "Indent current lines as declaration. |
5086 Line up the variable names based on previous declaration's indentation. | 4984 Line up the variable names based on previous declaration's indentation. |
5091 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | 4989 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) |
5092 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | 4990 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) |
5093 (point))) | 4991 (point))) |
5094 (ind) | 4992 (ind) |
5095 (val) | 4993 (val) |
5096 (m1 (make-marker)) | 4994 (m1 (make-marker))) |
5097 ) | |
5098 (setq val | 4995 (setq val |
5099 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) | 4996 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
5100 (indent-line-to val) | 4997 (indent-line-to val) |
5101 | 4998 |
5102 ;; Use previous declaration (in this module) as template. | 4999 ;; Use previous declaration (in this module) as template. |
5123 (progn | 5020 (progn |
5124 (forward-char -1) | 5021 (forward-char -1) |
5125 (just-one-space) | 5022 (just-one-space) |
5126 (goto-char (marker-position m1)) | 5023 (goto-char (marker-position m1)) |
5127 (just-one-space) | 5024 (just-one-space) |
5128 (indent-to ind) | 5025 (indent-to ind)) |
5129 ) | |
5130 (if (/= (current-column) ind) | 5026 (if (/= (current-column) ind) |
5131 (progn | 5027 (progn |
5132 (just-one-space) | 5028 (just-one-space) |
5133 (indent-to ind)) | 5029 (indent-to ind))))) |
5134 ))) | |
5135 (if (looking-at verilog-declaration-re-2-no-macro) | 5030 (if (looking-at verilog-declaration-re-2-no-macro) |
5136 (let ((p (match-end 0))) | 5031 (let ((p (match-end 0))) |
5137 (set-marker m1 p) | 5032 (set-marker m1 p) |
5138 (if (verilog-re-search-forward "[[`#]" p 'move) | 5033 (if (verilog-re-search-forward "[[`#]" p 'move) |
5139 (progn | 5034 (progn |
5360 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | 5255 (setq match (buffer-substring (match-beginning 0) (match-end 0))) |
5361 (if (string-match (concat "\\<" verilog-str) match) | 5256 (if (string-match (concat "\\<" verilog-str) match) |
5362 (if (or (null verilog-pred) | 5257 (if (or (null verilog-pred) |
5363 (funcall verilog-pred match)) | 5258 (funcall verilog-pred match)) |
5364 (setq verilog-all (cons match verilog-all))))) | 5259 (setq verilog-all (cons match verilog-all))))) |
5365 (forward-line 1) | 5260 (forward-line 1))) |
5366 ) | 5261 verilog-all) |
5367 ) | |
5368 verilog-all | |
5369 ) | |
5370 | 5262 |
5371 (defun verilog-type-completion () | 5263 (defun verilog-type-completion () |
5372 "Calculate all possible completions for types." | 5264 "Calculate all possible completions for types." |
5373 (let ((start (point)) | 5265 (let ((start (point)) |
5374 goon) | 5266 goon) |
5661 (re-search-forward (verilog-build-defun-re label t) nil t))) | 5553 (re-search-forward (verilog-build-defun-re label t) nil t))) |
5662 (when pt | 5554 (when pt |
5663 (goto-char pt) | 5555 (goto-char pt) |
5664 (beginning-of-line)) | 5556 (beginning-of-line)) |
5665 pt) | 5557 pt) |
5666 (verilog-goto-defun-file label) | 5558 (verilog-goto-defun-file label)))) |
5667 ))) | |
5668 | 5559 |
5669 ;; Eliminate compile warning | 5560 ;; Eliminate compile warning |
5670 (eval-when-compile | 5561 (eval-when-compile |
5671 (if (not (boundp 'occur-pos-list)) | 5562 (if (not (boundp 'occur-pos-list)) |
5672 (defvar occur-pos-list nil "Backward compatibility occur positions."))) | 5563 (defvar occur-pos-list nil "Backward compatibility occur positions."))) |
5678 (linenum 1) | 5569 (linenum 1) |
5679 (nlines 0) | 5570 (nlines 0) |
5680 (first 1) | 5571 (first 1) |
5681 (prevpos (point-min)) | 5572 (prevpos (point-min)) |
5682 (final-context-start (make-marker)) | 5573 (final-context-start (make-marker)) |
5683 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)") | 5574 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
5684 ) | |
5685 (with-output-to-temp-buffer "*Occur*" | 5575 (with-output-to-temp-buffer "*Occur*" |
5686 (save-excursion | 5576 (save-excursion |
5687 (message (format "Searching for %s ..." regexp)) | 5577 (message (format "Searching for %s ..." regexp)) |
5688 ;; Find next match, but give up if prev match was at end of buffer. | 5578 ;; Find next match, but give up if prev match was at end of buffer. |
5689 (while (and (not (= prevpos (point-max))) | 5579 (while (and (not (= prevpos (point-max))) |
5852 (search-forward "<company>") | 5742 (search-forward "<company>") |
5853 (replace-match string t t) | 5743 (replace-match string t t) |
5854 (search-forward "<company>") | 5744 (search-forward "<company>") |
5855 (replace-match string t t) | 5745 (replace-match string t t) |
5856 (search-backward "<description>") | 5746 (search-backward "<description>") |
5857 (replace-match "" t t) | 5747 (replace-match "" t t)))) |
5858 ))) | |
5859 | 5748 |
5860 ;; verilog-header Uses the verilog-insert-date function | 5749 ;; verilog-header Uses the verilog-insert-date function |
5861 | 5750 |
5862 (defun verilog-insert-date () | 5751 (defun verilog-insert-date () |
5863 "Insert date from the system." | 5752 "Insert date from the system." |
5992 sv-enum (verilog-sig-enum sig) | 5881 sv-enum (verilog-sig-enum sig) |
5993 sv-signed (verilog-sig-signed sig) | 5882 sv-signed (verilog-sig-signed sig) |
5994 sv-type (verilog-sig-type sig) | 5883 sv-type (verilog-sig-type sig) |
5995 sv-multidim (verilog-sig-multidim sig) | 5884 sv-multidim (verilog-sig-multidim sig) |
5996 combo "" | 5885 combo "" |
5997 buswarn "" | 5886 buswarn "")) |
5998 )) | |
5999 ;; Extract bus details | 5887 ;; Extract bus details |
6000 (setq bus (verilog-sig-bits sig)) | 5888 (setq bus (verilog-sig-bits sig)) |
6001 (cond ((and bus | 5889 (cond ((and bus |
6002 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) | 5890 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) |
6003 (setq highbit (string-to-number (match-string 1 bus)) | 5891 (setq highbit (string-to-number (match-string 1 bus)) |
6041 (list sv-name | 5929 (list sv-name |
6042 (or sv-busstring | 5930 (or sv-busstring |
6043 (if sv-highbit | 5931 (if sv-highbit |
6044 (concat "[" (int-to-string sv-highbit) ":" | 5932 (concat "[" (int-to-string sv-highbit) ":" |
6045 (int-to-string sv-lowbit) "]"))) | 5933 (int-to-string sv-lowbit) "]"))) |
6046 (concat sv-comment combo buswarn) | 5934 (concat sv-comment combo buswarn) |
6047 sv-memory sv-enum sv-signed sv-type sv-multidim) | 5935 sv-memory sv-enum sv-signed sv-type sv-multidim) |
6048 out-list) | 5936 out-list) |
6049 sv-name nil))) | 5937 sv-name nil)))) |
6050 ) | |
6051 ;; | 5938 ;; |
6052 out-list)) | 5939 out-list)) |
6053 | 5940 |
6054 (defun verilog-sig-tieoff (sig &optional no-width) | 5941 (defun verilog-sig-tieoff (sig &optional no-width) |
6055 "Return tieoff expression for given SIGNAL, with appropriate width. | 5942 "Return tieoff expression for given SIG, with appropriate width. |
6056 Ignore width if optional NO-WIDTH is set." | 5943 Ignore width if optional NO-WIDTH is set." |
6057 (let* ((width (if no-width nil (verilog-sig-width sig)))) | 5944 (let* ((width (if no-width nil (verilog-sig-width sig)))) |
6058 (concat | 5945 (concat |
6059 (if (and verilog-active-low-regexp | 5946 (if (and verilog-active-low-regexp |
6060 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | 5947 (string-match verilog-active-low-regexp (verilog-sig-name sig))) |
6187 ((looking-at "[})]") | 6074 ((looking-at "[})]") |
6188 (setq paren (1- paren)) | 6075 (setq paren (1- paren)) |
6189 (forward-char 1) | 6076 (forward-char 1) |
6190 (when (< paren sig-paren) | 6077 (when (< paren sig-paren) |
6191 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list | 6078 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list |
6192 t) | 6079 t)))) |
6193 ))) | |
6194 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") | 6080 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
6195 (goto-char (match-end 0)) | 6081 (goto-char (match-end 0)) |
6196 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | 6082 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) |
6197 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | 6083 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) |
6198 (vec ;; Multidimensional | 6084 (vec ;; Multidimensional |
6270 (nreverse sigs-in) | 6156 (nreverse sigs-in) |
6271 (nreverse sigs-wire) | 6157 (nreverse sigs-wire) |
6272 (nreverse sigs-reg) | 6158 (nreverse sigs-reg) |
6273 (nreverse sigs-assign) | 6159 (nreverse sigs-assign) |
6274 (nreverse sigs-const) | 6160 (nreverse sigs-const) |
6275 (nreverse sigs-gparam) | 6161 (nreverse sigs-gparam))))) |
6276 )))) | 6162 |
6277 | 6163 (eval-when-compile |
6278 (defvar sigs-in) ; Prevent compile warning | 6164 ;; Prevent compile warnings; these are let's, not globals |
6279 (defvar sigs-inout) ; Prevent compile warning | 6165 ;; Do not remove the eval-when-compile |
6280 (defvar sigs-out) ; Prevent compile warning | 6166 ;; - we want a error when we are debugging this code if they are refed. |
6167 (defvar sigs-in) | |
6168 (defvar sigs-inout) | |
6169 (defvar sigs-out)) | |
6281 | 6170 |
6282 | 6171 |
6283 (defsubst verilog-modi-get-decls (modi) | 6172 (defsubst verilog-modi-get-decls (modi) |
6284 (verilog-modi-cache-results modi 'verilog-read-decls)) | 6173 (verilog-modi-cache-results modi 'verilog-read-decls)) |
6285 | 6174 |
6522 (let* ((beg-pt (prog1 (point) | 6411 (let* ((beg-pt (prog1 (point) |
6523 (forward-sexp 1))) ;; Closing paren | 6412 (forward-sexp 1))) ;; Closing paren |
6524 (end-pt (point))) | 6413 (end-pt (point))) |
6525 (eval-region beg-pt end-pt nil))))) | 6414 (eval-region beg-pt end-pt nil))))) |
6526 | 6415 |
6527 ;; These are passed in a let, not global | 6416 (eval-when-compile |
6528 (defvar got-sig) | 6417 ;; Prevent compile warnings; these are let's, not globals |
6529 (defvar got-rvalue) | 6418 ;; Do not remove the eval-when-compile |
6530 (defvar uses-delayed) | 6419 ;; - we want a error when we are debugging this code if they are refed. |
6420 (defvar sigs-in) | |
6421 (defvar sigs-out) | |
6422 (defvar got-sig) | |
6423 (defvar got-rvalue) | |
6424 (defvar uses-delayed) | |
6425 (defvar vector-skip-list)) | |
6531 | 6426 |
6532 (defun verilog-read-always-signals-recurse | 6427 (defun verilog-read-always-signals-recurse |
6533 (exit-keywd rvalue ignore-next) | 6428 (exit-keywd rvalue ignore-next) |
6534 "Recursive routine for parentheses/bracket matching. | 6429 "Recursive routine for parentheses/bracket matching. |
6535 EXIT-KEYWD is expression to stop at, nil if top level. | 6430 EXIT-KEYWD is expression to stop at, nil if top level. |
6651 sig-tolk t))) | 6546 sig-tolk t))) |
6652 (skip-chars-forward "a-zA-Z0-9$_.%`")) | 6547 (skip-chars-forward "a-zA-Z0-9$_.%`")) |
6653 (t | 6548 (t |
6654 (forward-char 1))) | 6549 (forward-char 1))) |
6655 ;; End of non-comment token | 6550 ;; End of non-comment token |
6656 (setq last-keywd keywd) | 6551 (setq last-keywd keywd))) |
6657 )) | |
6658 (skip-syntax-forward " ")) | 6552 (skip-syntax-forward " ")) |
6659 ;; Append the final pending signal | 6553 ;; Append the final pending signal |
6660 (when got-sig | 6554 (when got-sig |
6661 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | 6555 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) |
6662 (setq sigs-out (cons got-sig sigs-out))) | 6556 (setq sigs-out (cons got-sig sigs-out))) |
6698 ;;(if (looking-at "^\\(.+\\)$") | 6592 ;;(if (looking-at "^\\(.+\\)$") |
6699 (let ((module (match-string 1)) | 6593 (let ((module (match-string 1)) |
6700 (instant (match-string 2))) | 6594 (instant (match-string 2))) |
6701 (if (not (member module verilog-keywords)) | 6595 (if (not (member module verilog-keywords)) |
6702 (setq instants-list (cons (list module instant) instants-list))))) | 6596 (setq instants-list (cons (list module instant) instants-list))))) |
6703 (forward-line 1) | 6597 (forward-line 1))) |
6704 )) | |
6705 instants-list)) | 6598 instants-list)) |
6706 | 6599 |
6707 | 6600 |
6708 (defun verilog-read-auto-template (module) | 6601 (defun verilog-read-auto-template (module) |
6709 "Look for a auto_template for the instantiation of the given MODULE. | 6602 "Look for a auto_template for the instantiation of the given MODULE. |
6774 (or (search-forward "*/") | 6667 (or (search-forward "*/") |
6775 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | 6668 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) |
6776 (t | 6669 (t |
6777 (error "%s: AUTO_TEMPLATE parsing error: %s" | 6670 (error "%s: AUTO_TEMPLATE parsing error: %s" |
6778 (verilog-point-text) | 6671 (verilog-point-text) |
6779 (progn (looking-at ".*$") (match-string 0)))) | 6672 (progn (looking-at ".*$") (match-string 0)))))) |
6780 )) | |
6781 ;; Return | 6673 ;; Return |
6782 (vector tpl-regexp | 6674 (vector tpl-regexp |
6783 (list tpl-sig-list tpl-wild-list))) | 6675 (list tpl-sig-list tpl-wild-list))) |
6784 ;; If no template found | 6676 ;; If no template found |
6785 (t (vector tpl-regexp nil)))))) | 6677 (t (vector tpl-regexp nil)))))) |
6797 (if (equal defvalue "") "1" defvalue))) | 6689 (if (equal defvalue "") "1" defvalue))) |
6798 (if enumname | 6690 (if enumname |
6799 (let ((enumvar (intern (concat "venum-" enumname)))) | 6691 (let ((enumvar (intern (concat "venum-" enumname)))) |
6800 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | 6692 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) |
6801 (make-variable-buffer-local enumvar) | 6693 (make-variable-buffer-local enumvar) |
6802 (add-to-list enumvar defname))) | 6694 (add-to-list enumvar defname))))) |
6803 )) | |
6804 | 6695 |
6805 (defun verilog-read-defines (&optional filename recurse subcall) | 6696 (defun verilog-read-defines (&optional filename recurse subcall) |
6806 "Read `defines and parameters for the current file, or optional FILENAME. | 6697 "Read `defines and parameters for the current file, or optional FILENAME. |
6807 If the filename is provided, `verilog-library-flags' will be used to | 6698 If the filename is provided, `verilog-library-flags' will be used to |
6808 resolve it. If optional RECURSE is non-nil, recurse through `includes. | 6699 resolve it. If optional RECURSE is non-nil, recurse through `includes. |
6882 (verilog-set-define var val origbuf enumname)) | 6773 (verilog-set-define var val origbuf enumname)) |
6883 (forward-comment 999) | 6774 (forward-comment 999) |
6884 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | 6775 (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) | 6776 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) |
6886 (goto-char (match-end 0)) | 6777 (goto-char (match-end 0)) |
6887 (forward-comment 999)))) | 6778 (forward-comment 999))))))) |
6888 ))) | |
6889 | 6779 |
6890 (defun verilog-read-includes () | 6780 (defun verilog-read-includes () |
6891 "Read `includes for the current file. | 6781 "Read `includes for the current file. |
6892 This will find all of the `includes which are at the beginning of lines, | 6782 This will find all of the `includes which are at the beginning of lines, |
6893 ignoring any ifdefs or multiline comments around them. | 6783 ignoring any ifdefs or multiline comments around them. |
6948 (goto-char (match-end 0)) | 6838 (goto-char (match-end 0)) |
6949 (setq keywd (match-string-no-properties 1)) | 6839 (setq keywd (match-string-no-properties 1)) |
6950 (or (member keywd verilog-keywords) | 6840 (or (member keywd verilog-keywords) |
6951 (member keywd sigs-all) | 6841 (member keywd sigs-all) |
6952 (setq sigs-all (cons keywd sigs-all)))) | 6842 (setq sigs-all (cons keywd sigs-all)))) |
6953 (t (forward-char 1))) | 6843 (t (forward-char 1)))) |
6954 ) | |
6955 ;; Return list | 6844 ;; Return list |
6956 sigs-all))) | 6845 sigs-all))) |
6957 | 6846 |
6958 ;; | 6847 ;; |
6959 ;; Argument file parsing | 6848 ;; Argument file parsing |
7017 (verilog-add-list-unique `verilog-library-directories arg)) | 6906 (verilog-add-list-unique `verilog-library-directories arg)) |
7018 ;; Filename | 6907 ;; Filename |
7019 ((string-match "^[^-+]" arg) | 6908 ((string-match "^[^-+]" arg) |
7020 (verilog-add-list-unique `verilog-library-files arg)) | 6909 (verilog-add-list-unique `verilog-library-files arg)) |
7021 ;; Default - ignore; no warning | 6910 ;; Default - ignore; no warning |
7022 ) | 6911 )))) |
7023 ) | |
7024 ) | |
7025 ) | |
7026 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) | 6912 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
7027 | 6913 |
7028 (defun verilog-getopt-file (filename) | 6914 (defun verilog-getopt-file (filename) |
7029 "Read verilog options from the specified FILENAME." | 6915 "Read verilog options from the specified FILENAME." |
7030 (save-excursion | 6916 (save-excursion |
7094 | 6980 |
7095 (defun verilog-is-number (symbol) | 6981 (defun verilog-is-number (symbol) |
7096 "Return true if SYMBOL is number-like." | 6982 "Return true if SYMBOL is number-like." |
7097 (or (string-match "^[0-9 \t:]+$" symbol) | 6983 (or (string-match "^[0-9 \t:]+$" symbol) |
7098 (string-match "^[---]*[0-9]+$" symbol) | 6984 (string-match "^[---]*[0-9]+$" symbol) |
7099 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol) | 6985 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
7100 )) | |
7101 | 6986 |
7102 (defun verilog-symbol-detick (symbol wing-it) | 6987 (defun verilog-symbol-detick (symbol wing-it) |
7103 "Return a expanded SYMBOL name without any defines. | 6988 "Return a expanded SYMBOL name without any defines. |
7104 If the variable vh-{symbol} is defined, return that value. | 6989 If the variable vh-{symbol} is defined, return that value. |
7105 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | 6990 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." |
7183 (directory-files root t pattern nil))) | 7068 (directory-files root t pattern nil))) |
7184 (while dirfiles | 7069 (while dirfiles |
7185 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) | 7070 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) |
7186 dirfiles (cdr dirfiles)) | 7071 dirfiles (cdr dirfiles)) |
7187 (if (file-directory-p dirfile) | 7072 (if (file-directory-p dirfile) |
7188 (setq dirlist (cons dirfile dirlist)))) | 7073 (setq dirlist (cons dirfile dirlist))))) |
7189 ) | |
7190 ;; Defaults | 7074 ;; Defaults |
7191 (t | 7075 (t |
7192 (if (file-directory-p dirname) | 7076 (if (file-directory-p dirname) |
7193 (setq dirlist (cons dirname dirlist)))) | 7077 (setq dirlist (cons dirname dirlist)))))) |
7194 )) | |
7195 dirlist)) | 7078 dirlist)) |
7196 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | 7079 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) |
7197 | 7080 |
7198 (defun verilog-library-filenames (filename current &optional check-ext) | 7081 (defun verilog-library-filenames (filename current &optional check-ext) |
7199 "Return a search path to find the given FILENAME name. | 7082 "Return a search path to find the given FILENAME name. |
7293 (if (not (equal module realmod)) | 7176 (if (not (equal module realmod)) |
7294 (concat " (Expanded macro to " realmod ")") | 7177 (concat " (Expanded macro to " realmod ")") |
7295 "") | 7178 "") |
7296 "\n Check the verilog-library-directories variable." | 7179 "\n Check the verilog-library-directories variable." |
7297 "\n I looked in (if not listed, doesn't exist):\n\t" | 7180 "\n I looked in (if not listed, doesn't exist):\n\t" |
7298 (mapconcat 'concat orig-filenames "\n\t"))))) | 7181 (mapconcat 'concat orig-filenames "\n\t")))))) |
7299 ) | |
7300 (setq verilog-modi-lookup-last-mod module | 7182 (setq verilog-modi-lookup-last-mod module |
7301 verilog-modi-lookup-last-current current | 7183 verilog-modi-lookup-last-current current |
7302 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | 7184 verilog-modi-lookup-last-tick (buffer-modified-tick))))) |
7303 verilog-modi-lookup-last-modi | 7185 verilog-modi-lookup-last-modi)) |
7304 )) | |
7305 | 7186 |
7306 (defsubst verilog-modi-name (modi) | 7187 (defsubst verilog-modi-name (modi) |
7307 (aref modi 0)) | 7188 (aref modi 0)) |
7308 (defsubst verilog-modi-file-or-buffer (modi) | 7189 (defsubst verilog-modi-file-or-buffer (modi) |
7309 (aref modi 1)) | 7190 (aref modi 1)) |
7368 (setq verilog-modi-cache-list | 7249 (setq verilog-modi-cache-list |
7369 (cons (list (list (verilog-modi-name modi) function) | 7250 (cons (list (list (verilog-modi-name modi) function) |
7370 (buffer-modified-tick) | 7251 (buffer-modified-tick) |
7371 (visited-file-modtime) | 7252 (visited-file-modtime) |
7372 func-returns) | 7253 func-returns) |
7373 verilog-modi-cache-list))) | 7254 verilog-modi-cache-list))))) |
7374 )) | |
7375 ;; | 7255 ;; |
7376 func-returns)) | 7256 func-returns)) |
7377 | 7257 |
7378 (defun verilog-modi-cache-add (modi function element sig-list) | 7258 (defun verilog-modi-cache-add (modi function element sig-list) |
7379 "Add function return results to the module cache. | 7259 "Add function return results to the module cache. |
7481 (goto-char (match-beginning 0)) | 7361 (goto-char (match-beginning 0)) |
7482 (verilog-inside-comment-p))) | 7362 (verilog-inside-comment-p))) |
7483 (funcall func)))) | 7363 (funcall func)))) |
7484 | 7364 |
7485 (defun verilog-insert-one-definition (sig type indent-pt) | 7365 (defun verilog-insert-one-definition (sig type indent-pt) |
7486 "Print out a definition for SIGNAL of the given TYPE, | 7366 "Print out a definition for SIG of the given TYPE, |
7487 with appropriate INDENT-PT indentation." | 7367 with appropriate INDENT-PT indentation." |
7488 (indent-to indent-pt) | 7368 (indent-to indent-pt) |
7489 (insert type) | 7369 (insert type) |
7490 (when (verilog-sig-signed sig) | 7370 (when (verilog-sig-signed sig) |
7491 (insert " " (verilog-sig-signed sig))) | 7371 (insert " " (verilog-sig-signed sig))) |
7592 (int-to-string | 7472 (int-to-string |
7593 (1+ (abs (- (string-to-number (match-string 1 range-exp)) | 7473 (1+ (abs (- (string-to-number (match-string 1 range-exp)) |
7594 (string-to-number (match-string 2 range-exp))))))) | 7474 (string-to-number (match-string 2 range-exp))))))) |
7595 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) | 7475 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) |
7596 (concat "(1+(" (match-string 1 range-exp) ")" | 7476 (concat "(1+(" (match-string 1 range-exp) ")" |
7597 (if (equal "0" (match-string 2 range-exp)) | 7477 (if (equal "0" (match-string 2 range-exp)) |
7598 ;; Don't bother with -(0) | 7478 "" ;; Don't bother with -(0) |
7599 "" | |
7600 (concat "-(" (match-string 2 range-exp) ")")) | 7479 (concat "-(" (match-string 2 range-exp) ")")) |
7601 ")")) | 7480 ")")) |
7602 (t nil))))) | 7481 (t nil))))) |
7603 ;;(verilog-make-width-expression "`A:`B") | 7482 ;;(verilog-make-width-expression "`A:`B") |
7604 | 7483 |
7619 (looking-at "\\s-*// Beginning") | 7498 (looking-at "\\s-*// Beginning") |
7620 (search-forward "// End of automatic" nil t)) | 7499 (search-forward "// End of automatic" nil t)) |
7621 ;; End exists | 7500 ;; End exists |
7622 (end-of-line) | 7501 (end-of-line) |
7623 (delete-region pt (point)) | 7502 (delete-region pt (point)) |
7624 (forward-line 1)) | 7503 (forward-line 1)))) |
7625 )) | |
7626 | 7504 |
7627 (defun verilog-forward-close-paren () | 7505 (defun verilog-forward-close-paren () |
7628 "Find the close parenthesis that match the current point, | 7506 "Find the close parenthesis that match the current point, |
7629 ignore other close parenthesis with matching open parens" | 7507 ignore other close parenthesis with matching open parens" |
7630 (let ((parens 1)) | 7508 (let ((parens 1)) |
7895 (verilog-auto)) | 7773 (verilog-auto)) |
7896 (t | 7774 (t |
7897 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | 7775 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") |
7898 (verilog-auto)) | 7776 (verilog-auto)) |
7899 ;; Don't ask again if didn't update | 7777 ;; Don't ask again if didn't update |
7900 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | 7778 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
7901 )) | |
7902 (when (not verilog-auto-star-save) | 7779 (when (not verilog-auto-star-save) |
7903 (verilog-delete-auto-star-implicit)) | 7780 (verilog-delete-auto-star-implicit)) |
7904 nil) ;; Always return nil -- we don't write the file ourselves | 7781 nil) ;; Always return nil -- we don't write the file ourselves |
7905 | 7782 |
7906 (defun verilog-auto-read-locals () | 7783 (defun verilog-auto-read-locals () |
8006 "// Inputs" | 7883 "// Inputs" |
8007 verilog-indent-level-declaration) | 7884 verilog-indent-level-declaration) |
8008 (verilog-repair-close-comma) | 7885 (verilog-repair-close-comma) |
8009 (unless (eq (char-before) ?/ ) | 7886 (unless (eq (char-before) ?/ ) |
8010 (insert "\n")) | 7887 (insert "\n")) |
8011 (indent-to verilog-indent-level-declaration) | 7888 (indent-to verilog-indent-level-declaration)))) |
8012 ))) | |
8013 | 7889 |
8014 (defun verilog-auto-inst-port-map (port-st) | 7890 (defun verilog-auto-inst-port-map (port-st) |
8015 nil) | 7891 nil) |
8016 | 7892 |
8017 (defvar vector-skip-list nil) ; Prevent compile warning | |
8018 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7893 (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 | 7894 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8020 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7895 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8021 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7896 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8022 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | 7897 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8023 | 7898 |
8024 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) | 7899 (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. | 7900 "Print out a instantiation connection for this PORT-ST. |
8026 Insert to INDENT-PT, use template TPL-LIST. | 7901 Insert to INDENT-PT, use template TPL-LIST. |
8027 @ are instantiation numbers, replaced with TPL-NUM. | 7902 @ are instantiation numbers, replaced with TPL-NUM. |
8028 @\"(expression @)\" are evaluated, with @ as a variable." | 7903 @\"(expression @)\" are evaluated, with @ as a variable. |
7904 If FOR-STAR add comment it is a .* expansion." | |
8029 (let* ((port (verilog-sig-name port-st)) | 7905 (let* ((port (verilog-sig-name port-st)) |
8030 (tpl-ass (or (assoc port (car tpl-list)) | 7906 (tpl-ass (or (assoc port (car tpl-list)) |
8031 (verilog-auto-inst-port-map port-st))) | 7907 (verilog-auto-inst-port-map port-st))) |
8032 ;; vl-* are documented for user use | 7908 ;; vl-* are documented for user use |
8033 (vl-name (verilog-sig-name port-st)) | 7909 (vl-name (verilog-sig-name port-st)) |
8070 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | 7946 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) |
8071 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | 7947 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) |
8072 (prin1 (eval (car (read-from-string expr))) | 7948 (prin1 (eval (car (read-from-string expr))) |
8073 (lambda (ch) ()))))) | 7949 (lambda (ch) ()))))) |
8074 (if (numberp value) (setq value (number-to-string value))) | 7950 (if (numberp value) (setq value (number-to-string value))) |
8075 value | 7951 value)) |
8076 )) | |
8077 (substring tpl-net (match-end 0)))))) | 7952 (substring tpl-net (match-end 0)))))) |
8078 ;; Replace @ and [] magic variables in final output | 7953 ;; Replace @ and [] magic variables in final output |
8079 (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net)) | 7954 (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)) | 7955 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
8081 ) | |
8082 (indent-to indent-pt) | 7956 (indent-to indent-pt) |
8083 (insert "." port) | 7957 (insert "." port) |
8084 (indent-to verilog-auto-inst-column) | 7958 (indent-to verilog-auto-inst-column) |
8085 (insert "(" tpl-net "),") | 7959 (insert "(" tpl-net "),") |
8086 (cond (tpl-ass | 7960 (cond (tpl-ass |
8460 (search-forward "\n") ;; Added by inst-port | 8334 (search-forward "\n") ;; Added by inst-port |
8461 (delete-backward-char 1) | 8335 (delete-backward-char 1) |
8462 (if (search-forward ")" nil t) ;; From user, moved up a line | 8336 (if (search-forward ")" nil t) ;; From user, moved up a line |
8463 (delete-backward-char 1)) | 8337 (delete-backward-char 1)) |
8464 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it | 8338 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it |
8465 (delete-backward-char 1)) | 8339 (delete-backward-char 1))))))))) |
8466 ))) | |
8467 )))) | |
8468 | 8340 |
8469 (defun verilog-auto-inst-param () | 8341 (defun verilog-auto-inst-param () |
8470 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | 8342 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. |
8471 Replace the parameter connections to an instantiation with ones | 8343 Replace the parameter connections to an instantiation with ones |
8472 automatically derived from the module header of the instantiated netlist. | 8344 automatically derived from the module header of the instantiated netlist. |
8564 (delete-char 1) | 8436 (delete-char 1) |
8565 (insert ")") | 8437 (insert ")") |
8566 (search-forward "\n") ;; Added by inst-port | 8438 (search-forward "\n") ;; Added by inst-port |
8567 (delete-backward-char 1) | 8439 (delete-backward-char 1) |
8568 (if (search-forward ")" nil t) ;; From user, moved up a line | 8440 (if (search-forward ")" nil t) ;; From user, moved up a line |
8569 (delete-backward-char 1)) | 8441 (delete-backward-char 1))))))))) |
8570 ))) | |
8571 )))) | |
8572 | 8442 |
8573 (defun verilog-auto-reg () | 8443 (defun verilog-auto-reg () |
8574 "Expand AUTOREG statements, as part of \\[verilog-auto]. | 8444 "Expand AUTOREG statements, as part of \\[verilog-auto]. |
8575 Make reg statements for any output that isn't already declared, | 8445 Make reg statements for any output that isn't already declared, |
8576 and isn't a wire output from a block. | 8446 and isn't a wire output from a block. |
8610 (verilog-modi-get-regs modi) | 8480 (verilog-modi-get-regs modi) |
8611 (verilog-modi-get-assigns modi) | 8481 (verilog-modi-get-assigns modi) |
8612 (verilog-modi-get-consts modi) | 8482 (verilog-modi-get-consts modi) |
8613 (verilog-modi-get-gparams modi) | 8483 (verilog-modi-get-gparams modi) |
8614 (verilog-modi-get-sub-outputs modi) | 8484 (verilog-modi-get-sub-outputs modi) |
8615 (verilog-modi-get-sub-inouts modi) | 8485 (verilog-modi-get-sub-inouts modi))))) |
8616 )))) | |
8617 (forward-line 1) | 8486 (forward-line 1) |
8618 (when sig-list | 8487 (when sig-list |
8619 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | 8488 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") |
8620 (verilog-insert-definition sig-list "reg" indent-pt nil) | 8489 (verilog-insert-definition sig-list "reg" indent-pt nil) |
8621 (verilog-modi-cache-add-regs modi sig-list) | 8490 (verilog-modi-cache-add-regs modi sig-list) |
8622 (verilog-insert-indent "// End of automatics\n")) | 8491 (verilog-insert-indent "// End of automatics\n"))))) |
8623 ))) | |
8624 | 8492 |
8625 (defun verilog-auto-reg-input () | 8493 (defun verilog-auto-reg-input () |
8626 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | 8494 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. |
8627 Make reg statements instantiation inputs that aren't already declared. | 8495 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 | 8496 This is useful for making a top level shell for testing the module that is |
8663 (modi (verilog-modi-current)) | 8531 (modi (verilog-modi-current)) |
8664 (sig-list (verilog-signals-combine-bus | 8532 (sig-list (verilog-signals-combine-bus |
8665 (verilog-signals-not-in | 8533 (verilog-signals-not-in |
8666 (append (verilog-modi-get-sub-inputs modi) | 8534 (append (verilog-modi-get-sub-inputs modi) |
8667 (verilog-modi-get-sub-inouts modi)) | 8535 (verilog-modi-get-sub-inouts modi)) |
8668 (verilog-modi-get-signals modi) | 8536 (verilog-modi-get-signals modi))))) |
8669 )))) | |
8670 (forward-line 1) | 8537 (forward-line 1) |
8671 (when sig-list | 8538 (when sig-list |
8672 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | 8539 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") |
8673 (verilog-insert-definition sig-list "reg" indent-pt nil) | 8540 (verilog-insert-definition sig-list "reg" indent-pt nil) |
8674 (verilog-modi-cache-add-regs modi sig-list) | 8541 (verilog-modi-cache-add-regs modi sig-list) |
8675 (verilog-insert-indent "// End of automatics\n")) | 8542 (verilog-insert-indent "// End of automatics\n"))))) |
8676 ))) | |
8677 | 8543 |
8678 (defun verilog-auto-wire () | 8544 (defun verilog-auto-wire () |
8679 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | 8545 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. |
8680 Make wire statements for instantiations outputs that aren't | 8546 Make wire statements for instantiations outputs that aren't |
8681 already declared. | 8547 already declared. |
8724 (modi (verilog-modi-current)) | 8590 (modi (verilog-modi-current)) |
8725 (sig-list (verilog-signals-combine-bus | 8591 (sig-list (verilog-signals-combine-bus |
8726 (verilog-signals-not-in | 8592 (verilog-signals-not-in |
8727 (append (verilog-modi-get-sub-outputs modi) | 8593 (append (verilog-modi-get-sub-outputs modi) |
8728 (verilog-modi-get-sub-inouts modi)) | 8594 (verilog-modi-get-sub-inouts modi)) |
8729 (verilog-modi-get-signals modi) | 8595 (verilog-modi-get-signals modi))))) |
8730 )))) | |
8731 (forward-line 1) | 8596 (forward-line 1) |
8732 (when sig-list | 8597 (when sig-list |
8733 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | 8598 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") |
8734 (verilog-insert-definition sig-list "wire" indent-pt nil) | 8599 (verilog-insert-definition sig-list "wire" indent-pt nil) |
8735 (verilog-modi-cache-add-wires modi sig-list) | 8600 (verilog-modi-cache-add-wires modi sig-list) |
8737 (when nil ;; Too slow on huge modules, plus makes everyone's module change | 8602 (when nil ;; Too slow on huge modules, plus makes everyone's module change |
8738 (beginning-of-line) | 8603 (beginning-of-line) |
8739 (setq pnt (point)) | 8604 (setq pnt (point)) |
8740 (verilog-pretty-declarations) | 8605 (verilog-pretty-declarations) |
8741 (goto-char pnt) | 8606 (goto-char pnt) |
8742 (verilog-pretty-expr "//"))) | 8607 (verilog-pretty-expr "//")))))) |
8743 ))) | |
8744 | 8608 |
8745 (defun verilog-auto-output () | 8609 (defun verilog-auto-output () |
8746 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. | 8610 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. |
8747 Make output statements for any output signal from an /*AUTOINST*/ that | 8611 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 | 8612 isn't a input to another AUTOINST. This is useful for modules which |
8791 (sig-list (verilog-signals-not-in | 8655 (sig-list (verilog-signals-not-in |
8792 (verilog-modi-get-sub-outputs modi) | 8656 (verilog-modi-get-sub-outputs modi) |
8793 (append (verilog-modi-get-outputs modi) | 8657 (append (verilog-modi-get-outputs modi) |
8794 (verilog-modi-get-inouts modi) | 8658 (verilog-modi-get-inouts modi) |
8795 (verilog-modi-get-sub-inputs modi) | 8659 (verilog-modi-get-sub-inputs modi) |
8796 (verilog-modi-get-sub-inouts modi) | 8660 (verilog-modi-get-sub-inouts modi))))) |
8797 )))) | |
8798 (setq sig-list (verilog-signals-not-matching-regexp | 8661 (setq sig-list (verilog-signals-not-matching-regexp |
8799 sig-list verilog-auto-output-ignore-regexp)) | 8662 sig-list verilog-auto-output-ignore-regexp)) |
8800 (forward-line 1) | 8663 (forward-line 1) |
8801 (when v2k (verilog-repair-open-comma)) | 8664 (when v2k (verilog-repair-open-comma)) |
8802 (when sig-list | 8665 (when sig-list |
8803 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | 8666 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") |
8804 (verilog-insert-definition sig-list "output" indent-pt v2k) | 8667 (verilog-insert-definition sig-list "output" indent-pt v2k) |
8805 (verilog-modi-cache-add-outputs modi sig-list) | 8668 (verilog-modi-cache-add-outputs modi sig-list) |
8806 (verilog-insert-indent "// End of automatics\n")) | 8669 (verilog-insert-indent "// End of automatics\n")) |
8807 (when v2k (verilog-repair-close-comma)) | 8670 (when v2k (verilog-repair-close-comma))))) |
8808 ))) | |
8809 | 8671 |
8810 (defun verilog-auto-output-every () | 8672 (defun verilog-auto-output-every () |
8811 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | 8673 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. |
8812 Make output statements for any signals that aren't primary inputs or | 8674 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 | 8675 outputs already. This makes every signal in the design a output. This is |
8845 (v2k (verilog-in-paren)) | 8707 (v2k (verilog-in-paren)) |
8846 (modi (verilog-modi-current)) | 8708 (modi (verilog-modi-current)) |
8847 (sig-list (verilog-signals-combine-bus | 8709 (sig-list (verilog-signals-combine-bus |
8848 (verilog-signals-not-in | 8710 (verilog-signals-not-in |
8849 (verilog-modi-get-signals modi) | 8711 (verilog-modi-get-signals modi) |
8850 (verilog-modi-get-ports modi) | 8712 (verilog-modi-get-ports modi))))) |
8851 )))) | |
8852 (forward-line 1) | 8713 (forward-line 1) |
8853 (when v2k (verilog-repair-open-comma)) | 8714 (when v2k (verilog-repair-open-comma)) |
8854 (when sig-list | 8715 (when sig-list |
8855 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | 8716 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") |
8856 (verilog-insert-definition sig-list "output" indent-pt v2k) | 8717 (verilog-insert-definition sig-list "output" indent-pt v2k) |
8857 (verilog-modi-cache-add-outputs modi sig-list) | 8718 (verilog-modi-cache-add-outputs modi sig-list) |
8858 (verilog-insert-indent "// End of automatics\n")) | 8719 (verilog-insert-indent "// End of automatics\n")) |
8859 (when v2k (verilog-repair-close-comma)) | 8720 (when v2k (verilog-repair-close-comma))))) |
8860 ))) | |
8861 | 8721 |
8862 (defun verilog-auto-input () | 8722 (defun verilog-auto-input () |
8863 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. | 8723 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. |
8864 Make input statements for any input signal into an /*AUTOINST*/ that | 8724 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 | 8725 isn't declared elsewhere inside the module. This is useful for modules which |
8911 (verilog-modi-get-wires modi) | 8771 (verilog-modi-get-wires modi) |
8912 (verilog-modi-get-regs modi) | 8772 (verilog-modi-get-regs modi) |
8913 (verilog-modi-get-consts modi) | 8773 (verilog-modi-get-consts modi) |
8914 (verilog-modi-get-gparams modi) | 8774 (verilog-modi-get-gparams modi) |
8915 (verilog-modi-get-sub-outputs modi) | 8775 (verilog-modi-get-sub-outputs modi) |
8916 (verilog-modi-get-sub-inouts modi) | 8776 (verilog-modi-get-sub-inouts modi))))) |
8917 )))) | |
8918 (setq sig-list (verilog-signals-not-matching-regexp | 8777 (setq sig-list (verilog-signals-not-matching-regexp |
8919 sig-list verilog-auto-input-ignore-regexp)) | 8778 sig-list verilog-auto-input-ignore-regexp)) |
8920 (forward-line 1) | 8779 (forward-line 1) |
8921 (when v2k (verilog-repair-open-comma)) | 8780 (when v2k (verilog-repair-open-comma)) |
8922 (when sig-list | 8781 (when sig-list |
8923 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | 8782 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") |
8924 (verilog-insert-definition sig-list "input" indent-pt v2k) | 8783 (verilog-insert-definition sig-list "input" indent-pt v2k) |
8925 (verilog-modi-cache-add-inputs modi sig-list) | 8784 (verilog-modi-cache-add-inputs modi sig-list) |
8926 (verilog-insert-indent "// End of automatics\n")) | 8785 (verilog-insert-indent "// End of automatics\n")) |
8927 (when v2k (verilog-repair-close-comma)) | 8786 (when v2k (verilog-repair-close-comma))))) |
8928 ))) | |
8929 | 8787 |
8930 (defun verilog-auto-inout () | 8788 (defun verilog-auto-inout () |
8931 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. | 8789 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. |
8932 Make inout statements for any inout signal in an /*AUTOINST*/ that | 8790 Make inout statements for any inout signal in an /*AUTOINST*/ that |
8933 isn't declared elsewhere inside the module. | 8791 isn't declared elsewhere inside the module. |
8976 (verilog-modi-get-sub-inouts modi) | 8834 (verilog-modi-get-sub-inouts modi) |
8977 (append (verilog-modi-get-outputs modi) | 8835 (append (verilog-modi-get-outputs modi) |
8978 (verilog-modi-get-inouts modi) | 8836 (verilog-modi-get-inouts modi) |
8979 (verilog-modi-get-inputs modi) | 8837 (verilog-modi-get-inputs modi) |
8980 (verilog-modi-get-sub-inputs modi) | 8838 (verilog-modi-get-sub-inputs modi) |
8981 (verilog-modi-get-sub-outputs modi) | 8839 (verilog-modi-get-sub-outputs modi))))) |
8982 )))) | |
8983 (setq sig-list (verilog-signals-not-matching-regexp | 8840 (setq sig-list (verilog-signals-not-matching-regexp |
8984 sig-list verilog-auto-inout-ignore-regexp)) | 8841 sig-list verilog-auto-inout-ignore-regexp)) |
8985 (forward-line 1) | 8842 (forward-line 1) |
8986 (when v2k (verilog-repair-open-comma)) | 8843 (when v2k (verilog-repair-open-comma)) |
8987 (when sig-list | 8844 (when sig-list |
8988 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | 8845 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") |
8989 (verilog-insert-definition sig-list "inout" indent-pt v2k) | 8846 (verilog-insert-definition sig-list "inout" indent-pt v2k) |
8990 (verilog-modi-cache-add-inouts modi sig-list) | 8847 (verilog-modi-cache-add-inouts modi sig-list) |
8991 (verilog-insert-indent "// End of automatics\n")) | 8848 (verilog-insert-indent "// End of automatics\n")) |
8992 (when v2k (verilog-repair-close-comma)) | 8849 (when v2k (verilog-repair-close-comma))))) |
8993 ))) | |
8994 | 8850 |
8995 (defun verilog-auto-inout-module () | 8851 (defun verilog-auto-inout-module () |
8996 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. | 8852 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. |
8997 Take input/output/inout statements from the specified module and insert | 8853 Take input/output/inout statements from the specified module and insert |
8998 into the current module. This is useful for making null templates and | 8854 into the current module. This is useful for making null templates and |
9060 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | 8916 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) |
9061 (verilog-modi-cache-add-inputs modi sig-list-i) | 8917 (verilog-modi-cache-add-inputs modi sig-list-i) |
9062 (verilog-modi-cache-add-outputs modi sig-list-o) | 8918 (verilog-modi-cache-add-outputs modi sig-list-o) |
9063 (verilog-modi-cache-add-inouts modi sig-list-io) | 8919 (verilog-modi-cache-add-inouts modi sig-list-io) |
9064 (verilog-insert-indent "// End of automatics\n")) | 8920 (verilog-insert-indent "// End of automatics\n")) |
9065 (when v2k (verilog-repair-close-comma)) | 8921 (when v2k (verilog-repair-close-comma))))))) |
9066 ))))) | |
9067 | 8922 |
9068 (defun verilog-auto-sense-sigs (modi presense-sigs) | 8923 (defun verilog-auto-sense-sigs (modi presense-sigs) |
9069 "Return list of signals for current AUTOSENSE block." | 8924 "Return list of signals for current AUTOSENSE block." |
9070 (let* ((sigss (verilog-read-always-signals)) | 8925 (let* ((sigss (verilog-read-always-signals)) |
9071 (sig-list (verilog-signals-not-params | 8926 (sig-list (verilog-signals-not-params |
9162 (indent-to indent-pt) | 9017 (indent-to indent-pt) |
9163 (if not-first (insert "or "))) | 9018 (if not-first (insert "or "))) |
9164 (not-first (insert " or "))) | 9019 (not-first (insert " or "))) |
9165 (insert (verilog-sig-name (car sig-list))) | 9020 (insert (verilog-sig-name (car sig-list))) |
9166 (setq sig-list (cdr sig-list) | 9021 (setq sig-list (cdr sig-list) |
9167 not-first t)) | 9022 not-first t))))) |
9168 ))) | |
9169 | 9023 |
9170 (defun verilog-auto-reset () | 9024 (defun verilog-auto-reset () |
9171 "Expand AUTORESET statements, as part of \\[verilog-auto]. | 9025 "Expand AUTORESET statements, as part of \\[verilog-auto]. |
9172 Replace the /*AUTORESET*/ comment with code to initialize all | 9026 Replace the /*AUTORESET*/ comment with code to initialize all |
9173 registers set elsewhere in the always block. | 9027 registers set elsewhere in the always block. |
9258 assignment-str | 9112 assignment-str |
9259 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | 9113 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) |
9260 ";\n") | 9114 ";\n") |
9261 (indent-to indent-pt) | 9115 (indent-to indent-pt) |
9262 (setq sig-list (cdr sig-list)))) | 9116 (setq sig-list (cdr sig-list)))) |
9263 (insert "// End of automatics")) | 9117 (insert "// End of automatics"))))) |
9264 ))) | |
9265 | 9118 |
9266 (defun verilog-auto-tieoff () | 9119 (defun verilog-auto-tieoff () |
9267 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | 9120 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. |
9268 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | 9121 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output |
9269 signals to deasserted. | 9122 signals to deasserted. |
9314 (verilog-modi-get-regs modi) | 9167 (verilog-modi-get-regs modi) |
9315 (verilog-modi-get-assigns modi) | 9168 (verilog-modi-get-assigns modi) |
9316 (verilog-modi-get-consts modi) | 9169 (verilog-modi-get-consts modi) |
9317 (verilog-modi-get-gparams modi) | 9170 (verilog-modi-get-gparams modi) |
9318 (verilog-modi-get-sub-outputs modi) | 9171 (verilog-modi-get-sub-outputs modi) |
9319 (verilog-modi-get-sub-inouts modi) | 9172 (verilog-modi-get-sub-inouts modi))))) |
9320 )))) | |
9321 (when sig-list | 9173 (when sig-list |
9322 (forward-line 1) | 9174 (forward-line 1) |
9323 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | 9175 (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)) | 9176 (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 | 9177 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list |
9328 (verilog-insert-one-definition sig "wire" indent-pt) | 9180 (verilog-insert-one-definition sig "wire" indent-pt) |
9329 (indent-to (max 48 (+ indent-pt 40))) | 9181 (indent-to (max 48 (+ indent-pt 40))) |
9330 (insert "= " (verilog-sig-tieoff sig) | 9182 (insert "= " (verilog-sig-tieoff sig) |
9331 ";\n") | 9183 ";\n") |
9332 (setq sig-list (cdr sig-list)))) | 9184 (setq sig-list (cdr sig-list)))) |
9333 (verilog-insert-indent "// End of automatics\n") | 9185 (verilog-insert-indent "// End of automatics\n"))))) |
9334 )))) | |
9335 | 9186 |
9336 (defun verilog-auto-unused () | 9187 (defun verilog-auto-unused () |
9337 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | 9188 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. |
9338 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | 9189 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused |
9339 input and inout signals. | 9190 input and inout signals. |
9393 (modi (verilog-modi-current)) | 9244 (modi (verilog-modi-current)) |
9394 (sig-list (verilog-signals-not-in | 9245 (sig-list (verilog-signals-not-in |
9395 (append (verilog-modi-get-inputs modi) | 9246 (append (verilog-modi-get-inputs modi) |
9396 (verilog-modi-get-inouts modi)) | 9247 (verilog-modi-get-inouts modi)) |
9397 (append (verilog-modi-get-sub-inputs modi) | 9248 (append (verilog-modi-get-sub-inputs modi) |
9398 (verilog-modi-get-sub-inouts modi) | 9249 (verilog-modi-get-sub-inouts modi))))) |
9399 )))) | |
9400 (setq sig-list (verilog-signals-not-matching-regexp | 9250 (setq sig-list (verilog-signals-not-matching-regexp |
9401 sig-list verilog-auto-unused-ignore-regexp)) | 9251 sig-list verilog-auto-unused-ignore-regexp)) |
9402 (when sig-list | 9252 (when sig-list |
9403 (forward-line 1) | 9253 (forward-line 1) |
9404 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | 9254 (verilog-insert-indent "// Beginning of automatic unused inputs\n") |
9406 (while sig-list | 9256 (while sig-list |
9407 (let ((sig (car sig-list))) | 9257 (let ((sig (car sig-list))) |
9408 (indent-to indent-pt) | 9258 (indent-to indent-pt) |
9409 (insert (verilog-sig-name sig) ",\n") | 9259 (insert (verilog-sig-name sig) ",\n") |
9410 (setq sig-list (cdr sig-list)))) | 9260 (setq sig-list (cdr sig-list)))) |
9411 (verilog-insert-indent "// End of automatics\n") | 9261 (verilog-insert-indent "// End of automatics\n"))))) |
9412 )))) | |
9413 | 9262 |
9414 (defun verilog-enum-ascii (signm elim-regexp) | 9263 (defun verilog-enum-ascii (signm elim-regexp) |
9415 "Convert a enum name SIGNM to a ascii string for insertion. | 9264 "Convert a enum name SIGNM to a ascii string for insertion. |
9416 Remove user provided prefix ELIM-REGEXP." | 9265 Remove user provided prefix ELIM-REGEXP." |
9417 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | 9266 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) |
9541 ;; | 9390 ;; |
9542 (setq indent-pt (- indent-pt verilog-case-indent)) | 9391 (setq indent-pt (- indent-pt verilog-case-indent)) |
9543 (verilog-insert-indent "endcase\n") | 9392 (verilog-insert-indent "endcase\n") |
9544 (setq indent-pt (- indent-pt verilog-indent-level)) | 9393 (setq indent-pt (- indent-pt verilog-indent-level)) |
9545 (verilog-insert-indent "end\n" | 9394 (verilog-insert-indent "end\n" |
9546 "// End of automatics\n") | 9395 "// End of automatics\n")))) |
9547 ))) | |
9548 | 9396 |
9549 (defun verilog-auto-templated-rel () | 9397 (defun verilog-auto-templated-rel () |
9550 "Replace Templated relative line numbers with absolute line numbers. | 9398 "Replace Templated relative line numbers with absolute line numbers. |
9551 Internal use only. This hacks around the line numbers in AUTOINST Templates | 9399 Internal use only. This hacks around the line numbers in AUTOINST Templates |
9552 being different from the final output's line numbering." | 9400 being different from the final output's line numbering." |
9692 ;; After we've created all new variables | 9540 ;; After we've created all new variables |
9693 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) | 9541 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) |
9694 ;; Must be after all inputs outputs are generated | 9542 ;; Must be after all inputs outputs are generated |
9695 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) | 9543 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) |
9696 ;; Fix line numbers (comments only) | 9544 ;; Fix line numbers (comments only) |
9697 (verilog-auto-templated-rel) | 9545 (verilog-auto-templated-rel)) |
9698 ) | |
9699 ;; | 9546 ;; |
9700 (run-hooks 'verilog-auto-hook) | 9547 (run-hooks 'verilog-auto-hook) |
9701 ;; | 9548 ;; |
9702 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | 9549 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) |
9703 ;; | 9550 ;; |
9707 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | 9554 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) |
9708 (t (unless noninteractive (message "Updating AUTOs...done"))))) | 9555 (t (unless noninteractive (message "Updating AUTOs...done"))))) |
9709 ;; Unwind forms | 9556 ;; Unwind forms |
9710 (progn | 9557 (progn |
9711 ;; Restore font-lock | 9558 ;; Restore font-lock |
9712 (when fontlocked (font-lock-mode t))) | 9559 (when fontlocked (font-lock-mode t)))))) |
9713 ))) | |
9714 | 9560 |
9715 | 9561 |
9716 ;; | 9562 ;; |
9717 ;; Skeleton based code insertion | 9563 ;; Skeleton based code insertion |
9718 ;; | 9564 ;; |
9719 (defvar verilog-template-map | 9565 (defvar verilog-template-map |
9720 (let ((map (make-sparse-keymap))) | 9566 (let ((map (make-sparse-keymap))) |
9721 (define-key map "a" 'verilog-sk-always) | 9567 (define-key map "a" 'verilog-sk-always) |
9722 (define-key map "b" 'verilog-sk-begin) | 9568 (define-key map "b" 'verilog-sk-begin) |
9723 (define-key map "c" 'verilog-sk-case) | 9569 (define-key map "c" 'verilog-sk-case) |
9724 (define-key map "f" 'verilog-sk-for) | 9570 (define-key map "f" 'verilog-sk-for) |
9983 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) | 9829 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
9984 | 9830 |
9985 (defun verilog-sk-define-signal () | 9831 (defun verilog-sk-define-signal () |
9986 "Insert a definition of signal under point at top of module." | 9832 "Insert a definition of signal under point at top of module." |
9987 (interactive "*") | 9833 (interactive "*") |
9988 (let* ( | 9834 (let* ((sig-re "[a-zA-Z0-9_]*") |
9989 (sig-re "[a-zA-Z0-9_]*") | |
9990 (v1 (buffer-substring | 9835 (v1 (buffer-substring |
9991 (save-excursion | 9836 (save-excursion |
9992 (skip-chars-backward sig-re) | 9837 (skip-chars-backward sig-re) |
9993 (point)) | 9838 (point)) |
9994 (save-excursion | 9839 (save-excursion |
9995 (skip-chars-forward sig-re) | 9840 (skip-chars-forward sig-re) |
9996 (point)))) | 9841 (point))))) |
9997 ) | |
9998 (if (not (member v1 verilog-keywords)) | 9842 (if (not (member v1 verilog-keywords)) |
9999 (save-excursion | 9843 (save-excursion |
10000 (setq verilog-sk-signal v1) | 9844 (setq verilog-sk-signal v1) |
10001 (verilog-beg-of-defun) | 9845 (verilog-beg-of-defun) |
10002 (verilog-end-of-statement) | 9846 (verilog-end-of-statement) |
10003 (verilog-forward-syntactic-ws) | 9847 (verilog-forward-syntactic-ws) |
10004 (verilog-sk-def-reg) | 9848 (verilog-sk-def-reg) |
10005 (message "signal at point is %s" v1)) | 9849 (message "signal at point is %s" v1)) |
10006 (message "object at point (%s) is a keyword" v1)) | 9850 (message "object at point (%s) is a keyword" v1)))) |
10007 ) | |
10008 ) | |
10009 | |
10010 | 9851 |
10011 (define-skeleton verilog-sk-wire | 9852 (define-skeleton verilog-sk-wire |
10012 "Insert a wire definition." | 9853 "Insert a wire definition." |
10013 () | 9854 () |
10014 > "wire [" (verilog-sk-datadef)) | 9855 > "wire [" (verilog-sk-datadef)) |
10107 | 9948 |
10108 (defconst verilog-include-file-regexp | 9949 (defconst verilog-include-file-regexp |
10109 "^`include\\s-+\"\\([^\n\"]*\\)\"" | 9950 "^`include\\s-+\"\\([^\n\"]*\\)\"" |
10110 "Regexp that matches the include file.") | 9951 "Regexp that matches the include file.") |
10111 | 9952 |
10112 (defvar verilog-mode-mouse-map | 9953 (defvar verilog-mode-mouse-map |
10113 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map | 9954 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
10114 (set-keymap-parent map verilog-mode-map) | 9955 (set-keymap-parent map verilog-mode-map) |
10115 ;; mouse button bindings | 9956 ;; mouse button bindings |
10116 (define-key map "\r" 'verilog-load-file-at-point) | 9957 (define-key map "\r" 'verilog-load-file-at-point) |
10117 (if (featurep 'xemacs) | 9958 (if (featurep 'xemacs) |
10187 (find-file (car (verilog-library-filenames | 10028 (find-file (car (verilog-library-filenames |
10188 (match-string 1) (buffer-file-name)))) | 10029 (match-string 1) (buffer-file-name)))) |
10189 (progn | 10030 (progn |
10190 (message | 10031 (message |
10191 "File '%s' isn't readable, use shift-mouse2 to paste in this field" | 10032 "File '%s' isn't readable, use shift-mouse2 to paste in this field" |
10192 (match-string 1)))) | 10033 (match-string 1))))))) |
10193 ))) | |
10194 | 10034 |
10195 ;; ffap isn't useable for verilog mode. It uses library paths. | 10035 ;; 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 | 10036 ;; so define this function to do more or less the same as ffap |
10197 ;; but first resolve filename... | 10037 ;; but first resolve filename... |
10198 (defun verilog-load-file-at-point () | 10038 (defun verilog-load-file-at-point () |
10206 (car (verilog-library-filenames | 10046 (car (verilog-library-filenames |
10207 (match-string 1) (buffer-file-name))) | 10047 (match-string 1) (buffer-file-name))) |
10208 (file-readable-p (car (verilog-library-filenames | 10048 (file-readable-p (car (verilog-library-filenames |
10209 (match-string 1) (buffer-file-name))))) | 10049 (match-string 1) (buffer-file-name))))) |
10210 (find-file (car (verilog-library-filenames | 10050 (find-file (car (verilog-library-filenames |
10211 (match-string 1) (buffer-file-name)))))) | 10051 (match-string 1) (buffer-file-name)))))))) |
10212 )) | |
10213 | 10052 |
10214 | 10053 |
10215 ;; | 10054 ;; |
10216 ;; Bug reporting | 10055 ;; Bug reporting |
10217 ;; | 10056 ;; |
10228 (princ "\n") | 10067 (princ "\n") |
10229 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | 10068 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") |
10230 (princ "\n"))) | 10069 (princ "\n"))) |
10231 | 10070 |
10232 (autoload 'reporter-submit-bug-report "reporter") | 10071 (autoload 'reporter-submit-bug-report "reporter") |
10072 (defvar reporter-prompt-for-summary-p) | |
10233 | 10073 |
10234 (defun verilog-submit-bug-report () | 10074 (defun verilog-submit-bug-report () |
10235 "Submit via mail a bug report on verilog-mode.el." | 10075 "Submit via mail a bug report on verilog-mode.el." |
10236 (interactive) | 10076 (interactive) |
10237 (let ((reporter-prompt-for-summary-p t)) | 10077 (let ((reporter-prompt-for-summary-p t)) |