diff options
| author | Wilson Snyder | 2017-05-08 13:44:47 -0400 |
|---|---|---|
| committer | Wilson Snyder | 2017-05-08 13:44:47 -0400 |
| commit | e93f39d2e6b56319511f778e85da32ba05359668 (patch) | |
| tree | b9eb565f3bf06e525781009828ec40789a67add0 | |
| parent | 73e3ed48e21287d48fda8d04e55f8b79b526ca50 (diff) | |
| download | emacs-e93f39d2e6b56319511f778e85da32ba05359668.tar.gz emacs-e93f39d2e6b56319511f778e85da32ba05359668.zip | |
Fix various verilog-mode.el issues.
* lisp/progmodes/verilog-mode.el (verilog-read-decls): Fix SystemVerilog
2012 import breaking AUTOINST. Reported by Johannes Schaefer.
(verilog-auto-wire-type, verilog-insert-definition): Fix AUTOWIRE using
logic in top-level non-SystemVerilog module, bug1142. Reported by Marcin K.
(verilog-define-abbrev-table) (verilog-mode-abbrev-table): Don't expand
abbrev inside comment/strings, bug1102. Reported by Slava Yuzhaninov.
(verilog-auto): Fix AUTORESET widths pulling from AUTOREGINPUT,
msg2143. Reported by Galen Seitz.
(verilog-modify-compile-command): Fix expansion of __FLAGS__ when
compile-command is globally set, bug1119. Reported by Galen Seitz.
| -rw-r--r-- | lisp/progmodes/verilog-mode.el | 91 |
1 files changed, 67 insertions, 24 deletions
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 4860ea25998..ea1ad7c064e 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el | |||
| @@ -123,7 +123,7 @@ | |||
| 123 | ;; | 123 | ;; |
| 124 | 124 | ||
| 125 | ;; This variable will always hold the version number of the mode | 125 | ;; This variable will always hold the version number of the mode |
| 126 | (defconst verilog-mode-version "2016-11-14-26d3540-vpo-GNU" | 126 | (defconst verilog-mode-version "2017-05-08-b240c8f-vpo-GNU" |
| 127 | "Version of this Verilog mode.") | 127 | "Version of this Verilog mode.") |
| 128 | (defconst verilog-mode-release-emacs t | 128 | (defconst verilog-mode-release-emacs t |
| 129 | "If non-nil, this version of Verilog mode was released with Emacs itself.") | 129 | "If non-nil, this version of Verilog mode was released with Emacs itself.") |
| @@ -387,6 +387,14 @@ wherever possible, since it is slow." | |||
| 387 | ;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) | 387 | ;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) |
| 388 | ;; "----" ["MB" nil :help "Help MB"])) | 388 | ;; "----" ["MB" nil :help "Help MB"])) |
| 389 | 389 | ||
| 390 | (defun verilog-define-abbrev-table (tablename definitions &optional docstring &rest props) | ||
| 391 | "Filter `define-abbrev-table' TABLENAME DEFINITIONS | ||
| 392 | Provides DOCSTRING PROPS in newer Emacs (23.1)." | ||
| 393 | (condition-case nil | ||
| 394 | (apply 'define-abbrev-table tablename definitions docstring props) | ||
| 395 | (error | ||
| 396 | (define-abbrev-table tablename definitions)))) | ||
| 397 | |||
| 390 | (defun verilog-define-abbrev (table name expansion &optional hook) | 398 | (defun verilog-define-abbrev (table name expansion &optional hook) |
| 391 | "Filter `define-abbrev' TABLE NAME EXPANSION and call HOOK. | 399 | "Filter `define-abbrev' TABLE NAME EXPANSION and call HOOK. |
| 392 | Provides SYSTEM-FLAG in newer Emacs." | 400 | Provides SYSTEM-FLAG in newer Emacs." |
| @@ -762,10 +770,13 @@ mode is experimental." | |||
| 762 | 770 | ||
| 763 | (defcustom verilog-auto-wire-type nil | 771 | (defcustom verilog-auto-wire-type nil |
| 764 | "Non-nil specifies the data type to use with `verilog-auto-wire' etc. | 772 | "Non-nil specifies the data type to use with `verilog-auto-wire' etc. |
| 765 | Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'." | 773 | Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'. |
| 774 | Set this to \"wire\" to force use of wire when logic is otherwise appropriate; | ||
| 775 | this is generally only appropriate when making a non-SystemVerilog wrapper | ||
| 776 | containing SystemVerilog cells." | ||
| 766 | :version "24.1" ; rev673 | 777 | :version "24.1" ; rev673 |
| 767 | :group 'verilog-mode-actions | 778 | :group 'verilog-mode-actions |
| 768 | :type 'boolean) | 779 | :type 'string) |
| 769 | (put 'verilog-auto-wire-type 'safe-local-variable `stringp) | 780 | (put 'verilog-auto-wire-type 'safe-local-variable `stringp) |
| 770 | 781 | ||
| 771 | (defcustom verilog-auto-endcomments t | 782 | (defcustom verilog-auto-endcomments t |
| @@ -1356,13 +1367,13 @@ See also `verilog-case-fold'." | |||
| 1356 | :type 'hook) | 1367 | :type 'hook) |
| 1357 | 1368 | ||
| 1358 | (defcustom verilog-before-save-font-hook nil | 1369 | (defcustom verilog-before-save-font-hook nil |
| 1359 | "Hook run before `verilog-save-font-mods' removes highlighting." | 1370 | "Hook run before `verilog-save-font-no-change-functions' removes highlighting." |
| 1360 | :version "24.3" ; rev735 | 1371 | :version "24.3" ; rev735 |
| 1361 | :group 'verilog-mode-auto | 1372 | :group 'verilog-mode-auto |
| 1362 | :type 'hook) | 1373 | :type 'hook) |
| 1363 | 1374 | ||
| 1364 | (defcustom verilog-after-save-font-hook nil | 1375 | (defcustom verilog-after-save-font-hook nil |
| 1365 | "Hook run after `verilog-save-font-mods' restores highlighting." | 1376 | "Hook run after `verilog-save-font-no-change-functions' restores highlighting." |
| 1366 | :version "24.3" ; rev735 | 1377 | :version "24.3" ; rev735 |
| 1367 | :group 'verilog-mode-auto | 1378 | :group 'verilog-mode-auto |
| 1368 | :type 'hook) | 1379 | :type 'hook) |
| @@ -1702,7 +1713,13 @@ If set will become buffer local.") | |||
| 1702 | (defvar verilog-mode-abbrev-table nil | 1713 | (defvar verilog-mode-abbrev-table nil |
| 1703 | "Abbrev table in use in Verilog-mode buffers.") | 1714 | "Abbrev table in use in Verilog-mode buffers.") |
| 1704 | 1715 | ||
| 1705 | (define-abbrev-table 'verilog-mode-abbrev-table ()) | 1716 | ;;(makunbound 'verilog-mode-abbrev-table) ; For testing, clear out old defvar |
| 1717 | (verilog-define-abbrev-table | ||
| 1718 | 'verilog-mode-abbrev-table () | ||
| 1719 | "Abbrev table for Verilog mode skeletons." | ||
| 1720 | :case-fixed t | ||
| 1721 | ;; Only expand in code. | ||
| 1722 | :enable-function (lambda () (not (verilog-in-comment-or-string-p)))) | ||
| 1706 | (verilog-define-abbrev verilog-mode-abbrev-table "class" "" 'verilog-sk-ovm-class) | 1723 | (verilog-define-abbrev verilog-mode-abbrev-table "class" "" 'verilog-sk-ovm-class) |
| 1707 | (verilog-define-abbrev verilog-mode-abbrev-table "always" "" 'verilog-sk-always) | 1724 | (verilog-define-abbrev verilog-mode-abbrev-table "always" "" 'verilog-sk-always) |
| 1708 | (verilog-define-abbrev verilog-mode-abbrev-table "begin" nil `verilog-sk-begin) | 1725 | (verilog-define-abbrev verilog-mode-abbrev-table "begin" nil `verilog-sk-begin) |
| @@ -1943,13 +1960,29 @@ be substituted." | |||
| 1943 | t t command)) | 1960 | t t command)) |
| 1944 | command) | 1961 | command) |
| 1945 | 1962 | ||
| 1963 | ;; Eliminate compile warning | ||
| 1964 | (defvar verilog-compile-command-pre-mod) | ||
| 1965 | (defvar verilog-compile-command-post-mod) | ||
| 1966 | |||
| 1946 | (defun verilog-modify-compile-command () | 1967 | (defun verilog-modify-compile-command () |
| 1947 | "Update `compile-command' using `verilog-expand-command'." | 1968 | "Update `compile-command' using `verilog-expand-command'." |
| 1948 | (when (and | 1969 | ;; Entry into verilog-mode a call to this before Local Variables exist |
| 1949 | (stringp compile-command) | 1970 | ;; Likewise user may have hook or something that changes the flags. |
| 1950 | (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command)) | 1971 | ;; So, remember we're responsible for the expansion and on re-entry |
| 1951 | (set (make-local-variable 'compile-command) | 1972 | ;; recompute __FLAGS__ on each reentry. |
| 1952 | (verilog-expand-command compile-command)))) | 1973 | (when (stringp compile-command) |
| 1974 | (when (and | ||
| 1975 | (boundp 'verilog-compile-command-post-mod) | ||
| 1976 | (equal compile-command verilog-compile-command-post-mod)) | ||
| 1977 | (setq compile-command verilog-compile-command-pre-mod)) | ||
| 1978 | (when (and | ||
| 1979 | (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command)) | ||
| 1980 | (set (make-local-variable 'verilog-compile-command-pre-mod) | ||
| 1981 | compile-command) | ||
| 1982 | (set (make-local-variable 'compile-command) | ||
| 1983 | (verilog-expand-command compile-command)) | ||
| 1984 | (set (make-local-variable 'verilog-compile-command-post-mod) | ||
| 1985 | compile-command)))) | ||
| 1953 | 1986 | ||
| 1954 | (if (featurep 'xemacs) | 1987 | (if (featurep 'xemacs) |
| 1955 | ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling. | 1988 | ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling. |
| @@ -8428,13 +8461,13 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8428 | ;;(if dbg (setq dbg (concat dbg (format "Pt %s Vec %s C%c Kwd'%s'\n" (point) vec (following-char) keywd)))) | 8461 | ;;(if dbg (setq dbg (concat dbg (format "Pt %s Vec %s C%c Kwd'%s'\n" (point) vec (following-char) keywd)))) |
| 8429 | (cond | 8462 | (cond |
| 8430 | ((looking-at "//") | 8463 | ((looking-at "//") |
| 8431 | (if (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | 8464 | (when (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") |
| 8432 | (setq enum (match-string 2))) | 8465 | (setq enum (match-string 2))) |
| 8433 | (search-forward "\n")) | 8466 | (search-forward "\n")) |
| 8434 | ((looking-at "/\\*") | 8467 | ((looking-at "/\\*") |
| 8435 | (forward-char 2) | 8468 | (forward-char 2) |
| 8436 | (if (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | 8469 | (when (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") |
| 8437 | (setq enum (match-string 2))) | 8470 | (setq enum (match-string 2))) |
| 8438 | (or (search-forward "*/") | 8471 | (or (search-forward "*/") |
| 8439 | (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | 8472 | (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) |
| 8440 | ((looking-at "(\\*") | 8473 | ((looking-at "(\\*") |
| @@ -8447,7 +8480,7 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8447 | (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | 8480 | (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) |
| 8448 | ((eq ?\; (following-char)) | 8481 | ((eq ?\; (following-char)) |
| 8449 | (cond (in-ign-to-semi ; Such as inside a "import ...;" in a module header | 8482 | (cond (in-ign-to-semi ; Such as inside a "import ...;" in a module header |
| 8450 | (setq in-ign-to-semi nil)) | 8483 | (setq in-ign-to-semi nil rvalue nil)) |
| 8451 | ((and in-modport (not (eq in-modport t))) ; end of a modport declaration | 8484 | ((and in-modport (not (eq in-modport t))) ; end of a modport declaration |
| 8452 | (verilog-modport-decls-set | 8485 | (verilog-modport-decls-set |
| 8453 | in-modport | 8486 | in-modport |
| @@ -8503,7 +8536,8 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8503 | (when (string-match "^\\\\" (match-string 1)) | 8536 | (when (string-match "^\\\\" (match-string 1)) |
| 8504 | (setq keywd (concat keywd " "))) ; Escaped ID needs space at end | 8537 | (setq keywd (concat keywd " "))) ; Escaped ID needs space at end |
| 8505 | ;; Add any :: package names to same identifier | 8538 | ;; Add any :: package names to same identifier |
| 8506 | (while (looking-at "\\s-*::\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | 8539 | ;; '*' here is for "import x::*" |
| 8540 | (while (looking-at "\\s-*::\\s-*\\(\\*\\|[a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | ||
| 8507 | (goto-char (match-end 0)) | 8541 | (goto-char (match-end 0)) |
| 8508 | (setq keywd (concat keywd "::" (match-string 1))) | 8542 | (setq keywd (concat keywd "::" (match-string 1))) |
| 8509 | (when (string-match "^\\\\" (match-string 1)) | 8543 | (when (string-match "^\\\\" (match-string 1)) |
| @@ -8568,8 +8602,8 @@ Return an array of [outputs inouts inputs wire reg assign const]." | |||
| 8568 | (not (equal last-keywd "default"))) | 8602 | (not (equal last-keywd "default"))) |
| 8569 | (setq in-clocking t)) | 8603 | (setq in-clocking t)) |
| 8570 | ((equal keywd "import") | 8604 | ((equal keywd "import") |
| 8571 | (if v2kargs-ok ; import in module header, not a modport import | 8605 | (when v2kargs-ok ; import in module header, not a modport import |
| 8572 | (setq in-ign-to-semi t rvalue t))) | 8606 | (setq in-ign-to-semi t rvalue t))) |
| 8573 | ((equal keywd "type") | 8607 | ((equal keywd "type") |
| 8574 | (setq ptype t)) | 8608 | (setq ptype t)) |
| 8575 | ((equal keywd "var")) | 8609 | ((equal keywd "var")) |
| @@ -10358,13 +10392,21 @@ When MODI is non-null, also add to modi-cache, for tracking." | |||
| 10358 | (verilog-insert-one-definition | 10392 | (verilog-insert-one-definition |
| 10359 | sig | 10393 | sig |
| 10360 | ;; Want "type x" or "output type x", not "wire type x" | 10394 | ;; Want "type x" or "output type x", not "wire type x" |
| 10361 | (cond ((or (verilog-sig-type sig) | 10395 | (cond ((and (equal "wire" verilog-auto-wire-type) |
| 10396 | (or (not (verilog-sig-type sig)) | ||
| 10397 | (equal "logic" (verilog-sig-type sig)))) | ||
| 10398 | (if (member direction '("input" "output" "inout")) | ||
| 10399 | direction | ||
| 10400 | "wire")) | ||
| 10401 | ;; | ||
| 10402 | ((or (verilog-sig-type sig) | ||
| 10362 | verilog-auto-wire-type) | 10403 | verilog-auto-wire-type) |
| 10363 | (concat | 10404 | (concat |
| 10364 | (when (member direction '("input" "output" "inout")) | 10405 | (when (member direction '("input" "output" "inout")) |
| 10365 | (concat direction " ")) | 10406 | (concat direction " ")) |
| 10366 | (or (verilog-sig-type sig) | 10407 | (or (verilog-sig-type sig) |
| 10367 | verilog-auto-wire-type))) | 10408 | verilog-auto-wire-type))) |
| 10409 | ;; | ||
| 10368 | ((and verilog-auto-declare-nettype | 10410 | ((and verilog-auto-declare-nettype |
| 10369 | (member direction '("input" "output" "inout"))) | 10411 | (member direction '("input" "output" "inout"))) |
| 10370 | (concat direction " " verilog-auto-declare-nettype)) | 10412 | (concat direction " " verilog-auto-declare-nettype)) |
| @@ -13761,9 +13803,6 @@ Wilson Snyder (wsnyder@wsnyder.org)." | |||
| 13761 | (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param) | 13803 | (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param) |
| 13762 | (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst) | 13804 | (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst) |
| 13763 | (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star) | 13805 | (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star) |
| 13764 | ;; Doesn't matter when done, but combine it with a common changer | ||
| 13765 | (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) | ||
| 13766 | (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) | ||
| 13767 | ;; Must be done before autoin/out as creates a reg | 13806 | ;; Must be done before autoin/out as creates a reg |
| 13768 | (verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 'verilog-auto-ascii-enum) | 13807 | (verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 'verilog-auto-ascii-enum) |
| 13769 | ;; | 13808 | ;; |
| @@ -13789,6 +13828,10 @@ Wilson Snyder (wsnyder@wsnyder.org)." | |||
| 13789 | (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input) | 13828 | (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input) |
| 13790 | ;; outputevery needs AUTOOUTPUTs done first | 13829 | ;; outputevery needs AUTOOUTPUTs done first |
| 13791 | (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\((.*?)\\)?\\*/" 'verilog-auto-output-every) | 13830 | (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\((.*?)\\)?\\*/" 'verilog-auto-output-every) |
| 13831 | ;; Doesn't matter when done, but combine it with a common changer | ||
| 13832 | (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) | ||
| 13833 | ;; After AUTOREG*, as they may have set signal widths | ||
| 13834 | (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) | ||
| 13792 | ;; After we've created all new variables | 13835 | ;; After we've created all new variables |
| 13793 | (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused) | 13836 | (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused) |
| 13794 | ;; Must be after all inputs outputs are generated | 13837 | ;; Must be after all inputs outputs are generated |