Mercurial > emacs
annotate lisp/progmodes/verilog-mode.el @ 95307:7d02dd821410
(w32font_text_extents): Zero whole metrics struct first.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Mon, 26 May 2008 10:37:12 +0000 |
parents | e087ad93ebd1 |
children | 138e8a4ee5a6 |
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 | |
94116
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93340
diff
changeset
|
14 ;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this |
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93340
diff
changeset
|
15 ;; file on 19/3/2008, and the maintainer agreed that when a bug is |
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93340
diff
changeset
|
16 ;; filed in the Emacs bug reporting system against this file, a copy |
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93340
diff
changeset
|
17 ;; of the bug report be sent to the maintainer's email address. |
842d446b22d9
Cleanup the bug-report email addresses and make sure the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93340
diff
changeset
|
18 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
19 ;; This code supports Emacs 21.1 and later |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
20 ;; And XEmacs 21.1 and later |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
21 ;; 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
|
22 ;; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
23 ;; |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
24 |
79551 | 25 ;; This file is part of GNU Emacs. |
26 | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
27 ;; GNU Emacs is free software: you can redistribute it and/or modify |
79545 | 28 ;; it under the terms of the GNU General Public License as published by |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
29 ;; the Free Software Foundation, either version 3 of the License, or |
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
30 ;; (at your option) any later version. |
79551 | 31 |
32 ;; GNU Emacs is distributed in the hope that it will be useful, | |
79545 | 33 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
34 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
35 ;; GNU General Public License for more details. | |
36 | |
37 ;; You should have received a copy of the GNU General Public License | |
94673
52b7a8c22af5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94116
diff
changeset
|
38 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
79545 | 39 |
40 ;;; Commentary: | |
41 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
42 ;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs |
79545 | 43 |
44 ;; USAGE | |
45 ;; ===== | |
46 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
47 ;; A major mode for editing Verilog HDL source code. When you have |
79545 | 48 ;; entered Verilog mode, you may get more info by pressing C-h m. You |
49 ;; may also get online help describing various functions by: C-h f | |
50 ;; <Name of function you want described> | |
51 | |
52 ;; KNOWN BUGS / BUG REPORTS | |
53 ;; ======================= | |
54 | |
55 ;; 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
|
56 ;; 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
|
57 ;; has bugs. Please report any and all bugs to me at mac@verilog.com. |
79545 | 58 ;; Please use verilog-submit-bug-report to submit a report; type C-c |
59 ;; C-b to invoke this and as a result I will have a much easier time | |
60 ;; of reproducing the bug you find, and hence fixing it. | |
61 | |
62 ;; INSTALLING THE MODE | |
63 ;; =================== | |
64 | |
65 ;; An older version of this mode may be already installed as a part of | |
66 ;; 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
|
67 ;; your Emacs environment. Sometimes this is difficult for local |
79545 | 68 ;; political/control reasons, and hence you can always install a |
69 ;; private copy (or even a shared copy) which overrides the system | |
70 ;; default. | |
71 | |
72 ;; You can get step by step help in installing this file by going to | |
73 ;; <http://www.verilog.com/emacs_install.html> | |
74 | |
75 ;; 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
|
76 ;; automatic Verilog mode, put this file in your load path, and put |
79545 | 77 ;; the following in code (please un comment it first!) in your |
78 ;; .emacs, or in your site's site-load.el | |
79 | |
80 ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) | |
81 ; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist)) | |
82 ; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist)) | |
83 | |
84 ;; If you want to customize Verilog mode to fit your needs better, | |
85 ;; 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
|
86 ;; here are the defaults). Note also that if you use an Emacs that |
79545 | 87 ;; supports custom, it's probably better to use the custom menu to |
88 ;; edit these. | |
89 ;; | |
90 ;; Be sure to examine at the help for verilog-auto, and the other | |
91 ;; verilog-auto-* functions for some major coding time savers. | |
92 ;; | |
93 ; ;; User customization for Verilog mode | |
94 ; (setq verilog-indent-level 3 | |
95 ; verilog-indent-level-module 3 | |
96 ; verilog-indent-level-declaration 3 | |
97 ; verilog-indent-level-behavioral 3 | |
98 ; verilog-indent-level-directive 1 | |
99 ; verilog-case-indent 2 | |
100 ; verilog-auto-newline t | |
101 ; verilog-auto-indent-on-newline t | |
102 ; verilog-tab-always-indent t | |
103 ; verilog-auto-endcomments t | |
104 ; verilog-minimum-comment-distance 40 | |
105 ; verilog-indent-begin-after-if t | |
106 ; verilog-auto-lineup '(all) | |
107 ; verilog-highlight-p1800-keywords nil | |
108 ; verilog-linter "my_lint_shell_command" | |
109 ; ) | |
110 | |
111 ;; | |
112 | |
113 ;;; History: | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
114 ;; |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
115 ;; 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
|
116 ;; (This section is required to appease checkdoc.) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
117 |
79545 | 118 ;;; Code: |
119 | |
120 ;; This variable will always hold the version number of the mode | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
121 (defconst verilog-mode-version "423" |
80143
adbd1e116992
(verilog-mode-version, verilog-mode-release-date, erilog-mode-release-emacs,
Juanma Barranquero <lekktu@gmail.com>
parents:
80141
diff
changeset
|
122 "Version of this Verilog mode.") |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
123 (defconst verilog-mode-release-date "2008-05-07-GNU" |
80143
adbd1e116992
(verilog-mode-version, verilog-mode-release-date, erilog-mode-release-emacs,
Juanma Barranquero <lekktu@gmail.com>
parents:
80141
diff
changeset
|
124 "Release date of this Verilog mode.") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
125 (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
|
126 "If non-nil, this version of Verilog mode was released with Emacs itself.") |
79545 | 127 |
128 (defun verilog-version () | |
129 "Inform caller of the version of this file." | |
130 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
131 (message "Using verilog-mode version %s" verilog-mode-version)) |
79545 | 132 |
133 ;; 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
|
134 ;; Be sure to note which Emacs flavor and version added each feature. |
79546 | 135 (eval-when-compile |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
136 ;; 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
|
137 ;; 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
|
138 (when (featurep 'xemacs) |
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 'easymenu) |
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 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
143 (require 'regexp-opt) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
144 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
145 ;; 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
|
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 (load "skeleton") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
148 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
149 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
150 (if (fboundp 'when) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
151 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
152 (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
|
153 (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
|
154 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
155 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
156 (if (fboundp 'unless) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
157 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
158 (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
|
159 (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
|
160 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
161 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
162 (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
|
163 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
164 (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
|
165 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
166 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
167 (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
|
168 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
169 (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
|
170 (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
|
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 (require 'custom) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
174 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
175 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
176 (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
|
177 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
178 (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
|
179 "Return string of text matched by last search, without text properties. |
79545 | 180 NUM specifies which parenthesized expression in the last regexp. |
181 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. | |
182 Zero means the entire text matched by the whole regexp or whole string. | |
183 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
|
184 (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
|
185 (if string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
186 (let ((result |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
187 (substring string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
188 (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
|
189 (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
|
190 result) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
191 (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
|
192 (match-end num) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
193 (current-buffer))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
194 ) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
195 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
196 (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
|
197 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
|
198 ;; 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
|
199 (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
|
200 (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
|
201 (message |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
202 "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
|
203 (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
|
204 `(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
|
205 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
206 (if (fboundp 'defface) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
207 nil ; great! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
208 (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
|
209 `(make-face ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
210 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
211 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
212 (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
|
213 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
|
214 ;; 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
|
215 (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
|
216 `(customize ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
217 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
218 |
79545 | 219 ;; Provide a regular expression optimization routine, using regexp-opt |
220 ;; if provided by the user's elisp libraries | |
221 (eval-and-compile | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
222 ;; 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
|
223 ;; 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
|
224 (if (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
225 (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
|
226 ;; 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
|
227 (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
|
228 (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
|
229 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
230 ((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
|
231 (condition-case nil ; Hide this defun from emacses |
79545 | 232 ;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
|
233 (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
|
234 "Deal with differing number of required arguments for `regexp-opt'. |
79545 | 235 Call 'regexp-opt' on A and B." |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
236 (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
|
237 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
238 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
239 ((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
|
240 (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
|
241 "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
|
242 (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
|
243 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
244 (t nil))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
245 ;; 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
|
246 (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
|
247 "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
|
248 (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
|
249 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
250 ;; 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
|
251 (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
|
252 (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
|
253 (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
|
254 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
255 ;; Emacs. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
256 (defalias 'verilog-regexp-opt 'regexp-opt))) |
79545 | 257 |
79555
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
258 (eval-when-compile |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
259 (defun verilog-regexp-words (a) |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
260 "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
|
261 (concat "\\<" (verilog-regexp-opt a t) "\\>"))) |
79545 | 262 |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
263 (defun verilog-easy-menu-filter (menu) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
264 "Filter a easy-menu-define to support new features." |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
265 (cond ((not (featurep 'xemacs)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
266 menu) ;; GNU Emacs - passthru |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
267 ;; Xemacs doesn't support :help. Strip it. |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
268 ;; Recursively filter the a submenu |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
269 ((listp menu) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
270 (mapcar 'verilog-easy-menu-filter menu)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
271 ;; Look for [:help "blah"] and remove |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
272 ((vectorp menu) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
273 (let ((i 0) (out [])) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
274 (while (< i (length menu)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
275 (if (equal `:help (aref menu i)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
276 (setq i (+ 2 i)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
277 (setq out (vconcat out (vector (aref menu i))) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
278 i (1+ i)))) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
279 out)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
280 (t menu))) ;; Default - ok |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
281 ;;(verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
282 ;; `("Verilog" ("MA" ["SAA" nil :help "Help SAA"] ["SAB" nil :help "Help SAA"]) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
283 ;; "----" ["MB" nil :help "Help MB"])) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
284 |
79545 | 285 (defun verilog-customize () |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
286 "Customize variables and other settings used by Verilog-Mode." |
79545 | 287 (interactive) |
288 (customize-group 'verilog-mode)) | |
289 | |
290 (defun verilog-font-customize () | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
291 "Customize fonts used by Verilog-Mode." |
79545 | 292 (interactive) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
293 (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
|
294 (customize-apropos "font-lock-*" 'faces))) |
79545 | 295 |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
296 (defun verilog-booleanp (value) |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
297 "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
|
298 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
|
299 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
|
300 (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
|
301 |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
302 (defalias 'verilog-syntax-ppss |
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
303 (if (fboundp 'syntax-ppss) 'syntax-ppss |
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
304 (lambda (&optional pos) (parse-partial-sexp (point-min) (or pos (point)))))) |
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
305 |
79545 | 306 (defgroup verilog-mode nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
307 "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
|
308 :version "22.2" |
79545 | 309 :group 'languages) |
310 | |
311 ; (defgroup verilog-mode-fonts nil | |
312 ; "Facilitates easy customization fonts used in Verilog source text" | |
313 ; :link '(customize-apropos "font-lock-*" 'faces) | |
314 ; :group 'verilog-mode) | |
315 | |
316 (defgroup verilog-mode-indent nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
317 "Customize indentation and highlighting of Verilog source text." |
79545 | 318 :group 'verilog-mode) |
319 | |
320 (defgroup verilog-mode-actions nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
321 "Customize actions on Verilog source text." |
79545 | 322 :group 'verilog-mode) |
323 | |
324 (defgroup verilog-mode-auto nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
325 "Customize AUTO actions when expanding Verilog source text." |
79545 | 326 :group 'verilog-mode) |
327 | |
328 (defcustom verilog-linter | |
329 "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
|
330 "*Unix program and arguments to call to run a lint checker on Verilog source. |
79545 | 331 Depending on the `verilog-set-compile-command', this may be invoked when |
332 you type \\[compile]. When the compile completes, \\[next-error] will take | |
333 you to the next lint error." | |
334 :type 'string | |
335 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
336 ;; We don't mark it safe, as it's used as a shell command |
79545 | 337 |
338 (defcustom verilog-coverage | |
339 "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
|
340 "*Program and arguments to use to annotate for coverage Verilog source. |
79545 | 341 Depending on the `verilog-set-compile-command', this may be invoked when |
342 you type \\[compile]. When the compile completes, \\[next-error] will take | |
343 you to the next lint error." | |
344 :type 'string | |
345 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
346 ;; We don't mark it safe, as it's used as a shell command |
79545 | 347 |
348 (defcustom verilog-simulator | |
349 "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
|
350 "*Program and arguments to use to interpret Verilog source. |
79545 | 351 Depending on the `verilog-set-compile-command', this may be invoked when |
352 you type \\[compile]. When the compile completes, \\[next-error] will take | |
353 you to the next lint error." | |
354 :type 'string | |
355 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
356 ;; We don't mark it safe, as it's used as a shell command |
79545 | 357 |
358 (defcustom verilog-compiler | |
359 "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
|
360 "*Program and arguments to use to compile Verilog source. |
79545 | 361 Depending on the `verilog-set-compile-command', this may be invoked when |
362 you type \\[compile]. When the compile completes, \\[next-error] will take | |
363 you to the next lint error." | |
364 :type 'string | |
365 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
366 ;; We don't mark it safe, as it's used as a shell command |
79545 | 367 |
368 (defvar verilog-tool 'verilog-linter | |
369 "Which tool to use for building compiler-command. | |
370 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | |
371 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | |
372 menu. See `verilog-set-compile-command' for more information.") | |
373 | |
374 (defcustom verilog-highlight-translate-off nil | |
375 "*Non-nil means background-highlight code excluded from translation. | |
376 That is, all code between \"// synopsys translate_off\" and | |
377 \"// synopsys translate_on\" is highlighted using a different background color | |
378 \(face `verilog-font-lock-translate-off-face'). | |
379 | |
380 Note: This will slow down on-the-fly fontification (and thus editing). | |
381 | |
382 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | |
383 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." | |
384 :type 'boolean | |
385 :group 'verilog-mode-indent) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
386 ;; 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
|
387 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp) |
79545 | 388 |
389 (defcustom verilog-indent-level 3 | |
390 "*Indentation of Verilog statements with respect to containing block." | |
391 :group 'verilog-mode-indent | |
392 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
393 (put 'verilog-indent-level 'safe-local-variable 'integerp) |
79545 | 394 |
395 (defcustom verilog-indent-level-module 3 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
396 "*Indentation of Module level Verilog statements (eg always, initial). |
79545 | 397 Set to 0 to get initial and always statements lined up on the left side of |
398 your screen." | |
399 :group 'verilog-mode-indent | |
400 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
401 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) |
79545 | 402 |
403 (defcustom verilog-indent-level-declaration 3 | |
404 "*Indentation of declarations with respect to containing block. | |
405 Set to 0 to get them list right under containing block." | |
406 :group 'verilog-mode-indent | |
407 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
408 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) |
79545 | 409 |
410 (defcustom verilog-indent-declaration-macros nil | |
411 "*How to treat macro expansions in a declaration. | |
412 If nil, indent as: | |
413 input [31:0] a; | |
414 input `CP; | |
415 output c; | |
416 If non nil, treat as: | |
417 input [31:0] a; | |
418 input `CP ; | |
419 output c;" | |
420 :group 'verilog-mode-indent | |
421 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
422 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp) |
79545 | 423 |
424 (defcustom verilog-indent-lists t | |
425 "*How to treat indenting items in a list. | |
426 If t (the default), indent as: | |
427 always @( posedge a or | |
428 reset ) begin | |
429 | |
430 If nil, treat as: | |
431 always @( posedge a or | |
432 reset ) begin" | |
433 :group 'verilog-mode-indent | |
434 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
435 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp) |
79545 | 436 |
437 (defcustom verilog-indent-level-behavioral 3 | |
438 "*Absolute indentation of first begin in a task or function block. | |
439 Set to 0 to get such code to start at the left side of the screen." | |
440 :group 'verilog-mode-indent | |
441 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
442 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) |
79545 | 443 |
444 (defcustom verilog-indent-level-directive 1 | |
445 "*Indentation to add to each level of `ifdef declarations. | |
446 Set to 0 to have all directives start at the left side of the screen." | |
447 :group 'verilog-mode-indent | |
448 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
449 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) |
79545 | 450 |
451 (defcustom verilog-cexp-indent 2 | |
452 "*Indentation of Verilog statements split across lines." | |
453 :group 'verilog-mode-indent | |
454 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
455 (put 'verilog-cexp-indent 'safe-local-variable 'integerp) |
79545 | 456 |
457 (defcustom verilog-case-indent 2 | |
458 "*Indentation for case statements." | |
459 :group 'verilog-mode-indent | |
460 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
461 (put 'verilog-case-indent 'safe-local-variable 'integerp) |
79545 | 462 |
463 (defcustom verilog-auto-newline t | |
464 "*True means automatically newline after semicolons." | |
465 :group 'verilog-mode-indent | |
466 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
467 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 468 |
469 (defcustom verilog-auto-indent-on-newline t | |
470 "*True means automatically indent line after newline." | |
471 :group 'verilog-mode-indent | |
472 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
473 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 474 |
475 (defcustom verilog-tab-always-indent t | |
476 "*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
|
477 A nil value means TAB will only reindent when at the beginning of the line." |
79545 | 478 :group 'verilog-mode-indent |
479 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
480 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp) |
79545 | 481 |
482 (defcustom verilog-tab-to-comment nil | |
483 "*True means TAB moves to the right hand column in preparation for a comment." | |
484 :group 'verilog-mode-actions | |
485 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
486 (put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp) |
79545 | 487 |
488 (defcustom verilog-indent-begin-after-if t | |
489 "*If true, indent begin statements following if, else, while, for and repeat. | |
490 Otherwise, line them up." | |
491 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
492 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
493 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp) |
79545 | 494 |
495 | |
496 (defcustom verilog-align-ifelse nil | |
497 "*If true, align `else' under matching `if'. | |
498 Otherwise else is lined up with first character on line holding matching if." | |
499 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
500 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
501 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp) |
79545 | 502 |
503 (defcustom verilog-minimum-comment-distance 10 | |
504 "*Minimum distance (in lines) between begin and end required before a comment. | |
505 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
|
506 default avoids too many redundant comments in tight quarters." |
79545 | 507 :group 'verilog-mode-indent |
508 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
509 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) |
79545 | 510 |
511 (defcustom verilog-auto-lineup '(declaration) | |
512 "*Algorithm for lining up statements on multiple lines. | |
513 | |
514 If this list contains the symbol 'all', then all line ups described below | |
515 are done. | |
516 | |
517 If this list contains the symbol 'declaration', then declarations are lined up | |
518 with any preceding declarations, taking into account widths and the like, so | |
519 for example the code: | |
520 reg [31:0] a; | |
521 reg b; | |
522 would become | |
523 reg [31:0] a; | |
524 reg b; | |
525 | |
526 If this list contains the symbol 'assignment', then assignments are lined up | |
527 with any preceding assignments, so for example the code | |
528 a_long_variable = b + c; | |
529 d = e + f; | |
530 would become | |
531 a_long_variable = b + c; | |
532 d = e + f;" | |
533 | |
534 ;; The following is not implemented: | |
535 ;If this list contains the symbol 'case', then case items are lined up | |
536 ;with any preceding case items, so for example the code | |
537 ; case (a) begin | |
538 ; a_long_state : a = 3; | |
539 ; b: a = 4; | |
540 ; endcase | |
541 ;would become | |
542 ; case (a) begin | |
543 ; a_long_state : a = 3; | |
544 ; b : a = 4; | |
545 ; endcase | |
546 ; | |
547 | |
548 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
549 :type 'list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
550 (put 'verilog-auto-lineup 'safe-local-variable 'listp) |
79545 | 551 |
552 (defcustom verilog-highlight-p1800-keywords nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
553 "*True means highlight words newly reserved by IEEE-1800. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
554 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
|
555 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
|
556 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
|
557 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
|
558 to see the effect as font color choices are cached by Emacs." |
79545 | 559 :group 'verilog-mode-indent |
560 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
561 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp) |
79545 | 562 |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
563 (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
|
564 "*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
|
565 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
|
566 `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
|
567 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
|
568 :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
|
569 :type 'boolean) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
570 (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
|
571 |
79545 | 572 (defcustom verilog-auto-endcomments t |
573 "*True means insert a comment /* ... */ after 'end's. | |
574 The name of the function or case will be set between the braces." | |
575 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
576 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
577 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) |
79545 | 578 |
579 (defcustom verilog-auto-read-includes nil | |
580 "*True means to automatically read includes before AUTOs. | |
581 This will do a `verilog-read-defines' and `verilog-read-includes' before | |
582 each AUTO expansion. This makes it easier to embed defines and includes, | |
583 but can result in very slow reading times if there are many or large | |
584 include files." | |
585 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
586 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
587 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp) |
79545 | 588 |
589 (defcustom verilog-auto-save-policy nil | |
590 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | |
591 A value of `force' will always do a \\[verilog-auto] automatically if | |
592 needed on every save. A value of `detect' will do \\[verilog-auto] | |
593 automatically when it thinks necessary. A value of `ask' will query the | |
594 user when it thinks updating is needed. | |
595 | |
596 You should not rely on the 'ask or 'detect policies, they are safeguards | |
597 only. They do not detect when AUTOINSTs need to be updated because a | |
598 sub-module's port list has changed." | |
599 :group 'verilog-mode-actions | |
600 :type '(choice (const nil) (const ask) (const detect) (const force))) | |
601 | |
602 (defcustom verilog-auto-star-expand t | |
603 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | |
604 They will be expanded in the same way as if there was a AUTOINST in the | |
605 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." | |
606 :group 'verilog-mode-actions | |
607 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
608 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp) |
79545 | 609 |
610 (defcustom verilog-auto-star-save nil | |
611 "*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
|
612 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
|
613 Only meaningful to those created due to `verilog-auto-star-expand' being set. |
79545 | 614 |
615 Instead of setting this, you may want to use /*AUTOINST*/, which will | |
616 always be saved." | |
617 :group 'verilog-mode-actions | |
618 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
619 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp) |
79545 | 620 |
621 (defvar verilog-auto-update-tick nil | |
622 "Modification tick at which autos were last performed.") | |
623 | |
624 (defvar verilog-auto-last-file-locals nil | |
625 "Text from file-local-variables during last evaluation.") | |
626 | |
627 (defvar verilog-error-regexp-add-didit nil) | |
628 (defvar verilog-error-regexp nil) | |
629 (setq verilog-error-regexp-add-didit nil | |
630 verilog-error-regexp | |
631 '( | |
632 ; SureLint | |
633 ;; ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) | |
634 ; Most SureFire tools | |
635 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 ) | |
636 ("\ | |
637 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
638 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) | |
639 ; xsim | |
640 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED] | |
641 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) | |
642 ; vcs | |
643 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) | |
644 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) | |
645 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) | |
646 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) | |
647 ; Verilator | |
648 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
649 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) | |
650 ; vxl | |
651 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) | |
652 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl | |
653 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2) | |
654 ; nc-verilog | |
655 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2) | |
656 ; Leda | |
657 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2) | |
658 ) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
659 ; "*List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist for the formatting." |
79545 | 660 ) |
661 | |
662 (defvar verilog-error-font-lock-keywords | |
663 '( | |
664 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t) | |
665 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t) | |
666 | |
667 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t) | |
668 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t) | |
669 | |
670 ("\ | |
671 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
672 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
673 ("\ | |
674 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
675 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
676 | |
677 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t) | |
678 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t) | |
679 | |
680 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t) | |
681 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t) | |
682 | |
683 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
684 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
685 | |
686 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
687 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t) | |
688 | |
689 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t) | |
690 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
691 ; vxl | |
692 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
693 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
694 | |
695 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t) | |
696 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t) | |
697 | |
698 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t) | |
699 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t) | |
700 ; nc-verilog | |
701 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t) | |
702 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | |
703 ; Leda | |
704 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | |
705 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) | |
706 ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
707 "*Keywords to also highlight in Verilog *compilation* buffers.") |
79545 | 708 |
709 (defcustom verilog-library-flags '("") | |
710 "*List of standard Verilog arguments to use for /*AUTOINST*/. | |
711 These arguments are used to find files for `verilog-auto', and match | |
712 the flags accepted by a standard Verilog-XL simulator. | |
713 | |
714 -f filename Reads more `verilog-library-flags' from the filename. | |
715 +incdir+dir Adds the directory to `verilog-library-directories'. | |
716 -Idir Adds the directory to `verilog-library-directories'. | |
717 -y dir Adds the directory to `verilog-library-directories'. | |
718 +libext+.v Adds the extensions to `verilog-library-extensions'. | |
719 -v filename Adds the filename to `verilog-library-files'. | |
720 | |
721 filename Adds the filename to `verilog-library-files'. | |
722 This is not recommended, -v is a better choice. | |
723 | |
724 You might want these defined in each file; put at the *END* of your file | |
725 something like: | |
726 | |
727 // Local Variables: | |
728 // verilog-library-flags:(\"-y dir -y otherdir\") | |
729 // End: | |
730 | |
731 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
|
732 are only insured to be correct when the file is first visited. Thus if you |
79545 | 733 have problems, use \\[find-alternate-file] RET to have these take effect. |
734 | |
735 See also the variables mentioned above." | |
736 :group 'verilog-mode-auto | |
737 :type '(repeat string)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
738 (put 'verilog-library-flags 'safe-local-variable 'listp) |
79545 | 739 |
740 (defcustom verilog-library-directories '(".") | |
741 "*List of directories when looking for files for /*AUTOINST*/. | |
742 The directory may be relative to the current file, or absolute. | |
743 Environment variables are also expanded in the directory names. | |
744 Having at least the current directory is a good idea. | |
745 | |
746 You might want these defined in each file; put at the *END* of your file | |
747 something like: | |
748 | |
749 // Local Variables: | |
750 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\") | |
751 // End: | |
752 | |
753 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
|
754 are only insured to be correct when the file is first visited. Thus if you |
79545 | 755 have problems, use \\[find-alternate-file] RET to have these take effect. |
756 | |
757 See also `verilog-library-flags', `verilog-library-files' | |
758 and `verilog-library-extensions'." | |
759 :group 'verilog-mode-auto | |
760 :type '(repeat file)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
761 (put 'verilog-library-directories 'safe-local-variable 'listp) |
79545 | 762 |
763 (defcustom verilog-library-files '() | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
764 "*List of files to search for modules. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
765 AUTOINST will use this when it needs to resolve a module name. |
79545 | 766 This is a complete path, usually to a technology file with many standard |
767 cells defined in it. | |
768 | |
769 You might want these defined in each file; put at the *END* of your file | |
770 something like: | |
771 | |
772 // Local Variables: | |
773 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\") | |
774 // End: | |
775 | |
776 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
|
777 are only insured to be correct when the file is first visited. Thus if you |
79545 | 778 have problems, use \\[find-alternate-file] RET to have these take effect. |
779 | |
780 See also `verilog-library-flags', `verilog-library-directories'." | |
781 :group 'verilog-mode-auto | |
782 :type '(repeat directory)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
783 (put 'verilog-library-files 'safe-local-variable 'listp) |
79545 | 784 |
785 (defcustom verilog-library-extensions '(".v") | |
786 "*List of extensions to use when looking for files for /*AUTOINST*/. | |
787 See also `verilog-library-flags', `verilog-library-directories'." | |
788 :type '(repeat string) | |
789 :group 'verilog-mode-auto) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
790 (put 'verilog-library-extensions 'safe-local-variable 'listp) |
79545 | 791 |
792 (defcustom verilog-active-low-regexp nil | |
793 "*If set, treat signals matching this regexp as active low. | |
794 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | |
795 you will probably also need `verilog-auto-reset-widths' set." | |
796 :group 'verilog-mode-auto | |
797 :type 'string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
798 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) |
79545 | 799 |
800 (defcustom verilog-auto-sense-include-inputs nil | |
801 "*If true, AUTOSENSE should include all inputs. | |
802 If nil, only inputs that are NOT output signals in the same block are | |
803 included." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
804 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
805 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
806 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp) |
79545 | 807 |
808 (defcustom verilog-auto-sense-defines-constant nil | |
809 "*If true, AUTOSENSE should assume all defines represent constants. | |
810 When true, the defines will not be included in sensitivity lists. To | |
811 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
|
812 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
|
813 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
814 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
815 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) |
79545 | 816 |
817 (defcustom verilog-auto-reset-widths t | |
818 "*If true, AUTORESET should determine the width of signals. | |
819 This is then used to set the width of the zero (32'h0 for example). This | |
820 is required by some lint tools that aren't smart enough to ignore widths of | |
821 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
|
822 the MSB or LSB of a signal inside an AUTORESET." |
79545 | 823 :type 'boolean |
824 :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
|
825 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp) |
79545 | 826 |
827 (defcustom verilog-assignment-delay "" | |
828 "*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
|
829 :group 'verilog-mode-auto |
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-assignment-delay 'safe-local-variable 'stringp) |
79545 | 832 |
833 (defcustom verilog-auto-inst-vector t | |
834 "*If true, when creating default ports with AUTOINST, use bus subscripts. | |
835 If nil, skip the subscript when it matches the entire bus as declared in | |
836 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
|
837 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
|
838 speed up some simulators, but is less general and harder to read, so avoid." |
79545 | 839 :group 'verilog-mode-auto |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
840 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
841 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp) |
79545 | 842 |
843 (defcustom verilog-auto-inst-template-numbers nil | |
844 "*If true, when creating templated ports with AUTOINST, add a comment. | |
845 The comment will add the line number of the template that was used for that | |
846 port declaration. Setting this aids in debugging, but nil is suggested for | |
847 regular use to prevent large numbers of merge conflicts." | |
848 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
849 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
850 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) |
79545 | 851 |
852 (defvar verilog-auto-inst-column 40 | |
853 "Column number for first part of auto-inst.") | |
854 | |
855 (defcustom verilog-auto-input-ignore-regexp nil | |
856 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | |
857 See the \\[verilog-faq] for examples on using this." | |
858 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
859 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
860 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 861 |
862 (defcustom verilog-auto-inout-ignore-regexp nil | |
863 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | |
864 See the \\[verilog-faq] for examples on using this." | |
865 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
866 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
867 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 868 |
869 (defcustom verilog-auto-output-ignore-regexp nil | |
870 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | |
871 See the \\[verilog-faq] for examples on using this." | |
872 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
873 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
874 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 875 |
876 (defcustom verilog-auto-unused-ignore-regexp nil | |
877 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | |
878 See the \\[verilog-faq] for examples on using this." | |
879 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
880 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
881 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 882 |
883 (defcustom verilog-typedef-regexp nil | |
884 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | |
885 For example, \"_t$\" matches typedefs named with _t, as in the C language." | |
886 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
887 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
888 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) |
79545 | 889 |
890 (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
|
891 "*Hook run after Verilog mode is loaded." |
79545 | 892 :type 'hook |
893 :group 'verilog-mode) | |
894 | |
895 (defcustom verilog-auto-hook nil | |
896 "*Hook run after `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
897 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
898 :type 'hook) |
79545 | 899 |
900 (defcustom verilog-before-auto-hook nil | |
901 "*Hook run before `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
902 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
903 :type 'hook) |
79545 | 904 |
905 (defcustom verilog-delete-auto-hook nil | |
906 "*Hook run after `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
907 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
908 :type 'hook) |
79545 | 909 |
910 (defcustom verilog-before-delete-auto-hook nil | |
911 "*Hook run before `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
912 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
913 :type 'hook) |
79545 | 914 |
915 (defcustom verilog-getopt-flags-hook nil | |
916 "*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
|
917 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
918 :type 'hook) |
79545 | 919 |
920 (defcustom verilog-before-getopt-flags-hook nil | |
921 "*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
|
922 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
923 :type 'hook) |
79545 | 924 |
925 (defvar verilog-imenu-generic-expression | |
926 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | |
927 ("*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
|
928 "Imenu expression for Verilog mode. See `imenu-generic-expression'.") |
79545 | 929 |
930 ;; | |
931 ;; provide a verilog-header function. | |
932 ;; Customization variables: | |
933 ;; | |
934 (defvar verilog-date-scientific-format nil | |
935 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17). | |
936 If nil, in European format (e.g. 17.09.1997). The brain-dead American | |
937 format (e.g. 09/17/1997) is not supported.") | |
938 | |
939 (defvar verilog-company nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
940 "*Default name of Company for Verilog header. |
79545 | 941 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
|
942 (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
|
943 |
79545 | 944 (defvar verilog-project nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
945 "*Default name of Project for Verilog header. |
79545 | 946 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
|
947 (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
|
948 |
79549
d9595ed9b084
* progmodes/verilog-mode.el (verilog-mode-map): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79547
diff
changeset
|
949 (defvar verilog-mode-map |
79546 | 950 (let ((map (make-sparse-keymap))) |
951 (define-key map ";" 'electric-verilog-semi) | |
952 (define-key map [(control 59)] 'electric-verilog-semi-with-comment) | |
953 (define-key map ":" 'electric-verilog-colon) | |
954 ;;(define-key map "=" 'electric-verilog-equal) | |
955 (define-key map "\`" 'electric-verilog-tick) | |
956 (define-key map "\t" 'electric-verilog-tab) | |
957 (define-key map "\r" 'electric-verilog-terminate-line) | |
958 ;; backspace/delete key bindings | |
959 (define-key map [backspace] 'backward-delete-char-untabify) | |
960 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable | |
961 (define-key map [delete] 'delete-char) | |
962 (define-key map [(meta delete)] 'kill-word)) | |
963 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) | |
964 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) | |
965 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | |
966 (define-key map "\M-\t" 'verilog-complete-word) | |
967 (define-key map "\M-?" 'verilog-show-completions) | |
968 (define-key map "\C-c\`" 'verilog-lint-off) | |
969 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | |
970 (define-key map "\C-c\C-r" 'verilog-label-be) | |
971 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) | |
972 (define-key map "\C-c=" 'verilog-pretty-expr) | |
973 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) | |
974 (define-key map "\M-*" 'verilog-star-comment) | |
975 (define-key map "\C-c\C-c" 'verilog-comment-region) | |
976 (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
|
977 (when (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
978 (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
|
979 (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
|
980 (define-key map "\M-\C-e" 'verilog-end-of-defun)) |
79546 | 981 (define-key map "\C-c\C-d" 'verilog-goto-defun) |
982 (define-key map "\C-c\C-k" 'verilog-delete-auto) | |
983 (define-key map "\C-c\C-a" 'verilog-auto) | |
984 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) | |
985 (define-key map "\C-c\C-z" 'verilog-inject-auto) | |
986 (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
|
987 (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
|
988 map) |
79545 | 989 "Keymap used in Verilog mode.") |
990 | |
991 ;; menus | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
992 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
993 verilog-menu verilog-mode-map "Menu for Verilog mode" |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
994 (verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
995 '("Verilog" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
996 ("Choose Compilation Action" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
997 ["None" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
998 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
999 (setq verilog-tool nil) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1000 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1001 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1002 :selected (equal verilog-tool nil) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1003 :help "When invoking compilation, use compile-command"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1004 ["Lint" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1005 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1006 (setq verilog-tool 'verilog-linter) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1007 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1008 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1009 :selected (equal verilog-tool `verilog-linter) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1010 :help "When invoking compilation, use lint checker"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1011 ["Coverage" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1012 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1013 (setq verilog-tool 'verilog-coverage) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1014 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1015 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1016 :selected (equal verilog-tool `verilog-coverage) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1017 :help "When invoking compilation, annotate for coverage"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1018 ["Simulator" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1019 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1020 (setq verilog-tool 'verilog-simulator) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1021 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1022 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1023 :selected (equal verilog-tool `verilog-simulator) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1024 :help "When invoking compilation, interpret Verilog source"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1025 ["Compiler" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1026 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1027 (setq verilog-tool 'verilog-compiler) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1028 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1029 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1030 :selected (equal verilog-tool `verilog-compiler) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1031 :help "When invoking compilation, compile Verilog source"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1032 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1033 ("Move" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1034 ["Beginning of function" verilog-beg-of-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1035 :keys "C-M-a" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1036 :help "Move backward to the beginning of the current function or procedure"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1037 ["End of function" verilog-end-of-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1038 :keys "C-M-e" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1039 :help "Move forward to the end of the current function or procedure"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1040 ["Mark function" verilog-mark-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1041 :keys "C-M-h" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1042 :help "Mark the current Verilog function or procedure"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1043 ["Goto function/module" verilog-goto-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1044 :help "Move to specified Verilog module/task/function"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1045 ["Move to beginning of block" electric-verilog-backward-sexp |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1046 :help "Move backward over one balanced expression"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1047 ["Move to end of block" electric-verilog-forward-sexp |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1048 :help "Move forward over one balanced expression"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1049 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1050 ("Comments" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1051 ["Comment Region" verilog-comment-region |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1052 :help "Put marked area into a comment"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1053 ["UnComment Region" verilog-uncomment-region |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1054 :help "Uncomment an area commented with Comment Region"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1055 ["Multi-line comment insert" verilog-star-comment |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1056 :help "Insert Verilog /* */ comment at point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1057 ["Lint error to comment" verilog-lint-off |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1058 :help "Convert a Verilog linter warning line into a disable statement"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1059 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1060 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1061 ["Compile" compile |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1062 :help "Perform compilation-action (above) on the current buffer"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1063 ["AUTO, Save, Compile" verilog-auto-save-compile |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1064 :help "Recompute AUTOs, save buffer, and compile"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1065 ["Next Compile Error" next-error |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1066 :help "Visit next compilation error message and corresponding source code"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1067 ["Ignore Lint Warning at point" verilog-lint-off |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1068 :help "Convert a Verilog linter warning line into a disable statement"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1069 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1070 ["Line up declarations around point" verilog-pretty-declarations |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1071 :help "Line up declarations around point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1072 ["Line up equations around point" verilog-pretty-expr |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1073 :help "Line up expressions around point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1074 ["Redo/insert comments on every end" verilog-label-be |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1075 :help "Label matching begin ... end statements"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1076 ["Expand [x:y] vector line" verilog-expand-vector |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1077 :help "Take a signal vector on the current line and expand it to multiple lines"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1078 ["Insert begin-end block" verilog-insert-block |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1079 :help "Insert begin ... end"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1080 ["Complete word" verilog-complete-word |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1081 :help "Complete word at point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1082 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1083 ["Recompute AUTOs" verilog-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1084 :help "Expand AUTO meta-comment statements"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1085 ["Kill AUTOs" verilog-delete-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1086 :help "Remove AUTO expansions"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1087 ["Inject AUTOs" verilog-inject-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1088 :help "Inject AUTOs into legacy non-AUTO buffer"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1089 ("AUTO Help..." |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1090 ["AUTO General" (describe-function 'verilog-auto) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1091 :help "Help introduction on AUTOs"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1092 ["AUTO Library Flags" (describe-variable 'verilog-library-flags) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1093 :help "Help on verilog-library-flags"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1094 ["AUTO Library Path" (describe-variable 'verilog-library-directories) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1095 :help "Help on verilog-library-directories"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1096 ["AUTO Library Files" (describe-variable 'verilog-library-files) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1097 :help "Help on verilog-library-files"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1098 ["AUTO Library Extensions" (describe-variable 'verilog-library-extensions) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1099 :help "Help on verilog-library-extensions"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1100 ["AUTO `define Reading" (describe-function 'verilog-read-defines) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1101 :help "Help on reading `defines"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1102 ["AUTO `include Reading" (describe-function 'verilog-read-includes) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1103 :help "Help on parsing `includes"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1104 ["AUTOARG" (describe-function 'verilog-auto-arg) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1105 :help "Help on AUTOARG - declaring module port list"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1106 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1107 :help "Help on AUTOASCIIENUM - creating ASCII for enumerations"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1108 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1109 :help "Help on AUTOINOUTMODULE - copying i/o from another file"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1110 ["AUTOINOUT" (describe-function 'verilog-auto-inout) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1111 :help "Help on AUTOINOUT - adding inouts from cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1112 ["AUTOINPUT" (describe-function 'verilog-auto-input) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1113 :help "Help on AUTOINPUT - adding inputs from cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1114 ["AUTOINST" (describe-function 'verilog-auto-inst) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1115 :help "Help on AUTOINST - adding pins for cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1116 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1117 :help "Help on expanding Verilog-2001 .* pins"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1118 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1119 :help "Help on AUTOINSTPARAM - adding parameter pins to cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1120 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1121 :help "Help on AUTOOUTPUT - adding outputs from cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1122 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1123 :help "Help on AUTOOUTPUTEVERY - adding outputs of all signals"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1124 ["AUTOREG" (describe-function 'verilog-auto-reg) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1125 :help "Help on AUTOREG - declaring registers for non-wires"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1126 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1127 :help "Help on AUTOREGINPUT - declaring inputs for non-wires"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1128 ["AUTORESET" (describe-function 'verilog-auto-reset) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1129 :help "Help on AUTORESET - resetting always blocks"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1130 ["AUTOSENSE" (describe-function 'verilog-auto-sense) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1131 :help "Help on AUTOSENSE - sensitivity lists for always blocks"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1132 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1133 :help "Help on AUTOTIEOFF - tieing off unused outputs"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1134 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1135 :help "Help on AUTOUNUSED - terminating unused inputs"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1136 ["AUTOWIRE" (describe-function 'verilog-auto-wire) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1137 :help "Help on AUTOWIRE - declaring wires for cells"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1138 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1139 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1140 ["Submit bug report" verilog-submit-bug-report |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1141 :help "Submit via mail a bug report on verilog-mode.el"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1142 ["Version and FAQ" verilog-faq |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1143 :help "Show the current version, and where to get the FAQ etc"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1144 ["Customize Verilog Mode..." verilog-customize |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1145 :help "Customize variables and other settings used by Verilog-Mode"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1146 ["Customize Verilog Fonts & Colors" verilog-font-customize |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1147 :help "Customize fonts used by Verilog-Mode."]))) |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1148 |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1149 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1150 verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog." |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1151 (verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1152 '("Statements" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1153 ["Header" verilog-sk-header |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1154 :help "Insert a header block at the top of file"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1155 ["Comment" verilog-sk-comment |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1156 :help "Insert a comment block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1157 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1158 ["Module" verilog-sk-module |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1159 :help "Insert a module .. (/*AUTOARG*/);.. endmodule block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1160 ["Primitive" verilog-sk-primitive |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1161 :help "Insert a primitive .. (.. );.. endprimitive block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1162 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1163 ["Input" verilog-sk-input |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1164 :help "Insert an input declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1165 ["Output" verilog-sk-output |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1166 :help "Insert an output declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1167 ["Inout" verilog-sk-inout |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1168 :help "Insert an inout declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1169 ["Wire" verilog-sk-wire |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1170 :help "Insert a wire declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1171 ["Reg" verilog-sk-reg |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1172 :help "Insert a register declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1173 ["Define thing under point as a register" verilog-sk-define-signal |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1174 :help "Define signal under point as a register at the top of the module"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1175 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1176 ["Initial" verilog-sk-initial |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1177 :help "Insert an initial begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1178 ["Always" verilog-sk-always |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1179 :help "Insert an always @(AS) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1180 ["Function" verilog-sk-function |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1181 :help "Insert a function .. begin .. end endfunction block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1182 ["Task" verilog-sk-task |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1183 :help "Insert a task .. begin .. end endtask block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1184 ["Specify" verilog-sk-specify |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1185 :help "Insert a specify .. endspecify block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1186 ["Generate" verilog-sk-generate |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1187 :help "Insert a generate .. endgenerate block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1188 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1189 ["Begin" verilog-sk-begin |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1190 :help "Insert a begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1191 ["If" verilog-sk-if |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1192 :help "Insert an if (..) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1193 ["(if) else" verilog-sk-else-if |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1194 :help "Insert an else if (..) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1195 ["For" verilog-sk-for |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1196 :help "Insert a for (...) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1197 ["While" verilog-sk-while |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1198 :help "Insert a while (...) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1199 ["Fork" verilog-sk-fork |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1200 :help "Insert a fork begin .. end .. join block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1201 ["Repeat" verilog-sk-repeat |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1202 :help "Insert a repeat (..) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1203 ["Case" verilog-sk-case |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1204 :help "Insert a case block, prompting for details"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1205 ["Casex" verilog-sk-casex |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1206 :help "Insert a casex (...) item: begin.. end endcase block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1207 ["Casez" verilog-sk-casez |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1208 :help "Insert a casez (...) item: begin.. end endcase block"]))) |
79545 | 1209 |
1210 (defvar verilog-mode-abbrev-table nil | |
1211 "Abbrev table in use in Verilog-mode buffers.") | |
1212 | |
1213 (define-abbrev-table 'verilog-mode-abbrev-table ()) | |
1214 | |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1215 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1216 ;; Macros |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1217 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1218 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1219 (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
|
1220 "Replace occurrences of FROM-STRING with TO-STRING. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1221 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
|
1222 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
|
1223 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
|
1224 ;; Hopefully soon to a emacs built-in |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1225 (let ((start 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1226 (while (string-match from-string string start) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1227 (setq string (replace-match to-string fixedcase literal string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1228 start (min (length string) (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1229 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1230 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1231 (defsubst verilog-string-remove-spaces (string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1232 "Remove spaces surrounding STRING." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1233 (save-match-data |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1234 (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
|
1235 (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
|
1236 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1237 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1238 (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1239 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1240 "Like `re-search-forward', but skips over match in comments or strings." |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1241 (store-match-data '(nil nil)) ;; So match-end will return nil if no matches found |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1242 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1243 (re-search-forward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1244 (and (verilog-skip-forward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1245 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1246 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1247 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1248 (< (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1249 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1250 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1251 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1252 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1253 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1254 "Like `re-search-backward', but skips over match in comments or strings." |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1255 (store-match-data '(nil nil)) ;; So match-end will return nil if no matches found |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1256 (while (and |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1257 (re-search-backward REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1258 (and (verilog-skip-backward-comment-or-string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1259 (progn |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1260 (store-match-data '(nil nil)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1261 (if BOUND |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1262 (> (point) BOUND) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1263 t))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1264 (match-end 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1265 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1266 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1267 "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
|
1268 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
|
1269 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
|
1270 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
|
1271 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1272 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1273 (re-search-forward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1274 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1275 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1276 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1277 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1278 (defsubst verilog-re-search-backward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1279 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1280 "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
|
1281 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
|
1282 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
|
1283 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
|
1284 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1285 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1286 (re-search-backward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1287 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1288 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1289 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1290 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1291 (defsubst verilog-get-beg-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1292 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1293 (beginning-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1294 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1295 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1296 (defsubst verilog-get-end-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1297 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1298 (end-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1299 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1300 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1301 (defsubst verilog-within-string () |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1302 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1303 (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
|
1304 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1305 (defvar compile-command) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1306 |
79545 | 1307 ;; compilation program |
1308 (defun verilog-set-compile-command () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1309 "Function to compute shell command to compile Verilog. |
79545 | 1310 |
1311 This reads `verilog-tool' and sets `compile-command'. This specifies the | |
1312 program that executes when you type \\[compile] or | |
1313 \\[verilog-auto-save-compile]. | |
1314 | |
1315 By default `verilog-tool' uses a Makefile if one exists in the current | |
1316 directory. If not, it is set to the `verilog-linter', `verilog-coverage', | |
1317 `verilog-simulator', or `verilog-compiler' variables, as selected with the | |
1318 Verilog -> \"Choose Compilation Action\" menu. | |
1319 | |
1320 You should set `verilog-tool' or the other variables to the path and | |
1321 arguments for your Verilog simulator. For example: | |
1322 \"vcs -p123 -O\" | |
1323 or a string like: | |
1324 \"(cd /tmp; surecov %s)\". | |
1325 | |
1326 In the former case, the path to the current buffer is concat'ed to the | |
1327 value of `verilog-tool'; in the later, the path to the current buffer is | |
1328 substituted for the %s. | |
1329 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1330 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
|
1331 current buffer, without the directory portion, will be substituted." |
79545 | 1332 (interactive) |
1333 (cond | |
1334 ((or (file-exists-p "makefile") ;If there is a makefile, use it | |
1335 (file-exists-p "Makefile")) | |
1336 (make-local-variable 'compile-command) | |
1337 (setq compile-command "make ")) | |
1338 (t | |
1339 (make-local-variable 'compile-command) | |
1340 (setq compile-command | |
1341 (if verilog-tool | |
1342 (if (string-match "%s" (eval verilog-tool)) | |
1343 (format (eval verilog-tool) (or buffer-file-name "")) | |
1344 (concat (eval verilog-tool) " " (or buffer-file-name ""))) | |
1345 "")))) | |
1346 (verilog-modify-compile-command)) | |
1347 | |
1348 (defun verilog-modify-compile-command () | |
1349 "Replace meta-information in `compile-command'. | |
1350 Where __FILE__ appears in the string, the current buffer's file-name, | |
1351 without the directory portion, will be substituted." | |
1352 (when (and | |
1353 (stringp compile-command) | |
1354 (string-match "\\b__FILE__\\b" compile-command)) | |
1355 (make-local-variable 'compile-command) | |
1356 (setq compile-command | |
1357 (verilog-string-replace-matches | |
1358 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) | |
1359 t t compile-command)))) | |
1360 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1361 ;; 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
|
1362 (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
|
1363 |
79545 | 1364 (defun verilog-error-regexp-add () |
1365 "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
|
1366 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
|
1367 find the errors." |
79545 | 1368 (if (not verilog-error-regexp-add-didit) |
1369 (progn | |
1370 (setq verilog-error-regexp-add-didit t) | |
1371 (setq-default compilation-error-regexp-alist | |
1372 (append verilog-error-regexp | |
1373 (default-value 'compilation-error-regexp-alist))) | |
1374 ;; 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
|
1375 (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
|
1376 (default-value 'compilation-error-regexp-alist)) |
79545 | 1377 (set (make-local-variable 'compilation-error-regexp-alist) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1378 (default-value 'compilation-error-regexp-alist))))) |
79545 | 1379 |
1380 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add) | |
1381 | |
1382 (defconst verilog-directive-re | |
1383 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | |
1384 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1385 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1386 ;; "`time_scale" "`undef" "`while" | |
1387 "\\<`\\(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\\)\\>") | |
1388 | |
1389 (defconst verilog-directive-begin | |
1390 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>") | |
1391 | |
1392 (defconst verilog-directive-middle | |
1393 "\\<`\\(else\\|default\\|case\\)\\>") | |
1394 | |
1395 (defconst verilog-directive-end | |
1396 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>") | |
1397 | |
1398 (defconst verilog-directive-re-1 | |
1399 (concat "[ \t]*" verilog-directive-re)) | |
1400 | |
1401 ;; | |
1402 ;; Regular expressions used to calculate indent, etc. | |
1403 ;; | |
1404 (defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>") | |
1405 (defconst verilog-case-re "\\(\\<case[xz]?\\>\\|\\<randcase\\>\\)") | |
1406 ;; Want to match | |
1407 ;; aa : | |
1408 ;; aa,bb : | |
1409 ;; a[34:32] : | |
1410 ;; a, | |
1411 ;; b : | |
1412 | |
1413 (defconst verilog-no-indent-begin-re | |
1414 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>") | |
1415 | |
1416 (defconst verilog-ends-re | |
1417 ;; Parenthesis indicate type of keyword found | |
1418 (concat | |
1419 "\\(\\<else\\>\\)\\|" ; 1 | |
1420 "\\(\\<if\\>\\)\\|" ; 2 | |
1421 "\\(\\<end\\>\\)\\|" ; 3 | |
1422 "\\(\\<endcase\\>\\)\\|" ; 4 | |
1423 "\\(\\<endfunction\\>\\)\\|" ; 5 | |
1424 "\\(\\<endtask\\>\\)\\|" ; 6 | |
1425 "\\(\\<endspecify\\>\\)\\|" ; 7 | |
1426 "\\(\\<endtable\\>\\)\\|" ; 8 | |
1427 "\\(\\<endgenerate\\>\\)\\|" ; 9 | |
1428 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10 | |
1429 "\\(\\<endclass\\>\\)\\|" ; 11 | |
1430 "\\(\\<endgroup\\>\\)" ; 12 | |
1431 )) | |
1432 | |
1433 (defconst verilog-auto-end-comment-lines-re | |
1434 ;; Matches to names in this list cause auto-end-commentation | |
1435 (concat "\\(" | |
1436 verilog-directive-re "\\)\\|\\(" | |
1437 (eval-when-compile | |
1438 (verilog-regexp-words | |
1439 `( "begin" | |
1440 "else" | |
1441 "end" | |
1442 "endcase" | |
1443 "endclass" | |
1444 "endclocking" | |
1445 "endgroup" | |
1446 "endfunction" | |
1447 "endmodule" | |
1448 "endprogram" | |
1449 "endprimitive" | |
1450 "endinterface" | |
1451 "endpackage" | |
1452 "endsequence" | |
1453 "endspecify" | |
1454 "endtable" | |
1455 "endtask" | |
1456 "join" | |
1457 "join_any" | |
1458 "join_none" | |
1459 "module" | |
1460 "macromodule" | |
1461 "primitive" | |
1462 "interface" | |
1463 "package"))) | |
1464 "\\)")) | |
1465 | |
1466 ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and | |
1467 ;;; verilog-end-block-ordered-re matches exactly the same strings. | |
1468 (defconst verilog-end-block-ordered-re | |
1469 ;; Parenthesis indicate type of keyword found | |
1470 (concat "\\(\\<endcase\\>\\)\\|" ; 1 | |
1471 "\\(\\<end\\>\\)\\|" ; 2 | |
1472 "\\(\\<end" ; 3, but not used | |
1473 "\\(" ; 4, but not used | |
1474 "\\(function\\)\\|" ; 5 | |
1475 "\\(task\\)\\|" ; 6 | |
1476 "\\(module\\)\\|" ; 7 | |
1477 "\\(primitive\\)\\|" ; 8 | |
1478 "\\(interface\\)\\|" ; 9 | |
1479 "\\(package\\)\\|" ; 10 | |
1480 "\\(class\\)\\|" ; 11 | |
1481 "\\(group\\)\\|" ; 12 | |
1482 "\\(program\\)\\|" ; 13 | |
1483 "\\(sequence\\)\\|" ; 14 | |
1484 "\\(clocking\\)\\|" ; 15 | |
1485 "\\)\\>\\)")) | |
1486 (defconst verilog-end-block-re | |
1487 (eval-when-compile | |
1488 (verilog-regexp-words | |
1489 | |
1490 `("end" ;; closes begin | |
1491 "endcase" ;; closes any of case, casex casez or randcase | |
1492 "join" "join_any" "join_none" ;; closes fork | |
1493 "endclass" | |
1494 "endtable" | |
1495 "endspecify" | |
1496 "endfunction" | |
1497 "endgenerate" | |
1498 "endtask" | |
1499 "endgroup" | |
1500 "endproperty" | |
1501 "endinterface" | |
1502 "endpackage" | |
1503 "endprogram" | |
1504 "endsequence" | |
1505 "endclocking" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1506 )))) |
79545 | 1507 |
1508 | |
1509 (defconst verilog-endcomment-reason-re | |
1510 ;; Parenthesis indicate type of keyword found | |
1511 (concat | |
1512 "\\(\\<fork\\>\\)\\|" | |
1513 "\\(\\<begin\\>\\)\\|" | |
1514 "\\(\\<if\\>\\)\\|" | |
1515 "\\(\\<clocking\\>\\)\\|" | |
1516 "\\(\\<else\\>\\)\\|" | |
1517 "\\(\\<end\\>.*\\<else\\>\\)\\|" | |
1518 "\\(\\<task\\>\\)\\|" | |
1519 "\\(\\<function\\>\\)\\|" | |
1520 "\\(\\<initial\\>\\)\\|" | |
1521 "\\(\\<interface\\>\\)\\|" | |
1522 "\\(\\<package\\>\\)\\|" | |
1523 "\\(\\<final\\>\\)\\|" | |
1524 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1525 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1526 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1527 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|" | |
1528 "\\(@\\)\\|" | |
1529 "\\(\\<while\\>\\)\\|" | |
1530 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|" | |
1531 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|" | |
1532 "#")) | |
1533 | |
1534 (defconst verilog-named-block-re "begin[ \t]*:") | |
1535 | |
1536 ;; These words begin a block which can occur inside a module which should be indented, | |
1537 ;; and closed with the respective word from the end-block list | |
1538 | |
1539 (defconst verilog-beg-block-re | |
1540 (eval-when-compile | |
1541 (verilog-regexp-words | |
1542 `("begin" | |
1543 "case" "casex" "casez" "randcase" | |
1544 "clocking" | |
1545 "generate" | |
1546 "fork" | |
1547 "function" | |
1548 "property" | |
1549 "specify" | |
1550 "table" | |
1551 "task" | |
1552 )))) | |
1553 ;; These are the same words, in a specific order in the regular | |
1554 ;; expression so that matching will work nicely for | |
1555 ;; verilog-forward-sexp and verilog-calc-indent | |
1556 | |
1557 (defconst verilog-beg-block-re-ordered | |
1558 ( concat "\\<" | |
1559 "\\(begin\\)" ;1 | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1560 "\\|\\(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
|
1561 "\\|\\(\\(disable\\s-+\\)?fork\\)" ;4 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1562 "\\|\\(class\\)" ;5 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1563 "\\|\\(table\\)" ;6 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1564 "\\|\\(specify\\)" ;7 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1565 "\\|\\(function\\)" ;8 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1566 "\\|\\(task\\)" ;9 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1567 "\\|\\(generate\\)" ;10 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1568 "\\|\\(covergroup\\)" ;11 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1569 "\\|\\(property\\)" ;12 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1570 "\\|\\(\\(rand\\)?sequence\\)" ;13 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1571 "\\|\\(clocking\\)" ;14 |
79545 | 1572 "\\>")) |
1573 | |
1574 (defconst verilog-end-block-ordered-rry | |
1575 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1576 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" | |
1577 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1578 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" | |
1579 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" | |
1580 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" | |
1581 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" | |
1582 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" | |
1583 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" | |
1584 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" | |
1585 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" | |
1586 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" | |
1587 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" | |
1588 ] ) | |
1589 | |
1590 (defconst verilog-nameable-item-re | |
1591 (eval-when-compile | |
1592 (verilog-regexp-words | |
1593 `("begin" | |
1594 "fork" | |
1595 "join" "join_any" "join_none" | |
1596 "end" | |
1597 "endcase" | |
1598 "endconfig" | |
1599 "endclass" | |
1600 "endclocking" | |
1601 "endfunction" | |
1602 "endgenerate" | |
1603 "endmodule" | |
1604 "endprimative" | |
1605 "endinterface" | |
1606 "endpackage" | |
1607 "endspecify" | |
1608 "endtable" | |
1609 "endtask" ) | |
1610 ))) | |
1611 | |
1612 (defconst verilog-declaration-opener | |
1613 (eval-when-compile | |
1614 (verilog-regexp-words | |
1615 `("module" "begin" "task" "function")))) | |
1616 | |
1617 (defconst verilog-declaration-prefix-re | |
1618 (eval-when-compile | |
1619 (verilog-regexp-words | |
1620 `( | |
1621 ;; port direction | |
79546 | 1622 "inout" "input" "output" "ref" |
79545 | 1623 ;; changeableness |
1624 "const" "static" "protected" "local" | |
1625 ;; parameters | |
79546 | 1626 "localparam" "parameter" "var" |
79545 | 1627 ;; type creation |
1628 "typedef" | |
1629 )))) | |
1630 (defconst verilog-declaration-core-re | |
1631 (eval-when-compile | |
1632 (verilog-regexp-words | |
1633 `( | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
1634 ;; port direction (by themselves) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
1635 "inout" "input" "output" |
79545 | 1636 ;; integer_atom_type |
1637 "byte" "shortint" "int" "longint" "integer" "time" | |
1638 ;; integer_vector_type | |
1639 "bit" "logic" "reg" | |
1640 ;; non_integer_type | |
1641 "shortreal" "real" "realtime" | |
1642 ;; net_type | |
1643 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor" | |
1644 ;; misc | |
1645 "string" "event" "chandle" "virtual" "enum" "genvar" | |
1646 "struct" "union" | |
1647 ;; builtin classes | |
79546 | 1648 "mailbox" "semaphore" |
79545 | 1649 )))) |
79546 | 1650 (defconst verilog-declaration-re |
79545 | 1651 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re)) |
1652 (defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+") | |
1653 (defconst verilog-optional-signed-re "\\s-*\\(signed\\)?") | |
1654 (defconst verilog-optional-signed-range-re | |
1655 (concat | |
1656 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?")) | |
1657 (defconst verilog-macroexp-re "`\\sw+") | |
1658 | |
1659 (defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)") | |
1660 (defconst verilog-declaration-re-2-no-macro | |
1661 (concat "\\s-*" verilog-declaration-re | |
1662 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1663 "\\)?")) | |
1664 (defconst verilog-declaration-re-2-macro | |
1665 (concat "\\s-*" verilog-declaration-re | |
1666 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
1667 "\\|\\(" verilog-macroexp-re "\\)" | |
1668 "\\)?")) | |
1669 (defconst verilog-declaration-re-1-macro | |
1670 (concat "^" verilog-declaration-re-2-macro)) | |
1671 | |
1672 (defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro)) | |
1673 | |
1674 (defconst verilog-defun-re | |
1675 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config")))) | |
1676 (defconst verilog-end-defun-re | |
1677 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig")))) | |
1678 (defconst verilog-zero-indent-re | |
1679 (concat verilog-defun-re "\\|" verilog-end-defun-re)) | |
1680 | |
1681 (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
|
1682 (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
|
1683 "function" "task")))) |
79545 | 1684 |
1685 (defconst verilog-indent-re | |
1686 (eval-when-compile | |
1687 (verilog-regexp-words | |
1688 `( | |
1689 "{" | |
1690 "always" "always_latch" "always_ff" "always_comb" | |
1691 "begin" "end" | |
1692 ; "unique" "priority" | |
1693 "case" "casex" "casez" "randcase" "endcase" | |
1694 "class" "endclass" | |
1695 "clocking" "endclocking" | |
1696 "config" "endconfig" | |
1697 "covergroup" "endgroup" | |
1698 "fork" "join" "join_any" "join_none" | |
1699 "function" "endfunction" | |
1700 "final" | |
1701 "generate" "endgenerate" | |
1702 "initial" | |
1703 "interface" "endinterface" | |
1704 "module" "macromodule" "endmodule" | |
1705 "package" "endpackage" | |
1706 "primitive" "endprimative" | |
1707 "program" "endprogram" | |
1708 "property" "endproperty" | |
1709 "sequence" "randsequence" "endsequence" | |
1710 "specify" "endspecify" | |
1711 "table" "endtable" | |
1712 "task" "endtask" | |
1713 "`case" | |
1714 "`default" | |
1715 "`define" "`undef" | |
1716 "`if" "`ifdef" "`ifndef" "`else" "`endif" | |
1717 "`while" "`endwhile" | |
1718 "`for" "`endfor" | |
1719 "`format" | |
1720 "`include" | |
1721 "`let" | |
1722 "`protect" "`endprotect" | |
1723 "`switch" "`endswitch" | |
1724 "`timescale" | |
1725 "`time_scale" | |
1726 )))) | |
1727 | |
1728 (defconst verilog-defun-level-re | |
1729 (eval-when-compile | |
1730 (verilog-regexp-words | |
1731 `( | |
1732 "module" "macromodule" "primitive" "class" "program" "initial" "final" "always" "always_comb" | |
1733 "always_ff" "always_latch" "endtask" "endfunction" "interface" "package" | |
1734 "config")))) | |
1735 | |
1736 (defconst verilog-defun-level-not-generate-re | |
1737 (eval-when-compile | |
1738 (verilog-regexp-words | |
1739 `( | |
1740 "module" "macromodule" "primitive" "class" "program" "interface" "package" "config")))) | |
1741 | |
1742 (defconst verilog-cpp-level-re | |
1743 (eval-when-compile | |
1744 (verilog-regexp-words | |
1745 `( | |
1746 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" | |
1747 )))) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1748 (defconst verilog-disable-fork-re "disable\\s-+fork") |
79545 | 1749 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") |
1750 (defconst verilog-extended-complete-re | |
1751 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" | |
1752 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)" | |
1753 "\\|" verilog-extended-case-re )) | |
1754 (defconst verilog-basic-complete-re | |
1755 (eval-when-compile | |
1756 (verilog-regexp-words | |
1757 `( | |
1758 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint" | |
1759 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while" | |
1760 "if" "for" "forever" "foreach" "else" "parameter" "do" | |
1761 )))) | |
1762 (defconst verilog-complete-reg | |
1763 (concat | |
1764 verilog-extended-complete-re | |
1765 "\\|" | |
1766 verilog-basic-complete-re)) | |
1767 | |
1768 (defconst verilog-end-statement-re | |
1769 (concat "\\(" verilog-beg-block-re "\\)\\|\\(" | |
1770 verilog-end-block-re "\\)")) | |
1771 | |
1772 (defconst verilog-endcase-re | |
1773 (concat verilog-case-re "\\|" | |
1774 "\\(endcase\\)\\|" | |
1775 verilog-defun-re | |
1776 )) | |
1777 | |
1778 (defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----" | |
1779 "String used to mark beginning of excluded text.") | |
1780 (defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */" | |
1781 "String used to mark end of excluded text.") | |
1782 (defconst verilog-preprocessor-re | |
1783 (eval-when-compile | |
1784 (verilog-regexp-words | |
1785 `( | |
1786 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else" | |
1787 )))) | |
1788 | |
1789 (defconst verilog-keywords | |
1790 '( "`case" "`default" "`define" "`else" "`endfor" "`endif" | |
1791 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1792 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1793 "`time_scale" "`undef" "`while" | |
1794 | |
1795 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" | |
1796 "assert" "assign" "assume" "automatic" "before" "begin" "bind" | |
1797 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" | |
1798 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" | |
1799 "config" "const" "constraint" "context" "continue" "cover" | |
1800 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" | |
1801 "design" "disable" "dist" "do" "edge" "else" "end" "endcase" | |
1802 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" | |
1803 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" | |
1804 "endprogram" "endproperty" "endspecify" "endsequence" "endtable" | |
1805 "endtask" "enum" "event" "expect" "export" "extends" "extern" | |
1806 "final" "first_match" "for" "force" "foreach" "forever" "fork" | |
1807 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" | |
1808 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" | |
1809 "include" "initial" "inout" "input" "inside" "instance" "int" | |
1810 "integer" "interface" "intersect" "join" "join_any" "join_none" | |
1811 "large" "liblist" "library" "local" "localparam" "logic" | |
1812 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" | |
1813 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" | |
1814 "notif0" "notif1" "null" "or" "output" "package" "packed" | |
1815 "parameter" "pmos" "posedge" "primitive" "priority" "program" | |
1816 "property" "protected" "pull0" "pull1" "pulldown" "pullup" | |
1817 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1818 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" | |
1819 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" | |
1820 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" | |
1821 "showcancelled" "signed" "small" "solve" "specify" "specparam" | |
1822 "static" "string" "strong0" "strong1" "struct" "super" "supply0" | |
1823 "supply1" "table" "tagged" "task" "this" "throughout" "time" | |
1824 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" | |
1825 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" | |
1826 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" | |
1827 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | |
1828 "wire" "with" "within" "wor" "xnor" "xor" | |
1829 ) | |
1830 "List of Verilog keywords.") | |
1831 | |
1832 (defconst verilog-comment-start-regexp "//\\|/\\*" | |
1833 "Dual comment value for `comment-start-regexp'.") | |
1834 | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1835 (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
|
1836 (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
|
1837 ;; Populate the syntax TABLE. |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1838 (modify-syntax-entry ?\\ "\\" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1839 (modify-syntax-entry ?+ "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1840 (modify-syntax-entry ?- "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1841 (modify-syntax-entry ?= "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1842 (modify-syntax-entry ?% "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1843 (modify-syntax-entry ?< "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1844 (modify-syntax-entry ?> "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1845 (modify-syntax-entry ?& "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1846 (modify-syntax-entry ?| "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1847 (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
|
1848 (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
|
1849 (modify-syntax-entry ?\' "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1850 |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1851 ;; 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
|
1852 (if (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1853 (progn |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1854 ;; 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
|
1855 (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
|
1856 (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
|
1857 (modify-syntax-entry ?\n "> b" table)) |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
1858 ;; Emacs does things differently, but we can work with it |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1859 (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
|
1860 (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
|
1861 (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
|
1862 table) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1863 "Syntax table used in Verilog mode buffers.") |
79545 | 1864 |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1865 (defvar verilog-font-lock-keywords nil |
79545 | 1866 "Default highlighting for Verilog mode.") |
1867 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1868 (defvar verilog-font-lock-keywords-1 nil |
79545 | 1869 "Subdued level highlighting for Verilog mode.") |
1870 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1871 (defvar verilog-font-lock-keywords-2 nil |
79545 | 1872 "Medium level highlighting for Verilog mode. |
1873 See also `verilog-font-lock-extra-types'.") | |
1874 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1875 (defvar verilog-font-lock-keywords-3 nil |
79545 | 1876 "Gaudy level highlighting for Verilog mode. |
1877 See also `verilog-font-lock-extra-types'.") | |
1878 (defvar verilog-font-lock-translate-off-face | |
1879 'verilog-font-lock-translate-off-face | |
1880 "Font to use for translated off regions.") | |
1881 (defface verilog-font-lock-translate-off-face | |
1882 '((((class color) | |
1883 (background light)) | |
1884 (:background "gray90" :italic t )) | |
1885 (((class color) | |
1886 (background dark)) | |
1887 (:background "gray10" :italic t )) | |
1888 (((class grayscale) (background light)) | |
1889 (:foreground "DimGray" :italic t)) | |
1890 (((class grayscale) (background dark)) | |
1891 (:foreground "LightGray" :italic t)) | |
1892 (t (:italis t))) | |
1893 "Font lock mode face used to background highlight translate-off regions." | |
1894 :group 'font-lock-highlighting-faces) | |
1895 | |
1896 (defvar verilog-font-lock-p1800-face | |
1897 'verilog-font-lock-p1800-face | |
1898 "Font to use for p1800 keywords.") | |
1899 (defface verilog-font-lock-p1800-face | |
1900 '((((class color) | |
1901 (background light)) | |
1902 (:foreground "DarkOrange3" :bold t )) | |
1903 (((class color) | |
1904 (background dark)) | |
1905 (:foreground "orange1" :bold t )) | |
1906 (t (:italic t))) | |
1907 "Font lock mode face used to highlight P1800 keywords." | |
1908 :group 'font-lock-highlighting-faces) | |
1909 | |
1910 (defvar verilog-font-lock-ams-face | |
1911 'verilog-font-lock-ams-face | |
1912 "Font to use for Analog/Mixed Signal keywords.") | |
1913 (defface verilog-font-lock-ams-face | |
1914 '((((class color) | |
1915 (background light)) | |
1916 (:foreground "Purple" :bold t )) | |
1917 (((class color) | |
1918 (background dark)) | |
1919 (:foreground "orange1" :bold t )) | |
1920 (t (:italic t))) | |
1921 "Font lock mode face used to highlight AMS keywords." | |
1922 :group 'font-lock-highlighting-faces) | |
1923 | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1924 (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
|
1925 '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
|
1926 "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
|
1927 (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
|
1928 '((((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1929 (background light)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1930 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1931 (((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1932 (background dark)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1933 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1934 (t (:italic t))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
1935 "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
|
1936 :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
|
1937 |
79545 | 1938 (let* ((verilog-type-font-keywords |
1939 (eval-when-compile | |
1940 (verilog-regexp-opt | |
1941 '( | |
1942 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam" | |
1943 "event" "genvar" "inout" "input" "integer" "localparam" | |
1944 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or" | |
1945 "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
1946 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" | |
1947 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply" | |
1948 "supply0" "supply1" "time" "tran" "tranif0" "tranif1" | |
1949 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef" | |
1950 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor" | |
1951 ) nil ))) | |
1952 | |
1953 (verilog-pragma-keywords | |
1954 (eval-when-compile | |
1955 (verilog-regexp-opt | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
1956 '("surefire" "synopsys" "rtl_synthesis" "verilint" "leda" "0in") nil |
79545 | 1957 ))) |
1958 | |
1959 (verilog-p1800-keywords | |
1960 (eval-when-compile | |
1961 (verilog-regexp-opt | |
1962 '("alias" "assert" "assume" "automatic" "before" "bind" | |
1963 "bins" "binsof" "break" "byte" "cell" "chandle" "class" | |
1964 "clocking" "config" "const" "constraint" "context" "continue" | |
1965 "cover" "covergroup" "coverpoint" "cross" "deassign" "design" | |
1966 "dist" "do" "edge" "endclass" "endclocking" "endconfig" | |
1967 "endgroup" "endprogram" "endproperty" "endsequence" "enum" | |
1968 "expect" "export" "extends" "extern" "first_match" "foreach" | |
1969 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins" | |
1970 "illegal_bins" "import" "incdir" "include" "inside" "instance" | |
1971 "int" "intersect" "large" "liblist" "library" "local" "longint" | |
1972 "matches" "medium" "modport" "new" "noshowcancelled" "null" | |
1973 "packed" "program" "property" "protected" "pull0" "pull1" | |
1974 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
1975 "randcase" "randsequence" "ref" "release" "return" "scalared" | |
1976 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve" | |
1977 "specparam" "static" "string" "strong0" "strong1" "struct" | |
1978 "super" "tagged" "this" "throughout" "timeprecision" "timeunit" | |
1979 "type" "union" "unsigned" "use" "var" "virtual" "void" | |
1980 "wait_order" "weak0" "weak1" "wildcard" "with" "within" | |
1981 ) nil ))) | |
1982 | |
1983 (verilog-ams-keywords | |
1984 (eval-when-compile | |
1985 (verilog-regexp-opt | |
1986 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim" | |
1987 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh" | |
1988 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt" | |
1989 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules" | |
1990 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise" | |
1991 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf" | |
1992 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp" | |
1993 "last_crossing" "limexp" "ln" "log" "max" "min" "nature" | |
1994 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin" | |
1995 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise" | |
1996 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil ))) | |
1997 | |
1998 (verilog-font-keywords | |
1999 (eval-when-compile | |
2000 (verilog-regexp-opt | |
2001 '( | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2002 "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
|
2003 "default" "disable" "else" "endcase" "endfunction" |
79545 | 2004 "endgenerate" "endinterface" "endmodule" "endprimitive" |
2005 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break" | |
2006 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial" | |
2007 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge" | |
2008 "package" "endpackage" "always" "always_comb" "always_ff" | |
2009 "always_latch" "posedge" "primitive" "priority" "release" | |
2010 "repeat" "specify" "table" "task" "unique" "wait" "while" | |
2011 "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
|
2012 ) nil ))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2013 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2014 (verilog-font-grouping-keywords |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2015 (eval-when-compile |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2016 (verilog-regexp-opt |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2017 '( "begin" "end" ) nil )))) |
79545 | 2018 |
2019 (setq verilog-font-lock-keywords | |
2020 (list | |
2021 ;; Fontify all builtin keywords | |
2022 (concat "\\<\\(" verilog-font-keywords "\\|" | |
2023 ;; 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
|
2024 "\\$[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
|
2025 "\\)\\>") |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2026 ;; Fontify all types |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2027 (if verilog-highlight-grouping-keywords |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2028 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2029 'verilog-font-lock-ams-face) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2030 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2031 'font-lock-type-face)) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2032 (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
|
2033 'font-lock-type-face) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2034 ;; Fontify IEEE-P1800 keywords appropriately |
79545 | 2035 (if verilog-highlight-p1800-keywords |
2036 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
2037 'verilog-font-lock-p1800-face) | |
2038 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
2039 'font-lock-type-face)) | |
2040 ;; Fontify Verilog-AMS keywords | |
2041 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2042 'verilog-font-lock-ams-face))) |
79545 | 2043 |
2044 (setq verilog-font-lock-keywords-1 | |
2045 (append verilog-font-lock-keywords | |
2046 (list | |
2047 ;; Fontify module definitions | |
2048 (list | |
2049 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)" | |
2050 '(1 font-lock-keyword-face) | |
2051 '(3 font-lock-function-name-face 'prepend)) | |
2052 ;; Fontify function definitions | |
2053 (list | |
2054 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | |
2055 '(1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2056 '(3 font-lock-reference-face prepend)) |
79545 | 2057 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
2058 (1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2059 (2 font-lock-reference-face append)) |
79545 | 2060 '("\\<function\\>\\s-+\\(\\sw+\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2061 1 'font-lock-reference-face append)))) |
79545 | 2062 |
2063 (setq verilog-font-lock-keywords-2 | |
2064 (append verilog-font-lock-keywords-1 | |
2065 (list | |
2066 ;; Fontify pragmas | |
2067 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)") | |
2068 ;; Fontify escaped names | |
2069 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) | |
2070 ;; Fontify macro definitions/ uses | |
2071 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) | |
2072 'font-lock-preprocessor-face | |
2073 'font-lock-type-face)) | |
2074 ;; Fontify delays/numbers | |
2075 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | |
2076 0 font-lock-type-face append) | |
2077 ;; Fontify instantiation names | |
2078 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | |
2079 ))) | |
2080 | |
2081 (setq verilog-font-lock-keywords-3 | |
2082 (append verilog-font-lock-keywords-2 | |
2083 (when verilog-highlight-translate-off | |
2084 (list | |
2085 ;; 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
|
2086 '(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
|
2087 (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
|
2088 ))))) |
79545 | 2089 |
2090 | |
2091 (defun verilog-inside-comment-p () | |
2092 "Check if point inside a nested comment." | |
2093 (save-excursion | |
2094 (let ((st-point (point)) hitbeg) | |
2095 (or (search-backward "//" (verilog-get-beg-of-line) t) | |
2096 (if (progn | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2097 ;; This is for tricky case //*, we keep searching if /* |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2098 ;; 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
|
2099 (while |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2100 (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
|
2101 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2102 (forward-char 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2103 (search-backward "//" (verilog-get-beg-of-line) t)))) |
79545 | 2104 hitbeg) |
2105 (not (search-forward "*/" st-point t))))))) | |
2106 | |
2107 (defun verilog-declaration-end () | |
2108 (search-forward ";")) | |
2109 | |
2110 (defun verilog-point-text (&optional pointnum) | |
2111 "Return text describing where POINTNUM or current point is (for errors). | |
2112 Use filename, if current buffer being edited shorten to just buffer name." | |
2113 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer)) | |
2114 (buffer-name)) | |
2115 buffer-file-name | |
2116 (buffer-name)) | |
2117 ":" (int-to-string (count-lines (point-min) (or pointnum (point)))))) | |
2118 | |
2119 (defun electric-verilog-backward-sexp () | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2120 "Move backward over one balanced expression." |
79545 | 2121 (interactive) |
2122 ;; 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
|
2123 (verilog-backward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2124 |
79545 | 2125 (defun electric-verilog-forward-sexp () |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2126 "Move forward over one balanced expression." |
79545 | 2127 (interactive) |
2128 ;; 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
|
2129 (verilog-forward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2130 |
79545 | 2131 ;;;used by hs-minor-mode |
2132 (defun verilog-forward-sexp-function (arg) | |
2133 (if (< arg 0) | |
2134 (verilog-backward-sexp) | |
2135 (verilog-forward-sexp))) | |
2136 | |
2137 | |
2138 (defun verilog-backward-sexp () | |
2139 (let ((reg) | |
2140 (elsec 1) | |
2141 (found nil) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2142 (st (point))) |
79545 | 2143 (if (not (looking-at "\\<")) |
2144 (forward-word -1)) | |
2145 (cond | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2146 ((verilog-skip-backward-comment-or-string)) |
79545 | 2147 ((looking-at "\\<else\\>") |
2148 (setq reg (concat | |
2149 verilog-end-block-re | |
2150 "\\|\\(\\<else\\>\\)" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2151 "\\|\\(\\<if\\>\\)")) |
79545 | 2152 (while (and (not found) |
2153 (verilog-re-search-backward reg nil 'move)) | |
2154 (cond | |
2155 ((match-end 1) ; matched verilog-end-block-re | |
2156 ; try to leap back to matching outward block by striding across | |
2157 ; indent level changing tokens then immediately | |
2158 ; previous line governs indentation. | |
2159 (verilog-leap-to-head)) | |
2160 ((match-end 2) ; else, we're in deep | |
2161 (setq elsec (1+ elsec))) | |
2162 ((match-end 3) ; found it | |
2163 (setq elsec (1- elsec)) | |
2164 (if (= 0 elsec) | |
2165 ;; Now previous line describes syntax | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2166 (setq found 't)))))) |
79545 | 2167 ((looking-at verilog-end-block-re) |
2168 (verilog-leap-to-head)) | |
2169 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | |
2170 (cond | |
2171 ((match-end 1) | |
2172 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move)) | |
2173 ((match-end 2) | |
2174 (verilog-re-search-backward "\\<primitive\\>" nil 'move)) | |
2175 ((match-end 3) | |
2176 (verilog-re-search-backward "\\<class\\>" nil 'move)) | |
2177 ((match-end 4) | |
2178 (verilog-re-search-backward "\\<program\\>" nil 'move)) | |
2179 ((match-end 5) | |
2180 (verilog-re-search-backward "\\<interface\\>" nil 'move)) | |
2181 ((match-end 6) | |
2182 (verilog-re-search-backward "\\<package\\>" nil 'move)) | |
2183 (t | |
2184 (goto-char st) | |
2185 (backward-sexp 1)))) | |
2186 (t | |
2187 (goto-char st) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2188 (backward-sexp))))) |
79545 | 2189 |
2190 (defun verilog-forward-sexp () | |
2191 (let ((reg) | |
2192 (md 2) | |
2193 (st (point))) | |
2194 (if (not (looking-at "\\<")) | |
2195 (forward-word -1)) | |
2196 (cond | |
2197 ((verilog-skip-forward-comment-or-string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2198 (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
|
2199 ((looking-at verilog-beg-block-re-ordered) ;; begin|(case)|xx|(fork)|class|table|specify|function|task|generate|covergroup|property|sequence|clocking |
79545 | 2200 (cond |
2201 ((match-end 1) ; end | |
2202 ;; Search forward for matching begin | |
2203 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
2204 ((match-end 2) ; endcase | |
2205 ;; 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
|
2206 (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
|
2207 (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
|
2208 ) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2209 ((match-end 4) ; join |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2210 ;; might be "disable fork" |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2211 (if (or |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2212 (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
|
2213 (and (looking-at "fork") |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2214 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2215 (forward-word -1) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2216 (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
|
2217 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2218 (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
|
2219 (forward-word) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2220 (setq reg nil)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2221 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2222 ;; 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
|
2223 (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
|
2224 ((match-end 5) ; endclass |
79545 | 2225 ;; Search forward for matching class |
2226 (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
|
2227 ((match-end 6) ; endtable |
79545 | 2228 ;; Search forward for matching table |
2229 (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
|
2230 ((match-end 7) ; endspecify |
79545 | 2231 ;; Search forward for matching specify |
2232 (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
|
2233 ((match-end 8) ; endfunction |
79545 | 2234 ;; Search forward for matching function |
2235 (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
|
2236 ((match-end 9) ; endtask |
79545 | 2237 ;; Search forward for matching task |
2238 (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
|
2239 ((match-end 10) ; endgenerate |
79545 | 2240 ;; Search forward for matching generate |
2241 (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
|
2242 ((match-end 11) ; endgroup |
79545 | 2243 ;; Search forward for matching covergroup |
2244 (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
|
2245 ((match-end 12) ; endproperty |
79545 | 2246 ;; Search forward for matching property |
2247 (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
|
2248 ((match-end 13) ; endsequence |
79545 | 2249 ;; Search forward for matching sequence |
2250 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2251 (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
|
2252 ((match-end 14) ; endclocking |
79545 | 2253 ;; Search forward for matching clocking |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2254 (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
|
2255 (if (and reg |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2256 (forward-word 1)) |
79545 | 2257 (catch 'skip |
2258 (let ((nest 1)) | |
2259 (while (verilog-re-search-forward reg nil 'move) | |
2260 (cond | |
2261 ((match-end md) ; the closer in reg, so we are climbing out | |
2262 (setq nest (1- nest)) | |
2263 (if (= 0 nest) ; we are out! | |
2264 (throw 'skip 1))) | |
2265 ((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
|
2266 (setq nest (1+ nest))))))))) |
79545 | 2267 ((looking-at (concat |
2268 "\\(\\<\\(macro\\)?module\\>\\)\\|" | |
2269 "\\(\\<primitive\\>\\)\\|" | |
2270 "\\(\\<class\\>\\)\\|" | |
2271 "\\(\\<program\\>\\)\\|" | |
2272 "\\(\\<interface\\>\\)\\|" | |
2273 "\\(\\<package\\>\\)")) | |
2274 (cond | |
2275 ((match-end 1) | |
2276 (verilog-re-search-forward "\\<endmodule\\>" nil 'move)) | |
2277 ((match-end 2) | |
2278 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move)) | |
2279 ((match-end 3) | |
2280 (verilog-re-search-forward "\\<endclass\\>" nil 'move)) | |
2281 ((match-end 4) | |
2282 (verilog-re-search-forward "\\<endprogram\\>" nil 'move)) | |
2283 ((match-end 5) | |
2284 (verilog-re-search-forward "\\<endinterface\\>" nil 'move)) | |
2285 ((match-end 6) | |
2286 (verilog-re-search-forward "\\<endpackage\\>" nil 'move)) | |
2287 (t | |
2288 (goto-char st) | |
2289 (if (= (following-char) ?\) ) | |
2290 (forward-char 1) | |
2291 (forward-sexp 1))))) | |
2292 (t | |
2293 (goto-char st) | |
2294 (if (= (following-char) ?\) ) | |
2295 (forward-char 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2296 (forward-sexp 1)))))) |
79545 | 2297 |
2298 (defun verilog-declaration-beg () | |
2299 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | |
2300 | |
2301 (defun verilog-font-lock-init () | |
2302 "Initialize fontification." | |
2303 ;; highlight keywords and standardized types, attributes, enumeration | |
2304 ;; values, and subprograms | |
2305 (setq verilog-font-lock-keywords-3 | |
2306 (append verilog-font-lock-keywords-2 | |
2307 (when verilog-highlight-translate-off | |
2308 (list | |
2309 ;; 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
|
2310 '(verilog-match-translate-off |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2311 (0 'verilog-font-lock-translate-off-face prepend)))))) |
79545 | 2312 (put 'verilog-mode 'font-lock-defaults |
2313 '((verilog-font-lock-keywords | |
2314 verilog-font-lock-keywords-1 | |
2315 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
|
2316 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
|
2317 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
|
2318 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
|
2319 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
|
2320 ;; 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
|
2321 verilog-beg-of-defun))) |
79545 | 2322 |
2323 ;; initialize fontification for Verilog Mode | |
2324 (verilog-font-lock-init) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2325 |
79545 | 2326 ;; |
2327 ;; | |
2328 ;; Mode | |
2329 ;; | |
2330 (defvar verilog-which-tool 1) | |
79546 | 2331 ;;;###autoload |
79545 | 2332 (defun verilog-mode () |
2333 "Major mode for editing Verilog code. | |
2334 \\<verilog-mode-map> | |
2335 See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how | |
2336 AUTOs can improve coding efficiency. | |
2337 | |
2338 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
2339 | |
2340 NEWLINE, TAB indents for Verilog code. | |
2341 Delete converts tabs to spaces as it moves back. | |
2342 | |
2343 Supports highlighting. | |
2344 | |
2345 Turning on Verilog mode calls the value of the variable `verilog-mode-hook' | |
2346 with no args, if that value is non-nil. | |
2347 | |
2348 Variables controlling indentation/edit style: | |
2349 | |
2350 variable `verilog-indent-level' (default 3) | |
2351 Indentation of Verilog statements with respect to containing block. | |
2352 `verilog-indent-level-module' (default 3) | |
2353 Absolute indentation of Module level Verilog statements. | |
2354 Set to 0 to get initial and always statements lined up | |
2355 on the left side of your screen. | |
2356 `verilog-indent-level-declaration' (default 3) | |
2357 Indentation of declarations with respect to containing block. | |
2358 Set to 0 to get them list right under containing block. | |
2359 `verilog-indent-level-behavioral' (default 3) | |
2360 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
|
2361 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
|
2362 function keyword. |
79545 | 2363 `verilog-indent-level-directive' (default 1) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2364 Indentation of `ifdef/`endif blocks. |
79545 | 2365 `verilog-cexp-indent' (default 1) |
2366 Indentation of Verilog statements broken across lines i.e.: | |
2367 if (a) | |
2368 begin | |
2369 `verilog-case-indent' (default 2) | |
2370 Indentation for case statements. | |
2371 `verilog-auto-newline' (default nil) | |
2372 Non-nil means automatically newline after semicolons and the punctuation | |
2373 mark after an end. | |
2374 `verilog-auto-indent-on-newline' (default t) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2375 Non-nil means automatically indent line after newline. |
79545 | 2376 `verilog-tab-always-indent' (default t) |
2377 Non-nil means TAB in Verilog mode should always reindent the current line, | |
2378 regardless of where in the line point is when the TAB command is used. | |
2379 `verilog-indent-begin-after-if' (default t) | |
2380 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
|
2381 if, else, while, for and repeat statements, if any. Otherwise, |
79545 | 2382 the begin is lined up with the preceding token. If t, you get: |
2383 if (a) | |
2384 begin // amount of indent based on `verilog-cexp-indent' | |
2385 otherwise you get: | |
2386 if (a) | |
2387 begin | |
2388 `verilog-auto-endcomments' (default t) | |
2389 Non-nil means a comment /* ... */ is set after the ends which ends | |
2390 cases, tasks, functions and modules. | |
2391 The type and name of the object will be set between the braces. | |
2392 `verilog-minimum-comment-distance' (default 10) | |
2393 Minimum distance (in lines) between begin and end required before a comment | |
2394 will be inserted. Setting this variable to zero results in every | |
2395 end acquiring a comment; the default avoids too many redundant | |
2396 comments in tight quarters. | |
2397 `verilog-auto-lineup' (default `(all)) | |
2398 List of contexts where auto lineup of code should be done. | |
2399 | |
2400 Variables controlling other actions: | |
2401 | |
2402 `verilog-linter' (default surelint) | |
2403 Unix program to call to run the lint checker. This is the default | |
2404 command for \\[compile-command] and \\[verilog-auto-save-compile]. | |
2405 | |
2406 See \\[customize] for the complete list of variables. | |
2407 | |
2408 AUTO expansion functions are, in part: | |
2409 | |
2410 \\[verilog-auto] Expand AUTO statements. | |
2411 \\[verilog-delete-auto] Remove the AUTOs. | |
2412 \\[verilog-inject-auto] Insert AUTOs for the first time. | |
2413 | |
2414 Some other functions are: | |
2415 | |
2416 \\[verilog-complete-word] Complete word with appropriate possibilities. | |
2417 \\[verilog-mark-defun] Mark function. | |
2418 \\[verilog-beg-of-defun] Move to beginning of current function. | |
2419 \\[verilog-end-of-defun] Move to end of current function. | |
2420 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements. | |
2421 | |
2422 \\[verilog-comment-region] Put marked area in a comment. | |
2423 \\[verilog-uncomment-region] Uncomment an area commented with \\[verilog-comment-region]. | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2424 \\[verilog-insert-block] Insert begin ... end. |
79545 | 2425 \\[verilog-star-comment] Insert /* ... */. |
2426 | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2427 \\[verilog-sk-always] Insert an always @(AS) begin .. end block. |
79545 | 2428 \\[verilog-sk-begin] Insert a begin .. end block. |
2429 \\[verilog-sk-case] Insert a case block, prompting for details. | |
2430 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details. | |
2431 \\[verilog-sk-generate] Insert a generate .. endgenerate block. | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2432 \\[verilog-sk-header] Insert a header block at the top of file. |
79545 | 2433 \\[verilog-sk-initial] Insert an initial begin .. end block. |
2434 \\[verilog-sk-fork] Insert a fork begin .. end .. join block. | |
2435 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block. | |
2436 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block. | |
2437 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. | |
2438 \\[verilog-sk-specify] Insert a specify .. endspecify block. | |
2439 \\[verilog-sk-task] Insert a task .. begin .. end endtask block. | |
2440 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details. | |
2441 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details. | |
2442 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details. | |
2443 \\[verilog-sk-if] Insert an if (..) begin .. end block. | |
2444 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block. | |
2445 \\[verilog-sk-comment] Insert a comment block. | |
2446 \\[verilog-sk-assign] Insert an assign .. = ..; statement. | |
2447 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block. | |
2448 \\[verilog-sk-input] Insert an input declaration, prompting for details. | |
2449 \\[verilog-sk-output] Insert an output declaration, prompting for details. | |
2450 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details. | |
2451 \\[verilog-sk-inout] Insert an inout declaration, prompting for details. | |
2452 \\[verilog-sk-wire] Insert a wire declaration, prompting for details. | |
2453 \\[verilog-sk-reg] Insert a register declaration, prompting for details. | |
2454 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module. | |
2455 | |
2456 All key bindings can be seen in a Verilog-buffer with \\[describe-bindings]. | |
2457 Key bindings specific to `verilog-mode-map' are: | |
2458 | |
2459 \\{verilog-mode-map}" | |
2460 (interactive) | |
2461 (kill-all-local-variables) | |
2462 (use-local-map verilog-mode-map) | |
2463 (setq major-mode 'verilog-mode) | |
2464 (setq mode-name "Verilog") | |
2465 (setq local-abbrev-table verilog-mode-abbrev-table) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2466 (set (make-local-variable 'beginning-of-defun-function) |
79546 | 2467 'verilog-beg-of-defun) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2468 (set (make-local-variable 'end-of-defun-function) |
79546 | 2469 'verilog-end-of-defun) |
79545 | 2470 (set-syntax-table verilog-mode-syntax-table) |
2471 (make-local-variable 'indent-line-function) | |
2472 (setq indent-line-function 'verilog-indent-line-relative) | |
2473 (setq comment-indent-function 'verilog-comment-indent) | |
2474 (make-local-variable 'parse-sexp-ignore-comments) | |
2475 (setq parse-sexp-ignore-comments nil) | |
2476 (make-local-variable 'comment-start) | |
2477 (make-local-variable 'comment-end) | |
2478 (make-local-variable 'comment-multi-line) | |
2479 (make-local-variable 'comment-start-skip) | |
2480 (setq comment-start "// " | |
2481 comment-end "" | |
2482 comment-start-skip "/\\*+ *\\|// *" | |
2483 comment-multi-line nil) | |
2484 ;; Set up for compilation | |
2485 (setq verilog-which-tool 1) | |
2486 (setq verilog-tool 'verilog-linter) | |
2487 (verilog-set-compile-command) | |
2488 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables | |
2489 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) | |
2490 | |
2491 ;; Setting up menus | |
79546 | 2492 (when (featurep 'xemacs) |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2493 (easy-menu-add verilog-stmt-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2494 (easy-menu-add verilog-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2495 (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
|
2496 |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2497 ;; 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
|
2498 (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
|
2499 '((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
|
2500 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
|
2501 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
|
2502 nil nil nil verilog-beg-of-defun)) |
79545 | 2503 ;;------------------------------------------------------------ |
2504 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el) | |
2505 ;; 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
|
2506 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2507 (make-local-hook 'font-lock-mode-hook) |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2508 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in Emacs |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2509 (make-local-hook 'after-change-functions)) |
79545 | 2510 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t) |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2511 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in Emacs |
79545 | 2512 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) |
2513 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2514 ;; Tell imenu how to handle Verilog. |
79545 | 2515 (make-local-variable 'imenu-generic-expression) |
2516 (setq imenu-generic-expression verilog-imenu-generic-expression) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2517 ;; Tell which-func-modes that imenu knows about verilog |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2518 (when (boundp 'which-function-modes) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2519 (add-to-list 'which-func-modes 'verilog-mode)) |
79545 | 2520 ;; hideshow support |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2521 (when (boundp 'hs-special-modes-alist) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2522 (unless (assq 'verilog-mode hs-special-modes-alist) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2523 (setq hs-special-modes-alist |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2524 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2525 verilog-forward-sexp-function) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2526 hs-special-modes-alist)))) |
79545 | 2527 |
2528 ;; Stuff for autos | |
2529 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | |
2530 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them | |
2531 ;; (verilog-getopt-flags) | |
2532 (run-hooks 'verilog-mode-hook)) | |
2533 | |
2534 | |
2535 ;; | |
2536 ;; Electric functions | |
2537 ;; | |
2538 (defun electric-verilog-terminate-line (&optional arg) | |
2539 "Terminate line and indent next line. | |
2540 With optional ARG, remove existing end of line comments." | |
2541 (interactive) | |
2542 ;; before that see if we are in a comment | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2543 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 2544 (cond |
2545 ((nth 7 state) ; Inside // comment | |
2546 (if (eolp) | |
2547 (progn | |
2548 (delete-horizontal-space) | |
2549 (newline)) | |
2550 (progn | |
2551 (newline) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2552 (insert "// ") |
79545 | 2553 (beginning-of-line))) |
2554 (verilog-indent-line)) | |
2555 ((nth 4 state) ; Inside any comment (hence /**/) | |
2556 (newline) | |
2557 (verilog-more-comment)) | |
2558 ((eolp) | |
2559 ;; First, check if current line should be indented | |
2560 (if (save-excursion | |
2561 (delete-horizontal-space) | |
2562 (beginning-of-line) | |
2563 (skip-chars-forward " \t") | |
2564 (if (looking-at verilog-auto-end-comment-lines-re) | |
2565 (let ((indent-str (verilog-indent-line))) | |
2566 ;; Maybe we should set some endcomments | |
2567 (if verilog-auto-endcomments | |
2568 (verilog-set-auto-endcomments indent-str arg)) | |
2569 (end-of-line) | |
2570 (delete-horizontal-space) | |
2571 (if arg | |
2572 () | |
2573 (newline)) | |
2574 nil) | |
2575 (progn | |
2576 (end-of-line) | |
2577 (delete-horizontal-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2578 't))) |
79545 | 2579 ;; see if we should line up assignments |
2580 (progn | |
2581 (if (or (memq 'all verilog-auto-lineup) | |
2582 (memq 'assignments verilog-auto-lineup)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2583 (verilog-pretty-expr)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2584 (newline)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2585 (forward-line 1)) |
79545 | 2586 ;; Indent next line |
2587 (if verilog-auto-indent-on-newline | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2588 (verilog-indent-line))) |
79545 | 2589 (t |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2590 (newline))))) |
79545 | 2591 |
2592 (defun electric-verilog-terminate-and-indent () | |
2593 "Insert a newline and indent for the next statement." | |
2594 (interactive) | |
2595 (electric-verilog-terminate-line 1)) | |
2596 | |
2597 (defun electric-verilog-semi () | |
2598 "Insert `;' character and reindent the line." | |
2599 (interactive) | |
2600 (insert last-command-char) | |
2601 | |
2602 (if (or (verilog-in-comment-or-string-p) | |
2603 (verilog-in-escaped-name-p)) | |
2604 () | |
2605 (save-excursion | |
2606 (beginning-of-line) | |
2607 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2608 (verilog-indent-line)) |
79545 | 2609 (if (and verilog-auto-newline |
2610 (not (verilog-parenthesis-depth))) | |
2611 (electric-verilog-terminate-line)))) | |
2612 | |
2613 (defun electric-verilog-semi-with-comment () | |
2614 "Insert `;' character, reindent the line and indent for comment." | |
2615 (interactive) | |
2616 (insert "\;") | |
2617 (save-excursion | |
2618 (beginning-of-line) | |
2619 (verilog-indent-line)) | |
2620 (indent-for-comment)) | |
2621 | |
2622 (defun electric-verilog-colon () | |
2623 "Insert `:' and do all indentations except line indent on this line." | |
2624 (interactive) | |
2625 (insert last-command-char) | |
2626 ;; Do nothing if within string. | |
2627 (if (or | |
2628 (verilog-within-string) | |
2629 (not (verilog-in-case-region-p))) | |
2630 () | |
2631 (save-excursion | |
2632 (let ((p (point)) | |
2633 (lim (progn (verilog-beg-of-statement) (point)))) | |
2634 (goto-char p) | |
2635 (verilog-backward-case-item lim) | |
2636 (verilog-indent-line))) | |
2637 ;; (let ((verilog-tab-always-indent nil)) | |
2638 ;; (verilog-indent-line)) | |
2639 )) | |
2640 | |
2641 ;;(defun electric-verilog-equal () | |
2642 ;; "Insert `=', and do indentation if within block." | |
2643 ;; (interactive) | |
2644 ;; (insert last-command-char) | |
2645 ;; Could auto line up expressions, but not yet | |
2646 ;; (if (eq (car (verilog-calculate-indent)) 'block) | |
2647 ;; (let ((verilog-tab-always-indent nil)) | |
2648 ;; (verilog-indent-command))) | |
2649 ;; ) | |
2650 | |
2651 (defun electric-verilog-tick () | |
2652 "Insert back-tick, and indent to column 0 if this is a CPP directive." | |
2653 (interactive) | |
2654 (insert last-command-char) | |
2655 (save-excursion | |
2656 (if (progn | |
2657 (beginning-of-line) | |
2658 (looking-at verilog-directive-re-1)) | |
2659 (verilog-indent-line)))) | |
2660 | |
2661 (defun electric-verilog-tab () | |
2662 "Function called when TAB is pressed in Verilog mode." | |
2663 (interactive) | |
2664 ;; If verilog-tab-always-indent, indent the beginning of the line. | |
2665 (if (or verilog-tab-always-indent | |
2666 (save-excursion | |
2667 (skip-chars-backward " \t") | |
2668 (bolp))) | |
2669 (let* ((oldpnt (point)) | |
2670 (boi-point | |
2671 (save-excursion | |
2672 (beginning-of-line) | |
2673 (skip-chars-forward " \t") | |
2674 (verilog-indent-line) | |
2675 (back-to-indentation) | |
2676 (point)))) | |
2677 (if (< (point) boi-point) | |
2678 (back-to-indentation) | |
2679 (cond ((not verilog-tab-to-comment)) | |
2680 ((not (eolp)) | |
2681 (end-of-line)) | |
2682 (t | |
2683 (indent-for-comment) | |
2684 (when (and (eolp) (= oldpnt (point))) | |
2685 ; kill existing comment | |
2686 (beginning-of-line) | |
2687 (re-search-forward comment-start-skip oldpnt 'move) | |
2688 (goto-char (match-beginning 0)) | |
2689 (skip-chars-backward " \t") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2690 (kill-region (point) oldpnt)))))) |
79545 | 2691 (progn (insert "\t")))) |
2692 | |
2693 | |
2694 | |
2695 ;; | |
2696 ;; Interactive functions | |
2697 ;; | |
2698 | |
2699 (defun verilog-indent-buffer () | |
2700 "Indent-region the entire buffer as Verilog code. | |
2701 To call this from the command line, see \\[verilog-batch-indent]." | |
2702 (interactive) | |
2703 (verilog-mode) | |
2704 (indent-region (point-min) (point-max) nil)) | |
2705 | |
2706 (defun verilog-insert-block () | |
2707 "Insert Verilog begin ... end; block in the code with right indentation." | |
2708 (interactive) | |
2709 (verilog-indent-line) | |
2710 (insert "begin") | |
2711 (electric-verilog-terminate-line) | |
2712 (save-excursion | |
2713 (electric-verilog-terminate-line) | |
2714 (insert "end") | |
2715 (beginning-of-line) | |
2716 (verilog-indent-line))) | |
2717 | |
2718 (defun verilog-star-comment () | |
2719 "Insert Verilog star comment at point." | |
2720 (interactive) | |
2721 (verilog-indent-line) | |
2722 (insert "/*") | |
2723 (save-excursion | |
2724 (newline) | |
2725 (insert " */")) | |
2726 (newline) | |
2727 (insert " * ")) | |
2728 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2729 (defun verilog-insert-1 (fmt max) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2730 "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
|
2731 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
|
2732 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
|
2733 (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
|
2734 (n 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2735 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2736 (while (< n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2737 (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
|
2738 (forward-line 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2739 ;; 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
|
2740 ;; shorter than col. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2741 (if (eobp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2742 (setq n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2743 (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
|
2744 (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
|
2745 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2746 (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
|
2747 "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
|
2748 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
|
2749 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
|
2750 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
|
2751 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
|
2752 located after the first 'a' gives: |
79545 | 2753 |
2754 a = b a[ 0] = b | |
2755 a = b a[ 1] = b | |
2756 a = b a[ 2] = b | |
2757 a = b a[ 3] = b | |
2758 a = b ==> insert-indices ==> a[ 4] = b | |
2759 a = b a[ 5] = b | |
2760 a = b a[ 6] = b | |
2761 a = b a[ 7] = b | |
2762 a = b a[ 8] = b" | |
2763 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2764 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2765 (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
|
2766 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2767 (defun verilog-generate-numbers (max) |
79545 | 2768 "Insert a set of generated numbers into a rectangle. |
2769 The upper left corner is defined by point. The numbers are padded to three | |
2770 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
|
2771 is supplied, then the user is prompted for the MAX number. Consider the |
79545 | 2772 following code fragment: |
2773 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2774 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
|
2775 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
|
2776 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
|
2777 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
|
2778 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
|
2779 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
|
2780 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
|
2781 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
|
2782 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
|
2783 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2784 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2785 (verilog-insert-1 "%3.3d" max)) |
79545 | 2786 |
2787 (defun verilog-mark-defun () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2788 "Mark the current Verilog function (or procedure). |
79545 | 2789 This puts the mark at the end, and point at the beginning." |
2790 (interactive) | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2791 (if (featurep 'xemacs) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2792 (progn |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2793 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2794 (verilog-end-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2795 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2796 (verilog-beg-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2797 (if (fboundp 'zmacs-activate-region) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2798 (zmacs-activate-region))) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2799 (mark-defun))) |
79545 | 2800 |
2801 (defun verilog-comment-region (start end) | |
2802 ; checkdoc-params: (start end) | |
2803 "Put the region into a Verilog comment. | |
2804 The comments that are in this area are \"deformed\": | |
2805 `*)' becomes `!(*' and `}' becomes `!{'. | |
2806 These deformed comments are returned to normal if you use | |
2807 \\[verilog-uncomment-region] to undo the commenting. | |
2808 | |
2809 The commented area starts with `verilog-exclude-str-start', and ends with | |
2810 `verilog-exclude-str-end'. But if you change these variables, | |
2811 \\[verilog-uncomment-region] won't recognize the comments." | |
2812 (interactive "r") | |
2813 (save-excursion | |
2814 ;; Insert start and endcomments | |
2815 (goto-char end) | |
2816 (if (and (save-excursion (skip-chars-forward " \t") (eolp)) | |
2817 (not (save-excursion (skip-chars-backward " \t") (bolp)))) | |
2818 (forward-line 1) | |
2819 (beginning-of-line)) | |
2820 (insert verilog-exclude-str-end) | |
2821 (setq end (point)) | |
2822 (newline) | |
2823 (goto-char start) | |
2824 (beginning-of-line) | |
2825 (insert verilog-exclude-str-start) | |
2826 (newline) | |
2827 ;; Replace end-comments within commented area | |
2828 (goto-char end) | |
2829 (save-excursion | |
2830 (while (re-search-backward "\\*/" start t) | |
2831 (replace-match "*-/" t t))) | |
2832 (save-excursion | |
2833 (let ((s+1 (1+ start))) | |
2834 (while (re-search-backward "/\\*" s+1 t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2835 (replace-match "/-*" t t)))))) |
79545 | 2836 |
2837 (defun verilog-uncomment-region () | |
2838 "Uncomment a commented area; change deformed comments back to normal. | |
2839 This command does nothing if the pointer is not in a commented | |
2840 area. See also `verilog-comment-region'." | |
2841 (interactive) | |
2842 (save-excursion | |
2843 (let ((start (point)) | |
2844 (end (point))) | |
2845 ;; Find the boundaries of the comment | |
2846 (save-excursion | |
2847 (setq start (progn (search-backward verilog-exclude-str-start nil t) | |
2848 (point))) | |
2849 (setq end (progn (search-forward verilog-exclude-str-end nil t) | |
2850 (point)))) | |
2851 ;; Check if we're really inside a comment | |
2852 (if (or (equal start (point)) (<= end (point))) | |
2853 (message "Not standing within commented area.") | |
2854 (progn | |
2855 ;; Remove endcomment | |
2856 (goto-char end) | |
2857 (beginning-of-line) | |
2858 (let ((pos (point))) | |
2859 (end-of-line) | |
2860 (delete-region pos (1+ (point)))) | |
2861 ;; Change comments back to normal | |
2862 (save-excursion | |
2863 (while (re-search-backward "\\*-/" start t) | |
2864 (replace-match "*/" t t))) | |
2865 (save-excursion | |
2866 (while (re-search-backward "/-\\*" start t) | |
2867 (replace-match "/*" t t))) | |
2868 ;; Remove start comment | |
2869 (goto-char start) | |
2870 (beginning-of-line) | |
2871 (let ((pos (point))) | |
2872 (end-of-line) | |
2873 (delete-region pos (1+ (point))))))))) | |
2874 | |
2875 (defun verilog-beg-of-defun () | |
2876 "Move backward to the beginning of the current function or procedure." | |
2877 (interactive) | |
2878 (verilog-re-search-backward verilog-defun-re nil 'move)) | |
2879 | |
2880 (defun verilog-end-of-defun () | |
2881 "Move forward to the end of the current function or procedure." | |
2882 (interactive) | |
2883 (verilog-re-search-forward verilog-end-defun-re nil 'move)) | |
2884 | |
2885 (defun verilog-get-beg-of-defun (&optional warn) | |
2886 (save-excursion | |
2887 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t) | |
2888 (point)) | |
2889 (t | |
2890 (error "%s: Can't find module beginning" (verilog-point-text)) | |
2891 (point-max))))) | |
2892 (defun verilog-get-end-of-defun (&optional warn) | |
2893 (save-excursion | |
2894 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t) | |
2895 (point)) | |
2896 (t | |
2897 (error "%s: Can't find endmodule" (verilog-point-text)) | |
2898 (point-max))))) | |
2899 | |
2900 (defun verilog-label-be (&optional arg) | |
2901 "Label matching begin ... end, fork ... join and case ... endcase statements. | |
2902 With ARG, first kill any existing labels." | |
2903 (interactive) | |
2904 (let ((cnt 0) | |
2905 (oldpos (point)) | |
2906 (b (progn | |
2907 (verilog-beg-of-defun) | |
2908 (point-marker))) | |
2909 (e (progn | |
2910 (verilog-end-of-defun) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2911 (point-marker)))) |
79545 | 2912 (goto-char (marker-position b)) |
2913 (if (> (- e b) 200) | |
2914 (message "Relabeling module...")) | |
2915 (while (and | |
2916 (> (marker-position e) (point)) | |
2917 (verilog-re-search-forward | |
2918 (concat | |
2919 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>" | |
2920 "\\|\\(`endif\\)\\|\\(`else\\)") | |
2921 nil 'move)) | |
2922 (goto-char (match-beginning 0)) | |
2923 (let ((indent-str (verilog-indent-line))) | |
2924 (verilog-set-auto-endcomments indent-str 't) | |
2925 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2926 (delete-horizontal-space)) |
79545 | 2927 (setq cnt (1+ cnt)) |
2928 (if (= 9 (% cnt 10)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2929 (message "%d..." cnt))) |
79545 | 2930 (goto-char oldpos) |
2931 (if (or | |
2932 (> (- e b) 200) | |
2933 (> cnt 20)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2934 (message "%d lines auto commented" cnt)))) |
79545 | 2935 |
2936 (defun verilog-beg-of-statement () | |
2937 "Move backward to beginning of statement." | |
2938 (interactive) | |
2939 ;; Move back token by token until we see the end | |
2940 ;; of some ealier line. | |
2941 (while | |
2942 ;; If the current point does not begin a new | |
2943 ;; statement, as in the character ahead of us is a ';', or SOF | |
2944 ;; or the string after us unambiguosly starts a statement, | |
2945 ;; or the token before us unambiguously ends a statement, | |
2946 ;; then move back a token and test again. | |
2947 (not (or | |
2948 (bolp) | |
2949 (= (preceding-char) ?\;) | |
2950 (not (or | |
2951 (looking-at "\\<") | |
2952 (forward-word -1))) | |
2953 (and | |
2954 (looking-at verilog-extended-complete-re) | |
2955 (not (save-excursion | |
2956 (verilog-backward-token) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2957 (looking-at verilog-extended-complete-re)))) |
79545 | 2958 (looking-at verilog-basic-complete-re) |
2959 (save-excursion | |
2960 (verilog-backward-token) | |
2961 (or | |
2962 (looking-at verilog-end-block-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2963 (looking-at verilog-preprocessor-re))))) |
79545 | 2964 (verilog-backward-syntactic-ws) |
2965 (verilog-backward-token)) | |
2966 ;; Now point is where the previous line ended. | |
2967 (verilog-forward-syntactic-ws)) | |
2968 | |
2969 (defun verilog-beg-of-statement-1 () | |
2970 "Move backward to beginning of statement." | |
2971 (interactive) | |
2972 (let ((pt (point))) | |
2973 | |
2974 (while (and (not (looking-at verilog-complete-reg)) | |
2975 (setq pt (point)) | |
2976 (verilog-backward-token) | |
2977 (not (looking-at verilog-complete-reg)) | |
2978 (verilog-backward-syntactic-ws) | |
2979 (setq pt (point)) | |
2980 (not (bolp)) | |
2981 (not (= (preceding-char) ?\;)))) | |
2982 (goto-char pt) | |
2983 (verilog-forward-ws&directives))) | |
2984 | |
2985 (defun verilog-end-of-statement () | |
2986 "Move forward to end of current statement." | |
2987 (interactive) | |
2988 (let ((nest 0) pos) | |
2989 (or (looking-at verilog-beg-block-re) | |
2990 ;; Skip to end of statement | |
2991 (setq pos (catch 'found | |
2992 (while t | |
2993 (forward-sexp 1) | |
2994 (verilog-skip-forward-comment-or-string) | |
2995 (cond ((looking-at "[ \t]*;") | |
2996 (skip-chars-forward "^;") | |
2997 (forward-char 1) | |
2998 (throw 'found (point))) | |
2999 ((save-excursion | |
3000 (forward-sexp -1) | |
3001 (looking-at verilog-beg-block-re)) | |
3002 (goto-char (match-beginning 0)) | |
3003 (throw 'found nil)) | |
3004 ((looking-at "[ \t]*)") | |
79546 | 3005 (throw 'found (point))) |
79545 | 3006 ((eobp) |
3007 (throw 'found (point)))))))) | |
3008 (if (not pos) | |
3009 ;; Skip a whole block | |
3010 (catch 'found | |
3011 (while t | |
3012 (verilog-re-search-forward verilog-end-statement-re nil 'move) | |
3013 (setq nest (if (match-end 1) | |
3014 (1+ nest) | |
3015 (1- nest))) | |
3016 (cond ((eobp) | |
3017 (throw 'found (point))) | |
3018 ((= 0 nest) | |
3019 (throw 'found (verilog-end-of-statement)))))) | |
3020 pos))) | |
3021 | |
3022 (defun verilog-in-case-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3023 "Return true if in a case region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3024 More specifically, point @ in the line foo : @ begin" |
79545 | 3025 (interactive) |
3026 (save-excursion | |
3027 (if (and | |
3028 (progn (verilog-forward-syntactic-ws) | |
3029 (looking-at "\\<begin\\>")) | |
3030 (progn (verilog-backward-syntactic-ws) | |
3031 (= (preceding-char) ?\:))) | |
3032 (catch 'found | |
3033 (let ((nest 1)) | |
3034 (while t | |
3035 (verilog-re-search-backward | |
3036 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|" | |
3037 "\\(\\<endcase\\>\\)\\>") | |
3038 nil 'move) | |
3039 (cond | |
3040 ((match-end 3) | |
3041 (setq nest (1+ nest))) | |
3042 ((match-end 2) | |
3043 (if (= nest 1) | |
3044 (throw 'found 1)) | |
3045 (setq nest (1- nest))) | |
3046 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3047 (throw 'found (= nest 0))))))) |
79545 | 3048 nil))) |
3049 (defun verilog-in-struct-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3050 "Return true if in a struct region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3051 More specifically, in a list after a struct|union keyword." |
79545 | 3052 (interactive) |
3053 (save-excursion | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
3054 (let* ((state (verilog-syntax-ppss)) |
79545 | 3055 (depth (nth 0 state))) |
3056 (if depth | |
3057 (progn (backward-up-list depth) | |
3058 (verilog-beg-of-statement) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3059 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
79545 | 3060 |
3061 (defun verilog-in-generate-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3062 "Return true if in a generate region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3063 More specifically, after a generate and before an endgenerate." |
79545 | 3064 (interactive) |
3065 (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
|
3066 (nest 1)) |
79545 | 3067 (save-excursion |
3068 (while (and | |
3069 (/= nest 0) | |
3070 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move) | |
3071 (cond | |
3072 ((match-end 1) ; generate | |
3073 (setq nest (1- nest))) | |
3074 ((match-end 2) ; endgenerate | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3075 (setq nest (1+ nest))))))) |
79545 | 3076 (= nest 0) )) ; return nest |
3077 | |
3078 (defun verilog-in-fork-region-p () | |
3079 "Return true if between a fork and join." | |
3080 (interactive) | |
3081 (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
|
3082 (nest 1)) |
79545 | 3083 (save-excursion |
3084 (while (and | |
3085 (/= nest 0) | |
3086 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | |
3087 (cond | |
3088 ((match-end 1) ; fork | |
3089 (setq nest (1- nest))) | |
3090 ((match-end 2) ; join | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3091 (setq nest (1+ nest))))))) |
79545 | 3092 (= nest 0) )) ; return nest |
3093 | |
3094 (defun verilog-backward-case-item (lim) | |
3095 "Skip backward to nearest enclosing case item. | |
3096 Limit search to point LIM." | |
3097 (interactive) | |
3098 (let ((str 'nil) | |
3099 (lim1 | |
3100 (progn | |
3101 (save-excursion | |
3102 (verilog-re-search-backward verilog-endcomment-reason-re | |
3103 lim 'move) | |
3104 (point))))) | |
3105 ;; Try to find the real : | |
3106 (if (save-excursion (search-backward ":" lim1 t)) | |
3107 (let ((colon 0) | |
3108 b e ) | |
3109 (while | |
3110 (and | |
3111 (< colon 1) | |
3112 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" | |
3113 lim1 'move)) | |
3114 (cond | |
3115 ((match-end 1) ;; [ | |
3116 (setq colon (1+ colon)) | |
3117 (if (>= colon 0) | |
3118 (error "%s: unbalanced [" (verilog-point-text)))) | |
3119 ((match-end 2) ;; ] | |
3120 (setq colon (1- colon))) | |
3121 | |
3122 ((match-end 3) ;; : | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3123 (setq colon (1+ colon))))) |
79545 | 3124 ;; Skip back to beginning of case item |
3125 (skip-chars-backward "\t ") | |
3126 (verilog-skip-backward-comment-or-string) | |
3127 (setq e (point)) | |
3128 (setq b | |
3129 (progn | |
3130 (if | |
3131 (verilog-re-search-backward | |
3132 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move) | |
3133 (progn | |
3134 (cond | |
3135 ((match-end 1) | |
3136 (goto-char (match-end 1)) | |
3137 (verilog-forward-ws&directives) | |
3138 (if (looking-at "(") | |
3139 (progn | |
3140 (forward-sexp) | |
3141 (verilog-forward-ws&directives))) | |
3142 (point)) | |
3143 (t | |
3144 (goto-char (match-end 0)) | |
3145 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3146 (point)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3147 (error "Malformed case item")))) |
79545 | 3148 (setq str (buffer-substring b e)) |
3149 (if | |
3150 (setq e | |
3151 (string-match | |
3152 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3153 (setq str (concat (substring str 0 e) "..."))) | |
3154 str) | |
3155 'nil))) | |
3156 | |
3157 | |
3158 ;; | |
3159 ;; Other functions | |
3160 ;; | |
3161 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3162 (defun verilog-kill-existing-comment () |
79545 | 3163 "Kill auto comment on this line." |
3164 (save-excursion | |
3165 (let* ( | |
3166 (e (progn | |
3167 (end-of-line) | |
3168 (point))) | |
3169 (b (progn | |
3170 (beginning-of-line) | |
3171 (search-forward "//" e t)))) | |
3172 (if b | |
3173 (delete-region (- b 2) e))))) | |
3174 | |
3175 (defconst verilog-directive-nest-re | |
3176 (concat "\\(`else\\>\\)\\|" | |
3177 "\\(`endif\\>\\)\\|" | |
3178 "\\(`if\\>\\)\\|" | |
3179 "\\(`ifdef\\>\\)\\|" | |
3180 "\\(`ifndef\\>\\)")) | |
3181 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment) | |
3182 "Add ending comment with given INDENT-STR. | |
3183 With KILL-EXISTING-COMMENT, remove what was there before. | |
3184 Insert `// case: 7 ' or `// NAME ' on this line if appropriate. | |
3185 Insert `// case expr ' if this line ends a case block. | |
3186 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
|
3187 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
|
3188 primitive or interface named NAME." |
79545 | 3189 (save-excursion |
3190 (cond | |
3191 (; Comment close preprocessor directives | |
3192 (and | |
3193 (looking-at "\\(`endif\\)\\|\\(`else\\)") | |
3194 (or kill-existing-comment | |
3195 (not (save-excursion | |
3196 (end-of-line) | |
3197 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3198 (let ((nest 1) b e | |
3199 m | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3200 (else (if (match-end 2) "!" " "))) |
79545 | 3201 (end-of-line) |
3202 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3203 (verilog-kill-existing-comment)) |
79545 | 3204 (delete-horizontal-space) |
3205 (save-excursion | |
3206 (backward-sexp 1) | |
3207 (while (and (/= nest 0) | |
3208 (verilog-re-search-backward verilog-directive-nest-re nil 'move)) | |
3209 (cond | |
3210 ((match-end 1) ; `else | |
3211 (if (= nest 1) | |
3212 (setq else "!"))) | |
3213 ((match-end 2) ; `endif | |
3214 (setq nest (1+ nest))) | |
3215 ((match-end 3) ; `if | |
3216 (setq nest (1- nest))) | |
3217 ((match-end 4) ; `ifdef | |
3218 (setq nest (1- nest))) | |
3219 ((match-end 5) ; `ifndef | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3220 (setq nest (1- nest))))) |
79545 | 3221 (if (match-end 0) |
3222 (setq | |
3223 m (buffer-substring | |
3224 (match-beginning 0) | |
3225 (match-end 0)) | |
3226 b (progn | |
3227 (skip-chars-forward "^ \t") | |
3228 (verilog-forward-syntactic-ws) | |
3229 (point)) | |
3230 e (progn | |
3231 (skip-chars-forward "a-zA-Z0-9_") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3232 (point))))) |
79545 | 3233 (if b |
3234 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | |
3235 (insert (concat " // " else m " " (buffer-substring b e)))) | |
3236 (progn | |
3237 (insert " // unmatched `else or `endif") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3238 (ding 't))))) |
79545 | 3239 |
3240 (; Comment close case/class/function/task/module and named block | |
3241 (and (looking-at "\\<end") | |
3242 (or kill-existing-comment | |
3243 (not (save-excursion | |
3244 (end-of-line) | |
3245 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3246 (let ((type (car indent-str))) | |
3247 (unless (eq type 'declaration) | |
3248 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends | |
3249 (if (looking-at verilog-end-block-ordered-re) | |
3250 (cond | |
3251 (;- This is a case block; search back for the start of this case | |
3252 (match-end 1) ;; of verilog-end-block-ordered-re | |
3253 | |
3254 (let ((err 't) | |
3255 (str "UNMATCHED!!")) | |
3256 (save-excursion | |
3257 (verilog-leap-to-head) | |
3258 (cond | |
3259 ((looking-at "\\<randcase\\>") | |
3260 (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
|
3261 (setq err nil)) |
79545 | 3262 ((match-end 0) |
3263 (goto-char (match-end 1)) | |
3264 (if nil | |
3265 (let (s f) | |
3266 (setq s (match-beginning 1)) | |
3267 (setq f (progn (end-of-line) | |
3268 (point))) | |
3269 (setq str (buffer-substring s f))) | |
3270 (setq err nil)) | |
3271 (setq str (concat (buffer-substring (match-beginning 1) (match-end 1)) | |
3272 " " | |
3273 (verilog-get-expr)))))) | |
3274 (end-of-line) | |
3275 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3276 (verilog-kill-existing-comment)) |
79545 | 3277 (delete-horizontal-space) |
3278 (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
|
3279 (if err (ding 't)))) |
79545 | 3280 |
3281 (;- This is a begin..end block | |
3282 (match-end 2) ;; of verilog-end-block-ordered-re | |
3283 (let ((str " // UNMATCHED !!") | |
3284 (err 't) | |
3285 (here (point)) | |
3286 there | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3287 cntx) |
79545 | 3288 (save-excursion |
3289 (verilog-leap-to-head) | |
3290 (setq there (point)) | |
3291 (if (not (match-end 0)) | |
3292 (progn | |
3293 (goto-char here) | |
3294 (end-of-line) | |
3295 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3296 (verilog-kill-existing-comment)) |
79545 | 3297 (delete-horizontal-space) |
3298 (insert str) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3299 (ding 't)) |
79545 | 3300 (let ((lim |
3301 (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3302 (here (point))) |
79545 | 3303 (cond |
3304 (;-- handle named block differently | |
3305 (looking-at verilog-named-block-re) | |
3306 (search-forward ":") | |
3307 (setq there (point)) | |
3308 (setq str (verilog-get-expr)) | |
3309 (setq err nil) | |
3310 (setq str (concat " // block: " str ))) | |
3311 | |
3312 ((verilog-in-case-region-p) ;-- handle case item differently | |
3313 (goto-char here) | |
3314 (setq str (verilog-backward-case-item lim)) | |
3315 (setq there (point)) | |
3316 (setq err nil) | |
3317 (setq str (concat " // case: " str ))) | |
3318 | |
3319 (;- try to find "reason" for this begin | |
3320 (cond | |
3321 (; | |
3322 (eq here (progn | |
3323 (verilog-backward-token) | |
3324 (verilog-beg-of-statement-1) | |
3325 (point))) | |
3326 (setq err nil) | |
3327 (setq str "")) | |
3328 ((looking-at verilog-endcomment-reason-re) | |
3329 (setq there (match-end 0)) | |
3330 (setq cntx (concat | |
3331 (buffer-substring (match-beginning 0) (match-end 0)) " ")) | |
3332 (cond | |
3333 (;- begin | |
3334 (match-end 2) | |
3335 (setq err nil) | |
3336 (save-excursion | |
3337 (if (and (verilog-continued-line) | |
3338 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) | |
3339 (progn | |
3340 (goto-char (match-end 0)) | |
3341 (setq there (point)) | |
3342 (setq str | |
3343 (concat " // " | |
3344 (buffer-substring (match-beginning 0) (match-end 0)) " " | |
3345 (verilog-get-expr)))) | |
3346 (setq str "")))) | |
3347 | |
3348 (;- else | |
3349 (match-end 4) | |
3350 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3351 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3352 (catch 'skip |
3353 (while (verilog-re-search-backward reg nil 'move) | |
3354 (cond | |
3355 ((match-end 1) ; begin | |
3356 (setq nest (1- nest))) | |
3357 ((match-end 2) ; end | |
3358 (setq nest (1+ nest))) | |
3359 ((match-end 3) | |
3360 (if (= 0 nest) | |
3361 (progn | |
3362 (goto-char (match-end 0)) | |
3363 (setq there (point)) | |
3364 (setq err nil) | |
3365 (setq str (verilog-get-expr)) | |
3366 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3367 (throw 'skip 1))))))))) |
79545 | 3368 |
3369 (;- end else | |
3370 (match-end 5) | |
3371 (goto-char there) | |
3372 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3373 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3374 (catch 'skip |
3375 (while (verilog-re-search-backward reg nil 'move) | |
3376 (cond | |
3377 ((match-end 1) ; begin | |
3378 (setq nest (1- nest))) | |
3379 ((match-end 2) ; end | |
3380 (setq nest (1+ nest))) | |
3381 ((match-end 3) | |
3382 (if (= 0 nest) | |
3383 (progn | |
3384 (goto-char (match-end 0)) | |
3385 (setq there (point)) | |
3386 (setq err nil) | |
3387 (setq str (verilog-get-expr)) | |
3388 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3389 (throw 'skip 1))))))))) |
79545 | 3390 |
3391 (;- task/function/initial et cetera | |
3392 t | |
3393 (match-end 0) | |
3394 (goto-char (match-end 0)) | |
3395 (setq there (point)) | |
3396 (setq err nil) | |
3397 (setq str (verilog-get-expr)) | |
3398 (setq str (concat " // " cntx str ))) | |
3399 | |
3400 (;-- otherwise... | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3401 (setq str " // auto-endcomment confused ")))) |
79545 | 3402 |
3403 ((and | |
3404 (verilog-in-case-region-p) ;-- handle case item differently | |
3405 (progn | |
3406 (setq there (point)) | |
3407 (goto-char here) | |
3408 (setq str (verilog-backward-case-item lim)))) | |
3409 (setq err nil) | |
3410 (setq str (concat " // case: " str ))) | |
3411 | |
3412 ((verilog-in-fork-region-p) | |
3413 (setq err nil) | |
3414 (setq str " // fork branch" )) | |
3415 | |
3416 ((looking-at "\\<end\\>") | |
3417 ;; HERE | |
3418 (forward-word 1) | |
3419 (verilog-forward-syntactic-ws) | |
3420 (setq err nil) | |
3421 (setq str (verilog-get-expr)) | |
3422 (setq str (concat " // " cntx str ))) | |
3423 | |
3424 )))) | |
3425 (goto-char here) | |
3426 (end-of-line) | |
3427 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3428 (verilog-kill-existing-comment)) |
79545 | 3429 (delete-horizontal-space) |
3430 (if (or err | |
3431 (> (count-lines here there) verilog-minimum-comment-distance)) | |
3432 (insert str)) | |
3433 (if err (ding 't)) | |
3434 )))) | |
3435 (;- this is endclass, which can be nested | |
3436 (match-end 11) ;; of verilog-end-block-ordered-re | |
3437 ;;(goto-char there) | |
3438 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3439 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3440 string) |
79545 | 3441 (save-excursion |
3442 (catch 'skip | |
3443 (while (verilog-re-search-backward reg nil 'move) | |
3444 (cond | |
3445 ((match-end 3) ; endclass | |
3446 (ding 't) | |
3447 (setq string "unmatched endclass") | |
3448 (throw 'skip 1)) | |
3449 | |
3450 ((match-end 2) ; endclass | |
3451 (setq nest (1+ nest))) | |
3452 | |
3453 ((match-end 1) ; class | |
3454 (setq nest (1- nest)) | |
3455 (if (< nest 0) | |
3456 (progn | |
3457 (goto-char (match-end 0)) | |
3458 (let (b e) | |
3459 (setq b (progn | |
3460 (skip-chars-forward "^ \t") | |
3461 (verilog-forward-ws&directives) | |
3462 (point)) | |
3463 e (progn | |
3464 (skip-chars-forward "a-zA-Z0-9_") | |
3465 (point))) | |
3466 (setq string (buffer-substring b e))) | |
3467 (throw 'skip 1)))) | |
3468 )))) | |
3469 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3470 (insert (concat " // " string )))) |
79545 | 3471 |
3472 (;- this is end{function,generate,task,module,primitive,table,generate} | |
3473 ;- which can not be nested. | |
3474 t | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3475 (let (string reg (name-re nil)) |
79545 | 3476 (end-of-line) |
3477 (if kill-existing-comment | |
3478 (save-match-data | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3479 (verilog-kill-existing-comment))) |
79545 | 3480 (delete-horizontal-space) |
3481 (backward-sexp) | |
3482 (cond | |
3483 ((match-end 5) ;; of verilog-end-block-ordered-re | |
3484 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)") | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3485 (setq name-re "\\w+\\s-*(") |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3486 ) |
79545 | 3487 ((match-end 6) ;; of verilog-end-block-ordered-re |
3488 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | |
3489 ((match-end 7) ;; of verilog-end-block-ordered-re | |
3490 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | |
3491 ((match-end 8) ;; of verilog-end-block-ordered-re | |
3492 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3493 ((match-end 9) ;; of verilog-end-block-ordered-re | |
3494 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) | |
3495 ((match-end 10) ;; of verilog-end-block-ordered-re | |
3496 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3497 ((match-end 11) ;; of verilog-end-block-ordered-re | |
3498 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3499 ((match-end 12) ;; of verilog-end-block-ordered-re | |
3500 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3501 ((match-end 13) ;; of verilog-end-block-ordered-re | |
3502 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3503 ((match-end 14) ;; of verilog-end-block-ordered-re | |
3504 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3505 ((match-end 15) ;; of verilog-end-block-ordered-re | |
3506 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | |
3507 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3508 (t (error "Problem in verilog-set-auto-endcomments"))) |
79545 | 3509 (let (b e) |
3510 (save-excursion | |
3511 (verilog-re-search-backward reg nil 'move) | |
3512 (cond | |
3513 ((match-end 1) | |
3514 (setq b (progn | |
3515 (skip-chars-forward "^ \t") | |
3516 (verilog-forward-ws&directives) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3517 (if (and name-re (verilog-re-search-forward name-re nil 'move)) |
79545 | 3518 (progn |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3519 (goto-char (match-beginning 0)) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3520 (verilog-forward-ws&directives))) |
79545 | 3521 (point)) |
3522 e (progn | |
3523 (skip-chars-forward "a-zA-Z0-9_") | |
3524 (point))) | |
3525 (setq string (buffer-substring b e))) | |
3526 (t | |
3527 (ding 't) | |
3528 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) | |
3529 (end-of-line) | |
3530 (insert (concat " // " string ))) | |
3531 )))))))))) | |
3532 | |
3533 (defun verilog-get-expr() | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3534 "Grab expression at point, e.g, case ( a | b & (c ^d))." |
79545 | 3535 (let* ((b (progn |
3536 (verilog-forward-syntactic-ws) | |
3537 (skip-chars-forward " \t") | |
3538 (point))) | |
3539 (e (let ((par 1)) | |
3540 (cond | |
3541 ((looking-at "@") | |
3542 (forward-char 1) | |
3543 (verilog-forward-syntactic-ws) | |
3544 (if (looking-at "(") | |
3545 (progn | |
3546 (forward-char 1) | |
3547 (while (and (/= par 0) | |
3548 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3549 (cond | |
3550 ((match-end 1) | |
3551 (setq par (1+ par))) | |
3552 ((match-end 2) | |
3553 (setq par (1- par))))))) | |
3554 (point)) | |
3555 ((looking-at "(") | |
3556 (forward-char 1) | |
3557 (while (and (/= par 0) | |
3558 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3559 (cond | |
3560 ((match-end 1) | |
3561 (setq par (1+ par))) | |
3562 ((match-end 2) | |
3563 (setq par (1- par))))) | |
3564 (point)) | |
3565 ((looking-at "\\[") | |
3566 (forward-char 1) | |
3567 (while (and (/= par 0) | |
3568 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move)) | |
3569 (cond | |
3570 ((match-end 1) | |
3571 (setq par (1+ par))) | |
3572 ((match-end 2) | |
3573 (setq par (1- par))))) | |
3574 (verilog-forward-syntactic-ws) | |
3575 (skip-chars-forward "^ \t\n\f") | |
3576 (point)) | |
3577 ((looking-at "/[/\\*]") | |
3578 b) | |
3579 ('t | |
3580 (skip-chars-forward "^: \t\n\f") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3581 (point))))) |
79545 | 3582 (str (buffer-substring b e))) |
3583 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3584 (setq str (concat (substring str 0 e) "..."))) | |
3585 str)) | |
3586 | |
3587 (defun verilog-expand-vector () | |
3588 "Take a signal vector on the current line and expand it to multiple lines. | |
3589 Useful for creating tri's and other expanded fields." | |
3590 (interactive) | |
3591 (verilog-expand-vector-internal "[" "]")) | |
3592 | |
3593 (defun verilog-expand-vector-internal (bra ket) | |
3594 "Given BRA, the start brace and KET, the end brace, expand one line into many lines." | |
3595 (save-excursion | |
3596 (forward-line 0) | |
3597 (let ((signal-string (buffer-substring (point) | |
3598 (progn | |
3599 (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
|
3600 (if (string-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3601 (concat "\\(.*\\)" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3602 (regexp-quote bra) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3603 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3604 (regexp-quote ket) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3605 "\\(.*\\)$") signal-string) |
79545 | 3606 (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
|
3607 (vec-start (string-to-number (match-string 2 signal-string))) |
79545 | 3608 (vec-end (if (= (match-beginning 3) (match-end 3)) |
3609 vec-start | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3610 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3611 (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
|
3612 (match-end 3))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3613 (vec-range |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3614 (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
|
3615 1 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3616 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3617 (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
|
3618 (match-end 4))))) |
79545 | 3619 (sig-tail (match-string 5 signal-string)) |
3620 vec) | |
3621 ;; Decode vectors | |
3622 (setq vec nil) | |
3623 (if (< vec-range 0) | |
3624 (let ((tmp vec-start)) | |
3625 (setq vec-start vec-end | |
3626 vec-end tmp | |
3627 vec-range (- vec-range)))) | |
3628 (if (< vec-end vec-start) | |
3629 (while (<= vec-end vec-start) | |
3630 (setq vec (append vec (list vec-start))) | |
3631 (setq vec-start (- vec-start vec-range))) | |
3632 (while (<= vec-start vec-end) | |
3633 (setq vec (append vec (list vec-start))) | |
3634 (setq vec-start (+ vec-start vec-range)))) | |
3635 ;; | |
3636 ;; Delete current line | |
3637 (delete-region (point) (progn (forward-line 0) (point))) | |
3638 ;; | |
3639 ;; Expand vector | |
3640 (while vec | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3641 (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
|
3642 (int-to-string (car vec)) ket sig-tail "\n")) |
79545 | 3643 (setq vec (cdr vec))) |
3644 (delete-char -1) | |
3645 ;; | |
3646 ))))) | |
3647 | |
3648 (defun verilog-strip-comments () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3649 "Strip all comments from the Verilog code." |
79545 | 3650 (interactive) |
3651 (goto-char (point-min)) | |
3652 (while (re-search-forward "//" nil t) | |
3653 (if (verilog-within-string) | |
3654 (re-search-forward "\"" nil t) | |
3655 (if (verilog-in-star-comment-p) | |
3656 (re-search-forward "\*/" nil t) | |
3657 (let ((bpt (- (point) 2))) | |
3658 (end-of-line) | |
3659 (delete-region bpt (point)))))) | |
3660 ;; | |
3661 (goto-char (point-min)) | |
3662 (while (re-search-forward "/\\*" nil t) | |
3663 (if (verilog-within-string) | |
3664 (re-search-forward "\"" nil t) | |
3665 (let ((bpt (- (point) 2))) | |
3666 (re-search-forward "\\*/") | |
3667 (delete-region bpt (point)))))) | |
3668 | |
3669 (defun verilog-one-line () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3670 "Convert structural Verilog instances to occupy one line." |
79545 | 3671 (interactive) |
3672 (goto-char (point-min)) | |
3673 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) | |
3674 (replace-match "\\1 " nil nil))) | |
3675 | |
3676 (defun verilog-linter-name () | |
3677 "Return name of linter, either surelint or verilint." | |
3678 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3679 compile-command)) | |
3680 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
3681 verilog-linter))) | |
3682 (cond ((equal compile-word1 "surelint") `surelint) | |
3683 ((equal compile-word1 "verilint") `verilint) | |
3684 ((equal lint-word1 "surelint") `surelint) | |
3685 ((equal lint-word1 "verilint") `verilint) | |
3686 (t `surelint)))) ;; back compatibility | |
3687 | |
3688 (defun verilog-lint-off () | |
3689 "Convert a Verilog linter warning line into a disable statement. | |
3690 For example: | |
3691 pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3692 becomes a comment for the appropriate tool. | |
3693 | |
3694 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
|
3695 variables is used to determine which product is being used. |
79545 | 3696 |
3697 See \\[verilog-surelint-off] and \\[verilog-verilint-off]." | |
3698 (interactive) | |
3699 (let ((linter (verilog-linter-name))) | |
3700 (cond ((equal linter `surelint) | |
3701 (verilog-surelint-off)) | |
3702 ((equal linter `verilint) | |
3703 (verilog-verilint-off)) | |
3704 (t (error "Linter name not set"))))) | |
3705 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3706 (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
|
3707 |
79545 | 3708 (defun verilog-surelint-off () |
3709 "Convert a SureLint warning line into a disable statement. | |
3710 Run from Verilog source window; assumes there is a *compile* buffer | |
3711 with point set appropriately. | |
3712 | |
3713 For example: | |
3714 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned. | |
3715 becomes: | |
3716 // surefire lint_line_off UDDONX" | |
3717 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3718 (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
|
3719 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
|
3720 compilation-last-buffer))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3721 (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
|
3722 ;; 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
|
3723 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3724 (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
|
3725 (beginning-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3726 (when |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3727 (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
|
3728 (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
|
3729 (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
|
3730 (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
|
3731 (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
|
3732 dir filename) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3733 (unless buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3734 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3735 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3736 (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
|
3737 (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
|
3738 (or buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3739 (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
|
3740 (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
|
3741 (read-file-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3742 (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
|
3743 file) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3744 dir file t)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3745 (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
|
3746 (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
|
3747 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3748 (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
|
3749 (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
|
3750 (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
|
3751 (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
|
3752 (end-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3753 (catch 'already |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3754 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3755 ((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
|
3756 (re-search-backward "//") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3757 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3758 ((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
|
3759 (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
|
3760 (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
|
3761 (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
|
3762 (throw 'already t) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3763 (insert (concat " " code))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3764 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3765 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3766 ((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
|
3767 (re-search-backward "/\*") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3768 (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
|
3769 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3770 (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
|
3771 ))))))))) |
79545 | 3772 |
3773 (defun verilog-verilint-off () | |
3774 "Convert a Verilint warning line into a disable statement. | |
3775 | |
3776 For example: | |
3777 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
3778 becomes: | |
3779 //Verilint 240 off // WARNING: Unused input" | |
3780 (interactive) | |
3781 (save-excursion | |
3782 (beginning-of-line) | |
3783 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$") | |
3784 (replace-match (format | |
3785 ;; %3s makes numbers 1-999 line up nicely | |
3786 "\\1//Verilint %3s off // WARNING: \\3" | |
3787 (match-string 2))) | |
3788 (beginning-of-line) | |
3789 (verilog-indent-line)))) | |
3790 | |
3791 (defun verilog-auto-save-compile () | |
3792 "Update automatics with \\[verilog-auto], save the buffer, and compile." | |
3793 (interactive) | |
3794 (verilog-auto) ; Always do it for safety | |
3795 (save-buffer) | |
3796 (compile compile-command)) | |
3797 | |
3798 | |
3799 | |
3800 ;; | |
3801 ;; Batch | |
3802 ;; | |
3803 | |
3804 (defmacro verilog-batch-error-wrapper (&rest body) | |
3805 "Execute BODY and add error prefix to any errors found. | |
3806 This lets programs calling batch mode to easily extract error messages." | |
79546 | 3807 `(condition-case err |
3808 (progn ,@body) | |
3809 (error | |
3810 (error "%%Error: %s%s" (error-message-string err) | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
3811 (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline |
79545 | 3812 |
3813 (defun verilog-batch-execute-func (funref) | |
3814 "Internal processing of a batch command, running FUNREF on all command arguments." | |
3815 (verilog-batch-error-wrapper | |
3816 ;; General globals needed | |
3817 (setq make-backup-files nil) | |
3818 (setq-default make-backup-files nil) | |
3819 (setq enable-local-variables t) | |
3820 (setq enable-local-eval t) | |
3821 ;; Make sure any sub-files we read get proper mode | |
3822 (setq default-major-mode `verilog-mode) | |
3823 ;; 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
|
3824 (mapc (lambda (buf) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3825 (when (buffer-file-name buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3826 (save-excursion |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3827 (set-buffer buf) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3828 (verilog-mode)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3829 (buffer-list)) |
79545 | 3830 ;; Process the files |
3831 (mapcar '(lambda (buf) | |
3832 (when (buffer-file-name buf) | |
3833 (save-excursion | |
3834 (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
|
3835 (error |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3836 (concat "File not found: " (buffer-file-name buf)))) |
79545 | 3837 (message (concat "Processing " (buffer-file-name buf))) |
3838 (set-buffer buf) | |
3839 (funcall funref) | |
3840 (save-buffer)))) | |
3841 (buffer-list)))) | |
3842 | |
3843 (defun verilog-batch-auto () | |
3844 "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
|
3845 This sets up the appropriate Verilog mode environment, updates automatics |
79545 | 3846 with \\[verilog-auto] on all command-line files, and saves the buffers. |
3847 For proper results, multiple filenames need to be passed on the command | |
3848 line in bottom-up order." | |
3849 (unless noninteractive | |
3850 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3851 (verilog-batch-execute-func `verilog-auto)) | |
3852 | |
3853 (defun verilog-batch-delete-auto () | |
3854 "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
|
3855 This sets up the appropriate Verilog mode environment, deletes automatics |
79545 | 3856 with \\[verilog-delete-auto] on all command-line files, and saves the buffers." |
3857 (unless noninteractive | |
3858 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3859 (verilog-batch-execute-func `verilog-delete-auto)) | |
3860 | |
3861 (defun verilog-batch-inject-auto () | |
3862 "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
|
3863 This sets up the appropriate Verilog mode environment, injects new automatics |
79545 | 3864 with \\[verilog-inject-auto] on all command-line files, and saves the buffers. |
3865 For proper results, multiple filenames need to be passed on the command | |
3866 line in bottom-up order." | |
3867 (unless noninteractive | |
3868 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3869 (verilog-batch-execute-func `verilog-inject-auto)) | |
3870 | |
3871 (defun verilog-batch-indent () | |
3872 "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
|
3873 This sets up the appropriate Verilog mode environment, calls |
79545 | 3874 \\[verilog-indent-buffer] on all command-line files, and saves the buffers." |
3875 (unless noninteractive | |
3876 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes | |
3877 (verilog-batch-execute-func `verilog-indent-buffer)) | |
3878 | |
3879 | |
3880 ;; | |
3881 ;; Indentation | |
3882 ;; | |
3883 (defconst verilog-indent-alist | |
3884 '((block . (+ ind verilog-indent-level)) | |
3885 (case . (+ ind verilog-case-indent)) | |
3886 (cparenexp . (+ ind verilog-indent-level)) | |
3887 (cexp . (+ ind verilog-cexp-indent)) | |
3888 (defun . verilog-indent-level-module) | |
3889 (declaration . verilog-indent-level-declaration) | |
3890 (directive . (verilog-calculate-indent-directive)) | |
3891 (tf . verilog-indent-level) | |
3892 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module)) | |
3893 (statement . ind) | |
3894 (cpp . 0) | |
3895 (comment . (verilog-comment-indent)) | |
3896 (unknown . 3) | |
3897 (string . 0))) | |
3898 | |
3899 (defun verilog-continued-line-1 (lim) | |
3900 "Return true if this is a continued line. | |
3901 Set point to where line starts. Limit search to point LIM." | |
3902 (let ((continued 't)) | |
3903 (if (eq 0 (forward-line -1)) | |
3904 (progn | |
3905 (end-of-line) | |
3906 (verilog-backward-ws&directives lim) | |
3907 (if (bobp) | |
3908 (setq continued nil) | |
3909 (setq continued (verilog-backward-token)))) | |
3910 (setq continued nil)) | |
3911 continued)) | |
3912 | |
3913 (defun verilog-calculate-indent () | |
3914 "Calculate the indent of the current Verilog line. | |
3915 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
|
3916 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
|
3917 Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." |
79545 | 3918 (save-excursion |
3919 (let* ((starting_position (point)) | |
3920 (par 0) | |
3921 (begin (looking-at "[ \t]*begin\\>")) | |
3922 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) | |
3923 (type (catch 'nesting | |
3924 ;; Keep working backwards until we can figure out | |
3925 ;; what type of statement this is. | |
3926 ;; Basically we need to figure out | |
3927 ;; 1) if this is a continuation of the previous line; | |
3928 ;; 2) are we in a block scope (begin..end) | |
3929 | |
3930 ;; if we are in a comment, done. | |
3931 (if (verilog-in-star-comment-p) | |
3932 (throw 'nesting 'comment)) | |
3933 | |
3934 ;; if we have a directive, done. | |
3935 (if (save-excursion (beginning-of-line) (looking-at verilog-directive-re-1)) | |
3936 (throw 'nesting 'directive)) | |
3937 | |
3938 ;; unless we are in the newfangled coverpoint or constraint blocks | |
3939 ;; if we are in a parenthesized list, and the user likes to indent these, return. | |
3940 (if (and | |
3941 verilog-indent-lists | |
3942 (not (verilog-in-coverage)) | |
3943 (verilog-in-paren)) | |
3944 (progn (setq par 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3945 (throw 'nesting 'block))) |
79545 | 3946 |
3947 ;; See if we are continuing a previous line | |
3948 (while t | |
3949 ;; trap out if we crawl off the top of the buffer | |
3950 (if (bobp) (throw 'nesting 'cpp)) | |
3951 | |
3952 (if (verilog-continued-line-1 lim) | |
3953 (let ((sp (point))) | |
3954 (if (and | |
3955 (not (looking-at verilog-complete-reg)) | |
3956 (verilog-continued-line-1 lim)) | |
3957 (progn (goto-char sp) | |
3958 (throw 'nesting 'cexp)) | |
3959 | |
3960 (goto-char sp)) | |
3961 | |
3962 (if (and begin | |
3963 (not verilog-indent-begin-after-if) | |
3964 (looking-at verilog-no-indent-begin-re)) | |
3965 (progn | |
3966 (beginning-of-line) | |
3967 (skip-chars-forward " \t") | |
3968 (throw 'nesting 'statement)) | |
3969 (progn | |
3970 (throw 'nesting 'cexp)))) | |
3971 ;; not a continued line | |
3972 (goto-char starting_position)) | |
3973 | |
3974 (if (looking-at "\\<else\\>") | |
3975 ;; search back for governing if, striding across begin..end pairs | |
3976 ;; appropriately | |
3977 (let ((elsec 1)) | |
3978 (while (verilog-re-search-backward verilog-ends-re nil 'move) | |
3979 (cond | |
3980 ((match-end 1) ; else, we're in deep | |
3981 (setq elsec (1+ elsec))) | |
3982 ((match-end 2) ; if | |
3983 (setq elsec (1- elsec)) | |
3984 (if (= 0 elsec) | |
3985 (if verilog-align-ifelse | |
3986 (throw 'nesting 'statement) | |
3987 (progn ;; back up to first word on this line | |
3988 (beginning-of-line) | |
3989 (verilog-forward-syntactic-ws) | |
3990 (throw 'nesting 'statement))))) | |
3991 (t ; endblock | |
3992 ; try to leap back to matching outward block by striding across | |
3993 ; indent level changing tokens then immediately | |
3994 ; previous line governs indentation. | |
3995 (let (( reg) (nest 1)) | |
3996 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup | |
3997 (cond | |
3998 ((match-end 3) ; end | |
3999 ;; Search back for matching begin | |
4000 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
4001 ((match-end 4) ; endcase | |
4002 ;; Search back for matching case | |
4003 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
4004 ((match-end 5) ; endfunction | |
4005 ;; Search back for matching function | |
4006 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
4007 ((match-end 6) ; endtask | |
4008 ;; Search back for matching task | |
4009 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
4010 ((match-end 7) ; endspecify | |
4011 ;; Search back for matching specify | |
4012 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
4013 ((match-end 8) ; endtable | |
4014 ;; Search back for matching table | |
4015 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
4016 ((match-end 9) ; endgenerate | |
4017 ;; Search back for matching generate | |
4018 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
4019 ((match-end 10) ; joins | |
4020 ;; Search back for matching fork | |
4021 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) | |
4022 ((match-end 11) ; class | |
4023 ;; Search back for matching class | |
4024 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
4025 ((match-end 12) ; covergroup | |
4026 ;; Search back for matching covergroup | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4027 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
79545 | 4028 (catch 'skip |
4029 (while (verilog-re-search-backward reg nil 'move) | |
4030 (cond | |
4031 ((match-end 1) ; begin | |
4032 (setq nest (1- nest)) | |
4033 (if (= 0 nest) | |
4034 (throw 'skip 1))) | |
4035 ((match-end 2) ; end | |
4036 (setq nest (1+ nest))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4037 ))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4038 (throw 'nesting (verilog-calc-1))) |
79545 | 4039 );; catch nesting |
4040 );; type | |
4041 ) | |
4042 ;; Return type of block and indent level. | |
4043 (if (not type) | |
4044 (setq type 'cpp)) | |
4045 (if (> par 0) ; Unclosed Parenthesis | |
4046 (list 'cparenexp par) | |
4047 (cond | |
4048 ((eq type 'case) | |
4049 (list type (verilog-case-indent-level))) | |
4050 ((eq type 'statement) | |
4051 (list type (current-column))) | |
4052 ((eq type 'defun) | |
4053 (list type 0)) | |
4054 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4055 (list type (verilog-current-indent-level)))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4056 |
79545 | 4057 (defun verilog-wai () |
4058 "Show matching nesting block for debugging." | |
4059 (interactive) | |
4060 (save-excursion | |
4061 (let ((nesting (verilog-calc-1))) | |
4062 (message "You are at nesting %s" nesting)))) | |
4063 | |
4064 (defun verilog-calc-1 () | |
4065 (catch 'nesting | |
4066 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move) | |
4067 (cond | |
4068 ((equal (char-after) ?\{) | |
4069 (if (verilog-at-constraint-p) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4070 (throw 'nesting 'block))) |
79545 | 4071 ((equal (char-after) ?\}) |
4072 | |
4073 (let ((there (verilog-at-close-constraint-p))) | |
4074 (if there (goto-char there)))) | |
4075 | |
4076 ((looking-at verilog-beg-block-re-ordered) | |
4077 (cond | |
4078 ((match-end 2) ; *sigh* could be "unique case" or "priority casex" | |
4079 (let ((here (point))) | |
4080 (verilog-beg-of-statement) | |
4081 (if (looking-at verilog-extended-case-re) | |
4082 (throw 'nesting 'case) | |
4083 (goto-char here))) | |
4084 (throw 'nesting 'case)) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4085 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4086 ((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
|
4087 (let ((here (point))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4088 (verilog-beg-of-statement) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4089 (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
|
4090 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
|
4091 (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
|
4092 (goto-char here) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4093 (throw 'nesting 'block))))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4094 |
79545 | 4095 |
4096 ;; need to consider typedef struct here... | |
4097 ((looking-at "\\<class\\|struct\\|function\\|task\\|property\\>") | |
4098 ; *sigh* These words have an optional prefix: | |
4099 ; extern {virtual|protected}? function a(); | |
4100 ; assert property (p_1); | |
4101 ; typedef class foo; | |
4102 ; and we don't want to confuse this with | |
4103 ; function a(); | |
4104 ; property | |
4105 ; ... | |
4106 ; endfunction | |
4107 (let ((here (point))) | |
4108 (save-excursion | |
4109 (verilog-beg-of-statement) | |
4110 (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
|
4111 (throw 'nesting 'block))))) |
79545 | 4112 (t (throw 'nesting 'block)))) |
4113 | |
4114 ((looking-at verilog-end-block-re) | |
4115 (verilog-leap-to-head) | |
4116 (if (verilog-in-case-region-p) | |
4117 (progn | |
4118 (verilog-leap-to-case-head) | |
4119 (if (looking-at verilog-case-re) | |
4120 (throw 'nesting 'case))))) | |
4121 | |
4122 ((looking-at (if (verilog-in-generate-region-p) | |
4123 verilog-defun-level-not-generate-re | |
4124 verilog-defun-level-re)) | |
4125 (throw 'nesting 'defun)) | |
4126 | |
4127 ((looking-at verilog-cpp-level-re) | |
4128 (throw 'nesting 'cpp)) | |
4129 | |
4130 ((bobp) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4131 (throw 'nesting 'cpp)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4132 (throw 'nesting 'cpp))) |
79545 | 4133 |
4134 (defun verilog-calculate-indent-directive () | |
4135 "Return indentation level for directive. | |
4136 For speed, the searcher looks at the last directive, not the indent | |
4137 of the appropriate enclosing block." | |
4138 (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
|
4139 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) |
79545 | 4140 ;; Start at current location, scan back for another directive |
4141 | |
4142 (save-excursion | |
4143 (beginning-of-line) | |
4144 (while (and (< base 0) | |
4145 (verilog-re-search-backward verilog-directive-re nil t)) | |
4146 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4147 (setq base (current-indentation)))) |
79545 | 4148 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
4149 (setq ind (- ind verilog-indent-level-directive))) | |
4150 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | |
4151 (setq ind (+ ind verilog-indent-level-directive))) | |
4152 ((looking-at verilog-directive-begin) | |
4153 (setq ind (+ ind verilog-indent-level-directive))))) | |
4154 ;; Adjust indent to starting indent of critical line | |
4155 (setq ind (max 0 (+ ind base)))) | |
4156 | |
4157 (save-excursion | |
4158 (beginning-of-line) | |
4159 (skip-chars-forward " \t") | |
4160 (cond ((or (looking-at verilog-directive-middle) | |
4161 (looking-at verilog-directive-end)) | |
4162 (setq ind (max 0 (- ind verilog-indent-level-directive)))))) | |
4163 ind)) | |
4164 | |
4165 (defun verilog-leap-to-case-head () | |
4166 (let ((nest 1)) | |
4167 (while (/= 0 nest) | |
4168 (verilog-re-search-backward "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" nil 'move) | |
4169 (cond | |
4170 ((match-end 1) | |
4171 (setq nest (1- nest))) | |
4172 ((match-end 2) | |
4173 (setq nest (1+ nest))) | |
4174 ((bobp) | |
4175 (ding 't) | |
4176 (setq nest 0)))))) | |
4177 | |
4178 (defun verilog-leap-to-head () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4179 "Move point to the head of this block. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4180 Jump from end to matching begin, from endcase to matching case, and so on." |
79545 | 4181 (let ((reg nil) |
4182 snest | |
4183 (nest 1)) | |
4184 (cond | |
4185 ((looking-at "\\<end\\>") | |
4186 ;; 1: Search back for matching begin | |
4187 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|" | |
4188 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))) | |
4189 ((looking-at "\\<endcase\\>") | |
4190 ;; 2: Search back for matching case | |
4191 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" )) | |
4192 ((looking-at "\\<join\\(_any\\|_none\\)?\\>") | |
4193 ;; 3: Search back for matching fork | |
4194 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4195 ((looking-at "\\<endclass\\>") | |
4196 ;; 4: Search back for matching class | |
4197 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
4198 ((looking-at "\\<endtable\\>") | |
4199 ;; 5: Search back for matching table | |
4200 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
4201 ((looking-at "\\<endspecify\\>") | |
4202 ;; 6: Search back for matching specify | |
4203 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
4204 ((looking-at "\\<endfunction\\>") | |
4205 ;; 7: Search back for matching function | |
4206 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
4207 ((looking-at "\\<endgenerate\\>") | |
4208 ;; 8: Search back for matching generate | |
4209 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
4210 ((looking-at "\\<endtask\\>") | |
4211 ;; 9: Search back for matching task | |
4212 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
4213 ((looking-at "\\<endgroup\\>") | |
4214 ;; 10: Search back for matching covergroup | |
4215 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
4216 ((looking-at "\\<endproperty\\>") | |
4217 ;; 11: Search back for matching property | |
4218 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
4219 ((looking-at "\\<endinterface\\>") | |
4220 ;; 12: Search back for matching interface | |
4221 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" )) | |
4222 ((looking-at "\\<endsequence\\>") | |
4223 ;; 12: Search back for matching sequence | |
4224 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | |
4225 ((looking-at "\\<endclocking\\>") | |
4226 ;; 12: Search back for matching clocking | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4227 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
79545 | 4228 (if reg |
4229 (catch 'skip | |
4230 (let (sreg) | |
4231 (while (verilog-re-search-backward reg nil 'move) | |
4232 (cond | |
4233 ((match-end 1) ; begin | |
4234 (setq nest (1- nest)) | |
4235 (if (= 0 nest) | |
4236 ;; Now previous line describes syntax | |
4237 (throw 'skip 1)) | |
4238 (if (and snest | |
4239 (= snest nest)) | |
4240 (setq reg sreg))) | |
4241 ((match-end 2) ; end | |
4242 (setq nest (1+ nest))) | |
4243 ((match-end 3) | |
4244 ;; endcase, jump to case | |
4245 (setq snest nest) | |
4246 (setq nest (1+ nest)) | |
4247 (setq sreg reg) | |
4248 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
4249 ((match-end 4) | |
4250 ;; join, jump to fork | |
4251 (setq snest nest) | |
4252 (setq nest (1+ nest)) | |
4253 (setq sreg reg) | |
4254 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) | |
4255 ))))))) | |
4256 | |
4257 (defun verilog-continued-line () | |
4258 "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
|
4259 Set point to where line starts." |
79545 | 4260 (let ((continued 't)) |
4261 (if (eq 0 (forward-line -1)) | |
4262 (progn | |
4263 (end-of-line) | |
4264 (verilog-backward-ws&directives) | |
4265 (if (bobp) | |
4266 (setq continued nil) | |
4267 (while (and continued | |
4268 (save-excursion | |
4269 (skip-chars-backward " \t") | |
4270 (not (bolp)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4271 (setq continued (verilog-backward-token))))) |
79545 | 4272 (setq continued nil)) |
4273 continued)) | |
4274 | |
4275 (defun verilog-backward-token () | |
4276 "Step backward token, returning true if we are now at an end of line token." | |
4277 (interactive) | |
4278 (verilog-backward-syntactic-ws) | |
4279 (cond | |
4280 ((bolp) | |
4281 nil) | |
4282 (;-- Anything ending in a ; is complete | |
4283 (= (preceding-char) ?\;) | |
4284 nil) | |
4285 (; If a "}" is prefixed by a ";", then this is a complete statement | |
4286 ; i.e.: constraint foo { a = b; } | |
4287 (= (preceding-char) ?\}) | |
4288 (progn | |
4289 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4290 (verilog-at-close-constraint-p))) |
79545 | 4291 (;-- constraint foo { a = b } |
4292 ; is a complete statement. *sigh* | |
4293 (= (preceding-char) ?\{) | |
4294 (progn | |
4295 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4296 (not (verilog-at-constraint-p)))) |
79545 | 4297 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4298 ; also could be simply '@(foo)' | |
4299 ; or foo u1 #(a=8) | |
4300 ; (b, ... which ISN'T complete | |
4301 ;;;; Do we need this??? | |
4302 (= (preceding-char) ?\)) | |
4303 (progn | |
4304 (backward-char) | |
4305 (backward-up-list 1) | |
4306 (verilog-backward-syntactic-ws) | |
4307 (let ((back (point))) | |
4308 (forward-word -1) | |
4309 (cond | |
4310 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") | |
4311 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]"))) | |
4312 (t | |
4313 (goto-char back) | |
4314 (cond | |
4315 ((= (preceding-char) ?\@) | |
4316 (backward-char) | |
4317 (save-excursion | |
4318 (verilog-backward-token) | |
4319 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | |
4320 ((= (preceding-char) ?\#) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4321 (backward-char)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4322 (t t))))))) |
79545 | 4323 |
4324 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | |
4325 t | |
4326 (forward-word -1) | |
4327 (cond | |
4328 ((looking-at "\\<else\\>") | |
4329 t) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4330 ((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
|
4331 t) |
79545 | 4332 ((looking-at verilog-indent-re) |
4333 nil) | |
4334 (t | |
4335 (let | |
4336 ((back (point))) | |
4337 (verilog-backward-syntactic-ws) | |
4338 (cond | |
4339 ((= (preceding-char) ?\:) | |
4340 (backward-char) | |
4341 (verilog-backward-syntactic-ws) | |
4342 (backward-sexp) | |
4343 (if (looking-at verilog-nameable-item-re ) | |
4344 nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4345 t)) |
79545 | 4346 ((= (preceding-char) ?\#) |
4347 (backward-char) | |
4348 t) | |
4349 ((= (preceding-char) ?\`) | |
4350 (backward-char) | |
4351 t) | |
4352 | |
4353 (t | |
4354 (goto-char back) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4355 t)))))))) |
79545 | 4356 |
4357 (defun verilog-backward-syntactic-ws (&optional bound) | |
4358 "Backward skip over syntactic whitespace for Emacs 19. | |
4359 Optional BOUND limits search." | |
4360 (save-restriction | |
4361 (let* ((bound (or bound (point-min))) (here bound) ) | |
4362 (if (< bound (point)) | |
4363 (progn | |
4364 (narrow-to-region bound (point)) | |
4365 (while (/= here (point)) | |
4366 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4367 (verilog-skip-backward-comments)))))) |
79545 | 4368 t) |
4369 | |
4370 (defun verilog-forward-syntactic-ws (&optional bound) | |
4371 "Forward skip over syntactic whitespace for Emacs 19. | |
4372 Optional BOUND limits search." | |
4373 (save-restriction | |
4374 (let* ((bound (or bound (point-max))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4375 (here bound)) |
79545 | 4376 (if (> bound (point)) |
4377 (progn | |
4378 (narrow-to-region (point) bound) | |
4379 (while (/= here (point)) | |
4380 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4381 (forward-comment (buffer-size)))))))) |
79545 | 4382 |
4383 (defun verilog-backward-ws&directives (&optional bound) | |
4384 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4385 Optional BOUND limits search." | |
4386 (save-restriction | |
4387 (let* ((bound (or bound (point-min))) | |
4388 (here bound) | |
4389 (p nil) ) | |
4390 (if (< bound (point)) | |
4391 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4392 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4393 (cond |
4394 ((nth 7 state) ;; in // comment | |
4395 (verilog-re-search-backward "//" nil 'move) | |
4396 (skip-chars-backward "/")) | |
4397 ((nth 4 state) ;; in /* */ comment | |
4398 (verilog-re-search-backward "/\*" nil 'move)))) | |
4399 (narrow-to-region bound (point)) | |
4400 (while (/= here (point)) | |
4401 (setq here (point)) | |
4402 (verilog-skip-backward-comments) | |
4403 (setq p | |
4404 (save-excursion | |
4405 (beginning-of-line) | |
4406 (cond | |
4407 ((verilog-within-translate-off) | |
4408 (verilog-back-to-start-translate-off (point-min))) | |
4409 ((looking-at verilog-directive-re-1) | |
4410 (point)) | |
4411 (t | |
4412 nil)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4413 (if p (goto-char p)))))))) |
79545 | 4414 |
4415 (defun verilog-forward-ws&directives (&optional bound) | |
4416 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4417 Optional BOUND limits search." | |
4418 (save-restriction | |
4419 (let* ((bound (or bound (point-max))) | |
4420 (here bound) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4421 jump) |
79545 | 4422 (if (> bound (point)) |
4423 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4424 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4425 (cond |
4426 ((nth 7 state) ;; in // comment | |
4427 (verilog-re-search-forward "//" nil 'move)) | |
4428 ((nth 4 state) ;; in /* */ comment | |
4429 (verilog-re-search-forward "/\*" nil 'move)))) | |
4430 (narrow-to-region (point) bound) | |
4431 (while (/= here (point)) | |
4432 (setq here (point) | |
4433 jump nil) | |
4434 (forward-comment (buffer-size)) | |
4435 (save-excursion | |
4436 (beginning-of-line) | |
4437 (if (looking-at verilog-directive-re-1) | |
4438 (setq jump t))) | |
4439 (if jump | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4440 (beginning-of-line 2)))))))) |
79545 | 4441 |
4442 (defun verilog-in-comment-p () | |
4443 "Return true if in a star or // comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4444 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4445 (or (nth 4 state) (nth 7 state)))) |
4446 | |
4447 (defun verilog-in-star-comment-p () | |
4448 "Return true if in a star comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4449 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4450 (and |
4451 (nth 4 state) ; t if in a comment of style a // or b /**/ | |
4452 (not | |
4453 (nth 7 state) ; t if in a comment of style b /**/ | |
4454 )))) | |
4455 | |
4456 (defun verilog-in-slash-comment-p () | |
4457 "Return true if in a slash comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4458 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4459 (nth 7 state))) |
4460 | |
4461 (defun verilog-in-comment-or-string-p () | |
4462 "Return true if in a string or comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4463 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4464 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) |
4465 | |
4466 (defun verilog-in-escaped-name-p () | |
4467 "Return true if in an escaped name." | |
4468 (save-excursion | |
4469 (backward-char) | |
4470 (skip-chars-backward "^ \t\n\f") | |
4471 (if (equal (char-after (point) ) ?\\ ) | |
4472 t | |
4473 nil))) | |
4474 | |
4475 (defun verilog-in-paren () | |
4476 "Return true if in a parenthetical expression." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4477 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4478 (> (nth 0 state) 0 ))) |
4479 | |
4480 (defun verilog-in-coverage () | |
4481 "Return true if in a constraint or coverpoint expression." | |
4482 (interactive) | |
4483 (save-excursion | |
4484 (if (verilog-in-paren) | |
4485 (progn | |
4486 (backward-up-list 1) | |
4487 (verilog-at-constraint-p) | |
4488 ) | |
4489 nil))) | |
4490 (defun verilog-at-close-constraint-p () | |
4491 "If at the } that closes a constraint or covergroup, return true." | |
4492 (if (and | |
4493 (equal (char-after) ?\}) | |
4494 (verilog-in-paren)) | |
4495 | |
4496 (save-excursion | |
4497 (verilog-backward-ws&directives) | |
4498 (if (equal (char-before) ?\;) | |
4499 (point) | |
4500 nil)))) | |
4501 | |
4502 (defun verilog-at-constraint-p () | |
4503 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." | |
4504 (if (save-excursion | |
4505 (and | |
4506 (equal (char-after) ?\{) | |
4507 (forward-list) | |
4508 (progn (backward-char 1) | |
4509 (verilog-backward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4510 (equal (char-before) ?\;)))) |
79545 | 4511 ;; maybe |
4512 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | |
4513 ;; not | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4514 nil)) |
79545 | 4515 |
4516 (defun verilog-parenthesis-depth () | |
4517 "Return non zero if in parenthetical-expression." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4518 (save-excursion (nth 1 (verilog-syntax-ppss)))) |
79545 | 4519 |
4520 | |
4521 (defun verilog-skip-forward-comment-or-string () | |
4522 "Return true if in a string or comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4523 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4524 (cond |
4525 ((nth 3 state) ;Inside string | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
4526 (search-forward "\"") |
79545 | 4527 t) |
4528 ((nth 7 state) ;Inside // comment | |
4529 (forward-line 1) | |
4530 t) | |
4531 ((nth 4 state) ;Inside any comment (hence /**/) | |
4532 (search-forward "*/")) | |
4533 (t | |
4534 nil)))) | |
4535 | |
4536 (defun verilog-skip-backward-comment-or-string () | |
4537 "Return true if in a string or comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4538 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4539 (cond |
4540 ((nth 3 state) ;Inside string | |
4541 (search-backward "\"") | |
4542 t) | |
4543 ((nth 7 state) ;Inside // comment | |
4544 (search-backward "//") | |
4545 (skip-chars-backward "/") | |
4546 t) | |
4547 ((nth 4 state) ;Inside /* */ comment | |
4548 (search-backward "/*") | |
4549 t) | |
4550 (t | |
4551 nil)))) | |
4552 | |
4553 (defun verilog-skip-backward-comments () | |
4554 "Return true if a comment was skipped." | |
4555 (let ((more t)) | |
4556 (while more | |
4557 (setq more | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4558 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4559 (cond |
4560 ((nth 7 state) ;Inside // comment | |
4561 (search-backward "//") | |
4562 (skip-chars-backward "/") | |
4563 (skip-chars-backward " \t\n\f") | |
4564 t) | |
4565 ((nth 4 state) ;Inside /* */ comment | |
4566 (search-backward "/*") | |
4567 (skip-chars-backward " \t\n\f") | |
4568 t) | |
4569 ((and (not (bobp)) | |
4570 (= (char-before) ?\/) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4571 (= (char-before (1- (point))) ?\*)) |
79545 | 4572 (goto-char (- (point) 2)) |
4573 t) | |
4574 (t | |
4575 (skip-chars-backward " \t\n\f") | |
4576 nil))))))) | |
4577 | |
4578 (defun verilog-skip-forward-comment-p () | |
4579 "If in comment, move to end and return true." | |
4580 (let (state) | |
4581 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4582 (setq state (save-excursion (verilog-syntax-ppss))) |
79545 | 4583 (cond |
4584 ((nth 3 state) | |
4585 t) | |
4586 ((nth 7 state) ;Inside // comment | |
4587 (end-of-line) | |
4588 (forward-char 1) | |
4589 t) | |
4590 ((nth 4 state) ;Inside any comment | |
4591 t) | |
4592 (t | |
4593 nil))))) | |
4594 | |
4595 (defun verilog-indent-line-relative () | |
4596 "Cheap version of indent line. | |
4597 Only look at a few lines to determine indent level." | |
4598 (interactive) | |
4599 (let ((indent-str) | |
4600 (sp (point))) | |
4601 (if (looking-at "^[ \t]*$") | |
4602 (cond ;- A blank line; No need to be too smart. | |
4603 ((bobp) | |
4604 (setq indent-str (list 'cpp 0))) | |
4605 ((verilog-continued-line) | |
4606 (let ((sp1 (point))) | |
4607 (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
|
4608 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4609 (goto-char sp) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4610 (setq indent-str |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4611 (list 'statement (verilog-current-indent-level)))) |
79545 | 4612 (goto-char sp1) |
4613 (setq indent-str (list 'block (verilog-current-indent-level))))) | |
4614 (goto-char sp)) | |
4615 ((goto-char sp) | |
4616 (setq indent-str (verilog-calculate-indent)))) | |
4617 (progn (skip-chars-forward " \t") | |
4618 (setq indent-str (verilog-calculate-indent)))) | |
4619 (verilog-do-indent indent-str))) | |
4620 | |
4621 (defun verilog-indent-line () | |
4622 "Indent for special part of code." | |
4623 (verilog-do-indent (verilog-calculate-indent))) | |
4624 | |
4625 (defun verilog-do-indent (indent-str) | |
4626 (let ((type (car indent-str)) | |
4627 (ind (car (cdr indent-str)))) | |
4628 (cond | |
4629 (; handle continued exp | |
4630 (eq type 'cexp) | |
4631 (let ((here (point))) | |
4632 (verilog-backward-syntactic-ws) | |
4633 (cond | |
4634 ((or | |
4635 (= (preceding-char) ?\,) | |
4636 (= (preceding-char) ?\]) | |
4637 (save-excursion | |
4638 (verilog-beg-of-statement-1) | |
4639 (looking-at verilog-declaration-re))) | |
4640 (let* ( fst | |
4641 (val | |
4642 (save-excursion | |
4643 (backward-char 1) | |
4644 (verilog-beg-of-statement-1) | |
4645 (setq fst (point)) | |
4646 (if (looking-at verilog-declaration-re) | |
4647 (progn ;; we have multiple words | |
4648 (goto-char (match-end 0)) | |
4649 (skip-chars-forward " \t") | |
4650 (cond | |
4651 ((and verilog-indent-declaration-macros | |
4652 (= (following-char) ?\`)) | |
4653 (progn | |
4654 (forward-char 1) | |
4655 (forward-word 1) | |
4656 (skip-chars-forward " \t"))) | |
4657 ((= (following-char) ?\[) | |
4658 (progn | |
4659 (forward-char 1) | |
4660 (backward-up-list -1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4661 (skip-chars-forward " \t")))) |
79545 | 4662 (current-column)) |
4663 (progn | |
4664 (goto-char fst) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4665 (+ (current-column) verilog-cexp-indent)))))) |
79545 | 4666 (goto-char here) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4667 (indent-line-to val))) |
79545 | 4668 ((= (preceding-char) ?\) ) |
4669 (goto-char here) | |
4670 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4671 (indent-line-to val))) | |
4672 (t | |
4673 (goto-char here) | |
4674 (let ((val)) | |
4675 (verilog-beg-of-statement-1) | |
4676 (if (and (< (point) here) | |
4677 (verilog-re-search-forward "=[ \\t]*" here 'move)) | |
4678 (setq val (current-column)) | |
4679 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | |
4680 (goto-char here) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4681 (indent-line-to val)))))) |
79545 | 4682 |
4683 (; handle inside parenthetical expressions | |
4684 (eq type 'cparenexp) | |
4685 (let ((val (save-excursion | |
4686 (backward-up-list 1) | |
4687 (forward-char 1) | |
4688 (skip-chars-forward " \t") | |
4689 (current-column)))) | |
4690 (indent-line-to val) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
4691 )) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
4692 |
79545 | 4693 (;-- Handle the ends |
4694 (or | |
4695 (looking-at verilog-end-block-re ) | |
4696 (verilog-at-close-constraint-p)) | |
4697 (let ((val (if (eq type 'statement) | |
4698 (- ind verilog-indent-level) | |
4699 ind))) | |
4700 (indent-line-to val))) | |
4701 | |
4702 (;-- Case -- maybe line 'em up | |
4703 (and (eq type 'case) (not (looking-at "^[ \t]*$"))) | |
4704 (progn | |
4705 (cond | |
4706 ((looking-at "\\<endcase\\>") | |
4707 (indent-line-to ind)) | |
4708 (t | |
4709 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
4710 (indent-line-to val)))))) | |
4711 | |
4712 (;-- defun | |
4713 (and (eq type 'defun) | |
4714 (looking-at verilog-zero-indent-re)) | |
4715 (indent-line-to 0)) | |
4716 | |
4717 (;-- declaration | |
4718 (and (or | |
4719 (eq type 'defun) | |
4720 (eq type 'block)) | |
4721 (looking-at verilog-declaration-re)) | |
4722 (verilog-indent-declaration ind)) | |
4723 | |
4724 (;-- Everything else | |
4725 t | |
4726 (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
|
4727 (indent-line-to val)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4728 |
79545 | 4729 (if (looking-at "[ \t]+$") |
4730 (skip-chars-forward " \t")) | |
4731 indent-str ; Return indent data | |
4732 )) | |
4733 | |
4734 (defun verilog-current-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4735 "Return the indent-level of the current statement." |
79545 | 4736 (save-excursion |
4737 (let (par-pos) | |
4738 (beginning-of-line) | |
4739 (setq par-pos (verilog-parenthesis-depth)) | |
4740 (while par-pos | |
4741 (goto-char par-pos) | |
4742 (beginning-of-line) | |
4743 (setq par-pos (verilog-parenthesis-depth))) | |
4744 (skip-chars-forward " \t") | |
4745 (current-column)))) | |
4746 | |
4747 (defun verilog-case-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4748 "Return the indent-level of the current statement. |
79545 | 4749 Do not count named blocks or case-statements." |
4750 (save-excursion | |
4751 (skip-chars-forward " \t") | |
4752 (cond | |
4753 ((looking-at verilog-named-block-re) | |
4754 (current-column)) | |
4755 ((and (not (looking-at verilog-case-re)) | |
4756 (looking-at "^[^:;]+[ \t]*:")) | |
4757 (verilog-re-search-forward ":" nil t) | |
4758 (skip-chars-forward " \t") | |
4759 (current-column)) | |
4760 (t | |
4761 (current-column))))) | |
4762 | |
4763 (defun verilog-indent-comment () | |
4764 "Indent current line as comment." | |
4765 (let* ((stcol | |
4766 (cond | |
4767 ((verilog-in-star-comment-p) | |
4768 (save-excursion | |
4769 (re-search-backward "/\\*" nil t) | |
4770 (1+(current-column)))) | |
4771 (comment-column | |
4772 comment-column ) | |
4773 (t | |
4774 (save-excursion | |
4775 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4776 (current-column)))))) |
79545 | 4777 (indent-line-to stcol) |
4778 stcol)) | |
4779 | |
4780 (defun verilog-more-comment () | |
4781 "Make more comment lines like the previous." | |
4782 (let* ((star 0) | |
4783 (stcol | |
4784 (cond | |
4785 ((verilog-in-star-comment-p) | |
4786 (save-excursion | |
4787 (setq star 1) | |
4788 (re-search-backward "/\\*" nil t) | |
4789 (1+(current-column)))) | |
4790 (comment-column | |
4791 comment-column ) | |
4792 (t | |
4793 (save-excursion | |
4794 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4795 (current-column)))))) |
79545 | 4796 (progn |
4797 (indent-to stcol) | |
4798 (if (and star | |
4799 (save-excursion | |
4800 (forward-line -1) | |
4801 (skip-chars-forward " \t") | |
4802 (looking-at "\*"))) | |
4803 (insert "* "))))) | |
4804 | |
4805 (defun verilog-comment-indent (&optional arg) | |
4806 "Return the column number the line should be indented to. | |
4807 ARG is ignored, for `comment-indent-function' compatibility." | |
4808 (cond | |
4809 ((verilog-in-star-comment-p) | |
4810 (save-excursion | |
4811 (re-search-backward "/\\*" nil t) | |
4812 (1+(current-column)))) | |
4813 ( comment-column | |
4814 comment-column ) | |
4815 (t | |
4816 (save-excursion | |
4817 (re-search-backward "//" nil t) | |
4818 (current-column))))) | |
4819 | |
4820 ;; | |
4821 | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4822 (defun verilog-pretty-declarations (&optional quiet) |
79545 | 4823 "Line up declarations around point." |
4824 (interactive) | |
4825 (save-excursion | |
4826 (if (progn | |
4827 (verilog-beg-of-statement-1) | |
4828 (looking-at verilog-declaration-re)) | |
4829 (let* ((m1 (make-marker)) | |
4830 (e) (r) | |
4831 (here (point)) | |
4832 ;; Start of declaration range | |
4833 (start | |
4834 (progn | |
4835 (verilog-beg-of-statement-1) | |
4836 (while (looking-at verilog-declaration-re) | |
4837 (beginning-of-line) | |
4838 (setq e (point)) | |
4839 (verilog-backward-syntactic-ws) | |
4840 (backward-char) | |
4841 (verilog-beg-of-statement-1)) ;Ack, need to grok `define | |
4842 e)) | |
4843 ;; End of declaration range | |
4844 (end | |
4845 (progn | |
4846 (goto-char here) | |
4847 (verilog-end-of-statement) | |
4848 (setq e (point)) ;Might be on last line | |
4849 (verilog-forward-syntactic-ws) | |
4850 (while (looking-at verilog-declaration-re) | |
4851 (beginning-of-line) | |
4852 (verilog-end-of-statement) | |
4853 (setq e (point)) | |
4854 (verilog-forward-syntactic-ws)) | |
4855 e)) | |
4856 (edpos (set-marker (make-marker) end)) | |
4857 (ind) | |
4858 (base-ind | |
4859 (progn | |
4860 (goto-char start) | |
4861 (verilog-do-indent (verilog-calculate-indent)) | |
4862 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4863 (current-column)))) |
79545 | 4864 (goto-char end) |
4865 (goto-char start) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4866 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4867 (> (- end start) 100)) |
79545 | 4868 (message "Lining up declarations..(please stand by)")) |
4869 ;; Get the beginning of line indent first | |
4870 (while (progn (setq e (marker-position edpos)) | |
4871 (< (point) e)) | |
4872 (cond | |
4873 ( (save-excursion (skip-chars-backward " \t") | |
4874 (bolp)) | |
4875 (verilog-forward-ws&directives) | |
4876 (indent-line-to base-ind) | |
4877 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4878 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
79545 | 4879 (t |
4880 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4881 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4882 ;;(forward-line) |
79545 | 4883 ) |
4884 ;; Now find biggest prefix | |
4885 (setq ind (verilog-get-lineup-indent start edpos)) | |
4886 ;; Now indent each line. | |
4887 (goto-char start) | |
4888 (while (progn (setq e (marker-position edpos)) | |
4889 (setq r (- e (point))) | |
4890 (> r 0)) | |
4891 (setq e (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4892 (unless quiet (message "%d" r)) |
79545 | 4893 (cond |
4894 ((or (and verilog-indent-declaration-macros | |
4895 (looking-at verilog-declaration-re-1-macro)) | |
4896 (looking-at verilog-declaration-re-1-no-macro)) | |
4897 (let ((p (match-end 0))) | |
4898 (set-marker m1 p) | |
4899 (if (verilog-re-search-forward "[[#`]" p 'move) | |
4900 (progn | |
4901 (forward-char -1) | |
4902 (just-one-space) | |
4903 (goto-char (marker-position m1)) | |
4904 (just-one-space) | |
4905 (indent-to ind)) | |
4906 (progn | |
4907 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4908 (indent-to ind))))) |
79545 | 4909 ((verilog-continued-line-1 start) |
4910 (goto-char e) | |
4911 (indent-line-to ind)) | |
4912 (t ; Must be comment or white space | |
4913 (goto-char e) | |
4914 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4915 (forward-line -1))) |
79545 | 4916 (forward-line 1)) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4917 (unless quiet (message "")))))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4918 |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4919 (defun verilog-pretty-expr (&optional quiet myre) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4920 "Line up expressions around point, or optional regexp MYRE." |
79545 | 4921 (interactive "sRegular Expression: ((<|:)?=) ") |
4922 (save-excursion | |
4923 (if (or (eq myre nil) | |
4924 (string-equal myre "")) | |
4925 (setq myre "\\(<\\|:\\)?=")) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
4926 (setq myre (concat "\\(^[^;#<=>]*\\)\\(" myre "\\)")) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4927 (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
|
4928 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4929 (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
|
4930 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4931 (let* ((here (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4932 (e) (r) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4933 (start |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4934 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4935 (beginning-of-line) |
79545 | 4936 (setq e (point)) |
4937 (verilog-backward-syntactic-ws) | |
4938 (beginning-of-line) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4939 (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
|
4940 (looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4941 (not (bobp)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4942 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4943 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4944 (verilog-backward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4945 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4946 ) ;Ack, need to grok `define |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4947 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4948 (end |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4949 (progn |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4950 (goto-char here) |
79545 | 4951 (end-of-line) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4952 (setq e (point)) ;Might be on last line |
79545 | 4953 (verilog-forward-syntactic-ws) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4954 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4955 (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
|
4956 (looking-at myre)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4957 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4958 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4959 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4960 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4961 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4962 e)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4963 (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
|
4964 (ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4965 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4966 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4967 (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
|
4968 (if (and (not quiet) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4969 (> (- end start) 100)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4970 (message "Lining up expressions..(please stand by)")) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4971 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4972 ;; 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
|
4973 (while (< (point) (marker-position edpos)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4974 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4975 (verilog-just-one-space myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4976 (end-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4977 (verilog-forward-syntactic-ws) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4978 ) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
4979 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4980 ;; Now find biggest prefix |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4981 (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
|
4982 |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4983 ;; Now indent each line. |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4984 (goto-char start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4985 (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
|
4986 (setq r (- e (point))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4987 (> r 0)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4988 (setq e (point)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4989 (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
|
4990 (cond |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4991 ((looking-at myre) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4992 (goto-char (match-end 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4993 (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
|
4994 (if (eq (char-after) ?=) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4995 (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
|
4996 (indent-to ind) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4997 ))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4998 ((verilog-continued-line-1 start) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
4999 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5000 (indent-line-to ind)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5001 (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
|
5002 (goto-char e) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5003 (verilog-forward-ws&directives) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5004 (forward-line -1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5005 ) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5006 (forward-line 1)) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5007 (unless quiet (message "")) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5008 ))))) |
79545 | 5009 |
5010 (defun verilog-just-one-space (myre) | |
5011 "Remove extra spaces around regular expression MYRE." | |
5012 (interactive) | |
5013 (if (and (not(looking-at verilog-complete-reg)) | |
5014 (looking-at myre)) | |
5015 (let ((p1 (match-end 1)) | |
5016 (p2 (match-end 2))) | |
5017 (progn | |
5018 (goto-char p2) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5019 (if (looking-at "\\s-") (just-one-space)) |
79545 | 5020 (goto-char p1) |
5021 (forward-char -1) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5022 (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
|
5023 )))) |
79545 | 5024 |
5025 (defun verilog-indent-declaration (baseind) | |
5026 "Indent current lines as declaration. | |
5027 Line up the variable names based on previous declaration's indentation. | |
5028 BASEIND is the base indent to offset everything." | |
5029 (interactive) | |
5030 (let ((pos (point-marker)) | |
5031 (lim (save-excursion | |
5032 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | |
5033 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | |
5034 (point))) | |
5035 (ind) | |
5036 (val) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5037 (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
|
5038 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5039 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 5040 (indent-line-to val) |
5041 | |
5042 ;; Use previous declaration (in this module) as template. | |
5043 (if (or (memq 'all verilog-auto-lineup) | |
5044 (memq 'declaration verilog-auto-lineup)) | |
79546 | 5045 (if (verilog-re-search-backward |
79545 | 5046 (or (and verilog-indent-declaration-macros |
5047 verilog-declaration-re-1-macro) | |
5048 verilog-declaration-re-1-no-macro) lim t) | |
5049 (progn | |
5050 (goto-char (match-end 0)) | |
5051 (skip-chars-forward " \t") | |
5052 (setq ind (current-column)) | |
5053 (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
|
5054 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5055 (+ baseind |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5056 (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 5057 (indent-line-to val) |
5058 (if (and verilog-indent-declaration-macros | |
5059 (looking-at verilog-declaration-re-2-macro)) | |
5060 (let ((p (match-end 0))) | |
5061 (set-marker m1 p) | |
5062 (if (verilog-re-search-forward "[[#`]" p 'move) | |
5063 (progn | |
5064 (forward-char -1) | |
5065 (just-one-space) | |
5066 (goto-char (marker-position m1)) | |
5067 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5068 (indent-to ind)) |
79545 | 5069 (if (/= (current-column) ind) |
5070 (progn | |
5071 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5072 (indent-to ind))))) |
79545 | 5073 (if (looking-at verilog-declaration-re-2-no-macro) |
5074 (let ((p (match-end 0))) | |
5075 (set-marker m1 p) | |
5076 (if (verilog-re-search-forward "[[`#]" p 'move) | |
5077 (progn | |
5078 (forward-char -1) | |
5079 (just-one-space) | |
5080 (goto-char (marker-position m1)) | |
5081 (just-one-space) | |
5082 (indent-to ind)) | |
5083 (if (/= (current-column) ind) | |
5084 (progn | |
5085 (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
|
5086 (indent-to ind)))))))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5087 (goto-char pos))) |
79545 | 5088 |
5089 (defun verilog-get-lineup-indent (b edpos) | |
5090 "Return the indent level that will line up several lines within the region. | |
5091 Region is defined by B and EDPOS." | |
5092 (save-excursion | |
5093 (let ((ind 0) e) | |
5094 (goto-char b) | |
5095 ;; Get rightmost position | |
5096 (while (progn (setq e (marker-position edpos)) | |
5097 (< (point) e)) | |
79546 | 5098 (if (verilog-re-search-forward |
79545 | 5099 (or (and verilog-indent-declaration-macros |
5100 verilog-declaration-re-1-macro) | |
5101 verilog-declaration-re-1-no-macro) e 'move) | |
5102 (progn | |
5103 (goto-char (match-end 0)) | |
5104 (verilog-backward-syntactic-ws) | |
5105 (if (> (current-column) ind) | |
5106 (setq ind (current-column))) | |
5107 (goto-char (match-end 0))))) | |
5108 (if (> ind 0) | |
5109 (1+ ind) | |
5110 ;; No lineup-string found | |
5111 (goto-char b) | |
5112 (end-of-line) | |
5113 (skip-chars-backward " \t") | |
5114 (1+ (current-column)))))) | |
5115 | |
5116 (defun verilog-get-lineup-indent-2 (myre b edpos) | |
5117 "Return the indent level that will line up several lines within the region." | |
5118 (save-excursion | |
5119 (let ((ind 0) e) | |
5120 (goto-char b) | |
5121 ;; Get rightmost position | |
5122 (while (progn (setq e (marker-position edpos)) | |
5123 (< (point) e)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5124 (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
|
5125 (not (verilog-parenthesis-depth))) ;; skip parenthsized exprs |
79545 | 5126 (progn |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5127 (goto-char (match-beginning 2)) |
79545 | 5128 (verilog-backward-syntactic-ws) |
5129 (if (> (current-column) ind) | |
5130 (setq ind (current-column))) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5131 (goto-char (match-end 0))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5132 )) |
79545 | 5133 (if (> ind 0) |
5134 (1+ ind) | |
5135 ;; No lineup-string found | |
5136 (goto-char b) | |
5137 (end-of-line) | |
5138 (skip-chars-backward " \t") | |
5139 (1+ (current-column)))))) | |
5140 | |
5141 (defun verilog-comment-depth (type val) | |
5142 "A useful mode debugging aide. TYPE and VAL are comments for insertion." | |
5143 (save-excursion | |
5144 (let | |
5145 ((b (prog2 | |
5146 (beginning-of-line) | |
5147 (point-marker) | |
5148 (end-of-line))) | |
5149 (e (point-marker))) | |
5150 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t) | |
5151 (progn | |
5152 (replace-match " /* -# ## */") | |
5153 (end-of-line)) | |
5154 (progn | |
5155 (end-of-line) | |
5156 (insert " /* ## ## */")))) | |
5157 (backward-char 6) | |
5158 (insert | |
5159 (format "%s %d" type val)))) | |
5160 | |
5161 ;; | |
5162 ;; | |
5163 ;; Completion | |
5164 ;; | |
5165 (defvar verilog-str nil) | |
5166 (defvar verilog-all nil) | |
5167 (defvar verilog-pred nil) | |
5168 (defvar verilog-buffer-to-use nil) | |
5169 (defvar verilog-flag nil) | |
5170 (defvar verilog-toggle-completions nil | |
5171 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one. | |
5172 Repeated use of \\[verilog-complete-word] will show you all of them. | |
5173 Normally, when there is more than one possible completion, | |
5174 it displays a list of all possible completions.") | |
5175 | |
5176 | |
5177 (defvar verilog-type-keywords | |
5178 '( | |
5179 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input" | |
5180 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0" | |
5181 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
5182 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0" | |
5183 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1" | |
5184 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor" | |
5185 ) | |
5186 "*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
|
5187 \(Eg. integer, real, reg...)") |
79545 | 5188 |
5189 (defvar verilog-cpp-keywords | |
5190 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else" | |
5191 "endif") | |
5192 "*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
|
5193 \(Eg. initial, always, begin, assign.) |
79545 | 5194 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
|
5195 will be completed at runtime and should not be added to this list.") |
79545 | 5196 |
5197 (defvar verilog-defun-keywords | |
5198 (append | |
5199 '( | |
5200 "always" "always_comb" "always_ff" "always_latch" "assign" | |
5201 "begin" "end" "generate" "endgenerate" "module" "endmodule" | |
5202 "specify" "endspecify" "function" "endfunction" "initial" "final" | |
5203 "task" "endtask" "primitive" "endprimitive" | |
5204 ) | |
5205 verilog-type-keywords) | |
5206 "*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
|
5207 \(Eg. initial, always, begin, assign.) |
79545 | 5208 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
|
5209 will be completed at runtime and should not be added to this list.") |
79545 | 5210 |
5211 (defvar verilog-block-keywords | |
5212 '( | |
5213 "begin" "break" "case" "continue" "else" "end" "endfunction" | |
5214 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask" | |
5215 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return" | |
5216 "while") | |
5217 "*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
|
5218 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5219 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
|
5220 will be completed at runtime and should not be added to this list.") |
79545 | 5221 |
5222 (defvar verilog-tf-keywords | |
5223 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat") | |
5224 "*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
|
5225 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5226 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
|
5227 will be completed at runtime and should not be added to this list.") |
79545 | 5228 |
5229 (defvar verilog-case-keywords | |
5230 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat") | |
5231 "*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
|
5232 \(Eg. begin, if, then, else, for, fork.) |
79545 | 5233 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
|
5234 will be completed at runtime and should not be added to this list.") |
79545 | 5235 |
5236 (defvar verilog-separator-keywords | |
5237 '("else" "then" "begin") | |
5238 "*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
|
5239 \(Eg. else, then.) |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5240 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
|
5241 will be completed at runtime and should not be added to this list.") |
79545 | 5242 |
5243 (defun verilog-string-diff (str1 str2) | |
5244 "Return index of first letter where STR1 and STR2 differs." | |
5245 (catch 'done | |
5246 (let ((diff 0)) | |
5247 (while t | |
5248 (if (or (> (1+ diff) (length str1)) | |
5249 (> (1+ diff) (length str2))) | |
5250 (throw 'done diff)) | |
5251 (or (equal (aref str1 diff) (aref str2 diff)) | |
5252 (throw 'done diff)) | |
5253 (setq diff (1+ diff)))))) | |
5254 | |
5255 ;; Calculate all possible completions for functions if argument is `function', | |
5256 ;; completions for procedures if argument is `procedure' or both functions and | |
5257 ;; procedures otherwise. | |
5258 | |
5259 (defun verilog-func-completion (type) | |
5260 "Build regular expression for module/task/function names. | |
5261 TYPE is 'module, 'tf for task or function, or t if unknown." | |
5262 (if (string= verilog-str "") | |
5263 (setq verilog-str "[a-zA-Z_]")) | |
5264 (let ((verilog-str (concat (cond | |
5265 ((eq type 'module) "\\<\\(module\\)\\s +") | |
5266 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") | |
5267 (t "\\<\\(task\\|function\\|module\\)\\s +")) | |
5268 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) | |
5269 match) | |
5270 | |
5271 (if (not (looking-at verilog-defun-re)) | |
5272 (verilog-re-search-backward verilog-defun-re nil t)) | |
5273 (forward-char 1) | |
5274 | |
5275 ;; Search through all reachable functions | |
5276 (goto-char (point-min)) | |
5277 (while (verilog-re-search-forward verilog-str (point-max) t) | |
5278 (progn (setq match (buffer-substring (match-beginning 2) | |
5279 (match-end 2))) | |
5280 (if (or (null verilog-pred) | |
5281 (funcall verilog-pred match)) | |
5282 (setq verilog-all (cons match verilog-all))))) | |
5283 (if (match-beginning 0) | |
5284 (goto-char (match-beginning 0))))) | |
5285 | |
5286 (defun verilog-get-completion-decl (end) | |
5287 "Macro for searching through current declaration (var, type or const) | |
5288 for matches of `str' and adding the occurrence tp `all' through point END." | |
5289 (let ((re (or (and verilog-indent-declaration-macros | |
5290 verilog-declaration-re-2-macro) | |
5291 verilog-declaration-re-2-no-macro)) | |
5292 decl-end match) | |
5293 ;; Traverse lines | |
5294 (while (and (< (point) end) | |
5295 (verilog-re-search-forward re end t)) | |
5296 ;; Traverse current line | |
5297 (setq decl-end (save-excursion (verilog-declaration-end))) | |
5298 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t) | |
5299 (not (match-end 1))) | |
5300 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | |
5301 (if (string-match (concat "\\<" verilog-str) match) | |
5302 (if (or (null verilog-pred) | |
5303 (funcall verilog-pred match)) | |
5304 (setq verilog-all (cons match verilog-all))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5305 (forward-line 1))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5306 verilog-all) |
79545 | 5307 |
5308 (defun verilog-type-completion () | |
5309 "Calculate all possible completions for types." | |
5310 (let ((start (point)) | |
5311 goon) | |
5312 ;; Search for all reachable type declarations | |
5313 (while (or (verilog-beg-of-defun) | |
5314 (setq goon (not goon))) | |
5315 (save-excursion | |
5316 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun) | |
5317 (point)) | |
5318 (forward-char 1))) | |
5319 (verilog-re-search-forward | |
5320 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" | |
5321 start t) | |
5322 (not (match-end 1))) | |
5323 ;; Check current type declaration | |
5324 (verilog-get-completion-decl start)))))) | |
5325 | |
5326 (defun verilog-var-completion () | |
5327 "Calculate all possible completions for variables (or constants)." | |
5328 (let ((start (point))) | |
5329 ;; Search for all reachable var declarations | |
5330 (verilog-beg-of-defun) | |
5331 (save-excursion | |
5332 ;; Check var declarations | |
5333 (verilog-get-completion-decl start)))) | |
5334 | |
5335 (defun verilog-keyword-completion (keyword-list) | |
5336 "Give list of all possible completions of keywords in KEYWORD-LIST." | |
5337 (mapcar '(lambda (s) | |
5338 (if (string-match (concat "\\<" verilog-str) s) | |
5339 (if (or (null verilog-pred) | |
5340 (funcall verilog-pred s)) | |
5341 (setq verilog-all (cons s verilog-all))))) | |
5342 keyword-list)) | |
5343 | |
5344 | |
5345 (defun verilog-completion (verilog-str verilog-pred verilog-flag) | |
5346 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5347 Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it | |
5348 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
|
5349 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
|
5350 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
|
5351 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
|
5352 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
|
5353 exact match, nil otherwise." |
79545 | 5354 (save-excursion |
5355 (let ((verilog-all nil)) | |
5356 ;; Set buffer to use for searching labels. This should be set | |
5357 ;; within functions which use verilog-completions | |
5358 (set-buffer verilog-buffer-to-use) | |
5359 | |
5360 ;; Determine what should be completed | |
5361 (let ((state (car (verilog-calculate-indent)))) | |
5362 (cond ((eq state 'defun) | |
5363 (save-excursion (verilog-var-completion)) | |
5364 (verilog-func-completion 'module) | |
5365 (verilog-keyword-completion verilog-defun-keywords)) | |
5366 | |
5367 ((eq state 'behavioral) | |
5368 (save-excursion (verilog-var-completion)) | |
5369 (verilog-func-completion 'module) | |
5370 (verilog-keyword-completion verilog-defun-keywords)) | |
5371 | |
5372 ((eq state 'block) | |
5373 (save-excursion (verilog-var-completion)) | |
5374 (verilog-func-completion 'tf) | |
5375 (verilog-keyword-completion verilog-block-keywords)) | |
5376 | |
5377 ((eq state 'case) | |
5378 (save-excursion (verilog-var-completion)) | |
5379 (verilog-func-completion 'tf) | |
5380 (verilog-keyword-completion verilog-case-keywords)) | |
5381 | |
5382 ((eq state 'tf) | |
5383 (save-excursion (verilog-var-completion)) | |
5384 (verilog-func-completion 'tf) | |
5385 (verilog-keyword-completion verilog-tf-keywords)) | |
5386 | |
5387 ((eq state 'cpp) | |
5388 (save-excursion (verilog-var-completion)) | |
5389 (verilog-keyword-completion verilog-cpp-keywords)) | |
5390 | |
5391 ((eq state 'cparenexp) | |
5392 (save-excursion (verilog-var-completion))) | |
5393 | |
5394 (t;--Anywhere else | |
5395 (save-excursion (verilog-var-completion)) | |
5396 (verilog-func-completion 'both) | |
5397 (verilog-keyword-completion verilog-separator-keywords)))) | |
5398 | |
5399 ;; Now we have built a list of all matches. Give response to caller | |
5400 (verilog-completion-response)))) | |
5401 | |
5402 (defun verilog-completion-response () | |
5403 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag)) | |
5404 ;; This was not called by all-completions | |
5405 (if (null verilog-all) | |
5406 ;; Return nil if there was no matching label | |
5407 nil | |
5408 ;; Get longest string common in the labels | |
5409 (let* ((elm (cdr verilog-all)) | |
5410 (match (car verilog-all)) | |
5411 (min (length match)) | |
5412 tmp) | |
5413 (if (string= match verilog-str) | |
5414 ;; Return t if first match was an exact match | |
5415 (setq match t) | |
5416 (while (not (null elm)) | |
5417 ;; Find longest common string | |
5418 (if (< (setq tmp (verilog-string-diff match (car elm))) min) | |
5419 (progn | |
5420 (setq min tmp) | |
5421 (setq match (substring match 0 min)))) | |
5422 ;; Terminate with match=t if this is an exact match | |
5423 (if (string= (car elm) verilog-str) | |
5424 (progn | |
5425 (setq match t) | |
5426 (setq elm nil)) | |
5427 (setq elm (cdr elm))))) | |
5428 ;; If this is a test just for exact match, return nil ot t | |
5429 (if (and (equal verilog-flag 'lambda) (not (equal match 't))) | |
5430 nil | |
5431 match)))) | |
5432 ;; If flag is t, this was called by all-completions. Return | |
5433 ;; list of all possible completions | |
5434 (verilog-flag | |
5435 verilog-all))) | |
5436 | |
5437 (defvar verilog-last-word-numb 0) | |
5438 (defvar verilog-last-word-shown nil) | |
5439 (defvar verilog-last-completions nil) | |
5440 | |
5441 (defun verilog-complete-word () | |
5442 "Complete word at current point. | |
5443 \(See also `verilog-toggle-completions', `verilog-type-keywords', | |
5444 and `verilog-separator-keywords'.)" | |
5445 (interactive) | |
5446 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5447 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5448 (verilog-str (buffer-substring b e)) | |
5449 ;; The following variable is used in verilog-completion | |
5450 (verilog-buffer-to-use (current-buffer)) | |
5451 (allcomp (if (and verilog-toggle-completions | |
5452 (string= verilog-last-word-shown verilog-str)) | |
5453 verilog-last-completions | |
5454 (all-completions verilog-str 'verilog-completion))) | |
5455 (match (if verilog-toggle-completions | |
5456 "" (try-completion | |
5457 verilog-str (mapcar '(lambda (elm) | |
5458 (cons elm 0)) allcomp))))) | |
5459 ;; Delete old string | |
5460 (delete-region b e) | |
5461 | |
5462 ;; Toggle-completions inserts whole labels | |
5463 (if verilog-toggle-completions | |
5464 (progn | |
5465 ;; Update entry number in list | |
5466 (setq verilog-last-completions allcomp | |
5467 verilog-last-word-numb | |
5468 (if (>= verilog-last-word-numb (1- (length allcomp))) | |
5469 0 | |
5470 (1+ verilog-last-word-numb))) | |
5471 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb)) | |
5472 ;; Display next match or same string if no match was found | |
5473 (if (not (null allcomp)) | |
5474 (insert "" verilog-last-word-shown) | |
5475 (insert "" verilog-str) | |
5476 (message "(No match)"))) | |
5477 ;; The other form of completion does not necessarily do that. | |
5478 | |
5479 ;; Insert match if found, or the original string if no match | |
5480 (if (or (null match) (equal match 't)) | |
5481 (progn (insert "" verilog-str) | |
5482 (message "(No match)")) | |
5483 (insert "" match)) | |
5484 ;; Give message about current status of completion | |
5485 (cond ((equal match 't) | |
5486 (if (not (null (cdr allcomp))) | |
5487 (message "(Complete but not unique)") | |
5488 (message "(Sole completion)"))) | |
5489 ;; Display buffer if the current completion didn't help | |
5490 ;; on completing the label. | |
5491 ((and (not (null (cdr allcomp))) (= (length verilog-str) | |
5492 (length match))) | |
5493 (with-output-to-temp-buffer "*Completions*" | |
5494 (display-completion-list allcomp)) | |
5495 ;; Wait for a key press. Then delete *Completion* window | |
5496 (momentary-string-display "" (point)) | |
5497 (delete-window (get-buffer-window (get-buffer "*Completions*"))) | |
5498 ))))) | |
5499 | |
5500 (defun verilog-show-completions () | |
5501 "Show all possible completions at current point." | |
5502 (interactive) | |
5503 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
5504 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
5505 (verilog-str (buffer-substring b e)) | |
5506 ;; The following variable is used in verilog-completion | |
5507 (verilog-buffer-to-use (current-buffer)) | |
5508 (allcomp (if (and verilog-toggle-completions | |
5509 (string= verilog-last-word-shown verilog-str)) | |
5510 verilog-last-completions | |
5511 (all-completions verilog-str 'verilog-completion)))) | |
5512 ;; Show possible completions in a temporary buffer. | |
5513 (with-output-to-temp-buffer "*Completions*" | |
5514 (display-completion-list allcomp)) | |
5515 ;; Wait for a key press. Then delete *Completion* window | |
5516 (momentary-string-display "" (point)) | |
5517 (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | |
5518 | |
5519 | |
5520 (defun verilog-get-default-symbol () | |
5521 "Return symbol around current point as a string." | |
5522 (save-excursion | |
5523 (buffer-substring (progn | |
5524 (skip-chars-backward " \t") | |
5525 (skip-chars-backward "a-zA-Z0-9_") | |
5526 (point)) | |
5527 (progn | |
5528 (skip-chars-forward "a-zA-Z0-9_") | |
5529 (point))))) | |
5530 | |
5531 (defun verilog-build-defun-re (str &optional arg) | |
5532 "Return function/task/module starting with STR as regular expression. | |
5533 With optional second ARG non-nil, STR is the complete name of the instruction." | |
5534 (if arg | |
5535 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>") | |
5536 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>"))) | |
5537 | |
5538 (defun verilog-comp-defun (verilog-str verilog-pred verilog-flag) | |
5539 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5540 Returns a completion on any function name based on VERILOG-STR prefix. If | |
5541 VERILOG-PRED is non-nil, it must be a function to be called for every match | |
5542 to check if this should really be a match. If VERILOG-FLAG is t, the | |
5543 function returns a list of all possible completions. If it is nil it | |
5544 returns a string, the longest possible completion, or t if VERILOG-STR is | |
5545 an exact match. If VERILOG-FLAG is 'lambda, the function returns t if | |
5546 VERILOG-STR is an exact match, nil otherwise." | |
5547 (save-excursion | |
5548 (let ((verilog-all nil) | |
5549 match) | |
5550 | |
5551 ;; Set buffer to use for searching labels. This should be set | |
5552 ;; within functions which use verilog-completions | |
5553 (set-buffer verilog-buffer-to-use) | |
5554 | |
5555 (let ((verilog-str verilog-str)) | |
5556 ;; Build regular expression for functions | |
5557 (if (string= verilog-str "") | |
5558 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]")) | |
5559 (setq verilog-str (verilog-build-defun-re verilog-str))) | |
5560 (goto-char (point-min)) | |
5561 | |
5562 ;; Build a list of all possible completions | |
5563 (while (verilog-re-search-forward verilog-str nil t) | |
5564 (setq match (buffer-substring (match-beginning 2) (match-end 2))) | |
5565 (if (or (null verilog-pred) | |
5566 (funcall verilog-pred match)) | |
5567 (setq verilog-all (cons match verilog-all))))) | |
5568 | |
5569 ;; Now we have built a list of all matches. Give response to caller | |
5570 (verilog-completion-response)))) | |
5571 | |
5572 (defun verilog-goto-defun () | |
5573 "Move to specified Verilog module/task/function. | |
5574 The default is a name found in the buffer around point. | |
5575 If search fails, other files are checked based on | |
5576 `verilog-library-flags'." | |
5577 (interactive) | |
5578 (let* ((default (verilog-get-default-symbol)) | |
5579 ;; The following variable is used in verilog-comp-function | |
5580 (verilog-buffer-to-use (current-buffer)) | |
5581 (label (if (not (string= default "")) | |
5582 ;; Do completion with default | |
5583 (completing-read (concat "Label: (default " default ") ") | |
5584 'verilog-comp-defun nil nil "") | |
5585 ;; There is no default value. Complete without it | |
5586 (completing-read "Label: " | |
5587 'verilog-comp-defun nil nil ""))) | |
5588 pt) | |
5589 ;; If there was no response on prompt, use default value | |
5590 (if (string= label "") | |
5591 (setq label default)) | |
5592 ;; Goto right place in buffer if label is not an empty string | |
5593 (or (string= label "") | |
5594 (progn | |
5595 (save-excursion | |
5596 (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
|
5597 (setq pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5598 (re-search-forward (verilog-build-defun-re label t) nil t))) |
79545 | 5599 (when pt |
5600 (goto-char pt) | |
5601 (beginning-of-line)) | |
5602 pt) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5603 (verilog-goto-defun-file label)))) |
79545 | 5604 |
5605 ;; Eliminate compile warning | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
5606 (defvar occur-pos-list) |
79545 | 5607 |
5608 (defun verilog-showscopes () | |
5609 "List all scopes in this module." | |
5610 (interactive) | |
5611 (let ((buffer (current-buffer)) | |
5612 (linenum 1) | |
5613 (nlines 0) | |
5614 (first 1) | |
5615 (prevpos (point-min)) | |
5616 (final-context-start (make-marker)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5617 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
79545 | 5618 (with-output-to-temp-buffer "*Occur*" |
5619 (save-excursion | |
5620 (message (format "Searching for %s ..." regexp)) | |
5621 ;; Find next match, but give up if prev match was at end of buffer. | |
5622 (while (and (not (= prevpos (point-max))) | |
5623 (verilog-re-search-forward regexp nil t)) | |
5624 (goto-char (match-beginning 0)) | |
5625 (beginning-of-line) | |
5626 (save-match-data | |
5627 (setq linenum (+ linenum (count-lines prevpos (point))))) | |
5628 (setq prevpos (point)) | |
5629 (goto-char (match-end 0)) | |
5630 (let* ((start (save-excursion | |
5631 (goto-char (match-beginning 0)) | |
5632 (forward-line (if (< nlines 0) nlines (- nlines))) | |
5633 (point))) | |
5634 (end (save-excursion | |
5635 (goto-char (match-end 0)) | |
5636 (if (> nlines 0) | |
5637 (forward-line (1+ nlines)) | |
5638 (forward-line 1)) | |
5639 (point))) | |
5640 (tag (format "%3d" linenum)) | |
5641 (empty (make-string (length tag) ?\ )) | |
5642 tem) | |
5643 (save-excursion | |
5644 (setq tem (make-marker)) | |
5645 (set-marker tem (point)) | |
5646 (set-buffer standard-output) | |
5647 (setq occur-pos-list (cons tem occur-pos-list)) | |
5648 (or first (zerop nlines) | |
5649 (insert "--------\n")) | |
5650 (setq first nil) | |
5651 (insert-buffer-substring buffer start end) | |
5652 (backward-char (- end start)) | |
5653 (setq tem (if (< nlines 0) (- nlines) nlines)) | |
5654 (while (> tem 0) | |
5655 (insert empty ?:) | |
5656 (forward-line 1) | |
5657 (setq tem (1- tem))) | |
5658 (let ((this-linenum linenum)) | |
5659 (set-marker final-context-start | |
5660 (+ (point) (- (match-end 0) (match-beginning 0)))) | |
5661 (while (< (point) final-context-start) | |
5662 (if (null tag) | |
5663 (setq tag (format "%3d" this-linenum))) | |
5664 (insert tag ?:))))))) | |
5665 (set-buffer-modified-p nil)))) | |
5666 | |
5667 | |
5668 ;; Highlight helper functions | |
5669 (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") | |
5670 (defun verilog-within-translate-off () | |
5671 "Return point if within translate-off region, else nil." | |
5672 (and (save-excursion | |
5673 (re-search-backward | |
5674 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>") | |
5675 nil t)) | |
5676 (equal "off" (match-string 2)) | |
5677 (point))) | |
5678 | |
5679 (defun verilog-start-translate-off (limit) | |
5680 "Return point before translate-off directive if before LIMIT, else nil." | |
5681 (when (re-search-forward | |
5682 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5683 limit t) | |
5684 (match-beginning 0))) | |
5685 | |
5686 (defun verilog-back-to-start-translate-off (limit) | |
5687 "Return point before translate-off directive if before LIMIT, else nil." | |
5688 (when (re-search-backward | |
5689 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
5690 limit t) | |
5691 (match-beginning 0))) | |
5692 | |
5693 (defun verilog-end-translate-off (limit) | |
5694 "Return point after translate-on directive if before LIMIT, else nil." | |
5695 | |
5696 (re-search-forward (concat | |
5697 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t)) | |
5698 | |
5699 (defun verilog-match-translate-off (limit) | |
5700 "Match a translate-off block, setting `match-data' and returning t, else nil. | |
5701 Bound search by LIMIT." | |
5702 (when (< (point) limit) | |
5703 (let ((start (or (verilog-within-translate-off) | |
5704 (verilog-start-translate-off limit))) | |
5705 (case-fold-search t)) | |
5706 (when start | |
5707 (let ((end (or (verilog-end-translate-off limit) limit))) | |
5708 (set-match-data (list start end)) | |
5709 (goto-char end)))))) | |
5710 | |
5711 (defun verilog-font-lock-match-item (limit) | |
5712 "Match, and move over, any declaration item after point. | |
5713 Bound search by LIMIT. Adapted from | |
5714 `font-lock-match-c-style-declaration-item-and-skip-to-next'." | |
5715 (condition-case nil | |
5716 (save-restriction | |
5717 (narrow-to-region (point-min) limit) | |
5718 ;; match item | |
5719 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)") | |
5720 (save-match-data | |
5721 (goto-char (match-end 1)) | |
5722 ;; move to next item | |
5723 (if (looking-at "\\(\\s-*,\\)") | |
5724 (goto-char (match-end 1)) | |
5725 (end-of-line) t)))) | |
5726 (error nil))) | |
5727 | |
5728 | |
5729 ;; Added by Subbu Meiyappan for Header | |
5730 | |
5731 (defun verilog-header () | |
5732 "Insert a standard Verilog file header." | |
5733 (interactive) | |
5734 (let ((start (point))) | |
5735 (insert "\ | |
5736 //----------------------------------------------------------------------------- | |
5737 // Title : <title> | |
5738 // Project : <project> | |
5739 //----------------------------------------------------------------------------- | |
5740 // File : <filename> | |
5741 // Author : <author> | |
5742 // Created : <credate> | |
5743 // Last modified : <moddate> | |
5744 //----------------------------------------------------------------------------- | |
5745 // Description : | |
5746 // <description> | |
5747 //----------------------------------------------------------------------------- | |
5748 // Copyright (c) <copydate> by <company> This model is the confidential and | |
5749 // proprietary property of <company> and the possession or use of this | |
5750 // file requires a written license from <company>. | |
5751 //------------------------------------------------------------------------------ | |
5752 // Modification history : | |
5753 // <modhist> | |
5754 //----------------------------------------------------------------------------- | |
5755 | |
5756 ") | |
5757 (goto-char start) | |
5758 (search-forward "<filename>") | |
5759 (replace-match (buffer-name) t t) | |
5760 (search-forward "<author>") (replace-match "" t t) | |
5761 (insert (user-full-name)) | |
5762 (insert " <" (user-login-name) "@" (system-name) ">") | |
5763 (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
|
5764 (verilog-insert-date) |
79545 | 5765 (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
|
5766 (verilog-insert-date) |
79545 | 5767 (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
|
5768 (verilog-insert-year) |
79545 | 5769 (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
|
5770 (verilog-insert-date) |
79545 | 5771 (insert " : created") |
5772 (goto-char start) | |
5773 (let (string) | |
5774 (setq string (read-string "title: ")) | |
5775 (search-forward "<title>") | |
5776 (replace-match string t t) | |
5777 (setq string (read-string "project: " verilog-project)) | |
5778 (setq verilog-project string) | |
5779 (search-forward "<project>") | |
5780 (replace-match string t t) | |
5781 (setq string (read-string "Company: " verilog-company)) | |
5782 (setq verilog-company string) | |
5783 (search-forward "<company>") | |
5784 (replace-match string t t) | |
5785 (search-forward "<company>") | |
5786 (replace-match string t t) | |
5787 (search-forward "<company>") | |
5788 (replace-match string t t) | |
5789 (search-backward "<description>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5790 (replace-match "" t t)))) |
79545 | 5791 |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5792 ;; 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
|
5793 |
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5794 (defun verilog-insert-date () |
79545 | 5795 "Insert date from the system." |
5796 (interactive) | |
5797 (let ((timpos)) | |
5798 (setq timpos (point)) | |
5799 (if verilog-date-scientific-format | |
5800 (shell-command "date \"+@%Y/%m/%d\"" t) | |
5801 (shell-command "date \"+@%d.%m.%Y\"" t)) | |
5802 (search-forward "@") | |
5803 (delete-region timpos (point)) | |
5804 (end-of-line)) | |
5805 (delete-char 1)) | |
5806 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
5807 (defun verilog-insert-year () |
79545 | 5808 "Insert year from the system." |
5809 (interactive) | |
5810 (let ((timpos)) | |
5811 (setq timpos (point)) | |
5812 (shell-command "date \"+@%Y\"" t) | |
5813 (search-forward "@") | |
5814 (delete-region timpos (point)) | |
5815 (end-of-line)) | |
5816 (delete-char 1)) | |
5817 | |
5818 | |
5819 ;; | |
5820 ;; Signal list parsing | |
5821 ;; | |
5822 | |
5823 ;; Elements of a signal list | |
5824 (defsubst verilog-sig-name (sig) | |
5825 (car sig)) | |
5826 (defsubst verilog-sig-bits (sig) | |
5827 (nth 1 sig)) | |
5828 (defsubst verilog-sig-comment (sig) | |
5829 (nth 2 sig)) | |
5830 (defsubst verilog-sig-memory (sig) | |
5831 (nth 3 sig)) | |
5832 (defsubst verilog-sig-enum (sig) | |
5833 (nth 4 sig)) | |
5834 (defsubst verilog-sig-signed (sig) | |
5835 (nth 5 sig)) | |
5836 (defsubst verilog-sig-type (sig) | |
5837 (nth 6 sig)) | |
5838 (defsubst verilog-sig-multidim (sig) | |
5839 (nth 7 sig)) | |
5840 (defsubst verilog-sig-multidim-string (sig) | |
5841 (if (verilog-sig-multidim sig) | |
5842 (let ((str "") (args (verilog-sig-multidim sig))) | |
5843 (while args | |
5844 (setq str (concat str (car args))) | |
5845 (setq args (cdr args))) | |
5846 str))) | |
5847 (defsubst verilog-sig-width (sig) | |
5848 (verilog-make-width-expression (verilog-sig-bits sig))) | |
5849 | |
5850 (defsubst verilog-alw-get-inputs (sigs) | |
5851 (nth 2 sigs)) | |
5852 (defsubst verilog-alw-get-outputs (sigs) | |
5853 (nth 0 sigs)) | |
5854 (defsubst verilog-alw-get-uses-delayed (sigs) | |
5855 (nth 3 sigs)) | |
5856 | |
5857 (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
|
5858 "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
|
5859 Also remove any duplicates in IN-LIST. |
79545 | 5860 Signals must be in standard (base vector) form." |
5861 (let (out-list) | |
5862 (while in-list | |
5863 (if (not (or (assoc (car (car in-list)) not-list) | |
5864 (assoc (car (car in-list)) out-list))) | |
5865 (setq out-list (cons (car in-list) out-list))) | |
5866 (setq in-list (cdr in-list))) | |
5867 (nreverse out-list))) | |
5868 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5869 | |
5870 (defun verilog-signals-in (in-list other-list) | |
5871 "Return list of signals in IN-LIST that are also in OTHER-LIST. | |
5872 Signals must be in standard (base vector) form." | |
5873 (let (out-list) | |
5874 (while in-list | |
5875 (if (assoc (car (car in-list)) other-list) | |
5876 (setq out-list (cons (car in-list) out-list))) | |
5877 (setq in-list (cdr in-list))) | |
5878 (nreverse out-list))) | |
5879 ;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
5880 | |
5881 (defun verilog-signals-memory (in-list) | |
5882 "Return list of signals in IN-LIST that are memoried (multidimensional)." | |
5883 (let (out-list) | |
5884 (while in-list | |
5885 (if (nth 3 (car in-list)) | |
5886 (setq out-list (cons (car in-list) out-list))) | |
5887 (setq in-list (cdr in-list))) | |
5888 out-list)) | |
5889 ;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil))) | |
5890 | |
5891 (defun verilog-signals-sort-compare (a b) | |
5892 "Compare signal A and B for sorting." | |
5893 (string< (car a) (car b))) | |
5894 | |
5895 (defun verilog-signals-not-params (in-list) | |
5896 "Return list of signals in IN-LIST that aren't parameters or numeric constants." | |
5897 (let (out-list) | |
5898 (while in-list | |
5899 (unless (boundp (intern (concat "vh-" (car (car in-list))))) | |
5900 (setq out-list (cons (car in-list) out-list))) | |
5901 (setq in-list (cdr in-list))) | |
5902 (nreverse out-list))) | |
5903 | |
5904 (defun verilog-signals-combine-bus (in-list) | |
5905 "Return a list of signals in IN-LIST, with busses combined. | |
5906 Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | |
5907 (let (combo buswarn | |
5908 out-list | |
5909 sig highbit lowbit ; Temp information about current signal | |
5910 sv-name sv-highbit sv-lowbit ; Details about signal we are forming | |
5911 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring | |
5912 bus) | |
5913 ;; Shove signals so duplicated signals will be adjacent | |
5914 (setq in-list (sort in-list `verilog-signals-sort-compare)) | |
5915 (while in-list | |
5916 (setq sig (car in-list)) | |
5917 ;; No current signal; form from existing details | |
5918 (unless sv-name | |
5919 (setq sv-name (verilog-sig-name sig) | |
5920 sv-highbit nil | |
5921 sv-busstring nil | |
5922 sv-comment (verilog-sig-comment sig) | |
5923 sv-memory (verilog-sig-memory sig) | |
5924 sv-enum (verilog-sig-enum sig) | |
5925 sv-signed (verilog-sig-signed sig) | |
5926 sv-type (verilog-sig-type sig) | |
5927 sv-multidim (verilog-sig-multidim sig) | |
5928 combo "" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5929 buswarn "")) |
79545 | 5930 ;; Extract bus details |
5931 (setq bus (verilog-sig-bits sig)) | |
5932 (cond ((and bus | |
5933 (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
|
5934 (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
|
5935 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
|
5936 (match-string 2 bus)))) |
79545 | 5937 (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
|
5938 (setq highbit (string-to-number (match-string 1 bus)) |
79545 | 5939 lowbit highbit)))) |
5940 ;; Combine bits in bus | |
5941 (if sv-highbit | |
5942 (setq sv-highbit (max highbit sv-highbit) | |
5943 sv-lowbit (min lowbit sv-lowbit)) | |
5944 (setq sv-highbit highbit | |
5945 sv-lowbit lowbit))) | |
5946 (bus | |
5947 ;; String, probably something like `preproc:0 | |
5948 (setq sv-busstring bus))) | |
5949 ;; Peek ahead to next signal | |
5950 (setq in-list (cdr in-list)) | |
5951 (setq sig (car in-list)) | |
5952 (cond ((and sig (equal sv-name (verilog-sig-name sig))) | |
5953 ;; 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
|
5954 (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
|
5955 (not (equal sv-busstring (verilog-sig-bits sig)))) |
79545 | 5956 (when nil ;; Debugging |
5957 (message (concat "Warning, can't merge into single bus " | |
5958 sv-name bus | |
5959 ", the AUTOs may be wrong"))) | |
5960 (setq buswarn ", Couldn't Merge")) | |
5961 (if (verilog-sig-comment sig) (setq combo ", ...")) | |
5962 (setq sv-memory (or sv-memory (verilog-sig-memory sig)) | |
5963 sv-enum (or sv-enum (verilog-sig-enum sig)) | |
5964 sv-signed (or sv-signed (verilog-sig-signed sig)) | |
5965 sv-type (or sv-type (verilog-sig-type sig)) | |
5966 sv-multidim (or sv-multidim (verilog-sig-multidim sig)))) | |
5967 ;; Doesn't match next signal, add to queue, zero in prep for next | |
5968 ;; Note sig may also be nil for the last signal in the list | |
5969 (t | |
5970 (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
|
5971 (cons |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5972 (list sv-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5973 (or sv-busstring |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5974 (if sv-highbit |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5975 (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
|
5976 (int-to-string sv-lowbit) "]"))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5977 (concat sv-comment combo buswarn) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5978 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
|
5979 out-list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5980 sv-name nil)))) |
79545 | 5981 ;; |
5982 out-list)) | |
5983 | |
5984 (defun verilog-sig-tieoff (sig &optional no-width) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5985 "Return tieoff expression for given SIG, with appropriate width. |
79545 | 5986 Ignore width if optional NO-WIDTH is set." |
5987 (let* ((width (if no-width nil (verilog-sig-width sig)))) | |
5988 (concat | |
5989 (if (and verilog-active-low-regexp | |
5990 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | |
5991 "~" "") | |
5992 (cond ((not width) | |
5993 "0") | |
5994 ((string-match "^[0-9]+$" width) | |
5995 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0"))) | |
5996 (t | |
5997 (concat "{" width "{1'b0}}")))))) | |
5998 | |
5999 ;; | |
6000 ;; Port/Wire/Etc Reading | |
6001 ;; | |
6002 | |
6003 (defun verilog-read-inst-backward-name () | |
6004 "Internal. Move point back to beginning of inst-name." | |
6005 (verilog-backward-open-paren) | |
6006 (let (done) | |
6007 (while (not done) | |
6008 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary | |
6009 (cond ((looking-at ")") | |
6010 (verilog-backward-open-paren)) | |
6011 (t (setq done t))))) | |
6012 (while (looking-at "\\]") | |
6013 (verilog-backward-open-bracket) | |
6014 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) | |
6015 (skip-chars-backward "a-zA-Z0-9`_$")) | |
6016 | |
6017 (defun verilog-read-inst-module () | |
6018 "Return module_name when point is inside instantiation." | |
6019 (save-excursion | |
6020 (verilog-read-inst-backward-name) | |
6021 ;; Skip over instantiation name | |
6022 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary | |
6023 ;; Check for parameterized instantiations | |
6024 (when (looking-at ")") | |
6025 (verilog-backward-open-paren) | |
6026 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)) | |
6027 (skip-chars-backward "a-zA-Z0-9'_$") | |
6028 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6029 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
79545 | 6030 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) |
6031 | |
6032 (defun verilog-read-inst-name () | |
6033 "Return instance_name when point is inside instantiation." | |
6034 (save-excursion | |
6035 (verilog-read-inst-backward-name) | |
6036 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6037 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
79545 | 6038 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) |
6039 | |
6040 (defun verilog-read-module-name () | |
6041 "Return module name when after its ( or ;." | |
6042 (save-excursion | |
6043 (re-search-backward "[(;]") | |
6044 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) | |
6045 (skip-chars-backward "a-zA-Z0-9`_$") | |
6046 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6047 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
79545 | 6048 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) |
6049 | |
6050 (defun verilog-read-auto-params (num-param &optional max-param) | |
6051 "Return parameter list inside auto. | |
6052 Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters." | |
6053 (let ((olist)) | |
6054 (save-excursion | |
6055 ;; /*AUTOPUNT("parameter", "parameter")*/ | |
6056 (search-backward "(") | |
6057 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?") | |
6058 (setq olist (cons (match-string 1) olist)) | |
6059 (goto-char (match-end 0)))) | |
6060 (or (eq nil num-param) | |
6061 (<= num-param (length olist)) | |
6062 (error "%s: Expected %d parameters" (verilog-point-text) num-param)) | |
6063 (if (eq max-param nil) (setq max-param num-param)) | |
6064 (or (eq nil max-param) | |
6065 (>= max-param (length olist)) | |
6066 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param)) | |
6067 (nreverse olist))) | |
6068 | |
6069 (defun verilog-read-decls () | |
6070 "Compute signal declaration information for the current module at point. | |
6071 Return a array of [outputs inouts inputs wire reg assign const]." | |
6072 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) | |
6073 (functask 0) (paren 0) (sig-paren 0) | |
6074 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const sigs-gparam | |
6075 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim) | |
6076 (save-excursion | |
6077 (verilog-beg-of-defun) | |
6078 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) | |
6079 (while (< (point) end-mod-point) | |
6080 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg))) | |
6081 (cond | |
6082 ((looking-at "//") | |
6083 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6084 (setq enum (match-string 1))) | |
6085 (search-forward "\n")) | |
6086 ((looking-at "/\\*") | |
6087 (forward-char 2) | |
6088 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6089 (setq enum (match-string 1))) | |
6090 (or (search-forward "*/") | |
6091 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6092 ((looking-at "(\\*") | |
6093 (forward-char 2) | |
6094 (or (looking-at "\\s-*)") ; It's a "always @ (*)" | |
6095 (search-forward "*)") | |
6096 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6097 ((eq ?\" (following-char)) | |
6098 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first | |
6099 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6100 ((eq ?\; (following-char)) | |
6101 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil) | |
6102 (forward-char 1)) | |
6103 ((eq ?= (following-char)) | |
6104 (setq rvalue t newsig nil) | |
6105 (forward-char 1)) | |
6106 ((and (or rvalue sig-paren) | |
6107 (cond ((and (eq ?, (following-char)) | |
6108 (eq paren sig-paren)) | |
6109 (setq rvalue nil) | |
6110 (forward-char 1) | |
6111 t) | |
6112 ;; ,'s can occur inside {} & funcs | |
6113 ((looking-at "[{(]") | |
6114 (setq paren (1+ paren)) | |
6115 (forward-char 1) | |
6116 t) | |
6117 ((looking-at "[})]") | |
6118 (setq paren (1- paren)) | |
6119 (forward-char 1) | |
6120 (when (< paren sig-paren) | |
6121 (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
|
6122 t)))) |
79545 | 6123 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
6124 (goto-char (match-end 0)) | |
6125 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | |
6126 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | |
6127 (vec ;; Multidimensional | |
6128 (setq multidim (cons vec multidim)) | |
6129 (setq vec (verilog-string-replace-matches | |
6130 "\\s-+" "" nil nil (match-string 1)))) | |
6131 (t ;; Bit width | |
6132 (setq vec (verilog-string-replace-matches | |
6133 "\\s-+" "" nil nil (match-string 1)))))) | |
6134 ;; Normal or escaped identifier -- note we remember the \ if escaped | |
6135 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | |
6136 (goto-char (match-end 0)) | |
6137 (setq keywd (match-string 1)) | |
6138 (when (string-match "^\\\\" keywd) | |
6139 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end | |
6140 (cond ((equal keywd "input") | |
6141 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6142 expect-signal 'sigs-in io t)) | |
6143 ((equal keywd "output") | |
6144 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6145 expect-signal 'sigs-out io t)) | |
6146 ((equal keywd "inout") | |
6147 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
6148 expect-signal 'sigs-inout io t)) | |
6149 ((or (equal keywd "wire") | |
6150 (equal keywd "tri") | |
6151 (equal keywd "tri0") | |
6152 (equal keywd "tri1")) | |
6153 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6154 expect-signal 'sigs-wire))) | |
6155 ((or (equal keywd "reg") | |
6156 (equal keywd "trireg")) | |
6157 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6158 expect-signal 'sigs-reg))) | |
6159 ((equal keywd "assign") | |
6160 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6161 expect-signal 'sigs-assign)) | |
6162 ((or (equal keywd "supply0") | |
6163 (equal keywd "supply1") | |
6164 (equal keywd "supply") | |
93096
ea3c318451b4
(verilog-read-decls): Fix AUTOINPUT/AUTOOUTPUT mis-including
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93095
diff
changeset
|
6165 (equal keywd "localparam") |
ea3c318451b4
(verilog-read-decls): Fix AUTOINPUT/AUTOOUTPUT mis-including
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93095
diff
changeset
|
6166 (equal keywd "genvar")) |
79545 | 6167 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren |
6168 expect-signal 'sigs-const))) | |
6169 ((or (equal keywd "parameter")) | |
6170 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
6171 expect-signal 'sigs-gparam))) | |
6172 ((equal keywd "signed") | |
6173 (setq signed "signed")) | |
6174 ((or (equal keywd "function") | |
6175 (equal keywd "task")) | |
6176 (setq functask (1+ functask))) | |
6177 ((or (equal keywd "endfunction") | |
6178 (equal keywd "endtask")) | |
6179 (setq functask (1- functask))) | |
6180 ((or (equal keywd "`ifdef") | |
6181 (equal keywd "`ifndef")) | |
6182 (setq rvalue t)) | |
6183 ((verilog-typedef-name-p keywd) | |
6184 (setq typedefed keywd)) | |
6185 ((and expect-signal | |
6186 (eq functask 0) | |
6187 (not rvalue) | |
6188 (eq paren sig-paren) | |
6189 (not (member keywd verilog-keywords))) | |
6190 ;; Add new signal to expect-signal's variable | |
6191 (setq newsig (list keywd vec nil nil enum signed typedefed multidim)) | |
6192 (set expect-signal (cons newsig | |
6193 (symbol-value expect-signal)))))) | |
6194 (t | |
6195 (forward-char 1))) | |
6196 (skip-syntax-forward " ")) | |
6197 ;; Return arguments | |
6198 (vector (nreverse sigs-out) | |
6199 (nreverse sigs-inout) | |
6200 (nreverse sigs-in) | |
6201 (nreverse sigs-wire) | |
6202 (nreverse sigs-reg) | |
6203 (nreverse sigs-assign) | |
6204 (nreverse sigs-const) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6205 (nreverse sigs-gparam))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6206 |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6207 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6208 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6209 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6210 ;; - 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
|
6211 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6212 (defvar sigs-inout) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6213 (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
|
6214 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6215 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6216 (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
|
6217 (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
|
6218 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6219 (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
|
6220 (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
|
6221 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6222 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6223 ;; 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
|
6224 ;; 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
|
6225 ;; verilog-modi-current function. |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6226 (defsubst verilog-decls-get-outputs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6227 (aref decls 0)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6228 (defsubst verilog-decls-get-inouts (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6229 (aref decls 1)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6230 (defsubst verilog-decls-get-inputs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6231 (aref decls 2)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6232 (defsubst verilog-decls-get-wires (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6233 (aref decls 3)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6234 (defsubst verilog-decls-get-regs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6235 (aref decls 4)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6236 (defsubst verilog-decls-get-assigns (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6237 (aref decls 5)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6238 (defsubst verilog-decls-get-consts (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6239 (aref decls 6)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6240 (defsubst verilog-decls-get-gparams (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6241 (aref decls 7)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6242 (defsubst verilog-subdecls-get-outputs (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6243 (aref subdecls 0)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6244 (defsubst verilog-subdecls-get-inouts (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6245 (aref subdecls 1)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6246 (defsubst verilog-subdecls-get-inputs (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6247 (aref subdecls 2)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6248 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6249 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6250 (defun verilog-read-sub-decls-sig (submoddecls comment port sig vec multidim) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6251 "For `verilog-read-sub-decls-line', add a signal." |
79545 | 6252 (let (portdata) |
6253 (when sig | |
6254 (setq port (verilog-symbol-detick-denumber port)) | |
6255 (setq sig (verilog-symbol-detick-denumber sig)) | |
6256 (if sig (setq sig (verilog-string-replace-matches "^[---+~!|&]+" "" nil nil sig))) | |
6257 (if vec (setq vec (verilog-symbol-detick-denumber vec))) | |
6258 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) | |
6259 (unless (or (not sig) | |
6260 (equal sig "")) ;; Ignore .foo(1'b1) assignments | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6261 (cond ((setq portdata (assoc port (verilog-decls-get-inouts submoddecls))) |
79545 | 6262 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil |
6263 (verilog-sig-signed portdata) | |
6264 (verilog-sig-type portdata) | |
6265 multidim) | |
6266 sigs-inout))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6267 ((setq portdata (assoc port (verilog-decls-get-outputs submoddecls))) |
79545 | 6268 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil |
6269 (verilog-sig-signed portdata) | |
6270 (verilog-sig-type portdata) | |
6271 multidim) | |
6272 sigs-out))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6273 ((setq portdata (assoc port (verilog-decls-get-inputs submoddecls))) |
79545 | 6274 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil |
6275 (verilog-sig-signed portdata) | |
6276 (verilog-sig-type portdata) | |
6277 multidim) | |
6278 sigs-in))) | |
6279 ;; (t -- warning pin isn't defined.) ; Leave for lint tool | |
6280 ))))) | |
6281 | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6282 (defun verilog-read-sub-decls-line (submoddecls comment) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6283 "For `verilog-read-sub-decls', read lines of port defs until none match anymore. |
79545 | 6284 Return the list of signals found, using submodi to look up each port." |
6285 (let (done port sig vec multidim) | |
6286 (save-excursion | |
6287 (forward-line 1) | |
6288 (while (not done) | |
6289 ;; Get port name | |
6290 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*") | |
6291 (setq port (match-string 1)) | |
6292 (goto-char (match-end 0))) | |
6293 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") | |
6294 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space | |
6295 (goto-char (match-end 0))) | |
6296 ((looking-at "\\s-*\\.[^(]*(") | |
6297 (setq port nil) ;; skip this line | |
6298 (goto-char (match-end 0))) | |
6299 (t | |
6300 (setq port nil done t))) ;; Unknown, ignore rest of line | |
6301 ;; Get signal name | |
6302 (when port | |
6303 (setq multidim nil) | |
6304 (cond ((looking-at "\\(\\\\[^ \t\n\f]*\\)\\s-*)") | |
6305 (setq sig (concat (match-string 1) " ") ;; escaped id's need trailing space | |
6306 vec nil)) | |
6307 ; We intentionally ignore (non-escaped) signals with .s in them | |
6308 ; this prevents AUTOWIRE etc from noticing hierarchical sigs. | |
6309 ((looking-at "\\([^[({).]*\\)\\s-*)") | |
6310 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6311 vec nil)) | |
6312 ((looking-at "\\([^[({).]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)") | |
6313 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6314 vec (match-string 2))) | |
6315 ((looking-at "\\([^[({).]*\\)\\s-*/\\*\\(\\[[^*]+\\]\\)\\*/\\s-*)") | |
6316 (setq sig (verilog-string-remove-spaces (match-string 1)) | |
6317 vec nil) | |
6318 (let ((parse (match-string 2))) | |
6319 (while (string-match "^\\(\\[[^]]+\\]\\)\\(.*\\)$" parse) | |
6320 (when vec (setq multidim (cons vec multidim))) | |
6321 (setq vec (match-string 1 parse)) | |
6322 (setq parse (match-string 2 parse))))) | |
6323 ((looking-at "{\\(.*\\)}.*\\s-*)") | |
6324 (let ((mlst (split-string (match-string 1) ",")) | |
6325 mstr) | |
6326 (while (setq mstr (pop mlst)) | |
6327 ;;(unless noninteractive (message "sig: %s " mstr)) | |
6328 (cond | |
6329 ((string-match "\\(['`a-zA-Z0-9_$]+\\)\\s-*$" mstr) | |
6330 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6331 vec nil) | |
6332 ;;(unless noninteractive (message "concat sig1: %s %s" mstr (match-string 1 mstr))) | |
6333 ) | |
6334 ((string-match "\\([^[({).]+\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*" mstr) | |
6335 (setq sig (verilog-string-remove-spaces (match-string 1 mstr)) | |
6336 vec (match-string 2 mstr)) | |
6337 ;;(unless noninteractive (message "concat sig2: '%s' '%s' '%s'" mstr (match-string 1 mstr) (match-string 2 mstr))) | |
6338 ) | |
6339 (t | |
6340 (setq sig nil))) | |
6341 ;; Process signals | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6342 (verilog-read-sub-decls-sig submoddecls comment port sig vec multidim)))) |
79545 | 6343 (t |
6344 (setq sig nil))) | |
6345 ;; Process signals | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6346 (verilog-read-sub-decls-sig submoddecls comment port sig vec multidim)) |
79545 | 6347 ;; |
6348 (forward-line 1))))) | |
6349 | |
6350 (defun verilog-read-sub-decls () | |
6351 "Internally parse signals going to modules under this module. | |
6352 Return a array of [ outputs inouts inputs ] signals for modules that are | |
6353 instantiated in this module. For example if declare A A (.B(SIG)) and SIG | |
6354 is a output, then SIG will be included in the list. | |
6355 | |
6356 This only works on instantiations created with /*AUTOINST*/ converted by | |
6357 \\[verilog-auto-inst]. Otherwise, it would have to read in the whole | |
6358 component library to determine connectivity of the design. | |
6359 | |
6360 One work around for this problem is to manually create // Inputs and // | |
6361 Outputs comments above subcell signals, for example: | |
6362 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
6363 module ModuleName ( |
79545 | 6364 // Outputs |
6365 .out (out), | |
6366 // Inputs | |
6367 .in (in));" | |
6368 (save-excursion | |
6369 (let ((end-mod-point (verilog-get-end-of-defun t)) | |
6370 st-point end-inst-point | |
6371 ;; below 3 modified by verilog-read-sub-decls-line | |
6372 sigs-out sigs-inout sigs-in) | |
6373 (verilog-beg-of-defun) | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
6374 (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t) |
79545 | 6375 (save-excursion |
6376 (goto-char (match-beginning 0)) | |
6377 (unless (verilog-inside-comment-p) | |
6378 ;; Attempt to snarf a comment | |
6379 (let* ((submod (verilog-read-inst-module)) | |
6380 (inst (verilog-read-inst-name)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6381 (comment (concat inst " of " submod ".v")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6382 submodi submoddecls) |
79545 | 6383 (when (setq submodi (verilog-modi-lookup submod t)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6384 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 6385 ;; This could have used a list created by verilog-auto-inst |
6386 ;; However I want it to be runnable even on user's manually added signals | |
6387 (verilog-backward-open-paren) | |
6388 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) | |
6389 st-point (point)) | |
6390 (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6391 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out |
79545 | 6392 (goto-char st-point) |
6393 (while (re-search-forward "\\s *// Inouts" end-inst-point t) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6394 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-inout |
79545 | 6395 (goto-char st-point) |
6396 (while (re-search-forward "\\s *// Inputs" end-inst-point t) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6397 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-in |
79545 | 6398 ))))) |
6399 ;; Combine duplicate bits | |
6400 ;;(setq rr (vector sigs-out sigs-inout sigs-in)) | |
6401 (vector (verilog-signals-combine-bus (nreverse sigs-out)) | |
6402 (verilog-signals-combine-bus (nreverse sigs-inout)) | |
6403 (verilog-signals-combine-bus (nreverse sigs-in)))))) | |
6404 | |
6405 (defun verilog-read-inst-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6406 "Return an array of [ pins ] for the current instantiation at point. |
79545 | 6407 For example if declare A A (.B(SIG)) then B will be included in the list." |
6408 (save-excursion | |
6409 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point | |
6410 pins pin) | |
6411 (verilog-backward-open-paren) | |
6412 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) | |
6413 (setq pin (match-string 1)) | |
6414 (unless (verilog-inside-comment-p) | |
6415 (setq pins (cons (list pin) pins)) | |
6416 (when (looking-at "(") | |
6417 (forward-sexp 1)))) | |
6418 (vector pins)))) | |
6419 | |
6420 (defun verilog-read-arg-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6421 "Return an array of [ pins ] for the current argument declaration at point." |
79545 | 6422 (save-excursion |
6423 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point | |
6424 pins pin) | |
6425 (verilog-backward-open-paren) | |
6426 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) | |
6427 (setq pin (match-string 1)) | |
6428 (unless (verilog-inside-comment-p) | |
6429 (setq pins (cons (list pin) pins)))) | |
6430 (vector pins)))) | |
6431 | |
6432 (defun verilog-read-auto-constants (beg end-mod-point) | |
6433 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT." | |
6434 ;; Insert new | |
6435 (save-excursion | |
6436 (let (sig-list tpl-end-pt) | |
6437 (goto-char beg) | |
6438 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t) | |
6439 (if (not (looking-at "\\s *(")) | |
6440 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text))) | |
6441 (search-forward "(" end-mod-point) | |
6442 (setq tpl-end-pt (save-excursion | |
6443 (backward-char 1) | |
6444 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6445 (backward-char 1) | |
6446 (point))) | |
6447 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) | |
6448 (setq sig-list (cons (list (match-string 1) nil nil) sig-list)))) | |
6449 sig-list))) | |
6450 | |
6451 (defun verilog-read-auto-lisp (start end) | |
6452 "Look for and evaluate a AUTO_LISP between START and END." | |
6453 (save-excursion | |
6454 (goto-char start) | |
6455 (while (re-search-forward "\\<AUTO_LISP(" end t) | |
6456 (backward-char) | |
6457 (let* ((beg-pt (prog1 (point) | |
6458 (forward-sexp 1))) ;; Closing paren | |
6459 (end-pt (point))) | |
6460 (eval-region beg-pt end-pt nil))))) | |
6461 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6462 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6463 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6464 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6465 ;; - 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
|
6466 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6467 (defvar sigs-out) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6468 (defvar got-sig) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6469 (defvar got-rvalue) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6470 (defvar uses-delayed) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6471 (defvar vector-skip-list)) |
79545 | 6472 |
6473 (defun verilog-read-always-signals-recurse | |
6474 (exit-keywd rvalue ignore-next) | |
6475 "Recursive routine for parentheses/bracket matching. | |
6476 EXIT-KEYWD is expression to stop at, nil if top level. | |
6477 RVALUE is true if at right hand side of equal. | |
6478 IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |
6479 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue | |
6480 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check) | |
6481 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next)))) | |
6482 (while (not (or (eobp) gotend)) | |
6483 (cond | |
6484 ((looking-at "//") | |
6485 (search-forward "\n")) | |
6486 ((looking-at "/\\*") | |
6487 (or (search-forward "*/") | |
6488 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6489 ((looking-at "(\\*") | |
6490 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6491 (search-forward "*)") | |
6492 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6493 (t (setq keywd (buffer-substring-no-properties | |
6494 (point) | |
6495 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6496 (forward-char 1)) | |
6497 (point))) | |
6498 sig-last-tolk sig-tolk | |
6499 sig-tolk nil) | |
6500 ;;(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)))) | |
6501 (cond | |
6502 ((equal keywd "\"") | |
6503 (or (re-search-forward "[^\\]\"" nil t) | |
6504 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6505 ;; else at top level loop, keep parsing | |
6506 ((and end-else-check (equal keywd "else")) | |
6507 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd)))) | |
6508 ;; no forward movement, want to see else in lower loop | |
6509 (setq end-else-check nil)) | |
6510 ;; End at top level loop | |
6511 ((and end-else-check (looking-at "[^ \t\n\f]")) | |
6512 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd)))) | |
6513 (setq gotend t)) | |
6514 ;; Final statement? | |
6515 ((and exit-keywd (equal keywd exit-keywd)) | |
6516 (setq gotend t) | |
6517 (forward-char (length keywd))) | |
6518 ;; Standard tokens... | |
6519 ((equal keywd ";") | |
6520 (setq ignore-next nil rvalue semi-rvalue) | |
6521 ;; Final statement at top level loop? | |
6522 (when (not exit-keywd) | |
6523 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd)))) | |
6524 (setq end-else-check t)) | |
6525 (forward-char 1)) | |
6526 ((equal keywd "'") | |
6527 (if (looking-at "'s?[hdxbo][0-9a-fA-F_xz? \t]*") | |
6528 (goto-char (match-end 0)) | |
6529 (forward-char 1))) | |
6530 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z | |
6531 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next | |
6532 (setq ignore-next nil rvalue nil)) | |
6533 ((equal "?" exit-keywd) ;; x?y:z rvalue | |
6534 ) ;; NOP | |
6535 (got-sig ;; label: statement | |
6536 (setq ignore-next nil rvalue semi-rvalue got-sig nil)) | |
6537 ((not rvalue) ;; begin label | |
6538 (setq ignore-next t rvalue nil))) | |
6539 (forward-char 1)) | |
6540 ((equal keywd "=") | |
6541 (if (eq (char-before) ?< ) | |
6542 (setq uses-delayed 1)) | |
6543 (setq ignore-next nil rvalue t) | |
6544 (forward-char 1)) | |
6545 ((equal keywd "?") | |
6546 (forward-char 1) | |
6547 (verilog-read-always-signals-recurse ":" rvalue nil)) | |
6548 ((equal keywd "[") | |
6549 (forward-char 1) | |
6550 (verilog-read-always-signals-recurse "]" t nil)) | |
6551 ((equal keywd "(") | |
6552 (forward-char 1) | |
6553 (cond (sig-last-tolk ;; Function call; zap last signal | |
6554 (setq got-sig nil))) | |
6555 (cond ((equal last-keywd "for") | |
6556 (verilog-read-always-signals-recurse ";" nil nil) | |
6557 (verilog-read-always-signals-recurse ";" t nil) | |
6558 (verilog-read-always-signals-recurse ")" nil nil)) | |
6559 (t (verilog-read-always-signals-recurse ")" t nil)))) | |
6560 ((equal keywd "begin") | |
6561 (skip-syntax-forward "w_") | |
6562 (verilog-read-always-signals-recurse "end" nil nil) | |
6563 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd)))) | |
6564 (setq ignore-next nil rvalue semi-rvalue) | |
6565 (if (not exit-keywd) (setq end-else-check t))) | |
6566 ((or (equal keywd "case") | |
6567 (equal keywd "casex") | |
6568 (equal keywd "casez")) | |
6569 (skip-syntax-forward "w_") | |
6570 (verilog-read-always-signals-recurse "endcase" t nil) | |
6571 (setq ignore-next nil rvalue semi-rvalue) | |
6572 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end | |
6573 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent | |
6574 (cond ((or (equal keywd "`ifdef") | |
6575 (equal keywd "`ifndef")) | |
6576 (setq ignore-next t)) | |
6577 ((or ignore-next | |
6578 (member keywd verilog-keywords) | |
6579 (string-match "^\\$" keywd)) ;; PLI task | |
6580 (setq ignore-next nil)) | |
6581 (t | |
6582 (setq keywd (verilog-symbol-detick-denumber keywd)) | |
6583 (when got-sig | |
6584 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6585 (setq sigs-out (cons got-sig sigs-out))) | |
6586 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6587 ) | |
6588 (setq got-rvalue rvalue | |
6589 got-sig (if (or (not keywd) | |
6590 (assoc keywd (if got-rvalue sigs-in sigs-out))) | |
6591 nil (list keywd nil nil)) | |
6592 sig-tolk t))) | |
6593 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
6594 (t | |
6595 (forward-char 1))) | |
6596 ;; End of non-comment token | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6597 (setq last-keywd keywd))) |
79545 | 6598 (skip-syntax-forward " ")) |
6599 ;; Append the final pending signal | |
6600 (when got-sig | |
6601 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
6602 (setq sigs-out (cons got-sig sigs-out))) | |
6603 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
6604 (setq got-sig nil)) | |
6605 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd)))) | |
6606 )) | |
6607 | |
6608 (defun verilog-read-always-signals () | |
6609 "Parse always block at point and return list of (outputs inout inputs)." | |
6610 ;; Insert new | |
6611 (save-excursion | |
6612 (let* (;;(dbg "") | |
6613 sigs-in sigs-out | |
6614 uses-delayed) ;; Found signal/rvalue; push if not function | |
6615 (search-forward ")") | |
6616 (verilog-read-always-signals-recurse nil nil nil) | |
6617 ;;(if dbg (save-excursion (set-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg ""))) | |
6618 ;; Return what was found | |
6619 (list sigs-out nil sigs-in uses-delayed)))) | |
6620 | |
6621 (defun verilog-read-instants () | |
6622 "Parse module at point and return list of ( ( file instance ) ... )." | |
6623 (verilog-beg-of-defun) | |
6624 (let* ((end-mod-point (verilog-get-end-of-defun t)) | |
6625 (state nil) | |
6626 (instants-list nil)) | |
6627 (save-excursion | |
6628 (while (< (point) end-mod-point) | |
6629 ;; Stay at level 0, no comments | |
6630 (while (progn | |
6631 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil)) | |
6632 (or (> (car state) 0) ; in parens | |
6633 (nth 5 state) ; comment | |
6634 )) | |
6635 (forward-line 1)) | |
6636 (beginning-of-line) | |
6637 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(") | |
6638 ;;(if (looking-at "^\\(.+\\)$") | |
6639 (let ((module (match-string 1)) | |
6640 (instant (match-string 2))) | |
6641 (if (not (member module verilog-keywords)) | |
6642 (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
|
6643 (forward-line 1))) |
79545 | 6644 instants-list)) |
6645 | |
6646 | |
6647 (defun verilog-read-auto-template (module) | |
6648 "Look for a auto_template for the instantiation of the given MODULE. | |
6649 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
|
6650 list of ( (signal_name connection_name)... )." |
79545 | 6651 (save-excursion |
6652 ;; Find beginning | |
6653 (let ((tpl-regexp "\\([0-9]+\\)") | |
6654 (lineno 0) | |
6655 (templateno 0) | |
6656 tpl-sig-list tpl-wild-list tpl-end-pt rep) | |
6657 (cond ((or | |
6658 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t) | |
6659 (progn | |
6660 (goto-char (point-min)) | |
6661 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t))) | |
6662 (goto-char (match-end 0)) | |
6663 ;; Parse "REGEXP" | |
6664 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST | |
6665 (when (looking-at "\\s-*\"\\([^\"]*)\\)\"") | |
6666 (setq tpl-regexp (match-string 1)) | |
6667 (goto-char (match-end 0))) | |
6668 (search-forward "(") | |
6669 ;; Parse lines in the template | |
6670 (when verilog-auto-inst-template-numbers | |
6671 (save-excursion | |
6672 (goto-char (point-min)) | |
6673 (while (search-forward "AUTO_TEMPLATE" nil t) | |
6674 (setq templateno (1+ templateno))))) | |
6675 (setq tpl-end-pt (save-excursion | |
6676 (backward-char 1) | |
6677 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
6678 (backward-char 1) | |
6679 (point))) | |
6680 ;; | |
6681 (while (< (point) tpl-end-pt) | |
6682 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
6683 (setq tpl-sig-list (cons (list | |
6684 (match-string-no-properties 1) | |
6685 (match-string-no-properties 2) | |
6686 templateno lineno) | |
6687 tpl-sig-list)) | |
6688 (goto-char (match-end 0))) | |
6689 ;; Regexp form?? | |
6690 ((looking-at | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6691 ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last |
79545 | 6692 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") |
6693 (setq rep (match-string-no-properties 3)) | |
6694 (goto-char (match-end 0)) | |
6695 (setq tpl-wild-list | |
6696 (cons (list | |
6697 (concat "^" | |
6698 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil | |
6699 (match-string 1)) | |
6700 "$") | |
6701 rep | |
6702 templateno lineno) | |
6703 tpl-wild-list))) | |
6704 ((looking-at "[ \t\f]+") | |
6705 (goto-char (match-end 0))) | |
6706 ((looking-at "\n") | |
6707 (setq lineno (1+ lineno)) | |
6708 (goto-char (match-end 0))) | |
6709 ((looking-at "//") | |
6710 (search-forward "\n")) | |
6711 ((looking-at "/\\*") | |
6712 (forward-char 2) | |
6713 (or (search-forward "*/") | |
6714 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6715 (t | |
6716 (error "%s: AUTO_TEMPLATE parsing error: %s" | |
6717 (verilog-point-text) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6718 (progn (looking-at ".*$") (match-string 0)))))) |
79545 | 6719 ;; Return |
6720 (vector tpl-regexp | |
6721 (list tpl-sig-list tpl-wild-list))) | |
6722 ;; If no template found | |
6723 (t (vector tpl-regexp nil)))))) | |
6724 ;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry")) | |
6725 | |
6726 (defun verilog-set-define (defname defvalue &optional buffer enumname) | |
6727 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER. | |
6728 Optionally associate it with the specified enumeration ENUMNAME." | |
6729 (save-excursion | |
6730 (set-buffer (or buffer (current-buffer))) | |
6731 (let ((mac (intern (concat "vh-" defname)))) | |
6732 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6733 ;; Need to define to a constant if no value given | |
6734 (set (make-variable-buffer-local mac) | |
6735 (if (equal defvalue "") "1" defvalue))) | |
6736 (if enumname | |
6737 (let ((enumvar (intern (concat "venum-" enumname)))) | |
6738 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
6739 (make-variable-buffer-local enumvar) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6740 (add-to-list enumvar defname))))) |
79545 | 6741 |
6742 (defun verilog-read-defines (&optional filename recurse subcall) | |
6743 "Read `defines and parameters for the current file, or optional FILENAME. | |
6744 If the filename is provided, `verilog-library-flags' will be used to | |
6745 resolve it. If optional RECURSE is non-nil, recurse through `includes. | |
6746 | |
6747 Parameters must be simple assignments to constants, or have their own | |
6748 \"parameter\" label rather than a list of parameters. Thus: | |
6749 | |
6750 parameter X = 5, Y = 10; // Ok | |
6751 parameter X = {1'b1, 2'h2}; // Ok | |
6752 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines | |
6753 | |
6754 Defines must be simple text substitutions, one on a line, starting | |
6755 at the beginning of the line. Any ifdefs or multiline comments around the | |
6756 define are ignored. | |
6757 | |
6758 Defines are stored inside Emacs variables using the name vh-{definename}. | |
6759 | |
6760 This function is useful for setting vh-* variables. The file variables | |
6761 feature can be used to set defines that `verilog-mode' can see; put at the | |
6762 *END* of your file something like: | |
6763 | |
6764 // Local Variables: | |
6765 // vh-macro:\"macro_definition\" | |
6766 // End: | |
6767 | |
6768 If macros are defined earlier in the same file and you want their values, | |
6769 you can read them automatically (provided `enable-local-eval' is on): | |
6770 | |
6771 // Local Variables: | |
6772 // eval:(verilog-read-defines) | |
6773 // eval:(verilog-read-defines \"group_standard_includes.v\") | |
6774 // End: | |
6775 | |
6776 Note these are only read when the file is first visited, you must use | |
6777 \\[find-alternate-file] RET to have these take effect after editing them! | |
6778 | |
6779 If you want to disable the \"Process `eval' or hook local variables\" | |
6780 warning message, you need to add to your .emacs file: | |
6781 | |
6782 (setq enable-local-eval t)" | |
6783 (let ((origbuf (current-buffer))) | |
6784 (save-excursion | |
6785 (unless subcall (verilog-getopt-flags)) | |
6786 (when filename | |
6787 (let ((fns (verilog-library-filenames filename (buffer-file-name)))) | |
6788 (if fns | |
6789 (set-buffer (find-file-noselect (car fns))) | |
6790 (error (concat (verilog-point-text) | |
6791 ": Can't find verilog-read-defines file: " filename))))) | |
6792 (when recurse | |
6793 (goto-char (point-min)) | |
6794 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6795 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1)))) | |
6796 (unless (verilog-inside-comment-p) | |
6797 (verilog-read-defines inc recurse t))))) | |
6798 ;; Read `defines | |
6799 ;; note we don't use verilog-re... it's faster this way, and that | |
6800 ;; function has problems when comments are at the end of the define | |
6801 (goto-char (point-min)) | |
6802 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t) | |
6803 (let ((defname (match-string-no-properties 1)) | |
6804 (defvalue (match-string-no-properties 2))) | |
6805 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue)) | |
6806 (verilog-set-define defname defvalue origbuf))) | |
6807 ;; Hack: Read parameters | |
6808 (goto-char (point-min)) | |
6809 (while (re-search-forward | |
6810 "^\\s-*\\(parameter\\|localparam\\)\\(\\(\\s-*\\[[^]]*\\]\\|\\)\\s-+\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\|\\)\\s-*" nil t) | |
6811 (let ((var (match-string-no-properties 4)) | |
6812 (val (match-string-no-properties 5)) | |
6813 enumname) | |
6814 ;; The primary way of getting defines is verilog-read-decls | |
6815 ;; However, that isn't called yet for included files, so we'll add another scheme | |
6816 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6817 (setq enumname (match-string-no-properties 1))) | |
6818 (if var | |
6819 (verilog-set-define var val origbuf enumname)) | |
6820 (forward-comment 999) | |
6821 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | |
6822 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) | |
6823 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6824 (forward-comment 999))))))) |
79545 | 6825 |
6826 (defun verilog-read-includes () | |
6827 "Read `includes for the current file. | |
6828 This will find all of the `includes which are at the beginning of lines, | |
6829 ignoring any ifdefs or multiline comments around them. | |
6830 `verilog-read-defines' is then performed on the current and each included | |
6831 file. | |
6832 | |
6833 It is often useful put at the *END* of your file something like: | |
6834 | |
6835 // Local Variables: | |
6836 // eval:(verilog-read-defines) | |
6837 // eval:(verilog-read-includes) | |
6838 // End: | |
6839 | |
6840 Note includes are only read when the file is first visited, you must use | |
6841 \\[find-alternate-file] RET to have these take effect after editing them! | |
6842 | |
6843 It is good to get in the habit of including all needed files in each .v | |
6844 file that needs it, rather than waiting for compile time. This will aid | |
6845 this process, Verilint, and readability. To prevent defining the same | |
6846 variable over and over when many modules are compiled together, put a test | |
6847 around the inside each include file: | |
6848 | |
6849 foo.v (a include): | |
6850 `ifdef _FOO_V // include if not already included | |
6851 `else | |
6852 `define _FOO_V | |
6853 ... contents of file | |
6854 `endif // _FOO_V" | |
6855 ;;slow: (verilog-read-defines nil t)) | |
6856 (save-excursion | |
6857 (verilog-getopt-flags) | |
6858 (goto-char (point-min)) | |
6859 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
6860 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1)))) | |
6861 (verilog-read-defines inc nil t))))) | |
6862 | |
6863 (defun verilog-read-signals (&optional start end) | |
6864 "Return a simple list of all possible signals in the file. | |
6865 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
|
6866 Some macros and such are also found and included. For dinotrace.el." |
79545 | 6867 (let (sigs-all keywd) |
6868 (progn;save-excursion | |
6869 (goto-char (or start (point-min))) | |
6870 (setq end (or end (point-max))) | |
6871 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t) | |
6872 (forward-char -1) | |
6873 (cond | |
6874 ((looking-at "//") | |
6875 (search-forward "\n")) | |
6876 ((looking-at "/\\*") | |
6877 (search-forward "*/")) | |
6878 ((looking-at "(\\*") | |
6879 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
6880 (search-forward "*)"))) | |
6881 ((eq ?\" (following-char)) | |
6882 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first | |
6883 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") | |
6884 (goto-char (match-end 0)) | |
6885 (setq keywd (match-string-no-properties 1)) | |
6886 (or (member keywd verilog-keywords) | |
6887 (member keywd sigs-all) | |
6888 (setq sigs-all (cons keywd sigs-all)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6889 (t (forward-char 1)))) |
79545 | 6890 ;; Return list |
6891 sigs-all))) | |
6892 | |
6893 ;; | |
6894 ;; Argument file parsing | |
6895 ;; | |
6896 | |
6897 (defun verilog-getopt (arglist) | |
6898 "Parse -f, -v etc arguments in ARGLIST list or string." | |
6899 (unless (listp arglist) (setq arglist (list arglist))) | |
6900 (let ((space-args '()) | |
6901 arg next-param) | |
6902 ;; Split on spaces, so users can pass whole command lines | |
6903 (while arglist | |
6904 (setq arg (car arglist) | |
6905 arglist (cdr arglist)) | |
6906 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg) | |
6907 (setq space-args (append space-args | |
6908 (list (match-string-no-properties 1 arg)))) | |
6909 (setq arg (match-string 2 arg)))) | |
6910 ;; Parse arguments | |
6911 (while space-args | |
6912 (setq arg (car space-args) | |
6913 space-args (cdr space-args)) | |
6914 (cond | |
6915 ;; Need another arg | |
6916 ((equal arg "-f") | |
6917 (setq next-param arg)) | |
6918 ((equal arg "-v") | |
6919 (setq next-param arg)) | |
6920 ((equal arg "-y") | |
6921 (setq next-param arg)) | |
6922 ;; +libext+(ext1)+(ext2)... | |
6923 ((string-match "^\\+libext\\+\\(.*\\)" arg) | |
6924 (setq arg (match-string 1 arg)) | |
6925 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg) | |
6926 (verilog-add-list-unique `verilog-library-extensions | |
6927 (match-string 1 arg)) | |
6928 (setq arg (match-string 2 arg)))) | |
6929 ;; | |
6930 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val | |
6931 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine | |
6932 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val | |
6933 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define | |
6934 (verilog-set-define (match-string 1 arg) (match-string 2 arg))) | |
6935 ;; | |
6936 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir | |
6937 (string-match "^-I\\(.*\\)" arg)) ;; -Idir | |
6938 (verilog-add-list-unique `verilog-library-directories | |
6939 (match-string 1 arg))) | |
6940 ;; Ignore | |
6941 ((equal "+librescan" arg)) | |
6942 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine | |
6943 ;; Second parameters | |
6944 ((equal next-param "-f") | |
6945 (setq next-param nil) | |
6946 (verilog-getopt-file arg)) | |
6947 ((equal next-param "-v") | |
6948 (setq next-param nil) | |
6949 (verilog-add-list-unique `verilog-library-files arg)) | |
6950 ((equal next-param "-y") | |
6951 (setq next-param nil) | |
6952 (verilog-add-list-unique `verilog-library-directories arg)) | |
6953 ;; Filename | |
6954 ((string-match "^[^-+]" arg) | |
6955 (verilog-add-list-unique `verilog-library-files arg)) | |
6956 ;; Default - ignore; no warning | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6957 )))) |
79545 | 6958 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
6959 | |
6960 (defun verilog-getopt-file (filename) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6961 "Read Verilog options from the specified FILENAME." |
79545 | 6962 (save-excursion |
6963 (let ((fns (verilog-library-filenames filename (buffer-file-name))) | |
6964 (orig-buffer (current-buffer)) | |
6965 line) | |
6966 (if fns | |
6967 (set-buffer (find-file-noselect (car fns))) | |
6968 (error (concat (verilog-point-text) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6969 ": Can't find verilog-getopt-file -f file: " filename))) |
79545 | 6970 (goto-char (point-min)) |
6971 (while (not (eobp)) | |
6972 (setq line (buffer-substring (point) | |
6973 (save-excursion (end-of-line) (point)))) | |
6974 (forward-line 1) | |
6975 (when (string-match "//" line) | |
6976 (setq line (substring line 0 (match-beginning 0)))) | |
6977 (save-excursion | |
6978 (set-buffer orig-buffer) ; Variables are buffer-local, so need right context. | |
6979 (verilog-getopt line)))))) | |
6980 | |
6981 (defun verilog-getopt-flags () | |
6982 "Convert `verilog-library-flags' into standard library variables." | |
6983 ;; If the flags are local, then all the outputs should be local also | |
6984 (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
|
6985 (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
|
6986 verilog-library-directories |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6987 verilog-library-files |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6988 verilog-library-flags))) |
79545 | 6989 ;; Allow user to customize |
6990 (run-hooks 'verilog-before-getopt-flags-hook) | |
6991 ;; Process arguments | |
6992 (verilog-getopt verilog-library-flags) | |
6993 ;; Allow user to customize | |
6994 (run-hooks 'verilog-getopt-flags-hook)) | |
6995 | |
6996 (defun verilog-add-list-unique (varref object) | |
6997 "Append to VARREF list the given OBJECT, | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
6998 unless it is already a member of the variable's list." |
79545 | 6999 (unless (member object (symbol-value varref)) |
7000 (set varref (append (symbol-value varref) (list object)))) | |
7001 varref) | |
7002 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l) | |
7003 | |
7004 | |
7005 ;; | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7006 ;; Cached directory support |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7007 ;; |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7008 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7009 (defvar verilog-dir-cache-preserving nil |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7010 "If set, the directory cache is enabled, and file system changes are ignored. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7011 See `verilog-dir-exists-p' and `verilog-dir-files'.") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7012 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7013 ;; If adding new cached variable, add also to verilog-preserve-dir-cache |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7014 (defvar verilog-dir-cache-list nil |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7015 "Alist of (((Cwd Dirname) Results)...) for caching `verilog-dir-files'.") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7016 (defvar verilog-dir-cache-lib-filenames nil |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7017 "Cached data for `verilog-library-filenames'.") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7018 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7019 (defmacro verilog-preserve-dir-cache (&rest body) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7020 "Execute the BODY forms, allowing directory cache preservation within BODY. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7021 This means that changes inside BODY made to the file system will not be |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7022 seen by the `verilog-dir-files' and related functions." |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7023 `(let ((verilog-dir-cache-preserving t) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7024 verilog-dir-cache-list |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7025 verilog-dir-cache-lib-filenames) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7026 (progn ,@body))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7027 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7028 (defun verilog-dir-files (dirname) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7029 "Return all filenames in the DIRNAME directory. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7030 Relative paths depend on the `default-directory'. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7031 Results are cached if inside `verilog-preserve-dir-cache'." |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7032 (unless verilog-dir-cache-preserving |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7033 (setq verilog-dir-cache-list nil)) ;; Cache disabled |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7034 ;; We don't use expand-file-name on the dirname to make key, as it's slow |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7035 (let* ((cache-key (list dirname default-directory)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7036 (fass (assoc cache-key verilog-dir-cache-list)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7037 exp-dirname data) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7038 (cond (fass ;; Return data from cache hit |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7039 (nth 1 fass)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7040 (t |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7041 (setq exp-dirname (expand-file-name dirname) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7042 data (and (file-directory-p exp-dirname) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7043 (directory-files exp-dirname nil nil nil))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7044 ;; Note we also encache nil for non-existing dirs. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7045 (setq verilog-dir-cache-list (cons (list cache-key data) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7046 verilog-dir-cache-list)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7047 data)))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7048 ;; Miss-and-hit test: |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7049 ;;(verilog-preserve-dir-cache (prin1 (verilog-dir-files ".")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7050 ;; (prin1 (verilog-dir-files ".")) nil) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7051 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7052 (defun verilog-dir-file-exists-p (filename) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7053 "Return true if FILENAME exists. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7054 Like `file-exists-p' but results are cached if inside |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7055 `verilog-preserve-dir-cache'." |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7056 (let* ((dirname (file-name-directory filename)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7057 ;; Correct for file-name-nondirectory returning same if no slash. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7058 (dirnamed (if (or (not dirname) (equal dirname filename)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7059 default-directory dirname)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7060 (flist (verilog-dir-files dirnamed))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7061 (and flist |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7062 (member (file-name-nondirectory filename) flist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7063 t))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7064 ;;(verilog-dir-file-exists-p "verilog-mode.el") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7065 ;;(verilog-dir-file-exists-p "../verilog-mode/verilog-mode.el") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7066 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7067 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7068 ;; |
79545 | 7069 ;; Module name lookup |
7070 ;; | |
7071 | |
7072 (defun verilog-module-inside-filename-p (module filename) | |
7073 "Return point if MODULE is specified inside FILENAME, else nil. | |
7074 Allows version control to check out the file if need be." | |
7075 (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
|
7076 (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
|
7077 (vc-backend filename))) |
79545 | 7078 (let (pt) |
7079 (save-excursion | |
7080 (set-buffer (find-file-noselect filename)) | |
7081 (goto-char (point-min)) | |
7082 (while (and | |
7083 ;; It may be tempting to look for verilog-defun-re, don't, it slows things down a lot! | |
7084 (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
7085 (verilog-re-search-forward-quick "[(;]" nil t)) | |
7086 (if (equal module (verilog-read-module-name)) | |
7087 (setq pt (point)))) | |
7088 pt)))) | |
7089 | |
7090 (defun verilog-is-number (symbol) | |
7091 "Return true if SYMBOL is number-like." | |
7092 (or (string-match "^[0-9 \t:]+$" symbol) | |
7093 (string-match "^[---]*[0-9]+$" symbol) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7094 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
79545 | 7095 |
7096 (defun verilog-symbol-detick (symbol wing-it) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7097 "Return an expanded SYMBOL name without any defines. |
79545 | 7098 If the variable vh-{symbol} is defined, return that value. |
7099 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | |
7100 (while (and symbol (string-match "^`" symbol)) | |
7101 (setq symbol (substring symbol 1)) | |
7102 (setq symbol | |
7103 (if (boundp (intern (concat "vh-" symbol))) | |
7104 ;; Emacs has a bug where boundp on a buffer-local | |
7105 ;; variable in only one buffer returns t in another. | |
7106 ;; This can confuse, so check for nil. | |
7107 (let ((val (eval (intern (concat "vh-" symbol))))) | |
7108 (if (eq val nil) | |
7109 (if wing-it symbol nil) | |
7110 val)) | |
7111 (if wing-it symbol nil)))) | |
7112 symbol) | |
7113 ;;(verilog-symbol-detick "`mod" nil) | |
7114 | |
7115 (defun verilog-symbol-detick-denumber (symbol) | |
7116 "Return SYMBOL with defines converted and any numbers dropped to nil." | |
7117 (when (string-match "^`" symbol) | |
7118 ;; This only will work if the define is a simple signal, not | |
7119 ;; something like a[b]. Sorry, it should be substituted into the parser | |
7120 (setq symbol | |
7121 (verilog-string-replace-matches | |
7122 "\[[^0-9: \t]+\]" "" nil nil | |
7123 (or (verilog-symbol-detick symbol nil) | |
7124 (if verilog-auto-sense-defines-constant | |
7125 "0" | |
7126 symbol))))) | |
7127 (if (verilog-is-number symbol) | |
7128 nil | |
7129 symbol)) | |
7130 | |
7131 (defun verilog-symbol-detick-text (text) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7132 "Return TEXT without any known defines. |
79545 | 7133 If the variable vh-{symbol} is defined, substitute that value." |
7134 (let ((ok t) symbol val) | |
7135 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text)) | |
7136 (setq symbol (match-string 1 text)) | |
7137 (message symbol) | |
7138 (cond ((and | |
7139 (boundp (intern (concat "vh-" symbol))) | |
7140 ;; Emacs has a bug where boundp on a buffer-local | |
7141 ;; variable in only one buffer returns t in another. | |
7142 ;; This can confuse, so check for nil. | |
7143 (setq val (eval (intern (concat "vh-" symbol))))) | |
7144 (setq text (replace-match val nil nil text))) | |
7145 (t (setq ok nil))))) | |
7146 text) | |
7147 ;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed")) | |
7148 | |
7149 (defun verilog-expand-dirnames (&optional dirnames) | |
7150 "Return a list of existing directories given a list of wildcarded DIRNAMES. | |
7151 Or, just the existing dirnames themselves if there are no wildcards." | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7152 ;; Note this function is performance critical. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7153 ;; Do not call anything that requires disk access that cannot be cached. |
79545 | 7154 (interactive) |
7155 (unless dirnames (error "`verilog-library-directories' should include at least '.'")) | |
7156 (setq dirnames (reverse dirnames)) ; not nreverse | |
7157 (let ((dirlist nil) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7158 pattern dirfile dirfiles dirname root filename rest basefile) |
79545 | 7159 (while dirnames |
7160 (setq dirname (substitute-in-file-name (car dirnames)) | |
7161 dirnames (cdr dirnames)) | |
7162 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root | |
7163 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *? | |
7164 "\\(.*\\)") ;; rest | |
7165 dirname) | |
7166 (setq root (match-string 1 dirname) | |
7167 filename (match-string 2 dirname) | |
7168 rest (match-string 3 dirname) | |
7169 pattern filename) | |
7170 ;; now replace those * and ? with .+ and . | |
7171 ;; use ^ and /> to get only whole file names | |
7172 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) | |
7173 pattern (verilog-string-replace-matches "[?]" "." nil nil pattern) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7174 pattern (concat "^" pattern "$") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7175 dirfiles (verilog-dir-files root)) |
79545 | 7176 (while dirfiles |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7177 (setq basefile (car dirfiles) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7178 dirfile (expand-file-name (concat root basefile rest)) |
79545 | 7179 dirfiles (cdr dirfiles)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7180 (if (and (string-match pattern basefile) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7181 ;; Don't allow abc/*/rtl to match abc/rtl via .. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7182 (not (equal basefile ".")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7183 (not (equal basefile "..")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7184 (file-directory-p dirfile)) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7185 (setq dirlist (cons dirfile dirlist))))) |
79545 | 7186 ;; Defaults |
7187 (t | |
7188 (if (file-directory-p dirname) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7189 (setq dirlist (cons dirname dirlist)))))) |
79545 | 7190 dirlist)) |
7191 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | |
7192 | |
7193 (defun verilog-library-filenames (filename current &optional check-ext) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7194 "Return a search path to find the given FILENAME or module name. |
79545 | 7195 Uses the CURRENT filename, `verilog-library-directories' and |
7196 `verilog-library-extensions' variables to build the path. | |
7197 With optional CHECK-EXT also check `verilog-library-extensions'." | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7198 (unless verilog-dir-cache-preserving |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7199 (setq verilog-dir-cache-lib-filenames nil)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7200 (let* ((cache-key (list filename current check-ext)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7201 (fass (assoc cache-key verilog-dir-cache-lib-filenames)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7202 chkdirs chkdir chkexts fn outlist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7203 (cond (fass ;; Return data from cache hit |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7204 (nth 1 fass)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7205 (t |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7206 ;; Note this expand can't be easily cached, as we need to |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7207 ;; pick up buffer-local variables for newly read sub-module files |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7208 (setq chkdirs (verilog-expand-dirnames verilog-library-directories)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7209 (while chkdirs |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7210 (setq chkdir (expand-file-name (car chkdirs) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7211 (file-name-directory current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7212 chkexts (if check-ext verilog-library-extensions `(""))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7213 (while chkexts |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7214 (setq fn (expand-file-name (concat filename (car chkexts)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7215 chkdir)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7216 ;;(message "Check for %s" fn) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7217 (if (verilog-dir-file-exists-p fn) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7218 (setq outlist (cons (expand-file-name |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7219 fn (file-name-directory current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7220 outlist))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7221 (setq chkexts (cdr chkexts))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7222 (setq chkdirs (cdr chkdirs))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7223 (setq outlist (nreverse outlist)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7224 (setq verilog-dir-cache-lib-filenames |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7225 (cons (list cache-key outlist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7226 verilog-dir-cache-lib-filenames)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7227 outlist)))) |
79545 | 7228 |
7229 (defun verilog-module-filenames (module current) | |
7230 "Return a search path to find the given MODULE name. | |
7231 Uses the CURRENT filename, `verilog-library-extensions', | |
7232 `verilog-library-directories' and `verilog-library-files' | |
7233 variables to build the path." | |
7234 ;; Return search locations for it | |
7235 (append (list current) ; first, current buffer | |
7236 (verilog-library-filenames module current t) | |
7237 verilog-library-files)) ; finally, any libraries | |
7238 | |
7239 ;; | |
7240 ;; Module Information | |
7241 ;; | |
7242 ;; Many of these functions work on "modi" a module information structure | |
7243 ;; A modi is: [module-name-string file-name begin-point] | |
7244 | |
7245 (defvar verilog-cache-enabled t | |
7246 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!") | |
7247 | |
7248 (defvar verilog-modi-cache-list nil | |
7249 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)... | |
7250 For speeding up verilog-modi-get-* commands. | |
7251 Buffer-local.") | |
7252 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7253 (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
|
7254 |
79545 | 7255 (defvar verilog-modi-cache-preserve-tick nil |
7256 "Modification tick after which the cache is still considered valid. | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7257 Use `verilog-preserve-modi-cache' to set it.") |
79545 | 7258 (defvar verilog-modi-cache-preserve-buffer nil |
7259 "Modification tick after which the cache is still considered valid. | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7260 Use `verilog-preserve-modi-cache' to set it.") |
79545 | 7261 |
7262 (defun verilog-modi-current () | |
7263 "Return the modi structure for the module currently at point." | |
7264 (let* (name pt) | |
7265 ;; read current module's name | |
7266 (save-excursion | |
7267 (verilog-re-search-backward-quick verilog-defun-re nil nil) | |
7268 (verilog-re-search-forward-quick "(" nil nil) | |
7269 (setq name (verilog-read-module-name)) | |
7270 (setq pt (point))) | |
7271 ;; return | |
7272 (vector name (or (buffer-file-name) (current-buffer)) pt))) | |
7273 | |
7274 (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.") | |
7275 (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.") | |
7276 (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.") | |
7277 (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.") | |
7278 | |
7279 (defun verilog-modi-lookup (module allow-cache &optional ignore-error) | |
7280 "Find the file and point at which MODULE is defined. | |
7281 If ALLOW-CACHE is set, check and remember cache of previous lookups. | |
7282 Return modi if successful, else print message unless IGNORE-ERROR is true." | |
7283 (let* ((current (or (buffer-file-name) (current-buffer)))) | |
7284 (cond ((and verilog-modi-lookup-last-modi | |
7285 verilog-cache-enabled | |
7286 allow-cache | |
7287 (equal verilog-modi-lookup-last-mod module) | |
7288 (equal verilog-modi-lookup-last-current current) | |
7289 (equal verilog-modi-lookup-last-tick (buffer-modified-tick))) | |
7290 ;; ok as is | |
7291 ) | |
7292 (t (let* ((realmod (verilog-symbol-detick module t)) | |
7293 (orig-filenames (verilog-module-filenames realmod current)) | |
7294 (filenames orig-filenames) | |
7295 pt) | |
7296 (while (and filenames (not pt)) | |
7297 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames)))) | |
7298 (setq filenames (cdr filenames)))) | |
7299 (cond (pt (setq verilog-modi-lookup-last-modi | |
7300 (vector realmod (car filenames) pt))) | |
7301 (t (setq verilog-modi-lookup-last-modi nil) | |
7302 (or ignore-error | |
7303 (error (concat (verilog-point-text) | |
7304 ": Can't locate " module " module definition" | |
7305 (if (not (equal module realmod)) | |
7306 (concat " (Expanded macro to " realmod ")") | |
7307 "") | |
7308 "\n Check the verilog-library-directories variable." | |
7309 "\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
|
7310 (mapconcat 'concat orig-filenames "\n\t")))))) |
79545 | 7311 (setq verilog-modi-lookup-last-mod module |
7312 verilog-modi-lookup-last-current current | |
7313 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7314 verilog-modi-lookup-last-modi)) |
79545 | 7315 |
7316 (defsubst verilog-modi-name (modi) | |
7317 (aref modi 0)) | |
7318 (defsubst verilog-modi-file-or-buffer (modi) | |
7319 (aref modi 1)) | |
7320 (defsubst verilog-modi-point (modi) | |
7321 (aref modi 2)) | |
7322 | |
7323 (defun verilog-modi-filename (modi) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7324 "Filename of MODI, or name of buffer if it's never been saved." |
79545 | 7325 (if (bufferp (verilog-modi-file-or-buffer modi)) |
7326 (or (buffer-file-name (verilog-modi-file-or-buffer modi)) | |
7327 (buffer-name (verilog-modi-file-or-buffer modi))) | |
7328 (verilog-modi-file-or-buffer modi))) | |
7329 | |
7330 (defun verilog-modi-goto (modi) | |
7331 "Move point/buffer to specified MODI." | |
7332 (or modi (error "Passed unfound modi to goto, check earlier")) | |
7333 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) | |
7334 (verilog-modi-file-or-buffer modi) | |
7335 (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
|
7336 (or (equal major-mode `verilog-mode) ;; Put into Verilog mode to get syntax |
79545 | 7337 (verilog-mode)) |
7338 (goto-char (verilog-modi-point modi))) | |
7339 | |
7340 (defun verilog-goto-defun-file (module) | |
7341 "Move point to the file at which a given MODULE is defined." | |
7342 (interactive "sGoto File for Module: ") | |
7343 (let* ((modi (verilog-modi-lookup module nil))) | |
7344 (when modi | |
7345 (verilog-modi-goto modi) | |
7346 (switch-to-buffer (current-buffer))))) | |
7347 | |
7348 (defun verilog-modi-cache-results (modi function) | |
7349 "Run on MODI the given FUNCTION. Locate the module in a file. | |
7350 Cache the output of function so next call may have faster access." | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7351 (let (fass) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7352 (save-excursion ;; Cache is buffer-local so can't avoid this. |
79545 | 7353 (verilog-modi-goto modi) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7354 (if (and (setq fass (assoc (list modi function) |
79545 | 7355 verilog-modi-cache-list)) |
7356 ;; Destroy caching when incorrect; Modified or file changed | |
7357 (not (and verilog-cache-enabled | |
7358 (or (equal (buffer-modified-tick) (nth 1 fass)) | |
7359 (and verilog-modi-cache-preserve-tick | |
7360 (<= verilog-modi-cache-preserve-tick (nth 1 fass)) | |
7361 (equal verilog-modi-cache-preserve-buffer (current-buffer)))) | |
7362 (equal (visited-file-modtime) (nth 2 fass))))) | |
7363 (setq verilog-modi-cache-list nil | |
7364 fass nil)) | |
7365 (cond (fass | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7366 ;; Return data from cache hit |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7367 (nth 3 fass)) |
79545 | 7368 (t |
7369 ;; Read from file | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7370 ;; Clear then restore any hilighting to make emacs19 happy |
79545 | 7371 (let ((fontlocked (when (and (boundp 'font-lock-mode) |
7372 font-lock-mode) | |
7373 (font-lock-mode nil) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7374 t)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7375 func-returns) |
79545 | 7376 (setq func-returns (funcall function)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7377 (when fontlocked (font-lock-mode t)) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7378 ;; Cache for next time |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7379 (setq verilog-modi-cache-list |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7380 (cons (list (list modi function) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7381 (buffer-modified-tick) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7382 (visited-file-modtime) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7383 func-returns) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7384 verilog-modi-cache-list)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7385 func-returns)))))) |
79545 | 7386 |
7387 (defun verilog-modi-cache-add (modi function element sig-list) | |
7388 "Add function return results to the module cache. | |
7389 Update MODI's cache for given FUNCTION so that the return ELEMENT of that | |
7390 function now contains the additional SIG-LIST parameters." | |
7391 (let (fass) | |
7392 (save-excursion | |
7393 (verilog-modi-goto modi) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7394 (if (setq fass (assoc (list modi function) |
79545 | 7395 verilog-modi-cache-list)) |
7396 (let ((func-returns (nth 3 fass))) | |
7397 (aset func-returns element | |
7398 (append sig-list (aref func-returns element)))))))) | |
7399 | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7400 (defmacro verilog-preserve-modi-cache (&rest body) |
79545 | 7401 "Execute the BODY forms, allowing cache preservation within BODY. |
7402 This means that changes to the buffer will not result in the cache being | |
7403 flushed. If the changes affect the modsig state, they must call the | |
7404 modsig-cache-add-* function, else the results of later calls may be | |
7405 incorrect. Without this, changes are assumed to be adding/removing signals | |
7406 and invalidating the cache." | |
7407 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick)) | |
7408 (verilog-modi-cache-preserve-buffer (current-buffer))) | |
7409 (progn ,@body))) | |
7410 | |
7411 | |
7412 (defun verilog-signals-matching-enum (in-list enum) | |
7413 "Return all signals in IN-LIST matching the given ENUM." | |
7414 (let (out-list) | |
7415 (while in-list | |
7416 (if (equal (verilog-sig-enum (car in-list)) enum) | |
7417 (setq out-list (cons (car in-list) out-list))) | |
7418 (setq in-list (cdr in-list))) | |
7419 ;; New scheme | |
7420 (let* ((enumvar (intern (concat "venum-" enum))) | |
7421 (enumlist (and (boundp enumvar) (eval enumvar)))) | |
7422 (while enumlist | |
7423 (add-to-list 'out-list (list (car enumlist))) | |
7424 (setq enumlist (cdr enumlist)))) | |
7425 (nreverse out-list))) | |
7426 | |
93195 | 7427 (defun verilog-signals-matching-regexp (in-list regexp) |
7428 "Return all signals in IN-LIST matching the given REGEXP, if non-nil." | |
7429 (if (not regexp) | |
7430 in-list | |
7431 (let (out-list) | |
7432 (while in-list | |
7433 (if (string-match regexp (verilog-sig-name (car in-list))) | |
7434 (setq out-list (cons (car in-list) out-list))) | |
7435 (setq in-list (cdr in-list))) | |
7436 (nreverse out-list)))) | |
7437 | |
79545 | 7438 (defun verilog-signals-not-matching-regexp (in-list regexp) |
7439 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." | |
7440 (if (not regexp) | |
7441 in-list | |
7442 (let (out-list) | |
7443 (while in-list | |
7444 (if (not (string-match regexp (verilog-sig-name (car in-list)))) | |
7445 (setq out-list (cons (car in-list) out-list))) | |
7446 (setq in-list (cdr in-list))) | |
7447 (nreverse out-list)))) | |
7448 | |
7449 ;; Combined | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7450 (defun verilog-decls-get-signals (decls) |
79545 | 7451 (append |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7452 (verilog-decls-get-outputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7453 (verilog-decls-get-inouts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7454 (verilog-decls-get-inputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7455 (verilog-decls-get-wires decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7456 (verilog-decls-get-regs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7457 (verilog-decls-get-assigns decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7458 (verilog-decls-get-consts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7459 (verilog-decls-get-gparams decls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7460 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7461 (defun verilog-decls-get-ports (decls) |
79545 | 7462 (append |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7463 (verilog-decls-get-outputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7464 (verilog-decls-get-inouts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7465 (verilog-decls-get-inputs decls))) |
79545 | 7466 |
7467 (defsubst verilog-modi-cache-add-outputs (modi sig-list) | |
7468 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list)) | |
7469 (defsubst verilog-modi-cache-add-inouts (modi sig-list) | |
7470 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list)) | |
7471 (defsubst verilog-modi-cache-add-inputs (modi sig-list) | |
7472 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) | |
7473 (defsubst verilog-modi-cache-add-wires (modi sig-list) | |
7474 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) | |
7475 (defsubst verilog-modi-cache-add-regs (modi sig-list) | |
7476 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list)) | |
7477 | |
7478 (defun verilog-signals-from-signame (signame-list) | |
7479 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names." | |
7480 (mapcar (function (lambda (name) (list name nil nil))) | |
7481 signame-list)) | |
7482 | |
7483 ;; | |
7484 ;; Auto creation utilities | |
7485 ;; | |
7486 | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7487 (defun verilog-auto-re-search-do (search-for func) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7488 "Search for the given auto text regexp SEARCH-FOR, and perform FUNC where it occurs." |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7489 (goto-char (point-min)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7490 (while (verilog-re-search-forward search-for nil t) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7491 (funcall func))) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7492 |
79545 | 7493 (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
|
7494 "Print out a definition for SIG of the given TYPE, |
79545 | 7495 with appropriate INDENT-PT indentation." |
7496 (indent-to indent-pt) | |
7497 (insert type) | |
7498 (when (verilog-sig-signed sig) | |
7499 (insert " " (verilog-sig-signed sig))) | |
7500 (when (verilog-sig-multidim sig) | |
7501 (insert " " (verilog-sig-multidim-string sig))) | |
7502 (when (verilog-sig-bits sig) | |
7503 (insert " " (verilog-sig-bits sig))) | |
7504 (indent-to (max 24 (+ indent-pt 16))) | |
7505 (unless (= (char-syntax (preceding-char)) ?\ ) | |
7506 (insert " ")) ; Need space between "]name" if indent-to did nothing | |
7507 (insert (verilog-sig-name sig))) | |
7508 | |
7509 (defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort) | |
7510 "Print out a definition for a list of SIGS of the given DIRECTION, | |
7511 with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O | |
7512 format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output." | |
7513 (or dont-sort | |
7514 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) | |
7515 (while sigs | |
7516 (let ((sig (car sigs))) | |
7517 (verilog-insert-one-definition | |
7518 sig | |
7519 ;; Want "type x" or "output type x", not "wire type x" | |
7520 (cond ((verilog-sig-type sig) | |
7521 (concat | |
7522 (if (not (equal direction "wire")) | |
7523 (concat direction " ")) | |
7524 (verilog-sig-type sig))) | |
7525 (t direction)) | |
7526 indent-pt) | |
7527 (insert (if v2k "," ";")) | |
7528 (if (or (not (verilog-sig-comment sig)) | |
7529 (equal "" (verilog-sig-comment sig))) | |
7530 (insert "\n") | |
7531 (indent-to (max 48 (+ indent-pt 40))) | |
7532 (insert (concat "// " (verilog-sig-comment sig) "\n"))) | |
7533 (setq sigs (cdr sigs))))) | |
7534 | |
7535 (eval-when-compile | |
7536 (if (not (boundp 'indent-pt)) | |
7537 (defvar indent-pt nil "Local used by insert-indent"))) | |
7538 | |
7539 (defun verilog-insert-indent (&rest stuff) | |
7540 "Indent to position stored in local `indent-pt' variable, then insert STUFF. | |
7541 Presumes that any newlines end a list element." | |
7542 (let ((need-indent t)) | |
7543 (while stuff | |
7544 (if need-indent (indent-to indent-pt)) | |
7545 (setq need-indent nil) | |
7546 (insert (car stuff)) | |
7547 (setq need-indent (string-match "\n$" (car stuff)) | |
7548 stuff (cdr stuff))))) | |
7549 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n")) | |
7550 | |
7551 (defun verilog-repair-open-comma () | |
7552 "If backwards-from-point is other than a open parenthesis insert comma." | |
7553 (save-excursion | |
7554 (verilog-backward-syntactic-ws) | |
7555 (when (save-excursion | |
7556 (backward-char 1) | |
7557 (and (not (looking-at "[(,]")) | |
7558 (progn | |
7559 (verilog-re-search-backward "[(`]" nil t) | |
7560 (looking-at "(")))) | |
7561 (insert ",")))) | |
7562 | |
7563 (defun verilog-repair-close-comma () | |
7564 "If point is at a comma followed by a close parenthesis, fix it. | |
7565 This repairs those mis-inserted by a AUTOARG." | |
7566 ;; It would be much nicer if Verilog allowed extra commas like Perl does! | |
7567 (save-excursion | |
7568 (verilog-forward-close-paren) | |
7569 (backward-char 1) | |
7570 (verilog-backward-syntactic-ws) | |
7571 (backward-char 1) | |
7572 (when (looking-at ",") | |
7573 (delete-char 1)))) | |
7574 | |
7575 (defun verilog-get-list (start end) | |
7576 "Return the elements of a comma separated list between START and END." | |
7577 (interactive) | |
7578 (let ((my-list (list)) | |
7579 my-string) | |
7580 (save-excursion | |
7581 (while (< (point) end) | |
7582 (when (re-search-forward "\\([^,{]+\\)" end t) | |
7583 (setq my-string (verilog-string-remove-spaces (match-string 1))) | |
7584 (setq my-list (nconc my-list (list my-string) )) | |
7585 (goto-char (match-end 0)))) | |
7586 my-list))) | |
7587 | |
7588 (defun verilog-make-width-expression (range-exp) | |
7589 "Return an expression calculating the length of a range [x:y] in RANGE-EXP." | |
7590 ;; strip off the [] | |
7591 (cond ((not range-exp) | |
7592 "1") | |
7593 (t | |
7594 (if (string-match "^\\[\\(.*\\)\\]$" range-exp) | |
7595 (setq range-exp (match-string 1 range-exp))) | |
7596 (cond ((not range-exp) | |
7597 "1") | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7598 ((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
|
7599 range-exp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7600 (int-to-string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7601 (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
|
7602 (string-to-number (match-string 2 range-exp))))))) |
79545 | 7603 ((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
|
7604 (concat "(1+(" (match-string 1 range-exp) ")" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7605 (if (equal "0" (match-string 2 range-exp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7606 "" ;; Don't bother with -(0) |
79545 | 7607 (concat "-(" (match-string 2 range-exp) ")")) |
7608 ")")) | |
7609 (t nil))))) | |
7610 ;;(verilog-make-width-expression "`A:`B") | |
7611 | |
7612 (defun verilog-typedef-name-p (variable-name) | |
7613 "Return true if the VARIABLE-NAME is a type definition." | |
7614 (when verilog-typedef-regexp | |
7615 (string-match verilog-typedef-regexp variable-name))) | |
7616 | |
7617 ;; | |
7618 ;; Auto deletion | |
7619 ;; | |
7620 | |
7621 (defun verilog-delete-autos-lined () | |
7622 "Delete autos that occupy multiple lines, between begin and end comments." | |
7623 (let ((pt (point))) | |
7624 (forward-line 1) | |
7625 (when (and | |
7626 (looking-at "\\s-*// Beginning") | |
7627 (search-forward "// End of automatic" nil t)) | |
7628 ;; End exists | |
7629 (end-of-line) | |
7630 (delete-region pt (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7631 (forward-line 1)))) |
79545 | 7632 |
7633 (defun verilog-forward-close-paren () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7634 "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
|
7635 Ignore other close parenthesis with matching open parens." |
79545 | 7636 (let ((parens 1)) |
7637 (while (> parens 0) | |
7638 (unless (verilog-re-search-forward-quick "[()]" nil t) | |
7639 (error "%s: Mismatching ()" (verilog-point-text))) | |
7640 (cond ((= (preceding-char) ?\( ) | |
7641 (setq parens (1+ parens))) | |
7642 ((= (preceding-char) ?\) ) | |
7643 (setq parens (1- parens))))))) | |
7644 | |
7645 (defun verilog-backward-open-paren () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7646 "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
|
7647 Ignore other open parenthesis with matching close parens." |
79545 | 7648 (let ((parens 1)) |
7649 (while (> parens 0) | |
7650 (unless (verilog-re-search-backward-quick "[()]" nil t) | |
7651 (error "%s: Mismatching ()" (verilog-point-text))) | |
7652 (cond ((= (following-char) ?\) ) | |
7653 (setq parens (1+ parens))) | |
7654 ((= (following-char) ?\( ) | |
7655 (setq parens (1- parens))))))) | |
7656 | |
7657 (defun verilog-backward-open-bracket () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7658 "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
|
7659 Ignore other open bracket with matching close bracket." |
79545 | 7660 (let ((parens 1)) |
7661 (while (> parens 0) | |
7662 (unless (verilog-re-search-backward-quick "[][]" nil t) | |
7663 (error "%s: Mismatching []" (verilog-point-text))) | |
7664 (cond ((= (following-char) ?\] ) | |
7665 (setq parens (1+ parens))) | |
7666 ((= (following-char) ?\[ ) | |
7667 (setq parens (1- parens))))))) | |
7668 | |
7669 (defun verilog-delete-to-paren () | |
7670 "Delete the automatic inst/sense/arg created by autos. | |
7671 Deletion stops at the matching end parenthesis." | |
7672 (delete-region (point) | |
7673 (save-excursion | |
7674 (verilog-backward-open-paren) | |
7675 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
7676 (backward-char 1) | |
7677 (point)))) | |
7678 | |
7679 (defun verilog-auto-star-safe () | |
7680 "Return if a .* AUTOINST is safe to delete or expand. | |
7681 It was created by the AUTOS themselves, or by the user." | |
7682 (and verilog-auto-star-expand | |
7683 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\)\\)"))) | |
7684 | |
7685 (defun verilog-delete-auto-star-all () | |
7686 "Delete a .* AUTOINST, if it is safe." | |
7687 (when (verilog-auto-star-safe) | |
7688 (verilog-delete-to-paren))) | |
7689 | |
7690 (defun verilog-delete-auto-star-implicit () | |
7691 "Delete all .* implicit connections created by `verilog-auto-star'. | |
7692 This function will be called automatically at save unless | |
7693 `verilog-auto-star-save' is set, any non-templated expanded pins will be | |
7694 removed." | |
7695 (interactive) | |
7696 (let (paren-pt indent have-close-paren) | |
7697 (save-excursion | |
7698 (goto-char (point-min)) | |
7699 ;; We need to match these even outside of comments. | |
7700 ;; For reasonable performance, we don't check if inside comments, sorry. | |
7701 (while (re-search-forward "// Implicit \\.\\*" nil t) | |
7702 (setq paren-pt (point)) | |
7703 (beginning-of-line) | |
7704 (setq have-close-paren | |
7705 (save-excursion | |
7706 (when (search-forward ");" paren-pt t) | |
7707 (setq indent (current-indentation)) | |
7708 t))) | |
7709 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR | |
7710 (when have-close-paren | |
7711 ;; Delete extra commentary | |
7712 (save-excursion | |
7713 (while (progn | |
7714 (forward-line -1) | |
7715 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\)\n")) | |
7716 (delete-region (match-beginning 0) (match-end 0)))) | |
7717 ;; If it is simple, we can put the ); on the same line as the last text | |
7718 (let ((rtn-pt (point))) | |
7719 (save-excursion | |
7720 (while (progn (backward-char 1) | |
7721 (looking-at "[ \t\n\f]"))) | |
7722 (when (looking-at ",") | |
7723 (delete-region (+ 1 (point)) rtn-pt)))) | |
7724 (when (bolp) | |
7725 (indent-to indent)) | |
7726 (insert ");\n") | |
7727 ;; Still need to kill final comma - always is one as we put one after the .* | |
7728 (re-search-backward ",") | |
7729 (delete-char 1)))))) | |
7730 | |
7731 (defun verilog-delete-auto () | |
7732 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto]. | |
7733 Use \\[verilog-auto] to re-insert the updated AUTOs. | |
7734 | |
7735 The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are | |
7736 called before and after this function, respectively." | |
7737 (interactive) | |
7738 (save-excursion | |
7739 (if (buffer-file-name) | |
7740 (find-file-noselect (buffer-file-name))) ;; To check we have latest version | |
7741 ;; Allow user to customize | |
7742 (run-hooks 'verilog-before-delete-auto-hook) | |
7743 | |
93195 | 7744 ;; Remove those that have multi-line insertions, possibly with parameters |
7745 (verilog-auto-re-search-do | |
7746 (concat "/\\*" | |
7747 (eval-when-compile | |
7748 (verilog-regexp-words | |
7749 `("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE" | |
7750 "AUTOINOUT" "AUTOINOUTMODULE" "AUTOINPUT" "AUTOOUTPUT" | |
7751 "AUTOOUTPUTEVERY" | |
7752 "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF" | |
7753 "AUTOUNUSED" "AUTOWIRE"))) | |
7754 "\\(\\|([^)]*)\\|(\"[^\"]*\")\\)" ; Optional parens or quoted parameter | |
7755 "\\*/") | |
7756 'verilog-delete-autos-lined) | |
79545 | 7757 ;; Remove those that are in parenthesis |
93195 | 7758 (verilog-auto-re-search-do |
7759 (concat "/\\*" | |
7760 (eval-when-compile | |
7761 (verilog-regexp-words | |
7762 `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM" | |
7763 "AUTOSENSE"))) | |
7764 "\\*/") | |
7765 'verilog-delete-to-paren) | |
79545 | 7766 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments |
7767 (verilog-auto-re-search-do "\\.\\*" | |
7768 'verilog-delete-auto-star-all) | |
7769 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed | |
7770 (goto-char (point-min)) | |
7771 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t) | |
7772 (replace-match "")) | |
7773 | |
7774 ;; Final customize | |
7775 (run-hooks 'verilog-delete-auto-hook))) | |
7776 | |
7777 ;; | |
7778 ;; Auto inject | |
7779 ;; | |
7780 | |
7781 (defun verilog-inject-auto () | |
7782 "Examine legacy non-AUTO code and insert AUTOs in appropriate places. | |
7783 | |
7784 Any always @ blocks with sensitivity lists that match computed lists will | |
7785 be replaced with /*AS*/ comments. | |
7786 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7787 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
|
7788 Pins with have identical names will be deleted. |
79545 | 7789 |
7790 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to | |
7791 support adding new ports. You may wish to delete older ports yourself. | |
7792 | |
7793 For example: | |
7794 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7795 module ExampInject (i, o); |
79545 | 7796 input i; |
7797 input j; | |
7798 output o; | |
7799 always @ (i or j) | |
7800 o = i | j; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7801 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7802 (.foobar(baz), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7803 j(j)); |
79545 | 7804 endmodule |
7805 | |
7806 Typing \\[verilog-inject-auto] will make this into: | |
7807 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7808 module ExampInject (i, o/*AUTOARG*/ |
79545 | 7809 // Inputs |
7810 j); | |
7811 input i; | |
7812 output o; | |
7813 always @ (/*AS*/i or j) | |
7814 o = i | j; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7815 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7816 (.foobar(baz), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7817 /*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7818 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7819 j(j)); |
79545 | 7820 endmodule" |
7821 (interactive) | |
7822 (verilog-auto t)) | |
7823 | |
7824 (defun verilog-inject-arg () | |
7825 "Inject AUTOARG into new code. See `verilog-inject-auto'." | |
7826 ;; Presume one module per file. | |
7827 (save-excursion | |
7828 (goto-char (point-min)) | |
7829 (while (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
7830 (let ((endmodp (save-excursion | |
7831 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t) | |
7832 (point)))) | |
7833 ;; See if there's already a comment .. inside a comment so not verilog-re-search | |
7834 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t)) | |
7835 (verilog-re-search-forward-quick ";" nil t) | |
7836 (backward-char 1) | |
7837 (verilog-backward-syntactic-ws) | |
7838 (backward-char 1) ; Moves to paren that closes argdecl's | |
7839 (when (looking-at ")") | |
7840 (insert "/*AUTOARG*/"))))))) | |
7841 | |
7842 (defun verilog-inject-sense () | |
7843 "Inject AUTOSENSE into new code. See `verilog-inject-auto'." | |
7844 (save-excursion | |
7845 (goto-char (point-min)) | |
7846 (while (verilog-re-search-forward-quick "\\<always\\s *@\\s *(" nil t) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7847 (let* ((start-pt (point)) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7848 (modi (verilog-modi-current)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7849 (moddecls (verilog-modi-get-decls modi)) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7850 pre-sigs |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
7851 got-sigs) |
79545 | 7852 (backward-char 1) |
7853 (forward-sexp 1) | |
7854 (backward-char 1) ;; End ) | |
7855 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) | |
7856 (setq pre-sigs (verilog-signals-from-signame | |
7857 (verilog-read-signals start-pt (point))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7858 got-sigs (verilog-auto-sense-sigs moddecls nil)) |
79545 | 7859 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal? |
7860 (verilog-signals-not-in got-sigs pre-sigs))) | |
7861 (delete-region start-pt (point)) | |
7862 (insert "/*AS*/"))))))) | |
7863 | |
7864 (defun verilog-inject-inst () | |
7865 "Inject AUTOINST into new code. See `verilog-inject-auto'." | |
7866 (save-excursion | |
7867 (goto-char (point-min)) | |
7868 ;; It's hard to distinguish modules; we'll instead search for pins. | |
7869 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) | |
7870 (verilog-backward-open-paren) ;; Inst start | |
7871 (cond | |
7872 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip. | |
7873 (forward-char 1) | |
7874 (verilog-forward-close-paren)) ;; Parameters done | |
7875 (t | |
7876 (forward-char 1) | |
7877 (let ((indent-pt (+ (current-column))) | |
7878 (end-pt (save-excursion (verilog-forward-close-paren) (point)))) | |
7879 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) | |
7880 (goto-char end-pt)) ;; Already there, continue search with next instance | |
7881 (t | |
7882 ;; Delete identical interconnect | |
7883 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc | |
7884 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) | |
7885 (delete-region (match-beginning 0) (match-end 0)) | |
7886 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct | |
7887 (while (or (looking-at "[ \t\n\f,]+") | |
7888 (looking-at "//[^\n]*")) | |
7889 (delete-region (match-beginning 0) (match-end 0)) | |
7890 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0))))))) | |
7891 (verilog-forward-close-paren) | |
7892 (backward-char 1) | |
7893 ;; Not verilog-re-search, as we don't want to strip comments | |
7894 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t) | |
7895 (delete-region (match-beginning 0) (match-end 0))) | |
7896 (insert "\n") | |
7897 (indent-to indent-pt) | |
7898 (insert "/*AUTOINST*/"))))))))) | |
7899 | |
7900 ;; | |
7901 ;; Auto save | |
7902 ;; | |
7903 | |
7904 (defun verilog-auto-save-check () | |
7905 "On saving see if we need auto update." | |
7906 (cond ((not verilog-auto-save-policy)) ; disabled | |
7907 ((not (save-excursion | |
7908 (save-match-data | |
7909 (let ((case-fold-search nil)) | |
7910 (goto-char (point-min)) | |
7911 (re-search-forward "AUTO" nil t)))))) | |
7912 ((eq verilog-auto-save-policy 'force) | |
7913 (verilog-auto)) | |
7914 ((not (buffer-modified-p))) | |
7915 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date | |
7916 ((eq verilog-auto-save-policy 'detect) | |
7917 (verilog-auto)) | |
7918 (t | |
7919 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | |
7920 (verilog-auto)) | |
7921 ;; Don't ask again if didn't update | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7922 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
79545 | 7923 (when (not verilog-auto-star-save) |
7924 (verilog-delete-auto-star-implicit)) | |
7925 nil) ;; Always return nil -- we don't write the file ourselves | |
7926 | |
7927 (defun verilog-auto-read-locals () | |
7928 "Return file local variable segment at bottom of file." | |
7929 (save-excursion | |
7930 (goto-char (point-max)) | |
7931 (if (re-search-backward "Local Variables:" nil t) | |
7932 (buffer-substring-no-properties (point) (point-max)) | |
7933 ""))) | |
7934 | |
7935 (defun verilog-auto-reeval-locals (&optional force) | |
7936 "Read file local variable segment at bottom of file if it has changed. | |
7937 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
|
7938 (make-local-variable 'verilog-auto-last-file-locals) |
79545 | 7939 (let ((curlocal (verilog-auto-read-locals))) |
7940 (when (or force (not (equal verilog-auto-last-file-locals curlocal))) | |
7941 (setq verilog-auto-last-file-locals curlocal) | |
7942 ;; Note this may cause this function to be recursively invoked. | |
7943 ;; The above when statement will prevent it from recursing forever. | |
7944 (hack-local-variables) | |
7945 t))) | |
7946 | |
7947 ;; | |
7948 ;; Auto creation | |
7949 ;; | |
7950 | |
7951 (defun verilog-auto-arg-ports (sigs message indent-pt) | |
7952 "Print a list of ports for a AUTOINST. | |
7953 Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT." | |
7954 (when sigs | |
7955 (insert "\n") | |
7956 (indent-to indent-pt) | |
7957 (insert message) | |
7958 (insert "\n") | |
7959 (let ((space "")) | |
7960 (indent-to indent-pt) | |
7961 (while sigs | |
7962 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column) | |
7963 (insert "\n") | |
7964 (indent-to indent-pt)) | |
7965 (t (insert space))) | |
7966 (insert (verilog-sig-name (car sigs)) ",") | |
7967 (setq sigs (cdr sigs) | |
7968 space " "))))) | |
7969 | |
7970 (defun verilog-auto-arg () | |
7971 "Expand AUTOARG statements. | |
7972 Replace the argument declarations at the beginning of the | |
7973 module with ones automatically derived from input and output | |
7974 statements. This can be dangerous if the module is instantiated | |
7975 using position-based connections, so use only name-based when | |
7976 instantiating the resulting module. Long lines are split based | |
7977 on the `fill-column', see \\[set-fill-column]. | |
7978 | |
7979 Limitations: | |
7980 Concatenation and outputting partial busses is not supported. | |
7981 | |
7982 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
7983 | |
7984 For example: | |
7985 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7986 module ExampArg (/*AUTOARG*/); |
79545 | 7987 input i; |
7988 output o; | |
7989 endmodule | |
7990 | |
7991 Typing \\[verilog-auto] will make this into: | |
7992 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
7993 module ExampArg (/*AUTOARG*/ |
79545 | 7994 // Outputs |
7995 o, | |
7996 // Inputs | |
7997 i | |
7998 ); | |
7999 input i; | |
8000 output o; | |
8001 endmodule | |
8002 | |
8003 Any ports declared between the ( and /*AUTOARG*/ are presumed to be | |
8004 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
|
8005 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
|
8006 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
|
8007 to choose the comma yourself. |
79545 | 8008 |
8009 Avoid declaring ports manually, as it makes code harder to maintain." | |
8010 (save-excursion | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8011 (let* ((modi (verilog-modi-current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8012 (moddecls (verilog-modi-get-decls modi)) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8013 (skip-pins (aref (verilog-read-arg-pins) 0))) |
79545 | 8014 (verilog-repair-open-comma) |
8015 (verilog-auto-arg-ports (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8016 (verilog-decls-get-outputs moddecls) |
79545 | 8017 skip-pins) |
8018 "// Outputs" | |
8019 verilog-indent-level-declaration) | |
8020 (verilog-auto-arg-ports (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8021 (verilog-decls-get-inouts moddecls) |
79545 | 8022 skip-pins) |
8023 "// Inouts" | |
8024 verilog-indent-level-declaration) | |
8025 (verilog-auto-arg-ports (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8026 (verilog-decls-get-inputs moddecls) |
79545 | 8027 skip-pins) |
8028 "// Inputs" | |
8029 verilog-indent-level-declaration) | |
8030 (verilog-repair-close-comma) | |
8031 (unless (eq (char-before) ?/ ) | |
8032 (insert "\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8033 (indent-to verilog-indent-level-declaration)))) |
79545 | 8034 |
8035 (defun verilog-auto-inst-port-map (port-st) | |
8036 nil) | |
8037 | |
8038 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8039 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8040 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8041 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8042 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8043 | |
8044 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star) | |
8045 "Print out a instantiation connection for this PORT-ST. | |
8046 Insert to INDENT-PT, use template TPL-LIST. | |
8047 @ are instantiation numbers, replaced with TPL-NUM. | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8048 @\"(expression @)\" are evaluated, with @ as a variable. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8049 If FOR-STAR add comment it is a .* expansion." |
79545 | 8050 (let* ((port (verilog-sig-name port-st)) |
8051 (tpl-ass (or (assoc port (car tpl-list)) | |
8052 (verilog-auto-inst-port-map port-st))) | |
8053 ;; vl-* are documented for user use | |
8054 (vl-name (verilog-sig-name port-st)) | |
8055 (vl-width (verilog-sig-width port-st)) | |
8056 (vl-bits (if (or verilog-auto-inst-vector | |
8057 (not (assoc port vector-skip-list)) | |
8058 (not (equal (verilog-sig-bits port-st) | |
8059 (verilog-sig-bits (assoc port vector-skip-list))))) | |
8060 (or (verilog-sig-bits port-st) "") | |
8061 "")) | |
8062 ;; Default if not found | |
8063 (tpl-net (if (verilog-sig-multidim port-st) | |
8064 (concat port "/*" (verilog-sig-multidim-string port-st) | |
8065 vl-bits "*/") | |
8066 (concat port vl-bits))) | |
8067 (case-fold-search nil)) | |
8068 ;; Find template | |
8069 (cond (tpl-ass ; Template of exact port name | |
8070 (setq tpl-net (nth 1 tpl-ass))) | |
8071 ((nth 1 tpl-list) ; Wildcards in template, search them | |
8072 (let ((wildcards (nth 1 tpl-list))) | |
8073 (while wildcards | |
8074 (when (string-match (nth 0 (car wildcards)) port) | |
8075 (setq tpl-ass (car wildcards) ; so allow @ parsing | |
8076 tpl-net (replace-match (nth 1 (car wildcards)) | |
8077 t nil port))) | |
8078 (setq wildcards (cdr wildcards)))))) | |
8079 ;; Parse Templated variable | |
8080 (when tpl-ass | |
8081 ;; Evaluate @"(lispcode)" | |
8082 (when (string-match "@\".*[^\\]\"" tpl-net) | |
8083 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net) | |
8084 (setq tpl-net | |
8085 (concat | |
8086 (substring tpl-net 0 (match-beginning 0)) | |
8087 (save-match-data | |
8088 (let* ((expr (match-string 1 tpl-net)) | |
8089 (value | |
8090 (progn | |
8091 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | |
8092 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | |
8093 (prin1 (eval (car (read-from-string expr))) | |
8094 (lambda (ch) ()))))) | |
8095 (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
|
8096 value)) |
79545 | 8097 (substring tpl-net (match-end 0)))))) |
8098 ;; Replace @ and [] magic variables in final output | |
8099 (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
|
8100 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
79545 | 8101 (indent-to indent-pt) |
8102 (insert "." port) | |
8103 (indent-to verilog-auto-inst-column) | |
8104 (insert "(" tpl-net "),") | |
8105 (cond (tpl-ass | |
8106 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
8107 verilog-auto-inst-column)) | |
8108 (insert " // Templated") | |
8109 (when verilog-auto-inst-template-numbers | |
8110 (insert " T" (int-to-string (nth 2 tpl-ass)) | |
8111 " L" (int-to-string (nth 3 tpl-ass))))) | |
8112 (for-star | |
8113 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
8114 verilog-auto-inst-column)) | |
8115 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped... | |
8116 (insert "\n"))) | |
8117 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") | |
8118 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]") | |
8119 ;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));") | |
8120 | |
8121 (defun verilog-auto-inst-first () | |
8122 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]." | |
8123 ;; Do we need a trailing comma? | |
8124 ;; There maybe a ifdef or something similar before us. What a mess. Thus | |
8125 ;; to avoid trouble we only insert on preceeding ) or *. | |
8126 ;; Insert first port on new line | |
8127 (insert "\n") ;; Must insert before search, so point will move forward if insert comma | |
8128 (save-excursion | |
8129 (verilog-re-search-backward "[^ \t\n\f]" nil nil) | |
8130 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure | |
8131 (forward-char 1) | |
8132 (insert ",")))) | |
8133 | |
8134 (defun verilog-auto-star () | |
8135 "Expand SystemVerilog .* pins, as part of \\[verilog-auto]. | |
8136 | |
8137 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
|
8138 AUTOINST statements, otherwise they are ignored. For safety, Verilog mode |
79545 | 8139 will also ignore any .* that are not last in your pin list (this prevents |
8140 it from deleting pins following the .* when it expands the AUTOINST.) | |
8141 | |
8142 On writing your file, unless `verilog-auto-star-save' is set, any | |
8143 non-templated expanded pins will be removed. You may do this at any time | |
8144 with \\[verilog-delete-auto-star-implicit]. | |
8145 | |
8146 If you are converting a module to use .* for the first time, you may wish | |
8147 to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*. | |
8148 | |
8149 See `verilog-auto-inst' for examples, templates, and more information." | |
8150 (when (verilog-auto-star-safe) | |
8151 (verilog-auto-inst))) | |
8152 | |
8153 (defun verilog-auto-inst () | |
8154 "Expand AUTOINST statements, as part of \\[verilog-auto]. | |
8155 Replace the pin connections to an instantiation with ones | |
8156 automatically derived from the module header of the instantiated netlist. | |
8157 | |
8158 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports, | |
8159 and delete them before saving unless `verilog-auto-star-save' is set. | |
8160 See `verilog-auto-star' for more information. | |
8161 | |
8162 Limitations: | |
8163 Module names must be resolvable to filenames by adding a | |
8164 `verilog-library-extensions', and being found in the same directory, or | |
8165 by changing the variable `verilog-library-flags' or | |
8166 `verilog-library-directories'. Macros `modname are translated through the | |
8167 vh-{name} Emacs variable, if that is not found, it just ignores the `. | |
8168 | |
8169 In templates you must have one signal per line, ending in a ), or ));, | |
8170 and have proper () nesting, including a final ); to end the template. | |
8171 | |
8172 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8173 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8174 SystemVerilog multidimensional input/output has only experimental support. |
79545 | 8175 |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8176 For example, first take the submodule InstModule.v: |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8177 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8178 module InstModule (o,i) |
79545 | 8179 output [31:0] o; |
8180 input i; | |
8181 wire [31:0] o = {32{i}}; | |
8182 endmodule | |
8183 | |
8184 This is then used in a upper level module: | |
8185 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8186 module ExampInst (o,i) |
79545 | 8187 output o; |
8188 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8189 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8190 (/*AUTOINST*/); |
79545 | 8191 endmodule |
8192 | |
8193 Typing \\[verilog-auto] will make this into: | |
8194 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8195 module ExampInst (o,i) |
79545 | 8196 output o; |
8197 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8198 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8199 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8200 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8201 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8202 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8203 .i (i)); |
79545 | 8204 endmodule |
8205 | |
8206 Where the list of inputs and outputs came from the inst module. | |
8207 | |
8208 Exceptions: | |
8209 | |
8210 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
|
8211 something trivial like an adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY. |
79545 | 8212 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
|
8213 vrename from http://www.veripool.com. |
79545 | 8214 |
8215 When you need to violate this suggestion there are two ways to list | |
8216 exceptions, placing them before the AUTOINST, or using templates. | |
8217 | |
8218 Any ports defined before the /*AUTOINST*/ are not included in the list of | |
8219 automatics. This is similar to making a template as described below, but | |
8220 is restricted to simple connections just like you normally make. Also note | |
8221 that any signals before the AUTOINST will only be picked up by AUTOWIRE if | |
8222 you have the appropriate // Input or // Output comment, and exactly the | |
8223 same line formatting as AUTOINST itself uses. | |
8224 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8225 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8226 (// Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8227 .i (my_i_dont_mess_with_it), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8228 /*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8229 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8230 .ov (ov[31:0])); |
79545 | 8231 |
8232 | |
8233 Templates: | |
8234 | |
8235 For multiple instantiations based upon a single template, create a | |
8236 commented out template: | |
8237 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8238 /* InstModule AUTO_TEMPLATE ( |
79545 | 8239 .sig3 (sigz[]), |
8240 ); | |
8241 */ | |
8242 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8243 Templates go ABOVE the instantiation(s). When an instantiation is |
79545 | 8244 expanded `verilog-mode' simply searches up for the closest template. |
8245 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
|
8246 between the template for an instantiation and the instantiation itself. |
79545 | 8247 |
8248 The module name must be the same as the name of the module in the | |
8249 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact | |
8250 words and capitalized. Only signals that must be different for each | |
8251 instantiation need to be listed. | |
8252 | |
8253 Inside a template, a [] in a connection name (with nothing else inside | |
8254 the brackets) will be replaced by the same bus subscript as it is being | |
8255 connected to, or the [] will be removed if it is a single bit signal. | |
8256 Generally it is a good idea to do this for all connections in a template, | |
8257 as then they will work for any width signal, and with AUTOWIRE. See | |
8258 PTL_BUS becoming PTL_BUSNEW below. | |
8259 | |
8260 If you have a complicated template, set `verilog-auto-inst-template-numbers' | |
8261 to see which regexps are matching. Don't leave that mode set after | |
8262 debugging is completed though, it will result in lots of extra differences | |
8263 and merge conflicts. | |
8264 | |
8265 For example: | |
8266 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8267 /* InstModule AUTO_TEMPLATE ( |
79545 | 8268 .ptl_bus (ptl_busnew[]), |
8269 ); | |
8270 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8271 InstModule ms2m (/*AUTOINST*/); |
79545 | 8272 |
8273 Typing \\[verilog-auto] will make this into: | |
8274 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8275 InstModule ms2m (/*AUTOINST*/ |
79545 | 8276 // Outputs |
8277 .NotInTemplate (NotInTemplate), | |
8278 .ptl_bus (ptl_busnew[3:0]), // Templated | |
8279 .... | |
8280 | |
8281 @ Templates: | |
8282 | |
8283 It is common to instantiate a cell multiple times, so templates make it | |
8284 trivial to substitute part of the cell name into the connection name. | |
8285 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8286 /* InstName AUTO_TEMPLATE <optional \"REGEXP\"> ( |
79545 | 8287 .sig1 (sigx[@]), |
8288 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), | |
8289 ); | |
8290 */ | |
8291 | |
8292 If no regular expression is provided immediately after the AUTO_TEMPLATE | |
8293 keyword, then the @ character in any connection names will be replaced | |
8294 with the instantiation number; the first digits found in the cell's | |
8295 instantiation name. | |
8296 | |
8297 If a regular expression is provided, the @ character will be replaced | |
8298 with the first \(\) grouping that matches against the cell name. Using a | |
8299 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no | |
8300 regexp is provided. If you use multiple layers of parenthesis, | |
8301 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number | |
8302 characters after test and before _, whereas | |
8303 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire | |
8304 match. | |
8305 | |
8306 For example: | |
8307 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8308 /* InstModule AUTO_TEMPLATE ( |
79545 | 8309 .ptl_mapvalidx (ptl_mapvalid[@]), |
8310 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), | |
8311 ); | |
8312 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8313 InstModule ms2m (/*AUTOINST*/); |
79545 | 8314 |
8315 Typing \\[verilog-auto] will make this into: | |
8316 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8317 InstModule ms2m (/*AUTOINST*/ |
79545 | 8318 // Outputs |
8319 .ptl_mapvalidx (ptl_mapvalid[2]), | |
8320 .ptl_mapvalidp1x (ptl_mapvalid[3])); | |
8321 | |
8322 Note the @ character was replaced with the 2 from \"ms2m\". | |
8323 | |
8324 Alternatively, using a regular expression for @: | |
8325 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8326 /* InstModule AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( |
79545 | 8327 .ptl_mapvalidx (@_ptl_mapvalid), |
8328 .ptl_mapvalidp1x (ptl_mapvalid_@), | |
8329 ); | |
8330 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8331 InstModule ms2_FOO (/*AUTOINST*/); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8332 InstModule ms2_BAR (/*AUTOINST*/); |
79545 | 8333 |
8334 Typing \\[verilog-auto] will make this into: | |
8335 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8336 InstModule ms2_FOO (/*AUTOINST*/ |
79545 | 8337 // Outputs |
8338 .ptl_mapvalidx (FOO_ptl_mapvalid), | |
8339 .ptl_mapvalidp1x (ptl_mapvalid_FOO)); | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8340 InstModule ms2_BAR (/*AUTOINST*/ |
79545 | 8341 // Outputs |
8342 .ptl_mapvalidx (BAR_ptl_mapvalid), | |
8343 .ptl_mapvalidp1x (ptl_mapvalid_BAR)); | |
8344 | |
8345 | |
8346 Regexp Templates: | |
8347 | |
8348 A template entry of the form | |
8349 | |
8350 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]), | |
8351 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8352 will apply an Emacs style regular expression search for any port beginning |
79545 | 8353 in pci_req followed by numbers and ending in _l and connecting that to |
8354 the pci_req_jtag_[] net, with the bus subscript coming from what matches | |
8355 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2]. | |
8356 | |
8357 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name | |
8358 does the same thing. (Note a @ in the connection/replacement text is | |
8359 completely different -- still use \\1 there!) Thus this is the same as | |
8360 the above template: | |
8361 | |
8362 .pci_req@_l (pci_req_jtag_[\\1]), | |
8363 | |
8364 Here's another example to remove the _l, useful when naming conventions | |
8365 specify _ alone to mean active low. Note the use of [] to keep the bus | |
8366 subscript: | |
8367 | |
8368 .\\(.*\\)_l (\\1_[]), | |
8369 | |
8370 Lisp Templates: | |
8371 | |
8372 First any regular expression template is expanded. | |
8373 | |
8374 If the syntax @\"( ... )\" is found in a connection, the expression in | |
8375 quotes will be evaluated as a Lisp expression, with @ replaced by the | |
8376 instantiation number. The MAPVALIDP1X example above would put @+1 modulo | |
8377 4 into the brackets. Quote all double-quotes inside the expression with | |
8378 a leading backslash (\\\"). There are special variables defined that are | |
8379 useful in these Lisp functions: | |
8380 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8381 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
|
8382 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
|
8383 vl-width Width of the input/output port ('3' for [2:0]). |
79545 | 8384 May be a (...) expression if bits isn't a constant. |
8385 vl-dir Direction of the pin input/output/inout. | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8386 vl-cell-type Module name/type of the cell ('InstModule'). |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8387 vl-cell-name Instance name of the cell ('instName'). |
79545 | 8388 |
8389 Normal Lisp variables may be used in expressions. See | |
8390 `verilog-read-defines' which can set vh-{definename} variables for use | |
8391 here. Also, any comments of the form: | |
8392 | |
8393 /*AUTO_LISP(setq foo 1)*/ | |
8394 | |
8395 will evaluate any Lisp expression inside the parenthesis between the | |
8396 beginning of the buffer and the point of the AUTOINST. This allows | |
8397 functions to be defined or variables to be changed between instantiations. | |
8398 | |
8399 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
|
8400 number; you may need to use the standard Emacs Lisp functions |
79545 | 8401 `number-to-string' and `string-to-number'. |
8402 | |
8403 After the evaluation is completed, @ substitution and [] substitution | |
8404 occur." | |
8405 (save-excursion | |
8406 ;; Find beginning | |
8407 (let* ((pt (point)) | |
8408 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*"))) | |
8409 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8410 (1+ (current-column)))) | |
8411 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8412 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8413 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8414 (moddecls (verilog-modi-get-decls modi)) |
79545 | 8415 (vector-skip-list (unless verilog-auto-inst-vector |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8416 (verilog-decls-get-signals moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8417 submod submodi submoddecls |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8418 inst skip-pins tpl-list tpl-num did-first) |
79545 | 8419 ;; Find module name that is instantiated |
8420 (setq submod (verilog-read-inst-module) | |
8421 inst (verilog-read-inst-name) | |
8422 vl-cell-type submod | |
8423 vl-cell-name inst | |
8424 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8425 | |
8426 ;; Parse any AUTO_LISP() before here | |
8427 (verilog-read-auto-lisp (point-min) pt) | |
8428 | |
8429 ;; Lookup position, etc of submodule | |
8430 ;; Note this may raise an error | |
8431 (when (setq submodi (verilog-modi-lookup submod t)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8432 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 8433 ;; If there's a number in the instantiation, it may be a argument to the |
8434 ;; automatic variable instantiation program. | |
8435 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8436 (tpl-regexp (aref tpl-info 0))) | |
8437 (setq tpl-num (if (string-match tpl-regexp inst) | |
8438 (match-string 1 inst) | |
8439 "") | |
8440 tpl-list (aref tpl-info 1))) | |
8441 ;; Find submodule's signals and dump | |
8442 (let ((sig-list (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8443 (verilog-decls-get-outputs submoddecls) |
79545 | 8444 skip-pins)) |
8445 (vl-dir "output")) | |
8446 (when sig-list | |
8447 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8448 (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
|
8449 ;; 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
|
8450 (insert "// Outputs\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8451 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8452 (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
|
8453 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
|
8454 sig-list))) |
79545 | 8455 (let ((sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8456 (verilog-decls-get-inouts submoddecls) |
79545 | 8457 skip-pins)) |
8458 (vl-dir "inout")) | |
8459 (when sig-list | |
8460 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8461 (indent-to indent-pt) | |
8462 (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
|
8463 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8464 (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
|
8465 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
|
8466 sig-list))) |
79545 | 8467 (let ((sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8468 (verilog-decls-get-inputs submoddecls) |
79545 | 8469 skip-pins)) |
8470 (vl-dir "input")) | |
8471 (when sig-list | |
8472 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8473 (indent-to indent-pt) | |
8474 (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
|
8475 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8476 (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
|
8477 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
|
8478 sig-list))) |
79545 | 8479 ;; Kill extra semi |
8480 (save-excursion | |
8481 (cond (did-first | |
8482 (re-search-backward "," pt t) | |
8483 (delete-char 1) | |
8484 (insert ");") | |
8485 (search-forward "\n") ;; Added by inst-port | |
8486 (delete-backward-char 1) | |
8487 (if (search-forward ")" nil t) ;; From user, moved up a line | |
8488 (delete-backward-char 1)) | |
8489 (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
|
8490 (delete-backward-char 1))))))))) |
79545 | 8491 |
8492 (defun verilog-auto-inst-param () | |
8493 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | |
8494 Replace the parameter connections to an instantiation with ones | |
8495 automatically derived from the module header of the instantiated netlist. | |
8496 | |
8497 See \\[verilog-auto-inst] for limitations, and templates to customize the | |
8498 output. | |
8499 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8500 For example, first take the submodule InstModule.v: |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8501 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8502 module InstModule (o,i) |
79545 | 8503 parameter PAR; |
8504 endmodule | |
8505 | |
8506 This is then used in a upper level module: | |
8507 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8508 module ExampInst (o,i) |
79545 | 8509 parameter PAR; |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8510 InstModule #(/*AUTOINSTPARAM*/) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8511 instName (/*AUTOINST*/); |
79545 | 8512 endmodule |
8513 | |
8514 Typing \\[verilog-auto] will make this into: | |
8515 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8516 module ExampInst (o,i) |
79545 | 8517 output o; |
8518 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8519 InstModule #(/*AUTOINSTPARAM*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8520 // Parameters |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8521 .PAR (PAR)); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8522 instName (/*AUTOINST*/); |
79545 | 8523 endmodule |
8524 | |
8525 Where the list of parameter connections come from the inst module. | |
8526 | |
8527 Templates: | |
8528 | |
8529 You can customize the parameter connections using AUTO_TEMPLATEs, | |
8530 just as you would with \\[verilog-auto-inst]." | |
8531 (save-excursion | |
8532 ;; Find beginning | |
8533 (let* ((pt (point)) | |
8534 (indent-pt (save-excursion (verilog-backward-open-paren) | |
8535 (1+ (current-column)))) | |
8536 (verilog-auto-inst-column (max verilog-auto-inst-column | |
8537 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
8538 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8539 (moddecls (verilog-modi-get-decls modi)) |
79545 | 8540 (vector-skip-list (unless verilog-auto-inst-vector |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8541 (verilog-decls-get-signals moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8542 submod submodi submoddecls |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8543 inst skip-pins tpl-list tpl-num did-first) |
79545 | 8544 ;; Find module name that is instantiated |
8545 (setq submod (save-excursion | |
8546 ;; Get to the point where AUTOINST normally is to read the module | |
8547 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8548 (verilog-read-inst-module)) | |
8549 inst (save-excursion | |
8550 ;; Get to the point where AUTOINST normally is to read the module | |
8551 (verilog-re-search-forward-quick "[(;]" nil nil) | |
8552 (verilog-read-inst-name)) | |
8553 vl-cell-type submod | |
8554 vl-cell-name inst | |
8555 skip-pins (aref (verilog-read-inst-pins) 0)) | |
8556 | |
8557 ;; Parse any AUTO_LISP() before here | |
8558 (verilog-read-auto-lisp (point-min) pt) | |
8559 | |
8560 ;; Lookup position, etc of submodule | |
8561 ;; Note this may raise an error | |
8562 (when (setq submodi (verilog-modi-lookup submod t)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8563 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 8564 ;; If there's a number in the instantiation, it may be a argument to the |
8565 ;; automatic variable instantiation program. | |
8566 (let* ((tpl-info (verilog-read-auto-template submod)) | |
8567 (tpl-regexp (aref tpl-info 0))) | |
8568 (setq tpl-num (if (string-match tpl-regexp inst) | |
8569 (match-string 1 inst) | |
8570 "") | |
8571 tpl-list (aref tpl-info 1))) | |
8572 ;; Find submodule's signals and dump | |
8573 (let ((sig-list (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8574 (verilog-decls-get-gparams submoddecls) |
79545 | 8575 skip-pins)) |
8576 (vl-dir "parameter")) | |
8577 (when sig-list | |
8578 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
8579 (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
|
8580 ;; 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
|
8581 (insert "// Parameters\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8582 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8583 (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
|
8584 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
|
8585 sig-list))) |
79545 | 8586 ;; Kill extra semi |
8587 (save-excursion | |
8588 (cond (did-first | |
8589 (re-search-backward "," pt t) | |
8590 (delete-char 1) | |
8591 (insert ")") | |
8592 (search-forward "\n") ;; Added by inst-port | |
8593 (delete-backward-char 1) | |
8594 (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
|
8595 (delete-backward-char 1))))))))) |
79545 | 8596 |
8597 (defun verilog-auto-reg () | |
8598 "Expand AUTOREG statements, as part of \\[verilog-auto]. | |
8599 Make reg statements for any output that isn't already declared, | |
8600 and isn't a wire output from a block. | |
8601 | |
8602 Limitations: | |
8603 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8604 | |
8605 This does NOT work on memories, declare those yourself. | |
8606 | |
8607 An example: | |
8608 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8609 module ExampReg (o,i) |
79545 | 8610 output o; |
8611 input i; | |
8612 /*AUTOREG*/ | |
8613 always o = i; | |
8614 endmodule | |
8615 | |
8616 Typing \\[verilog-auto] will make this into: | |
8617 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8618 module ExampReg (o,i) |
79545 | 8619 output o; |
8620 input i; | |
8621 /*AUTOREG*/ | |
8622 // Beginning of automatic regs (for this module's undeclared outputs) | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8623 reg o; |
79545 | 8624 // End of automatics |
8625 always o = i; | |
8626 endmodule" | |
8627 (save-excursion | |
8628 ;; Point must be at insertion point. | |
8629 (let* ((indent-pt (current-indentation)) | |
8630 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8631 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8632 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 8633 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8634 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8635 (append (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8636 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8637 (verilog-decls-get-assigns moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8638 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8639 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8640 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8641 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 8642 (forward-line 1) |
8643 (when sig-list | |
8644 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | |
8645 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8646 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8647 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8648 |
8649 (defun verilog-auto-reg-input () | |
8650 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | |
8651 Make reg statements instantiation inputs that aren't already declared. | |
8652 This is useful for making a top level shell for testing the module that is | |
8653 to be instantiated. | |
8654 | |
8655 Limitations: | |
8656 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8657 | |
8658 This does NOT work on memories, declare those yourself. | |
8659 | |
8660 An example (see `verilog-auto-inst' for what else is going on here): | |
8661 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8662 module ExampRegInput (o,i) |
79545 | 8663 output o; |
8664 input i; | |
8665 /*AUTOREGINPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8666 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8667 (/*AUTOINST*/); |
79545 | 8668 endmodule |
8669 | |
8670 Typing \\[verilog-auto] will make this into: | |
8671 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8672 module ExampRegInput (o,i) |
79545 | 8673 output o; |
8674 input i; | |
8675 /*AUTOREGINPUT*/ | |
8676 // Beginning of automatic reg inputs (for undeclared ... | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8677 reg [31:0] iv; // From inst of inst.v |
79545 | 8678 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8679 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8680 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8681 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8682 .o (o[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8683 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8684 .iv (iv)); |
79545 | 8685 endmodule" |
8686 (save-excursion | |
8687 ;; Point must be at insertion point. | |
8688 (let* ((indent-pt (current-indentation)) | |
8689 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8690 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8691 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 8692 (sig-list (verilog-signals-combine-bus |
8693 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8694 (append (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8695 (verilog-subdecls-get-inouts modsubdecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8696 (verilog-decls-get-signals moddecls))))) |
79545 | 8697 (forward-line 1) |
8698 (when sig-list | |
8699 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | |
8700 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
8701 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8702 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 8703 |
8704 (defun verilog-auto-wire () | |
8705 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | |
8706 Make wire statements for instantiations outputs that aren't | |
8707 already declared. | |
8708 | |
8709 Limitations: | |
8710 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'), | |
8711 and all busses must have widths, such as those from AUTOINST, or using [] | |
8712 in AUTO_TEMPLATEs. | |
8713 | |
8714 This does NOT work on memories or SystemVerilog .name connections, | |
8715 declare those yourself. | |
8716 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8717 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
|
8718 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
|
8719 non-numeric or non-sequential bus subscripts. If Verilog mode |
79545 | 8720 mis-guessed, you'll have to declare them yourself. |
8721 | |
8722 An example (see `verilog-auto-inst' for what else is going on here): | |
8723 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8724 module ExampWire (o,i) |
79545 | 8725 output o; |
8726 input i; | |
8727 /*AUTOWIRE*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8728 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8729 (/*AUTOINST*/); |
79545 | 8730 endmodule |
8731 | |
8732 Typing \\[verilog-auto] will make this into: | |
8733 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8734 module ExampWire (o,i) |
79545 | 8735 output o; |
8736 input i; | |
8737 /*AUTOWIRE*/ | |
8738 // Beginning of automatic wires | |
8739 wire [31:0] ov; // From inst of inst.v | |
8740 // End of automatics | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8741 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8742 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8743 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8744 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8745 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8746 .i (i)); |
79545 | 8747 wire o = | ov; |
8748 endmodule" | |
8749 (save-excursion | |
8750 ;; Point must be at insertion point. | |
8751 (let* ((indent-pt (current-indentation)) | |
8752 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8753 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8754 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 8755 (sig-list (verilog-signals-combine-bus |
8756 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8757 (append (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8758 (verilog-subdecls-get-inouts modsubdecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8759 (verilog-decls-get-signals moddecls))))) |
79545 | 8760 (forward-line 1) |
8761 (when sig-list | |
8762 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | |
8763 (verilog-insert-definition sig-list "wire" indent-pt nil) | |
8764 (verilog-modi-cache-add-wires modi sig-list) | |
8765 (verilog-insert-indent "// End of automatics\n") | |
8766 (when nil ;; Too slow on huge modules, plus makes everyone's module change | |
8767 (beginning-of-line) | |
8768 (setq pnt (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
8769 (verilog-pretty-declarations quiet) |
79545 | 8770 (goto-char pnt) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8771 (verilog-pretty-expr "//")))))) |
79545 | 8772 |
93195 | 8773 (defun verilog-auto-output (&optional with-params) |
79545 | 8774 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. |
8775 Make output statements for any output signal from an /*AUTOINST*/ that | |
8776 isn't a input to another AUTOINST. This is useful for modules which | |
8777 only instantiate other modules. | |
8778 | |
8779 Limitations: | |
8780 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8781 | |
8782 If placed inside the parenthesis of a module declaration, it creates | |
8783 Verilog 2001 style, else uses Verilog 1995 style. | |
8784 | |
8785 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8786 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8787 | |
8788 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8789 | |
8790 Signals matching `verilog-auto-output-ignore-regexp' are not included. | |
8791 | |
8792 An example (see `verilog-auto-inst' for what else is going on here): | |
8793 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8794 module ExampOutput (ov,i) |
79545 | 8795 input i; |
8796 /*AUTOOUTPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8797 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8798 (/*AUTOINST*/); |
79545 | 8799 endmodule |
8800 | |
8801 Typing \\[verilog-auto] will make this into: | |
8802 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8803 module ExampOutput (ov,i) |
79545 | 8804 input i; |
8805 /*AUTOOUTPUT*/ | |
8806 // Beginning of automatic outputs (from unused autoinst outputs) | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8807 output [31:0] ov; // From inst of inst.v |
79545 | 8808 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8809 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8810 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8811 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8812 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8813 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8814 .i (i)); |
93195 | 8815 endmodule |
8816 | |
8817 You may also provide an optional regular expression, in which case only | |
8818 signals matching the regular expression will be included. For example the | |
8819 same expansion will result from only extracting outputs starting with ov: | |
8820 | |
8821 /*AUTOOUTPUT(\"^ov\")*/" | |
79545 | 8822 (save-excursion |
8823 ;; Point must be at insertion point. | |
8824 (let* ((indent-pt (current-indentation)) | |
93195 | 8825 (regexp (and with-params |
8826 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 8827 (v2k (verilog-in-paren)) |
8828 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8829 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8830 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 8831 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8832 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8833 (append (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8834 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8835 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8836 (verilog-subdecls-get-inouts modsubdecls))))) |
93195 | 8837 (when regexp |
8838 (setq sig-list (verilog-signals-matching-regexp | |
8839 sig-list regexp))) | |
79545 | 8840 (setq sig-list (verilog-signals-not-matching-regexp |
8841 sig-list verilog-auto-output-ignore-regexp)) | |
8842 (forward-line 1) | |
8843 (when v2k (verilog-repair-open-comma)) | |
8844 (when sig-list | |
8845 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | |
8846 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8847 (verilog-modi-cache-add-outputs modi sig-list) | |
8848 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8849 (when v2k (verilog-repair-close-comma))))) |
79545 | 8850 |
8851 (defun verilog-auto-output-every () | |
8852 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | |
8853 Make output statements for any signals that aren't primary inputs or | |
8854 outputs already. This makes every signal in the design a output. This is | |
8855 useful to get Synopsys to preserve every signal in the design, since it | |
8856 won't optimize away the outputs. | |
8857 | |
8858 An example: | |
8859 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8860 module ExampOutputEvery (o,i,tempa,tempb) |
79545 | 8861 output o; |
8862 input i; | |
8863 /*AUTOOUTPUTEVERY*/ | |
8864 wire tempa = i; | |
8865 wire tempb = tempa; | |
8866 wire o = tempb; | |
8867 endmodule | |
8868 | |
8869 Typing \\[verilog-auto] will make this into: | |
8870 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8871 module ExampOutputEvery (o,i,tempa,tempb) |
79545 | 8872 output o; |
8873 input i; | |
8874 /*AUTOOUTPUTEVERY*/ | |
8875 // Beginning of automatic outputs (every signal) | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8876 output tempb; |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8877 output tempa; |
79545 | 8878 // End of automatics |
8879 wire tempa = i; | |
8880 wire tempb = tempa; | |
8881 wire o = tempb; | |
8882 endmodule" | |
8883 (save-excursion | |
8884 ;;Point must be at insertion point | |
8885 (let* ((indent-pt (current-indentation)) | |
8886 (v2k (verilog-in-paren)) | |
8887 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8888 (moddecls (verilog-modi-get-decls modi)) |
79545 | 8889 (sig-list (verilog-signals-combine-bus |
8890 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8891 (verilog-decls-get-signals moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8892 (verilog-decls-get-ports moddecls))))) |
79545 | 8893 (forward-line 1) |
8894 (when v2k (verilog-repair-open-comma)) | |
8895 (when sig-list | |
8896 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | |
8897 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
8898 (verilog-modi-cache-add-outputs modi sig-list) | |
8899 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8900 (when v2k (verilog-repair-close-comma))))) |
79545 | 8901 |
93195 | 8902 (defun verilog-auto-input (&optional with-params) |
79545 | 8903 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. |
8904 Make input statements for any input signal into an /*AUTOINST*/ that | |
8905 isn't declared elsewhere inside the module. This is useful for modules which | |
8906 only instantiate other modules. | |
8907 | |
8908 Limitations: | |
8909 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8910 | |
8911 If placed inside the parenthesis of a module declaration, it creates | |
8912 Verilog 2001 style, else uses Verilog 1995 style. | |
8913 | |
8914 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8915 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8916 | |
8917 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8918 | |
8919 Signals matching `verilog-auto-input-ignore-regexp' are not included. | |
8920 | |
8921 An example (see `verilog-auto-inst' for what else is going on here): | |
8922 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8923 module ExampInput (ov,i) |
79545 | 8924 output [31:0] ov; |
8925 /*AUTOINPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8926 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8927 (/*AUTOINST*/); |
79545 | 8928 endmodule |
8929 | |
8930 Typing \\[verilog-auto] will make this into: | |
8931 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8932 module ExampInput (ov,i) |
79545 | 8933 output [31:0] ov; |
8934 /*AUTOINPUT*/ | |
8935 // Beginning of automatic inputs (from unused autoinst inputs) | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8936 input i; // From inst of inst.v |
79545 | 8937 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8938 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8939 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8940 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8941 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8942 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8943 .i (i)); |
93195 | 8944 endmodule |
8945 | |
8946 You may also provide an optional regular expression, in which case only | |
8947 signals matching the regular expression will be included. For example the | |
8948 same expansion will result from only extracting inputs starting with i: | |
8949 | |
8950 /*AUTOINPUT(\"^i\")*/" | |
79545 | 8951 (save-excursion |
8952 (let* ((indent-pt (current-indentation)) | |
93195 | 8953 (regexp (and with-params |
8954 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 8955 (v2k (verilog-in-paren)) |
8956 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8957 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8958 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 8959 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8960 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8961 (append (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8962 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8963 (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8964 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8965 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8966 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8967 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8968 (verilog-subdecls-get-inouts modsubdecls))))) |
93195 | 8969 (when regexp |
8970 (setq sig-list (verilog-signals-matching-regexp | |
8971 sig-list regexp))) | |
79545 | 8972 (setq sig-list (verilog-signals-not-matching-regexp |
8973 sig-list verilog-auto-input-ignore-regexp)) | |
8974 (forward-line 1) | |
8975 (when v2k (verilog-repair-open-comma)) | |
8976 (when sig-list | |
8977 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | |
8978 (verilog-insert-definition sig-list "input" indent-pt v2k) | |
8979 (verilog-modi-cache-add-inputs modi sig-list) | |
8980 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8981 (when v2k (verilog-repair-close-comma))))) |
79545 | 8982 |
93195 | 8983 (defun verilog-auto-inout (&optional with-params) |
79545 | 8984 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. |
8985 Make inout statements for any inout signal in an /*AUTOINST*/ that | |
8986 isn't declared elsewhere inside the module. | |
8987 | |
8988 Limitations: | |
8989 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
8990 | |
8991 If placed inside the parenthesis of a module declaration, it creates | |
8992 Verilog 2001 style, else uses Verilog 1995 style. | |
8993 | |
8994 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
8995 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
8996 | |
8997 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8998 | |
8999 Signals matching `verilog-auto-inout-ignore-regexp' are not included. | |
9000 | |
9001 An example (see `verilog-auto-inst' for what else is going on here): | |
9002 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9003 module ExampInout (ov,i) |
79545 | 9004 input i; |
9005 /*AUTOINOUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9006 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9007 (/*AUTOINST*/); |
79545 | 9008 endmodule |
9009 | |
9010 Typing \\[verilog-auto] will make this into: | |
9011 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9012 module ExampInout (ov,i) |
79545 | 9013 input i; |
9014 /*AUTOINOUT*/ | |
9015 // Beginning of automatic inouts (from unused autoinst inouts) | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9016 inout [31:0] ov; // From inst of inst.v |
79545 | 9017 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9018 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9019 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9020 // Inouts |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9021 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9022 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9023 .i (i)); |
93195 | 9024 endmodule |
9025 | |
9026 You may also provide an optional regular expression, in which case only | |
9027 signals matching the regular expression will be included. For example the | |
9028 same expansion will result from only extracting inouts starting with i: | |
9029 | |
9030 /*AUTOINOUT(\"^i\")*/" | |
79545 | 9031 (save-excursion |
9032 ;; Point must be at insertion point. | |
9033 (let* ((indent-pt (current-indentation)) | |
93195 | 9034 (regexp (and with-params |
9035 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 9036 (v2k (verilog-in-paren)) |
9037 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9038 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9039 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9040 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9041 (verilog-subdecls-get-inouts modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9042 (append (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9043 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9044 (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9045 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9046 (verilog-subdecls-get-outputs modsubdecls))))) |
93195 | 9047 (when regexp |
9048 (setq sig-list (verilog-signals-matching-regexp | |
9049 sig-list regexp))) | |
79545 | 9050 (setq sig-list (verilog-signals-not-matching-regexp |
9051 sig-list verilog-auto-inout-ignore-regexp)) | |
9052 (forward-line 1) | |
9053 (when v2k (verilog-repair-open-comma)) | |
9054 (when sig-list | |
9055 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | |
9056 (verilog-insert-definition sig-list "inout" indent-pt v2k) | |
9057 (verilog-modi-cache-add-inouts modi sig-list) | |
9058 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9059 (when v2k (verilog-repair-close-comma))))) |
79545 | 9060 |
9061 (defun verilog-auto-inout-module () | |
9062 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. | |
9063 Take input/output/inout statements from the specified module and insert | |
9064 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
|
9065 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
|
9066 Any I/O which are already defined in this module will not be redefined. |
79545 | 9067 |
9068 Limitations: | |
9069 If placed inside the parenthesis of a module declaration, it creates | |
9070 Verilog 2001 style, else uses Verilog 1995 style. | |
9071 | |
9072 Concatenation and outputting partial busses is not supported. | |
9073 | |
9074 Module names must be resolvable to filenames. See `verilog-auto-inst'. | |
9075 | |
9076 Signals are not inserted in the same order as in the original module, | |
9077 though they will appear to be in the same order to a AUTOINST | |
9078 instantiating either module. | |
9079 | |
9080 An example: | |
9081 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9082 module ExampShell (/*AUTOARG*/) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9083 /*AUTOINOUTMODULE(\"ExampMain\")*/ |
79545 | 9084 endmodule |
9085 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9086 module ExampMain (i,o,io) |
79545 | 9087 input i; |
9088 output o; | |
9089 inout io; | |
9090 endmodule | |
9091 | |
9092 Typing \\[verilog-auto] will make this into: | |
9093 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9094 module ExampShell (/*AUTOARG*/i,o,io) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9095 /*AUTOINOUTMODULE(\"ExampMain\")*/ |
79545 | 9096 // Beginning of automatic in/out/inouts (from specific module) |
9097 input i; | |
9098 output o; | |
9099 inout io; | |
9100 // End of automatics | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9101 endmodule |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9102 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9103 You may also provide an optional regular expression, in which case only |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9104 signals matching the regular expression will be included. For example the |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9105 same expansion will result from only extracting signals starting with i: |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9106 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9107 /*AUTOINOUTMODULE(\"ExampMain\",\"^i\")*/" |
79545 | 9108 (save-excursion |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9109 (let* ((params (verilog-read-auto-params 1 2)) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9110 (submod (nth 0 params)) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9111 (regexp (nth 1 params)) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9112 submodi) |
79545 | 9113 ;; Lookup position, etc of co-module |
9114 ;; Note this may raise an error | |
9115 (when (setq submodi (verilog-modi-lookup submod t)) | |
9116 (let* ((indent-pt (current-indentation)) | |
9117 (v2k (verilog-in-paren)) | |
9118 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9119 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9120 (submoddecls (verilog-modi-get-decls submodi)) |
79545 | 9121 (sig-list-i (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9122 (verilog-decls-get-inputs submoddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9123 (append (verilog-decls-get-inputs moddecls)))) |
79545 | 9124 (sig-list-o (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9125 (verilog-decls-get-outputs submoddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9126 (append (verilog-decls-get-outputs moddecls)))) |
79545 | 9127 (sig-list-io (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9128 (verilog-decls-get-inouts submoddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9129 (append (verilog-decls-get-inouts moddecls))))) |
79545 | 9130 (forward-line 1) |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9131 (when regexp |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9132 (setq sig-list-i (verilog-signals-matching-regexp |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9133 sig-list-i regexp) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9134 sig-list-o (verilog-signals-matching-regexp |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9135 sig-list-o regexp) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9136 sig-list-io (verilog-signals-matching-regexp |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9137 sig-list-io regexp))) |
79545 | 9138 (when v2k (verilog-repair-open-comma)) |
9139 (when (or sig-list-i sig-list-o sig-list-io) | |
9140 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") | |
9141 ;; Don't sort them so a upper AUTOINST will match the main module | |
9142 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) | |
9143 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t) | |
9144 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | |
9145 (verilog-modi-cache-add-inputs modi sig-list-i) | |
9146 (verilog-modi-cache-add-outputs modi sig-list-o) | |
9147 (verilog-modi-cache-add-inouts modi sig-list-io) | |
9148 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9149 (when v2k (verilog-repair-close-comma))))))) |
79545 | 9150 |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9151 (defun verilog-auto-sense-sigs (moddecls presense-sigs) |
79545 | 9152 "Return list of signals for current AUTOSENSE block." |
9153 (let* ((sigss (verilog-read-always-signals)) | |
9154 (sig-list (verilog-signals-not-params | |
9155 (verilog-signals-not-in (verilog-alw-get-inputs sigss) | |
9156 (append (and (not verilog-auto-sense-include-inputs) | |
9157 (verilog-alw-get-outputs sigss)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9158 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9159 (verilog-decls-get-gparams moddecls) |
79545 | 9160 presense-sigs))))) |
9161 sig-list)) | |
9162 | |
9163 (defun verilog-auto-sense () | |
9164 "Expand AUTOSENSE statements, as part of \\[verilog-auto]. | |
9165 Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short) | |
9166 with one automatically derived from all inputs declared in the always | |
9167 statement. Signals that are generated within the same always block are NOT | |
9168 placed into the sensitivity list (see `verilog-auto-sense-include-inputs'). | |
9169 Long lines are split based on the `fill-column', see \\[set-fill-column]. | |
9170 | |
9171 Limitations: | |
9172 Verilog does not allow memories (multidimensional arrays) in sensitivity | |
9173 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment. | |
9174 | |
9175 Constant signals: | |
9176 AUTOSENSE cannot always determine if a `define is a constant or a signal | |
9177 (it could be in a include file for example). If a `define or other signal | |
9178 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT | |
9179 declaration anywhere in the module (parenthesis are required): | |
9180 | |
9181 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */ | |
9182 | |
9183 Better yet, use a parameter, which will be understood to be constant | |
9184 automatically. | |
9185 | |
9186 OOps! | |
9187 If AUTOSENSE makes a mistake, please report it. (First try putting | |
9188 a begin/end after your always!) As a workaround, if a signal that | |
9189 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above. | |
9190 If a signal should be in the sensitivity list wasn't, placing it before | |
9191 the /*AUTOSENSE*/ comment will prevent it from being deleted when the | |
9192 autos are updated (or added if it occurs there already). | |
9193 | |
9194 An example: | |
9195 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9196 always @ (/*AS*/) begin |
79545 | 9197 /* AUTO_CONSTANT (`constant) */ |
9198 outin = ina | inb | `constant; | |
9199 out = outin; | |
9200 end | |
9201 | |
9202 Typing \\[verilog-auto] will make this into: | |
9203 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9204 always @ (/*AS*/ina or inb) begin |
79545 | 9205 /* AUTO_CONSTANT (`constant) */ |
9206 outin = ina | inb | `constant; | |
9207 out = outin; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9208 end |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9209 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9210 Note in Verilog 2001, you can often get the same result from the new @* |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9211 operator. (This was added to the language in part due to AUTOSENSE!) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9212 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9213 always @* begin |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9214 outin = ina | inb | `constant; |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9215 out = outin; |
79545 | 9216 end" |
9217 (save-excursion | |
9218 ;; Find beginning | |
9219 (let* ((start-pt (save-excursion | |
9220 (verilog-re-search-backward "(" nil t) | |
9221 (point))) | |
9222 (indent-pt (save-excursion | |
9223 (or (and (goto-char start-pt) (1+ (current-column))) | |
9224 (current-indentation)))) | |
9225 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9226 (moddecls (verilog-modi-get-decls modi)) |
79545 | 9227 (sig-memories (verilog-signals-memory |
9228 (append | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9229 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9230 (verilog-decls-get-wires moddecls)))) |
79545 | 9231 sig-list not-first presense-sigs) |
9232 ;; Read signals in always, eliminate outputs from sense list | |
9233 (setq presense-sigs (verilog-signals-from-signame | |
9234 (save-excursion | |
9235 (verilog-read-signals start-pt (point))))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9236 (setq sig-list (verilog-auto-sense-sigs moddecls presense-sigs)) |
79545 | 9237 (when sig-memories |
9238 (let ((tlen (length sig-list))) | |
9239 (setq sig-list (verilog-signals-not-in sig-list sig-memories)) | |
9240 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ ")))) | |
9241 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" | |
9242 (save-excursion (goto-char (point)) | |
9243 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
9244 (verilog-re-search-backward "\\s-" start-pt t) | |
9245 (while (looking-at "\\s-`endif") | |
9246 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
9247 (verilog-re-search-backward "\\s-" start-pt t)) | |
9248 (not (looking-at "\\s-or\\b")))) | |
9249 (setq not-first t)) | |
9250 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
9251 (while sig-list | |
9252 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or | |
9253 (insert "\n") | |
9254 (indent-to indent-pt) | |
9255 (if not-first (insert "or "))) | |
9256 (not-first (insert " or "))) | |
9257 (insert (verilog-sig-name (car sig-list))) | |
9258 (setq sig-list (cdr sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9259 not-first t))))) |
79545 | 9260 |
9261 (defun verilog-auto-reset () | |
9262 "Expand AUTORESET statements, as part of \\[verilog-auto]. | |
9263 Replace the /*AUTORESET*/ comment with code to initialize all | |
9264 registers set elsewhere in the always block. | |
9265 | |
9266 Limitations: | |
9267 AUTORESET will not clear memories. | |
9268 | |
9269 AUTORESET uses <= if there are any <= in the block, else it uses =. | |
9270 | |
9271 /*AUTORESET*/ presumes that any signals mentioned between the previous | |
9272 begin/case/if statement and the AUTORESET comment are being reset manually | |
9273 and should not be automatically reset. This includes omitting any signals | |
9274 used on the right hand side of assignments. | |
9275 | |
9276 By default, AUTORESET will include the width of the signal in the autos, | |
9277 this is a recent change. To control this behavior, see | |
9278 `verilog-auto-reset-widths'. | |
9279 | |
9280 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
9281 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
9282 them to a one. | |
9283 | |
9284 An example: | |
9285 | |
9286 always @(posedge clk or negedge reset_l) begin | |
9287 if (!reset_l) begin | |
9288 c <= 1; | |
9289 /*AUTORESET*/ | |
9290 end | |
9291 else begin | |
9292 a <= in_a; | |
9293 b <= in_b; | |
9294 c <= in_c; | |
9295 end | |
9296 end | |
9297 | |
9298 Typing \\[verilog-auto] will make this into: | |
9299 | |
9300 always @(posedge core_clk or negedge reset_l) begin | |
9301 if (!reset_l) begin | |
9302 c <= 1; | |
9303 /*AUTORESET*/ | |
9304 // Beginning of autoreset for uninitialized flops | |
9305 a <= 0; | |
9306 b <= 0; | |
9307 // End of automatics | |
9308 end | |
9309 else begin | |
9310 a <= in_a; | |
9311 b <= in_b; | |
9312 c <= in_c; | |
9313 end | |
9314 end" | |
9315 | |
9316 (interactive) | |
9317 (save-excursion | |
9318 ;; Find beginning | |
9319 (let* ((indent-pt (current-indentation)) | |
9320 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9321 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9322 (all-list (verilog-decls-get-signals moddecls)) |
79545 | 9323 sigss sig-list prereset-sigs assignment-str) |
9324 ;; Read signals in always, eliminate outputs from reset list | |
9325 (setq prereset-sigs (verilog-signals-from-signame | |
9326 (save-excursion | |
9327 (verilog-read-signals | |
9328 (save-excursion | |
9329 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t) | |
9330 (point)) | |
9331 (point))))) | |
9332 (save-excursion | |
9333 (verilog-re-search-backward "@" nil t) | |
9334 (setq sigss (verilog-read-always-signals))) | |
9335 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss) | |
9336 (concat " <= " verilog-assignment-delay) | |
9337 " = ")) | |
9338 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss) | |
9339 prereset-sigs)) | |
9340 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
9341 (when sig-list | |
9342 (insert "\n"); | |
9343 (indent-to indent-pt) | |
9344 (insert "// Beginning of autoreset for uninitialized flops\n"); | |
9345 (indent-to indent-pt) | |
9346 (while sig-list | |
9347 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths | |
9348 (car sig-list)))) | |
9349 (insert (verilog-sig-name sig) | |
9350 assignment-str | |
9351 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | |
9352 ";\n") | |
9353 (indent-to indent-pt) | |
9354 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9355 (insert "// End of automatics"))))) |
79545 | 9356 |
9357 (defun verilog-auto-tieoff () | |
9358 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | |
9359 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | |
9360 signals to deasserted. | |
9361 | |
9362 /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same | |
9363 input/output list as another module, but no internals. Specifically, it | |
9364 finds all outputs in the module, and if that input is not otherwise declared | |
9365 as a register or wire, creates a tieoff. | |
9366 | |
9367 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
9368 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
9369 them to a one. | |
9370 | |
9371 An example of making a stub for another module: | |
9372 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9373 module ExampStub (/*AUTOINST*/); |
79545 | 9374 /*AUTOINOUTMODULE(\"Foo\")*/ |
9375 /*AUTOTIEOFF*/ | |
9376 // verilator lint_off UNUSED | |
9377 wire _unused_ok = &{1'b0, | |
9378 /*AUTOUNUSED*/ | |
9379 1'b0}; | |
9380 // verilator lint_on UNUSED | |
9381 endmodule | |
9382 | |
9383 Typing \\[verilog-auto] will make this into: | |
9384 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9385 module ExampStub (/*AUTOINST*/...); |
79545 | 9386 /*AUTOINOUTMODULE(\"Foo\")*/ |
9387 // Beginning of autotieoff | |
9388 output [2:0] foo; | |
9389 // End of automatics | |
9390 | |
9391 /*AUTOTIEOFF*/ | |
9392 // Beginning of autotieoff | |
9393 wire [2:0] foo = 3'b0; | |
9394 // End of automatics | |
9395 ... | |
9396 endmodule" | |
9397 (interactive) | |
9398 (save-excursion | |
9399 ;; Find beginning | |
9400 (let* ((indent-pt (current-indentation)) | |
9401 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9402 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9403 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9404 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9405 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9406 (append (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9407 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9408 (verilog-decls-get-assigns moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9409 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9410 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9411 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9412 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 9413 (when sig-list |
9414 (forward-line 1) | |
9415 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | |
9416 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9417 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list | |
9418 (while sig-list | |
9419 (let ((sig (car sig-list))) | |
9420 (verilog-insert-one-definition sig "wire" indent-pt) | |
9421 (indent-to (max 48 (+ indent-pt 40))) | |
9422 (insert "= " (verilog-sig-tieoff sig) | |
9423 ";\n") | |
9424 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9425 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9426 |
9427 (defun verilog-auto-unused () | |
9428 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | |
9429 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | |
9430 input and inout signals. | |
9431 | |
9432 /*AUTOUNUSED*/ is used to make stub modules; modules that have the same | |
9433 input/output list as another module, but no internals. Specifically, it | |
9434 finds all inputs and inouts in the module, and if that input is not otherwise | |
9435 used, adds it to a comma separated list. | |
9436 | |
9437 The comma separated list is intended to be used to create a _unused_ok | |
9438 signal. Using the exact name \"_unused_ok\" for name of the temporary | |
9439 signal is recommended as it will insure maximum forward compatibility, it | |
9440 also makes lint warnings easy to understand; ignore any unused warnings | |
9441 with \"unused\" in the signal name. | |
9442 | |
9443 To reduce simulation time, the _unused_ok signal should be forced to a | |
9444 constant to prevent wiggling. The easiest thing to do is use a | |
9445 reduction-and with 1'b0 as shown. | |
9446 | |
9447 This way all unused signals are in one place, making it convenient to add | |
9448 your tool's specific pragmas around the assignment to disable any unused | |
9449 warnings. | |
9450 | |
9451 You can add signals you do not want included in AUTOUNUSED with | |
9452 `verilog-auto-unused-ignore-regexp'. | |
9453 | |
9454 An example of making a stub for another module: | |
9455 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9456 module ExampStub (/*AUTOINST*/); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9457 /*AUTOINOUTMODULE(\"Examp\")*/ |
79545 | 9458 /*AUTOTIEOFF*/ |
9459 // verilator lint_off UNUSED | |
9460 wire _unused_ok = &{1'b0, | |
9461 /*AUTOUNUSED*/ | |
9462 1'b0}; | |
9463 // verilator lint_on UNUSED | |
9464 endmodule | |
9465 | |
9466 Typing \\[verilog-auto] will make this into: | |
9467 | |
9468 ... | |
9469 // verilator lint_off UNUSED | |
9470 wire _unused_ok = &{1'b0, | |
9471 /*AUTOUNUSED*/ | |
9472 // Beginning of automatics | |
9473 unused_input_a, | |
9474 unused_input_b, | |
9475 unused_input_c, | |
9476 // End of automatics | |
9477 1'b0}; | |
9478 // verilator lint_on UNUSED | |
9479 endmodule" | |
9480 (interactive) | |
9481 (save-excursion | |
9482 ;; Find beginning | |
9483 (let* ((indent-pt (progn (search-backward "/*") (current-column))) | |
9484 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9485 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9486 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9487 (sig-list (verilog-signals-not-in |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9488 (append (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9489 (verilog-decls-get-inouts moddecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9490 (append (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9491 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 9492 (setq sig-list (verilog-signals-not-matching-regexp |
9493 sig-list verilog-auto-unused-ignore-regexp)) | |
9494 (when sig-list | |
9495 (forward-line 1) | |
9496 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | |
9497 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
9498 (while sig-list | |
9499 (let ((sig (car sig-list))) | |
9500 (indent-to indent-pt) | |
9501 (insert (verilog-sig-name sig) ",\n") | |
9502 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9503 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9504 |
9505 (defun verilog-enum-ascii (signm elim-regexp) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9506 "Convert an enum name SIGNM to an ascii string for insertion. |
79545 | 9507 Remove user provided prefix ELIM-REGEXP." |
9508 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | |
9509 (let ((case-fold-search t)) | |
9510 ;; All upper becomes all lower for readability | |
9511 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm)))) | |
9512 | |
9513 (defun verilog-auto-ascii-enum () | |
9514 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto]. | |
9515 Create a register to contain the ASCII decode of a enumerated signal type. | |
9516 This will allow trace viewers to show the ASCII name of states. | |
9517 | |
9518 First, parameters are built into a enumeration using the synopsys enum | |
9519 comment. The comment must be between the keyword and the symbol. | |
79546 | 9520 \(Annoying, but that's what Synopsys's dc_shell FSM reader requires.) |
79545 | 9521 |
9522 Next, registers which that enum applies to are also tagged with the same | |
9523 enum. Synopsys also suggests labeling state vectors, but `verilog-mode' | |
9524 doesn't care. | |
9525 | |
9526 Finally, a AUTOASCIIENUM command is used. | |
9527 | |
9528 The first parameter is the name of the signal to be decoded. | |
9529 | |
9530 The second parameter is the name to store the ASCII code into. For the | |
9531 signal foo, I suggest the name _foo__ascii, where the leading _ indicates | |
9532 a signal that is just for simulation, and the magic characters _ascii | |
9533 tell viewers like Dinotrace to display in ASCII format. | |
9534 | |
9535 The final optional parameter is a string which will be removed from the | |
9536 state names. | |
9537 | |
9538 An example: | |
9539 | |
9540 //== State enumeration | |
9541 parameter [2:0] // synopsys enum state_info | |
9542 SM_IDLE = 3'b000, | |
9543 SM_SEND = 3'b001, | |
9544 SM_WAIT1 = 3'b010; | |
9545 //== State variables | |
9546 reg [2:0] /* synopsys enum state_info */ | |
9547 state_r; /* synopsys state_vector state_r */ | |
9548 reg [2:0] /* synopsys enum state_info */ | |
9549 state_e1; | |
9550 | |
9551 //== ASCII state decoding | |
9552 | |
9553 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9554 | |
9555 Typing \\[verilog-auto] will make this into: | |
9556 | |
9557 ... same front matter ... | |
9558 | |
9559 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
9560 // Beginning of automatic ASCII enum decoding | |
9561 reg [39:0] state_ascii_r; // Decode of state_r | |
9562 always @(state_r) begin | |
9563 case ({state_r}) | |
9564 SM_IDLE: state_ascii_r = \"idle \"; | |
9565 SM_SEND: state_ascii_r = \"send \"; | |
9566 SM_WAIT1: state_ascii_r = \"wait1\"; | |
9567 default: state_ascii_r = \"%Erro\"; | |
9568 endcase | |
9569 end | |
9570 // End of automatics" | |
9571 (save-excursion | |
9572 (let* ((params (verilog-read-auto-params 2 3)) | |
9573 (undecode-name (nth 0 params)) | |
9574 (ascii-name (nth 1 params)) | |
9575 (elim-regexp (nth 2 params)) | |
9576 ;; | |
9577 (indent-pt (current-indentation)) | |
9578 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9579 (moddecls (verilog-modi-get-decls modi)) |
79545 | 9580 ;; |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9581 (sig-list-consts (append (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9582 (verilog-decls-get-gparams moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9583 (sig-list-all (append (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9584 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9585 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9586 (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9587 (verilog-decls-get-wires moddecls))) |
79545 | 9588 ;; |
9589 (undecode-sig (or (assoc undecode-name sig-list-all) | |
9590 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) | |
9591 (undecode-enum (or (verilog-sig-enum undecode-sig) | |
9592 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name))) | |
9593 ;; | |
9594 (enum-sigs (or (verilog-signals-matching-enum sig-list-consts undecode-enum) | |
9595 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum))) | |
9596 ;; | |
9597 (enum-chars 0) | |
9598 (ascii-chars 0)) | |
9599 ;; | |
9600 ;; Find number of ascii chars needed | |
9601 (let ((tmp-sigs enum-sigs)) | |
9602 (while tmp-sigs | |
9603 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs)))) | |
9604 ascii-chars (max ascii-chars (length (verilog-enum-ascii | |
9605 (verilog-sig-name (car tmp-sigs)) | |
9606 elim-regexp))) | |
9607 tmp-sigs (cdr tmp-sigs)))) | |
9608 ;; | |
9609 (forward-line 1) | |
9610 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") | |
9611 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) | |
9612 (concat "Decode of " undecode-name) nil nil)))) | |
9613 (verilog-insert-definition decode-sig-list "reg" indent-pt nil) | |
9614 (verilog-modi-cache-add-regs modi decode-sig-list)) | |
9615 ;; | |
9616 (verilog-insert-indent "always @(" undecode-name ") begin\n") | |
9617 (setq indent-pt (+ indent-pt verilog-indent-level)) | |
9618 (indent-to indent-pt) | |
9619 (insert "case ({" undecode-name "})\n") | |
9620 (setq indent-pt (+ indent-pt verilog-case-indent)) | |
9621 ;; | |
9622 (let ((tmp-sigs enum-sigs) | |
9623 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" (1+ (max 8 enum-chars)) | |
9624 ascii-name ascii-chars)) | |
9625 (errname (substring "%Error" 0 (min 6 ascii-chars)))) | |
9626 (while tmp-sigs | |
9627 (verilog-insert-indent | |
9628 (format chrfmt (concat (verilog-sig-name (car tmp-sigs)) ":") | |
9629 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs)) | |
9630 elim-regexp))) | |
9631 (setq tmp-sigs (cdr tmp-sigs))) | |
9632 (verilog-insert-indent (format chrfmt "default:" errname))) | |
9633 ;; | |
9634 (setq indent-pt (- indent-pt verilog-case-indent)) | |
9635 (verilog-insert-indent "endcase\n") | |
9636 (setq indent-pt (- indent-pt verilog-indent-level)) | |
9637 (verilog-insert-indent "end\n" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9638 "// End of automatics\n")))) |
79545 | 9639 |
9640 (defun verilog-auto-templated-rel () | |
9641 "Replace Templated relative line numbers with absolute line numbers. | |
9642 Internal use only. This hacks around the line numbers in AUTOINST Templates | |
9643 being different from the final output's line numbering." | |
9644 (let ((templateno 0) (template-line (list 0))) | |
9645 ;; Find line number each template is on | |
9646 (goto-char (point-min)) | |
9647 (while (search-forward "AUTO_TEMPLATE" nil t) | |
9648 (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
|
9649 (setq template-line |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9650 (cons (count-lines (point-min) (point)) template-line))) |
79545 | 9651 (setq template-line (nreverse template-line)) |
9652 ;; Replace T# L# with absolute line number | |
9653 (goto-char (point-min)) | |
9654 (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
|
9655 (replace-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9656 (concat " Templated " |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9657 (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
|
9658 template-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9659 (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
|
9660 t t)))) |
79545 | 9661 |
9662 | |
9663 ;; | |
9664 ;; Auto top level | |
9665 ;; | |
9666 | |
9667 (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg | |
9668 "Expand AUTO statements. | |
9669 Look for any /*AUTO...*/ commands in the code, as used in | |
9670 instantiations or argument headers. Update the list of signals | |
9671 following the /*AUTO...*/ command. | |
9672 | |
9673 Use \\[verilog-delete-auto] to remove the AUTOs. | |
9674 | |
9675 Use \\[verilog-inject-auto] to insert AUTOs for the first time. | |
9676 | |
9677 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
9678 | |
9679 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are | |
9680 called before and after this function, respectively. | |
9681 | |
9682 For example: | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9683 module ModuleName (/*AUTOARG*/) |
79545 | 9684 /*AUTOINPUT*/ |
9685 /*AUTOOUTPUT*/ | |
9686 /*AUTOWIRE*/ | |
9687 /*AUTOREG*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9688 InstMod instName #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); |
79545 | 9689 |
9690 You can also update the AUTOs from the shell using: | |
9691 emacs --batch <filenames.v> -f verilog-batch-auto | |
9692 Or fix indentation with: | |
9693 emacs --batch <filenames.v> -f verilog-batch-indent | |
9694 Likewise, you can delete or inject AUTOs with: | |
9695 emacs --batch <filenames.v> -f verilog-batch-delete-auto | |
9696 emacs --batch <filenames.v> -f verilog-batch-inject-auto | |
9697 | |
9698 Using \\[describe-function], see also: | |
9699 `verilog-auto-arg' for AUTOARG module instantiations | |
9700 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding | |
9701 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere | |
9702 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts | |
9703 `verilog-auto-input' for AUTOINPUT making hierarchy inputs | |
9704 `verilog-auto-inst' for AUTOINST instantiation pins | |
9705 `verilog-auto-star' for AUTOINST .* SystemVerilog pins | |
9706 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params | |
9707 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs | |
9708 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs | |
9709 `verilog-auto-reg' for AUTOREG registers | |
9710 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers | |
9711 `verilog-auto-reset' for AUTORESET flop resets | |
9712 `verilog-auto-sense' for AUTOSENSE always sensitivity lists | |
9713 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs | |
9714 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts | |
9715 `verilog-auto-wire' for AUTOWIRE instantiation wires | |
9716 | |
9717 `verilog-read-defines' for reading `define values | |
9718 `verilog-read-includes' for reading `includes | |
9719 | |
9720 If you have bugs with these autos, try contacting the AUTOAUTHOR | |
9721 Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com." | |
9722 (interactive) | |
9723 (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
|
9724 (if (fboundp 'dinotrace-unannotate-all) |
79545 | 9725 (dinotrace-unannotate-all)) |
9726 (let ((oldbuf (if (not (buffer-modified-p)) | |
9727 (buffer-string))) | |
9728 ;; Before version 20, match-string with font-lock returns a | |
9729 ;; vector that is not equal to the string. IE if on "input" | |
9730 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0))) | |
9731 (fontlocked (when (and (boundp 'font-lock-mode) | |
9732 font-lock-mode) | |
9733 (font-lock-mode nil) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9734 t)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9735 ;; Cache directories; we don't write new files, so can't change |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9736 (verilog-dir-cache-preserving t)) |
79545 | 9737 (unwind-protect |
9738 (save-excursion | |
9739 ;; If we're not in verilog-mode, change syntax table so parsing works right | |
9740 (unless (eq major-mode `verilog-mode) (verilog-mode)) | |
9741 ;; Allow user to customize | |
9742 (run-hooks 'verilog-before-auto-hook) | |
9743 ;; Try to save the user from needing to revert-file to reread file local-variables | |
9744 (verilog-auto-reeval-locals) | |
9745 (verilog-read-auto-lisp (point-min) (point-max)) | |
9746 (verilog-getopt-flags) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9747 ;; From here on out, we can cache anything we read from disk |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9748 (verilog-preserve-dir-cache |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9749 ;; These two may seem obvious to do always, but on large includes it can be way too slow |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9750 (when verilog-auto-read-includes |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9751 (verilog-read-includes) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9752 (verilog-read-defines nil nil t)) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9753 ;; This particular ordering is important |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9754 ;; INST: Lower modules correct, no internal dependencies, FIRST |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9755 (verilog-preserve-modi-cache |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9756 ;; Clear existing autos else we'll be screwed by existing ones |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9757 (verilog-delete-auto) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9758 ;; Injection if appropriate |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9759 (when inject |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9760 (verilog-inject-inst) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9761 (verilog-inject-sense) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9762 (verilog-inject-arg)) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9763 ;; |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9764 (verilog-auto-re-search-do "/\\*AUTOINSTPARAM\\*/" 'verilog-auto-inst-param) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9765 (verilog-auto-re-search-do "/\\*AUTOINST\\*/" 'verilog-auto-inst) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9766 (verilog-auto-re-search-do "\\.\\*" 'verilog-auto-star) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9767 ;; Doesn't matter when done, but combine it with a common changer |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9768 (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9769 (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9770 ;; Must be done before autoin/out as creates a reg |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9771 (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9772 ;; |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9773 ;; first in/outs from other files |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9774 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9775 ;; next in/outs which need previous sucked inputs first |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9776 (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/" |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9777 '(lambda () (verilog-auto-output t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9778 (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\*/" 'verilog-auto-output) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9779 (verilog-auto-re-search-do "/\\*AUTOINPUT\\((\"[^\"]*\")\\)\\*/" |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9780 '(lambda () (verilog-auto-input t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9781 (verilog-auto-re-search-do "/\\*AUTOINPUT\\*/" 'verilog-auto-input) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9782 (verilog-auto-re-search-do "/\\*AUTOINOUT\\((\"[^\"]*\")\\)\\*/" |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9783 '(lambda () (verilog-auto-inout t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9784 (verilog-auto-re-search-do "/\\*AUTOINOUT\\*/" 'verilog-auto-inout) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9785 ;; Then tie off those in/outs |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9786 (verilog-auto-re-search-do "/\\*AUTOTIEOFF\\*/" 'verilog-auto-tieoff) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9787 ;; Wires/regs must be after inputs/outputs |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9788 (verilog-auto-re-search-do "/\\*AUTOWIRE\\*/" 'verilog-auto-wire) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9789 (verilog-auto-re-search-do "/\\*AUTOREG\\*/" 'verilog-auto-reg) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9790 (verilog-auto-re-search-do "/\\*AUTOREGINPUT\\*/" 'verilog-auto-reg-input) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9791 ;; outputevery needs AUTOOUTPUTs done first |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9792 (verilog-auto-re-search-do "/\\*AUTOOUTPUTEVERY\\*/" 'verilog-auto-output-every) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9793 ;; After we've created all new variables |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9794 (verilog-auto-re-search-do "/\\*AUTOUNUSED\\*/" 'verilog-auto-unused) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9795 ;; Must be after all inputs outputs are generated |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9796 (verilog-auto-re-search-do "/\\*AUTOARG\\*/" 'verilog-auto-arg) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
9797 ;; Fix line numbers (comments only) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9798 (verilog-auto-templated-rel))) |
79545 | 9799 ;; |
9800 (run-hooks 'verilog-auto-hook) | |
9801 ;; | |
9802 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | |
9803 ;; | |
9804 ;; If end result is same as when started, clear modified flag | |
9805 (cond ((and oldbuf (equal oldbuf (buffer-string))) | |
9806 (set-buffer-modified-p nil) | |
9807 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9808 (t (unless noninteractive (message "Updating AUTOs...done")))))) |
79545 | 9809 ;; Unwind forms |
9810 (progn | |
9811 ;; Restore font-lock | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9812 (when fontlocked (font-lock-mode t))))) |
79545 | 9813 |
9814 | |
9815 ;; | |
9816 ;; Skeleton based code insertion | |
9817 ;; | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9818 (defvar verilog-template-map |
79546 | 9819 (let ((map (make-sparse-keymap))) |
9820 (define-key map "a" 'verilog-sk-always) | |
9821 (define-key map "b" 'verilog-sk-begin) | |
9822 (define-key map "c" 'verilog-sk-case) | |
9823 (define-key map "f" 'verilog-sk-for) | |
9824 (define-key map "g" 'verilog-sk-generate) | |
9825 (define-key map "h" 'verilog-sk-header) | |
9826 (define-key map "i" 'verilog-sk-initial) | |
9827 (define-key map "j" 'verilog-sk-fork) | |
9828 (define-key map "m" 'verilog-sk-module) | |
9829 (define-key map "p" 'verilog-sk-primitive) | |
9830 (define-key map "r" 'verilog-sk-repeat) | |
9831 (define-key map "s" 'verilog-sk-specify) | |
9832 (define-key map "t" 'verilog-sk-task) | |
9833 (define-key map "w" 'verilog-sk-while) | |
9834 (define-key map "x" 'verilog-sk-casex) | |
9835 (define-key map "z" 'verilog-sk-casez) | |
9836 (define-key map "?" 'verilog-sk-if) | |
9837 (define-key map ":" 'verilog-sk-else-if) | |
9838 (define-key map "/" 'verilog-sk-comment) | |
9839 (define-key map "A" 'verilog-sk-assign) | |
9840 (define-key map "F" 'verilog-sk-function) | |
9841 (define-key map "I" 'verilog-sk-input) | |
9842 (define-key map "O" 'verilog-sk-output) | |
9843 (define-key map "S" 'verilog-sk-state-machine) | |
9844 (define-key map "=" 'verilog-sk-inout) | |
9845 (define-key map "W" 'verilog-sk-wire) | |
9846 (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
|
9847 (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
|
9848 map) |
79545 | 9849 "Keymap used in Verilog mode for smart template operations.") |
9850 | |
9851 | |
9852 ;; | |
9853 ;; Place the templates into Verilog Mode. They may be inserted under any key. | |
9854 ;; C-c C-t will be the default. If you use templates a lot, you | |
9855 ;; may want to consider moving the binding to another key in your .emacs | |
9856 ;; file. | |
9857 ;; | |
9858 ;(define-key verilog-mode-map "\C-ct" verilog-template-map) | |
9859 (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) | |
9860 | |
9861 ;;; ---- statement skeletons ------------------------------------------ | |
9862 | |
9863 (define-skeleton verilog-sk-prompt-condition | |
9864 "Prompt for the loop condition." | |
9865 "[condition]: " str ) | |
9866 | |
9867 (define-skeleton verilog-sk-prompt-init | |
9868 "Prompt for the loop init statement." | |
9869 "[initial statement]: " str ) | |
9870 | |
9871 (define-skeleton verilog-sk-prompt-inc | |
9872 "Prompt for the loop increment statement." | |
9873 "[increment statement]: " str ) | |
9874 | |
9875 (define-skeleton verilog-sk-prompt-name | |
9876 "Prompt for the name of something." | |
9877 "[name]: " str) | |
9878 | |
9879 (define-skeleton verilog-sk-prompt-clock | |
9880 "Prompt for the name of something." | |
9881 "name and edge of clock(s): " str) | |
9882 | |
9883 (defvar verilog-sk-reset nil) | |
9884 (defun verilog-sk-prompt-reset () | |
9885 "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
|
9886 (setq verilog-sk-reset (read-string "name of reset: " "rst"))) |
79545 | 9887 |
9888 | |
9889 (define-skeleton verilog-sk-prompt-state-selector | |
9890 "Prompt for the name of a state machine selector." | |
9891 "name of selector (eg {a,b,c,d}): " str ) | |
9892 | |
9893 (define-skeleton verilog-sk-prompt-output | |
9894 "Prompt for the name of something." | |
9895 "output: " str) | |
9896 | |
9897 (define-skeleton verilog-sk-prompt-msb | |
9898 "Prompt for least significant bit specification." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9899 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 ) |
79545 | 9900 |
9901 (define-skeleton verilog-sk-prompt-lsb | |
9902 "Prompt for least significant bit specification." | |
9903 "lsb:" str ) | |
9904 | |
9905 (defvar verilog-sk-p nil) | |
9906 (define-skeleton verilog-sk-prompt-width | |
9907 "Prompt for a width specification." | |
9908 () | |
9909 (progn | |
9910 (setq verilog-sk-p (point)) | |
9911 (verilog-sk-prompt-msb) | |
9912 (if (> (point) verilog-sk-p) "] " " "))) | |
9913 | |
9914 (defun verilog-sk-header () | |
9915 "Insert a descriptive header at the top of the file." | |
9916 (interactive "*") | |
9917 (save-excursion | |
9918 (goto-char (point-min)) | |
9919 (verilog-sk-header-tmpl))) | |
9920 | |
9921 (define-skeleton verilog-sk-header-tmpl | |
9922 "Insert a comment block containing the module title, author, etc." | |
9923 "[Description]: " | |
9924 "// -*- Mode: Verilog -*-" | |
9925 "\n// Filename : " (buffer-name) | |
9926 "\n// Description : " str | |
9927 "\n// Author : " (user-full-name) | |
9928 "\n// Created On : " (current-time-string) | |
9929 "\n// Last Modified By: ." | |
9930 "\n// Last Modified On: ." | |
9931 "\n// Update Count : 0" | |
9932 "\n// Status : Unknown, Use with caution!" | |
9933 "\n") | |
9934 | |
9935 (define-skeleton verilog-sk-module | |
9936 "Insert a module definition." | |
9937 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9938 > "module " '(verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n |
79545 | 9939 > _ \n |
9940 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) | |
9941 | |
9942 (define-skeleton verilog-sk-primitive | |
9943 "Insert a task definition." | |
9944 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9945 > "primitive " '(verilog-sk-prompt-name) " ( " '(verilog-sk-prompt-output) ("input:" ", " str ) " );"\n |
79545 | 9946 > _ \n |
9947 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil)) | |
9948 | |
9949 (define-skeleton verilog-sk-task | |
9950 "Insert a task definition." | |
9951 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9952 > "task " '(verilog-sk-prompt-name) & ?; \n |
79545 | 9953 > _ \n |
9954 > "begin" \n | |
9955 > \n | |
9956 > (- verilog-indent-level-behavioral) "end" \n | |
9957 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil)) | |
9958 | |
9959 (define-skeleton verilog-sk-function | |
9960 "Insert a function definition." | |
9961 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
9962 > "function [" '(verilog-sk-prompt-width) | -1 '(verilog-sk-prompt-name) ?; \n |
79545 | 9963 > _ \n |
9964 > "begin" \n | |
9965 > \n | |
9966 > (- verilog-indent-level-behavioral) "end" \n | |
9967 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil)) | |
9968 | |
9969 (define-skeleton verilog-sk-always | |
9970 "Insert always block. Uses the minibuffer to prompt | |
9971 for sensitivity list." | |
9972 () | |
9973 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
9974 > _ \n | |
9975 > (- verilog-indent-level-behavioral) "end" \n > | |
9976 ) | |
9977 | |
9978 (define-skeleton verilog-sk-initial | |
9979 "Insert an initial block." | |
9980 () | |
9981 > "initial begin\n" | |
9982 > _ \n | |
9983 > (- verilog-indent-level-behavioral) "end" \n > ) | |
9984 | |
9985 (define-skeleton verilog-sk-specify | |
9986 "Insert specify block. " | |
9987 () | |
9988 > "specify\n" | |
9989 > _ \n | |
9990 > (- verilog-indent-level-behavioral) "endspecify" \n > ) | |
9991 | |
9992 (define-skeleton verilog-sk-generate | |
9993 "Insert generate block. " | |
9994 () | |
9995 > "generate\n" | |
9996 > _ \n | |
9997 > (- verilog-indent-level-behavioral) "endgenerate" \n > ) | |
9998 | |
9999 (define-skeleton verilog-sk-begin | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10000 "Insert begin end block. Uses the minibuffer to prompt for name." |
79545 | 10001 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10002 > "begin" '(verilog-sk-prompt-name) \n |
79545 | 10003 > _ \n |
10004 > (- verilog-indent-level-behavioral) "end" | |
10005 ) | |
10006 | |
10007 (define-skeleton verilog-sk-fork | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10008 "Insert a fork join block." |
79545 | 10009 () |
10010 > "fork\n" | |
10011 > "begin" \n | |
10012 > _ \n | |
10013 > (- verilog-indent-level-behavioral) "end" \n | |
10014 > "begin" \n | |
10015 > \n | |
10016 > (- verilog-indent-level-behavioral) "end" \n | |
10017 > (- verilog-indent-level-behavioral) "join" \n | |
10018 > ) | |
10019 | |
10020 | |
10021 (define-skeleton verilog-sk-case | |
10022 "Build skeleton case statement, prompting for the selector expression, | |
10023 and the case items." | |
10024 "[selector expression]: " | |
10025 > "case (" str ") " \n | |
10026 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
10027 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
10028 | |
10029 (define-skeleton verilog-sk-casex | |
10030 "Build skeleton casex statement, prompting for the selector expression, | |
10031 and the case items." | |
10032 "[selector expression]: " | |
10033 > "casex (" str ") " \n | |
10034 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
10035 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
10036 | |
10037 (define-skeleton verilog-sk-casez | |
10038 "Build skeleton casez statement, prompting for the selector expression, | |
10039 and the case items." | |
10040 "[selector expression]: " | |
10041 > "casez (" str ") " \n | |
10042 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n ) | |
10043 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) | |
10044 | |
10045 (define-skeleton verilog-sk-if | |
10046 "Insert a skeleton if statement." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10047 > "if (" '(verilog-sk-prompt-condition) & ")" " begin" \n |
79545 | 10048 > _ \n |
10049 > (- verilog-indent-level-behavioral) "end " \n ) | |
10050 | |
10051 (define-skeleton verilog-sk-else-if | |
10052 "Insert a skeleton else if statement." | |
10053 > (verilog-indent-line) "else if (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10054 (progn (setq verilog-sk-p (point)) nil) '(verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n |
79545 | 10055 > _ \n |
10056 > "end" (progn (electric-verilog-terminate-line) nil)) | |
10057 | |
10058 (define-skeleton verilog-sk-datadef | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10059 "Common routine to get data definition." |
79545 | 10060 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10061 '(verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n) |
79545 | 10062 |
10063 (define-skeleton verilog-sk-input | |
10064 "Insert an input definition." | |
10065 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10066 > "input [" '(verilog-sk-datadef)) |
79545 | 10067 |
10068 (define-skeleton verilog-sk-output | |
10069 "Insert an output definition." | |
10070 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10071 > "output [" '(verilog-sk-datadef)) |
79545 | 10072 |
10073 (define-skeleton verilog-sk-inout | |
10074 "Insert an inout definition." | |
10075 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10076 > "inout [" '(verilog-sk-datadef)) |
79545 | 10077 |
10078 (defvar verilog-sk-signal nil) | |
10079 (define-skeleton verilog-sk-def-reg | |
10080 "Insert a reg definition." | |
10081 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10082 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
79545 | 10083 |
10084 (defun verilog-sk-define-signal () | |
10085 "Insert a definition of signal under point at top of module." | |
10086 (interactive "*") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10087 (let* ((sig-re "[a-zA-Z0-9_]*") |
79545 | 10088 (v1 (buffer-substring |
10089 (save-excursion | |
10090 (skip-chars-backward sig-re) | |
10091 (point)) | |
10092 (save-excursion | |
10093 (skip-chars-forward sig-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10094 (point))))) |
79545 | 10095 (if (not (member v1 verilog-keywords)) |
10096 (save-excursion | |
10097 (setq verilog-sk-signal v1) | |
10098 (verilog-beg-of-defun) | |
10099 (verilog-end-of-statement) | |
10100 (verilog-forward-syntactic-ws) | |
10101 (verilog-sk-def-reg) | |
10102 (message "signal at point is %s" v1)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10103 (message "object at point (%s) is a keyword" v1)))) |
79545 | 10104 |
10105 (define-skeleton verilog-sk-wire | |
10106 "Insert a wire definition." | |
10107 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10108 > "wire [" '(verilog-sk-datadef)) |
79545 | 10109 |
10110 (define-skeleton verilog-sk-reg | |
10111 "Insert a reg definition." | |
10112 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10113 > "reg [" '(verilog-sk-datadef)) |
79545 | 10114 |
10115 (define-skeleton verilog-sk-assign | |
10116 "Insert a skeleton assign statement." | |
10117 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10118 > "assign " '(verilog-sk-prompt-name) " = " _ ";" \n) |
79545 | 10119 |
10120 (define-skeleton verilog-sk-while | |
10121 "Insert a skeleton while loop statement." | |
10122 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10123 > "while (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 10124 > _ \n |
10125 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
10126 | |
10127 (define-skeleton verilog-sk-repeat | |
10128 "Insert a skeleton repeat loop statement." | |
10129 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10130 > "repeat (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 10131 > _ \n |
10132 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
10133 | |
10134 (define-skeleton verilog-sk-for | |
10135 "Insert a skeleton while loop statement." | |
10136 () | |
10137 > "for (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10138 '(verilog-sk-prompt-init) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10139 '(verilog-sk-prompt-condition) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10140 '(verilog-sk-prompt-inc) |
79545 | 10141 ") begin" \n |
10142 > _ \n | |
10143 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
10144 | |
10145 (define-skeleton verilog-sk-comment | |
10146 "Inserts three comment lines, making a display comment." | |
10147 () | |
10148 > "/*\n" | |
10149 > "* " _ \n | |
10150 > "*/") | |
10151 | |
10152 (define-skeleton verilog-sk-state-machine | |
10153 "Insert a state machine definition." | |
10154 "Name of state variable: " | |
10155 '(setq input "state") | |
10156 > "// State registers for " str | -23 \n | |
10157 '(setq verilog-sk-state str) | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10158 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n |
79545 | 10159 '(setq input nil) |
10160 > \n | |
10161 > "// State FF for " verilog-sk-state \n | |
10162 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n | |
10163 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n | |
10164 > verilog-sk-state " = next_" verilog-sk-state ?; \n | |
10165 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil) | |
10166 > \n | |
10167 > "// Next State Logic for " verilog-sk-state \n | |
10168 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10169 > "case (" '(verilog-sk-prompt-state-selector) ") " \n |
79545 | 10170 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n ) |
10171 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) | |
10172 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) | |
10173 | |
10174 | |
10175 ;; | |
10176 ;; Include file loading with mouse/return event | |
10177 ;; | |
10178 ;; idea & first impl.: M. Rouat (eldo-mode.el) | |
10179 ;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el) | |
10180 | |
10181 (if (featurep 'xemacs) | |
10182 (require 'overlay) | |
10183 (require 'lucid)) ;; what else can we do ?? | |
10184 | |
10185 (defconst verilog-include-file-regexp | |
10186 "^`include\\s-+\"\\([^\n\"]*\\)\"" | |
10187 "Regexp that matches the include file.") | |
10188 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10189 (defvar verilog-mode-mouse-map |
79545 | 10190 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
10191 (set-keymap-parent map verilog-mode-map) | |
10192 ;; mouse button bindings | |
10193 (define-key map "\r" 'verilog-load-file-at-point) | |
10194 (if (featurep 'xemacs) | |
10195 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ? | |
10196 (define-key map [mouse-2] 'verilog-load-file-at-mouse)) | |
10197 (if (featurep 'xemacs) | |
10198 (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
|
10199 (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
|
10200 map) |
79546 | 10201 "Map containing mouse bindings for `verilog-mode'.") |
10202 | |
79545 | 10203 |
10204 (defun verilog-colorize-include-files (beg end old-len) | |
10205 "This function colorizes included files when the mouse passes over them. | |
10206 Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |
10207 (save-excursion | |
10208 (save-match-data | |
10209 (let (end-point) | |
10210 (goto-char end) | |
10211 (setq end-point (verilog-get-end-of-line)) | |
10212 (goto-char beg) | |
10213 (beginning-of-line) ; scan entire line ! | |
10214 ;; delete overlays existing on this line | |
10215 (let ((overlays (overlays-in (point) end-point))) | |
10216 (while overlays | |
10217 (if (and | |
10218 (overlay-get (car overlays) 'detachable) | |
10219 (overlay-get (car overlays) 'verilog-include-file)) | |
10220 (delete-overlay (car overlays))) | |
10221 (setq overlays (cdr overlays)))) ; let | |
10222 ;; make new ones, could reuse deleted one ? | |
10223 (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
|
10224 (let (ov) |
79545 | 10225 (goto-char (match-beginning 1)) |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
10226 (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
|
10227 (overlay-put ov 'start-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
10228 (overlay-put ov 'end-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
10229 (overlay-put ov 'evaporate 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
10230 (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
|
10231 (overlay-put ov 'mouse-face 'highlight) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
10232 (overlay-put ov 'local-map verilog-mode-mouse-map))))))) |
79545 | 10233 |
10234 | |
10235 (defun verilog-colorize-include-files-buffer () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10236 "Colorize an include file." |
79545 | 10237 (interactive) |
10238 ;; delete overlays | |
10239 (let ((overlays (overlays-in (point-min) (point-max)))) | |
10240 (while overlays | |
10241 (if (and | |
10242 (overlay-get (car overlays) 'detachable) | |
10243 (overlay-get (car overlays) 'verilog-include-file)) | |
10244 (delete-overlay (car overlays))) | |
10245 (setq overlays (cdr overlays)))) ; let | |
10246 ;; remake overlays | |
10247 (verilog-colorize-include-files (point-min) (point-max) nil)) | |
10248 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10249 ;; ffap-at-mouse isn't useful for Verilog mode. It uses library paths. |
79545 | 10250 ;; so define this function to do more or less the same as ffap-at-mouse |
10251 ;; but first resolve filename... | |
10252 (defun verilog-load-file-at-mouse (event) | |
10253 "Load file under button 2 click's EVENT. | |
10254 Files are checked based on `verilog-library-directories'." | |
10255 (interactive "@e") | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10256 (save-excursion ;; implement a Verilog specific ffap-at-mouse |
79545 | 10257 (mouse-set-point event) |
10258 (beginning-of-line) | |
10259 (if (looking-at verilog-include-file-regexp) | |
10260 (if (and (car (verilog-library-filenames | |
10261 (match-string 1) (buffer-file-name))) | |
10262 (file-readable-p (car (verilog-library-filenames | |
10263 (match-string 1) (buffer-file-name))))) | |
10264 (find-file (car (verilog-library-filenames | |
10265 (match-string 1) (buffer-file-name)))) | |
10266 (progn | |
10267 (message | |
10268 "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
|
10269 (match-string 1))))))) |
79545 | 10270 |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10271 ;; ffap isn't useable for Verilog mode. It uses library paths. |
79545 | 10272 ;; so define this function to do more or less the same as ffap |
10273 ;; but first resolve filename... | |
10274 (defun verilog-load-file-at-point () | |
10275 "Load file under point. | |
10276 Files are checked based on `verilog-library-directories'." | |
10277 (interactive) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10278 (save-excursion ;; implement a Verilog specific ffap |
79545 | 10279 (beginning-of-line) |
10280 (if (looking-at verilog-include-file-regexp) | |
10281 (if (and | |
10282 (car (verilog-library-filenames | |
10283 (match-string 1) (buffer-file-name))) | |
10284 (file-readable-p (car (verilog-library-filenames | |
10285 (match-string 1) (buffer-file-name))))) | |
10286 (find-file (car (verilog-library-filenames | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10287 (match-string 1) (buffer-file-name)))))))) |
79545 | 10288 |
10289 | |
10290 ;; | |
10291 ;; Bug reporting | |
10292 ;; | |
10293 | |
10294 (defun verilog-faq () | |
10295 "Tell the user their current version, and where to get the FAQ etc." | |
10296 (interactive) | |
10297 (with-output-to-temp-buffer "*verilog-mode help*" | |
10298 (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) | |
10299 (princ "\n") | |
10300 (princ "For new releases, see http://www.verilog.com\n") | |
10301 (princ "\n") | |
10302 (princ "For frequently asked questions, see http://www.veripool.com/verilog-mode-faq.html\n") | |
10303 (princ "\n") | |
10304 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | |
10305 (princ "\n"))) | |
10306 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10307 (autoload 'reporter-submit-bug-report "reporter") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10308 (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
|
10309 |
79545 | 10310 (defun verilog-submit-bug-report () |
10311 "Submit via mail a bug report on verilog-mode.el." | |
10312 (interactive) | |
10313 (let ((reporter-prompt-for-summary-p t)) | |
10314 (reporter-submit-bug-report | |
10315 "mac@verilog.com" | |
10316 (concat "verilog-mode v" verilog-mode-version) | |
10317 '( | |
10318 verilog-align-ifelse | |
10319 verilog-auto-endcomments | |
10320 verilog-auto-hook | |
10321 verilog-auto-indent-on-newline | |
10322 verilog-auto-inst-vector | |
10323 verilog-auto-inst-template-numbers | |
10324 verilog-auto-lineup | |
10325 verilog-auto-newline | |
10326 verilog-auto-save-policy | |
10327 verilog-auto-sense-defines-constant | |
10328 verilog-auto-sense-include-inputs | |
10329 verilog-before-auto-hook | |
10330 verilog-case-indent | |
10331 verilog-cexp-indent | |
10332 verilog-compiler | |
10333 verilog-coverage | |
10334 verilog-highlight-translate-off | |
10335 verilog-indent-begin-after-if | |
10336 verilog-indent-declaration-macros | |
10337 verilog-indent-level | |
10338 verilog-indent-level-behavioral | |
10339 verilog-indent-level-declaration | |
10340 verilog-indent-level-directive | |
10341 verilog-indent-level-module | |
10342 verilog-indent-lists | |
10343 verilog-library-flags | |
10344 verilog-library-directories | |
10345 verilog-library-extensions | |
10346 verilog-library-files | |
10347 verilog-linter | |
10348 verilog-minimum-comment-distance | |
10349 verilog-mode-hook | |
10350 verilog-simulator | |
10351 verilog-tab-always-indent | |
10352 verilog-tab-to-comment | |
10353 ) | |
10354 nil nil | |
10355 (concat "Hi Mac, | |
10356 | |
10357 I want to report a bug. I've read the `Bugs' section of `Info' on | |
10358 Emacs, so I know how to make a clear and unambiguous report. To get | |
10359 to that Info section, I typed | |
10360 | |
10361 M-x info RET m " invocation-name " RET m bugs RET | |
10362 | |
10363 Before I go further, I want to say that Verilog mode has changed my life. | |
10364 I save so much time, my files are colored nicely, my co workers respect | |
10365 my coding ability... until now. I'd really appreciate anything you | |
10366 could do to help me out with this minor deficiency in the product. | |
10367 | |
10368 If you have bugs with the AUTO functions, please CC the AUTOAUTHOR Wilson | |
10369 Snyder (wsnyder@wsnyder.org) and/or see http://www.veripool.com. | |
10370 You may also want to look at the Verilog-Mode FAQ, see | |
10371 http://www.veripool.com/verilog-mode-faq.html. | |
10372 | |
10373 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
|
10374 -no-init-file -no-site-file'. In a new buffer, in Verilog mode, type |
79545 | 10375 the code included below. |
10376 | |
10377 Given those lines, I expected [[Fill in here]] to happen; | |
10378 but instead, [[Fill in here]] happens!. | |
10379 | |
10380 == The code: ==")))) | |
10381 | |
79546 | 10382 (provide 'verilog-mode) |
10383 | |
79545 | 10384 ;; Local Variables: |
10385 ;; checkdoc-permit-comma-termination-flag:t | |
10386 ;; checkdoc-force-docstrings-flag:nil | |
10387 ;; End: | |
10388 | |
79552 | 10389 ;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f |
79545 | 10390 ;;; verilog-mode.el ends here |