aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael McNamara2011-11-30 19:41:47 -0700
committerDan Nicolaescu2011-11-30 19:41:47 -0700
commit9489a4507f194a97a0d6b658c2f3aa3ea6ccfe96 (patch)
treeecb86cc662a0e10057296064ae4fe7dfb835a8f4
parentba076c751f944cda81703b5c143e52da541403d3 (diff)
downloademacs-9489a4507f194a97a0d6b658c2f3aa3ea6ccfe96.tar.gz
emacs-9489a4507f194a97a0d6b658c2f3aa3ea6ccfe96.zip
Update verilog-mode.el from master.
* progmodes/verilog-mode.el (verilog-pretty-expr): Rework verilog-pretty-expr to handle new assignment operators in system verilog, such as += *= and the like. (verilog-assignment-operator-re): Regular expression to find the assigment operator in a verilog assignment. (verilog-assignment-operation-re): Regular expression to find an assignment statement for pretty-expr. (verilog-in-attribute-p): Query returns true if point is in an attribute context; used to skip these for expression line up from pretty-expr. (verilog-in-parameter-p): Query returns true if point is in an parameter definition context; used to skip these for expression line up from pretty-expr. (verilog-in-parenthesis-p): Query returns true if point is in a parenthetical expression, specifically ( ) but not [ ] or { }; used by pretty-expr. (verilog-just-one-space): If there is no space, don't add one. (verilog-get-lineup-indent-2): Specifically skip just attribute contexts for expression lineup, rather than skipping all parenthetical expressions. (verilog-calculate-indent): Fix comment, and fix indent. (verilog-do-indent): Indent declarations in lists (suggested by Joachim Lechner). (verilog-mode-abbrev-table): Populate abbrev mode with the various skeleton items. (verilog-sk-ovm-class): Add skeleton for OVM classes (reported by Alain Mellan). * verilog-mode.el (verilog-read-defines): Fix reading parameters with embedded comments. Reported by Ray Stevens. (verilog-calc-1, verilog-fork-wait-re) (verilog-forward-sexp, verilog-wait-fork-re): Fix indentation of "wait fork", bug407. Reported by Tim Holt. (verilog-auto): Fix AUTOing a upper module then AUTOing module instantiated by upper module causing wrong expansion until AUTOed a second time. Reported by K C Buckenmaier. (verilog-diff-auto): Fix showing .* as a difference when `verilog-auto-star-save' off. Reported by Dan Dever. (verilog-auto-reset, verilog-read-always-signals) (verilog-auto-reset-blocking-in-non): Fix AUTORESET including temporary signals in reset list if verilog-auto-reset-blocking-in-non is nil, and match assignment style to each signal's assignment type, bug381. Reported by Thomas Esposito. (verilog-sk-uvm-class, verilog-uvm-begin-re, verilog-uvm-end-re) (verilog-uvm-statement-re): Support UVM indentation and highlighting, with old OVM keywords only. (verilog-auto-tieoff, verilog-auto-tieoff-declaration): Support AUTOTIEOFF creating non-wire data types. Suggested by Jonathan Greenlaw. (verilog-auto-insert-lisp, verilog-delete-to-paren) (verilog-forward-sexp-cmt, verilog-forward-sexp-ign-cmt) (verilog-inject-sense, verilog-read-inst-pins) (verilog-read-sub-decls, verilog-read-sub-decls-line): Fix mismatching parenthesis inside commented out code when deleting AUTOINST, bug383. Reported by Jonathan Greenlaw. (verilog-auto-ascii-enum): Fix AUTOASCIIENUM one-hot with non-numeric vector width. Reported by Alex Reed. (verilog-auto-ascii-enum): Add "onehot" option to work around not detecting signals with parameter widths. Reported by Alex Reed. (verilog-auto-delete-trailing-whitespace): With `verilog-auto-delete-trailing-whitespace' remove trailing whitespace in auto expansion, bug371. Reported by Brad Dobbie. (verilog-run-hooks, verilog-scan-cache-flush, verilog-syntax-ppss): Fix verilog-scan-cache corruption when running user AUTO expansion hooks that call indentation routines. (verilog-simplify-range-expression): Fix typo ignoring lower case identifiers. (verilog-delete-auto): Fix delete-autos to also remove user created automatics, as long as they start with AUTO. (verilog-batch-diff-auto, verilog-diff-auto) (verilog-diff-function): Add `verilog-diff-auto' and bind to "C-c?" to report differences in AUTO expansion, ignoring spaces. (verilog-backward-syntactic-ws-quick, verilog-beg-of-defun-quick) (verilog-in-paren-quick, verilog-re-search-backward-quick) (verilog-re-search-forward-quick, verilog-syntax-ppss): Fix calling `syntax-ppss' when inside auto expansions as the ppss hook is disabled and its cache will get corrupt, causing AUTOS not to expand. Instead use only -quick functions. (verilog-scan-region): Fix scanning over escaped quotes. (verilog-inside-comment-or-string-p, verilog-inside-comment-p) (verilog-re-search-backward-quick) (verilog-re-search-forward-quick, verilog-scan): verilog-scan and related functions now ignore strings, to fix misparsing of strings with magic comments embedded in them. (verilog-read-auto-template): Fix 'verilog-auto-inst-template-numbers' with extra newline before (. Reported by Brad Dobbie. (verilog-read-auto-template): Fix 'verilog-auto-inst-template-numbers' with comments. Reported by Brad Dobbie. (verilog-auto-inst, verilog-auto-inst-param) (verilog-auto-inst-sort): Add 'verilog-auto-inst-sort' to reduce merge conflicts with AUTOINST, bug358. Reported by Brad Dobbie. (verilog-auto-inst-template-numbers): Add 'lhs' policy for debugging templates without merge conflicts, bug357. Reported by Brad Dobbie. (verilog-read-auto-template): Fix verilog-auto-inst-template-numbers with multiple templates. Reported by Brad Dobbie. (verilog-define-abbrev): Fix verilog-mode abbrevs to be system abbrevs so user won't be asked to save. (verilog-read-auto-lisp-present): Fix to start at beginning of buffer in case called outside of verilog-auto. (verilog-simplify-range-expression): Fix AUTOWIRE expanding "X-1+1" to "X-2". Reported by Matthew Myers. (verilog-auto, verilog-auto-inout-in): Add AUTOINOUTIN for creating all inputs from module templates. Reported by Leith Johnson. (verilog-module-inside-filename-p): Fix locating programs as with modules. (verilog-auto-inst-port): Fix vl-width expressions when using verilog-auto-inst-param-value, bug331. Reported by Julian Gorfajn. (verilog-decls-get-regs, verilog-decls-get-signals, verilog-decls-get-vars, verilog-decls-get-wires, verilog-decls-new, verilog-modi-cache-add-vars, verilog-modi-cache-add-wires, verilog-read-decls): Combine reg and wire structures into one var structure to represent SystemVerilog concepts. (verilog-auto-ascii-enum, verilog-auto-logic, verilog-auto-reg) (verilog-auto-reg-input, verilog-auto-tieoff, verilog-auto-wire) (verilog-auto-wire-type, verilog-insert-definition): Add verilog-auto-wire-type and AUTOLOGIC to support using SystemVerilog "logic" keyword instead of "wire"/"reg". (verilog-auto-reg-input, verilog-decls-get-signals): Fix AUTOWIRE to declares outputs that also have assignments (presumably in an ifdef or generate if so there's not a driver conflict). Reported by Matthew Myers. (verilog-auto-declare-nettype, verilog-insert-definition): Add verilog-auto-declare-nettype to fix declarations using `default_nettype none. Reported by Julian Gorfajn. (verilog-read-always-signals-recurse, verilog-read-decls) (verilog-read-sub-decls-gate): Fix infinite loop with (*) and malformed end statement, bug325. Reported by Joshua Wise and Andrew Drake. (verilog-auto-star-safe, verilog-delete-auto-star-implicit) (verilog-inst-comment-re): Fix not deleting Interfaced comment when expanding .* in interfaces, bug320. Reported by Pierre-David Pfister. (verilog-read-module-name): Fix import statements between module name and open parenthesis, bug317. Reported by Pierre-David Pfister. (verilog-simplify-range-expression): Fix simplification of multiplications inside AUTOWIRE connections, bug303. (verilog-auto-inst-port): Support parameter expansion in multidimensional arrays. (verilog-read-decls): Fix AUTOREG etc looking for "endproperty" after "assert property". Reported by Julian Gorfajn. (verilog-simplify-range-expression): Fix "couldn't merge" errors with multiplication, bug303. (verilog-read-decls): Fix parsing of unsigned data types, bug302.
-rw-r--r--lisp/progmodes/verilog-mode.el2058
1 files changed, 1473 insertions, 585 deletions
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 3570a2cfa3e..3ae66a477e8 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -87,7 +87,7 @@
87;; you may add the below lines (the values of the variables presented 87;; you may add the below lines (the values of the variables presented
88;; here are the defaults). Note also that if you use an Emacs that 88;; here are the defaults). Note also that if you use an Emacs that
89;; supports custom, it's probably better to use the custom menu to 89;; supports custom, it's probably better to use the custom menu to
90;; edit these. If working as a member of a large team these settings 90;; edit these. If working as a member of a large team these settings
91;; should be common across all users (in a site-start file), or set 91;; should be common across all users (in a site-start file), or set
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.
@@ -123,9 +123,9 @@
123;;; Code: 123;;; Code:
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 "650" 126(defconst verilog-mode-version "725"
127 "Version of this Verilog mode.") 127 "Version of this Verilog mode.")
128(defconst verilog-mode-release-date "2010-11-05-GNU" 128(defconst verilog-mode-release-date "2011-11-27-GNU"
129 "Release date of this Verilog mode.") 129 "Release date of this Verilog mode.")
130(defconst verilog-mode-release-emacs t 130(defconst verilog-mode-release-emacs t
131 "If non-nil, this version of Verilog mode was released with Emacs itself.") 131 "If non-nil, this version of Verilog mode was released with Emacs itself.")
@@ -174,6 +174,18 @@
174 (char-after (1- (point))))) 174 (char-after (1- (point)))))
175 (error nil)) 175 (error nil))
176 (condition-case nil 176 (condition-case nil
177 (if (fboundp 'when)
178 nil ;; fab
179 (defsubst point-at-bol (&optional N)
180 (save-excursion (beginning-of-line N) (point))))
181 (error nil))
182 (condition-case nil
183 (if (fboundp 'when)
184 nil ;; fab
185 (defsubst point-at-eol (&optional N)
186 (save-excursion (end-of-line N) (point))))
187 (error nil))
188 (condition-case nil
177 (require 'custom) 189 (require 'custom)
178 (error nil)) 190 (error nil))
179 (condition-case nil 191 (condition-case nil
@@ -275,8 +287,19 @@ STRING should be given if the last search was by `string-match' on STRING."
275(eval-and-compile 287(eval-and-compile
276 ;; Both xemacs and emacs 288 ;; Both xemacs and emacs
277 (condition-case nil 289 (condition-case nil
290 (require 'diff) ;; diff-command and diff-switches
291 (error nil))
292 (condition-case nil
293 (require 'compile) ;; compilation-error-regexp-alist-alist
294 (error nil))
295 (condition-case nil
278 (unless (fboundp 'buffer-chars-modified-tick) ;; Emacs 22 added 296 (unless (fboundp 'buffer-chars-modified-tick) ;; Emacs 22 added
279 (defmacro buffer-chars-modified-tick () (buffer-modified-tick))) 297 (defmacro buffer-chars-modified-tick () (buffer-modified-tick)))
298 (error nil))
299 ;; Added in Emacs 24.1
300 (condition-case nil
301 (unless (fboundp 'prog-mode)
302 (define-derived-mode prog-mode fundamental-mode "Prog"))
280 (error nil))) 303 (error nil)))
281 304
282(eval-when-compile 305(eval-when-compile
@@ -310,6 +333,14 @@ STRING should be given if the last search was by `string-match' on STRING."
310;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) 333;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"])
311;; "----" ["MB" nil :help "Help MB"])) 334;; "----" ["MB" nil :help "Help MB"]))
312 335
336(defun verilog-define-abbrev (table name expansion &optional hook)
337 "Filter `define-abbrev' TABLE NAME EXPANSION and call HOOK.
338Provides SYSTEM-FLAG in newer Emacs."
339 (condition-case nil
340 (define-abbrev table name expansion hook 0 t)
341 (error
342 (define-abbrev table name expansion hook))))
343
313(defun verilog-customize () 344(defun verilog-customize ()
314 "Customize variables and other settings used by Verilog-Mode." 345 "Customize variables and other settings used by Verilog-Mode."
315 (interactive) 346 (interactive)
@@ -335,9 +366,31 @@ This function may be removed when Emacs 21 is no longer supported."
335 ;; And GNU Emacs 22 has obsoleted last-command-char 366 ;; And GNU Emacs 22 has obsoleted last-command-char
336 last-command-event))) 367 last-command-event)))
337 368
338(defalias 'verilog-syntax-ppss 369(defvar verilog-no-change-functions nil
339 (if (fboundp 'syntax-ppss) 'syntax-ppss 370 "True if `after-change-functions' is disabled.
340 (lambda (&optional pos) (parse-partial-sexp (point-min) (or pos (point)))))) 371Use of `syntax-ppss' may break, as ppss's cache may get corrupted.")
372
373(defvar verilog-in-hooks nil
374 "True when within a `verilog-run-hooks' block.")
375
376(defmacro verilog-run-hooks (&rest hooks)
377 "Run each hook in HOOKS using `run-hooks'.
378Set `verilog-in-hooks' during this time, to assist AUTO caches."
379 `(let ((verilog-in-hooks t))
380 (run-hooks ,@hooks)))
381
382(defun verilog-syntax-ppss (&optional pos)
383 (when verilog-no-change-functions
384 (if verilog-in-hooks
385 (verilog-scan-cache-flush)
386 ;; else don't let the AUTO code itself get away with flushing the cache,
387 ;; as that'll make things very slow
388 (backtrace)
389 (error "%s: Internal problem; use of syntax-ppss when cache may be corrupt"
390 (verilog-point-text))))
391 (if (fboundp 'syntax-ppss)
392 (syntax-ppss pos)
393 (parse-partial-sexp (point-min) (or pos (point)))))
341 394
342(defgroup verilog-mode nil 395(defgroup verilog-mode nil
343 "Facilitates easy editing of Verilog source text." 396 "Facilitates easy editing of Verilog source text."
@@ -631,6 +684,22 @@ file referenced. If false, this is not supported."
631 :type 'boolean) 684 :type 'boolean)
632(put 'verilog-highlight-includes 'safe-local-variable 'verilog-booleanp) 685(put 'verilog-highlight-includes 'safe-local-variable 'verilog-booleanp)
633 686
687(defcustom verilog-auto-declare-nettype nil
688 "*Non-nil specifies the data type to use with `verilog-auto-input' etc.
689Set this to \"wire\" if the Verilog code uses \"`default_nettype
690none\". Note using `default_nettype none isn't recommended practice; this
691mode is experimental."
692 :group 'verilog-mode-actions
693 :type 'boolean)
694(put 'verilog-auto-declare-nettype 'safe-local-variable `stringp)
695
696(defcustom verilog-auto-wire-type nil
697 "*Non-nil specifies the data type to use with `verilog-auto-wire' etc.
698Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'."
699 :group 'verilog-mode-actions
700 :type 'boolean)
701(put 'verilog-auto-wire-type 'safe-local-variable `stringp)
702
634(defcustom verilog-auto-endcomments t 703(defcustom verilog-auto-endcomments t
635 "*True means insert a comment /* ... */ after 'end's. 704 "*True means insert a comment /* ... */ after 'end's.
636The name of the function or case will be set between the braces." 705The name of the function or case will be set between the braces."
@@ -638,6 +707,12 @@ The name of the function or case will be set between the braces."
638 :type 'boolean) 707 :type 'boolean)
639(put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) 708(put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp)
640 709
710(defcustom verilog-auto-delete-trailing-whitespace nil
711 "*True means to `delete-trailing-whitespace' in `verilog-auto'."
712 :group 'verilog-mode-actions
713 :type 'boolean)
714(put 'verilog-auto-delete-trailing-whitespace 'safe-local-variable 'verilog-booleanp)
715
641(defcustom verilog-auto-ignore-concat nil 716(defcustom verilog-auto-ignore-concat nil
642 "*True means ignore signals in {...} concatenations for AUTOWIRE etc. 717 "*True means ignore signals in {...} concatenations for AUTOWIRE etc.
643This will exclude signals referenced as pin connections in {...} 718This will exclude signals referenced as pin connections in {...}
@@ -696,6 +771,12 @@ always be saved."
696(defvar verilog-auto-last-file-locals nil 771(defvar verilog-auto-last-file-locals nil
697 "Text from file-local-variables during last evaluation.") 772 "Text from file-local-variables during last evaluation.")
698 773
774(defvar verilog-diff-function 'verilog-diff-report
775 "*Function to run when `verilog-diff-auto' detects differences.
776Function takes three arguments, the original buffer, the
777difference buffer, and the point in original buffer with the
778first difference.")
779
699;;; Compile support 780;;; Compile support
700(require 'compile) 781(require 'compile)
701(defvar verilog-error-regexp-added nil) 782(defvar verilog-error-regexp-added nil)
@@ -896,6 +977,19 @@ of each Verilog file that requires it, rather than being set globally."
896 :type 'boolean) 977 :type 'boolean)
897(put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) 978(put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp)
898 979
980(defcustom verilog-auto-reset-blocking-in-non t
981 "*If true, AUTORESET will reset those signals which were
982assigned with blocking assignments (=) even in a block with
983non-blocking assignments (<=).
984
985If nil, all blocking assigned signals are ignored when any
986non-blocking assignment is in the AUTORESET block. This allows
987blocking assignments to be used for temporary values and not have
988those temporaries reset. See example in `verilog-auto-reset'."
989 :type 'boolean
990 :group 'verilog-mode-auto)
991(put 'verilog-auto-reset-blocking-in-non 'safe-local-variable 'verilog-booleanp)
992
899(defcustom verilog-auto-reset-widths t 993(defcustom verilog-auto-reset-widths t
900 "*If true, AUTORESET should determine the width of signals. 994 "*If true, AUTORESET should determine the width of signals.
901This is then used to set the width of the zero (32'h0 for example). This 995This is then used to set the width of the zero (32'h0 for example). This
@@ -917,7 +1011,9 @@ the MSB or LSB of a signal inside an AUTORESET."
917Declaration order is advantageous with order based instantiations 1011Declaration order is advantageous with order based instantiations
918and is the default for backward compatibility. Sorted order 1012and is the default for backward compatibility. Sorted order
919reduces changes when declarations are moved around in a file, and 1013reduces changes when declarations are moved around in a file, and
920it's bad practice to rely on order based instantiations anyhow." 1014it's bad practice to rely on order based instantiations anyhow.
1015
1016See also `verilog-auto-inst-sort'."
921 :group 'verilog-mode-auto 1017 :group 'verilog-mode-auto
922 :type 'boolean) 1018 :type 'boolean)
923(put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp) 1019(put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp)
@@ -969,6 +1065,18 @@ instead expand to:
969 :type 'boolean) 1065 :type 'boolean)
970(put 'verilog-auto-inst-param-value 'safe-local-variable 'verilog-booleanp) 1066(put 'verilog-auto-inst-param-value 'safe-local-variable 'verilog-booleanp)
971 1067
1068(defcustom verilog-auto-inst-sort nil
1069 "*If set, AUTOINST signal names will be sorted, not in declaration order.
1070Also affects AUTOINSTPARAM. Declaration order is the default for
1071backward compatibility, and as some teams prefer signals that are
1072declared together to remain together. Sorted order reduces
1073changes when declarations are moved around in a file.
1074
1075See also `verilog-auto-arg-sort'."
1076 :group 'verilog-mode-auto
1077 :type 'boolean)
1078(put 'verilog-auto-inst-sort 'safe-local-variable 'verilog-booleanp)
1079
972(defcustom verilog-auto-inst-vector t 1080(defcustom verilog-auto-inst-vector t
973 "*If true, when creating default ports with AUTOINST, use bus subscripts. 1081 "*If true, when creating default ports with AUTOINST, use bus subscripts.
974If nil, skip the subscript when it matches the entire bus as declared in 1082If nil, skip the subscript when it matches the entire bus as declared in
@@ -981,12 +1089,20 @@ speed up some simulators, but is less general and harder to read, so avoid."
981 1089
982(defcustom verilog-auto-inst-template-numbers nil 1090(defcustom verilog-auto-inst-template-numbers nil
983 "*If true, when creating templated ports with AUTOINST, add a comment. 1091 "*If true, when creating templated ports with AUTOINST, add a comment.
984The comment will add the line number of the template that was used for that 1092
985port declaration. Setting this aids in debugging, but nil is suggested for 1093If t, the comment will add the line number of the template that
986regular use to prevent large numbers of merge conflicts." 1094was used for that port declaration. This setting is suggested
1095only for debugging use, as regular use may cause a large numbers
1096of merge conflicts.
1097
1098If 'lhs', the comment will show the left hand side of the
1099AUTO_TEMPLATE rule that is matched. This is less precise than
1100numbering (t) when multiple rules have the same pin name, but
1101won't merge conflict."
987 :group 'verilog-mode-auto 1102 :group 'verilog-mode-auto
988 :type 'boolean) 1103 :type '(choice (const nil) (const t) (const lhs)))
989(put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) 1104(put 'verilog-auto-inst-template-numbers 'safe-local-variable
1105 '(lambda (x) (memq x '(nil t lhs))))
990 1106
991(defcustom verilog-auto-inst-column 40 1107(defcustom verilog-auto-inst-column 40
992 "*Indent-to column number for net name part of AUTOINST created pin." 1108 "*Indent-to column number for net name part of AUTOINST created pin."
@@ -1015,6 +1131,14 @@ See the \\[verilog-faq] for examples on using this."
1015 :type 'string) 1131 :type 'string)
1016(put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) 1132(put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp)
1017 1133
1134(defcustom verilog-auto-tieoff-declaration "wire"
1135 "*Data type used for the declaration for AUTOTIEOFF. If \"wire\" then
1136create a wire, if \"assign\" create an assignment, else the data type for
1137variable creation."
1138 :group 'verilog-mode-auto
1139 :type 'string)
1140(put 'verilog-auto-tieoff-declaration 'safe-local-variable 'stringp)
1141
1018(defcustom verilog-auto-tieoff-ignore-regexp nil 1142(defcustom verilog-auto-tieoff-ignore-regexp nil
1019 "*If set, when creating AUTOTIEOFF list, ignore signals matching this regexp. 1143 "*If set, when creating AUTOTIEOFF list, ignore signals matching this regexp.
1020See the \\[verilog-faq] for examples on using this." 1144See the \\[verilog-faq] for examples on using this."
@@ -1114,8 +1238,10 @@ If set will become buffer local.")
1114 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) 1238 (define-key map "\M-\r" `electric-verilog-terminate-and-indent)
1115 (define-key map "\M-\t" 'verilog-complete-word) 1239 (define-key map "\M-\t" 'verilog-complete-word)
1116 (define-key map "\M-?" 'verilog-show-completions) 1240 (define-key map "\M-?" 'verilog-show-completions)
1241 ;; Note \C-c and letter are reserved for users
1117 (define-key map "\C-c\`" 'verilog-lint-off) 1242 (define-key map "\C-c\`" 'verilog-lint-off)
1118 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) 1243 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit)
1244 (define-key map "\C-c\?" 'verilog-diff-auto)
1119 (define-key map "\C-c\C-r" 'verilog-label-be) 1245 (define-key map "\C-c\C-r" 'verilog-label-be)
1120 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) 1246 (define-key map "\C-c\C-i" 'verilog-pretty-declarations)
1121 (define-key map "\C-c=" 'verilog-pretty-expr) 1247 (define-key map "\C-c=" 'verilog-pretty-expr)
@@ -1241,6 +1367,8 @@ If set will become buffer local.")
1241 :help "Expand AUTO meta-comment statements"] 1367 :help "Expand AUTO meta-comment statements"]
1242 ["Kill AUTOs" verilog-delete-auto 1368 ["Kill AUTOs" verilog-delete-auto
1243 :help "Remove AUTO expansions"] 1369 :help "Remove AUTO expansions"]
1370 ["Diff AUTOs" verilog-diff-auto
1371 :help "Show differences in AUTO expansions"]
1244 ["Inject AUTOs" verilog-inject-auto 1372 ["Inject AUTOs" verilog-inject-auto
1245 :help "Inject AUTOs into legacy non-AUTO buffer"] 1373 :help "Inject AUTOs into legacy non-AUTO buffer"]
1246 ("AUTO Help..." 1374 ("AUTO Help..."
@@ -1264,6 +1392,8 @@ If set will become buffer local.")
1264 :help "Help on AUTOASCIIENUM - creating ASCII for enumerations"] 1392 :help "Help on AUTOASCIIENUM - creating ASCII for enumerations"]
1265 ["AUTOINOUTCOMP" (describe-function 'verilog-auto-inout-comp) 1393 ["AUTOINOUTCOMP" (describe-function 'verilog-auto-inout-comp)
1266 :help "Help on AUTOINOUTCOMP - copying complemented i/o from another file"] 1394 :help "Help on AUTOINOUTCOMP - copying complemented i/o from another file"]
1395 ["AUTOINOUTIN" (describe-function 'verilog-auto-inout-in)
1396 :help "Help on AUTOINOUTCOMP - copying i/o from another file as all inputs"]
1267 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) 1397 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module)
1268 :help "Help on AUTOINOUTMODULE - copying i/o from another file"] 1398 :help "Help on AUTOINOUTMODULE - copying i/o from another file"]
1269 ["AUTOINSERTLISP" (describe-function 'verilog-auto-insert-lisp) 1399 ["AUTOINSERTLISP" (describe-function 'verilog-auto-insert-lisp)
@@ -1278,6 +1408,8 @@ If set will become buffer local.")
1278 :help "Help on expanding Verilog-2001 .* pins"] 1408 :help "Help on expanding Verilog-2001 .* pins"]
1279 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) 1409 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param)
1280 :help "Help on AUTOINSTPARAM - adding parameter pins to cells"] 1410 :help "Help on AUTOINSTPARAM - adding parameter pins to cells"]
1411 ["AUTOLOGIC" (describe-function 'verilog-auto-logic)
1412 :help "Help on AUTOLOGIC - declaring logic signals"]
1281 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) 1413 ["AUTOOUTPUT" (describe-function 'verilog-auto-output)
1282 :help "Help on AUTOOUTPUT - adding outputs from cells"] 1414 :help "Help on AUTOOUTPUT - adding outputs from cells"]
1283 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) 1415 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every)
@@ -1318,6 +1450,10 @@ If set will become buffer local.")
1318 "----" 1450 "----"
1319 ["Module" verilog-sk-module 1451 ["Module" verilog-sk-module
1320 :help "Insert a module .. (/*AUTOARG*/);.. endmodule block"] 1452 :help "Insert a module .. (/*AUTOARG*/);.. endmodule block"]
1453 ["OVM Class" verilog-sk-ovm-class
1454 :help "Insert an OVM class block"]
1455 ["UVM Class" verilog-sk-uvm-class
1456 :help "Insert an UVM class block"]
1321 ["Primitive" verilog-sk-primitive 1457 ["Primitive" verilog-sk-primitive
1322 :help "Insert a primitive .. (.. );.. endprimitive block"] 1458 :help "Insert a primitive .. (.. );.. endprimitive block"]
1323 "----" 1459 "----"
@@ -1372,6 +1508,31 @@ If set will become buffer local.")
1372 "Abbrev table in use in Verilog-mode buffers.") 1508 "Abbrev table in use in Verilog-mode buffers.")
1373 1509
1374(define-abbrev-table 'verilog-mode-abbrev-table ()) 1510(define-abbrev-table 'verilog-mode-abbrev-table ())
1511(verilog-define-abbrev verilog-mode-abbrev-table "class" "" 'verilog-sk-ovm-class)
1512(verilog-define-abbrev verilog-mode-abbrev-table "always" "" 'verilog-sk-always)
1513(verilog-define-abbrev verilog-mode-abbrev-table "begin" nil `verilog-sk-begin)
1514(verilog-define-abbrev verilog-mode-abbrev-table "case" "" `verilog-sk-case)
1515(verilog-define-abbrev verilog-mode-abbrev-table "for" "" `verilog-sk-for)
1516(verilog-define-abbrev verilog-mode-abbrev-table "generate" "" `verilog-sk-generate)
1517(verilog-define-abbrev verilog-mode-abbrev-table "initial" "" `verilog-sk-initial)
1518(verilog-define-abbrev verilog-mode-abbrev-table "fork" "" `verilog-sk-fork)
1519(verilog-define-abbrev verilog-mode-abbrev-table "module" "" `verilog-sk-module)
1520(verilog-define-abbrev verilog-mode-abbrev-table "primitive" "" `verilog-sk-primitive)
1521(verilog-define-abbrev verilog-mode-abbrev-table "repeat" "" `verilog-sk-repeat)
1522(verilog-define-abbrev verilog-mode-abbrev-table "specify" "" `verilog-sk-specify)
1523(verilog-define-abbrev verilog-mode-abbrev-table "task" "" `verilog-sk-task)
1524(verilog-define-abbrev verilog-mode-abbrev-table "while" "" `verilog-sk-while)
1525(verilog-define-abbrev verilog-mode-abbrev-table "casex" "" `verilog-sk-casex)
1526(verilog-define-abbrev verilog-mode-abbrev-table "casez" "" `verilog-sk-casez)
1527(verilog-define-abbrev verilog-mode-abbrev-table "if" "" `verilog-sk-if)
1528(verilog-define-abbrev verilog-mode-abbrev-table "else if" "" `verilog-sk-else-if)
1529(verilog-define-abbrev verilog-mode-abbrev-table "assign" "" `verilog-sk-assign)
1530(verilog-define-abbrev verilog-mode-abbrev-table "function" "" `verilog-sk-function)
1531(verilog-define-abbrev verilog-mode-abbrev-table "input" "" `verilog-sk-input)
1532(verilog-define-abbrev verilog-mode-abbrev-table "output" "" `verilog-sk-output)
1533(verilog-define-abbrev verilog-mode-abbrev-table "inout" "" `verilog-sk-inout)
1534(verilog-define-abbrev verilog-mode-abbrev-table "wire" "" `verilog-sk-wire)
1535(verilog-define-abbrev verilog-mode-abbrev-table "reg" "" `verilog-sk-reg)
1375 1536
1376;; 1537;;
1377;; Macros 1538;; Macros
@@ -1386,6 +1547,9 @@ FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace.
1386The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\") 1547The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\")
1387will break, as the o's continuously replace. xa -> x works ok though." 1548will break, as the o's continuously replace. xa -> x works ok though."
1388 ;; Hopefully soon to a emacs built-in 1549 ;; Hopefully soon to a emacs built-in
1550 ;; Also note \ in the replacement prevent multiple replacements; IE
1551 ;; (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil "wire@_@")
1552 ;; Gives "wire\([0-9]+\)_@" not "wire\([0-9]+\)_\([0-9]+\)"
1389 (let ((start 0)) 1553 (let ((start 0))
1390 (while (string-match from-string string start) 1554 (while (string-match from-string string start)
1391 (setq string (replace-match to-string fixedcase literal string) 1555 (setq string (replace-match to-string fixedcase literal string)
@@ -1434,26 +1598,28 @@ will break, as the o's continuously replace. xa -> x works ok though."
1434(defsubst verilog-re-search-forward-quick (regexp bound noerror) 1598(defsubst verilog-re-search-forward-quick (regexp bound noerror)
1435 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, 1599 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR,
1436but trashes match data and is faster for REGEXP that doesn't match often. 1600but trashes match data and is faster for REGEXP that doesn't match often.
1437This may at some point use text properties to ignore comments, 1601This uses `verilog-scan' and text properties to ignore comments,
1438so there may be a large up front penalty for the first search." 1602so there may be a large up front penalty for the first search."
1439 (let (pt) 1603 (let (pt)
1440 (while (and (not pt) 1604 (while (and (not pt)
1441 (re-search-forward regexp bound noerror)) 1605 (re-search-forward regexp bound noerror))
1442 (if (not (verilog-inside-comment-p)) 1606 (if (verilog-inside-comment-or-string-p)
1443 (setq pt (match-end 0)))) 1607 (re-search-forward "[/\"\n]" nil t) ;; Only way a comment or quote can end
1608 (setq pt (match-end 0))))
1444 pt)) 1609 pt))
1445 1610
1446(defsubst verilog-re-search-backward-quick (regexp bound noerror) 1611(defsubst verilog-re-search-backward-quick (regexp bound noerror)
1447 ; checkdoc-params: (REGEXP BOUND NOERROR) 1612 ; checkdoc-params: (REGEXP BOUND NOERROR)
1448 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR, 1613 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR,
1449but trashes match data and is faster for REGEXP that doesn't match often. 1614but trashes match data and is faster for REGEXP that doesn't match often.
1450This may at some point use text properties to ignore comments, 1615This uses `verilog-scan' and text properties to ignore comments,
1451so there may be a large up front penalty for the first search." 1616so there may be a large up front penalty for the first search."
1452 (let (pt) 1617 (let (pt)
1453 (while (and (not pt) 1618 (while (and (not pt)
1454 (re-search-backward regexp bound noerror)) 1619 (re-search-backward regexp bound noerror))
1455 (if (not (verilog-inside-comment-p)) 1620 (if (verilog-inside-comment-or-string-p)
1456 (setq pt (match-end 0)))) 1621 (re-search-backward "[/\"]" nil t) ;; Only way a comment or quote can begin
1622 (setq pt (match-beginning 0))))
1457 pt)) 1623 pt))
1458 1624
1459(defsubst verilog-re-search-forward-substr (substr regexp bound noerror) 1625(defsubst verilog-re-search-forward-substr (substr regexp bound noerror)
@@ -1496,6 +1662,14 @@ This speeds up complicated regexp matches."
1496 done)) 1662 done))
1497;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ;;-end (test bait) 1663;;(verilog-re-search-backward-substr "-end" "get-end-of" nil t) ;;-end (test bait)
1498 1664
1665(defun verilog-delete-trailing-whitespace ()
1666 "Delete trailing spaces or tabs, but not newlines nor linefeeds."
1667 ;; Similar to `delete-trailing-whitespace' but that's not present in XEmacs
1668 (save-excursion
1669 (goto-char (point-min))
1670 (while (re-search-forward "[ \t]+$" nil t) ;; Not syntatic WS as no formfeed
1671 (replace-match "" nil nil))))
1672
1499(defvar compile-command) 1673(defvar compile-command)
1500 1674
1501;; compilation program 1675;; compilation program
@@ -1535,11 +1709,11 @@ portion, will be substituted."
1535 (set (make-local-variable 'compile-command) "make ")) 1709 (set (make-local-variable 'compile-command) "make "))
1536 (t 1710 (t
1537 (set (make-local-variable 'compile-command) 1711 (set (make-local-variable 'compile-command)
1538 (if verilog-tool 1712 (if verilog-tool
1539 (if (string-match "%s" (eval verilog-tool)) 1713 (if (string-match "%s" (eval verilog-tool))
1540 (format (eval verilog-tool) (or buffer-file-name "")) 1714 (format (eval verilog-tool) (or buffer-file-name ""))
1541 (concat (eval verilog-tool) " " (or buffer-file-name ""))) 1715 (concat (eval verilog-tool) " " (or buffer-file-name "")))
1542 "")))) 1716 ""))))
1543 (verilog-modify-compile-command)) 1717 (verilog-modify-compile-command))
1544 1718
1545(defun verilog-expand-command (command) 1719(defun verilog-expand-command (command)
@@ -1564,7 +1738,7 @@ be substituted."
1564 (stringp compile-command) 1738 (stringp compile-command)
1565 (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command)) 1739 (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command))
1566 (set (make-local-variable 'compile-command) 1740 (set (make-local-variable 'compile-command)
1567 (verilog-expand-command compile-command)))) 1741 (verilog-expand-command compile-command))))
1568 1742
1569(if (featurep 'xemacs) 1743(if (featurep 'xemacs)
1570 ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling. 1744 ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling.
@@ -1585,8 +1759,8 @@ find the errors."
1585 (cdr compilation-error-regexp-alist-alist))))) 1759 (cdr compilation-error-regexp-alist-alist)))))
1586 (if (boundp 'compilation-font-lock-keywords) 1760 (if (boundp 'compilation-font-lock-keywords)
1587 (progn 1761 (progn
1588 (set (make-local-variable 'compilation-font-lock-keywords) 1762 (set (make-local-variable 'compilation-font-lock-keywords)
1589 verilog-error-font-lock-keywords) 1763 verilog-error-font-lock-keywords)
1590 (font-lock-set-defaults))) 1764 (font-lock-set-defaults)))
1591 ;; Need to re-run compilation-error-regexp builder 1765 ;; Need to re-run compilation-error-regexp builder
1592 (if (fboundp 'compilation-build-compilation-error-regexp-alist) 1766 (if (fboundp 'compilation-build-compilation-error-regexp-alist)
@@ -1657,6 +1831,30 @@ find the errors."
1657 "`ovm_sequencer_utils_end" 1831 "`ovm_sequencer_utils_end"
1658 ) nil ))) 1832 ) nil )))
1659 1833
1834(defconst verilog-uvm-begin-re
1835 (eval-when-compile
1836 (verilog-regexp-opt
1837 '(
1838 "`uvm_component_utils_begin"
1839 "`uvm_component_param_utils_begin"
1840 "`uvm_field_utils_begin"
1841 "`uvm_object_utils_begin"
1842 "`uvm_object_param_utils_begin"
1843 "`uvm_sequence_utils_begin"
1844 "`uvm_sequencer_utils_begin"
1845 ) nil )))
1846
1847(defconst verilog-uvm-end-re
1848 (eval-when-compile
1849 (verilog-regexp-opt
1850 '(
1851 "`uvm_component_utils_end"
1852 "`uvm_field_utils_end"
1853 "`uvm_object_utils_end"
1854 "`uvm_sequence_utils_end"
1855 "`uvm_sequencer_utils_end"
1856 ) nil )))
1857
1660(defconst verilog-vmm-begin-re 1858(defconst verilog-vmm-begin-re
1661 (eval-when-compile 1859 (eval-when-compile
1662 (verilog-regexp-opt 1860 (verilog-regexp-opt
@@ -1794,6 +1992,145 @@ find the errors."
1794 "`static_dut_error" 1992 "`static_dut_error"
1795 "`static_message") nil ))) 1993 "`static_message") nil )))
1796 1994
1995(defconst verilog-uvm-statement-re
1996 (eval-when-compile
1997 (verilog-regexp-opt
1998 '(
1999 ;; Statements
2000 "`uvm_analysis_imp_decl"
2001 "`uvm_blocking_get_imp_decl"
2002 "`uvm_blocking_get_peek_imp_decl"
2003 "`uvm_blocking_master_imp_decl"
2004 "`uvm_blocking_peek_imp_decl"
2005 "`uvm_blocking_put_imp_decl"
2006 "`uvm_blocking_slave_imp_decl"
2007 "`uvm_blocking_transport_imp_decl"
2008 "`uvm_component_param_utils"
2009 "`uvm_component_registry"
2010 "`uvm_component_registry_param"
2011 "`uvm_component_utils"
2012 "`uvm_create"
2013 "`uvm_create_on"
2014 "`uvm_create_seq" ;; Undocumented in 1.1
2015 "`uvm_declare_p_sequencer"
2016 "`uvm_declare_sequence_lib" ;; Deprecated in 1.1
2017 "`uvm_do"
2018 "`uvm_do_callbacks"
2019 "`uvm_do_callbacks_exit_on"
2020 "`uvm_do_obj_callbacks"
2021 "`uvm_do_obj_callbacks_exit_on"
2022 "`uvm_do_on"
2023 "`uvm_do_on_pri"
2024 "`uvm_do_on_pri_with"
2025 "`uvm_do_on_with"
2026 "`uvm_do_pri"
2027 "`uvm_do_pri_with"
2028 "`uvm_do_seq" ;; Undocumented in 1.1
2029 "`uvm_do_seq_with" ;; Undocumented in 1.1
2030 "`uvm_do_with"
2031 "`uvm_error"
2032 "`uvm_error_context"
2033 "`uvm_fatal"
2034 "`uvm_fatal_context"
2035 "`uvm_field_aa_int_byte"
2036 "`uvm_field_aa_int_byte_unsigned"
2037 "`uvm_field_aa_int_enum"
2038 "`uvm_field_aa_int_int"
2039 "`uvm_field_aa_int_int_unsigned"
2040 "`uvm_field_aa_int_integer"
2041 "`uvm_field_aa_int_integer_unsigned"
2042 "`uvm_field_aa_int_key"
2043 "`uvm_field_aa_int_longint"
2044 "`uvm_field_aa_int_longint_unsigned"
2045 "`uvm_field_aa_int_shortint"
2046 "`uvm_field_aa_int_shortint_unsigned"
2047 "`uvm_field_aa_int_string"
2048 "`uvm_field_aa_object_int"
2049 "`uvm_field_aa_object_string"
2050 "`uvm_field_aa_string_int"
2051 "`uvm_field_aa_string_string"
2052 "`uvm_field_array_enum"
2053 "`uvm_field_array_int"
2054 "`uvm_field_array_object"
2055 "`uvm_field_array_string"
2056 "`uvm_field_enum"
2057 "`uvm_field_event"
2058 "`uvm_field_int"
2059 "`uvm_field_object"
2060 "`uvm_field_queue_enum"
2061 "`uvm_field_queue_int"
2062 "`uvm_field_queue_object"
2063 "`uvm_field_queue_string"
2064 "`uvm_field_real"
2065 "`uvm_field_sarray_enum"
2066 "`uvm_field_sarray_int"
2067 "`uvm_field_sarray_object"
2068 "`uvm_field_sarray_string"
2069 "`uvm_field_string"
2070 "`uvm_field_utils"
2071 "`uvm_file" ;; Undocumented in 1.1, use `__FILE__
2072 "`uvm_get_imp_decl"
2073 "`uvm_get_peek_imp_decl"
2074 "`uvm_info"
2075 "`uvm_info_context"
2076 "`uvm_line" ;; Undocumented in 1.1, use `__LINE__
2077 "`uvm_master_imp_decl"
2078 "`uvm_non_blocking_transport_imp_decl" ;; Deprecated in 1.1
2079 "`uvm_nonblocking_get_imp_decl"
2080 "`uvm_nonblocking_get_peek_imp_decl"
2081 "`uvm_nonblocking_master_imp_decl"
2082 "`uvm_nonblocking_peek_imp_decl"
2083 "`uvm_nonblocking_put_imp_decl"
2084 "`uvm_nonblocking_slave_imp_decl"
2085 "`uvm_nonblocking_transport_imp_decl"
2086 "`uvm_object_param_utils"
2087 "`uvm_object_registry"
2088 "`uvm_object_registry_param" ;; Undocumented in 1.1
2089 "`uvm_object_utils"
2090 "`uvm_pack_array"
2091 "`uvm_pack_arrayN"
2092 "`uvm_pack_enum"
2093 "`uvm_pack_enumN"
2094 "`uvm_pack_int"
2095 "`uvm_pack_intN"
2096 "`uvm_pack_queue"
2097 "`uvm_pack_queueN"
2098 "`uvm_pack_real"
2099 "`uvm_pack_sarray"
2100 "`uvm_pack_sarrayN"
2101 "`uvm_pack_string"
2102 "`uvm_peek_imp_decl"
2103 "`uvm_put_imp_decl"
2104 "`uvm_rand_send"
2105 "`uvm_rand_send_pri"
2106 "`uvm_rand_send_pri_with"
2107 "`uvm_rand_send_with"
2108 "`uvm_record_attribute"
2109 "`uvm_record_field"
2110 "`uvm_register_cb"
2111 "`uvm_send"
2112 "`uvm_send_pri"
2113 "`uvm_sequence_utils" ;; Deprecated in 1.1
2114 "`uvm_set_super_type"
2115 "`uvm_slave_imp_decl"
2116 "`uvm_transport_imp_decl"
2117 "`uvm_unpack_array"
2118 "`uvm_unpack_arrayN"
2119 "`uvm_unpack_enum"
2120 "`uvm_unpack_enumN"
2121 "`uvm_unpack_int"
2122 "`uvm_unpack_intN"
2123 "`uvm_unpack_queue"
2124 "`uvm_unpack_queueN"
2125 "`uvm_unpack_real"
2126 "`uvm_unpack_sarray"
2127 "`uvm_unpack_sarrayN"
2128 "`uvm_unpack_string"
2129 "`uvm_update_sequence_lib" ;; Deprecated in 1.1
2130 "`uvm_update_sequence_lib_and_item" ;; Deprecated in 1.1
2131 "`uvm_warning"
2132 "`uvm_warning_context") nil )))
2133
1797 2134
1798;; 2135;;
1799;; Regular expressions used to calculate indent, etc. 2136;; Regular expressions used to calculate indent, etc.
@@ -1805,6 +2142,29 @@ find the errors."
1805;; a[34:32] : 2142;; a[34:32] :
1806;; a, 2143;; a,
1807;; b : 2144;; b :
2145(defconst verilog-assignment-operator-re
2146 (eval-when-compile
2147 (verilog-regexp-opt
2148 `(
2149 ;; blocking assignment_operator
2150 "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>="
2151 ;; non blocking assignment operator
2152 "<="
2153 ;; comparison
2154 "==" "!=" "===" "!===" "<=" ">=" "==\?" "!=\?"
2155 ;; event_trigger
2156 "->" "->>"
2157 ;; property_expr
2158 "|->" "|=>"
2159 ;; Is this a legal verilog operator?
2160 ":="
2161 ) 't
2162 )))
2163(defconst verilog-assignment-operation-re
2164 (concat
2165; "\\(^\\s-*[A-Za-z0-9_]+\\(\\[\\([A-Za-z0-9_]+\\)\\]\\)*\\s-*\\)"
2166; "\\(^\\s-*[^=<>+-*/%&|^:\\s-]+[^=<>+-*/%&|^\n]*?\\)"
2167 "\\(^.*?\\)" "\\B" verilog-assignment-operator-re "\\B" ))
1808 2168
1809(defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*")) 2169(defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*"))
1810(defconst verilog-property-re 2170(defconst verilog-property-re
@@ -1843,7 +2203,12 @@ find the errors."
1843 "\\(\\<`ovm_object_utils_end\\>\\)\\|" 2203 "\\(\\<`ovm_object_utils_end\\>\\)\\|"
1844 "\\(\\<`ovm_sequence_utils_end\\>\\)\\|" 2204 "\\(\\<`ovm_sequence_utils_end\\>\\)\\|"
1845 "\\(\\<`ovm_sequencer_utils_end\\>\\)" 2205 "\\(\\<`ovm_sequencer_utils_end\\>\\)"
1846 2206 ;; UVM
2207 "\\(\\<`uvm_component_utils_end\\>\\)\\|"
2208 "\\(\\<`uvm_field_utils_end\\>\\)\\|"
2209 "\\(\\<`uvm_object_utils_end\\>\\)\\|"
2210 "\\(\\<`uvm_sequence_utils_end\\>\\)\\|"
2211 "\\(\\<`uvm_sequencer_utils_end\\>\\)"
1847 )) 2212 ))
1848 2213
1849(defconst verilog-auto-end-comment-lines-re 2214(defconst verilog-auto-end-comment-lines-re
@@ -1925,6 +2290,12 @@ find the errors."
1925 "`ovm_object_utils_end" 2290 "`ovm_object_utils_end"
1926 "`ovm_sequence_utils_end" 2291 "`ovm_sequence_utils_end"
1927 "`ovm_sequencer_utils_end" 2292 "`ovm_sequencer_utils_end"
2293 ;; UVM
2294 "`uvm_component_utils_end"
2295 "`uvm_field_utils_end"
2296 "`uvm_object_utils_end"
2297 "`uvm_sequence_utils_end"
2298 "`uvm_sequencer_utils_end"
1928 ;; VMM 2299 ;; VMM
1929 "`vmm_data_member_end" 2300 "`vmm_data_member_end"
1930 "`vmm_env_member_end" 2301 "`vmm_env_member_end"
@@ -1979,7 +2350,7 @@ find the errors."
1979 "specify" 2350 "specify"
1980 "table" 2351 "table"
1981 "task" 2352 "task"
1982 ;;; OVM 2353 ;; OVM
1983 "`ovm_component_utils_begin" 2354 "`ovm_component_utils_begin"
1984 "`ovm_component_param_utils_begin" 2355 "`ovm_component_param_utils_begin"
1985 "`ovm_field_utils_begin" 2356 "`ovm_field_utils_begin"
@@ -1987,6 +2358,14 @@ find the errors."
1987 "`ovm_object_param_utils_begin" 2358 "`ovm_object_param_utils_begin"
1988 "`ovm_sequence_utils_begin" 2359 "`ovm_sequence_utils_begin"
1989 "`ovm_sequencer_utils_begin" 2360 "`ovm_sequencer_utils_begin"
2361 ;; UVM
2362 "`uvm_component_utils_begin"
2363 "`uvm_component_param_utils_begin"
2364 "`uvm_field_utils_begin"
2365 "`uvm_object_utils_begin"
2366 "`uvm_object_param_utils_begin"
2367 "`uvm_sequence_utils_begin"
2368 "`uvm_sequencer_utils_begin"
1990 ;; VMM 2369 ;; VMM
1991 "`vmm_data_member_begin" 2370 "`vmm_data_member_begin"
1992 "`vmm_env_member_begin" 2371 "`vmm_env_member_begin"
@@ -2000,7 +2379,7 @@ find the errors."
2000(defconst verilog-beg-block-re-ordered 2379(defconst verilog-beg-block-re-ordered
2001 ( concat "\\(\\<begin\\>\\)" ;1 2380 ( concat "\\(\\<begin\\>\\)" ;1
2002 "\\|\\(\\<randcase\\>\\|\\(\\<unique\\s-+\\|priority\\s-+\\)?case[xz]?\\>\\)" ; 2,3 2381 "\\|\\(\\<randcase\\>\\|\\(\\<unique\\s-+\\|priority\\s-+\\)?case[xz]?\\>\\)" ; 2,3
2003 "\\|\\(\\(\\<disable\\>\\s-+\\)?fork\\>\\)" ;4,5 2382 "\\|\\(\\(\\<disable\\>\\s-+\\|\\<wait\\>\\s-+\\)?fork\\>\\)" ;4,5
2004 "\\|\\(\\<class\\>\\)" ;6 2383 "\\|\\(\\<class\\>\\)" ;6
2005 "\\|\\(\\<table\\>\\)" ;7 2384 "\\|\\(\\<table\\>\\)" ;7
2006 "\\|\\(\\<specify\\>\\)" ;8 2385 "\\|\\(\\<specify\\>\\)" ;8
@@ -2013,7 +2392,7 @@ find the errors."
2013 "\\|\\(\\(\\(\\<cover\\>\\s-+\\)\\|\\(\\<assert\\>\\s-+\\)\\)*\\<property\\>\\)" ;17 21 2392 "\\|\\(\\(\\(\\<cover\\>\\s-+\\)\\|\\(\\<assert\\>\\s-+\\)\\)*\\<property\\>\\)" ;17 21
2014 "\\|\\(\\<\\(rand\\)?sequence\\>\\)" ;21 25 2393 "\\|\\(\\<\\(rand\\)?sequence\\>\\)" ;21 25
2015 "\\|\\(\\<clocking\\>\\)" ;22 27 2394 "\\|\\(\\<clocking\\>\\)" ;22 27
2016 "\\|\\(\\<`ovm_[a-z_]+_begin\\>\\)" ;28 2395 "\\|\\(\\<`[ou]vm_[a-z_]+_begin\\>\\)" ;28
2017 "\\|\\(\\<`vmm_[a-z_]+_member_begin\\>\\)" 2396 "\\|\\(\\<`vmm_[a-z_]+_member_begin\\>\\)"
2018 ;; 2397 ;;
2019 2398
@@ -2125,6 +2504,8 @@ find the errors."
2125 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig")))) 2504 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig"))))
2126(defconst verilog-zero-indent-re 2505(defconst verilog-zero-indent-re
2127 (concat verilog-defun-re "\\|" verilog-end-defun-re)) 2506 (concat verilog-defun-re "\\|" verilog-end-defun-re))
2507(defconst verilog-inst-comment-re
2508 (eval-when-compile (verilog-regexp-words `("Outputs" "Inouts" "Inputs" "Interfaces" "Interfaced"))))
2128 2509
2129(defconst verilog-behavioral-block-beg-re 2510(defconst verilog-behavioral-block-beg-re
2130 (eval-when-compile (verilog-regexp-words `("initial" "final" "always" "always_comb" "always_latch" "always_ff" 2511 (eval-when-compile (verilog-regexp-words `("initial" "final" "always" "always_comb" "always_latch" "always_ff"
@@ -2186,6 +2567,20 @@ find the errors."
2186 "`ovm_object_utils_end" 2567 "`ovm_object_utils_end"
2187 "`ovm_sequence_utils_end" 2568 "`ovm_sequence_utils_end"
2188 "`ovm_sequencer_utils_end" 2569 "`ovm_sequencer_utils_end"
2570 ;; UVM Begin tokens
2571 "`uvm_component_utils_begin"
2572 "`uvm_component_param_utils_begin"
2573 "`uvm_field_utils_begin"
2574 "`uvm_object_utils_begin"
2575 "`uvm_object_param_utils_begin"
2576 "`uvm_sequence_utils_begin"
2577 "`uvm_sequencer_utils_begin"
2578 ;; UVM End tokens
2579 "`uvm_component_utils_end" ;; Typo in spec, it's not uvm_component_end
2580 "`uvm_field_utils_end"
2581 "`uvm_object_utils_end"
2582 "`uvm_sequence_utils_end"
2583 "`uvm_sequencer_utils_end"
2189 ;; VMM Begin tokens 2584 ;; VMM Begin tokens
2190 "`vmm_data_member_begin" 2585 "`vmm_data_member_begin"
2191 "`vmm_env_member_begin" 2586 "`vmm_env_member_begin"
@@ -2227,8 +2622,7 @@ find the errors."
2227 `( 2622 `(
2228 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" 2623 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass"
2229 )))) 2624 ))))
2230(defconst verilog-disable-fork-re "disable\\s-+fork\\>") 2625(defconst verilog-disable-fork-re "\\(disable\\|wait\\)\\s-+fork\\>")
2231(defconst verilog-fork-wait-re "fork\\s-+wait\\>")
2232(defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") 2626(defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?")
2233(defconst verilog-extended-complete-re 2627(defconst verilog-extended-complete-re
2234 (concat "\\(\\<extern\\s-+\\|\\<\\(\\<pure\\>\\s-+\\)?virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" 2628 (concat "\\(\\<extern\\s-+\\|\\<\\(\\<pure\\>\\s-+\\)?virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
@@ -2609,6 +3003,7 @@ user-visible changes to the buffer must not be within a
2609 (buffer-undo-list t) 3003 (buffer-undo-list t)
2610 (inhibit-read-only t) 3004 (inhibit-read-only t)
2611 (inhibit-point-motion-hooks t) 3005 (inhibit-point-motion-hooks t)
3006 (verilog-no-change-functions t)
2612 before-change-functions 3007 before-change-functions
2613 after-change-functions 3008 after-change-functions
2614 deactivate-mark 3009 deactivate-mark
@@ -2624,6 +3019,7 @@ user-visible changes to the buffer must not be within a
2624 "Execute BODY forms, disabling all change hooks in BODY. 3019 "Execute BODY forms, disabling all change hooks in BODY.
2625For insignificant changes, see instead `verilog-save-buffer-state'." 3020For insignificant changes, see instead `verilog-save-buffer-state'."
2626 `(let* ((inhibit-point-motion-hooks t) 3021 `(let* ((inhibit-point-motion-hooks t)
3022 (verilog-no-change-functions t)
2627 before-change-functions 3023 before-change-functions
2628 after-change-functions) 3024 after-change-functions)
2629 (progn ,@body))) 3025 (progn ,@body)))
@@ -2633,13 +3029,17 @@ For insignificant changes, see instead `verilog-save-buffer-state'."
2633 3029
2634(defvar verilog-scan-cache-preserving nil 3030(defvar verilog-scan-cache-preserving nil
2635 "If set, the specified buffer's comment properties are static. 3031 "If set, the specified buffer's comment properties are static.
2636Buffer changes will be ignored. See `verilog-inside-comment-p' 3032Buffer changes will be ignored. See `verilog-inside-comment-or-string-p'
2637and `verilog-scan'.") 3033and `verilog-scan'.")
2638 3034
2639(defvar verilog-scan-cache-tick nil 3035(defvar verilog-scan-cache-tick nil
2640 "Modification tick at which `verilog-scan' was last completed.") 3036 "Modification tick at which `verilog-scan' was last completed.")
2641(make-variable-buffer-local 'verilog-scan-cache-tick) 3037(make-variable-buffer-local 'verilog-scan-cache-tick)
2642 3038
3039(defun verilog-scan-cache-flush ()
3040 "Flush the `verilog-scan' cache."
3041 (setq verilog-scan-cache-tick nil))
3042
2643(defun verilog-scan-cache-ok-p () 3043(defun verilog-scan-cache-ok-p ()
2644 "Return t iff the scan cache is up to date." 3044 "Return t iff the scan cache is up to date."
2645 (or (and verilog-scan-cache-preserving 3045 (or (and verilog-scan-cache-preserving
@@ -2660,8 +3060,8 @@ This requires that insertions must use `verilog-insert'."
2660 (progn ,@body)))) 3060 (progn ,@body))))
2661 3061
2662(defun verilog-scan-region (beg end) 3062(defun verilog-scan-region (beg end)
2663 "Parse comments between BEG and END for `verilog-inside-comment-p'. 3063 "Parse between BEG and END for `verilog-inside-comment-or-string-p'.
2664This creates v-cmt properties where comments are in force." 3064This creates v-cmts properties where comments are in force."
2665 ;; Why properties and not overlays? Overlays have much slower non O(1) 3065 ;; Why properties and not overlays? Overlays have much slower non O(1)
2666 ;; lookup times. 3066 ;; lookup times.
2667 ;; This function is warm - called on every verilog-insert 3067 ;; This function is warm - called on every verilog-insert
@@ -2678,8 +3078,9 @@ This creates v-cmt properties where comments are in force."
2678 ;; "1+": The leading // or /* itself isn't considered as 3078 ;; "1+": The leading // or /* itself isn't considered as
2679 ;; being "inside" the comment, so that a (search-backward) 3079 ;; being "inside" the comment, so that a (search-backward)
2680 ;; that lands at the start of the // won't mis-indicate 3080 ;; that lands at the start of the // won't mis-indicate
2681 ;; it's inside a comment 3081 ;; it's inside a comment. Also otherwise it would be
2682 (put-text-property (1+ pt) (point) 'v-cmt t)) 3082 ;; hard to find a commented out /*AS*/ vs one that isn't
3083 (put-text-property (1+ pt) (point) 'v-cmts t))
2683 ((looking-at "/\\*") 3084 ((looking-at "/\\*")
2684 (setq pt (point)) 3085 (setq pt (point))
2685 (or (search-forward "*/" end t) 3086 (or (search-forward "*/" end t)
@@ -2688,17 +3089,24 @@ This creates v-cmt properties where comments are in force."
2688 ;;(error "%s: Unmatched /* */, at char %d" 3089 ;;(error "%s: Unmatched /* */, at char %d"
2689 ;; (verilog-point-text) (point)) 3090 ;; (verilog-point-text) (point))
2690 (goto-char end)) 3091 (goto-char end))
2691 (put-text-property (1+ pt) (point) 'v-cmt t)) 3092 (put-text-property (1+ pt) (point) 'v-cmts t))
3093 ((looking-at "\"")
3094 (setq pt (point))
3095 (or (re-search-forward "[^\\]\"" end t) ;; don't forward-char first, since we look for a non backslash first
3096 ;; No error - let later code indicate it so we can
3097 (goto-char end))
3098 (put-text-property (1+ pt) (point) 'v-cmts t))
2692 (t 3099 (t
2693 (forward-char 1) 3100 (forward-char 1)
2694 (if (re-search-forward "/[/*]" end t) 3101 (if (re-search-forward "[/\"]" end t)
2695 (backward-char 2) 3102 (backward-char 1)
2696 (goto-char end)))))))))) 3103 (goto-char end))))))))))
2697 3104
2698(defun verilog-scan () 3105(defun verilog-scan ()
2699 "Parse the buffer, marking all comments with properties. 3106 "Parse the buffer, marking all comments with properties.
2700Also assumes any text inserted since `verilog-scan-cache-tick' 3107Also assumes any text inserted since `verilog-scan-cache-tick'
2701either is ok to parse as a non-comment, or `verilog-insert' was used." 3108either is ok to parse as a non-comment, or `verilog-insert' was used."
3109 ;; See also `verilog-scan-debug' and `verilog-scan-and-debug'
2702 (unless (verilog-scan-cache-ok-p) 3110 (unless (verilog-scan-cache-ok-p)
2703 (save-excursion 3111 (save-excursion
2704 (verilog-save-buffer-state 3112 (verilog-save-buffer-state
@@ -2706,21 +3114,47 @@ either is ok to parse as a non-comment, or `verilog-insert' was used."
2706 (message "Scanning %s cache=%s cachetick=%S tick=%S" (current-buffer) 3114 (message "Scanning %s cache=%s cachetick=%S tick=%S" (current-buffer)
2707 verilog-scan-cache-preserving verilog-scan-cache-tick 3115 verilog-scan-cache-preserving verilog-scan-cache-tick
2708 (buffer-chars-modified-tick))) 3116 (buffer-chars-modified-tick)))
2709 (remove-text-properties (point-min) (point-max) '(v-cmt nil)) 3117 (remove-text-properties (point-min) (point-max) '(v-cmts nil))
2710 (verilog-scan-region (point-min) (point-max)) 3118 (verilog-scan-region (point-min) (point-max))
2711 (setq verilog-scan-cache-tick (buffer-chars-modified-tick)) 3119 (setq verilog-scan-cache-tick (buffer-chars-modified-tick))
2712 (when verilog-debug (message "Scanning... done")))))) 3120 (when verilog-debug (message "Scanning... done"))))))
2713 3121
2714(defun verilog-inside-comment-p () 3122(defun verilog-scan-debug ()
2715 "Check if point inside a comment. 3123 "For debugging, show with display face results of `verilog-scan'."
3124 (font-lock-mode 0)
3125 ;;(if dbg (setq dbg (concat dbg (format "verilog-scan-debug\n"))))
3126 (save-excursion
3127 (goto-char (point-min))
3128 (remove-text-properties (point-min) (point-max) '(face nil))
3129 (while (not (eobp))
3130 (cond ((get-text-property (point) 'v-cmts)
3131 (put-text-property (point) (1+ (point)) `face 'underline)
3132 ;;(if dbg (setq dbg (concat dbg (format " v-cmts at %S\n" (point)))))
3133 (forward-char 1))
3134 (t
3135 (goto-char (or (next-property-change (point)) (point-max))))))))
3136
3137(defun verilog-scan-and-debug ()
3138 "For debugging, run `verilog-scan' and `verilog-scan-debug'."
3139 (let (verilog-scan-cache-preserving
3140 verilog-scan-cache-tick)
3141 (goto-char (point-min))
3142 (verilog-scan)
3143 (verilog-scan-debug)))
3144
3145(defun verilog-inside-comment-or-string-p (&optional pos)
3146 "Check if optional point POS is inside a comment.
2716This may require a slow pre-parse of the buffer with `verilog-scan' 3147This may require a slow pre-parse of the buffer with `verilog-scan'
2717to establish comment properties on all text." 3148to establish comment properties on all text."
2718 ;; This function is very hot 3149 ;; This function is very hot
2719 (verilog-scan) 3150 (verilog-scan)
2720 (get-text-property (point) 'v-cmt)) 3151 (if pos
3152 (and (>= pos (point-min))
3153 (get-text-property pos 'v-cmts))
3154 (get-text-property (point) 'v-cmts)))
2721 3155
2722(defun verilog-insert (&rest stuff) 3156(defun verilog-insert (&rest stuff)
2723 "Insert STUFF arguments, tracking comments for `verilog-inside-comment-p'. 3157 "Insert STUFF arguments, tracking for `verilog-inside-comment-or-string-p'.
2724Any insert that includes a comment must have the entire commente 3158Any insert that includes a comment must have the entire commente
2725inserted using a single call to `verilog-insert'." 3159inserted using a single call to `verilog-insert'."
2726 (let ((pt (point))) 3160 (let ((pt (point)))
@@ -2741,7 +3175,7 @@ Use filename, if current buffer being edited shorten to just buffer name."
2741 (buffer-name)) 3175 (buffer-name))
2742 buffer-file-name 3176 buffer-file-name
2743 (buffer-name)) 3177 (buffer-name))
2744 ":" (int-to-string (count-lines (point-min) (or pointnum (point)))))) 3178 ":" (int-to-string (1+ (count-lines (point-min) (or pointnum (point)))))))
2745 3179
2746(defun electric-verilog-backward-sexp () 3180(defun electric-verilog-backward-sexp ()
2747 "Move backward over one balanced expression." 3181 "Move backward over one balanced expression."
@@ -2835,28 +3269,24 @@ Use filename, if current buffer being edited shorten to just buffer name."
2835 (setq md 3) ;; ender is third item in regexp 3269 (setq md 3) ;; ender is third item in regexp
2836 ) 3270 )
2837 ((match-end 4) 3271 ((match-end 4)
2838 ;; might be "disable fork" or "fork wait" 3272 ;; might be "disable fork" or "wait fork"
2839 (let 3273 (let
2840 (here) 3274 (here)
2841 (if (looking-at verilog-fork-wait-re) 3275 (if (or
2842 (progn ;; it is a fork wait; ignore it 3276 (looking-at verilog-disable-fork-re)
3277 (and (looking-at "fork")
3278 (progn
3279 (setq here (point)) ;; sometimes a fork is just a fork
3280 (forward-word -1)
3281 (looking-at verilog-disable-fork-re))))
3282 (progn ;; it is a disable fork; ignore it
2843 (goto-char (match-end 0)) 3283 (goto-char (match-end 0))
3284 (forward-word 1)
2844 (setq reg nil)) 3285 (setq reg nil))
2845 (if (or 3286 (progn ;; it is a nice simple fork
2846 (looking-at verilog-disable-fork-re) 3287 (goto-char here) ;; return from looking for "disable fork"
2847 (and (looking-at "fork") 3288 ;; Search forward for matching join
2848 (progn 3289 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))))
2849 (setq here (point)) ;; sometimes a fork is just a fork
2850 (forward-word -1)
2851 (looking-at verilog-disable-fork-re))))
2852 (progn ;; it is a disable fork; ignore it
2853 (goto-char (match-end 0))
2854 (forward-word 1)
2855 (setq reg nil))
2856 (progn ;; it is a nice simple fork
2857 (goto-char here) ;; return from looking for "disable fork"
2858 ;; Search forward for matching join
2859 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))))))
2860 ((match-end 6) 3290 ((match-end 6)
2861 ;; Search forward for matching endclass 3291 ;; Search forward for matching endclass
2862 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) 3292 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
@@ -2916,8 +3346,6 @@ Use filename, if current buffer being edited shorten to just buffer name."
2916 (setq here (point)) ; remember where we started 3346 (setq here (point)) ; remember where we started
2917 (goto-char (match-beginning 1)) 3347 (goto-char (match-beginning 1))
2918 (cond 3348 (cond
2919 ((looking-at verilog-fork-wait-re)
2920 (goto-char (match-end 0))) ; false alarm
2921 ((if (or 3349 ((if (or
2922 (looking-at verilog-disable-fork-re) 3350 (looking-at verilog-disable-fork-re)
2923 (and (looking-at "fork") 3351 (and (looking-at "fork")
@@ -3076,6 +3504,8 @@ Some other functions are:
3076 \\[verilog-sk-initial] Insert an initial begin .. end block. 3504 \\[verilog-sk-initial] Insert an initial begin .. end block.
3077 \\[verilog-sk-fork] Insert a fork begin .. end .. join block. 3505 \\[verilog-sk-fork] Insert a fork begin .. end .. join block.
3078 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block. 3506 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block.
3507 \\[verilog-sk-ovm-class] Insert an OVM Class block.
3508 \\[verilog-sk-uvm-class] Insert an UVM Class block.
3079 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block. 3509 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block.
3080 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. 3510 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block.
3081 \\[verilog-sk-specify] Insert a specify .. endspecify block. 3511 \\[verilog-sk-specify] Insert a specify .. endspecify block.
@@ -3110,7 +3540,6 @@ Key bindings specific to `verilog-mode-map' are:
3110 #'verilog-indent-line-relative) 3540 #'verilog-indent-line-relative)
3111 (setq comment-indent-function 'verilog-comment-indent) 3541 (setq comment-indent-function 'verilog-comment-indent)
3112 (set (make-local-variable 'parse-sexp-ignore-comments) nil) 3542 (set (make-local-variable 'parse-sexp-ignore-comments) nil)
3113
3114 (set (make-local-variable 'comment-start) "// ") 3543 (set (make-local-variable 'comment-start) "// ")
3115 (set (make-local-variable 'comment-end) "") 3544 (set (make-local-variable 'comment-end) "")
3116 (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|// *") 3545 (set (make-local-variable 'comment-start-skip) "/\\*+ *\\|// *")
@@ -3168,7 +3597,9 @@ Key bindings specific to `verilog-mode-map' are:
3168 hs-special-modes-alist)))) 3597 hs-special-modes-alist))))
3169 3598
3170 ;; Stuff for autos 3599 ;; Stuff for autos
3171 (add-hook 'write-contents-hooks 'verilog-auto-save-check nil 'local)) 3600 (add-hook 'write-contents-hooks 'verilog-auto-save-check nil 'local)
3601 ;; verilog-mode-hook call added by define-derived-mode
3602 )
3172 3603
3173 3604
3174;; 3605;;
@@ -3519,6 +3950,12 @@ area. See also `verilog-comment-region'."
3519 (interactive) 3950 (interactive)
3520 (verilog-re-search-backward verilog-defun-re nil 'move)) 3951 (verilog-re-search-backward verilog-defun-re nil 'move))
3521 3952
3953(defun verilog-beg-of-defun-quick ()
3954 "Move backward to the beginning of the current function or procedure.
3955Uses `verilog-scan' cache."
3956 (interactive)
3957 (verilog-re-search-backward-quick verilog-defun-re nil 'move))
3958
3522(defun verilog-end-of-defun () 3959(defun verilog-end-of-defun ()
3523 "Move forward to the end of the current function or procedure." 3960 "Move forward to the end of the current function or procedure."
3524 (interactive) 3961 (interactive)
@@ -3741,13 +4178,21 @@ More specifically, point @ in the line foo : @ begin"
3741 (t 4178 (t
3742 (throw 'found (= nest 0))))))) 4179 (throw 'found (= nest 0)))))))
3743 nil))) 4180 nil)))
4181
3744(defun verilog-backward-up-list (arg) 4182(defun verilog-backward-up-list (arg)
3745 "Like backward-up-list, but deal with comments." 4183 "Like `backward-up-list', but deal with comments."
3746 (let (saved-psic parse-sexp-ignore-comments) 4184 (let ((parse-sexp-ignore-comments t))
3747 (setq parse-sexp-ignore-comments 1) 4185 (backward-up-list arg)))
3748 (backward-up-list arg) 4186
3749 (setq parse-sexp-ignore-comments saved-psic) 4187(defun verilog-forward-sexp-cmt (arg)
3750 )) 4188 "Call `forward-sexp', inside comments."
4189 (let ((parse-sexp-ignore-comments nil))
4190 (forward-sexp arg)))
4191
4192(defun verilog-forward-sexp-ign-cmt (arg)
4193 "Call `forward-sexp', ignoring comments."
4194 (let ((parse-sexp-ignore-comments t))
4195 (forward-sexp arg)))
3751 4196
3752(defun verilog-in-struct-region-p () 4197(defun verilog-in-struct-region-p ()
3753 "Return true if in a struct region. 4198 "Return true if in a struct region.
@@ -4449,7 +4894,6 @@ becomes:
4449 next-error-last-buffer 4894 next-error-last-buffer
4450 compilation-last-buffer))) 4895 compilation-last-buffer)))
4451 (when (buffer-live-p buff) 4896 (when (buffer-live-p buff)
4452 ;; FIXME with-current-buffer?
4453 (save-excursion 4897 (save-excursion
4454 (switch-to-buffer buff) 4898 (switch-to-buffer buff)
4455 (beginning-of-line) 4899 (beginning-of-line)
@@ -4565,8 +5009,9 @@ This lets programs calling batch mode to easily extract error messages."
4565 (error "%%Error: %s%s" (error-message-string err) 5009 (error "%%Error: %s%s" (error-message-string err)
4566 (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline 5010 (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline
4567 5011
4568(defun verilog-batch-execute-func (funref) 5012(defun verilog-batch-execute-func (funref &optional no-save)
4569 "Internal processing of a batch command, running FUNREF on all command arguments." 5013 "Internal processing of a batch command, running FUNREF on all command arguments.
5014Save the result unless optional NO-SAVE is t."
4570 (verilog-batch-error-wrapper 5015 (verilog-batch-error-wrapper
4571 ;; Setting global variables like that is *VERY NASTY* !!! --Stef 5016 ;; Setting global variables like that is *VERY NASTY* !!! --Stef
4572 ;; However, this function is called only when Emacs is being used as 5017 ;; However, this function is called only when Emacs is being used as
@@ -4587,15 +5032,15 @@ This lets programs calling batch mode to easily extract error messages."
4587 (buffer-list)) 5032 (buffer-list))
4588 ;; Process the files 5033 ;; Process the files
4589 (mapcar (lambda (buf) 5034 (mapcar (lambda (buf)
4590 (when (buffer-file-name buf) 5035 (when (buffer-file-name buf)
4591 (save-excursion 5036 (save-excursion
4592 (if (not (file-exists-p (buffer-file-name buf))) 5037 (if (not (file-exists-p (buffer-file-name buf)))
4593 (error 5038 (error
4594 (concat "File not found: " (buffer-file-name buf)))) 5039 (concat "File not found: " (buffer-file-name buf))))
4595 (message (concat "Processing " (buffer-file-name buf))) 5040 (message (concat "Processing " (buffer-file-name buf)))
4596 (set-buffer buf) 5041 (set-buffer buf)
4597 (funcall funref) 5042 (funcall funref)
4598 (save-buffer)))) 5043 (unless no-save (save-buffer)))))
4599 (buffer-list)))) 5044 (buffer-list))))
4600 5045
4601(defun verilog-batch-auto () 5046(defun verilog-batch-auto ()
@@ -4616,6 +5061,16 @@ with \\[verilog-delete-auto] on all command-line files, and saves the buffers."
4616 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes 5061 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
4617 (verilog-batch-execute-func `verilog-delete-auto)) 5062 (verilog-batch-execute-func `verilog-delete-auto))
4618 5063
5064(defun verilog-batch-diff-auto ()
5065 "For use with --batch, perform automatic differences as a stand-alone tool.
5066This sets up the appropriate Verilog mode environment, expand automatics
5067with \\[verilog-diff-auto] on all command-line files, and reports an error
5068if any differences are observed. This is appropriate for adding to regressions
5069to insure automatics are always properly maintained."
5070 (unless noninteractive
5071 (error "Use verilog-batch-diff-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
5072 (verilog-batch-execute-func `verilog-diff-auto t))
5073
4619(defun verilog-batch-inject-auto () 5074(defun verilog-batch-inject-auto ()
4620 "For use with --batch, perform automatic injection as a stand-alone tool. 5075 "For use with --batch, perform automatic injection as a stand-alone tool.
4621This sets up the appropriate Verilog mode environment, injects new automatics 5076This sets up the appropriate Verilog mode environment, injects new automatics
@@ -4627,7 +5082,7 @@ line in bottom-up order."
4627 (verilog-batch-execute-func `verilog-inject-auto)) 5082 (verilog-batch-execute-func `verilog-inject-auto))
4628 5083
4629(defun verilog-batch-indent () 5084(defun verilog-batch-indent ()
4630 "For use with --batch, reindent an entire file as a stand-alone tool. 5085 "For use with --batch, reindent an a entire file as a stand-alone tool.
4631This sets up the appropriate Verilog mode environment, calls 5086This sets up the appropriate Verilog mode environment, calls
4632\\[verilog-indent-buffer] on all command-line files, and saves the buffers." 5087\\[verilog-indent-buffer] on all command-line files, and saves the buffers."
4633 (unless noninteractive 5088 (unless noninteractive
@@ -4692,123 +5147,123 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
4692 ;; if we have a directive, done. 5147 ;; if we have a directive, done.
4693 (if (save-excursion (beginning-of-line) 5148 (if (save-excursion (beginning-of-line)
4694 (and (looking-at verilog-directive-re-1) 5149 (and (looking-at verilog-directive-re-1)
4695 (not (or (looking-at "[ \t]*`ovm_") 5150 (not (or (looking-at "[ \t]*`[ou]vm_")
4696 (looking-at "[ \t]*`vmm_"))))) 5151 (looking-at "[ \t]*`vmm_")))))
4697 (throw 'nesting 'directive)) 5152 (throw 'nesting 'directive))
4698 ;; indent structs as if there were module level 5153 ;; indent structs as if there were module level
4699 (if (verilog-in-struct-p) 5154 (if (verilog-in-struct-p)
4700 (throw 'nesting 'block)) 5155 (throw 'nesting 'block))
4701 5156
4702 ;; unless we are in the newfangled coverpoint or constraint blocks 5157 ;; if we are in a parenthesized list, and the user likes to indent these, return.
4703 ;; if we are in a parenthesized list, and the user likes to indent these, return. 5158 ;; unless we are in the newfangled coverpoint or constraint blocks
4704 (if (and 5159 (if (and
4705 verilog-indent-lists 5160 verilog-indent-lists
4706 (verilog-in-paren) 5161 (verilog-in-paren)
4707 (not (verilog-in-coverage-p)) 5162 (not (verilog-in-coverage-p))
4708 ) 5163 )
4709 (progn (setq par 1) 5164 (progn (setq par 1)
4710 (throw 'nesting 'block))) 5165 (throw 'nesting 'block)))
4711 5166
4712 ;; See if we are continuing a previous line 5167 ;; See if we are continuing a previous line
4713 (while t 5168 (while t
4714 ;; trap out if we crawl off the top of the buffer 5169 ;; trap out if we crawl off the top of the buffer
4715 (if (bobp) (throw 'nesting 'cpp)) 5170 (if (bobp) (throw 'nesting 'cpp))
4716 5171
4717 (if (verilog-continued-line-1 lim) 5172 (if (verilog-continued-line-1 lim)
4718 (let ((sp (point))) 5173 (let ((sp (point)))
4719 (if (and 5174 (if (and
4720 (not (looking-at verilog-complete-reg)) 5175 (not (looking-at verilog-complete-reg))
4721 (verilog-continued-line-1 lim)) 5176 (verilog-continued-line-1 lim))
4722 (progn (goto-char sp) 5177 (progn (goto-char sp)
4723 (throw 'nesting 'cexp)) 5178 (throw 'nesting 'cexp))
4724 5179
4725 (goto-char sp)) 5180 (goto-char sp))
4726 5181
4727 (if (and begin 5182 (if (and begin
4728 (not verilog-indent-begin-after-if) 5183 (not verilog-indent-begin-after-if)
4729 (looking-at verilog-no-indent-begin-re)) 5184 (looking-at verilog-no-indent-begin-re))
4730 (progn 5185 (progn
4731 (beginning-of-line) 5186 (beginning-of-line)
4732 (skip-chars-forward " \t") 5187 (skip-chars-forward " \t")
4733 (throw 'nesting 'statement)) 5188 (throw 'nesting 'statement))
4734 (progn 5189 (progn
4735 (throw 'nesting 'cexp)))) 5190 (throw 'nesting 'cexp))))
4736 ;; not a continued line 5191 ;; not a continued line
4737 (goto-char starting_position)) 5192 (goto-char starting_position))
4738 5193
4739 (if (looking-at "\\<else\\>") 5194 (if (looking-at "\\<else\\>")
4740 ;; search back for governing if, striding across begin..end pairs 5195 ;; search back for governing if, striding across begin..end pairs
4741 ;; appropriately 5196 ;; appropriately
4742 (let ((elsec 1)) 5197 (let ((elsec 1))
4743 (while (verilog-re-search-backward verilog-ends-re nil 'move) 5198 (while (verilog-re-search-backward verilog-ends-re nil 'move)
5199 (cond
5200 ((match-end 1) ; else, we're in deep
5201 (setq elsec (1+ elsec)))
5202 ((match-end 2) ; if
5203 (setq elsec (1- elsec))
5204 (if (= 0 elsec)
5205 (if verilog-align-ifelse
5206 (throw 'nesting 'statement)
5207 (progn ;; back up to first word on this line
5208 (beginning-of-line)
5209 (verilog-forward-syntactic-ws)
5210 (throw 'nesting 'statement)))))
5211 ((match-end 3) ; assert block
5212 (setq elsec (1- elsec))
5213 (verilog-beg-of-statement) ;; doesn't get to beginning
5214 (if (looking-at verilog-property-re)
5215 (throw 'nesting 'statement) ; We don't need an endproperty for these
5216 (throw 'nesting 'block) ;We still need a endproperty
5217 ))
5218 (t ; endblock
5219 ; try to leap back to matching outward block by striding across
5220 ; indent level changing tokens then immediately
5221 ; previous line governs indentation.
5222 (let (( reg) (nest 1))
5223 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup
5224 (cond
5225 ((match-end 4) ; end
5226 ;; Search back for matching begin
5227 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
5228 ((match-end 5) ; endcase
5229 ;; Search back for matching case
5230 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
5231 ((match-end 6) ; endfunction
5232 ;; Search back for matching function
5233 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
5234 ((match-end 7) ; endtask
5235 ;; Search back for matching task
5236 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
5237 ((match-end 8) ; endspecify
5238 ;; Search back for matching specify
5239 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
5240 ((match-end 9) ; endtable
5241 ;; Search back for matching table
5242 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
5243 ((match-end 10) ; endgenerate
5244 ;; Search back for matching generate
5245 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
5246 ((match-end 11) ; joins
5247 ;; Search back for matching fork
5248 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" ))
5249 ((match-end 12) ; class
5250 ;; Search back for matching class
5251 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
5252 ((match-end 13) ; covergroup
5253 ;; Search back for matching covergroup
5254 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )))
5255 (catch 'skip
5256 (while (verilog-re-search-backward reg nil 'move)
4744 (cond 5257 (cond
4745 ((match-end 1) ; else, we're in deep 5258 ((match-end 1) ; begin
4746 (setq elsec (1+ elsec))) 5259 (setq nest (1- nest))
4747 ((match-end 2) ; if 5260 (if (= 0 nest)
4748 (setq elsec (1- elsec)) 5261 (throw 'skip 1)))
4749 (if (= 0 elsec) 5262 ((match-end 2) ; end
4750 (if verilog-align-ifelse 5263 (setq nest (1+ nest)))))
4751 (throw 'nesting 'statement) 5264 )))))))
4752 (progn ;; back up to first word on this line 5265 (throw 'nesting (verilog-calc-1)))
4753 (beginning-of-line) 5266 );; catch nesting
4754 (verilog-forward-syntactic-ws)
4755 (throw 'nesting 'statement)))))
4756 ((match-end 3) ; assert block
4757 (setq elsec (1- elsec))
4758 (verilog-beg-of-statement) ;; doesn't get to beginning
4759 (if (looking-at verilog-property-re)
4760 (throw 'nesting 'statement) ; We don't need an endproperty for these
4761 (throw 'nesting 'block) ;We still need a endproperty
4762 ))
4763 (t ; endblock
4764 ; try to leap back to matching outward block by striding across
4765 ; indent level changing tokens then immediately
4766 ; previous line governs indentation.
4767 (let (( reg) (nest 1))
4768;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup
4769 (cond
4770 ((match-end 4) ; end
4771 ;; Search back for matching begin
4772 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
4773 ((match-end 5) ; endcase
4774 ;; Search back for matching case
4775 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
4776 ((match-end 6) ; endfunction
4777 ;; Search back for matching function
4778 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
4779 ((match-end 7) ; endtask
4780 ;; Search back for matching task
4781 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
4782 ((match-end 8) ; endspecify
4783 ;; Search back for matching specify
4784 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
4785 ((match-end 9) ; endtable
4786 ;; Search back for matching table
4787 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
4788 ((match-end 10) ; endgenerate
4789 ;; Search back for matching generate
4790 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
4791 ((match-end 11) ; joins
4792 ;; Search back for matching fork
4793 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" ))
4794 ((match-end 12) ; class
4795 ;; Search back for matching class
4796 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
4797 ((match-end 13) ; covergroup
4798 ;; Search back for matching covergroup
4799 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )))
4800 (catch 'skip
4801 (while (verilog-re-search-backward reg nil 'move)
4802 (cond
4803 ((match-end 1) ; begin
4804 (setq nest (1- nest))
4805 (if (= 0 nest)
4806 (throw 'skip 1)))
4807 ((match-end 2) ; end
4808 (setq nest (1+ nest)))))
4809 )))))))
4810 (throw 'nesting (verilog-calc-1)))
4811 );; catch nesting
4812 );; type 5267 );; type
4813 ) 5268 )
4814 ;; Return type of block and indent level. 5269 ;; Return type of block and indent level.
@@ -4883,8 +5338,7 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
4883 ((match-end 4) ; *sigh* could be "disable fork" 5338 ((match-end 4) ; *sigh* could be "disable fork"
4884 (let ((here (point))) 5339 (let ((here (point)))
4885 (verilog-beg-of-statement) 5340 (verilog-beg-of-statement)
4886 (if (or (looking-at verilog-disable-fork-re) 5341 (if (looking-at verilog-disable-fork-re)
4887 (looking-at verilog-fork-wait-re))
4888 t ; this is a normal statement 5342 t ; this is a normal statement
4889 (progn ; or is fork, starts a new block 5343 (progn ; or is fork, starts a new block
4890 (goto-char here) 5344 (goto-char here)
@@ -5050,6 +5504,9 @@ Jump from end to matching begin, from endcase to matching case, and so on."
5050 ((looking-at "\\<endproperty\\>") 5504 ((looking-at "\\<endproperty\\>")
5051 ;; 11: Search back for matching property 5505 ;; 11: Search back for matching property
5052 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) 5506 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" ))
5507 ((looking-at verilog-uvm-end-re)
5508 ;; 12: Search back for matching sequence
5509 (setq reg (concat "\\(" verilog-uvm-begin-re "\\|" verilog-uvm-end-re "\\)")))
5053 ((looking-at verilog-ovm-end-re) 5510 ((looking-at verilog-ovm-end-re)
5054 ;; 12: Search back for matching sequence 5511 ;; 12: Search back for matching sequence
5055 (setq reg (concat "\\(" verilog-ovm-begin-re "\\|" verilog-ovm-end-re "\\)"))) 5512 (setq reg (concat "\\(" verilog-ovm-begin-re "\\|" verilog-ovm-end-re "\\)")))
@@ -5177,6 +5634,12 @@ Set point to where line starts."
5177 ;;XX 5634 ;;XX
5178 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") 5635 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>")
5179 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]"))) 5636 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]")))
5637 ((looking-at verilog-uvm-statement-re)
5638 nil)
5639 ((looking-at verilog-uvm-begin-re)
5640 t)
5641 ((looking-at verilog-uvm-end-re)
5642 t)
5180 ((looking-at verilog-ovm-statement-re) 5643 ((looking-at verilog-ovm-statement-re)
5181 nil) 5644 nil)
5182 ((looking-at verilog-ovm-begin-re) 5645 ((looking-at verilog-ovm-begin-re)
@@ -5241,9 +5704,24 @@ Set point to where line starts."
5241 t)))))))) 5704 t))))))))
5242 5705
5243(defun verilog-backward-syntactic-ws () 5706(defun verilog-backward-syntactic-ws ()
5707 "Move backwards putting point after first non-whitespace non-comment."
5244 (verilog-skip-backward-comments) 5708 (verilog-skip-backward-comments)
5245 (forward-comment (- (buffer-size)))) 5709 (forward-comment (- (buffer-size))))
5246 5710
5711(defun verilog-backward-syntactic-ws-quick ()
5712 "As with `verilog-backward-syntactic-ws' but uses `verilog-scan' cache."
5713 (while (cond ((bobp)
5714 nil) ; Done
5715 ((> (skip-syntax-backward " ") 0)
5716 t)
5717 ((eq (preceding-char) ?\n) ;; \n's terminate // so aren't space syntax
5718 (forward-char -1)
5719 t)
5720 ((or (verilog-inside-comment-or-string-p (1- (point)))
5721 (verilog-inside-comment-or-string-p (point)))
5722 (re-search-backward "[/\"]" nil t) ;; Only way a comment or quote can begin
5723 t))))
5724
5247(defun verilog-forward-syntactic-ws () 5725(defun verilog-forward-syntactic-ws ()
5248 (verilog-skip-forward-comment-p) 5726 (verilog-skip-forward-comment-p)
5249 (forward-comment (buffer-size))) 5727 (forward-comment (buffer-size)))
@@ -5339,9 +5817,17 @@ Optional BOUND limits search."
5339 5817
5340(defun verilog-in-attribute-p () 5818(defun verilog-in-attribute-p ()
5341 "Return true if point is in an attribute (* [] attribute *)." 5819 "Return true if point is in an attribute (* [] attribute *)."
5342 (save-excursion 5820 (save-match-data
5343 (verilog-re-search-backward "\\((\\*\\)\\|\\(\\*)\\)" nil 'move) 5821 (save-excursion
5344 (numberp (match-beginning 1)))) 5822 (verilog-re-search-backward "\\((\\*\\)\\|\\(\\*)\\)" nil 'move)
5823 (numberp (match-beginning 1)))))
5824
5825(defun verilog-in-parameter-p ()
5826 "Return true if point is in a parameter assignment #( p1=1, p2=5)."
5827 (save-match-data
5828 (save-excursion
5829 (verilog-re-search-backward "\\(#(\\)\\|\\()\\)" nil 'move)
5830 (numberp (match-beginning 1)))))
5345 5831
5346(defun verilog-in-escaped-name-p () 5832(defun verilog-in-escaped-name-p ()
5347 "Return true if in an escaped name." 5833 "Return true if in an escaped name."
@@ -5357,11 +5843,27 @@ Optional BOUND limits search."
5357 (beginning-of-line) 5843 (beginning-of-line)
5358 (looking-at verilog-directive-re-1))) 5844 (looking-at verilog-directive-re-1)))
5359 5845
5846(defun verilog-in-parenthesis-p ()
5847 "Return true if in a ( ) expression (but not { } or [ ])."
5848 (save-match-data
5849 (save-excursion
5850 (verilog-re-search-backward "\\((\\)\\|\\()\\)" nil 'move)
5851 (numberp (match-beginning 1)))))
5852
5360(defun verilog-in-paren () 5853(defun verilog-in-paren ()
5361 "Return true if in a parenthetical expression." 5854 "Return true if in a parenthetical expression.
5855May cache result using `verilog-syntax-ppss'."
5362 (let ((state (save-excursion (verilog-syntax-ppss)))) 5856 (let ((state (save-excursion (verilog-syntax-ppss))))
5363 (> (nth 0 state) 0 ))) 5857 (> (nth 0 state) 0 )))
5364 5858
5859(defun verilog-in-paren-quick ()
5860 "Return true if in a parenthetical expression.
5861Always starts from point-min, to allow inserts with hooks disabled."
5862 ;; The -quick refers to its use alongside the other -quick functions,
5863 ;; not that it's likely to be faster than verilog-in-paren.
5864 (let ((state (save-excursion (parse-partial-sexp (point-min) (point)))))
5865 (> (nth 0 state) 0 )))
5866
5365(defun verilog-in-struct-p () 5867(defun verilog-in-struct-p ()
5366 "Return true if in a struct declaration." 5868 "Return true if in a struct declaration."
5367 (interactive) 5869 (interactive)
@@ -5607,7 +6109,11 @@ Only look at a few lines to determine indent level."
5607 (goto-char fst) 6109 (goto-char fst)
5608 (+ (current-column) verilog-cexp-indent)))))) 6110 (+ (current-column) verilog-cexp-indent))))))
5609 (goto-char here) 6111 (goto-char here)
5610 (indent-line-to val))) 6112 (indent-line-to val)
6113 (if (and (not verilog-indent-lists)
6114 (verilog-in-paren))
6115 (verilog-pretty-declarations))
6116 ))
5611 ((= (preceding-char) ?\) ) 6117 ((= (preceding-char) ?\) )
5612 (goto-char here) 6118 (goto-char here)
5613 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) 6119 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
@@ -5915,102 +6421,104 @@ Be verbose about progress unless optional QUIET set."
5915 (unless quiet (message ""))))))) 6421 (unless quiet (message "")))))))
5916 6422
5917(defun verilog-pretty-expr (&optional quiet myre) 6423(defun verilog-pretty-expr (&optional quiet myre)
5918 "Line up expressions around point, optionally QUIET with regexp MYRE." 6424 "Line up expressions around point, optionally QUIET with regexp MYRE ignored."
5919 (interactive "i\nsRegular Expression: ((<|:)?=) ") 6425 (interactive)
5920 (save-excursion 6426 (if (not (verilog-in-comment-or-string-p))
5921 (if (or (eq myre nil) 6427 (save-excursion
5922 (string-equal myre "")) 6428 (let ((rexp (concat "^\\s-*" verilog-complete-reg)))
5923 (setq myre "\\(<\\|:\\)?=")) 6429 (beginning-of-line)
5924 ;; want to match the first <= | := | = 6430 (if (and (not (looking-at rexp ))
5925 (setq myre (concat "\\(^.*?\\)\\(" myre "\\)")) 6431 (looking-at verilog-assignment-operation-re)
5926 (let ((rexp(concat "^\\s-*" verilog-complete-reg))) 6432 (save-excursion
5927 (beginning-of-line) 6433 (goto-char (match-end 2))
5928 (if (and (not (looking-at rexp )) 6434 (and (not (verilog-in-attribute-p))
5929 (looking-at myre) 6435 (not (verilog-in-parameter-p))
5930 (save-excursion 6436 (not (verilog-in-comment-or-string-p)))))
5931 (goto-char (match-beginning 2)) 6437 (let* ((here (point))
5932 (not (verilog-in-comment-or-string-p)))) 6438 (e) (r)
5933 (let* ((here (point)) 6439 (start
5934 (e) (r) 6440 (progn
5935 (start 6441 (beginning-of-line)
5936 (progn 6442 (setq e (point))
5937 (beginning-of-line) 6443 (verilog-backward-syntactic-ws)
5938 (setq e (point)) 6444 (beginning-of-line)
5939 (verilog-backward-syntactic-ws) 6445 (while (and (not (looking-at rexp ))
5940 (beginning-of-line) 6446 (looking-at verilog-assignment-operation-re)
5941 (while (and (not (looking-at rexp )) 6447 (not (bobp))
5942 (looking-at myre) 6448 )
5943 (not (bobp)) 6449 (setq e (point))
5944 ) 6450 (verilog-backward-syntactic-ws)
5945 (setq e (point)) 6451 (beginning-of-line)
5946 (verilog-backward-syntactic-ws) 6452 ) ;Ack, need to grok `define
5947 (beginning-of-line) 6453 e))
5948 ) ;Ack, need to grok `define 6454 (end
5949 e)) 6455 (progn
5950 (end 6456 (goto-char here)
5951 (progn 6457 (end-of-line)
5952 (goto-char here) 6458 (setq e (point)) ;Might be on last line
5953 (end-of-line) 6459 (verilog-forward-syntactic-ws)
5954 (setq e (point)) ;Might be on last line 6460 (beginning-of-line)
5955 (verilog-forward-syntactic-ws) 6461 (while (and
5956 (beginning-of-line) 6462 (not (looking-at rexp ))
5957 (while (and 6463 (looking-at verilog-assignment-operation-re)
5958 (not (looking-at rexp )) 6464 (progn
5959 (looking-at myre) 6465 (end-of-line)
5960 (progn 6466 (not (eq e (point)))))
5961 (end-of-line) 6467 (setq e (point))
5962 (not (eq e (point))))) 6468 (verilog-forward-syntactic-ws)
5963 (setq e (point)) 6469 (beginning-of-line)
5964 (verilog-forward-syntactic-ws) 6470 )
5965 (beginning-of-line) 6471 e))
5966 ) 6472 (endpos (set-marker (make-marker) end))
5967 e)) 6473 (ind)
5968 (endpos (set-marker (make-marker) end)) 6474 )
5969 (ind) 6475 (goto-char start)
5970 ) 6476 (verilog-do-indent (verilog-calculate-indent))
5971 (goto-char start) 6477 (if (and (not quiet)
5972 (verilog-do-indent (verilog-calculate-indent)) 6478 (> (- end start) 100))
5973 (if (and (not quiet) 6479 (message "Lining up expressions..(please stand by)"))
5974 (> (- end start) 100)) 6480
5975 (message "Lining up expressions..(please stand by)")) 6481 ;; Set indent to minimum throughout region
5976 6482 (while (< (point) (marker-position endpos))
5977 ;; Set indent to minimum throughout region 6483 (beginning-of-line)
5978 (while (< (point) (marker-position endpos)) 6484 (verilog-just-one-space verilog-assignment-operation-re)
5979 (beginning-of-line) 6485 (beginning-of-line)
5980 (verilog-just-one-space myre) 6486 (verilog-do-indent (verilog-calculate-indent))
5981 (end-of-line) 6487 (end-of-line)
5982 (verilog-forward-syntactic-ws) 6488 (verilog-forward-syntactic-ws)
5983 ) 6489 )
5984 6490
5985 ;; Now find biggest prefix 6491 ;; Now find biggest prefix
5986 (setq ind (verilog-get-lineup-indent-2 myre start endpos)) 6492 (setq ind (verilog-get-lineup-indent-2 verilog-assignment-operation-re start endpos))
5987 6493
5988 ;; Now indent each line. 6494 ;; Now indent each line.
5989 (goto-char start) 6495 (goto-char start)
5990 (while (progn (setq e (marker-position endpos)) 6496 (while (progn (setq e (marker-position endpos))
5991 (setq r (- e (point))) 6497 (setq r (- e (point)))
5992 (> r 0)) 6498 (> r 0))
5993 (setq e (point)) 6499 (setq e (point))
5994 (if (not quiet) (message "%d" r)) 6500 (if (not quiet) (message "%d" r))
5995 (cond 6501 (cond
5996 ((looking-at myre) 6502 ((looking-at verilog-assignment-operation-re)
5997 (goto-char (match-beginning 2)) 6503 (goto-char (match-beginning 2))
5998 (if (not (verilog-parenthesis-depth)) ;; ignore parenthesized exprs 6504 (if (not (or (verilog-in-parenthesis-p) ;; leave attributes and comparisons alone
5999 (if (eq (char-after) ?=) 6505 (verilog-in-coverage-p)))
6000 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = 6506 (if (eq (char-after) ?=)
6001 (indent-to ind) 6507 (indent-to (1+ ind)) ; line up the = of the <= with surrounding =
6002 ))) 6508 (indent-to ind)
6003 ((verilog-continued-line-1 start) 6509 ))
6004 (goto-char e) 6510 )
6005 (indent-line-to ind)) 6511 ((verilog-continued-line-1 start)
6006 (t ; Must be comment or white space 6512 (goto-char e)
6007 (goto-char e) 6513 (indent-line-to ind))
6008 (verilog-forward-ws&directives) 6514 (t ; Must be comment or white space
6009 (forward-line -1)) 6515 (goto-char e)
6010 ) 6516 (verilog-forward-ws&directives)
6011 (forward-line 1)) 6517 (forward-line -1))
6012 (unless quiet (message "")) 6518 )
6013 ))))) 6519 (forward-line 1))
6520 (unless quiet (message ""))
6521 ))))))
6014 6522
6015(defun verilog-just-one-space (myre) 6523(defun verilog-just-one-space (myre)
6016 "Remove extra spaces around regular expression MYRE." 6524 "Remove extra spaces around regular expression MYRE."
@@ -6021,11 +6529,9 @@ Be verbose about progress unless optional QUIET set."
6021 (p2 (match-end 2))) 6529 (p2 (match-end 2)))
6022 (progn 6530 (progn
6023 (goto-char p2) 6531 (goto-char p2)
6024 (if (looking-at "\\s-") (just-one-space)) 6532 (just-one-space)
6025 (goto-char p1) 6533 (goto-char p1)
6026 (forward-char -1) 6534 (just-one-space)))))
6027 (if (looking-at "\\s-") (just-one-space))
6028 ))))
6029 6535
6030(defun verilog-indent-declaration (baseind) 6536(defun verilog-indent-declaration (baseind)
6031 "Indent current lines as declaration. 6537 "Indent current lines as declaration.
@@ -6128,7 +6634,7 @@ Region is defined by B and EDPOS."
6128 (while (progn (setq e (marker-position edpos)) 6634 (while (progn (setq e (marker-position edpos))
6129 (< (point) e)) 6635 (< (point) e))
6130 (if (and (verilog-re-search-forward myre e 'move) 6636 (if (and (verilog-re-search-forward myre e 'move)
6131 (not (verilog-parenthesis-depth))) ;; skip parenthesized exprs 6637 (not (verilog-in-attribute-p))) ;; skip attribute exprs
6132 (progn 6638 (progn
6133 (goto-char (match-beginning 2)) 6639 (goto-char (match-beginning 2))
6134 (verilog-backward-syntactic-ws) 6640 (verilog-backward-syntactic-ws)
@@ -6374,10 +6880,10 @@ for matches of `str' and adding the occurrence tp `all' through point END."
6374(defun verilog-keyword-completion (keyword-list) 6880(defun verilog-keyword-completion (keyword-list)
6375 "Give list of all possible completions of keywords in KEYWORD-LIST." 6881 "Give list of all possible completions of keywords in KEYWORD-LIST."
6376 (mapcar (lambda (s) 6882 (mapcar (lambda (s)
6377 (if (string-match (concat "\\<" verilog-str) s) 6883 (if (string-match (concat "\\<" verilog-str) s)
6378 (if (or (null verilog-pred) 6884 (if (or (null verilog-pred)
6379 (funcall verilog-pred s)) 6885 (funcall verilog-pred s))
6380 (setq verilog-all (cons s verilog-all))))) 6886 (setq verilog-all (cons s verilog-all)))))
6381 keyword-list)) 6887 keyword-list))
6382 6888
6383 6889
@@ -6883,16 +7389,18 @@ See also `verilog-sk-header' for an alternative format."
6883(defsubst verilog-sig-width (sig) 7389(defsubst verilog-sig-width (sig)
6884 (verilog-make-width-expression (verilog-sig-bits sig))) 7390 (verilog-make-width-expression (verilog-sig-bits sig)))
6885 7391
6886(defsubst verilog-alw-new (outputs temps inputs delayed) 7392(defsubst verilog-alw-new (outputs-del outputs-imm temps inputs)
6887 (list outputs temps inputs delayed)) 7393 (list outputs-del outputs-imm temps inputs))
6888(defsubst verilog-alw-get-outputs (sigs) 7394(defsubst verilog-alw-get-outputs-delayed (sigs)
6889 (nth 0 sigs)) 7395 (nth 0 sigs))
6890(defsubst verilog-alw-get-temps (sigs) 7396(defsubst verilog-alw-get-outputs-immediate (sigs)
6891 (nth 1 sigs)) 7397 (nth 1 sigs))
6892(defsubst verilog-alw-get-inputs (sigs) 7398(defsubst verilog-alw-get-temps (sigs)
6893 (nth 2 sigs)) 7399 (nth 2 sigs))
6894(defsubst verilog-alw-get-uses-delayed (sigs) 7400(defsubst verilog-alw-get-inputs (sigs)
6895 (nth 3 sigs)) 7401 (nth 3 sigs))
7402(defsubst verilog-alw-get-uses-delayed (sigs)
7403 (nth 0 sigs))
6896 7404
6897(defsubst verilog-modi-new (name fob pt type) 7405(defsubst verilog-modi-new (name fob pt type)
6898 (vector name fob pt type)) 7406 (vector name fob pt type))
@@ -6911,18 +7419,18 @@ See also `verilog-sk-header' for an alternative format."
6911 7419
6912;; Signal reading for given module 7420;; Signal reading for given module
6913;; Note these all take modi's - as returned from verilog-modi-current 7421;; Note these all take modi's - as returned from verilog-modi-current
6914(defsubst verilog-decls-new (out inout in wires regs assigns consts gparams interfaces) 7422(defsubst verilog-decls-new (out inout in vars unuseds assigns consts gparams interfaces)
6915 (vector out inout in wires regs assigns consts gparams interfaces)) 7423 (vector out inout in vars unuseds assigns consts gparams interfaces))
6916(defsubst verilog-decls-get-outputs (decls) 7424(defsubst verilog-decls-get-outputs (decls)
6917 (aref decls 0)) 7425 (aref decls 0))
6918(defsubst verilog-decls-get-inouts (decls) 7426(defsubst verilog-decls-get-inouts (decls)
6919 (aref decls 1)) 7427 (aref decls 1))
6920(defsubst verilog-decls-get-inputs (decls) 7428(defsubst verilog-decls-get-inputs (decls)
6921 (aref decls 2)) 7429 (aref decls 2))
6922(defsubst verilog-decls-get-wires (decls) 7430(defsubst verilog-decls-get-vars (decls)
6923 (aref decls 3)) 7431 (aref decls 3))
6924(defsubst verilog-decls-get-regs (decls) 7432;;(defsubst verilog-decls-get-unused (decls)
6925 (aref decls 4)) 7433;; (aref decls 4))
6926(defsubst verilog-decls-get-assigns (decls) 7434(defsubst verilog-decls-get-assigns (decls)
6927 (aref decls 5)) 7435 (aref decls 5))
6928(defsubst verilog-decls-get-consts (decls) 7436(defsubst verilog-decls-get-consts (decls)
@@ -7026,6 +7534,7 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
7026 buswarn "")) 7534 buswarn ""))
7027 ;; Extract bus details 7535 ;; Extract bus details
7028 (setq bus (verilog-sig-bits sig)) 7536 (setq bus (verilog-sig-bits sig))
7537 (setq bus (and bus (verilog-simplify-range-expression bus)))
7029 (cond ((and bus 7538 (cond ((and bus
7030 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) 7539 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus)
7031 (setq highbit (string-to-number (match-string 1 bus)) 7540 (setq highbit (string-to-number (match-string 1 bus))
@@ -7145,9 +7654,10 @@ Ignore width if optional NO-WIDTH is set."
7145 "Return module name when after its ( or ;." 7654 "Return module name when after its ( or ;."
7146 (save-excursion 7655 (save-excursion
7147 (re-search-backward "[(;]") 7656 (re-search-backward "[(;]")
7148 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) 7657 ;; Due to "module x import y (" we must search for declaration begin
7149 (skip-chars-backward "a-zA-Z0-9`_$") 7658 (verilog-re-search-backward-quick verilog-defun-re nil nil)
7150 (looking-at "[a-zA-Z0-9`_\$]+") 7659 (goto-char (match-end 0))
7660 (verilog-re-search-forward-quick "\\b[a-zA-Z0-9`_\$]+" nil nil)
7151 ;; Important: don't use match string, this must work with Emacs 19 font-lock on 7661 ;; Important: don't use match string, this must work with Emacs 19 font-lock on
7152 (verilog-symbol-detick 7662 (verilog-symbol-detick
7153 (buffer-substring-no-properties (match-beginning 0) (match-end 0)) t))) 7663 (buffer-substring-no-properties (match-beginning 0) (match-end 0)) t)))
@@ -7203,13 +7713,13 @@ Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters."
7203Return a array of [outputs inouts inputs wire reg assign const]." 7713Return a array of [outputs inouts inputs wire reg assign const]."
7204 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) 7714 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max)))
7205 (functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t) 7715 (functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t)
7206 in-modport 7716 in-modport ign-prop
7207 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const 7717 sigs-in sigs-out sigs-inout sigs-var sigs-assign sigs-const
7208 sigs-gparam sigs-intf 7718 sigs-gparam sigs-intf
7209 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim 7719 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim
7210 modport) 7720 modport)
7211 (save-excursion 7721 (save-excursion
7212 (verilog-beg-of-defun) 7722 (verilog-beg-of-defun-quick)
7213 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) 7723 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point))
7214 (while (< (point) end-mod-point) 7724 (while (< (point) end-mod-point)
7215 ;;(if dbg (setq dbg (concat dbg (format "Pt %s Vec %s C%c Kwd'%s'\n" (point) vec (following-char) keywd)))) 7725 ;;(if dbg (setq dbg (concat dbg (format "Pt %s Vec %s C%c Kwd'%s'\n" (point) vec (following-char) keywd))))
@@ -7225,16 +7735,16 @@ Return a array of [outputs inouts inputs wire reg assign const]."
7225 (or (search-forward "*/") 7735 (or (search-forward "*/")
7226 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) 7736 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
7227 ((looking-at "(\\*") 7737 ((looking-at "(\\*")
7228 (forward-char 2) 7738 ;; To advance past either "(*)" or "(* ... *)" don't forward past first *
7229 (or (looking-at "\\s-*)") ; It's an "always @ (*)" 7739 (forward-char 1)
7230 (search-forward "*)") 7740 (or (search-forward "*)")
7231 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) 7741 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
7232 ((eq ?\" (following-char)) 7742 ((eq ?\" (following-char))
7233 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first 7743 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first
7234 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) 7744 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
7235 ((eq ?\; (following-char)) 7745 ((eq ?\; (following-char))
7236 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil 7746 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil
7237 v2kargs-ok nil in-modport nil) 7747 v2kargs-ok nil in-modport nil ign-prop nil)
7238 (forward-char 1)) 7748 (forward-char 1))
7239 ((eq ?= (following-char)) 7749 ((eq ?= (following-char))
7240 (setq rvalue t newsig nil) 7750 (setq rvalue t newsig nil)
@@ -7290,16 +7800,15 @@ Return a array of [outputs inouts inputs wire reg assign const]."
7290 ((equal keywd "parameter") 7800 ((equal keywd "parameter")
7291 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren 7801 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
7292 expect-signal 'sigs-gparam io t modport nil)) 7802 expect-signal 'sigs-gparam io t modport nil))
7293 ((member keywd '("wire" "tri" "tri0" "tri1" "triand" "trior" "wand" "wor")) 7803 ((member keywd '("wire"
7294 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren 7804 "tri" "tri0" "tri1" "triand" "trior" "wand" "wor"
7295 expect-signal 'sigs-wire modport nil))) 7805 "reg" "trireg"
7296 ((member keywd '("reg" "trireg"
7297 "byte" "shortint" "int" "longint" "integer" "time" 7806 "byte" "shortint" "int" "longint" "integer" "time"
7298 "bit" "logic" 7807 "bit" "logic"
7299 "shortreal" "real" "realtime" 7808 "shortreal" "real" "realtime"
7300 "string" "event" "chandle")) 7809 "string" "event" "chandle"))
7301 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren 7810 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
7302 expect-signal 'sigs-reg modport nil))) 7811 expect-signal 'sigs-var modport nil)))
7303 ((equal keywd "assign") 7812 ((equal keywd "assign")
7304 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren 7813 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
7305 expect-signal 'sigs-assign modport nil)) 7814 expect-signal 'sigs-assign modport nil))
@@ -7307,11 +7816,14 @@ Return a array of [outputs inouts inputs wire reg assign const]."
7307 "localparam" "genvar")) 7816 "localparam" "genvar"))
7308 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren 7817 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
7309 expect-signal 'sigs-const modport nil))) 7818 expect-signal 'sigs-const modport nil)))
7310 ((equal keywd "signed") 7819 ((member keywd '("signed" "unsigned"))
7311 (setq signed "signed")) 7820 (setq signed keywd))
7821 ((member keywd '("assert" "assume" "cover" "expect" "restrict"))
7822 (setq ign-prop t))
7312 ((member keywd '("class" "clocking" "covergroup" "function" 7823 ((member keywd '("class" "clocking" "covergroup" "function"
7313 "property" "randsequence" "sequence" "task")) 7824 "property" "randsequence" "sequence" "task"))
7314 (setq functask (1+ functask))) 7825 (unless ign-prop
7826 (setq functask (1+ functask))))
7315 ((member keywd '("endclass" "endclocking" "endgroup" "endfunction" 7827 ((member keywd '("endclass" "endclocking" "endgroup" "endfunction"
7316 "endproperty" "endsequence" "endtask")) 7828 "endproperty" "endsequence" "endtask"))
7317 (setq functask (1- functask))) 7829 (setq functask (1- functask)))
@@ -7354,8 +7866,8 @@ Return a array of [outputs inouts inputs wire reg assign const]."
7354 (verilog-decls-new (nreverse sigs-out) 7866 (verilog-decls-new (nreverse sigs-out)
7355 (nreverse sigs-inout) 7867 (nreverse sigs-inout)
7356 (nreverse sigs-in) 7868 (nreverse sigs-in)
7357 (nreverse sigs-wire) 7869 (nreverse sigs-var)
7358 (nreverse sigs-reg) 7870 nil
7359 (nreverse sigs-assign) 7871 (nreverse sigs-assign)
7360 (nreverse sigs-const) 7872 (nreverse sigs-const)
7361 (nreverse sigs-gparam) 7873 (nreverse sigs-gparam)
@@ -7442,8 +7954,7 @@ Return a array of [outputs inouts inputs wire reg assign const]."
7442 multidim nil) 7954 multidim nil)
7443 sigs-intf))) 7955 sigs-intf)))
7444 ((setq portdata (and verilog-read-sub-decls-in-interfaced 7956 ((setq portdata (and verilog-read-sub-decls-in-interfaced
7445 (or (assoc port (verilog-decls-get-regs submoddecls)) 7957 (assoc port (verilog-decls-get-vars submoddecls))))
7446 (assoc port (verilog-decls-get-wires submoddecls)))))
7447 (setq sigs-intfd 7958 (setq sigs-intfd
7448 (cons (verilog-sig-new 7959 (cons (verilog-sig-new
7449 sig 7960 sig
@@ -7556,7 +8067,8 @@ Inserts the list of signals found, using submodi to look up each port."
7556 submoddecls comment port 8067 submoddecls comment port
7557 (buffer-substring 8068 (buffer-substring
7558 (point) (1- (progn (search-backward "(") ; start at ( 8069 (point) (1- (progn (search-backward "(") ; start at (
7559 (forward-sexp 1) (point)))))))) ; expr 8070 (verilog-forward-sexp-ign-cmt 1)
8071 (point)))))))) ; expr
7560 ;; 8072 ;;
7561 (forward-line 1))))) 8073 (forward-line 1)))))
7562 8074
@@ -7573,8 +8085,9 @@ Inserts the list of signals found."
7573 (or (search-forward "*/") 8085 (or (search-forward "*/")
7574 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) 8086 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
7575 ((looking-at "(\\*") 8087 ((looking-at "(\\*")
7576 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" 8088 ;; To advance past either "(*)" or "(* ... *)" don't forward past first *
7577 (search-forward "*)") 8089 (forward-char 1)
8090 (or (search-forward "*)")
7578 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) 8091 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
7579 ;; On pins, parse and advance to next pin 8092 ;; On pins, parse and advance to next pin
7580 ;; Looking at pin, but *not* an // Output comment, or ) to end the inst 8093 ;; Looking at pin, but *not* an // Output comment, or ) to end the inst
@@ -7612,11 +8125,11 @@ Outputs comments above subcell signals, for example:
7612 st-point end-inst-point 8125 st-point end-inst-point
7613 ;; below 3 modified by verilog-read-sub-decls-line 8126 ;; below 3 modified by verilog-read-sub-decls-line
7614 sigs-out sigs-inout sigs-in sigs-intf sigs-intfd) 8127 sigs-out sigs-inout sigs-in sigs-intf sigs-intfd)
7615 (verilog-beg-of-defun) 8128 (verilog-beg-of-defun-quick)
7616 (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t) 8129 (while (verilog-re-search-forward-quick "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t)
7617 (save-excursion 8130 (save-excursion
7618 (goto-char (match-beginning 0)) 8131 (goto-char (match-beginning 0))
7619 (unless (verilog-inside-comment-p) 8132 (unless (verilog-inside-comment-or-string-p)
7620 ;; Attempt to snarf a comment 8133 ;; Attempt to snarf a comment
7621 (let* ((submod (verilog-read-inst-module)) 8134 (let* ((submod (verilog-read-inst-module))
7622 (inst (verilog-read-inst-name)) 8135 (inst (verilog-read-inst-name))
@@ -7629,7 +8142,8 @@ Outputs comments above subcell signals, for example:
7629 submoddecls (verilog-decls-new nil nil nil nil nil nil nil nil nil) 8142 submoddecls (verilog-decls-new nil nil nil nil nil nil nil nil nil)
7630 comment (concat inst " of " submod)) 8143 comment (concat inst " of " submod))
7631 (verilog-backward-open-paren) 8144 (verilog-backward-open-paren)
7632 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) 8145 (setq end-inst-point (save-excursion (verilog-forward-sexp-ign-cmt 1)
8146 (point))
7633 st-point (point)) 8147 st-point (point))
7634 (forward-char 1) 8148 (forward-char 1)
7635 (verilog-read-sub-decls-gate submoddecls comment submod end-inst-point)) 8149 (verilog-read-sub-decls-gate submoddecls comment submod end-inst-point))
@@ -7639,7 +8153,8 @@ Outputs comments above subcell signals, for example:
7639 (setq submoddecls (verilog-modi-get-decls submodi) 8153 (setq submoddecls (verilog-modi-get-decls submodi)
7640 verilog-read-sub-decls-gate-ios nil) 8154 verilog-read-sub-decls-gate-ios nil)
7641 (verilog-backward-open-paren) 8155 (verilog-backward-open-paren)
7642 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) 8156 (setq end-inst-point (save-excursion (verilog-forward-sexp-ign-cmt 1)
8157 (point))
7643 st-point (point)) 8158 st-point (point))
7644 ;; This could have used a list created by verilog-auto-inst 8159 ;; This could have used a list created by verilog-auto-inst
7645 ;; However I want it to be runnable even on user's manually added signals 8160 ;; However I want it to be runnable even on user's manually added signals
@@ -7677,10 +8192,10 @@ For example if declare A A (.B(SIG)) then B will be included in the list."
7677 (verilog-backward-open-paren) 8192 (verilog-backward-open-paren)
7678 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) 8193 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t)
7679 (setq pin (match-string 1)) 8194 (setq pin (match-string 1))
7680 (unless (verilog-inside-comment-p) 8195 (unless (verilog-inside-comment-or-string-p)
7681 (setq pins (cons (list pin) pins)) 8196 (setq pins (cons (list pin) pins))
7682 (when (looking-at "(") 8197 (when (looking-at "(")
7683 (forward-sexp 1)))) 8198 (verilog-forward-sexp-ign-cmt 1))))
7684 (vector pins)))) 8199 (vector pins))))
7685 8200
7686(defun verilog-read-arg-pins () 8201(defun verilog-read-arg-pins ()
@@ -7691,7 +8206,7 @@ For example if declare A A (.B(SIG)) then B will be included in the list."
7691 (verilog-backward-open-paren) 8206 (verilog-backward-open-paren)
7692 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) 8207 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t)
7693 (setq pin (match-string 1)) 8208 (setq pin (match-string 1))
7694 (unless (verilog-inside-comment-p) 8209 (unless (verilog-inside-comment-or-string-p)
7695 (setq pins (cons (list pin) pins)))) 8210 (setq pins (cons (list pin) pins))))
7696 (vector pins)))) 8211 (vector pins))))
7697 8212
@@ -7707,7 +8222,7 @@ For example if declare A A (.B(SIG)) then B will be included in the list."
7707 (search-forward "(" end-mod-point) 8222 (search-forward "(" end-mod-point)
7708 (setq tpl-end-pt (save-excursion 8223 (setq tpl-end-pt (save-excursion
7709 (backward-char 1) 8224 (backward-char 1)
7710 (forward-sexp 1) ;; Moves to paren that closes argdecl's 8225 (verilog-forward-sexp-cmt 1) ;; Moves to paren that closes argdecl's
7711 (backward-char 1) 8226 (backward-char 1)
7712 (point))) 8227 (point)))
7713 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) 8228 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t)
@@ -7720,6 +8235,7 @@ For example if declare A A (.B(SIG)) then B will be included in the list."
7720(defun verilog-read-auto-lisp-present () 8235(defun verilog-read-auto-lisp-present ()
7721 "Set `verilog-cache-has-lisp' if any AUTO_LISP in this buffer." 8236 "Set `verilog-cache-has-lisp' if any AUTO_LISP in this buffer."
7722 (save-excursion 8237 (save-excursion
8238 (goto-char (point-min))
7723 (setq verilog-cache-has-lisp (re-search-forward "\\<AUTO_LISP(" nil t)))) 8239 (setq verilog-cache-has-lisp (re-search-forward "\\<AUTO_LISP(" nil t))))
7724 8240
7725(defun verilog-read-auto-lisp (start end) 8241(defun verilog-read-auto-lisp (start end)
@@ -7732,7 +8248,7 @@ Must call `verilog-read-auto-lisp-present' before this function."
7732 (while (re-search-forward "\\<AUTO_LISP(" end t) 8248 (while (re-search-forward "\\<AUTO_LISP(" end t)
7733 (backward-char) 8249 (backward-char)
7734 (let* ((beg-pt (prog1 (point) 8250 (let* ((beg-pt (prog1 (point)
7735 (forward-sexp 1))) ;; Closing paren 8251 (verilog-forward-sexp-cmt 1))) ;; Closing paren
7736 (end-pt (point))) 8252 (end-pt (point)))
7737 (eval-region beg-pt end-pt nil)))))) 8253 (eval-region beg-pt end-pt nil))))))
7738 8254
@@ -7741,9 +8257,10 @@ Must call `verilog-read-auto-lisp-present' before this function."
7741 ;; Do not remove the eval-when-compile 8257 ;; Do not remove the eval-when-compile
7742 ;; - we want a error when we are debugging this code if they are refed. 8258 ;; - we want a error when we are debugging this code if they are refed.
7743 (defvar sigs-in) 8259 (defvar sigs-in)
7744 (defvar sigs-out) 8260 (defvar sigs-out-d)
8261 (defvar sigs-out-i)
8262 (defvar sigs-out-unk)
7745 (defvar sigs-temp) 8263 (defvar sigs-temp)
7746 (defvar uses-delayed)
7747 (defvar vector-skip-list)) 8264 (defvar vector-skip-list))
7748 8265
7749(defun verilog-read-always-signals-recurse 8266(defun verilog-read-always-signals-recurse
@@ -7764,8 +8281,9 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement."
7764 (or (search-forward "*/") 8281 (or (search-forward "*/")
7765 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) 8282 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
7766 ((looking-at "(\\*") 8283 ((looking-at "(\\*")
7767 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" 8284 ;; To advance past either "(*)" or "(* ... *)" don't forward past first *
7768 (search-forward "*)") 8285 (forward-char 1)
8286 (or (search-forward "*)")
7769 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) 8287 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
7770 (t (setq keywd (buffer-substring-no-properties 8288 (t (setq keywd (buffer-substring-no-properties
7771 (point) 8289 (point)
@@ -7817,9 +8335,16 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement."
7817 (setq ignore-next t rvalue nil))) 8335 (setq ignore-next t rvalue nil)))
7818 (forward-char 1)) 8336 (forward-char 1))
7819 ((equal keywd "=") 8337 ((equal keywd "=")
7820 (if (and (eq (char-before) ?< ) 8338 (when got-sig
7821 (not rvalue)) 8339 ;;(if dbg (setq dbg (concat dbg (format "\t\tequal got-sig=%S got-list=%s\n" got-sig got-list))))
7822 (setq uses-delayed 1)) 8340 (set got-list (cons got-sig (symbol-value got-list)))
8341 (setq got-sig nil))
8342 (when (not rvalue)
8343 (if (eq (char-before) ?< )
8344 (setq sigs-out-d (append sigs-out-d sigs-out-unk)
8345 sigs-out-unk nil)
8346 (setq sigs-out-i (append sigs-out-i sigs-out-unk)
8347 sigs-out-unk nil)))
7823 (setq ignore-next nil rvalue t) 8348 (setq ignore-next nil rvalue t)
7824 (forward-char 1)) 8349 (forward-char 1))
7825 ((equal keywd "?") 8350 ((equal keywd "?")
@@ -7865,7 +8390,7 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement."
7865 ) 8390 )
7866 (setq got-list (cond (temp-next 'sigs-temp) 8391 (setq got-list (cond (temp-next 'sigs-temp)
7867 (rvalue 'sigs-in) 8392 (rvalue 'sigs-in)
7868 (t 'sigs-out)) 8393 (t 'sigs-out-unk))
7869 got-sig (if (or (not keywd) 8394 got-sig (if (or (not keywd)
7870 (assoc keywd (symbol-value got-list))) 8395 (assoc keywd (symbol-value got-list)))
7871 nil (list keywd nil nil)) 8396 nil (list keywd nil nil))
@@ -7889,17 +8414,18 @@ IGNORE-NEXT is true to ignore next token, fake from inside case statement."
7889 "Parse always block at point and return list of (outputs inout inputs)." 8414 "Parse always block at point and return list of (outputs inout inputs)."
7890 (save-excursion 8415 (save-excursion
7891 (let* (;;(dbg "") 8416 (let* (;;(dbg "")
7892 sigs-out sigs-temp sigs-in 8417 sigs-out-d sigs-out-i sigs-out-unk sigs-temp sigs-in)
7893 uses-delayed) ;; Found signal/rvalue; push if not function
7894 (search-forward ")") 8418 (search-forward ")")
7895 (verilog-read-always-signals-recurse nil nil nil) 8419 (verilog-read-always-signals-recurse nil nil nil)
8420 (setq sigs-out-i (append sigs-out-i sigs-out-unk)
8421 sigs-out-unk nil)
7896 ;;(if dbg (with-current-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg "")) 8422 ;;(if dbg (with-current-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg ""))
7897 ;; Return what was found 8423 ;; Return what was found
7898 (verilog-alw-new sigs-out sigs-temp sigs-in uses-delayed)))) 8424 (verilog-alw-new sigs-out-d sigs-out-i sigs-temp sigs-in))))
7899 8425
7900(defun verilog-read-instants () 8426(defun verilog-read-instants ()
7901 "Parse module at point and return list of ( ( file instance ) ... )." 8427 "Parse module at point and return list of ( ( file instance ) ... )."
7902 (verilog-beg-of-defun) 8428 (verilog-beg-of-defun-quick)
7903 (let* ((end-mod-point (verilog-get-end-of-defun t)) 8429 (let* ((end-mod-point (verilog-get-end-of-defun t))
7904 (state nil) 8430 (state nil)
7905 (instants-list nil)) 8431 (instants-list nil))
@@ -7930,7 +8456,7 @@ list of ( (signal_name connection_name)... )."
7930 (save-excursion 8456 (save-excursion
7931 ;; Find beginning 8457 ;; Find beginning
7932 (let ((tpl-regexp "\\([0-9]+\\)") 8458 (let ((tpl-regexp "\\([0-9]+\\)")
7933 (lineno 0) 8459 (lineno -1) ; -1 to offset for the AUTO_TEMPLATE's newline
7934 (templateno 0) 8460 (templateno 0)
7935 (pt (point)) 8461 (pt (point))
7936 tpl-sig-list tpl-wild-list tpl-end-pt rep) 8462 tpl-sig-list tpl-wild-list tpl-end-pt rep)
@@ -7962,22 +8488,27 @@ list of ( (signal_name connection_name)... )."
7962 ;; Parse lines in the template 8488 ;; Parse lines in the template
7963 (when verilog-auto-inst-template-numbers 8489 (when verilog-auto-inst-template-numbers
7964 (save-excursion 8490 (save-excursion
7965 (goto-char (point-min)) 8491 (let ((pre-pt (point)))
7966 (while (search-forward "AUTO_TEMPLATE" nil t) 8492 (goto-char (point-min))
7967 (setq templateno (1+ templateno))))) 8493 (while (search-forward "AUTO_TEMPLATE" pre-pt t)
8494 (setq templateno (1+ templateno)))
8495 (while (< (point) pre-pt)
8496 (forward-line 1)
8497 (setq lineno (1+ lineno))))))
7968 (setq tpl-end-pt (save-excursion 8498 (setq tpl-end-pt (save-excursion
7969 (backward-char 1) 8499 (backward-char 1)
7970 (forward-sexp 1) ;; Moves to paren that closes argdecl's 8500 (verilog-forward-sexp-cmt 1) ;; Moves to paren that closes argdecl's
7971 (backward-char 1) 8501 (backward-char 1)
7972 (point))) 8502 (point)))
7973 ;; 8503 ;;
7974 (while (< (point) tpl-end-pt) 8504 (while (< (point) tpl-end-pt)
7975 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") 8505 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
7976 (setq tpl-sig-list (cons (list 8506 (setq tpl-sig-list
7977 (match-string-no-properties 1) 8507 (cons (list
7978 (match-string-no-properties 2) 8508 (match-string-no-properties 1)
7979 templateno lineno) 8509 (match-string-no-properties 2)
7980 tpl-sig-list)) 8510 templateno lineno)
8511 tpl-sig-list))
7981 (goto-char (match-end 0))) 8512 (goto-char (match-end 0)))
7982 ;; Regexp form?? 8513 ;; Regexp form??
7983 ((looking-at 8514 ((looking-at
@@ -8000,7 +8531,8 @@ list of ( (signal_name connection_name)... )."
8000 (setq lineno (1+ lineno)) 8531 (setq lineno (1+ lineno))
8001 (goto-char (match-end 0))) 8532 (goto-char (match-end 0)))
8002 ((looking-at "//") 8533 ((looking-at "//")
8003 (search-forward "\n")) 8534 (search-forward "\n")
8535 (setq lineno (1+ lineno)))
8004 ((looking-at "/\\*") 8536 ((looking-at "/\\*")
8005 (forward-char 2) 8537 (forward-char 2)
8006 (or (search-forward "*/") 8538 (or (search-forward "*/")
@@ -8086,7 +8618,7 @@ warning message, you need to add to your .emacs file:
8086 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) 8618 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
8087 (let ((inc (verilog-string-replace-matches 8619 (let ((inc (verilog-string-replace-matches
8088 "\"" "" nil nil (match-string-no-properties 1)))) 8620 "\"" "" nil nil (match-string-no-properties 1))))
8089 (unless (verilog-inside-comment-p) 8621 (unless (verilog-inside-comment-or-string-p)
8090 (verilog-read-defines inc recurse t))))) 8622 (verilog-read-defines inc recurse t)))))
8091 ;; Read `defines 8623 ;; Read `defines
8092 ;; note we don't use verilog-re... it's faster this way, and that 8624 ;; note we don't use verilog-re... it's faster this way, and that
@@ -8100,14 +8632,15 @@ warning message, you need to add to your .emacs file:
8100 ;; Hack: Read parameters 8632 ;; Hack: Read parameters
8101 (goto-char (point-min)) 8633 (goto-char (point-min))
8102 (while (re-search-forward 8634 (while (re-search-forward
8103 "^\\s-*\\(parameter\\|localparam\\)\\(\\s-*\\[[^]]*\\]\\)?\\s-+" nil t) 8635 "^\\s-*\\(parameter\\|localparam\\)\\(\\s-*\\[[^]]*\\]\\)?\\s-*" nil t)
8104 (let (enumname) 8636 (let (enumname)
8105 ;; The primary way of getting defines is verilog-read-decls 8637 ;; The primary way of getting defines is verilog-read-decls
8106 ;; However, that isn't called yet for included files, so we'll add another scheme 8638 ;; However, that isn't called yet for included files, so we'll add another scheme
8107 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") 8639 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
8108 (setq enumname (match-string-no-properties 1))) 8640 (setq enumname (match-string-no-properties 1)))
8109 (forward-comment 999) 8641 (forward-comment 999)
8110 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") 8642 (while (looking-at (concat "\\s-*,?\\s-*\\(?:/[/*].*?$\\)?\\s-*\\([a-zA-Z0-9_$]+\\)"
8643 "\\s-*=\\s-*\\([^;,]*\\),?\\s-*\\(/[/*].*?$\\)?\\s-*"))
8111 (verilog-set-define (match-string-no-properties 1) 8644 (verilog-set-define (match-string-no-properties 1)
8112 (match-string-no-properties 2) origbuf enumname) 8645 (match-string-no-properties 2) origbuf enumname)
8113 (goto-char (match-end 0)) 8646 (goto-char (match-end 0))
@@ -8278,11 +8811,11 @@ Some macros and such are also found and included. For dinotrace.el."
8278 verilog-library-files 8811 verilog-library-files
8279 verilog-library-flags))) 8812 verilog-library-flags)))
8280 ;; Allow user to customize 8813 ;; Allow user to customize
8281 (run-hooks 'verilog-before-getopt-flags-hook) 8814 (verilog-run-hooks 'verilog-before-getopt-flags-hook)
8282 ;; Process arguments 8815 ;; Process arguments
8283 (verilog-getopt verilog-library-flags) 8816 (verilog-getopt verilog-library-flags)
8284 ;; Allow user to customize 8817 ;; Allow user to customize
8285 (run-hooks 'verilog-getopt-flags-hook)) 8818 (verilog-run-hooks 'verilog-getopt-flags-hook))
8286 8819
8287(defun verilog-add-list-unique (varref object) 8820(defun verilog-add-list-unique (varref object)
8288 "Append to VARREF list the given OBJECT, 8821 "Append to VARREF list the given OBJECT,
@@ -8387,7 +8920,7 @@ Allows version control to check out the file if need be."
8387 (while (and 8920 (while (and
8388 ;; It may be tempting to look for verilog-defun-re, 8921 ;; It may be tempting to look for verilog-defun-re,
8389 ;; don't, it slows things down a lot! 8922 ;; don't, it slows things down a lot!
8390 (verilog-re-search-forward-quick "\\<\\(module\\|interface\\)\\>" nil t) 8923 (verilog-re-search-forward-quick "\\<\\(module\\|interface\\|program\\)\\>" nil t)
8391 (setq type (match-string-no-properties 0)) 8924 (setq type (match-string-no-properties 0))
8392 (verilog-re-search-forward-quick "[(;]" nil t)) 8925 (verilog-re-search-forward-quick "[(;]" nil t))
8393 (if (equal module (verilog-read-module-name)) 8926 (if (equal module (verilog-read-module-name))
@@ -8804,13 +9337,12 @@ if non-nil."
8804 9337
8805;; Combined 9338;; Combined
8806(defun verilog-decls-get-signals (decls) 9339(defun verilog-decls-get-signals (decls)
9340 "Return all declared signals, excluding 'assign' statements."
8807 (append 9341 (append
8808 (verilog-decls-get-outputs decls) 9342 (verilog-decls-get-outputs decls)
8809 (verilog-decls-get-inouts decls) 9343 (verilog-decls-get-inouts decls)
8810 (verilog-decls-get-inputs decls) 9344 (verilog-decls-get-inputs decls)
8811 (verilog-decls-get-wires decls) 9345 (verilog-decls-get-vars decls)
8812 (verilog-decls-get-regs decls)
8813 (verilog-decls-get-assigns decls)
8814 (verilog-decls-get-consts decls) 9346 (verilog-decls-get-consts decls)
8815 (verilog-decls-get-gparams decls))) 9347 (verilog-decls-get-gparams decls)))
8816 9348
@@ -8826,10 +9358,8 @@ if non-nil."
8826 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list)) 9358 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list))
8827(defsubst verilog-modi-cache-add-inputs (modi sig-list) 9359(defsubst verilog-modi-cache-add-inputs (modi sig-list)
8828 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) 9360 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list))
8829(defsubst verilog-modi-cache-add-wires (modi sig-list) 9361(defsubst verilog-modi-cache-add-vars (modi sig-list)
8830 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) 9362 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list))
8831(defsubst verilog-modi-cache-add-regs (modi sig-list)
8832 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list))
8833 9363
8834(defun verilog-signals-from-signame (signame-list) 9364(defun verilog-signals-from-signame (signame-list)
8835 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names." 9365 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names."
@@ -8843,7 +9373,7 @@ if non-nil."
8843(defun verilog-auto-re-search-do (search-for func) 9373(defun verilog-auto-re-search-do (search-for func)
8844 "Search for the given auto text regexp SEARCH-FOR, and perform FUNC where it occurs." 9374 "Search for the given auto text regexp SEARCH-FOR, and perform FUNC where it occurs."
8845 (goto-char (point-min)) 9375 (goto-char (point-min))
8846 (while (verilog-re-search-forward search-for nil t) 9376 (while (verilog-re-search-forward-quick search-for nil t)
8847 (funcall func))) 9377 (funcall func)))
8848 9378
8849(defun verilog-insert-one-definition (sig type indent-pt) 9379(defun verilog-insert-one-definition (sig type indent-pt)
@@ -8867,10 +9397,31 @@ with appropriate INDENT-PT indentation."
8867 (when (verilog-sig-memory sig) 9397 (when (verilog-sig-memory sig)
8868 (insert " " (verilog-sig-memory sig)))) 9398 (insert " " (verilog-sig-memory sig))))
8869 9399
8870(defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort) 9400(defun verilog-insert-definition (modi sigs direction indent-pt v2k &optional dont-sort)
8871 "Print out a definition for a list of SIGS of the given DIRECTION, 9401 "Print out a definition for MODI's list of SIGS of the given DIRECTION,
8872with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O 9402with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O
8873format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output." 9403format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output.
9404When MODI is non-null, also add to modi-cache, for tracking."
9405 (when modi
9406 (cond ((equal direction "wire")
9407 (verilog-modi-cache-add-vars modi sigs))
9408 ((equal direction "reg")
9409 (verilog-modi-cache-add-vars modi sigs))
9410 ((equal direction "output")
9411 (verilog-modi-cache-add-outputs modi sigs)
9412 (when verilog-auto-declare-nettype
9413 (verilog-modi-cache-add-vars modi sigs)))
9414 ((equal direction "input")
9415 (verilog-modi-cache-add-inputs modi sigs)
9416 (when verilog-auto-declare-nettype
9417 (verilog-modi-cache-add-vars modi sigs)))
9418 ((equal direction "inout")
9419 (verilog-modi-cache-add-inouts modi sigs)
9420 (when verilog-auto-declare-nettype
9421 (verilog-modi-cache-add-vars modi sigs)))
9422 ((equal direction "interface"))
9423 (t
9424 (error "Unsupported verilog-insert-definition direction: %s" direction))))
8874 (or dont-sort 9425 (or dont-sort
8875 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) 9426 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare)))
8876 (while sigs 9427 (while sigs
@@ -8878,12 +9429,18 @@ format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output."
8878 (verilog-insert-one-definition 9429 (verilog-insert-one-definition
8879 sig 9430 sig
8880 ;; Want "type x" or "output type x", not "wire type x" 9431 ;; Want "type x" or "output type x", not "wire type x"
8881 (cond ((verilog-sig-type sig) 9432 (cond ((or (verilog-sig-type sig)
9433 verilog-auto-wire-type)
8882 (concat 9434 (concat
8883 (if (not (member direction '("wire" "interface"))) 9435 (when (member direction '("input" "output" "inout"))
8884 (concat direction " ")) 9436 (concat direction " "))
8885 (verilog-sig-type sig))) 9437 (or (verilog-sig-type sig)
8886 (t direction)) 9438 verilog-auto-wire-type)))
9439 ((and verilog-auto-declare-nettype
9440 (member direction '("input" "output" "inout")))
9441 (concat direction " " verilog-auto-declare-nettype))
9442 (t
9443 direction))
8887 indent-pt) 9444 indent-pt)
8888 (insert (if v2k "," ";")) 9445 (insert (if v2k "," ";"))
8889 (if (or (not (verilog-sig-comment sig)) 9446 (if (or (not (verilog-sig-comment sig))
@@ -8914,7 +9471,7 @@ Presumes that any newlines end a list element."
8914 ;; We can't just search backward for ) as it might be inside another expression. 9471 ;; We can't just search backward for ) as it might be inside another expression.
8915 ;; Also want "`ifdef X input foo `endif" to just leave things to the human to deal with 9472 ;; Also want "`ifdef X input foo `endif" to just leave things to the human to deal with
8916 (save-excursion 9473 (save-excursion
8917 (verilog-backward-syntactic-ws) 9474 (verilog-backward-syntactic-ws-quick)
8918 (when (and (not (save-excursion ;; Not beginning (, or existing , 9475 (when (and (not (save-excursion ;; Not beginning (, or existing ,
8919 (backward-char 1) 9476 (backward-char 1)
8920 (looking-at "[(,]"))) 9477 (looking-at "[(,]")))
@@ -8931,7 +9488,7 @@ This repairs those mis-inserted by a AUTOARG."
8931 (save-excursion 9488 (save-excursion
8932 (verilog-forward-close-paren) 9489 (verilog-forward-close-paren)
8933 (backward-char 1) 9490 (backward-char 1)
8934 (verilog-backward-syntactic-ws) 9491 (verilog-backward-syntactic-ws-quick)
8935 (backward-char 1) 9492 (backward-char 1)
8936 (when (looking-at ",") 9493 (when (looking-at ",")
8937 (delete-char 1)))) 9494 (delete-char 1))))
@@ -8978,27 +9535,68 @@ This repairs those mis-inserted by a AUTOARG."
8978 (t nil))))) 9535 (t nil)))))
8979;;(verilog-make-width-expression "`A:`B") 9536;;(verilog-make-width-expression "`A:`B")
8980 9537
8981(defun verilog-simplify-range-expression (range-exp) 9538(defun verilog-simplify-range-expression (expr)
8982 "Return a simplified range expression with constants eliminated from RANGE-EXP." 9539 "Return a simplified range expression with constants eliminated from EXPR."
8983 (let ((out range-exp) 9540 ;; Note this is always called with brackets; ie [z] or [z:z]
8984 (last-pass "")) 9541 (if (not (string-match "[---+*()]" expr))
8985 (while (not (equal last-pass out)) 9542 expr ;; short-circuit
8986 (setq last-pass out) 9543 (let ((out expr)
8987 (while (string-match "(\\<\\([0-9A-Z-az_]+\\)\\>)" out) 9544 (last-pass ""))
8988 (setq out (replace-match "\\1" nil nil out))) 9545 (while (not (equal last-pass out))
8989 (while (string-match "\\<\\([0-9]+\\)\\>\\s *\\+\\s *\\<\\([0-9]+\\)\\>" out) 9546 (setq last-pass out)
8990 (setq out (replace-match 9547 ;; Prefix regexp needs beginning of match, or some symbol of
8991 (int-to-string (+ (string-to-number (match-string 1 out)) 9548 ;; lesser or equal precedence. We assume the [:]'s exist in expr.
8992 (string-to-number (match-string 2 out)))) 9549 ;; Ditto the end.
8993 nil nil out))) 9550 (while (string-match
8994 (while (string-match "\\<\\([0-9]+\\)\\>\\s *\\-\\s *\\<\\([0-9]+\\)\\>" out) 9551 (concat "\\([[({:*+-]\\)" ; - must be last
8995 (setq out (replace-match 9552 "(\\<\\([0-9A-Za-z_]+\\))"
8996 (int-to-string (- (string-to-number (match-string 1 out)) 9553 "\\([])}:*+-]\\)")
8997 (string-to-number (match-string 2 out)))) 9554 out)
8998 nil nil out)))) 9555 (setq out (replace-match "\\1\\2\\3" nil nil out)))
8999 out)) 9556 ;; For precedence do * before +/-
9000;;(verilog-simplify-range-expression "1") 9557 (while (string-match
9001;;(verilog-simplify-range-expression "(((16)+1)-3)") 9558 (concat "\\([[({:*+-]\\)"
9559 "\\([0-9]+\\)\\s *\\([*]\\)\\s *\\([0-9]+\\)"
9560 "\\([])}:*+-]\\)")
9561 out)
9562 (setq out (replace-match
9563 (concat (match-string 1 out)
9564 (int-to-string (* (string-to-number (match-string 2 out))
9565 (string-to-number (match-string 4 out))))
9566 (match-string 5 out))
9567 nil nil out)))
9568 (while (string-match
9569 (concat "\\([[({:+-]\\)" ; No * here as higher prec
9570 "\\([0-9]+\\)\\s *\\([---+]\\)\\s *\\([0-9]+\\)"
9571 "\\([])}:+-]\\)")
9572 out)
9573 (let ((pre (match-string 1 out))
9574 (lhs (string-to-number (match-string 2 out)))
9575 (rhs (string-to-number (match-string 4 out)))
9576 (post (match-string 5 out))
9577 val)
9578 (when (equal pre "-")
9579 (setq lhs (- lhs)))
9580 (setq val (if (equal (match-string 3 out) "-")
9581 (- lhs rhs)
9582 (+ lhs rhs))
9583 out (replace-match
9584 (concat (if (and (equal pre "-")
9585 (< val 0))
9586 "" ;; Not "--20" but just "-20"
9587 pre)
9588 (int-to-string val)
9589 post)
9590 nil nil out)) )))
9591 out)))
9592;;(verilog-simplify-range-expression "[1:3]") ;; 1
9593;;(verilog-simplify-range-expression "[(1):3]") ;; 1
9594;;(verilog-simplify-range-expression "[(((16)+1)+1+(1+1))]") ;;20
9595;;(verilog-simplify-range-expression "[(2*3+6*7)]") ;; 48
9596;;(verilog-simplify-range-expression "[(FOO*4-1*2)]") ;; FOO*4-2
9597;;(verilog-simplify-range-expression "[(FOO*4+1-1)]") ;; FOO*4+0
9598;;(verilog-simplify-range-expression "[(func(BAR))]") ;; func(BAR)
9599;;(verilog-simplify-range-expression "[FOO-1+1-1+1]") ;; FOO-0
9002 9600
9003(defun verilog-typedef-name-p (variable-name) 9601(defun verilog-typedef-name-p (variable-name)
9004 "Return true if the VARIABLE-NAME is a type definition." 9602 "Return true if the VARIABLE-NAME is a type definition."
@@ -9011,15 +9609,17 @@ This repairs those mis-inserted by a AUTOARG."
9011 9609
9012(defun verilog-delete-autos-lined () 9610(defun verilog-delete-autos-lined ()
9013 "Delete autos that occupy multiple lines, between begin and end comments." 9611 "Delete autos that occupy multiple lines, between begin and end comments."
9612 ;; The newline must not have a comment property, so we must
9613 ;; delete the end auto's newline, not the first newline
9614 (forward-line 1)
9014 (let ((pt (point))) 9615 (let ((pt (point)))
9015 (forward-line 1)
9016 (when (and 9616 (when (and
9017 (looking-at "\\s-*// Beginning") 9617 (looking-at "\\s-*// Beginning")
9018 (search-forward "// End of automatic" nil t)) 9618 (search-forward "// End of automatic" nil t))
9019 ;; End exists 9619 ;; End exists
9020 (end-of-line) 9620 (end-of-line)
9021 (delete-region pt (point)) 9621 (forward-line 1)
9022 (forward-line 1)))) 9622 (delete-region pt (point)))))
9023 9623
9024(defun verilog-delete-empty-auto-pair () 9624(defun verilog-delete-empty-auto-pair ()
9025 "Delete begin/end auto pair at point, if empty." 9625 "Delete begin/end auto pair at point, if empty."
@@ -9066,11 +9666,11 @@ Ignore other open bracket with matching close bracket."
9066 9666
9067(defun verilog-delete-to-paren () 9667(defun verilog-delete-to-paren ()
9068 "Delete the automatic inst/sense/arg created by autos. 9668 "Delete the automatic inst/sense/arg created by autos.
9069Deletion stops at the matching end parenthesis." 9669Deletion stops at the matching end parenthesis, outside comments."
9070 (delete-region (point) 9670 (delete-region (point)
9071 (save-excursion 9671 (save-excursion
9072 (verilog-backward-open-paren) 9672 (verilog-backward-open-paren)
9073 (forward-sexp 1) ;; Moves to paren that closes argdecl's 9673 (verilog-forward-sexp-ign-cmt 1) ;; Moves to paren that closes argdecl's
9074 (backward-char 1) 9674 (backward-char 1)
9075 (point)))) 9675 (point))))
9076 9676
@@ -9078,7 +9678,8 @@ Deletion stops at the matching end parenthesis."
9078 "Return if a .* AUTOINST is safe to delete or expand. 9678 "Return if a .* AUTOINST is safe to delete or expand.
9079It was created by the AUTOS themselves, or by the user." 9679It was created by the AUTOS themselves, or by the user."
9080 (and verilog-auto-star-expand 9680 (and verilog-auto-star-expand
9081 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\|Interfaces\\)\\)"))) 9681 (looking-at
9682 (concat "[ \t\n\f,]*\\([)]\\|// " verilog-inst-comment-re "\\)"))))
9082 9683
9083(defun verilog-delete-auto-star-all () 9684(defun verilog-delete-auto-star-all ()
9084 "Delete a .* AUTOINST, if it is safe." 9685 "Delete a .* AUTOINST, if it is safe."
@@ -9110,7 +9711,7 @@ removed."
9110 (save-excursion 9711 (save-excursion
9111 (while (progn 9712 (while (progn
9112 (forward-line -1) 9713 (forward-line -1)
9113 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\|Interfaces\\)\n")) 9714 (looking-at (concat "\\s *//\\s *" verilog-inst-comment-re "\n")))
9114 (delete-region (match-beginning 0) (match-end 0)))) 9715 (delete-region (match-beginning 0) (match-end 0))))
9115 ;; If it is simple, we can put the ); on the same line as the last text 9716 ;; If it is simple, we can put the ); on the same line as the last text
9116 (let ((rtn-pt (point))) 9717 (let ((rtn-pt (point)))
@@ -9139,18 +9740,13 @@ called before and after this function, respectively."
9139 (verilog-save-no-change-functions 9740 (verilog-save-no-change-functions
9140 (verilog-save-scan-cache 9741 (verilog-save-scan-cache
9141 ;; Allow user to customize 9742 ;; Allow user to customize
9142 (run-hooks 'verilog-before-delete-auto-hook) 9743 (verilog-run-hooks 'verilog-before-delete-auto-hook)
9143 9744
9144 ;; Remove those that have multi-line insertions, possibly with parameters 9745 ;; Remove those that have multi-line insertions, possibly with parameters
9746 ;; We allow anything beginning with AUTO, so that users can add their own
9747 ;; patterns
9145 (verilog-auto-re-search-do 9748 (verilog-auto-re-search-do
9146 (concat "/\\*" 9749 (concat "/\\*AUTO[A-Za-z0-9_]+"
9147 (eval-when-compile
9148 (verilog-regexp-words
9149 `("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE"
9150 "AUTOINOUT" "AUTOINOUTCOMP" "AUTOINOUTMODULE"
9151 "AUTOINPUT" "AUTOINSERTLISP" "AUTOOUTPUT" "AUTOOUTPUTEVERY"
9152 "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF"
9153 "AUTOUNUSED" "AUTOWIRE")))
9154 ;; Optional parens or quoted parameter or .* for (((...))) 9750 ;; Optional parens or quoted parameter or .* for (((...)))
9155 "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?" 9751 "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?"
9156 "\\*/") 9752 "\\*/")
@@ -9169,11 +9765,11 @@ called before and after this function, respectively."
9169 'verilog-delete-auto-star-all) 9765 'verilog-delete-auto-star-all)
9170 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed 9766 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
9171 (goto-char (point-min)) 9767 (goto-char (point-min))
9172 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t) 9768 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ \tLT0-9]*\\| LHS: .*\\)?$" nil t)
9173 (replace-match "")) 9769 (replace-match ""))
9174 9770
9175 ;; Final customize 9771 ;; Final customize
9176 (run-hooks 'verilog-delete-auto-hook))))) 9772 (verilog-run-hooks 'verilog-delete-auto-hook)))))
9177 9773
9178;; 9774;;
9179;; Auto inject 9775;; Auto inject
@@ -9235,7 +9831,7 @@ Typing \\[verilog-inject-auto] will make this into:
9235 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t)) 9831 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t))
9236 (verilog-re-search-forward-quick ";" nil t) 9832 (verilog-re-search-forward-quick ";" nil t)
9237 (backward-char 1) 9833 (backward-char 1)
9238 (verilog-backward-syntactic-ws) 9834 (verilog-backward-syntactic-ws-quick)
9239 (backward-char 1) ; Moves to paren that closes argdecl's 9835 (backward-char 1) ; Moves to paren that closes argdecl's
9240 (when (looking-at ")") 9836 (when (looking-at ")")
9241 (verilog-insert "/*AUTOARG*/"))))))) 9837 (verilog-insert "/*AUTOARG*/")))))))
@@ -9251,9 +9847,9 @@ Typing \\[verilog-inject-auto] will make this into:
9251 pre-sigs 9847 pre-sigs
9252 got-sigs) 9848 got-sigs)
9253 (backward-char 1) 9849 (backward-char 1)
9254 (forward-sexp 1) 9850 (verilog-forward-sexp-ign-cmt 1)
9255 (backward-char 1) ;; End ) 9851 (backward-char 1) ;; End )
9256 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) 9852 (when (not (verilog-re-search-backward-quick "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t))
9257 (setq pre-sigs (verilog-signals-from-signame 9853 (setq pre-sigs (verilog-signals-from-signame
9258 (verilog-read-signals start-pt (point))) 9854 (verilog-read-signals start-pt (point)))
9259 got-sigs (verilog-auto-sense-sigs moddecls nil)) 9855 got-sigs (verilog-auto-sense-sigs moddecls nil))
@@ -9277,12 +9873,12 @@ Typing \\[verilog-inject-auto] will make this into:
9277 (forward-char 1) 9873 (forward-char 1)
9278 (let ((indent-pt (+ (current-column))) 9874 (let ((indent-pt (+ (current-column)))
9279 (end-pt (save-excursion (verilog-forward-close-paren) (point)))) 9875 (end-pt (save-excursion (verilog-forward-close-paren) (point))))
9280 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) 9876 (cond ((verilog-re-search-forward-quick "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t)
9281 (goto-char end-pt)) ;; Already there, continue search with next instance 9877 (goto-char end-pt)) ;; Already there, continue search with next instance
9282 (t 9878 (t
9283 ;; Delete identical interconnect 9879 ;; Delete identical interconnect
9284 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc 9880 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc
9285 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) 9881 (while (verilog-re-search-forward-quick "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t)
9286 (delete-region (match-beginning 0) (match-end 0)) 9882 (delete-region (match-beginning 0) (match-end 0))
9287 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct 9883 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct
9288 (while (or (looking-at "[ \t\n\f,]+") 9884 (while (or (looking-at "[ \t\n\f,]+")
@@ -9298,6 +9894,131 @@ Typing \\[verilog-inject-auto] will make this into:
9298 (verilog-insert-indent "/*AUTOINST*/"))))))))) 9894 (verilog-insert-indent "/*AUTOINST*/")))))))))
9299 9895
9300;; 9896;;
9897;; Auto diff
9898;;
9899
9900(defun verilog-diff-buffers-p (b1 b2 &optional whitespace)
9901 "Return nil if buffers B1 and B2 have same contents.
9902Else, return point in B1 that first mismatches.
9903If optional WHITESPACE true, ignore whitespace."
9904 (save-excursion
9905 (let* ((case-fold-search nil) ;; compare-buffer-substrings cares
9906 (p1 (with-current-buffer b1 (goto-char (point-min))))
9907 (p2 (with-current-buffer b2 (goto-char (point-min))))
9908 (maxp1 (with-current-buffer b1 (point-max)))
9909 (maxp2 (with-current-buffer b2 (point-max)))
9910 (op1 -1) (op2 -1)
9911 progress size)
9912 (while (not (and (eq p1 op1) (eq p2 op2)))
9913 ;; If both windows have whitespace optionally skip over it.
9914 (when whitespace
9915 ;; skip-syntax-* doesn't count \n
9916 (with-current-buffer b1
9917 (goto-char p1)
9918 (skip-chars-forward " \t\n\r\f\v")
9919 (setq p1 (point)))
9920 (with-current-buffer b2
9921 (goto-char p2)
9922 (skip-chars-forward " \t\n\r\f\v")
9923 (setq p2 (point))))
9924 (setq size (min (- maxp1 p1) (- maxp2 p2)))
9925 (setq progress (compare-buffer-substrings b2 p2 (+ size p2)
9926 b1 p1 (+ size p1)))
9927 (setq progress (if (zerop progress) size (1- (abs progress))))
9928 (setq op1 p1 op2 p2
9929 p1 (+ p1 progress)
9930 p2 (+ p2 progress)))
9931 ;; Return value
9932 (if (and (eq p1 maxp1) (eq p2 maxp2))
9933 nil p1))))
9934
9935(defun verilog-diff-file-with-buffer (f1 b2 &optional whitespace show)
9936 "View the differences between file F1 and buffer B2.
9937This requires the external program `diff-command' to be in your `exec-path',
9938and uses `diff-switches' in which you may want to have \"-u\" flag.
9939Ignores WHITESPACE if t, and writes output to stdout if SHOW."
9940 ;; Similar to `diff-buffer-with-file' but works on XEmacs, and doesn't
9941 ;; call `diff' as `diff' has different calling semantics on different
9942 ;; versions of Emacs.
9943 (if (not (file-exists-p f1))
9944 (message "Buffer %s has no associated file on disc" (buffer-name b2))
9945 (with-temp-buffer "*Verilog-Diff*"
9946 (let ((outbuf (current-buffer))
9947 (f2 (make-temp-file "vm-diff-auto-")))
9948 (unwind-protect
9949 (progn
9950 (with-current-buffer b2
9951 (save-restriction
9952 (widen)
9953 (write-region (point-min) (point-max) f2 nil 'nomessage)))
9954 (call-process diff-command nil outbuf t
9955 diff-switches ;; User may want -u in diff-switches
9956 (if whitespace "-b" "")
9957 f1 f2)
9958 ;; Print out results. Alternatively we could have call-processed
9959 ;; ourself, but this way we can reuse diff switches
9960 (when show
9961 (with-current-buffer outbuf (message "%s" (buffer-string))))))
9962 (sit-for 0)
9963 (when (file-exists-p f2)
9964 (delete-file f2))))))
9965
9966(defun verilog-diff-report (b1 b2 diffpt)
9967 "Report differences detected with `verilog-diff-auto'.
9968Differences are between buffers B1 and B2, starting at point
9969DIFFPT. This function is called via `verilog-diff-function'."
9970 (let ((name1 (with-current-buffer b1 (buffer-file-name))))
9971 (message "%%Warning: %s:%d: Difference in AUTO expansion found"
9972 name1 (with-current-buffer b1 (1+ (count-lines (point-min) (point)))))
9973 (cond (noninteractive
9974 (verilog-diff-file-with-buffer name1 b2 t t))
9975 (t
9976 (ediff-buffers b1 b2)))))
9977
9978(defun verilog-diff-auto ()
9979 "Expand AUTOs in a temporary buffer and indicate any changes.
9980Whitespace differences are ignored to determine identicalness, but
9981once a difference is detected, whitespace differences may be shown.
9982
9983To call this from the command line, see \\[verilog-batch-diff-auto].
9984
9985The action on differences is selected with
9986`verilog-diff-function'. The default is `verilog-diff-report'
9987which will report an error and run `ediff' in interactive mode,
9988or `diff' in batch mode."
9989 (interactive)
9990 (let ((b1 (current-buffer)) b2 diffpt
9991 (name1 (buffer-file-name))
9992 (newname "*Verilog-Diff*"))
9993 (save-excursion
9994 (when (get-buffer newname)
9995 (kill-buffer newname))
9996 (setq b2 (let (buffer-file-name) ;; Else clone is upset
9997 (clone-buffer newname)))
9998 (with-current-buffer b2
9999 ;; auto requires the filename, but can't have same filename in two
10000 ;; buffers; so override both b1 and b2's names
10001 (let ((buffer-file-name name1))
10002 (unwind-protect
10003 (progn
10004 (with-current-buffer b1 (setq buffer-file-name nil))
10005 (verilog-auto)
10006 (when (not verilog-auto-star-save)
10007 (verilog-delete-auto-star-implicit)))
10008 ;; Restore name if unwind
10009 (with-current-buffer b1 (setq buffer-file-name name1)))))
10010 ;;
10011 (setq diffpt (verilog-diff-buffers-p b1 b2 t))
10012 (cond ((not diffpt)
10013 (unless noninteractive (message "AUTO expansion identical"))
10014 (kill-buffer newname)) ;; Nice to cleanup after oneself
10015 (t
10016 (funcall verilog-diff-function b1 b2 diffpt)))
10017 ;; Return result of compare
10018 diffpt)))
10019
10020
10021;;
9301;; Auto save 10022;; Auto save
9302;; 10023;;
9303 10024
@@ -9483,14 +10204,19 @@ If PAR-VALUES replace final strings with these parameter values."
9483 (concat "\\<" (nth 0 (car check-values)) "\\>") 10204 (concat "\\<" (nth 0 (car check-values)) "\\>")
9484 (concat "(" (nth 1 (car check-values)) ")") 10205 (concat "(" (nth 1 (car check-values)) ")")
9485 t t vl-bits) 10206 t t vl-bits)
10207 vl-mbits (verilog-string-replace-matches
10208 (concat "\\<" (nth 0 (car check-values)) "\\>")
10209 (concat "(" (nth 1 (car check-values)) ")")
10210 t t vl-mbits)
9486 check-values (cdr check-values))) 10211 check-values (cdr check-values)))
9487 (setq vl-bits (verilog-simplify-range-expression vl-bits))) ; Not in the loop for speed 10212 (setq vl-bits (verilog-simplify-range-expression vl-bits)
10213 vl-mbits (verilog-simplify-range-expression vl-mbits)
10214 vl-width (verilog-make-width-expression vl-bits))) ; Not in the loop for speed
9488 ;; Default net value if not found 10215 ;; Default net value if not found
9489 (setq tpl-net (concat port 10216 (setq tpl-net (concat port
9490 (if vl-modport (concat "." vl-modport) "") 10217 (if vl-modport (concat "." vl-modport) "")
9491 (if (verilog-sig-multidim port-st) 10218 (if (verilog-sig-multidim port-st)
9492 (concat "/*" (verilog-sig-multidim-string port-st) 10219 (concat "/*" vl-mbits vl-bits "*/")
9493 vl-bits "*/")
9494 (concat vl-bits)))) 10220 (concat vl-bits))))
9495 ;; Find template 10221 ;; Find template
9496 (cond (tpl-ass ; Template of exact port name 10222 (cond (tpl-ass ; Template of exact port name
@@ -9536,20 +10262,37 @@ If PAR-VALUES replace final strings with these parameter values."
9536 (cond (tpl-ass 10262 (cond (tpl-ass
9537 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) 10263 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
9538 verilog-auto-inst-column)) 10264 verilog-auto-inst-column))
9539 (if verilog-auto-inst-template-numbers 10265 ;; verilog-insert requires the complete comment in one call - including the newline
9540 (verilog-insert " // Templated" 10266 (cond ((equal verilog-auto-inst-template-numbers `lhs)
9541 " T" (int-to-string (nth 2 tpl-ass)) 10267 (verilog-insert " // Templated"
9542 " L" (int-to-string (nth 3 tpl-ass))) 10268 " LHS: " (nth 0 tpl-ass)
9543 (verilog-insert " // Templated"))) 10269 "\n"))
10270 (verilog-auto-inst-template-numbers
10271 (verilog-insert " // Templated"
10272 " T" (int-to-string (nth 2 tpl-ass))
10273 " L" (int-to-string (nth 3 tpl-ass))
10274 "\n"))
10275 (t
10276 (verilog-insert " // Templated\n"))))
9544 (for-star 10277 (for-star
9545 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) 10278 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
9546 verilog-auto-inst-column)) 10279 verilog-auto-inst-column))
9547 (verilog-insert " // Implicit .\*"))) ;For some reason the . or * must be escaped... 10280 (verilog-insert " // Implicit .\*\n")) ;For some reason the . or * must be escaped...
9548 (insert "\n"))) 10281 (t
10282 (insert "\n")))))
9549;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") 10283;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3")
9550;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]") 10284;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]")
9551;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));") 10285;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));")
9552 10286
10287(defun verilog-auto-inst-port-list (sig-list indent-pt tpl-list tpl-num for-star par-values)
10288 "For `verilog-auto-inst' print a list of ports using `verilog-auto-inst-port'."
10289 (when verilog-auto-inst-sort
10290 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)))
10291 (mapc (lambda (port)
10292 (verilog-auto-inst-port port indent-pt
10293 tpl-list tpl-num for-star par-values))
10294 sig-list))
10295
9553(defun verilog-auto-inst-first () 10296(defun verilog-auto-inst-first ()
9554 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]." 10297 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]."
9555 ;; Do we need a trailing comma? 10298 ;; Do we need a trailing comma?
@@ -9558,7 +10301,7 @@ If PAR-VALUES replace final strings with these parameter values."
9558 ;; Insert first port on new line 10301 ;; Insert first port on new line
9559 (insert "\n") ;; Must insert before search, so point will move forward if insert comma 10302 (insert "\n") ;; Must insert before search, so point will move forward if insert comma
9560 (save-excursion 10303 (save-excursion
9561 (verilog-re-search-backward "[^ \t\n\f]" nil nil) 10304 (verilog-re-search-backward-quick "[^ \t\n\f]" nil nil)
9562 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure 10305 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure
9563 (forward-char 1) 10306 (forward-char 1)
9564 (insert ",")))) 10307 (insert ","))))
@@ -9592,6 +10335,9 @@ If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports,
9592and delete them before saving unless `verilog-auto-star-save' is set. 10335and delete them before saving unless `verilog-auto-star-save' is set.
9593See `verilog-auto-star' for more information. 10336See `verilog-auto-star' for more information.
9594 10337
10338The pins are printed in declaration order or alphabetically,
10339based on the `verilog-auto-inst-sort' variable.
10340
9595Limitations: 10341Limitations:
9596 Module names must be resolvable to filenames by adding a 10342 Module names must be resolvable to filenames by adding a
9597 `verilog-library-extensions', and being found in the same directory, or 10343 `verilog-library-extensions', and being found in the same directory, or
@@ -9719,6 +10465,22 @@ Templates:
9719 .NotInTemplate (NotInTemplate), 10465 .NotInTemplate (NotInTemplate),
9720 .ptl_bus (ptl_busnew[3:0]), // Templated 10466 .ptl_bus (ptl_busnew[3:0]), // Templated
9721 .... 10467 ....
10468
10469
10470Multiple Module Templates:
10471
10472 The same template lines can be applied to multiple modules with
10473 the syntax as follows:
10474
10475 /* InstModuleA AUTO_TEMPLATE
10476 InstModuleB AUTO_TEMPLATE
10477 InstModuleC AUTO_TEMPLATE
10478 InstModuleD AUTO_TEMPLATE (
10479 .ptl_bus (ptl_busnew[]),
10480 );
10481 */
10482
10483 Note there is only one AUTO_TEMPLATE opening parenthesis.
9722 10484
9723@ Templates: 10485@ Templates:
9724 10486
@@ -9899,18 +10661,15 @@ For more information see the \\[verilog-faq] and forums at URL
9899 ;; Find submodule's signals and dump 10661 ;; Find submodule's signals and dump
9900 (let ((sig-list (and (equal (verilog-modi-get-type submodi) "interface") 10662 (let ((sig-list (and (equal (verilog-modi-get-type submodi) "interface")
9901 (verilog-signals-not-in 10663 (verilog-signals-not-in
9902 (append (verilog-decls-get-wires submoddecls) 10664 (verilog-decls-get-vars submoddecls)
9903 (verilog-decls-get-regs submoddecls))
9904 skip-pins))) 10665 skip-pins)))
9905 (vl-dir "interfaced")) 10666 (vl-dir "interfaced"))
9906 (when sig-list 10667 (when sig-list
9907 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10668 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
9908 ;; Note these are searched for in verilog-read-sub-decls. 10669 ;; Note these are searched for in verilog-read-sub-decls.
9909 (verilog-insert-indent "// Interfaced\n") 10670 (verilog-insert-indent "// Interfaced\n")
9910 (mapc (lambda (port) 10671 (verilog-auto-inst-port-list sig-list indent-pt
9911 (verilog-auto-inst-port port indent-pt 10672 tpl-list tpl-num for-star par-values)))
9912 tpl-list tpl-num for-star par-values))
9913 sig-list)))
9914 (let ((sig-list (verilog-signals-not-in 10673 (let ((sig-list (verilog-signals-not-in
9915 (verilog-decls-get-interfaces submoddecls) 10674 (verilog-decls-get-interfaces submoddecls)
9916 skip-pins)) 10675 skip-pins))
@@ -9919,10 +10678,8 @@ For more information see the \\[verilog-faq] and forums at URL
9919 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10678 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
9920 ;; Note these are searched for in verilog-read-sub-decls. 10679 ;; Note these are searched for in verilog-read-sub-decls.
9921 (verilog-insert-indent "// Interfaces\n") 10680 (verilog-insert-indent "// Interfaces\n")
9922 (mapc (lambda (port) 10681 (verilog-auto-inst-port-list sig-list indent-pt
9923 (verilog-auto-inst-port port indent-pt 10682 tpl-list tpl-num for-star par-values)))
9924 tpl-list tpl-num for-star par-values))
9925 sig-list)))
9926 (let ((sig-list (verilog-signals-not-in 10683 (let ((sig-list (verilog-signals-not-in
9927 (verilog-decls-get-outputs submoddecls) 10684 (verilog-decls-get-outputs submoddecls)
9928 skip-pins)) 10685 skip-pins))
@@ -9930,10 +10687,8 @@ For more information see the \\[verilog-faq] and forums at URL
9930 (when sig-list 10687 (when sig-list
9931 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10688 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
9932 (verilog-insert-indent "// Outputs\n") 10689 (verilog-insert-indent "// Outputs\n")
9933 (mapc (lambda (port) 10690 (verilog-auto-inst-port-list sig-list indent-pt
9934 (verilog-auto-inst-port port indent-pt 10691 tpl-list tpl-num for-star par-values)))
9935 tpl-list tpl-num for-star par-values))
9936 sig-list)))
9937 (let ((sig-list (verilog-signals-not-in 10692 (let ((sig-list (verilog-signals-not-in
9938 (verilog-decls-get-inouts submoddecls) 10693 (verilog-decls-get-inouts submoddecls)
9939 skip-pins)) 10694 skip-pins))
@@ -9941,10 +10696,8 @@ For more information see the \\[verilog-faq] and forums at URL
9941 (when sig-list 10696 (when sig-list
9942 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10697 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
9943 (verilog-insert-indent "// Inouts\n") 10698 (verilog-insert-indent "// Inouts\n")
9944 (mapc (lambda (port) 10699 (verilog-auto-inst-port-list sig-list indent-pt
9945 (verilog-auto-inst-port port indent-pt 10700 tpl-list tpl-num for-star par-values)))
9946 tpl-list tpl-num for-star par-values))
9947 sig-list)))
9948 (let ((sig-list (verilog-signals-not-in 10701 (let ((sig-list (verilog-signals-not-in
9949 (verilog-decls-get-inputs submoddecls) 10702 (verilog-decls-get-inputs submoddecls)
9950 skip-pins)) 10703 skip-pins))
@@ -9952,10 +10705,8 @@ For more information see the \\[verilog-faq] and forums at URL
9952 (when sig-list 10705 (when sig-list
9953 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10706 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
9954 (verilog-insert-indent "// Inputs\n") 10707 (verilog-insert-indent "// Inputs\n")
9955 (mapc (lambda (port) 10708 (verilog-auto-inst-port-list sig-list indent-pt
9956 (verilog-auto-inst-port port indent-pt 10709 tpl-list tpl-num for-star par-values)))
9957 tpl-list tpl-num for-star par-values))
9958 sig-list)))
9959 ;; Kill extra semi 10710 ;; Kill extra semi
9960 (save-excursion 10711 (save-excursion
9961 (cond (did-first 10712 (cond (did-first
@@ -10058,10 +10809,8 @@ Templates:
10058 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) 10809 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
10059 ;; Note these are searched for in verilog-read-sub-decls. 10810 ;; Note these are searched for in verilog-read-sub-decls.
10060 (verilog-insert-indent "// Parameters\n") 10811 (verilog-insert-indent "// Parameters\n")
10061 (mapc (lambda (port) 10812 (verilog-auto-inst-port-list sig-list indent-pt
10062 (verilog-auto-inst-port port indent-pt 10813 tpl-list tpl-num nil nil)))
10063 tpl-list tpl-num nil nil))
10064 sig-list)))
10065 ;; Kill extra semi 10814 ;; Kill extra semi
10066 (save-excursion 10815 (save-excursion
10067 (cond (did-first 10816 (cond (did-first
@@ -10076,7 +10825,8 @@ Templates:
10076(defun verilog-auto-reg () 10825(defun verilog-auto-reg ()
10077 "Expand AUTOREG statements, as part of \\[verilog-auto]. 10826 "Expand AUTOREG statements, as part of \\[verilog-auto].
10078Make reg statements for any output that isn't already declared, 10827Make reg statements for any output that isn't already declared,
10079and isn't a wire output from a block. 10828and isn't a wire output from a block. `verilog-auto-wire-type'
10829may be used to change the datatype of the declarations.
10080 10830
10081Limitations: 10831Limitations:
10082 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). 10832 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
@@ -10111,8 +10861,7 @@ Typing \\[verilog-auto] will make this into:
10111 (modsubdecls (verilog-modi-get-sub-decls modi)) 10861 (modsubdecls (verilog-modi-get-sub-decls modi))
10112 (sig-list (verilog-signals-not-in 10862 (sig-list (verilog-signals-not-in
10113 (verilog-decls-get-outputs moddecls) 10863 (verilog-decls-get-outputs moddecls)
10114 (append (verilog-decls-get-wires moddecls) 10864 (append (verilog-decls-get-vars moddecls)
10115 (verilog-decls-get-regs moddecls)
10116 (verilog-decls-get-assigns moddecls) 10865 (verilog-decls-get-assigns moddecls)
10117 (verilog-decls-get-consts moddecls) 10866 (verilog-decls-get-consts moddecls)
10118 (verilog-decls-get-gparams moddecls) 10867 (verilog-decls-get-gparams moddecls)
@@ -10122,8 +10871,7 @@ Typing \\[verilog-auto] will make this into:
10122 (forward-line 1) 10871 (forward-line 1)
10123 (when sig-list 10872 (when sig-list
10124 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") 10873 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n")
10125 (verilog-insert-definition sig-list "reg" indent-pt nil) 10874 (verilog-insert-definition modi sig-list "reg" indent-pt nil)
10126 (verilog-modi-cache-add-regs modi sig-list)
10127 (verilog-insert-indent "// End of automatics\n"))))) 10875 (verilog-insert-indent "// End of automatics\n")))))
10128 10876
10129(defun verilog-auto-reg-input () 10877(defun verilog-auto-reg-input ()
@@ -10173,18 +10921,40 @@ Typing \\[verilog-auto] will make this into:
10173 (verilog-signals-not-in 10921 (verilog-signals-not-in
10174 (append (verilog-subdecls-get-inputs modsubdecls) 10922 (append (verilog-subdecls-get-inputs modsubdecls)
10175 (verilog-subdecls-get-inouts modsubdecls)) 10923 (verilog-subdecls-get-inouts modsubdecls))
10176 (verilog-decls-get-signals moddecls))))) 10924 (append (verilog-decls-get-signals moddecls)
10925 (verilog-decls-get-assigns moddecls))))))
10177 (forward-line 1) 10926 (forward-line 1)
10178 (when sig-list 10927 (when sig-list
10179 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") 10928 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n")
10180 (verilog-insert-definition sig-list "reg" indent-pt nil) 10929 (verilog-insert-definition modi sig-list "reg" indent-pt nil)
10181 (verilog-modi-cache-add-regs modi sig-list)
10182 (verilog-insert-indent "// End of automatics\n"))))) 10930 (verilog-insert-indent "// End of automatics\n")))))
10183 10931
10932(defun verilog-auto-logic ()
10933 "Expand AUTOLOGIC statements, as part of \\[verilog-auto].
10934Make wire statements using the SystemVerilog logic keyword.
10935This is currently equivelent to:
10936
10937 /*AUTOWIRE*/
10938
10939with the below at the bottom of the file
10940
10941 // Local Variables:
10942 // verilog-auto-logic-type:\"logic\"
10943 // End:
10944
10945In the future AUTOLOGIC may declare additional identifiers,
10946while AUTOWIRE will not."
10947 (save-excursion
10948 (unless verilog-auto-wire-type
10949 (set (make-local-variable 'verilog-auto-wire-type)
10950 "logic"))
10951 (verilog-auto-wire)))
10952
10184(defun verilog-auto-wire () 10953(defun verilog-auto-wire ()
10185 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. 10954 "Expand AUTOWIRE statements, as part of \\[verilog-auto].
10186Make wire statements for instantiations outputs that aren't 10955Make wire statements for instantiations outputs that aren't
10187already declared. 10956already declared. `verilog-auto-wire-type' may be used to change
10957the datatype of the declarations.
10188 10958
10189Limitations: 10959Limitations:
10190 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'), 10960 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'),
@@ -10240,15 +11010,13 @@ Typing \\[verilog-auto] will make this into:
10240 (forward-line 1) 11010 (forward-line 1)
10241 (when sig-list 11011 (when sig-list
10242 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") 11012 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n")
10243 (verilog-insert-definition sig-list "wire" indent-pt nil) 11013 (verilog-insert-definition modi sig-list "wire" indent-pt nil)
10244 (verilog-modi-cache-add-wires modi sig-list)
10245 (verilog-insert-indent "// End of automatics\n") 11014 (verilog-insert-indent "// End of automatics\n")
10246 (when nil ;; Too slow on huge modules, plus makes everyone's module change 11015 ;; We used to optionally call verilog-pretty-declarations and
10247 (beginning-of-line) 11016 ;; verilog-pretty-expr here, but it's too slow on huge modules,
10248 (setq pnt (point)) 11017 ;; plus makes everyone's module change. Finally those call
10249 (verilog-pretty-declarations quiet) 11018 ;; syntax-ppss which is broken when change hooks are disabled.
10250 (goto-char pnt) 11019 ))))
10251 (verilog-pretty-expr t "//"))))))
10252 11020
10253(defun verilog-auto-output (&optional with-params) 11021(defun verilog-auto-output (&optional with-params)
10254 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. 11022 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto].
@@ -10304,7 +11072,7 @@ same expansion will result from only extracting outputs starting with ov:
10304 (let* ((indent-pt (current-indentation)) 11072 (let* ((indent-pt (current-indentation))
10305 (regexp (and with-params 11073 (regexp (and with-params
10306 (nth 0 (verilog-read-auto-params 1)))) 11074 (nth 0 (verilog-read-auto-params 1))))
10307 (v2k (verilog-in-paren)) 11075 (v2k (verilog-in-paren-quick))
10308 (modi (verilog-modi-current)) 11076 (modi (verilog-modi-current))
10309 (moddecls (verilog-modi-get-decls modi)) 11077 (moddecls (verilog-modi-get-decls modi))
10310 (modsubdecls (verilog-modi-get-sub-decls modi)) 11078 (modsubdecls (verilog-modi-get-sub-decls modi))
@@ -10323,8 +11091,7 @@ same expansion will result from only extracting outputs starting with ov:
10323 (when v2k (verilog-repair-open-comma)) 11091 (when v2k (verilog-repair-open-comma))
10324 (when sig-list 11092 (when sig-list
10325 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") 11093 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n")
10326 (verilog-insert-definition sig-list "output" indent-pt v2k) 11094 (verilog-insert-definition modi sig-list "output" indent-pt v2k)
10327 (verilog-modi-cache-add-outputs modi sig-list)
10328 (verilog-insert-indent "// End of automatics\n")) 11095 (verilog-insert-indent "// End of automatics\n"))
10329 (when v2k (verilog-repair-close-comma))))) 11096 (when v2k (verilog-repair-close-comma)))))
10330 11097
@@ -10363,7 +11130,7 @@ Typing \\[verilog-auto] will make this into:
10363 (save-excursion 11130 (save-excursion
10364 ;;Point must be at insertion point 11131 ;;Point must be at insertion point
10365 (let* ((indent-pt (current-indentation)) 11132 (let* ((indent-pt (current-indentation))
10366 (v2k (verilog-in-paren)) 11133 (v2k (verilog-in-paren-quick))
10367 (modi (verilog-modi-current)) 11134 (modi (verilog-modi-current))
10368 (moddecls (verilog-modi-get-decls modi)) 11135 (moddecls (verilog-modi-get-decls modi))
10369 (sig-list (verilog-signals-combine-bus 11136 (sig-list (verilog-signals-combine-bus
@@ -10374,8 +11141,7 @@ Typing \\[verilog-auto] will make this into:
10374 (when v2k (verilog-repair-open-comma)) 11141 (when v2k (verilog-repair-open-comma))
10375 (when sig-list 11142 (when sig-list
10376 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") 11143 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n")
10377 (verilog-insert-definition sig-list "output" indent-pt v2k) 11144 (verilog-insert-definition modi sig-list "output" indent-pt v2k)
10378 (verilog-modi-cache-add-outputs modi sig-list)
10379 (verilog-insert-indent "// End of automatics\n")) 11145 (verilog-insert-indent "// End of automatics\n"))
10380 (when v2k (verilog-repair-close-comma))))) 11146 (when v2k (verilog-repair-close-comma)))))
10381 11147
@@ -10432,7 +11198,7 @@ same expansion will result from only extracting inputs starting with i:
10432 (let* ((indent-pt (current-indentation)) 11198 (let* ((indent-pt (current-indentation))
10433 (regexp (and with-params 11199 (regexp (and with-params
10434 (nth 0 (verilog-read-auto-params 1)))) 11200 (nth 0 (verilog-read-auto-params 1))))
10435 (v2k (verilog-in-paren)) 11201 (v2k (verilog-in-paren-quick))
10436 (modi (verilog-modi-current)) 11202 (modi (verilog-modi-current))
10437 (moddecls (verilog-modi-get-decls modi)) 11203 (moddecls (verilog-modi-get-decls modi))
10438 (modsubdecls (verilog-modi-get-sub-decls modi)) 11204 (modsubdecls (verilog-modi-get-sub-decls modi))
@@ -10440,8 +11206,7 @@ same expansion will result from only extracting inputs starting with i:
10440 (verilog-subdecls-get-inputs modsubdecls) 11206 (verilog-subdecls-get-inputs modsubdecls)
10441 (append (verilog-decls-get-inputs moddecls) 11207 (append (verilog-decls-get-inputs moddecls)
10442 (verilog-decls-get-inouts moddecls) 11208 (verilog-decls-get-inouts moddecls)
10443 (verilog-decls-get-wires moddecls) 11209 (verilog-decls-get-vars moddecls)
10444 (verilog-decls-get-regs moddecls)
10445 (verilog-decls-get-consts moddecls) 11210 (verilog-decls-get-consts moddecls)
10446 (verilog-decls-get-gparams moddecls) 11211 (verilog-decls-get-gparams moddecls)
10447 (verilog-subdecls-get-interfaced modsubdecls) 11212 (verilog-subdecls-get-interfaced modsubdecls)
@@ -10456,8 +11221,7 @@ same expansion will result from only extracting inputs starting with i:
10456 (when v2k (verilog-repair-open-comma)) 11221 (when v2k (verilog-repair-open-comma))
10457 (when sig-list 11222 (when sig-list
10458 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") 11223 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n")
10459 (verilog-insert-definition sig-list "input" indent-pt v2k) 11224 (verilog-insert-definition modi sig-list "input" indent-pt v2k)
10460 (verilog-modi-cache-add-inputs modi sig-list)
10461 (verilog-insert-indent "// End of automatics\n")) 11225 (verilog-insert-indent "// End of automatics\n"))
10462 (when v2k (verilog-repair-close-comma))))) 11226 (when v2k (verilog-repair-close-comma)))))
10463 11227
@@ -10514,7 +11278,7 @@ same expansion will result from only extracting inouts starting with i:
10514 (let* ((indent-pt (current-indentation)) 11278 (let* ((indent-pt (current-indentation))
10515 (regexp (and with-params 11279 (regexp (and with-params
10516 (nth 0 (verilog-read-auto-params 1)))) 11280 (nth 0 (verilog-read-auto-params 1))))
10517 (v2k (verilog-in-paren)) 11281 (v2k (verilog-in-paren-quick))
10518 (modi (verilog-modi-current)) 11282 (modi (verilog-modi-current))
10519 (moddecls (verilog-modi-get-decls modi)) 11283 (moddecls (verilog-modi-get-decls modi))
10520 (modsubdecls (verilog-modi-get-sub-decls modi)) 11284 (modsubdecls (verilog-modi-get-sub-decls modi))
@@ -10534,18 +11298,18 @@ same expansion will result from only extracting inouts starting with i:
10534 (when v2k (verilog-repair-open-comma)) 11298 (when v2k (verilog-repair-open-comma))
10535 (when sig-list 11299 (when sig-list
10536 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") 11300 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n")
10537 (verilog-insert-definition sig-list "inout" indent-pt v2k) 11301 (verilog-insert-definition modi sig-list "inout" indent-pt v2k)
10538 (verilog-modi-cache-add-inouts modi sig-list)
10539 (verilog-insert-indent "// End of automatics\n")) 11302 (verilog-insert-indent "// End of automatics\n"))
10540 (when v2k (verilog-repair-close-comma))))) 11303 (when v2k (verilog-repair-close-comma)))))
10541 11304
10542(defun verilog-auto-inout-module (&optional complement) 11305(defun verilog-auto-inout-module (&optional complement all-in)
10543 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. 11306 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto].
10544Take input/output/inout statements from the specified module and insert 11307Take input/output/inout statements from the specified module and insert
10545into the current module. This is useful for making null templates and 11308into the current module. This is useful for making null templates and
10546shell modules which need to have identical I/O with another module. 11309shell modules which need to have identical I/O with another module.
10547Any I/O which are already defined in this module will not be redefined. 11310Any I/O which are already defined in this module will not be redefined.
10548For the complement of this function, see `verilog-auto-inout-comp'. 11311For the complement of this function, see `verilog-auto-inout-comp',
11312and to make monitors with all inputs, see `verilog-auto-inout-in'.
10549 11313
10550Limitations: 11314Limitations:
10551 If placed inside the parenthesis of a module declaration, it creates 11315 If placed inside the parenthesis of a module declaration, it creates
@@ -10610,22 +11374,29 @@ against the previous example's module:
10610 ;; Note this may raise an error 11374 ;; Note this may raise an error
10611 (when (setq submodi (verilog-modi-lookup submod t)) 11375 (when (setq submodi (verilog-modi-lookup submod t))
10612 (let* ((indent-pt (current-indentation)) 11376 (let* ((indent-pt (current-indentation))
10613 (v2k (verilog-in-paren)) 11377 (v2k (verilog-in-paren-quick))
10614 (modi (verilog-modi-current)) 11378 (modi (verilog-modi-current))
10615 (moddecls (verilog-modi-get-decls modi)) 11379 (moddecls (verilog-modi-get-decls modi))
10616 (submoddecls (verilog-modi-get-decls submodi)) 11380 (submoddecls (verilog-modi-get-decls submodi))
10617 (sig-list-i (verilog-signals-not-in 11381 (sig-list-i (verilog-signals-not-in
10618 (if complement 11382 (cond (all-in
10619 (verilog-decls-get-outputs submoddecls) 11383 (append
10620 (verilog-decls-get-inputs submoddecls)) 11384 (verilog-decls-get-inputs submoddecls)
11385 (verilog-decls-get-inouts submoddecls)
11386 (verilog-decls-get-outputs submoddecls)))
11387 (complement
11388 (verilog-decls-get-outputs submoddecls))
11389 (t (verilog-decls-get-inputs submoddecls)))
10621 (append (verilog-decls-get-inputs moddecls)))) 11390 (append (verilog-decls-get-inputs moddecls))))
10622 (sig-list-o (verilog-signals-not-in 11391 (sig-list-o (verilog-signals-not-in
10623 (if complement 11392 (cond (all-in nil)
10624 (verilog-decls-get-inputs submoddecls) 11393 (complement
10625 (verilog-decls-get-outputs submoddecls)) 11394 (verilog-decls-get-inputs submoddecls))
11395 (t (verilog-decls-get-outputs submoddecls)))
10626 (append (verilog-decls-get-outputs moddecls)))) 11396 (append (verilog-decls-get-outputs moddecls))))
10627 (sig-list-io (verilog-signals-not-in 11397 (sig-list-io (verilog-signals-not-in
10628 (verilog-decls-get-inouts submoddecls) 11398 (cond (all-in nil)
11399 (t (verilog-decls-get-inouts submoddecls)))
10629 (append (verilog-decls-get-inouts moddecls)))) 11400 (append (verilog-decls-get-inouts moddecls))))
10630 (sig-list-if (verilog-signals-not-in 11401 (sig-list-if (verilog-signals-not-in
10631 (verilog-decls-get-interfaces submoddecls) 11402 (verilog-decls-get-interfaces submoddecls)
@@ -10647,13 +11418,10 @@ against the previous example's module:
10647 (when (or sig-list-i sig-list-o sig-list-io) 11418 (when (or sig-list-i sig-list-o sig-list-io)
10648 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") 11419 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n")
10649 ;; Don't sort them so a upper AUTOINST will match the main module 11420 ;; Don't sort them so a upper AUTOINST will match the main module
10650 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) 11421 (verilog-insert-definition modi sig-list-o "output" indent-pt v2k t)
10651 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t) 11422 (verilog-insert-definition modi sig-list-io "inout" indent-pt v2k t)
10652 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) 11423 (verilog-insert-definition modi sig-list-i "input" indent-pt v2k t)
10653 (verilog-insert-definition sig-list-if "interface" indent-pt v2k t) 11424 (verilog-insert-definition modi sig-list-if "interface" indent-pt v2k t)
10654 (verilog-modi-cache-add-inputs modi sig-list-i)
10655 (verilog-modi-cache-add-outputs modi sig-list-o)
10656 (verilog-modi-cache-add-inouts modi sig-list-io)
10657 (verilog-insert-indent "// End of automatics\n")) 11425 (verilog-insert-indent "// End of automatics\n"))
10658 (when v2k (verilog-repair-close-comma))))))) 11426 (when v2k (verilog-repair-close-comma)))))))
10659 11427
@@ -10707,7 +11475,58 @@ signals matching the regular expression will be included. For example the
10707same expansion will result from only extracting signals starting with i: 11475same expansion will result from only extracting signals starting with i:
10708 11476
10709 /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/" 11477 /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/"
10710 (verilog-auto-inout-module t)) 11478 (verilog-auto-inout-module t nil))
11479
11480(defun verilog-auto-inout-in ()
11481 "Expand AUTOINOUTIN statements, as part of \\[verilog-auto].
11482Take input/output/inout statements from the specified module and
11483insert them as all inputs into the current module. This is
11484useful for making monitor modules which need to see all signals
11485as inputs based on another module. Any I/O which are already
11486defined in this module will not be redefined. See also
11487`verilog-auto-inout-module'.
11488
11489Limitations:
11490 If placed inside the parenthesis of a module declaration, it creates
11491 Verilog 2001 style, else uses Verilog 1995 style.
11492
11493 Concatenation and outputting partial busses is not supported.
11494
11495 Module names must be resolvable to filenames. See `verilog-auto-inst'.
11496
11497 Signals are not inserted in the same order as in the original module,
11498 though they will appear to be in the same order to a AUTOINST
11499 instantiating either module.
11500
11501An example:
11502
11503 module ExampShell (/*AUTOARG*/);
11504 /*AUTOINOUTIN(\"ExampMain\")*/
11505 endmodule
11506
11507 module ExampMain (i,o,io);
11508 input i;
11509 output o;
11510 inout io;
11511 endmodule
11512
11513Typing \\[verilog-auto] will make this into:
11514
11515 module ExampShell (/*AUTOARG*/i,o,io);
11516 /*AUTOINOUTIN(\"ExampMain\")*/
11517 // Beginning of automatic in/out/inouts (from specific module)
11518 input i;
11519 input io;
11520 input o;
11521 // End of automatics
11522 endmodule
11523
11524You may also provide an optional regular expression, in which case only
11525signals matching the regular expression will be included. For example the
11526same expansion will result from only extracting signals starting with i:
11527
11528 /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/"
11529 (verilog-auto-inout-module nil t))
10711 11530
10712(defun verilog-auto-insert-lisp () 11531(defun verilog-auto-insert-lisp ()
10713 "Expand AUTOINSERTLISP statements, as part of \\[verilog-auto]. 11532 "Expand AUTOINSERTLISP statements, as part of \\[verilog-auto].
@@ -10756,7 +11575,7 @@ text:
10756 (forward-char) 11575 (forward-char)
10757 (point))) ;; Closing paren 11576 (point))) ;; Closing paren
10758 (cmd-beg-pt (save-excursion (goto-char cmd-end-pt) 11577 (cmd-beg-pt (save-excursion (goto-char cmd-end-pt)
10759 (backward-sexp 1) 11578 (backward-sexp 1) ;; Inside comment
10760 (point))) ;; Beginning paren 11579 (point))) ;; Beginning paren
10761 (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt))) 11580 (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt)))
10762 (forward-line 1) 11581 (forward-line 1)
@@ -10776,7 +11595,9 @@ text:
10776 (sig-list (verilog-signals-not-params 11595 (sig-list (verilog-signals-not-params
10777 (verilog-signals-not-in (verilog-alw-get-inputs sigss) 11596 (verilog-signals-not-in (verilog-alw-get-inputs sigss)
10778 (append (and (not verilog-auto-sense-include-inputs) 11597 (append (and (not verilog-auto-sense-include-inputs)
10779 (verilog-alw-get-outputs sigss)) 11598 (verilog-alw-get-outputs-delayed sigss))
11599 (and (not verilog-auto-sense-include-inputs)
11600 (verilog-alw-get-outputs-immediate sigss))
10780 (verilog-alw-get-temps sigss) 11601 (verilog-alw-get-temps sigss)
10781 (verilog-decls-get-consts moddecls) 11602 (verilog-decls-get-consts moddecls)
10782 (verilog-decls-get-gparams moddecls) 11603 (verilog-decls-get-gparams moddecls)
@@ -10840,7 +11661,7 @@ operator. (This was added to the language in part due to AUTOSENSE!)
10840 (save-excursion 11661 (save-excursion
10841 ;; Find beginning 11662 ;; Find beginning
10842 (let* ((start-pt (save-excursion 11663 (let* ((start-pt (save-excursion
10843 (verilog-re-search-backward "(" nil t) 11664 (verilog-re-search-backward-quick "(" nil t)
10844 (point))) 11665 (point)))
10845 (indent-pt (save-excursion 11666 (indent-pt (save-excursion
10846 (or (and (goto-char start-pt) (1+ (current-column))) 11667 (or (and (goto-char start-pt) (1+ (current-column)))
@@ -10848,9 +11669,7 @@ operator. (This was added to the language in part due to AUTOSENSE!)
10848 (modi (verilog-modi-current)) 11669 (modi (verilog-modi-current))
10849 (moddecls (verilog-modi-get-decls modi)) 11670 (moddecls (verilog-modi-get-decls modi))
10850 (sig-memories (verilog-signals-memory 11671 (sig-memories (verilog-signals-memory
10851 (append 11672 (verilog-decls-get-vars moddecls)))
10852 (verilog-decls-get-regs moddecls)
10853 (verilog-decls-get-wires moddecls))))
10854 sig-list not-first presense-sigs) 11673 sig-list not-first presense-sigs)
10855 ;; Read signals in always, eliminate outputs from sense list 11674 ;; Read signals in always, eliminate outputs from sense list
10856 (setq presense-sigs (verilog-signals-from-signame 11675 (setq presense-sigs (verilog-signals-from-signame
@@ -10863,11 +11682,11 @@ operator. (This was added to the language in part due to AUTOSENSE!)
10863 (if (not (eq tlen (length sig-list))) (verilog-insert " /*memory or*/ ")))) 11682 (if (not (eq tlen (length sig-list))) (verilog-insert " /*memory or*/ "))))
10864 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" 11683 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/"
10865 (save-excursion (goto-char (point)) 11684 (save-excursion (goto-char (point))
10866 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) 11685 (verilog-re-search-backward-quick "[a-zA-Z0-9$_.%`]+" start-pt t)
10867 (verilog-re-search-backward "\\s-" start-pt t) 11686 (verilog-re-search-backward-quick "\\s-" start-pt t)
10868 (while (looking-at "\\s-`endif") 11687 (while (looking-at "\\s-`endif")
10869 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) 11688 (verilog-re-search-backward-quick "[a-zA-Z0-9$_.%`]+" start-pt t)
10870 (verilog-re-search-backward "\\s-" start-pt t)) 11689 (verilog-re-search-backward-quick "\\s-" start-pt t))
10871 (not (looking-at "\\s-or\\b")))) 11690 (not (looking-at "\\s-or\\b"))))
10872 (setq not-first t)) 11691 (setq not-first t))
10873 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) 11692 (setq sig-list (sort sig-list `verilog-signals-sort-compare))
@@ -10889,9 +11708,13 @@ registers set elsewhere in the always block.
10889Limitations: 11708Limitations:
10890 AUTORESET will not clear memories. 11709 AUTORESET will not clear memories.
10891 11710
10892 AUTORESET uses <= if there are any <= assignments in the block, 11711 AUTORESET uses <= if the signal has a <= assignment in the block,
10893 else it uses =. 11712 else it uses =.
10894 11713
11714 If <= is used, all = assigned variables are ignored if
11715 `verilog-auto-reset-blocking-in-non' is nil; they are presumed
11716 to be temporaries.
11717
10895/*AUTORESET*/ presumes that any signals mentioned between the previous 11718/*AUTORESET*/ presumes that any signals mentioned between the previous
10896begin/case/if statement and the AUTORESET comment are being reset manually 11719begin/case/if statement and the AUTORESET comment are being reset manually
10897and should not be automatically reset. This includes omitting any signals 11720and should not be automatically reset. This includes omitting any signals
@@ -10927,12 +11750,12 @@ Typing \\[verilog-auto] will make this into:
10927 /*AUTORESET*/ 11750 /*AUTORESET*/
10928 // Beginning of autoreset for uninitialized flops 11751 // Beginning of autoreset for uninitialized flops
10929 a <= 0; 11752 a <= 0;
10930 b <= 0; 11753 b = 0; // if `verilog-auto-reset-blocking-in-non' true
10931 // End of automatics 11754 // End of automatics
10932 end 11755 end
10933 else begin 11756 else begin
10934 a <= in_a; 11757 a <= in_a;
10935 b <= in_b; 11758 b = in_b;
10936 c <= in_c; 11759 c <= in_c;
10937 end 11760 end
10938 end" 11761 end"
@@ -10944,22 +11767,24 @@ Typing \\[verilog-auto] will make this into:
10944 (modi (verilog-modi-current)) 11767 (modi (verilog-modi-current))
10945 (moddecls (verilog-modi-get-decls modi)) 11768 (moddecls (verilog-modi-get-decls modi))
10946 (all-list (verilog-decls-get-signals moddecls)) 11769 (all-list (verilog-decls-get-signals moddecls))
10947 sigss sig-list prereset-sigs assignment-str) 11770 sigss sig-list dly-list prereset-sigs)
10948 ;; Read signals in always, eliminate outputs from reset list 11771 ;; Read signals in always, eliminate outputs from reset list
10949 (setq prereset-sigs (verilog-signals-from-signame 11772 (setq prereset-sigs (verilog-signals-from-signame
10950 (save-excursion 11773 (save-excursion
10951 (verilog-read-signals 11774 (verilog-read-signals
10952 (save-excursion 11775 (save-excursion
10953 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t) 11776 (verilog-re-search-backward-quick "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t)
10954 (point)) 11777 (point))
10955 (point))))) 11778 (point)))))
10956 (save-excursion 11779 (save-excursion
10957 (verilog-re-search-backward "@" nil t) 11780 (verilog-re-search-backward-quick "@" nil t)
10958 (setq sigss (verilog-read-always-signals))) 11781 (setq sigss (verilog-read-always-signals)))
10959 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss) 11782 (setq dly-list (verilog-alw-get-outputs-delayed sigss))
10960 (concat " <= " verilog-assignment-delay) 11783 (setq sig-list (verilog-signals-not-in (append
10961 " = ")) 11784 (verilog-alw-get-outputs-delayed sigss)
10962 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss) 11785 (when (or (not (verilog-alw-get-uses-delayed sigss))
11786 verilog-auto-reset-blocking-in-non)
11787 (verilog-alw-get-outputs-immediate sigss)))
10963 (append 11788 (append
10964 (verilog-alw-get-temps sigss) 11789 (verilog-alw-get-temps sigss)
10965 prereset-sigs))) 11790 prereset-sigs)))
@@ -10967,17 +11792,18 @@ Typing \\[verilog-auto] will make this into:
10967 (when sig-list 11792 (when sig-list
10968 (insert "\n"); 11793 (insert "\n");
10969 (verilog-insert-indent "// Beginning of autoreset for uninitialized flops\n"); 11794 (verilog-insert-indent "// Beginning of autoreset for uninitialized flops\n");
10970 (indent-to indent-pt)
10971 (while sig-list 11795 (while sig-list
10972 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths 11796 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths
10973 (car sig-list)))) 11797 (car sig-list))))
11798 (indent-to indent-pt)
10974 (insert (verilog-sig-name sig) 11799 (insert (verilog-sig-name sig)
10975 assignment-str 11800 (if (assoc (verilog-sig-name sig) dly-list)
11801 (concat " <= " verilog-assignment-delay)
11802 " = ")
10976 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) 11803 (verilog-sig-tieoff sig (not verilog-auto-reset-widths))
10977 ";\n") 11804 ";\n")
10978 (indent-to indent-pt)
10979 (setq sig-list (cdr sig-list)))) 11805 (setq sig-list (cdr sig-list))))
10980 (verilog-insert "// End of automatics"))))) 11806 (verilog-insert-indent "// End of automatics")))))
10981 11807
10982(defun verilog-auto-tieoff () 11808(defun verilog-auto-tieoff ()
10983 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. 11809 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto].
@@ -10996,6 +11822,9 @@ them to a one.
10996You can add signals you do not want included in AUTOTIEOFF with 11822You can add signals you do not want included in AUTOTIEOFF with
10997`verilog-auto-tieoff-ignore-regexp'. 11823`verilog-auto-tieoff-ignore-regexp'.
10998 11824
11825`verilog-auto-wire-type' may be used to change the datatype of
11826the declarations.
11827
10999An example of making a stub for another module: 11828An example of making a stub for another module:
11000 11829
11001 module ExampStub (/*AUTOINST*/); 11830 module ExampStub (/*AUTOINST*/);
@@ -11031,8 +11860,7 @@ Typing \\[verilog-auto] will make this into:
11031 (modsubdecls (verilog-modi-get-sub-decls modi)) 11860 (modsubdecls (verilog-modi-get-sub-decls modi))
11032 (sig-list (verilog-signals-not-in 11861 (sig-list (verilog-signals-not-in
11033 (verilog-decls-get-outputs moddecls) 11862 (verilog-decls-get-outputs moddecls)
11034 (append (verilog-decls-get-wires moddecls) 11863 (append (verilog-decls-get-vars moddecls)
11035 (verilog-decls-get-regs moddecls)
11036 (verilog-decls-get-assigns moddecls) 11864 (verilog-decls-get-assigns moddecls)
11037 (verilog-decls-get-consts moddecls) 11865 (verilog-decls-get-consts moddecls)
11038 (verilog-decls-get-gparams moddecls) 11866 (verilog-decls-get-gparams moddecls)
@@ -11045,10 +11873,14 @@ Typing \\[verilog-auto] will make this into:
11045 (forward-line 1) 11873 (forward-line 1)
11046 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") 11874 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n")
11047 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) 11875 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare))
11048 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list 11876 (verilog-modi-cache-add-vars modi sig-list) ; Before we trash list
11049 (while sig-list 11877 (while sig-list
11050 (let ((sig (car sig-list))) 11878 (let ((sig (car sig-list)))
11051 (verilog-insert-one-definition sig "wire" indent-pt) 11879 (cond ((equal verilog-auto-tieoff-declaration "assign")
11880 (indent-to indent-pt)
11881 (insert "assign " (verilog-sig-name sig)))
11882 (t
11883 (verilog-insert-one-definition sig verilog-auto-tieoff-declaration indent-pt)))
11052 (indent-to (max 48 (+ indent-pt 40))) 11884 (indent-to (max 48 (+ indent-pt 40)))
11053 (insert "= " (verilog-sig-tieoff sig) 11885 (insert "= " (verilog-sig-tieoff sig)
11054 ";\n") 11886 ";\n")
@@ -11151,24 +11983,28 @@ comment. The comment must be between the keyword and the symbol.
11151\(Annoying, but that's what Synopsys's dc_shell FSM reader requires.) 11983\(Annoying, but that's what Synopsys's dc_shell FSM reader requires.)
11152 11984
11153Next, registers which that enum applies to are also tagged with the same 11985Next, registers which that enum applies to are also tagged with the same
11154enum. Synopsys also suggests labeling state vectors, but `verilog-mode' 11986enum.
11155doesn't care.
11156 11987
11157Finally, a AUTOASCIIENUM command is used. 11988Finally, a AUTOASCIIENUM command is used.
11158 11989
11159 The first parameter is the name of the signal to be decoded. 11990 The first parameter is the name of the signal to be decoded.
11160 If and only if the first parameter width is 2^(number of states
11161 in enum) and does NOT match the width of the enum, the signal
11162 is assumed to be a one hot decode. Otherwise, it's a normal
11163 encoded state vector.
11164 11991
11165 The second parameter is the name to store the ASCII code into. For the 11992 The second parameter is the name to store the ASCII code into. For the
11166 signal foo, I suggest the name _foo__ascii, where the leading _ indicates 11993 signal foo, I suggest the name _foo__ascii, where the leading _ indicates
11167 a signal that is just for simulation, and the magic characters _ascii 11994 a signal that is just for simulation, and the magic characters _ascii
11168 tell viewers like Dinotrace to display in ASCII format. 11995 tell viewers like Dinotrace to display in ASCII format.
11169 11996
11170 The final optional parameter is a string which will be removed from the 11997 The third optional parameter is a string which will be removed
11171 state names. 11998 from the state names. It defaults to "" which removes nothing.
11999
12000 The fourth optional parameter is \"onehot\" to force one-hot
12001 decoding. If unspecified, if and only if the first parameter
12002 width is 2^(number of states in enum) and does NOT match the
12003 width of the enum, the signal is assumed to be a one hot
12004 decode. Otherwise, it's a normal encoded state vector.
12005
12006 `verilog-auto-wire-type' may be used to change the datatype of
12007 the declarations.
11172 12008
11173An example: 12009An example:
11174 12010
@@ -11202,10 +12038,13 @@ Typing \\[verilog-auto] will make this into:
11202 end 12038 end
11203 // End of automatics" 12039 // End of automatics"
11204 (save-excursion 12040 (save-excursion
11205 (let* ((params (verilog-read-auto-params 2 3)) 12041 (let* ((params (verilog-read-auto-params 2 4))
11206 (undecode-name (nth 0 params)) 12042 (undecode-name (nth 0 params))
11207 (ascii-name (nth 1 params)) 12043 (ascii-name (nth 1 params))
11208 (elim-regexp (nth 2 params)) 12044 (elim-regexp (and (nth 2 params)
12045 (not (equal (nth 2 params) ""))
12046 (nth 2 params)))
12047 (one-hot-flag (nth 3 params))
11209 ;; 12048 ;;
11210 (indent-pt (current-indentation)) 12049 (indent-pt (current-indentation))
11211 (modi (verilog-modi-current)) 12050 (modi (verilog-modi-current))
@@ -11213,11 +12052,10 @@ Typing \\[verilog-auto] will make this into:
11213 ;; 12052 ;;
11214 (sig-list-consts (append (verilog-decls-get-consts moddecls) 12053 (sig-list-consts (append (verilog-decls-get-consts moddecls)
11215 (verilog-decls-get-gparams moddecls))) 12054 (verilog-decls-get-gparams moddecls)))
11216 (sig-list-all (append (verilog-decls-get-regs moddecls) 12055 (sig-list-all (append (verilog-decls-get-vars moddecls)
11217 (verilog-decls-get-outputs moddecls) 12056 (verilog-decls-get-outputs moddecls)
11218 (verilog-decls-get-inouts moddecls) 12057 (verilog-decls-get-inouts moddecls)
11219 (verilog-decls-get-inputs moddecls) 12058 (verilog-decls-get-inputs moddecls)))
11220 (verilog-decls-get-wires moddecls)))
11221 ;; 12059 ;;
11222 (undecode-sig (or (assoc undecode-name sig-list-all) 12060 (undecode-sig (or (assoc undecode-name sig-list-all)
11223 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) 12061 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name)))
@@ -11229,13 +12067,15 @@ Typing \\[verilog-auto] will make this into:
11229 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum)) 12067 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum))
11230 nil)) 12068 nil))
11231 ;; 12069 ;;
11232 (one-hot (and ;; width(enum) != width(sig) 12070 (one-hot (or
11233 (or (not (verilog-sig-bits (car enum-sigs))) 12071 (string-match "onehot" (or one-hot-flag ""))
11234 (not (equal (verilog-sig-width (car enum-sigs)) 12072 (and ;; width(enum) != width(sig)
11235 (verilog-sig-width undecode-sig)))) 12073 (or (not (verilog-sig-bits (car enum-sigs)))
11236 ;; count(enums) == width(sig) 12074 (not (equal (verilog-sig-width (car enum-sigs))
11237 (equal (number-to-string (length enum-sigs)) 12075 (verilog-sig-width undecode-sig))))
11238 (verilog-sig-width undecode-sig)))) 12076 ;; count(enums) == width(sig)
12077 (equal (number-to-string (length enum-sigs))
12078 (verilog-sig-width undecode-sig)))))
11239 (enum-chars 0) 12079 (enum-chars 0)
11240 (ascii-chars 0)) 12080 (ascii-chars 0))
11241 ;; 12081 ;;
@@ -11252,13 +12092,11 @@ Typing \\[verilog-auto] will make this into:
11252 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") 12092 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n")
11253 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) 12093 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1))
11254 (concat "Decode of " undecode-name) nil nil)))) 12094 (concat "Decode of " undecode-name) nil nil))))
11255 (verilog-insert-definition decode-sig-list "reg" indent-pt nil) 12095 (verilog-insert-definition modi decode-sig-list "reg" indent-pt nil))
11256 (verilog-modi-cache-add-regs modi decode-sig-list))
11257 ;; 12096 ;;
11258 (verilog-insert-indent "always @(" undecode-name ") begin\n") 12097 (verilog-insert-indent "always @(" undecode-name ") begin\n")
11259 (setq indent-pt (+ indent-pt verilog-indent-level)) 12098 (setq indent-pt (+ indent-pt verilog-indent-level))
11260 (indent-to indent-pt) 12099 (verilog-insert-indent "case ({" undecode-name "})\n")
11261 (insert "case ({" undecode-name "})\n")
11262 (setq indent-pt (+ indent-pt verilog-case-indent)) 12100 (setq indent-pt (+ indent-pt verilog-case-indent))
11263 ;; 12101 ;;
11264 (let ((tmp-sigs enum-sigs) 12102 (let ((tmp-sigs enum-sigs)
@@ -11271,7 +12109,9 @@ Typing \\[verilog-auto] will make this into:
11271 (concat 12109 (concat
11272 (format chrfmt 12110 (format chrfmt
11273 (concat (if one-hot "(") 12111 (concat (if one-hot "(")
11274 (if one-hot (verilog-sig-width undecode-sig)) 12112 ;; Use enum-sigs length as that's numeric
12113 ;; verilog-sig-width undecode-sig might not be.
12114 (if one-hot (number-to-string (length enum-sigs)))
11275 ;; We use a shift instead of var[index] 12115 ;; We use a shift instead of var[index]
11276 ;; so that a non-one hot value will show as error. 12116 ;; so that a non-one hot value will show as error.
11277 (if one-hot "'b1<<") 12117 (if one-hot "'b1<<")
@@ -11326,6 +12166,8 @@ following the /*AUTO...*/ command.
11326 12166
11327Use \\[verilog-delete-auto] to remove the AUTOs. 12167Use \\[verilog-delete-auto] to remove the AUTOs.
11328 12168
12169Use \\[verilog-diff-auto] to see differences in AUTO expansion.
12170
11329Use \\[verilog-inject-auto] to insert AUTOs for the first time. 12171Use \\[verilog-inject-auto] to insert AUTOs for the first time.
11330 12172
11331Use \\[verilog-faq] for a pointer to frequently asked questions. 12173Use \\[verilog-faq] for a pointer to frequently asked questions.
@@ -11348,11 +12190,14 @@ Or fix indentation with:
11348Likewise, you can delete or inject AUTOs with: 12190Likewise, you can delete or inject AUTOs with:
11349 emacs --batch <filenames.v> -f verilog-batch-delete-auto 12191 emacs --batch <filenames.v> -f verilog-batch-delete-auto
11350 emacs --batch <filenames.v> -f verilog-batch-inject-auto 12192 emacs --batch <filenames.v> -f verilog-batch-inject-auto
12193Or check if AUTOs have the same expansion
12194 emacs --batch <filenames.v> -f verilog-batch-diff-auto
11351 12195
11352Using \\[describe-function], see also: 12196Using \\[describe-function], see also:
11353 `verilog-auto-arg' for AUTOARG module instantiations 12197 `verilog-auto-arg' for AUTOARG module instantiations
11354 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding 12198 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding
11355 `verilog-auto-inout-comp' for AUTOINOUTCOMP copy complemented i/o 12199 `verilog-auto-inout-comp' for AUTOINOUTCOMP copy complemented i/o
12200 `verilog-auto-inout-in' for AUTOINOUTIN inputs for all i/o
11356 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere 12201 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere
11357 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts 12202 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts
11358 `verilog-auto-input' for AUTOINPUT making hierarchy inputs 12203 `verilog-auto-input' for AUTOINPUT making hierarchy inputs
@@ -11360,6 +12205,7 @@ Using \\[describe-function], see also:
11360 `verilog-auto-inst' for AUTOINST instantiation pins 12205 `verilog-auto-inst' for AUTOINST instantiation pins
11361 `verilog-auto-star' for AUTOINST .* SystemVerilog pins 12206 `verilog-auto-star' for AUTOINST .* SystemVerilog pins
11362 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params 12207 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params
12208 `verilog-auto-logic' for AUTOLOGIC declaring logic signals
11363 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs 12209 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs
11364 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs 12210 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs
11365 `verilog-auto-reg' for AUTOREG registers 12211 `verilog-auto-reg' for AUTOREG registers
@@ -11402,10 +12248,13 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11402 (verilog-save-no-change-functions 12248 (verilog-save-no-change-functions
11403 (verilog-save-scan-cache 12249 (verilog-save-scan-cache
11404 (save-excursion 12250 (save-excursion
12251 ;; Wipe cache; otherwise if we AUTOed a block above this one,
12252 ;; we'll misremember we have generated IOs, confusing AUTOOUTPUT
12253 (setq verilog-modi-cache-list nil)
11405 ;; If we're not in verilog-mode, change syntax table so parsing works right 12254 ;; If we're not in verilog-mode, change syntax table so parsing works right
11406 (unless (eq major-mode `verilog-mode) (verilog-mode)) 12255 (unless (eq major-mode `verilog-mode) (verilog-mode))
11407 ;; Allow user to customize 12256 ;; Allow user to customize
11408 (run-hooks 'verilog-before-auto-hook) 12257 (verilog-run-hooks 'verilog-before-auto-hook)
11409 ;; Try to save the user from needing to revert-file to reread file local-variables 12258 ;; Try to save the user from needing to revert-file to reread file local-variables
11410 (verilog-auto-reeval-locals) 12259 (verilog-auto-reeval-locals)
11411 (verilog-read-auto-lisp-present) 12260 (verilog-read-auto-lisp-present)
@@ -11445,6 +12294,7 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11445 ;; first in/outs from other files 12294 ;; first in/outs from other files
11446 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) 12295 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module)
11447 (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp) 12296 (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp)
12297 (verilog-auto-re-search-do "/\\*AUTOINOUTIN([^)]*)\\*/" 'verilog-auto-inout-in)
11448 ;; next in/outs which need previous sucked inputs first 12298 ;; next in/outs which need previous sucked inputs first
11449 (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/" 12299 (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/"
11450 (lambda () (verilog-auto-output t))) 12300 (lambda () (verilog-auto-output t)))
@@ -11458,6 +12308,7 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11458 ;; Then tie off those in/outs 12308 ;; Then tie off those in/outs
11459 (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff) 12309 (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff)
11460 ;; Wires/regs must be after inputs/outputs 12310 ;; Wires/regs must be after inputs/outputs
12311 (verilog-auto-re-search-do "/\\*AUTOLOGIC\\*/" 'verilog-auto-logic)
11461 (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire) 12312 (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire)
11462 (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg) 12313 (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg)
11463 (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input) 12314 (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input)
@@ -11471,7 +12322,10 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11471 (when verilog-auto-inst-template-numbers 12322 (when verilog-auto-inst-template-numbers
11472 (verilog-auto-templated-rel)))) 12323 (verilog-auto-templated-rel))))
11473 ;; 12324 ;;
11474 (run-hooks 'verilog-auto-hook) 12325 (verilog-run-hooks 'verilog-auto-hook)
12326 ;;
12327 (when verilog-auto-delete-trailing-whitespace
12328 (verilog-delete-trailing-whitespace))
11475 ;; 12329 ;;
11476 (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick)) 12330 (set (make-local-variable 'verilog-auto-update-tick) (buffer-chars-modified-tick))
11477 ;; 12331 ;;
@@ -11502,10 +12356,12 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11502 (define-key map "i" 'verilog-sk-initial) 12356 (define-key map "i" 'verilog-sk-initial)
11503 (define-key map "j" 'verilog-sk-fork) 12357 (define-key map "j" 'verilog-sk-fork)
11504 (define-key map "m" 'verilog-sk-module) 12358 (define-key map "m" 'verilog-sk-module)
12359 (define-key map "o" 'verilog-sk-ovm-class)
11505 (define-key map "p" 'verilog-sk-primitive) 12360 (define-key map "p" 'verilog-sk-primitive)
11506 (define-key map "r" 'verilog-sk-repeat) 12361 (define-key map "r" 'verilog-sk-repeat)
11507 (define-key map "s" 'verilog-sk-specify) 12362 (define-key map "s" 'verilog-sk-specify)
11508 (define-key map "t" 'verilog-sk-task) 12363 (define-key map "t" 'verilog-sk-task)
12364 (define-key map "u" 'verilog-sk-uvm-class)
11509 (define-key map "w" 'verilog-sk-while) 12365 (define-key map "w" 'verilog-sk-while)
11510 (define-key map "x" 'verilog-sk-casex) 12366 (define-key map "x" 'verilog-sk-casex)
11511 (define-key map "z" 'verilog-sk-casez) 12367 (define-key map "z" 'verilog-sk-casez)
@@ -11531,7 +12387,7 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11531;; may want to consider moving the binding to another key in your .emacs 12387;; may want to consider moving the binding to another key in your .emacs
11532;; file. 12388;; file.
11533;; 12389;;
11534;(define-key verilog-mode-map "\C-ct" verilog-template-map) 12390;; Note \C-c and letter are reserved for users
11535(define-key verilog-mode-map "\C-c\C-t" verilog-template-map) 12391(define-key verilog-mode-map "\C-c\C-t" verilog-template-map)
11536 12392
11537;;; ---- statement skeletons ------------------------------------------ 12393;;; ---- statement skeletons ------------------------------------------
@@ -11571,7 +12427,7 @@ Wilson Snyder (wsnyder@wsnyder.org)."
11571 "output: " str) 12427 "output: " str)
11572 12428
11573(define-skeleton verilog-sk-prompt-msb 12429(define-skeleton verilog-sk-prompt-msb
11574 "Prompt for least significant bit specification." 12430 "Prompt for most significant bit specification."
11575 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 ) 12431 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 )
11576 12432
11577(define-skeleton verilog-sk-prompt-lsb 12433(define-skeleton verilog-sk-prompt-lsb
@@ -11616,6 +12472,38 @@ See also `verilog-header' for an alternative format."
11616 > _ \n 12472 > _ \n
11617 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) 12473 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil))
11618 12474
12475;;; ------------------------------------------------------------------------
12476;;; Define a default OVM class, with macros and new()
12477;;; ------------------------------------------------------------------------
12478
12479(define-skeleton verilog-sk-ovm-class
12480 "Insert a class definition"
12481 ()
12482 > "class " (setq name (skeleton-read "Name: ")) " extends " (skeleton-read "Extends: ") ";" \n
12483 > _ \n
12484 > "`ovm_object_utils_begin(" name ")" \n
12485 > (- verilog-indent-level) " `ovm_object_utils_end" \n
12486 > _ \n
12487 > "function new(name=\"" name "\");" \n
12488 > "super.new(name);" \n
12489 > (- verilog-indent-level) "endfunction" \n
12490 > _ \n
12491 > "endclass" (progn (electric-verilog-terminate-line) nil))
12492
12493(define-skeleton verilog-sk-uvm-class
12494 "Insert a class definition"
12495 ()
12496 > "class " (setq name (skeleton-read "Name: ")) " extends " (skeleton-read "Extends: ") ";" \n
12497 > _ \n
12498 > "`uvm_object_utils_begin(" name ")" \n
12499 > (- verilog-indent-level) " `uvm_object_utils_end" \n
12500 > _ \n
12501 > "function new(name=\"" name "\");" \n
12502 > "super.new(name);" \n
12503 > (- verilog-indent-level) "endfunction" \n
12504 > _ \n
12505 > "endclass" (progn (electric-verilog-terminate-line) nil))
12506
11619(define-skeleton verilog-sk-primitive 12507(define-skeleton verilog-sk-primitive
11620 "Insert a task definition." 12508 "Insert a task definition."
11621 () 12509 ()
@@ -11918,10 +12806,10 @@ Clicking on the middle-mouse button loads them in a buffer (as in dired)."
11918 ;; This scanner is syntax-fragile, so don't get bent 12806 ;; This scanner is syntax-fragile, so don't get bent
11919 (when verilog-highlight-modules 12807 (when verilog-highlight-modules
11920 (condition-case nil 12808 (condition-case nil
11921 (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-point t) 12809 (while (verilog-re-search-forward-quick "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-point t)
11922 (save-excursion 12810 (save-excursion
11923 (goto-char (match-beginning 0)) 12811 (goto-char (match-beginning 0))
11924 (unless (verilog-inside-comment-p) 12812 (unless (verilog-inside-comment-or-string-p)
11925 (verilog-read-inst-module-matcher) ;; sets match 0 12813 (verilog-read-inst-module-matcher) ;; sets match 0
11926 (let* ((ov (make-overlay (match-beginning 0) (match-end 0)))) 12814 (let* ((ov (make-overlay (match-beginning 0) (match-end 0))))
11927 (overlay-put ov 'start-closed 't) 12815 (overlay-put ov 'start-closed 't)