verilog-mode.el 469 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-2011  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 "725"
127
  "Version of this Verilog mode.")
128
(defconst verilog-mode-release-date "2011-11-27-GNU"
129
  "Release date of this Verilog mode.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
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
  "Facilitates easy editing of Verilog source text."
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 418 419
(defvar verilog-debug nil
  "If set, enable debug messages for `verilog-mode' internals.")

Dan Nicolaescu's avatar
Dan Nicolaescu committed
420 421
(defcustom verilog-linter
  "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'"
422
  "*Unix program and arguments to call to run a lint checker on Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
423 424 425 426 427
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
428
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
429 430 431

(defcustom verilog-coverage
  "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'"
432
  "*Program and arguments to use to annotate for coverage Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
433 434 435 436 437
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
438
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
439 440 441

(defcustom verilog-simulator
  "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'"
442
  "*Program and arguments to use to interpret Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
443 444 445 446 447
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
448
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
449 450 451

(defcustom verilog-compiler
  "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'"
452
  "*Program and arguments to use to compile Verilog source.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
453 454 455 456 457
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
458
;; We don't mark it safe, as it's used as a shell command
Dan Nicolaescu's avatar
Dan Nicolaescu committed
459

Wilson Snyder's avatar
Wilson Snyder committed
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
(defcustom verilog-preprocessor
  ;; Very few tools give preprocessed output, so we'll default to Verilog-Perl
  "vppreproc __FLAGS__ __FILE__"
  "*Program and arguments to use to preprocess Verilog source.
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
475 476
(defvar verilog-tool 'verilog-linter
  "Which tool to use for building compiler-command.
Wilson Snyder's avatar
Wilson Snyder committed
477 478 479 480
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
481 482 483 484 485 486 487 488 489 490 491 492 493

(defcustom verilog-highlight-translate-off nil
  "*Non-nil means background-highlight code excluded from translation.
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
494
;; Note we don't use :safe, as that would break on Emacsen before 22.0.
495
(put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
496

497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
(defcustom verilog-auto-lineup 'declarations
  "*Type of statements to lineup across multiple lines.
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 )
524
		(const :tag "Line up Declarations" declarations)
525 526 527
		(function :tag "Other"))
  :group 'verilog-mode-indent )

Dan Nicolaescu's avatar
Dan Nicolaescu committed
528 529 530 531
(defcustom verilog-indent-level 3
  "*Indentation of Verilog statements with respect to containing block."
  :group 'verilog-mode-indent
  :type 'integer)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
532
(put 'verilog-indent-level 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
533 534

(defcustom verilog-indent-level-module 3
535
  "*Indentation of Module level Verilog statements (eg always, initial).
Dan Nicolaescu's avatar
Dan Nicolaescu committed
536 537 538 539
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
540
(put 'verilog-indent-level-module 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
541 542 543 544 545 546

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

(defcustom verilog-indent-declaration-macros nil
  "*How to treat macro expansions in a declaration.
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)
561
(put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
562 563 564 565 566 567 568 569 570 571 572 573

(defcustom verilog-indent-lists t
  "*How to treat indenting items in a list.
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)
574
(put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
575 576 577 578 579 580

(defcustom verilog-indent-level-behavioral 3
  "*Absolute indentation of first begin in a task or function block.
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
581
(put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
582 583 584 585 586 587

(defcustom verilog-indent-level-directive 1
  "*Indentation to add to each level of `ifdef declarations.
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
588
(put 'verilog-indent-level-directive 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
589 590 591 592 593

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

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

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

(defcustom verilog-auto-indent-on-newline t
  "*True means automatically indent line after newline."
  :group 'verilog-mode-indent
  :type 'boolean)
612
(put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
613 614 615

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

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

(defcustom verilog-indent-begin-after-if t
  "*If true, indent begin statements following if, else, while, for and repeat.
Otherwise, line them up."
  :group 'verilog-mode-indent
Dan Nicolaescu's avatar
Dan Nicolaescu committed
631
  :type 'boolean)
632
(put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
633 634 635 636 637 638


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

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

(defcustom verilog-highlight-p1800-keywords nil
Dan Nicolaescu's avatar
Dan Nicolaescu committed
651 652 653
  "*True means highlight words newly reserved by IEEE-1800.
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.
654
A nil value means highlight these words as appropriate for the SystemVerilog
Dan Nicolaescu's avatar
Dan Nicolaescu committed
655
IEEE-1800 standard.  Note that changing this will require restarting Emacs
656
to see the effect as font color choices are cached by Emacs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
657 658
  :group 'verilog-mode-indent
  :type 'boolean)
659
(put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
660

661 662
(defcustom verilog-highlight-grouping-keywords nil
  "*True means highlight grouping keywords 'begin' and 'end' more dramatically.
663 664
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
665 666 667
grouping constructs allow the structure of the code to be understood at a glance."
  :group 'verilog-mode-indent
  :type 'boolean)
668
(put 'verilog-highlight-grouping-keywords 'safe-local-variable 'verilog-booleanp)
669

Wilson Snyder's avatar
Wilson Snyder committed
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
(defcustom verilog-highlight-modules nil
  "*True means highlight module statements for `verilog-load-file-at-point'.
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
  "*True means highlight module statements for `verilog-load-file-at-point'.
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)

687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
(defcustom verilog-auto-declare-nettype nil
  "*Non-nil specifies the data type to use with `verilog-auto-input' etc.
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."
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-declare-nettype 'safe-local-variable `stringp)

(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'."
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-wire-type 'safe-local-variable `stringp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
703 704 705 706
(defcustom verilog-auto-endcomments t
  "*True means insert a comment /* ... */ after 'end's.
The name of the function or case will be set between the braces."
  :group 'verilog-mode-actions
Dan Nicolaescu's avatar
Dan Nicolaescu committed
707
  :type 'boolean)
708
(put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
709

710 711 712 713 714 715
(defcustom verilog-auto-delete-trailing-whitespace nil
  "*True means to `delete-trailing-whitespace' in `verilog-auto'."
  :group 'verilog-mode-actions
  :type 'boolean)
(put 'verilog-auto-delete-trailing-whitespace 'safe-local-variable 'verilog-booleanp)

716 717 718 719 720 721 722 723 724 725
(defcustom verilog-auto-ignore-concat nil
  "*True means ignore signals in {...} concatenations for AUTOWIRE etc.
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
726 727 728 729 730 731 732
(defcustom verilog-auto-read-includes nil
  "*True means to automatically read includes before AUTOs.
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
733
  :type 'boolean)
734
(put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754

(defcustom verilog-auto-save-policy nil
  "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs.
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
  "*Non-nil indicates to expand a SystemVerilog .* instance ports.
They will be expanded in the same way as if there was a AUTOINST in the
instantiation.  See also `verilog-auto-star' and `verilog-auto-star-save'."
  :group 'verilog-mode-actions
  :type 'boolean)
755
(put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
756 757 758

(defcustom verilog-auto-star-save nil
  "*Non-nil indicates to save to disk SystemVerilog .* instance expansions.
759 760
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
761 762 763 764 765

Instead of setting this, you may want to use /*AUTOINST*/, which will
always be saved."
  :group 'verilog-mode-actions
  :type 'boolean)
766
(put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
767 768 769 770 771 772 773

(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.")

774 775 776 777 778 779
(defvar verilog-diff-function 'verilog-diff-report
  "*Function to run when `verilog-diff-auto' detects differences.
Function takes three arguments, the original buffer, the
difference buffer, and the point in original buffer with the
first difference.")

780 781
;;; Compile support
(require 'compile)
782
(defvar verilog-error-regexp-added nil)
Wilson Snyder's avatar
Wilson Snyder committed
783

784 785 786 787 788 789 790
(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
791
     ".*\\*[WE],[0-9A-Z]+\\(\[[0-9A-Z_,]+\]\\)? (\\([^ \t,]+\\),\\([0-9]+\\)" 2 3)
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
    (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
813
     "^In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\(Warning\\|Error\\|Failure\\)[^\n]*" 1 2)
814
    )
Wilson Snyder's avatar
Wilson Snyder committed
815 816 817 818 819 820
  "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
821
  ;; So we can just map from Emacs to XEmacs
Wilson Snyder's avatar
Wilson Snyder committed
822 823 824
  (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
825 826 827

(defvar verilog-error-font-lock-keywords
  '(
Wilson Snyder's avatar
Wilson Snyder committed
828 829 830 831 832 833 834 835 836 837
    ;; 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
838 839
    ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
    ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
Wilson Snyder's avatar
Wilson Snyder committed
840
    ;; verilog-surefire-2
Dan Nicolaescu's avatar
Dan Nicolaescu committed
841 842
    ("\\(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
843
    ;; verilog-verbose
Dan Nicolaescu's avatar
Dan Nicolaescu committed
844 845 846 847 848 849
    ("\
\\([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
850
    ;; verilog-vcs-1
Dan Nicolaescu's avatar
Dan Nicolaescu committed
851 852
    ("\\(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
853
    ;; verilog-vcs-2
Dan Nicolaescu's avatar
Dan Nicolaescu committed
854 855
    ("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
856
    ;; verilog-vcs-3
Dan Nicolaescu's avatar
Dan Nicolaescu committed
857 858
    ("\\(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
859
    ;; verilog-vcs-4
Dan Nicolaescu's avatar
Dan Nicolaescu committed
860 861
    ("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
862 863 864 865 866 867
    ;; 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
868
    )
Wilson Snyder's avatar
Wilson Snyder committed
869 870
  "*Keywords to also highlight in Verilog *compilation* buffers.
Only used in XEmacs; GNU Emacs uses `verilog-error-regexp-emacs-alist'.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894

(defcustom verilog-library-flags '("")
  "*List of standard Verilog arguments to use for /*AUTOINST*/.
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
895
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
896 897 898 899 900
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
901
(put 'verilog-library-flags 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916

(defcustom verilog-library-directories '(".")
  "*List of directories when looking for files for /*AUTOINST*/.
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
917
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
918 919 920 921 922 923
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
924
(put 'verilog-library-directories 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
925 926

(defcustom verilog-library-files '()
Dan Nicolaescu's avatar
Dan Nicolaescu committed
927 928
  "*List of files to search for modules.
AUTOINST will use this when it needs to resolve a module name.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
929 930 931 932 933 934 935 936 937 938 939
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
940
are only insured to be correct when the file is first visited.  Thus if you
Dan Nicolaescu's avatar
Dan Nicolaescu committed
941 942 943 944 945
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
946
(put 'verilog-library-files 'safe-local-variable 'listp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
947

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

(defcustom verilog-active-low-regexp nil
  "*If set, treat signals matching this regexp as active low.
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
961
(put 'verilog-active-low-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
962 963 964 965 966

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

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

980 981 982 983
(defcustom verilog-auto-reset-blocking-in-non t
  "*If true, AUTORESET will reset those signals which were
assigned with blocking assignments (=) even in a block with
non-blocking assignments (<=).
Paul Eggert's avatar
Paul Eggert committed
984

985 986 987 988 989 990 991 992
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'."
  :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
993 994 995 996 997
(defcustom verilog-auto-reset-widths t
  "*If true, AUTORESET should determine the width of signals.
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
the constant zero.  This may result in ugly code when parameters determine
998
the MSB or LSB of a signal inside an AUTORESET."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
999 1000
  :type 'boolean
  :group 'verilog-mode-auto)
1001
(put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1002 1003 1004

(defcustom verilog-assignment-delay ""
  "*Text used for delays in delayed assignments.  Add a trailing space if set."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1005 1006 1007
  :group 'verilog-mode-auto
  :type 'string)
(put 'verilog-assignment-delay 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1008

1009
(defcustom verilog-auto-arg-sort nil
Paul Eggert's avatar
Paul Eggert committed
1010
  "*If set, AUTOARG signal names will be sorted, not in declaration order.
1011 1012 1013
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
1014 1015 1016
it's bad practice to rely on order based instantiations anyhow.

See also `verilog-auto-inst-sort'."
1017 1018 1019 1020
  :group 'verilog-mode-auto
  :type 'boolean)
(put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp)

Wilson Snyder's avatar
Wilson Snyder committed
1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
(defcustom verilog-auto-inst-dot-name nil
  "*If true, when creating ports with AUTOINST, use .name syntax.
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)

1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
(defcustom verilog-auto-inst-param-value nil
  "*If set, AUTOINST will replace parameters with the parameter value.
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
inputs.  This is then used by a upper module:

Wilson Snyder's avatar
Wilson Snyder committed
1042
	module InstModule (o,i);
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065
	   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)
1066
(put 'verilog-auto-inst-param-value 'safe-local-variable 'verilog-booleanp)
1067

1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
(defcustom verilog-auto-inst-sort nil
  "*If set, AUTOINST signal names will be sorted, not in declaration order.
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'."
  :group 'verilog-mode-auto
  :type 'boolean)
(put 'verilog-auto-inst-sort 'safe-local-variable 'verilog-booleanp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
1080 1081 1082 1083
(defcustom verilog-auto-inst-vector t
  "*If true, when creating default ports with AUTOINST, use bus subscripts.
If nil, skip the subscript when it matches the entire bus as declared in
the module (AUTOWIRE signals always are subscripted, you must manually
1084 1085
declare the wire to have the subscripts removed.)  Setting this to nil may
speed up some simulators, but is less general and harder to read, so avoid."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1086
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1087
  :type 'boolean)
1088
(put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1089 1090 1091

(defcustom verilog-auto-inst-template-numbers nil
  "*If true, when creating templated ports with AUTOINST, add a comment.
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101

If t, the comment will add the line number of the template that
was used for that port declaration.  This setting is suggested
only for debugging use, as regular use may cause a large numbers
of merge conflicts.

If 'lhs', the comment will show the left hand side of the
AUTO_TEMPLATE rule that is matched.  This is less precise than
numbering (t) when multiple rules have the same pin name, but
won't merge conflict."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1102
  :group 'verilog-mode-auto
1103 1104 1105
  :type '(choice (const nil) (const t) (const lhs)))
(put 'verilog-auto-inst-template-numbers 'safe-local-variable
     '(lambda (x) (memq x '(nil t lhs))))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1106

1107 1108 1109 1110 1111
(defcustom verilog-auto-inst-column 40
  "*Indent-to column number for net name part of AUTOINST created pin."
  :group 'verilog-mode-indent
  :type 'integer)
(put 'verilog-auto-inst-column 'safe-local-variable 'integerp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1112 1113 1114 1115 1116

(defcustom verilog-auto-input-ignore-regexp nil
  "*If set, when creating AUTOINPUT list, ignore signals matching this regexp.
See the \\[verilog-faq] for examples on using this."
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1117 1118
  :type 'string)
(put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1119 1120 1121 1122 1123

(defcustom verilog-auto-inout-ignore-regexp nil
  "*If set, when creating AUTOINOUT list, ignore signals matching this regexp.
See the \\[verilog-faq] for examples on using this."
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1124 1125
  :type 'string)
(put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1126 1127 1128 1129 1130

(defcustom verilog-auto-output-ignore-regexp nil
  "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp.
See the \\[verilog-faq] for examples on using this."
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1131 1132
  :type 'string)
(put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1133

1134 1135 1136 1137 1138 1139 1140 1141
(defcustom verilog-auto-tieoff-declaration "wire"
  "*Data type used for the declaration for AUTOTIEOFF.  If \"wire\" then
create a wire, if \"assign\" create an assignment, else the data type for
variable creation."
  :group 'verilog-mode-auto
  :type 'string)
(put 'verilog-auto-tieoff-declaration 'safe-local-variable 'stringp)

Wilson Snyder's avatar
Wilson Snyder committed
1142 1143 1144 1145 1146 1147 1148
(defcustom verilog-auto-tieoff-ignore-regexp nil
  "*If set, when creating AUTOTIEOFF list, ignore signals matching this regexp.
See the \\[verilog-faq] for examples on using this."
  :group 'verilog-mode-auto
  :type 'string)
(put 'verilog-auto-tieoff-ignore-regexp 'safe-local-variable 'stringp)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
1149 1150 1151 1152
(defcustom verilog-auto-unused-ignore-regexp nil
  "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp.
See the \\[verilog-faq] for examples on using this."
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1153 1154
  :type 'string)
(put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1155 1156 1157 1158 1159

(defcustom verilog-typedef-regexp nil
  "*If non-nil, regular expression that matches Verilog-2001 typedef names.
For example, \"_t$\" matches typedefs named with _t, as in the C language."
  :group 'verilog-mode-auto
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1160 1161
  :type 'string)
(put 'verilog-typedef-regexp 'safe-local-variable 'stringp)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1162 1163

(defcustom verilog-mode-hook   'verilog-set-compile-command
1164
  "*Hook run after Verilog mode is loaded."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1165 1166 1167 1168 1169
  :type 'hook
  :group 'verilog-mode)

(defcustom verilog-auto-hook nil
  "*Hook run after `verilog-mode' updates AUTOs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1170 1171
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1172 1173 1174

(defcustom verilog-before-auto-hook nil
  "*Hook run before `verilog-mode' updates AUTOs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1175 1176
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1177 1178 1179

(defcustom verilog-delete-auto-hook nil
  "*Hook run after `verilog-mode' deletes AUTOs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1180 1181
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1182 1183 1184

(defcustom verilog-before-delete-auto-hook nil
  "*Hook run before `verilog-mode' deletes AUTOs."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1185 1186
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1187 1188 1189

(defcustom verilog-getopt-flags-hook nil
  "*Hook run after `verilog-getopt-flags' determines the Verilog option lists."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1190 1191
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1192 1193 1194

(defcustom verilog-before-getopt-flags-hook nil
  "*Hook run before `verilog-getopt-flags' determines the Verilog option lists."
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1195 1196
  :group 'verilog-mode-auto
  :type 'hook)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1197 1198 1199 1200

(defvar verilog-imenu-generic-expression
  '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4)
    ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3))
1201
  "Imenu expression for Verilog mode.  See `imenu-generic-expression'.")
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212

;;
;; provide a verilog-header function.
;; Customization variables:
;;
(defvar verilog-date-scientific-format nil
  "*If non-nil, dates are written in scientific format (e.g.  1997/09/17).
If nil, in European format (e.g.  17.09.1997).  The brain-dead American
format (e.g.  09/17/1997) is not supported.")

(defvar verilog-company nil
1213
  "*Default name of Company for Verilog header.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1214
If set will become buffer local.")
1215 1216
(make-variable-buffer-local 'verilog-company)

Dan Nicolaescu's avatar
Dan Nicolaescu committed
1217
(defvar verilog-project nil
1218
  "*Default name of Project for Verilog header.
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1219
If set will become buffer local.")
1220 1221
(make-variable-buffer-local 'verilog-project)

1222
(defvar verilog-mode-map
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240
  (let ((map (make-sparse-keymap)))
    (define-key map ";"        'electric-verilog-semi)
    (define-key map [(control 59)]    'electric-verilog-semi-with-comment)
    (define-key map ":"        'electric-verilog-colon)
    ;;(define-key map "="        'electric-verilog-equal)
    (define-key map "\`"       'electric-verilog-tick)
    (define-key map "\t"       'electric-verilog-tab)
    (define-key map "\r"       'electric-verilog-terminate-line)
    ;; backspace/delete key bindings
    (define-key map [backspace]    'backward-delete-char-untabify)
    (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable
      (define-key map [delete]       'delete-char)
      (define-key map [(meta delete)] 'kill-word))
    (define-key map "\M-\C-b"  'electric-verilog-backward-sexp)
    (define-key map "\M-\C-f"  'electric-verilog-forward-sexp)
    (define-key map "\M-\r"    `electric-verilog-terminate-and-indent)
    (define-key map "\M-\t"    'verilog-complete-word)
    (define-key map "\M-?"     'verilog-show-completions)
1241
    ;; Note \C-c and letter are reserved for users
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1242 1243
    (define-key map "\C-c\`"   'verilog-lint-off)
    (define-key map "\C-c\*"   'verilog-delete-auto-star-implicit)
1244
    (define-key map "\C-c\?"   'verilog-diff-auto)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1245 1246 1247 1248 1249 1250 1251
    (define-key map "\C-c\C-r" 'verilog-label-be)
    (define-key map "\C-c\C-i" 'verilog-pretty-declarations)
    (define-key map "\C-c="    'verilog-pretty-expr)
    (define-key map "\C-c\C-b" 'verilog-submit-bug-report)
    (define-key map "\M-*"     'verilog-star-comment)
    (define-key map "\C-c\C-c" 'verilog-comment-region)
    (define-key map "\C-c\C-u" 'verilog-uncomment-region)
1252 1253 1254 1255
    (when (featurep 'xemacs)
      (define-key map [(meta control h)] 'verilog-mark-defun)
      (define-key map "\M-\C-a"  'verilog-beg-of-defun)
      (define-key map "\M-\C-e"  'verilog-end-of-defun))
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1256 1257 1258 1259
    (define-key map "\C-c\C-d" 'verilog-goto-defun)
    (define-key map "\C-c\C-k" 'verilog-delete-auto)
    (define-key map "\C-c\C-a" 'verilog-auto)
    (define-key map "\C-c\C-s" 'verilog-auto-save-compile)
Wilson Snyder's avatar
Wilson Snyder committed
1260
    (define-key map "\C-c\C-p" 'verilog-preprocess)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1261 1262
    (define-key map "\C-c\C-z" 'verilog-inject-auto)
    (define-key map "\C-c\C-e" 'verilog-expand-vector)
1263 1264
    (define-key map "\C-c\C-h" 'verilog-header)
    map)
Dan Nicolaescu's avatar
Dan Nicolaescu committed
1265 1266 1267
  "Keymap used in Verilog mode.")

;; menus
1268 1269
(easy-menu-define
  verilog-menu verilog-mode-map "Menu for Verilog mode"
1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
  (verilog-easy-menu-filter
   '("Verilog"
     ("Choose Compilation Action"
      ["None"
       (progn
	 (setq verilog-tool nil)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool nil)
       :help "When invoking compilation, use compile-command"]
      ["Lint"
       (progn
	 (setq verilog-tool 'verilog-linter)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool `verilog-linter)
       :help "When invoking compilation, use lint checker"]
      ["Coverage"
       (progn
	 (setq verilog-tool 'verilog-coverage)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool `verilog-coverage)
       :help "When invoking compilation, annotate for coverage"]
      ["Simulator"
       (progn
	 (setq verilog-tool 'verilog-simulator)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool `verilog-simulator)
       :help "When invoking compilation, interpret Verilog source"]
      ["Compiler"
       (progn
	 (setq verilog-tool 'verilog-compiler)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool `verilog-compiler)
       :help "When invoking compilation, compile Verilog source"]
Wilson Snyder's avatar
Wilson Snyder committed
1308 1309 1310 1311 1312 1313 1314
      ["Preprocessor"
       (progn
	 (setq verilog-tool 'verilog-preprocessor)
	 (verilog-set-compile-command))
       :style radio
       :selected (equal verilog-tool `verilog-preprocessor)
       :help "When invoking compilation, preprocess Verilog source, see also `verilog-preprocess'"]
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369
      )
     ("Move"
      ["Beginning of function"		verilog-beg-of-defun
       :keys "C-M-a"
       :help		"Move backward to the beginning of the current function or procedure"]
      ["End of function"		verilog-end-of-defun
       :keys "C-M-e"
       :help		"Move forward to the end of the current function or procedure"]
      ["Mark function"			verilog-mark-defun
       :keys "C-M-h"
       :help		"Mark the current Verilog function or procedure"]
      ["Goto function/module"		verilog-goto-defun
       :help		"Move to specified Verilog module/task/function"]
      ["Move to beginning of block"	electric-verilog-backward-sexp
       :help		"Move backward over one balanced expression"]
      ["Move to end of block"		electric-verilog-forward-sexp
       :help		"Move forward over one balanced expression"]
      )
     ("Comments"
      ["Comment Region"			verilog-comment-region
       :help		"Put marked area into a comment"]
      ["UnComment Region"		verilog-uncomment-region
       :help		"Uncomment an area commented with Comment Region"]
      ["Multi-line comment insert"	verilog-star-comment
       :help		"Insert Verilog /* */ comment at point"]
      ["Lint error to comment"		verilog-lint-off
       :help		"Convert a Verilog linter warning line into a disable statement"]
      )
     "----"
     ["Compile"				compile
      :help		"Perform compilation-action (above) on the current buffer"]
     ["AUTO, Save, Compile"		verilog-auto-save-compile
      :help		"Recompute AUTOs, save buffer, and compile"]
     ["Next Compile Error"		next-error
      :help		"Visit next compilation error message and corresponding source code"]
     ["Ignore Lint Warning at point"	verilog-lint-off
      :help		"Convert a Verilog linter warning line into a disable statement"]
     "----"
     ["Line up declarations around point"	verilog-pretty-declarations
      :help		"Line up declarations around point"]
     ["Line up equations around point"		verilog-pretty-expr
      :help		"Line up expressions around point"]
     ["Redo/insert comments on every end"	verilog-label-be
      :help		"Label matching begin ... end statements"]
     ["Expand [x:y] vector line"	verilog-expand-vector
      :help		"Take a signal vector on the current line and expand it to multiple lines"]
     ["Insert begin-end block"		verilog-insert-block
      :help		"Insert begin ... end"]
     ["Complete word"			verilog-complete-word
      :help		"Complete word at point"]
     "----"
     ["Recompute AUTOs"			verilog-auto
      :help		"Expand AUTO meta-comment statements"]
     ["Kill AUTOs"			verilog-delete-auto
      :help		"Remove AUTO expansions"]
1370 1371
     ["Diff AUTOs"			verilog-diff-auto
      :help		"Show differences in AUTO expansions"]
1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
     ["Inject AUTOs"			verilog-inject-auto
      :help		"Inject AUTOs into legacy non-AUTO buffer"]
     ("AUTO Help..."
      ["AUTO General"			(describe-function 'verilog-auto)
       :help		"Help introduction on AUTOs"]
      ["AUTO Library Flags"		(describe-variable 'verilog-library-flags)
       :help		"Help on verilog-library-flags"]
      ["AUTO Library Path"		(describe-variable 'verilog-library-directories)
       :help		"Help on verilog-library-directories"]
      ["AUTO Library Files"		(describe-variable 'verilog-library-files)
       :help		"Help on verilog-library-files"]
      ["AUTO Library Extensions"	(describe-variable 'verilog-library-extensions)
       :help		"Help on verilog-library-extensions"]
      ["AUTO `define Reading"		(describe-function 'verilog-read-defines)
       :help		"Help on reading `defines"]
      ["AUTO `include Reading"		(describe-function 'verilog-read-includes)
       :help		"Help on parsing `includes"]
      ["AUTOARG"			(describe-function 'verilog-auto-arg)
       :help		"Help on AUTOARG - declaring module port list"]
      ["AUTOASCIIENUM"			(describe-function 'verilog-auto-ascii-enum)
       :help		"Help on AUTOASCIIENUM - creating ASCII for enumerations"]
1393
      ["AUTOINOUTCOMP"			(describe-function 'verilog-auto-inout-comp)
1394
       :help		"Help on AUTOINOUTCOMP - copying complemented i/o from another file"]
1395 1396
      ["AUTOINOUTIN"			(describe-function 'verilog-auto-inout-in)
       :help		"Help on AUTOINOUTCOMP - copying i/o from another file as all inputs"]
1397 1398
      ["AUTOINOUTMODULE"		(describe-function 'verilog-auto-inout-module)
       :help		"Help on AUTOINOUTMODULE - copying i/o from another file"]
1399 1400
      ["AUTOINSERTLISP"			(describe-function 'verilog-auto-insert-lisp)
       :help		"Help on AUTOINSERTLISP - insert text from a lisp function"]
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410
      ["AUTOINOUT"			(describe-function 'verilog-auto-inout)
       :help		"Help on AUTOINOUT - adding inouts from cells"]
      ["AUTOINPUT"			(describe-function 'verilog-auto-input)
       :help		"Help on AUTOINPUT - adding inputs from cells"]
      ["AUTOINST"			(describe-function 'verilog-auto-inst)
       :help		"Help on AUTOINST - adding pins for cells"]
      ["AUTOINST (.*)"			(describe-function 'verilog-auto-star)
       :help		"Help on expanding Verilog-2001 .* pins"]
      ["AUTOINSTPARAM"			(describe-function 'verilog-auto-inst-param)
       :help		"Help on AUTOINSTPARAM - adding parameter pins to cells"]
1411 1412
      ["AUTOLOGIC"			(describe-function 'verilog-auto-logic)
       :help		"Help on AUTOLOGIC - declaring logic signals"]
1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440
      ["AUTOOUTPUT"			(describe-function 'verilog-auto-output)
       :help		"Help on AUTOOUTPUT - adding outputs from cells"]
      ["AUTOOUTPUTEVERY"		(describe-function 'verilog-auto-output-every)
       :help		"Help on AUTOOUTPUTEVERY - adding outputs of all signals"]
      ["AUTOREG"			(describe-function 'verilog-auto-reg)
       :help		"Help on AUTOREG - declaring registers for non-wires"]
      ["AUTOREGINPUT"			(describe-function 'verilog-auto-reg-input)
       :help		"Help on AUTOREGINPUT - declaring inputs for non-wires"]
      ["AUTORESET"			(describe-function 'verilog-auto-reset)
       :help		"Help on AUTORESET - resetting always blocks"]
      ["AUTOSENSE"			(describe-function 'verilog-auto-sense)
       :help		"Help on AUTOSENSE - sensitivity lists for always blocks"]
      ["AUTOTIEOFF"			(describe-function 'verilog-auto-tieoff)
       :help		"Help on AUTOTIEOFF - tieing off unused outputs"]
      ["AUTOUNUSED"			(describe-function 'verilog-auto-unused)
       :help		"Help on AUTOUNUSED - terminating unused inputs"]
      ["AUTOWIRE"			(describe-function 'verilog-auto-wire)
       :help		"Help on AUTOWIRE - declaring wires for cells"]
      )
     "----"
     ["Submit bug report"		verilog-submit-bug-report
      :help		"Submit via mail a bug report on verilog-mode.el"]
     ["Version and FAQ"			verilog-faq
      :help		"Show the current version, and where to get the FAQ etc"]
     ["Customize Verilog Mode..."	verilog-customize
      :help		"Customize variables and other settings used by Verilog-Mode"]
     ["Customize Verilog Fonts & Colors"	verilog-font-customize
      :help		"Customize fonts used by Verilog-Mode."])))