verilog-mode.el 504 KB
Newer Older
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1 2
;; verilog-mode.el --- major mode for editing verilog source in Emacs

3
;; Copyright (C) 1996-2012  Free Software Foundation, Inc.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
4

Wilson Snyder's avatar
Wilson Snyder committed
5 6 7 8 9
;; Author: Michael McNamara (mac@verilog.com),
;;    Wilson Snyder (wsnyder@wsnyder.org)
;; Please see our web sites:
;;    http://www.verilog.com
;;    http://www.veripool.org
Dan Nicolaescu's avatar
Dan Nicolaescu committed
10 11 12
;;
;; Keywords: languages

13 14 15 16 17
;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
;; file on 19/3/2008, and the maintainer agreed that when a bug is
;; filed in the Emacs bug reporting system against this file, a copy
;; of the bug report be sent to the maintainer's email address.

Dan Nicolaescu's avatar
Dan Nicolaescu committed
18 19 20 21 22 23
;;    This code supports Emacs 21.1 and later
;;    And XEmacs 21.1 and later
;;    Please do not make changes that break Emacs 21.  Thanks!
;;
;;

Glenn Morris's avatar
Glenn Morris committed
24 25
;; This file is part of GNU Emacs.

26
;; GNU Emacs is free software: you can redistribute it and/or modify
Dan Nicolaescu's avatar
Dan Nicolaescu committed
27
;; it under the terms of the GNU General Public License as published by
28 29
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
30

Glenn Morris's avatar
Glenn Morris committed
31
;; GNU Emacs is distributed in the hope that it will be useful,
Dan Nicolaescu's avatar
Dan Nicolaescu committed
32 33 34 35 36
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
37
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
38 39 40

;;; Commentary:

Dan Nicolaescu's avatar
Dan Nicolaescu committed
41
;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs
Dan Nicolaescu's avatar
Dan Nicolaescu committed
42 43 44 45

;; USAGE
;; =====

Dan Nicolaescu's avatar
Dan Nicolaescu committed
46
;; A major mode for editing Verilog HDL source code.  When you have
Dan Nicolaescu's avatar
Dan Nicolaescu committed
47 48 49 50 51 52 53 54
;; entered Verilog mode, you may get more info by pressing C-h m. You
;; may also get online help describing various functions by: C-h f
;; <Name of function you want described>

;; KNOWN BUGS / BUG REPORTS
;; =======================

;; Verilog is a rapidly evolving language, and hence this mode is
Dan Nicolaescu's avatar
Dan Nicolaescu committed
55
;; under continuous development.  Hence this is beta code, and likely
56 57
;; has bugs.  Please report any issues to the issue tracker at
;; http://www.veripool.org/verilog-mode
Dan Nicolaescu's avatar
Dan Nicolaescu committed
58 59 60 61 62 63 64 65 66
;; Please use verilog-submit-bug-report to submit a report; type C-c
;; C-b to invoke this and as a result I will have a much easier time
;; of reproducing the bug you find, and hence fixing it.

;; INSTALLING THE MODE
;; ===================

;; An older version of this mode may be already installed as a part of
;; your environment, and one method of updating would be to update
Dan Nicolaescu's avatar
Dan Nicolaescu committed
67
;; your Emacs environment.  Sometimes this is difficult for local
Dan Nicolaescu's avatar
Dan Nicolaescu committed
68 69 70 71 72 73 74 75
;; political/control reasons, and hence you can always install a
;; private copy (or even a shared copy) which overrides the system
;; default.

;; You can get step by step help in installing this file by going to
;; <http://www.verilog.com/emacs_install.html>

;; The short list of installation instructions are: To set up
76
;; automatic Verilog mode, put this file in your load path, and put
Dan Nicolaescu's avatar
Dan Nicolaescu committed
77 78 79 80
;; the following in code (please un comment it first!) in your
;; .emacs, or in your site's site-load.el

; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
81
; (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
82

Wilson Snyder's avatar
Wilson Snyder committed
83 84 85
;; Be sure to examine at the help for verilog-auto, and the other
;; verilog-auto-* functions for some major coding time savers.
;;
Dan Nicolaescu's avatar
Dan Nicolaescu committed
86
;; If you want to customize Verilog mode to fit your needs better,
Wilson Snyder's avatar
Wilson Snyder committed
87
;; you may add the below lines (the values of the variables presented
Dan Nicolaescu's avatar
Dan Nicolaescu committed
88
;; here are the defaults). Note also that if you use an Emacs that
Dan Nicolaescu's avatar
Dan Nicolaescu committed
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
Wilson Snyder's avatar
Wilson Snyder committed
91 92 93
;; should be common across all users (in a site-start file), or set
;; in Local Variables in every file.  Otherwise, different people's
;; AUTO expansion may result different whitespace changes.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
94
;;
Wilson Snyder's avatar
Wilson Snyder committed
95 96 97
; ;; Enable syntax highlighting of **all** languages
; (global-font-lock-mode t)
;
Dan Nicolaescu's avatar
Dan Nicolaescu committed
98 99 100 101 102 103 104 105 106 107 108 109 110
; ;; User customization for Verilog mode
; (setq verilog-indent-level             3
;       verilog-indent-level-module      3
;       verilog-indent-level-declaration 3
;       verilog-indent-level-behavioral  3
;       verilog-indent-level-directive   1
;       verilog-case-indent              2
;       verilog-auto-newline             t
;       verilog-auto-indent-on-newline   t
;       verilog-tab-always-indent        t
;       verilog-auto-endcomments         t
;       verilog-minimum-comment-distance 40
;       verilog-indent-begin-after-if    t
111
;       verilog-auto-lineup              'declarations
Dan Nicolaescu's avatar
Dan Nicolaescu committed
112 113 114 115 116 117 118
;       verilog-highlight-p1800-keywords nil
;	verilog-linter			 "my_lint_shell_command"
;	)

;; 

;;; History:
119
;;
120
;; See commit history at http://www.veripool.org/verilog-mode.html
Dan Nicolaescu's avatar
Dan Nicolaescu committed
121 122
;; (This section is required to appease checkdoc.)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
123 124 125
;;; Code:

;; This variable will always hold the version number of the mode
126
(defconst verilog-mode-version (substring "$$Revision: 820 $$" 12 -3)
127
  "Version of this Verilog mode.")
128
(defconst verilog-mode-release-date (substring "$$Date: 2012-09-17 20:43:10 -0400 (Mon, 17 Sep 2012) $$" 8 -3)
129
  "Release date of this Verilog mode.")
130
(defconst verilog-mode-release-emacs t
131
  "If non-nil, this version of Verilog mode was released with Emacs itself.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
132 133 134 135

(defun verilog-version ()
  "Inform caller of the version of this file."
  (interactive)
136
  (message "Using verilog-mode version %s" verilog-mode-version))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
137 138

;; Insure we have certain packages, and deal with it if we don't
Dan Nicolaescu's avatar
Dan Nicolaescu committed
139
;; Be sure to note which Emacs flavor and version added each feature.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
140
(eval-when-compile
141
  ;; Provide stuff if we are XEmacs
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
  (when (featurep 'xemacs)
    (condition-case nil
        (require 'easymenu)
      (error nil))
    (condition-case nil
        (require 'regexp-opt)
      (error nil))
    ;; Bug in 19.28 through 19.30 skeleton.el, not provided.
    (condition-case nil
        (load "skeleton")
      (error nil))
    (condition-case nil
        (if (fboundp 'when)
            nil ;; fab
          (defmacro when (cond &rest body)
            (list 'if cond (cons 'progn body))))
      (error nil))
    (condition-case nil
        (if (fboundp 'unless)
            nil ;; fab
          (defmacro unless (cond &rest body)
            (cons 'if (cons cond (cons nil body)))))
      (error nil))
    (condition-case nil
        (if (fboundp 'store-match-data)
            nil ;; fab
          (defmacro store-match-data (&rest args) nil))
      (error nil))
    (condition-case nil
        (if (fboundp 'char-before)
            nil ;; great
          (defmacro char-before (&rest body)
            (char-after (1- (point)))))
      (error nil))
176 177 178 179 180 181 182 183 184 185 186 187
    (condition-case nil
        (if (fboundp 'when)
            nil ;; fab
          (defsubst point-at-bol (&optional N)
            (save-excursion (beginning-of-line N) (point))))
      (error nil))
    (condition-case nil
        (if (fboundp 'when)
            nil ;; fab
          (defsubst point-at-eol (&optional N)
            (save-excursion (end-of-line N) (point))))
      (error nil))
188 189 190 191 192 193 194 195
    (condition-case nil
        (require 'custom)
      (error nil))
    (condition-case nil
        (if (fboundp 'match-string-no-properties)
            nil ;; great
          (defsubst match-string-no-properties (num &optional string)
            "Return string of text matched by last search, without text properties.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
196 197 198 199
NUM specifies which parenthesized expression in the last regexp.
 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
Zero means the entire text matched by the whole regexp or whole string.
STRING should be given if the last search was by `string-match' on STRING."
200 201 202 203 204 205 206 207 208
            (if (match-beginning num)
                (if string
                    (let ((result
                           (substring string
				      (match-beginning num) (match-end num))))
                      (set-text-properties 0 (length result) nil result)
                      result)
                  (buffer-substring-no-properties (match-beginning num)
                                                  (match-end num)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
209 210
                                                  (current-buffer)))))
	  )
211 212 213 214 215 216 217
      (error nil))
    (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
        nil ;; We've got what we needed
      ;; We have the old custom-library, hack around it!
      (defmacro defgroup (&rest args)  nil)
      (defmacro customize (&rest args)
        (message
218
	 "Sorry, Customize is not available with this version of Emacs"))
219 220 221 222 223 224 225 226
      (defmacro defcustom (var value doc &rest args)
        `(defvar ,var ,value ,doc))
      )
    (if (fboundp 'defface)
        nil				; great!
      (defmacro defface (var values doc &rest args)
        `(make-face ,var))
      )
Dan Nicolaescu's avatar
Dan Nicolaescu committed
227

228 229 230 231 232
    (if (and (featurep 'custom) (fboundp 'customize-group))
        nil ;; We've got what we needed
      ;; We have an intermediate custom-library, hack around it!
      (defmacro customize-group (var &rest args)
        `(customize ,var))
Wilson Snyder's avatar
Wilson Snyder committed
233 234 235 236 237 238 239 240
      )

    (unless (boundp 'inhibit-point-motion-hooks)
      (defvar inhibit-point-motion-hooks nil))
    (unless (boundp 'deactivate-mark)
      (defvar deactivate-mark nil))
    )
  ;;
241 242 243 244 245 246
  ;; OK, do this stuff if we are NOT XEmacs:
  (unless (featurep 'xemacs)
    (unless (fboundp 'region-active-p)
      (defmacro region-active-p ()
	`(and transient-mark-mode mark-active))))
  )
Dan Nicolaescu's avatar
Dan Nicolaescu committed
247 248 249 250

;; Provide a regular expression optimization routine, using regexp-opt
;; if provided by the user's elisp libraries
(eval-and-compile
Dan Nicolaescu's avatar
Dan Nicolaescu committed
251 252
  ;; The below were disabled when GNU Emacs 22 was released;
  ;; perhaps some still need to be there to support Emacs 21.
253 254 255 256 257 258 259 260
  (if (featurep 'xemacs)
      (if (fboundp 'regexp-opt)
          ;; regexp-opt is defined, does it take 3 or 2 arguments?
          (if (fboundp 'function-max-args)
              (let ((args (function-max-args `regexp-opt)))
                (cond
                 ((eq args 3) ;; It takes 3
                  (condition-case nil	; Hide this defun from emacses
Dan Nicolaescu's avatar
Dan Nicolaescu committed
261
					;with just a two input regexp
262 263
                      (defun verilog-regexp-opt (a b)
                        "Deal with differing number of required arguments for  `regexp-opt'.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
264
         Call 'regexp-opt' on A and B."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
265
                        (regexp-opt a b 't))
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
                    (error nil))
                  )
                 ((eq args 2) ;; It takes 2
                  (defun verilog-regexp-opt (a b)
                    "Call 'regexp-opt' on A and B."
                    (regexp-opt a b))
                  )
                 (t nil)))
            ;; We can't tell; assume it takes 2
            (defun verilog-regexp-opt (a b)
              "Call 'regexp-opt' on A and B."
              (regexp-opt a b))
            )
        ;; There is no regexp-opt, provide our own
        (defun verilog-regexp-opt (strings &optional paren shy)
          (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
            (concat open (mapconcat 'regexp-quote strings "\\|") close)))
        )
    ;; Emacs.
    (defalias 'verilog-regexp-opt 'regexp-opt)))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
286

Wilson Snyder's avatar
Wilson Snyder committed
287 288
(eval-and-compile
  ;; Both xemacs and emacs
289 290 291 292 293 294
  (condition-case nil
      (require 'diff) ;; diff-command and diff-switches
    (error nil))
  (condition-case nil
      (require 'compile) ;; compilation-error-regexp-alist-alist
    (error nil))
Wilson Snyder's avatar
Wilson Snyder committed
295 296 297
  (condition-case nil
      (unless (fboundp 'buffer-chars-modified-tick)  ;; Emacs 22 added
	(defmacro buffer-chars-modified-tick () (buffer-modified-tick)))
298 299 300 301 302
    (error nil))
  ;; Added in Emacs 24.1
  (condition-case nil
      (unless (fboundp 'prog-mode)
	(define-derived-mode prog-mode fundamental-mode "Prog"))
Wilson Snyder's avatar
Wilson Snyder committed
303 304
    (error nil)))

305 306 307 308
(eval-when-compile
  (defun verilog-regexp-words (a)
    "Call 'regexp-opt' with word delimiters for the words A."
    (concat "\\<" (verilog-regexp-opt a t) "\\>")))
Wilson Snyder's avatar
Wilson Snyder committed
309 310 311 312
(defun verilog-regexp-words (a)
  "Call 'regexp-opt' with word delimiters for the words A."
  ;; The FAQ references this function, so user LISP sometimes calls it
  (concat "\\<" (verilog-regexp-opt a t) "\\>"))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
313

314
(defun verilog-easy-menu-filter (menu)
315
  "Filter `easy-menu-define' MENU to support new features."
316 317
  (cond ((not (featurep 'xemacs))
	 menu) ;; GNU Emacs - passthru
Juanma Barranquero's avatar
Juanma Barranquero committed
318
	;; XEmacs doesn't support :help.  Strip it.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
	;; Recursively filter the a submenu
	((listp menu)
	 (mapcar 'verilog-easy-menu-filter menu))
	;; Look for [:help "blah"] and remove
	((vectorp menu)
	 (let ((i 0) (out []))
	   (while (< i (length menu))
	     (if (equal `:help (aref menu i))
		 (setq i (+ 2 i))
	       (setq out (vconcat out (vector (aref menu i)))
		     i (1+ i))))
	   out))
	(t menu))) ;; Default - ok
;;(verilog-easy-menu-filter
;;  `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"])
;;     "----" ["MB" nil :help "Help MB"]))

336 337 338 339 340 341 342 343
(defun verilog-define-abbrev (table name expansion &optional hook)
  "Filter `define-abbrev' TABLE NAME EXPANSION and call HOOK.
Provides SYSTEM-FLAG in newer Emacs."
  (condition-case nil
      (define-abbrev table name expansion hook 0 t)
    (error
     (define-abbrev table name expansion hook))))

Dan Nicolaescu's avatar
Dan Nicolaescu committed
344
(defun verilog-customize ()
345
  "Customize variables and other settings used by Verilog-Mode."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
346 347 348 349
  (interactive)
  (customize-group 'verilog-mode))

(defun verilog-font-customize ()
350
  "Customize fonts used by Verilog-Mode."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
351
  (interactive)
352 353
  (if (fboundp 'customize-apropos)
      (customize-apropos "font-lock-*" 'faces)))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
354

355 356
(defun verilog-booleanp (value)
  "Return t if VALUE is boolean.
357 358
This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs.
This function may be removed when Emacs 21 is no longer supported."
359 360
  (or (equal value t) (equal value nil)))

361 362 363 364 365 366 367 368
(defun verilog-insert-last-command-event ()
  "Insert the `last-command-event'."
  (insert (if (featurep 'xemacs)
	      ;; XEmacs 21.5 doesn't like last-command-event
	      last-command-char
	    ;; And GNU Emacs 22 has obsoleted last-command-char
	    last-command-event)))

369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
(defvar verilog-no-change-functions nil
  "True if `after-change-functions' is disabled.
Use of `syntax-ppss' may break, as ppss's cache may get corrupted.")

(defvar verilog-in-hooks nil
  "True when within a `verilog-run-hooks' block.")

(defmacro verilog-run-hooks (&rest hooks)
  "Run each hook in HOOKS using `run-hooks'.
Set `verilog-in-hooks' during this time, to assist AUTO caches."
  `(let ((verilog-in-hooks t))
     (run-hooks ,@hooks)))

(defun verilog-syntax-ppss (&optional pos)
  (when verilog-no-change-functions
    (if verilog-in-hooks
	(verilog-scan-cache-flush)
      ;; else don't let the AUTO code itself get away with flushing the cache,
      ;; as that'll make things very slow
      (backtrace)
      (error "%s: Internal problem; use of syntax-ppss when cache may be corrupt"
	     (verilog-point-text))))
  (if (fboundp 'syntax-ppss)
      (syntax-ppss pos)
    (parse-partial-sexp (point-min) (or pos (point)))))
394

Dan Nicolaescu's avatar
Dan Nicolaescu committed
395
(defgroup verilog-mode nil
396
  "Major mode for Verilog source code."
397
  :version "22.2"
Dan Nicolaescu's avatar
Dan Nicolaescu committed
398 399 400 401 402 403 404 405
  :group 'languages)

; (defgroup verilog-mode-fonts nil
;   "Facilitates easy customization fonts used in Verilog source text"
;   :link '(customize-apropos "font-lock-*" 'faces)
;  :group 'verilog-mode)

(defgroup verilog-mode-indent nil
406
  "Customize indentation and highlighting of Verilog source text."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
407 408 409
  :group 'verilog-mode)

(defgroup verilog-mode-actions nil
410
  "Customize actions on Verilog source text."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
411 412 413
  :group 'verilog-mode)

(defgroup verilog-mode-auto nil
414
  "Customize AUTO actions when expanding Verilog source text."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
415 416
  :group 'verilog-mode)

Wilson Snyder's avatar
Wilson Snyder committed
417
(defvar verilog-debug nil
418 419 420 421
  "Non-nil means enable debug messages for `verilog-mode' internals.")

(defvar verilog-warn-fatal nil
  "Non-nil means `verilog-warn-error' warnings are fatal `error's.")
Wilson Snyder's avatar
Wilson Snyder committed
422

Dan Nicolaescu's avatar
Dan Nicolaescu committed
423 424
(defcustom verilog-linter
  "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'"
425
  "Unix program and arguments to call to run a lint checker on Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
426 427 428 429 430
Depending on the `verilog-set-compile-command', this may be invoked when
you type \\[compile].  When the compile completes, \\[next-error] will take
you to the next lint error."
  :type 'string
  :group 'verilog-mode-actions)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
431
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
432 433 434

(defcustom verilog-coverage
  "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'"
435
  "Program and arguments to use to annotate for coverage Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
436 437 438 439 440
Depending on the `verilog-set-compile-command', this may be invoked when
you type \\[compile].  When the compile completes, \\[next-error] will take
you to the next lint error."
  :type 'string
  :group 'verilog-mode-actions)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
441
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
442 443 444

(defcustom verilog-simulator
  "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'"
445
  "Program and arguments to use to interpret Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
446 447 448 449 450
Depending on the `verilog-set-compile-command', this may be invoked when
you type \\[compile].  When the compile completes, \\[next-error] will take
you to the next lint error."
  :type 'string
  :group 'verilog-mode-actions)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
451
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
452 453 454

(defcustom verilog-compiler
  "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'"
455
  "Program and arguments to use to compile Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
456 457 458 459 460
Depending on the `verilog-set-compile-command', this may be invoked when
you type \\[compile].  When the compile completes, \\[next-error] will take
you to the next lint error."
  :type 'string
  :group 'verilog-mode-actions)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
461
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
462

Wilson Snyder's avatar
Wilson Snyder committed
463 464 465
(defcustom verilog-preprocessor
  ;; Very few tools give preprocessed output, so we'll default to Verilog-Perl
  "vppreproc __FLAGS__ __FILE__"
466
  "Program and arguments to use to preprocess Verilog source.
Wilson Snyder's avatar
Wilson Snyder committed
467 468 469 470 471 472 473 474 475 476 477
This is invoked with `verilog-preprocess', and depending on the
`verilog-set-compile-command', may also be invoked when you type
\\[compile].  When the compile completes, \\[next-error] will
take you to the next lint error."
  :type 'string
  :group 'verilog-mode-actions)
;; We don't mark it safe, as it's used as a shell command

(defvar verilog-preprocess-history nil
  "History for `verilog-preprocess'.")

Dan Nicolaescu's avatar
Dan Nicolaescu committed
478 479
(defvar verilog-tool 'verilog-linter
  "Which tool to use for building compiler-command.
Wilson Snyder's avatar
Wilson Snyder committed
480 481 482 483
Either nil, `verilog-linter, `verilog-compiler,
`verilog-coverage, `verilog-preprocessor, or `verilog-simulator.
Alternatively use the \"Choose Compilation Action\" menu.  See
`verilog-set-compile-command' for more information.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
484 485

(defcustom verilog-highlight-translate-off nil
486
  "Non-nil means background-highlight code excluded from translation.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
487 488 489 490 491 492 493 494 495 496
That is, all code between \"// synopsys translate_off\" and
\"// synopsys translate_on\" is highlighted using a different background color
\(face `verilog-font-lock-translate-off-face').

Note: This will slow down on-the-fly fontification (and thus editing).

Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu
entry \"Fontify Buffer\").  XEmacs: turn off and on font locking."
  :type 'boolean
  :group 'verilog-mode-indent)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
497
;; Note we don't use :safe, as that would break on Emacsen before 22.0.
498
(put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
499

500
(defcustom verilog-auto-lineup 'declarations
501
  "Type of statements to lineup across multiple lines.
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
If 'all' is selected, then all line ups described below are done.

If 'declaration', then just declarations are lined up with any
preceding declarations, taking into account widths and the like,
so or example the code:
 	reg [31:0] a;
 	reg b;
would become
 	reg [31:0] a;
 	reg        b;

If 'assignment', then assignments are lined up with any preceding
assignments, so for example the code
	a_long_variable <= b + c;
	d = e + f;
would become
	a_long_variable <= b + c;
	d                = e + f;

In order to speed up editing, large blocks of statements are lined up
only when a \\[verilog-pretty-expr] is typed; and large blocks of declarations
are lineup only when \\[verilog-pretty-declarations] is typed."

  :type '(radio (const :tag "Line up Assignments and Declarations" all)
		(const :tag "Line up Assignment statements" assignments )
527
		(const :tag "Line up Declarations" declarations)
528 529
		(function :tag "Other"))
  :group 'verilog-mode-indent )
530 531
(put 'verilog-auto-lineup 'safe-local-variable
     '(lambda (x) (memq x '(nil all assignments declarations))))
532

Dan Nicolaescu's avatar
Dan Nicolaescu committed
533
(defcustom verilog-indent-level 3
534
  "Indentation of Verilog statements with respect to containing block."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
535 536
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
537
(put 'verilog-indent-level 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
538 539

(defcustom verilog-indent-level-module 3
540
  "Indentation of Module level Verilog statements (eg always, initial).
Dan Nicolaescu's avatar
Dan Nicolaescu committed
541 542 543 544
Set to 0 to get initial and always statements lined up on the left side of
your screen."
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
545
(put 'verilog-indent-level-module 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
546 547

(defcustom verilog-indent-level-declaration 3
548
  "Indentation of declarations with respect to containing block.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
549 550 551
Set to 0 to get them list right under containing block."
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
552
(put 'verilog-indent-level-declaration 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
553 554

(defcustom verilog-indent-declaration-macros nil
555
  "How to treat macro expansions in a declaration.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
556 557 558 559 560 561 562 563 564 565
If nil, indent as:
	input [31:0] a;
	input        `CP;
	output       c;
If non nil, treat as:
	input [31:0] a;
	input `CP    ;
	output       c;"
  :group 'verilog-mode-indent
  :type 'boolean)
566
(put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
567 568

(defcustom verilog-indent-lists t
569
  "How to treat indenting items in a list.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
570 571 572 573 574 575 576 577 578
If t (the default), indent as:
	always @( posedge a or
	          reset ) begin

If nil, treat as:
	always @( posedge a or
	   reset ) begin"
  :group 'verilog-mode-indent
  :type 'boolean)
579
(put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
580 581

(defcustom verilog-indent-level-behavioral 3
582
  "Absolute indentation of first begin in a task or function block.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
583 584 585
Set to 0 to get such code to start at the left side of the screen."
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
586
(put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
587 588

(defcustom verilog-indent-level-directive 1
589
  "Indentation to add to each level of `ifdef declarations.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
590 591 592
Set to 0 to have all directives start at the left side of the screen."
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
593
(put 'verilog-indent-level-directive 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
594 595

(defcustom verilog-cexp-indent 2
596
  "Indentation of Verilog statements split across lines."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
597 598
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
599
(put 'verilog-cexp-indent 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
600 601

(defcustom verilog-case-indent 2
602
  "Indentation for case statements."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
603 604
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
605
(put 'verilog-case-indent 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
606 607

(defcustom verilog-auto-newline t
608
  "Non-nil means automatically newline after semicolons."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
609 610
  :group 'verilog-mode-indent
  :type 'boolean)
611
(put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
612 613

(defcustom verilog-auto-indent-on-newline t
614
  "Non-nil means automatically indent line after newline."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
615 616
  :group 'verilog-mode-indent
  :type 'boolean)
617
(put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
618 619

(defcustom verilog-tab-always-indent t
620
  "Non-nil means TAB should always re-indent the current line.
621
A nil value means TAB will only reindent when at the beginning of the line."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
622 623
  :group 'verilog-mode-indent
  :type 'boolean)
624
(put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
625 626

(defcustom verilog-tab-to-comment nil
627
  "Non-nil means TAB moves to the right hand column in preparation for a comment."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
628 629
  :group 'verilog-mode-actions
  :type 'boolean)
630
(put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
631 632

(defcustom verilog-indent-begin-after-if t
633
  "Non-nil means indent begin statements following if, else, while, etc.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
634 635
Otherwise, line them up."
  :group 'verilog-mode-indent
Dan Nicolaescu's avatar
Dan Nicolaescu committed
636
  :type 'boolean)
637
(put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
638 639

(defcustom verilog-align-ifelse nil
640
  "Non-nil means align `else' under matching `if'.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
641 642
Otherwise else is lined up with first character on line holding matching if."
  :group 'verilog-mode-indent
Dan Nicolaescu's avatar
Dan Nicolaescu committed
643
  :type 'boolean)
644
(put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
645 646

(defcustom verilog-minimum-comment-distance 10
647
  "Minimum distance (in lines) between begin and end required before a comment.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
648
Setting this variable to zero results in every end acquiring a comment; the
649
default avoids too many redundant comments in tight quarters."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
650 651
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
652
(put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
653 654

(defcustom verilog-highlight-p1800-keywords nil
655
  "Non-nil means highlight words newly reserved by IEEE-1800.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
656 657
These will appear in `verilog-font-lock-p1800-face' in order to gently
suggest changing where these words are used as variables to something else.
658
A nil value means highlight these words as appropriate for the SystemVerilog
Dan Nicolaescu's avatar
Dan Nicolaescu committed
659
IEEE-1800 standard.  Note that changing this will require restarting Emacs
660
to see the effect as font color choices are cached by Emacs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
661 662
  :group 'verilog-mode-indent
  :type 'boolean)
663
(put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
664

665
(defcustom verilog-highlight-grouping-keywords nil
666
  "Non-nil means highlight grouping keywords 'begin' and 'end' more dramatically.
667 668
If false, these words are in the `font-lock-type-face'; if True then they are in
`verilog-font-lock-ams-face'.  Some find that special highlighting on these
669 670 671
grouping constructs allow the structure of the code to be understood at a glance."
  :group 'verilog-mode-indent
  :type 'boolean)
672
(put 'verilog-highlight-grouping-keywords 'safe-local-variable 'verilog-booleanp)
673

Wilson Snyder's avatar
Wilson Snyder committed
674
(defcustom verilog-highlight-modules nil
675
  "Non-nil means highlight module statements for `verilog-load-file-at-point'.
Wilson Snyder's avatar
Wilson Snyder committed
676 677 678 679 680 681 682 683
When true, mousing over module names will allow jumping to the
module definition.  If false, this is not supported.  Setting
this is experimental, and may lead to bad performance."
  :group 'verilog-mode-indent
  :type 'boolean)
(put 'verilog-highlight-modules 'safe-local-variable 'verilog-booleanp)

(defcustom verilog-highlight-includes t
684
  "Non-nil means highlight module statements for `verilog-load-file-at-point'.
Wilson Snyder's avatar
Wilson Snyder committed
685 686 687 688 689 690
When true, mousing over include file names will allow jumping to the
file referenced.  If false, this is not supported."
  :group 'verilog-mode-indent
  :type 'boolean)
(put 'verilog-highlight-includes 'safe-local-variable 'verilog-booleanp)

691
(defcustom verilog-auto-declare-nettype nil
692
  "Non-nil specifies the data type to use with `verilog-auto-input' etc.
693 694 695
Set this to \"wire\" if the Verilog code uses \"`default_nettype
none\".  Note using `default_nettype none isn't recommended practice; this
mode is experimental."
696
  :version "24.1"  ;; rev670
697 698 699 700 701
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-declare-nettype 'safe-local-variable `stringp)

(defcustom verilog-auto-wire-type nil
702
  "Non-nil specifies the data type to use with `verilog-auto-wire' etc.
703
Set this to \"logic\" for SystemVerilog code, or use `verilog-auto-logic'."
704
  :version "24.1"  ;; rev673
705 706 707 708
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-wire-type 'safe-local-variable `stringp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
709
(defcustom verilog-auto-endcomments t
710
  "Non-nil means insert a comment /* ... */ after 'end's.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
711 712
The name of the function or case will be set between the braces."
  :group 'verilog-mode-actions
Dan Nicolaescu's avatar
Dan Nicolaescu committed
713
  :type 'boolean)
714
(put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
715

716
(defcustom verilog-auto-delete-trailing-whitespace nil
717 718
  "Non-nil means to `delete-trailing-whitespace' in `verilog-auto'."
  :version "24.1"  ;; rev703
719 720 721 722
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-delete-trailing-whitespace 'safe-local-variable 'verilog-booleanp)

723
(defcustom verilog-auto-ignore-concat nil
724
  "Non-nil means ignore signals in {...} concatenations for AUTOWIRE etc.
725 726 727 728 729 730 731 732
This will exclude signals referenced as pin connections in {...}
from AUTOWIRE, AUTOOUTPUT and friends.  This flag should be set
for backward compatibility only and not set in new designs; it
may be removed in future versions."
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-ignore-concat 'safe-local-variable 'verilog-booleanp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
733
(defcustom verilog-auto-read-includes nil
734
  "Non-nil means to automatically read includes before AUTOs.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
735 736 737 738 739
This will do a `verilog-read-defines' and `verilog-read-includes' before
each AUTO expansion.  This makes it easier to embed defines and includes,
but can result in very slow reading times if there are many or large
include files."
  :group 'verilog-mode-actions
Dan Nicolaescu's avatar
Dan Nicolaescu committed
740
  :type 'boolean)
741
(put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
742 743

(defcustom verilog-auto-save-policy nil
744
  "Non-nil indicates action to take when saving a Verilog buffer with AUTOs.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
745 746 747 748 749 750 751 752 753 754 755 756
A value of `force' will always do a \\[verilog-auto] automatically if
needed on every save.  A value of `detect' will do \\[verilog-auto]
automatically when it thinks necessary.  A value of `ask' will query the
user when it thinks updating is needed.

You should not rely on the 'ask or 'detect policies, they are safeguards
only.  They do not detect when AUTOINSTs need to be updated because a
sub-module's port list has changed."
  :group 'verilog-mode-actions
  :type '(choice (const nil) (const ask) (const detect) (const force)))

(defcustom verilog-auto-star-expand t
757 758
  "Non-nil means to expand SystemVerilog .* instance ports.
They will be expanded in the same way as if there was an AUTOINST in the
Dan Nicolaescu's avatar
Dan Nicolaescu committed
759 760 761
instantiation.  See also `verilog-auto-star' and `verilog-auto-star-save'."
  :group 'verilog-mode-actions
  :type 'boolean)
762
(put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
763 764

(defcustom verilog-auto-star-save nil
765
  "Non-nil means save to disk SystemVerilog .* instance expansions.
766 767
A nil value indicates direct connections will be removed before saving.
Only meaningful to those created due to `verilog-auto-star-expand' being set.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
768 769 770 771 772

Instead of setting this, you may want to use /*AUTOINST*/, which will
always be saved."
  :group 'verilog-mode-actions
  :type 'boolean)
773
(put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
774 775 776 777 778 779 780

(defvar verilog-auto-update-tick nil
  "Modification tick at which autos were last performed.")

(defvar verilog-auto-last-file-locals nil
  "Text from file-local-variables during last evaluation.")

781
(defvar verilog-diff-function 'verilog-diff-report
782
  "Function to run when `verilog-diff-auto' detects differences.
783 784 785 786
Function takes three arguments, the original buffer, the
difference buffer, and the point in original buffer with the
first difference.")

787 788
;;; Compile support
(require 'compile)
789
(defvar verilog-error-regexp-added nil)
Wilson Snyder's avatar
Wilson Snyder committed
790

791 792 793 794 795 796 797
(defvar verilog-error-regexp-emacs-alist
  '(
    (verilog-xl-1
     "\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
    (verilog-xl-2
     "([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 3)
    (verilog-IES
Wilson Snyder's avatar
Wilson Snyder committed
798
     ".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)" 2 3)
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819
    (verilog-surefire-1
     "[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
    (verilog-surefire-2
     "\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 )
    (verilog-verbose
     "\
\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
    (verilog-xsim
     "\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
    (verilog-vcs-1
     "\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
    (verilog-vcs-2
     "Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
    (verilog-vcs-3
     "\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
    (verilog-vcs-4
     "syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
    (verilog-verilator
     "%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
    (verilog-leda
Wilson Snyder's avatar
Wilson Snyder committed
820
     "^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 2)
821
    )
Wilson Snyder's avatar
Wilson Snyder committed
822 823 824 825 826 827
  "List of regexps for Verilog compilers.
See `compilation-error-regexp-alist' for the formatting.  For Emacs 22+.")

(defvar verilog-error-regexp-xemacs-alist
  ;; Emacs form is '((v-tool "re" 1 2) ...)
  ;; XEmacs form is '(verilog ("re" 1 2) ...)
Juanma Barranquero's avatar
Juanma Barranquero committed
828
  ;; So we can just map from Emacs to XEmacs
Wilson Snyder's avatar
Wilson Snyder committed
829 830 831
  (cons 'verilog (mapcar 'cdr verilog-error-regexp-emacs-alist))
  "List of regexps for Verilog compilers.
See `compilation-error-regexp-alist-alist' for the formatting.  For XEmacs.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
832 833 834

(defvar verilog-error-font-lock-keywords
  '(
Wilson Snyder's avatar
Wilson Snyder committed
835 836 837 838 839 840 841 842 843 844
    ;; verilog-xl-1
    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
    ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
    ;; verilog-xl-2
    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 bold t)
    ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 3 bold t)
    ;; verilog-IES (nc-verilog)
    (".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t)
    (".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)|" 3 bold t)
    ;; verilog-surefire-1
Dan Nicolaescu's avatar
Dan Nicolaescu committed
845 846
    ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
    ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
847
    ;; verilog-surefire-2
Dan Nicolaescu's avatar
Dan Nicolaescu committed
848 849
    ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t)
    ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
850
    ;; verilog-verbose
Dan Nicolaescu's avatar
Dan Nicolaescu committed
851 852 853 854 855 856
    ("\
\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
    ("\
\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
857
    ;; verilog-vcs-1
Dan Nicolaescu's avatar
Dan Nicolaescu committed
858 859
    ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t)
    ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
860
    ;; verilog-vcs-2
Dan Nicolaescu's avatar
Dan Nicolaescu committed
861 862
    ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
    ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
863
    ;; verilog-vcs-3
Dan Nicolaescu's avatar
Dan Nicolaescu committed
864 865
    ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
    ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
866
    ;; verilog-vcs-4
Dan Nicolaescu's avatar
Dan Nicolaescu committed
867 868
    ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t)
    ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
869 870 871 872 873 874
    ;; verilog-verilator
    (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
    (".*%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
    ;; verilog-leda
    ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 bold t)
    ("^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 2 bold t)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
875
    )
876
  "Keywords to also highlight in Verilog *compilation* buffers.
Wilson Snyder's avatar
Wilson Snyder committed
877
Only used in XEmacs; GNU Emacs uses `verilog-error-regexp-emacs-alist'.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
878 879

(defcustom verilog-library-flags '("")
880
  "List of standard Verilog arguments to use for /*AUTOINST*/.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
These arguments are used to find files for `verilog-auto', and match
the flags accepted by a standard Verilog-XL simulator.

    -f filename     Reads more `verilog-library-flags' from the filename.
    +incdir+dir     Adds the directory to `verilog-library-directories'.
    -Idir           Adds the directory to `verilog-library-directories'.
    -y dir          Adds the directory to `verilog-library-directories'.
    +libext+.v      Adds the extensions to `verilog-library-extensions'.
    -v filename     Adds the filename to `verilog-library-files'.

    filename        Adds the filename to `verilog-library-files'.
                    This is not recommended, -v is a better choice.

You might want these defined in each file; put at the *END* of your file
something like:

    // Local Variables:
    // verilog-library-flags:(\"-y dir -y otherdir\")
    // End:

Verilog-mode attempts to detect changes to this local variable, but they
902
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
903 904 905 906 907
have problems, use \\[find-alternate-file] RET to have these take effect.

See also the variables mentioned above."
  :group 'verilog-mode-auto
  :type '(repeat string))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
908
(put 'verilog-library-flags 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
909 910

(defcustom verilog-library-directories '(".")
911
  "List of directories when looking for files for /*AUTOINST*/.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
912 913 914 915 916 917 918 919 920 921 922 923
The directory may be relative to the current file, or absolute.
Environment variables are also expanded in the directory names.
Having at least the current directory is a good idea.

You might want these defined in each file; put at the *END* of your file
something like:

    // Local Variables:
    // verilog-library-directories:(\".\" \"subdir\" \"subdir2\")
    // End:

Verilog-mode attempts to detect changes to this local variable, but they
924
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
925 926 927 928 929 930
have problems, use \\[find-alternate-file] RET to have these take effect.

See also `verilog-library-flags', `verilog-library-files'
and `verilog-library-extensions'."
  :group 'verilog-mode-auto
  :type '(repeat file))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
931
(put 'verilog-library-directories 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
932 933

(defcustom verilog-library-files '()
934
  "List of files to search for modules.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
935
AUTOINST will use this when it needs to resolve a module name.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
936 937 938 939 940 941 942 943 944 945 946
This is a complete path, usually to a technology file with many standard
cells defined in it.

You might want these defined in each file; put at the *END* of your file
something like:

    // Local Variables:
    // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\")
    // End:

Verilog-mode attempts to detect changes to this local variable, but they
947
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
948 949 950 951 952
have problems, use \\[find-alternate-file] RET to have these take effect.

See also `verilog-library-flags', `verilog-library-directories'."
  :group 'verilog-mode-auto
  :type '(repeat directory))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
953
(put 'verilog-library-files 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
954

955
(defcustom verilog-library-extensions '(".v" ".sv")
956
  "List of extensions to use when looking for files for /*AUTOINST*/.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
957 958 959
See also `verilog-library-flags', `verilog-library-directories'."
  :type '(repeat string)
  :group 'verilog-mode-auto)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
960
(put 'verilog-library-extensions 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
961 962

(defcustom verilog-active-low-regexp nil
963
  "If set, treat signals matching this regexp as active low.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
964 965 966 967
This is used for AUTORESET and AUTOTIEOFF.  For proper behavior,
you will probably also need `verilog-auto-reset-widths' set."
  :group 'verilog-mode-auto
  :type 'string)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
968
(put 'verilog-active-low-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
969 970

(defcustom verilog-auto-sense-include-inputs nil
971
  "Non-nil means AUTOSENSE should include all inputs.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
972 973
If nil, only inputs that are NOT output signals in the same block are
included."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
974 975
  :group 'verilog-mode-auto
  :type 'boolean)
976
(put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
977 978

(defcustom verilog-auto-sense-defines-constant nil
979
  "Non-nil means AUTOSENSE should assume all defines represent constants.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
980 981
When true, the defines will not be included in sensitivity lists.  To
maintain compatibility with other sites, this should be set at the bottom
982
of each Verilog file that requires it, rather than being set globally."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
983 984
  :group 'verilog-mode-auto
  :type 'boolean)
985
(put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
986

987
(defcustom verilog-auto-reset-blocking-in-non t
988 989 990 991
  "Non-nil means AUTORESET will reset blocking statements.
When true, AUTORESET will reset in blocking statements those
signals which were assigned with blocking assignments (=) even in
a block with non-blocking assignments (<=).
Paul Eggert's avatar
Paul Eggert committed
992

993 994 995 996
If nil, all blocking assigned signals are ignored when any
non-blocking assignment is in the AUTORESET block.  This allows
blocking assignments to be used for temporary values and not have
those temporaries reset.  See example in `verilog-auto-reset'."
997
  :version "24.1"  ;; rev718
998 999 1000 1001
  :type 'boolean
  :group 'verilog-mode-auto)
(put 'verilog-auto-reset-blocking-in-non 'safe-local-variable 'verilog-booleanp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
1002
(defcustom verilog-auto-reset-widths t
1003
  "True means AUTORESET should determine the width of signals.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1004 1005
This is then used to set the width of the zero (32'h0 for example).  This
is required by some lint tools that aren't smart enough to ignore widths of
1006 1007 1008 1009 1010 1011 1012 1013
the constant zero. This may result in ugly code when parameters determine
the MSB or LSB of a signal inside an AUTORESET.

If nil, AUTORESET uses \"0\" as the constant.

If 'unbased', AUTORESET used the unbased unsized literal \"'0\"
as the constant. This setting is strongly recommended for
SystemVerilog designs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1014 1015
  :type 'boolean
  :group 'verilog-mode-auto)
1016 1017
(put 'verilog-auto-reset-widths 'safe-local-variable
     '(lambda (x) (memq x '(nil t unbased))))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1018 1019

(defcustom verilog-assignment-delay ""
1020
  "Text used for delays in delayed assignments.  Add a trailing space if set."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1021 1022 1023
  :group 'verilog-mode-auto
  :type 'string)
(put 'verilog-assignment-delay 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1024

1025
(defcustom verilog-auto-arg-sort nil
1026
  "Non-nil means AUTOARG signal names will be sorted, not in declaration order.
1027 1028 1029
Declaration order is advantageous with order based instantiations
and is the default for backward compatibility.  Sorted order
reduces changes when declarations are moved around in a file, and
1030 1031 1032
it's bad practice to rely on order based instantiations anyhow.

See also `verilog-auto-inst-sort'."
1033 1034 1035 1036
  :group 'verilog-mode-auto
  :type 'boolean)
(put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp)

Wilson Snyder's avatar
Wilson Snyder committed
1037
(defcustom verilog-auto-inst-dot-name nil
1038
  "Non-nil means when creating ports with AUTOINST, use .name syntax.
Wilson Snyder's avatar
Wilson Snyder committed
1039 1040 1041 1042 1043 1044 1045 1046
This will use \".port\" instead of \".port(port)\" when possible.
This is only legal in SystemVerilog files, and will confuse older
simulators.  Setting `verilog-auto-inst-vector' to nil may also
be desirable to increase how often .name will be used."
  :group 'verilog-mode-auto
  :type 'boolean)
(put 'verilog-auto-inst-dot-name 'safe-local-variable 'verilog-booleanp)

1047
(defcustom verilog-auto-inst-param-value nil
1048
  "Non-nil means AUTOINST will replace parameters with the parameter value.
1049 1050 1051 1052 1053 1054 1055
If nil, leave parameters as symbolic names.

Parameters must be in Verilog 2001 format #(...), and if a parameter is not
listed as such there (as when the default value is acceptable), it will not
be replaced, and will remain symbolic.

For example, imagine a submodule uses parameters to declare the size of its
1056
inputs.  This is then used by an upper module:
1057

Wilson Snyder's avatar
Wilson Snyder committed
1058
	module InstModule (o,i);
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
	   parameter WIDTH;
	   input [WIDTH-1:0] i;
	endmodule

	module ExampInst;
	   InstModule
 	     #(PARAM(10))
	    instName
	     (/*AUTOINST*/
	      .i 	(i[PARAM-1:0]));

Note even though PARAM=10, the AUTOINST has left the parameter as a
symbolic name.  If `verilog-auto-inst-param-value' is set, this will
instead expand to:

	module ExampInst;
	   InstModule
 	     #(PARAM(10))
	    instName
	     (/*AUTOINST*/
	      .i 	(i[9:0]));"
  :group 'verilog-mode-auto
  :type 'boolean)
1082
(put 'verilog-auto-inst-param-value 'safe-local-variable 'verilog-booleanp)
1083

1084
(defcustom verilog-auto-inst-sort nil
1085
  "Non-nil means AUTOINST signals will be sorted, not in declaration order.
1086 1087 1088 1089 1090 1091
Also affects AUTOINSTPARAM.  Declaration order is the default for
backward compatibility, and as some teams prefer signals that are
declared together to remain together.  Sorted order reduces
changes when declarations are moved around in a file.

See also `verilog-auto-arg-sort'."
1092
  :version "24.1"  ;; rev688
1093 1094 1095 1096
  :group 'verilog-mode-auto
  :type 'boolean)
(put 'verilog-auto-inst-sort 'safe-local-variable 'verilog-booleanp)