Mercurial > emacs
annotate lisp/progmodes/verilog-mode.el @ 92692:d999f30304bc
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1095
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 10 Mar 2008 00:49:47 +0000 |
parents | f991f10f15ec e36e32d01703 |
children | f35f15ba549f |
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 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
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: | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
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 | |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
118 (defconst verilog-mode-version "404" |
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.") |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
120 (defconst verilog-mode-release-date "2008-03-02-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 (fboundp 'char-before) |
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 (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
|
167 (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
|
168 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
169 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
170 (require 'custom) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
171 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
172 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
173 (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
|
174 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
175 (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
|
176 "Return string of text matched by last search, without text properties. |
79545 | 177 NUM specifies which parenthesized expression in the last regexp. |
178 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. | |
179 Zero means the entire text matched by the whole regexp or whole string. | |
180 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
|
181 (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
|
182 (if string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
183 (let ((result |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
184 (substring string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
185 (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
|
186 (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
|
187 result) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
188 (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
|
189 (match-end num) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
190 (current-buffer))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
191 ) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
192 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
193 (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
|
194 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
|
195 ;; 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
|
196 (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
|
197 (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
|
198 (message |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
199 "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
|
200 (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
|
201 `(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
|
202 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
203 (if (fboundp 'defface) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
204 nil ; great! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
205 (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
|
206 `(make-face ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
207 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
208 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
209 (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
|
210 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
|
211 ;; 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
|
212 (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
|
213 `(customize ,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 |
79545 | 216 ;; Provide a regular expression optimization routine, using regexp-opt |
217 ;; if provided by the user's elisp libraries | |
218 (eval-and-compile | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
219 ;; 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
|
220 ;; 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
|
221 (if (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
222 (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
|
223 ;; 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
|
224 (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
|
225 (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
|
226 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
227 ((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
|
228 (condition-case nil ; Hide this defun from emacses |
79545 | 229 ;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
|
230 (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
|
231 "Deal with differing number of required arguments for `regexp-opt'. |
79545 | 232 Call 'regexp-opt' on A and B." |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
233 (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
|
234 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
235 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
236 ((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
|
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 "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
|
239 (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
|
240 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
241 (t nil))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
242 ;; 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
|
243 (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
|
244 "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
|
245 (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
|
246 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
247 ;; 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
|
248 (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
|
249 (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
|
250 (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
|
251 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
252 ;; Emacs. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
253 (defalias 'verilog-regexp-opt 'regexp-opt))) |
79545 | 254 |
79555
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
255 (eval-when-compile |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
256 (defun verilog-regexp-words (a) |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
257 "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
|
258 (concat "\\<" (verilog-regexp-opt a t) "\\>"))) |
79545 | 259 |
260 (defun verilog-customize () | |
261 "Link to customize screen for Verilog." | |
262 (interactive) | |
263 (customize-group 'verilog-mode)) | |
264 | |
265 (defun verilog-font-customize () | |
266 "Link to customize fonts used for Verilog." | |
267 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
268 (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
|
269 (customize-apropos "font-lock-*" 'faces))) |
79545 | 270 |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
271 (defun verilog-booleanp (value) |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
272 "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
|
273 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
|
274 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
|
275 (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
|
276 |
79545 | 277 (defgroup verilog-mode nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
278 "Facilitates easy editing of Verilog source text." |
80261
4af0bb174714
* textmodes/css-mode.el (css-indent-offset, css-electric-keys):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80172
diff
changeset
|
279 :version "22.2" |
79545 | 280 :group 'languages) |
281 | |
282 ; (defgroup verilog-mode-fonts nil | |
283 ; "Facilitates easy customization fonts used in Verilog source text" | |
284 ; :link '(customize-apropos "font-lock-*" 'faces) | |
285 ; :group 'verilog-mode) | |
286 | |
287 (defgroup verilog-mode-indent nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
288 "Customize indentation and highlighting of Verilog source text." |
79545 | 289 :group 'verilog-mode) |
290 | |
291 (defgroup verilog-mode-actions nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
292 "Customize actions on Verilog source text." |
79545 | 293 :group 'verilog-mode) |
294 | |
295 (defgroup verilog-mode-auto nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
296 "Customize AUTO actions when expanding Verilog source text." |
79545 | 297 :group 'verilog-mode) |
298 | |
299 (defcustom verilog-linter | |
300 "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'" | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
301 "*Unix program and arguments to call to run a lint checker on Verilog source. |
79545 | 302 Depending on the `verilog-set-compile-command', this may be invoked when |
303 you type \\[compile]. When the compile completes, \\[next-error] will take | |
304 you to the next lint error." | |
305 :type 'string | |
306 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
307 ;; We don't mark it safe, as it's used as a shell command |
79545 | 308 |
309 (defcustom verilog-coverage | |
310 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'" | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
311 "*Program and arguments to use to annotate for coverage Verilog source. |
79545 | 312 Depending on the `verilog-set-compile-command', this may be invoked when |
313 you type \\[compile]. When the compile completes, \\[next-error] will take | |
314 you to the next lint error." | |
315 :type 'string | |
316 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
317 ;; We don't mark it safe, as it's used as a shell command |
79545 | 318 |
319 (defcustom verilog-simulator | |
320 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'" | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
321 "*Program and arguments to use to interpret Verilog source. |
79545 | 322 Depending on the `verilog-set-compile-command', this may be invoked when |
323 you type \\[compile]. When the compile completes, \\[next-error] will take | |
324 you to the next lint error." | |
325 :type 'string | |
326 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
327 ;; We don't mark it safe, as it's used as a shell command |
79545 | 328 |
329 (defcustom verilog-compiler | |
330 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'" | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
331 "*Program and arguments to use to compile Verilog source. |
79545 | 332 Depending on the `verilog-set-compile-command', this may be invoked when |
333 you type \\[compile]. When the compile completes, \\[next-error] will take | |
334 you to the next lint error." | |
335 :type 'string | |
336 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
337 ;; We don't mark it safe, as it's used as a shell command |
79545 | 338 |
339 (defvar verilog-tool 'verilog-linter | |
340 "Which tool to use for building compiler-command. | |
341 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | |
342 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | |
343 menu. See `verilog-set-compile-command' for more information.") | |
344 | |
345 (defcustom verilog-highlight-translate-off nil | |
346 "*Non-nil means background-highlight code excluded from translation. | |
347 That is, all code between \"// synopsys translate_off\" and | |
348 \"// synopsys translate_on\" is highlighted using a different background color | |
349 \(face `verilog-font-lock-translate-off-face'). | |
350 | |
351 Note: This will slow down on-the-fly fontification (and thus editing). | |
352 | |
353 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | |
354 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." | |
355 :type 'boolean | |
356 :group 'verilog-mode-indent) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
357 ;; 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
|
358 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp) |
79545 | 359 |
360 (defcustom verilog-indent-level 3 | |
361 "*Indentation of Verilog statements with respect to containing block." | |
362 :group 'verilog-mode-indent | |
363 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
364 (put 'verilog-indent-level 'safe-local-variable 'integerp) |
79545 | 365 |
366 (defcustom verilog-indent-level-module 3 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
367 "*Indentation of Module level Verilog statements (eg always, initial). |
79545 | 368 Set to 0 to get initial and always statements lined up on the left side of |
369 your screen." | |
370 :group 'verilog-mode-indent | |
371 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
372 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) |
79545 | 373 |
374 (defcustom verilog-indent-level-declaration 3 | |
375 "*Indentation of declarations with respect to containing block. | |
376 Set to 0 to get them list right under containing block." | |
377 :group 'verilog-mode-indent | |
378 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
379 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) |
79545 | 380 |
381 (defcustom verilog-indent-declaration-macros nil | |
382 "*How to treat macro expansions in a declaration. | |
383 If nil, indent as: | |
384 input [31:0] a; | |
385 input `CP; | |
386 output c; | |
387 If non nil, treat as: | |
388 input [31:0] a; | |
389 input `CP ; | |
390 output c;" | |
391 :group 'verilog-mode-indent | |
392 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
393 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp) |
79545 | 394 |
395 (defcustom verilog-indent-lists t | |
396 "*How to treat indenting items in a list. | |
397 If t (the default), indent as: | |
398 always @( posedge a or | |
399 reset ) begin | |
400 | |
401 If nil, treat as: | |
402 always @( posedge a or | |
403 reset ) begin" | |
404 :group 'verilog-mode-indent | |
405 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
406 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp) |
79545 | 407 |
408 (defcustom verilog-indent-level-behavioral 3 | |
409 "*Absolute indentation of first begin in a task or function block. | |
410 Set to 0 to get such code to start at the left side of the screen." | |
411 :group 'verilog-mode-indent | |
412 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
413 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) |
79545 | 414 |
415 (defcustom verilog-indent-level-directive 1 | |
416 "*Indentation to add to each level of `ifdef declarations. | |
417 Set to 0 to have all directives start at the left side of the screen." | |
418 :group 'verilog-mode-indent | |
419 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
420 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) |
79545 | 421 |
422 (defcustom verilog-cexp-indent 2 | |
423 "*Indentation of Verilog statements split across lines." | |
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-cexp-indent 'safe-local-variable 'integerp) |
79545 | 427 |
428 (defcustom verilog-case-indent 2 | |
429 "*Indentation for case statements." | |
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-case-indent 'safe-local-variable 'integerp) |
79545 | 433 |
434 (defcustom verilog-auto-newline t | |
435 "*True means automatically newline after semicolons." | |
436 :group 'verilog-mode-indent | |
437 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
438 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 439 |
440 (defcustom verilog-auto-indent-on-newline t | |
441 "*True means automatically indent line after newline." | |
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-indent-on-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 445 |
446 (defcustom verilog-tab-always-indent t | |
447 "*True means TAB should always re-indent the current line. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
448 A nil value means TAB will only reindent when at the beginning of the line." |
79545 | 449 :group 'verilog-mode-indent |
450 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
451 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp) |
79545 | 452 |
453 (defcustom verilog-tab-to-comment nil | |
454 "*True means TAB moves to the right hand column in preparation for a comment." | |
455 :group 'verilog-mode-actions | |
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-to-comment 'safe-local-variable 'verilog-booleanp) |
79545 | 458 |
459 (defcustom verilog-indent-begin-after-if t | |
460 "*If true, indent begin statements following if, else, while, for and repeat. | |
461 Otherwise, line them up." | |
462 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
463 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
464 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp) |
79545 | 465 |
466 | |
467 (defcustom verilog-align-ifelse nil | |
468 "*If true, align `else' under matching `if'. | |
469 Otherwise else is lined up with first character on line holding matching if." | |
470 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
471 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
472 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp) |
79545 | 473 |
474 (defcustom verilog-minimum-comment-distance 10 | |
475 "*Minimum distance (in lines) between begin and end required before a comment. | |
476 Setting this variable to zero results in every end acquiring a comment; the | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
477 default avoids too many redundant comments in tight quarters." |
79545 | 478 :group 'verilog-mode-indent |
479 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
480 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) |
79545 | 481 |
482 (defcustom verilog-auto-lineup '(declaration) | |
483 "*Algorithm for lining up statements on multiple lines. | |
484 | |
485 If this list contains the symbol 'all', then all line ups described below | |
486 are done. | |
487 | |
488 If this list contains the symbol 'declaration', then declarations are lined up | |
489 with any preceding declarations, taking into account widths and the like, so | |
490 for example the code: | |
491 reg [31:0] a; | |
492 reg b; | |
493 would become | |
494 reg [31:0] a; | |
495 reg b; | |
496 | |
497 If this list contains the symbol 'assignment', then assignments are lined up | |
498 with any preceding assignments, so for example the code | |
499 a_long_variable = b + c; | |
500 d = e + f; | |
501 would become | |
502 a_long_variable = b + c; | |
503 d = e + f;" | |
504 | |
505 ;; The following is not implemented: | |
506 ;If this list contains the symbol 'case', then case items are lined up | |
507 ;with any preceding case items, so for example the code | |
508 ; case (a) begin | |
509 ; a_long_state : a = 3; | |
510 ; b: a = 4; | |
511 ; endcase | |
512 ;would become | |
513 ; case (a) begin | |
514 ; a_long_state : a = 3; | |
515 ; b : a = 4; | |
516 ; endcase | |
517 ; | |
518 | |
519 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
520 :type 'list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
521 (put 'verilog-auto-lineup 'safe-local-variable 'listp) |
79545 | 522 |
523 (defcustom verilog-highlight-p1800-keywords nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
524 "*True means highlight words newly reserved by IEEE-1800. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
525 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
|
526 suggest changing where these words are used as variables to something else. |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
527 A nil value 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
|
528 IEEE-1800 standard. Note that changing this will require restarting Emacs |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
529 to see the effect as font color choices are cached by Emacs." |
79545 | 530 :group 'verilog-mode-indent |
531 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
532 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp) |
79545 | 533 |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
534 (defcustom verilog-highlight-grouping-keywords nil |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
535 "*True means highlight grouping keywords 'begin' and 'end' more dramatically. |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
536 If false, these words are in the font-lock-type-face; if True then they are in |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
537 `verilog-font-lock-ams-face'. Some find that special highlighting on these |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
538 grouping constructs allow the structure of the code to be understood at a glance." |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
539 :group 'verilog-mode-indent |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
540 :type 'boolean) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
541 (put 'verilog-highlight-grouping-keywords 'safe-local-variable 'verilog-booleanp) |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
542 |
79545 | 543 (defcustom verilog-auto-endcomments t |
544 "*True means insert a comment /* ... */ after 'end's. | |
545 The name of the function or case will be set between the braces." | |
546 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
547 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
548 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) |
79545 | 549 |
550 (defcustom verilog-auto-read-includes nil | |
551 "*True means to automatically read includes before AUTOs. | |
552 This will do a `verilog-read-defines' and `verilog-read-includes' before | |
553 each AUTO expansion. This makes it easier to embed defines and includes, | |
554 but can result in very slow reading times if there are many or large | |
555 include files." | |
556 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
557 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
558 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp) |
79545 | 559 |
560 (defcustom verilog-auto-save-policy nil | |
561 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | |
562 A value of `force' will always do a \\[verilog-auto] automatically if | |
563 needed on every save. A value of `detect' will do \\[verilog-auto] | |
564 automatically when it thinks necessary. A value of `ask' will query the | |
565 user when it thinks updating is needed. | |
566 | |
567 You should not rely on the 'ask or 'detect policies, they are safeguards | |
568 only. They do not detect when AUTOINSTs need to be updated because a | |
569 sub-module's port list has changed." | |
570 :group 'verilog-mode-actions | |
571 :type '(choice (const nil) (const ask) (const detect) (const force))) | |
572 | |
573 (defcustom verilog-auto-star-expand t | |
574 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | |
575 They will be expanded in the same way as if there was a AUTOINST in the | |
576 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." | |
577 :group 'verilog-mode-actions | |
578 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
579 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp) |
79545 | 580 |
581 (defcustom verilog-auto-star-save nil | |
582 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
583 A nil value indicates direct connections will be removed before saving. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
584 Only meaningful to those created due to `verilog-auto-star-expand' being set. |
79545 | 585 |
586 Instead of setting this, you may want to use /*AUTOINST*/, which will | |
587 always be saved." | |
588 :group 'verilog-mode-actions | |
589 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
590 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp) |
79545 | 591 |
592 (defvar verilog-auto-update-tick nil | |
593 "Modification tick at which autos were last performed.") | |
594 | |
595 (defvar verilog-auto-last-file-locals nil | |
596 "Text from file-local-variables during last evaluation.") | |
597 | |
598 (defvar verilog-error-regexp-add-didit nil) | |
599 (defvar verilog-error-regexp nil) | |
600 (setq verilog-error-regexp-add-didit nil | |
601 verilog-error-regexp | |
602 '( | |
603 ; SureLint | |
604 ;; ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) | |
605 ; Most SureFire tools | |
606 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 ) | |
607 ("\ | |
608 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
609 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) | |
610 ; xsim | |
611 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED] | |
612 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) | |
613 ; vcs | |
614 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) | |
615 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) | |
616 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) | |
617 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) | |
618 ; Verilator | |
619 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
620 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
621 ; vxl | |
622 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) | |
623 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl | |
624 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2) | |
625 ; nc-verilog | |
626 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2) | |
627 ; Leda | |
628 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2) | |
629 ) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
630 ; "*List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist for the formatting." |
79545 | 631 ) |
632 | |
633 (defvar verilog-error-font-lock-keywords | |
634 '( | |
635 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t) | |
636 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t) | |
637 | |
638 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t) | |
639 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t) | |
640 | |
641 ("\ | |
642 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
643 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
644 ("\ | |
645 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
646 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
647 | |
648 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t) | |
649 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t) | |
650 | |
651 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t) | |
652 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t) | |
653 | |
654 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
655 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
656 | |
657 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
658 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t) | |
659 | |
660 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t) | |
661 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
662 ; vxl | |
663 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
664 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
665 | |
666 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t) | |
667 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t) | |
668 | |
669 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t) | |
670 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t) | |
671 ; nc-verilog | |
672 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t) | |
673 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | |
674 ; Leda | |
675 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | |
676 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) | |
677 ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
678 "*Keywords to also highlight in Verilog *compilation* buffers.") |
79545 | 679 |
680 (defcustom verilog-library-flags '("") | |
681 "*List of standard Verilog arguments to use for /*AUTOINST*/. | |
682 These arguments are used to find files for `verilog-auto', and match | |
683 the flags accepted by a standard Verilog-XL simulator. | |
684 | |
685 -f filename Reads more `verilog-library-flags' from the filename. | |
686 +incdir+dir Adds the directory to `verilog-library-directories'. | |
687 -Idir Adds the directory to `verilog-library-directories'. | |
688 -y dir Adds the directory to `verilog-library-directories'. | |
689 +libext+.v Adds the extensions to `verilog-library-extensions'. | |
690 -v filename Adds the filename to `verilog-library-files'. | |
691 | |
692 filename Adds the filename to `verilog-library-files'. | |
693 This is not recommended, -v is a better choice. | |
694 | |
695 You might want these defined in each file; put at the *END* of your file | |
696 something like: | |
697 | |
698 // Local Variables: | |
699 // verilog-library-flags:(\"-y dir -y otherdir\") | |
700 // End: | |
701 | |
702 Verilog-mode attempts to detect changes to this local variable, but they | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
703 are only insured to be correct when the file is first visited. Thus if you |
79545 | 704 have problems, use \\[find-alternate-file] RET to have these take effect. |
705 | |
706 See also the variables mentioned above." | |
707 :group 'verilog-mode-auto | |
708 :type '(repeat string)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
709 (put 'verilog-library-flags 'safe-local-variable 'listp) |
79545 | 710 |
711 (defcustom verilog-library-directories '(".") | |
712 "*List of directories when looking for files for /*AUTOINST*/. | |
713 The directory may be relative to the current file, or absolute. | |
714 Environment variables are also expanded in the directory names. | |
715 Having at least the current directory is a good idea. | |
716 | |
717 You might want these defined in each file; put at the *END* of your file | |
718 something like: | |
719 | |
720 // Local Variables: | |
721 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\") | |
722 // End: | |
723 | |
724 Verilog-mode attempts to detect changes to this local variable, but they | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
725 are only insured to be correct when the file is first visited. Thus if you |
79545 | 726 have problems, use \\[find-alternate-file] RET to have these take effect. |
727 | |
728 See also `verilog-library-flags', `verilog-library-files' | |
729 and `verilog-library-extensions'." | |
730 :group 'verilog-mode-auto | |
731 :type '(repeat file)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
732 (put 'verilog-library-directories 'safe-local-variable 'listp) |
79545 | 733 |
734 (defcustom verilog-library-files '() | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
735 "*List of files to search for modules. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
736 AUTOINST will use this when it needs to resolve a module name. |
79545 | 737 This is a complete path, usually to a technology file with many standard |
738 cells defined in it. | |
739 | |
740 You might want these defined in each file; put at the *END* of your file | |
741 something like: | |
742 | |
743 // Local Variables: | |
744 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\") | |
745 // End: | |
746 | |
747 Verilog-mode attempts to detect changes to this local variable, but they | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
748 are only insured to be correct when the file is first visited. Thus if you |
79545 | 749 have problems, use \\[find-alternate-file] RET to have these take effect. |
750 | |
751 See also `verilog-library-flags', `verilog-library-directories'." | |
752 :group 'verilog-mode-auto | |
753 :type '(repeat directory)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
754 (put 'verilog-library-files 'safe-local-variable 'listp) |
79545 | 755 |
756 (defcustom verilog-library-extensions '(".v") | |
757 "*List of extensions to use when looking for files for /*AUTOINST*/. | |
758 See also `verilog-library-flags', `verilog-library-directories'." | |
759 :type '(repeat string) | |
760 :group 'verilog-mode-auto) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
761 (put 'verilog-library-extensions 'safe-local-variable 'listp) |
79545 | 762 |
763 (defcustom verilog-active-low-regexp nil | |
764 "*If set, treat signals matching this regexp as active low. | |
765 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | |
766 you will probably also need `verilog-auto-reset-widths' set." | |
767 :group 'verilog-mode-auto | |
768 :type 'string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
769 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) |
79545 | 770 |
771 (defcustom verilog-auto-sense-include-inputs nil | |
772 "*If true, AUTOSENSE should include all inputs. | |
773 If nil, only inputs that are NOT output signals in the same block are | |
774 included." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
775 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
776 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
777 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp) |
79545 | 778 |
779 (defcustom verilog-auto-sense-defines-constant nil | |
780 "*If true, AUTOSENSE should assume all defines represent constants. | |
781 When true, the defines will not be included in sensitivity lists. To | |
782 maintain compatibility with other sites, this should be set at the bottom | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
783 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
|
784 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
785 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
786 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) |
79545 | 787 |
788 (defcustom verilog-auto-reset-widths t | |
789 "*If true, AUTORESET should determine the width of signals. | |
790 This is then used to set the width of the zero (32'h0 for example). This | |
791 is required by some lint tools that aren't smart enough to ignore widths of | |
792 the constant zero. This may result in ugly code when parameters determine | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
793 the MSB or LSB of a signal inside an AUTORESET." |
79545 | 794 :type 'boolean |
795 :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
|
796 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp) |
79545 | 797 |
798 (defcustom verilog-assignment-delay "" | |
799 "*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
|
800 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
801 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
802 (put 'verilog-assignment-delay 'safe-local-variable 'stringp) |
79545 | 803 |
804 (defcustom verilog-auto-inst-vector t | |
805 "*If true, when creating default ports with AUTOINST, use bus subscripts. | |
806 If nil, skip the subscript when it matches the entire bus as declared in | |
807 the module (AUTOWIRE signals always are subscripted, you must manually | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
808 declare the wire to have the subscripts removed.) Setting this to nil may |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
809 speed up some simulators, but is less general and harder to read, so avoid." |
79545 | 810 :group 'verilog-mode-auto |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
811 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
812 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp) |
79545 | 813 |
814 (defcustom verilog-auto-inst-template-numbers nil | |
815 "*If true, when creating templated ports with AUTOINST, add a comment. | |
816 The comment will add the line number of the template that was used for that | |
817 port declaration. Setting this aids in debugging, but nil is suggested for | |
818 regular use to prevent large numbers of merge conflicts." | |
819 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
820 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
821 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) |
79545 | 822 |
823 (defvar verilog-auto-inst-column 40 | |
824 "Column number for first part of auto-inst.") | |
825 | |
826 (defcustom verilog-auto-input-ignore-regexp nil | |
827 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | |
828 See the \\[verilog-faq] for examples on using this." | |
829 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
830 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
831 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 832 |
833 (defcustom verilog-auto-inout-ignore-regexp nil | |
834 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | |
835 See the \\[verilog-faq] for examples on using this." | |
836 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
837 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
838 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 839 |
840 (defcustom verilog-auto-output-ignore-regexp nil | |
841 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | |
842 See the \\[verilog-faq] for examples on using this." | |
843 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
844 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
845 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 846 |
847 (defcustom verilog-auto-unused-ignore-regexp nil | |
848 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | |
849 See the \\[verilog-faq] for examples on using this." | |
850 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
851 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
852 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 853 |
854 (defcustom verilog-typedef-regexp nil | |
855 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | |
856 For example, \"_t$\" matches typedefs named with _t, as in the C language." | |
857 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
858 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
859 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) |
79545 | 860 |
861 (defcustom verilog-mode-hook 'verilog-set-compile-command | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
862 "*Hook run after Verilog mode is loaded." |
79545 | 863 :type 'hook |
864 :group 'verilog-mode) | |
865 | |
866 (defcustom verilog-auto-hook nil | |
867 "*Hook run after `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
868 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
869 :type 'hook) |
79545 | 870 |
871 (defcustom verilog-before-auto-hook nil | |
872 "*Hook run before `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
873 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
874 :type 'hook) |
79545 | 875 |
876 (defcustom verilog-delete-auto-hook nil | |
877 "*Hook run after `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
878 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
879 :type 'hook) |
79545 | 880 |
881 (defcustom verilog-before-delete-auto-hook nil | |
882 "*Hook run before `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
883 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
884 :type 'hook) |
79545 | 885 |
886 (defcustom verilog-getopt-flags-hook nil | |
887 "*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
|
888 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
889 :type 'hook) |
79545 | 890 |
891 (defcustom verilog-before-getopt-flags-hook nil | |
892 "*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
|
893 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
894 :type 'hook) |
79545 | 895 |
896 (defvar verilog-imenu-generic-expression | |
897 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | |
898 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3)) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
899 "Imenu expression for Verilog mode. See `imenu-generic-expression'.") |
79545 | 900 |
901 ;; | |
902 ;; provide a verilog-header function. | |
903 ;; Customization variables: | |
904 ;; | |
905 (defvar verilog-date-scientific-format nil | |
906 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17). | |
907 If nil, in European format (e.g. 17.09.1997). The brain-dead American | |
908 format (e.g. 09/17/1997) is not supported.") | |
909 | |
910 (defvar verilog-company nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
911 "*Default name of Company for Verilog header. |
79545 | 912 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
|
913 (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
|
914 |
79545 | 915 (defvar verilog-project nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
916 "*Default name of Project for Verilog header. |
79545 | 917 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
|
918 (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
|
919 |
79549
d9595ed9b084
* progmodes/verilog-mode.el (verilog-mode-map): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79547
diff
changeset
|
920 (defvar verilog-mode-map |
79546 | 921 (let ((map (make-sparse-keymap))) |
922 (define-key map ";" 'electric-verilog-semi) | |
923 (define-key map [(control 59)] 'electric-verilog-semi-with-comment) | |
924 (define-key map ":" 'electric-verilog-colon) | |
925 ;;(define-key map "=" 'electric-verilog-equal) | |
926 (define-key map "\`" 'electric-verilog-tick) | |
927 (define-key map "\t" 'electric-verilog-tab) | |
928 (define-key map "\r" 'electric-verilog-terminate-line) | |
929 ;; backspace/delete key bindings | |
930 (define-key map [backspace] 'backward-delete-char-untabify) | |
931 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable | |
932 (define-key map [delete] 'delete-char) | |
933 (define-key map [(meta delete)] 'kill-word)) | |
934 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) | |
935 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) | |
936 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | |
937 (define-key map "\M-\t" 'verilog-complete-word) | |
938 (define-key map "\M-?" 'verilog-show-completions) | |
939 (define-key map "\C-c\`" 'verilog-lint-off) | |
940 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | |
941 (define-key map "\C-c\C-r" 'verilog-label-be) | |
942 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) | |
943 (define-key map "\C-c=" 'verilog-pretty-expr) | |
944 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) | |
945 (define-key map "\M-*" 'verilog-star-comment) | |
946 (define-key map "\C-c\C-c" 'verilog-comment-region) | |
947 (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
|
948 (when (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
949 (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
|
950 (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
|
951 (define-key map "\M-\C-e" 'verilog-end-of-defun)) |
79546 | 952 (define-key map "\C-c\C-d" 'verilog-goto-defun) |
953 (define-key map "\C-c\C-k" 'verilog-delete-auto) | |
954 (define-key map "\C-c\C-a" 'verilog-auto) | |
955 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) | |
956 (define-key map "\C-c\C-z" 'verilog-inject-auto) | |
957 (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
|
958 (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
|
959 map) |
79545 | 960 "Keymap used in Verilog mode.") |
961 | |
962 ;; menus | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
963 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
964 verilog-menu verilog-mode-map "Menu for Verilog mode" |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
965 `("Verilog" |
79545 | 966 ("Choose Compilation Action" |
967 ["None" | |
968 (progn | |
969 (setq verilog-tool nil) | |
970 (verilog-set-compile-command)) | |
971 :style radio | |
972 :selected (equal verilog-tool nil)] | |
973 ["Lint" | |
974 (progn | |
975 (setq verilog-tool 'verilog-linter) | |
976 (verilog-set-compile-command)) | |
977 :style radio | |
978 :selected (equal verilog-tool `verilog-linter)] | |
979 ["Coverage" | |
980 (progn | |
981 (setq verilog-tool 'verilog-coverage) | |
982 (verilog-set-compile-command)) | |
983 :style radio | |
984 :selected (equal verilog-tool `verilog-coverage)] | |
985 ["Simulator" | |
986 (progn | |
987 (setq verilog-tool 'verilog-simulator) | |
988 (verilog-set-compile-command)) | |
989 :style radio | |
990 :selected (equal verilog-tool `verilog-simulator)] | |
991 ["Compiler" | |
992 (progn | |
993 (setq verilog-tool 'verilog-compiler) | |
994 (verilog-set-compile-command)) | |
995 :style radio | |
996 :selected (equal verilog-tool `verilog-compiler)] | |
997 ) | |
998 ("Move" | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
999 ["Beginning of function" verilog-beg-of-defun |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1000 :keys "C-M-a"] |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1001 ["End of function" verilog-end-of-defun |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1002 :keys "C-M-e"] |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1003 ["Mark function" verilog-mark-defun |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1004 :keys "C-M-h"] |
79545 | 1005 ["Goto function/module" verilog-goto-defun t] |
1006 ["Move to beginning of block" electric-verilog-backward-sexp t] | |
1007 ["Move to end of block" electric-verilog-forward-sexp t] | |
1008 ) | |
1009 ("Comments" | |
1010 ["Comment Region" verilog-comment-region t] | |
1011 ["UnComment Region" verilog-uncomment-region t] | |
1012 ["Multi-line comment insert" verilog-star-comment t] | |
1013 ["Lint error to comment" verilog-lint-off t] | |
1014 ) | |
1015 "----" | |
1016 ["Compile" compile t] | |
1017 ["AUTO, Save, Compile" verilog-auto-save-compile t] | |
1018 ["Next Compile Error" next-error t] | |
1019 ["Ignore Lint Warning at point" verilog-lint-off t] | |
1020 "----" | |
1021 ["Line up declarations around point" verilog-pretty-declarations t] | |
1022 ["Line up equations around point" verilog-pretty-expr t] | |
1023 ["Redo/insert comments on every end" verilog-label-be t] | |
1024 ["Expand [x:y] vector line" verilog-expand-vector t] | |
1025 ["Insert begin-end block" verilog-insert-block t] | |
1026 ["Complete word" verilog-complete-word t] | |
1027 "----" | |
1028 ["Recompute AUTOs" verilog-auto t] | |
1029 ["Kill AUTOs" verilog-delete-auto t] | |
1030 ["Inject AUTOs" verilog-inject-auto t] | |
1031 ("AUTO Help..." | |
1032 ["AUTO General" (describe-function 'verilog-auto) t] | |
1033 ["AUTO Library Flags" (describe-variable 'verilog-library-flags) t] | |
1034 ["AUTO Library Path" (describe-variable 'verilog-library-directories) t] | |
1035 ["AUTO Library Files" (describe-variable 'verilog-library-files) t] | |
1036 ["AUTO Library Extensions" (describe-variable 'verilog-library-extensions) t] | |
1037 ["AUTO `define Reading" (describe-function 'verilog-read-defines) t] | |
1038 ["AUTO `include Reading" (describe-function 'verilog-read-includes) t] | |
1039 ["AUTOARG" (describe-function 'verilog-auto-arg) t] | |
1040 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) t] | |
1041 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) t] | |
1042 ["AUTOINOUT" (describe-function 'verilog-auto-inout) t] | |
1043 ["AUTOINPUT" (describe-function 'verilog-auto-input) t] | |
1044 ["AUTOINST" (describe-function 'verilog-auto-inst) t] | |
1045 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) t] | |
1046 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) t] | |
1047 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) t] | |
1048 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) t] | |
1049 ["AUTOREG" (describe-function 'verilog-auto-reg) t] | |
1050 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) t] | |
1051 ["AUTORESET" (describe-function 'verilog-auto-reset) t] | |
1052 ["AUTOSENSE" (describe-function 'verilog-auto-sense) t] | |
1053 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) t] | |
1054 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) t] | |
1055 ["AUTOWIRE" (describe-function 'verilog-auto-wire) t] | |
1056 ) | |
1057 "----" | |
1058 ["Submit bug report" verilog-submit-bug-report t] | |
1059 ["Version and FAQ" verilog-faq t] | |
1060 ["Customize Verilog Mode..." verilog-customize t] | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1061 ["Customize Verilog Fonts & Colors" verilog-font-customize t])) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1062 |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1063 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1064 verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." |
79545 | 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] | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1095 ["Casez" verilog-sk-casez t])) |
79545 | 1096 |
1097 (defvar verilog-mode-abbrev-table nil | |
1098 "Abbrev table in use in Verilog-mode buffers.") | |
1099 | |
1100 (define-abbrev-table 'verilog-mode-abbrev-table ()) | |
1101 | |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1102 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1103 ;; Macros |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1104 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1105 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1106 (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
|
1107 "Replace occurrences of FROM-STRING with TO-STRING. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1108 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
|
1109 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
|
1110 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
|
1111 ;; Hopefully soon to a emacs built-in |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1112 (let ((start 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1113 (while (string-match from-string string start) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1114 (setq string (replace-match to-string fixedcase literal string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1115 start (min (length string) (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1116 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1117 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1118 (defsubst verilog-string-remove-spaces (string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1119 "Remove spaces surrounding STRING." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1120 (save-match-data |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1121 (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
|
1122 (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
|
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-re-search-forward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1126 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1127 "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
|
1128 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1129 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1130 (re-search-forward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1131 (and (verilog-skip-forward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1132 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1133 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1134 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1135 (< (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1136 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1137 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1138 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1139 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1140 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1141 "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
|
1142 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1143 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1144 (re-search-backward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1145 (and (verilog-skip-backward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1146 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1147 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1148 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1149 (> (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1150 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1151 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1152 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1153 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1154 "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
|
1155 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
|
1156 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
|
1157 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
|
1158 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1159 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1160 (re-search-forward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1161 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1162 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1163 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1164 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1165 (defsubst verilog-re-search-backward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1166 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1167 "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
|
1168 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
|
1169 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
|
1170 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
|
1171 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1172 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1173 (re-search-backward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1174 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1175 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1176 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1177 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1178 (defsubst verilog-get-beg-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1179 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1180 (beginning-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1181 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1182 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1183 (defsubst verilog-get-end-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1184 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1185 (end-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1186 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1187 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1188 (defsubst verilog-within-string () |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1189 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1190 (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
|
1191 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1192 (defvar compile-command) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1193 |
79545 | 1194 ;; compilation program |
1195 (defun verilog-set-compile-command () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1196 "Function to compute shell command to compile Verilog. |
79545 | 1197 |
1198 This reads `verilog-tool' and sets `compile-command'. This specifies the | |
1199 program that executes when you type \\[compile] or | |
1200 \\[verilog-auto-save-compile]. | |
1201 | |
1202 By default `verilog-tool' uses a Makefile if one exists in the current | |
1203 directory. If not, it is set to the `verilog-linter', `verilog-coverage', | |
1204 `verilog-simulator', or `verilog-compiler' variables, as selected with the | |
1205 Verilog -> \"Choose Compilation Action\" menu. | |
1206 | |
1207 You should set `verilog-tool' or the other variables to the path and | |
1208 arguments for your Verilog simulator. For example: | |
1209 \"vcs -p123 -O\" | |
1210 or a string like: | |
1211 \"(cd /tmp; surecov %s)\". | |
1212 | |
1213 In the former case, the path to the current buffer is concat'ed to the | |
1214 value of `verilog-tool'; in the later, the path to the current buffer is | |
1215 substituted for the %s. | |
1216 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1217 Where __FILE__ appears in the string, the `buffer-file-name' of the |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1218 current buffer, without the directory portion, will be substituted." |
79545 | 1219 (interactive) |
1220 (cond | |
1221 ((or (file-exists-p "makefile") ;If there is a makefile, use it | |
1222 (file-exists-p "Makefile")) | |
1223 (make-local-variable 'compile-command) | |
1224 (setq compile-command "make ")) | |
1225 (t | |
1226 (make-local-variable 'compile-command) | |
1227 (setq compile-command | |
1228 (if verilog-tool | |
1229 (if (string-match "%s" (eval verilog-tool)) | |
1230 (format (eval verilog-tool) (or buffer-file-name "")) | |
1231 (concat (eval verilog-tool) " " (or buffer-file-name ""))) | |
1232 "")))) | |
1233 (verilog-modify-compile-command)) | |
1234 | |
1235 (defun verilog-modify-compile-command () | |
1236 "Replace meta-information in `compile-command'. | |
1237 Where __FILE__ appears in the string, the current buffer's file-name, | |
1238 without the directory portion, will be substituted." | |
1239 (when (and | |
1240 (stringp compile-command) | |
1241 (string-match "\\b__FILE__\\b" compile-command)) | |
1242 (make-local-variable 'compile-command) | |
1243 (setq compile-command | |
1244 (verilog-string-replace-matches | |
1245 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) | |
1246 t t compile-command)))) | |
1247 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1248 ;; 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
|
1249 (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
|
1250 |
79545 | 1251 (defun verilog-error-regexp-add () |
1252 "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
|
1253 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
|
1254 find the errors." |
79545 | 1255 (if (not verilog-error-regexp-add-didit) |
1256 (progn | |
1257 (setq verilog-error-regexp-add-didit t) | |
1258 (setq-default compilation-error-regexp-alist | |
1259 (append verilog-error-regexp | |
1260 (default-value 'compilation-error-regexp-alist))) | |
1261 ;; 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
|
1262 (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
|
1263 (default-value 'compilation-error-regexp-alist)) |
79545 | 1264 (set (make-local-variable 'compilation-error-regexp-alist) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1265 (default-value 'compilation-error-regexp-alist))))) |
79545 | 1266 |
1267 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) | |
1268 | |
1269 (defconst verilog-directive-re | |
1270 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | |
1271 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1272 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1273 ;; "`time_scale" "`undef" "`while" | |
1274 "\\<`\\(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\\)\\>") | |
1275 | |
1276 (defconst verilog-directive-begin | |
1277 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>") | |
1278 | |
1279 (defconst verilog-directive-middle | |
1280 "\\<`\\(else\\|default\\|case\\)\\>") | |
1281 | |
1282 (defconst verilog-directive-end | |
1283 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>") | |
1284 | |
1285 (defconst verilog-directive-re-1 | |
1286 (concat "[ \t]*" verilog-directive-re)) | |
1287 | |
1288 ;; | |
1289 ;; Regular expressions used to calculate indent, etc. | |
1290 ;; | |
1291 (defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>") | |
1292 (defconst verilog-case-re "\\(\\<case[xz]?\\>\\|\\<randcase\\>\\)") | |
1293 ;; Want to match | |
1294 ;; aa : | |
1295 ;; aa,bb : | |
1296 ;; a[34:32] : | |
1297 ;; a, | |
1298 ;; b : | |
1299 | |
1300 (defconst verilog-no-indent-begin-re | |
1301 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>") | |
1302 | |
1303 (defconst verilog-ends-re | |
1304 ;; Parenthesis indicate type of keyword found | |
1305 (concat | |
1306 "\\(\\<else\\>\\)\\|" ; 1 | |
1307 "\\(\\<if\\>\\)\\|" ; 2 | |
1308 "\\(\\<end\\>\\)\\|" ; 3 | |
1309 "\\(\\<endcase\\>\\)\\|" ; 4 | |
1310 "\\(\\<endfunction\\>\\)\\|" ; 5 | |
1311 "\\(\\<endtask\\>\\)\\|" ; 6 | |
1312 "\\(\\<endspecify\\>\\)\\|" ; 7 | |
1313 "\\(\\<endtable\\>\\)\\|" ; 8 | |
1314 "\\(\\<endgenerate\\>\\)\\|" ; 9 | |
1315 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10 | |
1316 "\\(\\<endclass\\>\\)\\|" ; 11 | |
1317 "\\(\\<endgroup\\>\\)" ; 12 | |
1318 )) | |
1319 | |
1320 (defconst verilog-auto-end-comment-lines-re | |
1321 ;; Matches to names in this list cause auto-end-commentation | |
1322 (concat "\\(" | |
1323 verilog-directive-re "\\)\\|\\(" | |
1324 (eval-when-compile | |
1325 (verilog-regexp-words | |
1326 `( "begin" | |
1327 "else" | |
1328 "end" | |
1329 "endcase" | |
1330 "endclass" | |
1331 "endclocking" | |
1332 "endgroup" | |
1333 "endfunction" | |
1334 "endmodule" | |
1335 "endprogram" | |
1336 "endprimitive" | |
1337 "endinterface" | |
1338 "endpackage" | |
1339 "endsequence" | |
1340 "endspecify" | |
1341 "endtable" | |
1342 "endtask" | |
1343 "join" | |
1344 "join_any" | |
1345 "join_none" | |
1346 "module" | |
1347 "macromodule" | |
1348 "primitive" | |
1349 "interface" | |
1350 "package"))) | |
1351 "\\)")) | |
1352 | |
1353 ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and | |
1354 ;;; verilog-end-block-ordered-re matches exactly the same strings. | |
1355 (defconst verilog-end-block-ordered-re | |
1356 ;; Parenthesis indicate type of keyword found | |
1357 (concat "\\(\\<endcase\\>\\)\\|" ; 1 | |
1358 "\\(\\<end\\>\\)\\|" ; 2 | |
1359 "\\(\\<end" ; 3, but not used | |
1360 "\\(" ; 4, but not used | |
1361 "\\(function\\)\\|" ; 5 | |
1362 "\\(task\\)\\|" ; 6 | |
1363 "\\(module\\)\\|" ; 7 | |
1364 "\\(primitive\\)\\|" ; 8 | |
1365 "\\(interface\\)\\|" ; 9 | |
1366 "\\(package\\)\\|" ; 10 | |
1367 "\\(class\\)\\|" ; 11 | |
1368 "\\(group\\)\\|" ; 12 | |
1369 "\\(program\\)\\|" ; 13 | |
1370 "\\(sequence\\)\\|" ; 14 | |
1371 "\\(clocking\\)\\|" ; 15 | |
1372 "\\)\\>\\)")) | |
1373 (defconst verilog-end-block-re | |
1374 (eval-when-compile | |
1375 (verilog-regexp-words | |
1376 | |
1377 `("end" ;; closes begin | |
1378 "endcase" ;; closes any of case, casex casez or randcase | |
1379 "join" "join_any" "join_none" ;; closes fork | |
1380 "endclass" | |
1381 "endtable" | |
1382 "endspecify" | |
1383 "endfunction" | |
1384 "endgenerate" | |
1385 "endtask" | |
1386 "endgroup" | |
1387 "endproperty" | |
1388 "endinterface" | |
1389 "endpackage" | |
1390 "endprogram" | |
1391 "endsequence" | |
1392 "endclocking" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1393 )))) |
79545 | 1394 |
1395 | |
1396 (defconst verilog-endcomment-reason-re | |
1397 ;; Parenthesis indicate type of keyword found | |
1398 (concat | |
1399 "\\(\\<fork\\>\\)\\|" | |
1400 "\\(\\<begin\\>\\)\\|" | |
1401 "\\(\\<if\\>\\)\\|" | |
1402 "\\(\\<clocking\\>\\)\\|" | |
1403 "\\(\\<else\\>\\)\\|" | |
1404 "\\(\\<end\\>.*\\<else\\>\\)\\|" | |
1405 "\\(\\<task\\>\\)\\|" | |
1406 "\\(\\<function\\>\\)\\|" | |
1407 "\\(\\<initial\\>\\)\\|" | |
1408 "\\(\\<interface\\>\\)\\|" | |
1409 "\\(\\<package\\>\\)\\|" | |
1410 "\\(\\<final\\>\\)\\|" | |
1411 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1412 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1413 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1414 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1415 "\\(@\\)\\|" | |
1416 "\\(\\<while\\>\\)\\|" | |
1417 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|" | |
1418 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|" | |
1419 "#")) | |
1420 | |
1421 (defconst verilog-named-block-re "begin[ \t]*:") | |
1422 | |
1423 ;; These words begin a block which can occur inside a module which should be indented, | |
1424 ;; and closed with the respective word from the end-block list | |
1425 | |
1426 (defconst verilog-beg-block-re | |
1427 (eval-when-compile | |
1428 (verilog-regexp-words | |
1429 `("begin" | |
1430 "case" "casex" "casez" "randcase" | |
1431 "clocking" | |
1432 "generate" | |
1433 "fork" | |
1434 "function" | |
1435 "property" | |
1436 "specify" | |
1437 "table" | |
1438 "task" | |
1439 )))) | |
1440 ;; These are the same words, in a specific order in the regular | |
1441 ;; expression so that matching will work nicely for | |
1442 ;; verilog-forward-sexp and verilog-calc-indent | |
1443 | |
1444 (defconst verilog-beg-block-re-ordered | |
1445 ( concat "\\<" | |
1446 "\\(begin\\)" ;1 | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1447 "\\|\\(randcase\\|\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?\\)" ; 2,3 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1448 "\\|\\(\\(disable\\s-+\\)?fork\\)" ;4 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1449 "\\|\\(class\\)" ;5 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1450 "\\|\\(table\\)" ;6 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1451 "\\|\\(specify\\)" ;7 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1452 "\\|\\(function\\)" ;8 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1453 "\\|\\(task\\)" ;9 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1454 "\\|\\(generate\\)" ;10 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1455 "\\|\\(covergroup\\)" ;11 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1456 "\\|\\(property\\)" ;12 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1457 "\\|\\(\\(rand\\)?sequence\\)" ;13 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1458 "\\|\\(clocking\\)" ;14 |
79545 | 1459 "\\>")) |
1460 | |
1461 (defconst verilog-end-block-ordered-rry | |
1462 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1463 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" | |
1464 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1465 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" | |
1466 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" | |
1467 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" | |
1468 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" | |
1469 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" | |
1470 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" | |
1471 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" | |
1472 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" | |
1473 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" | |
1474 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" | |
1475 ] ) | |
1476 | |
1477 (defconst verilog-nameable-item-re | |
1478 (eval-when-compile | |
1479 (verilog-regexp-words | |
1480 `("begin" | |
1481 "fork" | |
1482 "join" "join_any" "join_none" | |
1483 "end" | |
1484 "endcase" | |
1485 "endconfig" | |
1486 "endclass" | |
1487 "endclocking" | |
1488 "endfunction" | |
1489 "endgenerate" | |
1490 "endmodule" | |
1491 "endprimative" | |
1492 "endinterface" | |
1493 "endpackage" | |
1494 "endspecify" | |
1495 "endtable" | |
1496 "endtask" ) | |
1497 ))) | |
1498 | |
1499 (defconst verilog-declaration-opener | |
1500 (eval-when-compile | |
1501 (verilog-regexp-words | |
1502 `("module" "begin" "task" "function")))) | |
1503 | |
1504 (defconst verilog-declaration-prefix-re | |
1505 (eval-when-compile | |
1506 (verilog-regexp-words | |
1507 `( | |
1508 ;; port direction | |
79546 | 1509 "inout" "input" "output" "ref" |
79545 | 1510 ;; changeableness |
1511 "const" "static" "protected" "local" | |
1512 ;; parameters | |
79546 | 1513 "localparam" "parameter" "var" |
79545 | 1514 ;; type creation |
1515 "typedef" | |
1516 )))) | |
1517 (defconst verilog-declaration-core-re | |
1518 (eval-when-compile | |
1519 (verilog-regexp-words | |
1520 `( | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
1521 ;; port direction (by themselves) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
1522 "inout" "input" "output" |
79545 | 1523 ;; integer_atom_type |
1524 "byte" "shortint" "int" "longint" "integer" "time" | |
1525 ;; integer_vector_type | |
1526 "bit" "logic" "reg" | |
1527 ;; non_integer_type | |
1528 "shortreal" "real" "realtime" | |
1529 ;; net_type | |
1530 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor" | |
1531 ;; misc | |
1532 "string" "event" "chandle" "virtual" "enum" "genvar" | |
1533 "struct" "union" | |
1534 ;; builtin classes | |
79546 | 1535 "mailbox" "semaphore" |
79545 | 1536 )))) |
79546 | 1537 (defconst verilog-declaration-re |
79545 | 1538 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re)) |
1539 (defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+") | |
1540 (defconst verilog-optional-signed-re "\\s-*\\(signed\\)?") | |
1541 (defconst verilog-optional-signed-range-re | |
1542 (concat | |
1543 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?")) | |
1544 (defconst verilog-macroexp-re "`\\sw+") | |
1545 | |
1546 (defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)") | |
1547 (defconst verilog-declaration-re-2-no-macro | |
1548 (concat "\\s-*" verilog-declaration-re | |
1549 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1550 "\\)?")) | |
1551 (defconst verilog-declaration-re-2-macro | |
1552 (concat "\\s-*" verilog-declaration-re | |
1553 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1554 "\\|\\(" verilog-macroexp-re "\\)" | |
1555 "\\)?")) | |
1556 (defconst verilog-declaration-re-1-macro | |
1557 (concat "^" verilog-declaration-re-2-macro)) | |
1558 | |
1559 (defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro)) | |
1560 | |
1561 (defconst verilog-defun-re | |
1562 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config")))) | |
1563 (defconst verilog-end-defun-re | |
1564 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig")))) | |
1565 (defconst verilog-zero-indent-re | |
1566 (concat verilog-defun-re "\\|" verilog-end-defun-re)) | |
1567 | |
1568 (defconst verilog-behavioral-block-beg-re | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1569 (eval-when-compile (verilog-regexp-words `("initial" "final" "always" "always_comb" "always_latch" "always_ff" |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1570 "function" "task")))) |
79545 | 1571 |
1572 (defconst verilog-indent-re | |
1573 (eval-when-compile | |
1574 (verilog-regexp-words | |
1575 `( | |
1576 "{" | |
1577 "always" "always_latch" "always_ff" "always_comb" | |
1578 "begin" "end" | |
1579 ; "unique" "priority" | |
1580 "case" "casex" "casez" "randcase" "endcase" | |
1581 "class" "endclass" | |
1582 "clocking" "endclocking" | |
1583 "config" "endconfig" | |
1584 "covergroup" "endgroup" | |
1585 "fork" "join" "join_any" "join_none" | |
1586 "function" "endfunction" | |
1587 "final" | |
1588 "generate" "endgenerate" | |
1589 "initial" | |
1590 "interface" "endinterface" | |
1591 "module" "macromodule" "endmodule" | |
1592 "package" "endpackage" | |
1593 "primitive" "endprimative" | |
1594 "program" "endprogram" | |
1595 "property" "endproperty" | |
1596 "sequence" "randsequence" "endsequence" | |
1597 "specify" "endspecify" | |
1598 "table" "endtable" | |
1599 "task" "endtask" | |
1600 "`case" | |
1601 "`default" | |
1602 "`define" "`undef" | |
1603 "`if" "`ifdef" "`ifndef" "`else" "`endif" | |
1604 "`while" "`endwhile" | |
1605 "`for" "`endfor" | |
1606 "`format" | |
1607 "`include" | |
1608 "`let" | |
1609 "`protect" "`endprotect" | |
1610 "`switch" "`endswitch" | |
1611 "`timescale" | |
1612 "`time_scale" | |
1613 )))) | |
1614 | |
1615 (defconst verilog-defun-level-re | |
1616 (eval-when-compile | |
1617 (verilog-regexp-words | |
1618 `( | |
1619 "module" "macromodule" "primitive" "class" "program" "initial" "final" "always" "always_comb" | |
1620 "always_ff" "always_latch" "endtask" "endfunction" "interface" "package" | |
1621 "config")))) | |
1622 | |
1623 (defconst verilog-defun-level-not-generate-re | |
1624 (eval-when-compile | |
1625 (verilog-regexp-words | |
1626 `( | |
1627 "module" "macromodule" "primitive" "class" "program" "interface" "package" "config")))) | |
1628 | |
1629 (defconst verilog-cpp-level-re | |
1630 (eval-when-compile | |
1631 (verilog-regexp-words | |
1632 `( | |
1633 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" | |
1634 )))) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1635 (defconst verilog-disable-fork-re "disable\\s-+fork") |
79545 | 1636 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") |
1637 (defconst verilog-extended-complete-re | |
1638 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" | |
1639 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)" | |
1640 "\\|" verilog-extended-case-re )) | |
1641 (defconst verilog-basic-complete-re | |
1642 (eval-when-compile | |
1643 (verilog-regexp-words | |
1644 `( | |
1645 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint" | |
1646 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while" | |
1647 "if" "for" "forever" "foreach" "else" "parameter" "do" | |
1648 )))) | |
1649 (defconst verilog-complete-reg | |
1650 (concat | |
1651 verilog-extended-complete-re | |
1652 "\\|" | |
1653 verilog-basic-complete-re)) | |
1654 | |
1655 (defconst verilog-end-statement-re | |
1656 (concat "\\(" verilog-beg-block-re "\\)\\|\\(" | |
1657 verilog-end-block-re "\\)")) | |
1658 | |
1659 (defconst verilog-endcase-re | |
1660 (concat verilog-case-re "\\|" | |
1661 "\\(endcase\\)\\|" | |
1662 verilog-defun-re | |
1663 )) | |
1664 | |
1665 (defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----" | |
1666 "String used to mark beginning of excluded text.") | |
1667 (defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */" | |
1668 "String used to mark end of excluded text.") | |
1669 (defconst verilog-preprocessor-re | |
1670 (eval-when-compile | |
1671 (verilog-regexp-words | |
1672 `( | |
1673 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else" | |
1674 )))) | |
1675 | |
1676 (defconst verilog-keywords | |
1677 '( "`case" "`default" "`define" "`else" "`endfor" "`endif" | |
1678 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1679 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1680 "`time_scale" "`undef" "`while" | |
1681 | |
1682 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" | |
1683 "assert" "assign" "assume" "automatic" "before" "begin" "bind" | |
1684 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" | |
1685 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" | |
1686 "config" "const" "constraint" "context" "continue" "cover" | |
1687 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" | |
1688 "design" "disable" "dist" "do" "edge" "else" "end" "endcase" | |
1689 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" | |
1690 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" | |
1691 "endprogram" "endproperty" "endspecify" "endsequence" "endtable" | |
1692 "endtask" "enum" "event" "expect" "export" "extends" "extern" | |
1693 "final" "first_match" "for" "force" "foreach" "forever" "fork" | |
1694 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" | |
1695 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" | |
1696 "include" "initial" "inout" "input" "inside" "instance" "int" | |
1697 "integer" "interface" "intersect" "join" "join_any" "join_none" | |
1698 "large" "liblist" "library" "local" "localparam" "logic" | |
1699 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" | |
1700 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" | |
1701 "notif0" "notif1" "null" "or" "output" "package" "packed" | |
1702 "parameter" "pmos" "posedge" "primitive" "priority" "program" | |
1703 "property" "protected" "pull0" "pull1" "pulldown" "pullup" | |
1704 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1705 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" | |
1706 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" | |
1707 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" | |
1708 "showcancelled" "signed" "small" "solve" "specify" "specparam" | |
1709 "static" "string" "strong0" "strong1" "struct" "super" "supply0" | |
1710 "supply1" "table" "tagged" "task" "this" "throughout" "time" | |
1711 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" | |
1712 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" | |
1713 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" | |
1714 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | |
1715 "wire" "with" "within" "wor" "xnor" "xor" | |
1716 ) | |
1717 "List of Verilog keywords.") | |
1718 | |
1719 (defconst verilog-comment-start-regexp "//\\|/\\*" | |
1720 "Dual comment value for `comment-start-regexp'.") | |
1721 | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1722 (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
|
1723 (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
|
1724 ;; Populate the syntax TABLE. |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1725 (modify-syntax-entry ?\\ "\\" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1726 (modify-syntax-entry ?+ "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1727 (modify-syntax-entry ?- "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1728 (modify-syntax-entry ?= "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1729 (modify-syntax-entry ?% "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1730 (modify-syntax-entry ?< "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1731 (modify-syntax-entry ?> "." 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 ?` "w" 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 ?_ "w" 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 |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1738 ;; 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
|
1739 (if (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1740 (progn |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1741 ;; 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
|
1742 (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
|
1743 (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
|
1744 (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
|
1745 ;; 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
|
1746 (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
|
1747 (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
|
1748 (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
|
1749 table) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1750 "Syntax table used in Verilog mode buffers.") |
79545 | 1751 |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1752 (defvar verilog-font-lock-keywords nil |
79545 | 1753 "Default highlighting for Verilog mode.") |
1754 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1755 (defvar verilog-font-lock-keywords-1 nil |
79545 | 1756 "Subdued level highlighting for Verilog mode.") |
1757 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1758 (defvar verilog-font-lock-keywords-2 nil |
79545 | 1759 "Medium level highlighting for Verilog mode. |
1760 See also `verilog-font-lock-extra-types'.") | |
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-3 nil |
79545 | 1763 "Gaudy level highlighting for Verilog mode. |
1764 See also `verilog-font-lock-extra-types'.") | |
1765 (defvar verilog-font-lock-translate-off-face | |
1766 'verilog-font-lock-translate-off-face | |
1767 "Font to use for translated off regions.") | |
1768 (defface verilog-font-lock-translate-off-face | |
1769 '((((class color) | |
1770 (background light)) | |
1771 (:background "gray90" :italic t )) | |
1772 (((class color) | |
1773 (background dark)) | |
1774 (:background "gray10" :italic t )) | |
1775 (((class grayscale) (background light)) | |
1776 (:foreground "DimGray" :italic t)) | |
1777 (((class grayscale) (background dark)) | |
1778 (:foreground "LightGray" :italic t)) | |
1779 (t (:italis t))) | |
1780 "Font lock mode face used to background highlight translate-off regions." | |
1781 :group 'font-lock-highlighting-faces) | |
1782 | |
1783 (defvar verilog-font-lock-p1800-face | |
1784 'verilog-font-lock-p1800-face | |
1785 "Font to use for p1800 keywords.") | |
1786 (defface verilog-font-lock-p1800-face | |
1787 '((((class color) | |
1788 (background light)) | |
1789 (:foreground "DarkOrange3" :bold t )) | |
1790 (((class color) | |
1791 (background dark)) | |
1792 (:foreground "orange1" :bold t )) | |
1793 (t (:italic t))) | |
1794 "Font lock mode face used to highlight P1800 keywords." | |
1795 :group 'font-lock-highlighting-faces) | |
1796 | |
1797 (defvar verilog-font-lock-ams-face | |
1798 'verilog-font-lock-ams-face | |
1799 "Font to use for Analog/Mixed Signal keywords.") | |
1800 (defface verilog-font-lock-ams-face | |
1801 '((((class color) | |
1802 (background light)) | |
1803 (:foreground "Purple" :bold t )) | |
1804 (((class color) | |
1805 (background dark)) | |
1806 (:foreground "orange1" :bold t )) | |
1807 (t (:italic t))) | |
1808 "Font lock mode face used to highlight AMS keywords." | |
1809 :group 'font-lock-highlighting-faces) | |
1810 | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1811 (defvar verilog-font-grouping-keywords-face |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1812 'verilog-font-lock-grouping-keywords-face |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1813 "Font to use for Verilog Grouping Keywords (such as begin..end).") |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1814 (defface verilog-font-lock-grouping-keywords-face |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1815 '((((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1816 (background light)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1817 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1818 (((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1819 (background dark)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1820 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1821 (t (:italic t))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1822 "Font lock mode face used to highlight verilog grouping keywords." |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1823 :group 'font-lock-highlighting-faces) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1824 |
79545 | 1825 (let* ((verilog-type-font-keywords |
1826 (eval-when-compile | |
1827 (verilog-regexp-opt | |
1828 '( | |
1829 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam" | |
1830 "event" "genvar" "inout" "input" "integer" "localparam" | |
1831 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or" | |
1832 "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
1833 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" | |
1834 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply" | |
1835 "supply0" "supply1" "time" "tran" "tranif0" "tranif1" | |
1836 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef" | |
1837 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor" | |
1838 ) nil ))) | |
1839 | |
1840 (verilog-pragma-keywords | |
1841 (eval-when-compile | |
1842 (verilog-regexp-opt | |
1843 '("surefire" "synopsys" "rtl_synthesis" "verilint" ) nil | |
1844 ))) | |
1845 | |
1846 (verilog-p1800-keywords | |
1847 (eval-when-compile | |
1848 (verilog-regexp-opt | |
1849 '("alias" "assert" "assume" "automatic" "before" "bind" | |
1850 "bins" "binsof" "break" "byte" "cell" "chandle" "class" | |
1851 "clocking" "config" "const" "constraint" "context" "continue" | |
1852 "cover" "covergroup" "coverpoint" "cross" "deassign" "design" | |
1853 "dist" "do" "edge" "endclass" "endclocking" "endconfig" | |
1854 "endgroup" "endprogram" "endproperty" "endsequence" "enum" | |
1855 "expect" "export" "extends" "extern" "first_match" "foreach" | |
1856 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins" | |
1857 "illegal_bins" "import" "incdir" "include" "inside" "instance" | |
1858 "int" "intersect" "large" "liblist" "library" "local" "longint" | |
1859 "matches" "medium" "modport" "new" "noshowcancelled" "null" | |
1860 "packed" "program" "property" "protected" "pull0" "pull1" | |
1861 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1862 "randcase" "randsequence" "ref" "release" "return" "scalared" | |
1863 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve" | |
1864 "specparam" "static" "string" "strong0" "strong1" "struct" | |
1865 "super" "tagged" "this" "throughout" "timeprecision" "timeunit" | |
1866 "type" "union" "unsigned" "use" "var" "virtual" "void" | |
1867 "wait_order" "weak0" "weak1" "wildcard" "with" "within" | |
1868 ) nil ))) | |
1869 | |
1870 (verilog-ams-keywords | |
1871 (eval-when-compile | |
1872 (verilog-regexp-opt | |
1873 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim" | |
1874 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh" | |
1875 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt" | |
1876 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules" | |
1877 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise" | |
1878 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf" | |
1879 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp" | |
1880 "last_crossing" "limexp" "ln" "log" "max" "min" "nature" | |
1881 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin" | |
1882 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise" | |
1883 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil ))) | |
1884 | |
1885 (verilog-font-keywords | |
1886 (eval-when-compile | |
1887 (verilog-regexp-opt | |
1888 '( | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1889 "assign" "case" "casex" "casez" "randcase" "deassign" |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1890 "default" "disable" "else" "endcase" "endfunction" |
79545 | 1891 "endgenerate" "endinterface" "endmodule" "endprimitive" |
1892 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break" | |
1893 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial" | |
1894 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge" | |
1895 "package" "endpackage" "always" "always_comb" "always_ff" | |
1896 "always_latch" "posedge" "primitive" "priority" "release" | |
1897 "repeat" "specify" "table" "task" "unique" "wait" "while" | |
1898 "class" "program" "endclass" "endprogram" | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1899 ) nil ))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1900 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1901 (verilog-font-grouping-keywords |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1902 (eval-when-compile |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1903 (verilog-regexp-opt |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1904 '( "begin" "end" ) nil )))) |
79545 | 1905 |
1906 (setq verilog-font-lock-keywords | |
1907 (list | |
1908 ;; Fontify all builtin keywords | |
1909 (concat "\\<\\(" verilog-font-keywords "\\|" | |
1910 ;; And user/system tasks and functions | |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
1911 "\\$[a-zA-Z][a-zA-Z0-9_\\$]*" |
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
1912 "\\)\\>") |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1913 ;; Fontify all types |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1914 (if verilog-highlight-grouping-keywords |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1915 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1916 'verilog-font-lock-ams-face) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1917 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1918 'font-lock-type-face)) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1919 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>") |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
1920 'font-lock-type-face) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
1921 ;; Fontify IEEE-P1800 keywords appropriately |
79545 | 1922 (if verilog-highlight-p1800-keywords |
1923 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
1924 'verilog-font-lock-p1800-face) | |
1925 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
1926 'font-lock-type-face)) | |
1927 ;; Fontify Verilog-AMS keywords | |
1928 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1929 'verilog-font-lock-ams-face))) |
79545 | 1930 |
1931 (setq verilog-font-lock-keywords-1 | |
1932 (append verilog-font-lock-keywords | |
1933 (list | |
1934 ;; Fontify module definitions | |
1935 (list | |
1936 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)" | |
1937 '(1 font-lock-keyword-face) | |
1938 '(3 font-lock-function-name-face 'prepend)) | |
1939 ;; Fontify function definitions | |
1940 (list | |
1941 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | |
1942 '(1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1943 '(3 font-lock-reference-face prepend)) |
79545 | 1944 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
1945 (1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1946 (2 font-lock-reference-face append)) |
79545 | 1947 '("\\<function\\>\\s-+\\(\\sw+\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1948 1 'font-lock-reference-face append)))) |
79545 | 1949 |
1950 (setq verilog-font-lock-keywords-2 | |
1951 (append verilog-font-lock-keywords-1 | |
1952 (list | |
1953 ;; Fontify pragmas | |
1954 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)") | |
1955 ;; Fontify escaped names | |
1956 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) | |
1957 ;; Fontify macro definitions/ uses | |
1958 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) | |
1959 'font-lock-preprocessor-face | |
1960 'font-lock-type-face)) | |
1961 ;; Fontify delays/numbers | |
1962 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | |
1963 0 font-lock-type-face append) | |
1964 ;; Fontify instantiation names | |
1965 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | |
1966 ))) | |
1967 | |
1968 (setq verilog-font-lock-keywords-3 | |
1969 (append verilog-font-lock-keywords-2 | |
1970 (when verilog-highlight-translate-off | |
1971 (list | |
1972 ;; 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
|
1973 '(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
|
1974 (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
|
1975 ))))) |
79545 | 1976 |
1977 | |
1978 (defun verilog-inside-comment-p () | |
1979 "Check if point inside a nested comment." | |
1980 (save-excursion | |
1981 (let ((st-point (point)) hitbeg) | |
1982 (or (search-backward "//" (verilog-get-beg-of-line) t) | |
1983 (if (progn | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1984 ;; This is for tricky case //*, we keep searching if /* |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1985 ;; 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
|
1986 (while |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1987 (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
|
1988 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1989 (forward-char 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1990 (search-backward "//" (verilog-get-beg-of-line) t)))) |
79545 | 1991 hitbeg) |
1992 (not (search-forward "*/" st-point t))))))) | |
1993 | |
1994 (defun verilog-declaration-end () | |
1995 (search-forward ";")) | |
1996 | |
1997 (defun verilog-point-text (&optional pointnum) | |
1998 "Return text describing where POINTNUM or current point is (for errors). | |
1999 Use filename, if current buffer being edited shorten to just buffer name." | |
2000 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer)) | |
2001 (buffer-name)) | |
2002 buffer-file-name | |
2003 (buffer-name)) | |
2004 ":" (int-to-string (count-lines (point-min) (or pointnum (point)))))) | |
2005 | |
2006 (defun electric-verilog-backward-sexp () | |
2007 "Move backward over a sexp." | |
2008 (interactive) | |
2009 ;; 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
|
2010 (verilog-backward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2011 |
79545 | 2012 (defun electric-verilog-forward-sexp () |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2013 "Move forward over a sexp." |
79545 | 2014 (interactive) |
2015 ;; 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
|
2016 (verilog-forward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2017 |
79545 | 2018 ;;;used by hs-minor-mode |
2019 (defun verilog-forward-sexp-function (arg) | |
2020 (if (< arg 0) | |
2021 (verilog-backward-sexp) | |
2022 (verilog-forward-sexp))) | |
2023 | |
2024 | |
2025 (defun verilog-backward-sexp () | |
2026 (let ((reg) | |
2027 (elsec 1) | |
2028 (found nil) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2029 (st (point))) |
79545 | 2030 (if (not (looking-at "\\<")) |
2031 (forward-word -1)) | |
2032 (cond | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2033 ((verilog-skip-backward-comment-or-string)) |
79545 | 2034 ((looking-at "\\<else\\>") |
2035 (setq reg (concat | |
2036 verilog-end-block-re | |
2037 "\\|\\(\\<else\\>\\)" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2038 "\\|\\(\\<if\\>\\)")) |
79545 | 2039 (while (and (not found) |
2040 (verilog-re-search-backward reg nil 'move)) | |
2041 (cond | |
2042 ((match-end 1) ; matched verilog-end-block-re | |
2043 ; try to leap back to matching outward block by striding across | |
2044 ; indent level changing tokens then immediately | |
2045 ; previous line governs indentation. | |
2046 (verilog-leap-to-head)) | |
2047 ((match-end 2) ; else, we're in deep | |
2048 (setq elsec (1+ elsec))) | |
2049 ((match-end 3) ; found it | |
2050 (setq elsec (1- elsec)) | |
2051 (if (= 0 elsec) | |
2052 ;; Now previous line describes syntax | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2053 (setq found 't)))))) |
79545 | 2054 ((looking-at verilog-end-block-re) |
2055 (verilog-leap-to-head)) | |
2056 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | |
2057 (cond | |
2058 ((match-end 1) | |
2059 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move)) | |
2060 ((match-end 2) | |
2061 (verilog-re-search-backward "\\<primitive\\>" nil 'move)) | |
2062 ((match-end 3) | |
2063 (verilog-re-search-backward "\\<class\\>" nil 'move)) | |
2064 ((match-end 4) | |
2065 (verilog-re-search-backward "\\<program\\>" nil 'move)) | |
2066 ((match-end 5) | |
2067 (verilog-re-search-backward "\\<interface\\>" nil 'move)) | |
2068 ((match-end 6) | |
2069 (verilog-re-search-backward "\\<package\\>" nil 'move)) | |
2070 (t | |
2071 (goto-char st) | |
2072 (backward-sexp 1)))) | |
2073 (t | |
2074 (goto-char st) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2075 (backward-sexp))))) |
79545 | 2076 |
2077 (defun verilog-forward-sexp () | |
2078 (let ((reg) | |
2079 (md 2) | |
2080 (st (point))) | |
2081 (if (not (looking-at "\\<")) | |
2082 (forward-word -1)) | |
2083 (cond | |
2084 ((verilog-skip-forward-comment-or-string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2085 (verilog-forward-syntactic-ws)) |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2086 ((looking-at verilog-beg-block-re-ordered) ;; begin|(case)|xx|(fork)|class|table|specify|function|task|generate|covergroup|property|sequence|clocking |
79545 | 2087 (cond |
2088 ((match-end 1) ; end | |
2089 ;; Search forward for matching begin | |
2090 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
2091 ((match-end 2) ; endcase | |
2092 ;; Search forward for matching case | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2093 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2094 (setq md 3) ;; ender is third item in regexp |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2095 ) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2096 ((match-end 4) ; join |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2097 ;; might be "disable fork" |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2098 (if (or |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2099 (looking-at verilog-disable-fork-re) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2100 (and (looking-at "fork") |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2101 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2102 (forward-word -1) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2103 (looking-at verilog-disable-fork-re)))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2104 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2105 (goto-char (match-end 0)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2106 (forward-word) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2107 (setq reg nil)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2108 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2109 ;; Search forward for matching fork |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2110 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2111 ((match-end 5) ; endclass |
79545 | 2112 ;; Search forward for matching class |
2113 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2114 ((match-end 6) ; endtable |
79545 | 2115 ;; Search forward for matching table |
2116 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2117 ((match-end 7) ; endspecify |
79545 | 2118 ;; Search forward for matching specify |
2119 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2120 ((match-end 8) ; endfunction |
79545 | 2121 ;; Search forward for matching function |
2122 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2123 ((match-end 9) ; endtask |
79545 | 2124 ;; Search forward for matching task |
2125 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2126 ((match-end 10) ; endgenerate |
79545 | 2127 ;; Search forward for matching generate |
2128 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2129 ((match-end 11) ; endgroup |
79545 | 2130 ;; Search forward for matching covergroup |
2131 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2132 ((match-end 12) ; endproperty |
79545 | 2133 ;; Search forward for matching property |
2134 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2135 ((match-end 13) ; endsequence |
79545 | 2136 ;; Search forward for matching sequence |
2137 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2138 (setq md 3)) ; 3 to get to endsequence in the reg above |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2139 ((match-end 14) ; endclocking |
79545 | 2140 ;; Search forward for matching clocking |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2141 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" ))) |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2142 (if (and reg |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2143 (forward-word 1)) |
79545 | 2144 (catch 'skip |
2145 (let ((nest 1)) | |
2146 (while (verilog-re-search-forward reg nil 'move) | |
2147 (cond | |
2148 ((match-end md) ; the closer in reg, so we are climbing out | |
2149 (setq nest (1- nest)) | |
2150 (if (= 0 nest) ; we are out! | |
2151 (throw 'skip 1))) | |
2152 ((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
|
2153 (setq nest (1+ nest))))))))) |
79545 | 2154 ((looking-at (concat |
2155 "\\(\\<\\(macro\\)?module\\>\\)\\|" | |
2156 "\\(\\<primitive\\>\\)\\|" | |
2157 "\\(\\<class\\>\\)\\|" | |
2158 "\\(\\<program\\>\\)\\|" | |
2159 "\\(\\<interface\\>\\)\\|" | |
2160 "\\(\\<package\\>\\)")) | |
2161 (cond | |
2162 ((match-end 1) | |
2163 (verilog-re-search-forward "\\<endmodule\\>" nil 'move)) | |
2164 ((match-end 2) | |
2165 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move)) | |
2166 ((match-end 3) | |
2167 (verilog-re-search-forward "\\<endclass\\>" nil 'move)) | |
2168 ((match-end 4) | |
2169 (verilog-re-search-forward "\\<endprogram\\>" nil 'move)) | |
2170 ((match-end 5) | |
2171 (verilog-re-search-forward "\\<endinterface\\>" nil 'move)) | |
2172 ((match-end 6) | |
2173 (verilog-re-search-forward "\\<endpackage\\>" nil 'move)) | |
2174 (t | |
2175 (goto-char st) | |
2176 (if (= (following-char) ?\) ) | |
2177 (forward-char 1) | |
2178 (forward-sexp 1))))) | |
2179 (t | |
2180 (goto-char st) | |
2181 (if (= (following-char) ?\) ) | |
2182 (forward-char 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2183 (forward-sexp 1)))))) |
79545 | 2184 |
2185 (defun verilog-declaration-beg () | |
2186 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | |
2187 | |
2188 (defun verilog-font-lock-init () | |
2189 "Initialize fontification." | |
2190 ;; highlight keywords and standardized types, attributes, enumeration | |
2191 ;; values, and subprograms | |
2192 (setq verilog-font-lock-keywords-3 | |
2193 (append verilog-font-lock-keywords-2 | |
2194 (when verilog-highlight-translate-off | |
2195 (list | |
2196 ;; 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
|
2197 '(verilog-match-translate-off |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2198 (0 'verilog-font-lock-translate-off-face prepend)))))) |
79545 | 2199 (put 'verilog-mode 'font-lock-defaults |
2200 '((verilog-font-lock-keywords | |
2201 verilog-font-lock-keywords-1 | |
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 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
|
2207 ;; 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
|
2208 verilog-beg-of-defun))) |
79545 | 2209 |
2210 ;; initialize fontification for Verilog Mode | |
2211 (verilog-font-lock-init) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2212 |
79545 | 2213 ;; |
2214 ;; | |
2215 ;; Mode | |
2216 ;; | |
2217 (defvar verilog-which-tool 1) | |
79546 | 2218 ;;;###autoload |
79545 | 2219 (defun verilog-mode () |
2220 "Major mode for editing Verilog code. | |
2221 \\<verilog-mode-map> | |
2222 See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how | |
2223 AUTOs can improve coding efficiency. | |
2224 | |
2225 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
2226 | |
2227 NEWLINE, TAB indents for Verilog code. | |
2228 Delete converts tabs to spaces as it moves back. | |
2229 | |
2230 Supports highlighting. | |
2231 | |
2232 Turning on Verilog mode calls the value of the variable `verilog-mode-hook' | |
2233 with no args, if that value is non-nil. | |
2234 | |
2235 Variables controlling indentation/edit style: | |
2236 | |
2237 variable `verilog-indent-level' (default 3) | |
2238 Indentation of Verilog statements with respect to containing block. | |
2239 `verilog-indent-level-module' (default 3) | |
2240 Absolute indentation of Module level Verilog statements. | |
2241 Set to 0 to get initial and always statements lined up | |
2242 on the left side of your screen. | |
2243 `verilog-indent-level-declaration' (default 3) | |
2244 Indentation of declarations with respect to containing block. | |
2245 Set to 0 to get them list right under containing block. | |
2246 `verilog-indent-level-behavioral' (default 3) | |
2247 Indentation of first begin in a task or function block | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2248 Set to 0 to get such code to lined up underneath the task or |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2249 function keyword. |
79545 | 2250 `verilog-indent-level-directive' (default 1) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2251 Indentation of `ifdef/`endif blocks. |
79545 | 2252 `verilog-cexp-indent' (default 1) |
2253 Indentation of Verilog statements broken across lines i.e.: | |
2254 if (a) | |
2255 begin | |
2256 `verilog-case-indent' (default 2) | |
2257 Indentation for case statements. | |
2258 `verilog-auto-newline' (default nil) | |
2259 Non-nil means automatically newline after semicolons and the punctuation | |
2260 mark after an end. | |
2261 `verilog-auto-indent-on-newline' (default t) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2262 Non-nil means automatically indent line after newline. |
79545 | 2263 `verilog-tab-always-indent' (default t) |
2264 Non-nil means TAB in Verilog mode should always reindent the current line, | |
2265 regardless of where in the line point is when the TAB command is used. | |
2266 `verilog-indent-begin-after-if' (default t) | |
2267 Non-nil means to indent begin statements following a preceding | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2268 if, else, while, for and repeat statements, if any. Otherwise, |
79545 | 2269 the begin is lined up with the preceding token. If t, you get: |
2270 if (a) | |
2271 begin // amount of indent based on `verilog-cexp-indent' | |
2272 otherwise you get: | |
2273 if (a) | |
2274 begin | |
2275 `verilog-auto-endcomments' (default t) | |
2276 Non-nil means a comment /* ... */ is set after the ends which ends | |
2277 cases, tasks, functions and modules. | |
2278 The type and name of the object will be set between the braces. | |
2279 `verilog-minimum-comment-distance' (default 10) | |
2280 Minimum distance (in lines) between begin and end required before a comment | |
2281 will be inserted. Setting this variable to zero results in every | |
2282 end acquiring a comment; the default avoids too many redundant | |
2283 comments in tight quarters. | |
2284 `verilog-auto-lineup' (default `(all)) | |
2285 List of contexts where auto lineup of code should be done. | |
2286 | |
2287 Variables controlling other actions: | |
2288 | |
2289 `verilog-linter' (default surelint) | |
2290 Unix program to call to run the lint checker. This is the default | |
2291 command for \\[compile-command] and \\[verilog-auto-save-compile]. | |
2292 | |
2293 See \\[customize] for the complete list of variables. | |
2294 | |
2295 AUTO expansion functions are, in part: | |
2296 | |
2297 \\[verilog-auto] Expand AUTO statements. | |
2298 \\[verilog-delete-auto] Remove the AUTOs. | |
2299 \\[verilog-inject-auto] Insert AUTOs for the first time. | |
2300 | |
2301 Some other functions are: | |
2302 | |
2303 \\[verilog-complete-word] Complete word with appropriate possibilities. | |
2304 \\[verilog-mark-defun] Mark function. | |
2305 \\[verilog-beg-of-defun] Move to beginning of current function. | |
2306 \\[verilog-end-of-defun] Move to end of current function. | |
2307 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements. | |
2308 | |
2309 \\[verilog-comment-region] Put marked area in a comment. | |
2310 \\[verilog-uncomment-region] Uncomment an area commented with \\[verilog-comment-region]. | |
2311 \\[verilog-insert-block] Insert begin ... end;. | |
2312 \\[verilog-star-comment] Insert /* ... */. | |
2313 | |
2314 \\[verilog-sk-always] Insert a always @(AS) begin .. end block. | |
2315 \\[verilog-sk-begin] Insert a begin .. end block. | |
2316 \\[verilog-sk-case] Insert a case block, prompting for details. | |
2317 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details. | |
2318 \\[verilog-sk-generate] Insert a generate .. endgenerate block. | |
2319 \\[verilog-sk-header] Insert a nice header block at the top of file. | |
2320 \\[verilog-sk-initial] Insert an initial begin .. end block. | |
2321 \\[verilog-sk-fork] Insert a fork begin .. end .. join block. | |
2322 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block. | |
2323 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block. | |
2324 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. | |
2325 \\[verilog-sk-specify] Insert a specify .. endspecify block. | |
2326 \\[verilog-sk-task] Insert a task .. begin .. end endtask block. | |
2327 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details. | |
2328 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details. | |
2329 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details. | |
2330 \\[verilog-sk-if] Insert an if (..) begin .. end block. | |
2331 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block. | |
2332 \\[verilog-sk-comment] Insert a comment block. | |
2333 \\[verilog-sk-assign] Insert an assign .. = ..; statement. | |
2334 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block. | |
2335 \\[verilog-sk-input] Insert an input declaration, prompting for details. | |
2336 \\[verilog-sk-output] Insert an output declaration, prompting for details. | |
2337 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details. | |
2338 \\[verilog-sk-inout] Insert an inout declaration, prompting for details. | |
2339 \\[verilog-sk-wire] Insert a wire declaration, prompting for details. | |
2340 \\[verilog-sk-reg] Insert a register declaration, prompting for details. | |
2341 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module. | |
2342 | |
2343 All key bindings can be seen in a Verilog-buffer with \\[describe-bindings]. | |
2344 Key bindings specific to `verilog-mode-map' are: | |
2345 | |
2346 \\{verilog-mode-map}" | |
2347 (interactive) | |
2348 (kill-all-local-variables) | |
2349 (use-local-map verilog-mode-map) | |
2350 (setq major-mode 'verilog-mode) | |
2351 (setq mode-name "Verilog") | |
2352 (setq local-abbrev-table verilog-mode-abbrev-table) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2353 (set (make-local-variable 'beginning-of-defun-function) |
79546 | 2354 'verilog-beg-of-defun) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2355 (set (make-local-variable 'end-of-defun-function) |
79546 | 2356 'verilog-end-of-defun) |
79545 | 2357 (set-syntax-table verilog-mode-syntax-table) |
2358 (make-local-variable 'indent-line-function) | |
2359 (setq indent-line-function 'verilog-indent-line-relative) | |
2360 (setq comment-indent-function 'verilog-comment-indent) | |
2361 (make-local-variable 'parse-sexp-ignore-comments) | |
2362 (setq parse-sexp-ignore-comments nil) | |
2363 (make-local-variable 'comment-start) | |
2364 (make-local-variable 'comment-end) | |
2365 (make-local-variable 'comment-multi-line) | |
2366 (make-local-variable 'comment-start-skip) | |
2367 (setq comment-start "// " | |
2368 comment-end "" | |
2369 comment-start-skip "/\\*+ *\\|// *" | |
2370 comment-multi-line nil) | |
2371 ;; Set up for compilation | |
2372 (setq verilog-which-tool 1) | |
2373 (setq verilog-tool 'verilog-linter) | |
2374 (verilog-set-compile-command) | |
2375 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables | |
2376 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) | |
2377 | |
2378 ;; Setting up menus | |
79546 | 2379 (when (featurep 'xemacs) |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2380 (easy-menu-add verilog-stmt-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2381 (easy-menu-add verilog-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2382 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2383 |
79545 | 2384 ;; 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
|
2385 (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
|
2386 '((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
|
2387 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
|
2388 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
|
2389 nil nil nil verilog-beg-of-defun)) |
79545 | 2390 ;;------------------------------------------------------------ |
2391 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el) | |
2392 ;; 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
|
2393 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2394 (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
|
2395 (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
|
2396 (make-local-hook 'after-change-functions)) |
79545 | 2397 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t) |
2398 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20 | |
2399 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) | |
2400 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2401 ;; Tell imenu how to handle Verilog. |
79545 | 2402 (make-local-variable 'imenu-generic-expression) |
2403 (setq imenu-generic-expression verilog-imenu-generic-expression) | |
2404 ;; hideshow support | |
2405 (unless (assq 'verilog-mode hs-special-modes-alist) | |
2406 (setq hs-special-modes-alist | |
2407 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil | |
2408 verilog-forward-sexp-function) | |
2409 hs-special-modes-alist))) | |
2410 | |
2411 ;; Stuff for autos | |
2412 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | |
2413 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them | |
2414 ;; (verilog-getopt-flags) | |
2415 (run-hooks 'verilog-mode-hook)) | |
2416 | |
2417 | |
2418 ;; | |
2419 ;; Electric functions | |
2420 ;; | |
2421 (defun electric-verilog-terminate-line (&optional arg) | |
2422 "Terminate line and indent next line. | |
2423 With optional ARG, remove existing end of line comments." | |
2424 (interactive) | |
2425 ;; before that see if we are in a comment | |
2426 (let ((state | |
2427 (save-excursion | |
2428 (parse-partial-sexp (point-min) (point))))) | |
2429 (cond | |
2430 ((nth 7 state) ; Inside // comment | |
2431 (if (eolp) | |
2432 (progn | |
2433 (delete-horizontal-space) | |
2434 (newline)) | |
2435 (progn | |
2436 (newline) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2437 (insert "// ") |
79545 | 2438 (beginning-of-line))) |
2439 (verilog-indent-line)) | |
2440 ((nth 4 state) ; Inside any comment (hence /**/) | |
2441 (newline) | |
2442 (verilog-more-comment)) | |
2443 ((eolp) | |
2444 ;; First, check if current line should be indented | |
2445 (if (save-excursion | |
2446 (delete-horizontal-space) | |
2447 (beginning-of-line) | |
2448 (skip-chars-forward " \t") | |
2449 (if (looking-at verilog-auto-end-comment-lines-re) | |
2450 (let ((indent-str (verilog-indent-line))) | |
2451 ;; Maybe we should set some endcomments | |
2452 (if verilog-auto-endcomments | |
2453 (verilog-set-auto-endcomments indent-str arg)) | |
2454 (end-of-line) | |
2455 (delete-horizontal-space) | |
2456 (if arg | |
2457 () | |
2458 (newline)) | |
2459 nil) | |
2460 (progn | |
2461 (end-of-line) | |
2462 (delete-horizontal-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2463 't))) |
79545 | 2464 ;; see if we should line up assignments |
2465 (progn | |
2466 (if (or (memq 'all verilog-auto-lineup) | |
2467 (memq 'assignments verilog-auto-lineup)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2468 (verilog-pretty-expr)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2469 (newline)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2470 (forward-line 1)) |
79545 | 2471 ;; Indent next line |
2472 (if verilog-auto-indent-on-newline | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2473 (verilog-indent-line))) |
79545 | 2474 (t |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2475 (newline))))) |
79545 | 2476 |
2477 (defun electric-verilog-terminate-and-indent () | |
2478 "Insert a newline and indent for the next statement." | |
2479 (interactive) | |
2480 (electric-verilog-terminate-line 1)) | |
2481 | |
2482 (defun electric-verilog-semi () | |
2483 "Insert `;' character and reindent the line." | |
2484 (interactive) | |
2485 (insert last-command-char) | |
2486 | |
2487 (if (or (verilog-in-comment-or-string-p) | |
2488 (verilog-in-escaped-name-p)) | |
2489 () | |
2490 (save-excursion | |
2491 (beginning-of-line) | |
2492 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2493 (verilog-indent-line)) |
79545 | 2494 (if (and verilog-auto-newline |
2495 (not (verilog-parenthesis-depth))) | |
2496 (electric-verilog-terminate-line)))) | |
2497 | |
2498 (defun electric-verilog-semi-with-comment () | |
2499 "Insert `;' character, reindent the line and indent for comment." | |
2500 (interactive) | |
2501 (insert "\;") | |
2502 (save-excursion | |
2503 (beginning-of-line) | |
2504 (verilog-indent-line)) | |
2505 (indent-for-comment)) | |
2506 | |
2507 (defun electric-verilog-colon () | |
2508 "Insert `:' and do all indentations except line indent on this line." | |
2509 (interactive) | |
2510 (insert last-command-char) | |
2511 ;; Do nothing if within string. | |
2512 (if (or | |
2513 (verilog-within-string) | |
2514 (not (verilog-in-case-region-p))) | |
2515 () | |
2516 (save-excursion | |
2517 (let ((p (point)) | |
2518 (lim (progn (verilog-beg-of-statement) (point)))) | |
2519 (goto-char p) | |
2520 (verilog-backward-case-item lim) | |
2521 (verilog-indent-line))) | |
2522 ;; (let ((verilog-tab-always-indent nil)) | |
2523 ;; (verilog-indent-line)) | |
2524 )) | |
2525 | |
2526 ;;(defun electric-verilog-equal () | |
2527 ;; "Insert `=', and do indentation if within block." | |
2528 ;; (interactive) | |
2529 ;; (insert last-command-char) | |
2530 ;; Could auto line up expressions, but not yet | |
2531 ;; (if (eq (car (verilog-calculate-indent)) 'block) | |
2532 ;; (let ((verilog-tab-always-indent nil)) | |
2533 ;; (verilog-indent-command))) | |
2534 ;; ) | |
2535 | |
2536 (defun electric-verilog-tick () | |
2537 "Insert back-tick, and indent to column 0 if this is a CPP directive." | |
2538 (interactive) | |
2539 (insert last-command-char) | |
2540 (save-excursion | |
2541 (if (progn | |
2542 (beginning-of-line) | |
2543 (looking-at verilog-directive-re-1)) | |
2544 (verilog-indent-line)))) | |
2545 | |
2546 (defun electric-verilog-tab () | |
2547 "Function called when TAB is pressed in Verilog mode." | |
2548 (interactive) | |
2549 ;; If verilog-tab-always-indent, indent the beginning of the line. | |
2550 (if (or verilog-tab-always-indent | |
2551 (save-excursion | |
2552 (skip-chars-backward " \t") | |
2553 (bolp))) | |
2554 (let* ((oldpnt (point)) | |
2555 (boi-point | |
2556 (save-excursion | |
2557 (beginning-of-line) | |
2558 (skip-chars-forward " \t") | |
2559 (verilog-indent-line) | |
2560 (back-to-indentation) | |
2561 (point)))) | |
2562 (if (< (point) boi-point) | |
2563 (back-to-indentation) | |
2564 (cond ((not verilog-tab-to-comment)) | |
2565 ((not (eolp)) | |
2566 (end-of-line)) | |
2567 (t | |
2568 (indent-for-comment) | |
2569 (when (and (eolp) (= oldpnt (point))) | |
2570 ; kill existing comment | |
2571 (beginning-of-line) | |
2572 (re-search-forward comment-start-skip oldpnt 'move) | |
2573 (goto-char (match-beginning 0)) | |
2574 (skip-chars-backward " \t") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2575 (kill-region (point) oldpnt)))))) |
79545 | 2576 (progn (insert "\t")))) |
2577 | |
2578 | |
2579 | |
2580 ;; | |
2581 ;; Interactive functions | |
2582 ;; | |
2583 | |
2584 (defun verilog-indent-buffer () | |
2585 "Indent-region the entire buffer as Verilog code. | |
2586 To call this from the command line, see \\[verilog-batch-indent]." | |
2587 (interactive) | |
2588 (verilog-mode) | |
2589 (indent-region (point-min) (point-max) nil)) | |
2590 | |
2591 (defun verilog-insert-block () | |
2592 "Insert Verilog begin ... end; block in the code with right indentation." | |
2593 (interactive) | |
2594 (verilog-indent-line) | |
2595 (insert "begin") | |
2596 (electric-verilog-terminate-line) | |
2597 (save-excursion | |
2598 (electric-verilog-terminate-line) | |
2599 (insert "end") | |
2600 (beginning-of-line) | |
2601 (verilog-indent-line))) | |
2602 | |
2603 (defun verilog-star-comment () | |
2604 "Insert Verilog star comment at point." | |
2605 (interactive) | |
2606 (verilog-indent-line) | |
2607 (insert "/*") | |
2608 (save-excursion | |
2609 (newline) | |
2610 (insert " */")) | |
2611 (newline) | |
2612 (insert " * ")) | |
2613 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2614 (defun verilog-insert-1 (fmt max) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2615 "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
|
2616 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
|
2617 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
|
2618 (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
|
2619 (n 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2620 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2621 (while (< n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2622 (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
|
2623 (forward-line 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2624 ;; 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
|
2625 ;; shorter than col. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2626 (if (eobp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2627 (setq n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2628 (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
|
2629 (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
|
2630 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2631 (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
|
2632 "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
|
2633 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
|
2634 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
|
2635 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
|
2636 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
|
2637 located after the first 'a' gives: |
79545 | 2638 |
2639 a = b a[ 0] = b | |
2640 a = b a[ 1] = b | |
2641 a = b a[ 2] = b | |
2642 a = b a[ 3] = b | |
2643 a = b ==> insert-indices ==> a[ 4] = b | |
2644 a = b a[ 5] = b | |
2645 a = b a[ 6] = b | |
2646 a = b a[ 7] = b | |
2647 a = b a[ 8] = b" | |
2648 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2649 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2650 (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
|
2651 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2652 (defun verilog-generate-numbers (max) |
79545 | 2653 "Insert a set of generated numbers into a rectangle. |
2654 The upper left corner is defined by point. The numbers are padded to three | |
2655 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
|
2656 is supplied, then the user is prompted for the MAX number. Consider the |
79545 | 2657 following code fragment: |
2658 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2659 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
|
2660 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
|
2661 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
|
2662 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
|
2663 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
|
2664 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
|
2665 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
|
2666 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
|
2667 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
|
2668 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2669 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2670 (verilog-insert-1 "%3.3d" max)) |
79545 | 2671 |
2672 (defun verilog-mark-defun () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2673 "Mark the current Verilog function (or procedure). |
79545 | 2674 This puts the mark at the end, and point at the beginning." |
2675 (interactive) | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2676 (if (featurep 'xemacs) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2677 (progn |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2678 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2679 (verilog-end-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2680 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2681 (verilog-beg-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2682 (if (fboundp 'zmacs-activate-region) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2683 (zmacs-activate-region))) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2684 (mark-defun))) |
79545 | 2685 |
2686 (defun verilog-comment-region (start end) | |
2687 ; checkdoc-params: (start end) | |
2688 "Put the region into a Verilog comment. | |
2689 The comments that are in this area are \"deformed\": | |
2690 `*)' becomes `!(*' and `}' becomes `!{'. | |
2691 These deformed comments are returned to normal if you use | |
2692 \\[verilog-uncomment-region] to undo the commenting. | |
2693 | |
2694 The commented area starts with `verilog-exclude-str-start', and ends with | |
2695 `verilog-exclude-str-end'. But if you change these variables, | |
2696 \\[verilog-uncomment-region] won't recognize the comments." | |
2697 (interactive "r") | |
2698 (save-excursion | |
2699 ;; Insert start and endcomments | |
2700 (goto-char end) | |
2701 (if (and (save-excursion (skip-chars-forward " \t") (eolp)) | |
2702 (not (save-excursion (skip-chars-backward " \t") (bolp)))) | |
2703 (forward-line 1) | |
2704 (beginning-of-line)) | |
2705 (insert verilog-exclude-str-end) | |
2706 (setq end (point)) | |
2707 (newline) | |
2708 (goto-char start) | |
2709 (beginning-of-line) | |
2710 (insert verilog-exclude-str-start) | |
2711 (newline) | |
2712 ;; Replace end-comments within commented area | |
2713 (goto-char end) | |
2714 (save-excursion | |
2715 (while (re-search-backward "\\*/" start t) | |
2716 (replace-match "*-/" t t))) | |
2717 (save-excursion | |
2718 (let ((s+1 (1+ start))) | |
2719 (while (re-search-backward "/\\*" s+1 t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2720 (replace-match "/-*" t t)))))) |
79545 | 2721 |
2722 (defun verilog-uncomment-region () | |
2723 "Uncomment a commented area; change deformed comments back to normal. | |
2724 This command does nothing if the pointer is not in a commented | |
2725 area. See also `verilog-comment-region'." | |
2726 (interactive) | |
2727 (save-excursion | |
2728 (let ((start (point)) | |
2729 (end (point))) | |
2730 ;; Find the boundaries of the comment | |
2731 (save-excursion | |
2732 (setq start (progn (search-backward verilog-exclude-str-start nil t) | |
2733 (point))) | |
2734 (setq end (progn (search-forward verilog-exclude-str-end nil t) | |
2735 (point)))) | |
2736 ;; Check if we're really inside a comment | |
2737 (if (or (equal start (point)) (<= end (point))) | |
2738 (message "Not standing within commented area.") | |
2739 (progn | |
2740 ;; Remove endcomment | |
2741 (goto-char end) | |
2742 (beginning-of-line) | |
2743 (let ((pos (point))) | |
2744 (end-of-line) | |
2745 (delete-region pos (1+ (point)))) | |
2746 ;; Change comments back to normal | |
2747 (save-excursion | |
2748 (while (re-search-backward "\\*-/" start t) | |
2749 (replace-match "*/" t t))) | |
2750 (save-excursion | |
2751 (while (re-search-backward "/-\\*" start t) | |
2752 (replace-match "/*" t t))) | |
2753 ;; Remove start comment | |
2754 (goto-char start) | |
2755 (beginning-of-line) | |
2756 (let ((pos (point))) | |
2757 (end-of-line) | |
2758 (delete-region pos (1+ (point))))))))) | |
2759 | |
2760 (defun verilog-beg-of-defun () | |
2761 "Move backward to the beginning of the current function or procedure." | |
2762 (interactive) | |
2763 (verilog-re-search-backward verilog-defun-re nil 'move)) | |
2764 | |
2765 (defun verilog-end-of-defun () | |
2766 "Move forward to the end of the current function or procedure." | |
2767 (interactive) | |
2768 (verilog-re-search-forward verilog-end-defun-re nil 'move)) | |
2769 | |
2770 (defun verilog-get-beg-of-defun (&optional warn) | |
2771 (save-excursion | |
2772 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t) | |
2773 (point)) | |
2774 (t | |
2775 (error "%s: Can't find module beginning" (verilog-point-text)) | |
2776 (point-max))))) | |
2777 (defun verilog-get-end-of-defun (&optional warn) | |
2778 (save-excursion | |
2779 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t) | |
2780 (point)) | |
2781 (t | |
2782 (error "%s: Can't find endmodule" (verilog-point-text)) | |
2783 (point-max))))) | |
2784 | |
2785 (defun verilog-label-be (&optional arg) | |
2786 "Label matching begin ... end, fork ... join and case ... endcase statements. | |
2787 With ARG, first kill any existing labels." | |
2788 (interactive) | |
2789 (let ((cnt 0) | |
2790 (oldpos (point)) | |
2791 (b (progn | |
2792 (verilog-beg-of-defun) | |
2793 (point-marker))) | |
2794 (e (progn | |
2795 (verilog-end-of-defun) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2796 (point-marker)))) |
79545 | 2797 (goto-char (marker-position b)) |
2798 (if (> (- e b) 200) | |
2799 (message "Relabeling module...")) | |
2800 (while (and | |
2801 (> (marker-position e) (point)) | |
2802 (verilog-re-search-forward | |
2803 (concat | |
2804 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>" | |
2805 "\\|\\(`endif\\)\\|\\(`else\\)") | |
2806 nil 'move)) | |
2807 (goto-char (match-beginning 0)) | |
2808 (let ((indent-str (verilog-indent-line))) | |
2809 (verilog-set-auto-endcomments indent-str 't) | |
2810 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2811 (delete-horizontal-space)) |
79545 | 2812 (setq cnt (1+ cnt)) |
2813 (if (= 9 (% cnt 10)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2814 (message "%d..." cnt))) |
79545 | 2815 (goto-char oldpos) |
2816 (if (or | |
2817 (> (- e b) 200) | |
2818 (> cnt 20)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2819 (message "%d lines auto commented" cnt)))) |
79545 | 2820 |
2821 (defun verilog-beg-of-statement () | |
2822 "Move backward to beginning of statement." | |
2823 (interactive) | |
2824 ;; Move back token by token until we see the end | |
2825 ;; of some ealier line. | |
2826 (while | |
2827 ;; If the current point does not begin a new | |
2828 ;; statement, as in the character ahead of us is a ';', or SOF | |
2829 ;; or the string after us unambiguosly starts a statement, | |
2830 ;; or the token before us unambiguously ends a statement, | |
2831 ;; then move back a token and test again. | |
2832 (not (or | |
2833 (bolp) | |
2834 (= (preceding-char) ?\;) | |
2835 (not (or | |
2836 (looking-at "\\<") | |
2837 (forward-word -1))) | |
2838 (and | |
2839 (looking-at verilog-extended-complete-re) | |
2840 (not (save-excursion | |
2841 (verilog-backward-token) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2842 (looking-at verilog-extended-complete-re)))) |
79545 | 2843 (looking-at verilog-basic-complete-re) |
2844 (save-excursion | |
2845 (verilog-backward-token) | |
2846 (or | |
2847 (looking-at verilog-end-block-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2848 (looking-at verilog-preprocessor-re))))) |
79545 | 2849 (verilog-backward-syntactic-ws) |
2850 (verilog-backward-token)) | |
2851 ;; Now point is where the previous line ended. | |
2852 (verilog-forward-syntactic-ws)) | |
2853 | |
2854 (defun verilog-beg-of-statement-1 () | |
2855 "Move backward to beginning of statement." | |
2856 (interactive) | |
2857 (let ((pt (point))) | |
2858 | |
2859 (while (and (not (looking-at verilog-complete-reg)) | |
2860 (setq pt (point)) | |
2861 (verilog-backward-token) | |
2862 (not (looking-at verilog-complete-reg)) | |
2863 (verilog-backward-syntactic-ws) | |
2864 (setq pt (point)) | |
2865 (not (bolp)) | |
2866 (not (= (preceding-char) ?\;)))) | |
2867 (goto-char pt) | |
2868 (verilog-forward-ws&directives))) | |
2869 | |
2870 (defun verilog-end-of-statement () | |
2871 "Move forward to end of current statement." | |
2872 (interactive) | |
2873 (let ((nest 0) pos) | |
2874 (or (looking-at verilog-beg-block-re) | |
2875 ;; Skip to end of statement | |
2876 (setq pos (catch 'found | |
2877 (while t | |
2878 (forward-sexp 1) | |
2879 (verilog-skip-forward-comment-or-string) | |
2880 (cond ((looking-at "[ \t]*;") | |
2881 (skip-chars-forward "^;") | |
2882 (forward-char 1) | |
2883 (throw 'found (point))) | |
2884 ((save-excursion | |
2885 (forward-sexp -1) | |
2886 (looking-at verilog-beg-block-re)) | |
2887 (goto-char (match-beginning 0)) | |
2888 (throw 'found nil)) | |
2889 ((looking-at "[ \t]*)") | |
79546 | 2890 (throw 'found (point))) |
79545 | 2891 ((eobp) |
2892 (throw 'found (point)))))))) | |
2893 (if (not pos) | |
2894 ;; Skip a whole block | |
2895 (catch 'found | |
2896 (while t | |
2897 (verilog-re-search-forward verilog-end-statement-re nil 'move) | |
2898 (setq nest (if (match-end 1) | |
2899 (1+ nest) | |
2900 (1- nest))) | |
2901 (cond ((eobp) | |
2902 (throw 'found (point))) | |
2903 ((= 0 nest) | |
2904 (throw 'found (verilog-end-of-statement)))))) | |
2905 pos))) | |
2906 | |
2907 (defun verilog-in-case-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2908 "Return true if in a case region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2909 More specifically, point @ in the line foo : @ begin" |
79545 | 2910 (interactive) |
2911 (save-excursion | |
2912 (if (and | |
2913 (progn (verilog-forward-syntactic-ws) | |
2914 (looking-at "\\<begin\\>")) | |
2915 (progn (verilog-backward-syntactic-ws) | |
2916 (= (preceding-char) ?\:))) | |
2917 (catch 'found | |
2918 (let ((nest 1)) | |
2919 (while t | |
2920 (verilog-re-search-backward | |
2921 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|" | |
2922 "\\(\\<endcase\\>\\)\\>") | |
2923 nil 'move) | |
2924 (cond | |
2925 ((match-end 3) | |
2926 (setq nest (1+ nest))) | |
2927 ((match-end 2) | |
2928 (if (= nest 1) | |
2929 (throw 'found 1)) | |
2930 (setq nest (1- nest))) | |
2931 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2932 (throw 'found (= nest 0))))))) |
79545 | 2933 nil))) |
2934 (defun verilog-in-struct-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2935 "Return true if in a struct region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2936 More specifically, in a list after a struct|union keyword." |
79545 | 2937 (interactive) |
2938 (save-excursion | |
2939 (let* ((state (parse-partial-sexp (point-min) (point))) | |
2940 (depth (nth 0 state))) | |
2941 (if depth | |
2942 (progn (backward-up-list depth) | |
2943 (verilog-beg-of-statement) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2944 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
79545 | 2945 |
2946 (defun verilog-in-generate-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2947 "Return true if in a generate region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2948 More specifically, after a generate and before an endgenerate." |
79545 | 2949 (interactive) |
2950 (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
|
2951 (nest 1)) |
79545 | 2952 (save-excursion |
2953 (while (and | |
2954 (/= nest 0) | |
2955 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) | |
2956 (cond | |
2957 ((match-end 1) ; generate | |
2958 (setq nest (1- nest))) | |
2959 ((match-end 2) ; endgenerate | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2960 (setq nest (1+ nest))))))) |
79545 | 2961 (= nest 0) )) ; return nest |
2962 | |
2963 (defun verilog-in-fork-region-p () | |
2964 "Return true if between a fork and join." | |
2965 (interactive) | |
2966 (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
|
2967 (nest 1)) |
79545 | 2968 (save-excursion |
2969 (while (and | |
2970 (/= nest 0) | |
2971 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | |
2972 (cond | |
2973 ((match-end 1) ; fork | |
2974 (setq nest (1- nest))) | |
2975 ((match-end 2) ; join | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2976 (setq nest (1+ nest))))))) |
79545 | 2977 (= nest 0) )) ; return nest |
2978 | |
2979 (defun verilog-backward-case-item (lim) | |
2980 "Skip backward to nearest enclosing case item. | |
2981 Limit search to point LIM." | |
2982 (interactive) | |
2983 (let ((str 'nil) | |
2984 (lim1 | |
2985 (progn | |
2986 (save-excursion | |
2987 (verilog-re-search-backward verilog-endcomment-reason-re | |
2988 lim 'move) | |
2989 (point))))) | |
2990 ;; Try to find the real : | |
2991 (if (save-excursion (search-backward ":" lim1 t)) | |
2992 (let ((colon 0) | |
2993 b e ) | |
2994 (while | |
2995 (and | |
2996 (< colon 1) | |
2997 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" | |
2998 lim1 'move)) | |
2999 (cond | |
3000 ((match-end 1) ;; [ | |
3001 (setq colon (1+ colon)) | |
3002 (if (>= colon 0) | |
3003 (error "%s: unbalanced [" (verilog-point-text)))) | |
3004 ((match-end 2) ;; ] | |
3005 (setq colon (1- colon))) | |
3006 | |
3007 ((match-end 3) ;; : | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3008 (setq colon (1+ colon))))) |
79545 | 3009 ;; Skip back to beginning of case item |
3010 (skip-chars-backward "\t ") | |
3011 (verilog-skip-backward-comment-or-string) | |
3012 (setq e (point)) | |
3013 (setq b | |
3014 (progn | |
3015 (if | |
3016 (verilog-re-search-backward | |
3017 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move) | |
3018 (progn | |
3019 (cond | |
3020 ((match-end 1) | |
3021 (goto-char (match-end 1)) | |
3022 (verilog-forward-ws&directives) | |
3023 (if (looking-at "(") | |
3024 (progn | |
3025 (forward-sexp) | |
3026 (verilog-forward-ws&directives))) | |
3027 (point)) | |
3028 (t | |
3029 (goto-char (match-end 0)) | |
3030 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3031 (point)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3032 (error "Malformed case item")))) |
79545 | 3033 (setq str (buffer-substring b e)) |
3034 (if | |
3035 (setq e | |
3036 (string-match | |
3037 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3038 (setq str (concat (substring str 0 e) "..."))) | |
3039 str) | |
3040 'nil))) | |
3041 | |
3042 | |
3043 ;; | |
3044 ;; Other functions | |
3045 ;; | |
3046 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3047 (defun verilog-kill-existing-comment () |
79545 | 3048 "Kill auto comment on this line." |
3049 (save-excursion | |
3050 (let* ( | |
3051 (e (progn | |
3052 (end-of-line) | |
3053 (point))) | |
3054 (b (progn | |
3055 (beginning-of-line) | |
3056 (search-forward "//" e t)))) | |
3057 (if b | |
3058 (delete-region (- b 2) e))))) | |
3059 | |
3060 (defconst verilog-directive-nest-re | |
3061 (concat "\\(`else\\>\\)\\|" | |
3062 "\\(`endif\\>\\)\\|" | |
3063 "\\(`if\\>\\)\\|" | |
3064 "\\(`ifdef\\>\\)\\|" | |
3065 "\\(`ifndef\\>\\)")) | |
3066 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment) | |
3067 "Add ending comment with given INDENT-STR. | |
3068 With KILL-EXISTING-COMMENT, remove what was there before. | |
3069 Insert `// case: 7 ' or `// NAME ' on this line if appropriate. | |
3070 Insert `// case expr ' if this line ends a case block. | |
3071 Insert `// ifdef FOO ' if this line ends code conditional on FOO. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3072 Insert `// NAME ' if this line ends a function, task, module, |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3073 primitive or interface named NAME." |
79545 | 3074 (save-excursion |
3075 (cond | |
3076 (; Comment close preprocessor directives | |
3077 (and | |
3078 (looking-at "\\(`endif\\)\\|\\(`else\\)") | |
3079 (or kill-existing-comment | |
3080 (not (save-excursion | |
3081 (end-of-line) | |
3082 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3083 (let ((nest 1) b e | |
3084 m | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3085 (else (if (match-end 2) "!" " "))) |
79545 | 3086 (end-of-line) |
3087 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3088 (verilog-kill-existing-comment)) |
79545 | 3089 (delete-horizontal-space) |
3090 (save-excursion | |
3091 (backward-sexp 1) | |
3092 (while (and (/= nest 0) | |
3093 (verilog-re-search-backward verilog-directive-nest-re nil 'move)) | |
3094 (cond | |
3095 ((match-end 1) ; `else | |
3096 (if (= nest 1) | |
3097 (setq else "!"))) | |
3098 ((match-end 2) ; `endif | |
3099 (setq nest (1+ nest))) | |
3100 ((match-end 3) ; `if | |
3101 (setq nest (1- nest))) | |
3102 ((match-end 4) ; `ifdef | |
3103 (setq nest (1- nest))) | |
3104 ((match-end 5) ; `ifndef | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3105 (setq nest (1- nest))))) |
79545 | 3106 (if (match-end 0) |
3107 (setq | |
3108 m (buffer-substring | |
3109 (match-beginning 0) | |
3110 (match-end 0)) | |
3111 b (progn | |
3112 (skip-chars-forward "^ \t") | |
3113 (verilog-forward-syntactic-ws) | |
3114 (point)) | |
3115 e (progn | |
3116 (skip-chars-forward "a-zA-Z0-9_") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3117 (point))))) |
79545 | 3118 (if b |
3119 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | |
3120 (insert (concat " // " else m " " (buffer-substring b e)))) | |
3121 (progn | |
3122 (insert " // unmatched `else or `endif") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3123 (ding 't))))) |
79545 | 3124 |
3125 (; Comment close case/class/function/task/module and named block | |
3126 (and (looking-at "\\<end") | |
3127 (or kill-existing-comment | |
3128 (not (save-excursion | |
3129 (end-of-line) | |
3130 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3131 (let ((type (car indent-str))) | |
3132 (unless (eq type 'declaration) | |
3133 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends | |
3134 (if (looking-at verilog-end-block-ordered-re) | |
3135 (cond | |
3136 (;- This is a case block; search back for the start of this case | |
3137 (match-end 1) ;; of verilog-end-block-ordered-re | |
3138 | |
3139 (let ((err 't) | |
3140 (str "UNMATCHED!!")) | |
3141 (save-excursion | |
3142 (verilog-leap-to-head) | |
3143 (cond | |
3144 ((looking-at "\\<randcase\\>") | |
3145 (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
|
3146 (setq err nil)) |
79545 | 3147 ((match-end 0) |
3148 (goto-char (match-end 1)) | |
3149 (if nil | |
3150 (let (s f) | |
3151 (setq s (match-beginning 1)) | |
3152 (setq f (progn (end-of-line) | |
3153 (point))) | |
3154 (setq str (buffer-substring s f))) | |
3155 (setq err nil)) | |
3156 (setq str (concat (buffer-substring (match-beginning 1) (match-end 1)) | |
3157 " " | |
3158 (verilog-get-expr)))))) | |
3159 (end-of-line) | |
3160 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3161 (verilog-kill-existing-comment)) |
79545 | 3162 (delete-horizontal-space) |
3163 (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
|
3164 (if err (ding 't)))) |
79545 | 3165 |
3166 (;- This is a begin..end block | |
3167 (match-end 2) ;; of verilog-end-block-ordered-re | |
3168 (let ((str " // UNMATCHED !!") | |
3169 (err 't) | |
3170 (here (point)) | |
3171 there | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3172 cntx) |
79545 | 3173 (save-excursion |
3174 (verilog-leap-to-head) | |
3175 (setq there (point)) | |
3176 (if (not (match-end 0)) | |
3177 (progn | |
3178 (goto-char here) | |
3179 (end-of-line) | |
3180 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3181 (verilog-kill-existing-comment)) |
79545 | 3182 (delete-horizontal-space) |
3183 (insert str) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3184 (ding 't)) |
79545 | 3185 (let ((lim |
3186 (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3187 (here (point))) |
79545 | 3188 (cond |
3189 (;-- handle named block differently | |
3190 (looking-at verilog-named-block-re) | |
3191 (search-forward ":") | |
3192 (setq there (point)) | |
3193 (setq str (verilog-get-expr)) | |
3194 (setq err nil) | |
3195 (setq str (concat " // block: " str ))) | |
3196 | |
3197 ((verilog-in-case-region-p) ;-- handle case item differently | |
3198 (goto-char here) | |
3199 (setq str (verilog-backward-case-item lim)) | |
3200 (setq there (point)) | |
3201 (setq err nil) | |
3202 (setq str (concat " // case: " str ))) | |
3203 | |
3204 (;- try to find "reason" for this begin | |
3205 (cond | |
3206 (; | |
3207 (eq here (progn | |
3208 (verilog-backward-token) | |
3209 (verilog-beg-of-statement-1) | |
3210 (point))) | |
3211 (setq err nil) | |
3212 (setq str "")) | |
3213 ((looking-at verilog-endcomment-reason-re) | |
3214 (setq there (match-end 0)) | |
3215 (setq cntx (concat | |
3216 (buffer-substring (match-beginning 0) (match-end 0)) " ")) | |
3217 (cond | |
3218 (;- begin | |
3219 (match-end 2) | |
3220 (setq err nil) | |
3221 (save-excursion | |
3222 (if (and (verilog-continued-line) | |
3223 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) | |
3224 (progn | |
3225 (goto-char (match-end 0)) | |
3226 (setq there (point)) | |
3227 (setq str | |
3228 (concat " // " | |
3229 (buffer-substring (match-beginning 0) (match-end 0)) " " | |
3230 (verilog-get-expr)))) | |
3231 (setq str "")))) | |
3232 | |
3233 (;- else | |
3234 (match-end 4) | |
3235 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3236 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3237 (catch 'skip |
3238 (while (verilog-re-search-backward reg nil 'move) | |
3239 (cond | |
3240 ((match-end 1) ; begin | |
3241 (setq nest (1- nest))) | |
3242 ((match-end 2) ; end | |
3243 (setq nest (1+ nest))) | |
3244 ((match-end 3) | |
3245 (if (= 0 nest) | |
3246 (progn | |
3247 (goto-char (match-end 0)) | |
3248 (setq there (point)) | |
3249 (setq err nil) | |
3250 (setq str (verilog-get-expr)) | |
3251 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3252 (throw 'skip 1))))))))) |
79545 | 3253 |
3254 (;- end else | |
3255 (match-end 5) | |
3256 (goto-char there) | |
3257 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3258 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3259 (catch 'skip |
3260 (while (verilog-re-search-backward reg nil 'move) | |
3261 (cond | |
3262 ((match-end 1) ; begin | |
3263 (setq nest (1- nest))) | |
3264 ((match-end 2) ; end | |
3265 (setq nest (1+ nest))) | |
3266 ((match-end 3) | |
3267 (if (= 0 nest) | |
3268 (progn | |
3269 (goto-char (match-end 0)) | |
3270 (setq there (point)) | |
3271 (setq err nil) | |
3272 (setq str (verilog-get-expr)) | |
3273 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3274 (throw 'skip 1))))))))) |
79545 | 3275 |
3276 (;- task/function/initial et cetera | |
3277 t | |
3278 (match-end 0) | |
3279 (goto-char (match-end 0)) | |
3280 (setq there (point)) | |
3281 (setq err nil) | |
3282 (setq str (verilog-get-expr)) | |
3283 (setq str (concat " // " cntx str ))) | |
3284 | |
3285 (;-- otherwise... | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3286 (setq str " // auto-endcomment confused ")))) |
79545 | 3287 |
3288 ((and | |
3289 (verilog-in-case-region-p) ;-- handle case item differently | |
3290 (progn | |
3291 (setq there (point)) | |
3292 (goto-char here) | |
3293 (setq str (verilog-backward-case-item lim)))) | |
3294 (setq err nil) | |
3295 (setq str (concat " // case: " str ))) | |
3296 | |
3297 ((verilog-in-fork-region-p) | |
3298 (setq err nil) | |
3299 (setq str " // fork branch" )) | |
3300 | |
3301 ((looking-at "\\<end\\>") | |
3302 ;; HERE | |
3303 (forward-word 1) | |
3304 (verilog-forward-syntactic-ws) | |
3305 (setq err nil) | |
3306 (setq str (verilog-get-expr)) | |
3307 (setq str (concat " // " cntx str ))) | |
3308 | |
3309 )))) | |
3310 (goto-char here) | |
3311 (end-of-line) | |
3312 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3313 (verilog-kill-existing-comment)) |
79545 | 3314 (delete-horizontal-space) |
3315 (if (or err | |
3316 (> (count-lines here there) verilog-minimum-comment-distance)) | |
3317 (insert str)) | |
3318 (if err (ding 't)) | |
3319 )))) | |
3320 (;- this is endclass, which can be nested | |
3321 (match-end 11) ;; of verilog-end-block-ordered-re | |
3322 ;;(goto-char there) | |
3323 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3324 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3325 string) |
79545 | 3326 (save-excursion |
3327 (catch 'skip | |
3328 (while (verilog-re-search-backward reg nil 'move) | |
3329 (cond | |
3330 ((match-end 3) ; endclass | |
3331 (ding 't) | |
3332 (setq string "unmatched endclass") | |
3333 (throw 'skip 1)) | |
3334 | |
3335 ((match-end 2) ; endclass | |
3336 (setq nest (1+ nest))) | |
3337 | |
3338 ((match-end 1) ; class | |
3339 (setq nest (1- nest)) | |
3340 (if (< nest 0) | |
3341 (progn | |
3342 (goto-char (match-end 0)) | |
3343 (let (b e) | |
3344 (setq b (progn | |
3345 (skip-chars-forward "^ \t") | |
3346 (verilog-forward-ws&directives) | |
3347 (point)) | |
3348 e (progn | |
3349 (skip-chars-forward "a-zA-Z0-9_") | |
3350 (point))) | |
3351 (setq string (buffer-substring b e))) | |
3352 (throw 'skip 1)))) | |
3353 )))) | |
3354 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3355 (insert (concat " // " string )))) |
79545 | 3356 |
3357 (;- this is end{function,generate,task,module,primitive,table,generate} | |
3358 ;- which can not be nested. | |
3359 t | |
3360 (let (string reg (width nil)) | |
3361 (end-of-line) | |
3362 (if kill-existing-comment | |
3363 (save-match-data | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3364 (verilog-kill-existing-comment))) |
79545 | 3365 (delete-horizontal-space) |
3366 (backward-sexp) | |
3367 (cond | |
3368 ((match-end 5) ;; of verilog-end-block-ordered-re | |
3369 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3370 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?")) |
79545 | 3371 ((match-end 6) ;; of verilog-end-block-ordered-re |
3372 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | |
3373 ((match-end 7) ;; of verilog-end-block-ordered-re | |
3374 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | |
3375 ((match-end 8) ;; of verilog-end-block-ordered-re | |
3376 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3377 ((match-end 9) ;; of verilog-end-block-ordered-re | |
3378 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) | |
3379 ((match-end 10) ;; of verilog-end-block-ordered-re | |
3380 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3381 ((match-end 11) ;; of verilog-end-block-ordered-re | |
3382 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3383 ((match-end 12) ;; of verilog-end-block-ordered-re | |
3384 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3385 ((match-end 13) ;; of verilog-end-block-ordered-re | |
3386 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3387 ((match-end 14) ;; of verilog-end-block-ordered-re | |
3388 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3389 ((match-end 15) ;; of verilog-end-block-ordered-re | |
3390 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | |
3391 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3392 (t (error "Problem in verilog-set-auto-endcomments"))) |
79545 | 3393 (let (b e) |
3394 (save-excursion | |
3395 (verilog-re-search-backward reg nil 'move) | |
3396 (cond | |
3397 ((match-end 1) | |
3398 (setq b (progn | |
3399 (skip-chars-forward "^ \t") | |
3400 (verilog-forward-ws&directives) | |
3401 (if (and width (looking-at width)) | |
3402 (progn | |
3403 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3404 (verilog-forward-ws&directives))) |
79545 | 3405 (point)) |
3406 e (progn | |
3407 (skip-chars-forward "a-zA-Z0-9_") | |
3408 (point))) | |
3409 (setq string (buffer-substring b e))) | |
3410 (t | |
3411 (ding 't) | |
3412 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) | |
3413 (end-of-line) | |
3414 (insert (concat " // " string ))) | |
3415 )))))))))) | |
3416 | |
3417 (defun verilog-get-expr() | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3418 "Grab expression at point, e.g, case ( a | b & (c ^d))." |
79545 | 3419 (let* ((b (progn |
3420 (verilog-forward-syntactic-ws) | |
3421 (skip-chars-forward " \t") | |
3422 (point))) | |
3423 (e (let ((par 1)) | |
3424 (cond | |
3425 ((looking-at "@") | |
3426 (forward-char 1) | |
3427 (verilog-forward-syntactic-ws) | |
3428 (if (looking-at "(") | |
3429 (progn | |
3430 (forward-char 1) | |
3431 (while (and (/= par 0) | |
3432 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3433 (cond | |
3434 ((match-end 1) | |
3435 (setq par (1+ par))) | |
3436 ((match-end 2) | |
3437 (setq par (1- par))))))) | |
3438 (point)) | |
3439 ((looking-at "(") | |
3440 (forward-char 1) | |
3441 (while (and (/= par 0) | |
3442 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3443 (cond | |
3444 ((match-end 1) | |
3445 (setq par (1+ par))) | |
3446 ((match-end 2) | |
3447 (setq par (1- par))))) | |
3448 (point)) | |
3449 ((looking-at "\\[") | |
3450 (forward-char 1) | |
3451 (while (and (/= par 0) | |
3452 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move)) | |
3453 (cond | |
3454 ((match-end 1) | |
3455 (setq par (1+ par))) | |
3456 ((match-end 2) | |
3457 (setq par (1- par))))) | |
3458 (verilog-forward-syntactic-ws) | |
3459 (skip-chars-forward "^ \t\n\f") | |
3460 (point)) | |
3461 ((looking-at "/[/\\*]") | |
3462 b) | |
3463 ('t | |
3464 (skip-chars-forward "^: \t\n\f") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3465 (point))))) |
79545 | 3466 (str (buffer-substring b e))) |
3467 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3468 (setq str (concat (substring str 0 e) "..."))) | |
3469 str)) | |
3470 | |
3471 (defun verilog-expand-vector () | |
3472 "Take a signal vector on the current line and expand it to multiple lines. | |
3473 Useful for creating tri's and other expanded fields." | |
3474 (interactive) | |
3475 (verilog-expand-vector-internal "[" "]")) | |
3476 | |
3477 (defun verilog-expand-vector-internal (bra ket) | |
3478 "Given BRA, the start brace and KET, the end brace, expand one line into many lines." | |
3479 (save-excursion | |
3480 (forward-line 0) | |
3481 (let ((signal-string (buffer-substring (point) | |
3482 (progn | |
3483 (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
|
3484 (if (string-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3485 (concat "\\(.*\\)" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3486 (regexp-quote bra) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3487 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3488 (regexp-quote ket) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3489 "\\(.*\\)$") signal-string) |
79545 | 3490 (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
|
3491 (vec-start (string-to-number (match-string 2 signal-string))) |
79545 | 3492 (vec-end (if (= (match-beginning 3) (match-end 3)) |
3493 vec-start | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3494 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3495 (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
|
3496 (match-end 3))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3497 (vec-range |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3498 (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
|
3499 1 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3500 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3501 (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
|
3502 (match-end 4))))) |
79545 | 3503 (sig-tail (match-string 5 signal-string)) |
3504 vec) | |
3505 ;; Decode vectors | |
3506 (setq vec nil) | |
3507 (if (< vec-range 0) | |
3508 (let ((tmp vec-start)) | |
3509 (setq vec-start vec-end | |
3510 vec-end tmp | |
3511 vec-range (- vec-range)))) | |
3512 (if (< vec-end vec-start) | |
3513 (while (<= vec-end vec-start) | |
3514 (setq vec (append vec (list vec-start))) | |
3515 (setq vec-start (- vec-start vec-range))) | |
3516 (while (<= vec-start vec-end) | |
3517 (setq vec (append vec (list vec-start))) | |
3518 (setq vec-start (+ vec-start vec-range)))) | |
3519 ;; | |
3520 ;; Delete current line | |
3521 (delete-region (point) (progn (forward-line 0) (point))) | |
3522 ;; | |
3523 ;; Expand vector | |
3524 (while vec | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3525 (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
|
3526 (int-to-string (car vec)) ket sig-tail "\n")) |
79545 | 3527 (setq vec (cdr vec))) |
3528 (delete-char -1) | |
3529 ;; | |
3530 ))))) | |
3531 | |
3532 (defun verilog-strip-comments () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3533 "Strip all comments from the Verilog code." |
79545 | 3534 (interactive) |
3535 (goto-char (point-min)) | |
3536 (while (re-search-forward "//" nil t) | |
3537 (if (verilog-within-string) | |
3538 (re-search-forward "\"" nil t) | |
3539 (if (verilog-in-star-comment-p) | |
3540 (re-search-forward "\*/" nil t) | |
3541 (let ((bpt (- (point) 2))) | |
3542 (end-of-line) | |
3543 (delete-region bpt (point)))))) | |
3544 ;; | |
3545 (goto-char (point-min)) | |
3546 (while (re-search-forward "/\\*" nil t) | |
3547 (if (verilog-within-string) | |
3548 (re-search-forward "\"" nil t) | |
3549 (let ((bpt (- (point) 2))) | |
3550 (re-search-forward "\\*/") | |
3551 (delete-region bpt (point)))))) | |
3552 | |
3553 (defun verilog-one-line () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3554 "Convert structural Verilog instances to occupy one line." |
79545 | 3555 (interactive) |
3556 (goto-char (point-min)) | |
3557 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) | |
3558 (replace-match "\\1 " nil nil))) | |
3559 | |
3560 (defun verilog-linter-name () | |
3561 "Return name of linter, either surelint or verilint." | |
3562 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3563 compile-command)) | |
3564 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3565 verilog-linter))) | |
3566 (cond ((equal compile-word1 "surelint") `surelint) | |
3567 ((equal compile-word1 "verilint") `verilint) | |
3568 ((equal lint-word1 "surelint") `surelint) | |
3569 ((equal lint-word1 "verilint") `verilint) | |
3570 (t `surelint)))) ;; back compatibility | |
3571 | |
3572 (defun verilog-lint-off () | |
3573 "Convert a Verilog linter warning line into a disable statement. | |
3574 For example: | |
3575 pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3576 becomes a comment for the appropriate tool. | |
3577 | |
3578 The first word of the `compile-command' or `verilog-linter' | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3579 variables is used to determine which product is being used. |
79545 | 3580 |
3581 See \\[verilog-surelint-off] and \\[verilog-verilint-off]." | |
3582 (interactive) | |
3583 (let ((linter (verilog-linter-name))) | |
3584 (cond ((equal linter `surelint) | |
3585 (verilog-surelint-off)) | |
3586 ((equal linter `verilint) | |
3587 (verilog-verilint-off)) | |
3588 (t (error "Linter name not set"))))) | |
3589 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3590 (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
|
3591 |
79545 | 3592 (defun verilog-surelint-off () |
3593 "Convert a SureLint warning line into a disable statement. | |
3594 Run from Verilog source window; assumes there is a *compile* buffer | |
3595 with point set appropriately. | |
3596 | |
3597 For example: | |
3598 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned. | |
3599 becomes: | |
3600 // surefire lint_line_off UDDONX" | |
3601 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3602 (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
|
3603 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
|
3604 compilation-last-buffer))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3605 (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
|
3606 ;; 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
|
3607 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3608 (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
|
3609 (beginning-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3610 (when |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3611 (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
|
3612 (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
|
3613 (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
|
3614 (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
|
3615 (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
|
3616 dir filename) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3617 (unless buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3618 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3619 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3620 (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
|
3621 (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
|
3622 (or buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3623 (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
|
3624 (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
|
3625 (read-file-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3626 (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
|
3627 file) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3628 dir file t)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3629 (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
|
3630 (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
|
3631 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3632 (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
|
3633 (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
|
3634 (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
|
3635 (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
|
3636 (end-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3637 (catch 'already |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3638 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3639 ((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
|
3640 (re-search-backward "//") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3641 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3642 ((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
|
3643 (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
|
3644 (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
|
3645 (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
|
3646 (throw 'already t) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3647 (insert (concat " " code))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3648 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3649 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3650 ((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
|
3651 (re-search-backward "/\*") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3652 (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
|
3653 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3654 (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
|
3655 ))))))))) |
79545 | 3656 |
3657 (defun verilog-verilint-off () | |
3658 "Convert a Verilint warning line into a disable statement. | |
3659 | |
3660 For example: | |
3661 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3662 becomes: | |
3663 //Verilint 240 off // WARNING: Unused input" | |
3664 (interactive) | |
3665 (save-excursion | |
3666 (beginning-of-line) | |
3667 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$") | |
3668 (replace-match (format | |
3669 ;; %3s makes numbers 1-999 line up nicely | |
3670 "\\1//Verilint %3s off // WARNING: \\3" | |
3671 (match-string 2))) | |
3672 (beginning-of-line) | |
3673 (verilog-indent-line)))) | |
3674 | |
3675 (defun verilog-auto-save-compile () | |
3676 "Update automatics with \\[verilog-auto], save the buffer, and compile." | |
3677 (interactive) | |
3678 (verilog-auto) ; Always do it for safety | |
3679 (save-buffer) | |
3680 (compile compile-command)) | |
3681 | |
3682 | |
3683 | |
3684 ;; | |
3685 ;; Batch | |
3686 ;; | |
3687 | |
3688 (defmacro verilog-batch-error-wrapper (&rest body) | |
3689 "Execute BODY and add error prefix to any errors found. | |
3690 This lets programs calling batch mode to easily extract error messages." | |
79546 | 3691 `(condition-case err |
3692 (progn ,@body) | |
3693 (error | |
3694 (error "%%Error: %s%s" (error-message-string err) | |
3695 (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline | |
79545 | 3696 |
3697 (defun verilog-batch-execute-func (funref) | |
3698 "Internal processing of a batch command, running FUNREF on all command arguments." | |
3699 (verilog-batch-error-wrapper | |
3700 ;; General globals needed | |
3701 (setq make-backup-files nil) | |
3702 (setq-default make-backup-files nil) | |
3703 (setq enable-local-variables t) | |
3704 (setq enable-local-eval t) | |
3705 ;; Make sure any sub-files we read get proper mode | |
3706 (setq default-major-mode `verilog-mode) | |
3707 ;; 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
|
3708 (mapc (lambda (buf) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3709 (when (buffer-file-name buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3710 (save-excursion |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3711 (set-buffer buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3712 (verilog-mode)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3713 (buffer-list)) |
79545 | 3714 ;; Process the files |
3715 (mapcar '(lambda (buf) | |
3716 (when (buffer-file-name buf) | |
3717 (save-excursion | |
3718 (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
|
3719 (error |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3720 (concat "File not found: " (buffer-file-name buf)))) |
79545 | 3721 (message (concat "Processing " (buffer-file-name buf))) |
3722 (set-buffer buf) | |
3723 (funcall funref) | |
3724 (save-buffer)))) | |
3725 (buffer-list)))) | |
3726 | |
3727 (defun verilog-batch-auto () | |
3728 "For use with --batch, perform automatic expansions as a stand-alone tool. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3729 This sets up the appropriate Verilog mode environment, updates automatics |
79545 | 3730 with \\[verilog-auto] on all command-line files, and saves the buffers. |
3731 For proper results, multiple filenames need to be passed on the command | |
3732 line in bottom-up order." | |
3733 (unless noninteractive | |
3734 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3735 (verilog-batch-execute-func `verilog-auto)) | |
3736 | |
3737 (defun verilog-batch-delete-auto () | |
3738 "For use with --batch, perform automatic deletion as a stand-alone tool. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3739 This sets up the appropriate Verilog mode environment, deletes automatics |
79545 | 3740 with \\[verilog-delete-auto] on all command-line files, and saves the buffers." |
3741 (unless noninteractive | |
3742 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3743 (verilog-batch-execute-func `verilog-delete-auto)) | |
3744 | |
3745 (defun verilog-batch-inject-auto () | |
3746 "For use with --batch, perform automatic injection as a stand-alone tool. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3747 This sets up the appropriate Verilog mode environment, injects new automatics |
79545 | 3748 with \\[verilog-inject-auto] on all command-line files, and saves the buffers. |
3749 For proper results, multiple filenames need to be passed on the command | |
3750 line in bottom-up order." | |
3751 (unless noninteractive | |
3752 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3753 (verilog-batch-execute-func `verilog-inject-auto)) | |
3754 | |
3755 (defun verilog-batch-indent () | |
3756 "For use with --batch, reindent an a entire file as a stand-alone tool. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3757 This sets up the appropriate Verilog mode environment, calls |
79545 | 3758 \\[verilog-indent-buffer] on all command-line files, and saves the buffers." |
3759 (unless noninteractive | |
3760 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3761 (verilog-batch-execute-func `verilog-indent-buffer)) | |
3762 | |
3763 | |
3764 ;; | |
3765 ;; Indentation | |
3766 ;; | |
3767 (defconst verilog-indent-alist | |
3768 '((block . (+ ind verilog-indent-level)) | |
3769 (case . (+ ind verilog-case-indent)) | |
3770 (cparenexp . (+ ind verilog-indent-level)) | |
3771 (cexp . (+ ind verilog-cexp-indent)) | |
3772 (defun . verilog-indent-level-module) | |
3773 (declaration . verilog-indent-level-declaration) | |
3774 (directive . (verilog-calculate-indent-directive)) | |
3775 (tf . verilog-indent-level) | |
3776 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module)) | |
3777 (statement . ind) | |
3778 (cpp . 0) | |
3779 (comment . (verilog-comment-indent)) | |
3780 (unknown . 3) | |
3781 (string . 0))) | |
3782 | |
3783 (defun verilog-continued-line-1 (lim) | |
3784 "Return true if this is a continued line. | |
3785 Set point to where line starts. Limit search to point LIM." | |
3786 (let ((continued 't)) | |
3787 (if (eq 0 (forward-line -1)) | |
3788 (progn | |
3789 (end-of-line) | |
3790 (verilog-backward-ws&directives lim) | |
3791 (if (bobp) | |
3792 (setq continued nil) | |
3793 (setq continued (verilog-backward-token)))) | |
3794 (setq continued nil)) | |
3795 continued)) | |
3796 | |
3797 (defun verilog-calculate-indent () | |
3798 "Calculate the indent of the current Verilog line. | |
3799 Examine previous lines. Once a line is found that is definitive as to the | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3800 type of the current line, return that lines' indent level and its type. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3801 Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." |
79545 | 3802 (save-excursion |
3803 (let* ((starting_position (point)) | |
3804 (par 0) | |
3805 (begin (looking-at "[ \t]*begin\\>")) | |
3806 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) | |
3807 (type (catch 'nesting | |
3808 ;; Keep working backwards until we can figure out | |
3809 ;; what type of statement this is. | |
3810 ;; Basically we need to figure out | |
3811 ;; 1) if this is a continuation of the previous line; | |
3812 ;; 2) are we in a block scope (begin..end) | |
3813 | |
3814 ;; if we are in a comment, done. | |
3815 (if (verilog-in-star-comment-p) | |
3816 (throw 'nesting 'comment)) | |
3817 | |
3818 ;; if we have a directive, done. | |
3819 (if (save-excursion (beginning-of-line) (looking-at verilog-directive-re-1)) | |
3820 (throw 'nesting 'directive)) | |
3821 | |
3822 ;; unless we are in the newfangled coverpoint or constraint blocks | |
3823 ;; if we are in a parenthesized list, and the user likes to indent these, return. | |
3824 (if (and | |
3825 verilog-indent-lists | |
3826 (not (verilog-in-coverage)) | |
3827 (verilog-in-paren)) | |
3828 (progn (setq par 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3829 (throw 'nesting 'block))) |
79545 | 3830 |
3831 ;; See if we are continuing a previous line | |
3832 (while t | |
3833 ;; trap out if we crawl off the top of the buffer | |
3834 (if (bobp) (throw 'nesting 'cpp)) | |
3835 | |
3836 (if (verilog-continued-line-1 lim) | |
3837 (let ((sp (point))) | |
3838 (if (and | |
3839 (not (looking-at verilog-complete-reg)) | |
3840 (verilog-continued-line-1 lim)) | |
3841 (progn (goto-char sp) | |
3842 (throw 'nesting 'cexp)) | |
3843 | |
3844 (goto-char sp)) | |
3845 | |
3846 (if (and begin | |
3847 (not verilog-indent-begin-after-if) | |
3848 (looking-at verilog-no-indent-begin-re)) | |
3849 (progn | |
3850 (beginning-of-line) | |
3851 (skip-chars-forward " \t") | |
3852 (throw 'nesting 'statement)) | |
3853 (progn | |
3854 (throw 'nesting 'cexp)))) | |
3855 ;; not a continued line | |
3856 (goto-char starting_position)) | |
3857 | |
3858 (if (looking-at "\\<else\\>") | |
3859 ;; search back for governing if, striding across begin..end pairs | |
3860 ;; appropriately | |
3861 (let ((elsec 1)) | |
3862 (while (verilog-re-search-backward verilog-ends-re nil 'move) | |
3863 (cond | |
3864 ((match-end 1) ; else, we're in deep | |
3865 (setq elsec (1+ elsec))) | |
3866 ((match-end 2) ; if | |
3867 (setq elsec (1- elsec)) | |
3868 (if (= 0 elsec) | |
3869 (if verilog-align-ifelse | |
3870 (throw 'nesting 'statement) | |
3871 (progn ;; back up to first word on this line | |
3872 (beginning-of-line) | |
3873 (verilog-forward-syntactic-ws) | |
3874 (throw 'nesting 'statement))))) | |
3875 (t ; endblock | |
3876 ; try to leap back to matching outward block by striding across | |
3877 ; indent level changing tokens then immediately | |
3878 ; previous line governs indentation. | |
3879 (let (( reg) (nest 1)) | |
3880 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup | |
3881 (cond | |
3882 ((match-end 3) ; end | |
3883 ;; Search back for matching begin | |
3884 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
3885 ((match-end 4) ; endcase | |
3886 ;; Search back for matching case | |
3887 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
3888 ((match-end 5) ; endfunction | |
3889 ;; Search back for matching function | |
3890 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
3891 ((match-end 6) ; endtask | |
3892 ;; Search back for matching task | |
3893 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
3894 ((match-end 7) ; endspecify | |
3895 ;; Search back for matching specify | |
3896 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
3897 ((match-end 8) ; endtable | |
3898 ;; Search back for matching table | |
3899 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
3900 ((match-end 9) ; endgenerate | |
3901 ;; Search back for matching generate | |
3902 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
3903 ((match-end 10) ; joins | |
3904 ;; Search back for matching fork | |
3905 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) | |
3906 ((match-end 11) ; class | |
3907 ;; Search back for matching class | |
3908 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
3909 ((match-end 12) ; covergroup | |
3910 ;; Search back for matching covergroup | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3911 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
79545 | 3912 (catch 'skip |
3913 (while (verilog-re-search-backward reg nil 'move) | |
3914 (cond | |
3915 ((match-end 1) ; begin | |
3916 (setq nest (1- nest)) | |
3917 (if (= 0 nest) | |
3918 (throw 'skip 1))) | |
3919 ((match-end 2) ; end | |
3920 (setq nest (1+ nest))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3921 ))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3922 (throw 'nesting (verilog-calc-1))) |
79545 | 3923 );; catch nesting |
3924 );; type | |
3925 ) | |
3926 ;; Return type of block and indent level. | |
3927 (if (not type) | |
3928 (setq type 'cpp)) | |
3929 (if (> par 0) ; Unclosed Parenthesis | |
3930 (list 'cparenexp par) | |
3931 (cond | |
3932 ((eq type 'case) | |
3933 (list type (verilog-case-indent-level))) | |
3934 ((eq type 'statement) | |
3935 (list type (current-column))) | |
3936 ((eq type 'defun) | |
3937 (list type 0)) | |
3938 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3939 (list type (verilog-current-indent-level)))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3940 |
79545 | 3941 (defun verilog-wai () |
3942 "Show matching nesting block for debugging." | |
3943 (interactive) | |
3944 (save-excursion | |
3945 (let ((nesting (verilog-calc-1))) | |
3946 (message "You are at nesting %s" nesting)))) | |
3947 | |
3948 (defun verilog-calc-1 () | |
3949 (catch 'nesting | |
3950 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) | |
3951 (cond | |
3952 ((equal (char-after) ?\{) | |
3953 (if (verilog-at-constraint-p) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3954 (throw 'nesting 'block))) |
79545 | 3955 ((equal (char-after) ?\}) |
3956 | |
3957 (let ((there (verilog-at-close-constraint-p))) | |
3958 (if there (goto-char there)))) | |
3959 | |
3960 ((looking-at verilog-beg-block-re-ordered) | |
3961 (cond | |
3962 ((match-end 2) ; *sigh* could be "unique case" or "priority casex" | |
3963 (let ((here (point))) | |
3964 (verilog-beg-of-statement) | |
3965 (if (looking-at verilog-extended-case-re) | |
3966 (throw 'nesting 'case) | |
3967 (goto-char here))) | |
3968 (throw 'nesting 'case)) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3969 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3970 ((match-end 4) ; *sigh* could be "disable fork" |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3971 (let ((here (point))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3972 (verilog-beg-of-statement) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3973 (if (looking-at verilog-disable-fork-re) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3974 t ; is disable fork, this is a normal statement |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3975 (progn ; or is fork, starts a new block |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3976 (goto-char here) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3977 (throw 'nesting 'block))))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
3978 |
79545 | 3979 |
3980 ;; need to consider typedef struct here... | |
3981 ((looking-at "\\<class\\|struct\\|function\\|task\\|property\\>") | |
3982 ; *sigh* These words have an optional prefix: | |
3983 ; extern {virtual|protected}? function a(); | |
3984 ; assert property (p_1); | |
3985 ; typedef class foo; | |
3986 ; and we don't want to confuse this with | |
3987 ; function a(); | |
3988 ; property | |
3989 ; ... | |
3990 ; endfunction | |
3991 (let ((here (point))) | |
3992 (save-excursion | |
3993 (verilog-beg-of-statement) | |
3994 (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
|
3995 (throw 'nesting 'block))))) |
79545 | 3996 (t (throw 'nesting 'block)))) |
3997 | |
3998 ((looking-at verilog-end-block-re) | |
3999 (verilog-leap-to-head) | |
4000 (if (verilog-in-case-region-p) | |
4001 (progn | |
4002 (verilog-leap-to-case-head) | |
4003 (if (looking-at verilog-case-re) | |
4004 (throw 'nesting 'case))))) | |
4005 | |
4006 ((looking-at (if (verilog-in-generate-region-p) | |
4007 verilog-defun-level-not-generate-re | |
4008 verilog-defun-level-re)) | |
4009 (throw 'nesting 'defun)) | |
4010 | |
4011 ((looking-at verilog-cpp-level-re) | |
4012 (throw 'nesting 'cpp)) | |
4013 | |
4014 ((bobp) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4015 (throw 'nesting 'cpp)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4016 (throw 'nesting 'cpp))) |
79545 | 4017 |
4018 (defun verilog-calculate-indent-directive () | |
4019 "Return indentation level for directive. | |
4020 For speed, the searcher looks at the last directive, not the indent | |
4021 of the appropriate enclosing block." | |
4022 (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
|
4023 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) |
79545 | 4024 ;; Start at current location, scan back for another directive |
4025 | |
4026 (save-excursion | |
4027 (beginning-of-line) | |
4028 (while (and (< base 0) | |
4029 (verilog-re-search-backward verilog-directive-re nil t)) | |
4030 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4031 (setq base (current-indentation)))) |
79545 | 4032 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
4033 (setq ind (- ind verilog-indent-level-directive))) | |
4034 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | |
4035 (setq ind (+ ind verilog-indent-level-directive))) | |
4036 ((looking-at verilog-directive-begin) | |
4037 (setq ind (+ ind verilog-indent-level-directive))))) | |
4038 ;; Adjust indent to starting indent of critical line | |
4039 (setq ind (max 0 (+ ind base)))) | |
4040 | |
4041 (save-excursion | |
4042 (beginning-of-line) | |
4043 (skip-chars-forward " \t") | |
4044 (cond ((or (looking-at verilog-directive-middle) | |
4045 (looking-at verilog-directive-end)) | |
4046 (setq ind (max 0 (- ind verilog-indent-level-directive)))))) | |
4047 ind)) | |
4048 | |
4049 (defun verilog-leap-to-case-head () | |
4050 (let ((nest 1)) | |
4051 (while (/= 0 nest) | |
4052 (verilog-re-search-backward "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" nil 'move) | |
4053 (cond | |
4054 ((match-end 1) | |
4055 (setq nest (1- nest))) | |
4056 ((match-end 2) | |
4057 (setq nest (1+ nest))) | |
4058 ((bobp) | |
4059 (ding 't) | |
4060 (setq nest 0)))))) | |
4061 | |
4062 (defun verilog-leap-to-head () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4063 "Move point to the head of this block. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4064 Jump from end to matching begin, from endcase to matching case, and so on." |
79545 | 4065 (let ((reg nil) |
4066 snest | |
4067 (nest 1)) | |
4068 (cond | |
4069 ((looking-at "\\<end\\>") | |
4070 ;; 1: Search back for matching begin | |
4071 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|" | |
4072 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))) | |
4073 ((looking-at "\\<endcase\\>") | |
4074 ;; 2: Search back for matching case | |
4075 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" )) | |
4076 ((looking-at "\\<join\\(_any\\|_none\\)?\\>") | |
4077 ;; 3: Search back for matching fork | |
4078 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4079 ((looking-at "\\<endclass\\>") | |
4080 ;; 4: Search back for matching class | |
4081 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
4082 ((looking-at "\\<endtable\\>") | |
4083 ;; 5: Search back for matching table | |
4084 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
4085 ((looking-at "\\<endspecify\\>") | |
4086 ;; 6: Search back for matching specify | |
4087 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
4088 ((looking-at "\\<endfunction\\>") | |
4089 ;; 7: Search back for matching function | |
4090 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
4091 ((looking-at "\\<endgenerate\\>") | |
4092 ;; 8: Search back for matching generate | |
4093 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
4094 ((looking-at "\\<endtask\\>") | |
4095 ;; 9: Search back for matching task | |
4096 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
4097 ((looking-at "\\<endgroup\\>") | |
4098 ;; 10: Search back for matching covergroup | |
4099 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
4100 ((looking-at "\\<endproperty\\>") | |
4101 ;; 11: Search back for matching property | |
4102 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
4103 ((looking-at "\\<endinterface\\>") | |
4104 ;; 12: Search back for matching interface | |
4105 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" )) | |
4106 ((looking-at "\\<endsequence\\>") | |
4107 ;; 12: Search back for matching sequence | |
4108 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | |
4109 ((looking-at "\\<endclocking\\>") | |
4110 ;; 12: Search back for matching clocking | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4111 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
79545 | 4112 (if reg |
4113 (catch 'skip | |
4114 (let (sreg) | |
4115 (while (verilog-re-search-backward reg nil 'move) | |
4116 (cond | |
4117 ((match-end 1) ; begin | |
4118 (setq nest (1- nest)) | |
4119 (if (= 0 nest) | |
4120 ;; Now previous line describes syntax | |
4121 (throw 'skip 1)) | |
4122 (if (and snest | |
4123 (= snest nest)) | |
4124 (setq reg sreg))) | |
4125 ((match-end 2) ; end | |
4126 (setq nest (1+ nest))) | |
4127 ((match-end 3) | |
4128 ;; endcase, jump to case | |
4129 (setq snest nest) | |
4130 (setq nest (1+ nest)) | |
4131 (setq sreg reg) | |
4132 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
4133 ((match-end 4) | |
4134 ;; join, jump to fork | |
4135 (setq snest nest) | |
4136 (setq nest (1+ nest)) | |
4137 (setq sreg reg) | |
4138 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4139 ))))))) | |
4140 | |
4141 (defun verilog-continued-line () | |
4142 "Return true if this is a continued line. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4143 Set point to where line starts." |
79545 | 4144 (let ((continued 't)) |
4145 (if (eq 0 (forward-line -1)) | |
4146 (progn | |
4147 (end-of-line) | |
4148 (verilog-backward-ws&directives) | |
4149 (if (bobp) | |
4150 (setq continued nil) | |
4151 (while (and continued | |
4152 (save-excursion | |
4153 (skip-chars-backward " \t") | |
4154 (not (bolp)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4155 (setq continued (verilog-backward-token))))) |
79545 | 4156 (setq continued nil)) |
4157 continued)) | |
4158 | |
4159 (defun verilog-backward-token () | |
4160 "Step backward token, returning true if we are now at an end of line token." | |
4161 (interactive) | |
4162 (verilog-backward-syntactic-ws) | |
4163 (cond | |
4164 ((bolp) | |
4165 nil) | |
4166 (;-- Anything ending in a ; is complete | |
4167 (= (preceding-char) ?\;) | |
4168 nil) | |
4169 (; If a "}" is prefixed by a ";", then this is a complete statement | |
4170 ; i.e.: constraint foo { a = b; } | |
4171 (= (preceding-char) ?\}) | |
4172 (progn | |
4173 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4174 (verilog-at-close-constraint-p))) |
79545 | 4175 (;-- constraint foo { a = b } |
4176 ; is a complete statement. *sigh* | |
4177 (= (preceding-char) ?\{) | |
4178 (progn | |
4179 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4180 (not (verilog-at-constraint-p)))) |
79545 | 4181 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4182 ; also could be simply '@(foo)' | |
4183 ; or foo u1 #(a=8) | |
4184 ; (b, ... which ISN'T complete | |
4185 ;;;; Do we need this??? | |
4186 (= (preceding-char) ?\)) | |
4187 (progn | |
4188 (backward-char) | |
4189 (backward-up-list 1) | |
4190 (verilog-backward-syntactic-ws) | |
4191 (let ((back (point))) | |
4192 (forward-word -1) | |
4193 (cond | |
4194 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") | |
4195 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]"))) | |
4196 (t | |
4197 (goto-char back) | |
4198 (cond | |
4199 ((= (preceding-char) ?\@) | |
4200 (backward-char) | |
4201 (save-excursion | |
4202 (verilog-backward-token) | |
4203 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | |
4204 ((= (preceding-char) ?\#) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4205 (backward-char)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4206 (t t))))))) |
79545 | 4207 |
4208 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | |
4209 t | |
4210 (forward-word -1) | |
4211 (cond | |
4212 ((looking-at "\\<else\\>") | |
4213 t) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4214 ((looking-at verilog-behavioral-block-beg-re) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4215 t) |
79545 | 4216 ((looking-at verilog-indent-re) |
4217 nil) | |
4218 (t | |
4219 (let | |
4220 ((back (point))) | |
4221 (verilog-backward-syntactic-ws) | |
4222 (cond | |
4223 ((= (preceding-char) ?\:) | |
4224 (backward-char) | |
4225 (verilog-backward-syntactic-ws) | |
4226 (backward-sexp) | |
4227 (if (looking-at verilog-nameable-item-re ) | |
4228 nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4229 t)) |
79545 | 4230 ((= (preceding-char) ?\#) |
4231 (backward-char) | |
4232 t) | |
4233 ((= (preceding-char) ?\`) | |
4234 (backward-char) | |
4235 t) | |
4236 | |
4237 (t | |
4238 (goto-char back) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4239 t)))))))) |
79545 | 4240 |
4241 (defun verilog-backward-syntactic-ws (&optional bound) | |
4242 "Backward skip over syntactic whitespace for Emacs 19. | |
4243 Optional BOUND limits search." | |
4244 (save-restriction | |
4245 (let* ((bound (or bound (point-min))) (here bound) ) | |
4246 (if (< bound (point)) | |
4247 (progn | |
4248 (narrow-to-region bound (point)) | |
4249 (while (/= here (point)) | |
4250 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4251 (verilog-skip-backward-comments)))))) |
79545 | 4252 t) |
4253 | |
4254 (defun verilog-forward-syntactic-ws (&optional bound) | |
4255 "Forward skip over syntactic whitespace for Emacs 19. | |
4256 Optional BOUND limits search." | |
4257 (save-restriction | |
4258 (let* ((bound (or bound (point-max))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4259 (here bound)) |
79545 | 4260 (if (> bound (point)) |
4261 (progn | |
4262 (narrow-to-region (point) bound) | |
4263 (while (/= here (point)) | |
4264 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4265 (forward-comment (buffer-size)))))))) |
79545 | 4266 |
4267 (defun verilog-backward-ws&directives (&optional bound) | |
4268 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4269 Optional BOUND limits search." | |
4270 (save-restriction | |
4271 (let* ((bound (or bound (point-min))) | |
4272 (here bound) | |
4273 (p nil) ) | |
4274 (if (< bound (point)) | |
4275 (progn | |
4276 (let ((state | |
4277 (save-excursion | |
4278 (parse-partial-sexp (point-min) (point))))) | |
4279 (cond | |
4280 ((nth 7 state) ;; in // comment | |
4281 (verilog-re-search-backward "//" nil 'move) | |
4282 (skip-chars-backward "/")) | |
4283 ((nth 4 state) ;; in /* */ comment | |
4284 (verilog-re-search-backward "/\*" nil 'move)))) | |
4285 (narrow-to-region bound (point)) | |
4286 (while (/= here (point)) | |
4287 (setq here (point)) | |
4288 (verilog-skip-backward-comments) | |
4289 (setq p | |
4290 (save-excursion | |
4291 (beginning-of-line) | |
4292 (cond | |
4293 ((verilog-within-translate-off) | |
4294 (verilog-back-to-start-translate-off (point-min))) | |
4295 ((looking-at verilog-directive-re-1) | |
4296 (point)) | |
4297 (t | |
4298 nil)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4299 (if p (goto-char p)))))))) |
79545 | 4300 |
4301 (defun verilog-forward-ws&directives (&optional bound) | |
4302 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4303 Optional BOUND limits search." | |
4304 (save-restriction | |
4305 (let* ((bound (or bound (point-max))) | |
4306 (here bound) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4307 jump) |
79545 | 4308 (if (> bound (point)) |
4309 (progn | |
4310 (let ((state | |
4311 (save-excursion | |
4312 (parse-partial-sexp (point-min) (point))))) | |
4313 (cond | |
4314 ((nth 7 state) ;; in // comment | |
4315 (verilog-re-search-forward "//" nil 'move)) | |
4316 ((nth 4 state) ;; in /* */ comment | |
4317 (verilog-re-search-forward "/\*" nil 'move)))) | |
4318 (narrow-to-region (point) bound) | |
4319 (while (/= here (point)) | |
4320 (setq here (point) | |
4321 jump nil) | |
4322 (forward-comment (buffer-size)) | |
4323 (save-excursion | |
4324 (beginning-of-line) | |
4325 (if (looking-at verilog-directive-re-1) | |
4326 (setq jump t))) | |
4327 (if jump | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4328 (beginning-of-line 2)))))))) |
79545 | 4329 |
4330 (defun verilog-in-comment-p () | |
4331 "Return true if in a star or // comment." | |
4332 (let ((state | |
4333 (save-excursion | |
4334 (parse-partial-sexp (point-min) (point))))) | |
4335 (or (nth 4 state) (nth 7 state)))) | |
4336 | |
4337 (defun verilog-in-star-comment-p () | |
4338 "Return true if in a star comment." | |
4339 (let ((state | |
4340 (save-excursion | |
4341 (parse-partial-sexp (point-min) (point))))) | |
4342 (and | |
4343 (nth 4 state) ; t if in a comment of style a // or b /**/ | |
4344 (not | |
4345 (nth 7 state) ; t if in a comment of style b /**/ | |
4346 )))) | |
4347 | |
4348 (defun verilog-in-slash-comment-p () | |
4349 "Return true if in a slash comment." | |
4350 (let ((state | |
4351 (save-excursion | |
4352 (parse-partial-sexp (point-min) (point))))) | |
4353 (nth 7 state))) | |
4354 | |
4355 (defun verilog-in-comment-or-string-p () | |
4356 "Return true if in a string or comment." | |
4357 (let ((state | |
4358 (save-excursion | |
4359 (parse-partial-sexp (point-min) (point))))) | |
4360 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) | |
4361 | |
4362 (defun verilog-in-escaped-name-p () | |
4363 "Return true if in an escaped name." | |
4364 (save-excursion | |
4365 (backward-char) | |
4366 (skip-chars-backward "^ \t\n\f") | |
4367 (if (equal (char-after (point) ) ?\\ ) | |
4368 t | |
4369 nil))) | |
4370 | |
4371 (defun verilog-in-paren () | |
4372 "Return true if in a parenthetical expression." | |
4373 (let ((state | |
4374 (save-excursion | |
4375 (parse-partial-sexp (point-min) (point))))) | |
4376 (> (nth 0 state) 0 ))) | |
4377 | |
4378 (defun verilog-in-coverage () | |
4379 "Return true if in a constraint or coverpoint expression." | |
4380 (interactive) | |
4381 (save-excursion | |
4382 (if (verilog-in-paren) | |
4383 (progn | |
4384 (backward-up-list 1) | |
4385 (verilog-at-constraint-p) | |
4386 ) | |
4387 nil))) | |
4388 (defun verilog-at-close-constraint-p () | |
4389 "If at the } that closes a constraint or covergroup, return true." | |
4390 (if (and | |
4391 (equal (char-after) ?\}) | |
4392 (verilog-in-paren)) | |
4393 | |
4394 (save-excursion | |
4395 (verilog-backward-ws&directives) | |
4396 (if (equal (char-before) ?\;) | |
4397 (point) | |
4398 nil)))) | |
4399 | |
4400 (defun verilog-at-constraint-p () | |
4401 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." | |
4402 (if (save-excursion | |
4403 (and | |
4404 (equal (char-after) ?\{) | |
4405 (forward-list) | |
4406 (progn (backward-char 1) | |
4407 (verilog-backward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4408 (equal (char-before) ?\;)))) |
79545 | 4409 ;; maybe |
4410 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | |
4411 ;; not | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4412 nil)) |
79545 | 4413 |
4414 (defun verilog-parenthesis-depth () | |
4415 "Return non zero if in parenthetical-expression." | |
4416 (save-excursion | |
4417 (nth 1 (parse-partial-sexp (point-min) (point))))) | |
4418 | |
4419 | |
4420 (defun verilog-skip-forward-comment-or-string () | |
4421 "Return true if in a string or comment." | |
4422 (let ((state | |
4423 (save-excursion | |
4424 (parse-partial-sexp (point-min) (point))))) | |
4425 (cond | |
4426 ((nth 3 state) ;Inside string | |
4427 (goto-char (nth 3 state)) | |
4428 t) | |
4429 ((nth 7 state) ;Inside // comment | |
4430 (forward-line 1) | |
4431 t) | |
4432 ((nth 4 state) ;Inside any comment (hence /**/) | |
4433 (search-forward "*/")) | |
4434 (t | |
4435 nil)))) | |
4436 | |
4437 (defun verilog-skip-backward-comment-or-string () | |
4438 "Return true if in a string or comment." | |
4439 (let ((state | |
4440 (save-excursion | |
4441 (parse-partial-sexp (point-min) (point))))) | |
4442 (cond | |
4443 ((nth 3 state) ;Inside string | |
4444 (search-backward "\"") | |
4445 t) | |
4446 ((nth 7 state) ;Inside // comment | |
4447 (search-backward "//") | |
4448 (skip-chars-backward "/") | |
4449 t) | |
4450 ((nth 4 state) ;Inside /* */ comment | |
4451 (search-backward "/*") | |
4452 t) | |
4453 (t | |
4454 nil)))) | |
4455 | |
4456 (defun verilog-skip-backward-comments () | |
4457 "Return true if a comment was skipped." | |
4458 (let ((more t)) | |
4459 (while more | |
4460 (setq more | |
4461 (let ((state | |
4462 (save-excursion | |
4463 (parse-partial-sexp (point-min) (point))))) | |
4464 (cond | |
4465 ((nth 7 state) ;Inside // comment | |
4466 (search-backward "//") | |
4467 (skip-chars-backward "/") | |
4468 (skip-chars-backward " \t\n\f") | |
4469 t) | |
4470 ((nth 4 state) ;Inside /* */ comment | |
4471 (search-backward "/*") | |
4472 (skip-chars-backward " \t\n\f") | |
4473 t) | |
4474 ((and (not (bobp)) | |
4475 (= (char-before) ?\/) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4476 (= (char-before (1- (point))) ?\*)) |
79545 | 4477 (goto-char (- (point) 2)) |
4478 t) | |
4479 (t | |
4480 (skip-chars-backward " \t\n\f") | |
4481 nil))))))) | |
4482 | |
4483 (defun verilog-skip-forward-comment-p () | |
4484 "If in comment, move to end and return true." | |
4485 (let (state) | |
4486 (progn | |
4487 (setq state | |
4488 (save-excursion | |
4489 (parse-partial-sexp (point-min) (point)))) | |
4490 (cond | |
4491 ((nth 3 state) | |
4492 t) | |
4493 ((nth 7 state) ;Inside // comment | |
4494 (end-of-line) | |
4495 (forward-char 1) | |
4496 t) | |
4497 ((nth 4 state) ;Inside any comment | |
4498 t) | |
4499 (t | |
4500 nil))))) | |
4501 | |
4502 (defun verilog-indent-line-relative () | |
4503 "Cheap version of indent line. | |
4504 Only look at a few lines to determine indent level." | |
4505 (interactive) | |
4506 (let ((indent-str) | |
4507 (sp (point))) | |
4508 (if (looking-at "^[ \t]*$") | |
4509 (cond ;- A blank line; No need to be too smart. | |
4510 ((bobp) | |
4511 (setq indent-str (list 'cpp 0))) | |
4512 ((verilog-continued-line) | |
4513 (let ((sp1 (point))) | |
4514 (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
|
4515 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4516 (goto-char sp) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4517 (setq indent-str |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4518 (list 'statement (verilog-current-indent-level)))) |
79545 | 4519 (goto-char sp1) |
4520 (setq indent-str (list 'block (verilog-current-indent-level))))) | |
4521 (goto-char sp)) | |
4522 ((goto-char sp) | |
4523 (setq indent-str (verilog-calculate-indent)))) | |
4524 (progn (skip-chars-forward " \t") | |
4525 (setq indent-str (verilog-calculate-indent)))) | |
4526 (verilog-do-indent indent-str))) | |
4527 | |
4528 (defun verilog-indent-line () | |
4529 "Indent for special part of code." | |
4530 (verilog-do-indent (verilog-calculate-indent))) | |
4531 | |
4532 (defun verilog-do-indent (indent-str) | |
4533 (let ((type (car indent-str)) | |
4534 (ind (car (cdr indent-str)))) | |
4535 (cond | |
4536 (; handle continued exp | |
4537 (eq type 'cexp) | |
4538 (let ((here (point))) | |
4539 (verilog-backward-syntactic-ws) | |
4540 (cond | |
4541 ((or | |
4542 (= (preceding-char) ?\,) | |
4543 (= (preceding-char) ?\]) | |
4544 (save-excursion | |
4545 (verilog-beg-of-statement-1) | |
4546 (looking-at verilog-declaration-re))) | |
4547 (let* ( fst | |
4548 (val | |
4549 (save-excursion | |
4550 (backward-char 1) | |
4551 (verilog-beg-of-statement-1) | |
4552 (setq fst (point)) | |
4553 (if (looking-at verilog-declaration-re) | |
4554 (progn ;; we have multiple words | |
4555 (goto-char (match-end 0)) | |
4556 (skip-chars-forward " \t") | |
4557 (cond | |
4558 ((and verilog-indent-declaration-macros | |
4559 (= (following-char) ?\`)) | |
4560 (progn | |
4561 (forward-char 1) | |
4562 (forward-word 1) | |
4563 (skip-chars-forward " \t"))) | |
4564 ((= (following-char) ?\[) | |
4565 (progn | |
4566 (forward-char 1) | |
4567 (backward-up-list -1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4568 (skip-chars-forward " \t")))) |
79545 | 4569 (current-column)) |
4570 (progn | |
4571 (goto-char fst) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4572 (+ (current-column) verilog-cexp-indent)))))) |
79545 | 4573 (goto-char here) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4574 (indent-line-to val))) |
79545 | 4575 ((= (preceding-char) ?\) ) |
4576 (goto-char here) | |
4577 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4578 (indent-line-to val))) | |
4579 (t | |
4580 (goto-char here) | |
4581 (let ((val)) | |
4582 (verilog-beg-of-statement-1) | |
4583 (if (and (< (point) here) | |
4584 (verilog-re-search-forward "=[ \\t]*" here 'move)) | |
4585 (setq val (current-column)) | |
4586 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | |
4587 (goto-char here) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4588 (indent-line-to val)))))) |
79545 | 4589 |
4590 (; handle inside parenthetical expressions | |
4591 (eq type 'cparenexp) | |
4592 (let ((val (save-excursion | |
4593 (backward-up-list 1) | |
4594 (forward-char 1) | |
4595 (skip-chars-forward " \t") | |
4596 (current-column)))) | |
4597 (indent-line-to val) | |
4598 (if (and (not (verilog-in-struct-region-p)) | |
4599 (looking-at verilog-declaration-re)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4600 (verilog-indent-declaration ind)))) |
79545 | 4601 |
4602 (;-- Handle the ends | |
4603 (or | |
4604 (looking-at verilog-end-block-re ) | |
4605 (verilog-at-close-constraint-p)) | |
4606 (let ((val (if (eq type 'statement) | |
4607 (- ind verilog-indent-level) | |
4608 ind))) | |
4609 (indent-line-to val))) | |
4610 | |
4611 (;-- Case -- maybe line 'em up | |
4612 (and (eq type 'case) (not (looking-at "^[ \t]*$"))) | |
4613 (progn | |
4614 (cond | |
4615 ((looking-at "\\<endcase\\>") | |
4616 (indent-line-to ind)) | |
4617 (t | |
4618 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4619 (indent-line-to val)))))) | |
4620 | |
4621 (;-- defun | |
4622 (and (eq type 'defun) | |
4623 (looking-at verilog-zero-indent-re)) | |
4624 (indent-line-to 0)) | |
4625 | |
4626 (;-- declaration | |
4627 (and (or | |
4628 (eq type 'defun) | |
4629 (eq type 'block)) | |
4630 (looking-at verilog-declaration-re)) | |
4631 (verilog-indent-declaration ind)) | |
4632 | |
4633 (;-- Everything else | |
4634 t | |
4635 (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
|
4636 (indent-line-to val)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4637 |
79545 | 4638 (if (looking-at "[ \t]+$") |
4639 (skip-chars-forward " \t")) | |
4640 indent-str ; Return indent data | |
4641 )) | |
4642 | |
4643 (defun verilog-current-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4644 "Return the indent-level of the current statement." |
79545 | 4645 (save-excursion |
4646 (let (par-pos) | |
4647 (beginning-of-line) | |
4648 (setq par-pos (verilog-parenthesis-depth)) | |
4649 (while par-pos | |
4650 (goto-char par-pos) | |
4651 (beginning-of-line) | |
4652 (setq par-pos (verilog-parenthesis-depth))) | |
4653 (skip-chars-forward " \t") | |
4654 (current-column)))) | |
4655 | |
4656 (defun verilog-case-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4657 "Return the indent-level of the current statement. |
79545 | 4658 Do not count named blocks or case-statements." |
4659 (save-excursion | |
4660 (skip-chars-forward " \t") | |
4661 (cond | |
4662 ((looking-at verilog-named-block-re) | |
4663 (current-column)) | |
4664 ((and (not (looking-at verilog-case-re)) | |
4665 (looking-at "^[^:;]+[ \t]*:")) | |
4666 (verilog-re-search-forward ":" nil t) | |
4667 (skip-chars-forward " \t") | |
4668 (current-column)) | |
4669 (t | |
4670 (current-column))))) | |
4671 | |
4672 (defun verilog-indent-comment () | |
4673 "Indent current line as comment." | |
4674 (let* ((stcol | |
4675 (cond | |
4676 ((verilog-in-star-comment-p) | |
4677 (save-excursion | |
4678 (re-search-backward "/\\*" nil t) | |
4679 (1+(current-column)))) | |
4680 (comment-column | |
4681 comment-column ) | |
4682 (t | |
4683 (save-excursion | |
4684 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4685 (current-column)))))) |
79545 | 4686 (indent-line-to stcol) |
4687 stcol)) | |
4688 | |
4689 (defun verilog-more-comment () | |
4690 "Make more comment lines like the previous." | |
4691 (let* ((star 0) | |
4692 (stcol | |
4693 (cond | |
4694 ((verilog-in-star-comment-p) | |
4695 (save-excursion | |
4696 (setq star 1) | |
4697 (re-search-backward "/\\*" nil t) | |
4698 (1+(current-column)))) | |
4699 (comment-column | |
4700 comment-column ) | |
4701 (t | |
4702 (save-excursion | |
4703 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4704 (current-column)))))) |
79545 | 4705 (progn |
4706 (indent-to stcol) | |
4707 (if (and star | |
4708 (save-excursion | |
4709 (forward-line -1) | |
4710 (skip-chars-forward " \t") | |
4711 (looking-at "\*"))) | |
4712 (insert "* "))))) | |
4713 | |
4714 (defun verilog-comment-indent (&optional arg) | |
4715 "Return the column number the line should be indented to. | |
4716 ARG is ignored, for `comment-indent-function' compatibility." | |
4717 (cond | |
4718 ((verilog-in-star-comment-p) | |
4719 (save-excursion | |
4720 (re-search-backward "/\\*" nil t) | |
4721 (1+(current-column)))) | |
4722 ( comment-column | |
4723 comment-column ) | |
4724 (t | |
4725 (save-excursion | |
4726 (re-search-backward "//" nil t) | |
4727 (current-column))))) | |
4728 | |
4729 ;; | |
4730 | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4731 (defun verilog-pretty-declarations (&optional quiet) |
79545 | 4732 "Line up declarations around point." |
4733 (interactive) | |
4734 (save-excursion | |
4735 (if (progn | |
4736 (verilog-beg-of-statement-1) | |
4737 (looking-at verilog-declaration-re)) | |
4738 (let* ((m1 (make-marker)) | |
4739 (e) (r) | |
4740 (here (point)) | |
4741 ;; Start of declaration range | |
4742 (start | |
4743 (progn | |
4744 (verilog-beg-of-statement-1) | |
4745 (while (looking-at verilog-declaration-re) | |
4746 (beginning-of-line) | |
4747 (setq e (point)) | |
4748 (verilog-backward-syntactic-ws) | |
4749 (backward-char) | |
4750 (verilog-beg-of-statement-1)) ;Ack, need to grok `define | |
4751 e)) | |
4752 ;; End of declaration range | |
4753 (end | |
4754 (progn | |
4755 (goto-char here) | |
4756 (verilog-end-of-statement) | |
4757 (setq e (point)) ;Might be on last line | |
4758 (verilog-forward-syntactic-ws) | |
4759 (while (looking-at verilog-declaration-re) | |
4760 (beginning-of-line) | |
4761 (verilog-end-of-statement) | |
4762 (setq e (point)) | |
4763 (verilog-forward-syntactic-ws)) | |
4764 e)) | |
4765 (edpos (set-marker (make-marker) end)) | |
4766 (ind) | |
4767 (base-ind | |
4768 (progn | |
4769 (goto-char start) | |
4770 (verilog-do-indent (verilog-calculate-indent)) | |
4771 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4772 (current-column)))) |
79545 | 4773 (goto-char end) |
4774 (goto-char start) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4775 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4776 (> (- end start) 100)) |
79545 | 4777 (message "Lining up declarations..(please stand by)")) |
4778 ;; Get the beginning of line indent first | |
4779 (while (progn (setq e (marker-position edpos)) | |
4780 (< (point) e)) | |
4781 (cond | |
4782 ( (save-excursion (skip-chars-backward " \t") | |
4783 (bolp)) | |
4784 (verilog-forward-ws&directives) | |
4785 (indent-line-to base-ind) | |
4786 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4787 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
79545 | 4788 (t |
4789 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4790 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4791 ;;(forward-line) |
79545 | 4792 ) |
4793 ;; Now find biggest prefix | |
4794 (setq ind (verilog-get-lineup-indent start edpos)) | |
4795 ;; Now indent each line. | |
4796 (goto-char start) | |
4797 (while (progn (setq e (marker-position edpos)) | |
4798 (setq r (- e (point))) | |
4799 (> r 0)) | |
4800 (setq e (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4801 (unless quiet (message "%d" r)) |
79545 | 4802 (cond |
4803 ((or (and verilog-indent-declaration-macros | |
4804 (looking-at verilog-declaration-re-1-macro)) | |
4805 (looking-at verilog-declaration-re-1-no-macro)) | |
4806 (let ((p (match-end 0))) | |
4807 (set-marker m1 p) | |
4808 (if (verilog-re-search-forward "[[#`]" p 'move) | |
4809 (progn | |
4810 (forward-char -1) | |
4811 (just-one-space) | |
4812 (goto-char (marker-position m1)) | |
4813 (just-one-space) | |
4814 (indent-to ind)) | |
4815 (progn | |
4816 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4817 (indent-to ind))))) |
79545 | 4818 ((verilog-continued-line-1 start) |
4819 (goto-char e) | |
4820 (indent-line-to ind)) | |
4821 (t ; Must be comment or white space | |
4822 (goto-char e) | |
4823 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4824 (forward-line -1))) |
79545 | 4825 (forward-line 1)) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4826 (unless quiet (message "")))))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4827 |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4828 (defun verilog-pretty-expr (&optional quiet myre) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4829 "Line up expressions around point, or optional regexp MYRE." |
79545 | 4830 (interactive "sRegular Expression: ((<|:)?=) ") |
4831 (save-excursion | |
4832 (if (or (eq myre nil) | |
4833 (string-equal myre "")) | |
4834 (setq myre "\\(<\\|:\\)?=")) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4835 (setq myre (concat "\\(^[^;#:<=>]*\\)\\(" myre "\\)")) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4836 (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
|
4837 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4838 (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
|
4839 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4840 (let* ((here (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4841 (e) (r) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4842 (start |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4843 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4844 (beginning-of-line) |
79545 | 4845 (setq e (point)) |
4846 (verilog-backward-syntactic-ws) | |
4847 (beginning-of-line) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4848 (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
|
4849 (looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4850 (not (bobp)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4851 ) |
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 (verilog-backward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4854 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4855 ) ;Ack, need to grok `define |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4856 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4857 (end |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4858 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4859 (goto-char here) |
79545 | 4860 (end-of-line) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4861 (setq e (point)) ;Might be on last line |
79545 | 4862 (verilog-forward-syntactic-ws) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4863 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4864 (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
|
4865 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4866 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4867 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4868 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4869 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4870 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4871 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4872 (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
|
4873 (ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4874 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4875 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4876 (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
|
4877 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4878 (> (- end start) 100)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4879 (message "Lining up expressions..(please stand by)")) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4880 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4881 ;; 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
|
4882 (while (< (point) (marker-position edpos)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4883 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4884 (verilog-just-one-space myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4885 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4886 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4887 ) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4888 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4889 ;; Now find biggest prefix |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4890 (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
|
4891 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4892 ;; Now indent each line. |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4893 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4894 (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
|
4895 (setq r (- e (point))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4896 (> r 0)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4897 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4898 (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
|
4899 (cond |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4900 ((looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4901 (goto-char (match-end 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4902 (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
|
4903 (if (eq (char-after) ?=) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4904 (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
|
4905 (indent-to ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4906 ))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4907 ((verilog-continued-line-1 start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4908 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4909 (indent-line-to ind)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4910 (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
|
4911 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4912 (verilog-forward-ws&directives) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4913 (forward-line -1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4914 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4915 (forward-line 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4916 (unless quiet (message "")) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4917 ))))) |
79545 | 4918 |
4919 (defun verilog-just-one-space (myre) | |
4920 "Remove extra spaces around regular expression MYRE." | |
4921 (interactive) | |
4922 (if (and (not(looking-at verilog-complete-reg)) | |
4923 (looking-at myre)) | |
4924 (let ((p1 (match-end 1)) | |
4925 (p2 (match-end 2))) | |
4926 (progn | |
4927 (goto-char p2) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4928 (if (looking-at "\\s-") (just-one-space)) |
79545 | 4929 (goto-char p1) |
4930 (forward-char -1) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4931 (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
|
4932 )))) |
79545 | 4933 |
4934 (defun verilog-indent-declaration (baseind) | |
4935 "Indent current lines as declaration. | |
4936 Line up the variable names based on previous declaration's indentation. | |
4937 BASEIND is the base indent to offset everything." | |
4938 (interactive) | |
4939 (let ((pos (point-marker)) | |
4940 (lim (save-excursion | |
4941 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | |
4942 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | |
4943 (point))) | |
4944 (ind) | |
4945 (val) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4946 (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
|
4947 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4948 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 4949 (indent-line-to val) |
4950 | |
4951 ;; Use previous declaration (in this module) as template. | |
4952 (if (or (memq 'all verilog-auto-lineup) | |
4953 (memq 'declaration verilog-auto-lineup)) | |
79546 | 4954 (if (verilog-re-search-backward |
79545 | 4955 (or (and verilog-indent-declaration-macros |
4956 verilog-declaration-re-1-macro) | |
4957 verilog-declaration-re-1-no-macro) lim t) | |
4958 (progn | |
4959 (goto-char (match-end 0)) | |
4960 (skip-chars-forward " \t") | |
4961 (setq ind (current-column)) | |
4962 (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
|
4963 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4964 (+ baseind |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4965 (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 4966 (indent-line-to val) |
4967 (if (and verilog-indent-declaration-macros | |
4968 (looking-at verilog-declaration-re-2-macro)) | |
4969 (let ((p (match-end 0))) | |
4970 (set-marker m1 p) | |
4971 (if (verilog-re-search-forward "[[#`]" p 'move) | |
4972 (progn | |
4973 (forward-char -1) | |
4974 (just-one-space) | |
4975 (goto-char (marker-position m1)) | |
4976 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4977 (indent-to ind)) |
79545 | 4978 (if (/= (current-column) ind) |
4979 (progn | |
4980 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4981 (indent-to ind))))) |
79545 | 4982 (if (looking-at verilog-declaration-re-2-no-macro) |
4983 (let ((p (match-end 0))) | |
4984 (set-marker m1 p) | |
4985 (if (verilog-re-search-forward "[[`#]" p 'move) | |
4986 (progn | |
4987 (forward-char -1) | |
4988 (just-one-space) | |
4989 (goto-char (marker-position m1)) | |
4990 (just-one-space) | |
4991 (indent-to ind)) | |
4992 (if (/= (current-column) ind) | |
4993 (progn | |
4994 (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
|
4995 (indent-to ind)))))))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4996 (goto-char pos))) |
79545 | 4997 |
4998 (defun verilog-get-lineup-indent (b edpos) | |
4999 "Return the indent level that will line up several lines within the region. | |
5000 Region is defined by B and EDPOS." | |
5001 (save-excursion | |
5002 (let ((ind 0) e) | |
5003 (goto-char b) | |
5004 ;; Get rightmost position | |
5005 (while (progn (setq e (marker-position edpos)) | |
5006 (< (point) e)) | |
79546 | 5007 (if (verilog-re-search-forward |
79545 | 5008 (or (and verilog-indent-declaration-macros |
5009 verilog-declaration-re-1-macro) | |
5010 verilog-declaration-re-1-no-macro) e 'move) | |
5011 (progn | |
5012 (goto-char (match-end 0)) | |
5013 (verilog-backward-syntactic-ws) | |
5014 (if (> (current-column) ind) | |
5015 (setq ind (current-column))) | |
5016 (goto-char (match-end 0))))) | |
5017 (if (> ind 0) | |
5018 (1+ ind) | |
5019 ;; No lineup-string found | |
5020 (goto-char b) | |
5021 (end-of-line) | |
5022 (skip-chars-backward " \t") | |
5023 (1+ (current-column)))))) | |
5024 | |
5025 (defun verilog-get-lineup-indent-2 (myre b edpos) | |
5026 "Return the indent level that will line up several lines within the region." | |
5027 (save-excursion | |
5028 (let ((ind 0) e) | |
5029 (goto-char b) | |
5030 ;; Get rightmost position | |
5031 (while (progn (setq e (marker-position edpos)) | |
5032 (< (point) e)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5033 (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
|
5034 (not (verilog-parenthesis-depth))) ;; skip parenthsized exprs |
79545 | 5035 (progn |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5036 (goto-char (match-beginning 2)) |
79545 | 5037 (verilog-backward-syntactic-ws) |
5038 (if (> (current-column) ind) | |
5039 (setq ind (current-column))) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5040 (goto-char (match-end 0))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5041 )) |
79545 | 5042 (if (> ind 0) |
5043 (1+ ind) | |
5044 ;; No lineup-string found | |
5045 (goto-char b) | |
5046 (end-of-line) | |
5047 (skip-chars-backward " \t") | |
5048 (1+ (current-column)))))) | |
5049 | |
5050 (defun verilog-comment-depth (type val) | |
5051 "A useful mode debugging aide. TYPE and VAL are comments for insertion." | |
5052 (save-excursion | |
5053 (let | |
5054 ((b (prog2 | |
5055 (beginning-of-line) | |
5056 (point-marker) | |
5057 (end-of-line))) | |
5058 (e (point-marker))) | |
5059 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t) | |
5060 (progn | |
5061 (replace-match " /* -# ## */") | |
5062 (end-of-line)) | |
5063 (progn | |
5064 (end-of-line) | |
5065 (insert " /* ## ## */")))) | |
5066 (backward-char 6) | |
5067 (insert | |
5068 (format "%s %d" type val)))) | |
5069 | |
5070 ;; | |
5071 ;; | |
5072 ;; Completion | |
5073 ;; | |
5074 (defvar verilog-str nil) | |
5075 (defvar verilog-all nil) | |
5076 (defvar verilog-pred nil) | |
5077 (defvar verilog-buffer-to-use nil) | |
5078 (defvar verilog-flag nil) | |
5079 (defvar verilog-toggle-completions nil | |
5080 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one. | |
5081 Repeated use of \\[verilog-complete-word] will show you all of them. | |
5082 Normally, when there is more than one possible completion, | |
5083 it displays a list of all possible completions.") | |
5084 | |
5085 | |
5086 (defvar verilog-type-keywords | |
5087 '( | |
5088 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input" | |
5089 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0" | |
5090 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
5091 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0" | |
5092 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1" | |
5093 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor" | |
5094 ) | |
5095 "*Keywords for types used when completing a word in a declaration or parmlist. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5096 \(Eg. integer, real, reg...)") |
79545 | 5097 |
5098 (defvar verilog-cpp-keywords | |
5099 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else" | |
5100 "endif") | |
5101 "*Keywords to complete when at first word of a line in declarative scope. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5102 \(Eg. initial, always, begin, assign.) |
79545 | 5103 The procedures and variables defined within the Verilog program |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5104 will be completed at runtime and should not be added to this list.") |
79545 | 5105 |
5106 (defvar verilog-defun-keywords | |
5107 (append | |
5108 '( | |
5109 "always" "always_comb" "always_ff" "always_latch" "assign" | |
5110 "begin" "end" "generate" "endgenerate" "module" "endmodule" | |
5111 "specify" "endspecify" "function" "endfunction" "initial" "final" | |
5112 "task" "endtask" "primitive" "endprimitive" | |
5113 ) | |
5114 verilog-type-keywords) | |
5115 "*Keywords to complete when at first word of a line in declarative scope. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5116 \(Eg. initial, always, begin, assign.) |
79545 | 5117 The procedures and variables defined within the Verilog program |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5118 will be completed at runtime and should not be added to this list.") |
79545 | 5119 |
5120 (defvar verilog-block-keywords | |
5121 '( | |
5122 "begin" "break" "case" "continue" "else" "end" "endfunction" | |
5123 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask" | |
5124 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return" | |
5125 "while") | |
5126 "*Keywords to complete when at first word of a line in behavioral scope. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5127 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5128 The procedures and variables defined within the Verilog program |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5129 will be completed at runtime and should not be added to this list.") |
79545 | 5130 |
5131 (defvar verilog-tf-keywords | |
5132 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat") | |
5133 "*Keywords to complete when at first word of a line in a task or function. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5134 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5135 The procedures and variables defined within the Verilog program |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5136 will be completed at runtime and should not be added to this list.") |
79545 | 5137 |
5138 (defvar verilog-case-keywords | |
5139 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat") | |
5140 "*Keywords to complete when at first word of a line in case scope. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5141 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5142 The procedures and variables defined within the Verilog program |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5143 will be completed at runtime and should not be added to this list.") |
79545 | 5144 |
5145 (defvar verilog-separator-keywords | |
5146 '("else" "then" "begin") | |
5147 "*Keywords to complete when NOT standing at the first word of a statement. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5148 \(Eg. else, then.) |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5149 Variables and function names defined within the Verilog program |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5150 will be completed at runtime and should not be added to this list.") |
79545 | 5151 |
5152 (defun verilog-string-diff (str1 str2) | |
5153 "Return index of first letter where STR1 and STR2 differs." | |
5154 (catch 'done | |
5155 (let ((diff 0)) | |
5156 (while t | |
5157 (if (or (> (1+ diff) (length str1)) | |
5158 (> (1+ diff) (length str2))) | |
5159 (throw 'done diff)) | |
5160 (or (equal (aref str1 diff) (aref str2 diff)) | |
5161 (throw 'done diff)) | |
5162 (setq diff (1+ diff)))))) | |
5163 | |
5164 ;; Calculate all possible completions for functions if argument is `function', | |
5165 ;; completions for procedures if argument is `procedure' or both functions and | |
5166 ;; procedures otherwise. | |
5167 | |
5168 (defun verilog-func-completion (type) | |
5169 "Build regular expression for module/task/function names. | |
5170 TYPE is 'module, 'tf for task or function, or t if unknown." | |
5171 (if (string= verilog-str "") | |
5172 (setq verilog-str "[a-zA-Z_]")) | |
5173 (let ((verilog-str (concat (cond | |
5174 ((eq type 'module) "\\<\\(module\\)\\s +") | |
5175 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") | |
5176 (t "\\<\\(task\\|function\\|module\\)\\s +")) | |
5177 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) | |
5178 match) | |
5179 | |
5180 (if (not (looking-at verilog-defun-re)) | |
5181 (verilog-re-search-backward verilog-defun-re nil t)) | |
5182 (forward-char 1) | |
5183 | |
5184 ;; Search through all reachable functions | |
5185 (goto-char (point-min)) | |
5186 (while (verilog-re-search-forward verilog-str (point-max) t) | |
5187 (progn (setq match (buffer-substring (match-beginning 2) | |
5188 (match-end 2))) | |
5189 (if (or (null verilog-pred) | |
5190 (funcall verilog-pred match)) | |
5191 (setq verilog-all (cons match verilog-all))))) | |
5192 (if (match-beginning 0) | |
5193 (goto-char (match-beginning 0))))) | |
5194 | |
5195 (defun verilog-get-completion-decl (end) | |
5196 "Macro for searching through current declaration (var, type or const) | |
5197 for matches of `str' and adding the occurrence tp `all' through point END." | |
5198 (let ((re (or (and verilog-indent-declaration-macros | |
5199 verilog-declaration-re-2-macro) | |
5200 verilog-declaration-re-2-no-macro)) | |
5201 decl-end match) | |
5202 ;; Traverse lines | |
5203 (while (and (< (point) end) | |
5204 (verilog-re-search-forward re end t)) | |
5205 ;; Traverse current line | |
5206 (setq decl-end (save-excursion (verilog-declaration-end))) | |
5207 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t) | |
5208 (not (match-end 1))) | |
5209 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | |
5210 (if (string-match (concat "\\<" verilog-str) match) | |
5211 (if (or (null verilog-pred) | |
5212 (funcall verilog-pred match)) | |
5213 (setq verilog-all (cons match verilog-all))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5214 (forward-line 1))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5215 verilog-all) |
79545 | 5216 |
5217 (defun verilog-type-completion () | |
5218 "Calculate all possible completions for types." | |
5219 (let ((start (point)) | |
5220 goon) | |
5221 ;; Search for all reachable type declarations | |
5222 (while (or (verilog-beg-of-defun) | |
5223 (setq goon (not goon))) | |
5224 (save-excursion | |
5225 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun) | |
5226 (point)) | |
5227 (forward-char 1))) | |
5228 (verilog-re-search-forward | |
5229 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" | |
5230 start t) | |
5231 (not (match-end 1))) | |
5232 ;; Check current type declaration | |
5233 (verilog-get-completion-decl start)))))) | |
5234 | |
5235 (defun verilog-var-completion () | |
5236 "Calculate all possible completions for variables (or constants)." | |
5237 (let ((start (point))) | |
5238 ;; Search for all reachable var declarations | |
5239 (verilog-beg-of-defun) | |
5240 (save-excursion | |
5241 ;; Check var declarations | |
5242 (verilog-get-completion-decl start)))) | |
5243 | |
5244 (defun verilog-keyword-completion (keyword-list) | |
5245 "Give list of all possible completions of keywords in KEYWORD-LIST." | |
5246 (mapcar '(lambda (s) | |
5247 (if (string-match (concat "\\<" verilog-str) s) | |
5248 (if (or (null verilog-pred) | |
5249 (funcall verilog-pred s)) | |
5250 (setq verilog-all (cons s verilog-all))))) | |
5251 keyword-list)) | |
5252 | |
5253 | |
5254 (defun verilog-completion (verilog-str verilog-pred verilog-flag) | |
5255 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5256 Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it | |
5257 must be a function to be called for every match to check if this should | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5258 really be a match. If VERILOG-FLAG is t, the function returns a list of |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5259 all possible completions. If VERILOG-FLAG is nil it returns a string, |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5260 the longest possible completion, or t if VERILOG-STR is an exact match. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5261 If VERILOG-FLAG is 'lambda, the function returns t if VERILOG-STR is an |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5262 exact match, nil otherwise." |
79545 | 5263 (save-excursion |
5264 (let ((verilog-all nil)) | |
5265 ;; Set buffer to use for searching labels. This should be set | |
5266 ;; within functions which use verilog-completions | |
5267 (set-buffer verilog-buffer-to-use) | |
5268 | |
5269 ;; Determine what should be completed | |
5270 (let ((state (car (verilog-calculate-indent)))) | |
5271 (cond ((eq state 'defun) | |
5272 (save-excursion (verilog-var-completion)) | |
5273 (verilog-func-completion 'module) | |
5274 (verilog-keyword-completion verilog-defun-keywords)) | |
5275 | |
5276 ((eq state 'behavioral) | |
5277 (save-excursion (verilog-var-completion)) | |
5278 (verilog-func-completion 'module) | |
5279 (verilog-keyword-completion verilog-defun-keywords)) | |
5280 | |
5281 ((eq state 'block) | |
5282 (save-excursion (verilog-var-completion)) | |
5283 (verilog-func-completion 'tf) | |
5284 (verilog-keyword-completion verilog-block-keywords)) | |
5285 | |
5286 ((eq state 'case) | |
5287 (save-excursion (verilog-var-completion)) | |
5288 (verilog-func-completion 'tf) | |
5289 (verilog-keyword-completion verilog-case-keywords)) | |
5290 | |
5291 ((eq state 'tf) | |
5292 (save-excursion (verilog-var-completion)) | |
5293 (verilog-func-completion 'tf) | |
5294 (verilog-keyword-completion verilog-tf-keywords)) | |
5295 | |
5296 ((eq state 'cpp) | |
5297 (save-excursion (verilog-var-completion)) | |
5298 (verilog-keyword-completion verilog-cpp-keywords)) | |
5299 | |
5300 ((eq state 'cparenexp) | |
5301 (save-excursion (verilog-var-completion))) | |
5302 | |
5303 (t;--Anywhere else | |
5304 (save-excursion (verilog-var-completion)) | |
5305 (verilog-func-completion 'both) | |
5306 (verilog-keyword-completion verilog-separator-keywords)))) | |
5307 | |
5308 ;; Now we have built a list of all matches. Give response to caller | |
5309 (verilog-completion-response)))) | |
5310 | |
5311 (defun verilog-completion-response () | |
5312 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag)) | |
5313 ;; This was not called by all-completions | |
5314 (if (null verilog-all) | |
5315 ;; Return nil if there was no matching label | |
5316 nil | |
5317 ;; Get longest string common in the labels | |
5318 (let* ((elm (cdr verilog-all)) | |
5319 (match (car verilog-all)) | |
5320 (min (length match)) | |
5321 tmp) | |
5322 (if (string= match verilog-str) | |
5323 ;; Return t if first match was an exact match | |
5324 (setq match t) | |
5325 (while (not (null elm)) | |
5326 ;; Find longest common string | |
5327 (if (< (setq tmp (verilog-string-diff match (car elm))) min) | |
5328 (progn | |
5329 (setq min tmp) | |
5330 (setq match (substring match 0 min)))) | |
5331 ;; Terminate with match=t if this is an exact match | |
5332 (if (string= (car elm) verilog-str) | |
5333 (progn | |
5334 (setq match t) | |
5335 (setq elm nil)) | |
5336 (setq elm (cdr elm))))) | |
5337 ;; If this is a test just for exact match, return nil ot t | |
5338 (if (and (equal verilog-flag 'lambda) (not (equal match 't))) | |
5339 nil | |
5340 match)))) | |
5341 ;; If flag is t, this was called by all-completions. Return | |
5342 ;; list of all possible completions | |
5343 (verilog-flag | |
5344 verilog-all))) | |
5345 | |
5346 (defvar verilog-last-word-numb 0) | |
5347 (defvar verilog-last-word-shown nil) | |
5348 (defvar verilog-last-completions nil) | |
5349 | |
5350 (defun verilog-complete-word () | |
5351 "Complete word at current point. | |
5352 \(See also `verilog-toggle-completions', `verilog-type-keywords', | |
5353 and `verilog-separator-keywords'.)" | |
5354 (interactive) | |
5355 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5356 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5357 (verilog-str (buffer-substring b e)) | |
5358 ;; The following variable is used in verilog-completion | |
5359 (verilog-buffer-to-use (current-buffer)) | |
5360 (allcomp (if (and verilog-toggle-completions | |
5361 (string= verilog-last-word-shown verilog-str)) | |
5362 verilog-last-completions | |
5363 (all-completions verilog-str 'verilog-completion))) | |
5364 (match (if verilog-toggle-completions | |
5365 "" (try-completion | |
5366 verilog-str (mapcar '(lambda (elm) | |
5367 (cons elm 0)) allcomp))))) | |
5368 ;; Delete old string | |
5369 (delete-region b e) | |
5370 | |
5371 ;; Toggle-completions inserts whole labels | |
5372 (if verilog-toggle-completions | |
5373 (progn | |
5374 ;; Update entry number in list | |
5375 (setq verilog-last-completions allcomp | |
5376 verilog-last-word-numb | |
5377 (if (>= verilog-last-word-numb (1- (length allcomp))) | |
5378 0 | |
5379 (1+ verilog-last-word-numb))) | |
5380 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb)) | |
5381 ;; Display next match or same string if no match was found | |
5382 (if (not (null allcomp)) | |
5383 (insert "" verilog-last-word-shown) | |
5384 (insert "" verilog-str) | |
5385 (message "(No match)"))) | |
5386 ;; The other form of completion does not necessarily do that. | |
5387 | |
5388 ;; Insert match if found, or the original string if no match | |
5389 (if (or (null match) (equal match 't)) | |
5390 (progn (insert "" verilog-str) | |
5391 (message "(No match)")) | |
5392 (insert "" match)) | |
5393 ;; Give message about current status of completion | |
5394 (cond ((equal match 't) | |
5395 (if (not (null (cdr allcomp))) | |
5396 (message "(Complete but not unique)") | |
5397 (message "(Sole completion)"))) | |
5398 ;; Display buffer if the current completion didn't help | |
5399 ;; on completing the label. | |
5400 ((and (not (null (cdr allcomp))) (= (length verilog-str) | |
5401 (length match))) | |
5402 (with-output-to-temp-buffer "*Completions*" | |
5403 (display-completion-list allcomp)) | |
5404 ;; Wait for a key press. Then delete *Completion* window | |
5405 (momentary-string-display "" (point)) | |
5406 (delete-window (get-buffer-window (get-buffer "*Completions*"))) | |
5407 ))))) | |
5408 | |
5409 (defun verilog-show-completions () | |
5410 "Show all possible completions at current point." | |
5411 (interactive) | |
5412 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5413 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5414 (verilog-str (buffer-substring b e)) | |
5415 ;; The following variable is used in verilog-completion | |
5416 (verilog-buffer-to-use (current-buffer)) | |
5417 (allcomp (if (and verilog-toggle-completions | |
5418 (string= verilog-last-word-shown verilog-str)) | |
5419 verilog-last-completions | |
5420 (all-completions verilog-str 'verilog-completion)))) | |
5421 ;; Show possible completions in a temporary buffer. | |
5422 (with-output-to-temp-buffer "*Completions*" | |
5423 (display-completion-list allcomp)) | |
5424 ;; Wait for a key press. Then delete *Completion* window | |
5425 (momentary-string-display "" (point)) | |
5426 (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | |
5427 | |
5428 | |
5429 (defun verilog-get-default-symbol () | |
5430 "Return symbol around current point as a string." | |
5431 (save-excursion | |
5432 (buffer-substring (progn | |
5433 (skip-chars-backward " \t") | |
5434 (skip-chars-backward "a-zA-Z0-9_") | |
5435 (point)) | |
5436 (progn | |
5437 (skip-chars-forward "a-zA-Z0-9_") | |
5438 (point))))) | |
5439 | |
5440 (defun verilog-build-defun-re (str &optional arg) | |
5441 "Return function/task/module starting with STR as regular expression. | |
5442 With optional second ARG non-nil, STR is the complete name of the instruction." | |
5443 (if arg | |
5444 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>") | |
5445 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>"))) | |
5446 | |
5447 (defun verilog-comp-defun (verilog-str verilog-pred verilog-flag) | |
5448 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5449 Returns a completion on any function name based on VERILOG-STR prefix. If | |
5450 VERILOG-PRED is non-nil, it must be a function to be called for every match | |
5451 to check if this should really be a match. If VERILOG-FLAG is t, the | |
5452 function returns a list of all possible completions. If it is nil it | |
5453 returns a string, the longest possible completion, or t if VERILOG-STR is | |
5454 an exact match. If VERILOG-FLAG is 'lambda, the function returns t if | |
5455 VERILOG-STR is an exact match, nil otherwise." | |
5456 (save-excursion | |
5457 (let ((verilog-all nil) | |
5458 match) | |
5459 | |
5460 ;; Set buffer to use for searching labels. This should be set | |
5461 ;; within functions which use verilog-completions | |
5462 (set-buffer verilog-buffer-to-use) | |
5463 | |
5464 (let ((verilog-str verilog-str)) | |
5465 ;; Build regular expression for functions | |
5466 (if (string= verilog-str "") | |
5467 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]")) | |
5468 (setq verilog-str (verilog-build-defun-re verilog-str))) | |
5469 (goto-char (point-min)) | |
5470 | |
5471 ;; Build a list of all possible completions | |
5472 (while (verilog-re-search-forward verilog-str nil t) | |
5473 (setq match (buffer-substring (match-beginning 2) (match-end 2))) | |
5474 (if (or (null verilog-pred) | |
5475 (funcall verilog-pred match)) | |
5476 (setq verilog-all (cons match verilog-all))))) | |
5477 | |
5478 ;; Now we have built a list of all matches. Give response to caller | |
5479 (verilog-completion-response)))) | |
5480 | |
5481 (defun verilog-goto-defun () | |
5482 "Move to specified Verilog module/task/function. | |
5483 The default is a name found in the buffer around point. | |
5484 If search fails, other files are checked based on | |
5485 `verilog-library-flags'." | |
5486 (interactive) | |
5487 (let* ((default (verilog-get-default-symbol)) | |
5488 ;; The following variable is used in verilog-comp-function | |
5489 (verilog-buffer-to-use (current-buffer)) | |
5490 (label (if (not (string= default "")) | |
5491 ;; Do completion with default | |
5492 (completing-read (concat "Label: (default " default ") ") | |
5493 'verilog-comp-defun nil nil "") | |
5494 ;; There is no default value. Complete without it | |
5495 (completing-read "Label: " | |
5496 'verilog-comp-defun nil nil ""))) | |
5497 pt) | |
5498 ;; If there was no response on prompt, use default value | |
5499 (if (string= label "") | |
5500 (setq label default)) | |
5501 ;; Goto right place in buffer if label is not an empty string | |
5502 (or (string= label "") | |
5503 (progn | |
5504 (save-excursion | |
5505 (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
|
5506 (setq pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5507 (re-search-forward (verilog-build-defun-re label t) nil t))) |
79545 | 5508 (when pt |
5509 (goto-char pt) | |
5510 (beginning-of-line)) | |
5511 pt) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5512 (verilog-goto-defun-file label)))) |
79545 | 5513 |
5514 ;; Eliminate compile warning | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
5515 (defvar occur-pos-list) |
79545 | 5516 |
5517 (defun verilog-showscopes () | |
5518 "List all scopes in this module." | |
5519 (interactive) | |
5520 (let ((buffer (current-buffer)) | |
5521 (linenum 1) | |
5522 (nlines 0) | |
5523 (first 1) | |
5524 (prevpos (point-min)) | |
5525 (final-context-start (make-marker)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5526 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
79545 | 5527 (with-output-to-temp-buffer "*Occur*" |
5528 (save-excursion | |
5529 (message (format "Searching for %s ..." regexp)) | |
5530 ;; Find next match, but give up if prev match was at end of buffer. | |
5531 (while (and (not (= prevpos (point-max))) | |
5532 (verilog-re-search-forward regexp nil t)) | |
5533 (goto-char (match-beginning 0)) | |
5534 (beginning-of-line) | |
5535 (save-match-data | |
5536 (setq linenum (+ linenum (count-lines prevpos (point))))) | |
5537 (setq prevpos (point)) | |
5538 (goto-char (match-end 0)) | |
5539 (let* ((start (save-excursion | |
5540 (goto-char (match-beginning 0)) | |
5541 (forward-line (if (< nlines 0) nlines (- nlines))) | |
5542 (point))) | |
5543 (end (save-excursion | |
5544 (goto-char (match-end 0)) | |
5545 (if (> nlines 0) | |
5546 (forward-line (1+ nlines)) | |
5547 (forward-line 1)) | |
5548 (point))) | |
5549 (tag (format "%3d" linenum)) | |
5550 (empty (make-string (length tag) ?\ )) | |
5551 tem) | |
5552 (save-excursion | |
5553 (setq tem (make-marker)) | |
5554 (set-marker tem (point)) | |
5555 (set-buffer standard-output) | |
5556 (setq occur-pos-list (cons tem occur-pos-list)) | |
5557 (or first (zerop nlines) | |
5558 (insert "--------\n")) | |
5559 (setq first nil) | |
5560 (insert-buffer-substring buffer start end) | |
5561 (backward-char (- end start)) | |
5562 (setq tem (if (< nlines 0) (- nlines) nlines)) | |
5563 (while (> tem 0) | |
5564 (insert empty ?:) | |
5565 (forward-line 1) | |
5566 (setq tem (1- tem))) | |
5567 (let ((this-linenum linenum)) | |
5568 (set-marker final-context-start | |
5569 (+ (point) (- (match-end 0) (match-beginning 0)))) | |
5570 (while (< (point) final-context-start) | |
5571 (if (null tag) | |
5572 (setq tag (format "%3d" this-linenum))) | |
5573 (insert tag ?:))))))) | |
5574 (set-buffer-modified-p nil)))) | |
5575 | |
5576 | |
5577 ;; Highlight helper functions | |
5578 (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") | |
5579 (defun verilog-within-translate-off () | |
5580 "Return point if within translate-off region, else nil." | |
5581 (and (save-excursion | |
5582 (re-search-backward | |
5583 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>") | |
5584 nil t)) | |
5585 (equal "off" (match-string 2)) | |
5586 (point))) | |
5587 | |
5588 (defun verilog-start-translate-off (limit) | |
5589 "Return point before translate-off directive if before LIMIT, else nil." | |
5590 (when (re-search-forward | |
5591 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5592 limit t) | |
5593 (match-beginning 0))) | |
5594 | |
5595 (defun verilog-back-to-start-translate-off (limit) | |
5596 "Return point before translate-off directive if before LIMIT, else nil." | |
5597 (when (re-search-backward | |
5598 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5599 limit t) | |
5600 (match-beginning 0))) | |
5601 | |
5602 (defun verilog-end-translate-off (limit) | |
5603 "Return point after translate-on directive if before LIMIT, else nil." | |
5604 | |
5605 (re-search-forward (concat | |
5606 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t)) | |
5607 | |
5608 (defun verilog-match-translate-off (limit) | |
5609 "Match a translate-off block, setting `match-data' and returning t, else nil. | |
5610 Bound search by LIMIT." | |
5611 (when (< (point) limit) | |
5612 (let ((start (or (verilog-within-translate-off) | |
5613 (verilog-start-translate-off limit))) | |
5614 (case-fold-search t)) | |
5615 (when start | |
5616 (let ((end (or (verilog-end-translate-off limit) limit))) | |
5617 (set-match-data (list start end)) | |
5618 (goto-char end)))))) | |
5619 | |
5620 (defun verilog-font-lock-match-item (limit) | |
5621 "Match, and move over, any declaration item after point. | |
5622 Bound search by LIMIT. Adapted from | |
5623 `font-lock-match-c-style-declaration-item-and-skip-to-next'." | |
5624 (condition-case nil | |
5625 (save-restriction | |
5626 (narrow-to-region (point-min) limit) | |
5627 ;; match item | |
5628 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)") | |
5629 (save-match-data | |
5630 (goto-char (match-end 1)) | |
5631 ;; move to next item | |
5632 (if (looking-at "\\(\\s-*,\\)") | |
5633 (goto-char (match-end 1)) | |
5634 (end-of-line) t)))) | |
5635 (error nil))) | |
5636 | |
5637 | |
5638 ;; Added by Subbu Meiyappan for Header | |
5639 | |
5640 (defun verilog-header () | |
5641 "Insert a standard Verilog file header." | |
5642 (interactive) | |
5643 (let ((start (point))) | |
5644 (insert "\ | |
5645 //----------------------------------------------------------------------------- | |
5646 // Title : <title> | |
5647 // Project : <project> | |
5648 //----------------------------------------------------------------------------- | |
5649 // File : <filename> | |
5650 // Author : <author> | |
5651 // Created : <credate> | |
5652 // Last modified : <moddate> | |
5653 //----------------------------------------------------------------------------- | |
5654 // Description : | |
5655 // <description> | |
5656 //----------------------------------------------------------------------------- | |
5657 // Copyright (c) <copydate> by <company> This model is the confidential and | |
5658 // proprietary property of <company> and the possession or use of this | |
5659 // file requires a written license from <company>. | |
5660 //------------------------------------------------------------------------------ | |
5661 // Modification history : | |
5662 // <modhist> | |
5663 //----------------------------------------------------------------------------- | |
5664 | |
5665 ") | |
5666 (goto-char start) | |
5667 (search-forward "<filename>") | |
5668 (replace-match (buffer-name) t t) | |
5669 (search-forward "<author>") (replace-match "" t t) | |
5670 (insert (user-full-name)) | |
5671 (insert " <" (user-login-name) "@" (system-name) ">") | |
5672 (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
|
5673 (verilog-insert-date) |
79545 | 5674 (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
|
5675 (verilog-insert-date) |
79545 | 5676 (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
|
5677 (verilog-insert-year) |
79545 | 5678 (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
|
5679 (verilog-insert-date) |
79545 | 5680 (insert " : created") |
5681 (goto-char start) | |
5682 (let (string) | |
5683 (setq string (read-string "title: ")) | |
5684 (search-forward "<title>") | |
5685 (replace-match string t t) | |
5686 (setq string (read-string "project: " verilog-project)) | |
5687 (setq verilog-project string) | |
5688 (search-forward "<project>") | |
5689 (replace-match string t t) | |
5690 (setq string (read-string "Company: " verilog-company)) | |
5691 (setq verilog-company string) | |
5692 (search-forward "<company>") | |
5693 (replace-match string t t) | |
5694 (search-forward "<company>") | |
5695 (replace-match string t t) | |
5696 (search-forward "<company>") | |
5697 (replace-match string t t) | |
5698 (search-backward "<description>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5699 (replace-match "" t t)))) |
79545 | 5700 |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5701 ;; 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
|
5702 |
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5703 (defun verilog-insert-date () |
79545 | 5704 "Insert date from the system." |
5705 (interactive) | |
5706 (let ((timpos)) | |
5707 (setq timpos (point)) | |
5708 (if verilog-date-scientific-format | |
5709 (shell-command "date \"+@%Y/%m/%d\"" t) | |
5710 (shell-command "date \"+@%d.%m.%Y\"" t)) | |
5711 (search-forward "@") | |
5712 (delete-region timpos (point)) | |
5713 (end-of-line)) | |
5714 (delete-char 1)) | |
5715 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5716 (defun verilog-insert-year () |
79545 | 5717 "Insert year from the system." |
5718 (interactive) | |
5719 (let ((timpos)) | |
5720 (setq timpos (point)) | |
5721 (shell-command "date \"+@%Y\"" t) | |
5722 (search-forward "@") | |
5723 (delete-region timpos (point)) | |
5724 (end-of-line)) | |
5725 (delete-char 1)) | |
5726 | |
5727 | |
5728 ;; | |
5729 ;; Signal list parsing | |
5730 ;; | |
5731 | |
5732 ;; Elements of a signal list | |
5733 (defsubst verilog-sig-name (sig) | |
5734 (car sig)) | |
5735 (defsubst verilog-sig-bits (sig) | |
5736 (nth 1 sig)) | |
5737 (defsubst verilog-sig-comment (sig) | |
5738 (nth 2 sig)) | |
5739 (defsubst verilog-sig-memory (sig) | |
5740 (nth 3 sig)) | |
5741 (defsubst verilog-sig-enum (sig) | |
5742 (nth 4 sig)) | |
5743 (defsubst verilog-sig-signed (sig) | |
5744 (nth 5 sig)) | |
5745 (defsubst verilog-sig-type (sig) | |
5746 (nth 6 sig)) | |
5747 (defsubst verilog-sig-multidim (sig) | |
5748 (nth 7 sig)) | |
5749 (defsubst verilog-sig-multidim-string (sig) | |
5750 (if (verilog-sig-multidim sig) | |
5751 (let ((str "") (args (verilog-sig-multidim sig))) | |
5752 (while args | |
5753 (setq str (concat str (car args))) | |
5754 (setq args (cdr args))) | |
5755 str))) | |
5756 (defsubst verilog-sig-width (sig) | |
5757 (verilog-make-width-expression (verilog-sig-bits sig))) | |
5758 | |
5759 (defsubst verilog-alw-get-inputs (sigs) | |
5760 (nth 2 sigs)) | |
5761 (defsubst verilog-alw-get-outputs (sigs) | |
5762 (nth 0 sigs)) | |
5763 (defsubst verilog-alw-get-uses-delayed (sigs) | |
5764 (nth 3 sigs)) | |
5765 | |
5766 (defun verilog-signals-not-in (in-list not-list) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5767 "Return list of signals in IN-LIST that aren't also in NOT-LIST. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5768 Also remove any duplicates in IN-LIST. |
79545 | 5769 Signals must be in standard (base vector) form." |
5770 (let (out-list) | |
5771 (while in-list | |
5772 (if (not (or (assoc (car (car in-list)) not-list) | |
5773 (assoc (car (car in-list)) out-list))) | |
5774 (setq out-list (cons (car in-list) out-list))) | |
5775 (setq in-list (cdr in-list))) | |
5776 (nreverse out-list))) | |
5777 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5778 | |
5779 (defun verilog-signals-in (in-list other-list) | |
5780 "Return list of signals in IN-LIST that are also in OTHER-LIST. | |
5781 Signals must be in standard (base vector) form." | |
5782 (let (out-list) | |
5783 (while in-list | |
5784 (if (assoc (car (car in-list)) other-list) | |
5785 (setq out-list (cons (car in-list) out-list))) | |
5786 (setq in-list (cdr in-list))) | |
5787 (nreverse out-list))) | |
5788 ;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5789 | |
5790 (defun verilog-signals-memory (in-list) | |
5791 "Return list of signals in IN-LIST that are memoried (multidimensional)." | |
5792 (let (out-list) | |
5793 (while in-list | |
5794 (if (nth 3 (car in-list)) | |
5795 (setq out-list (cons (car in-list) out-list))) | |
5796 (setq in-list (cdr in-list))) | |
5797 out-list)) | |
5798 ;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil))) | |
5799 | |
5800 (defun verilog-signals-sort-compare (a b) | |
5801 "Compare signal A and B for sorting." | |
5802 (string< (car a) (car b))) | |
5803 | |
5804 (defun verilog-signals-not-params (in-list) | |
5805 "Return list of signals in IN-LIST that aren't parameters or numeric constants." | |
5806 (let (out-list) | |
5807 (while in-list | |
5808 (unless (boundp (intern (concat "vh-" (car (car in-list))))) | |
5809 (setq out-list (cons (car in-list) out-list))) | |
5810 (setq in-list (cdr in-list))) | |
5811 (nreverse out-list))) | |
5812 | |
5813 (defun verilog-signals-combine-bus (in-list) | |
5814 "Return a list of signals in IN-LIST, with busses combined. | |
5815 Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | |
5816 (let (combo buswarn | |
5817 out-list | |
5818 sig highbit lowbit ; Temp information about current signal | |
5819 sv-name sv-highbit sv-lowbit ; Details about signal we are forming | |
5820 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring | |
5821 bus) | |
5822 ;; Shove signals so duplicated signals will be adjacent | |
5823 (setq in-list (sort in-list `verilog-signals-sort-compare)) | |
5824 (while in-list | |
5825 (setq sig (car in-list)) | |
5826 ;; No current signal; form from existing details | |
5827 (unless sv-name | |
5828 (setq sv-name (verilog-sig-name sig) | |
5829 sv-highbit nil | |
5830 sv-busstring nil | |
5831 sv-comment (verilog-sig-comment sig) | |
5832 sv-memory (verilog-sig-memory sig) | |
5833 sv-enum (verilog-sig-enum sig) | |
5834 sv-signed (verilog-sig-signed sig) | |
5835 sv-type (verilog-sig-type sig) | |
5836 sv-multidim (verilog-sig-multidim sig) | |
5837 combo "" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5838 buswarn "")) |
79545 | 5839 ;; Extract bus details |
5840 (setq bus (verilog-sig-bits sig)) | |
5841 (cond ((and bus | |
5842 (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
|
5843 (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
|
5844 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
|
5845 (match-string 2 bus)))) |
79545 | 5846 (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
|
5847 (setq highbit (string-to-number (match-string 1 bus)) |
79545 | 5848 lowbit highbit)))) |
5849 ;; Combine bits in bus | |
5850 (if sv-highbit | |
5851 (setq sv-highbit (max highbit sv-highbit) | |
5852 sv-lowbit (min lowbit sv-lowbit)) | |
5853 (setq sv-highbit highbit | |
5854 sv-lowbit lowbit))) | |
5855 (bus | |
5856 ;; String, probably something like `preproc:0 | |
5857 (setq sv-busstring bus))) | |
5858 ;; Peek ahead to next signal | |
5859 (setq in-list (cdr in-list)) | |
5860 (setq sig (car in-list)) | |
5861 (cond ((and sig (equal sv-name (verilog-sig-name sig))) | |
5862 ;; 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
|
5863 (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
|
5864 (not (equal sv-busstring (verilog-sig-bits sig)))) |
79545 | 5865 (when nil ;; Debugging |
5866 (message (concat "Warning, can't merge into single bus " | |
5867 sv-name bus | |
5868 ", the AUTOs may be wrong"))) | |
5869 (setq buswarn ", Couldn't Merge")) | |
5870 (if (verilog-sig-comment sig) (setq combo ", ...")) | |
5871 (setq sv-memory (or sv-memory (verilog-sig-memory sig)) | |
5872 sv-enum (or sv-enum (verilog-sig-enum sig)) | |
5873 sv-signed (or sv-signed (verilog-sig-signed sig)) | |
5874 sv-type (or sv-type (verilog-sig-type sig)) | |
5875 sv-multidim (or sv-multidim (verilog-sig-multidim sig)))) | |
5876 ;; Doesn't match next signal, add to queue, zero in prep for next | |
5877 ;; Note sig may also be nil for the last signal in the list | |
5878 (t | |
5879 (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
|
5880 (cons |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5881 (list sv-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5882 (or sv-busstring |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5883 (if sv-highbit |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5884 (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
|
5885 (int-to-string sv-lowbit) "]"))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5886 (concat sv-comment combo buswarn) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5887 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
|
5888 out-list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5889 sv-name nil)))) |
79545 | 5890 ;; |
5891 out-list)) | |
5892 | |
5893 (defun verilog-sig-tieoff (sig &optional no-width) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5894 "Return tieoff expression for given SIG, with appropriate width. |
79545 | 5895 Ignore width if optional NO-WIDTH is set." |
5896 (let* ((width (if no-width nil (verilog-sig-width sig)))) | |
5897 (concat | |
5898 (if (and verilog-active-low-regexp | |
5899 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | |
5900 "~" "") | |
5901 (cond ((not width) | |
5902 "0") | |
5903 ((string-match "^[0-9]+$" width) | |
5904 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0"))) | |
5905 (t | |
5906 (concat "{" width "{1'b0}}")))))) | |
5907 | |
5908 ;; | |
5909 ;; Port/Wire/Etc Reading | |
5910 ;; | |
5911 | |
5912 (defun verilog-read-inst-backward-name () | |
5913 "Internal. Move point back to beginning of inst-name." | |
5914 (verilog-backward-open-paren) | |
5915 (let (done) | |
5916 (while (not done) | |
5917 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary | |
5918 (cond ((looking-at ")") | |
5919 (verilog-backward-open-paren)) | |
5920 (t (setq done t))))) | |
5921 (while (looking-at "\\]") | |
5922 (verilog-backward-open-bracket) | |
5923 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) | |
5924 (skip-chars-backward "a-zA-Z0-9`_$")) | |
5925 | |
5926 (defun verilog-read-inst-module () | |
5927 "Return module_name when point is inside instantiation." | |
5928 (save-excursion | |
5929 (verilog-read-inst-backward-name) | |
5930 ;; Skip over instantiation name | |
5931 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary | |
5932 ;; Check for parameterized instantiations | |
5933 (when (looking-at ")") | |
5934 (verilog-backward-open-paren) | |
5935 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)) | |
5936 (skip-chars-backward "a-zA-Z0-9'_$") | |
5937 (looking-at "[a-zA-Z0-9`_\$]+") | |
5938 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5939 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5940 | |
5941 (defun verilog-read-inst-name () | |
5942 "Return instance_name when point is inside instantiation." | |
5943 (save-excursion | |
5944 (verilog-read-inst-backward-name) | |
5945 (looking-at "[a-zA-Z0-9`_\$]+") | |
5946 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5947 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5948 | |
5949 (defun verilog-read-module-name () | |
5950 "Return module name when after its ( or ;." | |
5951 (save-excursion | |
5952 (re-search-backward "[(;]") | |
5953 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) | |
5954 (skip-chars-backward "a-zA-Z0-9`_$") | |
5955 (looking-at "[a-zA-Z0-9`_\$]+") | |
5956 ;; Important: don't use match string, this must work with emacs 19 font-lock on | |
5957 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) | |
5958 | |
5959 (defun verilog-read-auto-params (num-param &optional max-param) | |
5960 "Return parameter list inside auto. | |
5961 Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters." | |
5962 (let ((olist)) | |
5963 (save-excursion | |
5964 ;; /*AUTOPUNT("parameter", "parameter")*/ | |
5965 (search-backward "(") | |
5966 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?") | |
5967 (setq olist (cons (match-string 1) olist)) | |
5968 (goto-char (match-end 0)))) | |
5969 (or (eq nil num-param) | |
5970 (<= num-param (length olist)) | |
5971 (error "%s: Expected %d parameters" (verilog-point-text) num-param)) | |
5972 (if (eq max-param nil) (setq max-param num-param)) | |
5973 (or (eq nil max-param) | |
5974 (>= max-param (length olist)) | |
5975 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param)) | |
5976 (nreverse olist))) | |
5977 | |
5978 (defun verilog-read-decls () | |
5979 "Compute signal declaration information for the current module at point. | |
5980 Return a array of [outputs inouts inputs wire reg assign const]." | |
5981 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) | |
5982 (functask 0) (paren 0) (sig-paren 0) | |
5983 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const sigs-gparam | |
5984 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim) | |
5985 (save-excursion | |
5986 (verilog-beg-of-defun) | |
5987 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) | |
5988 (while (< (point) end-mod-point) | |
5989 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg))) | |
5990 (cond | |
5991 ((looking-at "//") | |
5992 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
5993 (setq enum (match-string 1))) | |
5994 (search-forward "\n")) | |
5995 ((looking-at "/\\*") | |
5996 (forward-char 2) | |
5997 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
5998 (setq enum (match-string 1))) | |
5999 (or (search-forward "*/") | |
6000 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6001 ((looking-at "(\\*") | |
6002 (forward-char 2) | |
6003 (or (looking-at "\\s-*)") ; It's a "always @ (*)" | |
6004 (search-forward "*)") | |
6005 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6006 ((eq ?\" (following-char)) | |
6007 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first | |
6008 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6009 ((eq ?\; (following-char)) | |
6010 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil) | |
6011 (forward-char 1)) | |
6012 ((eq ?= (following-char)) | |
6013 (setq rvalue t newsig nil) | |
6014 (forward-char 1)) | |
6015 ((and (or rvalue sig-paren) | |
6016 (cond ((and (eq ?, (following-char)) | |
6017 (eq paren sig-paren)) | |
6018 (setq rvalue nil) | |
6019 (forward-char 1) | |
6020 t) | |
6021 ;; ,'s can occur inside {} & funcs | |
6022 ((looking-at "[{(]") | |
6023 (setq paren (1+ paren)) | |
6024 (forward-char 1) | |
6025 t) | |
6026 ((looking-at "[})]") | |
6027 (setq paren (1- paren)) | |
6028 (forward-char 1) | |
6029 (when (< paren sig-paren) | |
6030 (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
|
6031 t)))) |
79545 | 6032 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
6033 (goto-char (match-end 0)) | |
6034 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | |
6035 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | |
6036 (vec ;; Multidimensional | |
6037 (setq multidim (cons vec multidim)) | |
6038 (setq vec (verilog-string-replace-matches | |
6039 "\\s-+" "" nil nil (match-string 1)))) | |
6040 (t ;; Bit width | |
6041 (setq vec (verilog-string-replace-matches | |
6042 "\\s-+" "" nil nil (match-string 1)))))) | |
6043 ;; Normal or escaped identifier -- note we remember the \ if escaped | |
6044 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | |
6045 (goto-char (match-end 0)) | |
6046 (setq keywd (match-string 1)) | |
6047 (when (string-match "^\\\\" keywd) | |
6048 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end | |
6049 (cond ((equal keywd "input") | |
6050 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6051 expect-signal 'sigs-in io t)) | |
6052 ((equal keywd "output") | |
6053 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6054 expect-signal 'sigs-out io t)) | |
6055 ((equal keywd "inout") | |
6056 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6057 expect-signal 'sigs-inout io t)) | |
6058 ((or (equal keywd "wire") | |
6059 (equal keywd "tri") | |
6060 (equal keywd "tri0") | |
6061 (equal keywd "tri1")) | |
6062 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6063 expect-signal 'sigs-wire))) | |
6064 ((or (equal keywd "reg") | |
6065 (equal keywd "trireg")) | |
6066 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6067 expect-signal 'sigs-reg))) | |
6068 ((equal keywd "assign") | |
6069 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6070 expect-signal 'sigs-assign)) | |
6071 ((or (equal keywd "supply0") | |
6072 (equal keywd "supply1") | |
6073 (equal keywd "supply") | |
6074 (equal keywd "localparam")) | |
6075 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6076 expect-signal 'sigs-const))) | |
6077 ((or (equal keywd "parameter")) | |
6078 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6079 expect-signal 'sigs-gparam))) | |
6080 ((equal keywd "signed") | |
6081 (setq signed "signed")) | |
6082 ((or (equal keywd "function") | |
6083 (equal keywd "task")) | |
6084 (setq functask (1+ functask))) | |
6085 ((or (equal keywd "endfunction") | |
6086 (equal keywd "endtask")) | |
6087 (setq functask (1- functask))) | |
6088 ((or (equal keywd "`ifdef") | |
6089 (equal keywd "`ifndef")) | |
6090 (setq rvalue t)) | |
6091 ((verilog-typedef-name-p keywd) | |
6092 (setq typedefed keywd)) | |
6093 ((and expect-signal | |
6094 (eq functask 0) | |
6095 (not rvalue) | |
6096 (eq paren sig-paren) | |
6097 (not (member keywd verilog-keywords))) | |
6098 ;; Add new signal to expect-signal's variable | |
6099 (setq newsig (list keywd vec nil nil enum signed typedefed multidim)) | |
6100 (set expect-signal (cons newsig | |
6101 (symbol-value expect-signal)))))) | |
6102 (t | |
6103 (forward-char 1))) | |
6104 (skip-syntax-forward " ")) | |
6105 ;; Return arguments | |
6106 (vector (nreverse sigs-out) | |
6107 (nreverse sigs-inout) | |
6108 (nreverse sigs-in) | |
6109 (nreverse sigs-wire) | |
6110 (nreverse sigs-reg) | |
6111 (nreverse sigs-assign) | |
6112 (nreverse sigs-const) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6113 (nreverse sigs-gparam))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6114 |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6115 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6116 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6117 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6118 ;; - 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
|
6119 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6120 (defvar sigs-inout) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6121 (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
|
6122 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6123 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6124 (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
|
6125 (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
|
6126 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6127 (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
|
6128 (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
|
6129 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6130 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6131 ;; 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
|
6132 ;; 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
|
6133 ;; 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
|
6134 (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
|
6135 (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
|
6136 (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
|
6137 (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
|
6138 (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
|
6139 (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
|
6140 (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
|
6141 (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
|
6142 (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
|
6143 (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
|
6144 (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
|
6145 (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
|
6146 (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
|
6147 (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
|
6148 (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
|
6149 (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
|
6150 (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
|
6151 (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
|
6152 (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
|
6153 (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
|
6154 (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
|
6155 (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
|
6156 |
79545 | 6157 |
6158 (defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6159 "For `verilog-read-sub-decls-line', add a signal." |
79545 | 6160 (let (portdata) |
6161 (when sig | |
6162 (setq port (verilog-symbol-detick-denumber port)) | |
6163 (setq sig (verilog-symbol-detick-denumber sig)) | |
6164 (if sig (setq sig (verilog-string-replace-matches "^[---+~!|&]+" "" nil nil sig))) | |
6165 (if vec (setq vec (verilog-symbol-detick-denumber vec))) | |
6166 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) | |
6167 (unless (or (not sig) | |
6168 (equal sig "")) ;; Ignore .foo(1'b1) assignments | |
6169 (cond ((setq portdata (assoc port (verilog-modi-get-inouts submodi))) | |
6170 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil | |
6171 (verilog-sig-signed portdata) | |
6172 (verilog-sig-type portdata) | |
6173 multidim) | |
6174 sigs-inout))) | |
6175 ((setq portdata (assoc port (verilog-modi-get-outputs submodi))) | |
6176 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil | |
6177 (verilog-sig-signed portdata) | |
6178 (verilog-sig-type portdata) | |
6179 multidim) | |
6180 sigs-out))) | |
6181 ((setq portdata (assoc port (verilog-modi-get-inputs submodi))) | |
6182 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil | |
6183 (verilog-sig-signed portdata) | |
6184 (verilog-sig-type portdata) | |
6185 multidim) | |
6186 sigs-in))) | |
6187 ;; (t -- warning pin isn't defined.) ; Leave for lint tool | |
6188 ))))) | |
6189 | |
6190 (defun verilog-read-sub-decls-line (submodi comment) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6191 "For `verilog-read-sub-decls', read lines of port defs until none match anymore. |
79545 | 6192 Return the list of signals found, using submodi to look up each port." |
6193 (let (done port sig vec multidim) | |
6194 (save-excursion | |
6195 (forward-line 1) | |
6196 (while (not done) | |
6197 ;; Get port name | |
6198 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*") | |
6199 (setq port (match-string 1)) | |
6200 (goto-char (match-end 0))) | |
6201 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") | |
6202 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space | |
6203 (goto-char (match-end 0))) | |
6204 ((looking-at "\\s-*\\.[^(]*(") | |
6205 (setq port nil) ;; skip this line | |
6206 (goto-char (match-end 0))) | |
6207 (t | |
6208 (setq port nil done t))) ;; Unknown, ignore rest of line | |
6209 ;; Get signal name | |
6210 (when port | |
6211 (setq multidim nil) | |
6212 (cond ((looking-at "\\(\\\\[^ \t\n\f]*\\)\\s-*)") | |
6213 (setq sig (concat (match-string 1) " ") ;; escaped id's need trailing space | |
6214 vec nil)) | |
6215 ; We intentionally ignore (non-escaped) signals with .s in them | |
6216 ; this prevents AUTOWIRE etc from noticing hierarchical sigs. | |
6217 ((looking-at "\\([^[({).]*\\)\\s-*)") | |
6218 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6219 vec nil)) | |
6220 ((looking-at "\\([^[({).]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)") | |
6221 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6222 vec (match-string 2))) | |
6223 ((looking-at "\\([^[({).]*\\)\\s-*/\\*\\(\\[[^*]+\\]\\)\\*/\\s-*)") | |
6224 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6225 vec nil) | |
6226 (let ((parse (match-string 2))) | |
6227 (while (string-match "^\\(\\[[^]]+\\]\\)\\(.*\\)$" parse) | |
6228 (when vec (setq multidim (cons vec multidim))) | |
6229 (setq vec (match-string 1 parse)) | |
6230 (setq parse (match-string 2 parse))))) | |
6231 ((looking-at "{\\(.*\\)}.*\\s-*)") | |
6232 (let ((mlst (split-string (match-string 1) ",")) | |
6233 mstr) | |
6234 (while (setq mstr (pop mlst)) | |
6235 ;;(unless noninteractive (message "sig: %s " mstr)) | |
6236 (cond | |
6237 ((string-match "\\(['`a-zA-Z0-9_$]+\\)\\s-*$" mstr) | |
6238 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6239 vec nil) | |
6240 ;;(unless noninteractive (message "concat sig1: %s %s" mstr (match-string 1 mstr))) | |
6241 ) | |
6242 ((string-match "\\([^[({).]+\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*" mstr) | |
6243 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6244 vec (match-string 2 mstr)) | |
6245 ;;(unless noninteractive (message "concat sig2: '%s' '%s' '%s'" mstr (match-string 1 mstr) (match-string 2 mstr))) | |
6246 ) | |
6247 (t | |
6248 (setq sig nil))) | |
6249 ;; Process signals | |
6250 (verilog-read-sub-decls-sig submodi comment port sig vec multidim)))) | |
6251 (t | |
6252 (setq sig nil))) | |
6253 ;; Process signals | |
6254 (verilog-read-sub-decls-sig submodi comment port sig vec multidim)) | |
6255 ;; | |
6256 (forward-line 1))))) | |
6257 | |
6258 (defun verilog-read-sub-decls () | |
6259 "Internally parse signals going to modules under this module. | |
6260 Return a array of [ outputs inouts inputs ] signals for modules that are | |
6261 instantiated in this module. For example if declare A A (.B(SIG)) and SIG | |
6262 is a output, then SIG will be included in the list. | |
6263 | |
6264 This only works on instantiations created with /*AUTOINST*/ converted by | |
6265 \\[verilog-auto-inst]. Otherwise, it would have to read in the whole | |
6266 component library to determine connectivity of the design. | |
6267 | |
6268 One work around for this problem is to manually create // Inputs and // | |
6269 Outputs comments above subcell signals, for example: | |
6270 | |
6271 module1 instance1x ( | |
6272 // Outputs | |
6273 .out (out), | |
6274 // Inputs | |
6275 .in (in));" | |
6276 (save-excursion | |
6277 (let ((end-mod-point (verilog-get-end-of-defun t)) | |
6278 st-point end-inst-point | |
6279 ;; below 3 modified by verilog-read-sub-decls-line | |
6280 sigs-out sigs-inout sigs-in) | |
6281 (verilog-beg-of-defun) | |
6282 (while (re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t) | |
6283 (save-excursion | |
6284 (goto-char (match-beginning 0)) | |
6285 (unless (verilog-inside-comment-p) | |
6286 ;; Attempt to snarf a comment | |
6287 (let* ((submod (verilog-read-inst-module)) | |
6288 (inst (verilog-read-inst-name)) | |
6289 (comment (concat inst " of " submod ".v")) submodi) | |
6290 (when (setq submodi (verilog-modi-lookup submod t)) | |
6291 ;; This could have used a list created by verilog-auto-inst | |
6292 ;; However I want it to be runnable even on user's manually added signals | |
6293 (verilog-backward-open-paren) | |
6294 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) | |
6295 st-point (point)) | |
6296 (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t) | |
6297 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-out | |
6298 (goto-char st-point) | |
6299 (while (re-search-forward "\\s *// Inouts" end-inst-point t) | |
6300 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-inout | |
6301 (goto-char st-point) | |
6302 (while (re-search-forward "\\s *// Inputs" end-inst-point t) | |
6303 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-in | |
6304 ))))) | |
6305 ;; Combine duplicate bits | |
6306 ;;(setq rr (vector sigs-out sigs-inout sigs-in)) | |
6307 (vector (verilog-signals-combine-bus (nreverse sigs-out)) | |
6308 (verilog-signals-combine-bus (nreverse sigs-inout)) | |
6309 (verilog-signals-combine-bus (nreverse sigs-in)))))) | |
6310 | |
6311 (defun verilog-read-inst-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6312 "Return an array of [ pins ] for the current instantiation at point. |
79545 | 6313 For example if declare A A (.B(SIG)) then B will be included in the list." |
6314 (save-excursion | |
6315 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point | |
6316 pins pin) | |
6317 (verilog-backward-open-paren) | |
6318 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) | |
6319 (setq pin (match-string 1)) | |
6320 (unless (verilog-inside-comment-p) | |
6321 (setq pins (cons (list pin) pins)) | |
6322 (when (looking-at "(") | |
6323 (forward-sexp 1)))) | |
6324 (vector pins)))) | |
6325 | |
6326 (defun verilog-read-arg-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6327 "Return an array of [ pins ] for the current argument declaration at point." |
79545 | 6328 (save-excursion |
6329 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point | |
6330 pins pin) | |
6331 (verilog-backward-open-paren) | |
6332 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) | |
6333 (setq pin (match-string 1)) | |
6334 (unless (verilog-inside-comment-p) | |
6335 (setq pins (cons (list pin) pins)))) | |
6336 (vector pins)))) | |
6337 | |
6338 (defun verilog-read-auto-constants (beg end-mod-point) | |
6339 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT." | |
6340 ;; Insert new | |
6341 (save-excursion | |
6342 (let (sig-list tpl-end-pt) | |
6343 (goto-char beg) | |
6344 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t) | |
6345 (if (not (looking-at "\\s *(")) | |
6346 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text))) | |
6347 (search-forward "(" end-mod-point) | |
6348 (setq tpl-end-pt (save-excursion | |
6349 (backward-char 1) | |
6350 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6351 (backward-char 1) | |
6352 (point))) | |
6353 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) | |
6354 (setq sig-list (cons (list (match-string 1) nil nil) sig-list)))) | |
6355 sig-list))) | |
6356 | |
6357 (defun verilog-read-auto-lisp (start end) | |
6358 "Look for and evaluate a AUTO_LISP between START and END." | |
6359 (save-excursion | |
6360 (goto-char start) | |
6361 (while (re-search-forward "\\<AUTO_LISP(" end t) | |
6362 (backward-char) | |
6363 (let* ((beg-pt (prog1 (point) | |
6364 (forward-sexp 1))) ;; Closing paren | |
6365 (end-pt (point))) | |
6366 (eval-region beg-pt end-pt nil))))) | |
6367 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6368 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6369 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6370 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6371 ;; - 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
|
6372 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6373 (defvar sigs-out) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6374 (defvar got-sig) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6375 (defvar got-rvalue) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6376 (defvar uses-delayed) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6377 (defvar vector-skip-list)) |
79545 | 6378 |
6379 (defun verilog-read-always-signals-recurse | |
6380 (exit-keywd rvalue ignore-next) | |
6381 "Recursive routine for parentheses/bracket matching. | |
6382 EXIT-KEYWD is expression to stop at, nil if top level. | |
6383 RVALUE is true if at right hand side of equal. | |
6384 IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |
6385 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue | |
6386 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check) | |
6387 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next)))) | |
6388 (while (not (or (eobp) gotend)) | |
6389 (cond | |
6390 ((looking-at "//") | |
6391 (search-forward "\n")) | |
6392 ((looking-at "/\\*") | |
6393 (or (search-forward "*/") | |
6394 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6395 ((looking-at "(\\*") | |
6396 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6397 (search-forward "*)") | |
6398 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6399 (t (setq keywd (buffer-substring-no-properties | |
6400 (point) | |
6401 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6402 (forward-char 1)) | |
6403 (point))) | |
6404 sig-last-tolk sig-tolk | |
6405 sig-tolk nil) | |
6406 ;;(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)))) | |
6407 (cond | |
6408 ((equal keywd "\"") | |
6409 (or (re-search-forward "[^\\]\"" nil t) | |
6410 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6411 ;; else at top level loop, keep parsing | |
6412 ((and end-else-check (equal keywd "else")) | |
6413 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd)))) | |
6414 ;; no forward movement, want to see else in lower loop | |
6415 (setq end-else-check nil)) | |
6416 ;; End at top level loop | |
6417 ((and end-else-check (looking-at "[^ \t\n\f]")) | |
6418 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd)))) | |
6419 (setq gotend t)) | |
6420 ;; Final statement? | |
6421 ((and exit-keywd (equal keywd exit-keywd)) | |
6422 (setq gotend t) | |
6423 (forward-char (length keywd))) | |
6424 ;; Standard tokens... | |
6425 ((equal keywd ";") | |
6426 (setq ignore-next nil rvalue semi-rvalue) | |
6427 ;; Final statement at top level loop? | |
6428 (when (not exit-keywd) | |
6429 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd)))) | |
6430 (setq end-else-check t)) | |
6431 (forward-char 1)) | |
6432 ((equal keywd "'") | |
6433 (if (looking-at "'s?[hdxbo][0-9a-fA-F_xz? \t]*") | |
6434 (goto-char (match-end 0)) | |
6435 (forward-char 1))) | |
6436 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z | |
6437 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next | |
6438 (setq ignore-next nil rvalue nil)) | |
6439 ((equal "?" exit-keywd) ;; x?y:z rvalue | |
6440 ) ;; NOP | |
6441 (got-sig ;; label: statement | |
6442 (setq ignore-next nil rvalue semi-rvalue got-sig nil)) | |
6443 ((not rvalue) ;; begin label | |
6444 (setq ignore-next t rvalue nil))) | |
6445 (forward-char 1)) | |
6446 ((equal keywd "=") | |
6447 (if (eq (char-before) ?< ) | |
6448 (setq uses-delayed 1)) | |
6449 (setq ignore-next nil rvalue t) | |
6450 (forward-char 1)) | |
6451 ((equal keywd "?") | |
6452 (forward-char 1) | |
6453 (verilog-read-always-signals-recurse ":" rvalue nil)) | |
6454 ((equal keywd "[") | |
6455 (forward-char 1) | |
6456 (verilog-read-always-signals-recurse "]" t nil)) | |
6457 ((equal keywd "(") | |
6458 (forward-char 1) | |
6459 (cond (sig-last-tolk ;; Function call; zap last signal | |
6460 (setq got-sig nil))) | |
6461 (cond ((equal last-keywd "for") | |
6462 (verilog-read-always-signals-recurse ";" nil nil) | |
6463 (verilog-read-always-signals-recurse ";" t nil) | |
6464 (verilog-read-always-signals-recurse ")" nil nil)) | |
6465 (t (verilog-read-always-signals-recurse ")" t nil)))) | |
6466 ((equal keywd "begin") | |
6467 (skip-syntax-forward "w_") | |
6468 (verilog-read-always-signals-recurse "end" nil nil) | |
6469 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd)))) | |
6470 (setq ignore-next nil rvalue semi-rvalue) | |
6471 (if (not exit-keywd) (setq end-else-check t))) | |
6472 ((or (equal keywd "case") | |
6473 (equal keywd "casex") | |
6474 (equal keywd "casez")) | |
6475 (skip-syntax-forward "w_") | |
6476 (verilog-read-always-signals-recurse "endcase" t nil) | |
6477 (setq ignore-next nil rvalue semi-rvalue) | |
6478 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end | |
6479 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent | |
6480 (cond ((or (equal keywd "`ifdef") | |
6481 (equal keywd "`ifndef")) | |
6482 (setq ignore-next t)) | |
6483 ((or ignore-next | |
6484 (member keywd verilog-keywords) | |
6485 (string-match "^\\$" keywd)) ;; PLI task | |
6486 (setq ignore-next nil)) | |
6487 (t | |
6488 (setq keywd (verilog-symbol-detick-denumber keywd)) | |
6489 (when got-sig | |
6490 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6491 (setq sigs-out (cons got-sig sigs-out))) | |
6492 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6493 ) | |
6494 (setq got-rvalue rvalue | |
6495 got-sig (if (or (not keywd) | |
6496 (assoc keywd (if got-rvalue sigs-in sigs-out))) | |
6497 nil (list keywd nil nil)) | |
6498 sig-tolk t))) | |
6499 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6500 (t | |
6501 (forward-char 1))) | |
6502 ;; End of non-comment token | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6503 (setq last-keywd keywd))) |
79545 | 6504 (skip-syntax-forward " ")) |
6505 ;; Append the final pending signal | |
6506 (when got-sig | |
6507 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6508 (setq sigs-out (cons got-sig sigs-out))) | |
6509 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6510 (setq got-sig nil)) | |
6511 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd)))) | |
6512 )) | |
6513 | |
6514 (defun verilog-read-always-signals () | |
6515 "Parse always block at point and return list of (outputs inout inputs)." | |
6516 ;; Insert new | |
6517 (save-excursion | |
6518 (let* (;;(dbg "") | |
6519 sigs-in sigs-out | |
6520 uses-delayed) ;; Found signal/rvalue; push if not function | |
6521 (search-forward ")") | |
6522 (verilog-read-always-signals-recurse nil nil nil) | |
6523 ;;(if dbg (save-excursion (set-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg ""))) | |
6524 ;; Return what was found | |
6525 (list sigs-out nil sigs-in uses-delayed)))) | |
6526 | |
6527 (defun verilog-read-instants () | |
6528 "Parse module at point and return list of ( ( file instance ) ... )." | |
6529 (verilog-beg-of-defun) | |
6530 (let* ((end-mod-point (verilog-get-end-of-defun t)) | |
6531 (state nil) | |
6532 (instants-list nil)) | |
6533 (save-excursion | |
6534 (while (< (point) end-mod-point) | |
6535 ;; Stay at level 0, no comments | |
6536 (while (progn | |
6537 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil)) | |
6538 (or (> (car state) 0) ; in parens | |
6539 (nth 5 state) ; comment | |
6540 )) | |
6541 (forward-line 1)) | |
6542 (beginning-of-line) | |
6543 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(") | |
6544 ;;(if (looking-at "^\\(.+\\)$") | |
6545 (let ((module (match-string 1)) | |
6546 (instant (match-string 2))) | |
6547 (if (not (member module verilog-keywords)) | |
6548 (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
|
6549 (forward-line 1))) |
79545 | 6550 instants-list)) |
6551 | |
6552 | |
6553 (defun verilog-read-auto-template (module) | |
6554 "Look for a auto_template for the instantiation of the given MODULE. | |
6555 If found returns the signal name connections. Return REGEXP and | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6556 list of ( (signal_name connection_name)... )." |
79545 | 6557 (save-excursion |
6558 ;; Find beginning | |
6559 (let ((tpl-regexp "\\([0-9]+\\)") | |
6560 (lineno 0) | |
6561 (templateno 0) | |
6562 tpl-sig-list tpl-wild-list tpl-end-pt rep) | |
6563 (cond ((or | |
6564 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t) | |
6565 (progn | |
6566 (goto-char (point-min)) | |
6567 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t))) | |
6568 (goto-char (match-end 0)) | |
6569 ;; Parse "REGEXP" | |
6570 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST | |
6571 (when (looking-at "\\s-*\"\\([^\"]*)\\)\"") | |
6572 (setq tpl-regexp (match-string 1)) | |
6573 (goto-char (match-end 0))) | |
6574 (search-forward "(") | |
6575 ;; Parse lines in the template | |
6576 (when verilog-auto-inst-template-numbers | |
6577 (save-excursion | |
6578 (goto-char (point-min)) | |
6579 (while (search-forward "AUTO_TEMPLATE" nil t) | |
6580 (setq templateno (1+ templateno))))) | |
6581 (setq tpl-end-pt (save-excursion | |
6582 (backward-char 1) | |
6583 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6584 (backward-char 1) | |
6585 (point))) | |
6586 ;; | |
6587 (while (< (point) tpl-end-pt) | |
6588 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
6589 (setq tpl-sig-list (cons (list | |
6590 (match-string-no-properties 1) | |
6591 (match-string-no-properties 2) | |
6592 templateno lineno) | |
6593 tpl-sig-list)) | |
6594 (goto-char (match-end 0))) | |
6595 ;; Regexp form?? | |
6596 ((looking-at | |
6597 ;; Regexp bug in xemacs disallows ][ inside [], and wants + last | |
6598 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
6599 (setq rep (match-string-no-properties 3)) | |
6600 (goto-char (match-end 0)) | |
6601 (setq tpl-wild-list | |
6602 (cons (list | |
6603 (concat "^" | |
6604 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil | |
6605 (match-string 1)) | |
6606 "$") | |
6607 rep | |
6608 templateno lineno) | |
6609 tpl-wild-list))) | |
6610 ((looking-at "[ \t\f]+") | |
6611 (goto-char (match-end 0))) | |
6612 ((looking-at "\n") | |
6613 (setq lineno (1+ lineno)) | |
6614 (goto-char (match-end 0))) | |
6615 ((looking-at "//") | |
6616 (search-forward "\n")) | |
6617 ((looking-at "/\\*") | |
6618 (forward-char 2) | |
6619 (or (search-forward "*/") | |
6620 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6621 (t | |
6622 (error "%s: AUTO_TEMPLATE parsing error: %s" | |
6623 (verilog-point-text) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6624 (progn (looking-at ".*$") (match-string 0)))))) |
79545 | 6625 ;; Return |
6626 (vector tpl-regexp | |
6627 (list tpl-sig-list tpl-wild-list))) | |
6628 ;; If no template found | |
6629 (t (vector tpl-regexp nil)))))) | |
6630 ;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry")) | |
6631 | |
6632 (defun verilog-set-define (defname defvalue &optional buffer enumname) | |
6633 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER. | |
6634 Optionally associate it with the specified enumeration ENUMNAME." | |
6635 (save-excursion | |
6636 (set-buffer (or buffer (current-buffer))) | |
6637 (let ((mac (intern (concat "vh-" defname)))) | |
6638 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6639 ;; Need to define to a constant if no value given | |
6640 (set (make-variable-buffer-local mac) | |
6641 (if (equal defvalue "") "1" defvalue))) | |
6642 (if enumname | |
6643 (let ((enumvar (intern (concat "venum-" enumname)))) | |
6644 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6645 (make-variable-buffer-local enumvar) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6646 (add-to-list enumvar defname))))) |
79545 | 6647 |
6648 (defun verilog-read-defines (&optional filename recurse subcall) | |
6649 "Read `defines and parameters for the current file, or optional FILENAME. | |
6650 If the filename is provided, `verilog-library-flags' will be used to | |
6651 resolve it. If optional RECURSE is non-nil, recurse through `includes. | |
6652 | |
6653 Parameters must be simple assignments to constants, or have their own | |
6654 \"parameter\" label rather than a list of parameters. Thus: | |
6655 | |
6656 parameter X = 5, Y = 10; // Ok | |
6657 parameter X = {1'b1, 2'h2}; // Ok | |
6658 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines | |
6659 | |
6660 Defines must be simple text substitutions, one on a line, starting | |
6661 at the beginning of the line. Any ifdefs or multiline comments around the | |
6662 define are ignored. | |
6663 | |
6664 Defines are stored inside Emacs variables using the name vh-{definename}. | |
6665 | |
6666 This function is useful for setting vh-* variables. The file variables | |
6667 feature can be used to set defines that `verilog-mode' can see; put at the | |
6668 *END* of your file something like: | |
6669 | |
6670 // Local Variables: | |
6671 // vh-macro:\"macro_definition\" | |
6672 // End: | |
6673 | |
6674 If macros are defined earlier in the same file and you want their values, | |
6675 you can read them automatically (provided `enable-local-eval' is on): | |
6676 | |
6677 // Local Variables: | |
6678 // eval:(verilog-read-defines) | |
6679 // eval:(verilog-read-defines \"group_standard_includes.v\") | |
6680 // End: | |
6681 | |
6682 Note these are only read when the file is first visited, you must use | |
6683 \\[find-alternate-file] RET to have these take effect after editing them! | |
6684 | |
6685 If you want to disable the \"Process `eval' or hook local variables\" | |
6686 warning message, you need to add to your .emacs file: | |
6687 | |
6688 (setq enable-local-eval t)" | |
6689 (let ((origbuf (current-buffer))) | |
6690 (save-excursion | |
6691 (unless subcall (verilog-getopt-flags)) | |
6692 (when filename | |
6693 (let ((fns (verilog-library-filenames filename (buffer-file-name)))) | |
6694 (if fns | |
6695 (set-buffer (find-file-noselect (car fns))) | |
6696 (error (concat (verilog-point-text) | |
6697 ": Can't find verilog-read-defines file: " filename))))) | |
6698 (when recurse | |
6699 (goto-char (point-min)) | |
6700 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6701 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1)))) | |
6702 (unless (verilog-inside-comment-p) | |
6703 (verilog-read-defines inc recurse t))))) | |
6704 ;; Read `defines | |
6705 ;; note we don't use verilog-re... it's faster this way, and that | |
6706 ;; function has problems when comments are at the end of the define | |
6707 (goto-char (point-min)) | |
6708 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t) | |
6709 (let ((defname (match-string-no-properties 1)) | |
6710 (defvalue (match-string-no-properties 2))) | |
6711 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue)) | |
6712 (verilog-set-define defname defvalue origbuf))) | |
6713 ;; Hack: Read parameters | |
6714 (goto-char (point-min)) | |
6715 (while (re-search-forward | |
6716 "^\\s-*\\(parameter\\|localparam\\)\\(\\(\\s-*\\[[^]]*\\]\\|\\)\\s-+\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\|\\)\\s-*" nil t) | |
6717 (let ((var (match-string-no-properties 4)) | |
6718 (val (match-string-no-properties 5)) | |
6719 enumname) | |
6720 ;; The primary way of getting defines is verilog-read-decls | |
6721 ;; However, that isn't called yet for included files, so we'll add another scheme | |
6722 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6723 (setq enumname (match-string-no-properties 1))) | |
6724 (if var | |
6725 (verilog-set-define var val origbuf enumname)) | |
6726 (forward-comment 999) | |
6727 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | |
6728 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) | |
6729 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6730 (forward-comment 999))))))) |
79545 | 6731 |
6732 (defun verilog-read-includes () | |
6733 "Read `includes for the current file. | |
6734 This will find all of the `includes which are at the beginning of lines, | |
6735 ignoring any ifdefs or multiline comments around them. | |
6736 `verilog-read-defines' is then performed on the current and each included | |
6737 file. | |
6738 | |
6739 It is often useful put at the *END* of your file something like: | |
6740 | |
6741 // Local Variables: | |
6742 // eval:(verilog-read-defines) | |
6743 // eval:(verilog-read-includes) | |
6744 // End: | |
6745 | |
6746 Note includes are only read when the file is first visited, you must use | |
6747 \\[find-alternate-file] RET to have these take effect after editing them! | |
6748 | |
6749 It is good to get in the habit of including all needed files in each .v | |
6750 file that needs it, rather than waiting for compile time. This will aid | |
6751 this process, Verilint, and readability. To prevent defining the same | |
6752 variable over and over when many modules are compiled together, put a test | |
6753 around the inside each include file: | |
6754 | |
6755 foo.v (a include): | |
6756 `ifdef _FOO_V // include if not already included | |
6757 `else | |
6758 `define _FOO_V | |
6759 ... contents of file | |
6760 `endif // _FOO_V" | |
6761 ;;slow: (verilog-read-defines nil t)) | |
6762 (save-excursion | |
6763 (verilog-getopt-flags) | |
6764 (goto-char (point-min)) | |
6765 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6766 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1)))) | |
6767 (verilog-read-defines inc nil t))))) | |
6768 | |
6769 (defun verilog-read-signals (&optional start end) | |
6770 "Return a simple list of all possible signals in the file. | |
6771 Bounded by optional region from START to END. Overly aggressive but fast. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6772 Some macros and such are also found and included. For dinotrace.el." |
79545 | 6773 (let (sigs-all keywd) |
6774 (progn;save-excursion | |
6775 (goto-char (or start (point-min))) | |
6776 (setq end (or end (point-max))) | |
6777 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t) | |
6778 (forward-char -1) | |
6779 (cond | |
6780 ((looking-at "//") | |
6781 (search-forward "\n")) | |
6782 ((looking-at "/\\*") | |
6783 (search-forward "*/")) | |
6784 ((looking-at "(\\*") | |
6785 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6786 (search-forward "*)"))) | |
6787 ((eq ?\" (following-char)) | |
6788 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first | |
6789 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") | |
6790 (goto-char (match-end 0)) | |
6791 (setq keywd (match-string-no-properties 1)) | |
6792 (or (member keywd verilog-keywords) | |
6793 (member keywd sigs-all) | |
6794 (setq sigs-all (cons keywd sigs-all)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6795 (t (forward-char 1)))) |
79545 | 6796 ;; Return list |
6797 sigs-all))) | |
6798 | |
6799 ;; | |
6800 ;; Argument file parsing | |
6801 ;; | |
6802 | |
6803 (defun verilog-getopt (arglist) | |
6804 "Parse -f, -v etc arguments in ARGLIST list or string." | |
6805 (unless (listp arglist) (setq arglist (list arglist))) | |
6806 (let ((space-args '()) | |
6807 arg next-param) | |
6808 ;; Split on spaces, so users can pass whole command lines | |
6809 (while arglist | |
6810 (setq arg (car arglist) | |
6811 arglist (cdr arglist)) | |
6812 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg) | |
6813 (setq space-args (append space-args | |
6814 (list (match-string-no-properties 1 arg)))) | |
6815 (setq arg (match-string 2 arg)))) | |
6816 ;; Parse arguments | |
6817 (while space-args | |
6818 (setq arg (car space-args) | |
6819 space-args (cdr space-args)) | |
6820 (cond | |
6821 ;; Need another arg | |
6822 ((equal arg "-f") | |
6823 (setq next-param arg)) | |
6824 ((equal arg "-v") | |
6825 (setq next-param arg)) | |
6826 ((equal arg "-y") | |
6827 (setq next-param arg)) | |
6828 ;; +libext+(ext1)+(ext2)... | |
6829 ((string-match "^\\+libext\\+\\(.*\\)" arg) | |
6830 (setq arg (match-string 1 arg)) | |
6831 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg) | |
6832 (verilog-add-list-unique `verilog-library-extensions | |
6833 (match-string 1 arg)) | |
6834 (setq arg (match-string 2 arg)))) | |
6835 ;; | |
6836 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val | |
6837 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine | |
6838 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val | |
6839 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define | |
6840 (verilog-set-define (match-string 1 arg) (match-string 2 arg))) | |
6841 ;; | |
6842 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir | |
6843 (string-match "^-I\\(.*\\)" arg)) ;; -Idir | |
6844 (verilog-add-list-unique `verilog-library-directories | |
6845 (match-string 1 arg))) | |
6846 ;; Ignore | |
6847 ((equal "+librescan" arg)) | |
6848 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine | |
6849 ;; Second parameters | |
6850 ((equal next-param "-f") | |
6851 (setq next-param nil) | |
6852 (verilog-getopt-file arg)) | |
6853 ((equal next-param "-v") | |
6854 (setq next-param nil) | |
6855 (verilog-add-list-unique `verilog-library-files arg)) | |
6856 ((equal next-param "-y") | |
6857 (setq next-param nil) | |
6858 (verilog-add-list-unique `verilog-library-directories arg)) | |
6859 ;; Filename | |
6860 ((string-match "^[^-+]" arg) | |
6861 (verilog-add-list-unique `verilog-library-files arg)) | |
6862 ;; Default - ignore; no warning | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6863 )))) |
79545 | 6864 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
6865 | |
6866 (defun verilog-getopt-file (filename) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6867 "Read Verilog options from the specified FILENAME." |
79545 | 6868 (save-excursion |
6869 (let ((fns (verilog-library-filenames filename (buffer-file-name))) | |
6870 (orig-buffer (current-buffer)) | |
6871 line) | |
6872 (if fns | |
6873 (set-buffer (find-file-noselect (car fns))) | |
6874 (error (concat (verilog-point-text) | |
6875 "Can't find verilog-getopt-file -f file: " filename))) | |
6876 (goto-char (point-min)) | |
6877 (while (not (eobp)) | |
6878 (setq line (buffer-substring (point) | |
6879 (save-excursion (end-of-line) (point)))) | |
6880 (forward-line 1) | |
6881 (when (string-match "//" line) | |
6882 (setq line (substring line 0 (match-beginning 0)))) | |
6883 (save-excursion | |
6884 (set-buffer orig-buffer) ; Variables are buffer-local, so need right context. | |
6885 (verilog-getopt line)))))) | |
6886 | |
6887 (defun verilog-getopt-flags () | |
6888 "Convert `verilog-library-flags' into standard library variables." | |
6889 ;; If the flags are local, then all the outputs should be local also | |
6890 (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
|
6891 (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
|
6892 verilog-library-directories |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6893 verilog-library-files |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6894 verilog-library-flags))) |
79545 | 6895 ;; Allow user to customize |
6896 (run-hooks 'verilog-before-getopt-flags-hook) | |
6897 ;; Process arguments | |
6898 (verilog-getopt verilog-library-flags) | |
6899 ;; Allow user to customize | |
6900 (run-hooks 'verilog-getopt-flags-hook)) | |
6901 | |
6902 (defun verilog-add-list-unique (varref object) | |
6903 "Append to VARREF list the given OBJECT, | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6904 unless it is already a member of the variable's list." |
79545 | 6905 (unless (member object (symbol-value varref)) |
6906 (set varref (append (symbol-value varref) (list object)))) | |
6907 varref) | |
6908 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l) | |
6909 | |
6910 | |
6911 ;; | |
6912 ;; Module name lookup | |
6913 ;; | |
6914 | |
6915 (defun verilog-module-inside-filename-p (module filename) | |
6916 "Return point if MODULE is specified inside FILENAME, else nil. | |
6917 Allows version control to check out the file if need be." | |
6918 (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
|
6919 (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
|
6920 (vc-backend filename))) |
79545 | 6921 (let (pt) |
6922 (save-excursion | |
6923 (set-buffer (find-file-noselect filename)) | |
6924 (goto-char (point-min)) | |
6925 (while (and | |
6926 ;; It may be tempting to look for verilog-defun-re, don't, it slows things down a lot! | |
6927 (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
6928 (verilog-re-search-forward-quick "[(;]" nil t)) | |
6929 (if (equal module (verilog-read-module-name)) | |
6930 (setq pt (point)))) | |
6931 pt)))) | |
6932 | |
6933 (defun verilog-is-number (symbol) | |
6934 "Return true if SYMBOL is number-like." | |
6935 (or (string-match "^[0-9 \t:]+$" symbol) | |
6936 (string-match "^[---]*[0-9]+$" symbol) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6937 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
79545 | 6938 |
6939 (defun verilog-symbol-detick (symbol wing-it) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6940 "Return an expanded SYMBOL name without any defines. |
79545 | 6941 If the variable vh-{symbol} is defined, return that value. |
6942 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | |
6943 (while (and symbol (string-match "^`" symbol)) | |
6944 (setq symbol (substring symbol 1)) | |
6945 (setq symbol | |
6946 (if (boundp (intern (concat "vh-" symbol))) | |
6947 ;; Emacs has a bug where boundp on a buffer-local | |
6948 ;; variable in only one buffer returns t in another. | |
6949 ;; This can confuse, so check for nil. | |
6950 (let ((val (eval (intern (concat "vh-" symbol))))) | |
6951 (if (eq val nil) | |
6952 (if wing-it symbol nil) | |
6953 val)) | |
6954 (if wing-it symbol nil)))) | |
6955 symbol) | |
6956 ;;(verilog-symbol-detick "`mod" nil) | |
6957 | |
6958 (defun verilog-symbol-detick-denumber (symbol) | |
6959 "Return SYMBOL with defines converted and any numbers dropped to nil." | |
6960 (when (string-match "^`" symbol) | |
6961 ;; This only will work if the define is a simple signal, not | |
6962 ;; something like a[b]. Sorry, it should be substituted into the parser | |
6963 (setq symbol | |
6964 (verilog-string-replace-matches | |
6965 "\[[^0-9: \t]+\]" "" nil nil | |
6966 (or (verilog-symbol-detick symbol nil) | |
6967 (if verilog-auto-sense-defines-constant | |
6968 "0" | |
6969 symbol))))) | |
6970 (if (verilog-is-number symbol) | |
6971 nil | |
6972 symbol)) | |
6973 | |
6974 (defun verilog-symbol-detick-text (text) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6975 "Return TEXT without any known defines. |
79545 | 6976 If the variable vh-{symbol} is defined, substitute that value." |
6977 (let ((ok t) symbol val) | |
6978 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text)) | |
6979 (setq symbol (match-string 1 text)) | |
6980 (message symbol) | |
6981 (cond ((and | |
6982 (boundp (intern (concat "vh-" symbol))) | |
6983 ;; Emacs has a bug where boundp on a buffer-local | |
6984 ;; variable in only one buffer returns t in another. | |
6985 ;; This can confuse, so check for nil. | |
6986 (setq val (eval (intern (concat "vh-" symbol))))) | |
6987 (setq text (replace-match val nil nil text))) | |
6988 (t (setq ok nil))))) | |
6989 text) | |
6990 ;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed")) | |
6991 | |
6992 (defun verilog-expand-dirnames (&optional dirnames) | |
6993 "Return a list of existing directories given a list of wildcarded DIRNAMES. | |
6994 Or, just the existing dirnames themselves if there are no wildcards." | |
6995 (interactive) | |
6996 (unless dirnames (error "`verilog-library-directories' should include at least '.'")) | |
6997 (setq dirnames (reverse dirnames)) ; not nreverse | |
6998 (let ((dirlist nil) | |
6999 pattern dirfile dirfiles dirname root filename rest) | |
7000 (while dirnames | |
7001 (setq dirname (substitute-in-file-name (car dirnames)) | |
7002 dirnames (cdr dirnames)) | |
7003 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root | |
7004 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *? | |
7005 "\\(.*\\)") ;; rest | |
7006 dirname) | |
7007 (setq root (match-string 1 dirname) | |
7008 filename (match-string 2 dirname) | |
7009 rest (match-string 3 dirname) | |
7010 pattern filename) | |
7011 ;; now replace those * and ? with .+ and . | |
7012 ;; use ^ and /> to get only whole file names | |
7013 ;;verilog-string-replace-matches | |
7014 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) | |
7015 pattern (verilog-string-replace-matches "[?]" "." nil nil pattern) | |
7016 | |
7017 ;; Unfortunately allows abc/*/rtl to match abc/rtl | |
7018 ;; because abc/.. shows up in dirfiles. Solutions welcome. | |
7019 dirfiles (if (file-directory-p root) ; Ignore version control external | |
7020 (directory-files root t pattern nil))) | |
7021 (while dirfiles | |
7022 (setq dirfile (expand-file-name (concat (car dirfiles) rest)) | |
7023 dirfiles (cdr dirfiles)) | |
7024 (if (file-directory-p dirfile) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7025 (setq dirlist (cons dirfile dirlist))))) |
79545 | 7026 ;; Defaults |
7027 (t | |
7028 (if (file-directory-p dirname) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7029 (setq dirlist (cons dirname dirlist)))))) |
79545 | 7030 dirlist)) |
7031 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | |
7032 | |
7033 (defun verilog-library-filenames (filename current &optional check-ext) | |
7034 "Return a search path to find the given FILENAME name. | |
7035 Uses the CURRENT filename, `verilog-library-directories' and | |
7036 `verilog-library-extensions' variables to build the path. | |
7037 With optional CHECK-EXT also check `verilog-library-extensions'." | |
7038 (let ((ckdir (verilog-expand-dirnames verilog-library-directories)) | |
7039 fn outlist) | |
7040 (while ckdir | |
7041 (let ((ckext (if check-ext verilog-library-extensions `("")))) | |
7042 (while ckext | |
7043 (setq fn (expand-file-name | |
7044 (concat filename (car ckext)) | |
7045 (expand-file-name (car ckdir) (file-name-directory current)))) | |
7046 (if (file-exists-p fn) | |
7047 (setq outlist (cons fn outlist))) | |
7048 (setq ckext (cdr ckext)))) | |
7049 (setq ckdir (cdr ckdir))) | |
7050 (nreverse outlist))) | |
7051 | |
7052 (defun verilog-module-filenames (module current) | |
7053 "Return a search path to find the given MODULE name. | |
7054 Uses the CURRENT filename, `verilog-library-extensions', | |
7055 `verilog-library-directories' and `verilog-library-files' | |
7056 variables to build the path." | |
7057 ;; Return search locations for it | |
7058 (append (list current) ; first, current buffer | |
7059 (verilog-library-filenames module current t) | |
7060 verilog-library-files)) ; finally, any libraries | |
7061 | |
7062 ;; | |
7063 ;; Module Information | |
7064 ;; | |
7065 ;; Many of these functions work on "modi" a module information structure | |
7066 ;; A modi is: [module-name-string file-name begin-point] | |
7067 | |
7068 (defvar verilog-cache-enabled t | |
7069 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!") | |
7070 | |
7071 (defvar verilog-modi-cache-list nil | |
7072 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)... | |
7073 For speeding up verilog-modi-get-* commands. | |
7074 Buffer-local.") | |
7075 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7076 (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
|
7077 |
79545 | 7078 (defvar verilog-modi-cache-preserve-tick nil |
7079 "Modification tick after which the cache is still considered valid. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7080 Use `verilog-preserve-cache' to set it.") |
79545 | 7081 (defvar verilog-modi-cache-preserve-buffer nil |
7082 "Modification tick after which the cache is still considered valid. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7083 Use `verilog-preserve-cache' to set it.") |
79545 | 7084 |
7085 (defun verilog-modi-current () | |
7086 "Return the modi structure for the module currently at point." | |
7087 (let* (name pt) | |
7088 ;; read current module's name | |
7089 (save-excursion | |
7090 (verilog-re-search-backward-quick verilog-defun-re nil nil) | |
7091 (verilog-re-search-forward-quick "(" nil nil) | |
7092 (setq name (verilog-read-module-name)) | |
7093 (setq pt (point))) | |
7094 ;; return | |
7095 (vector name (or (buffer-file-name) (current-buffer)) pt))) | |
7096 | |
7097 (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.") | |
7098 (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.") | |
7099 (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.") | |
7100 (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.") | |
7101 | |
7102 (defun verilog-modi-lookup (module allow-cache &optional ignore-error) | |
7103 "Find the file and point at which MODULE is defined. | |
7104 If ALLOW-CACHE is set, check and remember cache of previous lookups. | |
7105 Return modi if successful, else print message unless IGNORE-ERROR is true." | |
7106 (let* ((current (or (buffer-file-name) (current-buffer)))) | |
7107 (cond ((and verilog-modi-lookup-last-modi | |
7108 verilog-cache-enabled | |
7109 allow-cache | |
7110 (equal verilog-modi-lookup-last-mod module) | |
7111 (equal verilog-modi-lookup-last-current current) | |
7112 (equal verilog-modi-lookup-last-tick (buffer-modified-tick))) | |
7113 ;; ok as is | |
7114 ) | |
7115 (t (let* ((realmod (verilog-symbol-detick module t)) | |
7116 (orig-filenames (verilog-module-filenames realmod current)) | |
7117 (filenames orig-filenames) | |
7118 pt) | |
7119 (while (and filenames (not pt)) | |
7120 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames)))) | |
7121 (setq filenames (cdr filenames)))) | |
7122 (cond (pt (setq verilog-modi-lookup-last-modi | |
7123 (vector realmod (car filenames) pt))) | |
7124 (t (setq verilog-modi-lookup-last-modi nil) | |
7125 (or ignore-error | |
7126 (error (concat (verilog-point-text) | |
7127 ": Can't locate " module " module definition" | |
7128 (if (not (equal module realmod)) | |
7129 (concat " (Expanded macro to " realmod ")") | |
7130 "") | |
7131 "\n Check the verilog-library-directories variable." | |
7132 "\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
|
7133 (mapconcat 'concat orig-filenames "\n\t")))))) |
79545 | 7134 (setq verilog-modi-lookup-last-mod module |
7135 verilog-modi-lookup-last-current current | |
7136 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7137 verilog-modi-lookup-last-modi)) |
79545 | 7138 |
7139 (defsubst verilog-modi-name (modi) | |
7140 (aref modi 0)) | |
7141 (defsubst verilog-modi-file-or-buffer (modi) | |
7142 (aref modi 1)) | |
7143 (defsubst verilog-modi-point (modi) | |
7144 (aref modi 2)) | |
7145 | |
7146 (defun verilog-modi-filename (modi) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7147 "Filename of MODI, or name of buffer if it's never been saved." |
79545 | 7148 (if (bufferp (verilog-modi-file-or-buffer modi)) |
7149 (or (buffer-file-name (verilog-modi-file-or-buffer modi)) | |
7150 (buffer-name (verilog-modi-file-or-buffer modi))) | |
7151 (verilog-modi-file-or-buffer modi))) | |
7152 | |
7153 (defun verilog-modi-goto (modi) | |
7154 "Move point/buffer to specified MODI." | |
7155 (or modi (error "Passed unfound modi to goto, check earlier")) | |
7156 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) | |
7157 (verilog-modi-file-or-buffer modi) | |
7158 (find-file-noselect (verilog-modi-file-or-buffer modi)))) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7159 (or (equal major-mode `verilog-mode) ;; Put into Verilog mode to get syntax |
79545 | 7160 (verilog-mode)) |
7161 (goto-char (verilog-modi-point modi))) | |
7162 | |
7163 (defun verilog-goto-defun-file (module) | |
7164 "Move point to the file at which a given MODULE is defined." | |
7165 (interactive "sGoto File for Module: ") | |
7166 (let* ((modi (verilog-modi-lookup module nil))) | |
7167 (when modi | |
7168 (verilog-modi-goto modi) | |
7169 (switch-to-buffer (current-buffer))))) | |
7170 | |
7171 (defun verilog-modi-cache-results (modi function) | |
7172 "Run on MODI the given FUNCTION. Locate the module in a file. | |
7173 Cache the output of function so next call may have faster access." | |
7174 (let (func-returns fass) | |
7175 (save-excursion | |
7176 (verilog-modi-goto modi) | |
7177 (if (and (setq fass (assoc (list (verilog-modi-name modi) function) | |
7178 verilog-modi-cache-list)) | |
7179 ;; Destroy caching when incorrect; Modified or file changed | |
7180 (not (and verilog-cache-enabled | |
7181 (or (equal (buffer-modified-tick) (nth 1 fass)) | |
7182 (and verilog-modi-cache-preserve-tick | |
7183 (<= verilog-modi-cache-preserve-tick (nth 1 fass)) | |
7184 (equal verilog-modi-cache-preserve-buffer (current-buffer)))) | |
7185 (equal (visited-file-modtime) (nth 2 fass))))) | |
7186 (setq verilog-modi-cache-list nil | |
7187 fass nil)) | |
7188 (cond (fass | |
7189 ;; Found | |
7190 (setq func-returns (nth 3 fass))) | |
7191 (t | |
7192 ;; Read from file | |
7193 ;; Clear then restore any hilighting to make emacs19 happy | |
7194 (let ((fontlocked (when (and (boundp 'font-lock-mode) | |
7195 font-lock-mode) | |
7196 (font-lock-mode nil) | |
7197 t))) | |
7198 (setq func-returns (funcall function)) | |
7199 (when fontlocked (font-lock-mode t))) | |
7200 ;; Cache for next time | |
7201 (setq verilog-modi-cache-list | |
7202 (cons (list (list (verilog-modi-name modi) function) | |
7203 (buffer-modified-tick) | |
7204 (visited-file-modtime) | |
7205 func-returns) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7206 verilog-modi-cache-list))))) |
79545 | 7207 ;; |
7208 func-returns)) | |
7209 | |
7210 (defun verilog-modi-cache-add (modi function element sig-list) | |
7211 "Add function return results to the module cache. | |
7212 Update MODI's cache for given FUNCTION so that the return ELEMENT of that | |
7213 function now contains the additional SIG-LIST parameters." | |
7214 (let (fass) | |
7215 (save-excursion | |
7216 (verilog-modi-goto modi) | |
7217 (if (setq fass (assoc (list (verilog-modi-name modi) function) | |
7218 verilog-modi-cache-list)) | |
7219 (let ((func-returns (nth 3 fass))) | |
7220 (aset func-returns element | |
7221 (append sig-list (aref func-returns element)))))))) | |
7222 | |
7223 (defmacro verilog-preserve-cache (&rest body) | |
7224 "Execute the BODY forms, allowing cache preservation within BODY. | |
7225 This means that changes to the buffer will not result in the cache being | |
7226 flushed. If the changes affect the modsig state, they must call the | |
7227 modsig-cache-add-* function, else the results of later calls may be | |
7228 incorrect. Without this, changes are assumed to be adding/removing signals | |
7229 and invalidating the cache." | |
7230 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick)) | |
7231 (verilog-modi-cache-preserve-buffer (current-buffer))) | |
7232 (progn ,@body))) | |
7233 | |
7234 | |
7235 (defun verilog-signals-matching-enum (in-list enum) | |
7236 "Return all signals in IN-LIST matching the given ENUM." | |
7237 (let (out-list) | |
7238 (while in-list | |
7239 (if (equal (verilog-sig-enum (car in-list)) enum) | |
7240 (setq out-list (cons (car in-list) out-list))) | |
7241 (setq in-list (cdr in-list))) | |
7242 ;; New scheme | |
7243 (let* ((enumvar (intern (concat "venum-" enum))) | |
7244 (enumlist (and (boundp enumvar) (eval enumvar)))) | |
7245 (while enumlist | |
7246 (add-to-list 'out-list (list (car enumlist))) | |
7247 (setq enumlist (cdr enumlist)))) | |
7248 (nreverse out-list))) | |
7249 | |
7250 (defun verilog-signals-not-matching-regexp (in-list regexp) | |
7251 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." | |
7252 (if (not regexp) | |
7253 in-list | |
7254 (let (out-list) | |
7255 (while in-list | |
7256 (if (not (string-match regexp (verilog-sig-name (car in-list)))) | |
7257 (setq out-list (cons (car in-list) out-list))) | |
7258 (setq in-list (cdr in-list))) | |
7259 (nreverse out-list)))) | |
7260 | |
7261 ;; Combined | |
7262 (defun verilog-modi-get-signals (modi) | |
7263 (append | |
7264 (verilog-modi-get-outputs modi) | |
7265 (verilog-modi-get-inouts modi) | |
7266 (verilog-modi-get-inputs modi) | |
7267 (verilog-modi-get-wires modi) | |
7268 (verilog-modi-get-regs modi) | |
7269 (verilog-modi-get-assigns modi) | |
7270 (verilog-modi-get-consts modi) | |
7271 (verilog-modi-get-gparams modi))) | |
7272 | |
7273 (defun verilog-modi-get-ports (modi) | |
7274 (append | |
7275 (verilog-modi-get-outputs modi) | |
7276 (verilog-modi-get-inouts modi) | |
7277 (verilog-modi-get-inputs modi))) | |
7278 | |
7279 (defsubst verilog-modi-cache-add-outputs (modi sig-list) | |
7280 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list)) | |
7281 (defsubst verilog-modi-cache-add-inouts (modi sig-list) | |
7282 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list)) | |
7283 (defsubst verilog-modi-cache-add-inputs (modi sig-list) | |
7284 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) | |
7285 (defsubst verilog-modi-cache-add-wires (modi sig-list) | |
7286 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) | |
7287 (defsubst verilog-modi-cache-add-regs (modi sig-list) | |
7288 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list)) | |
7289 | |
7290 (defun verilog-signals-from-signame (signame-list) | |
7291 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names." | |
7292 (mapcar (function (lambda (name) (list name nil nil))) | |
7293 signame-list)) | |
7294 | |
7295 ;; | |
7296 ;; Auto creation utilities | |
7297 ;; | |
7298 | |
7299 (defun verilog-auto-search-do (search-for func) | |
7300 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs." | |
7301 (goto-char (point-min)) | |
7302 (while (search-forward search-for nil t) | |
7303 (if (not (save-excursion | |
7304 (goto-char (match-beginning 0)) | |
7305 (verilog-inside-comment-p))) | |
7306 (funcall func)))) | |
7307 | |
7308 (defun verilog-auto-re-search-do (search-for func) | |
7309 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs." | |
7310 (goto-char (point-min)) | |
7311 (while (re-search-forward search-for nil t) | |
7312 (if (not (save-excursion | |
7313 (goto-char (match-beginning 0)) | |
7314 (verilog-inside-comment-p))) | |
7315 (funcall func)))) | |
7316 | |
7317 (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
|
7318 "Print out a definition for SIG of the given TYPE, |
79545 | 7319 with appropriate INDENT-PT indentation." |
7320 (indent-to indent-pt) | |
7321 (insert type) | |
7322 (when (verilog-sig-signed sig) | |
7323 (insert " " (verilog-sig-signed sig))) | |
7324 (when (verilog-sig-multidim sig) | |
7325 (insert " " (verilog-sig-multidim-string sig))) | |
7326 (when (verilog-sig-bits sig) | |
7327 (insert " " (verilog-sig-bits sig))) | |
7328 (indent-to (max 24 (+ indent-pt 16))) | |
7329 (unless (= (char-syntax (preceding-char)) ?\ ) | |
7330 (insert " ")) ; Need space between "]name" if indent-to did nothing | |
7331 (insert (verilog-sig-name sig))) | |
7332 | |
7333 (defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort) | |
7334 "Print out a definition for a list of SIGS of the given DIRECTION, | |
7335 with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O | |
7336 format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output." | |
7337 (or dont-sort | |
7338 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) | |
7339 (while sigs | |
7340 (let ((sig (car sigs))) | |
7341 (verilog-insert-one-definition | |
7342 sig | |
7343 ;; Want "type x" or "output type x", not "wire type x" | |
7344 (cond ((verilog-sig-type sig) | |
7345 (concat | |
7346 (if (not (equal direction "wire")) | |
7347 (concat direction " ")) | |
7348 (verilog-sig-type sig))) | |
7349 (t direction)) | |
7350 indent-pt) | |
7351 (insert (if v2k "," ";")) | |
7352 (if (or (not (verilog-sig-comment sig)) | |
7353 (equal "" (verilog-sig-comment sig))) | |
7354 (insert "\n") | |
7355 (indent-to (max 48 (+ indent-pt 40))) | |
7356 (insert (concat "// " (verilog-sig-comment sig) "\n"))) | |
7357 (setq sigs (cdr sigs))))) | |
7358 | |
7359 (eval-when-compile | |
7360 (if (not (boundp 'indent-pt)) | |
7361 (defvar indent-pt nil "Local used by insert-indent"))) | |
7362 | |
7363 (defun verilog-insert-indent (&rest stuff) | |
7364 "Indent to position stored in local `indent-pt' variable, then insert STUFF. | |
7365 Presumes that any newlines end a list element." | |
7366 (let ((need-indent t)) | |
7367 (while stuff | |
7368 (if need-indent (indent-to indent-pt)) | |
7369 (setq need-indent nil) | |
7370 (insert (car stuff)) | |
7371 (setq need-indent (string-match "\n$" (car stuff)) | |
7372 stuff (cdr stuff))))) | |
7373 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n")) | |
7374 | |
7375 (defun verilog-repair-open-comma () | |
7376 "If backwards-from-point is other than a open parenthesis insert comma." | |
7377 (save-excursion | |
7378 (verilog-backward-syntactic-ws) | |
7379 (when (save-excursion | |
7380 (backward-char 1) | |
7381 (and (not (looking-at "[(,]")) | |
7382 (progn | |
7383 (verilog-re-search-backward "[(`]" nil t) | |
7384 (looking-at "(")))) | |
7385 (insert ",")))) | |
7386 | |
7387 (defun verilog-repair-close-comma () | |
7388 "If point is at a comma followed by a close parenthesis, fix it. | |
7389 This repairs those mis-inserted by a AUTOARG." | |
7390 ;; It would be much nicer if Verilog allowed extra commas like Perl does! | |
7391 (save-excursion | |
7392 (verilog-forward-close-paren) | |
7393 (backward-char 1) | |
7394 (verilog-backward-syntactic-ws) | |
7395 (backward-char 1) | |
7396 (when (looking-at ",") | |
7397 (delete-char 1)))) | |
7398 | |
7399 (defun verilog-get-list (start end) | |
7400 "Return the elements of a comma separated list between START and END." | |
7401 (interactive) | |
7402 (let ((my-list (list)) | |
7403 my-string) | |
7404 (save-excursion | |
7405 (while (< (point) end) | |
7406 (when (re-search-forward "\\([^,{]+\\)" end t) | |
7407 (setq my-string (verilog-string-remove-spaces (match-string 1))) | |
7408 (setq my-list (nconc my-list (list my-string) )) | |
7409 (goto-char (match-end 0)))) | |
7410 my-list))) | |
7411 | |
7412 (defun verilog-make-width-expression (range-exp) | |
7413 "Return an expression calculating the length of a range [x:y] in RANGE-EXP." | |
7414 ;; strip off the [] | |
7415 (cond ((not range-exp) | |
7416 "1") | |
7417 (t | |
7418 (if (string-match "^\\[\\(.*\\)\\]$" range-exp) | |
7419 (setq range-exp (match-string 1 range-exp))) | |
7420 (cond ((not range-exp) | |
7421 "1") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7422 ((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
|
7423 range-exp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7424 (int-to-string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7425 (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
|
7426 (string-to-number (match-string 2 range-exp))))))) |
79545 | 7427 ((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
|
7428 (concat "(1+(" (match-string 1 range-exp) ")" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7429 (if (equal "0" (match-string 2 range-exp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7430 "" ;; Don't bother with -(0) |
79545 | 7431 (concat "-(" (match-string 2 range-exp) ")")) |
7432 ")")) | |
7433 (t nil))))) | |
7434 ;;(verilog-make-width-expression "`A:`B") | |
7435 | |
7436 (defun verilog-typedef-name-p (variable-name) | |
7437 "Return true if the VARIABLE-NAME is a type definition." | |
7438 (when verilog-typedef-regexp | |
7439 (string-match verilog-typedef-regexp variable-name))) | |
7440 | |
7441 ;; | |
7442 ;; Auto deletion | |
7443 ;; | |
7444 | |
7445 (defun verilog-delete-autos-lined () | |
7446 "Delete autos that occupy multiple lines, between begin and end comments." | |
7447 (let ((pt (point))) | |
7448 (forward-line 1) | |
7449 (when (and | |
7450 (looking-at "\\s-*// Beginning") | |
7451 (search-forward "// End of automatic" nil t)) | |
7452 ;; End exists | |
7453 (end-of-line) | |
7454 (delete-region pt (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7455 (forward-line 1)))) |
79545 | 7456 |
7457 (defun verilog-forward-close-paren () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7458 "Find the close parenthesis that match the current point. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7459 Ignore other close parenthesis with matching open parens." |
79545 | 7460 (let ((parens 1)) |
7461 (while (> parens 0) | |
7462 (unless (verilog-re-search-forward-quick "[()]" nil t) | |
7463 (error "%s: Mismatching ()" (verilog-point-text))) | |
7464 (cond ((= (preceding-char) ?\( ) | |
7465 (setq parens (1+ parens))) | |
7466 ((= (preceding-char) ?\) ) | |
7467 (setq parens (1- parens))))))) | |
7468 | |
7469 (defun verilog-backward-open-paren () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7470 "Find the open parenthesis that match the current point. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7471 Ignore other open parenthesis with matching close parens." |
79545 | 7472 (let ((parens 1)) |
7473 (while (> parens 0) | |
7474 (unless (verilog-re-search-backward-quick "[()]" nil t) | |
7475 (error "%s: Mismatching ()" (verilog-point-text))) | |
7476 (cond ((= (following-char) ?\) ) | |
7477 (setq parens (1+ parens))) | |
7478 ((= (following-char) ?\( ) | |
7479 (setq parens (1- parens))))))) | |
7480 | |
7481 (defun verilog-backward-open-bracket () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7482 "Find the open bracket that match the current point. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7483 Ignore other open bracket with matching close bracket." |
79545 | 7484 (let ((parens 1)) |
7485 (while (> parens 0) | |
7486 (unless (verilog-re-search-backward-quick "[][]" nil t) | |
7487 (error "%s: Mismatching []" (verilog-point-text))) | |
7488 (cond ((= (following-char) ?\] ) | |
7489 (setq parens (1+ parens))) | |
7490 ((= (following-char) ?\[ ) | |
7491 (setq parens (1- parens))))))) | |
7492 | |
7493 (defun verilog-delete-to-paren () | |
7494 "Delete the automatic inst/sense/arg created by autos. | |
7495 Deletion stops at the matching end parenthesis." | |
7496 (delete-region (point) | |
7497 (save-excursion | |
7498 (verilog-backward-open-paren) | |
7499 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
7500 (backward-char 1) | |
7501 (point)))) | |
7502 | |
7503 (defun verilog-auto-star-safe () | |
7504 "Return if a .* AUTOINST is safe to delete or expand. | |
7505 It was created by the AUTOS themselves, or by the user." | |
7506 (and verilog-auto-star-expand | |
7507 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\)\\)"))) | |
7508 | |
7509 (defun verilog-delete-auto-star-all () | |
7510 "Delete a .* AUTOINST, if it is safe." | |
7511 (when (verilog-auto-star-safe) | |
7512 (verilog-delete-to-paren))) | |
7513 | |
7514 (defun verilog-delete-auto-star-implicit () | |
7515 "Delete all .* implicit connections created by `verilog-auto-star'. | |
7516 This function will be called automatically at save unless | |
7517 `verilog-auto-star-save' is set, any non-templated expanded pins will be | |
7518 removed." | |
7519 (interactive) | |
7520 (let (paren-pt indent have-close-paren) | |
7521 (save-excursion | |
7522 (goto-char (point-min)) | |
7523 ;; We need to match these even outside of comments. | |
7524 ;; For reasonable performance, we don't check if inside comments, sorry. | |
7525 (while (re-search-forward "// Implicit \\.\\*" nil t) | |
7526 (setq paren-pt (point)) | |
7527 (beginning-of-line) | |
7528 (setq have-close-paren | |
7529 (save-excursion | |
7530 (when (search-forward ");" paren-pt t) | |
7531 (setq indent (current-indentation)) | |
7532 t))) | |
7533 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR | |
7534 (when have-close-paren | |
7535 ;; Delete extra commentary | |
7536 (save-excursion | |
7537 (while (progn | |
7538 (forward-line -1) | |
7539 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\)\n")) | |
7540 (delete-region (match-beginning 0) (match-end 0)))) | |
7541 ;; If it is simple, we can put the ); on the same line as the last text | |
7542 (let ((rtn-pt (point))) | |
7543 (save-excursion | |
7544 (while (progn (backward-char 1) | |
7545 (looking-at "[ \t\n\f]"))) | |
7546 (when (looking-at ",") | |
7547 (delete-region (+ 1 (point)) rtn-pt)))) | |
7548 (when (bolp) | |
7549 (indent-to indent)) | |
7550 (insert ");\n") | |
7551 ;; Still need to kill final comma - always is one as we put one after the .* | |
7552 (re-search-backward ",") | |
7553 (delete-char 1)))))) | |
7554 | |
7555 (defun verilog-delete-auto () | |
7556 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto]. | |
7557 Use \\[verilog-auto] to re-insert the updated AUTOs. | |
7558 | |
7559 The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are | |
7560 called before and after this function, respectively." | |
7561 (interactive) | |
7562 (save-excursion | |
7563 (if (buffer-file-name) | |
7564 (find-file-noselect (buffer-file-name))) ;; To check we have latest version | |
7565 ;; Allow user to customize | |
7566 (run-hooks 'verilog-before-delete-auto-hook) | |
7567 | |
7568 ;; Remove those that have multi-line insertions | |
7569 (verilog-auto-re-search-do "/\\*AUTO\\(OUTPUTEVERY\\|CONCATCOMMENT\\|WIRE\\|REG\\|DEFINEVALUE\\|REGINPUT\\|INPUT\\|OUTPUT\\|INOUT\\|RESET\\|TIEOFF\\|UNUSED\\)\\*/" | |
7570 'verilog-delete-autos-lined) | |
7571 ;; Remove those that have multi-line insertions with parameters | |
7572 (verilog-auto-re-search-do "/\\*AUTO\\(INOUTMODULE\\|ASCIIENUM\\)([^)]*)\\*/" | |
7573 'verilog-delete-autos-lined) | |
7574 ;; Remove those that are in parenthesis | |
7575 (verilog-auto-re-search-do "/\\*\\(AS\\|AUTO\\(ARG\\|CONCATWIDTH\\|INST\\|INSTPARAM\\|SENSE\\)\\)\\*/" | |
7576 'verilog-delete-to-paren) | |
7577 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments | |
7578 (verilog-auto-re-search-do "\\.\\*" | |
7579 'verilog-delete-auto-star-all) | |
7580 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed | |
7581 (goto-char (point-min)) | |
7582 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t) | |
7583 (replace-match "")) | |
7584 | |
7585 ;; Final customize | |
7586 (run-hooks 'verilog-delete-auto-hook))) | |
7587 | |
7588 ;; | |
7589 ;; Auto inject | |
7590 ;; | |
7591 | |
7592 (defun verilog-inject-auto () | |
7593 "Examine legacy non-AUTO code and insert AUTOs in appropriate places. | |
7594 | |
7595 Any always @ blocks with sensitivity lists that match computed lists will | |
7596 be replaced with /*AS*/ comments. | |
7597 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7598 Any cells will get /*AUTOINST*/ added to the end of the pin list. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7599 Pins with have identical names will be deleted. |
79545 | 7600 |
7601 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to | |
7602 support adding new ports. You may wish to delete older ports yourself. | |
7603 | |
7604 For example: | |
7605 | |
7606 module ex_inject (i, o); | |
7607 input i; | |
7608 input j; | |
7609 output o; | |
7610 always @ (i or j) | |
7611 o = i | j; | |
7612 cell cell (.foobar(baz), | |
7613 .j(j)); | |
7614 endmodule | |
7615 | |
7616 Typing \\[verilog-inject-auto] will make this into: | |
7617 | |
7618 module ex_inject (i, o/*AUTOARG*/ | |
7619 // Inputs | |
7620 j); | |
7621 input i; | |
7622 output o; | |
7623 always @ (/*AS*/i or j) | |
7624 o = i | j; | |
7625 cell cell (.foobar(baz), | |
7626 /*AUTOINST*/ | |
7627 // Outputs | |
7628 .j(j)); | |
7629 endmodule" | |
7630 (interactive) | |
7631 (verilog-auto t)) | |
7632 | |
7633 (defun verilog-inject-arg () | |
7634 "Inject AUTOARG into new code. See `verilog-inject-auto'." | |
7635 ;; Presume one module per file. | |
7636 (save-excursion | |
7637 (goto-char (point-min)) | |
7638 (while (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
7639 (let ((endmodp (save-excursion | |
7640 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t) | |
7641 (point)))) | |
7642 ;; See if there's already a comment .. inside a comment so not verilog-re-search | |
7643 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t)) | |
7644 (verilog-re-search-forward-quick ";" nil t) | |
7645 (backward-char 1) | |
7646 (verilog-backward-syntactic-ws) | |
7647 (backward-char 1) ; Moves to paren that closes argdecl's | |
7648 (when (looking-at ")") | |
7649 (insert "/*AUTOARG*/"))))))) | |
7650 | |
7651 (defun verilog-inject-sense () | |
7652 "Inject AUTOSENSE into new code. See `verilog-inject-auto'." | |
7653 (save-excursion | |
7654 (goto-char (point-min)) | |
7655 (while (verilog-re-search-forward-quick "\\<always\\s *@\\s *(" nil t) | |
7656 (let ((start-pt (point)) | |
7657 (modi (verilog-modi-current)) | |
7658 pre-sigs | |
7659 got-sigs) | |
7660 (backward-char 1) | |
7661 (forward-sexp 1) | |
7662 (backward-char 1) ;; End ) | |
7663 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) | |
7664 (setq pre-sigs (verilog-signals-from-signame | |
7665 (verilog-read-signals start-pt (point))) | |
7666 got-sigs (verilog-auto-sense-sigs modi nil)) | |
7667 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal? | |
7668 (verilog-signals-not-in got-sigs pre-sigs))) | |
7669 (delete-region start-pt (point)) | |
7670 (insert "/*AS*/"))))))) | |
7671 | |
7672 (defun verilog-inject-inst () | |
7673 "Inject AUTOINST into new code. See `verilog-inject-auto'." | |
7674 (save-excursion | |
7675 (goto-char (point-min)) | |
7676 ;; It's hard to distinguish modules; we'll instead search for pins. | |
7677 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) | |
7678 (verilog-backward-open-paren) ;; Inst start | |
7679 (cond | |
7680 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip. | |
7681 (forward-char 1) | |
7682 (verilog-forward-close-paren)) ;; Parameters done | |
7683 (t | |
7684 (forward-char 1) | |
7685 (let ((indent-pt (+ (current-column))) | |
7686 (end-pt (save-excursion (verilog-forward-close-paren) (point)))) | |
7687 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) | |
7688 (goto-char end-pt)) ;; Already there, continue search with next instance | |
7689 (t | |
7690 ;; Delete identical interconnect | |
7691 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc | |
7692 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) | |
7693 (delete-region (match-beginning 0) (match-end 0)) | |
7694 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct | |
7695 (while (or (looking-at "[ \t\n\f,]+") | |
7696 (looking-at "//[^\n]*")) | |
7697 (delete-region (match-beginning 0) (match-end 0)) | |
7698 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0))))))) | |
7699 (verilog-forward-close-paren) | |
7700 (backward-char 1) | |
7701 ;; Not verilog-re-search, as we don't want to strip comments | |
7702 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t) | |
7703 (delete-region (match-beginning 0) (match-end 0))) | |
7704 (insert "\n") | |
7705 (indent-to indent-pt) | |
7706 (insert "/*AUTOINST*/"))))))))) | |
7707 | |
7708 ;; | |
7709 ;; Auto save | |
7710 ;; | |
7711 | |
7712 (defun verilog-auto-save-check () | |
7713 "On saving see if we need auto update." | |
7714 (cond ((not verilog-auto-save-policy)) ; disabled | |
7715 ((not (save-excursion | |
7716 (save-match-data | |
7717 (let ((case-fold-search nil)) | |
7718 (goto-char (point-min)) | |
7719 (re-search-forward "AUTO" nil t)))))) | |
7720 ((eq verilog-auto-save-policy 'force) | |
7721 (verilog-auto)) | |
7722 ((not (buffer-modified-p))) | |
7723 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date | |
7724 ((eq verilog-auto-save-policy 'detect) | |
7725 (verilog-auto)) | |
7726 (t | |
7727 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | |
7728 (verilog-auto)) | |
7729 ;; Don't ask again if didn't update | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7730 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
79545 | 7731 (when (not verilog-auto-star-save) |
7732 (verilog-delete-auto-star-implicit)) | |
7733 nil) ;; Always return nil -- we don't write the file ourselves | |
7734 | |
7735 (defun verilog-auto-read-locals () | |
7736 "Return file local variable segment at bottom of file." | |
7737 (save-excursion | |
7738 (goto-char (point-max)) | |
7739 (if (re-search-backward "Local Variables:" nil t) | |
7740 (buffer-substring-no-properties (point) (point-max)) | |
7741 ""))) | |
7742 | |
7743 (defun verilog-auto-reeval-locals (&optional force) | |
7744 "Read file local variable segment at bottom of file if it has changed. | |
7745 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
|
7746 (make-local-variable 'verilog-auto-last-file-locals) |
79545 | 7747 (let ((curlocal (verilog-auto-read-locals))) |
7748 (when (or force (not (equal verilog-auto-last-file-locals curlocal))) | |
7749 (setq verilog-auto-last-file-locals curlocal) | |
7750 ;; Note this may cause this function to be recursively invoked. | |
7751 ;; The above when statement will prevent it from recursing forever. | |
7752 (hack-local-variables) | |
7753 t))) | |
7754 | |
7755 ;; | |
7756 ;; Auto creation | |
7757 ;; | |
7758 | |
7759 (defun verilog-auto-arg-ports (sigs message indent-pt) | |
7760 "Print a list of ports for a AUTOINST. | |
7761 Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT." | |
7762 (when sigs | |
7763 (insert "\n") | |
7764 (indent-to indent-pt) | |
7765 (insert message) | |
7766 (insert "\n") | |
7767 (let ((space "")) | |
7768 (indent-to indent-pt) | |
7769 (while sigs | |
7770 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column) | |
7771 (insert "\n") | |
7772 (indent-to indent-pt)) | |
7773 (t (insert space))) | |
7774 (insert (verilog-sig-name (car sigs)) ",") | |
7775 (setq sigs (cdr sigs) | |
7776 space " "))))) | |
7777 | |
7778 (defun verilog-auto-arg () | |
7779 "Expand AUTOARG statements. | |
7780 Replace the argument declarations at the beginning of the | |
7781 module with ones automatically derived from input and output | |
7782 statements. This can be dangerous if the module is instantiated | |
7783 using position-based connections, so use only name-based when | |
7784 instantiating the resulting module. Long lines are split based | |
7785 on the `fill-column', see \\[set-fill-column]. | |
7786 | |
7787 Limitations: | |
7788 Concatenation and outputting partial busses is not supported. | |
7789 | |
7790 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
7791 | |
7792 For example: | |
7793 | |
7794 module ex_arg (/*AUTOARG*/); | |
7795 input i; | |
7796 output o; | |
7797 endmodule | |
7798 | |
7799 Typing \\[verilog-auto] will make this into: | |
7800 | |
7801 module ex_arg (/*AUTOARG*/ | |
7802 // Outputs | |
7803 o, | |
7804 // Inputs | |
7805 i | |
7806 ); | |
7807 input i; | |
7808 output o; | |
7809 endmodule | |
7810 | |
7811 Any ports declared between the ( and /*AUTOARG*/ are presumed to be | |
7812 predeclared and are not redeclared by AUTOARG. AUTOARG will make a | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7813 conservative guess on adding a comma for the first signal, if you have |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7814 any ifdefs or complicated expressions before the AUTOARG you will need |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7815 to choose the comma yourself. |
79545 | 7816 |
7817 Avoid declaring ports manually, as it makes code harder to maintain." | |
7818 (save-excursion | |
7819 (let ((modi (verilog-modi-current)) | |
7820 (skip-pins (aref (verilog-read-arg-pins) 0))) | |
7821 (verilog-repair-open-comma) | |
7822 (verilog-auto-arg-ports (verilog-signals-not-in | |
7823 (verilog-modi-get-outputs modi) | |
7824 skip-pins) | |
7825 "// Outputs" | |
7826 verilog-indent-level-declaration) | |
7827 (verilog-auto-arg-ports (verilog-signals-not-in | |
7828 (verilog-modi-get-inouts modi) | |
7829 skip-pins) | |
7830 "// Inouts" | |
7831 verilog-indent-level-declaration) | |
7832 (verilog-auto-arg-ports (verilog-signals-not-in | |
7833 (verilog-modi-get-inputs modi) | |
7834 skip-pins) | |
7835 "// Inputs" | |
7836 verilog-indent-level-declaration) | |
7837 (verilog-repair-close-comma) | |
7838 (unless (eq (char-before) ?/ ) | |
7839 (insert "\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7840 (indent-to verilog-indent-level-declaration)))) |
79545 | 7841 |
7842 (defun verilog-auto-inst-port-map (port-st) | |
7843 nil) | |
7844 | |
7845 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7846 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7847 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7848 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7849 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
7850 | |
7851 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) | |
7852 "Print out a instantiation connection for this PORT-ST. | |
7853 Insert to INDENT-PT, use template TPL-LIST. | |
7854 @ are instantiation numbers, replaced with TPL-NUM. | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7855 @\"(expression @)\" are evaluated, with @ as a variable. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7856 If FOR-STAR add comment it is a .* expansion." |
79545 | 7857 (let* ((port (verilog-sig-name port-st)) |
7858 (tpl-ass (or (assoc port (car tpl-list)) | |
7859 (verilog-auto-inst-port-map port-st))) | |
7860 ;; vl-* are documented for user use | |
7861 (vl-name (verilog-sig-name port-st)) | |
7862 (vl-width (verilog-sig-width port-st)) | |
7863 (vl-bits (if (or verilog-auto-inst-vector | |
7864 (not (assoc port vector-skip-list)) | |
7865 (not (equal (verilog-sig-bits port-st) | |
7866 (verilog-sig-bits (assoc port vector-skip-list))))) | |
7867 (or (verilog-sig-bits port-st) "") | |
7868 "")) | |
7869 ;; Default if not found | |
7870 (tpl-net (if (verilog-sig-multidim port-st) | |
7871 (concat port "/*" (verilog-sig-multidim-string port-st) | |
7872 vl-bits "*/") | |
7873 (concat port vl-bits))) | |
7874 (case-fold-search nil)) | |
7875 ;; Find template | |
7876 (cond (tpl-ass ; Template of exact port name | |
7877 (setq tpl-net (nth 1 tpl-ass))) | |
7878 ((nth 1 tpl-list) ; Wildcards in template, search them | |
7879 (let ((wildcards (nth 1 tpl-list))) | |
7880 (while wildcards | |
7881 (when (string-match (nth 0 (car wildcards)) port) | |
7882 (setq tpl-ass (car wildcards) ; so allow @ parsing | |
7883 tpl-net (replace-match (nth 1 (car wildcards)) | |
7884 t nil port))) | |
7885 (setq wildcards (cdr wildcards)))))) | |
7886 ;; Parse Templated variable | |
7887 (when tpl-ass | |
7888 ;; Evaluate @"(lispcode)" | |
7889 (when (string-match "@\".*[^\\]\"" tpl-net) | |
7890 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net) | |
7891 (setq tpl-net | |
7892 (concat | |
7893 (substring tpl-net 0 (match-beginning 0)) | |
7894 (save-match-data | |
7895 (let* ((expr (match-string 1 tpl-net)) | |
7896 (value | |
7897 (progn | |
7898 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | |
7899 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | |
7900 (prin1 (eval (car (read-from-string expr))) | |
7901 (lambda (ch) ()))))) | |
7902 (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
|
7903 value)) |
79545 | 7904 (substring tpl-net (match-end 0)))))) |
7905 ;; Replace @ and [] magic variables in final output | |
7906 (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
|
7907 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
79545 | 7908 (indent-to indent-pt) |
7909 (insert "." port) | |
7910 (indent-to verilog-auto-inst-column) | |
7911 (insert "(" tpl-net "),") | |
7912 (cond (tpl-ass | |
7913 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
7914 verilog-auto-inst-column)) | |
7915 (insert " // Templated") | |
7916 (when verilog-auto-inst-template-numbers | |
7917 (insert " T" (int-to-string (nth 2 tpl-ass)) | |
7918 " L" (int-to-string (nth 3 tpl-ass))))) | |
7919 (for-star | |
7920 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
7921 verilog-auto-inst-column)) | |
7922 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped... | |
7923 (insert "\n"))) | |
7924 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") | |
7925 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]") | |
7926 ;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));") | |
7927 | |
7928 (defun verilog-auto-inst-first () | |
7929 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]." | |
7930 ;; Do we need a trailing comma? | |
7931 ;; There maybe a ifdef or something similar before us. What a mess. Thus | |
7932 ;; to avoid trouble we only insert on preceeding ) or *. | |
7933 ;; Insert first port on new line | |
7934 (insert "\n") ;; Must insert before search, so point will move forward if insert comma | |
7935 (save-excursion | |
7936 (verilog-re-search-backward "[^ \t\n\f]" nil nil) | |
7937 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure | |
7938 (forward-char 1) | |
7939 (insert ",")))) | |
7940 | |
7941 (defun verilog-auto-star () | |
7942 "Expand SystemVerilog .* pins, as part of \\[verilog-auto]. | |
7943 | |
7944 If `verilog-auto-star-expand' is set, .* pins are treated if they were | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7945 AUTOINST statements, otherwise they are ignored. For safety, Verilog mode |
79545 | 7946 will also ignore any .* that are not last in your pin list (this prevents |
7947 it from deleting pins following the .* when it expands the AUTOINST.) | |
7948 | |
7949 On writing your file, unless `verilog-auto-star-save' is set, any | |
7950 non-templated expanded pins will be removed. You may do this at any time | |
7951 with \\[verilog-delete-auto-star-implicit]. | |
7952 | |
7953 If you are converting a module to use .* for the first time, you may wish | |
7954 to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*. | |
7955 | |
7956 See `verilog-auto-inst' for examples, templates, and more information." | |
7957 (when (verilog-auto-star-safe) | |
7958 (verilog-auto-inst))) | |
7959 | |
7960 (defun verilog-auto-inst () | |
7961 "Expand AUTOINST statements, as part of \\[verilog-auto]. | |
7962 Replace the pin connections to an instantiation with ones | |
7963 automatically derived from the module header of the instantiated netlist. | |
7964 | |
7965 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports, | |
7966 and delete them before saving unless `verilog-auto-star-save' is set. | |
7967 See `verilog-auto-star' for more information. | |
7968 | |
7969 Limitations: | |
7970 Module names must be resolvable to filenames by adding a | |
7971 `verilog-library-extensions', and being found in the same directory, or | |
7972 by changing the variable `verilog-library-flags' or | |
7973 `verilog-library-directories'. Macros `modname are translated through the | |
7974 vh-{name} Emacs variable, if that is not found, it just ignores the `. | |
7975 | |
7976 In templates you must have one signal per line, ending in a ), or ));, | |
7977 and have proper () nesting, including a final ); to end the template. | |
7978 | |
7979 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
7980 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7981 SystemVerilog multidimensional input/output has only experimental support. |
79545 | 7982 |
7983 For example, first take the submodule inst.v: | |
7984 | |
7985 module inst (o,i) | |
7986 output [31:0] o; | |
7987 input i; | |
7988 wire [31:0] o = {32{i}}; | |
7989 endmodule | |
7990 | |
7991 This is then used in a upper level module: | |
7992 | |
7993 module ex_inst (o,i) | |
7994 output o; | |
7995 input i; | |
7996 inst inst (/*AUTOINST*/); | |
7997 endmodule | |
7998 | |
7999 Typing \\[verilog-auto] will make this into: | |
8000 | |
8001 module ex_inst (o,i) | |
8002 output o; | |
8003 input i; | |
8004 inst inst (/*AUTOINST*/ | |
8005 // Outputs | |
8006 .ov (ov[31:0]), | |
8007 // Inputs | |
8008 .i (i)); | |
8009 endmodule | |
8010 | |
8011 Where the list of inputs and outputs came from the inst module. | |
8012 | |
8013 Exceptions: | |
8014 | |
8015 Unless you are instantiating a module multiple times, or the module is | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8016 something trivial like an adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY. |
79545 | 8017 It just makes for unmaintainable code. To sanitize signal names, try |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8018 vrename from http://www.veripool.com. |
79545 | 8019 |
8020 When you need to violate this suggestion there are two ways to list | |
8021 exceptions, placing them before the AUTOINST, or using templates. | |
8022 | |
8023 Any ports defined before the /*AUTOINST*/ are not included in the list of | |
8024 automatics. This is similar to making a template as described below, but | |
8025 is restricted to simple connections just like you normally make. Also note | |
8026 that any signals before the AUTOINST will only be picked up by AUTOWIRE if | |
8027 you have the appropriate // Input or // Output comment, and exactly the | |
8028 same line formatting as AUTOINST itself uses. | |
8029 | |
8030 inst inst (// Inputs | |
8031 .i (my_i_dont_mess_with_it), | |
8032 /*AUTOINST*/ | |
8033 // Outputs | |
8034 .ov (ov[31:0])); | |
8035 | |
8036 | |
8037 Templates: | |
8038 | |
8039 For multiple instantiations based upon a single template, create a | |
8040 commented out template: | |
8041 | |
8042 /* instantiating_module_name AUTO_TEMPLATE ( | |
8043 .sig3 (sigz[]), | |
8044 ); | |
8045 */ | |
8046 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8047 Templates go ABOVE the instantiation(s). When an instantiation is |
79545 | 8048 expanded `verilog-mode' simply searches up for the closest template. |
8049 Thus you can have multiple templates for the same module, just alternate | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8050 between the template for an instantiation and the instantiation itself. |
79545 | 8051 |
8052 The module name must be the same as the name of the module in the | |
8053 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact | |
8054 words and capitalized. Only signals that must be different for each | |
8055 instantiation need to be listed. | |
8056 | |
8057 Inside a template, a [] in a connection name (with nothing else inside | |
8058 the brackets) will be replaced by the same bus subscript as it is being | |
8059 connected to, or the [] will be removed if it is a single bit signal. | |
8060 Generally it is a good idea to do this for all connections in a template, | |
8061 as then they will work for any width signal, and with AUTOWIRE. See | |
8062 PTL_BUS becoming PTL_BUSNEW below. | |
8063 | |
8064 If you have a complicated template, set `verilog-auto-inst-template-numbers' | |
8065 to see which regexps are matching. Don't leave that mode set after | |
8066 debugging is completed though, it will result in lots of extra differences | |
8067 and merge conflicts. | |
8068 | |
8069 For example: | |
8070 | |
8071 /* psm_mas AUTO_TEMPLATE ( | |
8072 .ptl_bus (ptl_busnew[]), | |
8073 ); | |
8074 */ | |
8075 psm_mas ms2m (/*AUTOINST*/); | |
8076 | |
8077 Typing \\[verilog-auto] will make this into: | |
8078 | |
8079 psm_mas ms2m (/*AUTOINST*/ | |
8080 // Outputs | |
8081 .NotInTemplate (NotInTemplate), | |
8082 .ptl_bus (ptl_busnew[3:0]), // Templated | |
8083 .... | |
8084 | |
8085 @ Templates: | |
8086 | |
8087 It is common to instantiate a cell multiple times, so templates make it | |
8088 trivial to substitute part of the cell name into the connection name. | |
8089 | |
8090 /* cell_type AUTO_TEMPLATE <optional \"REGEXP\"> ( | |
8091 .sig1 (sigx[@]), | |
8092 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), | |
8093 ); | |
8094 */ | |
8095 | |
8096 If no regular expression is provided immediately after the AUTO_TEMPLATE | |
8097 keyword, then the @ character in any connection names will be replaced | |
8098 with the instantiation number; the first digits found in the cell's | |
8099 instantiation name. | |
8100 | |
8101 If a regular expression is provided, the @ character will be replaced | |
8102 with the first \(\) grouping that matches against the cell name. Using a | |
8103 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no | |
8104 regexp is provided. If you use multiple layers of parenthesis, | |
8105 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number | |
8106 characters after test and before _, whereas | |
8107 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire | |
8108 match. | |
8109 | |
8110 For example: | |
8111 | |
8112 /* psm_mas AUTO_TEMPLATE ( | |
8113 .ptl_mapvalidx (ptl_mapvalid[@]), | |
8114 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), | |
8115 ); | |
8116 */ | |
8117 psm_mas ms2m (/*AUTOINST*/); | |
8118 | |
8119 Typing \\[verilog-auto] will make this into: | |
8120 | |
8121 psm_mas ms2m (/*AUTOINST*/ | |
8122 // Outputs | |
8123 .ptl_mapvalidx (ptl_mapvalid[2]), | |
8124 .ptl_mapvalidp1x (ptl_mapvalid[3])); | |
8125 | |
8126 Note the @ character was replaced with the 2 from \"ms2m\". | |
8127 | |
8128 Alternatively, using a regular expression for @: | |
8129 | |
8130 /* psm_mas AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( | |
8131 .ptl_mapvalidx (@_ptl_mapvalid), | |
8132 .ptl_mapvalidp1x (ptl_mapvalid_@), | |
8133 ); | |
8134 */ | |
8135 psm_mas ms2_FOO (/*AUTOINST*/); | |
8136 psm_mas ms2_BAR (/*AUTOINST*/); | |
8137 | |
8138 Typing \\[verilog-auto] will make this into: | |
8139 | |
8140 psm_mas ms2_FOO (/*AUTOINST*/ | |
8141 // Outputs | |
8142 .ptl_mapvalidx (FOO_ptl_mapvalid), | |
8143 .ptl_mapvalidp1x (ptl_mapvalid_FOO)); | |
8144 psm_mas ms2_BAR (/*AUTOINST*/ | |
8145 // Outputs | |
8146 .ptl_mapvalidx (BAR_ptl_mapvalid), | |
8147 .ptl_mapvalidp1x (ptl_mapvalid_BAR)); | |
8148 | |
8149 | |
8150 Regexp Templates: | |
8151 | |
8152 A template entry of the form | |
8153 | |
8154 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]), | |
8155 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8156 will apply an Emacs style regular expression search for any port beginning |
79545 | 8157 in pci_req followed by numbers and ending in _l and connecting that to |
8158 the pci_req_jtag_[] net, with the bus subscript coming from what matches | |
8159 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2]. | |
8160 | |
8161 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name | |
8162 does the same thing. (Note a @ in the connection/replacement text is | |
8163 completely different -- still use \\1 there!) Thus this is the same as | |
8164 the above template: | |
8165 | |
8166 .pci_req@_l (pci_req_jtag_[\\1]), | |
8167 | |
8168 Here's another example to remove the _l, useful when naming conventions | |
8169 specify _ alone to mean active low. Note the use of [] to keep the bus | |
8170 subscript: | |
8171 | |
8172 .\\(.*\\)_l (\\1_[]), | |
8173 | |
8174 Lisp Templates: | |
8175 | |
8176 First any regular expression template is expanded. | |
8177 | |
8178 If the syntax @\"( ... )\" is found in a connection, the expression in | |
8179 quotes will be evaluated as a Lisp expression, with @ replaced by the | |
8180 instantiation number. The MAPVALIDP1X example above would put @+1 modulo | |
8181 4 into the brackets. Quote all double-quotes inside the expression with | |
8182 a leading backslash (\\\"). There are special variables defined that are | |
8183 useful in these Lisp functions: | |
8184 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8185 vl-name Name portion of the input/output port. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8186 vl-bits Bus bits portion of the input/output port ('[2:0]'). |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8187 vl-width Width of the input/output port ('3' for [2:0]). |
79545 | 8188 May be a (...) expression if bits isn't a constant. |
8189 vl-dir Direction of the pin input/output/inout. | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8190 vl-cell-type Module name/type of the cell ('psm_mas'). |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8191 vl-cell-name Instance name of the cell ('ms2m'). |
79545 | 8192 |
8193 Normal Lisp variables may be used in expressions. See | |
8194 `verilog-read-defines' which can set vh-{definename} variables for use | |
8195 here. Also, any comments of the form: | |
8196 | |
8197 /*AUTO_LISP(setq foo 1)*/ | |
8198 | |
8199 will evaluate any Lisp expression inside the parenthesis between the | |
8200 beginning of the buffer and the point of the AUTOINST. This allows | |
8201 functions to be defined or variables to be changed between instantiations. | |
8202 | |
8203 Note that when using lisp expressions errors may occur when @ is not a | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8204 number; you may need to use the standard Emacs Lisp functions |
79545 | 8205 `number-to-string' and `string-to-number'. |
8206 | |
8207 After the evaluation is completed, @ substitution and [] substitution | |
8208 occur." | |
8209 (save-excursion | |
8210 ;; Find beginning | |
8211 (let* ((pt (point)) | |
8212 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*"))) | |
8213 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8214 (1+ (current-column)))) | |
8215 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8216 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8217 (modi (verilog-modi-current)) | |
8218 (vector-skip-list (unless verilog-auto-inst-vector | |
8219 (verilog-modi-get-signals modi))) | |
8220 submod submodi inst skip-pins tpl-list tpl-num did-first) | |
8221 ;; Find module name that is instantiated | |
8222 (setq submod (verilog-read-inst-module) | |
8223 inst (verilog-read-inst-name) | |
8224 vl-cell-type submod | |
8225 vl-cell-name inst | |
8226 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8227 | |
8228 ;; Parse any AUTO_LISP() before here | |
8229 (verilog-read-auto-lisp (point-min) pt) | |
8230 | |
8231 ;; Lookup position, etc of submodule | |
8232 ;; Note this may raise an error | |
8233 (when (setq submodi (verilog-modi-lookup submod t)) | |
8234 ;; If there's a number in the instantiation, it may be a argument to the | |
8235 ;; automatic variable instantiation program. | |
8236 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8237 (tpl-regexp (aref tpl-info 0))) | |
8238 (setq tpl-num (if (string-match tpl-regexp inst) | |
8239 (match-string 1 inst) | |
8240 "") | |
8241 tpl-list (aref tpl-info 1))) | |
8242 ;; Find submodule's signals and dump | |
8243 (let ((sig-list (verilog-signals-not-in | |
8244 (verilog-modi-get-outputs submodi) | |
8245 skip-pins)) | |
8246 (vl-dir "output")) | |
8247 (when sig-list | |
8248 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8249 (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
|
8250 ;; 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
|
8251 (insert "// Outputs\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8252 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8253 (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
|
8254 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
|
8255 sig-list))) |
79545 | 8256 (let ((sig-list (verilog-signals-not-in |
8257 (verilog-modi-get-inouts submodi) | |
8258 skip-pins)) | |
8259 (vl-dir "inout")) | |
8260 (when sig-list | |
8261 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8262 (indent-to indent-pt) | |
8263 (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
|
8264 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8265 (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
|
8266 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
|
8267 sig-list))) |
79545 | 8268 (let ((sig-list (verilog-signals-not-in |
8269 (verilog-modi-get-inputs submodi) | |
8270 skip-pins)) | |
8271 (vl-dir "input")) | |
8272 (when sig-list | |
8273 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8274 (indent-to indent-pt) | |
8275 (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
|
8276 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8277 (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
|
8278 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
|
8279 sig-list))) |
79545 | 8280 ;; Kill extra semi |
8281 (save-excursion | |
8282 (cond (did-first | |
8283 (re-search-backward "," pt t) | |
8284 (delete-char 1) | |
8285 (insert ");") | |
8286 (search-forward "\n") ;; Added by inst-port | |
8287 (delete-backward-char 1) | |
8288 (if (search-forward ")" nil t) ;; From user, moved up a line | |
8289 (delete-backward-char 1)) | |
8290 (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
|
8291 (delete-backward-char 1))))))))) |
79545 | 8292 |
8293 (defun verilog-auto-inst-param () | |
8294 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | |
8295 Replace the parameter connections to an instantiation with ones | |
8296 automatically derived from the module header of the instantiated netlist. | |
8297 | |
8298 See \\[verilog-auto-inst] for limitations, and templates to customize the | |
8299 output. | |
8300 | |
8301 For example, first take the submodule inst.v: | |
8302 | |
8303 module inst (o,i) | |
8304 parameter PAR; | |
8305 endmodule | |
8306 | |
8307 This is then used in a upper level module: | |
8308 | |
8309 module ex_inst (o,i) | |
8310 parameter PAR; | |
8311 inst #(/*AUTOINSTPARAM*/) | |
8312 inst (/*AUTOINST*/); | |
8313 endmodule | |
8314 | |
8315 Typing \\[verilog-auto] will make this into: | |
8316 | |
8317 module ex_inst (o,i) | |
8318 output o; | |
8319 input i; | |
8320 inst (/*AUTOINSTPARAM*/ | |
8321 // Parameters | |
8322 .PAR (PAR)); | |
8323 inst (/*AUTOINST*/); | |
8324 endmodule | |
8325 | |
8326 Where the list of parameter connections come from the inst module. | |
8327 | |
8328 Templates: | |
8329 | |
8330 You can customize the parameter connections using AUTO_TEMPLATEs, | |
8331 just as you would with \\[verilog-auto-inst]." | |
8332 (save-excursion | |
8333 ;; Find beginning | |
8334 (let* ((pt (point)) | |
8335 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8336 (1+ (current-column)))) | |
8337 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8338 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8339 (modi (verilog-modi-current)) | |
8340 (vector-skip-list (unless verilog-auto-inst-vector | |
8341 (verilog-modi-get-signals modi))) | |
8342 submod submodi inst skip-pins tpl-list tpl-num did-first) | |
8343 ;; Find module name that is instantiated | |
8344 (setq submod (save-excursion | |
8345 ;; Get to the point where AUTOINST normally is to read the module | |
8346 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8347 (verilog-read-inst-module)) | |
8348 inst (save-excursion | |
8349 ;; Get to the point where AUTOINST normally is to read the module | |
8350 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8351 (verilog-read-inst-name)) | |
8352 vl-cell-type submod | |
8353 vl-cell-name inst | |
8354 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8355 | |
8356 ;; Parse any AUTO_LISP() before here | |
8357 (verilog-read-auto-lisp (point-min) pt) | |
8358 | |
8359 ;; Lookup position, etc of submodule | |
8360 ;; Note this may raise an error | |
8361 (when (setq submodi (verilog-modi-lookup submod t)) | |
8362 ;; If there's a number in the instantiation, it may be a argument to the | |
8363 ;; automatic variable instantiation program. | |
8364 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8365 (tpl-regexp (aref tpl-info 0))) | |
8366 (setq tpl-num (if (string-match tpl-regexp inst) | |
8367 (match-string 1 inst) | |
8368 "") | |
8369 tpl-list (aref tpl-info 1))) | |
8370 ;; Find submodule's signals and dump | |
8371 (let ((sig-list (verilog-signals-not-in | |
8372 (verilog-modi-get-gparams submodi) | |
8373 skip-pins)) | |
8374 (vl-dir "parameter")) | |
8375 (when sig-list | |
8376 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8377 (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
|
8378 ;; 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
|
8379 (insert "// Parameters\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8380 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8381 (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
|
8382 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
|
8383 sig-list))) |
79545 | 8384 ;; Kill extra semi |
8385 (save-excursion | |
8386 (cond (did-first | |
8387 (re-search-backward "," pt t) | |
8388 (delete-char 1) | |
8389 (insert ")") | |
8390 (search-forward "\n") ;; Added by inst-port | |
8391 (delete-backward-char 1) | |
8392 (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
|
8393 (delete-backward-char 1))))))))) |
79545 | 8394 |
8395 (defun verilog-auto-reg () | |
8396 "Expand AUTOREG statements, as part of \\[verilog-auto]. | |
8397 Make reg statements for any output that isn't already declared, | |
8398 and isn't a wire output from a block. | |
8399 | |
8400 Limitations: | |
8401 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8402 | |
8403 This does NOT work on memories, declare those yourself. | |
8404 | |
8405 An example: | |
8406 | |
8407 module ex_reg (o,i) | |
8408 output o; | |
8409 input i; | |
8410 /*AUTOREG*/ | |
8411 always o = i; | |
8412 endmodule | |
8413 | |
8414 Typing \\[verilog-auto] will make this into: | |
8415 | |
8416 module ex_reg (o,i) | |
8417 output o; | |
8418 input i; | |
8419 /*AUTOREG*/ | |
8420 // Beginning of automatic regs (for this module's undeclared outputs) | |
8421 reg o; | |
8422 // End of automatics | |
8423 always o = i; | |
8424 endmodule" | |
8425 (save-excursion | |
8426 ;; Point must be at insertion point. | |
8427 (let* ((indent-pt (current-indentation)) | |
8428 (modi (verilog-modi-current)) | |
8429 (sig-list (verilog-signals-not-in | |
8430 (verilog-modi-get-outputs modi) | |
8431 (append (verilog-modi-get-wires modi) | |
8432 (verilog-modi-get-regs modi) | |
8433 (verilog-modi-get-assigns modi) | |
8434 (verilog-modi-get-consts modi) | |
8435 (verilog-modi-get-gparams modi) | |
8436 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8437 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8438 (forward-line 1) |
8439 (when sig-list | |
8440 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | |
8441 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8442 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8443 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8444 |
8445 (defun verilog-auto-reg-input () | |
8446 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | |
8447 Make reg statements instantiation inputs that aren't already declared. | |
8448 This is useful for making a top level shell for testing the module that is | |
8449 to be instantiated. | |
8450 | |
8451 Limitations: | |
8452 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8453 | |
8454 This does NOT work on memories, declare those yourself. | |
8455 | |
8456 An example (see `verilog-auto-inst' for what else is going on here): | |
8457 | |
8458 module ex_reg_input (o,i) | |
8459 output o; | |
8460 input i; | |
8461 /*AUTOREGINPUT*/ | |
8462 inst inst (/*AUTOINST*/); | |
8463 endmodule | |
8464 | |
8465 Typing \\[verilog-auto] will make this into: | |
8466 | |
8467 module ex_reg_input (o,i) | |
8468 output o; | |
8469 input i; | |
8470 /*AUTOREGINPUT*/ | |
8471 // Beginning of automatic reg inputs (for undeclared ... | |
8472 reg [31:0] iv; // From inst of inst.v | |
8473 // End of automatics | |
8474 inst inst (/*AUTOINST*/ | |
8475 // Outputs | |
8476 .o (o[31:0]), | |
8477 // Inputs | |
8478 .iv (iv)); | |
8479 endmodule" | |
8480 (save-excursion | |
8481 ;; Point must be at insertion point. | |
8482 (let* ((indent-pt (current-indentation)) | |
8483 (modi (verilog-modi-current)) | |
8484 (sig-list (verilog-signals-combine-bus | |
8485 (verilog-signals-not-in | |
8486 (append (verilog-modi-get-sub-inputs modi) | |
8487 (verilog-modi-get-sub-inouts modi)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8488 (verilog-modi-get-signals modi))))) |
79545 | 8489 (forward-line 1) |
8490 (when sig-list | |
8491 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | |
8492 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8493 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8494 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8495 |
8496 (defun verilog-auto-wire () | |
8497 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | |
8498 Make wire statements for instantiations outputs that aren't | |
8499 already declared. | |
8500 | |
8501 Limitations: | |
8502 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'), | |
8503 and all busses must have widths, such as those from AUTOINST, or using [] | |
8504 in AUTO_TEMPLATEs. | |
8505 | |
8506 This does NOT work on memories or SystemVerilog .name connections, | |
8507 declare those yourself. | |
8508 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8509 Verilog mode will add \"Couldn't Merge\" comments to signals it cannot |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8510 determine how to bus together. This occurs when you have ports with |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8511 non-numeric or non-sequential bus subscripts. If Verilog mode |
79545 | 8512 mis-guessed, you'll have to declare them yourself. |
8513 | |
8514 An example (see `verilog-auto-inst' for what else is going on here): | |
8515 | |
8516 module ex_wire (o,i) | |
8517 output o; | |
8518 input i; | |
8519 /*AUTOWIRE*/ | |
8520 inst inst (/*AUTOINST*/); | |
8521 endmodule | |
8522 | |
8523 Typing \\[verilog-auto] will make this into: | |
8524 | |
8525 module ex_wire (o,i) | |
8526 output o; | |
8527 input i; | |
8528 /*AUTOWIRE*/ | |
8529 // Beginning of automatic wires | |
8530 wire [31:0] ov; // From inst of inst.v | |
8531 // End of automatics | |
8532 inst inst (/*AUTOINST*/ | |
8533 // Outputs | |
8534 .ov (ov[31:0]), | |
8535 // Inputs | |
8536 .i (i)); | |
8537 wire o = | ov; | |
8538 endmodule" | |
8539 (save-excursion | |
8540 ;; Point must be at insertion point. | |
8541 (let* ((indent-pt (current-indentation)) | |
8542 (modi (verilog-modi-current)) | |
8543 (sig-list (verilog-signals-combine-bus | |
8544 (verilog-signals-not-in | |
8545 (append (verilog-modi-get-sub-outputs modi) | |
8546 (verilog-modi-get-sub-inouts modi)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8547 (verilog-modi-get-signals modi))))) |
79545 | 8548 (forward-line 1) |
8549 (when sig-list | |
8550 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | |
8551 (verilog-insert-definition sig-list "wire" indent-pt nil) | |
8552 (verilog-modi-cache-add-wires modi sig-list) | |
8553 (verilog-insert-indent "// End of automatics\n") | |
8554 (when nil ;; Too slow on huge modules, plus makes everyone's module change | |
8555 (beginning-of-line) | |
8556 (setq pnt (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
8557 (verilog-pretty-declarations quiet) |
79545 | 8558 (goto-char pnt) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8559 (verilog-pretty-expr "//")))))) |
79545 | 8560 |
8561 (defun verilog-auto-output () | |
8562 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. | |
8563 Make output statements for any output signal from an /*AUTOINST*/ that | |
8564 isn't a input to another AUTOINST. This is useful for modules which | |
8565 only instantiate other modules. | |
8566 | |
8567 Limitations: | |
8568 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8569 | |
8570 If placed inside the parenthesis of a module declaration, it creates | |
8571 Verilog 2001 style, else uses Verilog 1995 style. | |
8572 | |
8573 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8574 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8575 | |
8576 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8577 | |
8578 Signals matching `verilog-auto-output-ignore-regexp' are not included. | |
8579 | |
8580 An example (see `verilog-auto-inst' for what else is going on here): | |
8581 | |
8582 module ex_output (ov,i) | |
8583 input i; | |
8584 /*AUTOOUTPUT*/ | |
8585 inst inst (/*AUTOINST*/); | |
8586 endmodule | |
8587 | |
8588 Typing \\[verilog-auto] will make this into: | |
8589 | |
8590 module ex_output (ov,i) | |
8591 input i; | |
8592 /*AUTOOUTPUT*/ | |
8593 // Beginning of automatic outputs (from unused autoinst outputs) | |
8594 output [31:0] ov; // From inst of inst.v | |
8595 // End of automatics | |
8596 inst inst (/*AUTOINST*/ | |
8597 // Outputs | |
8598 .ov (ov[31:0]), | |
8599 // Inputs | |
8600 .i (i)); | |
8601 endmodule" | |
8602 (save-excursion | |
8603 ;; Point must be at insertion point. | |
8604 (let* ((indent-pt (current-indentation)) | |
8605 (v2k (verilog-in-paren)) | |
8606 (modi (verilog-modi-current)) | |
8607 (sig-list (verilog-signals-not-in | |
8608 (verilog-modi-get-sub-outputs modi) | |
8609 (append (verilog-modi-get-outputs modi) | |
8610 (verilog-modi-get-inouts modi) | |
8611 (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8612 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8613 (setq sig-list (verilog-signals-not-matching-regexp |
8614 sig-list verilog-auto-output-ignore-regexp)) | |
8615 (forward-line 1) | |
8616 (when v2k (verilog-repair-open-comma)) | |
8617 (when sig-list | |
8618 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | |
8619 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8620 (verilog-modi-cache-add-outputs modi sig-list) | |
8621 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8622 (when v2k (verilog-repair-close-comma))))) |
79545 | 8623 |
8624 (defun verilog-auto-output-every () | |
8625 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | |
8626 Make output statements for any signals that aren't primary inputs or | |
8627 outputs already. This makes every signal in the design a output. This is | |
8628 useful to get Synopsys to preserve every signal in the design, since it | |
8629 won't optimize away the outputs. | |
8630 | |
8631 An example: | |
8632 | |
8633 module ex_output_every (o,i,tempa,tempb) | |
8634 output o; | |
8635 input i; | |
8636 /*AUTOOUTPUTEVERY*/ | |
8637 wire tempa = i; | |
8638 wire tempb = tempa; | |
8639 wire o = tempb; | |
8640 endmodule | |
8641 | |
8642 Typing \\[verilog-auto] will make this into: | |
8643 | |
8644 module ex_output_every (o,i,tempa,tempb) | |
8645 output o; | |
8646 input i; | |
8647 /*AUTOOUTPUTEVERY*/ | |
8648 // Beginning of automatic outputs (every signal) | |
8649 output tempb; | |
8650 output tempa; | |
8651 // End of automatics | |
8652 wire tempa = i; | |
8653 wire tempb = tempa; | |
8654 wire o = tempb; | |
8655 endmodule" | |
8656 (save-excursion | |
8657 ;;Point must be at insertion point | |
8658 (let* ((indent-pt (current-indentation)) | |
8659 (v2k (verilog-in-paren)) | |
8660 (modi (verilog-modi-current)) | |
8661 (sig-list (verilog-signals-combine-bus | |
8662 (verilog-signals-not-in | |
8663 (verilog-modi-get-signals modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8664 (verilog-modi-get-ports modi))))) |
79545 | 8665 (forward-line 1) |
8666 (when v2k (verilog-repair-open-comma)) | |
8667 (when sig-list | |
8668 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | |
8669 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8670 (verilog-modi-cache-add-outputs modi sig-list) | |
8671 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8672 (when v2k (verilog-repair-close-comma))))) |
79545 | 8673 |
8674 (defun verilog-auto-input () | |
8675 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. | |
8676 Make input statements for any input signal into an /*AUTOINST*/ that | |
8677 isn't declared elsewhere inside the module. This is useful for modules which | |
8678 only instantiate other modules. | |
8679 | |
8680 Limitations: | |
8681 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8682 | |
8683 If placed inside the parenthesis of a module declaration, it creates | |
8684 Verilog 2001 style, else uses Verilog 1995 style. | |
8685 | |
8686 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8687 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8688 | |
8689 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8690 | |
8691 Signals matching `verilog-auto-input-ignore-regexp' are not included. | |
8692 | |
8693 An example (see `verilog-auto-inst' for what else is going on here): | |
8694 | |
8695 module ex_input (ov,i) | |
8696 output [31:0] ov; | |
8697 /*AUTOINPUT*/ | |
8698 inst inst (/*AUTOINST*/); | |
8699 endmodule | |
8700 | |
8701 Typing \\[verilog-auto] will make this into: | |
8702 | |
8703 module ex_input (ov,i) | |
8704 output [31:0] ov; | |
8705 /*AUTOINPUT*/ | |
8706 // Beginning of automatic inputs (from unused autoinst inputs) | |
8707 input i; // From inst of inst.v | |
8708 // End of automatics | |
8709 inst inst (/*AUTOINST*/ | |
8710 // Outputs | |
8711 .ov (ov[31:0]), | |
8712 // Inputs | |
8713 .i (i)); | |
8714 endmodule" | |
8715 (save-excursion | |
8716 (let* ((indent-pt (current-indentation)) | |
8717 (v2k (verilog-in-paren)) | |
8718 (modi (verilog-modi-current)) | |
8719 (sig-list (verilog-signals-not-in | |
8720 (verilog-modi-get-sub-inputs modi) | |
8721 (append (verilog-modi-get-inputs modi) | |
8722 (verilog-modi-get-inouts modi) | |
8723 (verilog-modi-get-wires modi) | |
8724 (verilog-modi-get-regs modi) | |
8725 (verilog-modi-get-consts modi) | |
8726 (verilog-modi-get-gparams modi) | |
8727 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8728 (verilog-modi-get-sub-inouts modi))))) |
79545 | 8729 (setq sig-list (verilog-signals-not-matching-regexp |
8730 sig-list verilog-auto-input-ignore-regexp)) | |
8731 (forward-line 1) | |
8732 (when v2k (verilog-repair-open-comma)) | |
8733 (when sig-list | |
8734 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | |
8735 (verilog-insert-definition sig-list "input" indent-pt v2k) | |
8736 (verilog-modi-cache-add-inputs modi sig-list) | |
8737 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8738 (when v2k (verilog-repair-close-comma))))) |
79545 | 8739 |
8740 (defun verilog-auto-inout () | |
8741 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. | |
8742 Make inout statements for any inout signal in an /*AUTOINST*/ that | |
8743 isn't declared elsewhere inside the module. | |
8744 | |
8745 Limitations: | |
8746 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8747 | |
8748 If placed inside the parenthesis of a module declaration, it creates | |
8749 Verilog 2001 style, else uses Verilog 1995 style. | |
8750 | |
8751 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8752 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8753 | |
8754 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8755 | |
8756 Signals matching `verilog-auto-inout-ignore-regexp' are not included. | |
8757 | |
8758 An example (see `verilog-auto-inst' for what else is going on here): | |
8759 | |
8760 module ex_inout (ov,i) | |
8761 input i; | |
8762 /*AUTOINOUT*/ | |
8763 inst inst (/*AUTOINST*/); | |
8764 endmodule | |
8765 | |
8766 Typing \\[verilog-auto] will make this into: | |
8767 | |
8768 module ex_inout (ov,i) | |
8769 input i; | |
8770 /*AUTOINOUT*/ | |
8771 // Beginning of automatic inouts (from unused autoinst inouts) | |
8772 inout [31:0] ov; // From inst of inst.v | |
8773 // End of automatics | |
8774 inst inst (/*AUTOINST*/ | |
8775 // Inouts | |
8776 .ov (ov[31:0]), | |
8777 // Inputs | |
8778 .i (i)); | |
8779 endmodule" | |
8780 (save-excursion | |
8781 ;; Point must be at insertion point. | |
8782 (let* ((indent-pt (current-indentation)) | |
8783 (v2k (verilog-in-paren)) | |
8784 (modi (verilog-modi-current)) | |
8785 (sig-list (verilog-signals-not-in | |
8786 (verilog-modi-get-sub-inouts modi) | |
8787 (append (verilog-modi-get-outputs modi) | |
8788 (verilog-modi-get-inouts modi) | |
8789 (verilog-modi-get-inputs modi) | |
8790 (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8791 (verilog-modi-get-sub-outputs modi))))) |
79545 | 8792 (setq sig-list (verilog-signals-not-matching-regexp |
8793 sig-list verilog-auto-inout-ignore-regexp)) | |
8794 (forward-line 1) | |
8795 (when v2k (verilog-repair-open-comma)) | |
8796 (when sig-list | |
8797 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | |
8798 (verilog-insert-definition sig-list "inout" indent-pt v2k) | |
8799 (verilog-modi-cache-add-inouts modi sig-list) | |
8800 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8801 (when v2k (verilog-repair-close-comma))))) |
79545 | 8802 |
8803 (defun verilog-auto-inout-module () | |
8804 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. | |
8805 Take input/output/inout statements from the specified module and insert | |
8806 into the current module. This is useful for making null templates and | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8807 shell modules which need to have identical I/O with another module. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8808 Any I/O which are already defined in this module will not be redefined. |
79545 | 8809 |
8810 Limitations: | |
8811 If placed inside the parenthesis of a module declaration, it creates | |
8812 Verilog 2001 style, else uses Verilog 1995 style. | |
8813 | |
8814 Concatenation and outputting partial busses is not supported. | |
8815 | |
8816 Module names must be resolvable to filenames. See `verilog-auto-inst'. | |
8817 | |
8818 Signals are not inserted in the same order as in the original module, | |
8819 though they will appear to be in the same order to a AUTOINST | |
8820 instantiating either module. | |
8821 | |
8822 An example: | |
8823 | |
8824 module ex_shell (/*AUTOARG*/) | |
8825 /*AUTOINOUTMODULE(\"ex_main\")*/ | |
8826 endmodule | |
8827 | |
8828 module ex_main (i,o,io) | |
8829 input i; | |
8830 output o; | |
8831 inout io; | |
8832 endmodule | |
8833 | |
8834 Typing \\[verilog-auto] will make this into: | |
8835 | |
8836 module ex_shell (/*AUTOARG*/i,o,io) | |
8837 /*AUTOINOUTMODULE(\"ex_main\")*/ | |
8838 // Beginning of automatic in/out/inouts (from specific module) | |
8839 input i; | |
8840 output o; | |
8841 inout io; | |
8842 // End of automatics | |
8843 endmodule" | |
8844 (save-excursion | |
8845 (let* ((submod (car (verilog-read-auto-params 1))) submodi) | |
8846 ;; Lookup position, etc of co-module | |
8847 ;; Note this may raise an error | |
8848 (when (setq submodi (verilog-modi-lookup submod t)) | |
8849 (let* ((indent-pt (current-indentation)) | |
8850 (v2k (verilog-in-paren)) | |
8851 (modi (verilog-modi-current)) | |
8852 (sig-list-i (verilog-signals-not-in | |
8853 (verilog-modi-get-inputs submodi) | |
8854 (append (verilog-modi-get-inputs modi)))) | |
8855 (sig-list-o (verilog-signals-not-in | |
8856 (verilog-modi-get-outputs submodi) | |
8857 (append (verilog-modi-get-outputs modi)))) | |
8858 (sig-list-io (verilog-signals-not-in | |
8859 (verilog-modi-get-inouts submodi) | |
8860 (append (verilog-modi-get-inouts modi))))) | |
8861 (forward-line 1) | |
8862 (when v2k (verilog-repair-open-comma)) | |
8863 (when (or sig-list-i sig-list-o sig-list-io) | |
8864 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") | |
8865 ;; Don't sort them so a upper AUTOINST will match the main module | |
8866 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) | |
8867 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t) | |
8868 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | |
8869 (verilog-modi-cache-add-inputs modi sig-list-i) | |
8870 (verilog-modi-cache-add-outputs modi sig-list-o) | |
8871 (verilog-modi-cache-add-inouts modi sig-list-io) | |
8872 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8873 (when v2k (verilog-repair-close-comma))))))) |
79545 | 8874 |
8875 (defun verilog-auto-sense-sigs (modi presense-sigs) | |
8876 "Return list of signals for current AUTOSENSE block." | |
8877 (let* ((sigss (verilog-read-always-signals)) | |
8878 (sig-list (verilog-signals-not-params | |
8879 (verilog-signals-not-in (verilog-alw-get-inputs sigss) | |
8880 (append (and (not verilog-auto-sense-include-inputs) | |
8881 (verilog-alw-get-outputs sigss)) | |
8882 (verilog-modi-get-consts modi) | |
8883 (verilog-modi-get-gparams modi) | |
8884 presense-sigs))))) | |
8885 sig-list)) | |
8886 | |
8887 (defun verilog-auto-sense () | |
8888 "Expand AUTOSENSE statements, as part of \\[verilog-auto]. | |
8889 Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short) | |
8890 with one automatically derived from all inputs declared in the always | |
8891 statement. Signals that are generated within the same always block are NOT | |
8892 placed into the sensitivity list (see `verilog-auto-sense-include-inputs'). | |
8893 Long lines are split based on the `fill-column', see \\[set-fill-column]. | |
8894 | |
8895 Limitations: | |
8896 Verilog does not allow memories (multidimensional arrays) in sensitivity | |
8897 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment. | |
8898 | |
8899 Constant signals: | |
8900 AUTOSENSE cannot always determine if a `define is a constant or a signal | |
8901 (it could be in a include file for example). If a `define or other signal | |
8902 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT | |
8903 declaration anywhere in the module (parenthesis are required): | |
8904 | |
8905 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */ | |
8906 | |
8907 Better yet, use a parameter, which will be understood to be constant | |
8908 automatically. | |
8909 | |
8910 OOps! | |
8911 If AUTOSENSE makes a mistake, please report it. (First try putting | |
8912 a begin/end after your always!) As a workaround, if a signal that | |
8913 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above. | |
8914 If a signal should be in the sensitivity list wasn't, placing it before | |
8915 the /*AUTOSENSE*/ comment will prevent it from being deleted when the | |
8916 autos are updated (or added if it occurs there already). | |
8917 | |
8918 An example: | |
8919 | |
8920 always @ (/*AUTOSENSE*/) begin | |
8921 /* AUTO_CONSTANT (`constant) */ | |
8922 outin = ina | inb | `constant; | |
8923 out = outin; | |
8924 end | |
8925 | |
8926 Typing \\[verilog-auto] will make this into: | |
8927 | |
8928 always @ (/*AUTOSENSE*/ina or inb) begin | |
8929 /* AUTO_CONSTANT (`constant) */ | |
8930 outin = ina | inb | `constant; | |
8931 out = outin; | |
8932 end" | |
8933 (save-excursion | |
8934 ;; Find beginning | |
8935 (let* ((start-pt (save-excursion | |
8936 (verilog-re-search-backward "(" nil t) | |
8937 (point))) | |
8938 (indent-pt (save-excursion | |
8939 (or (and (goto-char start-pt) (1+ (current-column))) | |
8940 (current-indentation)))) | |
8941 (modi (verilog-modi-current)) | |
8942 (sig-memories (verilog-signals-memory | |
8943 (append | |
8944 (verilog-modi-get-regs modi) | |
8945 (verilog-modi-get-wires modi)))) | |
8946 sig-list not-first presense-sigs) | |
8947 ;; Read signals in always, eliminate outputs from sense list | |
8948 (setq presense-sigs (verilog-signals-from-signame | |
8949 (save-excursion | |
8950 (verilog-read-signals start-pt (point))))) | |
8951 (setq sig-list (verilog-auto-sense-sigs modi presense-sigs)) | |
8952 (when sig-memories | |
8953 (let ((tlen (length sig-list))) | |
8954 (setq sig-list (verilog-signals-not-in sig-list sig-memories)) | |
8955 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ ")))) | |
8956 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" | |
8957 (save-excursion (goto-char (point)) | |
8958 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
8959 (verilog-re-search-backward "\\s-" start-pt t) | |
8960 (while (looking-at "\\s-`endif") | |
8961 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
8962 (verilog-re-search-backward "\\s-" start-pt t)) | |
8963 (not (looking-at "\\s-or\\b")))) | |
8964 (setq not-first t)) | |
8965 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
8966 (while sig-list | |
8967 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or | |
8968 (insert "\n") | |
8969 (indent-to indent-pt) | |
8970 (if not-first (insert "or "))) | |
8971 (not-first (insert " or "))) | |
8972 (insert (verilog-sig-name (car sig-list))) | |
8973 (setq sig-list (cdr sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8974 not-first t))))) |
79545 | 8975 |
8976 (defun verilog-auto-reset () | |
8977 "Expand AUTORESET statements, as part of \\[verilog-auto]. | |
8978 Replace the /*AUTORESET*/ comment with code to initialize all | |
8979 registers set elsewhere in the always block. | |
8980 | |
8981 Limitations: | |
8982 AUTORESET will not clear memories. | |
8983 | |
8984 AUTORESET uses <= if there are any <= in the block, else it uses =. | |
8985 | |
8986 /*AUTORESET*/ presumes that any signals mentioned between the previous | |
8987 begin/case/if statement and the AUTORESET comment are being reset manually | |
8988 and should not be automatically reset. This includes omitting any signals | |
8989 used on the right hand side of assignments. | |
8990 | |
8991 By default, AUTORESET will include the width of the signal in the autos, | |
8992 this is a recent change. To control this behavior, see | |
8993 `verilog-auto-reset-widths'. | |
8994 | |
8995 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
8996 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
8997 them to a one. | |
8998 | |
8999 An example: | |
9000 | |
9001 always @(posedge clk or negedge reset_l) begin | |
9002 if (!reset_l) begin | |
9003 c <= 1; | |
9004 /*AUTORESET*/ | |
9005 end | |
9006 else begin | |
9007 a <= in_a; | |
9008 b <= in_b; | |
9009 c <= in_c; | |
9010 end | |
9011 end | |
9012 | |
9013 Typing \\[verilog-auto] will make this into: | |
9014 | |
9015 always @(posedge core_clk or negedge reset_l) begin | |
9016 if (!reset_l) begin | |
9017 c <= 1; | |
9018 /*AUTORESET*/ | |
9019 // Beginning of autoreset for uninitialized flops | |
9020 a <= 0; | |
9021 b <= 0; | |
9022 // End of automatics | |
9023 end | |
9024 else begin | |
9025 a <= in_a; | |
9026 b <= in_b; | |
9027 c <= in_c; | |
9028 end | |
9029 end" | |
9030 | |
9031 (interactive) | |
9032 (save-excursion | |
9033 ;; Find beginning | |
9034 (let* ((indent-pt (current-indentation)) | |
9035 (modi (verilog-modi-current)) | |
9036 (all-list (verilog-modi-get-signals modi)) | |
9037 sigss sig-list prereset-sigs assignment-str) | |
9038 ;; Read signals in always, eliminate outputs from reset list | |
9039 (setq prereset-sigs (verilog-signals-from-signame | |
9040 (save-excursion | |
9041 (verilog-read-signals | |
9042 (save-excursion | |
9043 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t) | |
9044 (point)) | |
9045 (point))))) | |
9046 (save-excursion | |
9047 (verilog-re-search-backward "@" nil t) | |
9048 (setq sigss (verilog-read-always-signals))) | |
9049 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss) | |
9050 (concat " <= " verilog-assignment-delay) | |
9051 " = ")) | |
9052 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss) | |
9053 prereset-sigs)) | |
9054 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
9055 (when sig-list | |
9056 (insert "\n"); | |
9057 (indent-to indent-pt) | |
9058 (insert "// Beginning of autoreset for uninitialized flops\n"); | |
9059 (indent-to indent-pt) | |
9060 (while sig-list | |
9061 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths | |
9062 (car sig-list)))) | |
9063 (insert (verilog-sig-name sig) | |
9064 assignment-str | |
9065 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | |
9066 ";\n") | |
9067 (indent-to indent-pt) | |
9068 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9069 (insert "// End of automatics"))))) |
79545 | 9070 |
9071 (defun verilog-auto-tieoff () | |
9072 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | |
9073 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | |
9074 signals to deasserted. | |
9075 | |
9076 /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same | |
9077 input/output list as another module, but no internals. Specifically, it | |
9078 finds all outputs in the module, and if that input is not otherwise declared | |
9079 as a register or wire, creates a tieoff. | |
9080 | |
9081 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
9082 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
9083 them to a one. | |
9084 | |
9085 An example of making a stub for another module: | |
9086 | |
9087 module FooStub (/*AUTOINST*/); | |
9088 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9089 /*AUTOTIEOFF*/ | |
9090 // verilator lint_off UNUSED | |
9091 wire _unused_ok = &{1'b0, | |
9092 /*AUTOUNUSED*/ | |
9093 1'b0}; | |
9094 // verilator lint_on UNUSED | |
9095 endmodule | |
9096 | |
9097 Typing \\[verilog-auto] will make this into: | |
9098 | |
9099 module FooStub (/*AUTOINST*/...); | |
9100 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9101 // Beginning of autotieoff | |
9102 output [2:0] foo; | |
9103 // End of automatics | |
9104 | |
9105 /*AUTOTIEOFF*/ | |
9106 // Beginning of autotieoff | |
9107 wire [2:0] foo = 3'b0; | |
9108 // End of automatics | |
9109 ... | |
9110 endmodule" | |
9111 (interactive) | |
9112 (save-excursion | |
9113 ;; Find beginning | |
9114 (let* ((indent-pt (current-indentation)) | |
9115 (modi (verilog-modi-current)) | |
9116 (sig-list (verilog-signals-not-in | |
9117 (verilog-modi-get-outputs modi) | |
9118 (append (verilog-modi-get-wires modi) | |
9119 (verilog-modi-get-regs modi) | |
9120 (verilog-modi-get-assigns modi) | |
9121 (verilog-modi-get-consts modi) | |
9122 (verilog-modi-get-gparams modi) | |
9123 (verilog-modi-get-sub-outputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9124 (verilog-modi-get-sub-inouts modi))))) |
79545 | 9125 (when sig-list |
9126 (forward-line 1) | |
9127 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | |
9128 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9129 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list | |
9130 (while sig-list | |
9131 (let ((sig (car sig-list))) | |
9132 (verilog-insert-one-definition sig "wire" indent-pt) | |
9133 (indent-to (max 48 (+ indent-pt 40))) | |
9134 (insert "= " (verilog-sig-tieoff sig) | |
9135 ";\n") | |
9136 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9137 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9138 |
9139 (defun verilog-auto-unused () | |
9140 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | |
9141 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | |
9142 input and inout signals. | |
9143 | |
9144 /*AUTOUNUSED*/ is used to make stub modules; modules that have the same | |
9145 input/output list as another module, but no internals. Specifically, it | |
9146 finds all inputs and inouts in the module, and if that input is not otherwise | |
9147 used, adds it to a comma separated list. | |
9148 | |
9149 The comma separated list is intended to be used to create a _unused_ok | |
9150 signal. Using the exact name \"_unused_ok\" for name of the temporary | |
9151 signal is recommended as it will insure maximum forward compatibility, it | |
9152 also makes lint warnings easy to understand; ignore any unused warnings | |
9153 with \"unused\" in the signal name. | |
9154 | |
9155 To reduce simulation time, the _unused_ok signal should be forced to a | |
9156 constant to prevent wiggling. The easiest thing to do is use a | |
9157 reduction-and with 1'b0 as shown. | |
9158 | |
9159 This way all unused signals are in one place, making it convenient to add | |
9160 your tool's specific pragmas around the assignment to disable any unused | |
9161 warnings. | |
9162 | |
9163 You can add signals you do not want included in AUTOUNUSED with | |
9164 `verilog-auto-unused-ignore-regexp'. | |
9165 | |
9166 An example of making a stub for another module: | |
9167 | |
9168 module FooStub (/*AUTOINST*/); | |
9169 /*AUTOINOUTMODULE(\"Foo\")*/ | |
9170 /*AUTOTIEOFF*/ | |
9171 // verilator lint_off UNUSED | |
9172 wire _unused_ok = &{1'b0, | |
9173 /*AUTOUNUSED*/ | |
9174 1'b0}; | |
9175 // verilator lint_on UNUSED | |
9176 endmodule | |
9177 | |
9178 Typing \\[verilog-auto] will make this into: | |
9179 | |
9180 ... | |
9181 // verilator lint_off UNUSED | |
9182 wire _unused_ok = &{1'b0, | |
9183 /*AUTOUNUSED*/ | |
9184 // Beginning of automatics | |
9185 unused_input_a, | |
9186 unused_input_b, | |
9187 unused_input_c, | |
9188 // End of automatics | |
9189 1'b0}; | |
9190 // verilator lint_on UNUSED | |
9191 endmodule" | |
9192 (interactive) | |
9193 (save-excursion | |
9194 ;; Find beginning | |
9195 (let* ((indent-pt (progn (search-backward "/*") (current-column))) | |
9196 (modi (verilog-modi-current)) | |
9197 (sig-list (verilog-signals-not-in | |
9198 (append (verilog-modi-get-inputs modi) | |
9199 (verilog-modi-get-inouts modi)) | |
9200 (append (verilog-modi-get-sub-inputs modi) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9201 (verilog-modi-get-sub-inouts modi))))) |
79545 | 9202 (setq sig-list (verilog-signals-not-matching-regexp |
9203 sig-list verilog-auto-unused-ignore-regexp)) | |
9204 (when sig-list | |
9205 (forward-line 1) | |
9206 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | |
9207 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9208 (while sig-list | |
9209 (let ((sig (car sig-list))) | |
9210 (indent-to indent-pt) | |
9211 (insert (verilog-sig-name sig) ",\n") | |
9212 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9213 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9214 |
9215 (defun verilog-enum-ascii (signm elim-regexp) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9216 "Convert an enum name SIGNM to an ascii string for insertion. |
79545 | 9217 Remove user provided prefix ELIM-REGEXP." |
9218 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | |
9219 (let ((case-fold-search t)) | |
9220 ;; All upper becomes all lower for readability | |
9221 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm)))) | |
9222 | |
9223 (defun verilog-auto-ascii-enum () | |
9224 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto]. | |
9225 Create a register to contain the ASCII decode of a enumerated signal type. | |
9226 This will allow trace viewers to show the ASCII name of states. | |
9227 | |
9228 First, parameters are built into a enumeration using the synopsys enum | |
9229 comment. The comment must be between the keyword and the symbol. | |
79546 | 9230 \(Annoying, but that's what Synopsys's dc_shell FSM reader requires.) |
79545 | 9231 |
9232 Next, registers which that enum applies to are also tagged with the same | |
9233 enum. Synopsys also suggests labeling state vectors, but `verilog-mode' | |
9234 doesn't care. | |
9235 | |
9236 Finally, a AUTOASCIIENUM command is used. | |
9237 | |
9238 The first parameter is the name of the signal to be decoded. | |
9239 | |
9240 The second parameter is the name to store the ASCII code into. For the | |
9241 signal foo, I suggest the name _foo__ascii, where the leading _ indicates | |
9242 a signal that is just for simulation, and the magic characters _ascii | |
9243 tell viewers like Dinotrace to display in ASCII format. | |
9244 | |
9245 The final optional parameter is a string which will be removed from the | |
9246 state names. | |
9247 | |
9248 An example: | |
9249 | |
9250 //== State enumeration | |
9251 parameter [2:0] // synopsys enum state_info | |
9252 SM_IDLE = 3'b000, | |
9253 SM_SEND = 3'b001, | |
9254 SM_WAIT1 = 3'b010; | |
9255 //== State variables | |
9256 reg [2:0] /* synopsys enum state_info */ | |
9257 state_r; /* synopsys state_vector state_r */ | |
9258 reg [2:0] /* synopsys enum state_info */ | |
9259 state_e1; | |
9260 | |
9261 //== ASCII state decoding | |
9262 | |
9263 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9264 | |
9265 Typing \\[verilog-auto] will make this into: | |
9266 | |
9267 ... same front matter ... | |
9268 | |
9269 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9270 // Beginning of automatic ASCII enum decoding | |
9271 reg [39:0] state_ascii_r; // Decode of state_r | |
9272 always @(state_r) begin | |
9273 case ({state_r}) | |
9274 SM_IDLE: state_ascii_r = \"idle \"; | |
9275 SM_SEND: state_ascii_r = \"send \"; | |
9276 SM_WAIT1: state_ascii_r = \"wait1\"; | |
9277 default: state_ascii_r = \"%Erro\"; | |
9278 endcase | |
9279 end | |
9280 // End of automatics" | |
9281 (save-excursion | |
9282 (let* ((params (verilog-read-auto-params 2 3)) | |
9283 (undecode-name (nth 0 params)) | |
9284 (ascii-name (nth 1 params)) | |
9285 (elim-regexp (nth 2 params)) | |
9286 ;; | |
9287 (indent-pt (current-indentation)) | |
9288 (modi (verilog-modi-current)) | |
9289 ;; | |
9290 (sig-list-consts (append (verilog-modi-get-consts modi) | |
9291 (verilog-modi-get-gparams modi))) | |
9292 (sig-list-all (append (verilog-modi-get-regs modi) | |
9293 (verilog-modi-get-outputs modi) | |
9294 (verilog-modi-get-inouts modi) | |
9295 (verilog-modi-get-inputs modi) | |
9296 (verilog-modi-get-wires modi))) | |
9297 ;; | |
9298 (undecode-sig (or (assoc undecode-name sig-list-all) | |
9299 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) | |
9300 (undecode-enum (or (verilog-sig-enum undecode-sig) | |
9301 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name))) | |
9302 ;; | |
9303 (enum-sigs (or (verilog-signals-matching-enum sig-list-consts undecode-enum) | |
9304 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum))) | |
9305 ;; | |
9306 (enum-chars 0) | |
9307 (ascii-chars 0)) | |
9308 ;; | |
9309 ;; Find number of ascii chars needed | |
9310 (let ((tmp-sigs enum-sigs)) | |
9311 (while tmp-sigs | |
9312 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs)))) | |
9313 ascii-chars (max ascii-chars (length (verilog-enum-ascii | |
9314 (verilog-sig-name (car tmp-sigs)) | |
9315 elim-regexp))) | |
9316 tmp-sigs (cdr tmp-sigs)))) | |
9317 ;; | |
9318 (forward-line 1) | |
9319 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") | |
9320 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) | |
9321 (concat "Decode of " undecode-name) nil nil)))) | |
9322 (verilog-insert-definition decode-sig-list "reg" indent-pt nil) | |
9323 (verilog-modi-cache-add-regs modi decode-sig-list)) | |
9324 ;; | |
9325 (verilog-insert-indent "always @(" undecode-name ") begin\n") | |
9326 (setq indent-pt (+ indent-pt verilog-indent-level)) | |
9327 (indent-to indent-pt) | |
9328 (insert "case ({" undecode-name "})\n") | |
9329 (setq indent-pt (+ indent-pt verilog-case-indent)) | |
9330 ;; | |
9331 (let ((tmp-sigs enum-sigs) | |
9332 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" (1+ (max 8 enum-chars)) | |
9333 ascii-name ascii-chars)) | |
9334 (errname (substring "%Error" 0 (min 6 ascii-chars)))) | |
9335 (while tmp-sigs | |
9336 (verilog-insert-indent | |
9337 (format chrfmt (concat (verilog-sig-name (car tmp-sigs)) ":") | |
9338 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs)) | |
9339 elim-regexp))) | |
9340 (setq tmp-sigs (cdr tmp-sigs))) | |
9341 (verilog-insert-indent (format chrfmt "default:" errname))) | |
9342 ;; | |
9343 (setq indent-pt (- indent-pt verilog-case-indent)) | |
9344 (verilog-insert-indent "endcase\n") | |
9345 (setq indent-pt (- indent-pt verilog-indent-level)) | |
9346 (verilog-insert-indent "end\n" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9347 "// End of automatics\n")))) |
79545 | 9348 |
9349 (defun verilog-auto-templated-rel () | |
9350 "Replace Templated relative line numbers with absolute line numbers. | |
9351 Internal use only. This hacks around the line numbers in AUTOINST Templates | |
9352 being different from the final output's line numbering." | |
9353 (let ((templateno 0) (template-line (list 0))) | |
9354 ;; Find line number each template is on | |
9355 (goto-char (point-min)) | |
9356 (while (search-forward "AUTO_TEMPLATE" nil t) | |
9357 (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
|
9358 (setq template-line |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9359 (cons (count-lines (point-min) (point)) template-line))) |
79545 | 9360 (setq template-line (nreverse template-line)) |
9361 ;; Replace T# L# with absolute line number | |
9362 (goto-char (point-min)) | |
9363 (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
|
9364 (replace-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9365 (concat " Templated " |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9366 (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
|
9367 template-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9368 (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
|
9369 t t)))) |
79545 | 9370 |
9371 | |
9372 ;; | |
9373 ;; Auto top level | |
9374 ;; | |
9375 | |
9376 (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg | |
9377 "Expand AUTO statements. | |
9378 Look for any /*AUTO...*/ commands in the code, as used in | |
9379 instantiations or argument headers. Update the list of signals | |
9380 following the /*AUTO...*/ command. | |
9381 | |
9382 Use \\[verilog-delete-auto] to remove the AUTOs. | |
9383 | |
9384 Use \\[verilog-inject-auto] to insert AUTOs for the first time. | |
9385 | |
9386 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
9387 | |
9388 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are | |
9389 called before and after this function, respectively. | |
9390 | |
9391 For example: | |
9392 module (/*AUTOARG*/) | |
9393 /*AUTOINPUT*/ | |
9394 /*AUTOOUTPUT*/ | |
9395 /*AUTOWIRE*/ | |
9396 /*AUTOREG*/ | |
9397 somesub sub #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); | |
9398 | |
9399 You can also update the AUTOs from the shell using: | |
9400 emacs --batch <filenames.v> -f verilog-batch-auto | |
9401 Or fix indentation with: | |
9402 emacs --batch <filenames.v> -f verilog-batch-indent | |
9403 Likewise, you can delete or inject AUTOs with: | |
9404 emacs --batch <filenames.v> -f verilog-batch-delete-auto | |
9405 emacs --batch <filenames.v> -f verilog-batch-inject-auto | |
9406 | |
9407 Using \\[describe-function], see also: | |
9408 `verilog-auto-arg' for AUTOARG module instantiations | |
9409 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding | |
9410 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere | |
9411 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts | |
9412 `verilog-auto-input' for AUTOINPUT making hierarchy inputs | |
9413 `verilog-auto-inst' for AUTOINST instantiation pins | |
9414 `verilog-auto-star' for AUTOINST .* SystemVerilog pins | |
9415 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params | |
9416 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs | |
9417 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs | |
9418 `verilog-auto-reg' for AUTOREG registers | |
9419 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers | |
9420 `verilog-auto-reset' for AUTORESET flop resets | |
9421 `verilog-auto-sense' for AUTOSENSE always sensitivity lists | |
9422 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs | |
9423 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts | |
9424 `verilog-auto-wire' for AUTOWIRE instantiation wires | |
9425 | |
9426 `verilog-read-defines' for reading `define values | |
9427 `verilog-read-includes' for reading `includes | |
9428 | |
9429 If you have bugs with these autos, try contacting the AUTOAUTHOR | |
9430 Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com." | |
9431 (interactive) | |
9432 (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
|
9433 (if (fboundp 'dinotrace-unannotate-all) |
79545 | 9434 (dinotrace-unannotate-all)) |
9435 (let ((oldbuf (if (not (buffer-modified-p)) | |
9436 (buffer-string))) | |
9437 ;; Before version 20, match-string with font-lock returns a | |
9438 ;; vector that is not equal to the string. IE if on "input" | |
9439 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0))) | |
9440 (fontlocked (when (and (boundp 'font-lock-mode) | |
9441 font-lock-mode) | |
9442 (font-lock-mode nil) | |
9443 t))) | |
9444 (unwind-protect | |
9445 (save-excursion | |
9446 ;; If we're not in verilog-mode, change syntax table so parsing works right | |
9447 (unless (eq major-mode `verilog-mode) (verilog-mode)) | |
9448 ;; Allow user to customize | |
9449 (run-hooks 'verilog-before-auto-hook) | |
9450 ;; Try to save the user from needing to revert-file to reread file local-variables | |
9451 (verilog-auto-reeval-locals) | |
9452 (verilog-read-auto-lisp (point-min) (point-max)) | |
9453 (verilog-getopt-flags) | |
9454 ;; These two may seem obvious to do always, but on large includes it can be way too slow | |
9455 (when verilog-auto-read-includes | |
9456 (verilog-read-includes) | |
9457 (verilog-read-defines nil nil t)) | |
9458 ;; This particular ordering is important | |
9459 ;; INST: Lower modules correct, no internal dependencies, FIRST | |
9460 (verilog-preserve-cache | |
9461 ;; Clear existing autos else we'll be screwed by existing ones | |
9462 (verilog-delete-auto) | |
9463 ;; Injection if appropriate | |
9464 (when inject | |
9465 (verilog-inject-inst) | |
9466 (verilog-inject-sense) | |
9467 (verilog-inject-arg)) | |
9468 ;; | |
9469 (verilog-auto-search-do "/*AUTOINSTPARAM*/" 'verilog-auto-inst-param) | |
9470 (verilog-auto-search-do "/*AUTOINST*/" 'verilog-auto-inst) | |
9471 (verilog-auto-search-do ".*" 'verilog-auto-star) | |
9472 ;; Doesn't matter when done, but combine it with a common changer | |
9473 (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) | |
9474 (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) | |
9475 ;; Must be done before autoin/out as creates a reg | |
9476 (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum) | |
9477 ;; | |
9478 ;; first in/outs from other files | |
9479 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) | |
9480 ;; next in/outs which need previous sucked inputs first | |
9481 (verilog-auto-search-do "/*AUTOOUTPUT*/" 'verilog-auto-output) | |
9482 (verilog-auto-search-do "/*AUTOINPUT*/" 'verilog-auto-input) | |
9483 (verilog-auto-search-do "/*AUTOINOUT*/" 'verilog-auto-inout) | |
9484 ;; Then tie off those in/outs | |
9485 (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff) | |
9486 ;; Wires/regs must be after inputs/outputs | |
9487 (verilog-auto-search-do "/*AUTOWIRE*/" 'verilog-auto-wire) | |
9488 (verilog-auto-search-do "/*AUTOREG*/" 'verilog-auto-reg) | |
9489 (verilog-auto-search-do "/*AUTOREGINPUT*/" 'verilog-auto-reg-input) | |
9490 ;; outputevery needs AUTOOUTPUTs done first | |
9491 (verilog-auto-search-do "/*AUTOOUTPUTEVERY*/" 'verilog-auto-output-every) | |
9492 ;; After we've created all new variables | |
9493 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused) | |
9494 ;; Must be after all inputs outputs are generated | |
9495 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg) | |
9496 ;; Fix line numbers (comments only) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9497 (verilog-auto-templated-rel)) |
79545 | 9498 ;; |
9499 (run-hooks 'verilog-auto-hook) | |
9500 ;; | |
9501 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | |
9502 ;; | |
9503 ;; If end result is same as when started, clear modified flag | |
9504 (cond ((and oldbuf (equal oldbuf (buffer-string))) | |
9505 (set-buffer-modified-p nil) | |
9506 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | |
9507 (t (unless noninteractive (message "Updating AUTOs...done"))))) | |
9508 ;; Unwind forms | |
9509 (progn | |
9510 ;; Restore font-lock | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9511 (when fontlocked (font-lock-mode t)))))) |
79545 | 9512 |
9513 | |
9514 ;; | |
9515 ;; Skeleton based code insertion | |
9516 ;; | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9517 (defvar verilog-template-map |
79546 | 9518 (let ((map (make-sparse-keymap))) |
9519 (define-key map "a" 'verilog-sk-always) | |
9520 (define-key map "b" 'verilog-sk-begin) | |
9521 (define-key map "c" 'verilog-sk-case) | |
9522 (define-key map "f" 'verilog-sk-for) | |
9523 (define-key map "g" 'verilog-sk-generate) | |
9524 (define-key map "h" 'verilog-sk-header) | |
9525 (define-key map "i" 'verilog-sk-initial) | |
9526 (define-key map "j" 'verilog-sk-fork) | |
9527 (define-key map "m" 'verilog-sk-module) | |
9528 (define-key map "p" 'verilog-sk-primitive) | |
9529 (define-key map "r" 'verilog-sk-repeat) | |
9530 (define-key map "s" 'verilog-sk-specify) | |
9531 (define-key map "t" 'verilog-sk-task) | |
9532 (define-key map "w" 'verilog-sk-while) | |
9533 (define-key map "x" 'verilog-sk-casex) | |
9534 (define-key map "z" 'verilog-sk-casez) | |
9535 (define-key map "?" 'verilog-sk-if) | |
9536 (define-key map ":" 'verilog-sk-else-if) | |
9537 (define-key map "/" 'verilog-sk-comment) | |
9538 (define-key map "A" 'verilog-sk-assign) | |
9539 (define-key map "F" 'verilog-sk-function) | |
9540 (define-key map "I" 'verilog-sk-input) | |
9541 (define-key map "O" 'verilog-sk-output) | |
9542 (define-key map "S" 'verilog-sk-state-machine) | |
9543 (define-key map "=" 'verilog-sk-inout) | |
9544 (define-key map "W" 'verilog-sk-wire) | |
9545 (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
|
9546 (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
|
9547 map) |
79545 | 9548 "Keymap used in Verilog mode for smart template operations.") |
9549 | |
9550 | |
9551 ;; | |
9552 ;; Place the templates into Verilog Mode. They may be inserted under any key. | |
9553 ;; C-c C-t will be the default. If you use templates a lot, you | |
9554 ;; may want to consider moving the binding to another key in your .emacs | |
9555 ;; file. | |
9556 ;; | |
9557 ;(define-key verilog-mode-map "\C-ct" verilog-template-map) | |
9558 (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) | |
9559 | |
9560 ;;; ---- statement skeletons ------------------------------------------ | |
9561 | |
9562 (define-skeleton verilog-sk-prompt-condition | |
9563 "Prompt for the loop condition." | |
9564 "[condition]: " str ) | |
9565 | |
9566 (define-skeleton verilog-sk-prompt-init | |
9567 "Prompt for the loop init statement." | |
9568 "[initial statement]: " str ) | |
9569 | |
9570 (define-skeleton verilog-sk-prompt-inc | |
9571 "Prompt for the loop increment statement." | |
9572 "[increment statement]: " str ) | |
9573 | |
9574 (define-skeleton verilog-sk-prompt-name | |
9575 "Prompt for the name of something." | |
9576 "[name]: " str) | |
9577 | |
9578 (define-skeleton verilog-sk-prompt-clock | |
9579 "Prompt for the name of something." | |
9580 "name and edge of clock(s): " str) | |
9581 | |
9582 (defvar verilog-sk-reset nil) | |
9583 (defun verilog-sk-prompt-reset () | |
9584 "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
|
9585 (setq verilog-sk-reset (read-string "name of reset: " "rst"))) |
79545 | 9586 |
9587 | |
9588 (define-skeleton verilog-sk-prompt-state-selector | |
9589 "Prompt for the name of a state machine selector." | |
9590 "name of selector (eg {a,b,c,d}): " str ) | |
9591 | |
9592 (define-skeleton verilog-sk-prompt-output | |
9593 "Prompt for the name of something." | |
9594 "output: " str) | |
9595 | |
9596 (define-skeleton verilog-sk-prompt-msb | |
9597 "Prompt for least significant bit specification." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9598 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 ) |
79545 | 9599 |
9600 (define-skeleton verilog-sk-prompt-lsb | |
9601 "Prompt for least significant bit specification." | |
9602 "lsb:" str ) | |
9603 | |
9604 (defvar verilog-sk-p nil) | |
9605 (define-skeleton verilog-sk-prompt-width | |
9606 "Prompt for a width specification." | |
9607 () | |
9608 (progn | |
9609 (setq verilog-sk-p (point)) | |
9610 (verilog-sk-prompt-msb) | |
9611 (if (> (point) verilog-sk-p) "] " " "))) | |
9612 | |
9613 (defun verilog-sk-header () | |
9614 "Insert a descriptive header at the top of the file." | |
9615 (interactive "*") | |
9616 (save-excursion | |
9617 (goto-char (point-min)) | |
9618 (verilog-sk-header-tmpl))) | |
9619 | |
9620 (define-skeleton verilog-sk-header-tmpl | |
9621 "Insert a comment block containing the module title, author, etc." | |
9622 "[Description]: " | |
9623 "// -*- Mode: Verilog -*-" | |
9624 "\n// Filename : " (buffer-name) | |
9625 "\n// Description : " str | |
9626 "\n// Author : " (user-full-name) | |
9627 "\n// Created On : " (current-time-string) | |
9628 "\n// Last Modified By: ." | |
9629 "\n// Last Modified On: ." | |
9630 "\n// Update Count : 0" | |
9631 "\n// Status : Unknown, Use with caution!" | |
9632 "\n") | |
9633 | |
9634 (define-skeleton verilog-sk-module | |
9635 "Insert a module definition." | |
9636 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9637 > "module " '(verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n |
79545 | 9638 > _ \n |
9639 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) | |
9640 | |
9641 (define-skeleton verilog-sk-primitive | |
9642 "Insert a task definition." | |
9643 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9644 > "primitive " '(verilog-sk-prompt-name) " ( " '(verilog-sk-prompt-output) ("input:" ", " str ) " );"\n |
79545 | 9645 > _ \n |
9646 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil)) | |
9647 | |
9648 (define-skeleton verilog-sk-task | |
9649 "Insert a task definition." | |
9650 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9651 > "task " '(verilog-sk-prompt-name) & ?; \n |
79545 | 9652 > _ \n |
9653 > "begin" \n | |
9654 > \n | |
9655 > (- verilog-indent-level-behavioral) "end" \n | |
9656 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil)) | |
9657 | |
9658 (define-skeleton verilog-sk-function | |
9659 "Insert a function definition." | |
9660 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9661 > "function [" '(verilog-sk-prompt-width) | -1 '(verilog-sk-prompt-name) ?; \n |
79545 | 9662 > _ \n |
9663 > "begin" \n | |
9664 > \n | |
9665 > (- verilog-indent-level-behavioral) "end" \n | |
9666 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil)) | |
9667 | |
9668 (define-skeleton verilog-sk-always | |
9669 "Insert always block. Uses the minibuffer to prompt | |
9670 for sensitivity list." | |
9671 () | |
9672 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
9673 > _ \n | |
9674 > (- verilog-indent-level-behavioral) "end" \n > | |
9675 ) | |
9676 | |
9677 (define-skeleton verilog-sk-initial | |
9678 "Insert an initial block." | |
9679 () | |
9680 > "initial begin\n" | |
9681 > _ \n | |
9682 > (- verilog-indent-level-behavioral) "end" \n > ) | |
9683 | |
9684 (define-skeleton verilog-sk-specify | |
9685 "Insert specify block. " | |
9686 () | |
9687 > "specify\n" | |
9688 > _ \n | |
9689 > (- verilog-indent-level-behavioral) "endspecify" \n > ) | |
9690 | |
9691 (define-skeleton verilog-sk-generate | |
9692 "Insert generate block. " | |
9693 () | |
9694 > "generate\n" | |
9695 > _ \n | |
9696 > (- verilog-indent-level-behavioral) "endgenerate" \n > ) | |
9697 | |
9698 (define-skeleton verilog-sk-begin | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9699 "Insert begin end block. Uses the minibuffer to prompt for name." |
79545 | 9700 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9701 > "begin" '(verilog-sk-prompt-name) \n |
79545 | 9702 > _ \n |
9703 > (- verilog-indent-level-behavioral) "end" | |
9704 ) | |
9705 | |
9706 (define-skeleton verilog-sk-fork | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9707 "Insert a fork join block." |
79545 | 9708 () |
9709 > "fork\n" | |
9710 > "begin" \n | |
9711 > _ \n | |
9712 > (- verilog-indent-level-behavioral) "end" \n | |
9713 > "begin" \n | |
9714 > \n | |
9715 > (- verilog-indent-level-behavioral) "end" \n | |
9716 > (- verilog-indent-level-behavioral) "join" \n | |
9717 > ) | |
9718 | |
9719 | |
9720 (define-skeleton verilog-sk-case | |
9721 "Build skeleton case statement, prompting for the selector expression, | |
9722 and the case items." | |
9723 "[selector expression]: " | |
9724 > "case (" str ") " \n | |
9725 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9726 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9727 | |
9728 (define-skeleton verilog-sk-casex | |
9729 "Build skeleton casex statement, prompting for the selector expression, | |
9730 and the case items." | |
9731 "[selector expression]: " | |
9732 > "casex (" str ") " \n | |
9733 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9734 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9735 | |
9736 (define-skeleton verilog-sk-casez | |
9737 "Build skeleton casez statement, prompting for the selector expression, | |
9738 and the case items." | |
9739 "[selector expression]: " | |
9740 > "casez (" str ") " \n | |
9741 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
9742 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
9743 | |
9744 (define-skeleton verilog-sk-if | |
9745 "Insert a skeleton if statement." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9746 > "if (" '(verilog-sk-prompt-condition) & ")" " begin" \n |
79545 | 9747 > _ \n |
9748 > (- verilog-indent-level-behavioral) "end " \n ) | |
9749 | |
9750 (define-skeleton verilog-sk-else-if | |
9751 "Insert a skeleton else if statement." | |
9752 > (verilog-indent-line) "else if (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9753 (progn (setq verilog-sk-p (point)) nil) '(verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n |
79545 | 9754 > _ \n |
9755 > "end" (progn (electric-verilog-terminate-line) nil)) | |
9756 | |
9757 (define-skeleton verilog-sk-datadef | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9758 "Common routine to get data definition." |
79545 | 9759 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9760 '(verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n) |
79545 | 9761 |
9762 (define-skeleton verilog-sk-input | |
9763 "Insert an input definition." | |
9764 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9765 > "input [" '(verilog-sk-datadef)) |
79545 | 9766 |
9767 (define-skeleton verilog-sk-output | |
9768 "Insert an output definition." | |
9769 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9770 > "output [" '(verilog-sk-datadef)) |
79545 | 9771 |
9772 (define-skeleton verilog-sk-inout | |
9773 "Insert an inout definition." | |
9774 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9775 > "inout [" '(verilog-sk-datadef)) |
79545 | 9776 |
9777 (defvar verilog-sk-signal nil) | |
9778 (define-skeleton verilog-sk-def-reg | |
9779 "Insert a reg definition." | |
9780 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9781 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
79545 | 9782 |
9783 (defun verilog-sk-define-signal () | |
9784 "Insert a definition of signal under point at top of module." | |
9785 (interactive "*") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9786 (let* ((sig-re "[a-zA-Z0-9_]*") |
79545 | 9787 (v1 (buffer-substring |
9788 (save-excursion | |
9789 (skip-chars-backward sig-re) | |
9790 (point)) | |
9791 (save-excursion | |
9792 (skip-chars-forward sig-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9793 (point))))) |
79545 | 9794 (if (not (member v1 verilog-keywords)) |
9795 (save-excursion | |
9796 (setq verilog-sk-signal v1) | |
9797 (verilog-beg-of-defun) | |
9798 (verilog-end-of-statement) | |
9799 (verilog-forward-syntactic-ws) | |
9800 (verilog-sk-def-reg) | |
9801 (message "signal at point is %s" v1)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9802 (message "object at point (%s) is a keyword" v1)))) |
79545 | 9803 |
9804 (define-skeleton verilog-sk-wire | |
9805 "Insert a wire definition." | |
9806 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9807 > "wire [" '(verilog-sk-datadef)) |
79545 | 9808 |
9809 (define-skeleton verilog-sk-reg | |
9810 "Insert a reg definition." | |
9811 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9812 > "reg [" '(verilog-sk-datadef)) |
79545 | 9813 |
9814 (define-skeleton verilog-sk-assign | |
9815 "Insert a skeleton assign statement." | |
9816 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9817 > "assign " '(verilog-sk-prompt-name) " = " _ ";" \n) |
79545 | 9818 |
9819 (define-skeleton verilog-sk-while | |
9820 "Insert a skeleton while loop statement." | |
9821 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9822 > "while (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 9823 > _ \n |
9824 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9825 | |
9826 (define-skeleton verilog-sk-repeat | |
9827 "Insert a skeleton repeat loop statement." | |
9828 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9829 > "repeat (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 9830 > _ \n |
9831 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9832 | |
9833 (define-skeleton verilog-sk-for | |
9834 "Insert a skeleton while loop statement." | |
9835 () | |
9836 > "for (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9837 '(verilog-sk-prompt-init) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9838 '(verilog-sk-prompt-condition) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9839 '(verilog-sk-prompt-inc) |
79545 | 9840 ") begin" \n |
9841 > _ \n | |
9842 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
9843 | |
9844 (define-skeleton verilog-sk-comment | |
9845 "Inserts three comment lines, making a display comment." | |
9846 () | |
9847 > "/*\n" | |
9848 > "* " _ \n | |
9849 > "*/") | |
9850 | |
9851 (define-skeleton verilog-sk-state-machine | |
9852 "Insert a state machine definition." | |
9853 "Name of state variable: " | |
9854 '(setq input "state") | |
9855 > "// State registers for " str | -23 \n | |
9856 '(setq verilog-sk-state str) | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9857 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n |
79545 | 9858 '(setq input nil) |
9859 > \n | |
9860 > "// State FF for " verilog-sk-state \n | |
9861 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n | |
9862 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n | |
9863 > verilog-sk-state " = next_" verilog-sk-state ?; \n | |
9864 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil) | |
9865 > \n | |
9866 > "// Next State Logic for " verilog-sk-state \n | |
9867 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9868 > "case (" '(verilog-sk-prompt-state-selector) ") " \n |
79545 | 9869 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n ) |
9870 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) | |
9871 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) | |
9872 | |
9873 | |
9874 ;; | |
9875 ;; Include file loading with mouse/return event | |
9876 ;; | |
9877 ;; idea & first impl.: M. Rouat (eldo-mode.el) | |
9878 ;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el) | |
9879 | |
9880 (if (featurep 'xemacs) | |
9881 (require 'overlay) | |
9882 (require 'lucid)) ;; what else can we do ?? | |
9883 | |
9884 (defconst verilog-include-file-regexp | |
9885 "^`include\\s-+\"\\([^\n\"]*\\)\"" | |
9886 "Regexp that matches the include file.") | |
9887 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9888 (defvar verilog-mode-mouse-map |
79545 | 9889 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
9890 (set-keymap-parent map verilog-mode-map) | |
9891 ;; mouse button bindings | |
9892 (define-key map "\r" 'verilog-load-file-at-point) | |
9893 (if (featurep 'xemacs) | |
9894 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ? | |
9895 (define-key map [mouse-2] 'verilog-load-file-at-mouse)) | |
9896 (if (featurep 'xemacs) | |
9897 (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
|
9898 (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
|
9899 map) |
79546 | 9900 "Map containing mouse bindings for `verilog-mode'.") |
9901 | |
79545 | 9902 |
9903 (defun verilog-colorize-include-files (beg end old-len) | |
9904 "This function colorizes included files when the mouse passes over them. | |
9905 Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |
9906 (save-excursion | |
9907 (save-match-data | |
9908 (let (end-point) | |
9909 (goto-char end) | |
9910 (setq end-point (verilog-get-end-of-line)) | |
9911 (goto-char beg) | |
9912 (beginning-of-line) ; scan entire line ! | |
9913 ;; delete overlays existing on this line | |
9914 (let ((overlays (overlays-in (point) end-point))) | |
9915 (while overlays | |
9916 (if (and | |
9917 (overlay-get (car overlays) 'detachable) | |
9918 (overlay-get (car overlays) 'verilog-include-file)) | |
9919 (delete-overlay (car overlays))) | |
9920 (setq overlays (cdr overlays)))) ; let | |
9921 ;; make new ones, could reuse deleted one ? | |
9922 (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
|
9923 (let (ov) |
79545 | 9924 (goto-char (match-beginning 1)) |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9925 (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
|
9926 (overlay-put ov 'start-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9927 (overlay-put ov 'end-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9928 (overlay-put ov 'evaporate 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9929 (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
|
9930 (overlay-put ov 'mouse-face 'highlight) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
9931 (overlay-put ov 'local-map verilog-mode-mouse-map))))))) |
79545 | 9932 |
9933 | |
9934 (defun verilog-colorize-include-files-buffer () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9935 "Colorize an include file." |
79545 | 9936 (interactive) |
9937 ;; delete overlays | |
9938 (let ((overlays (overlays-in (point-min) (point-max)))) | |
9939 (while overlays | |
9940 (if (and | |
9941 (overlay-get (car overlays) 'detachable) | |
9942 (overlay-get (car overlays) 'verilog-include-file)) | |
9943 (delete-overlay (car overlays))) | |
9944 (setq overlays (cdr overlays)))) ; let | |
9945 ;; remake overlays | |
9946 (verilog-colorize-include-files (point-min) (point-max) nil)) | |
9947 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9948 ;; ffap-at-mouse isn't useful for Verilog mode. It uses library paths. |
79545 | 9949 ;; so define this function to do more or less the same as ffap-at-mouse |
9950 ;; but first resolve filename... | |
9951 (defun verilog-load-file-at-mouse (event) | |
9952 "Load file under button 2 click's EVENT. | |
9953 Files are checked based on `verilog-library-directories'." | |
9954 (interactive "@e") | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9955 (save-excursion ;; implement a Verilog specific ffap-at-mouse |
79545 | 9956 (mouse-set-point event) |
9957 (beginning-of-line) | |
9958 (if (looking-at verilog-include-file-regexp) | |
9959 (if (and (car (verilog-library-filenames | |
9960 (match-string 1) (buffer-file-name))) | |
9961 (file-readable-p (car (verilog-library-filenames | |
9962 (match-string 1) (buffer-file-name))))) | |
9963 (find-file (car (verilog-library-filenames | |
9964 (match-string 1) (buffer-file-name)))) | |
9965 (progn | |
9966 (message | |
9967 "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
|
9968 (match-string 1))))))) |
79545 | 9969 |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9970 ;; ffap isn't useable for Verilog mode. It uses library paths. |
79545 | 9971 ;; so define this function to do more or less the same as ffap |
9972 ;; but first resolve filename... | |
9973 (defun verilog-load-file-at-point () | |
9974 "Load file under point. | |
9975 Files are checked based on `verilog-library-directories'." | |
9976 (interactive) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9977 (save-excursion ;; implement a Verilog specific ffap |
79545 | 9978 (beginning-of-line) |
9979 (if (looking-at verilog-include-file-regexp) | |
9980 (if (and | |
9981 (car (verilog-library-filenames | |
9982 (match-string 1) (buffer-file-name))) | |
9983 (file-readable-p (car (verilog-library-filenames | |
9984 (match-string 1) (buffer-file-name))))) | |
9985 (find-file (car (verilog-library-filenames | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9986 (match-string 1) (buffer-file-name)))))))) |
79545 | 9987 |
9988 | |
9989 ;; | |
9990 ;; Bug reporting | |
9991 ;; | |
9992 | |
9993 (defun verilog-faq () | |
9994 "Tell the user their current version, and where to get the FAQ etc." | |
9995 (interactive) | |
9996 (with-output-to-temp-buffer "*verilog-mode help*" | |
9997 (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) | |
9998 (princ "\n") | |
9999 (princ "For new releases, see http://www.verilog.com\n") | |
10000 (princ "\n") | |
10001 (princ "For frequently asked questions, see http://www.veripool.com/verilog-mode-faq.html\n") | |
10002 (princ "\n") | |
10003 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | |
10004 (princ "\n"))) | |
10005 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10006 (autoload 'reporter-submit-bug-report "reporter") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10007 (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
|
10008 |
79545 | 10009 (defun verilog-submit-bug-report () |
10010 "Submit via mail a bug report on verilog-mode.el." | |
10011 (interactive) | |
10012 (let ((reporter-prompt-for-summary-p t)) | |
10013 (reporter-submit-bug-report | |
10014 "mac@verilog.com" | |
10015 (concat "verilog-mode v" verilog-mode-version) | |
10016 '( | |
10017 verilog-align-ifelse | |
10018 verilog-auto-endcomments | |
10019 verilog-auto-hook | |
10020 verilog-auto-indent-on-newline | |
10021 verilog-auto-inst-vector | |
10022 verilog-auto-inst-template-numbers | |
10023 verilog-auto-lineup | |
10024 verilog-auto-newline | |
10025 verilog-auto-save-policy | |
10026 verilog-auto-sense-defines-constant | |
10027 verilog-auto-sense-include-inputs | |
10028 verilog-before-auto-hook | |
10029 verilog-case-indent | |
10030 verilog-cexp-indent | |
10031 verilog-compiler | |
10032 verilog-coverage | |
10033 verilog-highlight-translate-off | |
10034 verilog-indent-begin-after-if | |
10035 verilog-indent-declaration-macros | |
10036 verilog-indent-level | |
10037 verilog-indent-level-behavioral | |
10038 verilog-indent-level-declaration | |
10039 verilog-indent-level-directive | |
10040 verilog-indent-level-module | |
10041 verilog-indent-lists | |
10042 verilog-library-flags | |
10043 verilog-library-directories | |
10044 verilog-library-extensions | |
10045 verilog-library-files | |
10046 verilog-linter | |
10047 verilog-minimum-comment-distance | |
10048 verilog-mode-hook | |
10049 verilog-simulator | |
10050 verilog-tab-always-indent | |
10051 verilog-tab-to-comment | |
10052 ) | |
10053 nil nil | |
10054 (concat "Hi Mac, | |
10055 | |
10056 I want to report a bug. I've read the `Bugs' section of `Info' on | |
10057 Emacs, so I know how to make a clear and unambiguous report. To get | |
10058 to that Info section, I typed | |
10059 | |
10060 M-x info RET m " invocation-name " RET m bugs RET | |
10061 | |
10062 Before I go further, I want to say that Verilog mode has changed my life. | |
10063 I save so much time, my files are colored nicely, my co workers respect | |
10064 my coding ability... until now. I'd really appreciate anything you | |
10065 could do to help me out with this minor deficiency in the product. | |
10066 | |
10067 If you have bugs with the AUTO functions, please CC the AUTOAUTHOR Wilson | |
10068 Snyder (wsnyder@wsnyder.org) and/or see http://www.veripool.com. | |
10069 You may also want to look at the Verilog-Mode FAQ, see | |
10070 http://www.veripool.com/verilog-mode-faq.html. | |
10071 | |
10072 To reproduce the bug, start a fresh Emacs via " invocation-name " | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10073 -no-init-file -no-site-file'. In a new buffer, in Verilog mode, type |
79545 | 10074 the code included below. |
10075 | |
10076 Given those lines, I expected [[Fill in here]] to happen; | |
10077 but instead, [[Fill in here]] happens!. | |
10078 | |
10079 == The code: ==")))) | |
10080 | |
79546 | 10081 (provide 'verilog-mode) |
10082 | |
79545 | 10083 ;; Local Variables: |
10084 ;; checkdoc-permit-comma-termination-flag:t | |
10085 ;; checkdoc-force-docstrings-flag:nil | |
10086 ;; End: | |
10087 | |
79552 | 10088 ;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f |
79545 | 10089 ;;; verilog-mode.el ends here |