Mercurial > emacs
annotate lisp/progmodes/verilog-mode.el @ 80163:22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
(verilog-mode, verilog-mode-indent, verilog-mode-actions)
(verilog-mode-auto, verilog-indent-level-module)
(verilog-minimum-comment-distance, verilog-library-flags)
(verilog-library-directories, verilog-library-files)
(verilog-auto-reset-widths, verilog-imenu-generic-expression)
(verilog-xemacs-menu, verilog-set-compile-command)
(verilog-set-compile-command, verilog-mode-syntax-table, verilog-mode)
(verilog-get-expr, verilog-strip-comments, verilog-one-line)
(verilog-lint-off, verilog-batch-auto, verilog-batch-delete-auto)
(verilog-batch-inject-auto, verilog-batch-indent)
(verilog-continued-line, verilog-type-keywords)
(verilog-read-sub-decls-sig, verilog-read-sub-decls-line)
(verilog-read-inst-pins, verilog-read-arg-pins)
(verilog-read-auto-template, verilog-read-signals, verilog-getopt-file)
(verilog-add-list-unique, verilog-symbol-detick, verilog-modi-filename)
(verilog-auto-star, verilog-auto-inst, verilog-auto-wire)
(verilog-enum-ascii, verilog-sk-begin, verilog-sk-fork)
(verilog-sk-datadef, verilog-colorize-include-files-buffer)
(verilog-mode-version, verilog-mode-release-date)
(verilog-mode-release-emacs, verilog-linter, verilog-coverage)
(verilog-simulator, verilog-compiler)
(verilog-auto-sense-defines-constant, verilog-company)
(verilog-project, verilog-mark-defun, verilog-submit-bug-report):
Fix typos in docstrings.
(verilog-set-auto-endcomments, verilog-calculate-indent)
(verilog-inject-auto, verilog-auto-arg, verilog-auto-inout-module):
Reflow docstrings.
(verilog-tab-always-indent, verilog-highlight-p1800-keywords)
(verilog-auto-star-save, verilog-auto-inst-vector, verilog-mode-hook)
(electric-verilog-forward-sexp, verilog-in-case-region-p)
(verilog-in-struct-region-p, verilog-in-generate-region-p)
(verilog-leap-to-head, verilog-current-indent-level)
(verilog-case-indent-level, verilog-cpp-keywords)
(verilog-defun-keywords, verilog-block-keywords, verilog-tf-keywords)
(verilog-case-keywords, verilog-separator-keywords, verilog-completion)
(verilog-signals-not-in, verilog-symbol-detick-text)
(verilog-modi-cache-preserve-tick, verilog-modi-cache-preserve-buffer)
(verilog-forward-close-paren, verilog-backward-open-paren)
(verilog-backward-open-bracket): Doc fixes.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Wed, 20 Feb 2008 16:15:03 +0000 |
parents | adbd1e116992 |
children | 411da0873a97 |
rev | line source |
---|---|
79545 | 1 ;; verilog-mode.el --- major mode for editing verilog source in Emacs |
79551 | 2 |
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | |
79717 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
79545 | 5 |
6 ;; Author: Michael McNamara (mac@verilog.com) | |
7 ;; http://www.verilog.com | |
8 ;; | |
9 ;; AUTO features, signal, modsig; by: Wilson Snyder | |
10 ;; (wsnyder@wsnyder.org) | |
11 ;; http://www.veripool.com | |
12 ;; Keywords: languages | |
13 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
14 ;; This code supports Emacs 21.1 and later |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
15 ;; And XEmacs 21.1 and later |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
16 ;; Please do not make changes that break Emacs 21. Thanks! |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
17 ;; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
18 ;; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
19 |
79551 | 20 ;; This file is part of GNU Emacs. |
21 | |
22 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
79545 | 23 ;; it under the terms of the GNU General Public License as published by |
79551 | 24 ;; the Free Software Foundation; either version 3, or (at your option) |
25 ;; any later version. | |
26 | |
27 ;; GNU Emacs is distributed in the hope that it will be useful, | |
79545 | 28 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
29 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
30 ;; GNU General Public License for more details. | |
31 | |
32 ;; You should have received a copy of the GNU General Public License | |
79551 | 33 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
34 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
35 ;; Boston, MA 02110-1301, USA. | |
79545 | 36 |
37 ;;; Commentary: | |
38 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
39 ;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs |
79545 | 40 |
41 ;; USAGE | |
42 ;; ===== | |
43 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
44 ;; A major mode for editing Verilog HDL source code. When you have |
79545 | 45 ;; entered Verilog mode, you may get more info by pressing C-h m. You |
46 ;; may also get online help describing various functions by: C-h f | |
47 ;; <Name of function you want described> | |
48 | |
49 ;; KNOWN BUGS / BUG REPORTS | |
50 ;; ======================= | |
51 | |
52 ;; Verilog is a rapidly evolving language, and hence this mode is | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
53 ;; under continuous development. Hence this is beta code, and likely |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
54 ;; has bugs. Please report any and all bugs to me at mac@verilog.com. |
79545 | 55 ;; Please use verilog-submit-bug-report to submit a report; type C-c |
56 ;; C-b to invoke this and as a result I will have a much easier time | |
57 ;; of reproducing the bug you find, and hence fixing it. | |
58 | |
59 ;; INSTALLING THE MODE | |
60 ;; =================== | |
61 | |
62 ;; An older version of this mode may be already installed as a part of | |
63 ;; your environment, and one method of updating would be to update | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
64 ;; your Emacs environment. Sometimes this is difficult for local |
79545 | 65 ;; political/control reasons, and hence you can always install a |
66 ;; private copy (or even a shared copy) which overrides the system | |
67 ;; default. | |
68 | |
69 ;; You can get step by step help in installing this file by going to | |
70 ;; <http://www.verilog.com/emacs_install.html> | |
71 | |
72 ;; The short list of installation instructions are: To set up | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
73 ;; automatic verilog mode, put this file in your load path, and put |
79545 | 74 ;; the following in code (please un comment it first!) in your |
75 ;; .emacs, or in your site's site-load.el | |
76 | |
77 ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) | |
78 ; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist)) | |
79 ; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist)) | |
80 | |
81 ;; If you want to customize Verilog mode to fit your needs better, | |
82 ;; you may add these lines (the values of the variables presented | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
83 ;; here are the defaults). Note also that if you use an Emacs that |
79545 | 84 ;; supports custom, it's probably better to use the custom menu to |
85 ;; edit these. | |
86 ;; | |
87 ;; Be sure to examine at the help for verilog-auto, and the other | |
88 ;; verilog-auto-* functions for some major coding time savers. | |
89 ;; | |
90 ; ;; User customization for Verilog mode | |
91 ; (setq verilog-indent-level 3 | |
92 ; verilog-indent-level-module 3 | |
93 ; verilog-indent-level-declaration 3 | |
94 ; verilog-indent-level-behavioral 3 | |
95 ; verilog-indent-level-directive 1 | |
96 ; verilog-case-indent 2 | |
97 ; verilog-auto-newline t | |
98 ; verilog-auto-indent-on-newline t | |
99 ; verilog-tab-always-indent t | |
100 ; verilog-auto-endcomments t | |
101 ; verilog-minimum-comment-distance 40 | |
102 ; verilog-indent-begin-after-if t | |
103 ; verilog-auto-lineup '(all) | |
104 ; verilog-highlight-p1800-keywords nil | |
105 ; verilog-linter "my_lint_shell_command" | |
106 ; ) | |
107 | |
108 ;; | |
109 | |
110 ;;; History: | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
111 ;; |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
112 ;; See commit history at http://www.veripool.com/verilog-mode.html |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
113 ;; (This section is required to appease checkdoc.) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
114 |
79545 | 115 ;;; Code: |
116 | |
117 ;; This variable will always hold the version number of the mode | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
118 (defconst verilog-mode-version "389" |
80143
adbd1e116992
(verilog-mode-version, verilog-mode-release-date, erilog-mode-release-emacs,
Juanma Barranquero <lekktu@gmail.com>
parents:
80141
diff
changeset
|
119 "Version of this Verilog mode.") |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
120 (defconst verilog-mode-release-date "2008-02-01-GNU" |
80143
adbd1e116992
(verilog-mode-version, verilog-mode-release-date, erilog-mode-release-emacs,
Juanma Barranquero <lekktu@gmail.com>
parents:
80141
diff
changeset
|
121 "Release date of this Verilog mode.") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
122 (defconst verilog-mode-release-emacs t |
80143
adbd1e116992
(verilog-mode-version, verilog-mode-release-date, erilog-mode-release-emacs,
Juanma Barranquero <lekktu@gmail.com>
parents:
80141
diff
changeset
|
123 "If non-nil, this version of Verilog mode was released with Emacs itself.") |
79545 | 124 |
125 (defun verilog-version () | |
126 "Inform caller of the version of this file." | |
127 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
128 (message "Using verilog-mode version %s" verilog-mode-version)) |
79545 | 129 |
130 ;; Insure we have certain packages, and deal with it if we don't | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
131 ;; Be sure to note which Emacs flavor and version added each feature. |
79546 | 132 (eval-when-compile |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
133 ;; The below were disabled when GNU Emacs 22 was released; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
134 ;; perhaps some still need to be there to support Emacs 21. |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
135 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
136 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
137 (require 'easymenu) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
138 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
139 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
140 (require 'regexp-opt) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
141 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
142 ;; Bug in 19.28 through 19.30 skeleton.el, not provided. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
143 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
144 (load "skeleton") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
145 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
146 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
147 (if (fboundp 'when) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
148 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
149 (defmacro when (cond &rest body) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
150 (list 'if cond (cons 'progn body)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
151 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
152 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
153 (if (fboundp 'unless) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
154 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
155 (defmacro unless (cond &rest body) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
156 (cons 'if (cons cond (cons nil body))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
157 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
158 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
159 (if (fboundp 'store-match-data) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
160 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
161 (defmacro store-match-data (&rest args) nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
162 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
163 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
164 (if (boundp 'current-menubar) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
165 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
166 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
167 (defmacro add-submenu (&rest args) nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
168 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
169 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
170 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
171 (if (fboundp 'char-before) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
172 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
173 (defmacro char-before (&rest body) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
174 (char-after (1- (point))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
175 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
176 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
177 (require 'custom) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
178 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
179 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
180 (if (fboundp 'match-string-no-properties) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
181 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
182 (defsubst match-string-no-properties (num &optional string) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
183 "Return string of text matched by last search, without text properties. |
79545 | 184 NUM specifies which parenthesized expression in the last regexp. |
185 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. | |
186 Zero means the entire text matched by the whole regexp or whole string. | |
187 STRING should be given if the last search was by `string-match' on STRING." | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
188 (if (match-beginning num) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
189 (if string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
190 (let ((result |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
191 (substring string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
192 (match-beginning num) (match-end num)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
193 (set-text-properties 0 (length result) nil result) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
194 result) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
195 (buffer-substring-no-properties (match-beginning num) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
196 (match-end num) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
197 (current-buffer))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
198 ) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
199 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
200 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
201 nil ;; We've got what we needed |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
202 ;; We have the old custom-library, hack around it! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
203 (defmacro defgroup (&rest args) nil) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
204 (defmacro customize (&rest args) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
205 (message |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
206 "Sorry, Customize is not available with this version of emacs")) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
207 (defmacro defcustom (var value doc &rest args) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
208 `(defvar ,var ,value ,doc)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
209 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
210 (if (fboundp 'defface) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
211 nil ; great! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
212 (defmacro defface (var values doc &rest args) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
213 `(make-face ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
214 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
215 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
216 (if (and (featurep 'custom) (fboundp 'customize-group)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
217 nil ;; We've got what we needed |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
218 ;; We have an intermediate custom-library, hack around it! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
219 (defmacro customize-group (var &rest args) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
220 `(customize ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
221 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
222 |
79545 | 223 ;; Provide a regular expression optimization routine, using regexp-opt |
224 ;; if provided by the user's elisp libraries | |
225 (eval-and-compile | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
226 ;; The below were disabled when GNU Emacs 22 was released; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
227 ;; perhaps some still need to be there to support Emacs 21. |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
228 (if (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
229 (if (fboundp 'regexp-opt) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
230 ;; regexp-opt is defined, does it take 3 or 2 arguments? |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
231 (if (fboundp 'function-max-args) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
232 (let ((args (function-max-args `regexp-opt))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
233 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
234 ((eq args 3) ;; It takes 3 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
235 (condition-case nil ; Hide this defun from emacses |
79545 | 236 ;with just a two input regexp |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
237 (defun verilog-regexp-opt (a b) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
238 "Deal with differing number of required arguments for `regexp-opt'. |
79545 | 239 Call 'regexp-opt' on A and B." |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
240 (regexp-opt a b 't)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
241 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
242 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
243 ((eq args 2) ;; It takes 2 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
244 (defun verilog-regexp-opt (a b) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
245 "Call 'regexp-opt' on A and B." |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
246 (regexp-opt a b)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
247 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
248 (t nil))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
249 ;; We can't tell; assume it takes 2 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
250 (defun verilog-regexp-opt (a b) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
251 "Call 'regexp-opt' on A and B." |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
252 (regexp-opt a b)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
253 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
254 ;; There is no regexp-opt, provide our own |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
255 (defun verilog-regexp-opt (strings &optional paren shy) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
256 (let ((open (if paren "\\(" "")) (close (if paren "\\)" ""))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
257 (concat open (mapconcat 'regexp-quote strings "\\|") close))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
258 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
259 ;; Emacs. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
260 (defalias 'verilog-regexp-opt 'regexp-opt))) |
79545 | 261 |
79555
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
262 (eval-when-compile |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
263 (defun verilog-regexp-words (a) |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
264 "Call 'regexp-opt' with word delimiters for the words A." |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
265 (concat "\\<" (verilog-regexp-opt a t) "\\>"))) |
79545 | 266 |
267 (defun verilog-customize () | |
268 "Link to customize screen for Verilog." | |
269 (interactive) | |
270 (customize-group 'verilog-mode)) | |
271 | |
272 (defun verilog-font-customize () | |
273 "Link to customize fonts used for Verilog." | |
274 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
275 (if (fboundp 'customize-apropos) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
276 (customize-apropos "font-lock-*" 'faces))) |
79545 | 277 |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
278 (defun verilog-booleanp (value) |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
279 "Return t if VALUE is boolean. |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
280 This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs. |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
281 This function may be removed when Emacs 21 is no longer supported." |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
282 (or (equal value t) (equal value nil))) |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
283 |
79545 | 284 (defgroup verilog-mode nil |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
285 "Facilitates easy editing of Verilog source text" |
79545 | 286 :group 'languages) |
287 | |
288 ; (defgroup verilog-mode-fonts nil | |
289 ; "Facilitates easy customization fonts used in Verilog source text" | |
290 ; :link '(customize-apropos "font-lock-*" 'faces) | |
291 ; :group 'verilog-mode) | |
292 | |
293 (defgroup verilog-mode-indent nil | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
294 "Customize indentation and highlighting of verilog source text" |
79545 | 295 :group 'verilog-mode) |
296 | |
297 (defgroup verilog-mode-actions nil | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
298 "Customize actions on verilog source text" |
79545 | 299 :group 'verilog-mode) |
300 | |
301 (defgroup verilog-mode-auto nil | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
302 "Customize AUTO actions when expanding verilog source text" |
79545 | 303 :group 'verilog-mode) |
304 | |
305 (defcustom verilog-linter | |
306 "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'" | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
307 "*Unix program and arguments to call to run a lint checker on verilog source. |
79545 | 308 Depending on the `verilog-set-compile-command', this may be invoked when |
309 you type \\[compile]. When the compile completes, \\[next-error] will take | |
310 you to the next lint error." | |
311 :type 'string | |
312 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
313 ;; We don't mark it safe, as it's used as a shell command |
79545 | 314 |
315 (defcustom verilog-coverage | |
316 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
317 "*Program and arguments to use to annotate for coverage verilog source. |
79545 | 318 Depending on the `verilog-set-compile-command', this may be invoked when |
319 you type \\[compile]. When the compile completes, \\[next-error] will take | |
320 you to the next lint error." | |
321 :type 'string | |
322 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
323 ;; We don't mark it safe, as it's used as a shell command |
79545 | 324 |
325 (defcustom verilog-simulator | |
326 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
327 "*Program and arguments to use to interpret verilog source. |
79545 | 328 Depending on the `verilog-set-compile-command', this may be invoked when |
329 you type \\[compile]. When the compile completes, \\[next-error] will take | |
330 you to the next lint error." | |
331 :type 'string | |
332 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
333 ;; We don't mark it safe, as it's used as a shell command |
79545 | 334 |
335 (defcustom verilog-compiler | |
336 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
337 "*Program and arguments to use to compile verilog source. |
79545 | 338 Depending on the `verilog-set-compile-command', this may be invoked when |
339 you type \\[compile]. When the compile completes, \\[next-error] will take | |
340 you to the next lint error." | |
341 :type 'string | |
342 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
343 ;; We don't mark it safe, as it's used as a shell command |
79545 | 344 |
345 (defvar verilog-tool 'verilog-linter | |
346 "Which tool to use for building compiler-command. | |
347 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | |
348 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | |
349 menu. See `verilog-set-compile-command' for more information.") | |
350 | |
351 (defcustom verilog-highlight-translate-off nil | |
352 "*Non-nil means background-highlight code excluded from translation. | |
353 That is, all code between \"// synopsys translate_off\" and | |
354 \"// synopsys translate_on\" is highlighted using a different background color | |
355 \(face `verilog-font-lock-translate-off-face'). | |
356 | |
357 Note: This will slow down on-the-fly fontification (and thus editing). | |
358 | |
359 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | |
360 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." | |
361 :type 'boolean | |
362 :group 'verilog-mode-indent) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
363 ;; Note we don't use :safe, as that would break on Emacsen before 22.0. |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
364 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp) |
79545 | 365 |
366 (defcustom verilog-indent-level 3 | |
367 "*Indentation of Verilog statements with respect to containing block." | |
368 :group 'verilog-mode-indent | |
369 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
370 (put 'verilog-indent-level 'safe-local-variable 'integerp) |
79545 | 371 |
372 (defcustom verilog-indent-level-module 3 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
373 "*Indentation of Module level Verilog statements. (eg always, initial) |
79545 | 374 Set to 0 to get initial and always statements lined up on the left side of |
375 your screen." | |
376 :group 'verilog-mode-indent | |
377 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
378 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) |
79545 | 379 |
380 (defcustom verilog-indent-level-declaration 3 | |
381 "*Indentation of declarations with respect to containing block. | |
382 Set to 0 to get them list right under containing block." | |
383 :group 'verilog-mode-indent | |
384 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
385 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) |
79545 | 386 |
387 (defcustom verilog-indent-declaration-macros nil | |
388 "*How to treat macro expansions in a declaration. | |
389 If nil, indent as: | |
390 input [31:0] a; | |
391 input `CP; | |
392 output c; | |
393 If non nil, treat as: | |
394 input [31:0] a; | |
395 input `CP ; | |
396 output c;" | |
397 :group 'verilog-mode-indent | |
398 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
399 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp) |
79545 | 400 |
401 (defcustom verilog-indent-lists t | |
402 "*How to treat indenting items in a list. | |
403 If t (the default), indent as: | |
404 always @( posedge a or | |
405 reset ) begin | |
406 | |
407 If nil, treat as: | |
408 always @( posedge a or | |
409 reset ) begin" | |
410 :group 'verilog-mode-indent | |
411 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
412 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp) |
79545 | 413 |
414 (defcustom verilog-indent-level-behavioral 3 | |
415 "*Absolute indentation of first begin in a task or function block. | |
416 Set to 0 to get such code to start at the left side of the screen." | |
417 :group 'verilog-mode-indent | |
418 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
419 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) |
79545 | 420 |
421 (defcustom verilog-indent-level-directive 1 | |
422 "*Indentation to add to each level of `ifdef declarations. | |
423 Set to 0 to have all directives start at the left side of the screen." | |
424 :group 'verilog-mode-indent | |
425 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
426 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) |
79545 | 427 |
428 (defcustom verilog-cexp-indent 2 | |
429 "*Indentation of Verilog statements split across lines." | |
430 :group 'verilog-mode-indent | |
431 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
432 (put 'verilog-cexp-indent 'safe-local-variable 'integerp) |
79545 | 433 |
434 (defcustom verilog-case-indent 2 | |
435 "*Indentation for case statements." | |
436 :group 'verilog-mode-indent | |
437 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
438 (put 'verilog-case-indent 'safe-local-variable 'integerp) |
79545 | 439 |
440 (defcustom verilog-auto-newline t | |
441 "*True means automatically newline after semicolons." | |
442 :group 'verilog-mode-indent | |
443 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
444 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 445 |
446 (defcustom verilog-auto-indent-on-newline t | |
447 "*True means automatically indent line after newline." | |
448 :group 'verilog-mode-indent | |
449 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
450 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 451 |
452 (defcustom verilog-tab-always-indent t | |
453 "*True means TAB should always re-indent the current line. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
454 Nil means TAB will only reindent when at the beginning of the line." |
79545 | 455 :group 'verilog-mode-indent |
456 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
457 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp) |
79545 | 458 |
459 (defcustom verilog-tab-to-comment nil | |
460 "*True means TAB moves to the right hand column in preparation for a comment." | |
461 :group 'verilog-mode-actions | |
462 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
463 (put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp) |
79545 | 464 |
465 (defcustom verilog-indent-begin-after-if t | |
466 "*If true, indent begin statements following if, else, while, for and repeat. | |
467 Otherwise, line them up." | |
468 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
469 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
470 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp) |
79545 | 471 |
472 | |
473 (defcustom verilog-align-ifelse nil | |
474 "*If true, align `else' under matching `if'. | |
475 Otherwise else is lined up with first character on line holding matching if." | |
476 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
477 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
478 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp) |
79545 | 479 |
480 (defcustom verilog-minimum-comment-distance 10 | |
481 "*Minimum distance (in lines) between begin and end required before a comment. | |
482 Setting this variable to zero results in every end acquiring a comment; the | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
483 default avoids too many redundant comments in tight quarters" |
79545 | 484 :group 'verilog-mode-indent |
485 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
486 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) |
79545 | 487 |
488 (defcustom verilog-auto-lineup '(declaration) | |
489 "*Algorithm for lining up statements on multiple lines. | |
490 | |
491 If this list contains the symbol 'all', then all line ups described below | |
492 are done. | |
493 | |
494 If this list contains the symbol 'declaration', then declarations are lined up | |
495 with any preceding declarations, taking into account widths and the like, so | |
496 for example the code: | |
497 reg [31:0] a; | |
498 reg b; | |
499 would become | |
500 reg [31:0] a; | |
501 reg b; | |
502 | |
503 If this list contains the symbol 'assignment', then assignments are lined up | |
504 with any preceding assignments, so for example the code | |
505 a_long_variable = b + c; | |
506 d = e + f; | |
507 would become | |
508 a_long_variable = b + c; | |
509 d = e + f;" | |
510 | |
511 ;; The following is not implemented: | |
512 ;If this list contains the symbol 'case', then case items are lined up | |
513 ;with any preceding case items, so for example the code | |
514 ; case (a) begin | |
515 ; a_long_state : a = 3; | |
516 ; b: a = 4; | |
517 ; endcase | |
518 ;would become | |
519 ; case (a) begin | |
520 ; a_long_state : a = 3; | |
521 ; b : a = 4; | |
522 ; endcase | |
523 ; | |
524 | |
525 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
526 :type 'list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
527 (put 'verilog-auto-lineup 'safe-local-variable 'listp) |
79545 | 528 |
529 (defcustom verilog-highlight-p1800-keywords nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
530 "*True means highlight words newly reserved by IEEE-1800. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
531 These will appear in `verilog-font-lock-p1800-face' in order to gently |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
532 suggest changing where these words are used as variables to something else. |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
533 Nil means highlight these words as appropriate for the SystemVerilog |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
534 IEEE-1800 standard. Note that changing this will require restarting Emacs |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
535 to see the effect as font color choices are cached by Emacs" |
79545 | 536 :group 'verilog-mode-indent |
537 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
538 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp) |
79545 | 539 |
540 (defcustom verilog-auto-endcomments t | |
541 "*True means insert a comment /* ... */ after 'end's. | |
542 The name of the function or case will be set between the braces." | |
543 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
544 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
545 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) |
79545 | 546 |
547 (defcustom verilog-auto-read-includes nil | |
548 "*True means to automatically read includes before AUTOs. | |
549 This will do a `verilog-read-defines' and `verilog-read-includes' before | |
550 each AUTO expansion. This makes it easier to embed defines and includes, | |
551 but can result in very slow reading times if there are many or large | |
552 include files." | |
553 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
554 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
555 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp) |
79545 | 556 |
557 (defcustom verilog-auto-save-policy nil | |
558 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | |
559 A value of `force' will always do a \\[verilog-auto] automatically if | |
560 needed on every save. A value of `detect' will do \\[verilog-auto] | |
561 automatically when it thinks necessary. A value of `ask' will query the | |
562 user when it thinks updating is needed. | |
563 | |
564 You should not rely on the 'ask or 'detect policies, they are safeguards | |
565 only. They do not detect when AUTOINSTs need to be updated because a | |
566 sub-module's port list has changed." | |
567 :group 'verilog-mode-actions | |
568 :type '(choice (const nil) (const ask) (const detect) (const force))) | |
569 | |
570 (defcustom verilog-auto-star-expand t | |
571 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | |
572 They will be expanded in the same way as if there was a AUTOINST in the | |
573 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." | |
574 :group 'verilog-mode-actions | |
575 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
576 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp) |
79545 | 577 |
578 (defcustom verilog-auto-star-save nil | |
579 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
580 Nil indicates direct connections will be removed before saving. Only |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
581 meaningful to those created due to `verilog-auto-star-expand' being set. |
79545 | 582 |
583 Instead of setting this, you may want to use /*AUTOINST*/, which will | |
584 always be saved." | |
585 :group 'verilog-mode-actions | |
586 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
587 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp) |
79545 | 588 |
589 (defvar verilog-auto-update-tick nil | |
590 "Modification tick at which autos were last performed.") | |
591 | |
592 (defvar verilog-auto-last-file-locals nil | |
593 "Text from file-local-variables during last evaluation.") | |
594 | |
595 (defvar verilog-error-regexp-add-didit nil) | |
596 (defvar verilog-error-regexp nil) | |
597 (setq verilog-error-regexp-add-didit nil | |
598 verilog-error-regexp | |
599 '( | |
600 ; SureLint | |
601 ;; ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) | |
602 ; Most SureFire tools | |
603 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 ) | |
604 ("\ | |
605 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
606 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) | |
607 ; xsim | |
608 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED] | |
609 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) | |
610 ; vcs | |
611 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) | |
612 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) | |
613 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) | |
614 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) | |
615 ; Verilator | |
616 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
617 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
618 ; vxl | |
619 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) | |
620 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl | |
621 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2) | |
622 ; nc-verilog | |
623 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2) | |
624 ; Leda | |
625 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2) | |
626 ) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
627 ; "*List of regexps for verilog compilers, like verilint. See compilation-error-regexp-alist for the formatting." |
79545 | 628 ) |
629 | |
630 (defvar verilog-error-font-lock-keywords | |
631 '( | |
632 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t) | |
633 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t) | |
634 | |
635 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t) | |
636 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t) | |
637 | |
638 ("\ | |
639 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
640 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
641 ("\ | |
642 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
643 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
644 | |
645 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t) | |
646 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t) | |
647 | |
648 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t) | |
649 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t) | |
650 | |
651 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
652 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
653 | |
654 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
655 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t) | |
656 | |
657 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t) | |
658 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
659 ; vxl | |
660 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
661 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
662 | |
663 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t) | |
664 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t) | |
665 | |
666 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t) | |
667 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t) | |
668 ; nc-verilog | |
669 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t) | |
670 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | |
671 ; Leda | |
672 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | |
673 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) | |
674 ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
675 "*Keywords to also highlight in Verilog *compilation* buffers.") |
79545 | 676 |
677 (defcustom verilog-library-flags '("") | |
678 "*List of standard Verilog arguments to use for /*AUTOINST*/. | |
679 These arguments are used to find files for `verilog-auto', and match | |
680 the flags accepted by a standard Verilog-XL simulator. | |
681 | |
682 -f filename Reads more `verilog-library-flags' from the filename. | |
683 +incdir+dir Adds the directory to `verilog-library-directories'. | |
684 -Idir Adds the directory to `verilog-library-directories'. | |
685 -y dir Adds the directory to `verilog-library-directories'. | |
686 +libext+.v Adds the extensions to `verilog-library-extensions'. | |
687 -v filename Adds the filename to `verilog-library-files'. | |
688 | |
689 filename Adds the filename to `verilog-library-files'. | |
690 This is not recommended, -v is a better choice. | |
691 | |
692 You might want these defined in each file; put at the *END* of your file | |
693 something like: | |
694 | |
695 // Local Variables: | |
696 // verilog-library-flags:(\"-y dir -y otherdir\") | |
697 // End: | |
698 | |
699 Verilog-mode attempts to detect changes to this local variable, but they | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
700 are only insured to be correct when the file is first visited. Thus if you |
79545 | 701 have problems, use \\[find-alternate-file] RET to have these take effect. |
702 | |
703 See also the variables mentioned above." | |
704 :group 'verilog-mode-auto | |
705 :type '(repeat string)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
706 (put 'verilog-library-flags 'safe-local-variable 'listp) |
79545 | 707 |
708 (defcustom verilog-library-directories '(".") | |
709 "*List of directories when looking for files for /*AUTOINST*/. | |
710 The directory may be relative to the current file, or absolute. | |
711 Environment variables are also expanded in the directory names. | |
712 Having at least the current directory is a good idea. | |
713 | |
714 You might want these defined in each file; put at the *END* of your file | |
715 something like: | |
716 | |
717 // Local Variables: | |
718 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\") | |
719 // End: | |
720 | |
721 Verilog-mode attempts to detect changes to this local variable, but they | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
722 are only insured to be correct when the file is first visited. Thus if you |
79545 | 723 have problems, use \\[find-alternate-file] RET to have these take effect. |
724 | |
725 See also `verilog-library-flags', `verilog-library-files' | |
726 and `verilog-library-extensions'." | |
727 :group 'verilog-mode-auto | |
728 :type '(repeat file)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
729 (put 'verilog-library-directories 'safe-local-variable 'listp) |
79545 | 730 |
731 (defcustom verilog-library-files '() | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
732 "*List of files to search for modules. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
733 AUTOINST will use this when it needs to resolve a module name. |
79545 | 734 This is a complete path, usually to a technology file with many standard |
735 cells defined in it. | |
736 | |
737 You might want these defined in each file; put at the *END* of your file | |
738 something like: | |
739 | |
740 // Local Variables: | |
741 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\") | |
742 // End: | |
743 | |
744 Verilog-mode attempts to detect changes to this local variable, but they | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
745 are only insured to be correct when the file is first visited. Thus if you |
79545 | 746 have problems, use \\[find-alternate-file] RET to have these take effect. |
747 | |
748 See also `verilog-library-flags', `verilog-library-directories'." | |
749 :group 'verilog-mode-auto | |
750 :type '(repeat directory)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
751 (put 'verilog-library-files 'safe-local-variable 'listp) |
79545 | 752 |
753 (defcustom verilog-library-extensions '(".v") | |
754 "*List of extensions to use when looking for files for /*AUTOINST*/. | |
755 See also `verilog-library-flags', `verilog-library-directories'." | |
756 :type '(repeat string) | |
757 :group 'verilog-mode-auto) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
758 (put 'verilog-library-extensions 'safe-local-variable 'listp) |
79545 | 759 |
760 (defcustom verilog-active-low-regexp nil | |
761 "*If set, treat signals matching this regexp as active low. | |
762 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | |
763 you will probably also need `verilog-auto-reset-widths' set." | |
764 :group 'verilog-mode-auto | |
765 :type 'string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
766 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) |
79545 | 767 |
768 (defcustom verilog-auto-sense-include-inputs nil | |
769 "*If true, AUTOSENSE should include all inputs. | |
770 If nil, only inputs that are NOT output signals in the same block are | |
771 included." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
772 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
773 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
774 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp) |
79545 | 775 |
776 (defcustom verilog-auto-sense-defines-constant nil | |
777 "*If true, AUTOSENSE should assume all defines represent constants. | |
778 When true, the defines will not be included in sensitivity lists. To | |
779 maintain compatibility with other sites, this should be set at the bottom | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
780 of each verilog file that requires it, rather than being set globally." |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
781 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
782 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
783 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) |
79545 | 784 |
785 (defcustom verilog-auto-reset-widths t | |
786 "*If true, AUTORESET should determine the width of signals. | |
787 This is then used to set the width of the zero (32'h0 for example). This | |
788 is required by some lint tools that aren't smart enough to ignore widths of | |
789 the constant zero. This may result in ugly code when parameters determine | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
790 the MSB or LSB of a signal inside a AUTORESET." |
79545 | 791 :type 'boolean |
792 :group 'verilog-mode-auto) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
793 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp) |
79545 | 794 |
795 (defcustom verilog-assignment-delay "" | |
796 "*Text used for delays in delayed assignments. Add a trailing space if set." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
797 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
798 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
799 (put 'verilog-assignment-delay 'safe-local-variable 'stringp) |
79545 | 800 |
801 (defcustom verilog-auto-inst-vector t | |
802 "*If true, when creating default ports with AUTOINST, use bus subscripts. | |
803 If nil, skip the subscript when it matches the entire bus as declared in | |
804 the module (AUTOWIRE signals always are subscripted, you must manually | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
805 declare the wire to have the subscripts removed.) Nil may speed up some |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
806 simulators, but is less general and harder to read, so avoid." |
79545 | 807 :group 'verilog-mode-auto |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
808 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
809 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp) |
79545 | 810 |
811 (defcustom verilog-auto-inst-template-numbers nil | |
812 "*If true, when creating templated ports with AUTOINST, add a comment. | |
813 The comment will add the line number of the template that was used for that | |
814 port declaration. Setting this aids in debugging, but nil is suggested for | |
815 regular use to prevent large numbers of merge conflicts." | |
816 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
817 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
818 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) |
79545 | 819 |
820 (defvar verilog-auto-inst-column 40 | |
821 "Column number for first part of auto-inst.") | |
822 | |
823 (defcustom verilog-auto-input-ignore-regexp nil | |
824 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | |
825 See the \\[verilog-faq] for examples on using this." | |
826 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
827 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
828 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 829 |
830 (defcustom verilog-auto-inout-ignore-regexp nil | |
831 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | |
832 See the \\[verilog-faq] for examples on using this." | |
833 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
834 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
835 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 836 |
837 (defcustom verilog-auto-output-ignore-regexp nil | |
838 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | |
839 See the \\[verilog-faq] for examples on using this." | |
840 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
841 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
842 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 843 |
844 (defcustom verilog-auto-unused-ignore-regexp nil | |
845 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | |
846 See the \\[verilog-faq] for examples on using this." | |
847 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
848 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
849 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 850 |
851 (defcustom verilog-typedef-regexp nil | |
852 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | |
853 For example, \"_t$\" matches typedefs named with _t, as in the C language." | |
854 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
855 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
856 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) |
79545 | 857 |
858 (defcustom verilog-mode-hook 'verilog-set-compile-command | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
859 "*Hook (List of functions) run after verilog mode is loaded." |
79545 | 860 :type 'hook |
861 :group 'verilog-mode) | |
862 | |
863 (defcustom verilog-auto-hook nil | |
864 "*Hook run after `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
865 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
866 :type 'hook) |
79545 | 867 |
868 (defcustom verilog-before-auto-hook nil | |
869 "*Hook run before `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
870 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
871 :type 'hook) |
79545 | 872 |
873 (defcustom verilog-delete-auto-hook nil | |
874 "*Hook run after `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
875 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
876 :type 'hook) |
79545 | 877 |
878 (defcustom verilog-before-delete-auto-hook nil | |
879 "*Hook run before `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
880 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
881 :type 'hook) |
79545 | 882 |
883 (defcustom verilog-getopt-flags-hook nil | |
884 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
885 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
886 :type 'hook) |
79545 | 887 |
888 (defcustom verilog-before-getopt-flags-hook nil | |
889 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
890 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
891 :type 'hook) |
79545 | 892 |
893 (defvar verilog-imenu-generic-expression | |
894 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | |
895 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
896 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.") |
79545 | 897 |
898 ;; | |
899 ;; provide a verilog-header function. | |
900 ;; Customization variables: | |
901 ;; | |
902 (defvar verilog-date-scientific-format nil | |
903 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17). | |
904 If nil, in European format (e.g. 17.09.1997). The brain-dead American | |
905 format (e.g. 09/17/1997) is not supported.") | |
906 | |
907 (defvar verilog-company nil | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
908 "*Default name of Company for verilog header. |
79545 | 909 If set will become buffer local.") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
910 (make-variable-buffer-local 'verilog-company) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
911 |
79545 | 912 (defvar verilog-project nil |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
913 "*Default name of Project for verilog header. |
79545 | 914 If set will become buffer local.") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
915 (make-variable-buffer-local 'verilog-project) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
916 |
79549
d9595ed9b084
* progmodes/verilog-mode.el (verilog-mode-map): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79547
diff
changeset
|
917 (defvar verilog-mode-map |
79546 | 918 (let ((map (make-sparse-keymap))) |
919 (define-key map ";" 'electric-verilog-semi) | |
920 (define-key map [(control 59)] 'electric-verilog-semi-with-comment) | |
921 (define-key map ":" 'electric-verilog-colon) | |
922 ;;(define-key map "=" 'electric-verilog-equal) | |
923 (define-key map "\`" 'electric-verilog-tick) | |
924 (define-key map "\t" 'electric-verilog-tab) | |
925 (define-key map "\r" 'electric-verilog-terminate-line) | |
926 ;; backspace/delete key bindings | |
927 (define-key map [backspace] 'backward-delete-char-untabify) | |
928 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable | |
929 (define-key map [delete] 'delete-char) | |
930 (define-key map [(meta delete)] 'kill-word)) | |
931 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) | |
932 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) | |
933 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | |
934 (define-key map "\M-\t" 'verilog-complete-word) | |
935 (define-key map "\M-?" 'verilog-show-completions) | |
936 (define-key map "\C-c\`" 'verilog-lint-off) | |
937 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | |
938 (define-key map "\C-c\C-r" 'verilog-label-be) | |
939 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) | |
940 (define-key map "\C-c=" 'verilog-pretty-expr) | |
941 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) | |
942 (define-key map "\M-*" 'verilog-star-comment) | |
943 (define-key map "\C-c\C-c" 'verilog-comment-region) | |
944 (define-key map "\C-c\C-u" 'verilog-uncomment-region) | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
945 (when (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
946 (define-key map [(meta control h)] 'verilog-mark-defun) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
947 (define-key map "\M-\C-a" 'verilog-beg-of-defun) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
948 (define-key map "\M-\C-e" 'verilog-end-of-defun)) |
79546 | 949 (define-key map "\C-c\C-d" 'verilog-goto-defun) |
950 (define-key map "\C-c\C-k" 'verilog-delete-auto) | |
951 (define-key map "\C-c\C-a" 'verilog-auto) | |
952 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) | |
953 (define-key map "\C-c\C-z" 'verilog-inject-auto) | |
954 (define-key map "\C-c\C-e" 'verilog-expand-vector) | |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
955 (define-key map "\C-c\C-h" 'verilog-header) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
956 map) |
79545 | 957 "Keymap used in Verilog mode.") |
958 | |
959 ;; menus | |
960 (defvar verilog-xemacs-menu | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
961 `("Verilog" |
79545 | 962 ("Choose Compilation Action" |
963 ["None" | |
964 (progn | |
965 (setq verilog-tool nil) | |
966 (verilog-set-compile-command)) | |
967 :style radio | |
968 :selected (equal verilog-tool nil)] | |
969 ["Lint" | |
970 (progn | |
971 (setq verilog-tool 'verilog-linter) | |
972 (verilog-set-compile-command)) | |
973 :style radio | |
974 :selected (equal verilog-tool `verilog-linter)] | |
975 ["Coverage" | |
976 (progn | |
977 (setq verilog-tool 'verilog-coverage) | |
978 (verilog-set-compile-command)) | |
979 :style radio | |
980 :selected (equal verilog-tool `verilog-coverage)] | |
981 ["Simulator" | |
982 (progn | |
983 (setq verilog-tool 'verilog-simulator) | |
984 (verilog-set-compile-command)) | |
985 :style radio | |
986 :selected (equal verilog-tool `verilog-simulator)] | |
987 ["Compiler" | |
988 (progn | |
989 (setq verilog-tool 'verilog-compiler) | |
990 (verilog-set-compile-command)) | |
991 :style radio | |
992 :selected (equal verilog-tool `verilog-compiler)] | |
993 ) | |
994 ("Move" | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
995 ,(if (featurep 'xemacs) |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
996 (progn |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
997 ["Beginning of function" verilog-beg-of-defun t] |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
998 ["End of function" verilog-end-of-defun t] |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
999 ["Mark function" verilog-mark-defun t]) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1000 ["Beginning of function" beginning-of-defun t] |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1001 ["End of function" end-of-defun t] |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1002 ["Mark function" mark-defun t]) |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1003 |
79545 | 1004 ["Goto function/module" verilog-goto-defun t] |
1005 ["Move to beginning of block" electric-verilog-backward-sexp t] | |
1006 ["Move to end of block" electric-verilog-forward-sexp t] | |
1007 ) | |
1008 ("Comments" | |
1009 ["Comment Region" verilog-comment-region t] | |
1010 ["UnComment Region" verilog-uncomment-region t] | |
1011 ["Multi-line comment insert" verilog-star-comment t] | |
1012 ["Lint error to comment" verilog-lint-off t] | |
1013 ) | |
1014 "----" | |
1015 ["Compile" compile t] | |
1016 ["AUTO, Save, Compile" verilog-auto-save-compile t] | |
1017 ["Next Compile Error" next-error t] | |
1018 ["Ignore Lint Warning at point" verilog-lint-off t] | |
1019 "----" | |
1020 ["Line up declarations around point" verilog-pretty-declarations t] | |
1021 ["Line up equations around point" verilog-pretty-expr t] | |
1022 ["Redo/insert comments on every end" verilog-label-be t] | |
1023 ["Expand [x:y] vector line" verilog-expand-vector t] | |
1024 ["Insert begin-end block" verilog-insert-block t] | |
1025 ["Complete word" verilog-complete-word t] | |
1026 "----" | |
1027 ["Recompute AUTOs" verilog-auto t] | |
1028 ["Kill AUTOs" verilog-delete-auto t] | |
1029 ["Inject AUTOs" verilog-inject-auto t] | |
1030 ("AUTO Help..." | |
1031 ["AUTO General" (describe-function 'verilog-auto) t] | |
1032 ["AUTO Library Flags" (describe-variable 'verilog-library-flags) t] | |
1033 ["AUTO Library Path" (describe-variable 'verilog-library-directories) t] | |
1034 ["AUTO Library Files" (describe-variable 'verilog-library-files) t] | |
1035 ["AUTO Library Extensions" (describe-variable 'verilog-library-extensions) t] | |
1036 ["AUTO `define Reading" (describe-function 'verilog-read-defines) t] | |
1037 ["AUTO `include Reading" (describe-function 'verilog-read-includes) t] | |
1038 ["AUTOARG" (describe-function 'verilog-auto-arg) t] | |
1039 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) t] | |
1040 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) t] | |
1041 ["AUTOINOUT" (describe-function 'verilog-auto-inout) t] | |
1042 ["AUTOINPUT" (describe-function 'verilog-auto-input) t] | |
1043 ["AUTOINST" (describe-function 'verilog-auto-inst) t] | |
1044 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) t] | |
1045 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) t] | |
1046 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) t] | |
1047 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) t] | |
1048 ["AUTOREG" (describe-function 'verilog-auto-reg) t] | |
1049 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) t] | |
1050 ["AUTORESET" (describe-function 'verilog-auto-reset) t] | |
1051 ["AUTOSENSE" (describe-function 'verilog-auto-sense) t] | |
1052 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) t] | |
1053 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) t] | |
1054 ["AUTOWIRE" (describe-function 'verilog-auto-wire) t] | |
1055 ) | |
1056 "----" | |
1057 ["Submit bug report" verilog-submit-bug-report t] | |
1058 ["Version and FAQ" verilog-faq t] | |
1059 ["Customize Verilog Mode..." verilog-customize t] | |
1060 ["Customize Verilog Fonts & Colors" verilog-font-customize t] | |
1061 ) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1062 "Emacs menu for VERILOG mode." |
79545 | 1063 ) |
1064 (defvar verilog-statement-menu | |
1065 '("Statements" | |
1066 ["Header" verilog-sk-header t] | |
1067 ["Comment" verilog-sk-comment t] | |
1068 "----" | |
1069 ["Module" verilog-sk-module t] | |
1070 ["Primitive" verilog-sk-primitive t] | |
1071 "----" | |
1072 ["Input" verilog-sk-input t] | |
1073 ["Output" verilog-sk-output t] | |
1074 ["Inout" verilog-sk-inout t] | |
1075 ["Wire" verilog-sk-wire t] | |
1076 ["Reg" verilog-sk-reg t] | |
1077 ["Define thing under point as a register" verilog-sk-define-signal t] | |
1078 "----" | |
1079 ["Initial" verilog-sk-initial t] | |
1080 ["Always" verilog-sk-always t] | |
1081 ["Function" verilog-sk-function t] | |
1082 ["Task" verilog-sk-task t] | |
1083 ["Specify" verilog-sk-specify t] | |
1084 ["Generate" verilog-sk-generate t] | |
1085 "----" | |
1086 ["Begin" verilog-sk-begin t] | |
1087 ["If" verilog-sk-if t] | |
1088 ["(if) else" verilog-sk-else-if t] | |
1089 ["For" verilog-sk-for t] | |
1090 ["While" verilog-sk-while t] | |
1091 ["Fork" verilog-sk-fork t] | |
1092 ["Repeat" verilog-sk-repeat t] | |
1093 ["Case" verilog-sk-case t] | |
1094 ["Casex" verilog-sk-casex t] | |
1095 ["Casez" verilog-sk-casez t] | |
1096 ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1097 "Menu for statement templates in Verilog.") |
79545 | 1098 |
1099 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode" | |
1100 verilog-xemacs-menu) | |
1101 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." | |
1102 verilog-statement-menu) | |
1103 | |
1104 (defvar verilog-mode-abbrev-table nil | |
1105 "Abbrev table in use in Verilog-mode buffers.") | |
1106 | |
1107 (define-abbrev-table 'verilog-mode-abbrev-table ()) | |
1108 | |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1109 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1110 ;; Macros |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1111 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1112 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1113 (defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1114 "Replace occurrences of FROM-STRING with TO-STRING. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1115 FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1116 The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\") |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1117 will break, as the o's continuously replace. xa -> x works ok though." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1118 ;; Hopefully soon to a emacs built-in |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1119 (let ((start 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1120 (while (string-match from-string string start) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1121 (setq string (replace-match to-string fixedcase literal string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1122 start (min (length string) (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1123 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1124 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1125 (defsubst verilog-string-remove-spaces (string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1126 "Remove spaces surrounding STRING." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1127 (save-match-data |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1128 (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1129 (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1130 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1131 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1132 (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1133 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1134 "Like `re-search-forward', but skips over match in comments or strings." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1135 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1136 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1137 (re-search-forward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1138 (and (verilog-skip-forward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1139 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1140 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1141 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1142 (< (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1143 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1144 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1145 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1146 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1147 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1148 "Like `re-search-backward', but skips over match in comments or strings." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1149 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1150 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1151 (re-search-backward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1152 (and (verilog-skip-backward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1153 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1154 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1155 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1156 (> (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1157 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1158 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1159 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1160 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1161 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR, |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1162 but trashes match data and is faster for REGEXP that doesn't match often. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1163 This may at some point use text properties to ignore comments, |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1164 so there may be a large up front penalty for the first search." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1165 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1166 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1167 (re-search-forward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1168 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1169 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1170 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1171 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1172 (defsubst verilog-re-search-backward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1173 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1174 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR, |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1175 but trashes match data and is faster for REGEXP that doesn't match often. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1176 This may at some point use text properties to ignore comments, |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1177 so there may be a large up front penalty for the first search." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1178 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1179 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1180 (re-search-backward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1181 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1182 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1183 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1184 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1185 (defsubst verilog-get-beg-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1186 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1187 (beginning-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1188 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1189 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1190 (defsubst verilog-get-end-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1191 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1192 (end-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1193 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1194 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1195 (defsubst verilog-within-string () |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1196 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1197 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point))))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1198 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1199 (defvar compile-command) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1200 |
79545 | 1201 ;; compilation program |
1202 (defun verilog-set-compile-command () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1203 "Function to compute shell command to compile verilog. |
79545 | 1204 |
1205 This reads `verilog-tool' and sets `compile-command'. This specifies the | |
1206 program that executes when you type \\[compile] or | |
1207 \\[verilog-auto-save-compile]. | |
1208 | |
1209 By default `verilog-tool' uses a Makefile if one exists in the current | |
1210 directory. If not, it is set to the `verilog-linter', `verilog-coverage', | |
1211 `verilog-simulator', or `verilog-compiler' variables, as selected with the | |
1212 Verilog -> \"Choose Compilation Action\" menu. | |
1213 | |
1214 You should set `verilog-tool' or the other variables to the path and | |
1215 arguments for your Verilog simulator. For example: | |
1216 \"vcs -p123 -O\" | |
1217 or a string like: | |
1218 \"(cd /tmp; surecov %s)\". | |
1219 | |
1220 In the former case, the path to the current buffer is concat'ed to the | |
1221 value of `verilog-tool'; in the later, the path to the current buffer is | |
1222 substituted for the %s. | |
1223 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1224 Where __FILE__ appears in the string, the buffer-file-name of the current |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1225 buffer, without the directory portion, will be substituted." |
79545 | 1226 (interactive) |
1227 (cond | |
1228 ((or (file-exists-p "makefile") ;If there is a makefile, use it | |
1229 (file-exists-p "Makefile")) | |
1230 (make-local-variable 'compile-command) | |
1231 (setq compile-command "make ")) | |
1232 (t | |
1233 (make-local-variable 'compile-command) | |
1234 (setq compile-command | |
1235 (if verilog-tool | |
1236 (if (string-match "%s" (eval verilog-tool)) | |
1237 (format (eval verilog-tool) (or buffer-file-name "")) | |
1238 (concat (eval verilog-tool) " " (or buffer-file-name ""))) | |
1239 "")))) | |
1240 (verilog-modify-compile-command)) | |
1241 | |
1242 (defun verilog-modify-compile-command () | |
1243 "Replace meta-information in `compile-command'. | |
1244 Where __FILE__ appears in the string, the current buffer's file-name, | |
1245 without the directory portion, will be substituted." | |
1246 (when (and | |
1247 (stringp compile-command) | |
1248 (string-match "\\b__FILE__\\b" compile-command)) | |
1249 (make-local-variable 'compile-command) | |
1250 (setq compile-command | |
1251 (verilog-string-replace-matches | |
1252 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) | |
1253 t t compile-command)))) | |
1254 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1255 ;; Following code only gets called from compilation-mode-hook. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1256 (defvar compilation-error-regexp-alist) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1257 |
79545 | 1258 (defun verilog-error-regexp-add () |
1259 "Add the messages to the `compilation-error-regexp-alist'. | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1260 Called by `compilation-mode-hook'. This allows \\[next-error] to |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1261 find the errors." |
79545 | 1262 (if (not verilog-error-regexp-add-didit) |
1263 (progn | |
1264 (setq verilog-error-regexp-add-didit t) | |
1265 (setq-default compilation-error-regexp-alist | |
1266 (append verilog-error-regexp | |
1267 (default-value 'compilation-error-regexp-alist))) | |
1268 ;; Could be buffer local at this point; maybe also in let; change all three | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1269 (setq compilation-error-regexp-alist |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1270 (default-value 'compilation-error-regexp-alist)) |
79545 | 1271 (set (make-local-variable 'compilation-error-regexp-alist) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1272 (default-value 'compilation-error-regexp-alist))))) |
79545 | 1273 |
1274 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) | |
1275 | |
1276 (defconst verilog-directive-re | |
1277 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | |
1278 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1279 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1280 ;; "`time_scale" "`undef" "`while" | |
1281 "\\<`\\(case\\|def\\(ault\\|ine\\(\\)?\\)\\|e\\(lse\\|nd\\(for\\|if\\|protect\\|switch\\|while\\)\\)\\|for\\(mat\\)?\\|i\\(f\\(def\\|ndef\\)?\\|nclude\\)\\|let\\|protect\\|switch\\|time\\(_scale\\|scale\\)\\|undef\\|while\\)\\>") | |
1282 | |
1283 (defconst verilog-directive-begin | |
1284 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>") | |
1285 | |
1286 (defconst verilog-directive-middle | |
1287 "\\<`\\(else\\|default\\|case\\)\\>") | |
1288 | |
1289 (defconst verilog-directive-end | |
1290 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>") | |
1291 | |
1292 (defconst verilog-directive-re-1 | |
1293 (concat "[ \t]*" verilog-directive-re)) | |
1294 | |
1295 ;; | |
1296 ;; Regular expressions used to calculate indent, etc. | |
1297 ;; | |
1298 (defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>") | |
1299 (defconst verilog-case-re "\\(\\<case[xz]?\\>\\|\\<randcase\\>\\)") | |
1300 ;; Want to match | |
1301 ;; aa : | |
1302 ;; aa,bb : | |
1303 ;; a[34:32] : | |
1304 ;; a, | |
1305 ;; b : | |
1306 | |
1307 (defconst verilog-no-indent-begin-re | |
1308 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>") | |
1309 | |
1310 (defconst verilog-ends-re | |
1311 ;; Parenthesis indicate type of keyword found | |
1312 (concat | |
1313 "\\(\\<else\\>\\)\\|" ; 1 | |
1314 "\\(\\<if\\>\\)\\|" ; 2 | |
1315 "\\(\\<end\\>\\)\\|" ; 3 | |
1316 "\\(\\<endcase\\>\\)\\|" ; 4 | |
1317 "\\(\\<endfunction\\>\\)\\|" ; 5 | |
1318 "\\(\\<endtask\\>\\)\\|" ; 6 | |
1319 "\\(\\<endspecify\\>\\)\\|" ; 7 | |
1320 "\\(\\<endtable\\>\\)\\|" ; 8 | |
1321 "\\(\\<endgenerate\\>\\)\\|" ; 9 | |
1322 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10 | |
1323 "\\(\\<endclass\\>\\)\\|" ; 11 | |
1324 "\\(\\<endgroup\\>\\)" ; 12 | |
1325 )) | |
1326 | |
1327 (defconst verilog-auto-end-comment-lines-re | |
1328 ;; Matches to names in this list cause auto-end-commentation | |
1329 (concat "\\(" | |
1330 verilog-directive-re "\\)\\|\\(" | |
1331 (eval-when-compile | |
1332 (verilog-regexp-words | |
1333 `( "begin" | |
1334 "else" | |
1335 "end" | |
1336 "endcase" | |
1337 "endclass" | |
1338 "endclocking" | |
1339 "endgroup" | |
1340 "endfunction" | |
1341 "endmodule" | |
1342 "endprogram" | |
1343 "endprimitive" | |
1344 "endinterface" | |
1345 "endpackage" | |
1346 "endsequence" | |
1347 "endspecify" | |
1348 "endtable" | |
1349 "endtask" | |
1350 "join" | |
1351 "join_any" | |
1352 "join_none" | |
1353 "module" | |
1354 "macromodule" | |
1355 "primitive" | |
1356 "interface" | |
1357 "package"))) | |
1358 "\\)")) | |
1359 | |
1360 ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and | |
1361 ;;; verilog-end-block-ordered-re matches exactly the same strings. | |
1362 (defconst verilog-end-block-ordered-re | |
1363 ;; Parenthesis indicate type of keyword found | |
1364 (concat "\\(\\<endcase\\>\\)\\|" ; 1 | |
1365 "\\(\\<end\\>\\)\\|" ; 2 | |
1366 "\\(\\<end" ; 3, but not used | |
1367 "\\(" ; 4, but not used | |
1368 "\\(function\\)\\|" ; 5 | |
1369 "\\(task\\)\\|" ; 6 | |
1370 "\\(module\\)\\|" ; 7 | |
1371 "\\(primitive\\)\\|" ; 8 | |
1372 "\\(interface\\)\\|" ; 9 | |
1373 "\\(package\\)\\|" ; 10 | |
1374 "\\(class\\)\\|" ; 11 | |
1375 "\\(group\\)\\|" ; 12 | |
1376 "\\(program\\)\\|" ; 13 | |
1377 "\\(sequence\\)\\|" ; 14 | |
1378 "\\(clocking\\)\\|" ; 15 | |
1379 "\\)\\>\\)")) | |
1380 (defconst verilog-end-block-re | |
1381 (eval-when-compile | |
1382 (verilog-regexp-words | |
1383 | |
1384 `("end" ;; closes begin | |
1385 "endcase" ;; closes any of case, casex casez or randcase | |
1386 "join" "join_any" "join_none" ;; closes fork | |
1387 "endclass" | |
1388 "endtable" | |
1389 "endspecify" | |
1390 "endfunction" | |
1391 "endgenerate" | |
1392 "endtask" | |
1393 "endgroup" | |
1394 "endproperty" | |
1395 "endinterface" | |
1396 "endpackage" | |
1397 "endprogram" | |
1398 "endsequence" | |
1399 "endclocking" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1400 )))) |
79545 | 1401 |
1402 | |
1403 (defconst verilog-endcomment-reason-re | |
1404 ;; Parenthesis indicate type of keyword found | |
1405 (concat | |
1406 "\\(\\<fork\\>\\)\\|" | |
1407 "\\(\\<begin\\>\\)\\|" | |
1408 "\\(\\<if\\>\\)\\|" | |
1409 "\\(\\<clocking\\>\\)\\|" | |
1410 "\\(\\<else\\>\\)\\|" | |
1411 "\\(\\<end\\>.*\\<else\\>\\)\\|" | |
1412 "\\(\\<task\\>\\)\\|" | |
1413 "\\(\\<function\\>\\)\\|" | |
1414 "\\(\\<initial\\>\\)\\|" | |
1415 "\\(\\<interface\\>\\)\\|" | |
1416 "\\(\\<package\\>\\)\\|" | |
1417 "\\(\\<final\\>\\)\\|" | |
1418 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1419 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1420 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1421 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1422 "\\(@\\)\\|" | |
1423 "\\(\\<while\\>\\)\\|" | |
1424 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|" | |
1425 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|" | |
1426 "#")) | |
1427 | |
1428 (defconst verilog-named-block-re "begin[ \t]*:") | |
1429 | |
1430 ;; These words begin a block which can occur inside a module which should be indented, | |
1431 ;; and closed with the respective word from the end-block list | |
1432 | |
1433 (defconst verilog-beg-block-re | |
1434 (eval-when-compile | |
1435 (verilog-regexp-words | |
1436 `("begin" | |
1437 "case" "casex" "casez" "randcase" | |
1438 "clocking" | |
1439 "generate" | |
1440 "fork" | |
1441 "function" | |
1442 "property" | |
1443 "specify" | |
1444 "table" | |
1445 "task" | |
1446 )))) | |
1447 ;; These are the same words, in a specific order in the regular | |
1448 ;; expression so that matching will work nicely for | |
1449 ;; verilog-forward-sexp and verilog-calc-indent | |
1450 | |
1451 (defconst verilog-beg-block-re-ordered | |
1452 ( concat "\\<" | |
1453 "\\(begin\\)" ;1 | |
1454 "\\|\\(randcase\\|\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?\\)" ; 2 | |
1455 ;; "\\|\\(randcase\\|case[xz]?\\)" ; 2 | |
1456 "\\|\\(fork\\)" ;3 | |
1457 "\\|\\(class\\)" ;4 | |
1458 "\\|\\(table\\)" ;5 | |
1459 "\\|\\(specify\\)" ;6 | |
1460 "\\|\\(function\\)" ;7 | |
1461 "\\|\\(task\\)" ;8 | |
1462 "\\|\\(generate\\)" ;9 | |
1463 "\\|\\(covergroup\\)" ;10 | |
1464 "\\|\\(property\\)" ;11 | |
1465 "\\|\\(\\(rand\\)?sequence\\)" ;12 | |
1466 "\\|\\(clocking\\)" ;13 | |
1467 "\\>")) | |
1468 | |
1469 (defconst verilog-end-block-ordered-rry | |
1470 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1471 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" | |
1472 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1473 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" | |
1474 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" | |
1475 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" | |
1476 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" | |
1477 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" | |
1478 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" | |
1479 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" | |
1480 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" | |
1481 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" | |
1482 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" | |
1483 ] ) | |
1484 | |
1485 (defconst verilog-nameable-item-re | |
1486 (eval-when-compile | |
1487 (verilog-regexp-words | |
1488 `("begin" | |
1489 "fork" | |
1490 "join" "join_any" "join_none" | |
1491 "end" | |
1492 "endcase" | |
1493 "endconfig" | |
1494 "endclass" | |
1495 "endclocking" | |
1496 "endfunction" | |
1497 "endgenerate" | |
1498 "endmodule" | |
1499 "endprimative" | |
1500 "endinterface" | |
1501 "endpackage" | |
1502 "endspecify" | |
1503 "endtable" | |
1504 "endtask" ) | |
1505 ))) | |
1506 | |
1507 (defconst verilog-declaration-opener | |
1508 (eval-when-compile | |
1509 (verilog-regexp-words | |
1510 `("module" "begin" "task" "function")))) | |
1511 | |
1512 (defconst verilog-declaration-prefix-re | |
1513 (eval-when-compile | |
1514 (verilog-regexp-words | |
1515 `( | |
1516 ;; port direction | |
79546 | 1517 "inout" "input" "output" "ref" |
79545 | 1518 ;; changeableness |
1519 "const" "static" "protected" "local" | |
1520 ;; parameters | |
79546 | 1521 "localparam" "parameter" "var" |
79545 | 1522 ;; type creation |
1523 "typedef" | |
1524 )))) | |
1525 (defconst verilog-declaration-core-re | |
1526 (eval-when-compile | |
1527 (verilog-regexp-words | |
1528 `( | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
1529 ;; port direction (by themselves) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
1530 "inout" "input" "output" |
79545 | 1531 ;; integer_atom_type |
1532 "byte" "shortint" "int" "longint" "integer" "time" | |
1533 ;; integer_vector_type | |
1534 "bit" "logic" "reg" | |
1535 ;; non_integer_type | |
1536 "shortreal" "real" "realtime" | |
1537 ;; net_type | |
1538 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor" | |
1539 ;; misc | |
1540 "string" "event" "chandle" "virtual" "enum" "genvar" | |
1541 "struct" "union" | |
1542 ;; builtin classes | |
79546 | 1543 "mailbox" "semaphore" |
79545 | 1544 )))) |
79546 | 1545 (defconst verilog-declaration-re |
79545 | 1546 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re)) |
1547 (defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+") | |
1548 (defconst verilog-optional-signed-re "\\s-*\\(signed\\)?") | |
1549 (defconst verilog-optional-signed-range-re | |
1550 (concat | |
1551 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?")) | |
1552 (defconst verilog-macroexp-re "`\\sw+") | |
1553 | |
1554 (defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)") | |
1555 (defconst verilog-declaration-re-2-no-macro | |
1556 (concat "\\s-*" verilog-declaration-re | |
1557 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1558 "\\)?")) | |
1559 (defconst verilog-declaration-re-2-macro | |
1560 (concat "\\s-*" verilog-declaration-re | |
1561 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1562 "\\|\\(" verilog-macroexp-re "\\)" | |
1563 "\\)?")) | |
1564 (defconst verilog-declaration-re-1-macro | |
1565 (concat "^" verilog-declaration-re-2-macro)) | |
1566 | |
1567 (defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro)) | |
1568 | |
1569 (defconst verilog-defun-re | |
1570 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config")))) | |
1571 (defconst verilog-end-defun-re | |
1572 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig")))) | |
1573 (defconst verilog-zero-indent-re | |
1574 (concat verilog-defun-re "\\|" verilog-end-defun-re)) | |
1575 | |
1576 (defconst verilog-behavioral-block-beg-re | |
1577 (concat "\\(\\<initial\\>\\|\\<final\\>\\|\\<always\\>\\|\\<always_comb\\>\\|\\<always_ff\\>\\|" | |
1578 "\\<always_latch\\>\\|\\<function\\>\\|\\<task\\>\\)")) | |
1579 | |
1580 (defconst verilog-indent-re | |
1581 (eval-when-compile | |
1582 (verilog-regexp-words | |
1583 `( | |
1584 "{" | |
1585 "always" "always_latch" "always_ff" "always_comb" | |
1586 "begin" "end" | |
1587 ; "unique" "priority" | |
1588 "case" "casex" "casez" "randcase" "endcase" | |
1589 "class" "endclass" | |
1590 "clocking" "endclocking" | |
1591 "config" "endconfig" | |
1592 "covergroup" "endgroup" | |
1593 "fork" "join" "join_any" "join_none" | |
1594 "function" "endfunction" | |
1595 "final" | |
1596 "generate" "endgenerate" | |
1597 "initial" | |
1598 "interface" "endinterface" | |
1599 "module" "macromodule" "endmodule" | |
1600 "package" "endpackage" | |
1601 "primitive" "endprimative" | |
1602 "program" "endprogram" | |
1603 "property" "endproperty" | |
1604 "sequence" "randsequence" "endsequence" | |
1605 "specify" "endspecify" | |
1606 "table" "endtable" | |
1607 "task" "endtask" | |
1608 "`case" | |
1609 "`default" | |
1610 "`define" "`undef" | |
1611 "`if" "`ifdef" "`ifndef" "`else" "`endif" | |
1612 "`while" "`endwhile" | |
1613 "`for" "`endfor" | |
1614 "`format" | |
1615 "`include" | |
1616 "`let" | |
1617 "`protect" "`endprotect" | |
1618 "`switch" "`endswitch" | |
1619 "`timescale" | |
1620 "`time_scale" | |
1621 )))) | |
1622 | |
1623 (defconst verilog-defun-level-re | |
1624 (eval-when-compile | |
1625 (verilog-regexp-words | |
1626 `( | |
1627 "module" "macromodule" "primitive" "class" "program" "initial" "final" "always" "always_comb" | |
1628 "always_ff" "always_latch" "endtask" "endfunction" "interface" "package" | |
1629 "config")))) | |
1630 | |
1631 (defconst verilog-defun-level-not-generate-re | |
1632 (eval-when-compile | |
1633 (verilog-regexp-words | |
1634 `( | |
1635 "module" "macromodule" "primitive" "class" "program" "interface" "package" "config")))) | |
1636 | |
1637 (defconst verilog-cpp-level-re | |
1638 (eval-when-compile | |
1639 (verilog-regexp-words | |
1640 `( | |
1641 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" | |
1642 )))) | |
1643 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") | |
1644 (defconst verilog-extended-complete-re | |
1645 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" | |
1646 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)" | |
1647 "\\|" verilog-extended-case-re )) | |
1648 (defconst verilog-basic-complete-re | |
1649 (eval-when-compile | |
1650 (verilog-regexp-words | |
1651 `( | |
1652 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint" | |
1653 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while" | |
1654 "if" "for" "forever" "foreach" "else" "parameter" "do" | |
1655 )))) | |
1656 (defconst verilog-complete-reg | |
1657 (concat | |
1658 verilog-extended-complete-re | |
1659 "\\|" | |
1660 verilog-basic-complete-re)) | |
1661 | |
1662 (defconst verilog-end-statement-re | |
1663 (concat "\\(" verilog-beg-block-re "\\)\\|\\(" | |
1664 verilog-end-block-re "\\)")) | |
1665 | |
1666 (defconst verilog-endcase-re | |
1667 (concat verilog-case-re "\\|" | |
1668 "\\(endcase\\)\\|" | |
1669 verilog-defun-re | |
1670 )) | |
1671 | |
1672 (defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----" | |
1673 "String used to mark beginning of excluded text.") | |
1674 (defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */" | |
1675 "String used to mark end of excluded text.") | |
1676 (defconst verilog-preprocessor-re | |
1677 (eval-when-compile | |
1678 (verilog-regexp-words | |
1679 `( | |
1680 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else" | |
1681 )))) | |
1682 | |
1683 (defconst verilog-keywords | |
1684 '( "`case" "`default" "`define" "`else" "`endfor" "`endif" | |
1685 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1686 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1687 "`time_scale" "`undef" "`while" | |
1688 | |
1689 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" | |
1690 "assert" "assign" "assume" "automatic" "before" "begin" "bind" | |
1691 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" | |
1692 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" | |
1693 "config" "const" "constraint" "context" "continue" "cover" | |
1694 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" | |
1695 "design" "disable" "dist" "do" "edge" "else" "end" "endcase" | |
1696 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" | |
1697 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" | |
1698 "endprogram" "endproperty" "endspecify" "endsequence" "endtable" | |
1699 "endtask" "enum" "event" "expect" "export" "extends" "extern" | |
1700 "final" "first_match" "for" "force" "foreach" "forever" "fork" | |
1701 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" | |
1702 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" | |
1703 "include" "initial" "inout" "input" "inside" "instance" "int" | |
1704 "integer" "interface" "intersect" "join" "join_any" "join_none" | |
1705 "large" "liblist" "library" "local" "localparam" "logic" | |
1706 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" | |
1707 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" | |
1708 "notif0" "notif1" "null" "or" "output" "package" "packed" | |
1709 "parameter" "pmos" "posedge" "primitive" "priority" "program" | |
1710 "property" "protected" "pull0" "pull1" "pulldown" "pullup" | |
1711 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1712 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" | |
1713 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" | |
1714 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" | |
1715 "showcancelled" "signed" "small" "solve" "specify" "specparam" | |
1716 "static" "string" "strong0" "strong1" "struct" "super" "supply0" | |
1717 "supply1" "table" "tagged" "task" "this" "throughout" "time" | |
1718 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" | |
1719 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" | |
1720 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" | |
1721 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | |
1722 "wire" "with" "within" "wor" "xnor" "xor" | |
1723 ) | |
1724 "List of Verilog keywords.") | |
1725 | |
1726 (defconst verilog-comment-start-regexp "//\\|/\\*" | |
1727 "Dual comment value for `comment-start-regexp'.") | |
1728 | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1729 (defvar verilog-mode-syntax-table |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1730 (let ((table (make-syntax-table))) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1731 ;; Populate the syntax TABLE. |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1732 (modify-syntax-entry ?\\ "\\" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1733 (modify-syntax-entry ?+ "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1734 (modify-syntax-entry ?- "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1735 (modify-syntax-entry ?= "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1736 (modify-syntax-entry ?% "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1737 (modify-syntax-entry ?< "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1738 (modify-syntax-entry ?> "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1739 (modify-syntax-entry ?& "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1740 (modify-syntax-entry ?| "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1741 (modify-syntax-entry ?` "w" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1742 (modify-syntax-entry ?_ "w" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1743 (modify-syntax-entry ?\' "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1744 |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1745 ;; Set up TABLE to handle block and line style comments. |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1746 (if (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1747 (progn |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1748 ;; XEmacs (formerly Lucid) has the best implementation |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1749 (modify-syntax-entry ?/ ". 1456" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1750 (modify-syntax-entry ?* ". 23" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1751 (modify-syntax-entry ?\n "> b" table)) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1752 ;; Emacs 19 does things differently, but we can work with it |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1753 (modify-syntax-entry ?/ ". 124b" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1754 (modify-syntax-entry ?* ". 23" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1755 (modify-syntax-entry ?\n "> b" table)) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1756 table) |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1757 "Syntax table used in `verilog-mode' buffers.") |
79545 | 1758 |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1759 (defvar verilog-font-lock-keywords nil |
79545 | 1760 "Default highlighting for Verilog mode.") |
1761 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1762 (defvar verilog-font-lock-keywords-1 nil |
79545 | 1763 "Subdued level highlighting for Verilog mode.") |
1764 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1765 (defvar verilog-font-lock-keywords-2 nil |
79545 | 1766 "Medium level highlighting for Verilog mode. |
1767 See also `verilog-font-lock-extra-types'.") | |
1768 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1769 (defvar verilog-font-lock-keywords-3 nil |
79545 | 1770 "Gaudy level highlighting for Verilog mode. |
1771 See also `verilog-font-lock-extra-types'.") | |
1772 (defvar verilog-font-lock-translate-off-face | |
1773 'verilog-font-lock-translate-off-face | |
1774 "Font to use for translated off regions.") | |
1775 (defface verilog-font-lock-translate-off-face | |
1776 '((((class color) | |
1777 (background light)) | |
1778 (:background "gray90" :italic t )) | |
1779 (((class color) | |
1780 (background dark)) | |
1781 (:background "gray10" :italic t )) | |
1782 (((class grayscale) (background light)) | |
1783 (:foreground "DimGray" :italic t)) | |
1784 (((class grayscale) (background dark)) | |
1785 (:foreground "LightGray" :italic t)) | |
1786 (t (:italis t))) | |
1787 "Font lock mode face used to background highlight translate-off regions." | |
1788 :group 'font-lock-highlighting-faces) | |
1789 | |
1790 (defvar verilog-font-lock-p1800-face | |
1791 'verilog-font-lock-p1800-face | |
1792 "Font to use for p1800 keywords.") | |
1793 (defface verilog-font-lock-p1800-face | |
1794 '((((class color) | |
1795 (background light)) | |
1796 (:foreground "DarkOrange3" :bold t )) | |
1797 (((class color) | |
1798 (background dark)) | |
1799 (:foreground "orange1" :bold t )) | |
1800 (t (:italic t))) | |
1801 "Font lock mode face used to highlight P1800 keywords." | |
1802 :group 'font-lock-highlighting-faces) | |
1803 | |
1804 (defvar verilog-font-lock-ams-face | |
1805 'verilog-font-lock-ams-face | |
1806 "Font to use for Analog/Mixed Signal keywords.") | |
1807 (defface verilog-font-lock-ams-face | |
1808 '((((class color) | |
1809 (background light)) | |
1810 (:foreground "Purple" :bold t )) | |
1811 (((class color) | |
1812 (background dark)) | |
1813 (:foreground "orange1" :bold t )) | |
1814 (t (:italic t))) | |
1815 "Font lock mode face used to highlight AMS keywords." | |
1816 :group 'font-lock-highlighting-faces) | |
1817 | |
1818 (let* ((verilog-type-font-keywords | |
1819 (eval-when-compile | |
1820 (verilog-regexp-opt | |
1821 '( | |
1822 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam" | |
1823 "event" "genvar" "inout" "input" "integer" "localparam" | |
1824 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or" | |
1825 "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
1826 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" | |
1827 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply" | |
1828 "supply0" "supply1" "time" "tran" "tranif0" "tranif1" | |
1829 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef" | |
1830 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor" | |
1831 ) nil ))) | |
1832 | |
1833 (verilog-pragma-keywords | |
1834 (eval-when-compile | |
1835 (verilog-regexp-opt | |
1836 '("surefire" "synopsys" "rtl_synthesis" "verilint" ) nil | |
1837 ))) | |
1838 | |
1839 (verilog-p1800-keywords | |
1840 (eval-when-compile | |
1841 (verilog-regexp-opt | |
1842 '("alias" "assert" "assume" "automatic" "before" "bind" | |
1843 "bins" "binsof" "break" "byte" "cell" "chandle" "class" | |
1844 "clocking" "config" "const" "constraint" "context" "continue" | |
1845 "cover" "covergroup" "coverpoint" "cross" "deassign" "design" | |
1846 "dist" "do" "edge" "endclass" "endclocking" "endconfig" | |
1847 "endgroup" "endprogram" "endproperty" "endsequence" "enum" | |
1848 "expect" "export" "extends" "extern" "first_match" "foreach" | |
1849 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins" | |
1850 "illegal_bins" "import" "incdir" "include" "inside" "instance" | |
1851 "int" "intersect" "large" "liblist" "library" "local" "longint" | |
1852 "matches" "medium" "modport" "new" "noshowcancelled" "null" | |
1853 "packed" "program" "property" "protected" "pull0" "pull1" | |
1854 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1855 "randcase" "randsequence" "ref" "release" "return" "scalared" | |
1856 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve" | |
1857 "specparam" "static" "string" "strong0" "strong1" "struct" | |
1858 "super" "tagged" "this" "throughout" "timeprecision" "timeunit" | |
1859 "type" "union" "unsigned" "use" "var" "virtual" "void" | |
1860 "wait_order" "weak0" "weak1" "wildcard" "with" "within" | |
1861 ) nil ))) | |
1862 | |
1863 (verilog-ams-keywords | |
1864 (eval-when-compile | |
1865 (verilog-regexp-opt | |
1866 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim" | |
1867 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh" | |
1868 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt" | |
1869 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules" | |
1870 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise" | |
1871 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf" | |
1872 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp" | |
1873 "last_crossing" "limexp" "ln" "log" "max" "min" "nature" | |
1874 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin" | |
1875 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise" | |
1876 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil ))) | |
1877 | |
1878 (verilog-font-keywords | |
1879 (eval-when-compile | |
1880 (verilog-regexp-opt | |
1881 '( | |
1882 "assign" "begin" "case" "casex" "casez" "randcase" "deassign" | |
1883 "default" "disable" "else" "end" "endcase" "endfunction" | |
1884 "endgenerate" "endinterface" "endmodule" "endprimitive" | |
1885 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break" | |
1886 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial" | |
1887 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge" | |
1888 "package" "endpackage" "always" "always_comb" "always_ff" | |
1889 "always_latch" "posedge" "primitive" "priority" "release" | |
1890 "repeat" "specify" "table" "task" "unique" "wait" "while" | |
1891 "class" "program" "endclass" "endprogram" | |
1892 ) nil )))) | |
1893 | |
1894 (setq verilog-font-lock-keywords | |
1895 (list | |
1896 ;; Fontify all builtin keywords | |
1897 (concat "\\<\\(" verilog-font-keywords "\\|" | |
1898 ;; And user/system tasks and functions | |
1899 "\\$[a-zA-Z][a-zA-Z0-9_\\$]*" | |
1900 "\\)\\>") | |
1901 ;; Fontify all types | |
1902 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>") | |
1903 'font-lock-type-face) | |
1904 ;; Fontify IEEE-P1800 keywords appropriately | |
1905 (if verilog-highlight-p1800-keywords | |
1906 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
1907 'verilog-font-lock-p1800-face) | |
1908 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
1909 'font-lock-type-face)) | |
1910 ;; Fontify Verilog-AMS keywords | |
1911 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1912 'verilog-font-lock-ams-face))) |
79545 | 1913 |
1914 (setq verilog-font-lock-keywords-1 | |
1915 (append verilog-font-lock-keywords | |
1916 (list | |
1917 ;; Fontify module definitions | |
1918 (list | |
1919 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)" | |
1920 '(1 font-lock-keyword-face) | |
1921 '(3 font-lock-function-name-face 'prepend)) | |
1922 ;; Fontify function definitions | |
1923 (list | |
1924 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | |
1925 '(1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1926 '(3 font-lock-reference-face prepend)) |
79545 | 1927 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
1928 (1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1929 (2 font-lock-reference-face append)) |
79545 | 1930 '("\\<function\\>\\s-+\\(\\sw+\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1931 1 'font-lock-reference-face append)))) |
79545 | 1932 |
1933 (setq verilog-font-lock-keywords-2 | |
1934 (append verilog-font-lock-keywords-1 | |
1935 (list | |
1936 ;; Fontify pragmas | |
1937 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)") | |
1938 ;; Fontify escaped names | |
1939 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) | |
1940 ;; Fontify macro definitions/ uses | |
1941 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) | |
1942 'font-lock-preprocessor-face | |
1943 'font-lock-type-face)) | |
1944 ;; Fontify delays/numbers | |
1945 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | |
1946 0 font-lock-type-face append) | |
1947 ;; Fontify instantiation names | |
1948 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | |
1949 ))) | |
1950 | |
1951 (setq verilog-font-lock-keywords-3 | |
1952 (append verilog-font-lock-keywords-2 | |
1953 (when verilog-highlight-translate-off | |
1954 (list | |
1955 ;; Fontify things in translate off regions | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1956 '(verilog-match-translate-off |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1957 (0 'verilog-font-lock-translate-off-face prepend)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1958 ))))) |
79545 | 1959 |
1960 | |
1961 (defun verilog-inside-comment-p () | |
1962 "Check if point inside a nested comment." | |
1963 (save-excursion | |
1964 (let ((st-point (point)) hitbeg) | |
1965 (or (search-backward "//" (verilog-get-beg-of-line) t) | |
1966 (if (progn | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1967 ;; This is for tricky case //*, we keep searching if /* |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1968 ;; is proceeded by // on same line. |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1969 (while |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1970 (and (setq hitbeg (search-backward "/*" nil t)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1971 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1972 (forward-char 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1973 (search-backward "//" (verilog-get-beg-of-line) t)))) |
79545 | 1974 hitbeg) |
1975 (not (search-forward "*/" st-point t))))))) | |
1976 | |
1977 (defun verilog-declaration-end () | |
1978 (search-forward ";")) | |
1979 | |
1980 (defun verilog-point-text (&optional pointnum) | |
1981 "Return text describing where POINTNUM or current point is (for errors). | |
1982 Use filename, if current buffer being edited shorten to just buffer name." | |
1983 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer)) | |
1984 (buffer-name)) | |
1985 buffer-file-name | |
1986 (buffer-name)) | |
1987 ":" (int-to-string (count-lines (point-min) (or pointnum (point)))))) | |
1988 | |
1989 (defun electric-verilog-backward-sexp () | |
1990 "Move backward over a sexp." | |
1991 (interactive) | |
1992 ;; before that see if we are in a comment | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1993 (verilog-backward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1994 |
79545 | 1995 (defun electric-verilog-forward-sexp () |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
1996 "Move backward over a sexp." |
79545 | 1997 (interactive) |
1998 ;; before that see if we are in a comment | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1999 (verilog-forward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2000 |
79545 | 2001 ;;;used by hs-minor-mode |
2002 (defun verilog-forward-sexp-function (arg) | |
2003 (if (< arg 0) | |
2004 (verilog-backward-sexp) | |
2005 (verilog-forward-sexp))) | |
2006 | |
2007 | |
2008 (defun verilog-backward-sexp () | |
2009 (let ((reg) | |
2010 (elsec 1) | |
2011 (found nil) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2012 (st (point))) |
79545 | 2013 (if (not (looking-at "\\<")) |
2014 (forward-word -1)) | |
2015 (cond | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2016 ((verilog-skip-backward-comment-or-string)) |
79545 | 2017 ((looking-at "\\<else\\>") |
2018 (setq reg (concat | |
2019 verilog-end-block-re | |
2020 "\\|\\(\\<else\\>\\)" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2021 "\\|\\(\\<if\\>\\)")) |
79545 | 2022 (while (and (not found) |
2023 (verilog-re-search-backward reg nil 'move)) | |
2024 (cond | |
2025 ((match-end 1) ; matched verilog-end-block-re | |
2026 ; try to leap back to matching outward block by striding across | |
2027 ; indent level changing tokens then immediately | |
2028 ; previous line governs indentation. | |
2029 (verilog-leap-to-head)) | |
2030 ((match-end 2) ; else, we're in deep | |
2031 (setq elsec (1+ elsec))) | |
2032 ((match-end 3) ; found it | |
2033 (setq elsec (1- elsec)) | |
2034 (if (= 0 elsec) | |
2035 ;; Now previous line describes syntax | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2036 (setq found 't)))))) |
79545 | 2037 ((looking-at verilog-end-block-re) |
2038 (verilog-leap-to-head)) | |
2039 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | |
2040 (cond | |
2041 ((match-end 1) | |
2042 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move)) | |
2043 ((match-end 2) | |
2044 (verilog-re-search-backward "\\<primitive\\>" nil 'move)) | |
2045 ((match-end 3) | |
2046 (verilog-re-search-backward "\\<class\\>" nil 'move)) | |
2047 ((match-end 4) | |
2048 (verilog-re-search-backward "\\<program\\>" nil 'move)) | |
2049 ((match-end 5) | |
2050 (verilog-re-search-backward "\\<interface\\>" nil 'move)) | |
2051 ((match-end 6) | |
2052 (verilog-re-search-backward "\\<package\\>" nil 'move)) | |
2053 (t | |
2054 (goto-char st) | |
2055 (backward-sexp 1)))) | |
2056 (t | |
2057 (goto-char st) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2058 (backward-sexp))))) |
79545 | 2059 |
2060 (defun verilog-forward-sexp () | |
2061 (let ((reg) | |
2062 (md 2) | |
2063 (st (point))) | |
2064 (if (not (looking-at "\\<")) | |
2065 (forward-word -1)) | |
2066 (cond | |
2067 ((verilog-skip-forward-comment-or-string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2068 (verilog-forward-syntactic-ws)) |
79545 | 2069 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking |
2070 (cond | |
2071 ((match-end 1) ; end | |
2072 ;; Search forward for matching begin | |
2073 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
2074 ((match-end 2) ; endcase | |
2075 ;; Search forward for matching case | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2076 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) |
79545 | 2077 ((match-end 3) ; join |
2078 ;; Search forward for matching fork | |
2079 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
2080 ((match-end 4) ; endclass | |
2081 ;; Search forward for matching class | |
2082 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
2083 ((match-end 5) ; endtable | |
2084 ;; Search forward for matching table | |
2085 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
2086 ((match-end 6) ; endspecify | |
2087 ;; Search forward for matching specify | |
2088 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
2089 ((match-end 7) ; endfunction | |
2090 ;; Search forward for matching function | |
2091 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
2092 ((match-end 8) ; endtask | |
2093 ;; Search forward for matching task | |
2094 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
2095 ((match-end 9) ; endgenerate | |
2096 ;; Search forward for matching generate | |
2097 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
2098 ((match-end 10) ; endgroup | |
2099 ;; Search forward for matching covergroup | |
2100 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
2101 ((match-end 11) ; endproperty | |
2102 ;; Search forward for matching property | |
2103 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
2104 ((match-end 12) ; endsequence | |
2105 ;; Search forward for matching sequence | |
2106 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2107 (setq md 3)) ; 3 to get to endsequence in the reg above |
79545 | 2108 ((match-end 13) ; endclocking |
2109 ;; Search forward for matching clocking | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2110 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) |
79545 | 2111 (if (forward-word 1) |
2112 (catch 'skip | |
2113 (let ((nest 1)) | |
2114 (while (verilog-re-search-forward reg nil 'move) | |
2115 (cond | |
2116 ((match-end md) ; the closer in reg, so we are climbing out | |
2117 (setq nest (1- nest)) | |
2118 (if (= 0 nest) ; we are out! | |
2119 (throw 'skip 1))) | |
2120 ((match-end 1) ; the opener in reg, so we are deeper now | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2121 (setq nest (1+ nest))))))))) |
79545 | 2122 ((looking-at (concat |
2123 "\\(\\<\\(macro\\)?module\\>\\)\\|" | |
2124 "\\(\\<primitive\\>\\)\\|" | |
2125 "\\(\\<class\\>\\)\\|" | |
2126 "\\(\\<program\\>\\)\\|" | |
2127 "\\(\\<interface\\>\\)\\|" | |
2128 "\\(\\<package\\>\\)")) | |
2129 (cond | |
2130 ((match-end 1) | |
2131 (verilog-re-search-forward "\\<endmodule\\>" nil 'move)) | |
2132 ((match-end 2) | |
2133 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move)) | |
2134 ((match-end 3) | |
2135 (verilog-re-search-forward "\\<endclass\\>" nil 'move)) | |
2136 ((match-end 4) | |
2137 (verilog-re-search-forward "\\<endprogram\\>" nil 'move)) | |
2138 ((match-end 5) | |
2139 (verilog-re-search-forward "\\<endinterface\\>" nil 'move)) | |
2140 ((match-end 6) | |
2141 (verilog-re-search-forward "\\<endpackage\\>" nil 'move)) | |
2142 (t | |
2143 (goto-char st) | |
2144 (if (= (following-char) ?\) ) | |
2145 (forward-char 1) | |
2146 (forward-sexp 1))))) | |
2147 (t | |
2148 (goto-char st) | |
2149 (if (= (following-char) ?\) ) | |
2150 (forward-char 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2151 (forward-sexp 1)))))) |
79545 | 2152 |
2153 (defun verilog-declaration-beg () | |
2154 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | |
2155 | |
2156 (defun verilog-font-lock-init () | |
2157 "Initialize fontification." | |
2158 ;; highlight keywords and standardized types, attributes, enumeration | |
2159 ;; values, and subprograms | |
2160 (setq verilog-font-lock-keywords-3 | |
2161 (append verilog-font-lock-keywords-2 | |
2162 (when verilog-highlight-translate-off | |
2163 (list | |
2164 ;; Fontify things in translate off regions | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2165 '(verilog-match-translate-off |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2166 (0 'verilog-font-lock-translate-off-face prepend)))))) |
79545 | 2167 (put 'verilog-mode 'font-lock-defaults |
2168 '((verilog-font-lock-keywords | |
2169 verilog-font-lock-keywords-1 | |
2170 verilog-font-lock-keywords-2 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2171 verilog-font-lock-keywords-3) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2172 nil ; nil means highlight strings & comments as well as keywords |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2173 nil ; nil means keywords must match case |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2174 nil ; syntax table handled elsewhere |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2175 ;; Function to move to beginning of reasonable region to highlight |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2176 verilog-beg-of-defun))) |
79545 | 2177 |
2178 ;; initialize fontification for Verilog Mode | |
2179 (verilog-font-lock-init) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2180 |
79545 | 2181 ;; |
2182 ;; | |
2183 ;; Mode | |
2184 ;; | |
2185 (defvar verilog-which-tool 1) | |
79546 | 2186 ;;;###autoload |
79545 | 2187 (defun verilog-mode () |
2188 "Major mode for editing Verilog code. | |
2189 \\<verilog-mode-map> | |
2190 See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how | |
2191 AUTOs can improve coding efficiency. | |
2192 | |
2193 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
2194 | |
2195 NEWLINE, TAB indents for Verilog code. | |
2196 Delete converts tabs to spaces as it moves back. | |
2197 | |
2198 Supports highlighting. | |
2199 | |
2200 Turning on Verilog mode calls the value of the variable `verilog-mode-hook' | |
2201 with no args, if that value is non-nil. | |
2202 | |
2203 Variables controlling indentation/edit style: | |
2204 | |
2205 variable `verilog-indent-level' (default 3) | |
2206 Indentation of Verilog statements with respect to containing block. | |
2207 `verilog-indent-level-module' (default 3) | |
2208 Absolute indentation of Module level Verilog statements. | |
2209 Set to 0 to get initial and always statements lined up | |
2210 on the left side of your screen. | |
2211 `verilog-indent-level-declaration' (default 3) | |
2212 Indentation of declarations with respect to containing block. | |
2213 Set to 0 to get them list right under containing block. | |
2214 `verilog-indent-level-behavioral' (default 3) | |
2215 Indentation of first begin in a task or function block | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2216 Set to 0 to get such code to lined up underneath the task or function keyword |
79545 | 2217 `verilog-indent-level-directive' (default 1) |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2218 Indentation of `ifdef/`endif blocks |
79545 | 2219 `verilog-cexp-indent' (default 1) |
2220 Indentation of Verilog statements broken across lines i.e.: | |
2221 if (a) | |
2222 begin | |
2223 `verilog-case-indent' (default 2) | |
2224 Indentation for case statements. | |
2225 `verilog-auto-newline' (default nil) | |
2226 Non-nil means automatically newline after semicolons and the punctuation | |
2227 mark after an end. | |
2228 `verilog-auto-indent-on-newline' (default t) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2229 Non-nil means automatically indent line after newline |
79545 | 2230 `verilog-tab-always-indent' (default t) |
2231 Non-nil means TAB in Verilog mode should always reindent the current line, | |
2232 regardless of where in the line point is when the TAB command is used. | |
2233 `verilog-indent-begin-after-if' (default t) | |
2234 Non-nil means to indent begin statements following a preceding | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2235 if, else, while, for and repeat statements, if any. otherwise, |
79545 | 2236 the begin is lined up with the preceding token. If t, you get: |
2237 if (a) | |
2238 begin // amount of indent based on `verilog-cexp-indent' | |
2239 otherwise you get: | |
2240 if (a) | |
2241 begin | |
2242 `verilog-auto-endcomments' (default t) | |
2243 Non-nil means a comment /* ... */ is set after the ends which ends | |
2244 cases, tasks, functions and modules. | |
2245 The type and name of the object will be set between the braces. | |
2246 `verilog-minimum-comment-distance' (default 10) | |
2247 Minimum distance (in lines) between begin and end required before a comment | |
2248 will be inserted. Setting this variable to zero results in every | |
2249 end acquiring a comment; the default avoids too many redundant | |
2250 comments in tight quarters. | |
2251 `verilog-auto-lineup' (default `(all)) | |
2252 List of contexts where auto lineup of code should be done. | |
2253 | |
2254 Variables controlling other actions: | |
2255 | |
2256 `verilog-linter' (default surelint) | |
2257 Unix program to call to run the lint checker. This is the default | |
2258 command for \\[compile-command] and \\[verilog-auto-save-compile]. | |
2259 | |
2260 See \\[customize] for the complete list of variables. | |
2261 | |
2262 AUTO expansion functions are, in part: | |
2263 | |
2264 \\[verilog-auto] Expand AUTO statements. | |
2265 \\[verilog-delete-auto] Remove the AUTOs. | |
2266 \\[verilog-inject-auto] Insert AUTOs for the first time. | |
2267 | |
2268 Some other functions are: | |
2269 | |
2270 \\[verilog-complete-word] Complete word with appropriate possibilities. | |
2271 \\[verilog-mark-defun] Mark function. | |
2272 \\[verilog-beg-of-defun] Move to beginning of current function. | |
2273 \\[verilog-end-of-defun] Move to end of current function. | |
2274 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements. | |
2275 | |
2276 \\[verilog-comment-region] Put marked area in a comment. | |
2277 \\[verilog-uncomment-region] Uncomment an area commented with \\[verilog-comment-region]. | |
2278 \\[verilog-insert-block] Insert begin ... end;. | |
2279 \\[verilog-star-comment] Insert /* ... */. | |
2280 | |
2281 \\[verilog-sk-always] Insert a always @(AS) begin .. end block. | |
2282 \\[verilog-sk-begin] Insert a begin .. end block. | |
2283 \\[verilog-sk-case] Insert a case block, prompting for details. | |
2284 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details. | |
2285 \\[verilog-sk-generate] Insert a generate .. endgenerate block. | |
2286 \\[verilog-sk-header] Insert a nice header block at the top of file. | |
2287 \\[verilog-sk-initial] Insert an initial begin .. end block. | |
2288 \\[verilog-sk-fork] Insert a fork begin .. end .. join block. | |
2289 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block. | |
2290 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block. | |
2291 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. | |
2292 \\[verilog-sk-specify] Insert a specify .. endspecify block. | |
2293 \\[verilog-sk-task] Insert a task .. begin .. end endtask block. | |
2294 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details. | |
2295 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details. | |
2296 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details. | |
2297 \\[verilog-sk-if] Insert an if (..) begin .. end block. | |
2298 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block. | |
2299 \\[verilog-sk-comment] Insert a comment block. | |
2300 \\[verilog-sk-assign] Insert an assign .. = ..; statement. | |
2301 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block. | |
2302 \\[verilog-sk-input] Insert an input declaration, prompting for details. | |
2303 \\[verilog-sk-output] Insert an output declaration, prompting for details. | |
2304 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details. | |
2305 \\[verilog-sk-inout] Insert an inout declaration, prompting for details. | |
2306 \\[verilog-sk-wire] Insert a wire declaration, prompting for details. | |
2307 \\[verilog-sk-reg] Insert a register declaration, prompting for details. | |
2308 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module. | |
2309 | |
2310 All key bindings can be seen in a Verilog-buffer with \\[describe-bindings]. | |
2311 Key bindings specific to `verilog-mode-map' are: | |
2312 | |
2313 \\{verilog-mode-map}" | |
2314 (interactive) | |
2315 (kill-all-local-variables) | |
2316 (use-local-map verilog-mode-map) | |
2317 (setq major-mode 'verilog-mode) | |
2318 (setq mode-name "Verilog") | |
2319 (setq local-abbrev-table verilog-mode-abbrev-table) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2320 (set (make-local-variable 'beginning-of-defun-function) |
79546 | 2321 'verilog-beg-of-defun) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2322 (set (make-local-variable 'end-of-defun-function) |
79546 | 2323 'verilog-end-of-defun) |
79545 | 2324 (set-syntax-table verilog-mode-syntax-table) |
2325 (make-local-variable 'indent-line-function) | |
2326 (setq indent-line-function 'verilog-indent-line-relative) | |
2327 (setq comment-indent-function 'verilog-comment-indent) | |
2328 (make-local-variable 'parse-sexp-ignore-comments) | |
2329 (setq parse-sexp-ignore-comments nil) | |
2330 (make-local-variable 'comment-start) | |
2331 (make-local-variable 'comment-end) | |
2332 (make-local-variable 'comment-multi-line) | |
2333 (make-local-variable 'comment-start-skip) | |
2334 (setq comment-start "// " | |
2335 comment-end "" | |
2336 comment-start-skip "/\\*+ *\\|// *" | |
2337 comment-multi-line nil) | |
2338 ;; Set up for compilation | |
2339 (setq verilog-which-tool 1) | |
2340 (setq verilog-tool 'verilog-linter) | |
2341 (verilog-set-compile-command) | |
2342 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables | |
2343 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) | |
2344 | |
2345 ;; Setting up menus | |
79546 | 2346 (when (featurep 'xemacs) |
2347 (when (and current-menubar | |
2348 (not (assoc "Verilog" current-menubar))) | |
2349 ;; (set-buffer-menubar (copy-sequence current-menubar)) | |
2350 (add-submenu nil verilog-xemacs-menu) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2351 (add-submenu nil verilog-stmt-menu))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2352 |
79545 | 2353 ;; Stuff for GNU emacs |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2354 (set (make-local-variable 'font-lock-defaults) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2355 '((verilog-font-lock-keywords verilog-font-lock-keywords-1 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2356 verilog-font-lock-keywords-2 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2357 verilog-font-lock-keywords-3) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2358 nil nil nil verilog-beg-of-defun)) |
79545 | 2359 ;;------------------------------------------------------------ |
2360 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el) | |
2361 ;; all buffer local: | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2362 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2363 (make-local-hook 'font-lock-mode-hook) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2364 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2365 (make-local-hook 'after-change-functions)) |
79545 | 2366 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t) |
2367 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20 | |
2368 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) | |
2369 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2370 ;; Tell imenu how to handle verilog. |
79545 | 2371 (make-local-variable 'imenu-generic-expression) |
2372 (setq imenu-generic-expression verilog-imenu-generic-expression) | |
2373 ;; hideshow support | |
2374 (unless (assq 'verilog-mode hs-special-modes-alist) | |
2375 (setq hs-special-modes-alist | |
2376 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil | |
2377 verilog-forward-sexp-function) | |
2378 hs-special-modes-alist))) | |
2379 | |
2380 ;; Stuff for autos | |
2381 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | |
2382 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them | |
2383 ;; (verilog-getopt-flags) | |
2384 (run-hooks 'verilog-mode-hook)) | |
2385 | |
2386 | |
2387 ;; | |
2388 ;; Electric functions | |
2389 ;; | |
2390 (defun electric-verilog-terminate-line (&optional arg) | |
2391 "Terminate line and indent next line. | |
2392 With optional ARG, remove existing end of line comments." | |
2393 (interactive) | |
2394 ;; before that see if we are in a comment | |
2395 (let ((state | |
2396 (save-excursion | |
2397 (parse-partial-sexp (point-min) (point))))) | |
2398 (cond | |
2399 ((nth 7 state) ; Inside // comment | |
2400 (if (eolp) | |
2401 (progn | |
2402 (delete-horizontal-space) | |
2403 (newline)) | |
2404 (progn | |
2405 (newline) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2406 (insert "// ") |
79545 | 2407 (beginning-of-line))) |
2408 (verilog-indent-line)) | |
2409 ((nth 4 state) ; Inside any comment (hence /**/) | |
2410 (newline) | |
2411 (verilog-more-comment)) | |
2412 ((eolp) | |
2413 ;; First, check if current line should be indented | |
2414 (if (save-excursion | |
2415 (delete-horizontal-space) | |
2416 (beginning-of-line) | |
2417 (skip-chars-forward " \t") | |
2418 (if (looking-at verilog-auto-end-comment-lines-re) | |
2419 (let ((indent-str (verilog-indent-line))) | |
2420 ;; Maybe we should set some endcomments | |
2421 (if verilog-auto-endcomments | |
2422 (verilog-set-auto-endcomments indent-str arg)) | |
2423 (end-of-line) | |
2424 (delete-horizontal-space) | |
2425 (if arg | |
2426 () | |
2427 (newline)) | |
2428 nil) | |
2429 (progn | |
2430 (end-of-line) | |
2431 (delete-horizontal-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2432 't))) |
79545 | 2433 ;; see if we should line up assignments |
2434 (progn | |
2435 (if (or (memq 'all verilog-auto-lineup) | |
2436 (memq 'assignments verilog-auto-lineup)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2437 (verilog-pretty-expr)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2438 (newline)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2439 (forward-line 1)) |
79545 | 2440 ;; Indent next line |
2441 (if verilog-auto-indent-on-newline | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2442 (verilog-indent-line))) |
79545 | 2443 (t |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2444 (newline))))) |
79545 | 2445 |
2446 (defun electric-verilog-terminate-and-indent () | |
2447 "Insert a newline and indent for the next statement." | |
2448 (interactive) | |
2449 (electric-verilog-terminate-line 1)) | |
2450 | |
2451 (defun electric-verilog-semi () | |
2452 "Insert `;' character and reindent the line." | |
2453 (interactive) | |
2454 (insert last-command-char) | |
2455 | |
2456 (if (or (verilog-in-comment-or-string-p) | |
2457 (verilog-in-escaped-name-p)) | |
2458 () | |
2459 (save-excursion | |
2460 (beginning-of-line) | |
2461 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2462 (verilog-indent-line)) |
79545 | 2463 (if (and verilog-auto-newline |
2464 (not (verilog-parenthesis-depth))) | |
2465 (electric-verilog-terminate-line)))) | |
2466 | |
2467 (defun electric-verilog-semi-with-comment () | |
2468 "Insert `;' character, reindent the line and indent for comment." | |
2469 (interactive) | |
2470 (insert "\;") | |
2471 (save-excursion | |
2472 (beginning-of-line) | |
2473 (verilog-indent-line)) | |
2474 (indent-for-comment)) | |
2475 | |
2476 (defun electric-verilog-colon () | |
2477 "Insert `:' and do all indentations except line indent on this line." | |
2478 (interactive) | |
2479 (insert last-command-char) | |
2480 ;; Do nothing if within string. | |
2481 (if (or | |
2482 (verilog-within-string) | |
2483 (not (verilog-in-case-region-p))) | |
2484 () | |
2485 (save-excursion | |
2486 (let ((p (point)) | |
2487 (lim (progn (verilog-beg-of-statement) (point)))) | |
2488 (goto-char p) | |
2489 (verilog-backward-case-item lim) | |
2490 (verilog-indent-line))) | |
2491 ;; (let ((verilog-tab-always-indent nil)) | |
2492 ;; (verilog-indent-line)) | |
2493 )) | |
2494 | |
2495 ;;(defun electric-verilog-equal () | |
2496 ;; "Insert `=', and do indentation if within block." | |
2497 ;; (interactive) | |
2498 ;; (insert last-command-char) | |
2499 ;; Could auto line up expressions, but not yet | |
2500 ;; (if (eq (car (verilog-calculate-indent)) 'block) | |
2501 ;; (let ((verilog-tab-always-indent nil)) | |
2502 ;; (verilog-indent-command))) | |
2503 ;; ) | |
2504 | |
2505 (defun electric-verilog-tick () | |
2506 "Insert back-tick, and indent to column 0 if this is a CPP directive." | |
2507 (interactive) | |
2508 (insert last-command-char) | |
2509 (save-excursion | |
2510 (if (progn | |
2511 (beginning-of-line) | |
2512 (looking-at verilog-directive-re-1)) | |
2513 (verilog-indent-line)))) | |
2514 | |
2515 (defun electric-verilog-tab () | |
2516 "Function called when TAB is pressed in Verilog mode." | |
2517 (interactive) | |
2518 ;; If verilog-tab-always-indent, indent the beginning of the line. | |
2519 (if (or verilog-tab-always-indent | |
2520 (save-excursion | |
2521 (skip-chars-backward " \t") | |
2522 (bolp))) | |
2523 (let* ((oldpnt (point)) | |
2524 (boi-point | |
2525 (save-excursion | |
2526 (beginning-of-line) | |
2527 (skip-chars-forward " \t") | |
2528 (verilog-indent-line) | |
2529 (back-to-indentation) | |
2530 (point)))) | |
2531 (if (< (point) boi-point) | |
2532 (back-to-indentation) | |
2533 (cond ((not verilog-tab-to-comment)) | |
2534 ((not (eolp)) | |
2535 (end-of-line)) | |
2536 (t | |
2537 (indent-for-comment) | |
2538 (when (and (eolp) (= oldpnt (point))) | |
2539 ; kill existing comment | |
2540 (beginning-of-line) | |
2541 (re-search-forward comment-start-skip oldpnt 'move) | |
2542 (goto-char (match-beginning 0)) | |
2543 (skip-chars-backward " \t") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2544 (kill-region (point) oldpnt)))))) |
79545 | 2545 (progn (insert "\t")))) |
2546 | |
2547 | |
2548 | |
2549 ;; | |
2550 ;; Interactive functions | |
2551 ;; | |
2552 | |
2553 (defun verilog-indent-buffer () | |
2554 "Indent-region the entire buffer as Verilog code. | |
2555 To call this from the command line, see \\[verilog-batch-indent]." | |
2556 (interactive) | |
2557 (verilog-mode) | |
2558 (indent-region (point-min) (point-max) nil)) | |
2559 | |
2560 (defun verilog-insert-block () | |
2561 "Insert Verilog begin ... end; block in the code with right indentation." | |
2562 (interactive) | |
2563 (verilog-indent-line) | |
2564 (insert "begin") | |
2565 (electric-verilog-terminate-line) | |
2566 (save-excursion | |
2567 (electric-verilog-terminate-line) | |
2568 (insert "end") | |
2569 (beginning-of-line) | |
2570 (verilog-indent-line))) | |
2571 | |
2572 (defun verilog-star-comment () | |
2573 "Insert Verilog star comment at point." | |
2574 (interactive) | |
2575 (verilog-indent-line) | |
2576 (insert "/*") | |
2577 (save-excursion | |
2578 (newline) | |
2579 (insert " */")) | |
2580 (newline) | |
2581 (insert " * ")) | |
2582 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2583 (defun verilog-insert-1 (fmt max) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2584 "Use format string FMT to insert integers 0 to MAX - 1. |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2585 Inserts one integer per line, at the current column. Stops early |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2586 if it reaches the end of the buffer." |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2587 (let ((col (current-column)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2588 (n 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2589 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2590 (while (< n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2591 (insert (format fmt n)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2592 (forward-line 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2593 ;; Note that this function does not bother to check for lines |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2594 ;; shorter than col. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2595 (if (eobp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2596 (setq n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2597 (setq n (1+ n)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2598 (move-to-column col)))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2599 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2600 (defun verilog-insert-indices (max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2601 "Insert a set of indices into a rectangle. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2602 The upper left corner is defined by point. Indices begin with 0 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2603 and extend to the MAX - 1. If no prefix arg is given, the user |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2604 is prompted for a value. The indices are surrounded by square |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2605 brackets \[]. For example, the following code with the point |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2606 located after the first 'a' gives: |
79545 | 2607 |
2608 a = b a[ 0] = b | |
2609 a = b a[ 1] = b | |
2610 a = b a[ 2] = b | |
2611 a = b a[ 3] = b | |
2612 a = b ==> insert-indices ==> a[ 4] = b | |
2613 a = b a[ 5] = b | |
2614 a = b a[ 6] = b | |
2615 a = b a[ 7] = b | |
2616 a = b a[ 8] = b" | |
2617 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2618 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2619 (verilog-insert-1 "[%3d]" max)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2620 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2621 (defun verilog-generate-numbers (max) |
79545 | 2622 "Insert a set of generated numbers into a rectangle. |
2623 The upper left corner is defined by point. The numbers are padded to three | |
2624 digits, starting with 000 and extending to (MAX - 1). If no prefix argument | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2625 is supplied, then the user is prompted for the MAX number. Consider the |
79545 | 2626 following code fragment: |
2627 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2628 buf buf buf buf000 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2629 buf buf buf buf001 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2630 buf buf buf buf002 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2631 buf buf buf buf003 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2632 buf buf ==> generate-numbers ==> buf buf004 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2633 buf buf buf buf005 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2634 buf buf buf buf006 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2635 buf buf buf buf007 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2636 buf buf buf buf008" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2637 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2638 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2639 (verilog-insert-1 "%3.3d" max)) |
79545 | 2640 |
2641 (defun verilog-mark-defun () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2642 "Mark the current verilog function (or procedure). |
79545 | 2643 This puts the mark at the end, and point at the beginning." |
2644 (interactive) | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2645 (when (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2646 (push-mark (point)) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2647 (verilog-end-of-defun) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2648 (push-mark (point)) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2649 (verilog-beg-of-defun) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2650 (if (fboundp 'zmacs-activate-region) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2651 (zmacs-activate-region)))) |
79545 | 2652 |
2653 (defun verilog-comment-region (start end) | |
2654 ; checkdoc-params: (start end) | |
2655 "Put the region into a Verilog comment. | |
2656 The comments that are in this area are \"deformed\": | |
2657 `*)' becomes `!(*' and `}' becomes `!{'. | |
2658 These deformed comments are returned to normal if you use | |
2659 \\[verilog-uncomment-region] to undo the commenting. | |
2660 | |
2661 The commented area starts with `verilog-exclude-str-start', and ends with | |
2662 `verilog-exclude-str-end'. But if you change these variables, | |
2663 \\[verilog-uncomment-region] won't recognize the comments." | |
2664 (interactive "r") | |
2665 (save-excursion | |
2666 ;; Insert start and endcomments | |
2667 (goto-char end) | |
2668 (if (and (save-excursion (skip-chars-forward " \t") (eolp)) | |
2669 (not (save-excursion (skip-chars-backward " \t") (bolp)))) | |
2670 (forward-line 1) | |
2671 (beginning-of-line)) | |
2672 (insert verilog-exclude-str-end) | |
2673 (setq end (point)) | |
2674 (newline) | |
2675 (goto-char start) | |
2676 (beginning-of-line) | |
2677 (insert verilog-exclude-str-start) | |
2678 (newline) | |
2679 ;; Replace end-comments within commented area | |
2680 (goto-char end) | |
2681 (save-excursion | |
2682 (while (re-search-backward "\\*/" start t) | |
2683 (replace-match "*-/" t t))) | |
2684 (save-excursion | |
2685 (let ((s+1 (1+ start))) | |
2686 (while (re-search-backward "/\\*" s+1 t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2687 (replace-match "/-*" t t)))))) |
79545 | 2688 |
2689 (defun verilog-uncomment-region () | |
2690 "Uncomment a commented area; change deformed comments back to normal. | |
2691 This command does nothing if the pointer is not in a commented | |
2692 area. See also `verilog-comment-region'." | |
2693 (interactive) | |
2694 (save-excursion | |
2695 (let ((start (point)) | |
2696 (end (point))) | |
2697 ;; Find the boundaries of the comment | |
2698 (save-excursion | |
2699 (setq start (progn (search-backward verilog-exclude-str-start nil t) | |
2700 (point))) | |
2701 (setq end (progn (search-forward verilog-exclude-str-end nil t) | |
2702 (point)))) | |
2703 ;; Check if we're really inside a comment | |
2704 (if (or (equal start (point)) (<= end (point))) | |
2705 (message "Not standing within commented area.") | |
2706 (progn | |
2707 ;; Remove endcomment | |
2708 (goto-char end) | |
2709 (beginning-of-line) | |
2710 (let ((pos (point))) | |
2711 (end-of-line) | |
2712 (delete-region pos (1+ (point)))) | |
2713 ;; Change comments back to normal | |
2714 (save-excursion | |
2715 (while (re-search-backward "\\*-/" start t) | |
2716 (replace-match "*/" t t))) | |
2717 (save-excursion | |
2718 (while (re-search-backward "/-\\*" start t) | |
2719 (replace-match "/*" t t))) | |
2720 ;; Remove start comment | |
2721 (goto-char start) | |
2722 (beginning-of-line) | |
2723 (let ((pos (point))) | |
2724 (end-of-line) | |
2725 (delete-region pos (1+ (point))))))))) | |
2726 | |
2727 (defun verilog-beg-of-defun () | |
2728 "Move backward to the beginning of the current function or procedure." | |
2729 (interactive) | |
2730 (verilog-re-search-backward verilog-defun-re nil 'move)) | |
2731 | |
2732 (defun verilog-end-of-defun () | |
2733 "Move forward to the end of the current function or procedure." | |
2734 (interactive) | |
2735 (verilog-re-search-forward verilog-end-defun-re nil 'move)) | |
2736 | |
2737 (defun verilog-get-beg-of-defun (&optional warn) | |
2738 (save-excursion | |
2739 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t) | |
2740 (point)) | |
2741 (t | |
2742 (error "%s: Can't find module beginning" (verilog-point-text)) | |
2743 (point-max))))) | |
2744 (defun verilog-get-end-of-defun (&optional warn) | |
2745 (save-excursion | |
2746 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t) | |
2747 (point)) | |
2748 (t | |
2749 (error "%s: Can't find endmodule" (verilog-point-text)) | |
2750 (point-max))))) | |
2751 | |
2752 (defun verilog-label-be (&optional arg) | |
2753 "Label matching begin ... end, fork ... join and case ... endcase statements. | |
2754 With ARG, first kill any existing labels." | |
2755 (interactive) | |
2756 (let ((cnt 0) | |
2757 (oldpos (point)) | |
2758 (b (progn | |
2759 (verilog-beg-of-defun) | |
2760 (point-marker))) | |
2761 (e (progn | |
2762 (verilog-end-of-defun) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2763 (point-marker)))) |
79545 | 2764 (goto-char (marker-position b)) |
2765 (if (> (- e b) 200) | |
2766 (message "Relabeling module...")) | |
2767 (while (and | |
2768 (> (marker-position e) (point)) | |
2769 (verilog-re-search-forward | |
2770 (concat | |
2771 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>" | |
2772 "\\|\\(`endif\\)\\|\\(`else\\)") | |
2773 nil 'move)) | |
2774 (goto-char (match-beginning 0)) | |
2775 (let ((indent-str (verilog-indent-line))) | |
2776 (verilog-set-auto-endcomments indent-str 't) | |
2777 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2778 (delete-horizontal-space)) |
79545 | 2779 (setq cnt (1+ cnt)) |
2780 (if (= 9 (% cnt 10)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2781 (message "%d..." cnt))) |
79545 | 2782 (goto-char oldpos) |
2783 (if (or | |
2784 (> (- e b) 200) | |
2785 (> cnt 20)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2786 (message "%d lines auto commented" cnt)))) |
79545 | 2787 |
2788 (defun verilog-beg-of-statement () | |
2789 "Move backward to beginning of statement." | |
2790 (interactive) | |
2791 ;; Move back token by token until we see the end | |
2792 ;; of some ealier line. | |
2793 (while | |
2794 ;; If the current point does not begin a new | |
2795 ;; statement, as in the character ahead of us is a ';', or SOF | |
2796 ;; or the string after us unambiguosly starts a statement, | |
2797 ;; or the token before us unambiguously ends a statement, | |
2798 ;; then move back a token and test again. | |
2799 (not (or | |
2800 (bolp) | |
2801 (= (preceding-char) ?\;) | |
2802 (not (or | |
2803 (looking-at "\\<") | |
2804 (forward-word -1))) | |
2805 (and | |
2806 (looking-at verilog-extended-complete-re) | |
2807 (not (save-excursion | |
2808 (verilog-backward-token) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2809 (looking-at verilog-extended-complete-re)))) |
79545 | 2810 (looking-at verilog-basic-complete-re) |
2811 (save-excursion | |
2812 (verilog-backward-token) | |
2813 (or | |
2814 (looking-at verilog-end-block-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2815 (looking-at verilog-preprocessor-re))))) |
79545 | 2816 (verilog-backward-syntactic-ws) |
2817 (verilog-backward-token)) | |
2818 ;; Now point is where the previous line ended. | |
2819 (verilog-forward-syntactic-ws)) | |
2820 | |
2821 (defun verilog-beg-of-statement-1 () | |
2822 "Move backward to beginning of statement." | |
2823 (interactive) | |
2824 (let ((pt (point))) | |
2825 | |
2826 (while (and (not (looking-at verilog-complete-reg)) | |
2827 (setq pt (point)) | |
2828 (verilog-backward-token) | |
2829 (not (looking-at verilog-complete-reg)) | |
2830 (verilog-backward-syntactic-ws) | |
2831 (setq pt (point)) | |
2832 (not (bolp)) | |
2833 (not (= (preceding-char) ?\;)))) | |
2834 (goto-char pt) | |
2835 (verilog-forward-ws&directives))) | |
2836 | |
2837 (defun verilog-end-of-statement () | |
2838 "Move forward to end of current statement." | |
2839 (interactive) | |
2840 (let ((nest 0) pos) | |
2841 (or (looking-at verilog-beg-block-re) | |
2842 ;; Skip to end of statement | |
2843 (setq pos (catch 'found | |
2844 (while t | |
2845 (forward-sexp 1) | |
2846 (verilog-skip-forward-comment-or-string) | |
2847 (cond ((looking-at "[ \t]*;") | |
2848 (skip-chars-forward "^;") | |
2849 (forward-char 1) | |
2850 (throw 'found (point))) | |
2851 ((save-excursion | |
2852 (forward-sexp -1) | |
2853 (looking-at verilog-beg-block-re)) | |
2854 (goto-char (match-beginning 0)) | |
2855 (throw 'found nil)) | |
2856 ((looking-at "[ \t]*)") | |
79546 | 2857 (throw 'found (point))) |
79545 | 2858 ((eobp) |
2859 (throw 'found (point)))))))) | |
2860 (if (not pos) | |
2861 ;; Skip a whole block | |
2862 (catch 'found | |
2863 (while t | |
2864 (verilog-re-search-forward verilog-end-statement-re nil 'move) | |
2865 (setq nest (if (match-end 1) | |
2866 (1+ nest) | |
2867 (1- nest))) | |
2868 (cond ((eobp) | |
2869 (throw 'found (point))) | |
2870 ((= 0 nest) | |
2871 (throw 'found (verilog-end-of-statement)))))) | |
2872 pos))) | |
2873 | |
2874 (defun verilog-in-case-region-p () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2875 "Return TRUE if in a case region; |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2876 more specifically, point @ in the line foo : @ begin" |
79545 | 2877 (interactive) |
2878 (save-excursion | |
2879 (if (and | |
2880 (progn (verilog-forward-syntactic-ws) | |
2881 (looking-at "\\<begin\\>")) | |
2882 (progn (verilog-backward-syntactic-ws) | |
2883 (= (preceding-char) ?\:))) | |
2884 (catch 'found | |
2885 (let ((nest 1)) | |
2886 (while t | |
2887 (verilog-re-search-backward | |
2888 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|" | |
2889 "\\(\\<endcase\\>\\)\\>") | |
2890 nil 'move) | |
2891 (cond | |
2892 ((match-end 3) | |
2893 (setq nest (1+ nest))) | |
2894 ((match-end 2) | |
2895 (if (= nest 1) | |
2896 (throw 'found 1)) | |
2897 (setq nest (1- nest))) | |
2898 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2899 (throw 'found (= nest 0))))))) |
79545 | 2900 nil))) |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2901 |
79545 | 2902 (defun verilog-in-struct-region-p () |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2903 "Return TRUE if in a struct region; |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2904 more specifically, in a list after a struct|union keyword" |
79545 | 2905 (interactive) |
2906 (save-excursion | |
2907 (let* ((state (parse-partial-sexp (point-min) (point))) | |
2908 (depth (nth 0 state))) | |
2909 (if depth | |
2910 (progn (backward-up-list depth) | |
2911 (verilog-beg-of-statement) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2912 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
79545 | 2913 |
2914 (defun verilog-in-generate-region-p () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2915 "Return TRUE if in a generate region; |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
2916 more specifically, after a generate and before an endgenerate" |
79545 | 2917 (interactive) |
2918 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2919 (nest 1)) |
79545 | 2920 (save-excursion |
2921 (while (and | |
2922 (/= nest 0) | |
2923 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) | |
2924 (cond | |
2925 ((match-end 1) ; generate | |
2926 (setq nest (1- nest))) | |
2927 ((match-end 2) ; endgenerate | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2928 (setq nest (1+ nest))))))) |
79545 | 2929 (= nest 0) )) ; return nest |
2930 | |
2931 (defun verilog-in-fork-region-p () | |
2932 "Return true if between a fork and join." | |
2933 (interactive) | |
2934 (let ((lim (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2935 (nest 1)) |
79545 | 2936 (save-excursion |
2937 (while (and | |
2938 (/= nest 0) | |
2939 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | |
2940 (cond | |
2941 ((match-end 1) ; fork | |
2942 (setq nest (1- nest))) | |
2943 ((match-end 2) ; join | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2944 (setq nest (1+ nest))))))) |
79545 | 2945 (= nest 0) )) ; return nest |
2946 | |
2947 (defun verilog-backward-case-item (lim) | |
2948 "Skip backward to nearest enclosing case item. | |
2949 Limit search to point LIM." | |
2950 (interactive) | |
2951 (let ((str 'nil) | |
2952 (lim1 | |
2953 (progn | |
2954 (save-excursion | |
2955 (verilog-re-search-backward verilog-endcomment-reason-re | |
2956 lim 'move) | |
2957 (point))))) | |
2958 ;; Try to find the real : | |
2959 (if (save-excursion (search-backward ":" lim1 t)) | |
2960 (let ((colon 0) | |
2961 b e ) | |
2962 (while | |
2963 (and | |
2964 (< colon 1) | |
2965 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" | |
2966 lim1 'move)) | |
2967 (cond | |
2968 ((match-end 1) ;; [ | |
2969 (setq colon (1+ colon)) | |
2970 (if (>= colon 0) | |
2971 (error "%s: unbalanced [" (verilog-point-text)))) | |
2972 ((match-end 2) ;; ] | |
2973 (setq colon (1- colon))) | |
2974 | |
2975 ((match-end 3) ;; : | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2976 (setq colon (1+ colon))))) |
79545 | 2977 ;; Skip back to beginning of case item |
2978 (skip-chars-backward "\t ") | |
2979 (verilog-skip-backward-comment-or-string) | |
2980 (setq e (point)) | |
2981 (setq b | |
2982 (progn | |
2983 (if | |
2984 (verilog-re-search-backward | |
2985 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move) | |
2986 (progn | |
2987 (cond | |
2988 ((match-end 1) | |
2989 (goto-char (match-end 1)) | |
2990 (verilog-forward-ws&directives) | |
2991 (if (looking-at "(") | |
2992 (progn | |
2993 (forward-sexp) | |
2994 (verilog-forward-ws&directives))) | |
2995 (point)) | |
2996 (t | |
2997 (goto-char (match-end 0)) | |
2998 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2999 (point)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3000 (error "Malformed case item")))) |
79545 | 3001 (setq str (buffer-substring b e)) |
3002 (if | |
3003 (setq e | |
3004 (string-match | |
3005 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3006 (setq str (concat (substring str 0 e) "..."))) | |
3007 str) | |
3008 'nil))) | |
3009 | |
3010 | |
3011 ;; | |
3012 ;; Other functions | |
3013 ;; | |
3014 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3015 (defun verilog-kill-existing-comment () |
79545 | 3016 "Kill auto comment on this line." |
3017 (save-excursion | |
3018 (let* ( | |
3019 (e (progn | |
3020 (end-of-line) | |
3021 (point))) | |
3022 (b (progn | |
3023 (beginning-of-line) | |
3024 (search-forward "//" e t)))) | |
3025 (if b | |
3026 (delete-region (- b 2) e))))) | |
3027 | |
3028 (defconst verilog-directive-nest-re | |
3029 (concat "\\(`else\\>\\)\\|" | |
3030 "\\(`endif\\>\\)\\|" | |
3031 "\\(`if\\>\\)\\|" | |
3032 "\\(`ifdef\\>\\)\\|" | |
3033 "\\(`ifndef\\>\\)")) | |
3034 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment) | |
3035 "Add ending comment with given INDENT-STR. | |
3036 With KILL-EXISTING-COMMENT, remove what was there before. | |
3037 Insert `// case: 7 ' or `// NAME ' on this line if appropriate. | |
3038 Insert `// case expr ' if this line ends a case block. | |
3039 Insert `// ifdef FOO ' if this line ends code conditional on FOO. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3040 Insert `// NAME ' if this line ends a function, task, module, primitive or interface named NAME." |
79545 | 3041 (save-excursion |
3042 (cond | |
3043 (; Comment close preprocessor directives | |
3044 (and | |
3045 (looking-at "\\(`endif\\)\\|\\(`else\\)") | |
3046 (or kill-existing-comment | |
3047 (not (save-excursion | |
3048 (end-of-line) | |
3049 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3050 (let ((nest 1) b e | |
3051 m | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3052 (else (if (match-end 2) "!" " "))) |
79545 | 3053 (end-of-line) |
3054 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3055 (verilog-kill-existing-comment)) |
79545 | 3056 (delete-horizontal-space) |
3057 (save-excursion | |
3058 (backward-sexp 1) | |
3059 (while (and (/= nest 0) | |
3060 (verilog-re-search-backward verilog-directive-nest-re nil 'move)) | |
3061 (cond | |
3062 ((match-end 1) ; `else | |
3063 (if (= nest 1) | |
3064 (setq else "!"))) | |
3065 ((match-end 2) ; `endif | |
3066 (setq nest (1+ nest))) | |
3067 ((match-end 3) ; `if | |
3068 (setq nest (1- nest))) | |
3069 ((match-end 4) ; `ifdef | |
3070 (setq nest (1- nest))) | |
3071 ((match-end 5) ; `ifndef | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3072 (setq nest (1- nest))))) |
79545 | 3073 (if (match-end 0) |
3074 (setq | |
3075 m (buffer-substring | |
3076 (match-beginning 0) | |
3077 (match-end 0)) | |
3078 b (progn | |
3079 (skip-chars-forward "^ \t") | |
3080 (verilog-forward-syntactic-ws) | |
3081 (point)) | |
3082 e (progn | |
3083 (skip-chars-forward "a-zA-Z0-9_") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3084 (point))))) |
79545 | 3085 (if b |
3086 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | |
3087 (insert (concat " // " else m " " (buffer-substring b e)))) | |
3088 (progn | |
3089 (insert " // unmatched `else or `endif") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3090 (ding 't))))) |
79545 | 3091 |
3092 (; Comment close case/class/function/task/module and named block | |
3093 (and (looking-at "\\<end") | |
3094 (or kill-existing-comment | |
3095 (not (save-excursion | |
3096 (end-of-line) | |
3097 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3098 (let ((type (car indent-str))) | |
3099 (unless (eq type 'declaration) | |
3100 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends | |
3101 (if (looking-at verilog-end-block-ordered-re) | |
3102 (cond | |
3103 (;- This is a case block; search back for the start of this case | |
3104 (match-end 1) ;; of verilog-end-block-ordered-re | |
3105 | |
3106 (let ((err 't) | |
3107 (str "UNMATCHED!!")) | |
3108 (save-excursion | |
3109 (verilog-leap-to-head) | |
3110 (cond | |
3111 ((looking-at "\\<randcase\\>") | |
3112 (setq str "randcase") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3113 (setq err nil)) |
79545 | 3114 ((match-end 0) |
3115 (goto-char (match-end 1)) | |
3116 (if nil | |
3117 (let (s f) | |
3118 (setq s (match-beginning 1)) | |
3119 (setq f (progn (end-of-line) | |
3120 (point))) | |
3121 (setq str (buffer-substring s f))) | |
3122 (setq err nil)) | |
3123 (setq str (concat (buffer-substring (match-beginning 1) (match-end 1)) | |
3124 " " | |
3125 (verilog-get-expr)))))) | |
3126 (end-of-line) | |
3127 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3128 (verilog-kill-existing-comment)) |
79545 | 3129 (delete-horizontal-space) |
3130 (insert (concat " // " str )) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3131 (if err (ding 't)))) |
79545 | 3132 |
3133 (;- This is a begin..end block | |
3134 (match-end 2) ;; of verilog-end-block-ordered-re | |
3135 (let ((str " // UNMATCHED !!") | |
3136 (err 't) | |
3137 (here (point)) | |
3138 there | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3139 cntx) |
79545 | 3140 (save-excursion |
3141 (verilog-leap-to-head) | |
3142 (setq there (point)) | |
3143 (if (not (match-end 0)) | |
3144 (progn | |
3145 (goto-char here) | |
3146 (end-of-line) | |
3147 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3148 (verilog-kill-existing-comment)) |
79545 | 3149 (delete-horizontal-space) |
3150 (insert str) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3151 (ding 't)) |
79545 | 3152 (let ((lim |
3153 (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3154 (here (point))) |
79545 | 3155 (cond |
3156 (;-- handle named block differently | |
3157 (looking-at verilog-named-block-re) | |
3158 (search-forward ":") | |
3159 (setq there (point)) | |
3160 (setq str (verilog-get-expr)) | |
3161 (setq err nil) | |
3162 (setq str (concat " // block: " str ))) | |
3163 | |
3164 ((verilog-in-case-region-p) ;-- handle case item differently | |
3165 (goto-char here) | |
3166 (setq str (verilog-backward-case-item lim)) | |
3167 (setq there (point)) | |
3168 (setq err nil) | |
3169 (setq str (concat " // case: " str ))) | |
3170 | |
3171 (;- try to find "reason" for this begin | |
3172 (cond | |
3173 (; | |
3174 (eq here (progn | |
3175 (verilog-backward-token) | |
3176 (verilog-beg-of-statement-1) | |
3177 (point))) | |
3178 (setq err nil) | |
3179 (setq str "")) | |
3180 ((looking-at verilog-endcomment-reason-re) | |
3181 (setq there (match-end 0)) | |
3182 (setq cntx (concat | |
3183 (buffer-substring (match-beginning 0) (match-end 0)) " ")) | |
3184 (cond | |
3185 (;- begin | |
3186 (match-end 2) | |
3187 (setq err nil) | |
3188 (save-excursion | |
3189 (if (and (verilog-continued-line) | |
3190 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) | |
3191 (progn | |
3192 (goto-char (match-end 0)) | |
3193 (setq there (point)) | |
3194 (setq str | |
3195 (concat " // " | |
3196 (buffer-substring (match-beginning 0) (match-end 0)) " " | |
3197 (verilog-get-expr)))) | |
3198 (setq str "")))) | |
3199 | |
3200 (;- else | |
3201 (match-end 4) | |
3202 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3203 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3204 (catch 'skip |
3205 (while (verilog-re-search-backward reg nil 'move) | |
3206 (cond | |
3207 ((match-end 1) ; begin | |
3208 (setq nest (1- nest))) | |
3209 ((match-end 2) ; end | |
3210 (setq nest (1+ nest))) | |
3211 ((match-end 3) | |
3212 (if (= 0 nest) | |
3213 (progn | |
3214 (goto-char (match-end 0)) | |
3215 (setq there (point)) | |
3216 (setq err nil) | |
3217 (setq str (verilog-get-expr)) | |
3218 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3219 (throw 'skip 1))))))))) |
79545 | 3220 |
3221 (;- end else | |
3222 (match-end 5) | |
3223 (goto-char there) | |
3224 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3225 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3226 (catch 'skip |
3227 (while (verilog-re-search-backward reg nil 'move) | |
3228 (cond | |
3229 ((match-end 1) ; begin | |
3230 (setq nest (1- nest))) | |
3231 ((match-end 2) ; end | |
3232 (setq nest (1+ nest))) | |
3233 ((match-end 3) | |
3234 (if (= 0 nest) | |
3235 (progn | |
3236 (goto-char (match-end 0)) | |
3237 (setq there (point)) | |
3238 (setq err nil) | |
3239 (setq str (verilog-get-expr)) | |
3240 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3241 (throw 'skip 1))))))))) |
79545 | 3242 |
3243 (;- task/function/initial et cetera | |
3244 t | |
3245 (match-end 0) | |
3246 (goto-char (match-end 0)) | |
3247 (setq there (point)) | |
3248 (setq err nil) | |
3249 (setq str (verilog-get-expr)) | |
3250 (setq str (concat " // " cntx str ))) | |
3251 | |
3252 (;-- otherwise... | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3253 (setq str " // auto-endcomment confused ")))) |
79545 | 3254 |
3255 ((and | |
3256 (verilog-in-case-region-p) ;-- handle case item differently | |
3257 (progn | |
3258 (setq there (point)) | |
3259 (goto-char here) | |
3260 (setq str (verilog-backward-case-item lim)))) | |
3261 (setq err nil) | |
3262 (setq str (concat " // case: " str ))) | |
3263 | |
3264 ((verilog-in-fork-region-p) | |
3265 (setq err nil) | |
3266 (setq str " // fork branch" )) | |
3267 | |
3268 ((looking-at "\\<end\\>") | |
3269 ;; HERE | |
3270 (forward-word 1) | |
3271 (verilog-forward-syntactic-ws) | |
3272 (setq err nil) | |
3273 (setq str (verilog-get-expr)) | |
3274 (setq str (concat " // " cntx str ))) | |
3275 | |
3276 )))) | |
3277 (goto-char here) | |
3278 (end-of-line) | |
3279 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3280 (verilog-kill-existing-comment)) |
79545 | 3281 (delete-horizontal-space) |
3282 (if (or err | |
3283 (> (count-lines here there) verilog-minimum-comment-distance)) | |
3284 (insert str)) | |
3285 (if err (ding 't)) | |
3286 )))) | |
3287 (;- this is endclass, which can be nested | |
3288 (match-end 11) ;; of verilog-end-block-ordered-re | |
3289 ;;(goto-char there) | |
3290 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3291 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3292 string) |
79545 | 3293 (save-excursion |
3294 (catch 'skip | |
3295 (while (verilog-re-search-backward reg nil 'move) | |
3296 (cond | |
3297 ((match-end 3) ; endclass | |
3298 (ding 't) | |
3299 (setq string "unmatched endclass") | |
3300 (throw 'skip 1)) | |
3301 | |
3302 ((match-end 2) ; endclass | |
3303 (setq nest (1+ nest))) | |
3304 | |
3305 ((match-end 1) ; class | |
3306 (setq nest (1- nest)) | |
3307 (if (< nest 0) | |
3308 (progn | |
3309 (goto-char (match-end 0)) | |
3310 (let (b e) | |
3311 (setq b (progn | |
3312 (skip-chars-forward "^ \t") | |
3313 (verilog-forward-ws&directives) | |
3314 (point)) | |
3315 e (progn | |
3316 (skip-chars-forward "a-zA-Z0-9_") | |
3317 (point))) | |
3318 (setq string (buffer-substring b e))) | |
3319 (throw 'skip 1)))) | |
3320 )))) | |
3321 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3322 (insert (concat " // " string )))) |
79545 | 3323 |
3324 (;- this is end{function,generate,task,module,primitive,table,generate} | |
3325 ;- which can not be nested. | |
3326 t | |
3327 (let (string reg (width nil)) | |
3328 (end-of-line) | |
3329 (if kill-existing-comment | |
3330 (save-match-data | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3331 (verilog-kill-existing-comment))) |
79545 | 3332 (delete-horizontal-space) |
3333 (backward-sexp) | |
3334 (cond | |
3335 ((match-end 5) ;; of verilog-end-block-ordered-re | |
3336 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3337 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")) |
79545 | 3338 ((match-end 6) ;; of verilog-end-block-ordered-re |
3339 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | |
3340 ((match-end 7) ;; of verilog-end-block-ordered-re | |
3341 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | |
3342 ((match-end 8) ;; of verilog-end-block-ordered-re | |
3343 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3344 ((match-end 9) ;; of verilog-end-block-ordered-re | |
3345 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) | |
3346 ((match-end 10) ;; of verilog-end-block-ordered-re | |
3347 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3348 ((match-end 11) ;; of verilog-end-block-ordered-re | |
3349 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3350 ((match-end 12) ;; of verilog-end-block-ordered-re | |
3351 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3352 ((match-end 13) ;; of verilog-end-block-ordered-re | |
3353 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3354 ((match-end 14) ;; of verilog-end-block-ordered-re | |
3355 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3356 ((match-end 15) ;; of verilog-end-block-ordered-re | |
3357 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | |
3358 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3359 (t (error "Problem in verilog-set-auto-endcomments"))) |
79545 | 3360 (let (b e) |
3361 (save-excursion | |
3362 (verilog-re-search-backward reg nil 'move) | |
3363 (cond | |
3364 ((match-end 1) | |
3365 (setq b (progn | |
3366 (skip-chars-forward "^ \t") | |
3367 (verilog-forward-ws&directives) | |
3368 (if (and width (looking-at width)) | |
3369 (progn | |
3370 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3371 (verilog-forward-ws&directives))) |
79545 | 3372 (point)) |
3373 e (progn | |
3374 (skip-chars-forward "a-zA-Z0-9_") | |
3375 (point))) | |
3376 (setq string (buffer-substring b e))) | |
3377 (t | |
3378 (ding 't) | |
3379 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) | |
3380 (end-of-line) | |
3381 (insert (concat " // " string ))) | |
3382 )))))))))) | |
3383 | |
3384 (defun verilog-get-expr() | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3385 "Grab expression at point, e.g, case ( a | b & (c ^d))" |
79545 | 3386 (let* ((b (progn |
3387 (verilog-forward-syntactic-ws) | |
3388 (skip-chars-forward " \t") | |
3389 (point))) | |
3390 (e (let ((par 1)) | |
3391 (cond | |
3392 ((looking-at "@") | |
3393 (forward-char 1) | |
3394 (verilog-forward-syntactic-ws) | |
3395 (if (looking-at "(") | |
3396 (progn | |
3397 (forward-char 1) | |
3398 (while (and (/= par 0) | |
3399 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3400 (cond | |
3401 ((match-end 1) | |
3402 (setq par (1+ par))) | |
3403 ((match-end 2) | |
3404 (setq par (1- par))))))) | |
3405 (point)) | |
3406 ((looking-at "(") | |
3407 (forward-char 1) | |
3408 (while (and (/= par 0) | |
3409 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3410 (cond | |
3411 ((match-end 1) | |
3412 (setq par (1+ par))) | |
3413 ((match-end 2) | |
3414 (setq par (1- par))))) | |
3415 (point)) | |
3416 ((looking-at "\\[") | |
3417 (forward-char 1) | |
3418 (while (and (/= par 0) | |
3419 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move)) | |
3420 (cond | |
3421 ((match-end 1) | |
3422 (setq par (1+ par))) | |
3423 ((match-end 2) | |
3424 (setq par (1- par))))) | |
3425 (verilog-forward-syntactic-ws) | |
3426 (skip-chars-forward "^ \t\n\f") | |
3427 (point)) | |
3428 ((looking-at "/[/\\*]") | |
3429 b) | |
3430 ('t | |
3431 (skip-chars-forward "^: \t\n\f") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3432 (point))))) |
79545 | 3433 (str (buffer-substring b e))) |
3434 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3435 (setq str (concat (substring str 0 e) "..."))) | |
3436 str)) | |
3437 | |
3438 (defun verilog-expand-vector () | |
3439 "Take a signal vector on the current line and expand it to multiple lines. | |
3440 Useful for creating tri's and other expanded fields." | |
3441 (interactive) | |
3442 (verilog-expand-vector-internal "[" "]")) | |
3443 | |
3444 (defun verilog-expand-vector-internal (bra ket) | |
3445 "Given BRA, the start brace and KET, the end brace, expand one line into many lines." | |
3446 (save-excursion | |
3447 (forward-line 0) | |
3448 (let ((signal-string (buffer-substring (point) | |
3449 (progn | |
3450 (end-of-line) (point))))) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3451 (if (string-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3452 (concat "\\(.*\\)" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3453 (regexp-quote bra) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3454 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3455 (regexp-quote ket) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3456 "\\(.*\\)$") signal-string) |
79545 | 3457 (let* ((sig-head (match-string 1 signal-string)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3458 (vec-start (string-to-number (match-string 2 signal-string))) |
79545 | 3459 (vec-end (if (= (match-beginning 3) (match-end 3)) |
3460 vec-start | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3461 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3462 (substring signal-string (1+ (match-beginning 3)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3463 (match-end 3))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3464 (vec-range |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3465 (if (= (match-beginning 4) (match-end 4)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3466 1 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3467 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3468 (substring signal-string (+ 2 (match-beginning 4)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3469 (match-end 4))))) |
79545 | 3470 (sig-tail (match-string 5 signal-string)) |
3471 vec) | |
3472 ;; Decode vectors | |
3473 (setq vec nil) | |
3474 (if (< vec-range 0) | |
3475 (let ((tmp vec-start)) | |
3476 (setq vec-start vec-end | |
3477 vec-end tmp | |
3478 vec-range (- vec-range)))) | |
3479 (if (< vec-end vec-start) | |
3480 (while (<= vec-end vec-start) | |
3481 (setq vec (append vec (list vec-start))) | |
3482 (setq vec-start (- vec-start vec-range))) | |
3483 (while (<= vec-start vec-end) | |
3484 (setq vec (append vec (list vec-start))) | |
3485 (setq vec-start (+ vec-start vec-range)))) | |
3486 ;; | |
3487 ;; Delete current line | |
3488 (delete-region (point) (progn (forward-line 0) (point))) | |
3489 ;; | |
3490 ;; Expand vector | |
3491 (while vec | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3492 (insert (concat sig-head bra |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3493 (int-to-string (car vec)) ket sig-tail "\n")) |
79545 | 3494 (setq vec (cdr vec))) |
3495 (delete-char -1) | |
3496 ;; | |
3497 ))))) | |
3498 | |
3499 (defun verilog-strip-comments () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3500 "Strip all comments from the verilog code." |
79545 | 3501 (interactive) |
3502 (goto-char (point-min)) | |
3503 (while (re-search-forward "//" nil t) | |
3504 (if (verilog-within-string) | |
3505 (re-search-forward "\"" nil t) | |
3506 (if (verilog-in-star-comment-p) | |
3507 (re-search-forward "\*/" nil t) | |
3508 (let ((bpt (- (point) 2))) | |
3509 (end-of-line) | |
3510 (delete-region bpt (point)))))) | |
3511 ;; | |
3512 (goto-char (point-min)) | |
3513 (while (re-search-forward "/\\*" nil t) | |
3514 (if (verilog-within-string) | |
3515 (re-search-forward "\"" nil t) | |
3516 (let ((bpt (- (point) 2))) | |
3517 (re-search-forward "\\*/") | |
3518 (delete-region bpt (point)))))) | |
3519 | |
3520 (defun verilog-one-line () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3521 "Convert structural verilog instances to occupy one line." |
79545 | 3522 (interactive) |
3523 (goto-char (point-min)) | |
3524 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) | |
3525 (replace-match "\\1 " nil nil))) | |
3526 | |
3527 (defun verilog-linter-name () | |
3528 "Return name of linter, either surelint or verilint." | |
3529 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3530 compile-command)) | |
3531 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3532 verilog-linter))) | |
3533 (cond ((equal compile-word1 "surelint") `surelint) | |
3534 ((equal compile-word1 "verilint") `verilint) | |
3535 ((equal lint-word1 "surelint") `surelint) | |
3536 ((equal lint-word1 "verilint") `verilint) | |
3537 (t `surelint)))) ;; back compatibility | |
3538 | |
3539 (defun verilog-lint-off () | |
3540 "Convert a Verilog linter warning line into a disable statement. | |
3541 For example: | |
3542 pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3543 becomes a comment for the appropriate tool. | |
3544 | |
3545 The first word of the `compile-command' or `verilog-linter' | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3546 variables are used to determine which product is being used. |
79545 | 3547 |
3548 See \\[verilog-surelint-off] and \\[verilog-verilint-off]." | |
3549 (interactive) | |
3550 (let ((linter (verilog-linter-name))) | |
3551 (cond ((equal linter `surelint) | |
3552 (verilog-surelint-off)) | |
3553 ((equal linter `verilint) | |
3554 (verilog-verilint-off)) | |
3555 (t (error "Linter name not set"))))) | |
3556 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3557 (defvar compilation-last-buffer) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3558 |
79545 | 3559 (defun verilog-surelint-off () |
3560 "Convert a SureLint warning line into a disable statement. | |
3561 Run from Verilog source window; assumes there is a *compile* buffer | |
3562 with point set appropriately. | |
3563 | |
3564 For example: | |
3565 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned. | |
3566 becomes: | |
3567 // surefire lint_line_off UDDONX" | |
3568 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3569 (let ((buff (if (boundp 'next-error-last-buffer) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3570 next-error-last-buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3571 compilation-last-buffer))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3572 (when (buffer-live-p buff) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3573 ;; FIXME with-current-buffer? |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3574 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3575 (switch-to-buffer buff) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3576 (beginning-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3577 (when |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3578 (looking-at "\\(INFO\\|WARNING\\|ERROR\\) \\[[^-]+-\\([^]]+\\)\\]: \\([^,]+\\), line \\([0-9]+\\): \\(.*\\)$") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3579 (let* ((code (match-string 2)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3580 (file (match-string 3)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3581 (line (match-string 4)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3582 (buffer (get-file-buffer file)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3583 dir filename) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3584 (unless buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3585 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3586 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3587 (and (file-exists-p file) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3588 (find-file-noselect file))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3589 (or buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3590 (let* ((pop-up-windows t)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3591 (let ((name (expand-file-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3592 (read-file-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3593 (format "Find this error in: (default %s) " |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3594 file) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3595 dir file t)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3596 (if (file-directory-p name) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3597 (setq name (expand-file-name filename name))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3598 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3599 (and (file-exists-p name) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3600 (find-file-noselect name)))))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3601 (switch-to-buffer buffer) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3602 (goto-line (string-to-number line)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3603 (end-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3604 (catch 'already |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3605 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3606 ((verilog-in-slash-comment-p) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3607 (re-search-backward "//") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3608 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3609 ((looking-at "// surefire lint_off_line ") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3610 (goto-char (match-end 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3611 (let ((lim (save-excursion (end-of-line) (point)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3612 (if (re-search-forward code lim 'move) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3613 (throw 'already t) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3614 (insert (concat " " code))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3615 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3616 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3617 ((verilog-in-star-comment-p) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3618 (re-search-backward "/\*") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3619 (insert (format " // surefire lint_off_line %6s" code ))) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3620 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3621 (insert (format " // surefire lint_off_line %6s" code )) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3622 ))))))))) |
79545 | 3623 |
3624 (defun verilog-verilint-off () | |
3625 "Convert a Verilint warning line into a disable statement. | |
3626 | |
3627 For example: | |
3628 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3629 becomes: | |
3630 //Verilint 240 off // WARNING: Unused input" | |
3631 (interactive) | |
3632 (save-excursion | |
3633 (beginning-of-line) | |
3634 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$") | |
3635 (replace-match (format | |
3636 ;; %3s makes numbers 1-999 line up nicely | |
3637 "\\1//Verilint %3s off // WARNING: \\3" | |
3638 (match-string 2))) | |
3639 (beginning-of-line) | |
3640 (verilog-indent-line)))) | |
3641 | |
3642 (defun verilog-auto-save-compile () | |
3643 "Update automatics with \\[verilog-auto], save the buffer, and compile." | |
3644 (interactive) | |
3645 (verilog-auto) ; Always do it for safety | |
3646 (save-buffer) | |
3647 (compile compile-command)) | |
3648 | |
3649 | |
3650 | |
3651 ;; | |
3652 ;; Batch | |
3653 ;; | |
3654 | |
3655 (defmacro verilog-batch-error-wrapper (&rest body) | |
3656 "Execute BODY and add error prefix to any errors found. | |
3657 This lets programs calling batch mode to easily extract error messages." | |
79546 | 3658 `(condition-case err |
3659 (progn ,@body) | |
3660 (error | |
3661 (error "%%Error: %s%s" (error-message-string err) | |
3662 (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline | |
79545 | 3663 |
3664 (defun verilog-batch-execute-func (funref) | |
3665 "Internal processing of a batch command, running FUNREF on all command arguments." | |
3666 (verilog-batch-error-wrapper | |
3667 ;; General globals needed | |
3668 (setq make-backup-files nil) | |
3669 (setq-default make-backup-files nil) | |
3670 (setq enable-local-variables t) | |
3671 (setq enable-local-eval t) | |
3672 ;; Make sure any sub-files we read get proper mode | |
3673 (setq default-major-mode `verilog-mode) | |
3674 ;; Ditto files already read in | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3675 (mapc (lambda (buf) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3676 (when (buffer-file-name buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3677 (save-excursion |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3678 (set-buffer buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3679 (verilog-mode)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3680 (buffer-list)) |
79545 | 3681 ;; Process the files |
3682 (mapcar '(lambda (buf) | |
3683 (when (buffer-file-name buf) | |
3684 (save-excursion | |
3685 (if (not (file-exists-p (buffer-file-name buf))) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3686 (error |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3687 (concat "File not found: " (buffer-file-name buf)))) |
79545 | 3688 (message (concat "Processing " (buffer-file-name buf))) |
3689 (set-buffer buf) | |
3690 (funcall funref) | |
3691 (save-buffer)))) | |
3692 (buffer-list)))) | |
3693 | |
3694 (defun verilog-batch-auto () | |
3695 "For use with --batch, perform automatic expansions as a stand-alone tool. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3696 This sets up the appropriate Verilog-Mode environment, updates automatics |
79545 | 3697 with \\[verilog-auto] on all command-line files, and saves the buffers. |
3698 For proper results, multiple filenames need to be passed on the command | |
3699 line in bottom-up order." | |
3700 (unless noninteractive | |
3701 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3702 (verilog-batch-execute-func `verilog-auto)) | |
3703 | |
3704 (defun verilog-batch-delete-auto () | |
3705 "For use with --batch, perform automatic deletion as a stand-alone tool. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3706 This sets up the appropriate Verilog-Mode environment, deletes automatics |
79545 | 3707 with \\[verilog-delete-auto] on all command-line files, and saves the buffers." |
3708 (unless noninteractive | |
3709 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3710 (verilog-batch-execute-func `verilog-delete-auto)) | |
3711 | |
3712 (defun verilog-batch-inject-auto () | |
3713 "For use with --batch, perform automatic injection as a stand-alone tool. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3714 This sets up the appropriate Verilog-Mode environment, injects new automatics |
79545 | 3715 with \\[verilog-inject-auto] on all command-line files, and saves the buffers. |
3716 For proper results, multiple filenames need to be passed on the command | |
3717 line in bottom-up order." | |
3718 (unless noninteractive | |
3719 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3720 (verilog-batch-execute-func `verilog-inject-auto)) | |
3721 | |
3722 (defun verilog-batch-indent () | |
3723 "For use with --batch, reindent an a entire file as a stand-alone tool. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3724 This sets up the appropriate Verilog-Mode environment, calls |
79545 | 3725 \\[verilog-indent-buffer] on all command-line files, and saves the buffers." |
3726 (unless noninteractive | |
3727 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3728 (verilog-batch-execute-func `verilog-indent-buffer)) | |
3729 | |
3730 | |
3731 ;; | |
3732 ;; Indentation | |
3733 ;; | |
3734 (defconst verilog-indent-alist | |
3735 '((block . (+ ind verilog-indent-level)) | |
3736 (case . (+ ind verilog-case-indent)) | |
3737 (cparenexp . (+ ind verilog-indent-level)) | |
3738 (cexp . (+ ind verilog-cexp-indent)) | |
3739 (defun . verilog-indent-level-module) | |
3740 (declaration . verilog-indent-level-declaration) | |
3741 (directive . (verilog-calculate-indent-directive)) | |
3742 (tf . verilog-indent-level) | |
3743 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module)) | |
3744 (statement . ind) | |
3745 (cpp . 0) | |
3746 (comment . (verilog-comment-indent)) | |
3747 (unknown . 3) | |
3748 (string . 0))) | |
3749 | |
3750 (defun verilog-continued-line-1 (lim) | |
3751 "Return true if this is a continued line. | |
3752 Set point to where line starts. Limit search to point LIM." | |
3753 (let ((continued 't)) | |
3754 (if (eq 0 (forward-line -1)) | |
3755 (progn | |
3756 (end-of-line) | |
3757 (verilog-backward-ws&directives lim) | |
3758 (if (bobp) | |
3759 (setq continued nil) | |
3760 (setq continued (verilog-backward-token)))) | |
3761 (setq continued nil)) | |
3762 continued)) | |
3763 | |
3764 (defun verilog-calculate-indent () | |
3765 "Calculate the indent of the current Verilog line. | |
3766 Examine previous lines. Once a line is found that is definitive as to the | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3767 type of the current line, return that lines' indent level and its |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
3768 type. Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." |
79545 | 3769 (save-excursion |
3770 (let* ((starting_position (point)) | |
3771 (par 0) | |
3772 (begin (looking-at "[ \t]*begin\\>")) | |
3773 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) | |
3774 (type (catch 'nesting | |
3775 ;; Keep working backwards until we can figure out | |
3776 ;; what type of statement this is. | |
3777 ;; Basically we need to figure out | |
3778 ;; 1) if this is a continuation of the previous line; | |
3779 ;; 2) are we in a block scope (begin..end) | |
3780 | |
3781 ;; if we are in a comment, done. | |
3782 (if (verilog-in-star-comment-p) | |
3783 (throw 'nesting 'comment)) | |
3784 | |
3785 ;; if we have a directive, done. | |
3786 (if (save-excursion (beginning-of-line) (looking-at verilog-directive-re-1)) | |
3787 (throw 'nesting 'directive)) | |
3788 | |
3789 ;; unless we are in the newfangled coverpoint or constraint blocks | |
3790 ;; if we are in a parenthesized list, and the user likes to indent these, return. | |
3791 (if (and | |
3792 verilog-indent-lists | |
3793 (not (verilog-in-coverage)) | |
3794 (verilog-in-paren)) | |
3795 (progn (setq par 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3796 (throw 'nesting 'block))) |
79545 | 3797 |
3798 ;; See if we are continuing a previous line | |
3799 (while t | |
3800 ;; trap out if we crawl off the top of the buffer | |
3801 (if (bobp) (throw 'nesting 'cpp)) | |
3802 | |
3803 (if (verilog-continued-line-1 lim) | |
3804 (let ((sp (point))) | |
3805 (if (and | |
3806 (not (looking-at verilog-complete-reg)) | |
3807 (verilog-continued-line-1 lim)) | |
3808 (progn (goto-char sp) | |
3809 (throw 'nesting 'cexp)) | |
3810 | |
3811 (goto-char sp)) | |
3812 | |
3813 (if (and begin | |
3814 (not verilog-indent-begin-after-if) | |
3815 (looking-at verilog-no-indent-begin-re)) | |
3816 (progn | |
3817 (beginning-of-line) | |
3818 (skip-chars-forward " \t") | |
3819 (throw 'nesting 'statement)) | |
3820 (progn | |
3821 (throw 'nesting 'cexp)))) | |
3822 ;; not a continued line | |
3823 (goto-char starting_position)) | |
3824 | |
3825 (if (looking-at "\\<else\\>") | |
3826 ;; search back for governing if, striding across begin..end pairs | |
3827 ;; appropriately | |
3828 (let ((elsec 1)) | |
3829 (while (verilog-re-search-backward verilog-ends-re nil 'move) | |
3830 (cond | |
3831 ((match-end 1) ; else, we're in deep | |
3832 (setq elsec (1+ elsec))) | |
3833 ((match-end 2) ; if | |
3834 (setq elsec (1- elsec)) | |
3835 (if (= 0 elsec) | |
3836 (if verilog-align-ifelse | |
3837 (throw 'nesting 'statement) | |
3838 (progn ;; back up to first word on this line | |
3839 (beginning-of-line) | |
3840 (verilog-forward-syntactic-ws) | |
3841 (throw 'nesting 'statement))))) | |
3842 (t ; endblock | |
3843 ; try to leap back to matching outward block by striding across | |
3844 ; indent level changing tokens then immediately | |
3845 ; previous line governs indentation. | |
3846 (let (( reg) (nest 1)) | |
3847 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup | |
3848 (cond | |
3849 ((match-end 3) ; end | |
3850 ;; Search back for matching begin | |
3851 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
3852 ((match-end 4) ; endcase | |
3853 ;; Search back for matching case | |
3854 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
3855 ((match-end 5) ; endfunction | |
3856 ;; Search back for matching function | |
3857 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
3858 ((match-end 6) ; endtask | |
3859 ;; Search back for matching task | |
3860 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
3861 ((match-end 7) ; endspecify | |
3862 ;; Search back for matching specify | |
3863 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
3864 ((match-end 8) ; endtable | |
3865 ;; Search back for matching table | |
3866 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
3867 ((match-end 9) ; endgenerate | |
3868 ;; Search back for matching generate | |
3869 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
3870 ((match-end 10) ; joins | |
3871 ;; Search back for matching fork | |
3872 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) | |
3873 ((match-end 11) ; class | |
3874 ;; Search back for matching class | |
3875 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
3876 ((match-end 12) ; covergroup | |
3877 ;; Search back for matching covergroup | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3878 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
79545 | 3879 (catch 'skip |
3880 (while (verilog-re-search-backward reg nil 'move) | |
3881 (cond | |
3882 ((match-end 1) ; begin | |
3883 (setq nest (1- nest)) | |
3884 (if (= 0 nest) | |
3885 (throw 'skip 1))) | |
3886 ((match-end 2) ; end | |
3887 (setq nest (1+ nest))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3888 ))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3889 (throw 'nesting (verilog-calc-1))) |
79545 | 3890 );; catch nesting |
3891 );; type | |
3892 ) | |
3893 ;; Return type of block and indent level. | |
3894 (if (not type) | |
3895 (setq type 'cpp)) | |
3896 (if (> par 0) ; Unclosed Parenthesis | |
3897 (list 'cparenexp par) | |
3898 (cond | |
3899 ((eq type 'case) | |
3900 (list type (verilog-case-indent-level))) | |
3901 ((eq type 'statement) | |
3902 (list type (current-column))) | |
3903 ((eq type 'defun) | |
3904 (list type 0)) | |
3905 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3906 (list type (verilog-current-indent-level)))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3907 |
79545 | 3908 (defun verilog-wai () |
3909 "Show matching nesting block for debugging." | |
3910 (interactive) | |
3911 (save-excursion | |
3912 (let ((nesting (verilog-calc-1))) | |
3913 (message "You are at nesting %s" nesting)))) | |
3914 | |
3915 (defun verilog-calc-1 () | |
3916 (catch 'nesting | |
3917 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) | |
3918 (cond | |
3919 ((equal (char-after) ?\{) | |
3920 (if (verilog-at-constraint-p) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3921 (throw 'nesting 'block))) |
79545 | 3922 ((equal (char-after) ?\}) |
3923 | |
3924 (let ((there (verilog-at-close-constraint-p))) | |
3925 (if there (goto-char there)))) | |
3926 | |
3927 ((looking-at verilog-beg-block-re-ordered) | |
3928 (cond | |
3929 ((match-end 2) ; *sigh* could be "unique case" or "priority casex" | |
3930 (let ((here (point))) | |
3931 (verilog-beg-of-statement) | |
3932 (if (looking-at verilog-extended-case-re) | |
3933 (throw 'nesting 'case) | |
3934 (goto-char here))) | |
3935 (throw 'nesting 'case)) | |
3936 | |
3937 ;; need to consider typedef struct here... | |
3938 ((looking-at "\\<class\\|struct\\|function\\|task\\|property\\>") | |
3939 ; *sigh* These words have an optional prefix: | |
3940 ; extern {virtual|protected}? function a(); | |
3941 ; assert property (p_1); | |
3942 ; typedef class foo; | |
3943 ; and we don't want to confuse this with | |
3944 ; function a(); | |
3945 ; property | |
3946 ; ... | |
3947 ; endfunction | |
3948 (let ((here (point))) | |
3949 (save-excursion | |
3950 (verilog-beg-of-statement) | |
3951 (if (= (point) here) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3952 (throw 'nesting 'block))))) |
79545 | 3953 (t (throw 'nesting 'block)))) |
3954 | |
3955 ((looking-at verilog-end-block-re) | |
3956 (verilog-leap-to-head) | |
3957 (if (verilog-in-case-region-p) | |
3958 (progn | |
3959 (verilog-leap-to-case-head) | |
3960 (if (looking-at verilog-case-re) | |
3961 (throw 'nesting 'case))))) | |
3962 | |
3963 ((looking-at (if (verilog-in-generate-region-p) | |
3964 verilog-defun-level-not-generate-re | |
3965 verilog-defun-level-re)) | |
3966 (throw 'nesting 'defun)) | |
3967 | |
3968 ((looking-at verilog-cpp-level-re) | |
3969 (throw 'nesting 'cpp)) | |
3970 | |
3971 ((bobp) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3972 (throw 'nesting 'cpp)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3973 (throw 'nesting 'cpp))) |
79545 | 3974 |
3975 (defun verilog-calculate-indent-directive () | |
3976 "Return indentation level for directive. | |
3977 For speed, the searcher looks at the last directive, not the indent | |
3978 of the appropriate enclosing block." | |
3979 (let ((base -1) ;; Indent of the line that determines our indentation | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3980 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) |
79545 | 3981 ;; Start at current location, scan back for another directive |
3982 | |
3983 (save-excursion | |
3984 (beginning-of-line) | |
3985 (while (and (< base 0) | |
3986 (verilog-re-search-backward verilog-directive-re nil t)) | |
3987 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3988 (setq base (current-indentation)))) |
79545 | 3989 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
3990 (setq ind (- ind verilog-indent-level-directive))) | |
3991 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | |
3992 (setq ind (+ ind verilog-indent-level-directive))) | |
3993 ((looking-at verilog-directive-begin) | |
3994 (setq ind (+ ind verilog-indent-level-directive))))) | |
3995 ;; Adjust indent to starting indent of critical line | |
3996 (setq ind (max 0 (+ ind base)))) | |
3997 | |
3998 (save-excursion | |
3999 (beginning-of-line) | |
4000 (skip-chars-forward " \t") | |
4001 (cond ((or (looking-at verilog-directive-middle) | |
4002 (looking-at verilog-directive-end)) | |
4003 (setq ind (max 0 (- ind verilog-indent-level-directive)))))) | |
4004 ind)) | |
4005 | |
4006 (defun verilog-leap-to-case-head () | |
4007 (let ((nest 1)) | |
4008 (while (/= 0 nest) | |
4009 (verilog-re-search-backward "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" nil 'move) | |
4010 (cond | |
4011 ((match-end 1) | |
4012 (setq nest (1- nest))) | |
4013 ((match-end 2) | |
4014 (setq nest (1+ nest))) | |
4015 ((bobp) | |
4016 (ding 't) | |
4017 (setq nest 0)))))) | |
4018 | |
4019 (defun verilog-leap-to-head () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
4020 "Move point to the head of this block; jump from end to matching begin, |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
4021 from endcase to matching case, and so on." |
79545 | 4022 (let ((reg nil) |
4023 snest | |
4024 (nest 1)) | |
4025 (cond | |
4026 ((looking-at "\\<end\\>") | |
4027 ;; 1: Search back for matching begin | |
4028 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|" | |
4029 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))) | |
4030 ((looking-at "\\<endcase\\>") | |
4031 ;; 2: Search back for matching case | |
4032 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" )) | |
4033 ((looking-at "\\<join\\(_any\\|_none\\)?\\>") | |
4034 ;; 3: Search back for matching fork | |
4035 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4036 ((looking-at "\\<endclass\\>") | |
4037 ;; 4: Search back for matching class | |
4038 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
4039 ((looking-at "\\<endtable\\>") | |
4040 ;; 5: Search back for matching table | |
4041 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
4042 ((looking-at "\\<endspecify\\>") | |
4043 ;; 6: Search back for matching specify | |
4044 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
4045 ((looking-at "\\<endfunction\\>") | |
4046 ;; 7: Search back for matching function | |
4047 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
4048 ((looking-at "\\<endgenerate\\>") | |
4049 ;; 8: Search back for matching generate | |
4050 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
4051 ((looking-at "\\<endtask\\>") | |
4052 ;; 9: Search back for matching task | |
4053 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
4054 ((looking-at "\\<endgroup\\>") | |
4055 ;; 10: Search back for matching covergroup | |
4056 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
4057 ((looking-at "\\<endproperty\\>") | |
4058 ;; 11: Search back for matching property | |
4059 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
4060 ((looking-at "\\<endinterface\\>") | |
4061 ;; 12: Search back for matching interface | |
4062 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" )) | |
4063 ((looking-at "\\<endsequence\\>") | |
4064 ;; 12: Search back for matching sequence | |
4065 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | |
4066 ((looking-at "\\<endclocking\\>") | |
4067 ;; 12: Search back for matching clocking | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4068 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
79545 | 4069 (if reg |
4070 (catch 'skip | |
4071 (let (sreg) | |
4072 (while (verilog-re-search-backward reg nil 'move) | |
4073 (cond | |
4074 ((match-end 1) ; begin | |
4075 (setq nest (1- nest)) | |
4076 (if (= 0 nest) | |
4077 ;; Now previous line describes syntax | |
4078 (throw 'skip 1)) | |
4079 (if (and snest | |
4080 (= snest nest)) | |
4081 (setq reg sreg))) | |
4082 ((match-end 2) ; end | |
4083 (setq nest (1+ nest))) | |
4084 ((match-end 3) | |
4085 ;; endcase, jump to case | |
4086 (setq snest nest) | |
4087 (setq nest (1+ nest)) | |
4088 (setq sreg reg) | |
4089 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
4090 ((match-end 4) | |
4091 ;; join, jump to fork | |
4092 (setq snest nest) | |
4093 (setq nest (1+ nest)) | |
4094 (setq sreg reg) | |
4095 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4096 ))))))) | |
4097 | |
4098 (defun verilog-continued-line () | |
4099 "Return true if this is a continued line. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
4100 Set point to where line starts" |
79545 | 4101 (let ((continued 't)) |
4102 (if (eq 0 (forward-line -1)) | |
4103 (progn | |
4104 (end-of-line) | |
4105 (verilog-backward-ws&directives) | |
4106 (if (bobp) | |
4107 (setq continued nil) | |
4108 (while (and continued | |
4109 (save-excursion | |
4110 (skip-chars-backward " \t") | |
4111 (not (bolp)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4112 (setq continued (verilog-backward-token))))) |
79545 | 4113 (setq continued nil)) |
4114 continued)) | |
4115 | |
4116 (defun verilog-backward-token () | |
4117 "Step backward token, returning true if we are now at an end of line token." | |
4118 (interactive) | |
4119 (verilog-backward-syntactic-ws) | |
4120 (cond | |
4121 ((bolp) | |
4122 nil) | |
4123 (;-- Anything ending in a ; is complete | |
4124 (= (preceding-char) ?\;) | |
4125 nil) | |
4126 (; If a "}" is prefixed by a ";", then this is a complete statement | |
4127 ; i.e.: constraint foo { a = b; } | |
4128 (= (preceding-char) ?\}) | |
4129 (progn | |
4130 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4131 (verilog-at-close-constraint-p))) |
79545 | 4132 (;-- constraint foo { a = b } |
4133 ; is a complete statement. *sigh* | |
4134 (= (preceding-char) ?\{) | |
4135 (progn | |
4136 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4137 (not (verilog-at-constraint-p)))) |
79545 | 4138 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4139 ; also could be simply '@(foo)' | |
4140 ; or foo u1 #(a=8) | |
4141 ; (b, ... which ISN'T complete | |
4142 ;;;; Do we need this??? | |
4143 (= (preceding-char) ?\)) | |
4144 (progn | |
4145 (backward-char) | |
4146 (backward-up-list 1) | |
4147 (verilog-backward-syntactic-ws) | |
4148 (let ((back (point))) | |
4149 (forward-word -1) | |
4150 (cond | |
4151 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") | |
4152 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]"))) | |
4153 (t | |
4154 (goto-char back) | |
4155 (cond | |
4156 ((= (preceding-char) ?\@) | |
4157 (backward-char) | |
4158 (save-excursion | |
4159 (verilog-backward-token) | |
4160 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | |
4161 ((= (preceding-char) ?\#) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4162 (backward-char)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4163 (t t))))))) |
79545 | 4164 |
4165 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | |
4166 t | |
4167 (forward-word -1) | |
4168 (cond | |
4169 ((looking-at "\\<else\\>") | |
4170 t) | |
4171 ((looking-at verilog-indent-re) | |
4172 nil) | |
4173 (t | |
4174 (let | |
4175 ((back (point))) | |
4176 (verilog-backward-syntactic-ws) | |
4177 (cond | |
4178 ((= (preceding-char) ?\:) | |
4179 (backward-char) | |
4180 (verilog-backward-syntactic-ws) | |
4181 (backward-sexp) | |
4182 (if (looking-at verilog-nameable-item-re ) | |
4183 nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4184 t)) |
79545 | 4185 ((= (preceding-char) ?\#) |
4186 (backward-char) | |
4187 t) | |
4188 ((= (preceding-char) ?\`) | |
4189 (backward-char) | |
4190 t) | |
4191 | |
4192 (t | |
4193 (goto-char back) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4194 t)))))))) |
79545 | 4195 |
4196 (defun verilog-backward-syntactic-ws (&optional bound) | |
4197 "Backward skip over syntactic whitespace for Emacs 19. | |
4198 Optional BOUND limits search." | |
4199 (save-restriction | |
4200 (let* ((bound (or bound (point-min))) (here bound) ) | |
4201 (if (< bound (point)) | |
4202 (progn | |
4203 (narrow-to-region bound (point)) | |
4204 (while (/= here (point)) | |
4205 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4206 (verilog-skip-backward-comments)))))) |
79545 | 4207 t) |
4208 | |
4209 (defun verilog-forward-syntactic-ws (&optional bound) | |
4210 "Forward skip over syntactic whitespace for Emacs 19. | |
4211 Optional BOUND limits search." | |
4212 (save-restriction | |
4213 (let* ((bound (or bound (point-max))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4214 (here bound)) |
79545 | 4215 (if (> bound (point)) |
4216 (progn | |
4217 (narrow-to-region (point) bound) | |
4218 (while (/= here (point)) | |
4219 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4220 (forward-comment (buffer-size)))))))) |
79545 | 4221 |
4222 (defun verilog-backward-ws&directives (&optional bound) | |
4223 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4224 Optional BOUND limits search." | |
4225 (save-restriction | |
4226 (let* ((bound (or bound (point-min))) | |
4227 (here bound) | |
4228 (p nil) ) | |
4229 (if (< bound (point)) | |
4230 (progn | |
4231 (let ((state | |
4232 (save-excursion | |
4233 (parse-partial-sexp (point-min) (point))))) | |
4234 (cond | |
4235 ((nth 7 state) ;; in // comment | |
4236 (verilog-re-search-backward "//" nil 'move) | |
4237 (skip-chars-backward "/")) | |
4238 ((nth 4 state) ;; in /* */ comment | |
4239 (verilog-re-search-backward "/\*" nil 'move)))) | |
4240 (narrow-to-region bound (point)) | |
4241 (while (/= here (point)) | |
4242 (setq here (point)) | |
4243 (verilog-skip-backward-comments) | |
4244 (setq p | |
4245 (save-excursion | |
4246 (beginning-of-line) | |
4247 (cond | |
4248 ((verilog-within-translate-off) | |
4249 (verilog-back-to-start-translate-off (point-min))) | |
4250 ((looking-at verilog-directive-re-1) | |
4251 (point)) | |
4252 (t | |
4253 nil)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4254 (if p (goto-char p)))))))) |
79545 | 4255 |
4256 (defun verilog-forward-ws&directives (&optional bound) | |
4257 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4258 Optional BOUND limits search." | |
4259 (save-restriction | |
4260 (let* ((bound (or bound (point-max))) | |
4261 (here bound) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4262 jump) |
79545 | 4263 (if (> bound (point)) |
4264 (progn | |
4265 (let ((state | |
4266 (save-excursion | |
4267 (parse-partial-sexp (point-min) (point))))) | |
4268 (cond | |
4269 ((nth 7 state) ;; in // comment | |
4270 (verilog-re-search-forward "//" nil 'move)) | |
4271 ((nth 4 state) ;; in /* */ comment | |
4272 (verilog-re-search-forward "/\*" nil 'move)))) | |
4273 (narrow-to-region (point) bound) | |
4274 (while (/= here (point)) | |
4275 (setq here (point) | |
4276 jump nil) | |
4277 (forward-comment (buffer-size)) | |
4278 (save-excursion | |
4279 (beginning-of-line) | |
4280 (if (looking-at verilog-directive-re-1) | |
4281 (setq jump t))) | |
4282 (if jump | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4283 (beginning-of-line 2)))))))) |
79545 | 4284 |
4285 (defun verilog-in-comment-p () | |
4286 "Return true if in a star or // comment." | |
4287 (let ((state | |
4288 (save-excursion | |
4289 (parse-partial-sexp (point-min) (point))))) | |
4290 (or (nth 4 state) (nth 7 state)))) | |
4291 | |
4292 (defun verilog-in-star-comment-p () | |
4293 "Return true if in a star comment." | |
4294 (let ((state | |
4295 (save-excursion | |
4296 (parse-partial-sexp (point-min) (point))))) | |
4297 (and | |
4298 (nth 4 state) ; t if in a comment of style a // or b /**/ | |
4299 (not | |
4300 (nth 7 state) ; t if in a comment of style b /**/ | |
4301 )))) | |
4302 | |
4303 (defun verilog-in-slash-comment-p () | |
4304 "Return true if in a slash comment." | |
4305 (let ((state | |
4306 (save-excursion | |
4307 (parse-partial-sexp (point-min) (point))))) | |
4308 (nth 7 state))) | |
4309 | |
4310 (defun verilog-in-comment-or-string-p () | |
4311 "Return true if in a string or comment." | |
4312 (let ((state | |
4313 (save-excursion | |
4314 (parse-partial-sexp (point-min) (point))))) | |
4315 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) | |
4316 | |
4317 (defun verilog-in-escaped-name-p () | |
4318 "Return true if in an escaped name." | |
4319 (save-excursion | |
4320 (backward-char) | |
4321 (skip-chars-backward "^ \t\n\f") | |
4322 (if (equal (char-after (point) ) ?\\ ) | |
4323 t | |
4324 nil))) | |
4325 | |
4326 (defun verilog-in-paren () | |
4327 "Return true if in a parenthetical expression." | |
4328 (let ((state | |
4329 (save-excursion | |
4330 (parse-partial-sexp (point-min) (point))))) | |
4331 (> (nth 0 state) 0 ))) | |
4332 | |
4333 (defun verilog-in-coverage () | |
4334 "Return true if in a constraint or coverpoint expression." | |
4335 (interactive) | |
4336 (save-excursion | |
4337 (if (verilog-in-paren) | |
4338 (progn | |
4339 (backward-up-list 1) | |
4340 (verilog-at-constraint-p) | |
4341 ) | |
4342 nil))) | |
4343 (defun verilog-at-close-constraint-p () | |
4344 "If at the } that closes a constraint or covergroup, return true." | |
4345 (if (and | |
4346 (equal (char-after) ?\}) | |
4347 (verilog-in-paren)) | |
4348 | |
4349 (save-excursion | |
4350 (verilog-backward-ws&directives) | |
4351 (if (equal (char-before) ?\;) | |
4352 (point) | |
4353 nil)))) | |
4354 | |
4355 (defun verilog-at-constraint-p () | |
4356 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." | |
4357 (if (save-excursion | |
4358 (and | |
4359 (equal (char-after) ?\{) | |
4360 (forward-list) | |
4361 (progn (backward-char 1) | |
4362 (verilog-backward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4363 (equal (char-before) ?\;)))) |
79545 | 4364 ;; maybe |
4365 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | |
4366 ;; not | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4367 nil)) |
79545 | 4368 |
4369 (defun verilog-parenthesis-depth () | |
4370 "Return non zero if in parenthetical-expression." | |
4371 (save-excursion | |
4372 (nth 1 (parse-partial-sexp (point-min) (point))))) | |
4373 | |
4374 | |
4375 (defun verilog-skip-forward-comment-or-string () | |
4376 "Return true if in a string or comment." | |
4377 (let ((state | |
4378 (save-excursion | |
4379 (parse-partial-sexp (point-min) (point))))) | |
4380 (cond | |
4381 ((nth 3 state) ;Inside string | |
4382 (goto-char (nth 3 state)) | |
4383 t) | |
4384 ((nth 7 state) ;Inside // comment | |
4385 (forward-line 1) | |
4386 t) | |
4387 ((nth 4 state) ;Inside any comment (hence /**/) | |
4388 (search-forward "*/")) | |
4389 (t | |
4390 nil)))) | |
4391 | |
4392 (defun verilog-skip-backward-comment-or-string () | |
4393 "Return true if in a string or comment." | |
4394 (let ((state | |
4395 (save-excursion | |
4396 (parse-partial-sexp (point-min) (point))))) | |
4397 (cond | |
4398 ((nth 3 state) ;Inside string | |
4399 (search-backward "\"") | |
4400 t) | |
4401 ((nth 7 state) ;Inside // comment | |
4402 (search-backward "//") | |
4403 (skip-chars-backward "/") | |
4404 t) | |
4405 ((nth 4 state) ;Inside /* */ comment | |
4406 (search-backward "/*") | |
4407 t) | |
4408 (t | |
4409 nil)))) | |
4410 | |
4411 (defun verilog-skip-backward-comments () | |
4412 "Return true if a comment was skipped." | |
4413 (let ((more t)) | |
4414 (while more | |
4415 (setq more | |
4416 (let ((state | |
4417 (save-excursion | |
4418 (parse-partial-sexp (point-min) (point))))) | |
4419 (cond | |
4420 ((nth 7 state) ;Inside // comment | |
4421 (search-backward "//") | |
4422 (skip-chars-backward "/") | |
4423 (skip-chars-backward " \t\n\f") | |
4424 t) | |
4425 ((nth 4 state) ;Inside /* */ comment | |
4426 (search-backward "/*") | |
4427 (skip-chars-backward " \t\n\f") | |
4428 t) | |
4429 ((and (not (bobp)) | |
4430 (= (char-before) ?\/) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4431 (= (char-before (1- (point))) ?\*)) |
79545 | 4432 (goto-char (- (point) 2)) |
4433 t) | |
4434 (t | |
4435 (skip-chars-backward " \t\n\f") | |
4436 nil))))))) | |
4437 | |
4438 (defun verilog-skip-forward-comment-p () | |
4439 "If in comment, move to end and return true." | |
4440 (let (state) | |
4441 (progn | |
4442 (setq state | |
4443 (save-excursion | |
4444 (parse-partial-sexp (point-min) (point)))) | |
4445 (cond | |
4446 ((nth 3 state) | |
4447 t) | |
4448 ((nth 7 state) ;Inside // comment | |
4449 (end-of-line) | |
4450 (forward-char 1) | |
4451 t) | |
4452 ((nth 4 state) ;Inside any comment | |
4453 t) | |
4454 (t | |
4455 nil))))) | |
4456 | |
4457 (defun verilog-indent-line-relative () | |
4458 "Cheap version of indent line. | |
4459 Only look at a few lines to determine indent level." | |
4460 (interactive) | |
4461 (let ((indent-str) | |
4462 (sp (point))) | |
4463 (if (looking-at "^[ \t]*$") | |
4464 (cond ;- A blank line; No need to be too smart. | |
4465 ((bobp) | |
4466 (setq indent-str (list 'cpp 0))) | |
4467 ((verilog-continued-line) | |
4468 (let ((sp1 (point))) | |
4469 (if (verilog-continued-line) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4470 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4471 (goto-char sp) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4472 (setq indent-str |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4473 (list 'statement (verilog-current-indent-level)))) |
79545 | 4474 (goto-char sp1) |
4475 (setq indent-str (list 'block (verilog-current-indent-level))))) | |
4476 (goto-char sp)) | |
4477 ((goto-char sp) | |
4478 (setq indent-str (verilog-calculate-indent)))) | |
4479 (progn (skip-chars-forward " \t") | |
4480 (setq indent-str (verilog-calculate-indent)))) | |
4481 (verilog-do-indent indent-str))) | |
4482 | |
4483 (defun verilog-indent-line () | |
4484 "Indent for special part of code." | |
4485 (verilog-do-indent (verilog-calculate-indent))) | |
4486 | |
4487 (defun verilog-do-indent (indent-str) | |
4488 (let ((type (car indent-str)) | |
4489 (ind (car (cdr indent-str)))) | |
4490 (cond | |
4491 (; handle continued exp | |
4492 (eq type 'cexp) | |
4493 (let ((here (point))) | |
4494 (verilog-backward-syntactic-ws) | |
4495 (cond | |
4496 ((or | |
4497 (= (preceding-char) ?\,) | |
4498 (= (preceding-char) ?\]) | |
4499 (save-excursion | |
4500 (verilog-beg-of-statement-1) | |
4501 (looking-at verilog-declaration-re))) | |
4502 (let* ( fst | |
4503 (val | |
4504 (save-excursion | |
4505 (backward-char 1) | |
4506 (verilog-beg-of-statement-1) | |
4507 (setq fst (point)) | |
4508 (if (looking-at verilog-declaration-re) | |
4509 (progn ;; we have multiple words | |
4510 (goto-char (match-end 0)) | |
4511 (skip-chars-forward " \t") | |
4512 (cond | |
4513 ((and verilog-indent-declaration-macros | |
4514 (= (following-char) ?\`)) | |
4515 (progn | |
4516 (forward-char 1) | |
4517 (forward-word 1) | |
4518 (skip-chars-forward " \t"))) | |
4519 ((= (following-char) ?\[) | |
4520 (progn | |
4521 (forward-char 1) | |
4522 (backward-up-list -1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4523 (skip-chars-forward " \t")))) |
79545 | 4524 (current-column)) |
4525 (progn | |
4526 (goto-char fst) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4527 (+ (current-column) verilog-cexp-indent)))))) |
79545 | 4528 (goto-char here) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4529 (indent-line-to val))) |
79545 | 4530 ((= (preceding-char) ?\) ) |
4531 (goto-char here) | |
4532 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4533 (indent-line-to val))) | |
4534 (t | |
4535 (goto-char here) | |
4536 (let ((val)) | |
4537 (verilog-beg-of-statement-1) | |
4538 (if (and (< (point) here) | |
4539 (verilog-re-search-forward "=[ \\t]*" here 'move)) | |
4540 (setq val (current-column)) | |
4541 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | |
4542 (goto-char here) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4543 (indent-line-to val)))))) |
79545 | 4544 |
4545 (; handle inside parenthetical expressions | |
4546 (eq type 'cparenexp) | |
4547 (let ((val (save-excursion | |
4548 (backward-up-list 1) | |
4549 (forward-char 1) | |
4550 (skip-chars-forward " \t") | |
4551 (current-column)))) | |
4552 (indent-line-to val) | |
4553 (if (and (not (verilog-in-struct-region-p)) | |
4554 (looking-at verilog-declaration-re)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4555 (verilog-indent-declaration ind)))) |
79545 | 4556 |
4557 (;-- Handle the ends | |
4558 (or | |
4559 (looking-at verilog-end-block-re ) | |
4560 (verilog-at-close-constraint-p)) | |
4561 (let ((val (if (eq type 'statement) | |
4562 (- ind verilog-indent-level) | |
4563 ind))) | |
4564 (indent-line-to val))) | |
4565 | |
4566 (;-- Case -- maybe line 'em up | |
4567 (and (eq type 'case) (not (looking-at "^[ \t]*$"))) | |
4568 (progn | |
4569 (cond | |
4570 ((looking-at "\\<endcase\\>") | |
4571 (indent-line-to ind)) | |
4572 (t | |
4573 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4574 (indent-line-to val)))))) | |
4575 | |
4576 (;-- defun | |
4577 (and (eq type 'defun) | |
4578 (looking-at verilog-zero-indent-re)) | |
4579 (indent-line-to 0)) | |
4580 | |
4581 (;-- declaration | |
4582 (and (or | |
4583 (eq type 'defun) | |
4584 (eq type 'block)) | |
4585 (looking-at verilog-declaration-re)) | |
4586 (verilog-indent-declaration ind)) | |
4587 | |
4588 (;-- Everything else | |
4589 t | |
4590 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4591 (indent-line-to val)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4592 |
79545 | 4593 (if (looking-at "[ \t]+$") |
4594 (skip-chars-forward " \t")) | |
4595 indent-str ; Return indent data | |
4596 )) | |
4597 | |
4598 (defun verilog-current-indent-level () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
4599 "Return the indent-level the current statement has." |
79545 | 4600 (save-excursion |
4601 (let (par-pos) | |
4602 (beginning-of-line) | |
4603 (setq par-pos (verilog-parenthesis-depth)) | |
4604 (while par-pos | |
4605 (goto-char par-pos) | |
4606 (beginning-of-line) | |
4607 (setq par-pos (verilog-parenthesis-depth))) | |
4608 (skip-chars-forward " \t") | |
4609 (current-column)))) | |
4610 | |
4611 (defun verilog-case-indent-level () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
4612 "Return the indent-level the current statement has. |
79545 | 4613 Do not count named blocks or case-statements." |
4614 (save-excursion | |
4615 (skip-chars-forward " \t") | |
4616 (cond | |
4617 ((looking-at verilog-named-block-re) | |
4618 (current-column)) | |
4619 ((and (not (looking-at verilog-case-re)) | |
4620 (looking-at "^[^:;]+[ \t]*:")) | |
4621 (verilog-re-search-forward ":" nil t) | |
4622 (skip-chars-forward " \t") | |
4623 (current-column)) | |
4624 (t | |
4625 (current-column))))) | |
4626 | |
4627 (defun verilog-indent-comment () | |
4628 "Indent current line as comment." | |
4629 (let* ((stcol | |
4630 (cond | |
4631 ((verilog-in-star-comment-p) | |
4632 (save-excursion | |
4633 (re-search-backward "/\\*" nil t) | |
4634 (1+(current-column)))) | |
4635 (comment-column | |
4636 comment-column ) | |
4637 (t | |
4638 (save-excursion | |
4639 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4640 (current-column)))))) |
79545 | 4641 (indent-line-to stcol) |
4642 stcol)) | |
4643 | |
4644 (defun verilog-more-comment () | |
4645 "Make more comment lines like the previous." | |
4646 (let* ((star 0) | |
4647 (stcol | |
4648 (cond | |
4649 ((verilog-in-star-comment-p) | |
4650 (save-excursion | |
4651 (setq star 1) | |
4652 (re-search-backward "/\\*" nil t) | |
4653 (1+(current-column)))) | |
4654 (comment-column | |
4655 comment-column ) | |
4656 (t | |
4657 (save-excursion | |
4658 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4659 (current-column)))))) |
79545 | 4660 (progn |
4661 (indent-to stcol) | |
4662 (if (and star | |
4663 (save-excursion | |
4664 (forward-line -1) | |
4665 (skip-chars-forward " \t") | |
4666 (looking-at "\*"))) | |
4667 (insert "* "))))) | |
4668 | |
4669 (defun verilog-comment-indent (&optional arg) | |
4670 "Return the column number the line should be indented to. | |
4671 ARG is ignored, for `comment-indent-function' compatibility." | |
4672 (cond | |
4673 ((verilog-in-star-comment-p) | |
4674 (save-excursion | |
4675 (re-search-backward "/\\*" nil t) | |
4676 (1+(current-column)))) | |
4677 ( comment-column | |
4678 comment-column ) | |
4679 (t | |
4680 (save-excursion | |
4681 (re-search-backward "//" nil t) | |
4682 (current-column))))) | |
4683 | |
4684 ;; | |
4685 | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4686 (defun verilog-pretty-declarations (&optional quiet) |
79545 | 4687 "Line up declarations around point." |
4688 (interactive) | |
4689 (save-excursion | |
4690 (if (progn | |
4691 (verilog-beg-of-statement-1) | |
4692 (looking-at verilog-declaration-re)) | |
4693 (let* ((m1 (make-marker)) | |
4694 (e) (r) | |
4695 (here (point)) | |
4696 ;; Start of declaration range | |
4697 (start | |
4698 (progn | |
4699 (verilog-beg-of-statement-1) | |
4700 (while (looking-at verilog-declaration-re) | |
4701 (beginning-of-line) | |
4702 (setq e (point)) | |
4703 (verilog-backward-syntactic-ws) | |
4704 (backward-char) | |
4705 (verilog-beg-of-statement-1)) ;Ack, need to grok `define | |
4706 e)) | |
4707 ;; End of declaration range | |
4708 (end | |
4709 (progn | |
4710 (goto-char here) | |
4711 (verilog-end-of-statement) | |
4712 (setq e (point)) ;Might be on last line | |
4713 (verilog-forward-syntactic-ws) | |
4714 (while (looking-at verilog-declaration-re) | |
4715 (beginning-of-line) | |
4716 (verilog-end-of-statement) | |
4717 (setq e (point)) | |
4718 (verilog-forward-syntactic-ws)) | |
4719 e)) | |
4720 (edpos (set-marker (make-marker) end)) | |
4721 (ind) | |
4722 (base-ind | |
4723 (progn | |
4724 (goto-char start) | |
4725 (verilog-do-indent (verilog-calculate-indent)) | |
4726 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4727 (current-column)))) |
79545 | 4728 (goto-char end) |
4729 (goto-char start) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4730 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4731 (> (- end start) 100)) |
79545 | 4732 (message "Lining up declarations..(please stand by)")) |
4733 ;; Get the beginning of line indent first | |
4734 (while (progn (setq e (marker-position edpos)) | |
4735 (< (point) e)) | |
4736 (cond | |
4737 ( (save-excursion (skip-chars-backward " \t") | |
4738 (bolp)) | |
4739 (verilog-forward-ws&directives) | |
4740 (indent-line-to base-ind) | |
4741 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4742 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
79545 | 4743 (t |
4744 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4745 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4746 ;;(forward-line) |
79545 | 4747 ) |
4748 ;; Now find biggest prefix | |
4749 (setq ind (verilog-get-lineup-indent start edpos)) | |
4750 ;; Now indent each line. | |
4751 (goto-char start) | |
4752 (while (progn (setq e (marker-position edpos)) | |
4753 (setq r (- e (point))) | |
4754 (> r 0)) | |
4755 (setq e (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4756 (unless quiet (message "%d" r)) |
79545 | 4757 (cond |
4758 ((or (and verilog-indent-declaration-macros | |
4759 (looking-at verilog-declaration-re-1-macro)) | |
4760 (looking-at verilog-declaration-re-1-no-macro)) | |
4761 (let ((p (match-end 0))) | |
4762 (set-marker m1 p) | |
4763 (if (verilog-re-search-forward "[[#`]" p 'move) | |
4764 (progn | |
4765 (forward-char -1) | |
4766 (just-one-space) | |
4767 (goto-char (marker-position m1)) | |
4768 (just-one-space) | |
4769 (indent-to ind)) | |
4770 (progn | |
4771 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4772 (indent-to ind))))) |
79545 | 4773 ((verilog-continued-line-1 start) |
4774 (goto-char e) | |
4775 (indent-line-to ind)) | |
4776 (t ; Must be comment or white space | |
4777 (goto-char e) | |
4778 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4779 (forward-line -1))) |
79545 | 4780 (forward-line 1)) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4781 (unless quiet (message "")))))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4782 |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4783 (defun verilog-pretty-expr (&optional quiet myre) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4784 "Line up expressions around point, or optional regexp MYRE." |
79545 | 4785 (interactive "sRegular Expression: ((<|:)?=) ") |
4786 (save-excursion | |
4787 (if (or (eq myre nil) | |
4788 (string-equal myre "")) | |
4789 (setq myre "\\(<\\|:\\)?=")) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4790 (setq myre (concat "\\(^[^;#:<=>]*\\)\\(" myre "\\)")) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4791 (let ((rexp(concat "^\\s-*" verilog-complete-reg))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4792 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4793 (if (and (not (looking-at rexp )) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4794 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4795 (let* ((here (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4796 (e) (r) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4797 (start |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4798 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4799 (beginning-of-line) |
79545 | 4800 (setq e (point)) |
4801 (verilog-backward-syntactic-ws) | |
4802 (beginning-of-line) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4803 (while (and (not (looking-at rexp )) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4804 (looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4805 (not (bobp)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4806 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4807 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4808 (verilog-backward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4809 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4810 ) ;Ack, need to grok `define |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4811 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4812 (end |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4813 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4814 (goto-char here) |
79545 | 4815 (end-of-line) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4816 (setq e (point)) ;Might be on last line |
79545 | 4817 (verilog-forward-syntactic-ws) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4818 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4819 (while (and (not (looking-at rexp )) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4820 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4821 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4822 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4823 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4824 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4825 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4826 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4827 (edpos (set-marker (make-marker) end)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4828 (ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4829 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4830 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4831 (verilog-do-indent (verilog-calculate-indent)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4832 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4833 (> (- end start) 100)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4834 (message "Lining up expressions..(please stand by)")) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4835 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4836 ;; Set indent to minimum throughout region |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4837 (while (< (point) (marker-position edpos)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4838 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4839 (verilog-just-one-space myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4840 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4841 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4842 ) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4843 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4844 ;; Now find biggest prefix |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4845 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4846 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4847 ;; Now indent each line. |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4848 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4849 (while (progn (setq e (marker-position edpos)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4850 (setq r (- e (point))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4851 (> r 0)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4852 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4853 (if (not quiet) (message "%d" r)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4854 (cond |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4855 ((looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4856 (goto-char (match-end 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4857 (if (not (verilog-parenthesis-depth)) ;; ignore parenthsized exprs |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4858 (if (eq (char-after) ?=) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4859 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4860 (indent-to ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4861 ))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4862 ((verilog-continued-line-1 start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4863 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4864 (indent-line-to ind)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4865 (t ; Must be comment or white space |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4866 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4867 (verilog-forward-ws&directives) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4868 (forward-line -1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4869 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4870 (forward-line 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4871 (unless quiet (message "")) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4872 ))))) |
79545 | 4873 |
4874 (defun verilog-just-one-space (myre) | |
4875 "Remove extra spaces around regular expression MYRE." | |
4876 (interactive) | |
4877 (if (and (not(looking-at verilog-complete-reg)) | |
4878 (looking-at myre)) | |
4879 (let ((p1 (match-end 1)) | |
4880 (p2 (match-end 2))) | |
4881 (progn | |
4882 (goto-char p2) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4883 (if (looking-at "\\s-") (just-one-space)) |
79545 | 4884 (goto-char p1) |
4885 (forward-char -1) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4886 (if (looking-at "\\s-") (just-one-space)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4887 )))) |
79545 | 4888 |
4889 (defun verilog-indent-declaration (baseind) | |
4890 "Indent current lines as declaration. | |
4891 Line up the variable names based on previous declaration's indentation. | |
4892 BASEIND is the base indent to offset everything." | |
4893 (interactive) | |
4894 (let ((pos (point-marker)) | |
4895 (lim (save-excursion | |
4896 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | |
4897 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | |
4898 (point))) | |
4899 (ind) | |
4900 (val) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4901 (m1 (make-marker))) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4902 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4903 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 4904 (indent-line-to val) |
4905 | |
4906 ;; Use previous declaration (in this module) as template. | |
4907 (if (or (memq 'all verilog-auto-lineup) | |
4908 (memq 'declaration verilog-auto-lineup)) | |
79546 | 4909 (if (verilog-re-search-backward |
79545 | 4910 (or (and verilog-indent-declaration-macros |
4911 verilog-declaration-re-1-macro) | |
4912 verilog-declaration-re-1-no-macro) lim t) | |
4913 (progn | |
4914 (goto-char (match-end 0)) | |
4915 (skip-chars-forward " \t") | |
4916 (setq ind (current-column)) | |
4917 (goto-char pos) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4918 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4919 (+ baseind |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4920 (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 4921 (indent-line-to val) |
4922 (if (and verilog-indent-declaration-macros | |
4923 (looking-at verilog-declaration-re-2-macro)) | |
4924 (let ((p (match-end 0))) | |
4925 (set-marker m1 p) | |
4926 (if (verilog-re-search-forward "[[#`]" p 'move) | |
4927 (progn | |
4928 (forward-char -1) | |
4929 (just-one-space) | |
4930 (goto-char (marker-position m1)) | |
4931 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4932 (indent-to ind)) |
79545 | 4933 (if (/= (current-column) ind) |
4934 (progn | |
4935 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4936 (indent-to ind))))) |
79545 | 4937 (if (looking-at verilog-declaration-re-2-no-macro) |
4938 (let ((p (match-end 0))) | |
4939 (set-marker m1 p) | |
4940 (if (verilog-re-search-forward "[[`#]" p 'move) | |
4941 (progn | |
4942 (forward-char -1) | |
4943 (just-one-space) | |
4944 (goto-char (marker-position m1)) | |
4945 (just-one-space) | |
4946 (indent-to ind)) | |
4947 (if (/= (current-column) ind) | |
4948 (progn | |
4949 (just-one-space) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4950 (indent-to ind)))))))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4951 (goto-char pos))) |
79545 | 4952 |
4953 (defun verilog-get-lineup-indent (b edpos) | |
4954 "Return the indent level that will line up several lines within the region. | |
4955 Region is defined by B and EDPOS." | |
4956 (save-excursion | |
4957 (let ((ind 0) e) | |
4958 (goto-char b) | |
4959 ;; Get rightmost position | |
4960 (while (progn (setq e (marker-position edpos)) | |
4961 (< (point) e)) | |
79546 | 4962 (if (verilog-re-search-forward |
79545 | 4963 (or (and verilog-indent-declaration-macros |
4964 verilog-declaration-re-1-macro) | |
4965 verilog-declaration-re-1-no-macro) e 'move) | |
4966 (progn | |
4967 (goto-char (match-end 0)) | |
4968 (verilog-backward-syntactic-ws) | |
4969 (if (> (current-column) ind) | |
4970 (setq ind (current-column))) | |
4971 (goto-char (match-end 0))))) | |
4972 (if (> ind 0) | |
4973 (1+ ind) | |
4974 ;; No lineup-string found | |
4975 (goto-char b) | |
4976 (end-of-line) | |
4977 (skip-chars-backward " \t") | |
4978 (1+ (current-column)))))) | |
4979 | |
4980 (defun verilog-get-lineup-indent-2 (myre b edpos) | |
4981 "Return the indent level that will line up several lines within the region." | |
4982 (save-excursion | |
4983 (let ((ind 0) e) | |
4984 (goto-char b) | |
4985 ;; Get rightmost position | |
4986 (while (progn (setq e (marker-position edpos)) | |
4987 (< (point) e)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4988 (if (and (verilog-re-search-forward myre e 'move) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4989 (not (verilog-parenthesis-depth))) ;; skip parenthsized exprs |
79545 | 4990 (progn |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4991 (goto-char (match-beginning 2)) |
79545 | 4992 (verilog-backward-syntactic-ws) |
4993 (if (> (current-column) ind) | |
4994 (setq ind (current-column))) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4995 (goto-char (match-end 0))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4996 )) |
79545 | 4997 (if (> ind 0) |
4998 (1+ ind) | |
4999 ;; No lineup-string found | |
5000 (goto-char b) | |
5001 (end-of-line) | |
5002 (skip-chars-backward " \t") | |
5003 (1+ (current-column)))))) | |
5004 | |
5005 (defun verilog-comment-depth (type val) | |
5006 "A useful mode debugging aide. TYPE and VAL are comments for insertion." | |
5007 (save-excursion | |
5008 (let | |
5009 ((b (prog2 | |
5010 (beginning-of-line) | |
5011 (point-marker) | |
5012 (end-of-line))) | |
5013 (e (point-marker))) | |
5014 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t) | |
5015 (progn | |
5016 (replace-match " /* -# ## */") | |
5017 (end-of-line)) | |
5018 (progn | |
5019 (end-of-line) | |
5020 (insert " /* ## ## */")))) | |
5021 (backward-char 6) | |
5022 (insert | |
5023 (format "%s %d" type val)))) | |
5024 | |
5025 ;; | |
5026 ;; | |
5027 ;; Completion | |
5028 ;; | |
5029 (defvar verilog-str nil) | |
5030 (defvar verilog-all nil) | |
5031 (defvar verilog-pred nil) | |
5032 (defvar verilog-buffer-to-use nil) | |
5033 (defvar verilog-flag nil) | |
5034 (defvar verilog-toggle-completions nil | |
5035 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one. | |
5036 Repeated use of \\[verilog-complete-word] will show you all of them. | |
5037 Normally, when there is more than one possible completion, | |
5038 it displays a list of all possible completions.") | |
5039 | |
5040 | |
5041 (defvar verilog-type-keywords | |
5042 '( | |
5043 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input" | |
5044 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0" | |
5045 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
5046 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0" | |
5047 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1" | |
5048 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor" | |
5049 ) | |
5050 "*Keywords for types used when completing a word in a declaration or parmlist. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5051 \(eg. integer, real, reg...)") |
79545 | 5052 |
5053 (defvar verilog-cpp-keywords | |
5054 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else" | |
5055 "endif") | |
5056 "*Keywords to complete when at first word of a line in declarative scope. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5057 \(eg. initial, always, begin, assign.) |
79545 | 5058 The procedures and variables defined within the Verilog program |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5059 will be completed runtime and should not be added to this list.") |
79545 | 5060 |
5061 (defvar verilog-defun-keywords | |
5062 (append | |
5063 '( | |
5064 "always" "always_comb" "always_ff" "always_latch" "assign" | |
5065 "begin" "end" "generate" "endgenerate" "module" "endmodule" | |
5066 "specify" "endspecify" "function" "endfunction" "initial" "final" | |
5067 "task" "endtask" "primitive" "endprimitive" | |
5068 ) | |
5069 verilog-type-keywords) | |
5070 "*Keywords to complete when at first word of a line in declarative scope. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5071 \(eg. initial, always, begin, assign.) |
79545 | 5072 The procedures and variables defined within the Verilog program |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5073 will be completed runtime and should not be added to this list.") |
79545 | 5074 |
5075 (defvar verilog-block-keywords | |
5076 '( | |
5077 "begin" "break" "case" "continue" "else" "end" "endfunction" | |
5078 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask" | |
5079 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return" | |
5080 "while") | |
5081 "*Keywords to complete when at first word of a line in behavioral scope. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5082 \(eg. begin, if, then, else, for, fork.) |
79545 | 5083 The procedures and variables defined within the Verilog program |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5084 will be completed runtime and should not be added to this list.") |
79545 | 5085 |
5086 (defvar verilog-tf-keywords | |
5087 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat") | |
5088 "*Keywords to complete when at first word of a line in a task or function. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5089 \(eg. begin, if, then, else, for, fork.) |
79545 | 5090 The procedures and variables defined within the Verilog program |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5091 will be completed runtime and should not be added to this list.") |
79545 | 5092 |
5093 (defvar verilog-case-keywords | |
5094 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat") | |
5095 "*Keywords to complete when at first word of a line in case scope. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5096 \(eg. begin, if, then, else, for, fork.) |
79545 | 5097 The procedures and variables defined within the Verilog program |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5098 will be completed runtime and should not be added to this list.") |
79545 | 5099 |
5100 (defvar verilog-separator-keywords | |
5101 '("else" "then" "begin") | |
5102 "*Keywords to complete when NOT standing at the first word of a statement. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5103 \(eg. else, then.) |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5104 Variables and function names defined within the |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5105 Verilog program are completed runtime and should not be added to this list.") |
79545 | 5106 |
5107 (defun verilog-string-diff (str1 str2) | |
5108 "Return index of first letter where STR1 and STR2 differs." | |
5109 (catch 'done | |
5110 (let ((diff 0)) | |
5111 (while t | |
5112 (if (or (> (1+ diff) (length str1)) | |
5113 (> (1+ diff) (length str2))) | |
5114 (throw 'done diff)) | |
5115 (or (equal (aref str1 diff) (aref str2 diff)) | |
5116 (throw 'done diff)) | |
5117 (setq diff (1+ diff)))))) | |
5118 | |
5119 ;; Calculate all possible completions for functions if argument is `function', | |
5120 ;; completions for procedures if argument is `procedure' or both functions and | |
5121 ;; procedures otherwise. | |
5122 | |
5123 (defun verilog-func-completion (type) | |
5124 "Build regular expression for module/task/function names. | |
5125 TYPE is 'module, 'tf for task or function, or t if unknown." | |
5126 (if (string= verilog-str "") | |
5127 (setq verilog-str "[a-zA-Z_]")) | |
5128 (let ((verilog-str (concat (cond | |
5129 ((eq type 'module) "\\<\\(module\\)\\s +") | |
5130 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") | |
5131 (t "\\<\\(task\\|function\\|module\\)\\s +")) | |
5132 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) | |
5133 match) | |
5134 | |
5135 (if (not (looking-at verilog-defun-re)) | |
5136 (verilog-re-search-backward verilog-defun-re nil t)) | |
5137 (forward-char 1) | |
5138 | |
5139 ;; Search through all reachable functions | |
5140 (goto-char (point-min)) | |
5141 (while (verilog-re-search-forward verilog-str (point-max) t) | |
5142 (progn (setq match (buffer-substring (match-beginning 2) | |
5143 (match-end 2))) | |
5144 (if (or (null verilog-pred) | |
5145 (funcall verilog-pred match)) | |
5146 (setq verilog-all (cons match verilog-all))))) | |
5147 (if (match-beginning 0) | |
5148 (goto-char (match-beginning 0))))) | |
5149 | |
5150 (defun verilog-get-completion-decl (end) | |
5151 "Macro for searching through current declaration (var, type or const) | |
5152 for matches of `str' and adding the occurrence tp `all' through point END." | |
5153 (let ((re (or (and verilog-indent-declaration-macros | |
5154 verilog-declaration-re-2-macro) | |
5155 verilog-declaration-re-2-no-macro)) | |
5156 decl-end match) | |
5157 ;; Traverse lines | |
5158 (while (and (< (point) end) | |
5159 (verilog-re-search-forward re end t)) | |
5160 ;; Traverse current line | |
5161 (setq decl-end (save-excursion (verilog-declaration-end))) | |
5162 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t) | |
5163 (not (match-end 1))) | |
5164 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | |
5165 (if (string-match (concat "\\<" verilog-str) match) | |
5166 (if (or (null verilog-pred) | |
5167 (funcall verilog-pred match)) | |
5168 (setq verilog-all (cons match verilog-all))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5169 (forward-line 1))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5170 verilog-all) |
79545 | 5171 |
5172 (defun verilog-type-completion () | |
5173 "Calculate all possible completions for types." | |
5174 (let ((start (point)) | |
5175 goon) | |
5176 ;; Search for all reachable type declarations | |
5177 (while (or (verilog-beg-of-defun) | |
5178 (setq goon (not goon))) | |
5179 (save-excursion | |
5180 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun) | |
5181 (point)) | |
5182 (forward-char 1))) | |
5183 (verilog-re-search-forward | |
5184 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" | |
5185 start t) | |
5186 (not (match-end 1))) | |
5187 ;; Check current type declaration | |
5188 (verilog-get-completion-decl start)))))) | |
5189 | |
5190 (defun verilog-var-completion () | |
5191 "Calculate all possible completions for variables (or constants)." | |
5192 (let ((start (point))) | |
5193 ;; Search for all reachable var declarations | |
5194 (verilog-beg-of-defun) | |
5195 (save-excursion | |
5196 ;; Check var declarations | |
5197 (verilog-get-completion-decl start)))) | |
5198 | |
5199 (defun verilog-keyword-completion (keyword-list) | |
5200 "Give list of all possible completions of keywords in KEYWORD-LIST." | |
5201 (mapcar '(lambda (s) | |
5202 (if (string-match (concat "\\<" verilog-str) s) | |
5203 (if (or (null verilog-pred) | |
5204 (funcall verilog-pred s)) | |
5205 (setq verilog-all (cons s verilog-all))))) | |
5206 keyword-list)) | |
5207 | |
5208 | |
5209 (defun verilog-completion (verilog-str verilog-pred verilog-flag) | |
5210 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5211 Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it | |
5212 must be a function to be called for every match to check if this should | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5213 really be a match. If VERILOG-FLAG is t, the function returns a list of all |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5214 possible completions. If VERILOG-FLAG is nil it returns a string, the |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5215 longest possible completion, or t if STR is an exact match. If VERILOG-FLAG |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5216 is 'lambda, the function returns t if STR is an exact match, nil |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5217 otherwise." |
79545 | 5218 (save-excursion |
5219 (let ((verilog-all nil)) | |
5220 ;; Set buffer to use for searching labels. This should be set | |
5221 ;; within functions which use verilog-completions | |
5222 (set-buffer verilog-buffer-to-use) | |
5223 | |
5224 ;; Determine what should be completed | |
5225 (let ((state (car (verilog-calculate-indent)))) | |
5226 (cond ((eq state 'defun) | |
5227 (save-excursion (verilog-var-completion)) | |
5228 (verilog-func-completion 'module) | |
5229 (verilog-keyword-completion verilog-defun-keywords)) | |
5230 | |
5231 ((eq state 'behavioral) | |
5232 (save-excursion (verilog-var-completion)) | |
5233 (verilog-func-completion 'module) | |
5234 (verilog-keyword-completion verilog-defun-keywords)) | |
5235 | |
5236 ((eq state 'block) | |
5237 (save-excursion (verilog-var-completion)) | |
5238 (verilog-func-completion 'tf) | |
5239 (verilog-keyword-completion verilog-block-keywords)) | |
5240 | |
5241 ((eq state 'case) | |
5242 (save-excursion (verilog-var-completion)) | |
5243 (verilog-func-completion 'tf) | |
5244 (verilog-keyword-completion verilog-case-keywords)) | |
5245 | |
5246 ((eq state 'tf) | |
5247 (save-excursion (verilog-var-completion)) | |
5248 (verilog-func-completion 'tf) | |
5249 (verilog-keyword-completion verilog-tf-keywords)) | |
5250 | |
5251 ((eq state 'cpp) | |
5252 (save-excursion (verilog-var-completion)) | |
5253 (verilog-keyword-completion verilog-cpp-keywords)) | |
5254 | |
5255 ((eq state 'cparenexp) | |
5256 (save-excursion (verilog-var-completion))) | |
5257 | |
5258 (t;--Anywhere else | |
5259 (save-excursion (verilog-var-completion)) | |
5260 (verilog-func-completion 'both) | |
5261 (verilog-keyword-completion verilog-separator-keywords)))) | |
5262 | |
5263 ;; Now we have built a list of all matches. Give response to caller | |
5264 (verilog-completion-response)))) | |
5265 | |
5266 (defun verilog-completion-response () | |
5267 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag)) | |
5268 ;; This was not called by all-completions | |
5269 (if (null verilog-all) | |
5270 ;; Return nil if there was no matching label | |
5271 nil | |
5272 ;; Get longest string common in the labels | |
5273 (let* ((elm (cdr verilog-all)) | |
5274 (match (car verilog-all)) | |
5275 (min (length match)) | |
5276 tmp) | |
5277 (if (string= match verilog-str) | |
5278 ;; Return t if first match was an exact match | |
5279 (setq match t) | |
5280 (while (not (null elm)) | |
5281 ;; Find longest common string | |
5282 (if (< (setq tmp (verilog-string-diff match (car elm))) min) | |
5283 (progn | |
5284 (setq min tmp) | |
5285 (setq match (substring match 0 min)))) | |
5286 ;; Terminate with match=t if this is an exact match | |
5287 (if (string= (car elm) verilog-str) | |
5288 (progn | |
5289 (setq match t) | |
5290 (setq elm nil)) | |
5291 (setq elm (cdr elm))))) | |
5292 ;; If this is a test just for exact match, return nil ot t | |
5293 (if (and (equal verilog-flag 'lambda) (not (equal match 't))) | |
5294 nil | |
5295 match)))) | |
5296 ;; If flag is t, this was called by all-completions. Return | |
5297 ;; list of all possible completions | |
5298 (verilog-flag | |
5299 verilog-all))) | |
5300 | |
5301 (defvar verilog-last-word-numb 0) | |
5302 (defvar verilog-last-word-shown nil) | |
5303 (defvar verilog-last-completions nil) | |
5304 | |
5305 (defun verilog-complete-word () | |
5306 "Complete word at current point. | |
5307 \(See also `verilog-toggle-completions', `verilog-type-keywords', | |
5308 and `verilog-separator-keywords'.)" | |
5309 (interactive) | |
5310 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5311 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5312 (verilog-str (buffer-substring b e)) | |
5313 ;; The following variable is used in verilog-completion | |
5314 (verilog-buffer-to-use (current-buffer)) | |
5315 (allcomp (if (and verilog-toggle-completions | |
5316 (string= verilog-last-word-shown verilog-str)) | |
5317 verilog-last-completions | |
5318 (all-completions verilog-str 'verilog-completion))) | |
5319 (match (if verilog-toggle-completions | |
5320 "" (try-completion | |
5321 verilog-str (mapcar '(lambda (elm) | |
5322 (cons elm 0)) allcomp))))) | |
5323 ;; Delete old string | |
5324 (delete-region b e) | |
5325 | |
5326 ;; Toggle-completions inserts whole labels | |
5327 (if verilog-toggle-completions | |
5328 (progn | |
5329 ;; Update entry number in list | |
5330 (setq verilog-last-completions allcomp | |
5331 verilog-last-word-numb | |
5332 (if (>= verilog-last-word-numb (1- (length allcomp))) | |
5333 0 | |
5334 (1+ verilog-last-word-numb))) | |
5335 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb)) | |
5336 ;; Display next match or same string if no match was found | |
5337 (if (not (null allcomp)) | |
5338 (insert "" verilog-last-word-shown) | |
5339 (insert "" verilog-str) | |
5340 (message "(No match)"))) | |
5341 ;; The other form of completion does not necessarily do that. | |
5342 | |
5343 ;; Insert match if found, or the original string if no match | |
5344 (if (or (null match) (equal match 't)) | |
5345 (progn (insert "" verilog-str) | |
5346 (message "(No match)")) | |
5347 (insert "" match)) | |
5348 ;; Give message about current status of completion | |
5349 (cond ((equal match 't) | |
5350 (if (not (null (cdr allcomp))) | |
5351 (message "(Complete but not unique)") | |
5352 (message "(Sole completion)"))) | |
5353 ;; Display buffer if the current completion didn't help | |
5354 ;; on completing the label. | |
5355 ((and (not (null (cdr allcomp))) (= (length verilog-str) | |
5356 (length match))) | |
5357 (with-output-to-temp-buffer "*Completions*" | |
5358 (display-completion-list allcomp)) | |
5359 ;; Wait for a key press. Then delete *Completion* window | |
5360 (momentary-string-display "" (point)) | |
5361 (delete-window (get-buffer-window (get-buffer "*Completions*"))) | |
5362 ))))) | |
5363 | |
5364 (defun verilog-show-completions () | |
5365 "Show all possible completions at current point." | |
5366 (interactive) | |
5367 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5368 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5369 (verilog-str (buffer-substring b e)) | |
5370 ;; The following variable is used in verilog-completion | |
5371 (verilog-buffer-to-use (current-buffer)) | |
5372 (allcomp (if (and verilog-toggle-completions | |
5373 (string= verilog-last-word-shown verilog-str)) | |
5374 verilog-last-completions | |
5375 (all-completions verilog-str 'verilog-completion)))) | |
5376 ;; Show possible completions in a temporary buffer. | |
5377 (with-output-to-temp-buffer "*Completions*" | |
5378 (display-completion-list allcomp)) | |
5379 ;; Wait for a key press. Then delete *Completion* window | |
5380 (momentary-string-display "" (point)) | |
5381 (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | |
5382 | |
5383 | |
5384 (defun verilog-get-default-symbol () | |
5385 "Return symbol around current point as a string." | |
5386 (save-excursion | |
5387 (buffer-substring (progn | |
5388 (skip-chars-backward " \t") | |
5389 (skip-chars-backward "a-zA-Z0-9_") | |
5390 (point)) | |
5391 (progn | |
5392 (skip-chars-forward "a-zA-Z0-9_") | |
5393 (point))))) | |
5394 | |
5395 (defun verilog-build-defun-re (str &optional arg) | |
5396 "Return function/task/module starting with STR as regular expression. | |
5397 With optional second ARG non-nil, STR is the complete name of the instruction." | |
5398 (if arg | |
5399 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>") | |
5400 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>"))) | |
5401 | |
5402 (defun verilog-comp-defun (verilog-str verilog-pred verilog-flag) | |
5403 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5404 Returns a completion on any function name based on VERILOG-STR prefix. If | |
5405 VERILOG-PRED is non-nil, it must be a function to be called for every match | |
5406 to check if this should really be a match. If VERILOG-FLAG is t, the | |
5407 function returns a list of all possible completions. If it is nil it | |
5408 returns a string, the longest possible completion, or t if VERILOG-STR is | |
5409 an exact match. If VERILOG-FLAG is 'lambda, the function returns t if | |
5410 VERILOG-STR is an exact match, nil otherwise." | |
5411 (save-excursion | |
5412 (let ((verilog-all nil) | |
5413 match) | |
5414 | |
5415 ;; Set buffer to use for searching labels. This should be set | |
5416 ;; within functions which use verilog-completions | |
5417 (set-buffer verilog-buffer-to-use) | |
5418 | |
5419 (let ((verilog-str verilog-str)) | |
5420 ;; Build regular expression for functions | |
5421 (if (string= verilog-str "") | |
5422 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]")) | |
5423 (setq verilog-str (verilog-build-defun-re verilog-str))) | |
5424 (goto-char (point-min)) | |
5425 | |
5426 ;; Build a list of all possible completions | |
5427 (while (verilog-re-search-forward verilog-str nil t) | |
5428 (setq match (buffer-substring (match-beginning 2) (match-end 2))) | |
5429 (if (or (null verilog-pred) | |
5430 (funcall verilog-pred match)) | |
5431 (setq verilog-all (cons match verilog-all))))) | |
5432 | |
5433 ;; Now we have built a list of all matches. Give response to caller | |
5434 (verilog-completion-response)))) | |
5435 | |
5436 (defun verilog-goto-defun () | |
5437 "Move to specified Verilog module/task/function. | |
5438 The default is a name found in the buffer around point. | |
5439 If search fails, other files are checked based on | |
5440 `verilog-library-flags'." | |
5441 (interactive) | |
5442 (let* ((default (verilog-get-default-symbol)) | |
5443 ;; The following variable is used in verilog-comp-function | |
5444 (verilog-buffer-to-use (current-buffer)) | |
5445 (label (if (not (string= default "")) | |
5446 ;; Do completion with default | |
5447 (completing-read (concat "Label: (default " default ") ") | |
5448 'verilog-comp-defun nil nil "") | |
5449 ;; There is no default value. Complete without it | |
5450 (completing-read "Label: " | |
5451 'verilog-comp-defun nil nil ""))) | |
5452 pt) | |
5453 ;; If there was no response on prompt, use default value | |
5454 (if (string= label "") | |
5455 (setq label default)) | |
5456 ;; Goto right place in buffer if label is not an empty string | |
5457 (or (string= label "") | |
5458 (progn | |
5459 (save-excursion | |
5460 (goto-char (point-min)) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5461 (setq pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5462 (re-search-forward (verilog-build-defun-re label t) nil t))) |
79545 | 5463 (when pt |
5464 (goto-char pt) | |
5465 (beginning-of-line)) | |
5466 pt) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5467 (verilog-goto-defun-file label)))) |
79545 | 5468 |
5469 ;; Eliminate compile warning | |
5470 (eval-when-compile | |
5471 (if (not (boundp 'occur-pos-list)) | |
5472 (defvar occur-pos-list nil "Backward compatibility occur positions."))) | |
5473 | |
5474 (defun verilog-showscopes () | |
5475 "List all scopes in this module." | |
5476 (interactive) | |
5477 (let ((buffer (current-buffer)) | |
5478 (linenum 1) | |
5479 (nlines 0) | |
5480 (first 1) | |
5481 (prevpos (point-min)) | |
5482 (final-context-start (make-marker)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5483 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
79545 | 5484 (with-output-to-temp-buffer "*Occur*" |
5485 (save-excursion | |
5486 (message (format "Searching for %s ..." regexp)) | |
5487 ;; Find next match, but give up if prev match was at end of buffer. | |
5488 (while (and (not (= prevpos (point-max))) | |
5489 (verilog-re-search-forward regexp nil t)) | |
5490 (goto-char (match-beginning 0)) | |
5491 (beginning-of-line) | |
5492 (save-match-data | |
5493 (setq linenum (+ linenum (count-lines prevpos (point))))) | |
5494 (setq prevpos (point)) | |
5495 (goto-char (match-end 0)) | |
5496 (let* ((start (save-excursion | |
5497 (goto-char (match-beginning 0)) | |
5498 (forward-line (if (< nlines 0) nlines (- nlines))) | |
5499 (point))) | |
5500 (end (save-excursion | |
5501 (goto-char (match-end 0)) | |
5502 (if (> nlines 0) | |
5503 (forward-line (1+ nlines)) | |
5504 (forward-line 1)) | |
5505 (point))) | |
5506 (tag (format "%3d" linenum)) | |
5507 (empty (make-string (length tag) ?\ )) | |
5508 tem) | |
5509 (save-excursion | |
5510 (setq tem (make-marker)) | |
5511 (set-marker tem (point)) | |
5512 (set-buffer standard-output) | |
5513 (setq occur-pos-list (cons tem occur-pos-list)) | |
5514 (or first (zerop nlines) | |
5515 (insert "--------\n")) | |
5516 (setq first nil) | |
5517 (insert-buffer-substring buffer start end) | |
5518 (backward-char (- end start)) | |
5519 (setq tem (if (< nlines 0) (- nlines) nlines)) | |
5520 (while (> tem 0) | |
5521 (insert empty ?:) | |
5522 (forward-line 1) | |
5523 (setq tem (1- tem))) | |
5524 (let ((this-linenum linenum)) | |
5525 (set-marker final-context-start | |
5526 (+ (point) (- (match-end 0) (match-beginning 0)))) | |
5527 (while (< (point) final-context-start) | |
5528 (if (null tag) | |
5529 (setq tag (format "%3d" this-linenum))) | |
5530 (insert tag ?:))))))) | |
5531 (set-buffer-modified-p nil)))) | |
5532 | |
5533 | |
5534 ;; Highlight helper functions | |
5535 (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") | |
5536 (defun verilog-within-translate-off () | |
5537 "Return point if within translate-off region, else nil." | |
5538 (and (save-excursion | |
5539 (re-search-backward | |
5540 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>") | |
5541 nil t)) | |
5542 (equal "off" (match-string 2)) | |
5543 (point))) | |
5544 | |
5545 (defun verilog-start-translate-off (limit) | |
5546 "Return point before translate-off directive if before LIMIT, else nil." | |
5547 (when (re-search-forward | |
5548 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5549 limit t) | |
5550 (match-beginning 0))) | |
5551 | |
5552 (defun verilog-back-to-start-translate-off (limit) | |
5553 "Return point before translate-off directive if before LIMIT, else nil." | |
5554 (when (re-search-backward | |
5555 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5556 limit t) | |
5557 (match-beginning 0))) | |
5558 | |
5559 (defun verilog-end-translate-off (limit) | |
5560 "Return point after translate-on directive if before LIMIT, else nil." | |
5561 | |
5562 (re-search-forward (concat | |
5563 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t)) | |
5564 | |
5565 (defun verilog-match-translate-off (limit) | |
5566 "Match a translate-off block, setting `match-data' and returning t, else nil. | |
5567 Bound search by LIMIT." | |
5568 (when (< (point) limit) | |
5569 (let ((start (or (verilog-within-translate-off) | |
5570 (verilog-start-translate-off limit))) | |
5571 (case-fold-search t)) | |
5572 (when start | |
5573 (let ((end (or (verilog-end-translate-off limit) limit))) | |
5574 (set-match-data (list start end)) | |
5575 (goto-char end)))))) | |
5576 | |
5577 (defun verilog-font-lock-match-item (limit) | |
5578 "Match, and move over, any declaration item after point. | |
5579 Bound search by LIMIT. Adapted from | |
5580 `font-lock-match-c-style-declaration-item-and-skip-to-next'." | |
5581 (condition-case nil | |
5582 (save-restriction | |
5583 (narrow-to-region (point-min) limit) | |
5584 ;; match item | |
5585 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)") | |
5586 (save-match-data | |
5587 (goto-char (match-end 1)) | |
5588 ;; move to next item | |
5589 (if (looking-at "\\(\\s-*,\\)") | |
5590 (goto-char (match-end 1)) | |
5591 (end-of-line) t)))) | |
5592 (error nil))) | |
5593 | |
5594 | |
5595 ;; Added by Subbu Meiyappan for Header | |
5596 | |
5597 (defun verilog-header () | |
5598 "Insert a standard Verilog file header." | |
5599 (interactive) | |
5600 (let ((start (point))) | |
5601 (insert "\ | |
5602 //----------------------------------------------------------------------------- | |
5603 // Title : <title> | |
5604 // Project : <project> | |
5605 //----------------------------------------------------------------------------- | |
5606 // File : <filename> | |
5607 // Author : <author> | |
5608 // Created : <credate> | |
5609 // Last modified : <moddate> | |
5610 //----------------------------------------------------------------------------- | |
5611 // Description : | |
5612 // <description> | |
5613 //----------------------------------------------------------------------------- | |
5614 // Copyright (c) <copydate> by <company> This model is the confidential and | |
5615 // proprietary property of <company> and the possession or use of this | |
5616 // file requires a written license from <company>. | |
5617 //------------------------------------------------------------------------------ | |
5618 // Modification history : | |
5619 // <modhist> | |
5620 //----------------------------------------------------------------------------- | |
5621 | |
5622 ") | |
5623 (goto-char start) | |
5624 (search-forward "<filename>") | |
5625 (replace-match (buffer-name) t t) | |
5626 (search-forward "<author>") (replace-match "" t t) | |
5627 (insert (user-full-name)) | |
5628 (insert " <" (user-login-name) "@" (system-name) ">") | |
5629 (search-forward "<credate>") (replace-match "" t t) | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5630 (verilog-insert-date) |
79545 | 5631 (search-forward "<moddate>") (replace-match "" t t) |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5632 (verilog-insert-date) |
79545 | 5633 (search-forward "<copydate>") (replace-match "" t t) |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5634 (verilog-insert-year) |
79545 | 5635 (search-forward "<modhist>") (replace-match "" t t) |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5636 (verilog-insert-date) |
79545 | 5637 (insert " : created") |
5638 (goto-char start) | |
5639 (let (string) | |
5640 (setq string (read-string "title: ")) | |
5641 (search-forward "<title>") | |
5642 (replace-match string t t) | |
5643 (setq string (read-string "project: " verilog-project)) | |
5644 (setq verilog-project string) | |
5645 (search-forward "<project>") | |
5646 (replace-match string t t) | |
5647 (setq string (read-string "Company: " verilog-company)) | |
5648 (setq verilog-company string) | |
5649 (search-forward "<company>") | |
5650 (replace-match string t t) | |
5651 (search-forward "<company>") | |
5652 (replace-match string t t) | |
5653 (search-forward "<company>") | |
5654 (replace-match string t t) | |
5655 (search-backward "<description>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5656 (replace-match "" t t)))) |
79545 | 5657 |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5658 ;; verilog-header Uses the verilog-insert-date function |
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5659 |
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5660 (defun verilog-insert-date () |
79545 | 5661 "Insert date from the system." |
5662 (interactive) | |
5663 (let ((timpos)) | |
5664 (setq timpos (point)) | |
5665 (if verilog-date-scientific-format | |
5666 (shell-command "date \"+@%Y/%m/%d\"" t) | |
5667 (shell-command "date \"+@%d.%m.%Y\"" t)) | |
5668 (search-forward "@") | |
5669 (delete-region timpos (point)) | |
5670 (end-of-line)) | |
5671 (delete-char 1)) | |
5672 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5673 (defun verilog-insert-year () |
79545 | 5674 "Insert year from the system." |
5675 (interactive) | |
5676 (let ((timpos)) | |
5677 (setq timpos (point)) | |
5678 (shell-command "date \"+@%Y\"" t) | |
5679 (search-forward "@") | |
5680 (delete-region timpos (point)) | |
5681 (end-of-line)) | |
5682 (delete-char 1)) | |
5683 | |
5684 | |
5685 ;; | |
5686 ;; Signal list parsing | |
5687 ;; | |
5688 | |
5689 ;; Elements of a signal list | |
5690 (defsubst verilog-sig-name (sig) | |
5691 (car sig)) | |
5692 (defsubst verilog-sig-bits (sig) | |
5693 (nth 1 sig)) | |
5694 (defsubst verilog-sig-comment (sig) | |
5695 (nth 2 sig)) | |
5696 (defsubst verilog-sig-memory (sig) | |
5697 (nth 3 sig)) | |
5698 (defsubst verilog-sig-enum (sig) | |
5699 (nth 4 sig)) | |
5700 (defsubst verilog-sig-signed (sig) | |
5701 (nth 5 sig)) | |
5702 (defsubst verilog-sig-type (sig) | |
5703 (nth 6 sig)) | |
5704 (defsubst verilog-sig-multidim (sig) | |
5705 (nth 7 sig)) | |
5706 (defsubst verilog-sig-multidim-string (sig) | |
5707 (if (verilog-sig-multidim sig) | |
5708 (let ((str "") (args (verilog-sig-multidim sig))) | |
5709 (while args | |
5710 (setq str (concat str (car args))) | |
5711 (setq args (cdr args))) | |
5712 str))) | |
5713 (defsubst verilog-sig-width (sig) | |
5714 (verilog-make-width-expression (verilog-sig-bits sig))) | |
5715 | |
5716 (defsubst verilog-alw-get-inputs (sigs) | |
5717 (nth 2 sigs)) | |
5718 (defsubst verilog-alw-get-outputs (sigs) | |
5719 (nth 0 sigs)) | |
5720 (defsubst verilog-alw-get-uses-delayed (sigs) | |
5721 (nth 3 sigs)) | |
5722 | |
5723 (defun verilog-signals-not-in (in-list not-list) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5724 "Return list of signals in IN-LIST that aren't also in NOT-LIST, |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
5725 and also remove any duplicates in IN-LIST. |
79545 | 5726 Signals must be in standard (base vector) form." |
5727 (let (out-list) | |
5728 (while in-list | |
5729 (if (not (or (assoc (car (car in-list)) not-list) | |
5730 (assoc (car (car in-list)) out-list))) | |
5731 (setq out-list (cons (car in-list) out-list))) | |
5732 (setq in-list (cdr in-list))) | |
5733 (nreverse out-list))) | |
5734 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5735 | |
5736 (defun verilog-signals-in (in-list other-list) | |
5737 "Return list of signals in IN-LIST that are also in OTHER-LIST. | |
5738 Signals must be in standard (base vector) form." | |
5739 (let (out-list) | |
5740 (while in-list | |
5741 (if (assoc (car (car in-list)) other-list) | |
5742 (setq out-list (cons (car in-list) out-list))) | |
5743 (setq in-list (cdr in-list))) | |
5744 (nreverse out-list))) | |
5745 ;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5746 | |
5747 (defun verilog-signals-memory (in-list) | |
5748 "Return list of signals in IN-LIST that are memoried (multidimensional)." | |
5749 (let (out-list) | |
5750 (while in-list | |
5751 (if (nth 3 (car in-list)) | |
5752 (setq out-list (cons (car in-list) out-list))) | |
5753 (setq in-list (cdr in-list))) | |
5754 out-list)) | |
5755 ;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil))) | |
5756 | |
5757 (defun verilog-signals-sort-compare (a b) | |
5758 "Compare signal A and B for sorting." | |
5759 (string< (car a) (car b))) | |
5760 | |
5761 (defun verilog-signals-not-params (in-list) | |
5762 "Return list of signals in IN-LIST that aren't parameters or numeric constants." | |
5763 (let (out-list) | |
5764 (while in-list | |
5765 (unless (boundp (intern (concat "vh-" (car (car in-list))))) | |
5766 (setq out-list (cons (car in-list) out-list))) | |
5767 (setq in-list (cdr in-list))) | |
5768 (nreverse out-list))) | |
5769 | |
5770 (defun verilog-signals-combine-bus (in-list) | |
5771 "Return a list of signals in IN-LIST, with busses combined. | |
5772 Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | |
5773 (let (combo buswarn | |
5774 out-list | |
5775 sig highbit lowbit ; Temp information about current signal | |
5776 sv-name sv-highbit sv-lowbit ; Details about signal we are forming | |
5777 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring | |
5778 bus) | |
5779 ;; Shove signals so duplicated signals will be adjacent | |
5780 (setq in-list (sort in-list `verilog-signals-sort-compare)) | |
5781 (while in-list | |
5782 (setq sig (car in-list)) | |
5783 ;; No current signal; form from existing details | |
5784 (unless sv-name | |
5785 (setq sv-name (verilog-sig-name sig) | |
5786 sv-highbit nil | |
5787 sv-busstring nil | |
5788 sv-comment (verilog-sig-comment sig) | |
5789 sv-memory (verilog-sig-memory sig) | |
5790 sv-enum (verilog-sig-enum sig) | |
5791 sv-signed (verilog-sig-signed sig) | |
5792 sv-type (verilog-sig-type sig) | |
5793 sv-multidim (verilog-sig-multidim sig) | |
5794 combo "" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5795 buswarn "")) |
79545 | 5796 ;; Extract bus details |
5797 (setq bus (verilog-sig-bits sig)) | |
5798 (cond ((and bus | |
5799 (or (and (string-match "\\[\\([0-9]+\\):\\([0-9]+\\)\\]" bus) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5800 (setq highbit (string-to-number (match-string 1 bus)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5801 lowbit (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5802 (match-string 2 bus)))) |
79545 | 5803 (and (string-match "\\[\\([0-9]+\\)\\]" bus) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5804 (setq highbit (string-to-number (match-string 1 bus)) |
79545 | 5805 lowbit highbit)))) |
5806 ;; Combine bits in bus | |
5807 (if sv-highbit | |
5808 (setq sv-highbit (max highbit sv-highbit) | |
5809 sv-lowbit (min lowbit sv-lowbit)) | |
5810 (setq sv-highbit highbit | |
5811 sv-lowbit lowbit))) | |
5812 (bus | |
5813 ;; String, probably something like `preproc:0 | |
5814 (setq sv-busstring bus))) | |
5815 ;; Peek ahead to next signal | |
5816 (setq in-list (cdr in-list)) | |
5817 (setq sig (car in-list)) | |
5818 (cond ((and sig (equal sv-name (verilog-sig-name sig))) | |
5819 ;; Combine with this signal | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5820 (when (and sv-busstring |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5821 (not (equal sv-busstring (verilog-sig-bits sig)))) |
79545 | 5822 (when nil ;; Debugging |
5823 (message (concat "Warning, can't merge into single bus " | |
5824 sv-name bus | |
5825 ", the AUTOs may be wrong"))) | |
5826 (setq buswarn ", Couldn't Merge")) | |
5827 (if (verilog-sig-comment sig) (setq combo ", ...")) | |
5828 (setq sv-memory (or sv-memory (verilog-sig-memory sig)) | |
5829 sv-enum (or sv-enum (verilog-sig-enum sig)) | |
5830 sv-signed (or sv-signed (verilog-sig-signed sig)) | |
5831 sv-type (or sv-type (verilog-sig-type sig)) | |
5832 sv-multidim (or sv-multidim (verilog-sig-multidim sig)))) | |
5833 ;; Doesn't match next signal, add to queue, zero in prep for next | |
5834 ;; Note sig may also be nil for the last signal in the list | |
5835 (t | |
5836 (setq out-list | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5837 (cons |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5838 (list sv-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5839 (or sv-busstring |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5840 (if sv-highbit |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5841 (concat "[" (int-to-string sv-highbit) ":" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5842 (int-to-string sv-lowbit) "]"))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5843 (concat sv-comment combo buswarn) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5844 sv-memory sv-enum sv-signed sv-type sv-multidim) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5845 out-list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5846 sv-name nil)))) |
79545 | 5847 ;; |
5848 out-list)) | |
5849 | |
5850 (defun verilog-sig-tieoff (sig &optional no-width) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5851 "Return tieoff expression for given SIG, with appropriate width. |
79545 | 5852 Ignore width if optional NO-WIDTH is set." |
5853 (let* ((width (if no-width nil (verilog-sig-width sig)))) | |
5854 (concat | |
5855 (if (and verilog-active-low-regexp | |
5856 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | |
5857 "~" "") | |
5858 (cond ((not width) | |
5859 "0") | |
5860 ((string-match "^[0-9]+$" width) | |
5861 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0"))) | |
5862 (t | |
5863 (concat "{" width "{1'b0}}")))))) | |
5864 | |
5865 ;; | |
5866 ;; Port/Wire/Etc Reading | |
5867 ;; | |
5868 | |
5869 (defun verilog-read-inst-backward-name () | |
5870 "Internal. Move point back to beginning of inst-name." | |
5871 (verilog-backward-open-paren) | |
5872 (let (done) | |
5873 (while (not done) | |
5874 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary | |
5875 (cond ((looking-at ")") | |
5876 (verilog-backward-open-paren)) | |
5877 (t (setq done t))))) | |
5878 (while (looking-at "\\]") | |
5879 (verilog-backward-open-bracket) | |
5880 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) | |
5881 (skip-chars-backward "a-zA-Z0-9`_$")) | |
5882 | |
5883 (defun verilog-read-inst-module () | |
5884 "Return module_name when point is inside instantiation." | |
5885 (save-excursion | |
5886 (verilog-read-inst-backward-name) | |
5887 ;; Skip over instantiation name | |
5888 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary | |
5889 ;; Check for parameterized instantiations | |
5890 (when (looking-at ")") | |
5891 (verilog-backward-open-paren) | |
5892 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)) | |
5893 (skip-chars-backward "a-zA-Z0-9'_$") | |
5894 (looking-at "[a-zA-Z0-9`_\$]+") | |
5895 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5896 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5897 | |
5898 (defun verilog-read-inst-name () | |
5899 "Return instance_name when point is inside instantiation." | |
5900 (save-excursion | |
5901 (verilog-read-inst-backward-name) | |
5902 (looking-at "[a-zA-Z0-9`_\$]+") | |
5903 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5904 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5905 | |
5906 (defun verilog-read-module-name () | |
5907 "Return module name when after its ( or ;." | |
5908 (save-excursion | |
5909 (re-search-backward "[(;]") | |
5910 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) | |
5911 (skip-chars-backward "a-zA-Z0-9`_$") | |
5912 (looking-at "[a-zA-Z0-9`_\$]+") | |
5913 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5914 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5915 | |
5916 (defun verilog-read-auto-params (num-param &optional max-param) | |
5917 "Return parameter list inside auto. | |
5918 Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters." | |
5919 (let ((olist)) | |
5920 (save-excursion | |
5921 ;; /*AUTOPUNT("parameter", "parameter")*/ | |
5922 (search-backward "(") | |
5923 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?") | |
5924 (setq olist (cons (match-string 1) olist)) | |
5925 (goto-char (match-end 0)))) | |
5926 (or (eq nil num-param) | |
5927 (<= num-param (length olist)) | |
5928 (error "%s: Expected %d parameters" (verilog-point-text) num-param)) | |
5929 (if (eq max-param nil) (setq max-param num-param)) | |
5930 (or (eq nil max-param) | |
5931 (>= max-param (length olist)) | |
5932 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param)) | |
5933 (nreverse olist))) | |
5934 | |
5935 (defun verilog-read-decls () | |
5936 "Compute signal declaration information for the current module at point. | |
5937 Return a array of [outputs inouts inputs wire reg assign const]." | |
5938 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) | |
5939 (functask 0) (paren 0) (sig-paren 0) | |
5940 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const sigs-gparam | |
5941 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim) | |
5942 (save-excursion | |
5943 (verilog-beg-of-defun) | |
5944 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) | |
5945 (while (< (point) end-mod-point) | |
5946 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg))) | |
5947 (cond | |
5948 ((looking-at "//") | |
5949 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
5950 (setq enum (match-string 1))) | |
5951 (search-forward "\n")) | |
5952 ((looking-at "/\\*") | |
5953 (forward-char 2) | |
5954 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
5955 (setq enum (match-string 1))) | |
5956 (or (search-forward "*/") | |
5957 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
5958 ((looking-at "(\\*") | |
5959 (forward-char 2) | |
5960 (or (looking-at "\\s-*)") ; It's a "always @ (*)" | |
5961 (search-forward "*)") | |
5962 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
5963 ((eq ?\" (following-char)) | |
5964 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first | |
5965 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
5966 ((eq ?\; (following-char)) | |
5967 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil) | |
5968 (forward-char 1)) | |
5969 ((eq ?= (following-char)) | |
5970 (setq rvalue t newsig nil) | |
5971 (forward-char 1)) | |
5972 ((and (or rvalue sig-paren) | |
5973 (cond ((and (eq ?, (following-char)) | |
5974 (eq paren sig-paren)) | |
5975 (setq rvalue nil) | |
5976 (forward-char 1) | |
5977 t) | |
5978 ;; ,'s can occur inside {} & funcs | |
5979 ((looking-at "[{(]") | |
5980 (setq paren (1+ paren)) | |
5981 (forward-char 1) | |
5982 t) | |
5983 ((looking-at "[})]") | |
5984 (setq paren (1- paren)) | |
5985 (forward-char 1) | |
5986 (when (< paren sig-paren) | |
5987 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5988 t)))) |
79545 | 5989 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
5990 (goto-char (match-end 0)) | |
5991 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | |
5992 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | |
5993 (vec ;; Multidimensional | |
5994 (setq multidim (cons vec multidim)) | |
5995 (setq vec (verilog-string-replace-matches | |
5996 "\\s-+" "" nil nil (match-string 1)))) | |
5997 (t ;; Bit width | |
5998 (setq vec (verilog-string-replace-matches | |
5999 "\\s-+" "" nil nil (match-string 1)))))) | |
6000 ;; Normal or escaped identifier -- note we remember the \ if escaped | |
6001 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | |
6002 (goto-char (match-end 0)) | |
6003 (setq keywd (match-string 1)) | |
6004 (when (string-match "^\\\\" keywd) | |
6005 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end | |
6006 (cond ((equal keywd "input") | |
6007 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6008 expect-signal 'sigs-in io t)) | |
6009 ((equal keywd "output") | |
6010 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6011 expect-signal 'sigs-out io t)) | |
6012 ((equal keywd "inout") | |
6013 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6014 expect-signal 'sigs-inout io t)) | |
6015 ((or (equal keywd "wire") | |
6016 (equal keywd "tri") | |
6017 (equal keywd "tri0") | |
6018 (equal keywd "tri1")) | |
6019 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6020 expect-signal 'sigs-wire))) | |
6021 ((or (equal keywd "reg") | |
6022 (equal keywd "trireg")) | |
6023 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6024 expect-signal 'sigs-reg))) | |
6025 ((equal keywd "assign") | |
6026 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6027 expect-signal 'sigs-assign)) | |
6028 ((or (equal keywd "supply0") | |
6029 (equal keywd "supply1") | |
6030 (equal keywd "supply") | |
6031 (equal keywd "localparam")) | |
6032 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6033 expect-signal 'sigs-const))) | |
6034 ((or (equal keywd "parameter")) | |
6035 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6036 expect-signal 'sigs-gparam))) | |
6037 ((equal keywd "signed") | |
6038 (setq signed "signed")) | |
6039 ((or (equal keywd "function") | |
6040 (equal keywd "task")) | |
6041 (setq functask (1+ functask))) | |
6042 ((or (equal keywd "endfunction") | |
6043 (equal keywd "endtask")) | |
6044 (setq functask (1- functask))) | |
6045 ((or (equal keywd "`ifdef") | |
6046 (equal keywd "`ifndef")) | |
6047 (setq rvalue t)) | |
6048 ((verilog-typedef-name-p keywd) | |
6049 (setq typedefed keywd)) | |
6050 ((and expect-signal | |
6051 (eq functask 0) | |
6052 (not rvalue) | |
6053 (eq paren sig-paren) | |
6054 (not (member keywd verilog-keywords))) | |
6055 ;; Add new signal to expect-signal's variable | |
6056 (setq newsig (list keywd vec nil nil enum signed typedefed multidim)) | |
6057 (set expect-signal (cons newsig | |
6058 (symbol-value expect-signal)))))) | |
6059 (t | |
6060 (forward-char 1))) | |
6061 (skip-syntax-forward " ")) | |
6062 ;; Return arguments | |
6063 (vector (nreverse sigs-out) | |
6064 (nreverse sigs-inout) | |
6065 (nreverse sigs-in) | |
6066 (nreverse sigs-wire) | |
6067 (nreverse sigs-reg) | |
6068 (nreverse sigs-assign) | |
6069 (nreverse sigs-const) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6070 (nreverse sigs-gparam))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6071 |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6072 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6073 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6074 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6075 ;; - we want a error when we are debugging this code if they are refed. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6076 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6077 (defvar sigs-inout) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6078 (defvar sigs-out)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6079 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6080 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6081 (defsubst verilog-modi-get-decls (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6082 (verilog-modi-cache-results modi 'verilog-read-decls)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6083 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6084 (defsubst verilog-modi-get-sub-decls (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6085 (verilog-modi-cache-results modi 'verilog-read-sub-decls)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6086 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6087 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6088 ;; Signal reading for given module |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6089 ;; Note these all take modi's - as returned from the |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6090 ;; verilog-modi-current function. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6091 (defsubst verilog-modi-get-outputs (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6092 (aref (verilog-modi-get-decls modi) 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6093 (defsubst verilog-modi-get-inouts (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6094 (aref (verilog-modi-get-decls modi) 1)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6095 (defsubst verilog-modi-get-inputs (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6096 (aref (verilog-modi-get-decls modi) 2)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6097 (defsubst verilog-modi-get-wires (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6098 (aref (verilog-modi-get-decls modi) 3)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6099 (defsubst verilog-modi-get-regs (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6100 (aref (verilog-modi-get-decls modi) 4)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6101 (defsubst verilog-modi-get-assigns (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6102 (aref (verilog-modi-get-decls modi) 5)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6103 (defsubst verilog-modi-get-consts (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6104 (aref (verilog-modi-get-decls modi) 6)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6105 (defsubst verilog-modi-get-gparams (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6106 (aref (verilog-modi-get-decls modi) 7)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6107 (defsubst verilog-modi-get-sub-outputs (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6108 (aref (verilog-modi-get-sub-decls modi) 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6109 (defsubst verilog-modi-get-sub-inouts (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6110 (aref (verilog-modi-get-sub-decls modi) 1)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6111 (defsubst verilog-modi-get-sub-inputs (modi) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6112 (aref (verilog-modi-get-sub-decls modi) 2)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6113 |
79545 | 6114 |
6115 (defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6116 "For verilog-read-sub-decls-line, add a signal." |
79545 | 6117 (let (portdata) |
6118 (when sig | |
6119 (setq port (verilog-symbol-detick-denumber port)) | |
6120 (setq sig (verilog-symbol-detick-denumber sig)) | |
6121 (if sig (setq sig (verilog-string-replace-matches "^[---+~!|&]+" "" nil nil sig))) | |
6122 (if vec (setq vec (verilog-symbol-detick-denumber vec))) | |
6123 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) | |
6124 (unless (or (not sig) | |
6125 (equal sig "")) ;; Ignore .foo(1'b1) assignments | |
6126 (cond ((setq portdata (assoc port (verilog-modi-get-inouts submodi))) | |
6127 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil | |
6128 (verilog-sig-signed portdata) | |
6129 (verilog-sig-type portdata) | |
6130 multidim) | |
6131 sigs-inout))) | |
6132 ((setq portdata (assoc port (verilog-modi-get-outputs submodi))) | |
6133 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil | |
6134 (verilog-sig-signed portdata) | |
6135 (verilog-sig-type portdata) | |
6136 multidim) | |
6137 sigs-out))) | |
6138 ((setq portdata (assoc port (verilog-modi-get-inputs submodi))) | |
6139 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil | |
6140 (verilog-sig-signed portdata) | |
6141 (verilog-sig-type portdata) | |
6142 multidim) | |
6143 sigs-in))) | |
6144 ;; (t -- warning pin isn't defined.) ; Leave for lint tool | |
6145 ))))) | |
6146 | |
6147 (defun verilog-read-sub-decls-line (submodi comment) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6148 "For read-sub-decls, read lines of port defs until none match anymore. |
79545 | 6149 Return the list of signals found, using submodi to look up each port." |
6150 (let (done port sig vec multidim) | |
6151 (save-excursion | |
6152 (forward-line 1) | |
6153 (while (not done) | |
6154 ;; Get port name | |
6155 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*") | |
6156 (setq port (match-string 1)) | |
6157 (goto-char (match-end 0))) | |
6158 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") | |
6159 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space | |
6160 (goto-char (match-end 0))) | |
6161 ((looking-at "\\s-*\\.[^(]*(") | |
6162 (setq port nil) ;; skip this line | |
6163 (goto-char (match-end 0))) | |
6164 (t | |
6165 (setq port nil done t))) ;; Unknown, ignore rest of line | |
6166 ;; Get signal name | |
6167 (when port | |
6168 (setq multidim nil) | |
6169 (cond ((looking-at "\\(\\\\[^ \t\n\f]*\\)\\s-*)") | |
6170 (setq sig (concat (match-string 1) " ") ;; escaped id's need trailing space | |
6171 vec nil)) | |
6172 ; We intentionally ignore (non-escaped) signals with .s in them | |
6173 ; this prevents AUTOWIRE etc from noticing hierarchical sigs. | |
6174 ((looking-at "\\([^[({).]*\\)\\s-*)") | |
6175 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6176 vec nil)) | |
6177 ((looking-at "\\([^[({).]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)") | |
6178 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6179 vec (match-string 2))) | |
6180 ((looking-at "\\([^[({).]*\\)\\s-*/\\*\\(\\[[^*]+\\]\\)\\*/\\s-*)") | |
6181 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6182 vec nil) | |
6183 (let ((parse (match-string 2))) | |
6184 (while (string-match "^\\(\\[[^]]+\\]\\)\\(.*\\)$" parse) | |
6185 (when vec (setq multidim (cons vec multidim))) | |
6186 (setq vec (match-string 1 parse)) | |
6187 (setq parse (match-string 2 parse))))) | |
6188 ((looking-at "{\\(.*\\)}.*\\s-*)") | |
6189 (let ((mlst (split-string (match-string 1) ",")) | |
6190 mstr) | |
6191 (while (setq mstr (pop mlst)) | |
6192 ;;(unless noninteractive (message "sig: %s " mstr)) | |
6193 (cond | |
6194 ((string-match "\\(['`a-zA-Z0-9_$]+\\)\\s-*$" mstr) | |
6195 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6196 vec nil) | |
6197 ;;(unless noninteractive (message "concat sig1: %s %s" mstr (match-string 1 mstr))) | |
6198 ) | |
6199 ((string-match "\\([^[({).]+\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*" mstr) | |
6200 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6201 vec (match-string 2 mstr)) | |
6202 ;;(unless noninteractive (message "concat sig2: '%s' '%s' '%s'" mstr (match-string 1 mstr) (match-string 2 mstr))) | |
6203 ) | |
6204 (t | |
6205 (setq sig nil))) | |
6206 ;; Process signals | |
6207 (verilog-read-sub-decls-sig submodi comment port sig vec multidim)))) | |
6208 (t | |
6209 (setq sig nil))) | |
6210 ;; Process signals | |
6211 (verilog-read-sub-decls-sig submodi comment port sig vec multidim)) | |
6212 ;; | |
6213 (forward-line 1))))) | |
6214 | |
6215 (defun verilog-read-sub-decls () | |
6216 "Internally parse signals going to modules under this module. | |
6217 Return a array of [ outputs inouts inputs ] signals for modules that are | |
6218 instantiated in this module. For example if declare A A (.B(SIG)) and SIG | |
6219 is a output, then SIG will be included in the list. | |
6220 | |
6221 This only works on instantiations created with /*AUTOINST*/ converted by | |
6222 \\[verilog-auto-inst]. Otherwise, it would have to read in the whole | |
6223 component library to determine connectivity of the design. | |
6224 | |
6225 One work around for this problem is to manually create // Inputs and // | |
6226 Outputs comments above subcell signals, for example: | |
6227 | |
6228 module1 instance1x ( | |
6229 // Outputs | |
6230 .out (out), | |
6231 // Inputs | |
6232 .in (in));" | |
6233 (save-excursion | |
6234 (let ((end-mod-point (verilog-get-end-of-defun t)) | |
6235 st-point end-inst-point | |
6236 ;; below 3 modified by verilog-read-sub-decls-line | |
6237 sigs-out sigs-inout sigs-in) | |
6238 (verilog-beg-of-defun) | |
6239 (while (re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t) | |
6240 (save-excursion | |
6241 (goto-char (match-beginning 0)) | |
6242 (unless (verilog-inside-comment-p) | |
6243 ;; Attempt to snarf a comment | |
6244 (let* ((submod (verilog-read-inst-module)) | |
6245 (inst (verilog-read-inst-name)) | |
6246 (comment (concat inst " of " submod ".v")) submodi) | |
6247 (when (setq submodi (verilog-modi-lookup submod t)) | |
6248 ;; This could have used a list created by verilog-auto-inst | |
6249 ;; However I want it to be runnable even on user's manually added signals | |
6250 (verilog-backward-open-paren) | |
6251 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) | |
6252 st-point (point)) | |
6253 (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t) | |
6254 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-out | |
6255 (goto-char st-point) | |
6256 (while (re-search-forward "\\s *// Inouts" end-inst-point t) | |
6257 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-inout | |
6258 (goto-char st-point) | |
6259 (while (re-search-forward "\\s *// Inputs" end-inst-point t) | |
6260 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-in | |
6261 ))))) | |
6262 ;; Combine duplicate bits | |
6263 ;;(setq rr (vector sigs-out sigs-inout sigs-in)) | |
6264 (vector (verilog-signals-combine-bus (nreverse sigs-out)) | |
6265 (verilog-signals-combine-bus (nreverse sigs-inout)) | |
6266 (verilog-signals-combine-bus (nreverse sigs-in)))))) | |
6267 | |
6268 (defun verilog-read-inst-pins () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6269 "Return a array of [ pins ] for the current instantiation at point. |
79545 | 6270 For example if declare A A (.B(SIG)) then B will be included in the list." |
6271 (save-excursion | |
6272 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point | |
6273 pins pin) | |
6274 (verilog-backward-open-paren) | |
6275 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) | |
6276 (setq pin (match-string 1)) | |
6277 (unless (verilog-inside-comment-p) | |
6278 (setq pins (cons (list pin) pins)) | |
6279 (when (looking-at "(") | |
6280 (forward-sexp 1)))) | |
6281 (vector pins)))) | |
6282 | |
6283 (defun verilog-read-arg-pins () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6284 "Return a array of [ pins ] for the current argument declaration at point." |
79545 | 6285 (save-excursion |
6286 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point | |
6287 pins pin) | |
6288 (verilog-backward-open-paren) | |
6289 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) | |
6290 (setq pin (match-string 1)) | |
6291 (unless (verilog-inside-comment-p) | |
6292 (setq pins (cons (list pin) pins)))) | |
6293 (vector pins)))) | |
6294 | |
6295 (defun verilog-read-auto-constants (beg end-mod-point) | |
6296 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT." | |
6297 ;; Insert new | |
6298 (save-excursion | |
6299 (let (sig-list tpl-end-pt) | |
6300 (goto-char beg) | |
6301 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t) | |
6302 (if (not (looking-at "\\s *(")) | |
6303 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text))) | |
6304 (search-forward "(" end-mod-point) | |
6305 (setq tpl-end-pt (save-excursion | |
6306 (backward-char 1) | |
6307 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6308 (backward-char 1) | |
6309 (point))) | |
6310 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) | |
6311 (setq sig-list (cons (list (match-string 1) nil nil) sig-list)))) | |
6312 sig-list))) | |
6313 | |
6314 (defun verilog-read-auto-lisp (start end) | |
6315 "Look for and evaluate a AUTO_LISP between START and END." | |
6316 (save-excursion | |
6317 (goto-char start) | |
6318 (while (re-search-forward "\\<AUTO_LISP(" end t) | |
6319 (backward-char) | |
6320 (let* ((beg-pt (prog1 (point) | |
6321 (forward-sexp 1))) ;; Closing paren | |
6322 (end-pt (point))) | |
6323 (eval-region beg-pt end-pt nil))))) | |
6324 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6325 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6326 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6327 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6328 ;; - we want a error when we are debugging this code if they are refed. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6329 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6330 (defvar sigs-out) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6331 (defvar got-sig) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6332 (defvar got-rvalue) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6333 (defvar uses-delayed) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6334 (defvar vector-skip-list)) |
79545 | 6335 |
6336 (defun verilog-read-always-signals-recurse | |
6337 (exit-keywd rvalue ignore-next) | |
6338 "Recursive routine for parentheses/bracket matching. | |
6339 EXIT-KEYWD is expression to stop at, nil if top level. | |
6340 RVALUE is true if at right hand side of equal. | |
6341 IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |
6342 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue | |
6343 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check) | |
6344 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next)))) | |
6345 (while (not (or (eobp) gotend)) | |
6346 (cond | |
6347 ((looking-at "//") | |
6348 (search-forward "\n")) | |
6349 ((looking-at "/\\*") | |
6350 (or (search-forward "*/") | |
6351 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6352 ((looking-at "(\\*") | |
6353 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6354 (search-forward "*)") | |
6355 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6356 (t (setq keywd (buffer-substring-no-properties | |
6357 (point) | |
6358 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6359 (forward-char 1)) | |
6360 (point))) | |
6361 sig-last-tolk sig-tolk | |
6362 sig-tolk nil) | |
6363 ;;(if dbg (setq dbg (concat dbg (format "\tPt=%S %S\trv=%S in=%S ee=%S\n" (point) keywd rvalue ignore-next end-else-check)))) | |
6364 (cond | |
6365 ((equal keywd "\"") | |
6366 (or (re-search-forward "[^\\]\"" nil t) | |
6367 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6368 ;; else at top level loop, keep parsing | |
6369 ((and end-else-check (equal keywd "else")) | |
6370 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd)))) | |
6371 ;; no forward movement, want to see else in lower loop | |
6372 (setq end-else-check nil)) | |
6373 ;; End at top level loop | |
6374 ((and end-else-check (looking-at "[^ \t\n\f]")) | |
6375 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd)))) | |
6376 (setq gotend t)) | |
6377 ;; Final statement? | |
6378 ((and exit-keywd (equal keywd exit-keywd)) | |
6379 (setq gotend t) | |
6380 (forward-char (length keywd))) | |
6381 ;; Standard tokens... | |
6382 ((equal keywd ";") | |
6383 (setq ignore-next nil rvalue semi-rvalue) | |
6384 ;; Final statement at top level loop? | |
6385 (when (not exit-keywd) | |
6386 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd)))) | |
6387 (setq end-else-check t)) | |
6388 (forward-char 1)) | |
6389 ((equal keywd "'") | |
6390 (if (looking-at "'s?[hdxbo][0-9a-fA-F_xz? \t]*") | |
6391 (goto-char (match-end 0)) | |
6392 (forward-char 1))) | |
6393 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z | |
6394 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next | |
6395 (setq ignore-next nil rvalue nil)) | |
6396 ((equal "?" exit-keywd) ;; x?y:z rvalue | |
6397 ) ;; NOP | |
6398 (got-sig ;; label: statement | |
6399 (setq ignore-next nil rvalue semi-rvalue got-sig nil)) | |
6400 ((not rvalue) ;; begin label | |
6401 (setq ignore-next t rvalue nil))) | |
6402 (forward-char 1)) | |
6403 ((equal keywd "=") | |
6404 (if (eq (char-before) ?< ) | |
6405 (setq uses-delayed 1)) | |
6406 (setq ignore-next nil rvalue t) | |
6407 (forward-char 1)) | |
6408 ((equal keywd "?") | |
6409 (forward-char 1) | |
6410 (verilog-read-always-signals-recurse ":" rvalue nil)) | |
6411 ((equal keywd "[") | |
6412 (forward-char 1) | |
6413 (verilog-read-always-signals-recurse "]" t nil)) | |
6414 ((equal keywd "(") | |
6415 (forward-char 1) | |
6416 (cond (sig-last-tolk ;; Function call; zap last signal | |
6417 (setq got-sig nil))) | |
6418 (cond ((equal last-keywd "for") | |
6419 (verilog-read-always-signals-recurse ";" nil nil) | |
6420 (verilog-read-always-signals-recurse ";" t nil) | |
6421 (verilog-read-always-signals-recurse ")" nil nil)) | |
6422 (t (verilog-read-always-signals-recurse ")" t nil)))) | |
6423 ((equal keywd "begin") | |
6424 (skip-syntax-forward "w_") | |
6425 (verilog-read-always-signals-recurse "end" nil nil) | |
6426 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd)))) | |
6427 (setq ignore-next nil rvalue semi-rvalue) | |
6428 (if (not exit-keywd) (setq end-else-check t))) | |
6429 ((or (equal keywd "case") | |
6430 (equal keywd "casex") | |
6431 (equal keywd "casez")) | |
6432 (skip-syntax-forward "w_") | |
6433 (verilog-read-always-signals-recurse "endcase" t nil) | |
6434 (setq ignore-next nil rvalue semi-rvalue) | |
6435 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end | |
6436 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent | |
6437 (cond ((or (equal keywd "`ifdef") | |
6438 (equal keywd "`ifndef")) | |
6439 (setq ignore-next t)) | |
6440 ((or ignore-next | |
6441 (member keywd verilog-keywords) | |
6442 (string-match "^\\$" keywd)) ;; PLI task | |
6443 (setq ignore-next nil)) | |
6444 (t | |
6445 (setq keywd (verilog-symbol-detick-denumber keywd)) | |
6446 (when got-sig | |
6447 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6448 (setq sigs-out (cons got-sig sigs-out))) | |
6449 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6450 ) | |
6451 (setq got-rvalue rvalue | |
6452 got-sig (if (or (not keywd) | |
6453 (assoc keywd (if got-rvalue sigs-in sigs-out))) | |
6454 nil (list keywd nil nil)) | |
6455 sig-tolk t))) | |
6456 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6457 (t | |
6458 (forward-char 1))) | |
6459 ;; End of non-comment token | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6460 (setq last-keywd keywd))) |
79545 | 6461 (skip-syntax-forward " ")) |
6462 ;; Append the final pending signal | |
6463 (when got-sig | |
6464 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6465 (setq sigs-out (cons got-sig sigs-out))) | |
6466 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6467 (setq got-sig nil)) | |
6468 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd)))) | |
6469 )) | |
6470 | |
6471 (defun verilog-read-always-signals () | |
6472 "Parse always block at point and return list of (outputs inout inputs)." | |
6473 ;; Insert new | |
6474 (save-excursion | |
6475 (let* (;;(dbg "") | |
6476 sigs-in sigs-out | |
6477 uses-delayed) ;; Found signal/rvalue; push if not function | |
6478 (search-forward ")") | |
6479 (verilog-read-always-signals-recurse nil nil nil) | |
6480 ;;(if dbg (save-excursion (set-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg ""))) | |
6481 ;; Return what was found | |
6482 (list sigs-out nil sigs-in uses-delayed)))) | |
6483 | |
6484 (defun verilog-read-instants () | |
6485 "Parse module at point and return list of ( ( file instance ) ... )." | |
6486 (verilog-beg-of-defun) | |
6487 (let* ((end-mod-point (verilog-get-end-of-defun t)) | |
6488 (state nil) | |
6489 (instants-list nil)) | |
6490 (save-excursion | |
6491 (while (< (point) end-mod-point) | |
6492 ;; Stay at level 0, no comments | |
6493 (while (progn | |
6494 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil)) | |
6495 (or (> (car state) 0) ; in parens | |
6496 (nth 5 state) ; comment | |
6497 )) | |
6498 (forward-line 1)) | |
6499 (beginning-of-line) | |
6500 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(") | |
6501 ;;(if (looking-at "^\\(.+\\)$") | |
6502 (let ((module (match-string 1)) | |
6503 (instant (match-string 2))) | |
6504 (if (not (member module verilog-keywords)) | |
6505 (setq instants-list (cons (list module instant) instants-list))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6506 (forward-line 1))) |
79545 | 6507 instants-list)) |
6508 | |
6509 | |
6510 (defun verilog-read-auto-template (module) | |
6511 "Look for a auto_template for the instantiation of the given MODULE. | |
6512 If found returns the signal name connections. Return REGEXP and | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6513 list of ( (signal_name connection_name)... )" |
79545 | 6514 (save-excursion |
6515 ;; Find beginning | |
6516 (let ((tpl-regexp "\\([0-9]+\\)") | |
6517 (lineno 0) | |
6518 (templateno 0) | |
6519 tpl-sig-list tpl-wild-list tpl-end-pt rep) | |
6520 (cond ((or | |
6521 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t) | |
6522 (progn | |
6523 (goto-char (point-min)) | |
6524 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t))) | |
6525 (goto-char (match-end 0)) | |
6526 ;; Parse "REGEXP" | |
6527 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST | |
6528 (when (looking-at "\\s-*\"\\([^\"]*)\\)\"") | |
6529 (setq tpl-regexp (match-string 1)) | |
6530 (goto-char (match-end 0))) | |
6531 (search-forward "(") | |
6532 ;; Parse lines in the template | |
6533 (when verilog-auto-inst-template-numbers | |
6534 (save-excursion | |
6535 (goto-char (point-min)) | |
6536 (while (search-forward "AUTO_TEMPLATE" nil t) | |
6537 (setq templateno (1+ templateno))))) | |
6538 (setq tpl-end-pt (save-excursion | |
6539 (backward-char 1) | |
6540 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6541 (backward-char 1) | |
6542 (point))) | |
6543 ;; | |
6544 (while (< (point) tpl-end-pt) | |
6545 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
6546 (setq tpl-sig-list (cons (list | |
6547 (match-string-no-properties 1) | |
6548 (match-string-no-properties 2) | |
6549 templateno lineno) | |
6550 tpl-sig-list)) | |
6551 (goto-char (match-end 0))) | |
6552 ;; Regexp form?? | |
6553 ((looking-at | |
6554 ;; Regexp bug in xemacs disallows ][ inside [], and wants + last | |
6555 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
6556 (setq rep (match-string-no-properties 3)) | |
6557 (goto-char (match-end 0)) | |
6558 (setq tpl-wild-list | |
6559 (cons (list | |
6560 (concat "^" | |
6561 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil | |
6562 (match-string 1)) | |
6563 "$") | |
6564 rep | |
6565 templateno lineno) | |
6566 tpl-wild-list))) | |
6567 ((looking-at "[ \t\f]+") | |
6568 (goto-char (match-end 0))) | |
6569 ((looking-at "\n") | |
6570 (setq lineno (1+ lineno)) | |
6571 (goto-char (match-end 0))) | |
6572 ((looking-at "//") | |
6573 (search-forward "\n")) | |
6574 ((looking-at "/\\*") | |
6575 (forward-char 2) | |
6576 (or (search-forward "*/") | |
6577 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6578 (t | |
6579 (error "%s: AUTO_TEMPLATE parsing error: %s" | |
6580 (verilog-point-text) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6581 (progn (looking-at ".*$") (match-string 0)))))) |
79545 | 6582 ;; Return |
6583 (vector tpl-regexp | |
6584 (list tpl-sig-list tpl-wild-list))) | |
6585 ;; If no template found | |
6586 (t (vector tpl-regexp nil)))))) | |
6587 ;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry")) | |
6588 | |
6589 (defun verilog-set-define (defname defvalue &optional buffer enumname) | |
6590 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER. | |
6591 Optionally associate it with the specified enumeration ENUMNAME." | |
6592 (save-excursion | |
6593 (set-buffer (or buffer (current-buffer))) | |
6594 (let ((mac (intern (concat "vh-" defname)))) | |
6595 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6596 ;; Need to define to a constant if no value given | |
6597 (set (make-variable-buffer-local mac) | |
6598 (if (equal defvalue "") "1" defvalue))) | |
6599 (if enumname | |
6600 (let ((enumvar (intern (concat "venum-" enumname)))) | |
6601 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6602 (make-variable-buffer-local enumvar) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6603 (add-to-list enumvar defname))))) |
79545 | 6604 |
6605 (defun verilog-read-defines (&optional filename recurse subcall) | |
6606 "Read `defines and parameters for the current file, or optional FILENAME. | |
6607 If the filename is provided, `verilog-library-flags' will be used to | |
6608 resolve it. If optional RECURSE is non-nil, recurse through `includes. | |
6609 | |
6610 Parameters must be simple assignments to constants, or have their own | |
6611 \"parameter\" label rather than a list of parameters. Thus: | |
6612 | |
6613 parameter X = 5, Y = 10; // Ok | |
6614 parameter X = {1'b1, 2'h2}; // Ok | |
6615 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines | |
6616 | |
6617 Defines must be simple text substitutions, one on a line, starting | |
6618 at the beginning of the line. Any ifdefs or multiline comments around the | |
6619 define are ignored. | |
6620 | |
6621 Defines are stored inside Emacs variables using the name vh-{definename}. | |
6622 | |
6623 This function is useful for setting vh-* variables. The file variables | |
6624 feature can be used to set defines that `verilog-mode' can see; put at the | |
6625 *END* of your file something like: | |
6626 | |
6627 // Local Variables: | |
6628 // vh-macro:\"macro_definition\" | |
6629 // End: | |
6630 | |
6631 If macros are defined earlier in the same file and you want their values, | |
6632 you can read them automatically (provided `enable-local-eval' is on): | |
6633 | |
6634 // Local Variables: | |
6635 // eval:(verilog-read-defines) | |
6636 // eval:(verilog-read-defines \"group_standard_includes.v\") | |
6637 // End: | |
6638 | |
6639 Note these are only read when the file is first visited, you must use | |
6640 \\[find-alternate-file] RET to have these take effect after editing them! | |
6641 | |
6642 If you want to disable the \"Process `eval' or hook local variables\" | |
6643 warning message, you need to add to your .emacs file: | |
6644 | |
6645 (setq enable-local-eval t)" | |
6646 (let ((origbuf (current-buffer))) | |
6647 (save-excursion | |
6648 (unless subcall (verilog-getopt-flags)) | |
6649 (when filename | |
6650 (let ((fns (verilog-library-filenames filename (buffer-file-name)))) | |
6651 (if fns | |
6652 (set-buffer (find-file-noselect (car fns))) | |
6653 (error (concat (verilog-point-text) | |
6654 ": Can't find verilog-read-defines file: " filename))))) | |
6655 (when recurse | |
6656 (goto-char (point-min)) | |
6657 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6658 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1)))) | |
6659 (unless (verilog-inside-comment-p) | |
6660 (verilog-read-defines inc recurse t))))) | |
6661 ;; Read `defines | |
6662 ;; note we don't use verilog-re... it's faster this way, and that | |
6663 ;; function has problems when comments are at the end of the define | |
6664 (goto-char (point-min)) | |
6665 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t) | |
6666 (let ((defname (match-string-no-properties 1)) | |
6667 (defvalue (match-string-no-properties 2))) | |
6668 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue)) | |
6669 (verilog-set-define defname defvalue origbuf))) | |
6670 ;; Hack: Read parameters | |
6671 (goto-char (point-min)) | |
6672 (while (re-search-forward | |
6673 "^\\s-*\\(parameter\\|localparam\\)\\(\\(\\s-*\\[[^]]*\\]\\|\\)\\s-+\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\|\\)\\s-*" nil t) | |
6674 (let ((var (match-string-no-properties 4)) | |
6675 (val (match-string-no-properties 5)) | |
6676 enumname) | |
6677 ;; The primary way of getting defines is verilog-read-decls | |
6678 ;; However, that isn't called yet for included files, so we'll add another scheme | |
6679 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6680 (setq enumname (match-string-no-properties 1))) | |
6681 (if var | |
6682 (verilog-set-define var val origbuf enumname)) | |
6683 (forward-comment 999) | |
6684 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | |
6685 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) | |
6686 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6687 (forward-comment 999))))))) |
79545 | 6688 |
6689 (defun verilog-read-includes () | |
6690 "Read `includes for the current file. | |
6691 This will find all of the `includes which are at the beginning of lines, | |
6692 ignoring any ifdefs or multiline comments around them. | |
6693 `verilog-read-defines' is then performed on the current and each included | |
6694 file. | |
6695 | |
6696 It is often useful put at the *END* of your file something like: | |
6697 | |
6698 // Local Variables: | |
6699 // eval:(verilog-read-defines) | |
6700 // eval:(verilog-read-includes) | |
6701 // End: | |
6702 | |
6703 Note includes are only read when the file is first visited, you must use | |
6704 \\[find-alternate-file] RET to have these take effect after editing them! | |
6705 | |
6706 It is good to get in the habit of including all needed files in each .v | |
6707 file that needs it, rather than waiting for compile time. This will aid | |
6708 this process, Verilint, and readability. To prevent defining the same | |
6709 variable over and over when many modules are compiled together, put a test | |
6710 around the inside each include file: | |
6711 | |
6712 foo.v (a include): | |
6713 `ifdef _FOO_V // include if not already included | |
6714 `else | |
6715 `define _FOO_V | |
6716 ... contents of file | |
6717 `endif // _FOO_V" | |
6718 ;;slow: (verilog-read-defines nil t)) | |
6719 (save-excursion | |
6720 (verilog-getopt-flags) | |
6721 (goto-char (point-min)) | |
6722 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6723 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1)))) | |
6724 (verilog-read-defines inc nil t))))) | |
6725 | |
6726 (defun verilog-read-signals (&optional start end) | |
6727 "Return a simple list of all possible signals in the file. | |
6728 Bounded by optional region from START to END. Overly aggressive but fast. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6729 Some macros and such are also found and included. For dinotrace.el" |
79545 | 6730 (let (sigs-all keywd) |
6731 (progn;save-excursion | |
6732 (goto-char (or start (point-min))) | |
6733 (setq end (or end (point-max))) | |
6734 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t) | |
6735 (forward-char -1) | |
6736 (cond | |
6737 ((looking-at "//") | |
6738 (search-forward "\n")) | |
6739 ((looking-at "/\\*") | |
6740 (search-forward "*/")) | |
6741 ((looking-at "(\\*") | |
6742 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6743 (search-forward "*)"))) | |
6744 ((eq ?\" (following-char)) | |
6745 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first | |
6746 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") | |
6747 (goto-char (match-end 0)) | |
6748 (setq keywd (match-string-no-properties 1)) | |
6749 (or (member keywd verilog-keywords) | |
6750 (member keywd sigs-all) | |
6751 (setq sigs-all (cons keywd sigs-all)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6752 (t (forward-char 1)))) |
79545 | 6753 ;; Return list |
6754 sigs-all))) | |
6755 | |
6756 ;; | |
6757 ;; Argument file parsing | |
6758 ;; | |
6759 | |
6760 (defun verilog-getopt (arglist) | |
6761 "Parse -f, -v etc arguments in ARGLIST list or string." | |
6762 (unless (listp arglist) (setq arglist (list arglist))) | |
6763 (let ((space-args '()) | |
6764 arg next-param) | |
6765 ;; Split on spaces, so users can pass whole command lines | |
6766 (while arglist | |
6767 (setq arg (car arglist) | |
6768 arglist (cdr arglist)) | |
6769 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg) | |
6770 (setq space-args (append space-args | |
6771 (list (match-string-no-properties 1 arg)))) | |
6772 (setq arg (match-string 2 arg)))) | |
6773 ;; Parse arguments | |
6774 (while space-args | |
6775 (setq arg (car space-args) | |
6776 space-args (cdr space-args)) | |
6777 (cond | |
6778 ;; Need another arg | |
6779 ((equal arg "-f") | |
6780 (setq next-param arg)) | |
6781 ((equal arg "-v") | |
6782 (setq next-param arg)) | |
6783 ((equal arg "-y") | |
6784 (setq next-param arg)) | |
6785 ;; +libext+(ext1)+(ext2)... | |
6786 ((string-match "^\\+libext\\+\\(.*\\)" arg) | |
6787 (setq arg (match-string 1 arg)) | |
6788 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg) | |
6789 (verilog-add-list-unique `verilog-library-extensions | |
6790 (match-string 1 arg)) | |
6791 (setq arg (match-string 2 arg)))) | |
6792 ;; | |
6793 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val | |
6794 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine | |
6795 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val | |
6796 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define | |
6797 (verilog-set-define (match-string 1 arg) (match-string 2 arg))) | |
6798 ;; | |
6799 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir | |
6800 (string-match "^-I\\(.*\\)" arg)) ;; -Idir | |
6801 (verilog-add-list-unique `verilog-library-directories | |
6802 (match-string 1 arg))) | |
6803 ;; Ignore | |
6804 ((equal "+librescan" arg)) | |
6805 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine | |
6806 ;; Second parameters | |
6807 ((equal next-param "-f") | |
6808 (setq next-param nil) | |
6809 (verilog-getopt-file arg)) | |
6810 ((equal next-param "-v") | |
6811 (setq next-param nil) | |
6812 (verilog-add-list-unique `verilog-library-files arg)) | |
6813 ((equal next-param "-y") | |
6814 (setq next-param nil) | |
6815 (verilog-add-list-unique `verilog-library-directories arg)) | |
6816 ;; Filename | |
6817 ((string-match "^[^-+]" arg) | |
6818 (verilog-add-list-unique `verilog-library-files arg)) | |
6819 ;; Default - ignore; no warning | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6820 )))) |
79545 | 6821 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
6822 | |
6823 (defun verilog-getopt-file (filename) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6824 "Read verilog options from the specified FILENAME." |
79545 | 6825 (save-excursion |
6826 (let ((fns (verilog-library-filenames filename (buffer-file-name))) | |
6827 (orig-buffer (current-buffer)) | |
6828 line) | |
6829 (if fns | |
6830 (set-buffer (find-file-noselect (car fns))) | |
6831 (error (concat (verilog-point-text) | |
6832 "Can't find verilog-getopt-file -f file: " filename))) | |
6833 (goto-char (point-min)) | |
6834 (while (not (eobp)) | |
6835 (setq line (buffer-substring (point) | |
6836 (save-excursion (end-of-line) (point)))) | |
6837 (forward-line 1) | |
6838 (when (string-match "//" line) | |
6839 (setq line (substring line 0 (match-beginning 0)))) | |
6840 (save-excursion | |
6841 (set-buffer orig-buffer) ; Variables are buffer-local, so need right context. | |
6842 (verilog-getopt line)))))) | |
6843 | |
6844 (defun verilog-getopt-flags () | |
6845 "Convert `verilog-library-flags' into standard library variables." | |
6846 ;; If the flags are local, then all the outputs should be local also | |
6847 (when (local-variable-p `verilog-library-flags (current-buffer)) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6848 (mapc 'make-local-variable '(verilog-library-extensions |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6849 verilog-library-directories |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6850 verilog-library-files |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6851 verilog-library-flags))) |
79545 | 6852 ;; Allow user to customize |
6853 (run-hooks 'verilog-before-getopt-flags-hook) | |
6854 ;; Process arguments | |
6855 (verilog-getopt verilog-library-flags) | |
6856 ;; Allow user to customize | |
6857 (run-hooks 'verilog-getopt-flags-hook)) | |
6858 | |
6859 (defun verilog-add-list-unique (varref object) | |
6860 "Append to VARREF list the given OBJECT, | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6861 unless it is already a member of the variable's list" |
79545 | 6862 (unless (member object (symbol-value varref)) |
6863 (set varref (append (symbol-value varref) (list object)))) | |
6864 varref) | |
6865 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l) | |
6866 | |
6867 | |
6868 ;; | |
6869 ;; Module name lookup | |
6870 ;; | |
6871 | |
6872 (defun verilog-module-inside-filename-p (module filename) | |
6873 "Return point if MODULE is specified inside FILENAME, else nil. | |
6874 Allows version control to check out the file if need be." | |
6875 (and (or (file-exists-p filename) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6876 (and (fboundp 'vc-backend) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6877 (vc-backend filename))) |
79545 | 6878 (let (pt) |
6879 (save-excursion | |
6880 (set-buffer (find-file-noselect filename)) | |
6881 (goto-char (point-min)) | |
6882 (while (and | |
6883 ;; It may be tempting to look for verilog-defun-re, don't, it slows things down a lot! | |
6884 (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
6885 (verilog-re-search-forward-quick "[(;]" nil t)) | |
6886 (if (equal module (verilog-read-module-name)) | |
6887 (setq pt (point)))) | |
6888 pt)))) | |
6889 | |
6890 (defun verilog-is-number (symbol) | |
6891 "Return true if SYMBOL is number-like." | |
6892 (or (string-match "^[0-9 \t:]+$" symbol) | |
6893 (string-match "^[---]*[0-9]+$" symbol) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6894 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
79545 | 6895 |
6896 (defun verilog-symbol-detick (symbol wing-it) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6897 "Return a expanded SYMBOL name without any defines. |
79545 | 6898 If the variable vh-{symbol} is defined, return that value. |
6899 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | |
6900 (while (and symbol (string-match "^`" symbol)) | |
6901 (setq symbol (substring symbol 1)) | |
6902 (setq symbol | |
6903 (if (boundp (intern (concat "vh-" symbol))) | |
6904 ;; Emacs has a bug where boundp on a buffer-local | |
6905 ;; variable in only one buffer returns t in another. | |
6906 ;; This can confuse, so check for nil. | |
6907 (let ((val (eval (intern (concat "vh-" symbol))))) | |
6908 (if (eq val nil) | |
6909 (if wing-it symbol nil) | |
6910 val)) | |
6911 (if wing-it symbol nil)))) | |
6912 symbol) | |
6913 ;;(verilog-symbol-detick "`mod" nil) | |
6914 | |
6915 (defun verilog-symbol-detick-denumber (symbol) | |
6916 "Return SYMBOL with defines converted and any numbers dropped to nil." | |
6917 (when (string-match "^`" symbol) | |
6918 ;; This only will work if the define is a simple signal, not | |
6919 ;; something like a[b]. Sorry, it should be substituted into the parser | |
6920 (setq symbol | |
6921 (verilog-string-replace-matches | |
6922 "\[[^0-9: \t]+\]" "" nil nil | |
6923 (or (verilog-symbol-detick symbol nil) | |
6924 (if verilog-auto-sense-defines-constant | |
6925 "0" | |
6926 symbol))))) | |
6927 (if (verilog-is-number symbol) | |
6928 nil | |
6929 symbol)) | |
6930 | |
6931 (defun verilog-symbol-detick-text (text) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
6932 "Return TEXT with any without any known defines. |
79545 | 6933 If the variable vh-{symbol} is defined, substitute that value." |
6934 (let ((ok t) symbol val) | |
6935 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text)) | |
6936 (setq symbol (match-string 1 text)) | |
6937 (message symbol) | |
6938 (cond ((and | |
6939 (boundp (intern (concat "vh-" symbol))) | |
6940 ;; Emacs has a bug where boundp on a buffer-local | |
6941 ;; variable in only one buffer returns t in another. | |
6942 ;; This can confuse, so check for nil. | |
6943 (setq val (eval (intern (concat "vh-" symbol))))) | |
6944 (setq text (replace-match val nil nil text))) | |
6945 (t (setq ok nil))))) | |
6946 text) | |
6947 ;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed")) | |
6948 | |
6949 (defun verilog-expand-dirnames (&optional dirnames) | |
6950 "Return a list of existing directories given a list of wildcarded DIRNAMES. | |
6951 Or, just the existing dirnames themselves if there are no wildcards." | |
6952 (interactive) | |
6953 (unless dirnames (error "`verilog-library-directories' should include at least '.'")) | |
6954 (setq dirnames (reverse dirnames)) ; not nreverse | |
6955 (let ((dirlist nil) | |
6956 pattern dirfile dirfiles dirname root filename rest) | |
6957 (while dirnames | |
6958 (setq dirname (substitute-in-file-name (car dirnames)) | |
6959 dirnames (cdr dirnames)) | |
6960 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root | |
6961 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *? | |
6962 "\\(.*\\)") ;; rest | |
6963 dirname) | |
6964 (setq root (match-string 1 dirname) | |
6965 filename (match-string 2 dirname) | |
6966 rest (match-string 3 dirname) | |
6967 pattern filename) | |
6968 ;; now replace those * and ? with .+ and . | |
6969 ;; use ^ and /> to get only whole file names | |
6970 ;;verilog-string-replace-matches | |
6971 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) | |
6972 pattern (verilog-string-replace-matches "[?]" "." nil nil pattern) | |
6973 | |
6974 ;; Unfortunately allows abc/*/rtl to match abc/rtl | |
6975 ;; because abc/.. shows up in dirfiles. Solutions welcome. | |
6976 dirfiles (if (file-directory-p root) ; Ignore version control external | |
6977 (directory-files root t pattern nil))) | |
6978 (while dirfiles | |
6979 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) | |
6980 dirfiles (cdr dirfiles)) | |
6981 (if (file-directory-p dirfile) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6982 (setq dirlist (cons dirfile dirlist))))) |
79545 | 6983 ;; Defaults |
6984 (t | |
6985 (if (file-directory-p dirname) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6986 (setq dirlist (cons dirname dirlist)))))) |
79545 | 6987 dirlist)) |
6988 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | |
6989 | |
6990 (defun verilog-library-filenames (filename current &optional check-ext) | |
6991 "Return a search path to find the given FILENAME name. | |
6992 Uses the CURRENT filename, `verilog-library-directories' and | |
6993 `verilog-library-extensions' variables to build the path. | |
6994 With optional CHECK-EXT also check `verilog-library-extensions'." | |
6995 (let ((ckdir (verilog-expand-dirnames verilog-library-directories)) | |
6996 fn outlist) | |
6997 (while ckdir | |
6998 (let ((ckext (if check-ext verilog-library-extensions `("")))) | |
6999 (while ckext | |
7000 (setq fn (expand-file-name | |
7001 (concat filename (car ckext)) | |
7002 (expand-file-name (car ckdir) (file-name-directory current)))) | |
7003 (if (file-exists-p fn) | |
7004 (setq outlist (cons fn outlist))) | |
7005 (setq ckext (cdr ckext)))) | |
7006 (setq ckdir (cdr ckdir))) | |
7007 (nreverse outlist))) | |
7008 | |
7009 (defun verilog-module-filenames (module current) | |
7010 "Return a search path to find the given MODULE name. | |
7011 Uses the CURRENT filename, `verilog-library-extensions', | |
7012 `verilog-library-directories' and `verilog-library-files' | |
7013 variables to build the path." | |
7014 ;; Return search locations for it | |
7015 (append (list current) ; first, current buffer | |
7016 (verilog-library-filenames module current t) | |
7017 verilog-library-files)) ; finally, any libraries | |
7018 | |
7019 ;; | |
7020 ;; Module Information | |
7021 ;; | |
7022 ;; Many of these functions work on "modi" a module information structure | |
7023 ;; A modi is: [module-name-string file-name begin-point] | |
7024 | |
7025 (defvar verilog-cache-enabled t | |
7026 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!") | |
7027 | |
7028 (defvar verilog-modi-cache-list nil | |
7029 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)... | |
7030 For speeding up verilog-modi-get-* commands. | |
7031 Buffer-local.") | |
7032 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7033 (make-variable-buffer-local 'verilog-modi-cache-list) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7034 |
79545 | 7035 (defvar verilog-modi-cache-preserve-tick nil |
7036 "Modification tick after which the cache is still considered valid. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7037 Use verilog-preserve-cache's to set") |
79545 | 7038 (defvar verilog-modi-cache-preserve-buffer nil |
7039 "Modification tick after which the cache is still considered valid. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7040 Use verilog-preserve-cache's to set") |
79545 | 7041 |
7042 (defun verilog-modi-current () | |
7043 "Return the modi structure for the module currently at point." | |
7044 (let* (name pt) | |
7045 ;; read current module's name | |
7046 (save-excursion | |
7047 (verilog-re-search-backward-quick verilog-defun-re nil nil) | |
7048 (verilog-re-search-forward-quick "(" nil nil) | |
7049 (setq name (verilog-read-module-name)) | |
7050 (setq pt (point))) | |
7051 ;; return | |
7052 (vector name (or (buffer-file-name) (current-buffer)) pt))) | |
7053 | |
7054 (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.") | |
7055 (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.") | |
7056 (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.") | |
7057 (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.") | |
7058 | |
7059 (defun verilog-modi-lookup (module allow-cache &optional ignore-error) | |
7060 "Find the file and point at which MODULE is defined. | |
7061 If ALLOW-CACHE is set, check and remember cache of previous lookups. | |
7062 Return modi if successful, else print message unless IGNORE-ERROR is true." | |
7063 (let* ((current (or (buffer-file-name) (current-buffer)))) | |
7064 (cond ((and verilog-modi-lookup-last-modi | |
7065 verilog-cache-enabled | |
7066 allow-cache | |
7067 (equal verilog-modi-lookup-last-mod module) | |
7068 (equal verilog-modi-lookup-last-current current) | |
7069 (equal verilog-modi-lookup-last-tick (buffer-modified-tick))) | |
7070 ;; ok as is | |
7071 ) | |
7072 (t (let* ((realmod (verilog-symbol-detick module t)) | |
7073 (orig-filenames (verilog-module-filenames realmod current)) | |
7074 (filenames orig-filenames) | |
7075 pt) | |
7076 (while (and filenames (not pt)) | |
7077 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames)))) | |
7078 (setq filenames (cdr filenames)))) | |
7079 (cond (pt (setq verilog-modi-lookup-last-modi | |
7080 (vector realmod (car filenames) pt))) | |
7081 (t (setq verilog-modi-lookup-last-modi nil) | |
7082 (or ignore-error | |
7083 (error (concat (verilog-point-text) | |
7084 ": Can't locate " module " module definition" | |
7085 (if (not (equal module realmod)) | |
7086 (concat " (Expanded macro to " realmod ")") | |
7087 "") | |
7088 "\n Check the verilog-library-directories variable." | |
7089 "\n I looked in (if not listed, doesn't exist):\n\t" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7090 (mapconcat 'concat orig-filenames "\n\t")))))) |
79545 | 7091 (setq verilog-modi-lookup-last-mod module |
7092 verilog-modi-lookup-last-current current | |
7093 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7094 verilog-modi-lookup-last-modi)) |
79545 | 7095 |
7096 (defsubst verilog-modi-name (modi) | |
7097 (aref modi 0)) | |
7098 (defsubst verilog-modi-file-or-buffer (modi) | |
7099 (aref modi 1)) | |
7100 (defsubst verilog-modi-point (modi) | |
7101 (aref modi 2)) | |
7102 | |
7103 (defun verilog-modi-filename (modi) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7104 "Filename of MODI, or name of buffer if its never been saved." |
79545 | 7105 (if (bufferp (verilog-modi-file-or-buffer modi)) |
7106 (or (buffer-file-name (verilog-modi-file-or-buffer modi)) | |
7107 (buffer-name (verilog-modi-file-or-buffer modi))) | |
7108 (verilog-modi-file-or-buffer modi))) | |
7109 | |
7110 (defun verilog-modi-goto (modi) | |
7111 "Move point/buffer to specified MODI." | |
7112 (or modi (error "Passed unfound modi to goto, check earlier")) | |
7113 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) | |
7114 (verilog-modi-file-or-buffer modi) | |
7115 (find-file-noselect (verilog-modi-file-or-buffer modi)))) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7116 (or (equal major-mode `verilog-mode) ;; Put into verilog mode to get syntax |
79545 | 7117 (verilog-mode)) |
7118 (goto-char (verilog-modi-point modi))) | |
7119 | |
7120 (defun verilog-goto-defun-file (module) | |
7121 "Move point to the file at which a given MODULE is defined." | |
7122 (interactive "sGoto File for Module: ") | |
7123 (let* ((modi (verilog-modi-lookup module nil))) | |
7124 (when modi | |
7125 (verilog-modi-goto modi) | |
7126 (switch-to-buffer (current-buffer))))) | |
7127 | |
7128 (defun verilog-modi-cache-results (modi function) | |
7129 "Run on MODI the given FUNCTION. Locate the module in a file. | |
7130 Cache the output of function so next call may have faster access." | |
7131 (let (func-returns fass) | |
7132 (save-excursion | |
7133 (verilog-modi-goto modi) | |
7134 (if (and (setq fass (assoc (list (verilog-modi-name modi) function) | |
7135 verilog-modi-cache-list)) | |
7136 ;; Destroy caching when incorrect; Modified or file changed | |
7137 (not (and verilog-cache-enabled | |
7138 (or (equal (buffer-modified-tick) (nth 1 fass)) | |
7139 (and verilog-modi-cache-preserve-tick | |
7140 (<= verilog-modi-cache-preserve-tick (nth 1 fass)) | |
7141 (equal verilog-modi-cache-preserve-buffer (current-buffer)))) | |
7142 (equal (visited-file-modtime) (nth 2 fass))))) | |
7143 (setq verilog-modi-cache-list nil | |
7144 fass nil)) | |
7145 (cond (fass | |
7146 ;; Found | |
7147 (setq func-returns (nth 3 fass))) | |
7148 (t | |
7149 ;; Read from file | |
7150 ;; Clear then restore any hilighting to make emacs19 happy | |
7151 (let ((fontlocked (when (and (boundp 'font-lock-mode) | |
7152 font-lock-mode) | |
7153 (font-lock-mode nil) | |
7154 t))) | |
7155 (setq func-returns (funcall function)) | |
7156 (when fontlocked (font-lock-mode t))) | |
7157 ;; Cache for next time | |
7158 (setq verilog-modi-cache-list | |
7159 (cons (list (list (verilog-modi-name modi) function) | |
7160 (buffer-modified-tick) | |
7161 (visited-file-modtime) | |
7162 func-returns) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7163 verilog-modi-cache-list))))) |
79545 | 7164 ;; |
7165 func-returns)) | |
7166 | |
7167 (defun verilog-modi-cache-add (modi function element sig-list) | |
7168 "Add function return results to the module cache. | |
7169 Update MODI's cache for given FUNCTION so that the return ELEMENT of that | |
7170 function now contains the additional SIG-LIST parameters." | |
7171 (let (fass) | |
7172 (save-excursion | |
7173 (verilog-modi-goto modi) | |
7174 (if (setq fass (assoc (list (verilog-modi-name modi) function) | |
7175 verilog-modi-cache-list)) | |
7176 (let ((func-returns (nth 3 fass))) | |
7177 (aset func-returns element | |
7178 (append sig-list (aref func-returns element)))))))) | |
7179 | |
7180 (defmacro verilog-preserve-cache (&rest body) | |
7181 "Execute the BODY forms, allowing cache preservation within BODY. | |
7182 This means that changes to the buffer will not result in the cache being | |
7183 flushed. If the changes affect the modsig state, they must call the | |
7184 modsig-cache-add-* function, else the results of later calls may be | |
7185 incorrect. Without this, changes are assumed to be adding/removing signals | |
7186 and invalidating the cache." | |
7187 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick)) | |
7188 (verilog-modi-cache-preserve-buffer (current-buffer))) | |
7189 (progn ,@body))) | |
7190 | |
7191 | |
7192 (defun verilog-signals-matching-enum (in-list enum) | |
7193 "Return all signals in IN-LIST matching the given ENUM." | |
7194 (let (out-list) | |
7195 (while in-list | |
7196 (if (equal (verilog-sig-enum (car in-list)) enum) | |
7197 (setq out-list (cons (car in-list) out-list))) | |
7198 (setq in-list (cdr in-list))) | |
7199 ;; New scheme | |
7200 (let* ((enumvar (intern (concat "venum-" enum))) | |
7201 (enumlist (and (boundp enumvar) (eval enumvar)))) | |
7202 (while enumlist | |
7203 (add-to-list 'out-list (list (car enumlist))) | |
7204 (setq enumlist (cdr enumlist)))) | |
7205 (nreverse out-list))) | |
7206 | |
7207 (defun verilog-signals-not-matching-regexp (in-list regexp) | |
7208 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." | |
7209 (if (not regexp) | |
7210 in-list | |
7211 (let (out-list) | |
7212 (while in-list | |
7213 (if (not (string-match regexp (verilog-sig-name (car in-list)))) | |
7214 (setq out-list (cons (car in-list) out-list))) | |
7215 (setq in-list (cdr in-list))) | |
7216 (nreverse out-list)))) | |
7217 | |
7218 ;; Combined | |
7219 (defun verilog-modi-get-signals (modi) | |
7220 (append | |
7221 (verilog-modi-get-outputs modi) | |
7222 (verilog-modi-get-inouts modi) | |
7223 (verilog-modi-get-inputs modi) | |
7224 (verilog-modi-get-wires modi) | |
7225 (verilog-modi-get-regs modi) | |
7226 (verilog-modi-get-assigns modi) | |
7227 (verilog-modi-get-consts modi) | |
7228 (verilog-modi-get-gparams modi))) | |
7229 | |
7230 (defun verilog-modi-get-ports (modi) | |
7231 (append | |
7232 (verilog-modi-get-outputs modi) | |
7233 (verilog-modi-get-inouts modi) | |
7234 (verilog-modi-get-inputs modi))) | |
7235 | |
7236 (defsubst verilog-modi-cache-add-outputs (modi sig-list) | |
7237 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list)) | |
7238 (defsubst verilog-modi-cache-add-inouts (modi sig-list) | |
7239 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list)) | |
7240 (defsubst verilog-modi-cache-add-inputs (modi sig-list) | |
7241 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) | |
7242 (defsubst verilog-modi-cache-add-wires (modi sig-list) | |
7243 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) | |
7244 (defsubst verilog-modi-cache-add-regs (modi sig-list) | |
7245 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list)) | |
7246 | |
7247 (defun verilog-signals-from-signame (signame-list) | |
7248 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names." | |
7249 (mapcar (function (lambda (name) (list name nil nil))) | |
7250 signame-list)) | |
7251 | |
7252 ;; | |
7253 ;; Auto creation utilities | |
7254 ;; | |
7255 | |
7256 (defun verilog-auto-search-do (search-for func) | |
7257 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs." | |
7258 (goto-char (point-min)) | |
7259 (while (search-forward search-for nil t) | |
7260 (if (not (save-excursion | |
7261 (goto-char (match-beginning 0)) | |
7262 (verilog-inside-comment-p))) | |
7263 (funcall func)))) | |
7264 | |
7265 (defun verilog-auto-re-search-do (search-for func) | |
7266 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs." | |
7267 (goto-char (point-min)) | |
7268 (while (re-search-forward search-for nil t) | |
7269 (if (not (save-excursion | |
7270 (goto-char (match-beginning 0)) | |
7271 (verilog-inside-comment-p))) | |
7272 (funcall func)))) | |
7273 | |
7274 (defun verilog-insert-one-definition (sig type indent-pt) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7275 "Print out a definition for SIG of the given TYPE, |
79545 | 7276 with appropriate INDENT-PT indentation." |
7277 (indent-to indent-pt) | |
7278 (insert type) | |
7279 (when (verilog-sig-signed sig) | |
7280 (insert " " (verilog-sig-signed sig))) | |
7281 (when (verilog-sig-multidim sig) | |
7282 (insert " " (verilog-sig-multidim-string sig))) | |
7283 (when (verilog-sig-bits sig) | |
7284 (insert " " (verilog-sig-bits sig))) | |
7285 (indent-to (max 24 (+ indent-pt 16))) | |
7286 (unless (= (char-syntax (preceding-char)) ?\ ) | |
7287 (insert " ")) ; Need space between "]name" if indent-to did nothing | |
7288 (insert (verilog-sig-name sig))) | |
7289 | |
7290 (defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort) | |
7291 "Print out a definition for a list of SIGS of the given DIRECTION, | |
7292 with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O | |
7293 format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output." | |
7294 (or dont-sort | |
7295 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) | |
7296 (while sigs | |
7297 (let ((sig (car sigs))) | |
7298 (verilog-insert-one-definition | |
7299 sig | |
7300 ;; Want "type x" or "output type x", not "wire type x" | |
7301 (cond ((verilog-sig-type sig) | |
7302 (concat | |
7303 (if (not (equal direction "wire")) | |
7304 (concat direction " ")) | |
7305 (verilog-sig-type sig))) | |
7306 (t direction)) | |
7307 indent-pt) | |
7308 (insert (if v2k "," ";")) | |
7309 (if (or (not (verilog-sig-comment sig)) | |
7310 (equal "" (verilog-sig-comment sig))) | |
7311 (insert "\n") | |
7312 (indent-to (max 48 (+ indent-pt 40))) | |
7313 (insert (concat "// " (verilog-sig-comment sig) "\n"))) | |
7314 (setq sigs (cdr sigs))))) | |
7315 | |
7316 (eval-when-compile | |
7317 (if (not (boundp 'indent-pt)) | |
7318 (defvar indent-pt nil "Local used by insert-indent"))) | |
7319 | |
7320 (defun verilog-insert-indent (&rest stuff) | |
7321 "Indent to position stored in local `indent-pt' variable, then insert STUFF. | |
7322 Presumes that any newlines end a list element." | |
7323 (let ((need-indent t)) | |
7324 (while stuff | |
7325 (if need-indent (indent-to indent-pt)) | |
7326 (setq need-indent nil) | |
7327 (insert (car stuff)) | |
7328 (setq need-indent (string-match "\n$" (car stuff)) | |
7329 stuff (cdr stuff))))) | |
7330 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n")) | |
7331 | |
7332 (defun verilog-repair-open-comma () | |
7333 "If backwards-from-point is other than a open parenthesis insert comma." | |
7334 (save-excursion | |
7335 (verilog-backward-syntactic-ws) | |
7336 (when (save-excursion | |
7337 (backward-char 1) | |
7338 (and (not (looking-at "[(,]")) | |
7339 (progn | |
7340 (verilog-re-search-backward "[(`]" nil t) | |
7341 (looking-at "(")))) | |
7342 (insert ",")))) | |
7343 | |
7344 (defun verilog-repair-close-comma () | |
7345 "If point is at a comma followed by a close parenthesis, fix it. | |
7346 This repairs those mis-inserted by a AUTOARG." | |
7347 ;; It would be much nicer if Verilog allowed extra commas like Perl does! | |
7348 (save-excursion | |
7349 (verilog-forward-close-paren) | |
7350 (backward-char 1) | |
7351 (verilog-backward-syntactic-ws) | |
7352 (backward-char 1) | |
7353 (when (looking-at ",") | |
7354 (delete-char 1)))) | |
7355 | |
7356 (defun verilog-get-list (start end) | |
7357 "Return the elements of a comma separated list between START and END." | |
7358 (interactive) | |
7359 (let ((my-list (list)) | |
7360 my-string) | |
7361 (save-excursion | |
7362 (while (< (point) end) | |
7363 (when (re-search-forward "\\([^,{]+\\)" end t) | |
7364 (setq my-string (verilog-string-remove-spaces (match-string 1))) | |
7365 (setq my-list (nconc my-list (list my-string) )) | |
7366 (goto-char (match-end 0)))) | |
7367 my-list))) | |
7368 | |
7369 (defun verilog-make-width-expression (range-exp) | |
7370 "Return an expression calculating the length of a range [x:y] in RANGE-EXP." | |
7371 ;; strip off the [] | |
7372 (cond ((not range-exp) | |
7373 "1") | |
7374 (t | |
7375 (if (string-match "^\\[\\(.*\\)\\]$" range-exp) | |
7376 (setq range-exp (match-string 1 range-exp))) | |
7377 (cond ((not range-exp) | |
7378 "1") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7379 ((string-match "^\\s *\\([0-9]+\\)\\s *:\\s *\\([0-9]+\\)\\s *$" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7380 range-exp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7381 (int-to-string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7382 (1+ (abs (- (string-to-number (match-string 1 range-exp)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7383 (string-to-number (match-string 2 range-exp))))))) |
79545 | 7384 ((string-match "^\\(.*\\)\\s *:\\s *\\(.*\\)\\s *$" range-exp) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7385 (concat "(1+(" (match-string 1 range-exp) ")" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7386 (if (equal "0" (match-string 2 range-exp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7387 "" ;; Don't bother with -(0) |
79545 | 7388 (concat "-(" (match-string 2 range-exp) ")")) |
7389 ")")) | |
7390 (t nil))))) | |
7391 ;;(verilog-make-width-expression "`A:`B") | |
7392 | |
7393 (defun verilog-typedef-name-p (variable-name) | |
7394 "Return true if the VARIABLE-NAME is a type definition." | |
7395 (when verilog-typedef-regexp | |
7396 (string-match verilog-typedef-regexp variable-name))) | |
7397 | |
7398 ;; | |
7399 ;; Auto deletion | |
7400 ;; | |
7401 | |
7402 (defun verilog-delete-autos-lined () | |
7403 "Delete autos that occupy multiple lines, between begin and end comments." | |
7404 (let ((pt (point))) | |
7405 (forward-line 1) | |
7406 (when (and | |
7407 (looking-at "\\s-*// Beginning") | |
7408 (search-forward "// End of automatic" nil t)) | |
7409 ;; End exists | |
7410 (end-of-line) | |
7411 (delete-region pt (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7412 (forward-line 1)))) |
79545 | 7413 |
7414 (defun verilog-forward-close-paren () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7415 "Find the close parenthesis that match the current point, |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7416 ignore other close parenthesis with matching open parens" |
79545 | 7417 (let ((parens 1)) |
7418 (while (> parens 0) | |
7419 (unless (verilog-re-search-forward-quick "[()]" nil t) | |
7420 (error "%s: Mismatching ()" (verilog-point-text))) | |
7421 (cond ((= (preceding-char) ?\( ) | |
7422 (setq parens (1+ parens))) | |
7423 ((= (preceding-char) ?\) ) | |
7424 (setq parens (1- parens))))))) | |
7425 | |
7426 (defun verilog-backward-open-paren () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7427 "Find the open parenthesis that match the current point, |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7428 ignore other open parenthesis with matching close parens" |
79545 | 7429 (let ((parens 1)) |
7430 (while (> parens 0) | |
7431 (unless (verilog-re-search-backward-quick "[()]" nil t) | |
7432 (error "%s: Mismatching ()" (verilog-point-text))) | |
7433 (cond ((= (following-char) ?\) ) | |
7434 (setq parens (1+ parens))) | |
7435 ((= (following-char) ?\( ) | |
7436 (setq parens (1- parens))))))) | |
7437 | |
7438 (defun verilog-backward-open-bracket () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7439 "Find the open bracket that match the current point, |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7440 ignore other open bracket with matching close bracket" |
79545 | 7441 (let ((parens 1)) |
7442 (while (> parens 0) | |
7443 (unless (verilog-re-search-backward-quick "[][]" nil t) | |
7444 (error "%s: Mismatching []" (verilog-point-text))) | |
7445 (cond ((= (following-char) ?\] ) | |
7446 (setq parens (1+ parens))) | |
7447 ((= (following-char) ?\[ ) | |
7448 (setq parens (1- parens))))))) | |
7449 | |
7450 (defun verilog-delete-to-paren () | |
7451 "Delete the automatic inst/sense/arg created by autos. | |
7452 Deletion stops at the matching end parenthesis." | |
7453 (delete-region (point) | |
7454 (save-excursion | |
7455 (verilog-backward-open-paren) | |
7456 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
7457 (backward-char 1) | |
7458 (point)))) | |
7459 | |
7460 (defun verilog-auto-star-safe () | |
7461 "Return if a .* AUTOINST is safe to delete or expand. | |
7462 It was created by the AUTOS themselves, or by the user." | |
7463 (and verilog-auto-star-expand | |
7464 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\)\\)"))) | |
7465 | |
7466 (defun verilog-delete-auto-star-all () | |
7467 "Delete a .* AUTOINST, if it is safe." | |
7468 (when (verilog-auto-star-safe) | |
7469 (verilog-delete-to-paren))) | |
7470 | |
7471 (defun verilog-delete-auto-star-implicit () | |
7472 "Delete all .* implicit connections created by `verilog-auto-star'. | |
7473 This function will be called automatically at save unless | |
7474 `verilog-auto-star-save' is set, any non-templated expanded pins will be | |
7475 removed." | |
7476 (interactive) | |
7477 (let (paren-pt indent have-close-paren) | |
7478 (save-excursion | |
7479 (goto-char (point-min)) | |
7480 ;; We need to match these even outside of comments. | |
7481 ;; For reasonable performance, we don't check if inside comments, sorry. | |
7482 (while (re-search-forward "// Implicit \\.\\*" nil t) | |
7483 (setq paren-pt (point)) | |
7484 (beginning-of-line) | |
7485 (setq have-close-paren | |
7486 (save-excursion | |
7487 (when (search-forward ");" paren-pt t) | |
7488 (setq indent (current-indentation)) | |
7489 t))) | |
7490 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR | |
7491 (when have-close-paren | |
7492 ;; Delete extra commentary | |
7493 (save-excursion | |
7494 (while (progn | |
7495 (forward-line -1) | |
7496 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\)\n")) | |
7497 (delete-region (match-beginning 0) (match-end 0)))) | |
7498 ;; If it is simple, we can put the ); on the same line as the last text | |
7499 (let ((rtn-pt (point))) | |
7500 (save-excursion | |
7501 (while (progn (backward-char 1) | |
7502 (looking-at "[ \t\n\f]"))) | |
7503 (when (looking-at ",") | |
7504 (delete-region (+ 1 (point)) rtn-pt)))) | |
7505 (when (bolp) | |
7506 (indent-to indent)) | |
7507 (insert ");\n") | |
7508 ;; Still need to kill final comma - always is one as we put one after the .* | |
7509 (re-search-backward ",") | |
7510 (delete-char 1)))))) | |
7511 | |
7512 (defun verilog-delete-auto () | |
7513 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto]. | |
7514 Use \\[verilog-auto] to re-insert the updated AUTOs. | |
7515 | |
7516 The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are | |
7517 called before and after this function, respectively." | |
7518 (interactive) | |
7519 (save-excursion | |
7520 (if (buffer-file-name) | |
7521 (find-file-noselect (buffer-file-name))) ;; To check we have latest version | |
7522 ;; Allow user to customize | |
7523 (run-hooks 'verilog-before-delete-auto-hook) | |
7524 | |
7525 ;; Remove those that have multi-line insertions | |
7526 (verilog-auto-re-search-do "/\\*AUTO\\(OUTPUTEVERY\\|CONCATCOMMENT\\|WIRE\\|REG\\|DEFINEVALUE\\|REGINPUT\\|INPUT\\|OUTPUT\\|INOUT\\|RESET\\|TIEOFF\\|UNUSED\\)\\*/" | |
7527 'verilog-delete-autos-lined) | |
7528 ;; Remove those that have multi-line insertions with parameters | |
7529 (verilog-auto-re-search-do "/\\*AUTO\\(INOUTMODULE\\|ASCIIENUM\\)([^)]*)\\*/" | |
7530 'verilog-delete-autos-lined) | |
7531 ;; Remove those that are in parenthesis | |
7532 (verilog-auto-re-search-do "/\\*\\(AS\\|AUTO\\(ARG\\|CONCATWIDTH\\|INST\\|INSTPARAM\\|SENSE\\)\\)\\*/" | |
7533 'verilog-delete-to-paren) | |
7534 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments | |
7535 (verilog-auto-re-search-do "\\.\\*" | |
7536 'verilog-delete-auto-star-all) | |
7537 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed | |
7538 (goto-char (point-min)) | |
7539 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t) | |
7540 (replace-match "")) | |
7541 | |
7542 ;; Final customize | |
7543 (run-hooks 'verilog-delete-auto-hook))) | |
7544 | |
7545 ;; | |
7546 ;; Auto inject | |
7547 ;; | |
7548 | |
7549 (defun verilog-inject-auto () | |
7550 "Examine legacy non-AUTO code and insert AUTOs in appropriate places. | |
7551 | |
7552 Any always @ blocks with sensitivity lists that match computed lists will | |
7553 be replaced with /*AS*/ comments. | |
7554 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7555 Any cells will get /*AUTOINST*/ added to the end of the pin list. Pins with |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7556 have identical names will be deleted. |
79545 | 7557 |
7558 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to | |
7559 support adding new ports. You may wish to delete older ports yourself. | |
7560 | |
7561 For example: | |
7562 | |
7563 module ex_inject (i, o); | |
7564 input i; | |
7565 input j; | |
7566 output o; | |
7567 always @ (i or j) | |
7568 o = i | j; | |
7569 cell cell (.foobar(baz), | |
7570 .j(j)); | |
7571 endmodule | |
7572 | |
7573 Typing \\[verilog-inject-auto] will make this into: | |
7574 | |
7575 module ex_inject (i, o/*AUTOARG*/ | |
7576 // Inputs | |
7577 j); | |
7578 input i; | |
7579 output o; | |
7580 always @ (/*AS*/i or j) | |
7581 o = i | j; | |
7582 cell cell (.foobar(baz), | |
7583 /*AUTOINST*/ | |
7584 // Outputs | |
7585 .j(j)); | |
7586 endmodule" | |
7587 (interactive) | |
7588 (verilog-auto t)) | |
7589 | |
7590 (defun verilog-inject-arg () | |
7591 "Inject AUTOARG into new code. See `verilog-inject-auto'." | |
7592 ;; Presume one module per file. | |
7593 (save-excursion | |
7594 (goto-char (point-min)) | |
7595 (while (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
7596 (let ((endmodp (save-excursion | |
7597 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t) | |
7598 (point)))) | |
7599 ;; See if there's already a comment .. inside a comment so not verilog-re-search | |
7600 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t)) | |
7601 (verilog-re-search-forward-quick ";" nil t) | |
7602 (backward-char 1) | |
7603 (verilog-backward-syntactic-ws) | |
7604 (backward-char 1) ; Moves to paren that closes argdecl's | |
7605 (when (looking-at ")") | |
7606 (insert "/*AUTOARG*/"))))))) | |
7607 | |
7608 (defun verilog-inject-sense () | |
7609 "Inject AUTOSENSE into new code. See `verilog-inject-auto'." | |
7610 (save-excursion | |
7611 (goto-char (point-min)) | |
7612 (while (verilog-re-search-forward-quick "\\<always\\s *@\\s *(" nil t) | |
7613 (let ((start-pt (point)) | |
7614 (modi (verilog-modi-current)) | |
7615 pre-sigs | |
7616 got-sigs) | |
7617 (backward-char 1) | |
7618 (forward-sexp 1) | |
7619 (backward-char 1) ;; End ) | |
7620 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) | |
7621 (setq pre-sigs (verilog-signals-from-signame | |
7622 (verilog-read-signals start-pt (point))) | |
7623 got-sigs (verilog-auto-sense-sigs modi nil)) | |
7624 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal? | |
7625 (verilog-signals-not-in got-sigs pre-sigs))) | |
7626 (delete-region start-pt (point)) | |
7627 (insert "/*AS*/"))))))) | |
7628 | |
7629 (defun verilog-inject-inst () | |
7630 "Inject AUTOINST into new code. See `verilog-inject-auto'." | |
7631 (save-excursion | |
7632 (goto-char (point-min)) | |
7633 ;; It's hard to distinguish modules; we'll instead search for pins. | |
7634 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) | |
7635 (verilog-backward-open-paren) ;; Inst start | |
7636 (cond | |
7637 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip. | |
7638 (forward-char 1) | |
7639 (verilog-forward-close-paren)) ;; Parameters done | |
7640 (t | |
7641 (forward-char 1) | |
7642 (let ((indent-pt (+ (current-column))) | |
7643 (end-pt (save-excursion (verilog-forward-close-paren) (point)))) | |
7644 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) | |
7645 (goto-char end-pt)) ;; Already there, continue search with next instance | |
7646 (t | |
7647 ;; Delete identical interconnect | |
7648 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc | |
7649 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) | |
7650 (delete-region (match-beginning 0) (match-end 0)) | |
7651 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct | |
7652 (while (or (looking-at "[ \t\n\f,]+") | |
7653 (looking-at "//[^\n]*")) | |
7654 (delete-region (match-beginning 0) (match-end 0)) | |
7655 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0))))))) | |
7656 (verilog-forward-close-paren) | |
7657 (backward-char 1) | |
7658 ;; Not verilog-re-search, as we don't want to strip comments | |
7659 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t) | |
7660 (delete-region (match-beginning 0) (match-end 0))) | |
7661 (insert "\n") | |
7662 (indent-to indent-pt) | |
7663 (insert "/*AUTOINST*/"))))))))) | |
7664 | |
7665 ;; | |
7666 ;; Auto save | |
7667 ;; | |
7668 | |
7669 (defun verilog-auto-save-check () | |
7670 "On saving see if we need auto update." | |
7671 (cond ((not verilog-auto-save-policy)) ; disabled | |
7672 ((not (save-excursion | |
7673 (save-match-data | |
7674 (let ((case-fold-search nil)) | |
7675 (goto-char (point-min)) | |
7676 (re-search-forward "AUTO" nil t)))))) | |
7677 ((eq verilog-auto-save-policy 'force) | |
7678 (verilog-auto)) | |
7679 ((not (buffer-modified-p))) | |
7680 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date | |
7681 ((eq verilog-auto-save-policy 'detect) | |
7682 (verilog-auto)) | |
7683 (t | |
7684 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | |
7685 (verilog-auto)) | |
7686 ;; Don't ask again if didn't update | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7687 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
79545 | 7688 (when (not verilog-auto-star-save) |
7689 (verilog-delete-auto-star-implicit)) | |
7690 nil) ;; Always return nil -- we don't write the file ourselves | |
7691 | |
7692 (defun verilog-auto-read-locals () | |
7693 "Return file local variable segment at bottom of file." | |
7694 (save-excursion | |
7695 (goto-char (point-max)) | |
7696 (if (re-search-backward "Local Variables:" nil t) | |
7697 (buffer-substring-no-properties (point) (point-max)) | |
7698 ""))) | |
7699 | |
7700 (defun verilog-auto-reeval-locals (&optional force) | |
7701 "Read file local variable segment at bottom of file if it has changed. | |
7702 If FORCE, always reread it." | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7703 (make-local-variable 'verilog-auto-last-file-locals) |
79545 | 7704 (let ((curlocal (verilog-auto-read-locals))) |
7705 (when (or force (not (equal verilog-auto-last-file-locals curlocal))) | |
7706 (setq verilog-auto-last-file-locals curlocal) | |
7707 ;; Note this may cause this function to be recursively invoked. | |
7708 ;; The above when statement will prevent it from recursing forever. | |
7709 (hack-local-variables) | |
7710 t))) | |
7711 | |
7712 ;; | |
7713 ;; Auto creation | |
7714 ;; | |
7715 | |
7716 (defun verilog-auto-arg-ports (sigs message indent-pt) | |
7717 "Print a list of ports for a AUTOINST. | |
7718 Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT." | |
7719 (when sigs | |
7720 (insert "\n") | |
7721 (indent-to indent-pt) | |
7722 (insert message) | |
7723 (insert "\n") | |
7724 (let ((space "")) | |
7725 (indent-to indent-pt) | |
7726 (while sigs | |
7727 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column) | |
7728 (insert "\n") | |
7729 (indent-to indent-pt)) | |
7730 (t (insert space))) | |
7731 (insert (verilog-sig-name (car sigs)) ",") | |
7732 (setq sigs (cdr sigs) | |
7733 space " "))))) | |
7734 | |
7735 (defun verilog-auto-arg () | |
7736 "Expand AUTOARG statements. | |
7737 Replace the argument declarations at the beginning of the | |
7738 module with ones automatically derived from input and output | |
7739 statements. This can be dangerous if the module is instantiated | |
7740 using position-based connections, so use only name-based when | |
7741 instantiating the resulting module. Long lines are split based | |
7742 on the `fill-column', see \\[set-fill-column]. | |
7743 | |
7744 Limitations: | |
7745 Concatenation and outputting partial busses is not supported. | |
7746 | |
7747 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
7748 | |
7749 For example: | |
7750 | |
7751 module ex_arg (/*AUTOARG*/); | |
7752 input i; | |
7753 output o; | |
7754 endmodule | |
7755 | |
7756 Typing \\[verilog-auto] will make this into: | |
7757 | |
7758 module ex_arg (/*AUTOARG*/ | |
7759 // Outputs | |
7760 o, | |
7761 // Inputs | |
7762 i | |
7763 ); | |
7764 input i; | |
7765 output o; | |
7766 endmodule | |
7767 | |
7768 Any ports declared between the ( and /*AUTOARG*/ are presumed to be | |
7769 predeclared and are not redeclared by AUTOARG. AUTOARG will make a | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7770 conservative guess on adding a comma for the first signal, if you have any |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7771 ifdefs or complicated expressions before the AUTOARG you will need to |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7772 choose the comma yourself. |
79545 | 7773 |
7774 Avoid declaring ports manually, as it makes code harder to maintain." | |
7775 (save-excursion | |
7776 (let ((modi (verilog-modi-current)) | |
7777 (skip-pins (aref (verilog-read-arg-pins) 0))) | |
7778 (verilog-repair-open-comma) | |
7779 (verilog-auto-arg-ports (verilog-signals-not-in | |
7780 (verilog-modi-get-outputs modi) | |
7781 skip-pins) | |
7782 "// Outputs" | |
7783 verilog-indent-level-declaration) | |
7784 (verilog-auto-arg-ports (verilog-signals-not-in | |
7785 (verilog-modi-get-inouts modi) | |
7786 skip-pins) | |
7787 "// Inouts" | |
7788 verilog-indent-level-declaration) | |
7789 (verilog-auto-arg-ports (verilog-signals-not-in | |
7790 (verilog-modi-get-inputs modi) | |
7791 skip-pins) | |
7792 "// Inputs" | |
7793 verilog-indent-level-declaration) | |
7794 (verilog-repair-close-comma) | |
7795 (unless (eq (char-before) ?/ ) | |
7796 (insert "\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7797 (indent-to verilog-indent-level-declaration)))) |
79545 | 7798 |
7799 (defun verilog-auto-inst-port-map (port-st) | |
7800 nil) | |
7801 | |
7802 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7803 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7804 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7805 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7806 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7807 | |
7808 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) | |
7809 "Print out a instantiation connection for this PORT-ST. | |
7810 Insert to INDENT-PT, use template TPL-LIST. | |
7811 @ are instantiation numbers, replaced with TPL-NUM. | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7812 @\"(expression @)\" are evaluated, with @ as a variable. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7813 If FOR-STAR add comment it is a .* expansion." |
79545 | 7814 (let* ((port (verilog-sig-name port-st)) |
7815 (tpl-ass (or (assoc port (car tpl-list)) | |
7816 (verilog-auto-inst-port-map port-st))) | |
7817 ;; vl-* are documented for user use | |
7818 (vl-name (verilog-sig-name port-st)) | |
7819 (vl-width (verilog-sig-width port-st)) | |
7820 (vl-bits (if (or verilog-auto-inst-vector | |
7821 (not (assoc port vector-skip-list)) | |
7822 (not (equal (verilog-sig-bits port-st) | |
7823 (verilog-sig-bits (assoc port vector-skip-list))))) | |
7824 (or (verilog-sig-bits port-st) "") | |
7825 "")) | |
7826 ;; Default if not found | |
7827 (tpl-net (if (verilog-sig-multidim port-st) | |
7828 (concat port "/*" (verilog-sig-multidim-string port-st) | |
7829 vl-bits "*/") | |
7830 (concat port vl-bits))) | |
7831 (case-fold-search nil)) | |
7832 ;; Find template | |
7833 (cond (tpl-ass ; Template of exact port name | |
7834 (setq tpl-net (nth 1 tpl-ass))) | |
7835 ((nth 1 tpl-list) ; Wildcards in template, search them | |
7836 (let ((wildcards (nth 1 tpl-list))) | |
7837 (while wildcards | |
7838 (when (string-match (nth 0 (car wildcards)) port) | |
7839 (setq tpl-ass (car wildcards) ; so allow @ parsing | |
7840 tpl-net (replace-match (nth 1 (car wildcards)) | |
7841 t nil port))) | |
7842 (setq wildcards (cdr wildcards)))))) | |
7843 ;; Parse Templated variable | |
7844 (when tpl-ass | |
7845 ;; Evaluate @"(lispcode)" | |
7846 (when (string-match "@\".*[^\\]\"" tpl-net) | |
7847 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net) | |
7848 (setq tpl-net | |
7849 (concat | |
7850 (substring tpl-net 0 (match-beginning 0)) | |
7851 (save-match-data | |
7852 (let* ((expr (match-string 1 tpl-net)) | |
7853 (value | |
7854 (progn | |
7855 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | |
7856 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | |
7857 (prin1 (eval (car (read-from-string expr))) | |
7858 (lambda (ch) ()))))) | |
7859 (if (numberp value) (setq value (number-to-string value))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7860 value)) |
79545 | 7861 (substring tpl-net (match-end 0)))))) |
7862 ;; Replace @ and [] magic variables in final output | |
7863 (setq tpl-net (verilog-string-replace-matches "@" tpl-num nil nil tpl-net)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7864 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
79545 | 7865 (indent-to indent-pt) |
7866 (insert "." port) | |
7867 (indent-to verilog-auto-inst-column) | |
7868 (insert "(" tpl-net "),") | |
7869 (cond (tpl-ass | |
7870 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
7871 verilog-auto-inst-column)) | |
7872 (insert " // Templated") | |
7873 (when verilog-auto-inst-template-numbers | |
7874 (insert " T" (int-to-string (nth 2 tpl-ass)) | |
7875 " L" (int-to-string (nth 3 tpl-ass))))) | |
7876 (for-star | |
7877 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
7878 verilog-auto-inst-column)) | |
7879 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped... | |
7880 (insert "\n"))) | |
7881 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") | |
7882 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]") | |
7883 ;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));") | |
7884 | |
7885 (defun verilog-auto-inst-first () | |
7886 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]." | |
7887 ;; Do we need a trailing comma? | |
7888 ;; There maybe a ifdef or something similar before us. What a mess. Thus | |
7889 ;; to avoid trouble we only insert on preceeding ) or *. | |
7890 ;; Insert first port on new line | |
7891 (insert "\n") ;; Must insert before search, so point will move forward if insert comma | |
7892 (save-excursion | |
7893 (verilog-re-search-backward "[^ \t\n\f]" nil nil) | |
7894 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure | |
7895 (forward-char 1) | |
7896 (insert ",")))) | |
7897 | |
7898 (defun verilog-auto-star () | |
7899 "Expand SystemVerilog .* pins, as part of \\[verilog-auto]. | |
7900 | |
7901 If `verilog-auto-star-expand' is set, .* pins are treated if they were | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7902 AUTOINST statements, otherwise they are ignored. For safety, Verilog-Mode |
79545 | 7903 will also ignore any .* that are not last in your pin list (this prevents |
7904 it from deleting pins following the .* when it expands the AUTOINST.) | |
7905 | |
7906 On writing your file, unless `verilog-auto-star-save' is set, any | |
7907 non-templated expanded pins will be removed. You may do this at any time | |
7908 with \\[verilog-delete-auto-star-implicit]. | |
7909 | |
7910 If you are converting a module to use .* for the first time, you may wish | |
7911 to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*. | |
7912 | |
7913 See `verilog-auto-inst' for examples, templates, and more information." | |
7914 (when (verilog-auto-star-safe) | |
7915 (verilog-auto-inst))) | |
7916 | |
7917 (defun verilog-auto-inst () | |
7918 "Expand AUTOINST statements, as part of \\[verilog-auto]. | |
7919 Replace the pin connections to an instantiation with ones | |
7920 automatically derived from the module header of the instantiated netlist. | |
7921 | |
7922 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports, | |
7923 and delete them before saving unless `verilog-auto-star-save' is set. | |
7924 See `verilog-auto-star' for more information. | |
7925 | |
7926 Limitations: | |
7927 Module names must be resolvable to filenames by adding a | |
7928 `verilog-library-extensions', and being found in the same directory, or | |
7929 by changing the variable `verilog-library-flags' or | |
7930 `verilog-library-directories'. Macros `modname are translated through the | |
7931 vh-{name} Emacs variable, if that is not found, it just ignores the `. | |
7932 | |
7933 In templates you must have one signal per line, ending in a ), or ));, | |
7934 and have proper () nesting, including a final ); to end the template. | |
7935 | |
7936 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
7937 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7938 SystemVerilog multidimmensional input/output has only experimental support. |
79545 | 7939 |
7940 For example, first take the submodule inst.v: | |
7941 | |
7942 module inst (o,i) | |
7943 output [31:0] o; | |
7944 input i; | |
7945 wire [31:0] o = {32{i}}; | |
7946 endmodule | |
7947 | |
7948 This is then used in a upper level module: | |
7949 | |
7950 module ex_inst (o,i) | |
7951 output o; | |
7952 input i; | |
7953 inst inst (/*AUTOINST*/); | |
7954 endmodule | |
7955 | |
7956 Typing \\[verilog-auto] will make this into: | |
7957 | |
7958 module ex_inst (o,i) | |
7959 output o; | |
7960 input i; | |
7961 inst inst (/*AUTOINST*/ | |
7962 // Outputs | |
7963 .ov (ov[31:0]), | |
7964 // Inputs | |
7965 .i (i)); | |
7966 endmodule | |
7967 | |
7968 Where the list of inputs and outputs came from the inst module. | |
7969 | |
7970 Exceptions: | |
7971 | |
7972 Unless you are instantiating a module multiple times, or the module is | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7973 something trivial like a adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY. |
79545 | 7974 It just makes for unmaintainable code. To sanitize signal names, try |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
7975 vrename from http://www.veripool.com |
79545 | 7976 |
7977 When you need to violate this suggestion there are two ways to list | |
7978 exceptions, placing them before the AUTOINST, or using templates. | |
7979 | |
7980 Any ports defined before the /*AUTOINST*/ are not included in the list of | |
7981 automatics. This is similar to making a template as described below, but | |
7982 is restricted to simple connections just like you normally make. Also note | |
7983 that any signals before the AUTOINST will only be picked up by AUTOWIRE if | |
7984 you have the appropriate // Input or // Output comment, and exactly the | |
7985 same line formatting as AUTOINST itself uses. | |
7986 | |
7987 inst inst (// Inputs | |
7988 .i (my_i_dont_mess_with_it), | |
7989 /*AUTOINST*/ | |
7990 // Outputs | |
7991 .ov (ov[31:0])); | |
7992 | |
7993 | |
7994 Templates: | |
7995 | |
7996 For multiple instantiations based upon a single template, create a | |
7997 commented out template: | |
7998 | |
7999 /* instantiating_module_name AUTO_TEMPLATE ( | |
8000 .sig3 (sigz[]), | |
8001 ); | |
8002 */ | |
8003 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8004 Templates go ABOVE the instantiation(s). When a instantiation is |
79545 | 8005 expanded `verilog-mode' simply searches up for the closest template. |
8006 Thus you can have multiple templates for the same module, just alternate | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8007 between the template for a instantiation and the instantiation itself. |
79545 | 8008 |
8009 The module name must be the same as the name of the module in the | |
8010 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact | |
8011 words and capitalized. Only signals that must be different for each | |
8012 instantiation need to be listed. | |
8013 | |
8014 Inside a template, a [] in a connection name (with nothing else inside | |
8015 the brackets) will be replaced by the same bus subscript as it is being | |
8016 connected to, or the [] will be removed if it is a single bit signal. | |
8017 Generally it is a good idea to do this for all connections in a template, | |
8018 as then they will work for any width signal, and with AUTOWIRE. See | |
8019 PTL_BUS becoming PTL_BUSNEW below. | |
8020 | |
8021 If you have a complicated template, set `verilog-auto-inst-template-numbers' | |
8022 to see which regexps are matching. Don't leave that mode set after | |
8023 debugging is completed though, it will result in lots of extra differences | |
8024 and merge conflicts. | |
8025 | |
8026 For example: | |
8027 | |
8028 /* psm_mas AUTO_TEMPLATE ( | |
8029 .ptl_bus (ptl_busnew[]), | |
8030 ); | |
8031 */ | |
8032 psm_mas ms2m (/*AUTOINST*/); | |
8033 | |
8034 Typing \\[verilog-auto] will make this into: | |
8035 | |
8036 psm_mas ms2m (/*AUTOINST*/ | |
8037 // Outputs | |
8038 .NotInTemplate (NotInTemplate), | |
8039 .ptl_bus (ptl_busnew[3:0]), // Templated | |
8040 .... | |
8041 | |
8042 @ Templates: | |
8043 | |
8044 It is common to instantiate a cell multiple times, so templates make it | |
8045 trivial to substitute part of the cell name into the connection name. | |
8046 | |
8047 /* cell_type AUTO_TEMPLATE <optional \"REGEXP\"> ( | |
8048 .sig1 (sigx[@]), | |
8049 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), | |
8050 ); | |
8051 */ | |
8052 | |
8053 If no regular expression is provided immediately after the AUTO_TEMPLATE | |
8054 keyword, then the @ character in any connection names will be replaced | |
8055 with the instantiation number; the first digits found in the cell's | |
8056 instantiation name. | |
8057 | |
8058 If a regular expression is provided, the @ character will be replaced | |
8059 with the first \(\) grouping that matches against the cell name. Using a | |
8060 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no | |
8061 regexp is provided. If you use multiple layers of parenthesis, | |
8062 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number | |
8063 characters after test and before _, whereas | |
8064 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire | |
8065 match. | |
8066 | |
8067 For example: | |
8068 | |
8069 /* psm_mas AUTO_TEMPLATE ( | |
8070 .ptl_mapvalidx (ptl_mapvalid[@]), | |
8071 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), | |
8072 ); | |
8073 */ | |
8074 psm_mas ms2m (/*AUTOINST*/); | |
8075 | |
8076 Typing \\[verilog-auto] will make this into: | |
8077 | |
8078 psm_mas ms2m (/*AUTOINST*/ | |
8079 // Outputs | |
8080 .ptl_mapvalidx (ptl_mapvalid[2]), | |
8081 .ptl_mapvalidp1x (ptl_mapvalid[3])); | |
8082 | |
8083 Note the @ character was replaced with the 2 from \"ms2m\". | |
8084 | |
8085 Alternatively, using a regular expression for @: | |
8086 | |
8087 /* psm_mas AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( | |
8088 .ptl_mapvalidx (@_ptl_mapvalid), | |
8089 .ptl_mapvalidp1x (ptl_mapvalid_@), | |
8090 ); | |
8091 */ | |
8092 psm_mas ms2_FOO (/*AUTOINST*/); | |
8093 psm_mas ms2_BAR (/*AUTOINST*/); | |
8094 | |
8095 Typing \\[verilog-auto] will make this into: | |
8096 | |
8097 psm_mas ms2_FOO (/*AUTOINST*/ | |
8098 // Outputs | |
8099 .ptl_mapvalidx (FOO_ptl_mapvalid), | |
8100 .ptl_mapvalidp1x (ptl_mapvalid_FOO)); | |
8101 psm_mas ms2_BAR (/*AUTOINST*/ | |
8102 // Outputs | |
8103 .ptl_mapvalidx (BAR_ptl_mapvalid), | |
8104 .ptl_mapvalidp1x (ptl_mapvalid_BAR)); | |
8105 | |
8106 | |
8107 Regexp Templates: | |
8108 | |
8109 A template entry of the form | |
8110 | |
8111 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]), | |
8112 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8113 will apply a Emacs style regular expression search for any port beginning |
79545 | 8114 in pci_req followed by numbers and ending in _l and connecting that to |
8115 the pci_req_jtag_[] net, with the bus subscript coming from what matches | |
8116 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2]. | |
8117 | |
8118 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name | |
8119 does the same thing. (Note a @ in the connection/replacement text is | |
8120 completely different -- still use \\1 there!) Thus this is the same as | |
8121 the above template: | |
8122 | |
8123 .pci_req@_l (pci_req_jtag_[\\1]), | |
8124 | |
8125 Here's another example to remove the _l, useful when naming conventions | |
8126 specify _ alone to mean active low. Note the use of [] to keep the bus | |
8127 subscript: | |
8128 | |
8129 .\\(.*\\)_l (\\1_[]), | |
8130 | |
8131 Lisp Templates: | |
8132 | |
8133 First any regular expression template is expanded. | |
8134 | |
8135 If the syntax @\"( ... )\" is found in a connection, the expression in | |
8136 quotes will be evaluated as a Lisp expression, with @ replaced by the | |
8137 instantiation number. The MAPVALIDP1X example above would put @+1 modulo | |
8138 4 into the brackets. Quote all double-quotes inside the expression with | |
8139 a leading backslash (\\\"). There are special variables defined that are | |
8140 useful in these Lisp functions: | |
8141 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8142 vl-name Name portion of the input/output port |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8143 vl-bits Bus bits portion of the input/output port ('[2:0]') |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8144 vl-width Width of the input/output port ('3' for [2:0]) |
79545 | 8145 May be a (...) expression if bits isn't a constant. |
8146 vl-dir Direction of the pin input/output/inout. | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8147 vl-cell-type Module name/type of the cell ('psm_mas') |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8148 vl-cell-name Instance name of the cell ('ms2m') |
79545 | 8149 |
8150 Normal Lisp variables may be used in expressions. See | |
8151 `verilog-read-defines' which can set vh-{definename} variables for use | |
8152 here. Also, any comments of the form: | |
8153 | |
8154 /*AUTO_LISP(setq foo 1)*/ | |
8155 | |
8156 will evaluate any Lisp expression inside the parenthesis between the | |
8157 beginning of the buffer and the point of the AUTOINST. This allows | |
8158 functions to be defined or variables to be changed between instantiations. | |
8159 | |
8160 Note that when using lisp expressions errors may occur when @ is not a | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8161 number, you may need to use the standard Emacs Lisp functions |
79545 | 8162 `number-to-string' and `string-to-number'. |
8163 | |
8164 After the evaluation is completed, @ substitution and [] substitution | |
8165 occur." | |
8166 (save-excursion | |
8167 ;; Find beginning | |
8168 (let* ((pt (point)) | |
8169 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*"))) | |
8170 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8171 (1+ (current-column)))) | |
8172 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8173 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8174 (modi (verilog-modi-current)) | |
8175 (vector-skip-list (unless verilog-auto-inst-vector | |
8176 (verilog-modi-get-signals modi))) | |
8177 submod submodi inst skip-pins tpl-list tpl-num did-first) | |
8178 ;; Find module name that is instantiated | |
8179 (setq submod (verilog-read-inst-module) | |
8180 inst (verilog-read-inst-name) | |
8181 vl-cell-type submod | |
8182 vl-cell-name inst | |
8183 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8184 | |
8185 ;; Parse any AUTO_LISP() before here | |
8186 (verilog-read-auto-lisp (point-min) pt) | |
8187 | |
8188 ;; Lookup position, etc of submodule | |
8189 ;; Note this may raise an error | |
8190 (when (setq submodi (verilog-modi-lookup submod t)) | |
8191 ;; If there's a number in the instantiation, it may be a argument to the | |
8192 ;; automatic variable instantiation program. | |
8193 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8194 (tpl-regexp (aref tpl-info 0))) | |
8195 (setq tpl-num (if (string-match tpl-regexp inst) | |
8196 (match-string 1 inst) | |
8197 "") | |
8198 tpl-list (aref tpl-info 1))) | |
8199 ;; Find submodule's signals and dump | |
8200 (let ((sig-list (verilog-signals-not-in | |
8201 (verilog-modi-get-outputs submodi) | |
8202 skip-pins)) | |
8203 (vl-dir "output")) | |
8204 (when sig-list | |
8205 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8206 (indent-to indent-pt) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8207 ;; Note these are searched for in verilog-read-sub-decls. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8208 (insert "// Outputs\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8209 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8210 (verilog-auto-inst-port port indent-pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8211 tpl-list tpl-num for-star)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8212 sig-list))) |
79545 | 8213 (let ((sig-list (verilog-signals-not-in |
8214 (verilog-modi-get-inouts submodi) | |
8215 skip-pins)) | |
8216 (vl-dir "inout")) | |
8217 (when sig-list | |
8218 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8219 (indent-to indent-pt) | |
8220 (insert "// Inouts\n") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8221 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8222 (verilog-auto-inst-port port indent-pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8223 tpl-list tpl-num for-star)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8224 sig-list))) |
79545 | 8225 (let ((sig-list (verilog-signals-not-in |
8226 (verilog-modi-get-inputs submodi) | |
8227 skip-pins)) | |
8228 (vl-dir "input")) | |
8229 (when sig-list | |
8230 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8231 (indent-to indent-pt) | |
8232 (insert "// Inputs\n") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8233 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8234 (verilog-auto-inst-port port indent-pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8235 tpl-list tpl-num for-star)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8236 sig-list))) |
79545 | 8237 ;; Kill extra semi |
8238 (save-excursion | |
8239 (cond (did-first | |
8240 (re-search-backward "," pt t) | |
8241 (delete-char 1) | |
8242 (insert ");") | |
8243 (search-forward "\n") ;; Added by inst-port | |
8244 (delete-backward-char 1) | |
8245 (if (search-forward ")" nil t) ;; From user, moved up a line | |
8246 (delete-backward-char 1)) | |
8247 (if (search-forward ";" nil t) ;; Don't error if user had syntax error and forgot it | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8248 (delete-backward-char 1))))))))) |
79545 | 8249 |
8250 (defun verilog-auto-inst-param () | |
8251 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | |
8252 Replace the parameter connections to an instantiation with ones | |
8253 automatically derived from the module header of the instantiated netlist. | |
8254 | |
8255 See \\[verilog-auto-inst] for limitations, and templates to customize the | |
8256 output. | |
8257 | |
8258 For example, first take the submodule inst.v: | |
8259 | |
8260 module inst (o,i) | |
8261 parameter PAR; | |
8262 endmodule | |
8263 | |
8264 This is then used in a upper level module: | |
8265 | |
8266 module ex_inst (o,i) | |
8267 parameter PAR; | |
8268 inst #(/*AUTOINSTPARAM*/) | |
8269 inst (/*AUTOINST*/); | |
8270 endmodule | |
8271 | |
8272 Typing \\[verilog-auto] will make this into: | |
8273 | |
8274 module ex_inst (o,i) | |
8275 output o; | |
8276 input i; | |
8277 inst (/*AUTOINSTPARAM*/ | |
8278 // Parameters | |
8279 .PAR (PAR)); | |
8280 inst (/*AUTOINST*/); | |
8281 endmodule | |
8282 | |
8283 Where the list of parameter connections come from the inst module. | |
8284 | |
8285 Templates: | |
8286 | |
8287 You can customize the parameter connections using AUTO_TEMPLATEs, | |
8288 just as you would with \\[verilog-auto-inst]." | |
8289 (save-excursion | |
8290 ;; Find beginning | |
8291 (let* ((pt (point)) | |
8292 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8293 (1+ (current-column)))) | |
8294 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8295 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8296 (modi (verilog-modi-current)) | |
8297 (vector-skip-list (unless verilog-auto-inst-vector | |
8298 (verilog-modi-get-signals modi))) | |
8299 submod submodi inst skip-pins tpl-list tpl-num did-first) | |
8300 ;; Find module name that is instantiated | |
8301 (setq submod (save-excursion | |
8302 ;; Get to the point where AUTOINST normally is to read the module | |
8303 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8304 (verilog-read-inst-module)) | |
8305 inst (save-excursion | |
8306 ;; Get to the point where AUTOINST normally is to read the module | |
8307 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8308 (verilog-read-inst-name)) | |
8309 vl-cell-type submod | |
8310 vl-cell-name inst | |
8311 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8312 | |
8313 ;; Parse any AUTO_LISP() before here | |
8314 (verilog-read-auto-lisp (point-min) pt) | |
8315 | |
8316 ;; Lookup position, etc of submodule | |
8317 ;; Note this may raise an error | |
8318 (when (setq submodi (verilog-modi-lookup submod t)) | |
8319 ;; If there's a number in the instantiation, it may be a argument to the | |
8320 ;; automatic variable instantiation program. | |
8321 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8322 (tpl-regexp (aref tpl-info 0))) | |
8323 (setq tpl-num (if (string-match tpl-regexp inst) | |
8324 (match-string 1 inst) | |
8325 "") | |
8326 tpl-list (aref tpl-info 1))) | |
8327 ;; Find submodule's signals and dump | |
8328 (let ((sig-list (verilog-signals-not-in | |
8329 (verilog-modi-get-gparams submodi) | |
8330 skip-pins)) | |
8331 (vl-dir "parameter")) | |
8332 (when sig-list | |
8333 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8334 (indent-to indent-pt) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8335 ;; Note these are searched for in verilog-read-sub-decls. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8336 (insert "// Parameters\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8337 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8338 (verilog-auto-inst-port port indent-pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8339 tpl-list tpl-num nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8340 sig-list))) |
79545 | 8341 ;; Kill extra semi |
8342 (save-excursion | |
8343 (cond (did-first | |
8344 (re-search-backward "," pt t) | |
8345 (delete-char 1) | |
8346 (insert ")") | |
8347 (search-forward "\n") ;; Added by inst-port | |
8348 (delete-backward-char 1) | |
8349 (if (search-forward ")" nil t) ;; From user, moved up a line | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8350 (delete-backward-char 1))))))))) |
79545 | 8351 |
8352 (defun verilog-auto-reg () | |
8353 "Expand AUTOREG statements, as part of \\[verilog-auto]. | |
8354 Make reg statements for any output that isn't already declared, | |
8355 and isn't a wire output from a block. | |
8356 | |
8357 Limitations: | |
8358 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8359 | |
8360 This does NOT work on memories, declare those yourself. | |
8361 | |
8362 An example: | |
8363 | |
8364 module ex_reg (o,i) | |
8365 output o; | |
8366 input i; | |
8367 /*AUTOREG*/ | |
8368 always o = i; | |
8369 endmodule | |
8370 | |
8371 Typing \\[verilog-auto] will make this into: | |
8372 | |
8373 module ex_reg (o,i) | |
8374 output o; | |
8375 input i; | |
8376 /*AUTOREG*/ | |
8377 // Beginning of automatic regs (for this module's undeclared outputs) | |
8378 reg o; | |
8379 // End of automatics | |
8380 always o = i; | |
8381 endmodule" | |
8382 (save-excursion | |
8383 ;; Point must be at insertion point. | |
8384 (let* ((indent-pt (current-indentation)) | |
8385 (modi (verilog-modi-current)) | |
8386 (sig-list (verilog-signals-not-in | |
8387 (verilog-modi-get-outputs modi) | |
8388 (append (verilog-modi-get-wires modi) | |
8389 (verilog-modi-get-regs modi) | |
8390 (verilog-modi-get-assigns modi) | |
8391 (verilog-modi-get-consts modi) | |
8392 (verilog-modi-get-gparams modi) | |
8393 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8394 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8395 (forward-line 1) |
8396 (when sig-list | |
8397 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | |
8398 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8399 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8400 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8401 |
8402 (defun verilog-auto-reg-input () | |
8403 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | |
8404 Make reg statements instantiation inputs that aren't already declared. | |
8405 This is useful for making a top level shell for testing the module that is | |
8406 to be instantiated. | |
8407 | |
8408 Limitations: | |
8409 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8410 | |
8411 This does NOT work on memories, declare those yourself. | |
8412 | |
8413 An example (see `verilog-auto-inst' for what else is going on here): | |
8414 | |
8415 module ex_reg_input (o,i) | |
8416 output o; | |
8417 input i; | |
8418 /*AUTOREGINPUT*/ | |
8419 inst inst (/*AUTOINST*/); | |
8420 endmodule | |
8421 | |
8422 Typing \\[verilog-auto] will make this into: | |
8423 | |
8424 module ex_reg_input (o,i) | |
8425 output o; | |
8426 input i; | |
8427 /*AUTOREGINPUT*/ | |
8428 // Beginning of automatic reg inputs (for undeclared ... | |
8429 reg [31:0] iv; // From inst of inst.v | |
8430 // End of automatics | |
8431 inst inst (/*AUTOINST*/ | |
8432 // Outputs | |
8433 .o (o[31:0]), | |
8434 // Inputs | |
8435 .iv (iv)); | |
8436 endmodule" | |
8437 (save-excursion | |
8438 ;; Point must be at insertion point. | |
8439 (let* ((indent-pt (current-indentation)) | |
8440 (modi (verilog-modi-current)) | |
8441 (sig-list (verilog-signals-combine-bus | |
8442 (verilog-signals-not-in | |
8443 (append (verilog-modi-get-sub-inputs modi) | |
8444 (verilog-modi-get-sub-inouts modi)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8445 (verilog-modi-get-signals modi))))) |
79545 | 8446 (forward-line 1) |
8447 (when sig-list | |
8448 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | |
8449 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8450 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8451 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8452 |
8453 (defun verilog-auto-wire () | |
8454 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | |
8455 Make wire statements for instantiations outputs that aren't | |
8456 already declared. | |
8457 | |
8458 Limitations: | |
8459 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'), | |
8460 and all busses must have widths, such as those from AUTOINST, or using [] | |
8461 in AUTO_TEMPLATEs. | |
8462 | |
8463 This does NOT work on memories or SystemVerilog .name connections, | |
8464 declare those yourself. | |
8465 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8466 Verilog-mode will add \"Couldn't Merge\" comments to signals it cannot |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8467 determine how to bus together. This occurs when you have ports with |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8468 non-numeric or non-sequential bus subscripts. If Verilog-Mode |
79545 | 8469 mis-guessed, you'll have to declare them yourself. |
8470 | |
8471 An example (see `verilog-auto-inst' for what else is going on here): | |
8472 | |
8473 module ex_wire (o,i) | |
8474 output o; | |
8475 input i; | |
8476 /*AUTOWIRE*/ | |
8477 inst inst (/*AUTOINST*/); | |
8478 endmodule | |
8479 | |
8480 Typing \\[verilog-auto] will make this into: | |
8481 | |
8482 module ex_wire (o,i) | |
8483 output o; | |
8484 input i; | |
8485 /*AUTOWIRE*/ | |
8486 // Beginning of automatic wires | |
8487 wire [31:0] ov; // From inst of inst.v | |
8488 // End of automatics | |
8489 inst inst (/*AUTOINST*/ | |
8490 // Outputs | |
8491 .ov (ov[31:0]), | |
8492 // Inputs | |
8493 .i (i)); | |
8494 wire o = | ov; | |
8495 endmodule" | |
8496 (save-excursion | |
8497 ;; Point must be at insertion point. | |
8498 (let* ((indent-pt (current-indentation)) | |
8499 (modi (verilog-modi-current)) | |
8500 (sig-list (verilog-signals-combine-bus | |
8501 (verilog-signals-not-in | |
8502 (append (verilog-modi-get-sub-outputs modi) | |
8503 (verilog-modi-get-sub-inouts modi)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8504 (verilog-modi-get-signals modi))))) |
79545 | 8505 (forward-line 1) |
8506 (when sig-list | |
8507 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | |
8508 (verilog-insert-definition sig-list "wire" indent-pt nil) | |
8509 (verilog-modi-cache-add-wires modi sig-list) | |
8510 (verilog-insert-indent "// End of automatics\n") | |
8511 (when nil ;; Too slow on huge modules, plus makes everyone's module change | |
8512 (beginning-of-line) | |
8513 (setq pnt (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
8514 (verilog-pretty-declarations quiet) |
79545 | 8515 (goto-char pnt) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8516 (verilog-pretty-expr "//")))))) |
79545 | 8517 |
8518 (defun verilog-auto-output () | |
8519 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. | |
8520 Make output statements for any output signal from an /*AUTOINST*/ that | |
8521 isn't a input to another AUTOINST. This is useful for modules which | |
8522 only instantiate other modules. | |
8523 | |
8524 Limitations: | |
8525 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8526 | |
8527 If placed inside the parenthesis of a module declaration, it creates | |
8528 Verilog 2001 style, else uses Verilog 1995 style. | |
8529 | |
8530 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8531 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8532 | |
8533 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8534 | |
8535 Signals matching `verilog-auto-output-ignore-regexp' are not included. | |
8536 | |
8537 An example (see `verilog-auto-inst' for what else is going on here): | |
8538 | |
8539 module ex_output (ov,i) | |
8540 input i; | |
8541 /*AUTOOUTPUT*/ | |
8542 inst inst (/*AUTOINST*/); | |
8543 endmodule | |
8544 | |
8545 Typing \\[verilog-auto] will make this into: | |
8546 | |
8547 module ex_output (ov,i) | |
8548 input i; | |
8549 /*AUTOOUTPUT*/ | |
8550 // Beginning of automatic outputs (from unused autoinst outputs) | |
8551 output [31:0] ov; // From inst of inst.v | |
8552 // End of automatics | |
8553 inst inst (/*AUTOINST*/ | |
8554 // Outputs | |
8555 .ov (ov[31:0]), | |
8556 // Inputs | |
8557 .i (i)); | |
8558 endmodule" | |
8559 (save-excursion | |
8560 ;; Point must be at insertion point. | |
8561 (let* ((indent-pt (current-indentation)) | |
8562 (v2k (verilog-in-paren)) | |
8563 (modi (verilog-modi-current)) | |
8564 (sig-list (verilog-signals-not-in | |
8565 (verilog-modi-get-sub-outputs modi) | |
8566 (append (verilog-modi-get-outputs modi) | |
8567 (verilog-modi-get-inouts modi) | |
8568 (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8569 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8570 (setq sig-list (verilog-signals-not-matching-regexp |
8571 sig-list verilog-auto-output-ignore-regexp)) | |
8572 (forward-line 1) | |
8573 (when v2k (verilog-repair-open-comma)) | |
8574 (when sig-list | |
8575 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | |
8576 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8577 (verilog-modi-cache-add-outputs modi sig-list) | |
8578 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8579 (when v2k (verilog-repair-close-comma))))) |
79545 | 8580 |
8581 (defun verilog-auto-output-every () | |
8582 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | |
8583 Make output statements for any signals that aren't primary inputs or | |
8584 outputs already. This makes every signal in the design a output. This is | |
8585 useful to get Synopsys to preserve every signal in the design, since it | |
8586 won't optimize away the outputs. | |
8587 | |
8588 An example: | |
8589 | |
8590 module ex_output_every (o,i,tempa,tempb) | |
8591 output o; | |
8592 input i; | |
8593 /*AUTOOUTPUTEVERY*/ | |
8594 wire tempa = i; | |
8595 wire tempb = tempa; | |
8596 wire o = tempb; | |
8597 endmodule | |
8598 | |
8599 Typing \\[verilog-auto] will make this into: | |
8600 | |
8601 module ex_output_every (o,i,tempa,tempb) | |
8602 output o; | |
8603 input i; | |
8604 /*AUTOOUTPUTEVERY*/ | |
8605 // Beginning of automatic outputs (every signal) | |
8606 output tempb; | |
8607 output tempa; | |
8608 // End of automatics | |
8609 wire tempa = i; | |
8610 wire tempb = tempa; | |
8611 wire o = tempb; | |
8612 endmodule" | |
8613 (save-excursion | |
8614 ;;Point must be at insertion point | |
8615 (let* ((indent-pt (current-indentation)) | |
8616 (v2k (verilog-in-paren)) | |
8617 (modi (verilog-modi-current)) | |
8618 (sig-list (verilog-signals-combine-bus | |
8619 (verilog-signals-not-in | |
8620 (verilog-modi-get-signals modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8621 (verilog-modi-get-ports modi))))) |
79545 | 8622 (forward-line 1) |
8623 (when v2k (verilog-repair-open-comma)) | |
8624 (when sig-list | |
8625 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | |
8626 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8627 (verilog-modi-cache-add-outputs modi sig-list) | |
8628 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8629 (when v2k (verilog-repair-close-comma))))) |
79545 | 8630 |
8631 (defun verilog-auto-input () | |
8632 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. | |
8633 Make input statements for any input signal into an /*AUTOINST*/ that | |
8634 isn't declared elsewhere inside the module. This is useful for modules which | |
8635 only instantiate other modules. | |
8636 | |
8637 Limitations: | |
8638 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8639 | |
8640 If placed inside the parenthesis of a module declaration, it creates | |
8641 Verilog 2001 style, else uses Verilog 1995 style. | |
8642 | |
8643 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8644 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8645 | |
8646 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8647 | |
8648 Signals matching `verilog-auto-input-ignore-regexp' are not included. | |
8649 | |
8650 An example (see `verilog-auto-inst' for what else is going on here): | |
8651 | |
8652 module ex_input (ov,i) | |
8653 output [31:0] ov; | |
8654 /*AUTOINPUT*/ | |
8655 inst inst (/*AUTOINST*/); | |
8656 endmodule | |
8657 | |
8658 Typing \\[verilog-auto] will make this into: | |
8659 | |
8660 module ex_input (ov,i) | |
8661 output [31:0] ov; | |
8662 /*AUTOINPUT*/ | |
8663 // Beginning of automatic inputs (from unused autoinst inputs) | |
8664 input i; // From inst of inst.v | |
8665 // End of automatics | |
8666 inst inst (/*AUTOINST*/ | |
8667 // Outputs | |
8668 .ov (ov[31:0]), | |
8669 // Inputs | |
8670 .i (i)); | |
8671 endmodule" | |
8672 (save-excursion | |
8673 (let* ((indent-pt (current-indentation)) | |
8674 (v2k (verilog-in-paren)) | |
8675 (modi (verilog-modi-current)) | |
8676 (sig-list (verilog-signals-not-in | |
8677 (verilog-modi-get-sub-inputs modi) | |
8678 (append (verilog-modi-get-inputs modi) | |
8679 (verilog-modi-get-inouts modi) | |
8680 (verilog-modi-get-wires modi) | |
8681 (verilog-modi-get-regs modi) | |
8682 (verilog-modi-get-consts modi) | |
8683 (verilog-modi-get-gparams modi) | |
8684 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8685 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8686 (setq sig-list (verilog-signals-not-matching-regexp |
8687 sig-list verilog-auto-input-ignore-regexp)) | |
8688 (forward-line 1) | |
8689 (when v2k (verilog-repair-open-comma)) | |
8690 (when sig-list | |
8691 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | |
8692 (verilog-insert-definition sig-list "input" indent-pt v2k) | |
8693 (verilog-modi-cache-add-inputs modi sig-list) | |
8694 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8695 (when v2k (verilog-repair-close-comma))))) |
79545 | 8696 |
8697 (defun verilog-auto-inout () | |
8698 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. | |
8699 Make inout statements for any inout signal in an /*AUTOINST*/ that | |
8700 isn't declared elsewhere inside the module. | |
8701 | |
8702 Limitations: | |
8703 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8704 | |
8705 If placed inside the parenthesis of a module declaration, it creates | |
8706 Verilog 2001 style, else uses Verilog 1995 style. | |
8707 | |
8708 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8709 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8710 | |
8711 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8712 | |
8713 Signals matching `verilog-auto-inout-ignore-regexp' are not included. | |
8714 | |
8715 An example (see `verilog-auto-inst' for what else is going on here): | |
8716 | |
8717 module ex_inout (ov,i) | |
8718 input i; | |
8719 /*AUTOINOUT*/ | |
8720 inst inst (/*AUTOINST*/); | |
8721 endmodule | |
8722 | |
8723 Typing \\[verilog-auto] will make this into: | |
8724 | |
8725 module ex_inout (ov,i) | |
8726 input i; | |
8727 /*AUTOINOUT*/ | |
8728 // Beginning of automatic inouts (from unused autoinst inouts) | |
8729 inout [31:0] ov; // From inst of inst.v | |
8730 // End of automatics | |
8731 inst inst (/*AUTOINST*/ | |
8732 // Inouts | |
8733 .ov (ov[31:0]), | |
8734 // Inputs | |
8735 .i (i)); | |
8736 endmodule" | |
8737 (save-excursion | |
8738 ;; Point must be at insertion point. | |
8739 (let* ((indent-pt (current-indentation)) | |
8740 (v2k (verilog-in-paren)) | |
8741 (modi (verilog-modi-current)) | |
8742 (sig-list (verilog-signals-not-in | |
8743 (verilog-modi-get-sub-inouts modi) | |
8744 (append (verilog-modi-get-outputs modi) | |
8745 (verilog-modi-get-inouts modi) | |
8746 (verilog-modi-get-inputs modi) | |
8747 (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8748 (verilog-modi-get-sub-outputs modi))))) |
79545 | 8749 (setq sig-list (verilog-signals-not-matching-regexp |
8750 sig-list verilog-auto-inout-ignore-regexp)) | |
8751 (forward-line 1) | |
8752 (when v2k (verilog-repair-open-comma)) | |
8753 (when sig-list | |
8754 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | |
8755 (verilog-insert-definition sig-list "inout" indent-pt v2k) | |
8756 (verilog-modi-cache-add-inouts modi sig-list) | |
8757 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8758 (when v2k (verilog-repair-close-comma))))) |
79545 | 8759 |
8760 (defun verilog-auto-inout-module () | |
8761 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. | |
8762 Take input/output/inout statements from the specified module and insert | |
8763 into the current module. This is useful for making null templates and | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8764 shell modules which need to have identical I/O with another module. Any |
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
8765 I/O which are already defined in this module will not be redefined. |
79545 | 8766 |
8767 Limitations: | |
8768 If placed inside the parenthesis of a module declaration, it creates | |
8769 Verilog 2001 style, else uses Verilog 1995 style. | |
8770 | |
8771 Concatenation and outputting partial busses is not supported. | |
8772 | |
8773 Module names must be resolvable to filenames. See `verilog-auto-inst'. | |
8774 | |
8775 Signals are not inserted in the same order as in the original module, | |
8776 though they will appear to be in the same order to a AUTOINST | |
8777 instantiating either module. | |
8778 | |
8779 An example: | |
8780 | |
8781 module ex_shell (/*AUTOARG*/) | |
8782 /*AUTOINOUTMODULE(\"ex_main\")*/ | |
8783 endmodule | |
8784 | |
8785 module ex_main (i,o,io) | |
8786 input i; | |
8787 output o; | |
8788 inout io; | |
8789 endmodule | |
8790 | |
8791 Typing \\[verilog-auto] will make this into: | |
8792 | |
8793 module ex_shell (/*AUTOARG*/i,o,io) | |
8794 /*AUTOINOUTMODULE(\"ex_main\")*/ | |
8795 // Beginning of automatic in/out/inouts (from specific module) | |
8796 input i; | |
8797 output o; | |
8798 inout io; | |
8799 // End of automatics | |
8800 endmodule" | |
8801 (save-excursion | |
8802 (let* ((submod (car (verilog-read-auto-params 1))) submodi) | |
8803 ;; Lookup position, etc of co-module | |
8804 ;; Note this may raise an error | |
8805 (when (setq submodi (verilog-modi-lookup submod t)) | |
8806 (let* ((indent-pt (current-indentation)) | |
8807 (v2k (verilog-in-paren)) | |
8808 (modi (verilog-modi-current)) | |
8809 (sig-list-i (verilog-signals-not-in | |
8810 (verilog-modi-get-inputs submodi) | |
8811 (append (verilog-modi-get-inputs modi)))) | |
8812 (sig-list-o (verilog-signals-not-in | |
8813 (verilog-modi-get-outputs submodi) | |
8814 (append (verilog-modi-get-outputs modi)))) | |
8815 (sig-list-io (verilog-signals-not-in | |
8816 (verilog-modi-get-inouts submodi) | |
8817 (append (verilog-modi-get-inouts modi))))) | |
8818 (forward-line 1) | |
8819 (when v2k (verilog-repair-open-comma)) | |
8820 (when (or sig-list-i sig-list-o sig-list-io) | |
8821 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") | |
8822 ;; Don't sort them so a upper AUTOINST will match the main module | |
8823 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) | |
8824 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t) | |
8825 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | |
8826 (verilog-modi-cache-add-inputs modi sig-list-i) | |
8827 (verilog-modi-cache-add-outputs modi sig-list-o) | |
8828 (verilog-modi-cache-add-inouts modi sig-list-io) | |
8829 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8830 (when v2k (verilog-repair-close-comma))))))) |
79545 | 8831 |
8832 (defun verilog-auto-sense-sigs (modi presense-sigs) | |
8833 "Return list of signals for current AUTOSENSE block." | |
8834 (let* ((sigss (verilog-read-always-signals)) | |
8835 (sig-list (verilog-signals-not-params | |
8836 (verilog-signals-not-in (verilog-alw-get-inputs sigss) | |
8837 (append (and (not verilog-auto-sense-include-inputs) | |
8838 (verilog-alw-get-outputs sigss)) | |
8839 (verilog-modi-get-consts modi) | |
8840 (verilog-modi-get-gparams modi) | |
8841 presense-sigs))))) | |
8842 sig-list)) | |
8843 | |
8844 (defun verilog-auto-sense () | |
8845 "Expand AUTOSENSE statements, as part of \\[verilog-auto]. | |
8846 Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short) | |
8847 with one automatically derived from all inputs declared in the always | |
8848 statement. Signals that are generated within the same always block are NOT | |
8849 placed into the sensitivity list (see `verilog-auto-sense-include-inputs'). | |
8850 Long lines are split based on the `fill-column', see \\[set-fill-column]. | |
8851 | |
8852 Limitations: | |
8853 Verilog does not allow memories (multidimensional arrays) in sensitivity | |
8854 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment. | |
8855 | |
8856 Constant signals: | |
8857 AUTOSENSE cannot always determine if a `define is a constant or a signal | |
8858 (it could be in a include file for example). If a `define or other signal | |
8859 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT | |
8860 declaration anywhere in the module (parenthesis are required): | |
8861 | |
8862 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */ | |
8863 | |
8864 Better yet, use a parameter, which will be understood to be constant | |
8865 automatically. | |
8866 | |
8867 OOps! | |
8868 If AUTOSENSE makes a mistake, please report it. (First try putting | |
8869 a begin/end after your always!) As a workaround, if a signal that | |
8870 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above. | |
8871 If a signal should be in the sensitivity list wasn't, placing it before | |
8872 the /*AUTOSENSE*/ comment will prevent it from being deleted when the | |
8873 autos are updated (or added if it occurs there already). | |
8874 | |
8875 An example: | |
8876 | |
8877 always @ (/*AUTOSENSE*/) begin | |
8878 /* AUTO_CONSTANT (`constant) */ | |
8879 outin = ina | inb | `constant; | |
8880 out = outin; | |
8881 end | |
8882 | |
8883 Typing \\[verilog-auto] will make this into: | |
8884 | |
8885 always @ (/*AUTOSENSE*/ina or inb) begin | |
8886 /* AUTO_CONSTANT (`constant) */ | |
8887 outin = ina | inb | `constant; | |
8888 out = outin; | |
8889 end" | |
8890 (save-excursion | |
8891 ;; Find beginning | |
8892 (let* ((start-pt (save-excursion | |
8893 (verilog-re-search-backward "(" nil t) | |
8894 (point))) | |
8895 (indent-pt (save-excursion | |
8896 (or (and (goto-char start-pt) (1+ (current-column))) | |
8897 (current-indentation)))) | |
8898 (modi (verilog-modi-current)) | |
8899 (sig-memories (verilog-signals-memory | |
8900 (append | |
8901 (verilog-modi-get-regs modi) | |
8902 (verilog-modi-get-wires modi)))) | |
8903 sig-list not-first presense-sigs) | |
8904 ;; Read signals in always, eliminate outputs from sense list | |
8905 (setq presense-sigs (verilog-signals-from-signame | |
8906 (save-excursion | |
8907 (verilog-read-signals start-pt (point))))) | |
8908 (setq sig-list (verilog-auto-sense-sigs modi presense-sigs)) | |
8909 (when sig-memories | |
8910 (let ((tlen (length sig-list))) | |
8911 (setq sig-list (verilog-signals-not-in sig-list sig-memories)) | |
8912 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ ")))) | |
8913 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" | |
8914 (save-excursion (goto-char (point)) | |
8915 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
8916 (verilog-re-search-backward "\\s-" start-pt t) | |
8917 (while (looking-at "\\s-`endif") | |
8918 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
8919 (verilog-re-search-backward "\\s-" start-pt t)) | |
8920 (not (looking-at "\\s-or\\b")))) | |
8921 (setq not-first t)) | |
8922 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
8923 (while sig-list | |
8924 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or | |
8925 (insert "\n") | |
8926 (indent-to indent-pt) | |
8927 (if not-first (insert "or "))) | |
8928 (not-first (insert " or "))) | |
8929 (insert (verilog-sig-name (car sig-list))) | |
8930 (setq sig-list (cdr sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8931 not-first t))))) |
79545 | 8932 |
8933 (defun verilog-auto-reset () | |
8934 "Expand AUTORESET statements, as part of \\[verilog-auto]. | |
8935 Replace the /*AUTORESET*/ comment with code to initialize all | |
8936 registers set elsewhere in the always block. | |
8937 | |
8938 Limitations: | |
8939 AUTORESET will not clear memories. | |
8940 | |
8941 AUTORESET uses <= if there are any <= in the block, else it uses =. | |
8942 | |
8943 /*AUTORESET*/ presumes that any signals mentioned between the previous | |
8944 begin/case/if statement and the AUTORESET comment are being reset manually | |
8945 and should not be automatically reset. This includes omitting any signals | |
8946 used on the right hand side of assignments. | |
8947 | |
8948 By default, AUTORESET will include the width of the signal in the autos, | |
8949 this is a recent change. To control this behavior, see | |
8950 `verilog-auto-reset-widths'. | |
8951 | |
8952 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
8953 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
8954 them to a one. | |
8955 | |
8956 An example: | |
8957 | |
8958 always @(posedge clk or negedge reset_l) begin | |
8959 if (!reset_l) begin | |
8960 c <= 1; | |
8961 /*AUTORESET*/ | |
8962 end | |
8963 else begin | |
8964 a <= in_a; | |
8965 b <= in_b; | |
8966 c <= in_c; | |
8967 end | |
8968 end | |
8969 | |
8970 Typing \\[verilog-auto] will make this into: | |
8971 | |
8972 always @(posedge core_clk or negedge reset_l) begin | |
8973 if (!reset_l) begin | |
8974 c <= 1; | |
8975 /*AUTORESET*/ | |
8976 // Beginning of autoreset for uninitialized flops | |
8977 a <= 0; | |
8978 b <= 0; | |
8979 // End of automatics | |
8980 end | |
8981 else begin | |
8982 a <= in_a; | |
8983 b <= in_b; | |
8984 c <= in_c; | |
8985 end | |
8986 end" | |
8987 | |
8988 (interactive) | |
8989 (save-excursion | |
8990 ;; Find beginning | |
8991 (let* ((indent-pt (current-indentation)) | |
8992 (modi (verilog-modi-current)) | |
8993 (all-list (verilog-modi-get-signals modi)) | |
8994 sigss sig-list prereset-sigs assignment-str) | |
8995 ;; Read signals in always, eliminate outputs from reset list | |
8996 (setq prereset-sigs (verilog-signals-from-signame | |
8997 (save-excursion | |
8998 (verilog-read-signals | |
8999 (save-excursion | |
9000 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t) | |
9001 (point)) | |
9002 (point))))) | |
9003 (save-excursion | |
9004 (verilog-re-search-backward "@" nil t) | |
9005 (setq sigss (verilog-read-always-signals))) | |
9006 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss) | |
9007 (concat " <= " verilog-assignment-delay) | |
9008 " = ")) | |
9009 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss) | |
9010 prereset-sigs)) | |
9011 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
9012 (when sig-list | |
9013 (insert "\n"); | |
9014 (indent-to indent-pt) | |
9015 (insert "// Beginning of autoreset for uninitialized flops\n"); | |
9016 (indent-to indent-pt) | |
9017 (while sig-list | |
9018 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths | |
9019 (car sig-list)))) | |
9020 (insert (verilog-sig-name sig) | |
9021 assignment-str | |
9022 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | |
9023 ";\n") | |
9024 (indent-to indent-pt) | |
9025 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9026 (insert "// End of automatics"))))) |
79545 | 9027 |
9028 (defun verilog-auto-tieoff () | |
9029 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | |
9030 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | |
9031 signals to deasserted. | |
9032 | |
9033 /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same | |
9034 input/output list as another module, but no internals. Specifically, it | |
9035 finds all outputs in the module, and if that input is not otherwise declared | |
9036 as a register or wire, creates a tieoff. | |
9037 | |
9038 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
9039 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
9040 them to a one. | |
9041 | |
9042 An example of making a stub for another module: | |
9043 | |
9044 module FooStub (/*AUTOINST*/); | |
9045 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9046 /*AUTOTIEOFF*/ | |
9047 // verilator lint_off UNUSED | |
9048 wire _unused_ok = &{1'b0, | |
9049 /*AUTOUNUSED*/ | |
9050 1'b0}; | |
9051 // verilator lint_on UNUSED | |
9052 endmodule | |
9053 | |
9054 Typing \\[verilog-auto] will make this into: | |
9055 | |
9056 module FooStub (/*AUTOINST*/...); | |
9057 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9058 // Beginning of autotieoff | |
9059 output [2:0] foo; | |
9060 // End of automatics | |
9061 | |
9062 /*AUTOTIEOFF*/ | |
9063 // Beginning of autotieoff | |
9064 wire [2:0] foo = 3'b0; | |
9065 // End of automatics | |
9066 ... | |
9067 endmodule" | |
9068 (interactive) | |
9069 (save-excursion | |
9070 ;; Find beginning | |
9071 (let* ((indent-pt (current-indentation)) | |
9072 (modi (verilog-modi-current)) | |
9073 (sig-list (verilog-signals-not-in | |
9074 (verilog-modi-get-outputs modi) | |
9075 (append (verilog-modi-get-wires modi) | |
9076 (verilog-modi-get-regs modi) | |
9077 (verilog-modi-get-assigns modi) | |
9078 (verilog-modi-get-consts modi) | |
9079 (verilog-modi-get-gparams modi) | |
9080 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9081 (verilog-modi-get-sub-inouts modi))))) |
79545 | 9082 (when sig-list |
9083 (forward-line 1) | |
9084 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | |
9085 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9086 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list | |
9087 (while sig-list | |
9088 (let ((sig (car sig-list))) | |
9089 (verilog-insert-one-definition sig "wire" indent-pt) | |
9090 (indent-to (max 48 (+ indent-pt 40))) | |
9091 (insert "= " (verilog-sig-tieoff sig) | |
9092 ";\n") | |
9093 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9094 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9095 |
9096 (defun verilog-auto-unused () | |
9097 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | |
9098 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | |
9099 input and inout signals. | |
9100 | |
9101 /*AUTOUNUSED*/ is used to make stub modules; modules that have the same | |
9102 input/output list as another module, but no internals. Specifically, it | |
9103 finds all inputs and inouts in the module, and if that input is not otherwise | |
9104 used, adds it to a comma separated list. | |
9105 | |
9106 The comma separated list is intended to be used to create a _unused_ok | |
9107 signal. Using the exact name \"_unused_ok\" for name of the temporary | |
9108 signal is recommended as it will insure maximum forward compatibility, it | |
9109 also makes lint warnings easy to understand; ignore any unused warnings | |
9110 with \"unused\" in the signal name. | |
9111 | |
9112 To reduce simulation time, the _unused_ok signal should be forced to a | |
9113 constant to prevent wiggling. The easiest thing to do is use a | |
9114 reduction-and with 1'b0 as shown. | |
9115 | |
9116 This way all unused signals are in one place, making it convenient to add | |
9117 your tool's specific pragmas around the assignment to disable any unused | |
9118 warnings. | |
9119 | |
9120 You can add signals you do not want included in AUTOUNUSED with | |
9121 `verilog-auto-unused-ignore-regexp'. | |
9122 | |
9123 An example of making a stub for another module: | |
9124 | |
9125 module FooStub (/*AUTOINST*/); | |
9126 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9127 /*AUTOTIEOFF*/ | |
9128 // verilator lint_off UNUSED | |
9129 wire _unused_ok = &{1'b0, | |
9130 /*AUTOUNUSED*/ | |
9131 1'b0}; | |
9132 // verilator lint_on UNUSED | |
9133 endmodule | |
9134 | |
9135 Typing \\[verilog-auto] will make this into: | |
9136 | |
9137 ... | |
9138 // verilator lint_off UNUSED | |
9139 wire _unused_ok = &{1'b0, | |
9140 /*AUTOUNUSED*/ | |
9141 // Beginning of automatics | |
9142 unused_input_a, | |
9143 unused_input_b, | |
9144 unused_input_c, | |
9145 // End of automatics | |
9146 1'b0}; | |
9147 // verilator lint_on UNUSED | |
9148 endmodule" | |
9149 (interactive) | |
9150 (save-excursion | |
9151 ;; Find beginning | |
9152 (let* ((indent-pt (progn (search-backward "/*") (current-column))) | |
9153 (modi (verilog-modi-current)) | |
9154 (sig-list (verilog-signals-not-in | |
9155 (append (verilog-modi-get-inputs modi) | |
9156 (verilog-modi-get-inouts modi)) | |
9157 (append (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9158 (verilog-modi-get-sub-inouts modi))))) |
79545 | 9159 (setq sig-list (verilog-signals-not-matching-regexp |
9160 sig-list verilog-auto-unused-ignore-regexp)) | |
9161 (when sig-list | |
9162 (forward-line 1) | |
9163 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | |
9164 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9165 (while sig-list | |
9166 (let ((sig (car sig-list))) | |
9167 (indent-to indent-pt) | |
9168 (insert (verilog-sig-name sig) ",\n") | |
9169 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9170 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9171 |
9172 (defun verilog-enum-ascii (signm elim-regexp) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9173 "Convert a enum name SIGNM to a ascii string for insertion. |
79545 | 9174 Remove user provided prefix ELIM-REGEXP." |
9175 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | |
9176 (let ((case-fold-search t)) | |
9177 ;; All upper becomes all lower for readability | |
9178 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm)))) | |
9179 | |
9180 (defun verilog-auto-ascii-enum () | |
9181 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto]. | |
9182 Create a register to contain the ASCII decode of a enumerated signal type. | |
9183 This will allow trace viewers to show the ASCII name of states. | |
9184 | |
9185 First, parameters are built into a enumeration using the synopsys enum | |
9186 comment. The comment must be between the keyword and the symbol. | |
79546 | 9187 \(Annoying, but that's what Synopsys's dc_shell FSM reader requires.) |
79545 | 9188 |
9189 Next, registers which that enum applies to are also tagged with the same | |
9190 enum. Synopsys also suggests labeling state vectors, but `verilog-mode' | |
9191 doesn't care. | |
9192 | |
9193 Finally, a AUTOASCIIENUM command is used. | |
9194 | |
9195 The first parameter is the name of the signal to be decoded. | |
9196 | |
9197 The second parameter is the name to store the ASCII code into. For the | |
9198 signal foo, I suggest the name _foo__ascii, where the leading _ indicates | |
9199 a signal that is just for simulation, and the magic characters _ascii | |
9200 tell viewers like Dinotrace to display in ASCII format. | |
9201 | |
9202 The final optional parameter is a string which will be removed from the | |
9203 state names. | |
9204 | |
9205 An example: | |
9206 | |
9207 //== State enumeration | |
9208 parameter [2:0] // synopsys enum state_info | |
9209 SM_IDLE = 3'b000, | |
9210 SM_SEND = 3'b001, | |
9211 SM_WAIT1 = 3'b010; | |
9212 //== State variables | |
9213 reg [2:0] /* synopsys enum state_info */ | |
9214 state_r; /* synopsys state_vector state_r */ | |
9215 reg [2:0] /* synopsys enum state_info */ | |
9216 state_e1; | |
9217 | |
9218 //== ASCII state decoding | |
9219 | |
9220 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9221 | |
9222 Typing \\[verilog-auto] will make this into: | |
9223 | |
9224 ... same front matter ... | |
9225 | |
9226 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9227 // Beginning of automatic ASCII enum decoding | |
9228 reg [39:0] state_ascii_r; // Decode of state_r | |
9229 always @(state_r) begin | |
9230 case ({state_r}) | |
9231 SM_IDLE: state_ascii_r = \"idle \"; | |
9232 SM_SEND: state_ascii_r = \"send \"; | |
9233 SM_WAIT1: state_ascii_r = \"wait1\"; | |
9234 default: state_ascii_r = \"%Erro\"; | |
9235 endcase | |
9236 end | |
9237 // End of automatics" | |
9238 (save-excursion | |
9239 (let* ((params (verilog-read-auto-params 2 3)) | |
9240 (undecode-name (nth 0 params)) | |
9241 (ascii-name (nth 1 params)) | |
9242 (elim-regexp (nth 2 params)) | |
9243 ;; | |
9244 (indent-pt (current-indentation)) | |
9245 (modi (verilog-modi-current)) | |
9246 ;; | |
9247 (sig-list-consts (append (verilog-modi-get-consts modi) | |
9248 (verilog-modi-get-gparams modi))) | |
9249 (sig-list-all (append (verilog-modi-get-regs modi) | |
9250 (verilog-modi-get-outputs modi) | |
9251 (verilog-modi-get-inouts modi) | |
9252 (verilog-modi-get-inputs modi) | |
9253 (verilog-modi-get-wires modi))) | |
9254 ;; | |
9255 (undecode-sig (or (assoc undecode-name sig-list-all) | |
9256 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) | |
9257 (undecode-enum (or (verilog-sig-enum undecode-sig) | |
9258 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name))) | |
9259 ;; | |
9260 (enum-sigs (or (verilog-signals-matching-enum sig-list-consts undecode-enum) | |
9261 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum))) | |
9262 ;; | |
9263 (enum-chars 0) | |
9264 (ascii-chars 0)) | |
9265 ;; | |
9266 ;; Find number of ascii chars needed | |
9267 (let ((tmp-sigs enum-sigs)) | |
9268 (while tmp-sigs | |
9269 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs)))) | |
9270 ascii-chars (max ascii-chars (length (verilog-enum-ascii | |
9271 (verilog-sig-name (car tmp-sigs)) | |
9272 elim-regexp))) | |
9273 tmp-sigs (cdr tmp-sigs)))) | |
9274 ;; | |
9275 (forward-line 1) | |
9276 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") | |
9277 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) | |
9278 (concat "Decode of " undecode-name) nil nil)))) | |
9279 (verilog-insert-definition decode-sig-list "reg" indent-pt nil) | |
9280 (verilog-modi-cache-add-regs modi decode-sig-list)) | |
9281 ;; | |
9282 (verilog-insert-indent "always @(" undecode-name ") begin\n") | |
9283 (setq indent-pt (+ indent-pt verilog-indent-level)) | |
9284 (indent-to indent-pt) | |
9285 (insert "case ({" undecode-name "})\n") | |
9286 (setq indent-pt (+ indent-pt verilog-case-indent)) | |
9287 ;; | |
9288 (let ((tmp-sigs enum-sigs) | |
9289 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" (1+ (max 8 enum-chars)) | |
9290 ascii-name ascii-chars)) | |
9291 (errname (substring "%Error" 0 (min 6 ascii-chars)))) | |
9292 (while tmp-sigs | |
9293 (verilog-insert-indent | |
9294 (format chrfmt (concat (verilog-sig-name (car tmp-sigs)) ":") | |
9295 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs)) | |
9296 elim-regexp))) | |
9297 (setq tmp-sigs (cdr tmp-sigs))) | |
9298 (verilog-insert-indent (format chrfmt "default:" errname))) | |
9299 ;; | |
9300 (setq indent-pt (- indent-pt verilog-case-indent)) | |
9301 (verilog-insert-indent "endcase\n") | |
9302 (setq indent-pt (- indent-pt verilog-indent-level)) | |
9303 (verilog-insert-indent "end\n" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9304 "// End of automatics\n")))) |
79545 | 9305 |
9306 (defun verilog-auto-templated-rel () | |
9307 "Replace Templated relative line numbers with absolute line numbers. | |
9308 Internal use only. This hacks around the line numbers in AUTOINST Templates | |
9309 being different from the final output's line numbering." | |
9310 (let ((templateno 0) (template-line (list 0))) | |
9311 ;; Find line number each template is on | |
9312 (goto-char (point-min)) | |
9313 (while (search-forward "AUTO_TEMPLATE" nil t) | |
9314 (setq templateno (1+ templateno)) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9315 (setq template-line |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9316 (cons (count-lines (point-min) (point)) template-line))) |
79545 | 9317 (setq template-line (nreverse template-line)) |
9318 ;; Replace T# L# with absolute line number | |
9319 (goto-char (point-min)) | |
9320 (while (re-search-forward " Templated T\\([0-9]+\\) L\\([0-9]+\\)" nil t) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9321 (replace-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9322 (concat " Templated " |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9323 (int-to-string (+ (nth (string-to-number (match-string 1)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9324 template-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9325 (string-to-number (match-string 2))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9326 t t)))) |
79545 | 9327 |
9328 | |
9329 ;; | |
9330 ;; Auto top level | |
9331 ;; | |
9332 | |
9333 (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg | |
9334 "Expand AUTO statements. | |
9335 Look for any /*AUTO...*/ commands in the code, as used in | |
9336 instantiations or argument headers. Update the list of signals | |
9337 following the /*AUTO...*/ command. | |
9338 | |
9339 Use \\[verilog-delete-auto] to remove the AUTOs. | |
9340 | |
9341 Use \\[verilog-inject-auto] to insert AUTOs for the first time. | |
9342 | |
9343 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
9344 | |
9345 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are | |
9346 called before and after this function, respectively. | |
9347 | |
9348 For example: | |
9349 module (/*AUTOARG*/) | |
9350 /*AUTOINPUT*/ | |
9351 /*AUTOOUTPUT*/ | |
9352 /*AUTOWIRE*/ | |
9353 /*AUTOREG*/ | |
9354 somesub sub #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); | |
9355 | |
9356 You can also update the AUTOs from the shell using: | |
9357 emacs --batch <filenames.v> -f verilog-batch-auto | |
9358 Or fix indentation with: | |
9359 emacs --batch <filenames.v> -f verilog-batch-indent | |
9360 Likewise, you can delete or inject AUTOs with: | |
9361 emacs --batch <filenames.v> -f verilog-batch-delete-auto | |
9362 emacs --batch <filenames.v> -f verilog-batch-inject-auto | |
9363 | |
9364 Using \\[describe-function], see also: | |
9365 `verilog-auto-arg' for AUTOARG module instantiations | |
9366 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding | |
9367 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere | |
9368 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts | |
9369 `verilog-auto-input' for AUTOINPUT making hierarchy inputs | |
9370 `verilog-auto-inst' for AUTOINST instantiation pins | |
9371 `verilog-auto-star' for AUTOINST .* SystemVerilog pins | |
9372 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params | |
9373 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs | |
9374 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs | |
9375 `verilog-auto-reg' for AUTOREG registers | |
9376 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers | |
9377 `verilog-auto-reset' for AUTORESET flop resets | |
9378 `verilog-auto-sense' for AUTOSENSE always sensitivity lists | |
9379 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs | |
9380 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts | |
9381 `verilog-auto-wire' for AUTOWIRE instantiation wires | |
9382 | |
9383 `verilog-read-defines' for reading `define values | |
9384 `verilog-read-includes' for reading `includes | |
9385 | |
9386 If you have bugs with these autos, try contacting the AUTOAUTHOR | |
9387 Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com." | |
9388 (interactive) | |
9389 (unless noninteractive (message "Updating AUTOs...")) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9390 (if (fboundp 'dinotrace-unannotate-all) |
79545 | 9391 (dinotrace-unannotate-all)) |
9392 (let ((oldbuf (if (not (buffer-modified-p)) | |
9393 (buffer-string))) | |
9394 ;; Before version 20, match-string with font-lock returns a | |
9395 ;; vector that is not equal to the string. IE if on "input" | |
9396 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0))) | |
9397 (fontlocked (when (and (boundp 'font-lock-mode) | |
9398 font-lock-mode) | |
9399 (font-lock-mode nil) | |
9400 t))) | |
9401 (unwind-protect | |
9402 (save-excursion | |
9403 ;; If we're not in verilog-mode, change syntax table so parsing works right | |
9404 (unless (eq major-mode `verilog-mode) (verilog-mode)) | |
9405 ;; Allow user to customize | |
9406 (run-hooks 'verilog-before-auto-hook) | |
9407 ;; Try to save the user from needing to revert-file to reread file local-variables | |
9408 (verilog-auto-reeval-locals) | |
9409 (verilog-read-auto-lisp (point-min) (point-max)) | |
9410 (verilog-getopt-flags) | |
9411 ;; These two may seem obvious to do always, but on large includes it can be way too slow | |
9412 (when verilog-auto-read-includes | |
9413 (verilog-read-includes) | |
9414 (verilog-read-defines nil nil t)) | |
9415 ;; This particular ordering is important | |
9416 ;; INST: Lower modules correct, no internal dependencies, FIRST | |
9417 (verilog-preserve-cache | |
9418 ;; Clear existing autos else we'll be screwed by existing ones | |
9419 (verilog-delete-auto) | |
9420 ;; Injection if appropriate | |
9421 (when inject | |
9422 (verilog-inject-inst) | |
9423 (verilog-inject-sense) | |
9424 (verilog-inject-arg)) | |
9425 ;; | |
9426 (verilog-auto-search-do "/*AUTOINSTPARAM*/" 'verilog-auto-inst-param) | |
9427 (verilog-auto-search-do "/*AUTOINST*/" 'verilog-auto-inst) | |
9428 (verilog-auto-search-do ".*" 'verilog-auto-star) | |
9429 ;; Doesn't matter when done, but combine it with a common changer | |
9430 (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) | |
9431 (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) | |
9432 ;; Must be done before autoin/out as creates a reg | |
9433 (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum) | |
9434 ;; | |
9435 ;; first in/outs from other files | |
9436 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) | |
9437 ;; next in/outs which need previous sucked inputs first | |
9438 (verilog-auto-search-do "/*AUTOOUTPUT*/" 'verilog-auto-output) | |
9439 (verilog-auto-search-do "/*AUTOINPUT*/" 'verilog-auto-input) | |
9440 (verilog-auto-search-do "/*AUTOINOUT*/" 'verilog-auto-inout) | |
9441 ;; Then tie off those in/outs | |
9442 (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff) | |
9443 ;; Wires/regs must be after inputs/outputs | |
9444 (verilog-auto-search-do "/*AUTOWIRE*/" 'verilog-auto-wire) | |
9445 (verilog-auto-search-do "/*AUTOREG*/" 'verilog-auto-reg) | |
9446 (verilog-auto-search-do "/*AUTOREGINPUT*/" 'verilog-auto-reg-input) | |
9447 ;; outputevery needs AUTOOUTPUTs done first | |
9448 (verilog-auto-search-do "/*AUTOOUTPUTEVERY*/" 'verilog-auto-output-every) | |
9449 ;; After we've created all new variables | |
9450 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) | |
9451 ;; Must be after all inputs outputs are generated | |
9452 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) | |
9453 ;; Fix line numbers (comments only) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9454 (verilog-auto-templated-rel)) |
79545 | 9455 ;; |
9456 (run-hooks 'verilog-auto-hook) | |
9457 ;; | |
9458 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | |
9459 ;; | |
9460 ;; If end result is same as when started, clear modified flag | |
9461 (cond ((and oldbuf (equal oldbuf (buffer-string))) | |
9462 (set-buffer-modified-p nil) | |
9463 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | |
9464 (t (unless noninteractive (message "Updating AUTOs...done"))))) | |
9465 ;; Unwind forms | |
9466 (progn | |
9467 ;; Restore font-lock | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9468 (when fontlocked (font-lock-mode t)))))) |
79545 | 9469 |
9470 | |
9471 ;; | |
9472 ;; Skeleton based code insertion | |
9473 ;; | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9474 (defvar verilog-template-map |
79546 | 9475 (let ((map (make-sparse-keymap))) |
9476 (define-key map "a" 'verilog-sk-always) | |
9477 (define-key map "b" 'verilog-sk-begin) | |
9478 (define-key map "c" 'verilog-sk-case) | |
9479 (define-key map "f" 'verilog-sk-for) | |
9480 (define-key map "g" 'verilog-sk-generate) | |
9481 (define-key map "h" 'verilog-sk-header) | |
9482 (define-key map "i" 'verilog-sk-initial) | |
9483 (define-key map "j" 'verilog-sk-fork) | |
9484 (define-key map "m" 'verilog-sk-module) | |
9485 (define-key map "p" 'verilog-sk-primitive) | |
9486 (define-key map "r" 'verilog-sk-repeat) | |
9487 (define-key map "s" 'verilog-sk-specify) | |
9488 (define-key map "t" 'verilog-sk-task) | |
9489 (define-key map "w" 'verilog-sk-while) | |
9490 (define-key map "x" 'verilog-sk-casex) | |
9491 (define-key map "z" 'verilog-sk-casez) | |
9492 (define-key map "?" 'verilog-sk-if) | |
9493 (define-key map ":" 'verilog-sk-else-if) | |
9494 (define-key map "/" 'verilog-sk-comment) | |
9495 (define-key map "A" 'verilog-sk-assign) | |
9496 (define-key map "F" 'verilog-sk-function) | |
9497 (define-key map "I" 'verilog-sk-input) | |
9498 (define-key map "O" 'verilog-sk-output) | |
9499 (define-key map "S" 'verilog-sk-state-machine) | |
9500 (define-key map "=" 'verilog-sk-inout) | |
9501 (define-key map "W" 'verilog-sk-wire) | |
9502 (define-key map "R" 'verilog-sk-reg) | |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9503 (define-key map "D" 'verilog-sk-define-signal) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9504 map) |
79545 | 9505 "Keymap used in Verilog mode for smart template operations.") |
9506 | |
9507 | |
9508 ;; | |
9509 ;; Place the templates into Verilog Mode. They may be inserted under any key. | |
9510 ;; C-c C-t will be the default. If you use templates a lot, you | |
9511 ;; may want to consider moving the binding to another key in your .emacs | |
9512 ;; file. | |
9513 ;; | |
9514 ;(define-key verilog-mode-map "\C-ct" verilog-template-map) | |
9515 (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) | |
9516 | |
9517 ;;; ---- statement skeletons ------------------------------------------ | |
9518 | |
9519 (define-skeleton verilog-sk-prompt-condition | |
9520 "Prompt for the loop condition." | |
9521 "[condition]: " str ) | |
9522 | |
9523 (define-skeleton verilog-sk-prompt-init | |
9524 "Prompt for the loop init statement." | |
9525 "[initial statement]: " str ) | |
9526 | |
9527 (define-skeleton verilog-sk-prompt-inc | |
9528 "Prompt for the loop increment statement." | |
9529 "[increment statement]: " str ) | |
9530 | |
9531 (define-skeleton verilog-sk-prompt-name | |
9532 "Prompt for the name of something." | |
9533 "[name]: " str) | |
9534 | |
9535 (define-skeleton verilog-sk-prompt-clock | |
9536 "Prompt for the name of something." | |
9537 "name and edge of clock(s): " str) | |
9538 | |
9539 (defvar verilog-sk-reset nil) | |
9540 (defun verilog-sk-prompt-reset () | |
9541 "Prompt for the name of a state machine reset." | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9542 (setq verilog-sk-reset (read-string "name of reset: " "rst"))) |
79545 | 9543 |
9544 | |
9545 (define-skeleton verilog-sk-prompt-state-selector | |
9546 "Prompt for the name of a state machine selector." | |
9547 "name of selector (eg {a,b,c,d}): " str ) | |
9548 | |
9549 (define-skeleton verilog-sk-prompt-output | |
9550 "Prompt for the name of something." | |
9551 "output: " str) | |
9552 | |
9553 (define-skeleton verilog-sk-prompt-msb | |
9554 "Prompt for least significant bit specification." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9555 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 ) |
79545 | 9556 |
9557 (define-skeleton verilog-sk-prompt-lsb | |
9558 "Prompt for least significant bit specification." | |
9559 "lsb:" str ) | |
9560 | |
9561 (defvar verilog-sk-p nil) | |
9562 (define-skeleton verilog-sk-prompt-width | |
9563 "Prompt for a width specification." | |
9564 () | |
9565 (progn | |
9566 (setq verilog-sk-p (point)) | |
9567 (verilog-sk-prompt-msb) | |
9568 (if (> (point) verilog-sk-p) "] " " "))) | |
9569 | |
9570 (defun verilog-sk-header () | |
9571 "Insert a descriptive header at the top of the file." | |
9572 (interactive "*") | |
9573 (save-excursion | |
9574 (goto-char (point-min)) | |
9575 (verilog-sk-header-tmpl))) | |
9576 | |
9577 (define-skeleton verilog-sk-header-tmpl | |
9578 "Insert a comment block containing the module title, author, etc." | |
9579 "[Description]: " | |
9580 "// -*- Mode: Verilog -*-" | |
9581 "\n// Filename : " (buffer-name) | |
9582 "\n// Description : " str | |
9583 "\n// Author : " (user-full-name) | |
9584 "\n// Created On : " (current-time-string) | |
9585 "\n// Last Modified By: ." | |
9586 "\n// Last Modified On: ." | |
9587 "\n// Update Count : 0" | |
9588 "\n// Status : Unknown, Use with caution!" | |
9589 "\n") | |
9590 | |
9591 (define-skeleton verilog-sk-module | |
9592 "Insert a module definition." | |
9593 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9594 > "module " '(verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n |
79545 | 9595 > _ \n |
9596 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) | |
9597 | |
9598 (define-skeleton verilog-sk-primitive | |
9599 "Insert a task definition." | |
9600 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9601 > "primitive " '(verilog-sk-prompt-name) " ( " '(verilog-sk-prompt-output) ("input:" ", " str ) " );"\n |
79545 | 9602 > _ \n |
9603 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil)) | |
9604 | |
9605 (define-skeleton verilog-sk-task | |
9606 "Insert a task definition." | |
9607 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9608 > "task " '(verilog-sk-prompt-name) & ?; \n |
79545 | 9609 > _ \n |
9610 > "begin" \n | |
9611 > \n | |
9612 > (- verilog-indent-level-behavioral) "end" \n | |
9613 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil)) | |
9614 | |
9615 (define-skeleton verilog-sk-function | |
9616 "Insert a function definition." | |
9617 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9618 > "function [" '(verilog-sk-prompt-width) | -1 '(verilog-sk-prompt-name) ?; \n |
79545 | 9619 > _ \n |
9620 > "begin" \n | |
9621 > \n | |
9622 > (- verilog-indent-level-behavioral) "end" \n | |
9623 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil)) | |
9624 | |
9625 (define-skeleton verilog-sk-always | |
9626 "Insert always block. Uses the minibuffer to prompt | |
9627 for sensitivity list." | |
9628 () | |
9629 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
9630 > _ \n | |
9631 > (- verilog-indent-level-behavioral) "end" \n > | |
9632 ) | |
9633 | |
9634 (define-skeleton verilog-sk-initial | |
9635 "Insert an initial block." | |
9636 () | |
9637 > "initial begin\n" | |
9638 > _ \n | |
9639 > (- verilog-indent-level-behavioral) "end" \n > ) | |
9640 | |
9641 (define-skeleton verilog-sk-specify | |
9642 "Insert specify block. " | |
9643 () | |
9644 > "specify\n" | |
9645 > _ \n | |
9646 > (- verilog-indent-level-behavioral) "endspecify" \n > ) | |
9647 | |
9648 (define-skeleton verilog-sk-generate | |
9649 "Insert generate block. " | |
9650 () | |
9651 > "generate\n" | |
9652 > _ \n | |
9653 > (- verilog-indent-level-behavioral) "endgenerate" \n > ) | |
9654 | |
9655 (define-skeleton verilog-sk-begin | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9656 "Insert begin end block. Uses the minibuffer to prompt for name" |
79545 | 9657 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9658 > "begin" '(verilog-sk-prompt-name) \n |
79545 | 9659 > _ \n |
9660 > (- verilog-indent-level-behavioral) "end" | |
9661 ) | |
9662 | |
9663 (define-skeleton verilog-sk-fork | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9664 "Insert an fork join block." |
79545 | 9665 () |
9666 > "fork\n" | |
9667 > "begin" \n | |
9668 > _ \n | |
9669 > (- verilog-indent-level-behavioral) "end" \n | |
9670 > "begin" \n | |
9671 > \n | |
9672 > (- verilog-indent-level-behavioral) "end" \n | |
9673 > (- verilog-indent-level-behavioral) "join" \n | |
9674 > ) | |
9675 | |
9676 | |
9677 (define-skeleton verilog-sk-case | |
9678 "Build skeleton case statement, prompting for the selector expression, | |
9679 and the case items." | |
9680 "[selector expression]: " | |
9681 > "case (" str ") " \n | |
9682 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9683 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9684 | |
9685 (define-skeleton verilog-sk-casex | |
9686 "Build skeleton casex statement, prompting for the selector expression, | |
9687 and the case items." | |
9688 "[selector expression]: " | |
9689 > "casex (" str ") " \n | |
9690 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9691 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9692 | |
9693 (define-skeleton verilog-sk-casez | |
9694 "Build skeleton casez statement, prompting for the selector expression, | |
9695 and the case items." | |
9696 "[selector expression]: " | |
9697 > "casez (" str ") " \n | |
9698 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9699 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9700 | |
9701 (define-skeleton verilog-sk-if | |
9702 "Insert a skeleton if statement." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9703 > "if (" '(verilog-sk-prompt-condition) & ")" " begin" \n |
79545 | 9704 > _ \n |
9705 > (- verilog-indent-level-behavioral) "end " \n ) | |
9706 | |
9707 (define-skeleton verilog-sk-else-if | |
9708 "Insert a skeleton else if statement." | |
9709 > (verilog-indent-line) "else if (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9710 (progn (setq verilog-sk-p (point)) nil) '(verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n |
79545 | 9711 > _ \n |
9712 > "end" (progn (electric-verilog-terminate-line) nil)) | |
9713 | |
9714 (define-skeleton verilog-sk-datadef | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9715 "Common routine to get data definition" |
79545 | 9716 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9717 '(verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n) |
79545 | 9718 |
9719 (define-skeleton verilog-sk-input | |
9720 "Insert an input definition." | |
9721 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9722 > "input [" '(verilog-sk-datadef)) |
79545 | 9723 |
9724 (define-skeleton verilog-sk-output | |
9725 "Insert an output definition." | |
9726 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9727 > "output [" '(verilog-sk-datadef)) |
79545 | 9728 |
9729 (define-skeleton verilog-sk-inout | |
9730 "Insert an inout definition." | |
9731 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9732 > "inout [" '(verilog-sk-datadef)) |
79545 | 9733 |
9734 (defvar verilog-sk-signal nil) | |
9735 (define-skeleton verilog-sk-def-reg | |
9736 "Insert a reg definition." | |
9737 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9738 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
79545 | 9739 |
9740 (defun verilog-sk-define-signal () | |
9741 "Insert a definition of signal under point at top of module." | |
9742 (interactive "*") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9743 (let* ((sig-re "[a-zA-Z0-9_]*") |
79545 | 9744 (v1 (buffer-substring |
9745 (save-excursion | |
9746 (skip-chars-backward sig-re) | |
9747 (point)) | |
9748 (save-excursion | |
9749 (skip-chars-forward sig-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9750 (point))))) |
79545 | 9751 (if (not (member v1 verilog-keywords)) |
9752 (save-excursion | |
9753 (setq verilog-sk-signal v1) | |
9754 (verilog-beg-of-defun) | |
9755 (verilog-end-of-statement) | |
9756 (verilog-forward-syntactic-ws) | |
9757 (verilog-sk-def-reg) | |
9758 (message "signal at point is %s" v1)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9759 (message "object at point (%s) is a keyword" v1)))) |
79545 | 9760 |
9761 (define-skeleton verilog-sk-wire | |
9762 "Insert a wire definition." | |
9763 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9764 > "wire [" '(verilog-sk-datadef)) |
79545 | 9765 |
9766 (define-skeleton verilog-sk-reg | |
9767 "Insert a reg definition." | |
9768 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9769 > "reg [" '(verilog-sk-datadef)) |
79545 | 9770 |
9771 (define-skeleton verilog-sk-assign | |
9772 "Insert a skeleton assign statement." | |
9773 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9774 > "assign " '(verilog-sk-prompt-name) " = " _ ";" \n) |
79545 | 9775 |
9776 (define-skeleton verilog-sk-while | |
9777 "Insert a skeleton while loop statement." | |
9778 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9779 > "while (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 9780 > _ \n |
9781 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9782 | |
9783 (define-skeleton verilog-sk-repeat | |
9784 "Insert a skeleton repeat loop statement." | |
9785 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9786 > "repeat (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 9787 > _ \n |
9788 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9789 | |
9790 (define-skeleton verilog-sk-for | |
9791 "Insert a skeleton while loop statement." | |
9792 () | |
9793 > "for (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9794 '(verilog-sk-prompt-init) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9795 '(verilog-sk-prompt-condition) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9796 '(verilog-sk-prompt-inc) |
79545 | 9797 ") begin" \n |
9798 > _ \n | |
9799 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9800 | |
9801 (define-skeleton verilog-sk-comment | |
9802 "Inserts three comment lines, making a display comment." | |
9803 () | |
9804 > "/*\n" | |
9805 > "* " _ \n | |
9806 > "*/") | |
9807 | |
9808 (define-skeleton verilog-sk-state-machine | |
9809 "Insert a state machine definition." | |
9810 "Name of state variable: " | |
9811 '(setq input "state") | |
9812 > "// State registers for " str | -23 \n | |
9813 '(setq verilog-sk-state str) | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9814 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n |
79545 | 9815 '(setq input nil) |
9816 > \n | |
9817 > "// State FF for " verilog-sk-state \n | |
9818 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n | |
9819 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n | |
9820 > verilog-sk-state " = next_" verilog-sk-state ?; \n | |
9821 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil) | |
9822 > \n | |
9823 > "// Next State Logic for " verilog-sk-state \n | |
9824 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9825 > "case (" '(verilog-sk-prompt-state-selector) ") " \n |
79545 | 9826 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n ) |
9827 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) | |
9828 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) | |
9829 | |
9830 ;; Eliminate compile warning | |
9831 (eval-when-compile | |
9832 (if (not (boundp 'mode-popup-menu)) | |
9833 (defvar mode-popup-menu nil "Compatibility with XEmacs."))) | |
9834 | |
9835 ;; ---- add menu 'Statements' in Verilog mode (MH) | |
9836 (defun verilog-add-statement-menu () | |
9837 "Add the menu 'Statements' to the menu bar in Verilog mode." | |
9838 (if (featurep 'xemacs) | |
9839 (progn | |
9840 (easy-menu-add verilog-stmt-menu) | |
9841 (easy-menu-add verilog-menu) | |
9842 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu))))) | |
9843 | |
9844 (add-hook 'verilog-mode-hook 'verilog-add-statement-menu) | |
9845 | |
9846 | |
9847 | |
9848 ;; | |
9849 ;; Include file loading with mouse/return event | |
9850 ;; | |
9851 ;; idea & first impl.: M. Rouat (eldo-mode.el) | |
9852 ;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el) | |
9853 | |
9854 (if (featurep 'xemacs) | |
9855 (require 'overlay) | |
9856 (require 'lucid)) ;; what else can we do ?? | |
9857 | |
9858 (defconst verilog-include-file-regexp | |
9859 "^`include\\s-+\"\\([^\n\"]*\\)\"" | |
9860 "Regexp that matches the include file.") | |
9861 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9862 (defvar verilog-mode-mouse-map |
79545 | 9863 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
9864 (set-keymap-parent map verilog-mode-map) | |
9865 ;; mouse button bindings | |
9866 (define-key map "\r" 'verilog-load-file-at-point) | |
9867 (if (featurep 'xemacs) | |
9868 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ? | |
9869 (define-key map [mouse-2] 'verilog-load-file-at-mouse)) | |
9870 (if (featurep 'xemacs) | |
9871 (define-key map 'Sh-button2 'mouse-yank) ; you wanna paste don't you ? | |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9872 (define-key map [S-mouse-2] 'mouse-yank-at-click)) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9873 map) |
79546 | 9874 "Map containing mouse bindings for `verilog-mode'.") |
9875 | |
79545 | 9876 |
9877 (defun verilog-colorize-include-files (beg end old-len) | |
9878 "This function colorizes included files when the mouse passes over them. | |
9879 Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |
9880 (save-excursion | |
9881 (save-match-data | |
9882 (let (end-point) | |
9883 (goto-char end) | |
9884 (setq end-point (verilog-get-end-of-line)) | |
9885 (goto-char beg) | |
9886 (beginning-of-line) ; scan entire line ! | |
9887 ;; delete overlays existing on this line | |
9888 (let ((overlays (overlays-in (point) end-point))) | |
9889 (while overlays | |
9890 (if (and | |
9891 (overlay-get (car overlays) 'detachable) | |
9892 (overlay-get (car overlays) 'verilog-include-file)) | |
9893 (delete-overlay (car overlays))) | |
9894 (setq overlays (cdr overlays)))) ; let | |
9895 ;; make new ones, could reuse deleted one ? | |
9896 (while (search-forward-regexp verilog-include-file-regexp end-point t) | |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9897 (let (ov) |
79545 | 9898 (goto-char (match-beginning 1)) |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9899 (setq ov (make-overlay (match-beginning 1) (match-end 1))) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9900 (overlay-put ov 'start-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9901 (overlay-put ov 'end-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9902 (overlay-put ov 'evaporate 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9903 (overlay-put ov 'verilog-include-file 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9904 (overlay-put ov 'mouse-face 'highlight) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9905 (overlay-put ov 'local-map verilog-mode-mouse-map))))))) |
79545 | 9906 |
9907 | |
9908 (defun verilog-colorize-include-files-buffer () | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9909 "Colorize a include file." |
79545 | 9910 (interactive) |
9911 ;; delete overlays | |
9912 (let ((overlays (overlays-in (point-min) (point-max)))) | |
9913 (while overlays | |
9914 (if (and | |
9915 (overlay-get (car overlays) 'detachable) | |
9916 (overlay-get (car overlays) 'verilog-include-file)) | |
9917 (delete-overlay (car overlays))) | |
9918 (setq overlays (cdr overlays)))) ; let | |
9919 ;; remake overlays | |
9920 (verilog-colorize-include-files (point-min) (point-max) nil)) | |
9921 | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9922 ;; ffap-at-mouse isn't useful for verilog mode. It uses library paths. |
79545 | 9923 ;; so define this function to do more or less the same as ffap-at-mouse |
9924 ;; but first resolve filename... | |
9925 (defun verilog-load-file-at-mouse (event) | |
9926 "Load file under button 2 click's EVENT. | |
9927 Files are checked based on `verilog-library-directories'." | |
9928 (interactive "@e") | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9929 (save-excursion ;; implement a verilog specific ffap-at-mouse |
79545 | 9930 (mouse-set-point event) |
9931 (beginning-of-line) | |
9932 (if (looking-at verilog-include-file-regexp) | |
9933 (if (and (car (verilog-library-filenames | |
9934 (match-string 1) (buffer-file-name))) | |
9935 (file-readable-p (car (verilog-library-filenames | |
9936 (match-string 1) (buffer-file-name))))) | |
9937 (find-file (car (verilog-library-filenames | |
9938 (match-string 1) (buffer-file-name)))) | |
9939 (progn | |
9940 (message | |
9941 "File '%s' isn't readable, use shift-mouse2 to paste in this field" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9942 (match-string 1))))))) |
79545 | 9943 |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9944 ;; ffap isn't useable for verilog mode. It uses library paths. |
79545 | 9945 ;; so define this function to do more or less the same as ffap |
9946 ;; but first resolve filename... | |
9947 (defun verilog-load-file-at-point () | |
9948 "Load file under point. | |
9949 Files are checked based on `verilog-library-directories'." | |
9950 (interactive) | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
9951 (save-excursion ;; implement a verilog specific ffap |
79545 | 9952 (beginning-of-line) |
9953 (if (looking-at verilog-include-file-regexp) | |
9954 (if (and | |
9955 (car (verilog-library-filenames | |
9956 (match-string 1) (buffer-file-name))) | |
9957 (file-readable-p (car (verilog-library-filenames | |
9958 (match-string 1) (buffer-file-name))))) | |
9959 (find-file (car (verilog-library-filenames | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9960 (match-string 1) (buffer-file-name)))))))) |
79545 | 9961 |
9962 | |
9963 ;; | |
9964 ;; Bug reporting | |
9965 ;; | |
9966 | |
9967 (defun verilog-faq () | |
9968 "Tell the user their current version, and where to get the FAQ etc." | |
9969 (interactive) | |
9970 (with-output-to-temp-buffer "*verilog-mode help*" | |
9971 (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) | |
9972 (princ "\n") | |
9973 (princ "For new releases, see http://www.verilog.com\n") | |
9974 (princ "\n") | |
9975 (princ "For frequently asked questions, see http://www.veripool.com/verilog-mode-faq.html\n") | |
9976 (princ "\n") | |
9977 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | |
9978 (princ "\n"))) | |
9979 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9980 (autoload 'reporter-submit-bug-report "reporter") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9981 (defvar reporter-prompt-for-summary-p) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9982 |
79545 | 9983 (defun verilog-submit-bug-report () |
9984 "Submit via mail a bug report on verilog-mode.el." | |
9985 (interactive) | |
9986 (let ((reporter-prompt-for-summary-p t)) | |
9987 (reporter-submit-bug-report | |
9988 "mac@verilog.com" | |
9989 (concat "verilog-mode v" verilog-mode-version) | |
9990 '( | |
9991 verilog-align-ifelse | |
9992 verilog-auto-endcomments | |
9993 verilog-auto-hook | |
9994 verilog-auto-indent-on-newline | |
9995 verilog-auto-inst-vector | |
9996 verilog-auto-inst-template-numbers | |
9997 verilog-auto-lineup | |
9998 verilog-auto-newline | |
9999 verilog-auto-save-policy | |
10000 verilog-auto-sense-defines-constant | |
10001 verilog-auto-sense-include-inputs | |
10002 verilog-before-auto-hook | |
10003 verilog-case-indent | |
10004 verilog-cexp-indent | |
10005 verilog-compiler | |
10006 verilog-coverage | |
10007 verilog-highlight-translate-off | |
10008 verilog-indent-begin-after-if | |
10009 verilog-indent-declaration-macros | |
10010 verilog-indent-level | |
10011 verilog-indent-level-behavioral | |
10012 verilog-indent-level-declaration | |
10013 verilog-indent-level-directive | |
10014 verilog-indent-level-module | |
10015 verilog-indent-lists | |
10016 verilog-library-flags | |
10017 verilog-library-directories | |
10018 verilog-library-extensions | |
10019 verilog-library-files | |
10020 verilog-linter | |
10021 verilog-minimum-comment-distance | |
10022 verilog-mode-hook | |
10023 verilog-simulator | |
10024 verilog-tab-always-indent | |
10025 verilog-tab-to-comment | |
10026 ) | |
10027 nil nil | |
10028 (concat "Hi Mac, | |
10029 | |
10030 I want to report a bug. I've read the `Bugs' section of `Info' on | |
10031 Emacs, so I know how to make a clear and unambiguous report. To get | |
10032 to that Info section, I typed | |
10033 | |
10034 M-x info RET m " invocation-name " RET m bugs RET | |
10035 | |
10036 Before I go further, I want to say that Verilog mode has changed my life. | |
10037 I save so much time, my files are colored nicely, my co workers respect | |
10038 my coding ability... until now. I'd really appreciate anything you | |
10039 could do to help me out with this minor deficiency in the product. | |
10040 | |
10041 If you have bugs with the AUTO functions, please CC the AUTOAUTHOR Wilson | |
10042 Snyder (wsnyder@wsnyder.org) and/or see http://www.veripool.com. | |
10043 You may also want to look at the Verilog-Mode FAQ, see | |
10044 http://www.veripool.com/verilog-mode-faq.html. | |
10045 | |
10046 To reproduce the bug, start a fresh Emacs via " invocation-name " | |
80163
22e82356b25e
* progmodes/verilog-mode.el (customize): Fix typo in error message.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80143
diff
changeset
|
10047 -no-init-file -no-site-file'. In a new buffer, in verilog mode, type |
79545 | 10048 the code included below. |
10049 | |
10050 Given those lines, I expected [[Fill in here]] to happen; | |
10051 but instead, [[Fill in here]] happens!. | |
10052 | |
10053 == The code: ==")))) | |
10054 | |
79546 | 10055 (provide 'verilog-mode) |
10056 | |
79545 | 10057 ;; Local Variables: |
10058 ;; checkdoc-permit-comma-termination-flag:t | |
10059 ;; checkdoc-force-docstrings-flag:nil | |
10060 ;; End: | |
10061 | |
79552 | 10062 ;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f |
79545 | 10063 ;;; verilog-mode.el ends here |