;;
;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "2016-11-14-26d3540-vpo-GNU"
+(defconst verilog-mode-version "2017-05-08-b240c8f-vpo-GNU"
"Version of this Verilog mode.")
(defconst verilog-mode-release-emacs t
"If non-nil, this version of Verilog mode was released with Emacs itself.")
;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"])
;; "----" ["MB" nil :help "Help MB"]))
+(defun verilog-define-abbrev-table (tablename definitions &optional docstring &rest props)
+ "Filter `define-abbrev-table' TABLENAME DEFINITIONS
+Provides DOCSTRING PROPS in newer Emacs (23.1)."
+ (condition-case nil
+ (apply 'define-abbrev-table tablename definitions docstring props)
+ (error
+ (define-abbrev-table tablename definitions))))
+
(defun verilog-define-abbrev (table name expansion &optional hook)
"Filter `define-abbrev' TABLE NAME EXPANSION and call HOOK.
Provides SYSTEM-FLAG in newer Emacs."
(defcustom verilog-auto-wire-type nil
"Non-nil specifies the data type to use with `verilog-auto-wire' etc.
-Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'."
+Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'.
+Set this to \"wire\" to force use of wire when logic is otherwise appropriate;
+this is generally only appropriate when making a non-SystemVerilog wrapper
+containing SystemVerilog cells."
:version "24.1" ; rev673
:group 'verilog-mode-actions
- :type 'boolean)
+ :type 'string)
(put 'verilog-auto-wire-type 'safe-local-variable `stringp)
(defcustom verilog-auto-endcomments t
:type 'hook)
(defcustom verilog-before-save-font-hook nil
- "Hook run before `verilog-save-font-mods' removes highlighting."
+ "Hook run before `verilog-save-font-no-change-functions' removes highlighting."
:version "24.3" ; rev735
:group 'verilog-mode-auto
:type 'hook)
(defcustom verilog-after-save-font-hook nil
- "Hook run after `verilog-save-font-mods' restores highlighting."
+ "Hook run after `verilog-save-font-no-change-functions' restores highlighting."
:version "24.3" ; rev735
:group 'verilog-mode-auto
:type 'hook)
(defvar verilog-mode-abbrev-table nil
"Abbrev table in use in Verilog-mode buffers.")
-(define-abbrev-table 'verilog-mode-abbrev-table ())
+;;(makunbound 'verilog-mode-abbrev-table) ; For testing, clear out old defvar
+(verilog-define-abbrev-table
+ 'verilog-mode-abbrev-table ()
+ "Abbrev table for Verilog mode skeletons."
+ :case-fixed t
+ ;; Only expand in code.
+ :enable-function (lambda () (not (verilog-in-comment-or-string-p))))
(verilog-define-abbrev verilog-mode-abbrev-table "class" "" 'verilog-sk-ovm-class)
(verilog-define-abbrev verilog-mode-abbrev-table "always" "" 'verilog-sk-always)
(verilog-define-abbrev verilog-mode-abbrev-table "begin" nil `verilog-sk-begin)
t t command))
command)
+;; Eliminate compile warning
+(defvar verilog-compile-command-pre-mod)
+(defvar verilog-compile-command-post-mod)
+
(defun verilog-modify-compile-command ()
"Update `compile-command' using `verilog-expand-command'."
- (when (and
- (stringp compile-command)
- (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command))
- (set (make-local-variable 'compile-command)
- (verilog-expand-command compile-command))))
+ ;; Entry into verilog-mode a call to this before Local Variables exist
+ ;; Likewise user may have hook or something that changes the flags.
+ ;; So, remember we're responsible for the expansion and on re-entry
+ ;; recompute __FLAGS__ on each reentry.
+ (when (stringp compile-command)
+ (when (and
+ (boundp 'verilog-compile-command-post-mod)
+ (equal compile-command verilog-compile-command-post-mod))
+ (setq compile-command verilog-compile-command-pre-mod))
+ (when (and
+ (string-match "\\b\\(__FLAGS__\\|__FILE__\\)\\b" compile-command))
+ (set (make-local-variable 'verilog-compile-command-pre-mod)
+ compile-command)
+ (set (make-local-variable 'compile-command)
+ (verilog-expand-command compile-command))
+ (set (make-local-variable 'verilog-compile-command-post-mod)
+ compile-command))))
(if (featurep 'xemacs)
;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling.
;;(if dbg (setq dbg (concat dbg (format "Pt %s Vec %s C%c Kwd'%s'\n" (point) vec (following-char) keywd))))
(cond
((looking-at "//")
- (if (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
- (setq enum (match-string 2)))
+ (when (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
+ (setq enum (match-string 2)))
(search-forward "\n"))
((looking-at "/\\*")
(forward-char 2)
- (if (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
- (setq enum (match-string 2)))
+ (when (looking-at "[^\n]*\\(auto\\|synopsys\\)\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
+ (setq enum (match-string 2)))
(or (search-forward "*/")
(error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
((looking-at "(\\*")
(error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
((eq ?\; (following-char))
(cond (in-ign-to-semi ; Such as inside a "import ...;" in a module header
- (setq in-ign-to-semi nil))
+ (setq in-ign-to-semi nil rvalue nil))
((and in-modport (not (eq in-modport t))) ; end of a modport declaration
(verilog-modport-decls-set
in-modport
(when (string-match "^\\\\" (match-string 1))
(setq keywd (concat keywd " "))) ; Escaped ID needs space at end
;; Add any :: package names to same identifier
- (while (looking-at "\\s-*::\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
+ ;; '*' here is for "import x::*"
+ (while (looking-at "\\s-*::\\s-*\\(\\*\\|[a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
(goto-char (match-end 0))
(setq keywd (concat keywd "::" (match-string 1)))
(when (string-match "^\\\\" (match-string 1))
(not (equal last-keywd "default")))
(setq in-clocking t))
((equal keywd "import")
- (if v2kargs-ok ; import in module header, not a modport import
- (setq in-ign-to-semi t rvalue t)))
+ (when v2kargs-ok ; import in module header, not a modport import
+ (setq in-ign-to-semi t rvalue t)))
((equal keywd "type")
(setq ptype t))
((equal keywd "var"))
(verilog-insert-one-definition
sig
;; Want "type x" or "output type x", not "wire type x"
- (cond ((or (verilog-sig-type sig)
+ (cond ((and (equal "wire" verilog-auto-wire-type)
+ (or (not (verilog-sig-type sig))
+ (equal "logic" (verilog-sig-type sig))))
+ (if (member direction '("input" "output" "inout"))
+ direction
+ "wire"))
+ ;;
+ ((or (verilog-sig-type sig)
verilog-auto-wire-type)
(concat
(when (member direction '("input" "output" "inout"))
(concat direction " "))
- (or (verilog-sig-type sig)
+ (or (verilog-sig-type sig)
verilog-auto-wire-type)))
+ ;;
((and verilog-auto-declare-nettype
(member direction '("input" "output" "inout")))
(concat direction " " verilog-auto-declare-nettype))
(verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param)
(verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst)
(verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star)
- ;; Doesn't matter when done, but combine it with a common changer
- (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
- (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
;; Must be done before autoin/out as creates a reg
(verilog-auto-re-search-do "/\\*AUTOASCIIENUM(.*?)\\*/" 'verilog-auto-ascii-enum)
;;
(verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input)
;; outputevery needs AUTOOUTPUTs done first
(verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\((.*?)\\)?\\*/" 'verilog-auto-output-every)
+ ;; Doesn't matter when done, but combine it with a common changer
+ (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
+ ;; After AUTOREG*, as they may have set signal widths
+ (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
;; After we've created all new variables
(verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused)
;; Must be after all inputs outputs are generated