diff options
| author | Wilson Snyder | 2015-08-16 08:44:16 -0400 |
|---|---|---|
| committer | Wilson Snyder | 2015-08-16 08:44:16 -0400 |
| commit | 6bfde469c6f4f7d9bcda329f3d72140bba8dce33 (patch) | |
| tree | af132c3d550ea29c151695e01ecaaa7a35e2ff4c | |
| parent | 87c4e2a686ff8b166974ca21d46faf5e802fb1b6 (diff) | |
| download | emacs-6bfde469c6f4f7d9bcda329f3d72140bba8dce33.tar.gz emacs-6bfde469c6f4f7d9bcda329f3d72140bba8dce33.zip | |
Update verilog-mode.el to 2015-05-14-6232468-vpo-GNU.
* losp/progmodes/verilog-mode.el: Fix some non-automated indent
issues and comments, bug943. (verilog-type-font-keywords): Cycle
delay operators like ##1 and ##[0:$] are now highlighted in their
entirety similarly to the # delay-control operator. Likewise, the
followed-by operators #-# and #=# are no longer partially
highlighed. (verilog-backward-syntactic-ws-quick,
verilog-skip-backward-comments): Minor performance improvements to
buffer traversal functions for reduced latency. (verilog-calc-1,
verilog-in-deferred-immediate-final-p): When the keyword 'final'
follows 'assert/assume/cover', then it is part of a deferred
immediate assertion item and should not be treated as a final
construct for indentation. Reported by Yuri Sugihara.
(verilog-do-indent): Virtual task/function/class definition lines
should not be considered as declarations. Reported by Enzo Chi.
(verilog-do-indent): Do not falsely indent to '=' of
property/sequence operators on subsequent lines of a multi-line
statement. (verilog-assignment-operator-re): Fix '!==' operator
and add support for '<->', ':/', '#-#', and '#=#' operators.
(verilog-calculate-indent, verilog-label-be): Enable
case-sensitive regular expression parsing when looking for
keywords. (verilog-calc-1): Detect 'pure virtual method'
declarations which exist in abstract classes. Reported by Enzo
Chi and Kaushal Modi. (verilog-backward-ws&directives): When
moving back to the start of a line and the preceeding line ended
with an escaped-newline, then jump up one line. This properly
consumes a multi-line pre-processor directive. Reported by
Kaushal Modi. (verilog-dpi-import-export-re,
verilog-extended-complete-re, verilog-calc-1): Teach verilog-mode
to properly indent after a DPI import/export statement that
resides outside of a module. Reported by Kaushal Modi.
(verilog-extended-complete-re): Update regexp to match both
"DPI-C" and "DPI". Reported by Kaushal Modi.
| -rw-r--r-- | lisp/progmodes/verilog-mode.el | 2722 |
1 files changed, 1378 insertions, 1344 deletions
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 93572d9e64e..3ce185f601b 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el | |||
| @@ -77,8 +77,8 @@ | |||
| 77 | ;; the following in code (please un comment it first!) in your | 77 | ;; the following in code (please un comment it first!) in your |
| 78 | ;; .emacs, or in your site's site-load.el | 78 | ;; .emacs, or in your site's site-load.el |
| 79 | 79 | ||
| 80 | ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) | 80 | ;; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) |
| 81 | ; (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode)) | 81 | ;; (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode)) |
| 82 | 82 | ||
| 83 | ;; Be sure to examine at the help for verilog-auto, and the other | 83 | ;; Be sure to examine at the help for verilog-auto, and the other |
| 84 | ;; verilog-auto-* functions for some major coding time savers. | 84 | ;; verilog-auto-* functions for some major coding time savers. |
| @@ -92,38 +92,38 @@ | |||
| 92 | ;; in Local Variables in every file. Otherwise, different people's | 92 | ;; in Local Variables in every file. Otherwise, different people's |
| 93 | ;; AUTO expansion may result different whitespace changes. | 93 | ;; AUTO expansion may result different whitespace changes. |
| 94 | ;; | 94 | ;; |
| 95 | ; ;; Enable syntax highlighting of **all** languages | 95 | ;; ;; Enable syntax highlighting of **all** languages |
| 96 | ; (global-font-lock-mode t) | 96 | ;; (global-font-lock-mode t) |
| 97 | ; | 97 | ;; |
| 98 | ; ;; User customization for Verilog mode | 98 | ;; ;; User customization for Verilog mode |
| 99 | ; (setq verilog-indent-level 3 | 99 | ;; (setq verilog-indent-level 3 |
| 100 | ; verilog-indent-level-module 3 | 100 | ;; verilog-indent-level-module 3 |
| 101 | ; verilog-indent-level-declaration 3 | 101 | ;; verilog-indent-level-declaration 3 |
| 102 | ; verilog-indent-level-behavioral 3 | 102 | ;; verilog-indent-level-behavioral 3 |
| 103 | ; verilog-indent-level-directive 1 | 103 | ;; verilog-indent-level-directive 1 |
| 104 | ; verilog-case-indent 2 | 104 | ;; verilog-case-indent 2 |
| 105 | ; verilog-auto-newline t | 105 | ;; verilog-auto-newline t |
| 106 | ; verilog-auto-indent-on-newline t | 106 | ;; verilog-auto-indent-on-newline t |
| 107 | ; verilog-tab-always-indent t | 107 | ;; verilog-tab-always-indent t |
| 108 | ; verilog-auto-endcomments t | 108 | ;; verilog-auto-endcomments t |
| 109 | ; verilog-minimum-comment-distance 40 | 109 | ;; verilog-minimum-comment-distance 40 |
| 110 | ; verilog-indent-begin-after-if t | 110 | ;; verilog-indent-begin-after-if t |
| 111 | ; verilog-auto-lineup 'declarations | 111 | ;; verilog-auto-lineup 'declarations |
| 112 | ; verilog-highlight-p1800-keywords nil | 112 | ;; verilog-highlight-p1800-keywords nil |
| 113 | ; verilog-linter "my_lint_shell_command" | 113 | ;; verilog-linter "my_lint_shell_command" |
| 114 | ; ) | 114 | ;; ) |
| 115 | |||
| 116 | ;; | ||
| 117 | 115 | ||
| 116 | |||
| 118 | ;;; History: | 117 | ;;; History: |
| 119 | ;; | 118 | ;; |
| 120 | ;; See commit history at http://www.veripool.org/verilog-mode.html | 119 | ;; See commit history at http://www.veripool.org/verilog-mode.html |
| 121 | ;; (This section is required to appease checkdoc.) | 120 | ;; (This section is required to appease checkdoc.) |
| 122 | 121 | ||
| 123 | ;;; Code: | 122 | ;;; Code: |
| 123 | ;; | ||
| 124 | 124 | ||
| 125 | ;; This variable will always hold the version number of the mode | 125 | ;; This variable will always hold the version number of the mode |
| 126 | (defconst verilog-mode-version "2015-05-14-6232468-vpo-GNU" | 126 | (defconst verilog-mode-version "2015-08-16-ce03c7a-vpo-GNU" |
| 127 | "Version of this Verilog mode.") | 127 | "Version of this Verilog mode.") |
| 128 | (defconst verilog-mode-release-emacs t | 128 | (defconst verilog-mode-release-emacs t |
| 129 | "If non-nil, this version of Verilog mode was released with Emacs itself.") | 129 | "If non-nil, this version of Verilog mode was released with Emacs itself.") |
| @@ -150,36 +150,36 @@ | |||
| 150 | (error nil)) | 150 | (error nil)) |
| 151 | (condition-case nil | 151 | (condition-case nil |
| 152 | (if (fboundp 'when) | 152 | (if (fboundp 'when) |
| 153 | nil ;; fab | 153 | nil ; fab |
| 154 | (defmacro when (cond &rest body) | 154 | (defmacro when (cond &rest body) |
| 155 | (list 'if cond (cons 'progn body)))) | 155 | (list 'if cond (cons 'progn body)))) |
| 156 | (error nil)) | 156 | (error nil)) |
| 157 | (condition-case nil | 157 | (condition-case nil |
| 158 | (if (fboundp 'unless) | 158 | (if (fboundp 'unless) |
| 159 | nil ;; fab | 159 | nil ; fab |
| 160 | (defmacro unless (cond &rest body) | 160 | (defmacro unless (cond &rest body) |
| 161 | (cons 'if (cons cond (cons nil body))))) | 161 | (cons 'if (cons cond (cons nil body))))) |
| 162 | (error nil)) | 162 | (error nil)) |
| 163 | (condition-case nil | 163 | (condition-case nil |
| 164 | (if (fboundp 'store-match-data) | 164 | (if (fboundp 'store-match-data) |
| 165 | nil ;; fab | 165 | nil ; fab |
| 166 | (defmacro store-match-data (&rest _args) nil)) | 166 | (defmacro store-match-data (&rest _args) nil)) |
| 167 | (error nil)) | 167 | (error nil)) |
| 168 | (condition-case nil | 168 | (condition-case nil |
| 169 | (if (fboundp 'char-before) | 169 | (if (fboundp 'char-before) |
| 170 | nil ;; great | 170 | nil ; great |
| 171 | (defmacro char-before (&rest _body) | 171 | (defmacro char-before (&rest _body) |
| 172 | (char-after (1- (point))))) | 172 | (char-after (1- (point))))) |
| 173 | (error nil)) | 173 | (error nil)) |
| 174 | (condition-case nil | 174 | (condition-case nil |
| 175 | (if (fboundp 'when) | 175 | (if (fboundp 'when) |
| 176 | nil ;; fab | 176 | nil ; fab |
| 177 | (defsubst point-at-bol (&optional N) | 177 | (defsubst point-at-bol (&optional N) |
| 178 | (save-excursion (beginning-of-line N) (point)))) | 178 | (save-excursion (beginning-of-line N) (point)))) |
| 179 | (error nil)) | 179 | (error nil)) |
| 180 | (condition-case nil | 180 | (condition-case nil |
| 181 | (if (fboundp 'when) | 181 | (if (fboundp 'when) |
| 182 | nil ;; fab | 182 | nil ; fab |
| 183 | (defsubst point-at-eol (&optional N) | 183 | (defsubst point-at-eol (&optional N) |
| 184 | (save-excursion (end-of-line N) (point)))) | 184 | (save-excursion (end-of-line N) (point)))) |
| 185 | (error nil)) | 185 | (error nil)) |
| @@ -188,7 +188,7 @@ | |||
| 188 | (error nil)) | 188 | (error nil)) |
| 189 | (condition-case nil | 189 | (condition-case nil |
| 190 | (if (fboundp 'match-string-no-properties) | 190 | (if (fboundp 'match-string-no-properties) |
| 191 | nil ;; great | 191 | nil ; great |
| 192 | (defsubst match-string-no-properties (num &optional string) | 192 | (defsubst match-string-no-properties (num &optional string) |
| 193 | "Return string of text matched by last search, without text properties. | 193 | "Return string of text matched by last search, without text properties. |
| 194 | NUM specifies which parenthesized expression in the last regexp. | 194 | NUM specifies which parenthesized expression in the last regexp. |
| @@ -208,7 +208,7 @@ STRING should be given if the last search was by `string-match' on STRING." | |||
| 208 | ) | 208 | ) |
| 209 | (error nil)) | 209 | (error nil)) |
| 210 | (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) | 210 | (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
| 211 | nil ;; We've got what we needed | 211 | nil ; We've got what we needed |
| 212 | ;; We have the old custom-library, hack around it! | 212 | ;; We have the old custom-library, hack around it! |
| 213 | (defmacro defgroup (&rest _args) nil) | 213 | (defmacro defgroup (&rest _args) nil) |
| 214 | (defmacro customize (&rest _args) | 214 | (defmacro customize (&rest _args) |
| @@ -224,7 +224,7 @@ STRING should be given if the last search was by `string-match' on STRING." | |||
| 224 | ) | 224 | ) |
| 225 | 225 | ||
| 226 | (if (and (featurep 'custom) (fboundp 'customize-group)) | 226 | (if (and (featurep 'custom) (fboundp 'customize-group)) |
| 227 | nil ;; We've got what we needed | 227 | nil ; We've got what we needed |
| 228 | ;; We have an intermediate custom-library, hack around it! | 228 | ;; We have an intermediate custom-library, hack around it! |
| 229 | (defmacro customize-group (var &rest _args) | 229 | (defmacro customize-group (var &rest _args) |
| 230 | `(customize ,var)) | 230 | `(customize ,var)) |
| @@ -254,16 +254,16 @@ STRING should be given if the last search was by `string-match' on STRING." | |||
| 254 | (if (fboundp 'function-max-args) | 254 | (if (fboundp 'function-max-args) |
| 255 | (let ((args (function-max-args `regexp-opt))) | 255 | (let ((args (function-max-args `regexp-opt))) |
| 256 | (cond | 256 | (cond |
| 257 | ((eq args 3) ;; It takes 3 | 257 | ((eq args 3) ; It takes 3 |
| 258 | (condition-case nil ; Hide this defun from emacses | 258 | (condition-case nil ; Hide this defun from emacses |
| 259 | ;with just a two input regexp | 259 | ; with just a two input regexp |
| 260 | (defun verilog-regexp-opt (a b) | 260 | (defun verilog-regexp-opt (a b) |
| 261 | "Deal with differing number of required arguments for `regexp-opt'. | 261 | "Deal with differing number of required arguments for `regexp-opt'. |
| 262 | Call `regexp-opt' on A and B." | 262 | Call `regexp-opt' on A and B." |
| 263 | (regexp-opt a b t)) | 263 | (regexp-opt a b t)) |
| 264 | (error nil)) | 264 | (error nil)) |
| 265 | ) | 265 | ) |
| 266 | ((eq args 2) ;; It takes 2 | 266 | ((eq args 2) ; It takes 2 |
| 267 | (defun verilog-regexp-opt (a b) | 267 | (defun verilog-regexp-opt (a b) |
| 268 | "Call `regexp-opt' on A and B." | 268 | "Call `regexp-opt' on A and B." |
| 269 | (regexp-opt a b)) | 269 | (regexp-opt a b)) |
| @@ -307,35 +307,35 @@ LIMIT. | |||
| 307 | 307 | ||
| 308 | As a general recommendation, try to avoid using `looking-back' | 308 | As a general recommendation, try to avoid using `looking-back' |
| 309 | wherever possible, since it is slow." | 309 | wherever possible, since it is slow." |
| 310 | (let ((start (point)) | 310 | (let ((start (point)) |
| 311 | (pos | 311 | (pos |
| 312 | (save-excursion | 312 | (save-excursion |
| 313 | (and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t) | 313 | (and (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t) |
| 314 | (point))))) | 314 | (point))))) |
| 315 | (if (and greedy pos) | 315 | (if (and greedy pos) |
| 316 | (save-restriction | 316 | (save-restriction |
| 317 | (narrow-to-region (point-min) start) | 317 | (narrow-to-region (point-min) start) |
| 318 | (while (and (> pos (point-min)) | 318 | (while (and (> pos (point-min)) |
| 319 | (save-excursion | 319 | (save-excursion |
| 320 | (goto-char pos) | 320 | (goto-char pos) |
| 321 | (backward-char 1) | 321 | (backward-char 1) |
| 322 | (looking-at (concat "\\(?:" regexp "\\)\\'")))) | 322 | (looking-at (concat "\\(?:" regexp "\\)\\'")))) |
| 323 | (setq pos (1- pos))) | 323 | (setq pos (1- pos))) |
| 324 | (save-excursion | 324 | (save-excursion |
| 325 | (goto-char pos) | 325 | (goto-char pos) |
| 326 | (looking-at (concat "\\(?:" regexp "\\)\\'"))))) | 326 | (looking-at (concat "\\(?:" regexp "\\)\\'"))))) |
| 327 | (not (null pos))))))) | 327 | (not (null pos))))))) |
| 328 | 328 | ||
| 329 | (eval-and-compile | 329 | (eval-and-compile |
| 330 | ;; Both xemacs and emacs | 330 | ;; Both xemacs and emacs |
| 331 | (condition-case nil | 331 | (condition-case nil |
| 332 | (require 'diff) ;; diff-command and diff-switches | 332 | (require 'diff) ; diff-command and diff-switches |
| 333 | (error nil)) | 333 | (error nil)) |
| 334 | (condition-case nil | 334 | (condition-case nil |
| 335 | (require 'compile) ;; compilation-error-regexp-alist-alist | 335 | (require 'compile) ; compilation-error-regexp-alist-alist |
| 336 | (error nil)) | 336 | (error nil)) |
| 337 | (condition-case nil | 337 | (condition-case nil |
| 338 | (unless (fboundp 'buffer-chars-modified-tick) ;; Emacs 22 added | 338 | (unless (fboundp 'buffer-chars-modified-tick) ; Emacs 22 added |
| 339 | (defmacro buffer-chars-modified-tick () (buffer-modified-tick))) | 339 | (defmacro buffer-chars-modified-tick () (buffer-modified-tick))) |
| 340 | (error nil)) | 340 | (error nil)) |
| 341 | ;; Added in Emacs 24.1 | 341 | ;; Added in Emacs 24.1 |
| @@ -356,7 +356,7 @@ wherever possible, since it is slow." | |||
| 356 | (defun verilog-easy-menu-filter (menu) | 356 | (defun verilog-easy-menu-filter (menu) |
| 357 | "Filter `easy-menu-define' MENU to support new features." | 357 | "Filter `easy-menu-define' MENU to support new features." |
| 358 | (cond ((not (featurep 'xemacs)) | 358 | (cond ((not (featurep 'xemacs)) |
| 359 | menu) ;; GNU Emacs - passthru | 359 | menu) ; GNU Emacs - passthru |
| 360 | ;; XEmacs doesn't support :help. Strip it. | 360 | ;; XEmacs doesn't support :help. Strip it. |
| 361 | ;; Recursively filter the a submenu | 361 | ;; Recursively filter the a submenu |
| 362 | ((listp menu) | 362 | ((listp menu) |
| @@ -370,7 +370,7 @@ wherever possible, since it is slow." | |||
| 370 | (setq out (vconcat out (vector (aref menu i))) | 370 | (setq out (vconcat out (vector (aref menu i))) |
| 371 | i (1+ i)))) | 371 | i (1+ i)))) |
| 372 | out)) | 372 | out)) |
| 373 | (t menu))) ;; Default - ok | 373 | (t menu))) ; Default - ok |
| 374 | ;;(verilog-easy-menu-filter | 374 | ;;(verilog-easy-menu-filter |
| 375 | ;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) | 375 | ;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) |
| 376 | ;; "----" ["MB" nil :help "Help MB"])) | 376 | ;; "----" ["MB" nil :help "Help MB"])) |
| @@ -439,10 +439,10 @@ Set `verilog-in-hooks' during this time, to assist AUTO caches." | |||
| 439 | :version "22.2" | 439 | :version "22.2" |
| 440 | :group 'languages) | 440 | :group 'languages) |
| 441 | 441 | ||
| 442 | ; (defgroup verilog-mode-fonts nil | 442 | ;; (defgroup verilog-mode-fonts nil |
| 443 | ; "Facilitates easy customization fonts used in Verilog source text" | 443 | ;; "Facilitates easy customization fonts used in Verilog source text" |
| 444 | ; :link '(customize-apropos "font-lock-*" 'faces) | 444 | ;; :link '(customize-apropos "font-lock-*" 'faces) |
| 445 | ; :group 'verilog-mode) | 445 | ;; :group 'verilog-mode) |
| 446 | 446 | ||
| 447 | (defgroup verilog-mode-indent nil | 447 | (defgroup verilog-mode-indent nil |
| 448 | "Customize indentation and highlighting of Verilog source text." | 448 | "Customize indentation and highlighting of Verilog source text." |
| @@ -736,7 +736,7 @@ file referenced. If false, this is not supported." | |||
| 736 | Set this to \"wire\" if the Verilog code uses \"\\=`default_nettype | 736 | Set this to \"wire\" if the Verilog code uses \"\\=`default_nettype |
| 737 | none\". Note using \\=`default_nettype none isn't recommended practice; this | 737 | none\". Note using \\=`default_nettype none isn't recommended practice; this |
| 738 | mode is experimental." | 738 | mode is experimental." |
| 739 | :version "24.1" ;; rev670 | 739 | :version "24.1" ; rev670 |
| 740 | :group 'verilog-mode-actions | 740 | :group 'verilog-mode-actions |
| 741 | :type 'boolean) | 741 | :type 'boolean) |
| 742 | (put 'verilog-auto-declare-nettype 'safe-local-variable `stringp) | 742 | (put 'verilog-auto-declare-nettype 'safe-local-variable `stringp) |
| @@ -744,7 +744,7 @@ mode is experimental." | |||
| 744 | (defcustom verilog-auto-wire-type nil | 744 | (defcustom verilog-auto-wire-type nil |
| 745 | "Non-nil specifies the data type to use with `verilog-auto-wire' etc. | 745 | "Non-nil specifies the data type to use with `verilog-auto-wire' etc. |
| 746 | Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'." | 746 | Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'." |
| 747 | :version "24.1" ;; rev673 | 747 | :version "24.1" ; rev673 |
| 748 | :group 'verilog-mode-actions | 748 | :group 'verilog-mode-actions |
| 749 | :type 'boolean) | 749 | :type 'boolean) |
| 750 | (put 'verilog-auto-wire-type 'safe-local-variable `stringp) | 750 | (put 'verilog-auto-wire-type 'safe-local-variable `stringp) |
| @@ -758,7 +758,7 @@ The name of the function or case will be set between the braces." | |||
| 758 | 758 | ||
| 759 | (defcustom verilog-auto-delete-trailing-whitespace nil | 759 | (defcustom verilog-auto-delete-trailing-whitespace nil |
| 760 | "Non-nil means to `delete-trailing-whitespace' in `verilog-auto'." | 760 | "Non-nil means to `delete-trailing-whitespace' in `verilog-auto'." |
| 761 | :version "24.1" ;; rev703 | 761 | :version "24.1" ; rev703 |
| 762 | :group 'verilog-mode-actions | 762 | :group 'verilog-mode-actions |
| 763 | :type 'boolean) | 763 | :type 'boolean) |
| 764 | (put 'verilog-auto-delete-trailing-whitespace 'safe-local-variable 'verilog-booleanp) | 764 | (put 'verilog-auto-delete-trailing-whitespace 'safe-local-variable 'verilog-booleanp) |
| @@ -827,8 +827,11 @@ Function takes three arguments, the original buffer, the | |||
| 827 | difference buffer, and the point in original buffer with the | 827 | difference buffer, and the point in original buffer with the |
| 828 | first difference.") | 828 | first difference.") |
| 829 | 829 | ||
| 830 | ;;; Compile support | 830 | ;;; Compile support: |
| 831 | ;; | ||
| 832 | |||
| 831 | (require 'compile) | 833 | (require 'compile) |
| 834 | |||
| 832 | (defvar verilog-error-regexp-added nil) | 835 | (defvar verilog-error-regexp-added nil) |
| 833 | 836 | ||
| 834 | (defvar verilog-error-regexp-emacs-alist | 837 | (defvar verilog-error-regexp-emacs-alist |
| @@ -1037,7 +1040,7 @@ If nil, all blocking assigned signals are ignored when any | |||
| 1037 | non-blocking assignment is in the AUTORESET block. This allows | 1040 | non-blocking assignment is in the AUTORESET block. This allows |
| 1038 | blocking assignments to be used for temporary values and not have | 1041 | blocking assignments to be used for temporary values and not have |
| 1039 | those temporaries reset. See example in `verilog-auto-reset'." | 1042 | those temporaries reset. See example in `verilog-auto-reset'." |
| 1040 | :version "24.1" ;; rev718 | 1043 | :version "24.1" ; rev718 |
| 1041 | :type 'boolean | 1044 | :type 'boolean |
| 1042 | :group 'verilog-mode-auto) | 1045 | :group 'verilog-mode-auto) |
| 1043 | (put 'verilog-auto-reset-blocking-in-non 'safe-local-variable 'verilog-booleanp) | 1046 | (put 'verilog-auto-reset-blocking-in-non 'safe-local-variable 'verilog-booleanp) |
| @@ -1146,7 +1149,7 @@ declared together to remain together. Sorted order reduces | |||
| 1146 | changes when declarations are moved around in a file. | 1149 | changes when declarations are moved around in a file. |
| 1147 | 1150 | ||
| 1148 | See also `verilog-auto-arg-sort'." | 1151 | See also `verilog-auto-arg-sort'." |
| 1149 | :version "24.1" ;; rev688 | 1152 | :version "24.1" ; rev688 |
| 1150 | :group 'verilog-mode-auto | 1153 | :group 'verilog-mode-auto |
| 1151 | :type 'boolean) | 1154 | :type 'boolean) |
| 1152 | (put 'verilog-auto-inst-sort 'safe-local-variable 'verilog-booleanp) | 1155 | (put 'verilog-auto-inst-sort 'safe-local-variable 'verilog-booleanp) |
| @@ -1186,7 +1189,7 @@ won't merge conflict." | |||
| 1186 | 1189 | ||
| 1187 | (defcustom verilog-auto-inst-interfaced-ports nil | 1190 | (defcustom verilog-auto-inst-interfaced-ports nil |
| 1188 | "Non-nil means include interfaced ports in AUTOINST expansions." | 1191 | "Non-nil means include interfaced ports in AUTOINST expansions." |
| 1189 | :version "24.3" ;; rev773, default change rev815 | 1192 | :version "24.3" ; rev773, default change rev815 |
| 1190 | :group 'verilog-mode-auto | 1193 | :group 'verilog-mode-auto |
| 1191 | :type 'boolean) | 1194 | :type 'boolean) |
| 1192 | (put 'verilog-auto-inst-interfaced-ports 'safe-local-variable 'verilog-booleanp) | 1195 | (put 'verilog-auto-inst-interfaced-ports 'safe-local-variable 'verilog-booleanp) |
| @@ -1215,7 +1218,7 @@ See the \\[verilog-faq] for examples on using this." | |||
| 1215 | (defcustom verilog-auto-template-warn-unused nil | 1218 | (defcustom verilog-auto-template-warn-unused nil |
| 1216 | "Non-nil means report warning if an AUTO_TEMPLATE line is not used. | 1219 | "Non-nil means report warning if an AUTO_TEMPLATE line is not used. |
| 1217 | This feature is not supported before Emacs 21.1 or XEmacs 21.4." | 1220 | This feature is not supported before Emacs 21.1 or XEmacs 21.4." |
| 1218 | :version "24.3" ;;rev787 | 1221 | :version "24.3" ; rev787 |
| 1219 | :group 'verilog-mode-auto | 1222 | :group 'verilog-mode-auto |
| 1220 | :type 'boolean) | 1223 | :type 'boolean) |
| 1221 | (put 'verilog-auto-template-warn-unused 'safe-local-variable 'verilog-booleanp) | 1224 | (put 'verilog-auto-template-warn-unused 'safe-local-variable 'verilog-booleanp) |
| @@ -1224,7 +1227,7 @@ This feature is not supported before Emacs 21.1 or XEmacs 21.4." | |||
| 1224 | "Data type used for the declaration for AUTOTIEOFF. | 1227 | "Data type used for the declaration for AUTOTIEOFF. |
| 1225 | If \"wire\" then create a wire, if \"assign\" create an | 1228 | If \"wire\" then create a wire, if \"assign\" create an |
| 1226 | assignment, else the data type for variable creation." | 1229 | assignment, else the data type for variable creation." |
| 1227 | :version "24.1" ;; rev713 | 1230 | :version "24.1" ; rev713 |
| 1228 | :group 'verilog-mode-auto | 1231 | :group 'verilog-mode-auto |
| 1229 | :type 'string) | 1232 | :type 'string) |
| 1230 | (put 'verilog-auto-tieoff-declaration 'safe-local-variable 'stringp) | 1233 | (put 'verilog-auto-tieoff-declaration 'safe-local-variable 'stringp) |
| @@ -1296,13 +1299,13 @@ See also `verilog-case-fold'." | |||
| 1296 | 1299 | ||
| 1297 | (defcustom verilog-before-save-font-hook nil | 1300 | (defcustom verilog-before-save-font-hook nil |
| 1298 | "Hook run before `verilog-save-font-mods' removes highlighting." | 1301 | "Hook run before `verilog-save-font-mods' removes highlighting." |
| 1299 | :version "24.3" ;;rev735 | 1302 | :version "24.3" ; rev735 |
| 1300 | :group 'verilog-mode-auto | 1303 | :group 'verilog-mode-auto |
| 1301 | :type 'hook) | 1304 | :type 'hook) |
| 1302 | 1305 | ||
| 1303 | (defcustom verilog-after-save-font-hook nil | 1306 | (defcustom verilog-after-save-font-hook nil |
| 1304 | "Hook run after `verilog-save-font-mods' restores highlighting." | 1307 | "Hook run after `verilog-save-font-mods' restores highlighting." |
| 1305 | :version "24.3" ;;rev735 | 1308 | :version "24.3" ; rev735 |
| 1306 | :group 'verilog-mode-auto | 1309 | :group 'verilog-mode-auto |
| 1307 | :type 'hook) | 1310 | :type 'hook) |
| 1308 | 1311 | ||
| @@ -1330,6 +1333,9 @@ If set will become buffer local.") | |||
| 1330 | If set will become buffer local.") | 1333 | If set will become buffer local.") |
| 1331 | (make-variable-buffer-local 'verilog-project) | 1334 | (make-variable-buffer-local 'verilog-project) |
| 1332 | 1335 | ||
| 1336 | ;;; Keymap and Menu: | ||
| 1337 | ;; | ||
| 1338 | |||
| 1333 | (defvar verilog-mode-map | 1339 | (defvar verilog-mode-map |
| 1334 | (let ((map (make-sparse-keymap))) | 1340 | (let ((map (make-sparse-keymap))) |
| 1335 | (define-key map ";" 'electric-verilog-semi) | 1341 | (define-key map ";" 'electric-verilog-semi) |
| @@ -1697,7 +1703,7 @@ will break, as the o's continuously replace. xa -> x works ok though." | |||
| 1697 | (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) | 1703 | (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) |
| 1698 | ;; checkdoc-params: (REGEXP BOUND NOERROR) | 1704 | ;; checkdoc-params: (REGEXP BOUND NOERROR) |
| 1699 | "Like `re-search-forward', but skips over match in comments or strings." | 1705 | "Like `re-search-forward', but skips over match in comments or strings." |
| 1700 | (let ((mdata '(nil nil))) ;; So match-end will return nil if no matches found | 1706 | (let ((mdata '(nil nil))) ; So match-end will return nil if no matches found |
| 1701 | (while (and | 1707 | (while (and |
| 1702 | (re-search-forward REGEXP BOUND NOERROR) | 1708 | (re-search-forward REGEXP BOUND NOERROR) |
| 1703 | (setq mdata (match-data)) | 1709 | (setq mdata (match-data)) |
| @@ -1713,7 +1719,7 @@ will break, as the o's continuously replace. xa -> x works ok though." | |||
| 1713 | (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) | 1719 | (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
| 1714 | ;; checkdoc-params: (REGEXP BOUND NOERROR) | 1720 | ;; checkdoc-params: (REGEXP BOUND NOERROR) |
| 1715 | "Like `re-search-backward', but skips over match in comments or strings." | 1721 | "Like `re-search-backward', but skips over match in comments or strings." |
| 1716 | (let ((mdata '(nil nil))) ;; So match-end will return nil if no matches found | 1722 | (let ((mdata '(nil nil))) ; So match-end will return nil if no matches found |
| 1717 | (while (and | 1723 | (while (and |
| 1718 | (re-search-backward REGEXP BOUND NOERROR) | 1724 | (re-search-backward REGEXP BOUND NOERROR) |
| 1719 | (setq mdata (match-data)) | 1725 | (setq mdata (match-data)) |
| @@ -1735,7 +1741,7 @@ so there may be a large up front penalty for the first search." | |||
| 1735 | (while (and (not pt) | 1741 | (while (and (not pt) |
| 1736 | (re-search-forward regexp bound noerror)) | 1742 | (re-search-forward regexp bound noerror)) |
| 1737 | (if (verilog-inside-comment-or-string-p) | 1743 | (if (verilog-inside-comment-or-string-p) |
| 1738 | (re-search-forward "[/\"\n]" nil t) ;; Only way a comment or quote can end | 1744 | (re-search-forward "[/\"\n]" nil t) ; Only way a comment or quote can end |
| 1739 | (setq pt (match-end 0)))) | 1745 | (setq pt (match-end 0)))) |
| 1740 | pt)) | 1746 | pt)) |
| 1741 | 1747 | ||
| @@ -1749,7 +1755,7 @@ so there may be a large up front penalty for the first search." | |||
| 1749 | (while (and (not pt) | 1755 | (while (and (not pt) |
| 1750 | (re-search-backward regexp bound noerror)) | 1756 | (re-search-backward regexp bound noerror)) |
| 1751 | (if (verilog-inside-comment-or-string-p) | 1757 | (if (verilog-inside-comment-or-string-p) |
| 1752 | (re-search-backward "[/\"]" nil t) ;; Only way a comment or quote can begin | 1758 | (re-search-backward "[/\"]" nil t) ; Only way a comment or quote can begin |
| 1753 | (setq pt (match-beginning 0)))) | 1759 | (setq pt (match-beginning 0)))) |
| 1754 | pt)) | 1760 | pt)) |
| 1755 | 1761 | ||
| @@ -1771,7 +1777,7 @@ This speeds up complicated regexp matches." | |||
| 1771 | (setq done nil))) | 1777 | (setq done nil))) |
| 1772 | (when done (goto-char done)) | 1778 | (when done (goto-char done)) |
| 1773 | done)) | 1779 | done)) |
| 1774 | ;;(verilog-re-search-forward-substr "-end" "get-end-of" nil t) ;;-end (test bait) | 1780 | ;;(verilog-re-search-forward-substr "-end" "get-end-of" nil t) ; -end (test bait) |
| 1775 | 1781 | ||
| 1776 | (defsubst verilog-re-search-backward-substr (substr regexp bound noerror) | 1782 | (defsubst verilog-re-search-backward-substr (substr regexp bound noerror) |
| 1777 | "Like `re-search-backward', but first search for SUBSTR constant. | 1783 | "Like `re-search-backward', but first search for SUBSTR constant. |
| @@ -1791,7 +1797,7 @@ This speeds up complicated regexp matches." | |||
| 1791 | (setq done nil))) | 1797 | (setq done nil))) |
| 1792 | (when done (goto-char done)) | 1798 | (when done (goto-char done)) |
| 1793 | done)) | 1799 | done)) |
| 1794 | ;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ;;-end (test bait) | 1800 | ;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ; -end (test bait) |
| 1795 | 1801 | ||
| 1796 | (defun verilog-delete-trailing-whitespace () | 1802 | (defun verilog-delete-trailing-whitespace () |
| 1797 | "Delete trailing spaces or tabs, but not newlines nor linefeeds. | 1803 | "Delete trailing spaces or tabs, but not newlines nor linefeeds. |
| @@ -1803,13 +1809,13 @@ To call on \\[verilog-auto], set `verilog-auto-delete-trailing-whitespace'." | |||
| 1803 | ;; Similar to `delete-trailing-whitespace' but that's not present in XEmacs | 1809 | ;; Similar to `delete-trailing-whitespace' but that's not present in XEmacs |
| 1804 | (save-excursion | 1810 | (save-excursion |
| 1805 | (goto-char (point-min)) | 1811 | (goto-char (point-min)) |
| 1806 | (while (re-search-forward "[ \t]+$" nil t) ;; Not syntactic WS as no formfeed | 1812 | (while (re-search-forward "[ \t]+$" nil t) ; Not syntactic WS as no formfeed |
| 1807 | (replace-match "" nil nil)) | 1813 | (replace-match "" nil nil)) |
| 1808 | (goto-char (point-max)) | 1814 | (goto-char (point-max)) |
| 1809 | (unless (bolp) (insert "\n")))) | 1815 | (unless (bolp) (insert "\n")))) |
| 1810 | 1816 | ||
| 1811 | (defvar compile-command) | 1817 | (defvar compile-command) |
| 1812 | (defvar create-lockfiles) ;; Emacs 24 | 1818 | (defvar create-lockfiles) ; Emacs 24 |
| 1813 | 1819 | ||
| 1814 | ;; compilation program | 1820 | ;; compilation program |
| 1815 | (defun verilog-set-compile-command () | 1821 | (defun verilog-set-compile-command () |
| @@ -1867,7 +1873,7 @@ be substituted." | |||
| 1867 | t t command)) | 1873 | t t command)) |
| 1868 | (setq command (verilog-string-replace-matches | 1874 | (setq command (verilog-string-replace-matches |
| 1869 | "\\b__FILE__\\b" (file-name-nondirectory | 1875 | "\\b__FILE__\\b" (file-name-nondirectory |
| 1870 | (or (buffer-file-name) "")) | 1876 | (or (buffer-file-name) "")) |
| 1871 | t t command)) | 1877 | t t command)) |
| 1872 | command) | 1878 | command) |
| 1873 | 1879 | ||
| @@ -1908,35 +1914,34 @@ find the errors." | |||
| 1908 | 1914 | ||
| 1909 | ;; Following code only gets called from compilation-mode-hook on Emacs to add error handling. | 1915 | ;; Following code only gets called from compilation-mode-hook on Emacs to add error handling. |
| 1910 | (defun verilog-error-regexp-add-emacs () | 1916 | (defun verilog-error-regexp-add-emacs () |
| 1911 | "Tell Emacs compile that we are Verilog. | 1917 | "Tell Emacs compile that we are Verilog. |
| 1912 | Called by `compilation-mode-hook'. This allows \\[next-error] to | 1918 | Called by `compilation-mode-hook'. This allows \\[next-error] to |
| 1913 | find the errors." | 1919 | find the errors." |
| 1914 | (interactive) | 1920 | (interactive) |
| 1915 | (if (boundp 'compilation-error-regexp-alist-alist) | 1921 | (when (boundp 'compilation-error-regexp-alist-alist) |
| 1916 | (progn | 1922 | (when (not (assoc 'verilog-xl-1 compilation-error-regexp-alist-alist)) |
| 1917 | (if (not (assoc 'verilog-xl-1 compilation-error-regexp-alist-alist)) | 1923 | (mapcar |
| 1918 | (mapcar | 1924 | (lambda (item) |
| 1919 | (lambda (item) | 1925 | (push (car item) compilation-error-regexp-alist) |
| 1920 | (push (car item) compilation-error-regexp-alist) | 1926 | (push item compilation-error-regexp-alist-alist)) |
| 1921 | (push item compilation-error-regexp-alist-alist) | 1927 | verilog-error-regexp-emacs-alist)))) |
| 1922 | ) | ||
| 1923 | verilog-error-regexp-emacs-alist))))) | ||
| 1924 | 1928 | ||
| 1925 | (if (featurep 'xemacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-xemacs)) | 1929 | (if (featurep 'xemacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-xemacs)) |
| 1926 | (if (featurep 'emacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs)) | 1930 | (if (featurep 'emacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs)) |
| 1927 | 1931 | ||
| 1928 | (defconst verilog-compiler-directives | 1932 | (defconst verilog-compiler-directives |
| 1929 | (eval-when-compile | 1933 | (eval-when-compile |
| 1930 | '( ;; compiler directives, from IEEE 1800-2012 section 22.1 | 1934 | '( |
| 1931 | "`__FILE__" "`__LINE" "`begin_keywords" "`celldefine" "`default_nettype" | 1935 | ;; compiler directives, from IEEE 1800-2012 section 22.1 |
| 1932 | "`define" "`else" "`elsif" "`end_keywords" "`endcelldefine" "`endif" | 1936 | "`__FILE__" "`__LINE" "`begin_keywords" "`celldefine" "`default_nettype" |
| 1933 | "`ifdef" "`ifndef" "`include" "`line" "`nounconnected_drive" "`pragma" | 1937 | "`define" "`else" "`elsif" "`end_keywords" "`endcelldefine" "`endif" |
| 1934 | "`resetall" "`timescale" "`unconnected_drive" "`undef" "`undefineall" | 1938 | "`ifdef" "`ifndef" "`include" "`line" "`nounconnected_drive" "`pragma" |
| 1935 | ;; compiler directives not covered by IEEE 1800 | 1939 | "`resetall" "`timescale" "`unconnected_drive" "`undef" "`undefineall" |
| 1936 | "`case" "`default" "`endfor" "`endprotect" "`endswitch" "`endwhile" "`for" | 1940 | ;; compiler directives not covered by IEEE 1800 |
| 1937 | "`format" "`if" "`let" "`protect" "`switch" "`timescale" "`time_scale" | 1941 | "`case" "`default" "`endfor" "`endprotect" "`endswitch" "`endwhile" "`for" |
| 1938 | "`while" | 1942 | "`format" "`if" "`let" "`protect" "`switch" "`timescale" "`time_scale" |
| 1939 | )) | 1943 | "`while" |
| 1944 | )) | ||
| 1940 | "List of Verilog compiler directives.") | 1945 | "List of Verilog compiler directives.") |
| 1941 | 1946 | ||
| 1942 | (defconst verilog-directive-re | 1947 | (defconst verilog-directive-re |
| @@ -2028,10 +2033,10 @@ find the errors." | |||
| 2028 | (eval-when-compile | 2033 | (eval-when-compile |
| 2029 | (verilog-regexp-opt | 2034 | (verilog-regexp-opt |
| 2030 | '( | 2035 | '( |
| 2031 | ;; "`vmm_xactor_member_enum_array" | ||
| 2032 | "`vmm_\\(data\\|env\\|scenario\\|subenv\\|xactor\\)_member_\\(scalar\\|string\\|enum\\|vmm_data\\|channel\\|xactor\\|subenv\\|user_defined\\)\\(_array\\)?" | 2036 | "`vmm_\\(data\\|env\\|scenario\\|subenv\\|xactor\\)_member_\\(scalar\\|string\\|enum\\|vmm_data\\|channel\\|xactor\\|subenv\\|user_defined\\)\\(_array\\)?" |
| 2033 | ;; "`vmm_xactor_member_scalar_array" | 2037 | ;; "`vmm_xactor_member_enum_array" |
| 2034 | ;; "`vmm_xactor_member_scalar" | 2038 | ;; "`vmm_xactor_member_scalar_array" |
| 2039 | ;; "`vmm_xactor_member_scalar" | ||
| 2035 | ) nil ))) | 2040 | ) nil ))) |
| 2036 | 2041 | ||
| 2037 | (defconst verilog-ovm-statement-re | 2042 | (defconst verilog-ovm-statement-re |
| @@ -2158,9 +2163,9 @@ find the errors." | |||
| 2158 | "`uvm_component_utils" | 2163 | "`uvm_component_utils" |
| 2159 | "`uvm_create" | 2164 | "`uvm_create" |
| 2160 | "`uvm_create_on" | 2165 | "`uvm_create_on" |
| 2161 | "`uvm_create_seq" ;; Undocumented in 1.1 | 2166 | "`uvm_create_seq" ; Undocumented in 1.1 |
| 2162 | "`uvm_declare_p_sequencer" | 2167 | "`uvm_declare_p_sequencer" |
| 2163 | "`uvm_declare_sequence_lib" ;; Deprecated in 1.1 | 2168 | "`uvm_declare_sequence_lib" ; Deprecated in 1.1 |
| 2164 | "`uvm_do" | 2169 | "`uvm_do" |
| 2165 | "`uvm_do_callbacks" | 2170 | "`uvm_do_callbacks" |
| 2166 | "`uvm_do_callbacks_exit_on" | 2171 | "`uvm_do_callbacks_exit_on" |
| @@ -2172,8 +2177,8 @@ find the errors." | |||
| 2172 | "`uvm_do_on_with" | 2177 | "`uvm_do_on_with" |
| 2173 | "`uvm_do_pri" | 2178 | "`uvm_do_pri" |
| 2174 | "`uvm_do_pri_with" | 2179 | "`uvm_do_pri_with" |
| 2175 | "`uvm_do_seq" ;; Undocumented in 1.1 | 2180 | "`uvm_do_seq" ; Undocumented in 1.1 |
| 2176 | "`uvm_do_seq_with" ;; Undocumented in 1.1 | 2181 | "`uvm_do_seq_with" ; Undocumented in 1.1 |
| 2177 | "`uvm_do_with" | 2182 | "`uvm_do_with" |
| 2178 | "`uvm_error" | 2183 | "`uvm_error" |
| 2179 | "`uvm_error_context" | 2184 | "`uvm_error_context" |
| @@ -2215,14 +2220,14 @@ find the errors." | |||
| 2215 | "`uvm_field_sarray_string" | 2220 | "`uvm_field_sarray_string" |
| 2216 | "`uvm_field_string" | 2221 | "`uvm_field_string" |
| 2217 | "`uvm_field_utils" | 2222 | "`uvm_field_utils" |
| 2218 | "`uvm_file" ;; Undocumented in 1.1, use `__FILE__ | 2223 | "`uvm_file" ; Undocumented in 1.1, use `__FILE__ |
| 2219 | "`uvm_get_imp_decl" | 2224 | "`uvm_get_imp_decl" |
| 2220 | "`uvm_get_peek_imp_decl" | 2225 | "`uvm_get_peek_imp_decl" |
| 2221 | "`uvm_info" | 2226 | "`uvm_info" |
| 2222 | "`uvm_info_context" | 2227 | "`uvm_info_context" |
| 2223 | "`uvm_line" ;; Undocumented in 1.1, use `__LINE__ | 2228 | "`uvm_line" ; Undocumented in 1.1, use `__LINE__ |
| 2224 | "`uvm_master_imp_decl" | 2229 | "`uvm_master_imp_decl" |
| 2225 | "`uvm_non_blocking_transport_imp_decl" ;; Deprecated in 1.1 | 2230 | "`uvm_non_blocking_transport_imp_decl" ; Deprecated in 1.1 |
| 2226 | "`uvm_nonblocking_get_imp_decl" | 2231 | "`uvm_nonblocking_get_imp_decl" |
| 2227 | "`uvm_nonblocking_get_peek_imp_decl" | 2232 | "`uvm_nonblocking_get_peek_imp_decl" |
| 2228 | "`uvm_nonblocking_master_imp_decl" | 2233 | "`uvm_nonblocking_master_imp_decl" |
| @@ -2232,7 +2237,7 @@ find the errors." | |||
| 2232 | "`uvm_nonblocking_transport_imp_decl" | 2237 | "`uvm_nonblocking_transport_imp_decl" |
| 2233 | "`uvm_object_param_utils" | 2238 | "`uvm_object_param_utils" |
| 2234 | "`uvm_object_registry" | 2239 | "`uvm_object_registry" |
| 2235 | "`uvm_object_registry_param" ;; Undocumented in 1.1 | 2240 | "`uvm_object_registry_param" ; Undocumented in 1.1 |
| 2236 | "`uvm_object_utils" | 2241 | "`uvm_object_utils" |
| 2237 | "`uvm_pack_array" | 2242 | "`uvm_pack_array" |
| 2238 | "`uvm_pack_arrayN" | 2243 | "`uvm_pack_arrayN" |
| @@ -2257,7 +2262,7 @@ find the errors." | |||
| 2257 | "`uvm_register_cb" | 2262 | "`uvm_register_cb" |
| 2258 | "`uvm_send" | 2263 | "`uvm_send" |
| 2259 | "`uvm_send_pri" | 2264 | "`uvm_send_pri" |
| 2260 | "`uvm_sequence_utils" ;; Deprecated in 1.1 | 2265 | "`uvm_sequence_utils" ; Deprecated in 1.1 |
| 2261 | "`uvm_set_super_type" | 2266 | "`uvm_set_super_type" |
| 2262 | "`uvm_slave_imp_decl" | 2267 | "`uvm_slave_imp_decl" |
| 2263 | "`uvm_transport_imp_decl" | 2268 | "`uvm_transport_imp_decl" |
| @@ -2273,8 +2278,8 @@ find the errors." | |||
| 2273 | "`uvm_unpack_sarray" | 2278 | "`uvm_unpack_sarray" |
| 2274 | "`uvm_unpack_sarrayN" | 2279 | "`uvm_unpack_sarrayN" |
| 2275 | "`uvm_unpack_string" | 2280 | "`uvm_unpack_string" |
| 2276 | "`uvm_update_sequence_lib" ;; Deprecated in 1.1 | 2281 | "`uvm_update_sequence_lib" ; Deprecated in 1.1 |
| 2277 | "`uvm_update_sequence_lib_and_item" ;; Deprecated in 1.1 | 2282 | "`uvm_update_sequence_lib_and_item" ; Deprecated in 1.1 |
| 2278 | "`uvm_warning" | 2283 | "`uvm_warning" |
| 2279 | "`uvm_warning_context") nil ))) | 2284 | "`uvm_warning_context") nil ))) |
| 2280 | 2285 | ||
| @@ -2291,40 +2296,40 @@ find the errors." | |||
| 2291 | ;; b : | 2296 | ;; b : |
| 2292 | (defconst verilog-assignment-operator-re | 2297 | (defconst verilog-assignment-operator-re |
| 2293 | (eval-when-compile | 2298 | (eval-when-compile |
| 2294 | (verilog-regexp-opt | 2299 | (verilog-regexp-opt |
| 2295 | `( | 2300 | `( |
| 2296 | ;; blocking assignment_operator | 2301 | ;; blocking assignment_operator |
| 2297 | "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>=" | 2302 | "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>=" |
| 2298 | ;; non blocking assignment operator | 2303 | ;; non blocking assignment operator |
| 2299 | "<=" | 2304 | "<=" |
| 2300 | ;; comparison | 2305 | ;; comparison |
| 2301 | "==" "!=" "===" "!===" "<=" ">=" "==\?" "!=\?" | 2306 | "==" "!=" "===" "!==" "<=" ">=" "==\?" "!=\?" "<->" |
| 2302 | ;; event_trigger | 2307 | ;; event_trigger |
| 2303 | "->" "->>" | 2308 | "->" "->>" |
| 2304 | ;; property_expr | 2309 | ;; property_expr |
| 2305 | "|->" "|=>" | 2310 | "|->" "|=>" "#-#" "#=#" |
| 2306 | ;; Is this a legal verilog operator? | 2311 | ;; distribution weighting |
| 2307 | ":=" | 2312 | ":=" ":/" |
| 2308 | ) 't | 2313 | ) 't |
| 2309 | ))) | 2314 | ))) |
| 2310 | (defconst verilog-assignment-operation-re | 2315 | (defconst verilog-assignment-operation-re |
| 2311 | (concat | 2316 | (concat |
| 2312 | ; "\\(^\\s-*[A-Za-z0-9_]+\\(\\[\\([A-Za-z0-9_]+\\)\\]\\)*\\s-*\\)" | 2317 | ;; "\\(^\\s-*[A-Za-z0-9_]+\\(\\[\\([A-Za-z0-9_]+\\)\\]\\)*\\s-*\\)" |
| 2313 | ; "\\(^\\s-*[^=<>+-*/%&|^:\\s-]+[^=<>+-*/%&|^\n]*?\\)" | 2318 | ;; "\\(^\\s-*[^=<>+-*/%&|^:\\s-]+[^=<>+-*/%&|^\n]*?\\)" |
| 2314 | "\\(^.*?\\)" "\\B" verilog-assignment-operator-re "\\B" )) | 2319 | "\\(^.*?\\)" "\\B" verilog-assignment-operator-re "\\B" )) |
| 2315 | 2320 | ||
| 2316 | (defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*")) | 2321 | (defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*")) |
| 2317 | (defconst verilog-property-re | 2322 | (defconst verilog-property-re |
| 2318 | (concat "\\(" verilog-label-re "\\)?" | 2323 | (concat "\\(" verilog-label-re "\\)?" |
| 2324 | ;; "\\(assert\\|assume\\|cover\\)\\s-+property\\>" | ||
| 2319 | "\\(\\(assert\\|assume\\|cover\\)\\>\\s-+\\<property\\>\\)\\|\\(assert\\)")) | 2325 | "\\(\\(assert\\|assume\\|cover\\)\\>\\s-+\\<property\\>\\)\\|\\(assert\\)")) |
| 2320 | ;; "\\(assert\\|assume\\|cover\\)\\s-+property\\>" | ||
| 2321 | 2326 | ||
| 2322 | (defconst verilog-no-indent-begin-re | 2327 | (defconst verilog-no-indent-begin-re |
| 2323 | (eval-when-compile | 2328 | (eval-when-compile |
| 2324 | (verilog-regexp-words | 2329 | (verilog-regexp-words |
| 2325 | '("always" "always_comb" "always_ff" "always_latch" "initial" "final" ;; procedural blocks | 2330 | '("always" "always_comb" "always_ff" "always_latch" "initial" "final" ; procedural blocks |
| 2326 | "if" "else" ;; conditional statements | 2331 | "if" "else" ; conditional statements |
| 2327 | "while" "for" "foreach" "repeat" "do" "forever" )))) ;; loop statements | 2332 | "while" "for" "foreach" "repeat" "do" "forever" )))) ; loop statements |
| 2328 | 2333 | ||
| 2329 | (defconst verilog-ends-re | 2334 | (defconst verilog-ends-re |
| 2330 | ;; Parenthesis indicate type of keyword found | 2335 | ;; Parenthesis indicate type of keyword found |
| @@ -2396,8 +2401,8 @@ find the errors." | |||
| 2396 | "package"))) | 2401 | "package"))) |
| 2397 | "\\)")) | 2402 | "\\)")) |
| 2398 | 2403 | ||
| 2399 | ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and | 2404 | ;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and |
| 2400 | ;;; verilog-end-block-ordered-re matches exactly the same strings. | 2405 | ;; verilog-end-block-ordered-re matches exactly the same strings. |
| 2401 | (defconst verilog-end-block-ordered-re | 2406 | (defconst verilog-end-block-ordered-re |
| 2402 | ;; Parenthesis indicate type of keyword found | 2407 | ;; Parenthesis indicate type of keyword found |
| 2403 | (concat "\\(\\<endcase\\>\\)\\|" ; 1 | 2408 | (concat "\\(\\<endcase\\>\\)\\|" ; 1 |
| @@ -2421,9 +2426,9 @@ find the errors." | |||
| 2421 | (eval-when-compile | 2426 | (eval-when-compile |
| 2422 | (verilog-regexp-words | 2427 | (verilog-regexp-words |
| 2423 | 2428 | ||
| 2424 | `("end" ;; closes begin | 2429 | `("end" ; closes begin |
| 2425 | "endcase" ;; closes any of case, casex casez or randcase | 2430 | "endcase" ; closes any of case, casex casez or randcase |
| 2426 | "join" "join_any" "join_none" ;; closes fork | 2431 | "join" "join_any" "join_none" ; closes fork |
| 2427 | "endclass" | 2432 | "endclass" |
| 2428 | "endtable" | 2433 | "endtable" |
| 2429 | "endspecify" | 2434 | "endspecify" |
| @@ -2666,7 +2671,7 @@ find the errors." | |||
| 2666 | (eval-when-compile (verilog-regexp-words `("initial" "final" "always" "always_comb" "always_latch" "always_ff" | 2671 | (eval-when-compile (verilog-regexp-words `("initial" "final" "always" "always_comb" "always_latch" "always_ff" |
| 2667 | "function" "task")))) | 2672 | "function" "task")))) |
| 2668 | (defconst verilog-coverpoint-re "\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)" ) | 2673 | (defconst verilog-coverpoint-re "\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)" ) |
| 2669 | (defconst verilog-in-constraint-re ;; keywords legal in constraint blocks starting a statement/block | 2674 | (defconst verilog-in-constraint-re ; keywords legal in constraint blocks starting a statement/block |
| 2670 | (eval-when-compile (verilog-regexp-words `("if" "else" "solve" "foreach")))) | 2675 | (eval-when-compile (verilog-regexp-words `("if" "else" "solve" "foreach")))) |
| 2671 | 2676 | ||
| 2672 | (defconst verilog-indent-re | 2677 | (defconst verilog-indent-re |
| @@ -2676,7 +2681,7 @@ find the errors." | |||
| 2676 | "{" | 2681 | "{" |
| 2677 | "always" "always_latch" "always_ff" "always_comb" | 2682 | "always" "always_latch" "always_ff" "always_comb" |
| 2678 | "begin" "end" | 2683 | "begin" "end" |
| 2679 | ; "unique" "priority" | 2684 | ;; "unique" "priority" |
| 2680 | "case" "casex" "casez" "randcase" "endcase" | 2685 | "case" "casex" "casez" "randcase" "endcase" |
| 2681 | "class" "endclass" | 2686 | "class" "endclass" |
| 2682 | "clocking" "endclocking" | 2687 | "clocking" "endclocking" |
| @@ -2734,7 +2739,7 @@ find the errors." | |||
| 2734 | "`uvm_sequence_utils_begin" | 2739 | "`uvm_sequence_utils_begin" |
| 2735 | "`uvm_sequencer_utils_begin" | 2740 | "`uvm_sequencer_utils_begin" |
| 2736 | ;; UVM End tokens | 2741 | ;; UVM End tokens |
| 2737 | "`uvm_component_utils_end" ;; Typo in spec, it's not uvm_component_end | 2742 | "`uvm_component_utils_end" ; Typo in spec, it's not uvm_component_end |
| 2738 | "`uvm_field_utils_end" | 2743 | "`uvm_field_utils_end" |
| 2739 | "`uvm_object_utils_end" | 2744 | "`uvm_object_utils_end" |
| 2740 | "`uvm_sequence_utils_end" | 2745 | "`uvm_sequence_utils_end" |
| @@ -2780,12 +2785,18 @@ find the errors." | |||
| 2780 | `( | 2785 | `( |
| 2781 | "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" | 2786 | "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" |
| 2782 | )))) | 2787 | )))) |
| 2788 | |||
| 2789 | (defconst verilog-dpi-import-export-re | ||
| 2790 | (eval-when-compile | ||
| 2791 | "\\(\\<\\(import\\|export\\)\\>\\s-+\"DPI\\(-C\\)?\"\\s-+\\(\\<\\(context\\|pure\\)\\>\\s-+\\)?\\([A-Za-z_][A-Za-z0-9_]*\\s-*=\\s-*\\)?\\<\\(function\\|task\\)\\>\\)" | ||
| 2792 | )) | ||
| 2793 | |||
| 2783 | (defconst verilog-disable-fork-re "\\(disable\\|wait\\)\\s-+fork\\>") | 2794 | (defconst verilog-disable-fork-re "\\(disable\\|wait\\)\\s-+fork\\>") |
| 2784 | (defconst verilog-extended-case-re "\\(\\(unique0?\\s-+\\|priority\\s-+\\)?case[xz]?\\)") | 2795 | (defconst verilog-extended-case-re "\\(\\(unique0?\\s-+\\|priority\\s-+\\)?case[xz]?\\)") |
| 2785 | (defconst verilog-extended-complete-re | 2796 | (defconst verilog-extended-complete-re |
| 2786 | (concat "\\(\\(\\<extern\\s-+\\|\\<\\(\\<\\(pure\\|context\\)\\>\\s-+\\)?virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)\\)" | 2797 | (concat "\\(\\(\\<extern\\s-+\\|\\<\\(\\<\\(pure\\|context\\)\\>\\s-+\\)?virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)\\)" |
| 2787 | "\\|\\(\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)\\)" | 2798 | "\\|\\(\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)\\)" |
| 2788 | "\\|\\(\\(\\<import\\>\\s-+\\)?\\(\"DPI-C\"\\s-+\\)?\\(\\<\\(pure\\|context\\)\\>\\s-+\\)?\\([A-Za-z_][A-Za-z0-9_]*\\s-+=\\s-+\\)?\\(function\\>\\|task\\>\\)\\)" | 2799 | "\\|\\(\\(\\<\\(import\\|export\\)\\>\\s-+\\)?\\(\"DPI\\(-C\\)?\"\\s-+\\)?\\(\\<\\(pure\\|context\\)\\>\\s-+\\)?\\([A-Za-z_][A-Za-z0-9_]*\\s-*=\\s-*\\)?\\(function\\>\\|task\\>\\)\\)" |
| 2789 | "\\|" verilog-extended-case-re )) | 2800 | "\\|" verilog-extended-case-re )) |
| 2790 | (defconst verilog-basic-complete-re | 2801 | (defconst verilog-basic-complete-re |
| 2791 | (eval-when-compile | 2802 | (eval-when-compile |
| @@ -2848,10 +2859,10 @@ find the errors." | |||
| 2848 | "\\)\\|\\(?:" | 2859 | "\\)\\|\\(?:" |
| 2849 | ;; `define and `if can span multiple lines if line ends in '\'. NOTE: `if is not IEEE 1800-2012 | 2860 | ;; `define and `if can span multiple lines if line ends in '\'. NOTE: `if is not IEEE 1800-2012 |
| 2850 | ;; from http://www.emacswiki.org/emacs/MultilineRegexp | 2861 | ;; from http://www.emacswiki.org/emacs/MultilineRegexp |
| 2851 | (concat "\\<\\(`define\\|`if\\)\\>" ;; directive | 2862 | (concat "\\<\\(`define\\|`if\\)\\>" ; directive |
| 2852 | "\\s-+" ;; separator | 2863 | "\\s-+" ; separator |
| 2853 | "\\(?:.*?\\(?:\n.*\\)*?\\)" ;; definition: to end of line, then maybe more lines (excludes any trailing \n) | 2864 | "\\(?:.*?\\(?:\n.*\\)*?\\)" ; definition: to end of line, then maybe more lines (excludes any trailing \n) |
| 2854 | "\\(?:\n\\s-*\n\\|\\'\\)") ;; blank line or EOF | 2865 | "\\(?:\n\\s-*\n\\|\\'\\)") ; blank line or EOF |
| 2855 | "\\)\\|\\(?:" | 2866 | "\\)\\|\\(?:" |
| 2856 | ;; `<macro>() : i.e. `uvm_info(a,b,c) or any other pre-defined macro | 2867 | ;; `<macro>() : i.e. `uvm_info(a,b,c) or any other pre-defined macro |
| 2857 | ;; Since parameters inside the macro can have parentheses, and | 2868 | ;; Since parameters inside the macro can have parentheses, and |
| @@ -2859,56 +2870,56 @@ find the errors." | |||
| 2859 | ;; parentheses and then continue to the end of the first | 2870 | ;; parentheses and then continue to the end of the first |
| 2860 | ;; non-escaped EOL | 2871 | ;; non-escaped EOL |
| 2861 | (concat "\\<`\\w+\\>\\s-*(" | 2872 | (concat "\\<`\\w+\\>\\s-*(" |
| 2862 | "\\(?:.*?\\(?:\n.*\\)*?\\)" ;; definition: to end of line, then maybe more lines (excludes any trailing \n) | 2873 | "\\(?:.*?\\(?:\n.*\\)*?\\)" ; definition: to end of line, then maybe more lines (excludes any trailing \n) |
| 2863 | "\\(?:\n\\s-*\n\\|\\'\\)") ;; blank line or EOF | 2874 | "\\(?:\n\\s-*\n\\|\\'\\)") ; blank line or EOF |
| 2864 | "\\)" | 2875 | "\\)" |
| 2865 | ))) | 2876 | ))) |
| 2866 | 2877 | ||
| 2867 | (defconst verilog-keywords | 2878 | (defconst verilog-keywords |
| 2868 | (append verilog-compiler-directives | 2879 | (append verilog-compiler-directives |
| 2869 | '( | 2880 | '( |
| 2870 | "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" | 2881 | "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" |
| 2871 | "assert" "assign" "assume" "automatic" "before" "begin" "bind" | 2882 | "assert" "assign" "assume" "automatic" "before" "begin" "bind" |
| 2872 | "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" | 2883 | "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" |
| 2873 | "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" | 2884 | "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" |
| 2874 | "config" "const" "constraint" "context" "continue" "cover" | 2885 | "config" "const" "constraint" "context" "continue" "cover" |
| 2875 | "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" | 2886 | "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" |
| 2876 | "design" "disable" "dist" "do" "edge" "else" "end" "endcase" | 2887 | "design" "disable" "dist" "do" "edge" "else" "end" "endcase" |
| 2877 | "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" | 2888 | "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" |
| 2878 | "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" | 2889 | "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" |
| 2879 | "endprogram" "endproperty" "endspecify" "endsequence" "endtable" | 2890 | "endprogram" "endproperty" "endspecify" "endsequence" "endtable" |
| 2880 | "endtask" "enum" "event" "expect" "export" "extends" "extern" | 2891 | "endtask" "enum" "event" "expect" "export" "extends" "extern" |
| 2881 | "final" "first_match" "for" "force" "foreach" "forever" "fork" | 2892 | "final" "first_match" "for" "force" "foreach" "forever" "fork" |
| 2882 | "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" | 2893 | "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" |
| 2883 | "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" | 2894 | "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" |
| 2884 | "include" "initial" "inout" "input" "inside" "instance" "int" | 2895 | "include" "initial" "inout" "input" "inside" "instance" "int" |
| 2885 | "integer" "interface" "intersect" "join" "join_any" "join_none" | 2896 | "integer" "interface" "intersect" "join" "join_any" "join_none" |
| 2886 | "large" "liblist" "library" "local" "localparam" "logic" | 2897 | "large" "liblist" "library" "local" "localparam" "logic" |
| 2887 | "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" | 2898 | "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" |
| 2888 | "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" | 2899 | "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" |
| 2889 | "notif0" "notif1" "null" "or" "output" "package" "packed" | 2900 | "notif0" "notif1" "null" "or" "output" "package" "packed" |
| 2890 | "parameter" "pmos" "posedge" "primitive" "priority" "program" | 2901 | "parameter" "pmos" "posedge" "primitive" "priority" "program" |
| 2891 | "property" "protected" "pull0" "pull1" "pulldown" "pullup" | 2902 | "property" "protected" "pull0" "pull1" "pulldown" "pullup" |
| 2892 | "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | 2903 | "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" |
| 2893 | "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" | 2904 | "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" |
| 2894 | "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" | 2905 | "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" |
| 2895 | "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" | 2906 | "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" |
| 2896 | "showcancelled" "signed" "small" "solve" "specify" "specparam" | 2907 | "showcancelled" "signed" "small" "solve" "specify" "specparam" |
| 2897 | "static" "string" "strong0" "strong1" "struct" "super" "supply0" | 2908 | "static" "string" "strong0" "strong1" "struct" "super" "supply0" |
| 2898 | "supply1" "table" "tagged" "task" "this" "throughout" "time" | 2909 | "supply1" "table" "tagged" "task" "this" "throughout" "time" |
| 2899 | "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" | 2910 | "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" |
| 2900 | "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" | 2911 | "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" |
| 2901 | "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" | 2912 | "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" |
| 2902 | "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | 2913 | "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" |
| 2903 | "wire" "with" "within" "wor" "xnor" "xor" | 2914 | "wire" "with" "within" "wor" "xnor" "xor" |
| 2904 | ;; 1800-2009 | 2915 | ;; 1800-2009 |
| 2905 | "accept_on" "checker" "endchecker" "eventually" "global" "implies" | 2916 | "accept_on" "checker" "endchecker" "eventually" "global" "implies" |
| 2906 | "let" "nexttime" "reject_on" "restrict" "s_always" "s_eventually" | 2917 | "let" "nexttime" "reject_on" "restrict" "s_always" "s_eventually" |
| 2907 | "s_nexttime" "s_until" "s_until_with" "strong" "sync_accept_on" | 2918 | "s_nexttime" "s_until" "s_until_with" "strong" "sync_accept_on" |
| 2908 | "sync_reject_on" "unique0" "until" "until_with" "untyped" "weak" | 2919 | "sync_reject_on" "unique0" "until" "until_with" "untyped" "weak" |
| 2909 | ;; 1800-2012 | 2920 | ;; 1800-2012 |
| 2910 | "implements" "interconnect" "nettype" "soft" | 2921 | "implements" "interconnect" "nettype" "soft" |
| 2911 | )) | 2922 | )) |
| 2912 | "List of Verilog keywords.") | 2923 | "List of Verilog keywords.") |
| 2913 | 2924 | ||
| 2914 | (defconst verilog-comment-start-regexp "//\\|/\\*" | 2925 | (defconst verilog-comment-start-regexp "//\\|/\\*" |
| @@ -2928,7 +2939,7 @@ find the errors." | |||
| 2928 | (modify-syntax-entry ?| "." table) | 2939 | (modify-syntax-entry ?| "." table) |
| 2929 | ;; FIXME: This goes against Emacs conventions. Use "_" syntax instead and | 2940 | ;; FIXME: This goes against Emacs conventions. Use "_" syntax instead and |
| 2930 | ;; then use regexps with things like "\\_<...\\_>". | 2941 | ;; then use regexps with things like "\\_<...\\_>". |
| 2931 | (modify-syntax-entry ?` "w" table) ;; ` is part of definition symbols in Verilog | 2942 | (modify-syntax-entry ?` "w" table) ; ` is part of definition symbols in Verilog |
| 2932 | (modify-syntax-entry ?_ "w" table) | 2943 | (modify-syntax-entry ?_ "w" table) |
| 2933 | (modify-syntax-entry ?\' "." table) | 2944 | (modify-syntax-entry ?\' "." table) |
| 2934 | 2945 | ||
| @@ -3119,9 +3130,9 @@ See also `verilog-font-lock-extra-types'.") | |||
| 3119 | (list | 3130 | (list |
| 3120 | ;; Fontify all builtin keywords | 3131 | ;; Fontify all builtin keywords |
| 3121 | (concat "\\<\\(" verilog-font-keywords "\\|" | 3132 | (concat "\\<\\(" verilog-font-keywords "\\|" |
| 3122 | ;; And user/system tasks and functions | 3133 | ;; And user/system tasks and functions |
| 3123 | "\\$[a-zA-Z][a-zA-Z0-9_\\$]*" | 3134 | "\\$[a-zA-Z][a-zA-Z0-9_\\$]*" |
| 3124 | "\\)\\>") | 3135 | "\\)\\>") |
| 3125 | ;; Fontify all types | 3136 | ;; Fontify all types |
| 3126 | (if verilog-highlight-grouping-keywords | 3137 | (if verilog-highlight-grouping-keywords |
| 3127 | (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") | 3138 | (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
| @@ -3129,7 +3140,7 @@ See also `verilog-font-lock-extra-types'.") | |||
| 3129 | (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") | 3140 | (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
| 3130 | 'font-lock-type-face)) | 3141 | 'font-lock-type-face)) |
| 3131 | (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>") | 3142 | (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>") |
| 3132 | 'font-lock-type-face) | 3143 | 'font-lock-type-face) |
| 3133 | ;; Fontify IEEE-1800-2005 keywords appropriately | 3144 | ;; Fontify IEEE-1800-2005 keywords appropriately |
| 3134 | (if verilog-highlight-p1800-keywords | 3145 | (if verilog-highlight-p1800-keywords |
| 3135 | (cons (concat "\\<\\(" verilog-1800-2005-keywords "\\)\\>") | 3146 | (cons (concat "\\<\\(" verilog-1800-2005-keywords "\\)\\>") |
| @@ -3163,8 +3174,8 @@ See also `verilog-font-lock-extra-types'.") | |||
| 3163 | ;; Fontify function definitions | 3174 | ;; Fontify function definitions |
| 3164 | (list | 3175 | (list |
| 3165 | (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | 3176 | (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) |
| 3166 | '(1 font-lock-keyword-face) | 3177 | '(1 font-lock-keyword-face) |
| 3167 | '(3 font-lock-constant-face prepend)) | 3178 | '(3 font-lock-constant-face prepend)) |
| 3168 | '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" | 3179 | '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
| 3169 | (1 font-lock-keyword-face) | 3180 | (1 font-lock-keyword-face) |
| 3170 | (2 font-lock-constant-face append)) | 3181 | (2 font-lock-constant-face append)) |
| @@ -3180,11 +3191,14 @@ See also `verilog-font-lock-extra-types'.") | |||
| 3180 | '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) | 3191 | '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) |
| 3181 | ;; Fontify macro definitions/ uses | 3192 | ;; Fontify macro definitions/ uses |
| 3182 | '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) | 3193 | '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) |
| 3183 | 'font-lock-preprocessor-face | 3194 | 'font-lock-preprocessor-face |
| 3184 | 'font-lock-type-face)) | 3195 | 'font-lock-type-face)) |
| 3185 | ;; Fontify delays/numbers | 3196 | ;; Fontify delays/numbers |
| 3186 | '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | 3197 | '("\\(@\\)\\|\\([ \t\n\f\r]#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" |
| 3187 | 0 font-lock-type-face append) | 3198 | 0 font-lock-type-face append) |
| 3199 | ;; Fontify property/sequence cycle delays - these start with '##' | ||
| 3200 | '("\\(##\\(\\sw+\\|\\[[^\]]+\\]\\)\\)" | ||
| 3201 | 0 font-lock-type-face append) | ||
| 3188 | ;; Fontify instantiation names | 3202 | ;; Fontify instantiation names |
| 3189 | '("\\([A-Za-z][A-Za-z0-9_]*\\)\\s-*(" 1 font-lock-function-name-face) | 3203 | '("\\([A-Za-z][A-Za-z0-9_]*\\)\\s-*(" 1 font-lock-function-name-face) |
| 3190 | ))) | 3204 | ))) |
| @@ -3257,10 +3271,10 @@ to full text form for parsing. Additional actions may be specified with | |||
| 3257 | (font-lock-mode 0) | 3271 | (font-lock-mode 0) |
| 3258 | t))) | 3272 | t))) |
| 3259 | (unwind-protect | 3273 | (unwind-protect |
| 3260 | (progn ,@body) | 3274 | (progn ,@body) |
| 3261 | ;; Unwind forms | 3275 | ;; Unwind forms |
| 3262 | (when fontlocked (font-lock-mode t)) | 3276 | (when fontlocked (font-lock-mode t)) |
| 3263 | (when hooked (verilog-run-hooks 'verilog-after-save-font-hook))))) | 3277 | (when hooked (verilog-run-hooks 'verilog-after-save-font-hook))))) |
| 3264 | 3278 | ||
| 3265 | ;; | 3279 | ;; |
| 3266 | ;; Comment detection and caching | 3280 | ;; Comment detection and caching |
| @@ -3292,7 +3306,7 @@ This requires that insertions must use `verilog-insert'." | |||
| 3292 | ;; Note this must work properly if there's multiple layers of calls | 3306 | ;; Note this must work properly if there's multiple layers of calls |
| 3293 | ;; to verilog-save-scan-cache even with differing ticks. | 3307 | ;; to verilog-save-scan-cache even with differing ticks. |
| 3294 | `(progn | 3308 | `(progn |
| 3295 | (unless (verilog-scan-cache-ok-p) ;; Must be before let | 3309 | (unless (verilog-scan-cache-ok-p) ; Must be before let |
| 3296 | (setq verilog-scan-cache-tick nil)) | 3310 | (setq verilog-scan-cache-tick nil)) |
| 3297 | (let* ((verilog-scan-cache-preserving (current-buffer))) | 3311 | (let* ((verilog-scan-cache-preserving (current-buffer))) |
| 3298 | (progn ,@body)))) | 3312 | (progn ,@body)))) |
| @@ -3330,7 +3344,7 @@ This creates v-cmts properties where comments are in force." | |||
| 3330 | (put-text-property (1+ pt) (point) 'v-cmts t)) | 3344 | (put-text-property (1+ pt) (point) 'v-cmts t)) |
| 3331 | ((looking-at "\"") | 3345 | ((looking-at "\"") |
| 3332 | (setq pt (point)) | 3346 | (setq pt (point)) |
| 3333 | (or (re-search-forward "[^\\]\"" end t) ;; don't forward-char first, since we look for a non backslash first | 3347 | (or (re-search-forward "[^\\]\"" end t) ; don't forward-char first, since we look for a non backslash first |
| 3334 | ;; No error - let later code indicate it so we can | 3348 | ;; No error - let later code indicate it so we can |
| 3335 | (goto-char end)) | 3349 | (goto-char end)) |
| 3336 | (put-text-property (1+ pt) (point) 'v-cmts t)) | 3350 | (put-text-property (1+ pt) (point) 'v-cmts t)) |
| @@ -3348,14 +3362,14 @@ either is ok to parse as a non-comment, or `verilog-insert' was used." | |||
| 3348 | (unless (verilog-scan-cache-ok-p) | 3362 | (unless (verilog-scan-cache-ok-p) |
| 3349 | (save-excursion | 3363 | (save-excursion |
| 3350 | (verilog-save-buffer-state | 3364 | (verilog-save-buffer-state |
| 3351 | (when verilog-debug | 3365 | (when verilog-debug |
| 3352 | (message "Scanning %s cache=%s cachetick=%S tick=%S" (current-buffer) | 3366 | (message "Scanning %s cache=%s cachetick=%S tick=%S" (current-buffer) |
| 3353 | verilog-scan-cache-preserving verilog-scan-cache-tick | 3367 | verilog-scan-cache-preserving verilog-scan-cache-tick |
| 3354 | (buffer-chars-modified-tick))) | 3368 | (buffer-chars-modified-tick))) |
| 3355 | (remove-text-properties (point-min) (point-max) '(v-cmts nil)) | 3369 | (remove-text-properties (point-min) (point-max) '(v-cmts nil)) |
| 3356 | (verilog-scan-region (point-min) (point-max)) | 3370 | (verilog-scan-region (point-min) (point-max)) |
| 3357 | (setq verilog-scan-cache-tick (buffer-chars-modified-tick)) | 3371 | (setq verilog-scan-cache-tick (buffer-chars-modified-tick)) |
| 3358 | (when verilog-debug (message "Scanning... done")))))) | 3372 | (when verilog-debug (message "Scanning... done")))))) |
| 3359 | 3373 | ||
| 3360 | (defun verilog-scan-debug () | 3374 | (defun verilog-scan-debug () |
| 3361 | "For debugging, show with display face results of `verilog-scan'." | 3375 | "For debugging, show with display face results of `verilog-scan'." |
| @@ -3427,13 +3441,13 @@ Use filename, if current buffer being edited shorten to just buffer name." | |||
| 3427 | ;; before that see if we are in a comment | 3441 | ;; before that see if we are in a comment |
| 3428 | (verilog-forward-sexp)) | 3442 | (verilog-forward-sexp)) |
| 3429 | 3443 | ||
| 3430 | ;;;used by hs-minor-mode | ||
| 3431 | (defun verilog-forward-sexp-function (arg) | 3444 | (defun verilog-forward-sexp-function (arg) |
| 3445 | "Move forward a sexp." | ||
| 3446 | ;; Used by hs-minor-mode | ||
| 3432 | (if (< arg 0) | 3447 | (if (< arg 0) |
| 3433 | (verilog-backward-sexp) | 3448 | (verilog-backward-sexp) |
| 3434 | (verilog-forward-sexp))) | 3449 | (verilog-forward-sexp))) |
| 3435 | 3450 | ||
| 3436 | |||
| 3437 | (defun verilog-backward-sexp () | 3451 | (defun verilog-backward-sexp () |
| 3438 | (let ((reg) | 3452 | (let ((reg) |
| 3439 | (elsec 1) | 3453 | (elsec 1) |
| @@ -3504,7 +3518,7 @@ Use filename, if current buffer being edited shorten to just buffer name." | |||
| 3504 | ((match-end 2) | 3518 | ((match-end 2) |
| 3505 | ;; Search forward for matching endcase | 3519 | ;; Search forward for matching endcase |
| 3506 | (setq reg "\\(\\<randcase\\>\\|\\(\\<unique0?\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ) | 3520 | (setq reg "\\(\\<randcase\\>\\|\\(\\<unique0?\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ) |
| 3507 | (setq md 3) ;; ender is third item in regexp | 3521 | (setq md 3) ; ender is third item in regexp |
| 3508 | ) | 3522 | ) |
| 3509 | ((match-end 4) | 3523 | ((match-end 4) |
| 3510 | ;; might be "disable fork" or "wait fork" | 3524 | ;; might be "disable fork" or "wait fork" |
| @@ -3514,15 +3528,15 @@ Use filename, if current buffer being edited shorten to just buffer name." | |||
| 3514 | (looking-at verilog-disable-fork-re) | 3528 | (looking-at verilog-disable-fork-re) |
| 3515 | (and (looking-at "fork") | 3529 | (and (looking-at "fork") |
| 3516 | (progn | 3530 | (progn |
| 3517 | (setq here (point)) ;; sometimes a fork is just a fork | 3531 | (setq here (point)) ; sometimes a fork is just a fork |
| 3518 | (forward-word -1) | 3532 | (forward-word -1) |
| 3519 | (looking-at verilog-disable-fork-re)))) | 3533 | (looking-at verilog-disable-fork-re)))) |
| 3520 | (progn ;; it is a disable fork; ignore it | 3534 | (progn ; it is a disable fork; ignore it |
| 3521 | (goto-char (match-end 0)) | 3535 | (goto-char (match-end 0)) |
| 3522 | (forward-word 1) | 3536 | (forward-word 1) |
| 3523 | (setq reg nil)) | 3537 | (setq reg nil)) |
| 3524 | (progn ;; it is a nice simple fork | 3538 | (progn ; it is a nice simple fork |
| 3525 | (goto-char here) ;; return from looking for "disable fork" | 3539 | (goto-char here) ; return from looking for "disable fork" |
| 3526 | ;; Search forward for matching join | 3540 | ;; Search forward for matching join |
| 3527 | (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))))) | 3541 | (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))))) |
| 3528 | ((match-end 6) | 3542 | ((match-end 6) |
| @@ -3533,41 +3547,41 @@ Use filename, if current buffer being edited shorten to just buffer name." | |||
| 3533 | ;; Search forward for matching endtable | 3547 | ;; Search forward for matching endtable |
| 3534 | (setq reg "\\<endtable\\>" ) | 3548 | (setq reg "\\<endtable\\>" ) |
| 3535 | (setq nest 'no)) | 3549 | (setq nest 'no)) |
| 3536 | ((match-end 8) | 3550 | ((match-end 8) |
| 3537 | ;; Search forward for matching endspecify | 3551 | ;; Search forward for matching endspecify |
| 3538 | (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | 3552 | (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) |
| 3539 | ((match-end 9) | 3553 | ((match-end 9) |
| 3540 | ;; Search forward for matching endfunction | 3554 | ;; Search forward for matching endfunction |
| 3541 | (setq reg "\\<endfunction\\>" ) | 3555 | (setq reg "\\<endfunction\\>" ) |
| 3542 | (setq nest 'no)) | 3556 | (setq nest 'no)) |
| 3543 | ((match-end 10) | 3557 | ((match-end 10) |
| 3544 | ;; Search forward for matching endfunction | 3558 | ;; Search forward for matching endfunction |
| 3545 | (setq reg "\\<endfunction\\>" ) | 3559 | (setq reg "\\<endfunction\\>" ) |
| 3546 | (setq nest 'no)) | 3560 | (setq nest 'no)) |
| 3547 | ((match-end 14) | 3561 | ((match-end 14) |
| 3548 | ;; Search forward for matching endtask | 3562 | ;; Search forward for matching endtask |
| 3549 | (setq reg "\\<endtask\\>" ) | 3563 | (setq reg "\\<endtask\\>" ) |
| 3550 | (setq nest 'no)) | 3564 | (setq nest 'no)) |
| 3551 | ((match-end 15) | 3565 | ((match-end 15) |
| 3552 | ;; Search forward for matching endtask | 3566 | ;; Search forward for matching endtask |
| 3553 | (setq reg "\\<endtask\\>" ) | 3567 | (setq reg "\\<endtask\\>" ) |
| 3554 | (setq nest 'no)) | 3568 | (setq nest 'no)) |
| 3555 | ((match-end 19) | 3569 | ((match-end 19) |
| 3556 | ;; Search forward for matching endgenerate | 3570 | ;; Search forward for matching endgenerate |
| 3557 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | 3571 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) |
| 3558 | ((match-end 20) | 3572 | ((match-end 20) |
| 3559 | ;; Search forward for matching endgroup | 3573 | ;; Search forward for matching endgroup |
| 3560 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | 3574 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) |
| 3561 | ((match-end 21) | 3575 | ((match-end 21) |
| 3562 | ;; Search forward for matching endproperty | 3576 | ;; Search forward for matching endproperty |
| 3563 | (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | 3577 | (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) |
| 3564 | ((match-end 25) | 3578 | ((match-end 25) |
| 3565 | ;; Search forward for matching endsequence | 3579 | ;; Search forward for matching endsequence |
| 3566 | (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | 3580 | (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) |
| 3567 | (setq md 3)) ; 3 to get to endsequence in the reg above | 3581 | (setq md 3)) ; 3 to get to endsequence in the reg above |
| 3568 | ((match-end 27) | 3582 | ((match-end 27) |
| 3569 | ;; Search forward for matching endclocking | 3583 | ;; Search forward for matching endclocking |
| 3570 | (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) | 3584 | (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) |
| 3571 | (if (and reg | 3585 | (if (and reg |
| 3572 | (forward-word 1)) | 3586 | (forward-word 1)) |
| 3573 | (catch 'skip | 3587 | (catch 'skip |
| @@ -3590,9 +3604,9 @@ Use filename, if current buffer being edited shorten to just buffer name." | |||
| 3590 | (progn | 3604 | (progn |
| 3591 | (forward-word -1) | 3605 | (forward-word -1) |
| 3592 | (looking-at verilog-disable-fork-re)))) | 3606 | (looking-at verilog-disable-fork-re)))) |
| 3593 | (progn ;; it is a disable fork; another false alarm | 3607 | (progn ; it is a disable fork; another false alarm |
| 3594 | (goto-char (match-end 0))) | 3608 | (goto-char (match-end 0))) |
| 3595 | (progn ;; it is a simple fork (or has nothing to do with fork) | 3609 | (progn ; it is a simple fork (or has nothing to do with fork) |
| 3596 | (goto-char here) | 3610 | (goto-char here) |
| 3597 | (setq depth (1+ depth)))))))))) | 3611 | (setq depth (1+ depth)))))))))) |
| 3598 | (if (verilog-re-search-forward reg nil 'move) | 3612 | (if (verilog-re-search-forward reg nil 'move) |
| @@ -3787,7 +3801,7 @@ Key bindings specific to `verilog-mode-map' are: | |||
| 3787 | (setq verilog-which-tool 1) | 3801 | (setq verilog-which-tool 1) |
| 3788 | (setq verilog-tool 'verilog-linter) | 3802 | (setq verilog-tool 'verilog-linter) |
| 3789 | (verilog-set-compile-command) | 3803 | (verilog-set-compile-command) |
| 3790 | (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables | 3804 | (when (boundp 'hack-local-variables-hook) ; Also modify any file-local-variables |
| 3791 | (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) | 3805 | (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) |
| 3792 | 3806 | ||
| 3793 | ;; Setting up menus | 3807 | ;; Setting up menus |
| @@ -3813,7 +3827,7 @@ Key bindings specific to `verilog-mode-map' are: | |||
| 3813 | ;;------------------------------------------------------------ | 3827 | ;;------------------------------------------------------------ |
| 3814 | ;; now hook in 'verilog-highlight-include-files (eldo-mode.el&spice-mode.el) | 3828 | ;; now hook in 'verilog-highlight-include-files (eldo-mode.el&spice-mode.el) |
| 3815 | ;; all buffer local: | 3829 | ;; all buffer local: |
| 3816 | (unless noninteractive ;; Else can't see the result, and change hooks are slow | 3830 | (unless noninteractive ; Else can't see the result, and change hooks are slow |
| 3817 | (when (featurep 'xemacs) | 3831 | (when (featurep 'xemacs) |
| 3818 | (make-local-hook 'font-lock-mode-hook) | 3832 | (make-local-hook 'font-lock-mode-hook) |
| 3819 | (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs | 3833 | (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs |
| @@ -3841,10 +3855,9 @@ Key bindings specific to `verilog-mode-map' are: | |||
| 3841 | ;; verilog-mode-hook call added by define-derived-mode | 3855 | ;; verilog-mode-hook call added by define-derived-mode |
| 3842 | ) | 3856 | ) |
| 3843 | 3857 | ||
| 3844 | 3858 | ;;; Electric functions: | |
| 3845 | ;; | ||
| 3846 | ;; Electric functions | ||
| 3847 | ;; | 3859 | ;; |
| 3860 | |||
| 3848 | (defun electric-verilog-terminate-line (&optional arg) | 3861 | (defun electric-verilog-terminate-line (&optional arg) |
| 3849 | "Terminate line and indent next line. | 3862 | "Terminate line and indent next line. |
| 3850 | With optional ARG, remove existing end of line comments." | 3863 | With optional ARG, remove existing end of line comments." |
| @@ -3866,36 +3879,36 @@ With optional ARG, remove existing end of line comments." | |||
| 3866 | (newline) | 3879 | (newline) |
| 3867 | (verilog-more-comment)) | 3880 | (verilog-more-comment)) |
| 3868 | ((eolp) | 3881 | ((eolp) |
| 3869 | ;; First, check if current line should be indented | 3882 | ;; First, check if current line should be indented |
| 3870 | (if (save-excursion | 3883 | (if (save-excursion |
| 3871 | (delete-horizontal-space) | 3884 | (delete-horizontal-space) |
| 3872 | (beginning-of-line) | 3885 | (beginning-of-line) |
| 3873 | (skip-chars-forward " \t") | 3886 | (skip-chars-forward " \t") |
| 3874 | (if (looking-at verilog-auto-end-comment-lines-re) | 3887 | (if (looking-at verilog-auto-end-comment-lines-re) |
| 3875 | (let ((indent-str (verilog-indent-line))) | 3888 | (let ((indent-str (verilog-indent-line))) |
| 3876 | ;; Maybe we should set some endcomments | 3889 | ;; Maybe we should set some endcomments |
| 3877 | (if verilog-auto-endcomments | 3890 | (if verilog-auto-endcomments |
| 3878 | (verilog-set-auto-endcomments indent-str arg)) | 3891 | (verilog-set-auto-endcomments indent-str arg)) |
| 3879 | (end-of-line) | 3892 | (end-of-line) |
| 3880 | (delete-horizontal-space) | 3893 | (delete-horizontal-space) |
| 3881 | (if arg | 3894 | (if arg |
| 3882 | () | 3895 | () |
| 3883 | (newline)) | 3896 | (newline)) |
| 3884 | nil) | 3897 | nil) |
| 3885 | (progn | 3898 | (progn |
| 3886 | (end-of-line) | 3899 | (end-of-line) |
| 3887 | (delete-horizontal-space) | 3900 | (delete-horizontal-space) |
| 3888 | 't))) | 3901 | 't))) |
| 3889 | ;; see if we should line up assignments | 3902 | ;; see if we should line up assignments |
| 3890 | (progn | 3903 | (progn |
| 3891 | (if (or (eq 'all verilog-auto-lineup) | 3904 | (if (or (eq 'all verilog-auto-lineup) |
| 3892 | (eq 'assignments verilog-auto-lineup)) | 3905 | (eq 'assignments verilog-auto-lineup)) |
| 3893 | (verilog-pretty-expr t "\\(<\\|:\\)?=" )) | 3906 | (verilog-pretty-expr t "\\(<\\|:\\)?=" )) |
| 3894 | (newline)) | 3907 | (newline)) |
| 3895 | (forward-line 1)) | 3908 | (forward-line 1)) |
| 3896 | ;; Indent next line | 3909 | ;; Indent next line |
| 3897 | (if verilog-auto-indent-on-newline | 3910 | (if verilog-auto-indent-on-newline |
| 3898 | (verilog-indent-line))) | 3911 | (verilog-indent-line))) |
| 3899 | (t | 3912 | (t |
| 3900 | (newline))))) | 3913 | (newline))))) |
| 3901 | 3914 | ||
| @@ -3944,8 +3957,8 @@ With optional ARG, remove existing end of line comments." | |||
| 3944 | (goto-char p) | 3957 | (goto-char p) |
| 3945 | (verilog-backward-case-item lim) | 3958 | (verilog-backward-case-item lim) |
| 3946 | (verilog-indent-line))) | 3959 | (verilog-indent-line))) |
| 3947 | ;; (let ((verilog-tab-always-indent nil)) | 3960 | ;; (let ((verilog-tab-always-indent nil)) |
| 3948 | ;; (verilog-indent-line)) | 3961 | ;; (verilog-indent-line)) |
| 3949 | )) | 3962 | )) |
| 3950 | 3963 | ||
| 3951 | ;;(defun electric-verilog-equal () | 3964 | ;;(defun electric-verilog-equal () |
| @@ -3995,7 +4008,7 @@ With optional ARG, remove existing end of line comments." | |||
| 3995 | (t | 4008 | (t |
| 3996 | (indent-for-comment) | 4009 | (indent-for-comment) |
| 3997 | (when (and (eolp) (= oldpnt (point))) | 4010 | (when (and (eolp) (= oldpnt (point))) |
| 3998 | ; kill existing comment | 4011 | ;; kill existing comment |
| 3999 | (beginning-of-line) | 4012 | (beginning-of-line) |
| 4000 | (re-search-forward comment-start-skip oldpnt 'move) | 4013 | (re-search-forward comment-start-skip oldpnt 'move) |
| 4001 | (goto-char (match-beginning 0)) | 4014 | (goto-char (match-beginning 0)) |
| @@ -4004,9 +4017,7 @@ With optional ARG, remove existing end of line comments." | |||
| 4004 | (t (progn (insert "\t"))))) | 4017 | (t (progn (insert "\t"))))) |
| 4005 | 4018 | ||
| 4006 | 4019 | ||
| 4007 | 4020 | ;;; Interactive functions: | |
| 4008 | ;; | ||
| 4009 | ;; Interactive functions | ||
| 4010 | ;; | 4021 | ;; |
| 4011 | 4022 | ||
| 4012 | (defun verilog-indent-buffer () | 4023 | (defun verilog-indent-buffer () |
| @@ -4213,6 +4224,7 @@ Uses `verilog-scan' cache." | |||
| 4213 | "Label matching begin ... end, fork ... join and case ... endcase statements." | 4224 | "Label matching begin ... end, fork ... join and case ... endcase statements." |
| 4214 | (interactive) | 4225 | (interactive) |
| 4215 | (let ((cnt 0) | 4226 | (let ((cnt 0) |
| 4227 | (case-fold-search nil) | ||
| 4216 | (oldpos (point)) | 4228 | (oldpos (point)) |
| 4217 | (b (progn | 4229 | (b (progn |
| 4218 | (verilog-beg-of-defun) | 4230 | (verilog-beg-of-defun) |
| @@ -4222,7 +4234,7 @@ Uses `verilog-scan' cache." | |||
| 4222 | (point-marker)))) | 4234 | (point-marker)))) |
| 4223 | (goto-char (marker-position b)) | 4235 | (goto-char (marker-position b)) |
| 4224 | (if (> (- e b) 200) | 4236 | (if (> (- e b) 200) |
| 4225 | (message "Relabeling module...")) | 4237 | (message "Relabeling module...")) |
| 4226 | (while (and | 4238 | (while (and |
| 4227 | (> (marker-position e) (point)) | 4239 | (> (marker-position e) (point)) |
| 4228 | (verilog-re-search-forward | 4240 | (verilog-re-search-forward |
| @@ -4240,7 +4252,7 @@ Uses `verilog-scan' cache." | |||
| 4240 | (if (or | 4252 | (if (or |
| 4241 | (> (- e b) 200) | 4253 | (> (- e b) 200) |
| 4242 | (> cnt 20)) | 4254 | (> cnt 20)) |
| 4243 | (message "%d lines auto commented" cnt)))) | 4255 | (message "%d lines auto commented" cnt)))) |
| 4244 | 4256 | ||
| 4245 | (defun verilog-beg-of-statement () | 4257 | (defun verilog-beg-of-statement () |
| 4246 | "Move backward to beginning of statement." | 4258 | "Move backward to beginning of statement." |
| @@ -4319,16 +4331,16 @@ Uses `verilog-scan' cache." | |||
| 4319 | (goto-char pt) | 4331 | (goto-char pt) |
| 4320 | (throw 'done t))))) | 4332 | (throw 'done t))))) |
| 4321 | (verilog-forward-syntactic-ws))) | 4333 | (verilog-forward-syntactic-ws))) |
| 4322 | ; | 4334 | ;; |
| 4323 | ; (while (and | 4335 | ;; (while (and |
| 4324 | ; (not (looking-at verilog-complete-reg)) | 4336 | ;; (not (looking-at verilog-complete-reg)) |
| 4325 | ; (not (bolp)) | 4337 | ;; (not (bolp)) |
| 4326 | ; (not (= (preceding-char) ?\;))) | 4338 | ;; (not (= (preceding-char) ?\;))) |
| 4327 | ; (verilog-backward-token) | 4339 | ;; (verilog-backward-token) |
| 4328 | ; (verilog-backward-syntactic-ws) | 4340 | ;; (verilog-backward-syntactic-ws) |
| 4329 | ; (setq pt (point))) | 4341 | ;; (setq pt (point))) |
| 4330 | ; (goto-char pt) | 4342 | ;; (goto-char pt) |
| 4331 | ; ;(verilog-forward-syntactic-ws) | 4343 | ;; ;(verilog-forward-syntactic-ws) |
| 4332 | 4344 | ||
| 4333 | (defun verilog-end-of-statement () | 4345 | (defun verilog-end-of-statement () |
| 4334 | "Move forward to end of current statement." | 4346 | "Move forward to end of current statement." |
| @@ -4347,30 +4359,30 @@ Uses `verilog-scan' cache." | |||
| 4347 | 4359 | ||
| 4348 | ;; Skip to end of statement | 4360 | ;; Skip to end of statement |
| 4349 | ((condition-case nil | 4361 | ((condition-case nil |
| 4350 | (setq pos | 4362 | (setq pos |
| 4351 | (catch 'found | 4363 | (catch 'found |
| 4352 | (while t | 4364 | (while t |
| 4353 | (forward-sexp 1) | 4365 | (forward-sexp 1) |
| 4354 | (verilog-skip-forward-comment-or-string) | 4366 | (verilog-skip-forward-comment-or-string) |
| 4355 | (if (eolp) | 4367 | (if (eolp) |
| 4356 | (forward-line 1)) | 4368 | (forward-line 1)) |
| 4357 | (cond ((looking-at "[ \t]*;") | 4369 | (cond ((looking-at "[ \t]*;") |
| 4358 | (skip-chars-forward "^;") | 4370 | (skip-chars-forward "^;") |
| 4359 | (forward-char 1) | 4371 | (forward-char 1) |
| 4360 | (throw 'found (point))) | 4372 | (throw 'found (point))) |
| 4361 | ((save-excursion | 4373 | ((save-excursion |
| 4362 | (forward-sexp -1) | 4374 | (forward-sexp -1) |
| 4363 | (looking-at verilog-beg-block-re)) | 4375 | (looking-at verilog-beg-block-re)) |
| 4364 | (goto-char (match-beginning 0)) | 4376 | (goto-char (match-beginning 0)) |
| 4365 | (throw 'found nil)) | 4377 | (throw 'found nil)) |
| 4366 | ((looking-at "[ \t]*)") | 4378 | ((looking-at "[ \t]*)") |
| 4367 | (throw 'found (point))) | 4379 | (throw 'found (point))) |
| 4368 | ((eobp) | 4380 | ((eobp) |
| 4369 | (throw 'found (point))) | 4381 | (throw 'found (point))) |
| 4370 | ))) | 4382 | ))) |
| 4371 | 4383 | ||
| 4372 | ) | 4384 | ) |
| 4373 | (error nil)) | 4385 | (error nil)) |
| 4374 | (if (not pos) | 4386 | (if (not pos) |
| 4375 | ;; Skip a whole block | 4387 | ;; Skip a whole block |
| 4376 | (catch 'found | 4388 | (catch 'found |
| @@ -4464,6 +4476,13 @@ More specifically, after a generate and before an endgenerate." | |||
| 4464 | (setq nest (1+ nest))))))) | 4476 | (setq nest (1+ nest))))))) |
| 4465 | (= nest 0) )) ; return nest | 4477 | (= nest 0) )) ; return nest |
| 4466 | 4478 | ||
| 4479 | (defun verilog-in-deferred-immediate-final-p () | ||
| 4480 | "Return true if inside an 'assert/assume/cover final' statement." | ||
| 4481 | (interactive) | ||
| 4482 | (and (looking-at "final") | ||
| 4483 | (verilog-looking-back "\\<\\(?:assert\\|assume\\|cover\\)\\>\\s-+" nil)) | ||
| 4484 | ) | ||
| 4485 | |||
| 4467 | (defun verilog-backward-case-item (lim) | 4486 | (defun verilog-backward-case-item (lim) |
| 4468 | "Skip backward to nearest enclosing case item. | 4487 | "Skip backward to nearest enclosing case item. |
| 4469 | Limit search to point LIM." | 4488 | Limit search to point LIM." |
| @@ -4485,14 +4504,14 @@ Limit search to point LIM." | |||
| 4485 | (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" | 4504 | (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" |
| 4486 | lim1 'move)) | 4505 | lim1 'move)) |
| 4487 | (cond | 4506 | (cond |
| 4488 | ((match-end 1) ;; [ | 4507 | ((match-end 1) ; [ |
| 4489 | (setq colon (1+ colon)) | 4508 | (setq colon (1+ colon)) |
| 4490 | (if (>= colon 0) | 4509 | (if (>= colon 0) |
| 4491 | (error "%s: unbalanced [" (verilog-point-text)))) | 4510 | (error "%s: unbalanced [" (verilog-point-text)))) |
| 4492 | ((match-end 2) ;; ] | 4511 | ((match-end 2) ; ] |
| 4493 | (setq colon (1- colon))) | 4512 | (setq colon (1- colon))) |
| 4494 | 4513 | ||
| 4495 | ((match-end 3) ;; : | 4514 | ((match-end 3) ; : |
| 4496 | (setq colon (1+ colon))))) | 4515 | (setq colon (1+ colon))))) |
| 4497 | ;; Skip back to beginning of case item | 4516 | ;; Skip back to beginning of case item |
| 4498 | (skip-chars-backward "\t ") | 4517 | (skip-chars-backward "\t ") |
| @@ -4527,9 +4546,7 @@ Limit search to point LIM." | |||
| 4527 | str) | 4546 | str) |
| 4528 | 'nil))) | 4547 | 'nil))) |
| 4529 | 4548 | ||
| 4530 | 4549 | ;;; Other functions: | |
| 4531 | ;; | ||
| 4532 | ;; Other functions | ||
| 4533 | ;; | 4550 | ;; |
| 4534 | 4551 | ||
| 4535 | (defun verilog-kill-existing-comment () | 4552 | (defun verilog-kill-existing-comment () |
| @@ -4625,312 +4642,312 @@ primitive or interface named NAME." | |||
| 4625 | (search-backward "//" (point-at-bol) t))))) | 4642 | (search-backward "//" (point-at-bol) t))))) |
| 4626 | (let ((type (car indent-str))) | 4643 | (let ((type (car indent-str))) |
| 4627 | (unless (eq type 'declaration) | 4644 | (unless (eq type 'declaration) |
| 4628 | (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends | 4645 | (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ; ignore named ends |
| 4629 | (if (looking-at verilog-end-block-ordered-re) | 4646 | (if (looking-at verilog-end-block-ordered-re) |
| 4630 | (cond | 4647 | (cond |
| 4631 | (;- This is a case block; search back for the start of this case | 4648 | (;- This is a case block; search back for the start of this case |
| 4632 | (match-end 1) ;; of verilog-end-block-ordered-re | 4649 | (match-end 1) ; of verilog-end-block-ordered-re |
| 4633 | 4650 | ||
| 4634 | (let ((err 't) | 4651 | (let ((err 't) |
| 4635 | (str "UNMATCHED!!")) | 4652 | (str "UNMATCHED!!")) |
| 4636 | (save-excursion | 4653 | (save-excursion |
| 4637 | (verilog-leap-to-head) | 4654 | (verilog-leap-to-head) |
| 4638 | (cond | 4655 | (cond |
| 4639 | ((looking-at "\\<randcase\\>") | 4656 | ((looking-at "\\<randcase\\>") |
| 4640 | (setq str "randcase") | 4657 | (setq str "randcase") |
| 4641 | (setq err nil)) | 4658 | (setq err nil)) |
| 4642 | ((looking-at "\\(\\(unique0?\\s-+\\|priority\\s-+\\)?case[xz]?\\)") | 4659 | ((looking-at "\\(\\(unique0?\\s-+\\|priority\\s-+\\)?case[xz]?\\)") |
| 4643 | (goto-char (match-end 0)) | 4660 | (goto-char (match-end 0)) |
| 4644 | (setq str (concat (match-string 0) " " (verilog-get-expr))) | 4661 | (setq str (concat (match-string 0) " " (verilog-get-expr))) |
| 4645 | (setq err nil)) | 4662 | (setq err nil)) |
| 4646 | )) | 4663 | )) |
| 4647 | (end-of-line) | 4664 | (end-of-line) |
| 4648 | (if kill-existing-comment | 4665 | (if kill-existing-comment |
| 4649 | (verilog-kill-existing-comment)) | 4666 | (verilog-kill-existing-comment)) |
| 4650 | (delete-horizontal-space) | 4667 | (delete-horizontal-space) |
| 4651 | (insert (concat " // " str )) | 4668 | (insert (concat " // " str )) |
| 4652 | (if err (ding 't)))) | 4669 | (if err (ding 't)))) |
| 4653 | 4670 | ||
| 4654 | (;- This is a begin..end block | 4671 | (;- This is a begin..end block |
| 4655 | (match-end 2) ;; of verilog-end-block-ordered-re | 4672 | (match-end 2) ; of verilog-end-block-ordered-re |
| 4656 | (let ((str " // UNMATCHED !!") | 4673 | (let ((str " // UNMATCHED !!") |
| 4657 | (err 't) | 4674 | (err 't) |
| 4658 | (here (point)) | 4675 | (here (point)) |
| 4659 | there | 4676 | there |
| 4660 | cntx) | 4677 | cntx) |
| 4661 | (save-excursion | 4678 | (save-excursion |
| 4662 | (verilog-leap-to-head) | 4679 | (verilog-leap-to-head) |
| 4663 | (setq there (point)) | 4680 | (setq there (point)) |
| 4664 | (if (not (match-end 0)) | 4681 | (if (not (match-end 0)) |
| 4665 | (progn | 4682 | (progn |
| 4666 | (goto-char here) | 4683 | (goto-char here) |
| 4667 | (end-of-line) | 4684 | (end-of-line) |
| 4668 | (if kill-existing-comment | 4685 | (if kill-existing-comment |
| 4669 | (verilog-kill-existing-comment)) | 4686 | (verilog-kill-existing-comment)) |
| 4670 | (delete-horizontal-space) | 4687 | (delete-horizontal-space) |
| 4671 | (insert str) | 4688 | (insert str) |
| 4672 | (ding 't)) | 4689 | (ding 't)) |
| 4673 | (let ((lim | 4690 | (let ((lim |
| 4674 | (save-excursion (verilog-beg-of-defun) (point))) | 4691 | (save-excursion (verilog-beg-of-defun) (point))) |
| 4675 | (here (point))) | 4692 | (here (point))) |
| 4676 | (cond | 4693 | (cond |
| 4677 | (;-- handle named block differently | 4694 | (;-- handle named block differently |
| 4678 | (looking-at verilog-named-block-re) | 4695 | (looking-at verilog-named-block-re) |
| 4679 | (search-forward ":") | 4696 | (search-forward ":") |
| 4680 | (setq there (point)) | 4697 | (setq there (point)) |
| 4681 | (setq str (verilog-get-expr)) | 4698 | (setq str (verilog-get-expr)) |
| 4682 | (setq err nil) | 4699 | (setq err nil) |
| 4683 | (setq str (concat " // block: " str ))) | 4700 | (setq str (concat " // block: " str ))) |
| 4684 | 4701 | ||
| 4685 | ((verilog-in-case-region-p) ;-- handle case item differently | 4702 | ((verilog-in-case-region-p) ;-- handle case item differently |
| 4686 | (goto-char here) | 4703 | (goto-char here) |
| 4687 | (setq str (verilog-backward-case-item lim)) | 4704 | (setq str (verilog-backward-case-item lim)) |
| 4688 | (setq there (point)) | 4705 | (setq there (point)) |
| 4689 | (setq err nil) | 4706 | (setq err nil) |
| 4690 | (setq str (concat " // case: " str ))) | 4707 | (setq str (concat " // case: " str ))) |
| 4691 | 4708 | ||
| 4692 | (;- try to find "reason" for this begin | 4709 | (;- try to find "reason" for this begin |
| 4693 | (cond | 4710 | (cond |
| 4694 | (; | 4711 | (; |
| 4695 | (eq here (progn | 4712 | (eq here (progn |
| 4696 | ;; (verilog-backward-token) | 4713 | ;; (verilog-backward-token) |
| 4697 | (verilog-beg-of-statement) | 4714 | (verilog-beg-of-statement) |
| 4698 | (point))) | 4715 | (point))) |
| 4699 | (setq err nil) | 4716 | (setq err nil) |
| 4700 | (setq str "")) | 4717 | (setq str "")) |
| 4701 | ((looking-at verilog-endcomment-reason-re) | 4718 | ((looking-at verilog-endcomment-reason-re) |
| 4702 | (setq there (match-end 0)) | 4719 | (setq there (match-end 0)) |
| 4703 | (setq cntx (concat (match-string 0) " ")) | 4720 | (setq cntx (concat (match-string 0) " ")) |
| 4704 | (cond | 4721 | (cond |
| 4705 | (;- begin | 4722 | (;- begin |
| 4706 | (match-end 1) | 4723 | (match-end 1) |
| 4707 | (setq err nil) | 4724 | (setq err nil) |
| 4708 | (save-excursion | 4725 | (save-excursion |
| 4709 | (if (and (verilog-continued-line) | 4726 | (if (and (verilog-continued-line) |
| 4710 | (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) | 4727 | (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) |
| 4711 | (progn | 4728 | (progn |
| 4712 | (goto-char (match-end 0)) | 4729 | (goto-char (match-end 0)) |
| 4713 | (setq there (point)) | 4730 | (setq there (point)) |
| 4714 | (setq str | 4731 | (setq str |
| 4715 | (concat " // " (match-string 0) " " (verilog-get-expr)))) | 4732 | (concat " // " (match-string 0) " " (verilog-get-expr)))) |
| 4716 | (setq str "")))) | 4733 | (setq str "")))) |
| 4717 | 4734 | ||
| 4718 | (;- else | 4735 | (;- else |
| 4719 | (match-end 2) | 4736 | (match-end 2) |
| 4720 | (let ((nest 0) | 4737 | (let ((nest 0) |
| 4721 | ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)")) | 4738 | ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)")) |
| 4722 | (catch 'skip | 4739 | (catch 'skip |
| 4723 | (while (verilog-re-search-backward reg nil 'move) | 4740 | (while (verilog-re-search-backward reg nil 'move) |
| 4724 | (cond | 4741 | (cond |
| 4725 | ((match-end 1) ; begin | 4742 | ((match-end 1) ; begin |
| 4726 | (setq nest (1- nest))) | 4743 | (setq nest (1- nest))) |
| 4727 | ((match-end 2) ; end | 4744 | ((match-end 2) ; end |
| 4728 | (setq nest (1+ nest))) | 4745 | (setq nest (1+ nest))) |
| 4729 | ((match-end 3) | 4746 | ((match-end 3) |
| 4730 | (if (= 0 nest) | 4747 | (if (= 0 nest) |
| 4731 | (progn | 4748 | (progn |
| 4732 | (goto-char (match-end 0)) | 4749 | (goto-char (match-end 0)) |
| 4733 | (setq there (point)) | 4750 | (setq there (point)) |
| 4734 | (setq err nil) | 4751 | (setq err nil) |
| 4735 | (setq str (verilog-get-expr)) | 4752 | (setq str (verilog-get-expr)) |
| 4736 | (setq str (concat " // else: !if" str )) | 4753 | (setq str (concat " // else: !if" str )) |
| 4737 | (throw 'skip 1)))) | 4754 | (throw 'skip 1)))) |
| 4738 | ((match-end 4) | 4755 | ((match-end 4) |
| 4739 | (if (= 0 nest) | 4756 | (if (= 0 nest) |
| 4740 | (progn | 4757 | (progn |
| 4741 | (goto-char (match-end 0)) | 4758 | (goto-char (match-end 0)) |
| 4742 | (setq there (point)) | 4759 | (setq there (point)) |
| 4743 | (setq err nil) | 4760 | (setq err nil) |
| 4744 | (setq str (verilog-get-expr)) | 4761 | (setq str (verilog-get-expr)) |
| 4745 | (setq str (concat " // else: !assert " str )) | 4762 | (setq str (concat " // else: !assert " str )) |
| 4746 | (throw 'skip 1))))))))) | 4763 | (throw 'skip 1))))))))) |
| 4747 | (;- end else | 4764 | (;- end else |
| 4748 | (match-end 3) | 4765 | (match-end 3) |
| 4749 | (goto-char there) | 4766 | (goto-char there) |
| 4750 | (let ((nest 0) | 4767 | (let ((nest 0) |
| 4751 | (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)")) | 4768 | (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)\\|\\(assert\\)")) |
| 4752 | (catch 'skip | 4769 | (catch 'skip |
| 4753 | (while (verilog-re-search-backward reg nil 'move) | 4770 | (while (verilog-re-search-backward reg nil 'move) |
| 4754 | (cond | 4771 | (cond |
| 4755 | ((match-end 1) ; begin | 4772 | ((match-end 1) ; begin |
| 4756 | (setq nest (1- nest))) | 4773 | (setq nest (1- nest))) |
| 4757 | ((match-end 2) ; end | 4774 | ((match-end 2) ; end |
| 4758 | (setq nest (1+ nest))) | 4775 | (setq nest (1+ nest))) |
| 4759 | ((match-end 3) | 4776 | ((match-end 3) |
| 4760 | (if (= 0 nest) | 4777 | (if (= 0 nest) |
| 4761 | (progn | 4778 | (progn |
| 4762 | (goto-char (match-end 0)) | 4779 | (goto-char (match-end 0)) |
| 4763 | (setq there (point)) | 4780 | (setq there (point)) |
| 4764 | (setq err nil) | 4781 | (setq err nil) |
| 4765 | (setq str (verilog-get-expr)) | 4782 | (setq str (verilog-get-expr)) |
| 4766 | (setq str (concat " // else: !if" str )) | 4783 | (setq str (concat " // else: !if" str )) |
| 4767 | (throw 'skip 1)))) | 4784 | (throw 'skip 1)))) |
| 4768 | ((match-end 4) | 4785 | ((match-end 4) |
| 4769 | (if (= 0 nest) | 4786 | (if (= 0 nest) |
| 4770 | (progn | 4787 | (progn |
| 4771 | (goto-char (match-end 0)) | 4788 | (goto-char (match-end 0)) |
| 4772 | (setq there (point)) | 4789 | (setq there (point)) |
| 4773 | (setq err nil) | 4790 | (setq err nil) |
| 4774 | (setq str (verilog-get-expr)) | 4791 | (setq str (verilog-get-expr)) |
| 4775 | (setq str (concat " // else: !assert " str )) | 4792 | (setq str (concat " // else: !assert " str )) |
| 4776 | (throw 'skip 1))))))))) | 4793 | (throw 'skip 1))))))))) |
| 4777 | 4794 | ||
| 4778 | (; always, always_comb, always_latch w/o @... | 4795 | (; always, always_comb, always_latch w/o @... |
| 4779 | (match-end 5) | 4796 | (match-end 5) |
| 4780 | (goto-char (match-end 0)) | 4797 | (goto-char (match-end 0)) |
| 4781 | (setq there (point)) | 4798 | (setq there (point)) |
| 4782 | (setq err nil) | 4799 | (setq err nil) |
| 4783 | (setq str (concat " // " cntx ))) | 4800 | (setq str (concat " // " cntx ))) |
| 4784 | 4801 | ||
| 4785 | (;- task/function/initial et cetera | 4802 | (;- task/function/initial et cetera |
| 4786 | t | 4803 | t |
| 4787 | (match-end 0) | 4804 | (match-end 0) |
| 4788 | (goto-char (match-end 0)) | 4805 | (goto-char (match-end 0)) |
| 4789 | (setq there (point)) | 4806 | (setq there (point)) |
| 4790 | (setq err nil) | 4807 | (setq err nil) |
| 4791 | (setq str (concat " // " cntx (verilog-get-expr)))) | 4808 | (setq str (concat " // " cntx (verilog-get-expr)))) |
| 4792 | 4809 | ||
| 4793 | (;-- otherwise... | 4810 | (;-- otherwise... |
| 4794 | (setq str " // auto-endcomment confused ")))) | 4811 | (setq str " // auto-endcomment confused ")))) |
| 4795 | 4812 | ||
| 4796 | ((and | 4813 | ((and |
| 4797 | (verilog-in-case-region-p) ;-- handle case item differently | 4814 | (verilog-in-case-region-p) ;-- handle case item differently |
| 4798 | (progn | 4815 | (progn |
| 4799 | (setq there (point)) | 4816 | (setq there (point)) |
| 4800 | (goto-char here) | 4817 | (goto-char here) |
| 4801 | (setq str (verilog-backward-case-item lim)))) | 4818 | (setq str (verilog-backward-case-item lim)))) |
| 4802 | (setq err nil) | 4819 | (setq err nil) |
| 4803 | (setq str (concat " // case: " str ))) | 4820 | (setq str (concat " // case: " str ))) |
| 4804 | 4821 | ||
| 4805 | ((verilog-in-fork-region-p) | 4822 | ((verilog-in-fork-region-p) |
| 4806 | (setq err nil) | 4823 | (setq err nil) |
| 4807 | (setq str " // fork branch" )) | 4824 | (setq str " // fork branch" )) |
| 4808 | 4825 | ||
| 4809 | ((looking-at "\\<end\\>") | 4826 | ((looking-at "\\<end\\>") |
| 4810 | ;; HERE | 4827 | ;; HERE |
| 4811 | (forward-word 1) | 4828 | (forward-word 1) |
| 4812 | (verilog-forward-syntactic-ws) | 4829 | (verilog-forward-syntactic-ws) |
| 4813 | (setq err nil) | 4830 | (setq err nil) |
| 4814 | (setq str (verilog-get-expr)) | 4831 | (setq str (verilog-get-expr)) |
| 4815 | (setq str (concat " // " cntx str ))) | 4832 | (setq str (concat " // " cntx str ))) |
| 4816 | 4833 | ||
| 4817 | )))) | 4834 | )))) |
| 4818 | (goto-char here) | 4835 | (goto-char here) |
| 4819 | (end-of-line) | 4836 | (end-of-line) |
| 4820 | (if kill-existing-comment | 4837 | (if kill-existing-comment |
| 4821 | (verilog-kill-existing-comment)) | 4838 | (verilog-kill-existing-comment)) |
| 4822 | (delete-horizontal-space) | 4839 | (delete-horizontal-space) |
| 4823 | (if (or err | 4840 | (if (or err |
| 4824 | (> (count-lines here there) verilog-minimum-comment-distance)) | 4841 | (> (count-lines here there) verilog-minimum-comment-distance)) |
| 4825 | (insert str)) | 4842 | (insert str)) |
| 4826 | (if err (ding 't)) | 4843 | (if err (ding 't)) |
| 4827 | )))) | 4844 | )))) |
| 4828 | (;- this is endclass, which can be nested | 4845 | (;- this is endclass, which can be nested |
| 4829 | (match-end 11) ;; of verilog-end-block-ordered-re | 4846 | (match-end 11) ; of verilog-end-block-ordered-re |
| 4830 | ;;(goto-char there) | 4847 | ;;(goto-char there) |
| 4831 | (let ((nest 0) | 4848 | (let ((nest 0) |
| 4832 | (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") | 4849 | (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
| 4833 | string) | 4850 | string) |
| 4834 | (save-excursion | 4851 | (save-excursion |
| 4835 | (catch 'skip | 4852 | (catch 'skip |
| 4836 | (while (verilog-re-search-backward reg nil 'move) | 4853 | (while (verilog-re-search-backward reg nil 'move) |
| 4837 | (cond | 4854 | (cond |
| 4838 | ((match-end 3) ; endclass | 4855 | ((match-end 3) ; endclass |
| 4839 | (ding 't) | 4856 | (ding 't) |
| 4840 | (setq string "unmatched endclass") | 4857 | (setq string "unmatched endclass") |
| 4841 | (throw 'skip 1)) | 4858 | (throw 'skip 1)) |
| 4842 | 4859 | ||
| 4843 | ((match-end 2) ; endclass | 4860 | ((match-end 2) ; endclass |
| 4844 | (setq nest (1+ nest))) | 4861 | (setq nest (1+ nest))) |
| 4845 | 4862 | ||
| 4846 | ((match-end 1) ; class | 4863 | ((match-end 1) ; class |
| 4847 | (setq nest (1- nest)) | 4864 | (setq nest (1- nest)) |
| 4848 | (if (< nest 0) | 4865 | (if (< nest 0) |
| 4849 | (progn | 4866 | (progn |
| 4850 | (goto-char (match-end 0)) | 4867 | (goto-char (match-end 0)) |
| 4851 | (let (b e) | 4868 | (let (b e) |
| 4852 | (setq b (progn | 4869 | (setq b (progn |
| 4853 | (skip-chars-forward "^ \t") | 4870 | (skip-chars-forward "^ \t") |
| 4854 | (verilog-forward-ws&directives) | 4871 | (verilog-forward-ws&directives) |
| 4855 | (point)) | 4872 | (point)) |
| 4856 | e (progn | 4873 | e (progn |
| 4857 | (skip-chars-forward "a-zA-Z0-9_") | 4874 | (skip-chars-forward "a-zA-Z0-9_") |
| 4858 | (point))) | 4875 | (point))) |
| 4859 | (setq string (buffer-substring b e))) | 4876 | (setq string (buffer-substring b e))) |
| 4860 | (throw 'skip 1)))) | 4877 | (throw 'skip 1)))) |
| 4861 | )))) | 4878 | )))) |
| 4862 | (end-of-line) | 4879 | (end-of-line) |
| 4863 | (if kill-existing-comment | 4880 | (if kill-existing-comment |
| 4864 | (verilog-kill-existing-comment)) | 4881 | (verilog-kill-existing-comment)) |
| 4865 | (delete-horizontal-space) | 4882 | (delete-horizontal-space) |
| 4866 | (insert (concat " // " string )))) | 4883 | (insert (concat " // " string )))) |
| 4867 | 4884 | ||
| 4868 | (;- this is end{function,generate,task,module,primitive,table,generate} | 4885 | (; - this is end{function,generate,task,module,primitive,table,generate} |
| 4869 | ;- which can not be nested. | 4886 | ;; - which can not be nested. |
| 4870 | t | 4887 | t |
| 4871 | (let (string reg (name-re nil)) | 4888 | (let (string reg (name-re nil)) |
| 4872 | (end-of-line) | 4889 | (end-of-line) |
| 4873 | (if kill-existing-comment | 4890 | (if kill-existing-comment |
| 4874 | (save-match-data | 4891 | (save-match-data |
| 4875 | (verilog-kill-existing-comment))) | 4892 | (verilog-kill-existing-comment))) |
| 4876 | (delete-horizontal-space) | 4893 | (delete-horizontal-space) |
| 4877 | (backward-sexp) | 4894 | (backward-sexp) |
| 4878 | (cond | 4895 | (cond |
| 4879 | ((match-end 5) ;; of verilog-end-block-ordered-re | 4896 | ((match-end 5) ; of verilog-end-block-ordered-re |
| 4880 | (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | 4897 | (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") |
| 4881 | (setq name-re "\\w+\\(?:\n\\|\\s-\\)*[(;]")) | 4898 | (setq name-re "\\w+\\(?:\n\\|\\s-\\)*[(;]")) |
| 4882 | ((match-end 6) ;; of verilog-end-block-ordered-re | 4899 | ((match-end 6) ; of verilog-end-block-ordered-re |
| 4883 | (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | 4900 | (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)") |
| 4884 | (setq name-re "\\w+\\(?:\n\\|\\s-\\)*[(;]")) | 4901 | (setq name-re "\\w+\\(?:\n\\|\\s-\\)*[(;]")) |
| 4885 | ((match-end 7) ;; of verilog-end-block-ordered-re | 4902 | ((match-end 7) ; of verilog-end-block-ordered-re |
| 4886 | (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | 4903 | (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) |
| 4887 | ((match-end 8) ;; of verilog-end-block-ordered-re | 4904 | ((match-end 8) ; of verilog-end-block-ordered-re |
| 4888 | (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4905 | (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4889 | ((match-end 9) ;; of verilog-end-block-ordered-re | 4906 | ((match-end 9) ; of verilog-end-block-ordered-re |
| 4890 | (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) | 4907 | (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) |
| 4891 | ((match-end 10) ;; of verilog-end-block-ordered-re | 4908 | ((match-end 10) ; of verilog-end-block-ordered-re |
| 4892 | (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4909 | (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4893 | ((match-end 11) ;; of verilog-end-block-ordered-re | 4910 | ((match-end 11) ; of verilog-end-block-ordered-re |
| 4894 | (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4911 | (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4895 | ((match-end 12) ;; of verilog-end-block-ordered-re | 4912 | ((match-end 12) ; of verilog-end-block-ordered-re |
| 4896 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4913 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4897 | ((match-end 13) ;; of verilog-end-block-ordered-re | 4914 | ((match-end 13) ; of verilog-end-block-ordered-re |
| 4898 | (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4915 | (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4899 | ((match-end 14) ;; of verilog-end-block-ordered-re | 4916 | ((match-end 14) ; of verilog-end-block-ordered-re |
| 4900 | (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | 4917 | (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) |
| 4901 | ((match-end 15) ;; of verilog-end-block-ordered-re | 4918 | ((match-end 15) ; of verilog-end-block-ordered-re |
| 4902 | (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | 4919 | (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) |
| 4903 | ((match-end 16) ;; of verilog-end-block-ordered-re | 4920 | ((match-end 16) ; of verilog-end-block-ordered-re |
| 4904 | (setq reg "\\(\\<property\\>\\)\\|\\<endproperty\\>")) | 4921 | (setq reg "\\(\\<property\\>\\)\\|\\<endproperty\\>")) |
| 4905 | 4922 | ||
| 4906 | (t (error "Problem in verilog-set-auto-endcomments"))) | 4923 | (t (error "Problem in verilog-set-auto-endcomments"))) |
| 4907 | (let (b e) | 4924 | (let (b e) |
| 4908 | (save-excursion | 4925 | (save-excursion |
| 4909 | (verilog-re-search-backward reg nil 'move) | 4926 | (verilog-re-search-backward reg nil 'move) |
| 4910 | (cond | 4927 | (cond |
| 4911 | ((match-end 1) | 4928 | ((match-end 1) |
| 4912 | (setq b (progn | 4929 | (setq b (progn |
| 4913 | (skip-chars-forward "^ \t") | 4930 | (skip-chars-forward "^ \t") |
| 4914 | (verilog-forward-ws&directives) | 4931 | (verilog-forward-ws&directives) |
| 4915 | (if (looking-at "static\\|automatic") | 4932 | (if (looking-at "static\\|automatic") |
| 4916 | (progn | 4933 | (progn |
| 4917 | (goto-char (match-end 0)) | 4934 | (goto-char (match-end 0)) |
| 4918 | (verilog-forward-ws&directives))) | 4935 | (verilog-forward-ws&directives))) |
| 4919 | (if (and name-re (verilog-re-search-forward name-re nil 'move)) | 4936 | (if (and name-re (verilog-re-search-forward name-re nil 'move)) |
| 4920 | (progn | 4937 | (progn |
| 4921 | (goto-char (match-beginning 0)) | 4938 | (goto-char (match-beginning 0)) |
| 4922 | (verilog-forward-ws&directives))) | 4939 | (verilog-forward-ws&directives))) |
| 4923 | (point)) | 4940 | (point)) |
| 4924 | e (progn | 4941 | e (progn |
| 4925 | (skip-chars-forward "a-zA-Z0-9_") | 4942 | (skip-chars-forward "a-zA-Z0-9_") |
| 4926 | (point))) | 4943 | (point))) |
| 4927 | (setq string (buffer-substring b e))) | 4944 | (setq string (buffer-substring b e))) |
| 4928 | (t | 4945 | (t |
| 4929 | (ding 't) | 4946 | (ding 't) |
| 4930 | (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) | 4947 | (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) |
| 4931 | (end-of-line) | 4948 | (end-of-line) |
| 4932 | (insert (concat " // " string ))) | 4949 | (insert (concat " // " string ))) |
| 4933 | )))))))))) | 4950 | )))))))))) |
| 4934 | 4951 | ||
| 4935 | (defun verilog-get-expr() | 4952 | (defun verilog-get-expr() |
| 4936 | "Grab expression at point, e.g., case ( a | b & (c ^d))." | 4953 | "Grab expression at point, e.g., case ( a | b & (c ^d))." |
| @@ -5059,7 +5076,7 @@ Useful for creating tri's and other expanded fields." | |||
| 5059 | (let ((bpt (- (point) 2))) | 5076 | (let ((bpt (- (point) 2))) |
| 5060 | (end-of-line) | 5077 | (end-of-line) |
| 5061 | (delete-region bpt (point)))))) | 5078 | (delete-region bpt (point)))))) |
| 5062 | ;; | 5079 | ;; |
| 5063 | (goto-char (point-min)) | 5080 | (goto-char (point-min)) |
| 5064 | (while (re-search-forward "/\\*" nil t) | 5081 | (while (re-search-forward "/\\*" nil t) |
| 5065 | (if (verilog-within-string) | 5082 | (if (verilog-within-string) |
| @@ -5073,7 +5090,7 @@ Useful for creating tri's and other expanded fields." | |||
| 5073 | (interactive) | 5090 | (interactive) |
| 5074 | (goto-char (point-min)) | 5091 | (goto-char (point-min)) |
| 5075 | (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) | 5092 | (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) |
| 5076 | (replace-match "\\1 " nil nil))) | 5093 | (replace-match "\\1 " nil nil))) |
| 5077 | 5094 | ||
| 5078 | (defun verilog-linter-name () | 5095 | (defun verilog-linter-name () |
| 5079 | "Return name of linter, either surelint or verilint." | 5096 | "Return name of linter, either surelint or verilint." |
| @@ -5085,7 +5102,7 @@ Useful for creating tri's and other expanded fields." | |||
| 5085 | ((equal compile-word1 "verilint") `verilint) | 5102 | ((equal compile-word1 "verilint") `verilint) |
| 5086 | ((equal lint-word1 "surelint") `surelint) | 5103 | ((equal lint-word1 "surelint") `surelint) |
| 5087 | ((equal lint-word1 "verilint") `verilint) | 5104 | ((equal lint-word1 "verilint") `verilint) |
| 5088 | (t `surelint)))) ;; back compatibility | 5105 | (t `surelint)))) ; back compatibility |
| 5089 | 5106 | ||
| 5090 | (defun verilog-lint-off () | 5107 | (defun verilog-lint-off () |
| 5091 | "Convert a Verilog linter warning line into a disable statement. | 5108 | "Convert a Verilog linter warning line into a disable statement. |
| @@ -5227,9 +5244,7 @@ FILENAME to find directory to run in, or defaults to `buffer-file-name'." | |||
| 5227 | ;; So avoid bytecomp's interactive-only by going through intern. | 5244 | ;; So avoid bytecomp's interactive-only by going through intern. |
| 5228 | (when fontlocked (funcall (intern "font-lock-fontify-buffer")))))))) | 5245 | (when fontlocked (funcall (intern "font-lock-fontify-buffer")))))))) |
| 5229 | 5246 | ||
| 5230 | 5247 | ;;; Batch: | |
| 5231 | ;; | ||
| 5232 | ;; Batch | ||
| 5233 | ;; | 5248 | ;; |
| 5234 | 5249 | ||
| 5235 | (defun verilog-warn (string &rest args) | 5250 | (defun verilog-warn (string &rest args) |
| @@ -5251,7 +5266,7 @@ This lets programs calling batch mode to easily extract error messages." | |||
| 5251 | (progn ,@body) | 5266 | (progn ,@body) |
| 5252 | (error | 5267 | (error |
| 5253 | (error "%%Error: %s%s" (error-message-string err) | 5268 | (error "%%Error: %s%s" (error-message-string err) |
| 5254 | (if (featurep 'xemacs) "\n" "")))))) ;; XEmacs forgets to add a newline | 5269 | (if (featurep 'xemacs) "\n" "")))))) ; XEmacs forgets to add a newline |
| 5255 | 5270 | ||
| 5256 | (defun verilog-batch-execute-func (funref &optional no-save) | 5271 | (defun verilog-batch-execute-func (funref &optional no-save) |
| 5257 | "Internal processing of a batch command. | 5272 | "Internal processing of a batch command. |
| @@ -5291,7 +5306,7 @@ Save the result unless optional NO-SAVE is t." | |||
| 5291 | (set-buffer buf) | 5306 | (set-buffer buf) |
| 5292 | (funcall funref) | 5307 | (funcall funref) |
| 5293 | (when (and (not no-save) | 5308 | (when (and (not no-save) |
| 5294 | (buffer-modified-p)) ;; Avoid "no changes to be saved" | 5309 | (buffer-modified-p)) ; Avoid "no changes to be saved" |
| 5295 | (save-buffer))))) | 5310 | (save-buffer))))) |
| 5296 | orig-buffer-list)))) | 5311 | orig-buffer-list)))) |
| 5297 | 5312 | ||
| @@ -5302,7 +5317,7 @@ with \\[verilog-auto] on all command-line files, and saves the buffers. | |||
| 5302 | For proper results, multiple filenames need to be passed on the command | 5317 | For proper results, multiple filenames need to be passed on the command |
| 5303 | line in bottom-up order." | 5318 | line in bottom-up order." |
| 5304 | (unless noninteractive | 5319 | (unless noninteractive |
| 5305 | (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | 5320 | (error "Use verilog-batch-auto only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5306 | (verilog-batch-execute-func `verilog-auto)) | 5321 | (verilog-batch-execute-func `verilog-auto)) |
| 5307 | 5322 | ||
| 5308 | (defun verilog-batch-delete-auto () | 5323 | (defun verilog-batch-delete-auto () |
| @@ -5310,7 +5325,7 @@ line in bottom-up order." | |||
| 5310 | This sets up the appropriate Verilog mode environment, deletes automatics | 5325 | This sets up the appropriate Verilog mode environment, deletes automatics |
| 5311 | with \\[verilog-delete-auto] on all command-line files, and saves the buffers." | 5326 | with \\[verilog-delete-auto] on all command-line files, and saves the buffers." |
| 5312 | (unless noninteractive | 5327 | (unless noninteractive |
| 5313 | (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | 5328 | (error "Use verilog-batch-delete-auto only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5314 | (verilog-batch-execute-func `verilog-delete-auto)) | 5329 | (verilog-batch-execute-func `verilog-delete-auto)) |
| 5315 | 5330 | ||
| 5316 | (defun verilog-batch-delete-trailing-whitespace () | 5331 | (defun verilog-batch-delete-trailing-whitespace () |
| @@ -5319,7 +5334,7 @@ This sets up the appropriate Verilog mode environment, removes | |||
| 5319 | whitespace with \\[verilog-delete-trailing-whitespace] on all | 5334 | whitespace with \\[verilog-delete-trailing-whitespace] on all |
| 5320 | command-line files, and saves the buffers." | 5335 | command-line files, and saves the buffers." |
| 5321 | (unless noninteractive | 5336 | (unless noninteractive |
| 5322 | (error "Use verilog-batch-delete-trailing-whitespace only with --batch")) ;; Otherwise we'd mess up buffer modes | 5337 | (error "Use verilog-batch-delete-trailing-whitespace only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5323 | (verilog-batch-execute-func `verilog-delete-trailing-whitespace)) | 5338 | (verilog-batch-execute-func `verilog-delete-trailing-whitespace)) |
| 5324 | 5339 | ||
| 5325 | (defun verilog-batch-diff-auto () | 5340 | (defun verilog-batch-diff-auto () |
| @@ -5329,7 +5344,7 @@ with \\[verilog-diff-auto] on all command-line files, and reports an error | |||
| 5329 | if any differences are observed. This is appropriate for adding to regressions | 5344 | if any differences are observed. This is appropriate for adding to regressions |
| 5330 | to insure automatics are always properly maintained." | 5345 | to insure automatics are always properly maintained." |
| 5331 | (unless noninteractive | 5346 | (unless noninteractive |
| 5332 | (error "Use verilog-batch-diff-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | 5347 | (error "Use verilog-batch-diff-auto only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5333 | (verilog-batch-execute-func `verilog-diff-auto t)) | 5348 | (verilog-batch-execute-func `verilog-diff-auto t)) |
| 5334 | 5349 | ||
| 5335 | (defun verilog-batch-inject-auto () | 5350 | (defun verilog-batch-inject-auto () |
| @@ -5339,7 +5354,7 @@ with \\[verilog-inject-auto] on all command-line files, and saves the buffers. | |||
| 5339 | For proper results, multiple filenames need to be passed on the command | 5354 | For proper results, multiple filenames need to be passed on the command |
| 5340 | line in bottom-up order." | 5355 | line in bottom-up order." |
| 5341 | (unless noninteractive | 5356 | (unless noninteractive |
| 5342 | (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | 5357 | (error "Use verilog-batch-inject-auto only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5343 | (verilog-batch-execute-func `verilog-inject-auto)) | 5358 | (verilog-batch-execute-func `verilog-inject-auto)) |
| 5344 | 5359 | ||
| 5345 | (defun verilog-batch-indent () | 5360 | (defun verilog-batch-indent () |
| @@ -5347,12 +5362,10 @@ line in bottom-up order." | |||
| 5347 | This sets up the appropriate Verilog mode environment, calls | 5362 | This sets up the appropriate Verilog mode environment, calls |
| 5348 | \\[verilog-indent-buffer] on all command-line files, and saves the buffers." | 5363 | \\[verilog-indent-buffer] on all command-line files, and saves the buffers." |
| 5349 | (unless noninteractive | 5364 | (unless noninteractive |
| 5350 | (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes | 5365 | (error "Use verilog-batch-indent only with --batch")) ; Otherwise we'd mess up buffer modes |
| 5351 | (verilog-batch-execute-func `verilog-indent-buffer)) | 5366 | (verilog-batch-execute-func `verilog-indent-buffer)) |
| 5352 | 5367 | ||
| 5353 | 5368 | ;;; Indentation: | |
| 5354 | ;; | ||
| 5355 | ;; Indentation | ||
| 5356 | ;; | 5369 | ;; |
| 5357 | (defconst verilog-indent-alist | 5370 | (defconst verilog-indent-alist |
| 5358 | '((block . (+ ind verilog-indent-level)) | 5371 | '((block . (+ ind verilog-indent-level)) |
| @@ -5391,6 +5404,7 @@ type of the current line, return that lines' indent level and its type. | |||
| 5391 | Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | 5404 | Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." |
| 5392 | (save-excursion | 5405 | (save-excursion |
| 5393 | (let* ((starting_position (point)) | 5406 | (let* ((starting_position (point)) |
| 5407 | (case-fold-search nil) | ||
| 5394 | (par 0) | 5408 | (par 0) |
| 5395 | (begin (looking-at "[ \t]*begin\\>")) | 5409 | (begin (looking-at "[ \t]*begin\\>")) |
| 5396 | (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) | 5410 | (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) |
| @@ -5412,132 +5426,132 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5412 | (not (or (looking-at "[ \t]*`[ou]vm_") | 5426 | (not (or (looking-at "[ \t]*`[ou]vm_") |
| 5413 | (looking-at "[ \t]*`vmm_"))))) | 5427 | (looking-at "[ \t]*`vmm_"))))) |
| 5414 | (throw 'nesting 'directive)) | 5428 | (throw 'nesting 'directive)) |
| 5415 | ;; indent structs as if there were module level | 5429 | ;; indent structs as if there were module level |
| 5416 | (setq structres (verilog-in-struct-nested-p)) | 5430 | (setq structres (verilog-in-struct-nested-p)) |
| 5417 | (cond ((not structres) nil) | 5431 | (cond ((not structres) nil) |
| 5418 | ;;((and structres (equal (char-after) ?\})) (throw 'nesting 'struct-close)) | 5432 | ;;((and structres (equal (char-after) ?\})) (throw 'nesting 'struct-close)) |
| 5419 | ((> structres 0) (throw 'nesting 'nested-struct)) | 5433 | ((> structres 0) (throw 'nesting 'nested-struct)) |
| 5420 | ((= structres 0) (throw 'nesting 'block)) | 5434 | ((= structres 0) (throw 'nesting 'block)) |
| 5421 | (t nil)) | 5435 | (t nil)) |
| 5422 | 5436 | ||
| 5423 | ;; if we are in a parenthesized list, and the user likes to indent these, return. | 5437 | ;; if we are in a parenthesized list, and the user likes to indent these, return. |
| 5424 | ;; unless we are in the newfangled coverpoint or constraint blocks | 5438 | ;; unless we are in the newfangled coverpoint or constraint blocks |
| 5425 | (if (and | 5439 | (if (and |
| 5426 | verilog-indent-lists | 5440 | verilog-indent-lists |
| 5427 | (verilog-in-paren) | 5441 | (verilog-in-paren) |
| 5428 | (not (verilog-in-coverage-p)) | 5442 | (not (verilog-in-coverage-p)) |
| 5429 | ) | 5443 | ) |
| 5430 | (progn (setq par 1) | 5444 | (progn (setq par 1) |
| 5431 | (throw 'nesting 'block))) | 5445 | (throw 'nesting 'block))) |
| 5432 | 5446 | ||
| 5433 | ;; See if we are continuing a previous line | 5447 | ;; See if we are continuing a previous line |
| 5434 | (while t | 5448 | (while t |
| 5435 | ;; trap out if we crawl off the top of the buffer | 5449 | ;; trap out if we crawl off the top of the buffer |
| 5436 | (if (bobp) (throw 'nesting 'cpp)) | 5450 | (if (bobp) (throw 'nesting 'cpp)) |
| 5437 | 5451 | ||
| 5438 | (if (and (verilog-continued-line-1 lim) | 5452 | (if (and (verilog-continued-line-1 lim) |
| 5439 | (or (not (verilog-in-coverage-p)) | 5453 | (or (not (verilog-in-coverage-p)) |
| 5440 | (looking-at verilog-in-constraint-re) )) ;; may still get hosed if concat in constraint | 5454 | (looking-at verilog-in-constraint-re) )) ; may still get hosed if concat in constraint |
| 5441 | (let ((sp (point))) | 5455 | (let ((sp (point))) |
| 5442 | (if (and | 5456 | (if (and |
| 5443 | (not (looking-at verilog-complete-reg)) | 5457 | (not (looking-at verilog-complete-reg)) |
| 5444 | (verilog-continued-line-1 lim)) | 5458 | (verilog-continued-line-1 lim)) |
| 5445 | (progn (goto-char sp) | 5459 | (progn (goto-char sp) |
| 5446 | (throw 'nesting 'cexp)) | 5460 | (throw 'nesting 'cexp)) |
| 5447 | 5461 | ||
| 5448 | (goto-char sp)) | 5462 | (goto-char sp)) |
| 5449 | (if (and (verilog-in-coverage-p) | 5463 | (if (and (verilog-in-coverage-p) |
| 5450 | (looking-at verilog-in-constraint-re)) | 5464 | (looking-at verilog-in-constraint-re)) |
| 5451 | (progn | 5465 | (progn |
| 5452 | (beginning-of-line) | 5466 | (beginning-of-line) |
| 5453 | (skip-chars-forward " \t") | 5467 | (skip-chars-forward " \t") |
| 5454 | (throw 'nesting 'constraint))) | 5468 | (throw 'nesting 'constraint))) |
| 5455 | (if (and begin | 5469 | (if (and begin |
| 5456 | (not verilog-indent-begin-after-if) | 5470 | (not verilog-indent-begin-after-if) |
| 5457 | (looking-at verilog-no-indent-begin-re)) | 5471 | (looking-at verilog-no-indent-begin-re)) |
| 5458 | (progn | 5472 | (progn |
| 5459 | (beginning-of-line) | 5473 | (beginning-of-line) |
| 5460 | (skip-chars-forward " \t") | 5474 | (skip-chars-forward " \t") |
| 5461 | (throw 'nesting 'statement)) | 5475 | (throw 'nesting 'statement)) |
| 5462 | (progn | 5476 | (progn |
| 5463 | (throw 'nesting 'cexp)))) | 5477 | (throw 'nesting 'cexp)))) |
| 5464 | ;; not a continued line | 5478 | ;; not a continued line |
| 5465 | (goto-char starting_position)) | 5479 | (goto-char starting_position)) |
| 5466 | 5480 | ||
| 5467 | (if (looking-at "\\<else\\>") | 5481 | (if (looking-at "\\<else\\>") |
| 5468 | ;; search back for governing if, striding across begin..end pairs | 5482 | ;; search back for governing if, striding across begin..end pairs |
| 5469 | ;; appropriately | 5483 | ;; appropriately |
| 5470 | (let ((elsec 1)) | 5484 | (let ((elsec 1)) |
| 5471 | (while (verilog-re-search-backward verilog-ends-re nil 'move) | 5485 | (while (verilog-re-search-backward verilog-ends-re nil 'move) |
| 5472 | (cond | 5486 | (cond |
| 5473 | ((match-end 1) ; else, we're in deep | 5487 | ((match-end 1) ; else, we're in deep |
| 5474 | (setq elsec (1+ elsec))) | 5488 | (setq elsec (1+ elsec))) |
| 5475 | ((match-end 2) ; if | 5489 | ((match-end 2) ; if |
| 5476 | (setq elsec (1- elsec)) | 5490 | (setq elsec (1- elsec)) |
| 5477 | (if (= 0 elsec) | 5491 | (if (= 0 elsec) |
| 5478 | (if verilog-align-ifelse | 5492 | (if verilog-align-ifelse |
| 5479 | (throw 'nesting 'statement) | 5493 | (throw 'nesting 'statement) |
| 5480 | (progn ;; back up to first word on this line | 5494 | (progn ; back up to first word on this line |
| 5481 | (beginning-of-line) | 5495 | (beginning-of-line) |
| 5482 | (verilog-forward-syntactic-ws) | 5496 | (verilog-forward-syntactic-ws) |
| 5483 | (throw 'nesting 'statement))))) | 5497 | (throw 'nesting 'statement))))) |
| 5484 | ((match-end 3) ; assert block | 5498 | ((match-end 3) ; assert block |
| 5485 | (setq elsec (1- elsec)) | 5499 | (setq elsec (1- elsec)) |
| 5486 | (verilog-beg-of-statement) ;; doesn't get to beginning | 5500 | (verilog-beg-of-statement) ; doesn't get to beginning |
| 5487 | (if (looking-at verilog-property-re) | 5501 | (if (looking-at verilog-property-re) |
| 5488 | (throw 'nesting 'statement) ; We don't need an endproperty for these | 5502 | (throw 'nesting 'statement) ; We don't need an endproperty for these |
| 5489 | (throw 'nesting 'block) ;We still need an endproperty | 5503 | (throw 'nesting 'block) ; We still need an endproperty |
| 5490 | )) | 5504 | )) |
| 5491 | (t ; endblock | 5505 | (t ; endblock |
| 5492 | ; try to leap back to matching outward block by striding across | 5506 | ;; try to leap back to matching outward block by striding across |
| 5493 | ; indent level changing tokens then immediately | 5507 | ;; indent level changing tokens then immediately |
| 5494 | ; previous line governs indentation. | 5508 | ;; previous line governs indentation. |
| 5495 | (let (( reg) (nest 1)) | 5509 | (let (( reg) (nest 1)) |
| 5496 | ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup | 5510 | ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup |
| 5497 | (cond | 5511 | (cond |
| 5498 | ((match-end 4) ; end | 5512 | ((match-end 4) ; end |
| 5499 | ;; Search back for matching begin | 5513 | ;; Search back for matching begin |
| 5500 | (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | 5514 | (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) |
| 5501 | ((match-end 5) ; endcase | 5515 | ((match-end 5) ; endcase |
| 5502 | ;; Search back for matching case | 5516 | ;; Search back for matching case |
| 5503 | (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | 5517 | (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) |
| 5504 | ((match-end 6) ; endfunction | 5518 | ((match-end 6) ; endfunction |
| 5505 | ;; Search back for matching function | 5519 | ;; Search back for matching function |
| 5506 | (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | 5520 | (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) |
| 5507 | ((match-end 7) ; endtask | 5521 | ((match-end 7) ; endtask |
| 5508 | ;; Search back for matching task | 5522 | ;; Search back for matching task |
| 5509 | (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | 5523 | (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) |
| 5510 | ((match-end 8) ; endspecify | 5524 | ((match-end 8) ; endspecify |
| 5511 | ;; Search back for matching specify | 5525 | ;; Search back for matching specify |
| 5512 | (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | 5526 | (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) |
| 5513 | ((match-end 9) ; endtable | 5527 | ((match-end 9) ; endtable |
| 5514 | ;; Search back for matching table | 5528 | ;; Search back for matching table |
| 5515 | (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | 5529 | (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) |
| 5516 | ((match-end 10) ; endgenerate | 5530 | ((match-end 10) ; endgenerate |
| 5517 | ;; Search back for matching generate | 5531 | ;; Search back for matching generate |
| 5518 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | 5532 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) |
| 5519 | ((match-end 11) ; joins | 5533 | ((match-end 11) ; joins |
| 5520 | ;; Search back for matching fork | 5534 | ;; Search back for matching fork |
| 5521 | (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) | 5535 | (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) |
| 5522 | ((match-end 12) ; class | 5536 | ((match-end 12) ; class |
| 5523 | ;; Search back for matching class | 5537 | ;; Search back for matching class |
| 5524 | (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | 5538 | (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) |
| 5525 | ((match-end 13) ; covergroup | 5539 | ((match-end 13) ; covergroup |
| 5526 | ;; Search back for matching covergroup | 5540 | ;; Search back for matching covergroup |
| 5527 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) | 5541 | (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
| 5528 | (catch 'skip | 5542 | (catch 'skip |
| 5529 | (while (verilog-re-search-backward reg nil 'move) | 5543 | (while (verilog-re-search-backward reg nil 'move) |
| 5530 | (cond | 5544 | (cond |
| 5531 | ((match-end 1) ; begin | 5545 | ((match-end 1) ; begin |
| 5532 | (setq nest (1- nest)) | 5546 | (setq nest (1- nest)) |
| 5533 | (if (= 0 nest) | 5547 | (if (= 0 nest) |
| 5534 | (throw 'skip 1))) | 5548 | (throw 'skip 1))) |
| 5535 | ((match-end 2) ; end | 5549 | ((match-end 2) ; end |
| 5536 | (setq nest (1+ nest))))) | 5550 | (setq nest (1+ nest))))) |
| 5537 | ))))))) | 5551 | ))))))) |
| 5538 | (throw 'nesting (verilog-calc-1))) | 5552 | (throw 'nesting (verilog-calc-1))) |
| 5539 | );; catch nesting | 5553 | ) ; catch nesting |
| 5540 | );; type | 5554 | ) ; type |
| 5541 | ) | 5555 | ) |
| 5542 | ;; Return type of block and indent level. | 5556 | ;; Return type of block and indent level. |
| 5543 | (if (not type) | 5557 | (if (not type) |
| @@ -5545,18 +5559,18 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5545 | (if (> par 0) ; Unclosed Parenthesis | 5559 | (if (> par 0) ; Unclosed Parenthesis |
| 5546 | (list 'cparenexp par) | 5560 | (list 'cparenexp par) |
| 5547 | (cond | 5561 | (cond |
| 5548 | ((eq type 'case) | 5562 | ((eq type 'case) |
| 5549 | (list type (verilog-case-indent-level))) | 5563 | (list type (verilog-case-indent-level))) |
| 5550 | ((eq type 'statement) | 5564 | ((eq type 'statement) |
| 5551 | (list type (current-column))) | 5565 | (list type (current-column))) |
| 5552 | ((eq type 'defun) | 5566 | ((eq type 'defun) |
| 5553 | (list type 0)) | 5567 | (list type 0)) |
| 5554 | ((eq type 'constraint) | 5568 | ((eq type 'constraint) |
| 5555 | (list 'block (current-column))) | 5569 | (list 'block (current-column))) |
| 5556 | ((eq type 'nested-struct) | 5570 | ((eq type 'nested-struct) |
| 5557 | (list 'block structres)) | 5571 | (list 'block structres)) |
| 5558 | (t | 5572 | (t |
| 5559 | (list type (verilog-current-indent-level)))))))) | 5573 | (list type (verilog-current-indent-level)))))))) |
| 5560 | 5574 | ||
| 5561 | (defun verilog-wai () | 5575 | (defun verilog-wai () |
| 5562 | "Show matching nesting block for debugging." | 5576 | "Show matching nesting block for debugging." |
| @@ -5570,18 +5584,18 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5570 | (if (and | 5584 | (if (and |
| 5571 | verilog-indent-lists | 5585 | verilog-indent-lists |
| 5572 | (not(or (verilog-in-coverage-p) | 5586 | (not(or (verilog-in-coverage-p) |
| 5573 | (verilog-in-struct-p))) | 5587 | (verilog-in-struct-p))) |
| 5574 | (verilog-in-paren)) | 5588 | (verilog-in-paren)) |
| 5575 | (setq depth 1) | 5589 | (setq depth 1) |
| 5576 | (cond | 5590 | (cond |
| 5577 | ((eq type 'case) | 5591 | ((eq type 'case) |
| 5578 | (setq depth (verilog-case-indent-level))) | 5592 | (setq depth (verilog-case-indent-level))) |
| 5579 | ((eq type 'statement) | 5593 | ((eq type 'statement) |
| 5580 | (setq depth (current-column))) | 5594 | (setq depth (current-column))) |
| 5581 | ((eq type 'defun) | 5595 | ((eq type 'defun) |
| 5582 | (setq depth 0)) | 5596 | (setq depth 0)) |
| 5583 | (t | 5597 | (t |
| 5584 | (setq depth (verilog-current-indent-level))))) | 5598 | (setq depth (verilog-current-indent-level))))) |
| 5585 | (message "You are at nesting %s depth %d" type depth)))) | 5599 | (message "You are at nesting %s depth %d" type depth)))) |
| 5586 | 5600 | ||
| 5587 | (defun verilog-calc-1 () | 5601 | (defun verilog-calc-1 () |
| @@ -5589,108 +5603,115 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5589 | (let ((re (concat "\\({\\|}\\|" verilog-indent-re "\\)")) | 5603 | (let ((re (concat "\\({\\|}\\|" verilog-indent-re "\\)")) |
| 5590 | (inconstraint (verilog-in-coverage-p))) | 5604 | (inconstraint (verilog-in-coverage-p))) |
| 5591 | (while (verilog-re-search-backward re nil 'move) | 5605 | (while (verilog-re-search-backward re nil 'move) |
| 5592 | (catch 'continue | 5606 | (catch 'continue |
| 5593 | (cond | 5607 | (cond |
| 5594 | ((equal (char-after) ?\{) | 5608 | ((equal (char-after) ?\{) |
| 5595 | ;; block type returned based on outer constraint { or inner | 5609 | ;; block type returned based on outer constraint { or inner |
| 5596 | (if (verilog-at-constraint-p) | 5610 | (if (verilog-at-constraint-p) |
| 5597 | (cond (inconstraint | 5611 | (cond (inconstraint |
| 5598 | (beginning-of-line nil) | 5612 | (beginning-of-line nil) |
| 5599 | (skip-chars-forward " \t") | 5613 | (skip-chars-forward " \t") |
| 5600 | (throw 'nesting 'constraint)) | 5614 | (throw 'nesting 'constraint)) |
| 5601 | (t | 5615 | (t |
| 5602 | (throw 'nesting 'statement))))) | 5616 | (throw 'nesting 'statement))))) |
| 5603 | ((equal (char-after) ?\}) | 5617 | ((equal (char-after) ?\}) |
| 5604 | (let (par-pos | 5618 | (let (par-pos |
| 5605 | (there (verilog-at-close-constraint-p))) | 5619 | (there (verilog-at-close-constraint-p))) |
| 5606 | (if there ;; we are at the } that closes a constraint. Find the { that opens it | 5620 | (if there ; we are at the } that closes a constraint. Find the { that opens it |
| 5607 | (progn | 5621 | (progn |
| 5608 | (if (> (verilog-in-paren-count) 0) | 5622 | (if (> (verilog-in-paren-count) 0) |
| 5609 | (forward-char 1)) | 5623 | (forward-char 1)) |
| 5610 | (setq par-pos (verilog-parenthesis-depth)) | 5624 | (setq par-pos (verilog-parenthesis-depth)) |
| 5611 | (cond (par-pos | 5625 | (cond (par-pos |
| 5612 | (goto-char par-pos) | 5626 | (goto-char par-pos) |
| 5613 | (forward-char 1)) | 5627 | (forward-char 1)) |
| 5614 | (t | 5628 | (t |
| 5615 | (backward-char 1))))))) | 5629 | (backward-char 1))))))) |
| 5616 | 5630 | ||
| 5617 | ((looking-at verilog-beg-block-re-ordered) | 5631 | ((looking-at verilog-beg-block-re-ordered) |
| 5618 | (cond | 5632 | (cond |
| 5619 | ((match-end 2) ; *sigh* could be "unique case" or "priority casex" | 5633 | ((match-end 2) ; *sigh* could be "unique case" or "priority casex" |
| 5620 | (let ((here (point))) | 5634 | (let ((here (point))) |
| 5621 | (verilog-beg-of-statement) | 5635 | (verilog-beg-of-statement) |
| 5622 | (if (looking-at verilog-extended-case-re) | 5636 | (if (looking-at verilog-extended-case-re) |
| 5623 | (throw 'nesting 'case) | 5637 | (throw 'nesting 'case) |
| 5624 | (goto-char here))) | 5638 | (goto-char here))) |
| 5625 | (throw 'nesting 'case)) | 5639 | (throw 'nesting 'case)) |
| 5626 | 5640 | ||
| 5627 | ((match-end 4) ; *sigh* could be "disable fork" | 5641 | ((match-end 4) ; *sigh* could be "disable fork" |
| 5628 | (let ((here (point))) | 5642 | (let ((here (point))) |
| 5629 | (verilog-beg-of-statement) | 5643 | (verilog-beg-of-statement) |
| 5630 | (if (looking-at verilog-disable-fork-re) | 5644 | (if (looking-at verilog-disable-fork-re) |
| 5631 | t ; this is a normal statement | 5645 | t ; this is a normal statement |
| 5632 | (progn ; or is fork, starts a new block | 5646 | (progn ; or is fork, starts a new block |
| 5633 | (goto-char here) | 5647 | (goto-char here) |
| 5634 | (throw 'nesting 'block))))) | 5648 | (throw 'nesting 'block))))) |
| 5635 | 5649 | ||
| 5636 | ((match-end 27) ; *sigh* might be a clocking declaration | 5650 | ((match-end 27) ; *sigh* might be a clocking declaration |
| 5637 | (let ((here (point))) | 5651 | (let ((here (point))) |
| 5638 | (if (verilog-in-paren) | 5652 | (if (verilog-in-paren) |
| 5639 | t ; this is a normal statement | 5653 | t ; this is a normal statement |
| 5640 | (progn ; or is fork, starts a new block | 5654 | (progn ; or is fork, starts a new block |
| 5641 | (goto-char here) | 5655 | (goto-char here) |
| 5642 | (throw 'nesting 'block))))) | 5656 | (throw 'nesting 'block))))) |
| 5643 | 5657 | ||
| 5644 | ;; need to consider typedef struct here... | 5658 | ;; need to consider typedef struct here... |
| 5645 | ((looking-at "\\<class\\|struct\\|function\\|task\\>") | 5659 | ((looking-at "\\<class\\|struct\\|function\\|task\\>") |
| 5646 | ; *sigh* These words have an optional prefix: | 5660 | ;; *sigh* These words have an optional prefix: |
| 5647 | ; extern {virtual|protected}? function a(); | 5661 | ;; extern {virtual|protected}? function a(); |
| 5648 | ; typedef class foo; | 5662 | ;; typedef class foo; |
| 5649 | ; and we don't want to confuse this with | 5663 | ;; and we don't want to confuse this with |
| 5650 | ; function a(); | 5664 | ;; function a(); |
| 5651 | ; property | 5665 | ;; property |
| 5652 | ; ... | 5666 | ;; ... |
| 5653 | ; endfunction | 5667 | ;; endfunction |
| 5654 | (verilog-beg-of-statement) | 5668 | (verilog-beg-of-statement) |
| 5655 | (if (looking-at verilog-beg-block-re-ordered) | 5669 | (cond |
| 5656 | (throw 'nesting 'block) | 5670 | ((looking-at verilog-dpi-import-export-re) |
| 5657 | (throw 'nesting 'defun))) | 5671 | (throw 'continue 'foo)) |
| 5658 | 5672 | ((looking-at "\\<pure\\>\\s-+\\<virtual\\>\\s-+\\(?:\\<\\(local\\|protected\\|static\\)\\>\\s-+\\)?\\<\\(function\\|task\\)\\>\\s-+") | |
| 5659 | ;; | 5673 | (throw 'nesting 'statement)) |
| 5660 | ((looking-at "\\<property\\>") | 5674 | ((looking-at verilog-beg-block-re-ordered) |
| 5661 | ; *sigh* | 5675 | (throw 'nesting 'block)) |
| 5662 | ; {assert|assume|cover} property (); are complete | 5676 | (t |
| 5663 | ; and could also be labeled: - foo: assert property | 5677 | (throw 'nesting 'defun)))) |
| 5664 | ; but | 5678 | |
| 5665 | ; property ID () ... needs end_property | 5679 | ;; |
| 5666 | (verilog-beg-of-statement) | 5680 | ((looking-at "\\<property\\>") |
| 5667 | (if (looking-at verilog-property-re) | 5681 | ;; *sigh* |
| 5668 | (throw 'continue 'statement) ; We don't need an endproperty for these | 5682 | ;; {assert|assume|cover} property (); are complete |
| 5669 | (throw 'nesting 'block) ;We still need an endproperty | 5683 | ;; and could also be labeled: - foo: assert property |
| 5670 | )) | 5684 | ;; but |
| 5671 | 5685 | ;; property ID () ... needs end_property | |
| 5672 | (t (throw 'nesting 'block)))) | 5686 | (verilog-beg-of-statement) |
| 5673 | 5687 | (if (looking-at verilog-property-re) | |
| 5674 | ((looking-at verilog-end-block-re) | 5688 | (throw 'continue 'statement) ; We don't need an endproperty for these |
| 5675 | (verilog-leap-to-head) | 5689 | (throw 'nesting 'block) ;We still need an endproperty |
| 5676 | (if (verilog-in-case-region-p) | 5690 | )) |
| 5677 | (progn | 5691 | |
| 5678 | (verilog-leap-to-case-head) | 5692 | (t (throw 'nesting 'block)))) |
| 5679 | (if (looking-at verilog-extended-case-re) | 5693 | |
| 5680 | (throw 'nesting 'case))))) | 5694 | ((looking-at verilog-end-block-re) |
| 5681 | 5695 | (verilog-leap-to-head) | |
| 5682 | ((looking-at verilog-defun-level-re) | 5696 | (if (verilog-in-case-region-p) |
| 5683 | (if (looking-at verilog-defun-level-generate-only-re) | 5697 | (progn |
| 5684 | (if (verilog-in-generate-region-p) | 5698 | (verilog-leap-to-case-head) |
| 5685 | (throw 'continue 'foo) ; always block in a generate - keep looking | 5699 | (if (looking-at verilog-extended-case-re) |
| 5686 | (throw 'nesting 'defun)) | 5700 | (throw 'nesting 'case))))) |
| 5687 | (throw 'nesting 'defun))) | 5701 | |
| 5688 | 5702 | ((looking-at verilog-defun-level-re) | |
| 5689 | ((looking-at verilog-cpp-level-re) | 5703 | (if (looking-at verilog-defun-level-generate-only-re) |
| 5690 | (throw 'nesting 'cpp)) | 5704 | (if (or (verilog-in-generate-region-p) |
| 5691 | 5705 | (verilog-in-deferred-immediate-final-p)) | |
| 5692 | ((bobp) | 5706 | (throw 'continue 'foo) ; always block in a generate - keep looking |
| 5693 | (throw 'nesting 'cpp))))) | 5707 | (throw 'nesting 'defun)) |
| 5708 | (throw 'nesting 'defun))) | ||
| 5709 | |||
| 5710 | ((looking-at verilog-cpp-level-re) | ||
| 5711 | (throw 'nesting 'cpp)) | ||
| 5712 | |||
| 5713 | ((bobp) | ||
| 5714 | (throw 'nesting 'cpp))))) | ||
| 5694 | 5715 | ||
| 5695 | (throw 'nesting 'cpp)))) | 5716 | (throw 'nesting 'cpp)))) |
| 5696 | 5717 | ||
| @@ -5698,8 +5719,8 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." | |||
| 5698 | "Return indentation level for directive. | 5719 | "Return indentation level for directive. |
| 5699 | For speed, the searcher looks at the last directive, not the indent | 5720 | For speed, the searcher looks at the last directive, not the indent |
| 5700 | of the appropriate enclosing block." | 5721 | of the appropriate enclosing block." |
| 5701 | (let ((base -1) ;; Indent of the line that determines our indentation | 5722 | (let ((base -1) ; Indent of the line that determines our indentation |
| 5702 | (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) | 5723 | (ind 0)) ; Relative offset caused by other directives (like `endif on same line as `else) |
| 5703 | ;; Start at current location, scan back for another directive | 5724 | ;; Start at current location, scan back for another directive |
| 5704 | 5725 | ||
| 5705 | (save-excursion | 5726 | (save-excursion |
| @@ -5708,9 +5729,9 @@ of the appropriate enclosing block." | |||
| 5708 | (verilog-re-search-backward verilog-directive-re nil t)) | 5729 | (verilog-re-search-backward verilog-directive-re nil t)) |
| 5709 | (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | 5730 | (cond ((save-excursion (skip-chars-backward " \t") (bolp)) |
| 5710 | (setq base (current-indentation)))) | 5731 | (setq base (current-indentation)))) |
| 5711 | (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL | 5732 | (cond ((and (looking-at verilog-directive-end) (< base 0)) ; Only matters when not at BOL |
| 5712 | (setq ind (- ind verilog-indent-level-directive))) | 5733 | (setq ind (- ind verilog-indent-level-directive))) |
| 5713 | ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | 5734 | ((and (looking-at verilog-directive-middle) (>= base 0)) ; Only matters when at BOL |
| 5714 | (setq ind (+ ind verilog-indent-level-directive))) | 5735 | (setq ind (+ ind verilog-indent-level-directive))) |
| 5715 | ((looking-at verilog-directive-begin) | 5736 | ((looking-at verilog-directive-begin) |
| 5716 | (setq ind (+ ind verilog-indent-level-directive))))) | 5737 | (setq ind (+ ind verilog-indent-level-directive))))) |
| @@ -5723,7 +5744,7 @@ of the appropriate enclosing block." | |||
| 5723 | (cond ((or (looking-at verilog-directive-middle) | 5744 | (cond ((or (looking-at verilog-directive-middle) |
| 5724 | (looking-at verilog-directive-end)) | 5745 | (looking-at verilog-directive-end)) |
| 5725 | (setq ind (max 0 (- ind verilog-indent-level-directive)))))) | 5746 | (setq ind (max 0 (- ind verilog-indent-level-directive)))))) |
| 5726 | ind)) | 5747 | ind)) |
| 5727 | 5748 | ||
| 5728 | (defun verilog-leap-to-case-head () | 5749 | (defun verilog-leap-to-case-head () |
| 5729 | (let ((nest 1)) | 5750 | (let ((nest 1)) |
| @@ -5784,7 +5805,7 @@ Jump from end to matching begin, from endcase to matching case, and so on." | |||
| 5784 | ;; 8: Search back for matching function | 5805 | ;; 8: Search back for matching function |
| 5785 | (setq reg "\\(\\<function\\>\\)\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)+\\<function\\>\\)") | 5806 | (setq reg "\\(\\<function\\>\\)\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)+\\<function\\>\\)") |
| 5786 | (setq nesting 'no)) | 5807 | (setq nesting 'no)) |
| 5787 | ;;(setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | 5808 | ;;(setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) |
| 5788 | ((looking-at "\\<endgenerate\\>") | 5809 | ((looking-at "\\<endgenerate\\>") |
| 5789 | ;; 8: Search back for matching generate | 5810 | ;; 8: Search back for matching generate |
| 5790 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | 5811 | (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) |
| @@ -5870,7 +5891,7 @@ Set point to where line starts." | |||
| 5870 | (save-excursion | 5891 | (save-excursion |
| 5871 | (skip-chars-backward " \t") | 5892 | (skip-chars-backward " \t") |
| 5872 | (not (bolp)))) | 5893 | (not (bolp)))) |
| 5873 | (setq continued (verilog-backward-token))))) | 5894 | (setq continued (verilog-backward-token))))) |
| 5874 | (setq continued nil)) | 5895 | (setq continued nil)) |
| 5875 | continued)) | 5896 | continued)) |
| 5876 | 5897 | ||
| @@ -5884,14 +5905,14 @@ Set point to where line starts." | |||
| 5884 | (;-- Anything ending in a ; is complete | 5905 | (;-- Anything ending in a ; is complete |
| 5885 | (= (preceding-char) ?\;) | 5906 | (= (preceding-char) ?\;) |
| 5886 | nil) | 5907 | nil) |
| 5887 | (; If a "}" is prefixed by a ";", then this is a complete statement | 5908 | (; If a "}" is prefixed by a ";", then this is a complete statement |
| 5888 | ; i.e.: constraint foo { a = b; } | 5909 | ;; i.e.: constraint foo { a = b; } |
| 5889 | (= (preceding-char) ?\}) | 5910 | (= (preceding-char) ?\}) |
| 5890 | (progn | 5911 | (progn |
| 5891 | (backward-char) | 5912 | (backward-char) |
| 5892 | (not(verilog-at-close-constraint-p)))) | 5913 | (not(verilog-at-close-constraint-p)))) |
| 5893 | (;-- constraint foo { a = b } | 5914 | (;-- constraint foo { a = b } |
| 5894 | ; is a complete statement. *sigh* | 5915 | ;; is a complete statement. *sigh* |
| 5895 | (= (preceding-char) ?\{) | 5916 | (= (preceding-char) ?\{) |
| 5896 | (progn | 5917 | (progn |
| 5897 | (backward-char) | 5918 | (backward-char) |
| @@ -5909,10 +5930,10 @@ Set point to where line starts." | |||
| 5909 | t) | 5930 | t) |
| 5910 | 5931 | ||
| 5911 | (;-- Could be 'case (foo)' or 'always @(bar)' which is complete | 5932 | (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
| 5912 | ; also could be simply '@(foo)' | 5933 | ;; also could be simply '@(foo)' |
| 5913 | ; or foo u1 #(a=8) | 5934 | ;; or foo u1 #(a=8) |
| 5914 | ; (b, ... which ISN'T complete | 5935 | ;; (b, ... which ISN'T complete |
| 5915 | ;;;; Do we need this??? | 5936 | ;; Do we need this??? |
| 5916 | (= (preceding-char) ?\)) | 5937 | (= (preceding-char) ?\)) |
| 5917 | (progn | 5938 | (progn |
| 5918 | (backward-char) | 5939 | (backward-char) |
| @@ -5936,16 +5957,16 @@ Set point to where line starts." | |||
| 5936 | t) | 5957 | t) |
| 5937 | ((looking-at verilog-ovm-end-re) | 5958 | ((looking-at verilog-ovm-end-re) |
| 5938 | t) | 5959 | t) |
| 5939 | ;; JBA find VMM macros | 5960 | ;; JBA find VMM macros |
| 5940 | ((looking-at verilog-vmm-statement-re) | 5961 | ((looking-at verilog-vmm-statement-re) |
| 5941 | nil ) | 5962 | nil ) |
| 5942 | ((looking-at verilog-vmm-begin-re) | 5963 | ((looking-at verilog-vmm-begin-re) |
| 5943 | t) | 5964 | t) |
| 5944 | ((looking-at verilog-vmm-end-re) | 5965 | ((looking-at verilog-vmm-end-re) |
| 5945 | nil) | 5966 | nil) |
| 5946 | ;; JBA trying to catch macro lines with no ; at end | 5967 | ;; JBA trying to catch macro lines with no ; at end |
| 5947 | ((looking-at "\\<`") | 5968 | ((looking-at "\\<`") |
| 5948 | nil) | 5969 | nil) |
| 5949 | (t | 5970 | (t |
| 5950 | (goto-char back) | 5971 | (goto-char back) |
| 5951 | (cond | 5972 | (cond |
| @@ -6003,16 +6024,16 @@ Set point to where line starts." | |||
| 6003 | (defun verilog-backward-syntactic-ws-quick () | 6024 | (defun verilog-backward-syntactic-ws-quick () |
| 6004 | "As with `verilog-backward-syntactic-ws' but use `verilog-scan' cache." | 6025 | "As with `verilog-backward-syntactic-ws' but use `verilog-scan' cache." |
| 6005 | (while (cond ((bobp) | 6026 | (while (cond ((bobp) |
| 6006 | nil) ; Done | 6027 | nil) ; Done |
| 6007 | ((> (skip-syntax-backward " ") 0) | 6028 | ((< (skip-syntax-backward " ") 0) |
| 6008 | t) | 6029 | t) |
| 6009 | ((eq (preceding-char) ?\n) ;; \n's terminate // so aren't space syntax | 6030 | ((eq (preceding-char) ?\n) ; \n's terminate // so aren't space syntax |
| 6010 | (forward-char -1) | 6031 | (forward-char -1) |
| 6011 | t) | 6032 | t) |
| 6012 | ((or (verilog-inside-comment-or-string-p (1- (point))) | 6033 | ((or (verilog-inside-comment-or-string-p (1- (point))) |
| 6013 | (verilog-inside-comment-or-string-p (point))) | 6034 | (verilog-inside-comment-or-string-p (point))) |
| 6014 | (re-search-backward "[/\"]" nil t) ;; Only way a comment or quote can begin | 6035 | (re-search-backward "[/\"]" nil t) ; Only way a comment or quote can begin |
| 6015 | t)))) | 6036 | t)))) |
| 6016 | 6037 | ||
| 6017 | (defun verilog-forward-syntactic-ws () | 6038 | (defun verilog-forward-syntactic-ws () |
| 6018 | (verilog-skip-forward-comment-p) | 6039 | (verilog-skip-forward-comment-p) |
| @@ -6029,10 +6050,10 @@ Optional BOUND limits search." | |||
| 6029 | (progn | 6050 | (progn |
| 6030 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6051 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6031 | (cond | 6052 | (cond |
| 6032 | ((nth 7 state) ;; in // comment | 6053 | ((nth 7 state) ; in // comment |
| 6033 | (verilog-re-search-backward "//" nil 'move) | 6054 | (verilog-re-search-backward "//" nil 'move) |
| 6034 | (skip-chars-backward "/")) | 6055 | (skip-chars-backward "/")) |
| 6035 | ((nth 4 state) ;; in /* */ comment | 6056 | ((nth 4 state) ; in /* */ comment |
| 6036 | (verilog-re-search-backward "/\*" nil 'move)))) | 6057 | (verilog-re-search-backward "/\*" nil 'move)))) |
| 6037 | (narrow-to-region bound (point)) | 6058 | (narrow-to-region bound (point)) |
| 6038 | (while (/= here (point)) | 6059 | (while (/= here (point)) |
| @@ -6041,6 +6062,9 @@ Optional BOUND limits search." | |||
| 6041 | (setq p | 6062 | (setq p |
| 6042 | (save-excursion | 6063 | (save-excursion |
| 6043 | (beginning-of-line) | 6064 | (beginning-of-line) |
| 6065 | ;; for as long as we're right after a continued line, keep moving up | ||
| 6066 | (while (and (verilog-looking-back "\\\\[\n\r\f]" nil) | ||
| 6067 | (forward-line -1))) | ||
| 6044 | (cond | 6068 | (cond |
| 6045 | ((and verilog-highlight-translate-off | 6069 | ((and verilog-highlight-translate-off |
| 6046 | (verilog-within-translate-off)) | 6070 | (verilog-within-translate-off)) |
| @@ -6062,19 +6086,19 @@ Optional BOUND limits search." | |||
| 6062 | (progn | 6086 | (progn |
| 6063 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6087 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6064 | (cond | 6088 | (cond |
| 6065 | ((nth 7 state) ;; in // comment | 6089 | ((nth 7 state) ; in // comment |
| 6066 | (end-of-line) | 6090 | (end-of-line) |
| 6067 | (forward-char 1) | 6091 | (forward-char 1) |
| 6068 | (skip-chars-forward " \t\n\f") | 6092 | (skip-chars-forward " \t\n\f") |
| 6069 | ) | 6093 | ) |
| 6070 | ((nth 4 state) ;; in /* */ comment | 6094 | ((nth 4 state) ; in /* */ comment |
| 6071 | (verilog-re-search-forward "\*\/\\s-*" nil 'move)))) | 6095 | (verilog-re-search-forward "\*\/\\s-*" nil 'move)))) |
| 6072 | (narrow-to-region (point) bound) | 6096 | (narrow-to-region (point) bound) |
| 6073 | (while (/= here (point)) | 6097 | (while (/= here (point)) |
| 6074 | (setq here (point) | 6098 | (setq here (point) |
| 6075 | jump nil) | 6099 | jump nil) |
| 6076 | (forward-comment (buffer-size)) | 6100 | (forward-comment (buffer-size)) |
| 6077 | (and (looking-at "\\s-*(\\*.*\\*)\\s-*") ;; Attribute | 6101 | (and (looking-at "\\s-*(\\*.*\\*)\\s-*") ; Attribute |
| 6078 | (goto-char (match-end 0))) | 6102 | (goto-char (match-end 0))) |
| 6079 | (save-excursion | 6103 | (save-excursion |
| 6080 | (beginning-of-line) | 6104 | (beginning-of-line) |
| @@ -6084,38 +6108,38 @@ Optional BOUND limits search." | |||
| 6084 | (beginning-of-line 2)))))))) | 6108 | (beginning-of-line 2)))))))) |
| 6085 | 6109 | ||
| 6086 | (defun verilog-in-comment-p () | 6110 | (defun verilog-in-comment-p () |
| 6087 | "Return true if in a star or // comment." | 6111 | "Return true if in a star or // comment." |
| 6088 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6112 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6089 | (or (nth 4 state) (nth 7 state)))) | 6113 | (or (nth 4 state) (nth 7 state)))) |
| 6090 | 6114 | ||
| 6091 | (defun verilog-in-star-comment-p () | 6115 | (defun verilog-in-star-comment-p () |
| 6092 | "Return true if in a star comment." | 6116 | "Return true if in a star comment." |
| 6093 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6117 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6094 | (and | 6118 | (and |
| 6095 | (nth 4 state) ; t if in a comment of style a // or b /**/ | 6119 | (nth 4 state) ; t if in a comment of style a // or b /**/ |
| 6096 | (not | 6120 | (not |
| 6097 | (nth 7 state) ; t if in a comment of style b /**/ | 6121 | (nth 7 state) ; t if in a comment of style b /**/ |
| 6098 | )))) | 6122 | )))) |
| 6099 | 6123 | ||
| 6100 | (defun verilog-in-slash-comment-p () | 6124 | (defun verilog-in-slash-comment-p () |
| 6101 | "Return true if in a slash comment." | 6125 | "Return true if in a slash comment." |
| 6102 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6126 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6103 | (nth 7 state))) | 6127 | (nth 7 state))) |
| 6104 | 6128 | ||
| 6105 | (defun verilog-in-comment-or-string-p () | 6129 | (defun verilog-in-comment-or-string-p () |
| 6106 | "Return true if in a string or comment." | 6130 | "Return true if in a string or comment." |
| 6107 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6131 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6108 | (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) | 6132 | (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) |
| 6109 | 6133 | ||
| 6110 | (defun verilog-in-attribute-p () | 6134 | (defun verilog-in-attribute-p () |
| 6111 | "Return true if point is in an attribute (* [] attribute *)." | 6135 | "Return true if point is in an attribute (* [] attribute *)." |
| 6112 | (save-match-data | 6136 | (save-match-data |
| 6113 | (save-excursion | 6137 | (save-excursion |
| 6114 | (verilog-re-search-backward "\\((\\*\\)\\|\\(\\*)\\)" nil 'move) | 6138 | (verilog-re-search-backward "\\((\\*\\)\\|\\(\\*)\\)" nil 'move) |
| 6115 | (cond | 6139 | (cond |
| 6116 | ((match-end 1) | 6140 | ((match-end 1) |
| 6117 | (progn (goto-char (match-end 1)) | 6141 | (progn (goto-char (match-end 1)) |
| 6118 | (not (looking-at "\\s-*)"))) | 6142 | (not (looking-at "\\s-*)"))) |
| 6119 | nil) | 6143 | nil) |
| 6120 | ((match-end 2) | 6144 | ((match-end 2) |
| 6121 | (progn (goto-char (match-beginning 2)) | 6145 | (progn (goto-char (match-beginning 2)) |
| @@ -6124,91 +6148,93 @@ Optional BOUND limits search." | |||
| 6124 | (t nil))))) | 6148 | (t nil))))) |
| 6125 | 6149 | ||
| 6126 | (defun verilog-in-parameter-p () | 6150 | (defun verilog-in-parameter-p () |
| 6127 | "Return true if point is in a parameter assignment #( p1=1, p2=5)." | 6151 | "Return true if point is in a parameter assignment #( p1=1, p2=5)." |
| 6128 | (save-match-data | 6152 | (save-match-data |
| 6129 | (save-excursion | 6153 | (save-excursion |
| 6130 | (verilog-re-search-backward "\\(#(\\)\\|\\()\\)" nil 'move) | 6154 | (verilog-re-search-backward "\\(#(\\)\\|\\()\\)" nil 'move) |
| 6131 | (numberp (match-beginning 1))))) | 6155 | (numberp (match-beginning 1))))) |
| 6132 | 6156 | ||
| 6133 | (defun verilog-in-escaped-name-p () | 6157 | (defun verilog-in-escaped-name-p () |
| 6134 | "Return true if in an escaped name." | 6158 | "Return true if in an escaped name." |
| 6135 | (save-excursion | 6159 | (save-excursion |
| 6136 | (backward-char) | 6160 | (backward-char) |
| 6137 | (skip-chars-backward "^ \t\n\f") | 6161 | (skip-chars-backward "^ \t\n\f") |
| 6138 | (if (equal (char-after (point) ) ?\\ ) | 6162 | (if (equal (char-after (point) ) ?\\ ) |
| 6139 | t | 6163 | t |
| 6140 | nil))) | 6164 | nil))) |
| 6165 | |||
| 6141 | (defun verilog-in-directive-p () | 6166 | (defun verilog-in-directive-p () |
| 6142 | "Return true if in a directive." | 6167 | "Return true if in a directive." |
| 6143 | (save-excursion | 6168 | (save-excursion |
| 6144 | (beginning-of-line) | 6169 | (beginning-of-line) |
| 6145 | (looking-at verilog-directive-re-1))) | 6170 | (looking-at verilog-directive-re-1))) |
| 6146 | 6171 | ||
| 6147 | (defun verilog-in-parenthesis-p () | 6172 | (defun verilog-in-parenthesis-p () |
| 6148 | "Return true if in a ( ) expression (but not { } or [ ])." | 6173 | "Return true if in a ( ) expression (but not { } or [ ])." |
| 6149 | (save-match-data | 6174 | (save-match-data |
| 6150 | (save-excursion | 6175 | (save-excursion |
| 6151 | (verilog-re-search-backward "\\((\\)\\|\\()\\)" nil 'move) | 6176 | (verilog-re-search-backward "\\((\\)\\|\\()\\)" nil 'move) |
| 6152 | (numberp (match-beginning 1))))) | 6177 | (numberp (match-beginning 1))))) |
| 6153 | 6178 | ||
| 6154 | (defun verilog-in-paren () | 6179 | (defun verilog-in-paren () |
| 6155 | "Return true if in a parenthetical expression. | 6180 | "Return true if in a parenthetical expression. |
| 6156 | May cache result using `verilog-syntax-ppss'." | 6181 | May cache result using `verilog-syntax-ppss'." |
| 6157 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6182 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6158 | (> (nth 0 state) 0 ))) | 6183 | (> (nth 0 state) 0 ))) |
| 6159 | 6184 | ||
| 6160 | (defun verilog-in-paren-count () | 6185 | (defun verilog-in-paren-count () |
| 6161 | "Return paren depth, floor to 0. | 6186 | "Return paren depth, floor to 0. |
| 6162 | May cache result using `verilog-syntax-ppss'." | 6187 | May cache result using `verilog-syntax-ppss'." |
| 6163 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6188 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6164 | (if (> (nth 0 state) 0) | 6189 | (if (> (nth 0 state) 0) |
| 6165 | (nth 0 state) | 6190 | (nth 0 state) |
| 6166 | 0 ))) | 6191 | 0 ))) |
| 6167 | 6192 | ||
| 6168 | (defun verilog-in-paren-quick () | 6193 | (defun verilog-in-paren-quick () |
| 6169 | "Return true if in a parenthetical expression. | 6194 | "Return true if in a parenthetical expression. |
| 6170 | Always starts from `point-min', to allow inserts with hooks disabled." | 6195 | Always starts from `point-min', to allow inserts with hooks disabled." |
| 6171 | ;; The -quick refers to its use alongside the other -quick functions, | 6196 | ;; The -quick refers to its use alongside the other -quick functions, |
| 6172 | ;; not that it's likely to be faster than verilog-in-paren. | 6197 | ;; not that it's likely to be faster than verilog-in-paren. |
| 6173 | (let ((state (save-excursion (parse-partial-sexp (point-min) (point))))) | 6198 | (let ((state (save-excursion (parse-partial-sexp (point-min) (point))))) |
| 6174 | (> (nth 0 state) 0 ))) | 6199 | (> (nth 0 state) 0 ))) |
| 6175 | 6200 | ||
| 6176 | (defun verilog-in-struct-p () | 6201 | (defun verilog-in-struct-p () |
| 6177 | "Return true if in a struct declaration." | 6202 | "Return true if in a struct declaration." |
| 6178 | (interactive) | 6203 | (interactive) |
| 6179 | (save-excursion | 6204 | (save-excursion |
| 6180 | (if (verilog-in-paren) | 6205 | (if (verilog-in-paren) |
| 6181 | (progn | 6206 | (progn |
| 6182 | (verilog-backward-up-list 1) | 6207 | (verilog-backward-up-list 1) |
| 6183 | (verilog-at-struct-p) | 6208 | (verilog-at-struct-p) |
| 6184 | ) | 6209 | ) |
| 6185 | nil))) | 6210 | nil))) |
| 6186 | 6211 | ||
| 6187 | (defun verilog-in-struct-nested-p () | 6212 | (defun verilog-in-struct-nested-p () |
| 6188 | "Return nil for not in struct. | 6213 | "Return nil for not in struct. |
| 6189 | Return 0 for in non-nested struct. | 6214 | Return 0 for in non-nested struct. |
| 6190 | Return >0 for nested struct." | 6215 | Return >0 for nested struct." |
| 6191 | (interactive) | 6216 | (interactive) |
| 6192 | (let (col) | 6217 | (let (col) |
| 6193 | (save-excursion | 6218 | (save-excursion |
| 6194 | (if (verilog-in-paren) | 6219 | (if (verilog-in-paren) |
| 6195 | (progn | 6220 | (progn |
| 6196 | (verilog-backward-up-list 1) | 6221 | (verilog-backward-up-list 1) |
| 6197 | (setq col (verilog-at-struct-mv-p)) | 6222 | (setq col (verilog-at-struct-mv-p)) |
| 6198 | (if col | 6223 | (if col |
| 6199 | (if (verilog-in-struct-p) (current-column) 0))) | 6224 | (if (verilog-in-struct-p) (current-column) 0))) |
| 6200 | nil)))) | 6225 | nil)))) |
| 6201 | 6226 | ||
| 6202 | (defun verilog-in-coverage-p () | 6227 | (defun verilog-in-coverage-p () |
| 6203 | "Return true if in a constraint or coverpoint expression." | 6228 | "Return true if in a constraint or coverpoint expression." |
| 6204 | (interactive) | 6229 | (interactive) |
| 6205 | (save-excursion | 6230 | (save-excursion |
| 6206 | (if (verilog-in-paren) | 6231 | (if (verilog-in-paren) |
| 6207 | (progn | 6232 | (progn |
| 6208 | (verilog-backward-up-list 1) | 6233 | (verilog-backward-up-list 1) |
| 6209 | (verilog-at-constraint-p) | 6234 | (verilog-at-constraint-p) |
| 6210 | ) | 6235 | ) |
| 6211 | nil))) | 6236 | nil))) |
| 6237 | |||
| 6212 | (defun verilog-at-close-constraint-p () | 6238 | (defun verilog-at-close-constraint-p () |
| 6213 | "If at the } that closes a constraint or covergroup, return true." | 6239 | "If at the } that closes a constraint or covergroup, return true." |
| 6214 | (if (and | 6240 | (if (and |
| @@ -6218,8 +6244,8 @@ Return >0 for nested struct." | |||
| 6218 | (save-excursion | 6244 | (save-excursion |
| 6219 | (verilog-backward-ws&directives) | 6245 | (verilog-backward-ws&directives) |
| 6220 | (if (or (equal (char-before) ?\;) | 6246 | (if (or (equal (char-before) ?\;) |
| 6221 | (equal (char-before) ?\}) ;; can end with inner constraint { } block or ; | 6247 | (equal (char-before) ?\}) ; can end with inner constraint { } block or ; |
| 6222 | (equal (char-before) ?\{)) ;; empty constraint block | 6248 | (equal (char-before) ?\{)) ; empty constraint block |
| 6223 | (point) | 6249 | (point) |
| 6224 | nil)))) | 6250 | nil)))) |
| 6225 | 6251 | ||
| @@ -6227,17 +6253,17 @@ Return >0 for nested struct." | |||
| 6227 | "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." | 6253 | "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." |
| 6228 | (if (save-excursion | 6254 | (if (save-excursion |
| 6229 | (let ((p (point))) | 6255 | (let ((p (point))) |
| 6230 | (and | 6256 | (and |
| 6231 | (equal (char-after) ?\{) | 6257 | (equal (char-after) ?\{) |
| 6232 | (forward-list) | 6258 | (forward-list) |
| 6233 | (progn (backward-char 1) | 6259 | (progn (backward-char 1) |
| 6234 | (verilog-backward-ws&directives) | 6260 | (verilog-backward-ws&directives) |
| 6235 | (and | 6261 | (and |
| 6236 | (or (equal (char-before) ?\{) ;; empty case | 6262 | (or (equal (char-before) ?\{) ; empty case |
| 6237 | (equal (char-before) ?\;) | 6263 | (equal (char-before) ?\;) |
| 6238 | (equal (char-before) ?\})) | 6264 | (equal (char-before) ?\})) |
| 6239 | ;; skip what looks like bus repetition operator {#{ | 6265 | ;; skip what looks like bus repetition operator {#{ |
| 6240 | (not (string-match "^{\\s-*[0-9]+\\s-*{" (buffer-substring p (point))))))))) | 6266 | (not (string-match "^{\\s-*[0-9]+\\s-*{" (buffer-substring p (point))))))))) |
| 6241 | (progn | 6267 | (progn |
| 6242 | (let ( (pt (point)) (pass 0)) | 6268 | (let ( (pt (point)) (pass 0)) |
| 6243 | (verilog-backward-ws&directives) | 6269 | (verilog-backward-ws&directives) |
| @@ -6246,7 +6272,7 @@ Return >0 for nested struct." | |||
| 6246 | (progn (setq pass 1) | 6272 | (progn (setq pass 1) |
| 6247 | (if (looking-at "\\<with\\>") | 6273 | (if (looking-at "\\<with\\>") |
| 6248 | (progn (verilog-backward-ws&directives) | 6274 | (progn (verilog-backward-ws&directives) |
| 6249 | (beginning-of-line) ;; 1 | 6275 | (beginning-of-line) ; 1 |
| 6250 | (verilog-forward-ws&directives) | 6276 | (verilog-forward-ws&directives) |
| 6251 | 1 ) | 6277 | 1 ) |
| 6252 | (verilog-beg-of-statement) | 6278 | (verilog-beg-of-statement) |
| @@ -6294,76 +6320,78 @@ Return >0 for nested struct." | |||
| 6294 | nil)) | 6320 | nil)) |
| 6295 | 6321 | ||
| 6296 | (defun verilog-parenthesis-depth () | 6322 | (defun verilog-parenthesis-depth () |
| 6297 | "Return non zero if in parenthetical-expression." | 6323 | "Return non zero if in parenthetical-expression." |
| 6298 | (save-excursion (nth 1 (verilog-syntax-ppss)))) | 6324 | (save-excursion (nth 1 (verilog-syntax-ppss)))) |
| 6299 | 6325 | ||
| 6300 | 6326 | ||
| 6301 | (defun verilog-skip-forward-comment-or-string () | 6327 | (defun verilog-skip-forward-comment-or-string () |
| 6302 | "Return true if in a string or comment." | 6328 | "Return true if in a string or comment." |
| 6303 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6329 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6304 | (cond | 6330 | (cond |
| 6305 | ((nth 3 state) ;Inside string | 6331 | ((nth 3 state) ;Inside string |
| 6306 | (search-forward "\"") | 6332 | (search-forward "\"") |
| 6307 | t) | 6333 | t) |
| 6308 | ((nth 7 state) ;Inside // comment | 6334 | ((nth 7 state) ;Inside // comment |
| 6309 | (forward-line 1) | 6335 | (forward-line 1) |
| 6310 | t) | 6336 | t) |
| 6311 | ((nth 4 state) ;Inside any comment (hence /**/) | 6337 | ((nth 4 state) ;Inside any comment (hence /**/) |
| 6312 | (search-forward "*/")) | 6338 | (search-forward "*/")) |
| 6313 | (t | 6339 | (t |
| 6314 | nil)))) | 6340 | nil)))) |
| 6315 | 6341 | ||
| 6316 | (defun verilog-skip-backward-comment-or-string () | 6342 | (defun verilog-skip-backward-comment-or-string () |
| 6317 | "Return true if in a string or comment." | 6343 | "Return true if in a string or comment." |
| 6318 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6344 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6319 | (cond | 6345 | (cond |
| 6320 | ((nth 3 state) ;Inside string | 6346 | ((nth 3 state) ;Inside string |
| 6321 | (search-backward "\"") | 6347 | (search-backward "\"") |
| 6322 | t) | 6348 | t) |
| 6323 | ((nth 7 state) ;Inside // comment | 6349 | ((nth 7 state) ;Inside // comment |
| 6324 | (search-backward "//") | 6350 | (search-backward "//") |
| 6325 | (skip-chars-backward "/") | 6351 | (skip-chars-backward "/") |
| 6326 | t) | 6352 | t) |
| 6327 | ((nth 4 state) ;Inside /* */ comment | 6353 | ((nth 4 state) ;Inside /* */ comment |
| 6328 | (search-backward "/*") | 6354 | (search-backward "/*") |
| 6329 | t) | 6355 | t) |
| 6330 | (t | 6356 | (t |
| 6331 | nil)))) | 6357 | nil)))) |
| 6332 | 6358 | ||
| 6333 | (defun verilog-skip-backward-comments () | 6359 | (defun verilog-skip-backward-comments () |
| 6334 | "Return true if a comment was skipped." | 6360 | "Return true if a comment was skipped." |
| 6335 | (let ((more t)) | 6361 | (let ((more t)) |
| 6336 | (while more | 6362 | (while more |
| 6337 | (setq more | 6363 | (setq more |
| 6338 | (let ((state (save-excursion (verilog-syntax-ppss)))) | 6364 | (let ((state (save-excursion (verilog-syntax-ppss)))) |
| 6339 | (cond | 6365 | (cond |
| 6340 | ((nth 7 state) ;Inside // comment | 6366 | ((nth 7 state) ;Inside // comment |
| 6341 | (search-backward "//") | 6367 | (search-backward "//") |
| 6342 | (skip-chars-backward "/") | 6368 | (skip-chars-backward "/") |
| 6343 | (skip-chars-backward " \t\n\f") | 6369 | (skip-chars-backward " \t\n\f") |
| 6344 | t) | 6370 | t) |
| 6345 | ((nth 4 state) ;Inside /* */ comment | 6371 | ((nth 4 state) ;Inside /* */ comment |
| 6346 | (search-backward "/*") | 6372 | (search-backward "/*") |
| 6347 | (skip-chars-backward " \t\n\f") | 6373 | (skip-chars-backward " \t\n\f") |
| 6348 | t) | 6374 | t) |
| 6349 | ((and (not (bobp)) | 6375 | ((and (not (bobp)) |
| 6350 | (= (char-before) ?\/) | 6376 | (= (char-before) ?\/) |
| 6351 | (= (char-before (1- (point))) ?\*)) | 6377 | (= (char-before (1- (point))) ?\*)) |
| 6352 | (goto-char (- (point) 2)) | 6378 | (goto-char (- (point) 2)) |
| 6353 | t) ;; Let nth 4 state handle the rest | 6379 | t) ; Let nth 4 state handle the rest |
| 6354 | ((and (not (bobp)) | 6380 | ((and (not (bobp)) |
| 6355 | (verilog-looking-back "\\*)" nil) | 6381 | ;;(verilog-looking-back "\\*)" nil) ;; super slow, use two char-before instead |
| 6356 | (not (verilog-looking-back "(\\s-*\\*)" nil))) | 6382 | (= (char-before) ?\)) |
| 6357 | (goto-char (- (point) 2)) | 6383 | (= (char-before (1- (point))) ?\*) |
| 6358 | (if (search-backward "(*" nil t) | 6384 | (not (verilog-looking-back "(\\s-*\\*)" nil))) ;; slow but unlikely to be called |
| 6359 | (progn | 6385 | (goto-char (- (point) 2)) |
| 6360 | (skip-chars-backward " \t\n\f") | 6386 | (if (search-backward "(*" nil t) |
| 6361 | t) | 6387 | (progn |
| 6362 | (progn | 6388 | (skip-chars-backward " \t\n\f") |
| 6363 | (goto-char (+ (point) 2)) | 6389 | t) |
| 6364 | nil))) | 6390 | (progn |
| 6365 | (t | 6391 | (goto-char (+ (point) 2)) |
| 6366 | (/= (skip-chars-backward " \t\n\f") 0)))))))) | 6392 | nil))) |
| 6393 | (t | ||
| 6394 | (/= (skip-chars-backward " \t\n\f") 0)))))))) | ||
| 6367 | 6395 | ||
| 6368 | (defun verilog-skip-forward-comment-p () | 6396 | (defun verilog-skip-forward-comment-p () |
| 6369 | "If in comment, move to end and return true." | 6397 | "If in comment, move to end and return true." |
| @@ -6397,7 +6425,7 @@ Return >0 for nested struct." | |||
| 6397 | (progn | 6425 | (progn |
| 6398 | (goto-char h) | 6426 | (goto-char h) |
| 6399 | nil)))) | 6427 | nil)))) |
| 6400 | ((and (looking-at "(\\*") ;; attribute start, but not an event (*) or (* ) | 6428 | ((and (looking-at "(\\*") ; attribute start, but not an event (*) or (* ) |
| 6401 | (not (looking-at "(\\*\\s-*)"))) | 6429 | (not (looking-at "(\\*\\s-*)"))) |
| 6402 | (progn | 6430 | (progn |
| 6403 | (setq h (point)) | 6431 | (setq h (point)) |
| @@ -6463,7 +6491,7 @@ Only look at a few lines to determine indent level." | |||
| 6463 | (verilog-beg-of-statement-1) | 6491 | (verilog-beg-of-statement-1) |
| 6464 | (setq fst (point)) | 6492 | (setq fst (point)) |
| 6465 | (if (looking-at verilog-declaration-re) | 6493 | (if (looking-at verilog-declaration-re) |
| 6466 | (progn ;; we have multiple words | 6494 | (progn ; we have multiple words |
| 6467 | (goto-char (match-end 0)) | 6495 | (goto-char (match-end 0)) |
| 6468 | (skip-chars-forward " \t") | 6496 | (skip-chars-forward " \t") |
| 6469 | (cond | 6497 | (cond |
| @@ -6497,7 +6525,11 @@ Only look at a few lines to determine indent level." | |||
| 6497 | (let ((val)) | 6525 | (let ((val)) |
| 6498 | (verilog-beg-of-statement-1) | 6526 | (verilog-beg-of-statement-1) |
| 6499 | (if (and (< (point) here) | 6527 | (if (and (< (point) here) |
| 6500 | (verilog-re-search-forward "=[ \\t]*" here 'move)) | 6528 | (verilog-re-search-forward "=[ \\t]*" here 'move) |
| 6529 | ;; not at a |=>, #=#, or [=n] operator | ||
| 6530 | (not (string-match "\\[=.\\|#=#\\||=>" | ||
| 6531 | (or (buffer-substring (- (point) 2) (1+ (point))) | ||
| 6532 | "")))) ; don't let buffer over/under-run spoil the party | ||
| 6501 | (setq val (current-column)) | 6533 | (setq val (current-column)) |
| 6502 | (setq val (eval (cdr (assoc type verilog-indent-alist))))) | 6534 | (setq val (eval (cdr (assoc type verilog-indent-alist))))) |
| 6503 | (goto-char here) | 6535 | (goto-char here) |
| @@ -6509,11 +6541,11 @@ Only look at a few lines to determine indent level." | |||
| 6509 | (val (save-excursion | 6541 | (val (save-excursion |
| 6510 | (verilog-backward-up-list 1) | 6542 | (verilog-backward-up-list 1) |
| 6511 | (forward-char 1) | 6543 | (forward-char 1) |
| 6512 | (if verilog-indent-lists | 6544 | (if verilog-indent-lists |
| 6513 | (skip-chars-forward " \t") | 6545 | (skip-chars-forward " \t") |
| 6514 | (verilog-forward-syntactic-ws)) | 6546 | (verilog-forward-syntactic-ws)) |
| 6515 | (setq here (point)) | 6547 | (setq here (point)) |
| 6516 | (current-column))) | 6548 | (current-column))) |
| 6517 | 6549 | ||
| 6518 | (decl (save-excursion | 6550 | (decl (save-excursion |
| 6519 | (goto-char here) | 6551 | (goto-char here) |
| @@ -6553,7 +6585,11 @@ Only look at a few lines to determine indent level." | |||
| 6553 | (and (or | 6585 | (and (or |
| 6554 | (eq type 'defun) | 6586 | (eq type 'defun) |
| 6555 | (eq type 'block)) | 6587 | (eq type 'block)) |
| 6556 | (looking-at verilog-declaration-re)) | 6588 | (looking-at verilog-declaration-re) |
| 6589 | ;; Do not consider "virtual function", "virtual task", "virtual class" | ||
| 6590 | ;; as declarations | ||
| 6591 | (not (looking-at (concat verilog-declaration-re | ||
| 6592 | "\\s-+\\(function\\|task\\|class\\)\\b")))) | ||
| 6557 | (verilog-indent-declaration ind)) | 6593 | (verilog-indent-declaration ind)) |
| 6558 | 6594 | ||
| 6559 | (;-- form feeds - ignored as bug in indent-line-to in < 24.5 | 6595 | (;-- form feeds - ignored as bug in indent-line-to in < 24.5 |
| @@ -6607,7 +6643,7 @@ Do not count named blocks or case-statements." | |||
| 6607 | (re-search-backward "/\\*" nil t) | 6643 | (re-search-backward "/\\*" nil t) |
| 6608 | (1+(current-column)))) | 6644 | (1+(current-column)))) |
| 6609 | (comment-column | 6645 | (comment-column |
| 6610 | comment-column ) | 6646 | comment-column ) |
| 6611 | (t | 6647 | (t |
| 6612 | (save-excursion | 6648 | (save-excursion |
| 6613 | (re-search-backward "//" nil t) | 6649 | (re-search-backward "//" nil t) |
| @@ -6681,11 +6717,11 @@ Be verbose about progress unless optional QUIET set." | |||
| 6681 | ) | 6717 | ) |
| 6682 | (save-excursion | 6718 | (save-excursion |
| 6683 | (if (progn | 6719 | (if (progn |
| 6684 | ; (verilog-beg-of-statement-1) | 6720 | ;; (verilog-beg-of-statement-1) |
| 6685 | (beginning-of-line) | 6721 | (beginning-of-line) |
| 6686 | (verilog-forward-syntactic-ws) | 6722 | (verilog-forward-syntactic-ws) |
| 6687 | (and (not (verilog-in-directive-p)) ;; could have `define input foo | 6723 | (and (not (verilog-in-directive-p)) ; could have `define input foo |
| 6688 | (looking-at verilog-declaration-re))) | 6724 | (looking-at verilog-declaration-re))) |
| 6689 | (progn | 6725 | (progn |
| 6690 | (if (verilog-parenthesis-depth) | 6726 | (if (verilog-parenthesis-depth) |
| 6691 | ;; in an argument list or parameter block | 6727 | ;; in an argument list or parameter block |
| @@ -6693,7 +6729,7 @@ Be verbose about progress unless optional QUIET set." | |||
| 6693 | start (progn | 6729 | start (progn |
| 6694 | (goto-char e) | 6730 | (goto-char e) |
| 6695 | (verilog-backward-up-list 1) | 6731 | (verilog-backward-up-list 1) |
| 6696 | (forward-line) ;; ignore ( input foo, | 6732 | (forward-line) ; ignore ( input foo, |
| 6697 | (verilog-re-search-forward verilog-declaration-re el 'move) | 6733 | (verilog-re-search-forward verilog-declaration-re el 'move) |
| 6698 | (goto-char (match-beginning 0)) | 6734 | (goto-char (match-beginning 0)) |
| 6699 | (skip-chars-backward " \t") | 6735 | (skip-chars-backward " \t") |
| @@ -6752,11 +6788,11 @@ Be verbose about progress unless optional QUIET set." | |||
| 6752 | (cond | 6788 | (cond |
| 6753 | ((save-excursion (skip-chars-backward " \t") | 6789 | ((save-excursion (skip-chars-backward " \t") |
| 6754 | (bolp)) | 6790 | (bolp)) |
| 6755 | (verilog-forward-ws&directives) | 6791 | (verilog-forward-ws&directives) |
| 6756 | (indent-line-to base-ind) | 6792 | (indent-line-to base-ind) |
| 6757 | (verilog-forward-ws&directives) | 6793 | (verilog-forward-ws&directives) |
| 6758 | (if (< (point) e) | 6794 | (if (< (point) e) |
| 6759 | (verilog-re-search-forward "[ \t\n\f]" e 'move))) | 6795 | (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
| 6760 | (t | 6796 | (t |
| 6761 | (just-one-space) | 6797 | (just-one-space) |
| 6762 | (verilog-re-search-forward "[ \t\n\f]" e 'move))) | 6798 | (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
| @@ -6771,7 +6807,7 @@ Be verbose about progress unless optional QUIET set." | |||
| 6771 | (> r 0)) | 6807 | (> r 0)) |
| 6772 | (setq e (point)) | 6808 | (setq e (point)) |
| 6773 | (unless quiet (message "%d" r)) | 6809 | (unless quiet (message "%d" r)) |
| 6774 | ;;(verilog-do-indent (verilog-calculate-indent))) | 6810 | ;; (verilog-do-indent (verilog-calculate-indent))) |
| 6775 | (verilog-forward-ws&directives) | 6811 | (verilog-forward-ws&directives) |
| 6776 | (cond | 6812 | (cond |
| 6777 | ((or (and verilog-indent-declaration-macros | 6813 | ((or (and verilog-indent-declaration-macros |
| @@ -6885,7 +6921,7 @@ Be verbose about progress unless optional QUIET set." | |||
| 6885 | (cond | 6921 | (cond |
| 6886 | ((looking-at verilog-assignment-operation-re) | 6922 | ((looking-at verilog-assignment-operation-re) |
| 6887 | (goto-char (match-beginning 2)) | 6923 | (goto-char (match-beginning 2)) |
| 6888 | (if (not (or (verilog-in-parenthesis-p) ;; leave attributes and comparisons alone | 6924 | (if (not (or (verilog-in-parenthesis-p) ; leave attributes and comparisons alone |
| 6889 | (verilog-in-coverage-p))) | 6925 | (verilog-in-coverage-p))) |
| 6890 | (if (eq (char-after) ?=) | 6926 | (if (eq (char-after) ?=) |
| 6891 | (indent-to (1+ ind)) ; line up the = of the <= with surrounding = | 6927 | (indent-to (1+ ind)) ; line up the = of the <= with surrounding = |
| @@ -7018,7 +7054,7 @@ Region is defined by B and EDPOS." | |||
| 7018 | (while (progn (setq e (marker-position edpos)) | 7054 | (while (progn (setq e (marker-position edpos)) |
| 7019 | (< (point) e)) | 7055 | (< (point) e)) |
| 7020 | (if (and (verilog-re-search-forward myre e 'move) | 7056 | (if (and (verilog-re-search-forward myre e 'move) |
| 7021 | (not (verilog-in-attribute-p))) ;; skip attribute exprs | 7057 | (not (verilog-in-attribute-p))) ; skip attribute exprs |
| 7022 | (progn | 7058 | (progn |
| 7023 | (goto-char (match-beginning 2)) | 7059 | (goto-char (match-beginning 2)) |
| 7024 | (verilog-backward-syntactic-ws) | 7060 | (verilog-backward-syntactic-ws) |
| @@ -7053,9 +7089,8 @@ Region is defined by B and EDPOS." | |||
| 7053 | (insert | 7089 | (insert |
| 7054 | (format "%s %d" type val)))) | 7090 | (format "%s %d" type val)))) |
| 7055 | 7091 | ||
| 7056 | ;; | 7092 | |
| 7057 | ;; | 7093 | ;;; Completion: |
| 7058 | ;; Completion | ||
| 7059 | ;; | 7094 | ;; |
| 7060 | (defvar verilog-str nil) | 7095 | (defvar verilog-str nil) |
| 7061 | (defvar verilog-all nil) | 7096 | (defvar verilog-all nil) |
| @@ -7190,10 +7225,10 @@ TYPE is 'module, 'tf for task or function, or t if unknown." | |||
| 7190 | (if (string= verilog-str "") | 7225 | (if (string= verilog-str "") |
| 7191 | (setq verilog-str "[a-zA-Z_]")) | 7226 | (setq verilog-str "[a-zA-Z_]")) |
| 7192 | (let ((verilog-str (concat (cond | 7227 | (let ((verilog-str (concat (cond |
| 7193 | ((eq type 'module) "\\<\\(module\\)\\s +") | 7228 | ((eq type 'module) "\\<\\(module\\)\\s +") |
| 7194 | ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") | 7229 | ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") |
| 7195 | (t "\\<\\(task\\|function\\|module\\)\\s +")) | 7230 | (t "\\<\\(task\\|function\\|module\\)\\s +")) |
| 7196 | "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) | 7231 | "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) |
| 7197 | match) | 7232 | match) |
| 7198 | 7233 | ||
| 7199 | (if (not (looking-at verilog-defun-re)) | 7234 | (if (not (looking-at verilog-defun-re)) |
| @@ -7551,7 +7586,7 @@ If search fails, other files are checked based on | |||
| 7551 | (goto-char (match-end 0)) | 7586 | (goto-char (match-end 0)) |
| 7552 | (if (> nlines 0) | 7587 | (if (> nlines 0) |
| 7553 | (forward-line (1+ nlines)) | 7588 | (forward-line (1+ nlines)) |
| 7554 | (forward-line 1)) | 7589 | (forward-line 1)) |
| 7555 | (point))) | 7590 | (point))) |
| 7556 | (tag (format "%3d" linenum)) | 7591 | (tag (format "%3d" linenum)) |
| 7557 | (empty (make-string (length tag) ?\ )) | 7592 | (empty (make-string (length tag) ?\ )) |
| @@ -7583,6 +7618,7 @@ If search fails, other files are checked based on | |||
| 7583 | 7618 | ||
| 7584 | ;; Highlight helper functions | 7619 | ;; Highlight helper functions |
| 7585 | (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") | 7620 | (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") |
| 7621 | |||
| 7586 | (defun verilog-within-translate-off () | 7622 | (defun verilog-within-translate-off () |
| 7587 | "Return point if within translate-off region, else nil." | 7623 | "Return point if within translate-off region, else nil." |
| 7588 | (and (save-excursion | 7624 | (and (save-excursion |
| @@ -7595,15 +7631,15 @@ If search fails, other files are checked based on | |||
| 7595 | (defun verilog-start-translate-off (limit) | 7631 | (defun verilog-start-translate-off (limit) |
| 7596 | "Return point before translate-off directive if before LIMIT, else nil." | 7632 | "Return point before translate-off directive if before LIMIT, else nil." |
| 7597 | (when (re-search-forward | 7633 | (when (re-search-forward |
| 7598 | (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | 7634 | (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") |
| 7599 | limit t) | 7635 | limit t) |
| 7600 | (match-beginning 0))) | 7636 | (match-beginning 0))) |
| 7601 | 7637 | ||
| 7602 | (defun verilog-back-to-start-translate-off (limit) | 7638 | (defun verilog-back-to-start-translate-off (limit) |
| 7603 | "Return point before translate-off directive if before LIMIT, else nil." | 7639 | "Return point before translate-off directive if before LIMIT, else nil." |
| 7604 | (when (re-search-backward | 7640 | (when (re-search-backward |
| 7605 | (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | 7641 | (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") |
| 7606 | limit t) | 7642 | limit t) |
| 7607 | (match-beginning 0))) | 7643 | (match-beginning 0))) |
| 7608 | 7644 | ||
| 7609 | (defun verilog-end-translate-off (limit) | 7645 | (defun verilog-end-translate-off (limit) |
| @@ -7649,7 +7685,7 @@ Bound search by LIMIT. Adapted from | |||
| 7649 | See also `verilog-sk-header' for an alternative format." | 7685 | See also `verilog-sk-header' for an alternative format." |
| 7650 | (interactive) | 7686 | (interactive) |
| 7651 | (let ((start (point))) | 7687 | (let ((start (point))) |
| 7652 | (insert "\ | 7688 | (insert "\ |
| 7653 | //----------------------------------------------------------------------------- | 7689 | //----------------------------------------------------------------------------- |
| 7654 | // Title : <title> | 7690 | // Title : <title> |
| 7655 | // Project : <project> | 7691 | // Project : <project> |
| @@ -7721,8 +7757,7 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7721 | (insert (format-time-string "%Y"))) | 7757 | (insert (format-time-string "%Y"))) |
| 7722 | 7758 | ||
| 7723 | 7759 | ||
| 7724 | ;; | 7760 | ;;; Signal list parsing: |
| 7725 | ;; Signal list parsing | ||
| 7726 | ;; | 7761 | ;; |
| 7727 | 7762 | ||
| 7728 | ;; Elements of a signal list | 7763 | ;; Elements of a signal list |
| @@ -7731,11 +7766,11 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7731 | (list name bits comment mem enum signed type multidim modport)) | 7766 | (list name bits comment mem enum signed type multidim modport)) |
| 7732 | (defsubst verilog-sig-name (sig) | 7767 | (defsubst verilog-sig-name (sig) |
| 7733 | (car sig)) | 7768 | (car sig)) |
| 7734 | (defsubst verilog-sig-bits (sig) ;; First element of packed array (pre signal-name) | 7769 | (defsubst verilog-sig-bits (sig) ; First element of packed array (pre signal-name) |
| 7735 | (nth 1 sig)) | 7770 | (nth 1 sig)) |
| 7736 | (defsubst verilog-sig-comment (sig) | 7771 | (defsubst verilog-sig-comment (sig) |
| 7737 | (nth 2 sig)) | 7772 | (nth 2 sig)) |
| 7738 | (defsubst verilog-sig-memory (sig) ;; Unpacked array (post signal-name) | 7773 | (defsubst verilog-sig-memory (sig) ; Unpacked array (post signal-name) |
| 7739 | (nth 3 sig)) | 7774 | (nth 3 sig)) |
| 7740 | (defsubst verilog-sig-enum (sig) | 7775 | (defsubst verilog-sig-enum (sig) |
| 7741 | (nth 4 sig)) | 7776 | (nth 4 sig)) |
| @@ -7745,7 +7780,7 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7745 | (nth 6 sig)) | 7780 | (nth 6 sig)) |
| 7746 | (defsubst verilog-sig-type-set (sig type) | 7781 | (defsubst verilog-sig-type-set (sig type) |
| 7747 | (setcar (nthcdr 6 sig) type)) | 7782 | (setcar (nthcdr 6 sig) type)) |
| 7748 | (defsubst verilog-sig-multidim (sig) ;; Second and additional elements of packed array | 7783 | (defsubst verilog-sig-multidim (sig) ; Second and additional elements of packed array |
| 7749 | (nth 7 sig)) | 7784 | (nth 7 sig)) |
| 7750 | (defsubst verilog-sig-multidim-string (sig) | 7785 | (defsubst verilog-sig-multidim-string (sig) |
| 7751 | (if (verilog-sig-multidim sig) | 7786 | (if (verilog-sig-multidim sig) |
| @@ -7777,11 +7812,11 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7777 | (defsubst verilog-modport-name (sig) | 7812 | (defsubst verilog-modport-name (sig) |
| 7778 | (car sig)) | 7813 | (car sig)) |
| 7779 | (defsubst verilog-modport-clockings (sig) | 7814 | (defsubst verilog-modport-clockings (sig) |
| 7780 | (nth 1 sig)) ;; Returns list of names | 7815 | (nth 1 sig)) ; Returns list of names |
| 7781 | (defsubst verilog-modport-clockings-add (sig val) | 7816 | (defsubst verilog-modport-clockings-add (sig val) |
| 7782 | (setcar (nthcdr 1 sig) (cons val (nth 1 sig)))) | 7817 | (setcar (nthcdr 1 sig) (cons val (nth 1 sig)))) |
| 7783 | (defsubst verilog-modport-decls (sig) | 7818 | (defsubst verilog-modport-decls (sig) |
| 7784 | (nth 2 sig)) ;; Returns verilog-decls-* structure | 7819 | (nth 2 sig)) ; Returns verilog-decls-* structure |
| 7785 | (defsubst verilog-modport-decls-set (sig val) | 7820 | (defsubst verilog-modport-decls-set (sig val) |
| 7786 | (setcar (nthcdr 2 sig) val)) | 7821 | (setcar (nthcdr 2 sig) val)) |
| 7787 | 7822 | ||
| @@ -7793,7 +7828,7 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7793 | (aref modi 1)) | 7828 | (aref modi 1)) |
| 7794 | (defsubst verilog-modi-get-point (modi) | 7829 | (defsubst verilog-modi-get-point (modi) |
| 7795 | (aref modi 2)) | 7830 | (aref modi 2)) |
| 7796 | (defsubst verilog-modi-get-type (modi) ;; "module" or "interface" | 7831 | (defsubst verilog-modi-get-type (modi) ; "module" or "interface" |
| 7797 | (aref modi 3)) | 7832 | (aref modi 3)) |
| 7798 | (defsubst verilog-modi-get-decls (modi) | 7833 | (defsubst verilog-modi-get-decls (modi) |
| 7799 | (verilog-modi-cache-results modi 'verilog-read-decls)) | 7834 | (verilog-modi-cache-results modi 'verilog-read-decls)) |
| @@ -7819,8 +7854,8 @@ See also `verilog-sk-header' for an alternative format." | |||
| 7819 | (aref decls 2)) | 7854 | (aref decls 2)) |
| 7820 | (defsubst verilog-decls-get-vars (decls) | 7855 | (defsubst verilog-decls-get-vars (decls) |
| 7821 | (aref decls 3)) | 7856 | (aref decls 3)) |
| 7822 | (defsubst verilog-decls-get-modports (decls) ;; Also for clocking blocks; contains another verilog-decls struct | 7857 | (defsubst verilog-decls-get-modports (decls) ; Also for clocking blocks; contains another verilog-decls struct |
| 7823 | (aref decls 4)) ;; Returns verilog-modport* structure | 7858 | (aref decls 4)) ; Returns verilog-modport* structure |
| 7824 | (defsubst verilog-decls-get-assigns (decls) | 7859 | (defsubst verilog-decls-get-assigns (decls) |
| 7825 | (aref decls 5)) | 7860 | (aref decls 5)) |
| 7826 | (defsubst verilog-decls-get-consts (decls) | 7861 | (defsubst verilog-decls-get-consts (decls) |
| @@ -7985,7 +8020,8 @@ Signals must be in standard (base vector) form." | |||
| 7985 | (defun verilog-signals-combine-bus (in-list) | 8020 | (defun verilog-signals-combine-bus (in-list) |
| 7986 | "Return a list of signals in IN-LIST, with buses combined. | 8021 | "Return a list of signals in IN-LIST, with buses combined. |
| 7987 | Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | 8022 | Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." |
| 7988 | (let (combo buswarn | 8023 | (let (combo |
| 8024 | buswarn | ||
| 7989 | out-list | 8025 | out-list |
| 7990 | sig highbit lowbit ; Temp information about current signal | 8026 | sig highbit lowbit ; Temp information about current signal |
| 7991 | sv-name sv-highbit sv-lowbit ; Details about signal we are forming | 8027 | sv-name sv-highbit sv-lowbit ; Details about signal we are forming |
| @@ -8037,7 +8073,7 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | |||
| 8037 | ;; Combine with this signal | 8073 | ;; Combine with this signal |
| 8038 | (when (and sv-busstring | 8074 | (when (and sv-busstring |
| 8039 | (not (equal sv-busstring (verilog-sig-bits sig)))) | 8075 | (not (equal sv-busstring (verilog-sig-bits sig)))) |
| 8040 | (when nil ;; Debugging | 8076 | (when nil ; Debugging |
| 8041 | (message (concat "Warning, can't merge into single bus " | 8077 | (message (concat "Warning, can't merge into single bus " |
| 8042 | sv-name bus | 8078 | sv-name bus |
| 8043 | ", the AUTOs may be wrong"))) | 8079 | ", the AUTOs may be wrong"))) |
| @@ -8157,17 +8193,17 @@ Tieoff value uses `verilog-active-low-regexp' and | |||
| 8157 | 8193 | ||
| 8158 | (defun verilog-read-inst-backward-name () | 8194 | (defun verilog-read-inst-backward-name () |
| 8159 | "Internal. Move point back to beginning of inst-name." | 8195 | "Internal. Move point back to beginning of inst-name." |
| 8160 | (verilog-backward-open-paren) | 8196 | (verilog-backward-open-paren) |
| 8161 | (let (done) | 8197 | (let (done) |
| 8162 | (while (not done) | 8198 | (while (not done) |
| 8163 | (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary | 8199 | (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary |
| 8164 | (cond ((looking-at ")") | 8200 | (cond ((looking-at ")") |
| 8165 | (verilog-backward-open-paren)) | 8201 | (verilog-backward-open-paren)) |
| 8166 | (t (setq done t))))) | 8202 | (t (setq done t))))) |
| 8167 | (while (looking-at "\\]") | 8203 | (while (looking-at "\\]") |
| 8168 | (verilog-backward-open-bracket) | 8204 | (verilog-backward-open-bracket) |
| 8169 | (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) | 8205 | (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) |
| 8170 | (skip-chars-backward "a-zA-Z0-9`_$")) | 8206 | (skip-chars-backward "a-zA-Z0-9`_$")) |
| 8171 | 8207 | ||
| 8172 | (defun verilog-read-inst-module-matcher () | 8208 | (defun verilog-read-inst-module-matcher () |
| 8173 | "Set match data 0 with module_name when point is inside instantiation." | 8209 | "Set match data 0 with module_name when point is inside instantiation." |
| @@ -8296,12 +8332,12 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8296 | (or (search-forward "*)") | 8332 | (or (search-forward "*)") |
| 8297 | (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | 8333 | (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) |
| 8298 | ((eq ?\" (following-char)) | 8334 | ((eq ?\" (following-char)) |
| 8299 | (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first | 8335 | (or (re-search-forward "[^\\]\"" nil t) ; don't forward-char first, since we look for a non backslash first |
| 8300 | (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | 8336 | (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) |
| 8301 | ((eq ?\; (following-char)) | 8337 | ((eq ?\; (following-char)) |
| 8302 | (cond (in-ign-to-semi ;; Such as inside a "import ...;" in a module header | 8338 | (cond (in-ign-to-semi ; Such as inside a "import ...;" in a module header |
| 8303 | (setq in-ign-to-semi nil)) | 8339 | (setq in-ign-to-semi nil)) |
| 8304 | ((and in-modport (not (eq in-modport t))) ;; end of a modport declaration | 8340 | ((and in-modport (not (eq in-modport t))) ; end of a modport declaration |
| 8305 | (verilog-modport-decls-set | 8341 | (verilog-modport-decls-set |
| 8306 | in-modport | 8342 | in-modport |
| 8307 | (verilog-decls-new sigs-out sigs-inout sigs-in | 8343 | (verilog-decls-new sigs-out sigs-inout sigs-in |
| @@ -8341,11 +8377,11 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8341 | (if (verilog-sig-memory newsig) | 8377 | (if (verilog-sig-memory newsig) |
| 8342 | (concat (verilog-sig-memory newsig) (match-string 1)) | 8378 | (concat (verilog-sig-memory newsig) (match-string 1)) |
| 8343 | (match-string 1)))) | 8379 | (match-string 1)))) |
| 8344 | (vec ;; Multidimensional | 8380 | (vec ; Multidimensional |
| 8345 | (setq multidim (cons vec multidim)) | 8381 | (setq multidim (cons vec multidim)) |
| 8346 | (setq vec (verilog-string-replace-matches | 8382 | (setq vec (verilog-string-replace-matches |
| 8347 | "\\s-+" "" nil nil (match-string 1)))) | 8383 | "\\s-+" "" nil nil (match-string 1)))) |
| 8348 | (t ;; Bit width | 8384 | (t ; Bit width |
| 8349 | (setq vec (verilog-string-replace-matches | 8385 | (setq vec (verilog-string-replace-matches |
| 8350 | "\\s-+" "" nil nil (match-string 1)))))) | 8386 | "\\s-+" "" nil nil (match-string 1)))))) |
| 8351 | ;; Normal or escaped identifier -- note we remember the \ if escaped | 8387 | ;; Normal or escaped identifier -- note we remember the \ if escaped |
| @@ -8353,13 +8389,13 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8353 | (goto-char (match-end 0)) | 8389 | (goto-char (match-end 0)) |
| 8354 | (setq keywd (match-string 1)) | 8390 | (setq keywd (match-string 1)) |
| 8355 | (when (string-match "^\\\\" (match-string 1)) | 8391 | (when (string-match "^\\\\" (match-string 1)) |
| 8356 | (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end | 8392 | (setq keywd (concat keywd " "))) ; Escaped ID needs space at end |
| 8357 | ;; Add any :: package names to same identifier | 8393 | ;; Add any :: package names to same identifier |
| 8358 | (while (looking-at "\\s-*::\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | 8394 | (while (looking-at "\\s-*::\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") |
| 8359 | (goto-char (match-end 0)) | 8395 | (goto-char (match-end 0)) |
| 8360 | (setq keywd (concat keywd "::" (match-string 1))) | 8396 | (setq keywd (concat keywd "::" (match-string 1))) |
| 8361 | (when (string-match "^\\\\" (match-string 1)) | 8397 | (when (string-match "^\\\\" (match-string 1)) |
| 8362 | (setq keywd (concat keywd " ")))) ;; Escaped ID needs space at end | 8398 | (setq keywd (concat keywd " ")))) ; Escaped ID needs space at end |
| 8363 | (cond ((equal keywd "input") | 8399 | (cond ((equal keywd "input") |
| 8364 | (setq vec nil enum nil rvalue nil newsig nil signed nil | 8400 | (setq vec nil enum nil rvalue nil newsig nil signed nil |
| 8365 | typedefed nil multidim nil ptype nil modport nil | 8401 | typedefed nil multidim nil ptype nil modport nil |
| @@ -8419,7 +8455,7 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8419 | ((equal keywd "clocking") | 8455 | ((equal keywd "clocking") |
| 8420 | (setq in-clocking t)) | 8456 | (setq in-clocking t)) |
| 8421 | ((equal keywd "import") | 8457 | ((equal keywd "import") |
| 8422 | (if v2kargs-ok ;; import in module header, not a modport import | 8458 | (if v2kargs-ok ; import in module header, not a modport import |
| 8423 | (setq in-ign-to-semi t rvalue t))) | 8459 | (setq in-ign-to-semi t rvalue t))) |
| 8424 | ((equal keywd "type") | 8460 | ((equal keywd "type") |
| 8425 | (setq ptype t)) | 8461 | (setq ptype t)) |
| @@ -8552,7 +8588,7 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8552 | (if vec (setq vec (verilog-symbol-detick-denumber vec))) | 8588 | (if vec (setq vec (verilog-symbol-detick-denumber vec))) |
| 8553 | (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) | 8589 | (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) |
| 8554 | (unless (or (not sig) | 8590 | (unless (or (not sig) |
| 8555 | (equal sig "")) ;; Ignore .foo(1'b1) assignments | 8591 | (equal sig "")) ; Ignore .foo(1'b1) assignments |
| 8556 | (cond ((or (setq portdata (assoc port (verilog-decls-get-inouts submoddecls))) | 8592 | (cond ((or (setq portdata (assoc port (verilog-decls-get-inouts submoddecls))) |
| 8557 | (equal "inout" verilog-read-sub-decls-gate-ios)) | 8593 | (equal "inout" verilog-read-sub-decls-gate-ios)) |
| 8558 | (setq sigs-inout | 8594 | (setq sigs-inout |
| @@ -8650,7 +8686,7 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8650 | ;; Remove leading reduction operators, etc | 8686 | ;; Remove leading reduction operators, etc |
| 8651 | (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr)) | 8687 | (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr)) |
| 8652 | ;;(message "vrsde-ptop: '%s'" expr) | 8688 | ;;(message "vrsde-ptop: '%s'" expr) |
| 8653 | (cond ;; Find \signal. Final space is part of escaped signal name | 8689 | (cond ; Find \signal. Final space is part of escaped signal name |
| 8654 | ((string-match "^\\s-*\\(\\\\[^ \t\n\f]+\\s-\\)" expr) | 8690 | ((string-match "^\\s-*\\(\\\\[^ \t\n\f]+\\s-\\)" expr) |
| 8655 | ;;(message "vrsde-s: '%s'" (match-string 1 expr)) | 8691 | ;;(message "vrsde-s: '%s'" (match-string 1 expr)) |
| 8656 | (setq sig (match-string 1 expr) | 8692 | (setq sig (match-string 1 expr) |
| @@ -8684,7 +8720,7 @@ Inserts the list of signals found, using submodi to look up each port." | |||
| 8684 | (goto-char (match-end 0))) | 8720 | (goto-char (match-end 0))) |
| 8685 | ;; .\escaped ( | 8721 | ;; .\escaped ( |
| 8686 | ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") | 8722 | ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") |
| 8687 | (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space | 8723 | (setq port (concat (match-string 1) " ")) ; escaped id's need trailing space |
| 8688 | (goto-char (match-end 0))) | 8724 | (goto-char (match-end 0))) |
| 8689 | ;; .name | 8725 | ;; .name |
| 8690 | ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]") | 8726 | ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]") |
| @@ -8700,10 +8736,10 @@ Inserts the list of signals found, using submodi to look up each port." | |||
| 8700 | (setq port nil)) | 8736 | (setq port nil)) |
| 8701 | ;; random | 8737 | ;; random |
| 8702 | ((looking-at "\\s-*\\.[^(]*(") | 8738 | ((looking-at "\\s-*\\.[^(]*(") |
| 8703 | (setq port nil) ;; skip this line | 8739 | (setq port nil) ; skip this line |
| 8704 | (goto-char (match-end 0))) | 8740 | (goto-char (match-end 0))) |
| 8705 | (t | 8741 | (t |
| 8706 | (setq port nil done t))) ;; Unknown, ignore rest of line | 8742 | (setq port nil done t))) ; Unknown, ignore rest of line |
| 8707 | ;; Get signal name. Point is at the first-non-space after ( | 8743 | ;; Get signal name. Point is at the first-non-space after ( |
| 8708 | ;; We intentionally ignore (non-escaped) signals with .s in them | 8744 | ;; We intentionally ignore (non-escaped) signals with .s in them |
| 8709 | ;; this prevents AUTOWIRE etc from noticing hierarchical sigs. | 8745 | ;; this prevents AUTOWIRE etc from noticing hierarchical sigs. |
| @@ -8819,19 +8855,19 @@ Outputs comments above subcell signals, for example: | |||
| 8819 | ;; However I want it to be runnable even on user's manually added signals | 8855 | ;; However I want it to be runnable even on user's manually added signals |
| 8820 | (let ((verilog-read-sub-decls-in-interfaced t)) | 8856 | (let ((verilog-read-sub-decls-in-interfaced t)) |
| 8821 | (while (re-search-forward "\\s *(?\\s *// Interfaced" end-inst-point t) | 8857 | (while (re-search-forward "\\s *(?\\s *// Interfaced" end-inst-point t) |
| 8822 | (verilog-read-sub-decls-line submoddecls comment))) ;; Modifies sigs-ifd | 8858 | (verilog-read-sub-decls-line submoddecls comment))) ; Modifies sigs-ifd |
| 8823 | (goto-char st-point) | 8859 | (goto-char st-point) |
| 8824 | (while (re-search-forward "\\s *(?\\s *// Interfaces" end-inst-point t) | 8860 | (while (re-search-forward "\\s *(?\\s *// Interfaces" end-inst-point t) |
| 8825 | (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out | 8861 | (verilog-read-sub-decls-line submoddecls comment)) ; Modifies sigs-out |
| 8826 | (goto-char st-point) | 8862 | (goto-char st-point) |
| 8827 | (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t) | 8863 | (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t) |
| 8828 | (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out | 8864 | (verilog-read-sub-decls-line submoddecls comment)) ; Modifies sigs-out |
| 8829 | (goto-char st-point) | 8865 | (goto-char st-point) |
| 8830 | (while (re-search-forward "\\s *(?\\s *// Inouts" end-inst-point t) | 8866 | (while (re-search-forward "\\s *(?\\s *// Inouts" end-inst-point t) |
| 8831 | (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-inout | 8867 | (verilog-read-sub-decls-line submoddecls comment)) ; Modifies sigs-inout |
| 8832 | (goto-char st-point) | 8868 | (goto-char st-point) |
| 8833 | (while (re-search-forward "\\s *(?\\s *// Inputs" end-inst-point t) | 8869 | (while (re-search-forward "\\s *(?\\s *// Inputs" end-inst-point t) |
| 8834 | (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-in | 8870 | (verilog-read-sub-decls-line submoddecls comment)) ; Modifies sigs-in |
| 8835 | ))))))) | 8871 | ))))))) |
| 8836 | ;; Combine duplicate bits | 8872 | ;; Combine duplicate bits |
| 8837 | ;;(setq rr (vector sigs-out sigs-inout sigs-in)) | 8873 | ;;(setq rr (vector sigs-out sigs-inout sigs-in)) |
| @@ -8846,7 +8882,7 @@ Outputs comments above subcell signals, for example: | |||
| 8846 | "Return an array of [ pins ] for the current instantiation at point. | 8882 | "Return an array of [ pins ] for the current instantiation at point. |
| 8847 | For example if declare A A (.B(SIG)) then B will be included in the list." | 8883 | For example if declare A A (.B(SIG)) then B will be included in the list." |
| 8848 | (save-excursion | 8884 | (save-excursion |
| 8849 | (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point | 8885 | (let ((end-mod-point (point)) ; presume at /*AUTOINST*/ point |
| 8850 | pins pin) | 8886 | pins pin) |
| 8851 | (verilog-backward-open-paren) | 8887 | (verilog-backward-open-paren) |
| 8852 | (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) | 8888 | (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) |
| @@ -8860,7 +8896,7 @@ For example if declare A A (.B(SIG)) then B will be included in the list." | |||
| 8860 | (defun verilog-read-arg-pins () | 8896 | (defun verilog-read-arg-pins () |
| 8861 | "Return an array of [ pins ] for the current argument declaration at point." | 8897 | "Return an array of [ pins ] for the current argument declaration at point." |
| 8862 | (save-excursion | 8898 | (save-excursion |
| 8863 | (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point | 8899 | (let ((end-mod-point (point)) ; presume at /*AUTOARG*/ point |
| 8864 | pins pin) | 8900 | pins pin) |
| 8865 | (verilog-backward-open-paren) | 8901 | (verilog-backward-open-paren) |
| 8866 | (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) | 8902 | (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) |
| @@ -8881,7 +8917,7 @@ For example if declare A A (.B(SIG)) then B will be included in the list." | |||
| 8881 | (search-forward "(" end-mod-point) | 8917 | (search-forward "(" end-mod-point) |
| 8882 | (setq tpl-end-pt (save-excursion | 8918 | (setq tpl-end-pt (save-excursion |
| 8883 | (backward-char 1) | 8919 | (backward-char 1) |
| 8884 | (verilog-forward-sexp-cmt 1) ;; Moves to paren that closes argdecl's | 8920 | (verilog-forward-sexp-cmt 1) ; Moves to paren that closes argdecl's |
| 8885 | (backward-char 1) | 8921 | (backward-char 1) |
| 8886 | (point))) | 8922 | (point))) |
| 8887 | (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) | 8923 | (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) |
| @@ -8907,18 +8943,18 @@ Must call `verilog-read-auto-lisp-present' before this function." | |||
| 8907 | (while (re-search-forward "\\<AUTO_LISP(" end t) | 8943 | (while (re-search-forward "\\<AUTO_LISP(" end t) |
| 8908 | (backward-char) | 8944 | (backward-char) |
| 8909 | (let* ((beg-pt (prog1 (point) | 8945 | (let* ((beg-pt (prog1 (point) |
| 8910 | (verilog-forward-sexp-cmt 1))) ;; Closing paren | 8946 | (verilog-forward-sexp-cmt 1))) ; Closing paren |
| 8911 | (end-pt (point)) | 8947 | (end-pt (point)) |
| 8912 | (verilog-in-hooks t)) | 8948 | (verilog-in-hooks t)) |
| 8913 | (eval-region beg-pt end-pt nil)))))) | 8949 | (eval-region beg-pt end-pt nil)))))) |
| 8914 | 8950 | ||
| 8915 | (defun verilog-read-always-signals-recurse | 8951 | (defun verilog-read-always-signals-recurse |
| 8916 | (exit-keywd rvalue temp-next) | 8952 | (exit-keywd rvalue temp-next) |
| 8917 | "Recursive routine for parentheses/bracket matching. | 8953 | "Recursive routine for parentheses/bracket matching. |
| 8918 | EXIT-KEYWD is expression to stop at, nil if top level. | 8954 | EXIT-KEYWD is expression to stop at, nil if top level. |
| 8919 | RVALUE is true if at right hand side of equal. | 8955 | RVALUE is true if at right hand side of equal. |
| 8920 | IGNORE-NEXT is true to ignore next token, fake from inside case statement." | 8956 | IGNORE-NEXT is true to ignore next token, fake from inside case statement." |
| 8921 | (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue | 8957 | (let* ((semi-rvalue (equal "endcase" exit-keywd)) ; true if after a ; we are looking for rvalue |
| 8922 | keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-list end-else-check | 8958 | keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-list end-else-check |
| 8923 | ignore-next) | 8959 | ignore-next) |
| 8924 | ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue temp-next)))) | 8960 | ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue temp-next)))) |
| @@ -8971,16 +9007,16 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |||
| 8971 | (if (looking-at "'[sS]?[hdxboHDXBO]?[ \t]*[0-9a-fA-F_xzXZ?]+") | 9007 | (if (looking-at "'[sS]?[hdxboHDXBO]?[ \t]*[0-9a-fA-F_xzXZ?]+") |
| 8972 | (goto-char (match-end 0)) | 9008 | (goto-char (match-end 0)) |
| 8973 | (forward-char 1))) | 9009 | (forward-char 1))) |
| 8974 | ((equal keywd ":") ;; Case statement, begin/end label, x?y:z | 9010 | ((equal keywd ":") ; Case statement, begin/end label, x?y:z |
| 8975 | (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next | 9011 | (cond ((equal "endcase" exit-keywd) ; case x: y=z; statement next |
| 8976 | (setq ignore-next nil rvalue nil)) | 9012 | (setq ignore-next nil rvalue nil)) |
| 8977 | ((equal "?" exit-keywd) ;; x?y:z rvalue | 9013 | ((equal "?" exit-keywd) ; x?y:z rvalue |
| 8978 | ) ;; NOP | 9014 | ) ; NOP |
| 8979 | ((equal "]" exit-keywd) ;; [x:y] rvalue | 9015 | ((equal "]" exit-keywd) ; [x:y] rvalue |
| 8980 | ) ;; NOP | 9016 | ) ; NOP |
| 8981 | (got-sig ;; label: statement | 9017 | (got-sig ; label: statement |
| 8982 | (setq ignore-next nil rvalue semi-rvalue got-sig nil)) | 9018 | (setq ignore-next nil rvalue semi-rvalue got-sig nil)) |
| 8983 | ((not rvalue) ;; begin label | 9019 | ((not rvalue) ; begin label |
| 8984 | (setq ignore-next t rvalue nil))) | 9020 | (setq ignore-next t rvalue nil))) |
| 8985 | (forward-char 1)) | 9021 | (forward-char 1)) |
| 8986 | ((equal keywd "=") | 9022 | ((equal keywd "=") |
| @@ -9004,7 +9040,7 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |||
| 9004 | (verilog-read-always-signals-recurse "]" t nil)) | 9040 | (verilog-read-always-signals-recurse "]" t nil)) |
| 9005 | ((equal keywd "(") | 9041 | ((equal keywd "(") |
| 9006 | (forward-char 1) | 9042 | (forward-char 1) |
| 9007 | (cond (sig-last-tolk ;; Function call; zap last signal | 9043 | (cond (sig-last-tolk ; Function call; zap last signal |
| 9008 | (setq got-sig nil))) | 9044 | (setq got-sig nil))) |
| 9009 | (cond ((equal last-keywd "for") | 9045 | (cond ((equal last-keywd "for") |
| 9010 | ;; temp-next: Variables on LHS are lvalues, but generally we want | 9046 | ;; temp-next: Variables on LHS are lvalues, but generally we want |
| @@ -9023,13 +9059,13 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |||
| 9023 | (skip-syntax-forward "w_") | 9059 | (skip-syntax-forward "w_") |
| 9024 | (verilog-read-always-signals-recurse "endcase" t nil) | 9060 | (verilog-read-always-signals-recurse "endcase" t nil) |
| 9025 | (setq ignore-next nil rvalue semi-rvalue) | 9061 | (setq ignore-next nil rvalue semi-rvalue) |
| 9026 | (if (not exit-keywd) (setq gotend t))) ;; top level begin/end | 9062 | (if (not exit-keywd) (setq gotend t))) ; top level begin/end |
| 9027 | ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent | 9063 | ((string-match "^[$`a-zA-Z_]" keywd) ; not exactly word constituent |
| 9028 | (cond ((member keywd '("`ifdef" "`ifndef" "`elsif")) | 9064 | (cond ((member keywd '("`ifdef" "`ifndef" "`elsif")) |
| 9029 | (setq ignore-next t)) | 9065 | (setq ignore-next t)) |
| 9030 | ((or ignore-next | 9066 | ((or ignore-next |
| 9031 | (member keywd verilog-keywords) | 9067 | (member keywd verilog-keywords) |
| 9032 | (string-match "^\\$" keywd)) ;; PLI task | 9068 | (string-match "^\\$" keywd)) ; PLI task |
| 9033 | (setq ignore-next nil)) | 9069 | (setq ignore-next nil)) |
| 9034 | (t | 9070 | (t |
| 9035 | (setq keywd (verilog-symbol-detick-denumber keywd)) | 9071 | (setq keywd (verilog-symbol-detick-denumber keywd)) |
| @@ -9062,7 +9098,7 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |||
| 9062 | (defun verilog-read-always-signals () | 9098 | (defun verilog-read-always-signals () |
| 9063 | "Parse always block at point and return list of (outputs inout inputs)." | 9099 | "Parse always block at point and return list of (outputs inout inputs)." |
| 9064 | (save-excursion | 9100 | (save-excursion |
| 9065 | (let* (;;(dbg "") | 9101 | (let* (;(dbg "") |
| 9066 | sigs-out-d sigs-out-i sigs-out-unk sigs-temp sigs-in) | 9102 | sigs-out-d sigs-out-i sigs-out-unk sigs-temp sigs-in) |
| 9067 | (verilog-read-always-signals-recurse nil nil nil) | 9103 | (verilog-read-always-signals-recurse nil nil nil) |
| 9068 | (setq sigs-out-i (append sigs-out-i sigs-out-unk) | 9104 | (setq sigs-out-i (append sigs-out-i sigs-out-unk) |
| @@ -9126,7 +9162,7 @@ Returns REGEXP and list of ( (signal_name connection_name)... )." | |||
| 9126 | (setq lineno (1+ lineno)))))) | 9162 | (setq lineno (1+ lineno)))))) |
| 9127 | (setq tpl-end-pt (save-excursion | 9163 | (setq tpl-end-pt (save-excursion |
| 9128 | (backward-char 1) | 9164 | (backward-char 1) |
| 9129 | (verilog-forward-sexp-cmt 1) ;; Moves to paren that closes argdecl's | 9165 | (verilog-forward-sexp-cmt 1) ; Moves to paren that closes argdecl's |
| 9130 | (backward-char 1) | 9166 | (backward-char 1) |
| 9131 | (point))) | 9167 | (point))) |
| 9132 | ;; | 9168 | ;; |
| @@ -9207,13 +9243,19 @@ If found returns `verilog-read-auto-template-inside' structure." | |||
| 9207 | (defvar verilog-auto-template-hits nil "Successful lookups with `verilog-read-auto-template-hit'.") | 9243 | (defvar verilog-auto-template-hits nil "Successful lookups with `verilog-read-auto-template-hit'.") |
| 9208 | (make-variable-buffer-local 'verilog-auto-template-hits) | 9244 | (make-variable-buffer-local 'verilog-auto-template-hits) |
| 9209 | 9245 | ||
| 9246 | (defun verilog-read-auto-template-init () | ||
| 9247 | "Initialize `verilog-read-auto-template'." | ||
| 9248 | (when (eval-when-compile (fboundp 'make-hash-table)) ; else feature not allowed | ||
| 9249 | (when verilog-auto-template-warn-unused | ||
| 9250 | (setq verilog-auto-template-hits | ||
| 9251 | (make-hash-table :test 'equal :rehash-size 4.0))))) | ||
| 9252 | |||
| 9210 | (defun verilog-read-auto-template-hit (tpl-ass) | 9253 | (defun verilog-read-auto-template-hit (tpl-ass) |
| 9211 | "Record that TPL-ASS template from `verilog-read-auto-template' was used." | 9254 | "Record that TPL-ASS template from `verilog-read-auto-template' was used." |
| 9212 | (when (eval-when-compile (fboundp 'make-hash-table)) ;; else feature not allowed | 9255 | (when (eval-when-compile (fboundp 'make-hash-table)) ; else feature not allowed |
| 9213 | (when verilog-auto-template-warn-unused | 9256 | (when verilog-auto-template-warn-unused |
| 9214 | (unless verilog-auto-template-hits | 9257 | (unless verilog-auto-template-hits |
| 9215 | (setq verilog-auto-template-hits | 9258 | (verilog-read-auto-template-init)) |
| 9216 | (make-hash-table :test 'equal :rehash-size 4.0))) | ||
| 9217 | (puthash (vector (nth 2 tpl-ass) (nth 3 tpl-ass)) t | 9259 | (puthash (vector (nth 2 tpl-ass) (nth 3 tpl-ass)) t |
| 9218 | verilog-auto-template-hits)))) | 9260 | verilog-auto-template-hits)))) |
| 9219 | 9261 | ||
| @@ -9372,10 +9414,10 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9372 | ((looking-at "/\\*") | 9414 | ((looking-at "/\\*") |
| 9373 | (search-forward "*/")) | 9415 | (search-forward "*/")) |
| 9374 | ((looking-at "(\\*") | 9416 | ((looking-at "(\\*") |
| 9375 | (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | 9417 | (or (looking-at "(\\*\\s-*)") ; It's an "always @ (*)" |
| 9376 | (search-forward "*)"))) | 9418 | (search-forward "*)"))) |
| 9377 | ((eq ?\" (following-char)) | 9419 | ((eq ?\" (following-char)) |
| 9378 | (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first | 9420 | (re-search-forward "[^\\]\"")) ; don't forward-char first, since we look for a non backslash first |
| 9379 | ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") | 9421 | ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") |
| 9380 | (goto-char (match-end 0)) | 9422 | (goto-char (match-end 0)) |
| 9381 | (setq keywd (match-string-no-properties 1)) | 9423 | (setq keywd (match-string-no-properties 1)) |
| @@ -9423,19 +9465,19 @@ Some macros and such are also found and included. For dinotrace.el." | |||
| 9423 | (match-string 1 arg)) | 9465 | (match-string 1 arg)) |
| 9424 | (setq arg (match-string 2 arg)))) | 9466 | (setq arg (match-string 2 arg)))) |
| 9425 | ;; | 9467 | ;; |
| 9426 | ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val | 9468 | ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ; -Ddefine=val |
| 9427 | (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine | 9469 | (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ; -Ddefine |
| 9428 | (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val | 9470 | (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ; +define+val |
| 9429 | (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define | 9471 | (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ; +define+define |
| 9430 | (verilog-set-define (match-string 1 arg) (match-string 2 arg))) | 9472 | (verilog-set-define (match-string 1 arg) (match-string 2 arg))) |
| 9431 | ;; | 9473 | ;; |
| 9432 | ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir | 9474 | ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ; +incdir+dir |
| 9433 | (string-match "^-I\\(.*\\)" arg)) ;; -Idir | 9475 | (string-match "^-I\\(.*\\)" arg)) ; -Idir |
| 9434 | (verilog-add-list-unique `verilog-library-directories | 9476 | (verilog-add-list-unique `verilog-library-directories |
| 9435 | (match-string 1 (substitute-in-file-name arg)))) | 9477 | (match-string 1 (substitute-in-file-name arg)))) |
| 9436 | ;; Ignore | 9478 | ;; Ignore |
| 9437 | ((equal "+librescan" arg)) | 9479 | ((equal "+librescan" arg)) |
| 9438 | ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine | 9480 | ((string-match "^-U\\(.*\\)" arg)) ; -Udefine |
| 9439 | ;; Second parameters | 9481 | ;; Second parameters |
| 9440 | ((equal next-param "-f") | 9482 | ((equal next-param "-f") |
| 9441 | (setq next-param nil) | 9483 | (setq next-param nil) |
| @@ -9513,8 +9555,7 @@ Used for __FLAGS__ in `verilog-expand-command'." | |||
| 9513 | ;;(verilog-current-flags) | 9555 | ;;(verilog-current-flags) |
| 9514 | 9556 | ||
| 9515 | 9557 | ||
| 9516 | ;; | 9558 | ;;; Cached directory support: |
| 9517 | ;; Cached directory support | ||
| 9518 | ;; | 9559 | ;; |
| 9519 | 9560 | ||
| 9520 | (defvar verilog-dir-cache-preserving nil | 9561 | (defvar verilog-dir-cache-preserving nil |
| @@ -9541,12 +9582,12 @@ seen by the `verilog-dir-files' and related functions." | |||
| 9541 | Relative paths depend on the `default-directory'. | 9582 | Relative paths depend on the `default-directory'. |
| 9542 | Results are cached if inside `verilog-preserve-dir-cache'." | 9583 | Results are cached if inside `verilog-preserve-dir-cache'." |
| 9543 | (unless verilog-dir-cache-preserving | 9584 | (unless verilog-dir-cache-preserving |
| 9544 | (setq verilog-dir-cache-list nil)) ;; Cache disabled | 9585 | (setq verilog-dir-cache-list nil)) ; Cache disabled |
| 9545 | ;; We don't use expand-file-name on the dirname to make key, as it's slow | 9586 | ;; We don't use expand-file-name on the dirname to make key, as it's slow |
| 9546 | (let* ((cache-key (list dirname default-directory)) | 9587 | (let* ((cache-key (list dirname default-directory)) |
| 9547 | (fass (assoc cache-key verilog-dir-cache-list)) | 9588 | (fass (assoc cache-key verilog-dir-cache-list)) |
| 9548 | exp-dirname data) | 9589 | exp-dirname data) |
| 9549 | (cond (fass ;; Return data from cache hit | 9590 | (cond (fass ; Return data from cache hit |
| 9550 | (nth 1 fass)) | 9591 | (nth 1 fass)) |
| 9551 | (t | 9592 | (t |
| 9552 | (setq exp-dirname (expand-file-name dirname) | 9593 | (setq exp-dirname (expand-file-name dirname) |
| @@ -9576,8 +9617,7 @@ Like `file-exists-p' but results are cached if inside | |||
| 9576 | ;;(verilog-dir-file-exists-p "../verilog-mode/verilog-mode.el") | 9617 | ;;(verilog-dir-file-exists-p "../verilog-mode/verilog-mode.el") |
| 9577 | 9618 | ||
| 9578 | 9619 | ||
| 9579 | ;; | 9620 | ;;; Module name lookup: |
| 9580 | ;; Module name lookup | ||
| 9581 | ;; | 9621 | ;; |
| 9582 | 9622 | ||
| 9583 | (defun verilog-module-inside-filename-p (module filename) | 9623 | (defun verilog-module-inside-filename-p (module filename) |
| @@ -9676,9 +9716,9 @@ Or, just the existing dirnames themselves if there are no wildcards." | |||
| 9676 | (while dirnames | 9716 | (while dirnames |
| 9677 | (setq dirname (substitute-in-file-name (car dirnames)) | 9717 | (setq dirname (substitute-in-file-name (car dirnames)) |
| 9678 | dirnames (cdr dirnames)) | 9718 | dirnames (cdr dirnames)) |
| 9679 | (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root | 9719 | (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ; root |
| 9680 | "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *? | 9720 | "\\([^/\\]*[*?][^/\\]*\\)" ; filename with *? |
| 9681 | "\\(.*\\)") ;; rest | 9721 | "\\(.*\\)") ; rest |
| 9682 | dirname) | 9722 | dirname) |
| 9683 | (setq root (match-string 1 dirname) | 9723 | (setq root (match-string 1 dirname) |
| 9684 | filename (match-string 2 dirname) | 9724 | filename (match-string 2 dirname) |
| @@ -9719,7 +9759,7 @@ variables to build the path. With optional CHECK-EXT also check | |||
| 9719 | (let* ((cache-key (list filename current check-ext)) | 9759 | (let* ((cache-key (list filename current check-ext)) |
| 9720 | (fass (assoc cache-key verilog-dir-cache-lib-filenames)) | 9760 | (fass (assoc cache-key verilog-dir-cache-lib-filenames)) |
| 9721 | chkdirs chkdir chkexts fn outlist) | 9761 | chkdirs chkdir chkexts fn outlist) |
| 9722 | (cond (fass ;; Return data from cache hit | 9762 | (cond (fass ; Return data from cache hit |
| 9723 | (nth 1 fass)) | 9763 | (nth 1 fass)) |
| 9724 | (t | 9764 | (t |
| 9725 | ;; Note this expand can't be easily cached, as we need to | 9765 | ;; Note this expand can't be easily cached, as we need to |
| @@ -9881,7 +9921,7 @@ Return modi if successful, else print message unless IGNORE-ERROR is true." | |||
| 9881 | (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) | 9921 | (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) |
| 9882 | (verilog-modi-file-or-buffer modi) | 9922 | (verilog-modi-file-or-buffer modi) |
| 9883 | (find-file-noselect (verilog-modi-file-or-buffer modi)))) | 9923 | (find-file-noselect (verilog-modi-file-or-buffer modi)))) |
| 9884 | (or (equal major-mode `verilog-mode) ;; Put into Verilog mode to get syntax | 9924 | (or (equal major-mode `verilog-mode) ; Put into Verilog mode to get syntax |
| 9885 | (verilog-mode)) | 9925 | (verilog-mode)) |
| 9886 | (goto-char (verilog-modi-get-point modi))) | 9926 | (goto-char (verilog-modi-get-point modi))) |
| 9887 | 9927 | ||
| @@ -9897,7 +9937,7 @@ Return modi if successful, else print message unless IGNORE-ERROR is true." | |||
| 9897 | "Run on MODI the given FUNCTION. Locate the module in a file. | 9937 | "Run on MODI the given FUNCTION. Locate the module in a file. |
| 9898 | Cache the output of function so next call may have faster access." | 9938 | Cache the output of function so next call may have faster access." |
| 9899 | (let (fass) | 9939 | (let (fass) |
| 9900 | (save-excursion ;; Cache is buffer-local so can't avoid this. | 9940 | (save-excursion ; Cache is buffer-local so can't avoid this. |
| 9901 | (verilog-modi-goto modi) | 9941 | (verilog-modi-goto modi) |
| 9902 | (if (and (setq fass (assoc (list modi function) | 9942 | (if (and (setq fass (assoc (list modi function) |
| 9903 | verilog-modi-cache-list)) | 9943 | verilog-modi-cache-list)) |
| @@ -10093,8 +10133,7 @@ if non-nil." | |||
| 10093 | (verilog-modi-cache-add modi 'verilog-read-decls 7 sig-list)) | 10133 | (verilog-modi-cache-add modi 'verilog-read-decls 7 sig-list)) |
| 10094 | 10134 | ||
| 10095 | 10135 | ||
| 10096 | ;; | 10136 | ;;; Auto creation utilities: |
| 10097 | ;; Auto creation utilities | ||
| 10098 | ;; | 10137 | ;; |
| 10099 | 10138 | ||
| 10100 | (defun verilog-auto-re-search-do (search-for func) | 10139 | (defun verilog-auto-re-search-do (search-for func) |
| @@ -10164,7 +10203,7 @@ When MODI is non-null, also add to modi-cache, for tracking." | |||
| 10164 | (when (member direction '("input" "output" "inout")) | 10203 | (when (member direction '("input" "output" "inout")) |
| 10165 | (concat direction " ")) | 10204 | (concat direction " ")) |
| 10166 | (or (verilog-sig-type sig) | 10205 | (or (verilog-sig-type sig) |
| 10167 | verilog-auto-wire-type))) | 10206 | verilog-auto-wire-type))) |
| 10168 | ((and verilog-auto-declare-nettype | 10207 | ((and verilog-auto-declare-nettype |
| 10169 | (member direction '("input" "output" "inout"))) | 10208 | (member direction '("input" "output" "inout"))) |
| 10170 | (concat direction " " verilog-auto-declare-nettype)) | 10209 | (concat direction " " verilog-auto-declare-nettype)) |
| @@ -10206,10 +10245,10 @@ Presumes that any newlines end a list element." | |||
| 10206 | ;; Also want "`ifdef X input foo `endif" to just leave things to the human to deal with | 10245 | ;; Also want "`ifdef X input foo `endif" to just leave things to the human to deal with |
| 10207 | (save-excursion | 10246 | (save-excursion |
| 10208 | (verilog-backward-syntactic-ws-quick) | 10247 | (verilog-backward-syntactic-ws-quick) |
| 10209 | (when (and (not (save-excursion ;; Not beginning (, or existing , | 10248 | (when (and (not (save-excursion ; Not beginning (, or existing , |
| 10210 | (backward-char 1) | 10249 | (backward-char 1) |
| 10211 | (looking-at "[(,]"))) | 10250 | (looking-at "[(,]"))) |
| 10212 | (not (save-excursion ;; Not `endif, or user define | 10251 | (not (save-excursion ; Not `endif, or user define |
| 10213 | (backward-char 1) | 10252 | (backward-char 1) |
| 10214 | (skip-chars-backward "[a-zA-Z0-9_`]") | 10253 | (skip-chars-backward "[a-zA-Z0-9_`]") |
| 10215 | (looking-at "`")))) | 10254 | (looking-at "`")))) |
| @@ -10250,7 +10289,7 @@ This repairs those mis-inserted by an AUTOARG." | |||
| 10250 | ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) | 10289 | ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) |
| 10251 | (concat "(1+(" (match-string 1 range-exp) ")" | 10290 | (concat "(1+(" (match-string 1 range-exp) ")" |
| 10252 | (if (equal "0" (match-string 2 range-exp)) | 10291 | (if (equal "0" (match-string 2 range-exp)) |
| 10253 | "" ;; Don't bother with -(0) | 10292 | "" ; Don't bother with -(0) |
| 10254 | (concat "-(" (match-string 2 range-exp) ")")) | 10293 | (concat "-(" (match-string 2 range-exp) ")")) |
| 10255 | ")")) | 10294 | ")")) |
| 10256 | (t nil))))) | 10295 | (t nil))))) |
| @@ -10260,7 +10299,7 @@ This repairs those mis-inserted by an AUTOARG." | |||
| 10260 | "Return a simplified range expression with constants eliminated from EXPR." | 10299 | "Return a simplified range expression with constants eliminated from EXPR." |
| 10261 | ;; Note this is always called with brackets; ie [z] or [z:z] | 10300 | ;; Note this is always called with brackets; ie [z] or [z:z] |
| 10262 | (if (not (string-match "[---+*()]" expr)) | 10301 | (if (not (string-match "[---+*()]" expr)) |
| 10263 | expr ;; short-circuit | 10302 | expr ; short-circuit |
| 10264 | (let ((out expr) | 10303 | (let ((out expr) |
| 10265 | (last-pass "")) | 10304 | (last-pass "")) |
| 10266 | (while (not (equal last-pass out)) | 10305 | (while (not (equal last-pass out)) |
| @@ -10315,23 +10354,23 @@ This repairs those mis-inserted by an AUTOARG." | |||
| 10315 | out (replace-match | 10354 | out (replace-match |
| 10316 | (concat (if (and (equal pre "-") | 10355 | (concat (if (and (equal pre "-") |
| 10317 | (< val 0)) | 10356 | (< val 0)) |
| 10318 | "" ;; Not "--20" but just "-20" | 10357 | "" ; Not "--20" but just "-20" |
| 10319 | pre) | 10358 | pre) |
| 10320 | (int-to-string val) | 10359 | (int-to-string val) |
| 10321 | post) | 10360 | post) |
| 10322 | nil nil out)) ))) | 10361 | nil nil out)) ))) |
| 10323 | out))) | 10362 | out))) |
| 10324 | 10363 | ||
| 10325 | ;;(verilog-simplify-range-expression "[1:3]") ;; 1 | 10364 | ;;(verilog-simplify-range-expression "[1:3]") ; 1 |
| 10326 | ;;(verilog-simplify-range-expression "[(1):3]") ;; 1 | 10365 | ;;(verilog-simplify-range-expression "[(1):3]") ; 1 |
| 10327 | ;;(verilog-simplify-range-expression "[(((16)+1)+1+(1+1))]") ;;20 | 10366 | ;;(verilog-simplify-range-expression "[(((16)+1)+1+(1+1))]") ; 20 |
| 10328 | ;;(verilog-simplify-range-expression "[(2*3+6*7)]") ;; 48 | 10367 | ;;(verilog-simplify-range-expression "[(2*3+6*7)]") ; 48 |
| 10329 | ;;(verilog-simplify-range-expression "[(FOO*4-1*2)]") ;; FOO*4-2 | 10368 | ;;(verilog-simplify-range-expression "[(FOO*4-1*2)]") ; FOO*4-2 |
| 10330 | ;;(verilog-simplify-range-expression "[(FOO*4+1-1)]") ;; FOO*4+0 | 10369 | ;;(verilog-simplify-range-expression "[(FOO*4+1-1)]") ; FOO*4+0 |
| 10331 | ;;(verilog-simplify-range-expression "[(func(BAR))]") ;; func(BAR) | 10370 | ;;(verilog-simplify-range-expression "[(func(BAR))]") ; func(BAR) |
| 10332 | ;;(verilog-simplify-range-expression "[FOO-1+1-1+1]") ;; FOO-0 | 10371 | ;;(verilog-simplify-range-expression "[FOO-1+1-1+1]") ; FOO-0 |
| 10333 | ;;(verilog-simplify-range-expression "[$clog2(2)]") ;; 1 | 10372 | ;;(verilog-simplify-range-expression "[$clog2(2)]") ; 1 |
| 10334 | ;;(verilog-simplify-range-expression "[$clog2(7)]") ;; 3 | 10373 | ;;(verilog-simplify-range-expression "[$clog2(7)]") ; 3 |
| 10335 | 10374 | ||
| 10336 | (defun verilog-clog2 (value) | 10375 | (defun verilog-clog2 (value) |
| 10337 | "Compute $clog2 - ceiling log2 of VALUE." | 10376 | "Compute $clog2 - ceiling log2 of VALUE." |
| @@ -10344,8 +10383,7 @@ This repairs those mis-inserted by an AUTOARG." | |||
| 10344 | (when verilog-typedef-regexp | 10383 | (when verilog-typedef-regexp |
| 10345 | (verilog-string-match-fold verilog-typedef-regexp variable-name))) | 10384 | (verilog-string-match-fold verilog-typedef-regexp variable-name))) |
| 10346 | 10385 | ||
| 10347 | ;; | 10386 | ;;; Auto deletion: |
| 10348 | ;; Auto deletion | ||
| 10349 | ;; | 10387 | ;; |
| 10350 | 10388 | ||
| 10351 | (defun verilog-delete-autos-lined () | 10389 | (defun verilog-delete-autos-lined () |
| @@ -10411,7 +10449,7 @@ Deletion stops at the matching end parenthesis, outside comments." | |||
| 10411 | (delete-region (point) | 10449 | (delete-region (point) |
| 10412 | (save-excursion | 10450 | (save-excursion |
| 10413 | (verilog-backward-open-paren) | 10451 | (verilog-backward-open-paren) |
| 10414 | (verilog-forward-sexp-ign-cmt 1) ;; Moves to paren that closes argdecl's | 10452 | (verilog-forward-sexp-ign-cmt 1) ; Moves to paren that closes argdecl's |
| 10415 | (backward-char 1) | 10453 | (backward-char 1) |
| 10416 | (point)))) | 10454 | (point)))) |
| 10417 | 10455 | ||
| @@ -10477,7 +10515,7 @@ called before and after this function, respectively." | |||
| 10477 | (interactive) | 10515 | (interactive) |
| 10478 | (save-excursion | 10516 | (save-excursion |
| 10479 | (if (buffer-file-name) | 10517 | (if (buffer-file-name) |
| 10480 | (find-file-noselect (buffer-file-name))) ;; To check we have latest version | 10518 | (find-file-noselect (buffer-file-name))) ; To check we have latest version |
| 10481 | (verilog-save-no-change-functions | 10519 | (verilog-save-no-change-functions |
| 10482 | (verilog-save-scan-cache | 10520 | (verilog-save-scan-cache |
| 10483 | ;; Allow user to customize | 10521 | ;; Allow user to customize |
| @@ -10512,8 +10550,7 @@ called before and after this function, respectively." | |||
| 10512 | ;; Final customize | 10550 | ;; Final customize |
| 10513 | (verilog-run-hooks 'verilog-delete-auto-hook))))) | 10551 | (verilog-run-hooks 'verilog-delete-auto-hook))))) |
| 10514 | 10552 | ||
| 10515 | ;; | 10553 | ;;; Auto inject: |
| 10516 | ;; Auto inject | ||
| 10517 | ;; | 10554 | ;; |
| 10518 | 10555 | ||
| 10519 | (defun verilog-inject-auto () | 10556 | (defun verilog-inject-auto () |
| @@ -10589,7 +10626,7 @@ Typing \\[verilog-inject-auto] will make this into: | |||
| 10589 | got-sigs) | 10626 | got-sigs) |
| 10590 | (backward-char 1) | 10627 | (backward-char 1) |
| 10591 | (verilog-forward-sexp-ign-cmt 1) | 10628 | (verilog-forward-sexp-ign-cmt 1) |
| 10592 | (backward-char 1) ;; End ) | 10629 | (backward-char 1) ; End ) |
| 10593 | (when (not (verilog-re-search-backward-quick "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) | 10630 | (when (not (verilog-re-search-backward-quick "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) |
| 10594 | (setq pre-sigs (verilog-signals-from-signame | 10631 | (setq pre-sigs (verilog-signals-from-signame |
| 10595 | (verilog-read-signals start-pt (point))) | 10632 | (verilog-read-signals start-pt (point))) |
| @@ -10605,23 +10642,23 @@ Typing \\[verilog-inject-auto] will make this into: | |||
| 10605 | (goto-char (point-min)) | 10642 | (goto-char (point-min)) |
| 10606 | ;; It's hard to distinguish modules; we'll instead search for pins. | 10643 | ;; It's hard to distinguish modules; we'll instead search for pins. |
| 10607 | (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) | 10644 | (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) |
| 10608 | (verilog-backward-open-paren) ;; Inst start | 10645 | (verilog-backward-open-paren) ; Inst start |
| 10609 | (cond | 10646 | (cond |
| 10610 | ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip. | 10647 | ((= (preceding-char) ?\#) ; #(...) parameter section, not pin. Skip. |
| 10611 | (forward-char 1) | 10648 | (forward-char 1) |
| 10612 | (verilog-forward-close-paren)) ;; Parameters done | 10649 | (verilog-forward-close-paren)) ; Parameters done |
| 10613 | (t | 10650 | (t |
| 10614 | (forward-char 1) | 10651 | (forward-char 1) |
| 10615 | (let ((indent-pt (+ (current-column))) | 10652 | (let ((indent-pt (+ (current-column))) |
| 10616 | (end-pt (save-excursion (verilog-forward-close-paren) (point)))) | 10653 | (end-pt (save-excursion (verilog-forward-close-paren) (point)))) |
| 10617 | (cond ((verilog-re-search-forward-quick "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) | 10654 | (cond ((verilog-re-search-forward-quick "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) |
| 10618 | (goto-char end-pt)) ;; Already there, continue search with next instance | 10655 | (goto-char end-pt)) ; Already there, continue search with next instance |
| 10619 | (t | 10656 | (t |
| 10620 | ;; Delete identical interconnect | 10657 | ;; Delete identical interconnect |
| 10621 | (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc | 10658 | (let ((case-fold-search nil)) ; So we don't convert upper-to-lower, etc |
| 10622 | (while (verilog-re-search-forward-quick "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) | 10659 | (while (verilog-re-search-forward-quick "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) |
| 10623 | (delete-region (match-beginning 0) (match-end 0)) | 10660 | (delete-region (match-beginning 0) (match-end 0)) |
| 10624 | (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct | 10661 | (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ; Keep it correct |
| 10625 | (while (or (looking-at "[ \t\n\f,]+") | 10662 | (while (or (looking-at "[ \t\n\f,]+") |
| 10626 | (looking-at "//[^\n]*")) | 10663 | (looking-at "//[^\n]*")) |
| 10627 | (delete-region (match-beginning 0) (match-end 0)) | 10664 | (delete-region (match-beginning 0) (match-end 0)) |
| @@ -10633,9 +10670,9 @@ Typing \\[verilog-inject-auto] will make this into: | |||
| 10633 | (delete-region (match-beginning 0) (match-end 0))) | 10670 | (delete-region (match-beginning 0) (match-end 0))) |
| 10634 | (verilog-insert "\n") | 10671 | (verilog-insert "\n") |
| 10635 | (verilog-insert-indent "/*AUTOINST*/"))))))))) | 10672 | (verilog-insert-indent "/*AUTOINST*/"))))))))) |
| 10636 | 10673 | ||
| 10637 | ;; | 10674 | ;; |
| 10638 | ;; Auto diff | 10675 | ;; Auto diff: |
| 10639 | ;; | 10676 | ;; |
| 10640 | 10677 | ||
| 10641 | (defun verilog-diff-buffers-p (b1 b2 &optional whitespace) | 10678 | (defun verilog-diff-buffers-p (b1 b2 &optional whitespace) |
| @@ -10643,7 +10680,7 @@ Typing \\[verilog-inject-auto] will make this into: | |||
| 10643 | Else, return point in B1 that first mismatches. | 10680 | Else, return point in B1 that first mismatches. |
| 10644 | If optional WHITESPACE true, ignore whitespace." | 10681 | If optional WHITESPACE true, ignore whitespace." |
| 10645 | (save-excursion | 10682 | (save-excursion |
| 10646 | (let* ((case-fold-search nil) ;; compare-buffer-substrings cares | 10683 | (let* ((case-fold-search nil) ; compare-buffer-substrings cares |
| 10647 | (p1 (with-current-buffer b1 (goto-char (point-min)))) | 10684 | (p1 (with-current-buffer b1 (goto-char (point-min)))) |
| 10648 | (p2 (with-current-buffer b2 (goto-char (point-min)))) | 10685 | (p2 (with-current-buffer b2 (goto-char (point-min)))) |
| 10649 | (maxp1 (with-current-buffer b1 (point-max))) | 10686 | (maxp1 (with-current-buffer b1 (point-max))) |
| @@ -10684,25 +10721,25 @@ Ignores WHITESPACE if t, and writes output to stdout if SHOW." | |||
| 10684 | (if (not (file-exists-p f1)) | 10721 | (if (not (file-exists-p f1)) |
| 10685 | (message "Buffer %s has no associated file on disc" (buffer-name b2)) | 10722 | (message "Buffer %s has no associated file on disc" (buffer-name b2)) |
| 10686 | (with-temp-buffer "*Verilog-Diff*" | 10723 | (with-temp-buffer "*Verilog-Diff*" |
| 10687 | (let ((outbuf (current-buffer)) | 10724 | (let ((outbuf (current-buffer)) |
| 10688 | (f2 (make-temp-file "vm-diff-auto-"))) | 10725 | (f2 (make-temp-file "vm-diff-auto-"))) |
| 10689 | (unwind-protect | 10726 | (unwind-protect |
| 10690 | (progn | 10727 | (progn |
| 10691 | (with-current-buffer b2 | 10728 | (with-current-buffer b2 |
| 10692 | (save-restriction | 10729 | (save-restriction |
| 10693 | (widen) | 10730 | (widen) |
| 10694 | (write-region (point-min) (point-max) f2 nil 'nomessage))) | 10731 | (write-region (point-min) (point-max) f2 nil 'nomessage))) |
| 10695 | (call-process diff-command nil outbuf t | 10732 | (call-process diff-command nil outbuf t |
| 10696 | diff-switches ;; User may want -u in diff-switches | 10733 | diff-switches ; User may want -u in diff-switches |
| 10697 | (if whitespace "-b" "") | 10734 | (if whitespace "-b" "") |
| 10698 | f1 f2) | 10735 | f1 f2) |
| 10699 | ;; Print out results. Alternatively we could have call-processed | 10736 | ;; Print out results. Alternatively we could have call-processed |
| 10700 | ;; ourself, but this way we can reuse diff switches | 10737 | ;; ourself, but this way we can reuse diff switches |
| 10701 | (when show | 10738 | (when show |
| 10702 | (with-current-buffer outbuf (message "%s" (buffer-string)))))) | 10739 | (with-current-buffer outbuf (message "%s" (buffer-string)))))) |
| 10703 | (sit-for 0) | 10740 | (sit-for 0) |
| 10704 | (when (file-exists-p f2) | 10741 | (when (file-exists-p f2) |
| 10705 | (delete-file f2)))))) | 10742 | (delete-file f2)))))) |
| 10706 | 10743 | ||
| 10707 | (defun verilog-diff-report (b1 b2 diffpt) | 10744 | (defun verilog-diff-report (b1 b2 diffpt) |
| 10708 | "Report differences detected with `verilog-diff-auto'. | 10745 | "Report differences detected with `verilog-diff-auto'. |
| @@ -10735,7 +10772,7 @@ or `diff' in batch mode." | |||
| 10735 | (save-excursion | 10772 | (save-excursion |
| 10736 | (when (get-buffer newname) | 10773 | (when (get-buffer newname) |
| 10737 | (kill-buffer newname)) | 10774 | (kill-buffer newname)) |
| 10738 | (setq b2 (let (buffer-file-name) ;; Else clone is upset | 10775 | (setq b2 (let (buffer-file-name) ; Else clone is upset |
| 10739 | (clone-buffer newname))) | 10776 | (clone-buffer newname))) |
| 10740 | (with-current-buffer b2 | 10777 | (with-current-buffer b2 |
| 10741 | ;; auto requires the filename, but can't have same filename in two | 10778 | ;; auto requires the filename, but can't have same filename in two |
| @@ -10753,13 +10790,12 @@ or `diff' in batch mode." | |||
| 10753 | (setq diffpt (verilog-diff-buffers-p b1 b2 t)) | 10790 | (setq diffpt (verilog-diff-buffers-p b1 b2 t)) |
| 10754 | (cond ((not diffpt) | 10791 | (cond ((not diffpt) |
| 10755 | (unless noninteractive (message "AUTO expansion identical")) | 10792 | (unless noninteractive (message "AUTO expansion identical")) |
| 10756 | (kill-buffer newname)) ;; Nice to cleanup after oneself | 10793 | (kill-buffer newname)) ; Nice to cleanup after oneself |
| 10757 | (t | 10794 | (t |
| 10758 | (funcall verilog-diff-function b1 b2 diffpt))) | 10795 | (funcall verilog-diff-function b1 b2 diffpt))) |
| 10759 | ;; Return result of compare | 10796 | ;; Return result of compare |
| 10760 | diffpt))) | 10797 | diffpt))) |
| 10761 | 10798 | ||
| 10762 | |||
| 10763 | ;; | 10799 | ;; |
| 10764 | ;; Auto save | 10800 | ;; Auto save |
| 10765 | ;; | 10801 | ;; |
| @@ -10785,7 +10821,7 @@ or `diff' in batch mode." | |||
| 10785 | (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick)))) | 10821 | (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick)))) |
| 10786 | (when (not verilog-auto-star-save) | 10822 | (when (not verilog-auto-star-save) |
| 10787 | (verilog-delete-auto-star-implicit)) | 10823 | (verilog-delete-auto-star-implicit)) |
| 10788 | nil) ;; Always return nil -- we don't write the file ourselves | 10824 | nil) ; Always return nil -- we don't write the file ourselves |
| 10789 | 10825 | ||
| 10790 | (defun verilog-auto-read-locals () | 10826 | (defun verilog-auto-read-locals () |
| 10791 | "Return file local variable segment at bottom of file." | 10827 | "Return file local variable segment at bottom of file." |
| @@ -10807,8 +10843,7 @@ If FORCE, always reread it." | |||
| 10807 | (hack-local-variables) | 10843 | (hack-local-variables) |
| 10808 | t))) | 10844 | t))) |
| 10809 | 10845 | ||
| 10810 | ;; | 10846 | ;;; Auto creation: |
| 10811 | ;; Auto creation | ||
| 10812 | ;; | 10847 | ;; |
| 10813 | 10848 | ||
| 10814 | (defun verilog-auto-arg-ports (sigs message indent-pt) | 10849 | (defun verilog-auto-arg-ports (sigs message indent-pt) |
| @@ -10944,19 +10979,19 @@ See the example in `verilog-auto-inout-modport'." | |||
| 10944 | (modport-re (nth 1 params)) | 10979 | (modport-re (nth 1 params)) |
| 10945 | (inst-name (nth 2 params)) | 10980 | (inst-name (nth 2 params)) |
| 10946 | (regexp (nth 3 params)) | 10981 | (regexp (nth 3 params)) |
| 10947 | direction-re submodi) ;; direction argument not supported until requested | 10982 | direction-re submodi) ; direction argument not supported until requested |
| 10948 | ;; Lookup position, etc of co-module | 10983 | ;; Lookup position, etc of co-module |
| 10949 | ;; Note this may raise an error | 10984 | ;; Note this may raise an error |
| 10950 | (when (setq submodi (verilog-modi-lookup submod t)) | 10985 | (when (setq submodi (verilog-modi-lookup submod t)) |
| 10951 | (let* ((indent-pt (current-indentation)) | 10986 | (let* ((indent-pt (current-indentation)) |
| 10952 | (submoddecls (verilog-modi-get-decls submodi)) | 10987 | (submoddecls (verilog-modi-get-decls submodi)) |
| 10953 | (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) | 10988 | (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) |
| 10954 | (sig-list-i (verilog-signals-in ;; Decls doesn't have data types, must resolve | 10989 | (sig-list-i (verilog-signals-in ; Decls doesn't have data types, must resolve |
| 10955 | (verilog-decls-get-vars submoddecls) | 10990 | (verilog-decls-get-vars submoddecls) |
| 10956 | (verilog-signals-not-in | 10991 | (verilog-signals-not-in |
| 10957 | (verilog-decls-get-inputs submodportdecls) | 10992 | (verilog-decls-get-inputs submodportdecls) |
| 10958 | (verilog-decls-get-ports submoddecls)))) | 10993 | (verilog-decls-get-ports submoddecls)))) |
| 10959 | (sig-list-o (verilog-signals-in ;; Decls doesn't have data types, must resolve | 10994 | (sig-list-o (verilog-signals-in ; Decls doesn't have data types, must resolve |
| 10960 | (verilog-decls-get-vars submoddecls) | 10995 | (verilog-decls-get-vars submoddecls) |
| 10961 | (verilog-signals-not-in | 10996 | (verilog-signals-not-in |
| 10962 | (verilog-decls-get-outputs submodportdecls) | 10997 | (verilog-decls-get-outputs submodportdecls) |
| @@ -11140,10 +11175,10 @@ If PAR-VALUES replace final strings with these parameter values." | |||
| 11140 | ;; There maybe an ifdef or something similar before us. What a mess. Thus | 11175 | ;; There maybe an ifdef or something similar before us. What a mess. Thus |
| 11141 | ;; to avoid trouble we only insert on preceding ) or *. | 11176 | ;; to avoid trouble we only insert on preceding ) or *. |
| 11142 | ;; Insert first port on new line | 11177 | ;; Insert first port on new line |
| 11143 | (insert "\n") ;; Must insert before search, so point will move forward if insert comma | 11178 | (insert "\n") ; Must insert before search, so point will move forward if insert comma |
| 11144 | (save-excursion | 11179 | (save-excursion |
| 11145 | (verilog-re-search-backward-quick "[^ \t\n\f]" nil nil) | 11180 | (verilog-re-search-backward-quick "[^ \t\n\f]" nil nil) |
| 11146 | (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure | 11181 | (when (looking-at ")\\|\\*") ; Generally don't insert, unless we are fairly sure |
| 11147 | (forward-char 1) | 11182 | (forward-char 1) |
| 11148 | (insert ",")))) | 11183 | (insert ",")))) |
| 11149 | 11184 | ||
| @@ -11575,11 +11610,11 @@ For more information see the \\[verilog-faq] and forums at URL | |||
| 11575 | (re-search-backward "," pt t) | 11610 | (re-search-backward "," pt t) |
| 11576 | (delete-char 1) | 11611 | (delete-char 1) |
| 11577 | (insert ");") | 11612 | (insert ");") |
| 11578 | (search-forward "\n") ;; Added by inst-port | 11613 | (search-forward "\n") ; Added by inst-port |
| 11579 | (delete-char -1) | 11614 | (delete-char -1) |
| 11580 | (if (search-forward ")" nil t) ;; From user, moved up a line | 11615 | (if (search-forward ")" nil t) ; From user, moved up a line |
| 11581 | (delete-char -1)) | 11616 | (delete-char -1)) |
| 11582 | (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it | 11617 | (if (search-forward ";" nil t) ; Don't error if user had syntax error and forgot it |
| 11583 | (delete-char -1))))))))) | 11618 | (delete-char -1))))))))) |
| 11584 | 11619 | ||
| 11585 | (defun verilog-auto-inst-param () | 11620 | (defun verilog-auto-inst-param () |
| @@ -11677,9 +11712,9 @@ Templates: | |||
| 11677 | (re-search-backward "," pt t) | 11712 | (re-search-backward "," pt t) |
| 11678 | (delete-char 1) | 11713 | (delete-char 1) |
| 11679 | (insert ")") | 11714 | (insert ")") |
| 11680 | (search-forward "\n") ;; Added by inst-port | 11715 | (search-forward "\n") ; Added by inst-port |
| 11681 | (delete-char -1) | 11716 | (delete-char -1) |
| 11682 | (if (search-forward ")" nil t) ;; From user, moved up a line | 11717 | (if (search-forward ")" nil t) ; From user, moved up a line |
| 11683 | (delete-char -1))))))))) | 11718 | (delete-char -1))))))))) |
| 11684 | 11719 | ||
| 11685 | (defun verilog-auto-reg () | 11720 | (defun verilog-auto-reg () |
| @@ -11721,7 +11756,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 11721 | (modsubdecls (verilog-modi-get-sub-decls modi)) | 11756 | (modsubdecls (verilog-modi-get-sub-decls modi)) |
| 11722 | (sig-list (verilog-signals-not-in | 11757 | (sig-list (verilog-signals-not-in |
| 11723 | (verilog-decls-get-outputs moddecls) | 11758 | (verilog-decls-get-outputs moddecls) |
| 11724 | (append (verilog-signals-with ;; ignore typed signals | 11759 | (append (verilog-signals-with ; ignore typed signals |
| 11725 | 'verilog-sig-type | 11760 | 'verilog-sig-type |
| 11726 | (verilog-decls-get-outputs moddecls)) | 11761 | (verilog-decls-get-outputs moddecls)) |
| 11727 | (verilog-decls-get-vars moddecls) | 11762 | (verilog-decls-get-vars moddecls) |
| @@ -12594,7 +12629,7 @@ driver/monitor using AUTOINST in the testbench." | |||
| 12594 | (submod (nth 0 params)) | 12629 | (submod (nth 0 params)) |
| 12595 | (modport-re (nth 1 params)) | 12630 | (modport-re (nth 1 params)) |
| 12596 | (regexp (nth 2 params)) | 12631 | (regexp (nth 2 params)) |
| 12597 | direction-re submodi) ;; direction argument not supported until requested | 12632 | direction-re submodi) ; direction argument not supported until requested |
| 12598 | ;; Lookup position, etc of co-module | 12633 | ;; Lookup position, etc of co-module |
| 12599 | ;; Note this may raise an error | 12634 | ;; Note this may raise an error |
| 12600 | (when (setq submodi (verilog-modi-lookup submod t)) | 12635 | (when (setq submodi (verilog-modi-lookup submod t)) |
| @@ -12604,19 +12639,19 @@ driver/monitor using AUTOINST in the testbench." | |||
| 12604 | (moddecls (verilog-modi-get-decls modi)) | 12639 | (moddecls (verilog-modi-get-decls modi)) |
| 12605 | (submoddecls (verilog-modi-get-decls submodi)) | 12640 | (submoddecls (verilog-modi-get-decls submodi)) |
| 12606 | (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) | 12641 | (submodportdecls (verilog-modi-modport-lookup submodi modport-re)) |
| 12607 | (sig-list-i (verilog-signals-in ;; Decls doesn't have data types, must resolve | 12642 | (sig-list-i (verilog-signals-in ; Decls doesn't have data types, must resolve |
| 12608 | (verilog-decls-get-vars submoddecls) | 12643 | (verilog-decls-get-vars submoddecls) |
| 12609 | (verilog-signals-not-in | 12644 | (verilog-signals-not-in |
| 12610 | (verilog-decls-get-inputs submodportdecls) | 12645 | (verilog-decls-get-inputs submodportdecls) |
| 12611 | (append (verilog-decls-get-ports submoddecls) | 12646 | (append (verilog-decls-get-ports submoddecls) |
| 12612 | (verilog-decls-get-ports moddecls))))) | 12647 | (verilog-decls-get-ports moddecls))))) |
| 12613 | (sig-list-o (verilog-signals-in ;; Decls doesn't have data types, must resolve | 12648 | (sig-list-o (verilog-signals-in ; Decls doesn't have data types, must resolve |
| 12614 | (verilog-decls-get-vars submoddecls) | 12649 | (verilog-decls-get-vars submoddecls) |
| 12615 | (verilog-signals-not-in | 12650 | (verilog-signals-not-in |
| 12616 | (verilog-decls-get-outputs submodportdecls) | 12651 | (verilog-decls-get-outputs submodportdecls) |
| 12617 | (append (verilog-decls-get-ports submoddecls) | 12652 | (append (verilog-decls-get-ports submoddecls) |
| 12618 | (verilog-decls-get-ports moddecls))))) | 12653 | (verilog-decls-get-ports moddecls))))) |
| 12619 | (sig-list-io (verilog-signals-in ;; Decls doesn't have data types, must resolve | 12654 | (sig-list-io (verilog-signals-in ; Decls doesn't have data types, must resolve |
| 12620 | (verilog-decls-get-vars submoddecls) | 12655 | (verilog-decls-get-vars submoddecls) |
| 12621 | (verilog-signals-not-in | 12656 | (verilog-signals-not-in |
| 12622 | (verilog-decls-get-inouts submodportdecls) | 12657 | (verilog-decls-get-inouts submodportdecls) |
| @@ -12694,10 +12729,10 @@ text: | |||
| 12694 | (let* ((indent-pt (current-indentation)) | 12729 | (let* ((indent-pt (current-indentation)) |
| 12695 | (cmd-end-pt (save-excursion (search-backward ")") | 12730 | (cmd-end-pt (save-excursion (search-backward ")") |
| 12696 | (forward-char) | 12731 | (forward-char) |
| 12697 | (point))) ;; Closing paren | 12732 | (point))) ; Closing paren |
| 12698 | (cmd-beg-pt (save-excursion (goto-char cmd-end-pt) | 12733 | (cmd-beg-pt (save-excursion (goto-char cmd-end-pt) |
| 12699 | (backward-sexp 1) ;; Inside comment | 12734 | (backward-sexp 1) ; Inside comment |
| 12700 | (point))) ;; Beginning paren | 12735 | (point))) ; Beginning paren |
| 12701 | (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt))) | 12736 | (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt))) |
| 12702 | (verilog-forward-or-insert-line) | 12737 | (verilog-forward-or-insert-line) |
| 12703 | ;; Some commands don't move point (like insert-file) so we always | 12738 | ;; Some commands don't move point (like insert-file) so we always |
| @@ -12707,7 +12742,7 @@ text: | |||
| 12707 | (forward-line -1) | 12742 | (forward-line -1) |
| 12708 | (eval (read cmd)) | 12743 | (eval (read cmd)) |
| 12709 | (forward-line -1) | 12744 | (forward-line -1) |
| 12710 | (setq verilog-scan-cache-tick nil) ;; Clear cache; inserted unknown text | 12745 | (setq verilog-scan-cache-tick nil) ; Clear cache; inserted unknown text |
| 12711 | (verilog-delete-empty-auto-pair)))) | 12746 | (verilog-delete-empty-auto-pair)))) |
| 12712 | 12747 | ||
| 12713 | (defun verilog-auto-insert-last () | 12748 | (defun verilog-auto-insert-last () |
| @@ -12817,7 +12852,7 @@ operator. (This was added to the language in part due to AUTOSENSE!) | |||
| 12817 | (let ((tlen (length sig-list))) | 12852 | (let ((tlen (length sig-list))) |
| 12818 | (setq sig-list (verilog-signals-not-in sig-list sig-memories)) | 12853 | (setq sig-list (verilog-signals-not-in sig-list sig-memories)) |
| 12819 | (if (not (eq tlen (length sig-list))) (verilog-insert " /*memory or*/ ")))) | 12854 | (if (not (eq tlen (length sig-list))) (verilog-insert " /*memory or*/ ")))) |
| 12820 | (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" | 12855 | (if (and presense-sigs ; Add a "or" if not "(.... or /*AUTOSENSE*/" |
| 12821 | (save-excursion (goto-char (point)) | 12856 | (save-excursion (goto-char (point)) |
| 12822 | (verilog-re-search-backward-quick "[a-zA-Z0-9$_.%`]+" start-pt t) | 12857 | (verilog-re-search-backward-quick "[a-zA-Z0-9$_.%`]+" start-pt t) |
| 12823 | (verilog-re-search-backward-quick "\\s-" start-pt t) | 12858 | (verilog-re-search-backward-quick "\\s-" start-pt t) |
| @@ -12940,7 +12975,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 12940 | (insert "\n"); | 12975 | (insert "\n"); |
| 12941 | (verilog-insert-indent "// Beginning of autoreset for uninitialized flops\n"); | 12976 | (verilog-insert-indent "// Beginning of autoreset for uninitialized flops\n"); |
| 12942 | (while sig-list | 12977 | (while sig-list |
| 12943 | (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths | 12978 | (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ; As sig-list has no widths |
| 12944 | (car sig-list)))) | 12979 | (car sig-list)))) |
| 12945 | (indent-to indent-pt) | 12980 | (indent-to indent-pt) |
| 12946 | (insert (verilog-sig-name sig) | 12981 | (insert (verilog-sig-name sig) |
| @@ -13092,7 +13127,7 @@ defines the regular expression will be undefed." | |||
| 13092 | (setq def (match-string-no-properties 2)) | 13127 | (setq def (match-string-no-properties 2)) |
| 13093 | (when (and (or (not regexp) | 13128 | (when (and (or (not regexp) |
| 13094 | (string-match regexp def)) | 13129 | (string-match regexp def)) |
| 13095 | (not (member def defs))) ;; delete-dups not in 21.1 | 13130 | (not (member def defs))) ; delete-dups not in 21.1 |
| 13096 | (setq defs (cons def defs)))) | 13131 | (setq defs (cons def defs)))) |
| 13097 | (t | 13132 | (t |
| 13098 | (setq defs (delete (match-string-no-properties 2) defs)))))) | 13133 | (setq defs (delete (match-string-no-properties 2) defs)))))) |
| @@ -13288,7 +13323,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 13288 | ;; | 13323 | ;; |
| 13289 | (one-hot (or | 13324 | (one-hot (or |
| 13290 | (string-match "onehot" (or one-hot-flag "")) | 13325 | (string-match "onehot" (or one-hot-flag "")) |
| 13291 | (and ;; width(enum) != width(sig) | 13326 | (and ; width(enum) != width(sig) |
| 13292 | (or (not (verilog-sig-bits (car enum-sigs))) | 13327 | (or (not (verilog-sig-bits (car enum-sigs))) |
| 13293 | (not (equal (verilog-sig-width (car enum-sigs)) | 13328 | (not (equal (verilog-sig-width (car enum-sigs)) |
| 13294 | (verilog-sig-width undecode-sig)))) | 13329 | (verilog-sig-width undecode-sig)))) |
| @@ -13387,21 +13422,20 @@ Enable with `verilog-auto-template-warn-unused'." | |||
| 13387 | (while tlines | 13422 | (while tlines |
| 13388 | (setq tpl-ass (car tlines) | 13423 | (setq tpl-ass (car tlines) |
| 13389 | tlines (cdr tlines)) | 13424 | tlines (cdr tlines)) |
| 13390 | ;;; | 13425 | ;; |
| 13391 | (unless (or (not (eval-when-compile (fboundp 'make-hash-table))) ;; Not supported, no warning | 13426 | (unless (or (not (eval-when-compile (fboundp 'make-hash-table))) ; Not supported, no warning |
| 13392 | (not verilog-auto-template-hits) | 13427 | (not verilog-auto-template-hits) |
| 13393 | (gethash (vector (nth 2 tpl-ass) (nth 3 tpl-ass)) | 13428 | (gethash (vector (nth 2 tpl-ass) (nth 3 tpl-ass)) |
| 13394 | verilog-auto-template-hits)) | 13429 | verilog-auto-template-hits)) |
| 13395 | (verilog-warn-error "%s:%d: AUTO_TEMPLATE line unused: \".%s (%s)\"" | 13430 | (verilog-warn-error "%s:%d: AUTO_TEMPLATE line unused: \".%s (%s)\"" |
| 13396 | name1 | 13431 | name1 |
| 13397 | (+ (elt tpl-ass 3) ;; Template line number | 13432 | (+ (elt tpl-ass 3) ; Template line number |
| 13398 | (count-lines (point-min) (point))) | 13433 | (count-lines (point-min) (point))) |
| 13399 | (elt tpl-ass 0) (elt tpl-ass 1)) | 13434 | (elt tpl-ass 0) (elt tpl-ass 1)) |
| 13400 | ))))))) | 13435 | ))))))) |
| 13401 | 13436 | ||
| 13402 | 13437 | ||
| 13403 | ;; | 13438 | ;;; Auto top level: |
| 13404 | ;; Auto top level | ||
| 13405 | ;; | 13439 | ;; |
| 13406 | 13440 | ||
| 13407 | (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing an arg | 13441 | (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing an arg |
| @@ -13501,7 +13535,7 @@ Wilson Snyder (wsnyder@wsnyder.org)." | |||
| 13501 | ;; we'll misremember we have generated IOs, confusing AUTOOUTPUT | 13535 | ;; we'll misremember we have generated IOs, confusing AUTOOUTPUT |
| 13502 | (setq verilog-modi-cache-list nil) | 13536 | (setq verilog-modi-cache-list nil) |
| 13503 | ;; Local state | 13537 | ;; Local state |
| 13504 | (setq verilog-auto-template-hits nil) | 13538 | (verilog-read-auto-template-init) |
| 13505 | ;; If we're not in verilog-mode, change syntax table so parsing works right | 13539 | ;; If we're not in verilog-mode, change syntax table so parsing works right |
| 13506 | (unless (eq major-mode `verilog-mode) (verilog-mode)) | 13540 | (unless (eq major-mode `verilog-mode) (verilog-mode)) |
| 13507 | ;; Allow user to customize | 13541 | ;; Allow user to customize |
| @@ -13595,10 +13629,9 @@ Wilson Snyder (wsnyder@wsnyder.org)." | |||
| 13595 | ;; Currently handled in verilog-save-font-mods | 13629 | ;; Currently handled in verilog-save-font-mods |
| 13596 | )))) | 13630 | )))) |
| 13597 | 13631 | ||
| 13598 | 13632 | ;;; Skeletons: | |
| 13599 | ;; | ||
| 13600 | ;; Skeleton based code insertion | ||
| 13601 | ;; | 13633 | ;; |
| 13634 | |||
| 13602 | (defvar verilog-template-map | 13635 | (defvar verilog-template-map |
| 13603 | (let ((map (make-sparse-keymap))) | 13636 | (let ((map (make-sparse-keymap))) |
| 13604 | (define-key map "a" 'verilog-sk-always) | 13637 | (define-key map "a" 'verilog-sk-always) |
| @@ -13645,7 +13678,7 @@ Wilson Snyder (wsnyder@wsnyder.org)." | |||
| 13645 | ;; Note \C-c and letter are reserved for users | 13678 | ;; Note \C-c and letter are reserved for users |
| 13646 | (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) | 13679 | (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) |
| 13647 | 13680 | ||
| 13648 | ;;; ---- statement skeletons ------------------------------------------ | 13681 | ;; ---- statement skeletons ------------------------------------------ |
| 13649 | 13682 | ||
| 13650 | (define-skeleton verilog-sk-prompt-condition | 13683 | (define-skeleton verilog-sk-prompt-condition |
| 13651 | "Prompt for the loop condition." | 13684 | "Prompt for the loop condition." |
| @@ -13727,9 +13760,9 @@ See also `verilog-header' for an alternative format." | |||
| 13727 | > _ \n | 13760 | > _ \n |
| 13728 | > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) | 13761 | > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) |
| 13729 | 13762 | ||
| 13730 | ;;; ------------------------------------------------------------------------ | 13763 | ;; ------------------------------------------------------------------------ |
| 13731 | ;;; Define a default OVM class, with macros and new() | 13764 | ;; Define a default OVM class, with macros and new() |
| 13732 | ;;; ------------------------------------------------------------------------ | 13765 | ;; ------------------------------------------------------------------------ |
| 13733 | 13766 | ||
| 13734 | (define-skeleton verilog-sk-ovm-class | 13767 | (define-skeleton verilog-sk-ovm-class |
| 13735 | "Insert a class definition" | 13768 | "Insert a class definition" |
| @@ -13919,12 +13952,12 @@ and the case items." | |||
| 13919 | (interactive "*") | 13952 | (interactive "*") |
| 13920 | (let* ((sig-re "[a-zA-Z0-9_]*") | 13953 | (let* ((sig-re "[a-zA-Z0-9_]*") |
| 13921 | (v1 (buffer-substring | 13954 | (v1 (buffer-substring |
| 13922 | (save-excursion | 13955 | (save-excursion |
| 13923 | (skip-chars-backward sig-re) | 13956 | (skip-chars-backward sig-re) |
| 13924 | (point)) | 13957 | (point)) |
| 13925 | (save-excursion | 13958 | (save-excursion |
| 13926 | (skip-chars-forward sig-re) | 13959 | (skip-chars-forward sig-re) |
| 13927 | (point))))) | 13960 | (point))))) |
| 13928 | (if (not (member v1 verilog-keywords)) | 13961 | (if (not (member v1 verilog-keywords)) |
| 13929 | (save-excursion | 13962 | (save-excursion |
| 13930 | (setq verilog-sk-signal v1) | 13963 | (setq verilog-sk-signal v1) |
| @@ -14004,7 +14037,7 @@ and the case items." | |||
| 14004 | resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) | 14037 | resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) |
| 14005 | > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) | 14038 | > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) |
| 14006 | 14039 | ||
| 14007 | 14040 | ;;; Mouse Events: | |
| 14008 | ;; | 14041 | ;; |
| 14009 | ;; Include file loading with mouse/return event | 14042 | ;; Include file loading with mouse/return event |
| 14010 | ;; | 14043 | ;; |
| @@ -14039,7 +14072,7 @@ Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |||
| 14039 | (when (or verilog-highlight-includes | 14072 | (when (or verilog-highlight-includes |
| 14040 | verilog-highlight-modules) | 14073 | verilog-highlight-modules) |
| 14041 | (save-excursion | 14074 | (save-excursion |
| 14042 | (save-match-data ;; A query-replace may call this function - do not disturb | 14075 | (save-match-data ; A query-replace may call this function - do not disturb |
| 14043 | (verilog-save-buffer-state | 14076 | (verilog-save-buffer-state |
| 14044 | (verilog-save-scan-cache | 14077 | (verilog-save-scan-cache |
| 14045 | (let (end-point) | 14078 | (let (end-point) |
| @@ -14078,7 +14111,7 @@ Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |||
| 14078 | (save-excursion | 14111 | (save-excursion |
| 14079 | (goto-char (match-beginning 0)) | 14112 | (goto-char (match-beginning 0)) |
| 14080 | (unless (verilog-inside-comment-or-string-p) | 14113 | (unless (verilog-inside-comment-or-string-p) |
| 14081 | (verilog-read-inst-module-matcher) ;; sets match 0 | 14114 | (verilog-read-inst-module-matcher) ; sets match 0 |
| 14082 | (let* ((ov (make-overlay (match-beginning 0) (match-end 0)))) | 14115 | (let* ((ov (make-overlay (match-beginning 0) (match-end 0)))) |
| 14083 | (overlay-put ov 'start-closed 't) | 14116 | (overlay-put ov 'start-closed 't) |
| 14084 | (overlay-put ov 'end-closed 't) | 14117 | (overlay-put ov 'end-closed 't) |
| @@ -14110,7 +14143,7 @@ Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |||
| 14110 | "Load file under button 2 click's EVENT. | 14143 | "Load file under button 2 click's EVENT. |
| 14111 | Files are checked based on `verilog-library-flags'." | 14144 | Files are checked based on `verilog-library-flags'." |
| 14112 | (interactive "@e") | 14145 | (interactive "@e") |
| 14113 | (save-excursion ;; implement a Verilog specific ffap-at-mouse | 14146 | (save-excursion ; implement a Verilog specific ffap-at-mouse |
| 14114 | (mouse-set-point event) | 14147 | (mouse-set-point event) |
| 14115 | (verilog-load-file-at-point t))) | 14148 | (verilog-load-file-at-point t))) |
| 14116 | 14149 | ||
| @@ -14122,7 +14155,7 @@ Files are checked based on `verilog-library-flags'." | |||
| 14122 | If WARN, throw warning if not found. | 14155 | If WARN, throw warning if not found. |
| 14123 | Files are checked based on `verilog-library-flags'." | 14156 | Files are checked based on `verilog-library-flags'." |
| 14124 | (interactive) | 14157 | (interactive) |
| 14125 | (save-excursion ;; implement a Verilog specific ffap | 14158 | (save-excursion ; implement a Verilog specific ffap |
| 14126 | (let ((overlays (overlays-in (point) (point))) | 14159 | (let ((overlays (overlays-in (point) (point))) |
| 14127 | hit) | 14160 | hit) |
| 14128 | (while (and overlays (not hit)) | 14161 | (while (and overlays (not hit)) |
| @@ -14147,8 +14180,8 @@ Files are checked based on `verilog-library-flags'." | |||
| 14147 | "File '%s' isn't readable, use shift-mouse2 to paste in this field" | 14180 | "File '%s' isn't readable, use shift-mouse2 to paste in this field" |
| 14148 | (match-string 1)))))))) | 14181 | (match-string 1)))))))) |
| 14149 | 14182 | ||
| 14150 | ;; | 14183 | |
| 14151 | ;; Bug reporting | 14184 | ;;; Bug reporting: |
| 14152 | ;; | 14185 | ;; |
| 14153 | 14186 | ||
| 14154 | (defun verilog-faq () | 14187 | (defun verilog-faq () |
| @@ -14284,6 +14317,7 @@ but instead, [[Fill in here]] happens!. | |||
| 14284 | ;; Local Variables: | 14317 | ;; Local Variables: |
| 14285 | ;; checkdoc-permit-comma-termination-flag:t | 14318 | ;; checkdoc-permit-comma-termination-flag:t |
| 14286 | ;; checkdoc-force-docstrings-flag:nil | 14319 | ;; checkdoc-force-docstrings-flag:nil |
| 14320 | ;; indent-tabs-mode:nil | ||
| 14287 | ;; End: | 14321 | ;; End: |
| 14288 | 14322 | ||
| 14289 | ;;; verilog-mode.el ends here | 14323 | ;;; verilog-mode.el ends here |