Update verilog-mode.el to 2015-11-09-b121d60-vpo.

* verilog-mode.el (verilog-auto, verilog-delete-auto)
(verilog-modi-cache-results, verilog-save-buffer-state)
(verilog-save-font-no-change-functions): When internally suppressing change
functions, use `inhibit-modification-hooks' and call
`after-change-funtions' to more nicely work with user hooks.  Reported by
Stefan Monnier.

(verilog-auto, verilog-delete-auto, verilog-delete-auto-buffer):
Create `verilog-delete-auto-buffer' to avoid double-calling
fontification hooks.

(verilog-restore-buffer-modified-p, verilog-auto)
(verilog-save-buffer-state): Prefer restore-buffer-modified-p over
set-buffer-modified-p. Reported by Stefan Monnier.

(verilog-diff-auto, verilog-diff-buffers-p)
(verilog-diff-ignore-regexp): Add `verilog-diff-ignore-regexp'.

(verilog-auto-inst-port, verilog-read-sub-decls-expr): Fix
AUTOINST with unpacked dimensional parameters, bug981. Reported by
by Amol Nagapurkar.

(verilog-read-decls, verilog-read-sub-decls-line): Avoid unneeded
properties inside internal structures. No functional change
intended.
This commit is contained in:
Wilson Snyder 2015-11-13 21:17:57 -05:00
parent 138ad3d93b
commit 9e00a029c4

View file

@ -123,7 +123,7 @@
;; ;;
;; This variable will always hold the version number of the mode ;; This variable will always hold the version number of the mode
(defconst verilog-mode-version "2015-09-18-314cf1d-vpo-GNU" (defconst verilog-mode-version "2015-11-09-b121d60-vpo-GNU"
"Version of this Verilog mode.") "Version of this Verilog mode.")
(defconst verilog-mode-release-emacs t (defconst verilog-mode-release-emacs t
"If non-nil, this version of Verilog mode was released with Emacs itself.") "If non-nil, this version of Verilog mode was released with Emacs itself.")
@ -230,10 +230,9 @@ STRING should be given if the last search was by `string-match' on STRING."
`(customize ,var)) `(customize ,var))
) )
(unless (boundp 'inhibit-point-motion-hooks) (defvar inhibit-modification-hooks)
(defvar inhibit-point-motion-hooks nil)) (defvar inhibit-point-motion-hooks)
(unless (boundp 'deactivate-mark) (defvar deactivate-mark)
(defvar deactivate-mark nil))
) )
;; ;;
;; OK, do this stuff if we are NOT XEmacs: ;; OK, do this stuff if we are NOT XEmacs:
@ -326,6 +325,14 @@ wherever possible, since it is slow."
(looking-at (concat "\\(?:" regexp "\\)\\'"))))) (looking-at (concat "\\(?:" regexp "\\)\\'")))))
(not (null pos))))))) (not (null pos)))))))
(eval-and-compile
(cond
((fboundp 'restore-buffer-modified-p)
;; Faster, as does not update mode line when nothing changes
(defalias 'verilog-restore-buffer-modified-p 'restore-buffer-modified-p))
(t
(defalias 'verilog-restore-buffer-modified-p 'set-buffer-modified-p))))
(eval-and-compile (eval-and-compile
;; Both xemacs and emacs ;; Both xemacs and emacs
(condition-case nil (condition-case nil
@ -827,6 +834,10 @@ Function takes three arguments, the original buffer, the
difference buffer, and the point in original buffer with the difference buffer, and the point in original buffer with the
first difference.") first difference.")
(defvar verilog-diff-ignore-regexp nil
"Non-nil specifies regexp which `verilog-diff-auto' will ignore.
This is typically nil.")
;;; Compile support: ;;; Compile support:
;; ;;
@ -2937,8 +2948,6 @@ find the errors."
(modify-syntax-entry ?> "." table) (modify-syntax-entry ?> "." table)
(modify-syntax-entry ?& "." table) (modify-syntax-entry ?& "." table)
(modify-syntax-entry ?| "." table) (modify-syntax-entry ?| "." table)
;; FIXME: This goes against Emacs conventions. Use "_" syntax instead and
;; then use regexps with things like "\\_<...\\_>".
(modify-syntax-entry ?` "w" table) ; ` is part of definition symbols in Verilog (modify-syntax-entry ?` "w" table) ; ` is part of definition symbols in Verilog
(modify-syntax-entry ?_ "w" table) (modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?\' "." table) (modify-syntax-entry ?\' "." table)
@ -3230,9 +3239,10 @@ user-visible changes to the buffer must not be within a
(buffer-undo-list t) (buffer-undo-list t)
(inhibit-read-only t) (inhibit-read-only t)
(inhibit-point-motion-hooks t) (inhibit-point-motion-hooks t)
(inhibit-modification-hooks t)
(verilog-no-change-functions t) (verilog-no-change-functions t)
before-change-functions before-change-functions ; XEmacs ignores inhibit-modification-hooks
after-change-functions after-change-functions ; XEmacs ignores inhibit-modification-hooks
deactivate-mark deactivate-mark
buffer-file-name ; Prevent primitives checking buffer-file-name ; Prevent primitives checking
buffer-file-truename) ; for file modification buffer-file-truename) ; for file modification
@ -3240,41 +3250,44 @@ user-visible changes to the buffer must not be within a
(progn ,@body) (progn ,@body)
(and (not modified) (and (not modified)
(buffer-modified-p) (buffer-modified-p)
(set-buffer-modified-p nil))))) (verilog-restore-buffer-modified-p nil)))))
(defmacro verilog-save-no-change-functions (&rest body)
"Execute BODY forms, disabling all change hooks in BODY.
For insignificant changes, see instead `verilog-save-buffer-state'."
`(let* ((inhibit-point-motion-hooks t)
(verilog-no-change-functions t)
before-change-functions
after-change-functions)
(progn ,@body)))
(defvar verilog-save-font-mod-hooked nil (defvar verilog-save-font-mod-hooked nil
"Local variable when inside a `verilog-save-font-mods' block.") "Local variable when inside a `verilog-save-font-no-change-functions' block.")
(make-variable-buffer-local 'verilog-save-font-mod-hooked) (make-variable-buffer-local 'verilog-save-font-mod-hooked)
(defmacro verilog-save-font-mods (&rest body) (defmacro verilog-save-font-no-change-functions (&rest body)
"Execute BODY forms, disabling text modifications to allow performing BODY. "Execute BODY forms, disabling all change hooks in BODY.
Includes temporary disabling of `font-lock' to restore the buffer Includes temporary disabling of `font-lock' to restore the buffer
to full text form for parsing. Additional actions may be specified with to full text form for parsing. Additional actions may be specified with
`verilog-before-save-font-hook' and `verilog-after-save-font-hook'." `verilog-before-save-font-hook' and `verilog-after-save-font-hook'.
For insignificant changes, see instead `verilog-save-buffer-state'."
`(if verilog-save-font-mod-hooked ; A recursive call?
(progn ,@body)
;; Before version 20, match-string with font-lock returns a ;; Before version 20, match-string with font-lock returns a
;; vector that is not equal to the string. IE if on "input" ;; vector that is not equal to the string. IE if on "input"
;; nil==(equal "input" (progn (looking-at "input") (match-string 0))) ;; nil==(equal "input" (progn (looking-at "input") (match-string 0)))
`(let* ((hooked (unless verilog-save-font-mod-hooked ;; Therefore we must remove and restore font-lock mode
(verilog-run-hooks 'verilog-before-save-font-hook) (verilog-run-hooks 'verilog-before-save-font-hook)
t)) (let* ((verilog-save-font-mod-hooked (- (point-max) (point-min)))
(verilog-save-font-mod-hooked t)
(fontlocked (when (and (boundp 'font-lock-mode) font-lock-mode) (fontlocked (when (and (boundp 'font-lock-mode) font-lock-mode)
(font-lock-mode 0) (font-lock-mode 0)
t))) t)))
(run-hook-with-args 'before-change-functions (point-min) (point-max))
(unwind-protect (unwind-protect
(progn ,@body) ;; Must inhibit and restore hooks before restoring font-lock
(let* ((inhibit-point-motion-hooks t)
(inhibit-modification-hooks t)
(verilog-no-change-functions t)
before-change-functions ; XEmacs ignores inhibit-modification-hooks
after-change-functions) ; XEmacs ignores inhibit-modification-hooks
(progn ,@body))
;; Unwind forms ;; Unwind forms
(run-hook-with-args 'after-change-functions (point-min) (point-max)
verilog-save-font-mod-hooked) ; old length
(when fontlocked (font-lock-mode t)) (when fontlocked (font-lock-mode t))
(when hooked (verilog-run-hooks 'verilog-after-save-font-hook))))) (verilog-run-hooks 'verilog-after-save-font-hook)))))
;; ;;
;; Comment detection and caching ;; Comment detection and caching
@ -8074,7 +8087,7 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
(when (and sv-busstring (when (and sv-busstring
(not (equal sv-busstring (verilog-sig-bits sig)))) (not (equal sv-busstring (verilog-sig-bits sig))))
(when nil ; Debugging (when nil ; Debugging
(message (concat "Warning, can't merge into single bus %s%s" (message (concat "Warning, can't merge into single bus `%s%s'"
", the AUTOs may be wrong") ", the AUTOs may be wrong")
sv-name bus)) sv-name bus))
(setq buswarn ", Couldn't Merge")) (setq buswarn ", Couldn't Merge"))
@ -8377,18 +8390,18 @@ Return an array of [outputs inouts inputs wire reg assign const]."
(setcar (cdr (cdr (cdr newsig))) (setcar (cdr (cdr (cdr newsig)))
(if (verilog-sig-memory newsig) (if (verilog-sig-memory newsig)
(concat (verilog-sig-memory newsig) (match-string 1)) (concat (verilog-sig-memory newsig) (match-string 1))
(match-string 1)))) (match-string-no-properties 1))))
(vec ; Multidimensional (vec ; Multidimensional
(setq multidim (cons vec multidim)) (setq multidim (cons vec multidim))
(setq vec (verilog-string-replace-matches (setq vec (verilog-string-replace-matches
"\\s-+" "" nil nil (match-string 1)))) "\\s-+" "" nil nil (match-string-no-properties 1))))
(t ; Bit width (t ; Bit width
(setq vec (verilog-string-replace-matches (setq vec (verilog-string-replace-matches
"\\s-+" "" nil nil (match-string 1)))))) "\\s-+" "" nil nil (match-string-no-properties 1))))))
;; Normal or escaped identifier -- note we remember the \ if escaped ;; Normal or escaped identifier -- note we remember the \ if escaped
((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
(goto-char (match-end 0)) (goto-char (match-end 0))
(setq keywd (match-string 1)) (setq keywd (match-string-no-properties 1))
(when (string-match "^\\\\" (match-string 1)) (when (string-match "^\\\\" (match-string 1))
(setq keywd (concat keywd " "))) ; Escaped ID needs space at end (setq keywd (concat keywd " "))) ; Escaped ID needs space at end
;; Add any :: package names to same identifier ;; Add any :: package names to same identifier
@ -8573,11 +8586,12 @@ Return an array of [outputs inouts inputs wire reg assign const]."
(defvar sigs-out-unk) (defvar sigs-out-unk)
(defvar sigs-temp) (defvar sigs-temp)
;; These are known to be from other packages and may not be defined ;; These are known to be from other packages and may not be defined
(defvar diff-command nil) (defvar diff-command)
;; There are known to be from newer versions of Emacs ;; There are known to be from newer versions of Emacs
(defvar create-lockfiles)) (defvar create-lockfiles)
(defvar which-func-modes))
(defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim) (defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim mem)
"For `verilog-read-sub-decls-line', add a signal." "For `verilog-read-sub-decls-line', add a signal."
;; sig eq t to indicate .name syntax ;; sig eq t to indicate .name syntax
;;(message "vrsds: %s(%S)" port sig) ;;(message "vrsds: %s(%S)" port sig)
@ -8588,6 +8602,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
(setq sig (if dotname port (verilog-symbol-detick-denumber sig))) (setq sig (if dotname port (verilog-symbol-detick-denumber sig)))
(if vec (setq vec (verilog-symbol-detick-denumber vec))) (if vec (setq vec (verilog-symbol-detick-denumber vec)))
(if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim)))
(if mem (setq mem (verilog-symbol-detick-denumber mem)))
(unless (or (not sig) (unless (or (not sig)
(equal sig "")) ; Ignore .foo(1'b1) assignments (equal sig "")) ; Ignore .foo(1'b1) assignments
(cond ((or (setq portdata (assoc port (verilog-decls-get-inouts submoddecls))) (cond ((or (setq portdata (assoc port (verilog-decls-get-inouts submoddecls)))
@ -8597,7 +8612,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
sig sig
(if dotname (verilog-sig-bits portdata) vec) (if dotname (verilog-sig-bits portdata) vec)
(concat "To/From " comment) (concat "To/From " comment)
(verilog-sig-memory portdata) mem
nil nil
(verilog-sig-signed portdata) (verilog-sig-signed portdata)
(unless (member (verilog-sig-type portdata) '("wire" "reg")) (unless (member (verilog-sig-type portdata) '("wire" "reg"))
@ -8611,7 +8626,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
sig sig
(if dotname (verilog-sig-bits portdata) vec) (if dotname (verilog-sig-bits portdata) vec)
(concat "From " comment) (concat "From " comment)
(verilog-sig-memory portdata) mem
nil nil
(verilog-sig-signed portdata) (verilog-sig-signed portdata)
;; Though ok in SV, in V2K code, propagating the ;; Though ok in SV, in V2K code, propagating the
@ -8630,7 +8645,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
sig sig
(if dotname (verilog-sig-bits portdata) vec) (if dotname (verilog-sig-bits portdata) vec)
(concat "To " comment) (concat "To " comment)
(verilog-sig-memory portdata) mem
nil nil
(verilog-sig-signed portdata) (verilog-sig-signed portdata)
(unless (member (verilog-sig-type portdata) '("wire" "reg")) (unless (member (verilog-sig-type portdata) '("wire" "reg"))
@ -8643,7 +8658,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
sig sig
(if dotname (verilog-sig-bits portdata) vec) (if dotname (verilog-sig-bits portdata) vec)
(concat "To/From " comment) (concat "To/From " comment)
(verilog-sig-memory portdata) mem
nil nil
(verilog-sig-signed portdata) (verilog-sig-signed portdata)
(verilog-sig-type portdata) (verilog-sig-type portdata)
@ -8656,7 +8671,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
sig sig
(if dotname (verilog-sig-bits portdata) vec) (if dotname (verilog-sig-bits portdata) vec)
(concat "To/From " comment) (concat "To/From " comment)
(verilog-sig-memory portdata) mem
nil nil
(verilog-sig-signed portdata) (verilog-sig-signed portdata)
(verilog-sig-type portdata) (verilog-sig-type portdata)
@ -8669,7 +8684,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
"For `verilog-read-sub-decls-line', parse a subexpression and add signals." "For `verilog-read-sub-decls-line', parse a subexpression and add signals."
;;(message "vrsde: `%s'" expr) ;;(message "vrsde: `%s'" expr)
;; Replace special /*[....]*/ comments inserted by verilog-auto-inst-port ;; Replace special /*[....]*/ comments inserted by verilog-auto-inst-port
(setq expr (verilog-string-replace-matches "/\\*\\(\\[[^*]+\\]\\)\\*/" "\\1" nil nil expr)) (setq expr (verilog-string-replace-matches "/\\*\\(\\.?\\[[^*]+\\]\\)\\*/" "\\1" nil nil expr))
;; Remove front operators ;; Remove front operators
(setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr)) (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr))
;; ;;
@ -8683,7 +8698,7 @@ Return an array of [outputs inouts inputs wire reg assign const]."
(while (setq mstr (pop mlst)) (while (setq mstr (pop mlst))
(verilog-read-sub-decls-expr submoddecls comment port mstr))))) (verilog-read-sub-decls-expr submoddecls comment port mstr)))))
(t (t
(let (sig vec multidim) (let (sig vec multidim mem)
;; Remove leading reduction operators, etc ;; Remove leading reduction operators, etc
(setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr)) (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr))
;;(message "vrsde-ptop: `%s'" expr) ;;(message "vrsde-ptop: `%s'" expr)
@ -8703,10 +8718,15 @@ Return an array of [outputs inouts inputs wire reg assign const]."
(when vec (setq multidim (cons vec multidim))) (when vec (setq multidim (cons vec multidim)))
(setq vec (match-string 1 expr) (setq vec (match-string 1 expr)
expr (substring expr (match-end 0)))) expr (substring expr (match-end 0))))
;; Find .[unpacked_memory] or .[unpacked][unpacked]...
(while (string-match "^\\s-*\\.\\(\\[[^]]+\\]\\)" expr)
;;(message "vrsde-m: `%s'" (match-string 1 expr))
(setq mem (match-string 1 expr)
expr (substring expr (match-end 0))))
;; If found signal, and nothing unrecognized, add the signal ;; If found signal, and nothing unrecognized, add the signal
;;(message "vrsde-rem: `%s'" expr) ;;(message "vrsde-rem: `%s'" expr)
(when (and sig (string-match "^\\s-*$" expr)) (when (and sig (string-match "^\\s-*$" expr))
(verilog-read-sub-decls-sig submoddecls comment port sig vec multidim)))))) (verilog-read-sub-decls-sig submoddecls comment port sig vec multidim mem))))))
(defun verilog-read-sub-decls-line (submoddecls comment) (defun verilog-read-sub-decls-line (submoddecls comment)
"For `verilog-read-sub-decls', read lines of port defs until none match. "For `verilog-read-sub-decls', read lines of port defs until none match.
@ -8717,23 +8737,23 @@ Inserts the list of signals found, using submodi to look up each port."
(while (not done) (while (not done)
;; Get port name ;; Get port name
(cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*") (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*")
(setq port (match-string 1)) (setq port (match-string-no-properties 1))
(goto-char (match-end 0))) (goto-char (match-end 0)))
;; .\escaped ( ;; .\escaped (
((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*")
(setq port (concat (match-string 1) " ")) ; escaped id's need trailing space (setq port (concat (match-string-no-properties 1) " ")) ; escaped id's need trailing space
(goto-char (match-end 0))) (goto-char (match-end 0)))
;; .name ;; .name
((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]") ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*[,)/]")
(verilog-read-sub-decls-sig (verilog-read-sub-decls-sig
submoddecls comment (match-string 1) t ; sig==t for .name submoddecls comment (match-string-no-properties 1) t ; sig==t for .name
nil nil) ; vec multidim nil nil nil) ; vec multidim mem
(setq port nil)) (setq port nil))
;; .\escaped_name ;; .\escaped_name
((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*[,)/]") ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*[,)/]")
(verilog-read-sub-decls-sig (verilog-read-sub-decls-sig
submoddecls comment (concat (match-string 1) " ") t ; sig==t for .name submoddecls comment (concat (match-string-no-properties 1) " ") t ; sig==t for .name
nil nil) ; vec multidim nil nil nil) ; vec multidim mem
(setq port nil)) (setq port nil))
;; random ;; random
((looking-at "\\s-*\\.[^(]*(") ((looking-at "\\s-*\\.[^(]*(")
@ -8748,20 +8768,20 @@ Inserts the list of signals found, using submodi to look up each port."
(cond ((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*)") (cond ((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*)")
(verilog-read-sub-decls-sig (verilog-read-sub-decls-sig
submoddecls comment port submoddecls comment port
(verilog-string-remove-spaces (match-string 1)) ; sig (verilog-string-remove-spaces (match-string-no-properties 1)) ; sig
nil nil)) ; vec multidim nil nil nil)) ; vec multidim mem
;; ;;
((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)") ((looking-at "\\([a-zA-Z_][a-zA-Z_0-9]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
(verilog-read-sub-decls-sig (verilog-read-sub-decls-sig
submoddecls comment port submoddecls comment port
(verilog-string-remove-spaces (match-string 1)) ; sig (verilog-string-remove-spaces (match-string-no-properties 1)) ; sig
(match-string 2) nil)) ; vec multidim (match-string-no-properties 2) nil nil)) ; vec multidim mem
;; Fastpath was above looking-at's. ;; Fastpath was above looking-at's.
;; For something more complicated invoke a parser ;; For something more complicated invoke a parser
((looking-at "[^)]+") ((looking-at "[^)]+")
(verilog-read-sub-decls-expr (verilog-read-sub-decls-expr
submoddecls comment port submoddecls comment port
(buffer-substring (buffer-substring-no-properties
(point) (1- (progn (search-backward "(") ; start at ( (point) (1- (progn (search-backward "(") ; start at (
(verilog-forward-sexp-ign-cmt 1) (verilog-forward-sexp-ign-cmt 1)
(point)))))))) ; expr (point)))))))) ; expr
@ -9894,7 +9914,7 @@ Return modi if successful, else print message unless IGNORE-ERROR is true."
(or mif ignore-error (or mif ignore-error
(error (error
(concat (concat
"%s: Can't locate %s module definition%s" "%s: Can't locate `%s' module definition%s"
"\n Check the verilog-library-directories variable." "\n Check the verilog-library-directories variable."
"\n I looked in (if not listed, doesn't exist):\n\t%s") "\n I looked in (if not listed, doesn't exist):\n\t%s")
(verilog-point-text) module (verilog-point-text) module
@ -9959,9 +9979,9 @@ Cache the output of function so next call may have faster access."
(t (t
;; Read from file ;; Read from file
;; Clear then restore any highlighting to make emacs19 happy ;; Clear then restore any highlighting to make emacs19 happy
(let (func-returns) (let ((func-returns
(verilog-save-font-mods (verilog-save-font-no-change-functions
(setq func-returns (funcall function))) (funcall function))))
;; Cache for next time ;; Cache for next time
(setq verilog-modi-cache-list (setq verilog-modi-cache-list
(cons (list (list modi function) (cons (list (list modi function)
@ -10003,7 +10023,7 @@ Report errors unless optional IGNORE-ERROR."
(let* ((realname (verilog-symbol-detick name t)) (let* ((realname (verilog-symbol-detick name t))
(modport (assoc name (verilog-decls-get-modports (verilog-modi-get-decls modi))))) (modport (assoc name (verilog-decls-get-modports (verilog-modi-get-decls modi)))))
(or modport ignore-error (or modport ignore-error
(error "%s: Can't locate %s modport definition%s" (error "%s: Can't locate `%s' modport definition%s"
(verilog-point-text) name (verilog-point-text) name
(if (not (equal name realname)) (if (not (equal name realname))
(concat " (Expanded macro to " realname ")") (concat " (Expanded macro to " realname ")")
@ -10193,7 +10213,7 @@ When MODI is non-null, also add to modi-cache, for tracking."
((equal direction "parameter") ((equal direction "parameter")
(verilog-modi-cache-add-gparams modi sigs)) (verilog-modi-cache-add-gparams modi sigs))
(t (t
(error "Unsupported verilog-insert-definition direction: %s" direction)))) (error "Unsupported verilog-insert-definition direction: `%s'" direction))))
(or dont-sort (or dont-sort
(setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare)))
(while sigs (while sigs
@ -10224,7 +10244,7 @@ When MODI is non-null, also add to modi-cache, for tracking."
(eval-when-compile (eval-when-compile
(if (not (boundp 'indent-pt)) (if (not (boundp 'indent-pt))
(defvar indent-pt nil "Local used by insert-indent"))) (defvar indent-pt nil "Local used by `verilog-insert-indent'.")))
(defun verilog-insert-indent (&rest stuff) (defun verilog-insert-indent (&rest stuff)
"Indent to position stored in local `indent-pt' variable, then insert STUFF. "Indent to position stored in local `indent-pt' variable, then insert STUFF.
@ -10510,18 +10530,9 @@ removed."
(re-search-backward ",") (re-search-backward ",")
(delete-char 1)))))) (delete-char 1))))))
(defun verilog-delete-auto () (defun verilog-delete-auto-buffer ()
"Delete the automatic outputs, regs, and wires created by \\[verilog-auto]. "Perform `verilog-delete-auto' on the current buffer.
Use \\[verilog-auto] to re-insert the updated AUTOs. Intended for internal use inside a `verilog-save-font-no-change-functions' block."
The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are
called before and after this function, respectively."
(interactive)
(save-excursion
(if (buffer-file-name)
(find-file-noselect (buffer-file-name))) ; To check we have latest version
(verilog-save-no-change-functions
(verilog-save-scan-cache
;; Allow user to customize ;; Allow user to customize
(verilog-run-hooks 'verilog-before-delete-auto-hook) (verilog-run-hooks 'verilog-before-delete-auto-hook)
@ -10552,7 +10563,22 @@ called before and after this function, respectively."
(replace-match "")) (replace-match ""))
;; Final customize ;; Final customize
(verilog-run-hooks 'verilog-delete-auto-hook))))) (verilog-run-hooks 'verilog-delete-auto-hook))
(defun verilog-delete-auto ()
"Delete the automatic outputs, regs, and wires created by \\[verilog-auto].
Use \\[verilog-auto] to re-insert the updated AUTOs.
The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are
called before and after this function, respectively."
(interactive)
(save-excursion
(if (buffer-file-name)
(find-file-noselect (buffer-file-name))) ; To check we have latest version
(verilog-save-font-no-change-functions
(verilog-save-scan-cache
(verilog-delete-auto-buffer)))))
;;; Auto inject: ;;; Auto inject:
;; ;;
@ -10679,10 +10705,11 @@ Typing \\[verilog-inject-auto] will make this into:
;; Auto diff: ;; Auto diff:
;; ;;
(defun verilog-diff-buffers-p (b1 b2 &optional whitespace) (defun verilog-diff-buffers-p (b1 b2 &optional whitespace regexp)
"Return nil if buffers B1 and B2 have same contents. "Return nil if buffers B1 and B2 have same contents.
Else, return point in B1 that first mismatches. Else, return point in B1 that first mismatches.
If optional WHITESPACE true, ignore whitespace." If optional WHITESPACE true, ignore whitespace.
If optional REGEXP, ignore differences matching it."
(save-excursion (save-excursion
(let* ((case-fold-search nil) ; compare-buffer-substrings cares (let* ((case-fold-search nil) ; compare-buffer-substrings cares
(p1 (with-current-buffer b1 (goto-char (point-min)))) (p1 (with-current-buffer b1 (goto-char (point-min))))
@ -10703,6 +10730,15 @@ If optional WHITESPACE true, ignore whitespace."
(goto-char p2) (goto-char p2)
(skip-chars-forward " \t\n\r\f\v") (skip-chars-forward " \t\n\r\f\v")
(setq p2 (point)))) (setq p2 (point))))
(when regexp
(with-current-buffer b1
(goto-char p1)
(when (looking-at regexp)
(setq p1 (match-end 0))))
(with-current-buffer b2
(goto-char p2)
(when (looking-at regexp)
(setq p2 (match-end 0)))))
(setq size (min (- maxp1 p1) (- maxp2 p2))) (setq size (min (- maxp1 p1) (- maxp2 p2)))
(setq progress (compare-buffer-substrings b2 p2 (+ size p2) (setq progress (compare-buffer-substrings b2 p2 (+ size p2)
b1 p1 (+ size p1))) b1 p1 (+ size p1)))
@ -10723,7 +10759,7 @@ Ignores WHITESPACE if t, and writes output to stdout if SHOW."
;; call `diff' as `diff' has different calling semantics on different ;; call `diff' as `diff' has different calling semantics on different
;; versions of Emacs. ;; versions of Emacs.
(if (not (file-exists-p f1)) (if (not (file-exists-p f1))
(message "Buffer %s has no associated file on disc" (buffer-name b2)) (message "Buffer `%s' has no associated file on disk" (buffer-name b2))
(with-temp-buffer "*Verilog-Diff*" (with-temp-buffer "*Verilog-Diff*"
(let ((outbuf (current-buffer)) (let ((outbuf (current-buffer))
(f2 (make-temp-file "vm-diff-auto-"))) (f2 (make-temp-file "vm-diff-auto-")))
@ -10791,7 +10827,7 @@ or `diff' in batch mode."
;; Restore name if unwind ;; Restore name if unwind
(with-current-buffer b1 (setq buffer-file-name name1))))) (with-current-buffer b1 (setq buffer-file-name name1)))))
;; ;;
(setq diffpt (verilog-diff-buffers-p b1 b2 t)) (setq diffpt (verilog-diff-buffers-p b1 b2 t verilog-diff-ignore-regexp))
(cond ((not diffpt) (cond ((not diffpt)
(unless noninteractive (message "AUTO expansion identical")) (unless noninteractive (message "AUTO expansion identical"))
(kill-buffer newname)) ; Nice to cleanup after oneself (kill-buffer newname)) ; Nice to cleanup after oneself
@ -11054,6 +11090,7 @@ If PAR-VALUES replace final strings with these parameter values."
(vl-name (verilog-sig-name port-st)) (vl-name (verilog-sig-name port-st))
(vl-width (verilog-sig-width port-st)) (vl-width (verilog-sig-width port-st))
(vl-modport (verilog-sig-modport port-st)) (vl-modport (verilog-sig-modport port-st))
(vl-memory (verilog-sig-memory port-st))
(vl-mbits (if (verilog-sig-multidim port-st) (vl-mbits (if (verilog-sig-multidim port-st)
(verilog-sig-multidim-string port-st) "")) (verilog-sig-multidim-string port-st) ""))
(vl-bits (if (or verilog-auto-inst-vector (vl-bits (if (or verilog-auto-inst-vector
@ -11078,15 +11115,25 @@ If PAR-VALUES replace final strings with these parameter values."
(concat "\\<" (nth 0 (car check-values)) "\\>") (concat "\\<" (nth 0 (car check-values)) "\\>")
(concat "(" (nth 1 (car check-values)) ")") (concat "(" (nth 1 (car check-values)) ")")
t t vl-mbits) t t vl-mbits)
vl-memory (when vl-memory
(verilog-string-replace-matches
(concat "\\<" (nth 0 (car check-values)) "\\>")
(concat "(" (nth 1 (car check-values)) ")")
t t vl-memory))
check-values (cdr check-values))) check-values (cdr check-values)))
(setq vl-bits (verilog-simplify-range-expression vl-bits) (setq vl-bits (verilog-simplify-range-expression vl-bits)
vl-mbits (verilog-simplify-range-expression vl-mbits) vl-mbits (verilog-simplify-range-expression vl-mbits)
vl-memory (when vl-memory (verilog-simplify-range-expression vl-memory))
vl-width (verilog-make-width-expression vl-bits))) ; Not in the loop for speed vl-width (verilog-make-width-expression vl-bits))) ; Not in the loop for speed
;; Default net value if not found ;; Default net value if not found
(setq dflt-bits (if (and (verilog-sig-bits port-st) (setq dflt-bits (if (or (and (verilog-sig-bits port-st)
(or (verilog-sig-multidim port-st) (verilog-sig-multidim port-st))
(verilog-sig-memory port-st))) (verilog-sig-memory port-st))
(concat "/*" vl-mbits vl-bits "*/") (concat "/*" vl-mbits vl-bits
;; .[ used to separate packed from unpacked
(if vl-memory "." "")
(if vl-memory vl-memory "")
"*/")
(concat vl-bits)) (concat vl-bits))
tpl-net (concat port tpl-net (concat port
(if (and vl-modport (if (and vl-modport
@ -11157,7 +11204,7 @@ If PAR-VALUES replace final strings with these parameter values."
(for-star (for-star
(indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
verilog-auto-inst-column)) verilog-auto-inst-column))
(verilog-insert " // Implicit .\*\n")) ;For some reason the . or * must be escaped... (verilog-insert " // Implicit .*\n"))
(t (t
(insert "\n"))))) (insert "\n")))))
;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3")
@ -13316,13 +13363,16 @@ Typing \\[verilog-auto] will make this into:
(sig-list-all (verilog-decls-get-iovars moddecls)) (sig-list-all (verilog-decls-get-iovars moddecls))
;; ;;
(undecode-sig (or (assoc undecode-name sig-list-all) (undecode-sig (or (assoc undecode-name sig-list-all)
(error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) (error "%s: Signal `%s' not found in design"
(verilog-point-text) undecode-name)))
(undecode-enum (or (verilog-sig-enum undecode-sig) (undecode-enum (or (verilog-sig-enum undecode-sig)
(error "%s: Signal %s does not have an enum tag" (verilog-point-text) undecode-name))) (error "%s: Signal `%s' does not have an enum tag"
(verilog-point-text) undecode-name)))
;; ;;
(enum-sigs (verilog-signals-not-in (enum-sigs (verilog-signals-not-in
(or (verilog-signals-matching-enum sig-list-consts undecode-enum) (or (verilog-signals-matching-enum sig-list-consts undecode-enum)
(error "%s: No state definitions for %s" (verilog-point-text) undecode-enum)) (error "%s: No state definitions for `%s'"
(verilog-point-text) undecode-enum))
nil)) nil))
;; ;;
(one-hot (or (one-hot (or
@ -13518,7 +13568,10 @@ Wilson Snyder (wsnyder@wsnyder.org)."
(unless noninteractive (message "Updating AUTOs...")) (unless noninteractive (message "Updating AUTOs..."))
(if (fboundp 'dinotrace-unannotate-all) (if (fboundp 'dinotrace-unannotate-all)
(dinotrace-unannotate-all)) (dinotrace-unannotate-all))
(verilog-save-font-mods ;; Disable change hooks for speed
;; This let can't be part of above let; must restore
;; after-change-functions before font-lock resumes
(verilog-save-font-no-change-functions
(let ((oldbuf (if (not (buffer-modified-p)) (let ((oldbuf (if (not (buffer-modified-p))
(buffer-string))) (buffer-string)))
(case-fold-search verilog-case-fold) (case-fold-search verilog-case-fold)
@ -13528,11 +13581,6 @@ Wilson Snyder (wsnyder@wsnyder.org)."
(verilog-modi-cache-current-enable t) (verilog-modi-cache-current-enable t)
(verilog-modi-cache-current-max (point-min)) ; IE it's invalid (verilog-modi-cache-current-max (point-min)) ; IE it's invalid
verilog-modi-cache-current) verilog-modi-cache-current)
(unwind-protect
;; Disable change hooks for speed
;; This let can't be part of above let; must restore
;; after-change-functions before font-lock resumes
(verilog-save-no-change-functions
(verilog-save-scan-cache (verilog-save-scan-cache
(save-excursion (save-excursion
;; Wipe cache; otherwise if we AUTOed a block above this one, ;; Wipe cache; otherwise if we AUTOed a block above this one,
@ -13561,7 +13609,7 @@ Wilson Snyder (wsnyder@wsnyder.org)."
;; INST: Lower modules correct, no internal dependencies, FIRST ;; INST: Lower modules correct, no internal dependencies, FIRST
(verilog-preserve-modi-cache (verilog-preserve-modi-cache
;; Clear existing autos else we'll be screwed by existing ones ;; Clear existing autos else we'll be screwed by existing ones
(verilog-delete-auto) (verilog-delete-auto-buffer)
;; Injection if appropriate ;; Injection if appropriate
(when inject (when inject
(verilog-inject-inst) (verilog-inject-inst)
@ -13624,14 +13672,11 @@ Wilson Snyder (wsnyder@wsnyder.org)."
;; ;;
;; If end result is same as when started, clear modified flag ;; If end result is same as when started, clear modified flag
(cond ((and oldbuf (equal oldbuf (buffer-string))) (cond ((and oldbuf (equal oldbuf (buffer-string)))
(set-buffer-modified-p nil) (verilog-restore-buffer-modified-p nil)
(unless noninteractive (message "Updating AUTOs...done (no changes)"))) (unless noninteractive (message "Updating AUTOs...done (no changes)")))
(t (unless noninteractive (message "Updating AUTOs...done")))) (t (unless noninteractive (message "Updating AUTOs...done"))))
;; End of after-change protection ;; End of save-cache
))) )))))
;; Unwind forms
;; Currently handled in verilog-save-font-mods
))))
;;; Skeletons: ;;; Skeletons:
;; ;;