Mercurial > emacs
annotate lisp/progmodes/verilog-mode.el @ 106815:1d1d5d9bd884
Add 2010 to copyright years.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Wed, 13 Jan 2010 00:35:10 -0800 |
parents | cad98e90ecc5 |
children | d3738a1728c6 c1945e85d4b9 |
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, | |
106815 | 4 ;; 2005, 2006, 2007, 2008, 2009, 2010 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) | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
11 ;; http://www.veripool.org |
79545 | 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 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
57 ;; has bugs. Please report any issues to the issue tracker at |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
58 ;; http://www.veripool.org/verilog-mode |
79545 | 59 ;; Please use verilog-submit-bug-report to submit a report; type C-c |
60 ;; C-b to invoke this and as a result I will have a much easier time | |
61 ;; of reproducing the bug you find, and hence fixing it. | |
62 | |
63 ;; INSTALLING THE MODE | |
64 ;; =================== | |
65 | |
66 ;; An older version of this mode may be already installed as a part of | |
67 ;; 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
|
68 ;; your Emacs environment. Sometimes this is difficult for local |
79545 | 69 ;; political/control reasons, and hence you can always install a |
70 ;; private copy (or even a shared copy) which overrides the system | |
71 ;; default. | |
72 | |
73 ;; You can get step by step help in installing this file by going to | |
74 ;; <http://www.verilog.com/emacs_install.html> | |
75 | |
76 ;; 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
|
77 ;; automatic Verilog mode, put this file in your load path, and put |
79545 | 78 ;; the following in code (please un comment it first!) in your |
79 ;; .emacs, or in your site's site-load.el | |
80 | |
81 ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
82 ; (add-to-list 'auto-mode-alist '("\\.[ds]?v\\'" . verilog-mode)) |
79545 | 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 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
106 ; verilog-auto-lineup 'declarations |
79545 | 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 ;; |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
115 ;; See commit history at http://www.veripool.org/verilog-mode.html |
79799
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 | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
121 (defconst verilog-mode-version "556" |
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.") |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
123 (defconst verilog-mode-release-date "2009-12-10-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 |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
136 ;; Provide stuff if we are XEmacs |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
137 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
138 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
139 (require 'easymenu) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
140 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
141 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
142 (require 'regexp-opt) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
143 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
144 ;; 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
|
145 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
146 (load "skeleton") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
147 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
148 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
149 (if (fboundp 'when) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
150 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
151 (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
|
152 (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
|
153 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
154 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
155 (if (fboundp 'unless) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
156 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
157 (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
|
158 (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
|
159 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
160 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
161 (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
|
162 nil ;; fab |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
163 (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
|
164 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
165 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
166 (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
|
167 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
168 (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
|
169 (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
|
170 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
171 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
172 (require 'custom) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
173 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
174 (condition-case nil |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
175 (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
|
176 nil ;; great |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
177 (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
|
178 "Return string of text matched by last search, without text properties. |
79545 | 179 NUM specifies which parenthesized expression in the last regexp. |
180 Value is nil if NUMth pair didn't match, or there were less than NUM pairs. | |
181 Zero means the entire text matched by the whole regexp or whole string. | |
182 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
|
183 (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
|
184 (if string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
185 (let ((result |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
186 (substring string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
187 (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
|
188 (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
|
189 result) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
190 (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
|
191 (match-end num) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
192 (current-buffer))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
193 ) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
194 (error nil)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
195 (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
|
196 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
|
197 ;; 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
|
198 (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
|
199 (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
|
200 (message |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
201 "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
|
202 (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
|
203 `(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
|
204 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
205 (if (fboundp 'defface) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
206 nil ; great! |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
207 (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
|
208 `(make-face ,var)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
209 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
210 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
211 (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
|
212 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
|
213 ;; 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
|
214 (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
|
215 `(customize ,var)) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
216 )) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
217 ;; OK, do this stuff if we are NOT XEmacs: |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
218 (unless (featurep 'xemacs) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
219 (unless (fboundp 'region-active-p) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
220 (defmacro region-active-p () |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
221 `(and transient-mark-mode mark-active)))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
222 ) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
223 |
79545 | 224 ;; Provide a regular expression optimization routine, using regexp-opt |
225 ;; if provided by the user's elisp libraries | |
226 (eval-and-compile | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
227 ;; 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
|
228 ;; 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
|
229 (if (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
230 (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
|
231 ;; 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
|
232 (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
|
233 (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
|
234 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
235 ((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
|
236 (condition-case nil ; Hide this defun from emacses |
79545 | 237 ;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
|
238 (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
|
239 "Deal with differing number of required arguments for `regexp-opt'. |
79545 | 240 Call 'regexp-opt' on A and B." |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
241 (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
|
242 (error nil)) |
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 ((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
|
245 (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
|
246 "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
|
247 (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
|
248 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
249 (t nil))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
250 ;; 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
|
251 (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
|
252 "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
|
253 (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
|
254 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
255 ;; 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
|
256 (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
|
257 (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
|
258 (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
|
259 ) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
260 ;; Emacs. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
261 (defalias 'verilog-regexp-opt 'regexp-opt))) |
79545 | 262 |
79555
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
263 (eval-when-compile |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
264 (defun verilog-regexp-words (a) |
52d2889ab3d8
(set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79554
diff
changeset
|
265 "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
|
266 (concat "\\<" (verilog-regexp-opt a t) "\\>"))) |
79545 | 267 |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
268 (defun verilog-easy-menu-filter (menu) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
269 "Filter `easy-menu-define' MENU to support new features." |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
270 (cond ((not (featurep 'xemacs)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
271 menu) ;; GNU Emacs - passthru |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
272 ;; Xemacs doesn't support :help. Strip it. |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
273 ;; Recursively filter the a submenu |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
274 ((listp menu) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
275 (mapcar 'verilog-easy-menu-filter menu)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
276 ;; Look for [:help "blah"] and remove |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
277 ((vectorp menu) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
278 (let ((i 0) (out [])) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
279 (while (< i (length menu)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
280 (if (equal `:help (aref menu i)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
281 (setq i (+ 2 i)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
282 (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
|
283 i (1+ i)))) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
284 out)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
285 (t menu))) ;; Default - ok |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
286 ;;(verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
287 ;; `("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
|
288 ;; "----" ["MB" nil :help "Help MB"])) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
289 |
79545 | 290 (defun verilog-customize () |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
291 "Customize variables and other settings used by Verilog-Mode." |
79545 | 292 (interactive) |
293 (customize-group 'verilog-mode)) | |
294 | |
295 (defun verilog-font-customize () | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
296 "Customize fonts used by Verilog-Mode." |
79545 | 297 (interactive) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
298 (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
|
299 (customize-apropos "font-lock-*" 'faces))) |
79545 | 300 |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
301 (defun verilog-booleanp (value) |
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
302 "Return t if VALUE is boolean. |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
303 This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
304 This function may be removed when Emacs 21 is no longer supported." |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
305 (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
|
306 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
307 (defun verilog-insert-last-command-event () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
308 "Insert the `last-command-event'." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
309 (insert (if (featurep 'xemacs) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
310 ;; XEmacs 21.5 doesn't like last-command-event |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
311 last-command-char |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
312 ;; And GNU Emacs 22 has obsoleted last-command-char |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
313 last-command-event))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
314 |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
315 (defalias 'verilog-syntax-ppss |
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
316 (if (fboundp 'syntax-ppss) 'syntax-ppss |
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
317 (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
|
318 |
79545 | 319 (defgroup verilog-mode nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
320 "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
|
321 :version "22.2" |
79545 | 322 :group 'languages) |
323 | |
324 ; (defgroup verilog-mode-fonts nil | |
325 ; "Facilitates easy customization fonts used in Verilog source text" | |
326 ; :link '(customize-apropos "font-lock-*" 'faces) | |
327 ; :group 'verilog-mode) | |
328 | |
329 (defgroup verilog-mode-indent nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
330 "Customize indentation and highlighting of Verilog source text." |
79545 | 331 :group 'verilog-mode) |
332 | |
333 (defgroup verilog-mode-actions nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
334 "Customize actions on Verilog source text." |
79545 | 335 :group 'verilog-mode) |
336 | |
337 (defgroup verilog-mode-auto nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
338 "Customize AUTO actions when expanding Verilog source text." |
79545 | 339 :group 'verilog-mode) |
340 | |
341 (defcustom verilog-linter | |
342 "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
|
343 "*Unix program and arguments to call to run a lint checker on Verilog source. |
79545 | 344 Depending on the `verilog-set-compile-command', this may be invoked when |
345 you type \\[compile]. When the compile completes, \\[next-error] will take | |
346 you to the next lint error." | |
347 :type 'string | |
348 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
349 ;; We don't mark it safe, as it's used as a shell command |
79545 | 350 |
351 (defcustom verilog-coverage | |
352 "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
|
353 "*Program and arguments to use to annotate for coverage Verilog source. |
79545 | 354 Depending on the `verilog-set-compile-command', this may be invoked when |
355 you type \\[compile]. When the compile completes, \\[next-error] will take | |
356 you to the next lint error." | |
357 :type 'string | |
358 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
359 ;; We don't mark it safe, as it's used as a shell command |
79545 | 360 |
361 (defcustom verilog-simulator | |
362 "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
|
363 "*Program and arguments to use to interpret Verilog source. |
79545 | 364 Depending on the `verilog-set-compile-command', this may be invoked when |
365 you type \\[compile]. When the compile completes, \\[next-error] will take | |
366 you to the next lint error." | |
367 :type 'string | |
368 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
369 ;; We don't mark it safe, as it's used as a shell command |
79545 | 370 |
371 (defcustom verilog-compiler | |
372 "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
|
373 "*Program and arguments to use to compile Verilog source. |
79545 | 374 Depending on the `verilog-set-compile-command', this may be invoked when |
375 you type \\[compile]. When the compile completes, \\[next-error] will take | |
376 you to the next lint error." | |
377 :type 'string | |
378 :group 'verilog-mode-actions) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
379 ;; We don't mark it safe, as it's used as a shell command |
79545 | 380 |
381 (defvar verilog-tool 'verilog-linter | |
382 "Which tool to use for building compiler-command. | |
383 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or | |
384 `verilog-compiler. Alternatively use the \"Choose Compilation Action\" | |
385 menu. See `verilog-set-compile-command' for more information.") | |
386 | |
387 (defcustom verilog-highlight-translate-off nil | |
388 "*Non-nil means background-highlight code excluded from translation. | |
389 That is, all code between \"// synopsys translate_off\" and | |
390 \"// synopsys translate_on\" is highlighted using a different background color | |
391 \(face `verilog-font-lock-translate-off-face'). | |
392 | |
393 Note: This will slow down on-the-fly fontification (and thus editing). | |
394 | |
395 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu | |
396 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking." | |
397 :type 'boolean | |
398 :group 'verilog-mode-indent) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
399 ;; 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
|
400 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp) |
79545 | 401 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
402 (defcustom verilog-auto-lineup 'declarations |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
403 "*Type of statements to lineup across multiple lines. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
404 If 'all' is selected, then all line ups described below are done. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
405 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
406 If 'declaration', then just declarations are lined up with any |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
407 preceding declarations, taking into account widths and the like, |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
408 so or example the code: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
409 reg [31:0] a; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
410 reg b; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
411 would become |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
412 reg [31:0] a; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
413 reg b; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
414 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
415 If 'assignment', then assignments are lined up with any preceding |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
416 assignments, so for example the code |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
417 a_long_variable <= b + c; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
418 d = e + f; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
419 would become |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
420 a_long_variable <= b + c; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
421 d = e + f; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
422 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
423 In order to speed up editing, large blocks of statements are lined up |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
424 only when a \\[verilog-pretty-expr] is typed; and large blocks of declarations |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
425 are lineup only when \\[verilog-pretty-declarations] is typed." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
426 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
427 :type '(radio (const :tag "Line up Assignments and Declarations" all) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
428 (const :tag "Line up Assignment statements" assignments ) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
429 (const :tag "Line up Declarations" declarations) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
430 (function :tag "Other")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
431 :group 'verilog-mode-indent ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
432 |
79545 | 433 (defcustom verilog-indent-level 3 |
434 "*Indentation of Verilog statements with respect to containing block." | |
435 :group 'verilog-mode-indent | |
436 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
437 (put 'verilog-indent-level 'safe-local-variable 'integerp) |
79545 | 438 |
439 (defcustom verilog-indent-level-module 3 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
440 "*Indentation of Module level Verilog statements (eg always, initial). |
79545 | 441 Set to 0 to get initial and always statements lined up on the left side of |
442 your screen." | |
443 :group 'verilog-mode-indent | |
444 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
445 (put 'verilog-indent-level-module 'safe-local-variable 'integerp) |
79545 | 446 |
447 (defcustom verilog-indent-level-declaration 3 | |
448 "*Indentation of declarations with respect to containing block. | |
449 Set to 0 to get them list right under containing block." | |
450 :group 'verilog-mode-indent | |
451 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
452 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp) |
79545 | 453 |
454 (defcustom verilog-indent-declaration-macros nil | |
455 "*How to treat macro expansions in a declaration. | |
456 If nil, indent as: | |
457 input [31:0] a; | |
458 input `CP; | |
459 output c; | |
460 If non nil, treat as: | |
461 input [31:0] a; | |
462 input `CP ; | |
463 output c;" | |
464 :group 'verilog-mode-indent | |
465 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
466 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp) |
79545 | 467 |
468 (defcustom verilog-indent-lists t | |
469 "*How to treat indenting items in a list. | |
470 If t (the default), indent as: | |
471 always @( posedge a or | |
472 reset ) begin | |
473 | |
474 If nil, treat as: | |
475 always @( posedge a or | |
476 reset ) begin" | |
477 :group 'verilog-mode-indent | |
478 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
479 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp) |
79545 | 480 |
481 (defcustom verilog-indent-level-behavioral 3 | |
482 "*Absolute indentation of first begin in a task or function block. | |
483 Set to 0 to get such code to start at the left side of the screen." | |
484 :group 'verilog-mode-indent | |
485 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
486 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp) |
79545 | 487 |
488 (defcustom verilog-indent-level-directive 1 | |
489 "*Indentation to add to each level of `ifdef declarations. | |
490 Set to 0 to have all directives start at the left side of the screen." | |
491 :group 'verilog-mode-indent | |
492 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
493 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp) |
79545 | 494 |
495 (defcustom verilog-cexp-indent 2 | |
496 "*Indentation of Verilog statements split across lines." | |
497 :group 'verilog-mode-indent | |
498 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
499 (put 'verilog-cexp-indent 'safe-local-variable 'integerp) |
79545 | 500 |
501 (defcustom verilog-case-indent 2 | |
502 "*Indentation for case statements." | |
503 :group 'verilog-mode-indent | |
504 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
505 (put 'verilog-case-indent 'safe-local-variable 'integerp) |
79545 | 506 |
507 (defcustom verilog-auto-newline t | |
508 "*True means automatically newline after semicolons." | |
509 :group 'verilog-mode-indent | |
510 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
511 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 512 |
513 (defcustom verilog-auto-indent-on-newline t | |
514 "*True means automatically indent line after newline." | |
515 :group 'verilog-mode-indent | |
516 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
517 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp) |
79545 | 518 |
519 (defcustom verilog-tab-always-indent t | |
520 "*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
|
521 A nil value means TAB will only reindent when at the beginning of the line." |
79545 | 522 :group 'verilog-mode-indent |
523 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
524 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp) |
79545 | 525 |
526 (defcustom verilog-tab-to-comment nil | |
527 "*True means TAB moves to the right hand column in preparation for a comment." | |
528 :group 'verilog-mode-actions | |
529 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
530 (put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp) |
79545 | 531 |
532 (defcustom verilog-indent-begin-after-if t | |
533 "*If true, indent begin statements following if, else, while, for and repeat. | |
534 Otherwise, line them up." | |
535 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
536 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
537 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp) |
79545 | 538 |
539 | |
540 (defcustom verilog-align-ifelse nil | |
541 "*If true, align `else' under matching `if'. | |
542 Otherwise else is lined up with first character on line holding matching if." | |
543 :group 'verilog-mode-indent | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
544 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
545 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp) |
79545 | 546 |
547 (defcustom verilog-minimum-comment-distance 10 | |
548 "*Minimum distance (in lines) between begin and end required before a comment. | |
549 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
|
550 default avoids too many redundant comments in tight quarters." |
79545 | 551 :group 'verilog-mode-indent |
552 :type 'integer) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
553 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp) |
79545 | 554 |
555 (defcustom verilog-highlight-p1800-keywords nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
556 "*True means highlight words newly reserved by IEEE-1800. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
557 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
|
558 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
|
559 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
|
560 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
|
561 to see the effect as font color choices are cached by Emacs." |
79545 | 562 :group 'verilog-mode-indent |
563 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
564 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp) |
79545 | 565 |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
566 (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
|
567 "*True means highlight grouping keywords 'begin' and 'end' more dramatically. |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
568 If false, these words are in the `font-lock-type-face'; if True then they are in |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
569 `verilog-font-lock-ams-face'. Some find that special highlighting on these |
80267
c1d9521017f6
* verilog-mode.el (verilog-font-grouping-keywords): Fix bug in the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80261
diff
changeset
|
570 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
|
571 :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
|
572 :type 'boolean) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
573 (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
|
574 |
79545 | 575 (defcustom verilog-auto-endcomments t |
576 "*True means insert a comment /* ... */ after 'end's. | |
577 The name of the function or case will be set between the braces." | |
578 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
579 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
580 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp) |
79545 | 581 |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
582 (defcustom verilog-auto-ignore-concat nil |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
583 "*True means ignore signals in {...} concatenations for AUTOWIRE etc. |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
584 This will exclude signals referenced as pin connections in {...} |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
585 from AUTOWIRE, AUTOOUTPUT and friends. This flag should be set |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
586 for backward compatibility only and not set in new designs; it |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
587 may be removed in future versions." |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
588 :group 'verilog-mode-actions |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
589 :type 'boolean) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
590 (put 'verilog-auto-ignore-concat 'safe-local-variable 'verilog-booleanp) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
591 |
79545 | 592 (defcustom verilog-auto-read-includes nil |
593 "*True means to automatically read includes before AUTOs. | |
594 This will do a `verilog-read-defines' and `verilog-read-includes' before | |
595 each AUTO expansion. This makes it easier to embed defines and includes, | |
596 but can result in very slow reading times if there are many or large | |
597 include files." | |
598 :group 'verilog-mode-actions | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
599 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
600 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp) |
79545 | 601 |
602 (defcustom verilog-auto-save-policy nil | |
603 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs. | |
604 A value of `force' will always do a \\[verilog-auto] automatically if | |
605 needed on every save. A value of `detect' will do \\[verilog-auto] | |
606 automatically when it thinks necessary. A value of `ask' will query the | |
607 user when it thinks updating is needed. | |
608 | |
609 You should not rely on the 'ask or 'detect policies, they are safeguards | |
610 only. They do not detect when AUTOINSTs need to be updated because a | |
611 sub-module's port list has changed." | |
612 :group 'verilog-mode-actions | |
613 :type '(choice (const nil) (const ask) (const detect) (const force))) | |
614 | |
615 (defcustom verilog-auto-star-expand t | |
616 "*Non-nil indicates to expand a SystemVerilog .* instance ports. | |
617 They will be expanded in the same way as if there was a AUTOINST in the | |
618 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'." | |
619 :group 'verilog-mode-actions | |
620 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
621 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp) |
79545 | 622 |
623 (defcustom verilog-auto-star-save nil | |
624 "*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
|
625 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
|
626 Only meaningful to those created due to `verilog-auto-star-expand' being set. |
79545 | 627 |
628 Instead of setting this, you may want to use /*AUTOINST*/, which will | |
629 always be saved." | |
630 :group 'verilog-mode-actions | |
631 :type 'boolean) | |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
632 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp) |
79545 | 633 |
634 (defvar verilog-auto-update-tick nil | |
635 "Modification tick at which autos were last performed.") | |
636 | |
637 (defvar verilog-auto-last-file-locals nil | |
638 "Text from file-local-variables during last evaluation.") | |
639 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
640 ;;; Compile support |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
641 (require 'compile) |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
642 (defvar verilog-error-regexp-added nil) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
643 ; List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
644 ; for the formatting. |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
645 ; Here is the version for Emacs 22: |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
646 (defvar verilog-error-regexp-emacs-alist |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
647 '( |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
648 (verilog-xl-1 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
649 "\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
650 (verilog-xl-2 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
651 "([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
652 (verilog-IES |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
653 ".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
654 (verilog-surefire-1 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
655 "[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
656 (verilog-surefire-2 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
657 "\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 ) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
658 (verilog-verbose |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
659 "\ |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
660 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
661 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
662 (verilog-xsim |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
663 "\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
664 (verilog-vcs-1 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
665 "\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
666 (verilog-vcs-2 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
667 "Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
668 (verilog-vcs-3 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
669 "\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
670 (verilog-vcs-4 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
671 "syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
672 (verilog-verilator |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
673 "%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
674 (verilog-leda |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
675 "In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\): |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
676 .* |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
677 .* |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
678 .* |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
679 \\(Warning\\|Error\\|Failure\\)" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
680 )) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
681 ;; And the version for XEmacs: |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
682 (defvar verilog-error-regexp-xemacs-alist |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
683 '(verilog |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
684 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
685 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 ) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
686 ("\ |
79545 | 687 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ |
688 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
689 ; xsim |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
690 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED] |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
691 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
692 ; vcs |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
693 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
694 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
695 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
696 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
697 ; Verilator |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
698 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
699 ; verilog-xl |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
700 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
701 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
702 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
703 ; nc-verilog |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
704 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
705 ; Leda |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
706 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
707 ) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
708 ) |
79545 | 709 |
710 (defvar verilog-error-font-lock-keywords | |
711 '( | |
712 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t) | |
713 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t) | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
714 |
79545 | 715 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t) |
716 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t) | |
717 | |
718 ("\ | |
719 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
720 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
721 ("\ | |
722 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ | |
723 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t) | |
724 | |
725 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t) | |
726 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t) | |
727 | |
728 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t) | |
729 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t) | |
730 | |
731 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
732 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t) | |
733 | |
734 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
735 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t) | |
736 | |
737 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t) | |
738 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t) | |
739 ; vxl | |
740 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
741 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t) | |
742 | |
743 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t) | |
744 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t) | |
745 | |
746 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t) | |
747 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t) | |
748 ; nc-verilog | |
749 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t) | |
750 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t) | |
751 ; Leda | |
752 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t) | |
753 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t) | |
754 ) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
755 "*Keywords to also highlight in Verilog *compilation* buffers.") |
79545 | 756 |
757 (defcustom verilog-library-flags '("") | |
758 "*List of standard Verilog arguments to use for /*AUTOINST*/. | |
759 These arguments are used to find files for `verilog-auto', and match | |
760 the flags accepted by a standard Verilog-XL simulator. | |
761 | |
762 -f filename Reads more `verilog-library-flags' from the filename. | |
763 +incdir+dir Adds the directory to `verilog-library-directories'. | |
764 -Idir Adds the directory to `verilog-library-directories'. | |
765 -y dir Adds the directory to `verilog-library-directories'. | |
766 +libext+.v Adds the extensions to `verilog-library-extensions'. | |
767 -v filename Adds the filename to `verilog-library-files'. | |
768 | |
769 filename Adds the filename to `verilog-library-files'. | |
770 This is not recommended, -v is a better choice. | |
771 | |
772 You might want these defined in each file; put at the *END* of your file | |
773 something like: | |
774 | |
775 // Local Variables: | |
776 // verilog-library-flags:(\"-y dir -y otherdir\") | |
777 // End: | |
778 | |
779 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
|
780 are only insured to be correct when the file is first visited. Thus if you |
79545 | 781 have problems, use \\[find-alternate-file] RET to have these take effect. |
782 | |
783 See also the variables mentioned above." | |
784 :group 'verilog-mode-auto | |
785 :type '(repeat string)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
786 (put 'verilog-library-flags 'safe-local-variable 'listp) |
79545 | 787 |
788 (defcustom verilog-library-directories '(".") | |
789 "*List of directories when looking for files for /*AUTOINST*/. | |
790 The directory may be relative to the current file, or absolute. | |
791 Environment variables are also expanded in the directory names. | |
792 Having at least the current directory is a good idea. | |
793 | |
794 You might want these defined in each file; put at the *END* of your file | |
795 something like: | |
796 | |
797 // Local Variables: | |
798 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\") | |
799 // End: | |
800 | |
801 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
|
802 are only insured to be correct when the file is first visited. Thus if you |
79545 | 803 have problems, use \\[find-alternate-file] RET to have these take effect. |
804 | |
805 See also `verilog-library-flags', `verilog-library-files' | |
806 and `verilog-library-extensions'." | |
807 :group 'verilog-mode-auto | |
808 :type '(repeat file)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
809 (put 'verilog-library-directories 'safe-local-variable 'listp) |
79545 | 810 |
811 (defcustom verilog-library-files '() | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
812 "*List of files to search for modules. |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
813 AUTOINST will use this when it needs to resolve a module name. |
79545 | 814 This is a complete path, usually to a technology file with many standard |
815 cells defined in it. | |
816 | |
817 You might want these defined in each file; put at the *END* of your file | |
818 something like: | |
819 | |
820 // Local Variables: | |
821 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\") | |
822 // End: | |
823 | |
824 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
|
825 are only insured to be correct when the file is first visited. Thus if you |
79545 | 826 have problems, use \\[find-alternate-file] RET to have these take effect. |
827 | |
828 See also `verilog-library-flags', `verilog-library-directories'." | |
829 :group 'verilog-mode-auto | |
830 :type '(repeat directory)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
831 (put 'verilog-library-files 'safe-local-variable 'listp) |
79545 | 832 |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
833 (defcustom verilog-library-extensions '(".v" ".sv") |
79545 | 834 "*List of extensions to use when looking for files for /*AUTOINST*/. |
835 See also `verilog-library-flags', `verilog-library-directories'." | |
836 :type '(repeat string) | |
837 :group 'verilog-mode-auto) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
838 (put 'verilog-library-extensions 'safe-local-variable 'listp) |
79545 | 839 |
840 (defcustom verilog-active-low-regexp nil | |
841 "*If set, treat signals matching this regexp as active low. | |
842 This is used for AUTORESET and AUTOTIEOFF. For proper behavior, | |
843 you will probably also need `verilog-auto-reset-widths' set." | |
844 :group 'verilog-mode-auto | |
845 :type 'string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
846 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp) |
79545 | 847 |
848 (defcustom verilog-auto-sense-include-inputs nil | |
849 "*If true, AUTOSENSE should include all inputs. | |
850 If nil, only inputs that are NOT output signals in the same block are | |
851 included." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
852 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
853 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
854 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp) |
79545 | 855 |
856 (defcustom verilog-auto-sense-defines-constant nil | |
857 "*If true, AUTOSENSE should assume all defines represent constants. | |
858 When true, the defines will not be included in sensitivity lists. To | |
859 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
|
860 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
|
861 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
862 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
863 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp) |
79545 | 864 |
865 (defcustom verilog-auto-reset-widths t | |
866 "*If true, AUTORESET should determine the width of signals. | |
867 This is then used to set the width of the zero (32'h0 for example). This | |
868 is required by some lint tools that aren't smart enough to ignore widths of | |
869 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
|
870 the MSB or LSB of a signal inside an AUTORESET." |
79545 | 871 :type 'boolean |
872 :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
|
873 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp) |
79545 | 874 |
875 (defcustom verilog-assignment-delay "" | |
876 "*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
|
877 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
878 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
879 (put 'verilog-assignment-delay 'safe-local-variable 'stringp) |
79545 | 880 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
881 (defcustom verilog-auto-arg-sort nil |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
882 "*If set, AUTOARG signal names will be sorted, not in delaration order. |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
883 Declaration order is advantageous with order based instantiations |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
884 and is the default for backward compatibility. Sorted order |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
885 reduces changes when declarations are moved around in a file, and |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
886 it's bad practice to rely on order based instantiations anyhow." |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
887 :group 'verilog-mode-auto |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
888 :type 'boolean) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
889 (put 'verilog-auto-arg-sort 'safe-local-variable 'verilog-booleanp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
890 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
891 (defcustom verilog-auto-inst-param-value nil |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
892 "*If set, AUTOINST will replace parameters with the parameter value. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
893 If nil, leave parameters as symbolic names. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
894 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
895 Parameters must be in Verilog 2001 format #(...), and if a parameter is not |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
896 listed as such there (as when the default value is acceptable), it will not |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
897 be replaced, and will remain symbolic. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
898 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
899 For example, imagine a submodule uses parameters to declare the size of its |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
900 inputs. This is then used by a upper module: |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
901 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
902 module InstModule (o,i) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
903 parameter WIDTH; |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
904 input [WIDTH-1:0] i; |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
905 endmodule |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
906 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
907 module ExampInst; |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
908 InstModule |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
909 #(PARAM(10)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
910 instName |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
911 (/*AUTOINST*/ |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
912 .i (i[PARAM-1:0])); |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
913 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
914 Note even though PARAM=10, the AUTOINST has left the parameter as a |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
915 symbolic name. If `verilog-auto-inst-param-value' is set, this will |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
916 instead expand to: |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
917 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
918 module ExampInst; |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
919 InstModule |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
920 #(PARAM(10)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
921 instName |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
922 (/*AUTOINST*/ |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
923 .i (i[9:0]));" |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
924 :group 'verilog-mode-auto |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
925 :type 'boolean) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
926 (put 'verilog-auto-inst-param-value 'safe-local-variable 'verilog-booleanp) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
927 |
79545 | 928 (defcustom verilog-auto-inst-vector t |
929 "*If true, when creating default ports with AUTOINST, use bus subscripts. | |
930 If nil, skip the subscript when it matches the entire bus as declared in | |
931 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
|
932 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
|
933 speed up some simulators, but is less general and harder to read, so avoid." |
79545 | 934 :group 'verilog-mode-auto |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
935 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
936 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp) |
79545 | 937 |
938 (defcustom verilog-auto-inst-template-numbers nil | |
939 "*If true, when creating templated ports with AUTOINST, add a comment. | |
940 The comment will add the line number of the template that was used for that | |
941 port declaration. Setting this aids in debugging, but nil is suggested for | |
942 regular use to prevent large numbers of merge conflicts." | |
943 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
944 :type 'boolean) |
79801
1fc1252447c5
* progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79799
diff
changeset
|
945 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp) |
79545 | 946 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
947 (defcustom verilog-auto-inst-column 40 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
948 "*Indent-to column number for net name part of AUTOINST created pin." |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
949 :group 'verilog-mode-indent |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
950 :type 'integer) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
951 (put 'verilog-auto-inst-column 'safe-local-variable 'integerp) |
79545 | 952 |
953 (defcustom verilog-auto-input-ignore-regexp nil | |
954 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp. | |
955 See the \\[verilog-faq] for examples on using this." | |
956 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
957 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
958 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 959 |
960 (defcustom verilog-auto-inout-ignore-regexp nil | |
961 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp. | |
962 See the \\[verilog-faq] for examples on using this." | |
963 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
964 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
965 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 966 |
967 (defcustom verilog-auto-output-ignore-regexp nil | |
968 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp. | |
969 See the \\[verilog-faq] for examples on using this." | |
970 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
971 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
972 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 973 |
974 (defcustom verilog-auto-unused-ignore-regexp nil | |
975 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp. | |
976 See the \\[verilog-faq] for examples on using this." | |
977 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
978 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
979 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp) |
79545 | 980 |
981 (defcustom verilog-typedef-regexp nil | |
982 "*If non-nil, regular expression that matches Verilog-2001 typedef names. | |
983 For example, \"_t$\" matches typedefs named with _t, as in the C language." | |
984 :group 'verilog-mode-auto | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
985 :type 'string) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
986 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp) |
79545 | 987 |
988 (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
|
989 "*Hook run after Verilog mode is loaded." |
79545 | 990 :type 'hook |
991 :group 'verilog-mode) | |
992 | |
993 (defcustom verilog-auto-hook nil | |
994 "*Hook run after `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
995 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
996 :type 'hook) |
79545 | 997 |
998 (defcustom verilog-before-auto-hook nil | |
999 "*Hook run before `verilog-mode' updates AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1000 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1001 :type 'hook) |
79545 | 1002 |
1003 (defcustom verilog-delete-auto-hook nil | |
1004 "*Hook run after `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1005 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1006 :type 'hook) |
79545 | 1007 |
1008 (defcustom verilog-before-delete-auto-hook nil | |
1009 "*Hook run before `verilog-mode' deletes AUTOs." | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1010 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1011 :type 'hook) |
79545 | 1012 |
1013 (defcustom verilog-getopt-flags-hook nil | |
1014 "*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
|
1015 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1016 :type 'hook) |
79545 | 1017 |
1018 (defcustom verilog-before-getopt-flags-hook nil | |
1019 "*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
|
1020 :group 'verilog-mode-auto |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1021 :type 'hook) |
79545 | 1022 |
1023 (defvar verilog-imenu-generic-expression | |
1024 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4) | |
1025 ("*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
|
1026 "Imenu expression for Verilog mode. See `imenu-generic-expression'.") |
79545 | 1027 |
1028 ;; | |
1029 ;; provide a verilog-header function. | |
1030 ;; Customization variables: | |
1031 ;; | |
1032 (defvar verilog-date-scientific-format nil | |
1033 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17). | |
1034 If nil, in European format (e.g. 17.09.1997). The brain-dead American | |
1035 format (e.g. 09/17/1997) is not supported.") | |
1036 | |
1037 (defvar verilog-company nil | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1038 "*Default name of Company for Verilog header. |
79545 | 1039 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
|
1040 (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
|
1041 |
79545 | 1042 (defvar verilog-project nil |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1043 "*Default name of Project for Verilog header. |
79545 | 1044 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
|
1045 (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
|
1046 |
79549
d9595ed9b084
* progmodes/verilog-mode.el (verilog-mode-map): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79547
diff
changeset
|
1047 (defvar verilog-mode-map |
79546 | 1048 (let ((map (make-sparse-keymap))) |
1049 (define-key map ";" 'electric-verilog-semi) | |
1050 (define-key map [(control 59)] 'electric-verilog-semi-with-comment) | |
1051 (define-key map ":" 'electric-verilog-colon) | |
1052 ;;(define-key map "=" 'electric-verilog-equal) | |
1053 (define-key map "\`" 'electric-verilog-tick) | |
1054 (define-key map "\t" 'electric-verilog-tab) | |
1055 (define-key map "\r" 'electric-verilog-terminate-line) | |
1056 ;; backspace/delete key bindings | |
1057 (define-key map [backspace] 'backward-delete-char-untabify) | |
1058 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable | |
1059 (define-key map [delete] 'delete-char) | |
1060 (define-key map [(meta delete)] 'kill-word)) | |
1061 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp) | |
1062 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp) | |
1063 (define-key map "\M-\r" `electric-verilog-terminate-and-indent) | |
1064 (define-key map "\M-\t" 'verilog-complete-word) | |
1065 (define-key map "\M-?" 'verilog-show-completions) | |
1066 (define-key map "\C-c\`" 'verilog-lint-off) | |
1067 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit) | |
1068 (define-key map "\C-c\C-r" 'verilog-label-be) | |
1069 (define-key map "\C-c\C-i" 'verilog-pretty-declarations) | |
1070 (define-key map "\C-c=" 'verilog-pretty-expr) | |
1071 (define-key map "\C-c\C-b" 'verilog-submit-bug-report) | |
1072 (define-key map "\M-*" 'verilog-star-comment) | |
1073 (define-key map "\C-c\C-c" 'verilog-comment-region) | |
1074 (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
|
1075 (when (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
1076 (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
|
1077 (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
|
1078 (define-key map "\M-\C-e" 'verilog-end-of-defun)) |
79546 | 1079 (define-key map "\C-c\C-d" 'verilog-goto-defun) |
1080 (define-key map "\C-c\C-k" 'verilog-delete-auto) | |
1081 (define-key map "\C-c\C-a" 'verilog-auto) | |
1082 (define-key map "\C-c\C-s" 'verilog-auto-save-compile) | |
1083 (define-key map "\C-c\C-z" 'verilog-inject-auto) | |
1084 (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
|
1085 (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
|
1086 map) |
79545 | 1087 "Keymap used in Verilog mode.") |
1088 | |
1089 ;; menus | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1090 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1091 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
|
1092 (verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1093 '("Verilog" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1094 ("Choose Compilation Action" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1095 ["None" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1096 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1097 (setq verilog-tool nil) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1098 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1099 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1100 :selected (equal verilog-tool nil) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1101 :help "When invoking compilation, use compile-command"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1102 ["Lint" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1103 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1104 (setq verilog-tool 'verilog-linter) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1105 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1106 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1107 :selected (equal verilog-tool `verilog-linter) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1108 :help "When invoking compilation, use lint checker"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1109 ["Coverage" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1110 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1111 (setq verilog-tool 'verilog-coverage) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1112 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1113 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1114 :selected (equal verilog-tool `verilog-coverage) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1115 :help "When invoking compilation, annotate for coverage"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1116 ["Simulator" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1117 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1118 (setq verilog-tool 'verilog-simulator) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1119 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1120 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1121 :selected (equal verilog-tool `verilog-simulator) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1122 :help "When invoking compilation, interpret Verilog source"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1123 ["Compiler" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1124 (progn |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1125 (setq verilog-tool 'verilog-compiler) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1126 (verilog-set-compile-command)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1127 :style radio |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1128 :selected (equal verilog-tool `verilog-compiler) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1129 :help "When invoking compilation, compile Verilog source"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1130 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1131 ("Move" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1132 ["Beginning of function" verilog-beg-of-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1133 :keys "C-M-a" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1134 :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
|
1135 ["End of function" verilog-end-of-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1136 :keys "C-M-e" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1137 :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
|
1138 ["Mark function" verilog-mark-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1139 :keys "C-M-h" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1140 :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
|
1141 ["Goto function/module" verilog-goto-defun |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1142 :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
|
1143 ["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
|
1144 :help "Move backward over one balanced expression"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1145 ["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
|
1146 :help "Move forward over one balanced expression"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1147 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1148 ("Comments" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1149 ["Comment Region" verilog-comment-region |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1150 :help "Put marked area into a comment"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1151 ["UnComment Region" verilog-uncomment-region |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1152 :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
|
1153 ["Multi-line comment insert" verilog-star-comment |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1154 :help "Insert Verilog /* */ comment at point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1155 ["Lint error to comment" verilog-lint-off |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1156 :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
|
1157 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1158 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1159 ["Compile" compile |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1160 :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
|
1161 ["AUTO, Save, Compile" verilog-auto-save-compile |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1162 :help "Recompute AUTOs, save buffer, and compile"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1163 ["Next Compile Error" next-error |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1164 :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
|
1165 ["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
|
1166 :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
|
1167 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1168 ["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
|
1169 :help "Line up declarations around point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1170 ["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
|
1171 :help "Line up expressions around point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1172 ["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
|
1173 :help "Label matching begin ... end statements"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1174 ["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
|
1175 :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
|
1176 ["Insert begin-end block" verilog-insert-block |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1177 :help "Insert begin ... end"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1178 ["Complete word" verilog-complete-word |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1179 :help "Complete word at point"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1180 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1181 ["Recompute AUTOs" verilog-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1182 :help "Expand AUTO meta-comment statements"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1183 ["Kill AUTOs" verilog-delete-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1184 :help "Remove AUTO expansions"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1185 ["Inject AUTOs" verilog-inject-auto |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1186 :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
|
1187 ("AUTO Help..." |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1188 ["AUTO General" (describe-function 'verilog-auto) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1189 :help "Help introduction on AUTOs"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1190 ["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
|
1191 :help "Help on verilog-library-flags"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1192 ["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
|
1193 :help "Help on verilog-library-directories"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1194 ["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
|
1195 :help "Help on verilog-library-files"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1196 ["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
|
1197 :help "Help on verilog-library-extensions"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1198 ["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
|
1199 :help "Help on reading `defines"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1200 ["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
|
1201 :help "Help on parsing `includes"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1202 ["AUTOARG" (describe-function 'verilog-auto-arg) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1203 :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
|
1204 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1205 :help "Help on AUTOASCIIENUM - creating ASCII for enumerations"] |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1206 ["AUTOINOUTCOMP" (describe-function 'verilog-auto-inout-comp) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1207 :help "Help on AUTOINOUTCOMP - copying complemented i/o from another file"] |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1208 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1209 :help "Help on AUTOINOUTMODULE - copying i/o from another file"] |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1210 ["AUTOINSERTLISP" (describe-function 'verilog-auto-insert-lisp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1211 :help "Help on AUTOINSERTLISP - insert text from a lisp function"] |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1212 ["AUTOINOUT" (describe-function 'verilog-auto-inout) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1213 :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
|
1214 ["AUTOINPUT" (describe-function 'verilog-auto-input) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1215 :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
|
1216 ["AUTOINST" (describe-function 'verilog-auto-inst) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1217 :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
|
1218 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1219 :help "Help on expanding Verilog-2001 .* pins"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1220 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1221 :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
|
1222 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1223 :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
|
1224 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1225 :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
|
1226 ["AUTOREG" (describe-function 'verilog-auto-reg) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1227 :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
|
1228 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1229 :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
|
1230 ["AUTORESET" (describe-function 'verilog-auto-reset) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1231 :help "Help on AUTORESET - resetting always blocks"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1232 ["AUTOSENSE" (describe-function 'verilog-auto-sense) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1233 :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
|
1234 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1235 :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
|
1236 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1237 :help "Help on AUTOUNUSED - terminating unused inputs"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1238 ["AUTOWIRE" (describe-function 'verilog-auto-wire) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1239 :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
|
1240 ) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1241 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1242 ["Submit bug report" verilog-submit-bug-report |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1243 :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
|
1244 ["Version and FAQ" verilog-faq |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1245 :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
|
1246 ["Customize Verilog Mode..." verilog-customize |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1247 :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
|
1248 ["Customize Verilog Fonts & Colors" verilog-font-customize |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1249 :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
|
1250 |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1251 (easy-menu-define |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
1252 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
|
1253 (verilog-easy-menu-filter |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1254 '("Statements" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1255 ["Header" verilog-sk-header |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1256 :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
|
1257 ["Comment" verilog-sk-comment |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1258 :help "Insert a comment block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1259 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1260 ["Module" verilog-sk-module |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1261 :help "Insert a module .. (/*AUTOARG*/);.. endmodule block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1262 ["Primitive" verilog-sk-primitive |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1263 :help "Insert a primitive .. (.. );.. endprimitive block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1264 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1265 ["Input" verilog-sk-input |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1266 :help "Insert an input declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1267 ["Output" verilog-sk-output |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1268 :help "Insert an output declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1269 ["Inout" verilog-sk-inout |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1270 :help "Insert an inout declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1271 ["Wire" verilog-sk-wire |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1272 :help "Insert a wire declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1273 ["Reg" verilog-sk-reg |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1274 :help "Insert a register declaration"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1275 ["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
|
1276 :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
|
1277 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1278 ["Initial" verilog-sk-initial |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1279 :help "Insert an initial begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1280 ["Always" verilog-sk-always |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1281 :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
|
1282 ["Function" verilog-sk-function |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1283 :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
|
1284 ["Task" verilog-sk-task |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1285 :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
|
1286 ["Specify" verilog-sk-specify |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1287 :help "Insert a specify .. endspecify block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1288 ["Generate" verilog-sk-generate |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1289 :help "Insert a generate .. endgenerate block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1290 "----" |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1291 ["Begin" verilog-sk-begin |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1292 :help "Insert a begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1293 ["If" verilog-sk-if |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1294 :help "Insert an if (..) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1295 ["(if) else" verilog-sk-else-if |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1296 :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
|
1297 ["For" verilog-sk-for |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1298 :help "Insert a for (...) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1299 ["While" verilog-sk-while |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1300 :help "Insert a while (...) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1301 ["Fork" verilog-sk-fork |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1302 :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
|
1303 ["Repeat" verilog-sk-repeat |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1304 :help "Insert a repeat (..) begin .. end block"] |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1305 ["Case" verilog-sk-case |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1306 :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
|
1307 ["Casex" verilog-sk-casex |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1308 :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
|
1309 ["Casez" verilog-sk-casez |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
1310 :help "Insert a casez (...) item: begin.. end endcase block"]))) |
79545 | 1311 |
1312 (defvar verilog-mode-abbrev-table nil | |
1313 "Abbrev table in use in Verilog-mode buffers.") | |
1314 | |
1315 (define-abbrev-table 'verilog-mode-abbrev-table ()) | |
1316 | |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1317 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1318 ;; Macros |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1319 ;; |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1320 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1321 (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
|
1322 "Replace occurrences of FROM-STRING with TO-STRING. |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 ;; Hopefully soon to a emacs built-in |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1327 (let ((start 0)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1328 (while (string-match from-string string start) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1329 (setq string (replace-match to-string fixedcase literal string) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1330 start (min (length string) (+ (match-beginning 0) (length to-string))))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1331 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1332 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1333 (defsubst verilog-string-remove-spaces (string) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1334 "Remove spaces surrounding STRING." |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1335 (save-match-data |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1336 (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
|
1337 (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
|
1338 string)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1339 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1340 (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1341 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1342 "Like `re-search-forward', but skips over match in comments or strings." |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1343 (let ((mdata '(nil nil))) ;; So match-end will return nil if no matches found |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1344 (while (and |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1345 (re-search-forward REGEXP BOUND NOERROR) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1346 (setq mdata (match-data)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1347 (and (verilog-skip-forward-comment-or-string) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1348 (progn |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1349 (setq mdata '(nil nil)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1350 (if BOUND |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1351 (< (point) BOUND) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1352 t))))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1353 (store-match-data mdata) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1354 (match-end 0))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1355 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1356 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1357 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1358 "Like `re-search-backward', but skips over match in comments or strings." |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1359 (let ((mdata '(nil nil))) ;; So match-end will return nil if no matches found |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1360 (while (and |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1361 (re-search-backward REGEXP BOUND NOERROR) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1362 (setq mdata (match-data)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1363 (and (verilog-skip-backward-comment-or-string) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1364 (progn |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1365 (setq mdata '(nil nil)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1366 (if BOUND |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1367 (> (point) BOUND) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1368 t))))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1369 (store-match-data mdata) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
1370 (match-end 0))) |
79547
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1371 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1372 (defsubst verilog-re-search-forward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1373 "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
|
1374 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
|
1375 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
|
1376 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
|
1377 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1378 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1379 (re-search-forward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1380 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1381 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1382 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1383 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1384 (defsubst verilog-re-search-backward-quick (regexp bound noerror) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1385 ; checkdoc-params: (REGEXP BOUND NOERROR) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1386 "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
|
1387 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
|
1388 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
|
1389 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
|
1390 (let (pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1391 (while (and (not pt) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1392 (re-search-backward regexp bound noerror)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1393 (if (not (verilog-inside-comment-p)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1394 (setq pt (match-end 0)))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1395 pt)) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1396 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1397 (defsubst verilog-get-beg-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1398 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1399 (beginning-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1400 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1401 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1402 (defsubst verilog-get-end-of-line (&optional arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1403 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1404 (end-of-line arg) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1405 (point))) |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1406 |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1407 (defsubst verilog-within-string () |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1408 (save-excursion |
46725aa288e8
(verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79546
diff
changeset
|
1409 (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
|
1410 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1411 (defvar compile-command) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1412 |
79545 | 1413 ;; compilation program |
1414 (defun verilog-set-compile-command () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1415 "Function to compute shell command to compile Verilog. |
79545 | 1416 |
1417 This reads `verilog-tool' and sets `compile-command'. This specifies the | |
1418 program that executes when you type \\[compile] or | |
1419 \\[verilog-auto-save-compile]. | |
1420 | |
1421 By default `verilog-tool' uses a Makefile if one exists in the current | |
1422 directory. If not, it is set to the `verilog-linter', `verilog-coverage', | |
1423 `verilog-simulator', or `verilog-compiler' variables, as selected with the | |
1424 Verilog -> \"Choose Compilation Action\" menu. | |
1425 | |
1426 You should set `verilog-tool' or the other variables to the path and | |
1427 arguments for your Verilog simulator. For example: | |
1428 \"vcs -p123 -O\" | |
1429 or a string like: | |
1430 \"(cd /tmp; surecov %s)\". | |
1431 | |
1432 In the former case, the path to the current buffer is concat'ed to the | |
1433 value of `verilog-tool'; in the later, the path to the current buffer is | |
1434 substituted for the %s. | |
1435 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
1436 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
|
1437 current buffer, without the directory portion, will be substituted." |
79545 | 1438 (interactive) |
1439 (cond | |
1440 ((or (file-exists-p "makefile") ;If there is a makefile, use it | |
1441 (file-exists-p "Makefile")) | |
1442 (make-local-variable 'compile-command) | |
1443 (setq compile-command "make ")) | |
1444 (t | |
1445 (make-local-variable 'compile-command) | |
1446 (setq compile-command | |
1447 (if verilog-tool | |
1448 (if (string-match "%s" (eval verilog-tool)) | |
1449 (format (eval verilog-tool) (or buffer-file-name "")) | |
1450 (concat (eval verilog-tool) " " (or buffer-file-name ""))) | |
1451 "")))) | |
1452 (verilog-modify-compile-command)) | |
1453 | |
1454 (defun verilog-modify-compile-command () | |
1455 "Replace meta-information in `compile-command'. | |
1456 Where __FILE__ appears in the string, the current buffer's file-name, | |
1457 without the directory portion, will be substituted." | |
1458 (when (and | |
1459 (stringp compile-command) | |
1460 (string-match "\\b__FILE__\\b" compile-command)) | |
1461 (make-local-variable 'compile-command) | |
1462 (setq compile-command | |
1463 (verilog-string-replace-matches | |
1464 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) | |
1465 t t compile-command)))) | |
1466 | |
103980
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1467 (if (featurep 'xemacs) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1468 ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling. |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1469 (defun verilog-error-regexp-add-xemacs () |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1470 "Teach XEmacs about verilog errors. |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
1471 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
|
1472 find the errors." |
103980
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1473 (interactive) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1474 (if (boundp 'compilation-error-regexp-systems-alist) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1475 (if (and |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1476 (not (equal compilation-error-regexp-systems-list 'all)) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1477 (not (member compilation-error-regexp-systems-list 'verilog))) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1478 (push 'verilog compilation-error-regexp-systems-list))) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1479 (if (boundp 'compilation-error-regexp-alist-alist) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1480 (if (not (assoc 'verilog compilation-error-regexp-alist-alist)) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1481 (setcdr compilation-error-regexp-alist-alist |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1482 (cons verilog-error-regexp-xemacs-alist |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1483 (cdr compilation-error-regexp-alist-alist))))) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1484 (if (boundp 'compilation-font-lock-keywords) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1485 (progn |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1486 (make-local-variable 'compilation-font-lock-keywords) |
103980
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1487 (setq compilation-font-lock-keywords verilog-error-font-lock-keywords) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1488 (font-lock-set-defaults))) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1489 ;; Need to re-run compilation-error-regexp builder |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1490 (if (fboundp 'compilation-build-compilation-error-regexp-alist) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1491 (compilation-build-compilation-error-regexp-alist)) |
60489d78df5a
(verilog-error-regexp-add-xemacs): Silence compiler by only defining on XEmacs.
Glenn Morris <rgm@gnu.org>
parents:
103734
diff
changeset
|
1492 )) |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1493 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1494 ;; Following code only gets called from compilation-mode-hook on Emacs to add error handling. |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1495 (defun verilog-error-regexp-add-emacs () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1496 "Tell Emacs compile that we are Verilog. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1497 Called by `compilation-mode-hook'. This allows \\[next-error] to |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1498 find the errors." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1499 (interactive) |
103734
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1500 (if (boundp 'compilation-error-regexp-alist-alist) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1501 (progn |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1502 (if (not (assoc 'verilog-xl-1 compilation-error-regexp-alist-alist)) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1503 (mapcar |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1504 (lambda (item) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1505 (push (car item) compilation-error-regexp-alist) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1506 (push item compilation-error-regexp-alist-alist) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1507 ) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1508 verilog-error-regexp-emacs-alist))))) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1509 |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1510 (if (featurep 'xemacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-xemacs)) |
503d12c87acd
(verilog-error-regexp-emacs-alist): Coded custom
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103616
diff
changeset
|
1511 (if (featurep 'emacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs)) |
79545 | 1512 |
1513 (defconst verilog-directive-re | |
1514 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" | |
1515 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
1516 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
1517 ;; "`time_scale" "`undef" "`while" | |
1518 "\\<`\\(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\\)\\>") | |
1519 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1520 (defconst verilog-directive-re-1 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1521 (concat "[ \t]*" verilog-directive-re)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1522 |
79545 | 1523 (defconst verilog-directive-begin |
1524 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>") | |
1525 | |
1526 (defconst verilog-directive-middle | |
1527 "\\<`\\(else\\|default\\|case\\)\\>") | |
1528 | |
1529 (defconst verilog-directive-end | |
1530 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>") | |
1531 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1532 (defconst verilog-ovm-begin-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1533 (eval-when-compile |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1534 (verilog-regexp-opt |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1535 '( |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1536 "`ovm_component_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1537 "`ovm_component_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1538 "`ovm_field_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1539 "`ovm_object_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1540 "`ovm_object_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1541 "`ovm_sequence_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1542 "`ovm_sequencer_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1543 ) nil ))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1544 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1545 (defconst verilog-ovm-end-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1546 (eval-when-compile |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1547 (verilog-regexp-opt |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1548 '( |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1549 "`ovm_component_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1550 "`ovm_field_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1551 "`ovm_object_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1552 "`ovm_sequence_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1553 "`ovm_sequencer_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1554 ) nil ))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1555 |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1556 (defconst verilog-vmm-begin-re |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1557 (eval-when-compile |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1558 (verilog-regexp-opt |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1559 '( |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1560 "`vmm_data_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1561 "`vmm_env_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1562 "`vmm_scenario_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1563 "`vmm_subenv_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1564 "`vmm_xactor_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1565 ) nil ) ) ) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1566 |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1567 (defconst verilog-vmm-end-re |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1568 (eval-when-compile |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1569 (verilog-regexp-opt |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1570 '( |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1571 "`vmm_data_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1572 "`vmm_env_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1573 "`vmm_scenario_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1574 "`vmm_subenv_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1575 "`vmm_xactor_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1576 ) nil ) ) ) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1577 |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1578 (defconst verilog-vmm-statement-re |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1579 (eval-when-compile |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1580 (verilog-regexp-opt |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1581 '( |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1582 ;; "`vmm_xactor_member_enum_array" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1583 "`vmm_\\(data\\|env\\|scenario\\|subenv\\|xactor\\)_member_\\(scalar\\|string\\|enum\\|vmm_data\\|channel\\|xactor\\|subenv\\|user_defined\\)\\(_array\\)?" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1584 ;; "`vmm_xactor_member_scalar_array" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1585 ;; "`vmm_xactor_member_scalar" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1586 ) nil ))) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1587 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1588 (defconst verilog-ovm-statement-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1589 (eval-when-compile |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1590 (verilog-regexp-opt |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1591 '( |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1592 ;; Statements |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1593 "`DUT_ERROR" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1594 "`MESSAGE" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1595 "`dut_error" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1596 "`message" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1597 "`ovm_analysis_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1598 "`ovm_blocking_get_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1599 "`ovm_blocking_get_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1600 "`ovm_blocking_master_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1601 "`ovm_blocking_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1602 "`ovm_blocking_put_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1603 "`ovm_blocking_slave_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1604 "`ovm_blocking_transport_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1605 "`ovm_component_registry" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1606 "`ovm_component_registry_param" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1607 "`ovm_component_utils" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1608 "`ovm_create" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1609 "`ovm_create_seq" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1610 "`ovm_declare_sequence_lib" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1611 "`ovm_do" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1612 "`ovm_do_seq" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1613 "`ovm_do_seq_with" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1614 "`ovm_do_with" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1615 "`ovm_error" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1616 "`ovm_fatal" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1617 "`ovm_field_aa_int_byte" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1618 "`ovm_field_aa_int_byte_unsigned" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1619 "`ovm_field_aa_int_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1620 "`ovm_field_aa_int_int_unsigned" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1621 "`ovm_field_aa_int_integer" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1622 "`ovm_field_aa_int_integer_unsigned" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1623 "`ovm_field_aa_int_key" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1624 "`ovm_field_aa_int_longint" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1625 "`ovm_field_aa_int_longint_unsigned" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1626 "`ovm_field_aa_int_shortint" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1627 "`ovm_field_aa_int_shortint_unsigned" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1628 "`ovm_field_aa_int_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1629 "`ovm_field_aa_object_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1630 "`ovm_field_aa_object_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1631 "`ovm_field_aa_string_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1632 "`ovm_field_aa_string_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1633 "`ovm_field_array_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1634 "`ovm_field_array_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1635 "`ovm_field_array_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1636 "`ovm_field_enum" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1637 "`ovm_field_event" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1638 "`ovm_field_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1639 "`ovm_field_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1640 "`ovm_field_queue_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1641 "`ovm_field_queue_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1642 "`ovm_field_queue_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1643 "`ovm_field_sarray_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1644 "`ovm_field_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1645 "`ovm_field_utils" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1646 "`ovm_file" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1647 "`ovm_get_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1648 "`ovm_get_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1649 "`ovm_info" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1650 "`ovm_info1" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1651 "`ovm_info2" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1652 "`ovm_info3" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1653 "`ovm_info4" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1654 "`ovm_line" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1655 "`ovm_master_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1656 "`ovm_msg_detail" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1657 "`ovm_non_blocking_transport_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1658 "`ovm_nonblocking_get_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1659 "`ovm_nonblocking_get_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1660 "`ovm_nonblocking_master_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1661 "`ovm_nonblocking_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1662 "`ovm_nonblocking_put_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1663 "`ovm_nonblocking_slave_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1664 "`ovm_object_registry" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1665 "`ovm_object_registry_param" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1666 "`ovm_object_utils" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1667 "`ovm_peek_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1668 "`ovm_phase_func_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1669 "`ovm_phase_task_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1670 "`ovm_print_aa_int_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1671 "`ovm_print_aa_string_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1672 "`ovm_print_aa_string_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1673 "`ovm_print_aa_string_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1674 "`ovm_print_array_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1675 "`ovm_print_array_object" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1676 "`ovm_print_array_string" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1677 "`ovm_print_object_queue" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1678 "`ovm_print_queue_int" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1679 "`ovm_print_string_queue" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1680 "`ovm_put_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1681 "`ovm_rand_send" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1682 "`ovm_rand_send_with" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1683 "`ovm_send" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1684 "`ovm_sequence_utils" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1685 "`ovm_slave_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1686 "`ovm_transport_imp_decl" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1687 "`ovm_update_sequence_lib" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1688 "`ovm_update_sequence_lib_and_item" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1689 "`ovm_warning" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1690 "`static_dut_error" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1691 "`static_message") nil ))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1692 |
79545 | 1693 |
1694 ;; | |
1695 ;; Regular expressions used to calculate indent, etc. | |
1696 ;; | |
1697 (defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>") | |
1698 ;; Want to match | |
1699 ;; aa : | |
1700 ;; aa,bb : | |
1701 ;; a[34:32] : | |
1702 ;; a, | |
1703 ;; b : | |
1704 | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1705 (defconst verilog-label-re (concat verilog-symbol-re "\\s-*:\\s-*")) |
79545 | 1706 (defconst verilog-no-indent-begin-re |
1707 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>") | |
1708 | |
1709 (defconst verilog-ends-re | |
1710 ;; Parenthesis indicate type of keyword found | |
1711 (concat | |
1712 "\\(\\<else\\>\\)\\|" ; 1 | |
1713 "\\(\\<if\\>\\)\\|" ; 2 | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1714 "\\(\\<assert\\>\\)\\|" ; 3 |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1715 "\\(\\<end\\>\\)\\|" ; 3.1 |
79545 | 1716 "\\(\\<endcase\\>\\)\\|" ; 4 |
1717 "\\(\\<endfunction\\>\\)\\|" ; 5 | |
1718 "\\(\\<endtask\\>\\)\\|" ; 6 | |
1719 "\\(\\<endspecify\\>\\)\\|" ; 7 | |
1720 "\\(\\<endtable\\>\\)\\|" ; 8 | |
1721 "\\(\\<endgenerate\\>\\)\\|" ; 9 | |
1722 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10 | |
1723 "\\(\\<endclass\\>\\)\\|" ; 11 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1724 "\\(\\<endgroup\\>\\)\\|" ; 12 |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1725 ;; VMM |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1726 "\\(\\<`vmm_data_member_end\\>\\)\\|" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1727 "\\(\\<`vmm_env_member_end\\>\\)\\|" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1728 "\\(\\<`vmm_scenario_member_end\\>\\)\\|" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1729 "\\(\\<`vmm_subenv_member_end\\>\\)\\|" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1730 "\\(\\<`vmm_xactor_member_end\\>\\)\\|" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1731 ;; OVM |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1732 "\\(\\<`ovm_component_utils_end\\>\\)\\|" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1733 "\\(\\<`ovm_field_utils_end\\>\\)\\|" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1734 "\\(\\<`ovm_object_utils_end\\>\\)\\|" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1735 "\\(\\<`ovm_sequence_utils_end\\>\\)\\|" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1736 "\\(\\<`ovm_sequencer_utils_end\\>\\)" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1737 |
79545 | 1738 )) |
1739 | |
1740 (defconst verilog-auto-end-comment-lines-re | |
1741 ;; Matches to names in this list cause auto-end-commentation | |
1742 (concat "\\(" | |
1743 verilog-directive-re "\\)\\|\\(" | |
1744 (eval-when-compile | |
1745 (verilog-regexp-words | |
1746 `( "begin" | |
1747 "else" | |
1748 "end" | |
1749 "endcase" | |
1750 "endclass" | |
1751 "endclocking" | |
1752 "endgroup" | |
1753 "endfunction" | |
1754 "endmodule" | |
1755 "endprogram" | |
1756 "endprimitive" | |
1757 "endinterface" | |
1758 "endpackage" | |
1759 "endsequence" | |
1760 "endspecify" | |
1761 "endtable" | |
1762 "endtask" | |
1763 "join" | |
1764 "join_any" | |
1765 "join_none" | |
1766 "module" | |
1767 "macromodule" | |
1768 "primitive" | |
1769 "interface" | |
1770 "package"))) | |
1771 "\\)")) | |
1772 | |
1773 ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and | |
1774 ;;; verilog-end-block-ordered-re matches exactly the same strings. | |
1775 (defconst verilog-end-block-ordered-re | |
1776 ;; Parenthesis indicate type of keyword found | |
1777 (concat "\\(\\<endcase\\>\\)\\|" ; 1 | |
1778 "\\(\\<end\\>\\)\\|" ; 2 | |
1779 "\\(\\<end" ; 3, but not used | |
1780 "\\(" ; 4, but not used | |
1781 "\\(function\\)\\|" ; 5 | |
1782 "\\(task\\)\\|" ; 6 | |
1783 "\\(module\\)\\|" ; 7 | |
1784 "\\(primitive\\)\\|" ; 8 | |
1785 "\\(interface\\)\\|" ; 9 | |
1786 "\\(package\\)\\|" ; 10 | |
1787 "\\(class\\)\\|" ; 11 | |
1788 "\\(group\\)\\|" ; 12 | |
1789 "\\(program\\)\\|" ; 13 | |
1790 "\\(sequence\\)\\|" ; 14 | |
1791 "\\(clocking\\)\\|" ; 15 | |
1792 "\\)\\>\\)")) | |
1793 (defconst verilog-end-block-re | |
1794 (eval-when-compile | |
1795 (verilog-regexp-words | |
1796 | |
1797 `("end" ;; closes begin | |
1798 "endcase" ;; closes any of case, casex casez or randcase | |
1799 "join" "join_any" "join_none" ;; closes fork | |
1800 "endclass" | |
1801 "endtable" | |
1802 "endspecify" | |
1803 "endfunction" | |
1804 "endgenerate" | |
1805 "endtask" | |
1806 "endgroup" | |
1807 "endproperty" | |
1808 "endinterface" | |
1809 "endpackage" | |
1810 "endprogram" | |
1811 "endsequence" | |
1812 "endclocking" | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1813 ;; OVM |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1814 "`ovm_component_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1815 "`ovm_field_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1816 "`ovm_object_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1817 "`ovm_sequence_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1818 "`ovm_sequencer_utils_end" |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1819 ;; VMM |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1820 "`vmm_data_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1821 "`vmm_env_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1822 "`vmm_scenario_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1823 "`vmm_subenv_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1824 "`vmm_xactor_member_end" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
1825 )))) |
79545 | 1826 |
1827 | |
1828 (defconst verilog-endcomment-reason-re | |
1829 ;; Parenthesis indicate type of keyword found | |
1830 (concat | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1831 "\\(\\<begin\\>\\)\\|" ; 1 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1832 "\\(\\<else\\>\\)\\|" ; 2 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1833 "\\(\\<end\\>\\s-+\\<else\\>\\)\\|" ; 3 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1834 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|" ; 4 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1835 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|" ; 5 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1836 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|" ; 6 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1837 "\\(\\<fork\\>\\)\\|" ; 7 |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1838 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|" |
79545 | 1839 "\\(\\<if\\>\\)\\|" |
1840 "\\(\\<clocking\\>\\)\\|" | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1841 "\\(\\<task\\>\\)\\|" |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1842 "\\(\\<function\\>\\)\\|" |
79545 | 1843 "\\(\\<initial\\>\\)\\|" |
1844 "\\(\\<interface\\>\\)\\|" | |
1845 "\\(\\<package\\>\\)\\|" | |
1846 "\\(\\<final\\>\\)\\|" | |
1847 "\\(@\\)\\|" | |
1848 "\\(\\<while\\>\\)\\|" | |
1849 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|" | |
1850 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|" | |
1851 "#")) | |
1852 | |
1853 (defconst verilog-named-block-re "begin[ \t]*:") | |
1854 | |
1855 ;; These words begin a block which can occur inside a module which should be indented, | |
1856 ;; and closed with the respective word from the end-block list | |
1857 | |
1858 (defconst verilog-beg-block-re | |
1859 (eval-when-compile | |
1860 (verilog-regexp-words | |
1861 `("begin" | |
1862 "case" "casex" "casez" "randcase" | |
1863 "clocking" | |
1864 "generate" | |
1865 "fork" | |
1866 "function" | |
1867 "property" | |
1868 "specify" | |
1869 "table" | |
1870 "task" | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1871 ;;; OVM |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1872 "`ovm_component_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1873 "`ovm_component_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1874 "`ovm_field_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1875 "`ovm_object_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
1876 "`ovm_object_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1877 "`ovm_sequence_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1878 "`ovm_sequencer_utils_begin" |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1879 ;; VMM |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1880 "`vmm_data_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1881 "`vmm_env_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1882 "`vmm_scenario_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1883 "`vmm_subenv_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1884 "`vmm_xactor_member_begin" |
79545 | 1885 )))) |
1886 ;; These are the same words, in a specific order in the regular | |
1887 ;; expression so that matching will work nicely for | |
1888 ;; verilog-forward-sexp and verilog-calc-indent | |
1889 (defconst verilog-beg-block-re-ordered | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1890 ( concat "\\(\\<begin\\>\\)" ;1 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1891 "\\|\\(\\<randcase\\>\\|\\(\\<unique\\s-+\\|priority\\s-+\\)?case[xz]?\\>\\)" ; 2,3 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1892 "\\|\\(\\(\\<disable\\>\\s-+\\)?fork\\>\\)" ;4,5 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1893 "\\|\\(\\<class\\>\\)" ;6 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1894 "\\|\\(\\<table\\>\\)" ;7 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1895 "\\|\\(\\<specify\\>\\)" ;8 |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1896 "\\|\\(\\<function\\>\\)" ;9 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1897 "\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)*\\<function\\>\\)" ;10 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1898 "\\|\\(\\<task\\>\\)" ;14 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1899 "\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)*\\<task\\>\\)" ;15 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1900 "\\|\\(\\<generate\\>\\)" ;18 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1901 "\\|\\(\\<covergroup\\>\\)" ;16 20 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1902 "\\|\\(\\(\\(\\<cover\\>\\s-+\\)\\|\\(\\<assert\\>\\s-+\\)\\)*\\<property\\>\\)" ;17 21 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1903 "\\|\\(\\<\\(rand\\)?sequence\\>\\)" ;21 25 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1904 "\\|\\(\\<clocking\\>\\)" ;22 27 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1905 "\\|\\(\\<`ovm_[a-z_]+_begin\\>\\)" ;28 |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1906 "\\|\\(\\<`vmm_[a-z_]+_member_begin\\>\\)" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1907 ;; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
1908 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
1909 )) |
79545 | 1910 |
1911 (defconst verilog-end-block-ordered-rry | |
1912 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1913 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" | |
1914 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" | |
1915 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" | |
1916 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" | |
1917 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" | |
1918 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" | |
1919 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" | |
1920 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" | |
1921 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" | |
1922 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" | |
1923 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" | |
1924 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" | |
1925 ] ) | |
1926 | |
1927 (defconst verilog-nameable-item-re | |
1928 (eval-when-compile | |
1929 (verilog-regexp-words | |
1930 `("begin" | |
1931 "fork" | |
1932 "join" "join_any" "join_none" | |
1933 "end" | |
1934 "endcase" | |
1935 "endconfig" | |
1936 "endclass" | |
1937 "endclocking" | |
1938 "endfunction" | |
1939 "endgenerate" | |
1940 "endmodule" | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
1941 "endprimitive" |
79545 | 1942 "endinterface" |
1943 "endpackage" | |
1944 "endspecify" | |
1945 "endtable" | |
1946 "endtask" ) | |
1947 ))) | |
1948 | |
1949 (defconst verilog-declaration-opener | |
1950 (eval-when-compile | |
1951 (verilog-regexp-words | |
1952 `("module" "begin" "task" "function")))) | |
1953 | |
1954 (defconst verilog-declaration-prefix-re | |
1955 (eval-when-compile | |
1956 (verilog-regexp-words | |
1957 `( | |
1958 ;; port direction | |
79546 | 1959 "inout" "input" "output" "ref" |
79545 | 1960 ;; changeableness |
1961 "const" "static" "protected" "local" | |
1962 ;; parameters | |
79546 | 1963 "localparam" "parameter" "var" |
79545 | 1964 ;; type creation |
1965 "typedef" | |
1966 )))) | |
1967 (defconst verilog-declaration-core-re | |
1968 (eval-when-compile | |
1969 (verilog-regexp-words | |
1970 `( | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
1971 ;; port direction (by themselves) |
80141
00b853b0f933
(customize): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents:
80024
diff
changeset
|
1972 "inout" "input" "output" |
79545 | 1973 ;; integer_atom_type |
1974 "byte" "shortint" "int" "longint" "integer" "time" | |
1975 ;; integer_vector_type | |
1976 "bit" "logic" "reg" | |
1977 ;; non_integer_type | |
1978 "shortreal" "real" "realtime" | |
1979 ;; net_type | |
1980 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor" | |
1981 ;; misc | |
1982 "string" "event" "chandle" "virtual" "enum" "genvar" | |
1983 "struct" "union" | |
1984 ;; builtin classes | |
79546 | 1985 "mailbox" "semaphore" |
79545 | 1986 )))) |
79546 | 1987 (defconst verilog-declaration-re |
79545 | 1988 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re)) |
1989 (defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+") | |
1990 (defconst verilog-optional-signed-re "\\s-*\\(signed\\)?") | |
1991 (defconst verilog-optional-signed-range-re | |
1992 (concat | |
1993 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?")) | |
1994 (defconst verilog-macroexp-re "`\\sw+") | |
1995 | |
1996 (defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)") | |
1997 (defconst verilog-declaration-re-2-no-macro | |
1998 (concat "\\s-*" verilog-declaration-re | |
1999 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
2000 "\\)?")) | |
2001 (defconst verilog-declaration-re-2-macro | |
2002 (concat "\\s-*" verilog-declaration-re | |
2003 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)" | |
2004 "\\|\\(" verilog-macroexp-re "\\)" | |
2005 "\\)?")) | |
2006 (defconst verilog-declaration-re-1-macro | |
2007 (concat "^" verilog-declaration-re-2-macro)) | |
2008 | |
2009 (defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro)) | |
2010 | |
2011 (defconst verilog-defun-re | |
2012 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config")))) | |
2013 (defconst verilog-end-defun-re | |
2014 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig")))) | |
2015 (defconst verilog-zero-indent-re | |
2016 (concat verilog-defun-re "\\|" verilog-end-defun-re)) | |
2017 | |
2018 (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
|
2019 (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
|
2020 "function" "task")))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2021 (defconst verilog-coverpoint-re "\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)" ) |
79545 | 2022 (defconst verilog-indent-re |
2023 (eval-when-compile | |
2024 (verilog-regexp-words | |
2025 `( | |
2026 "{" | |
2027 "always" "always_latch" "always_ff" "always_comb" | |
2028 "begin" "end" | |
2029 ; "unique" "priority" | |
2030 "case" "casex" "casez" "randcase" "endcase" | |
2031 "class" "endclass" | |
2032 "clocking" "endclocking" | |
2033 "config" "endconfig" | |
2034 "covergroup" "endgroup" | |
2035 "fork" "join" "join_any" "join_none" | |
2036 "function" "endfunction" | |
2037 "final" | |
2038 "generate" "endgenerate" | |
2039 "initial" | |
2040 "interface" "endinterface" | |
2041 "module" "macromodule" "endmodule" | |
2042 "package" "endpackage" | |
2043 "primitive" "endprimative" | |
2044 "program" "endprogram" | |
2045 "property" "endproperty" | |
2046 "sequence" "randsequence" "endsequence" | |
2047 "specify" "endspecify" | |
2048 "table" "endtable" | |
2049 "task" "endtask" | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2050 "virtual" |
79545 | 2051 "`case" |
2052 "`default" | |
2053 "`define" "`undef" | |
2054 "`if" "`ifdef" "`ifndef" "`else" "`endif" | |
2055 "`while" "`endwhile" | |
2056 "`for" "`endfor" | |
2057 "`format" | |
2058 "`include" | |
2059 "`let" | |
2060 "`protect" "`endprotect" | |
2061 "`switch" "`endswitch" | |
2062 "`timescale" | |
2063 "`time_scale" | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2064 ;; OVM Begin tokens |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2065 "`ovm_component_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
2066 "`ovm_component_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2067 "`ovm_field_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2068 "`ovm_object_utils_begin" |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
2069 "`ovm_object_param_utils_begin" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2070 "`ovm_sequence_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2071 "`ovm_sequencer_utils_begin" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2072 ;; OVM End tokens |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2073 "`ovm_component_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2074 "`ovm_field_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2075 "`ovm_object_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2076 "`ovm_sequence_utils_end" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2077 "`ovm_sequencer_utils_end" |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2078 ;; VMM Begin tokens |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2079 "`vmm_data_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2080 "`vmm_env_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2081 "`vmm_scenario_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2082 "`vmm_subenv_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2083 "`vmm_xactor_member_begin" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2084 ;; VMM End tokens |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2085 "`vmm_data_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2086 "`vmm_env_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2087 "`vmm_scenario_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2088 "`vmm_subenv_member_end" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
2089 "`vmm_xactor_member_end" |
79545 | 2090 )))) |
2091 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2092 (defconst verilog-defun-level-not-generate-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2093 (eval-when-compile |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2094 (verilog-regexp-words |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2095 `( "module" "macromodule" "primitive" "class" "program" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2096 "interface" "package" "config")))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2097 |
79545 | 2098 (defconst verilog-defun-level-re |
2099 (eval-when-compile | |
2100 (verilog-regexp-words | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2101 (append |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2102 `( "module" "macromodule" "primitive" "class" "program" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2103 "interface" "package" "config") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2104 `( "initial" "final" "always" "always_comb" "always_ff" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2105 "always_latch" "endtask" "endfunction" ))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2106 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2107 (defconst verilog-defun-level-generate-only-re |
79545 | 2108 (eval-when-compile |
2109 (verilog-regexp-words | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2110 `( "initial" "final" "always" "always_comb" "always_ff" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2111 "always_latch" "endtask" "endfunction" )))) |
79545 | 2112 |
2113 (defconst verilog-cpp-level-re | |
2114 (eval-when-compile | |
2115 (verilog-regexp-words | |
2116 `( | |
2117 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" | |
2118 )))) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2119 (defconst verilog-disable-fork-re "disable\\s-+fork") |
79545 | 2120 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") |
2121 (defconst verilog-extended-complete-re | |
2122 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" | |
2123 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)" | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2124 "\\|\\(\\<import\\>\\s-+\\)?\"DPI-C\"\\s-+\\(function\\>\\|task\\>\\)" |
79545 | 2125 "\\|" verilog-extended-case-re )) |
2126 (defconst verilog-basic-complete-re | |
2127 (eval-when-compile | |
2128 (verilog-regexp-words | |
2129 `( | |
2130 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint" | |
2131 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while" | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
2132 "if" "for" "forever" "foreach" "else" "parameter" "do" "localparam" "assert" |
79545 | 2133 )))) |
2134 (defconst verilog-complete-reg | |
2135 (concat | |
2136 verilog-extended-complete-re | |
2137 "\\|" | |
2138 verilog-basic-complete-re)) | |
2139 | |
2140 (defconst verilog-end-statement-re | |
2141 (concat "\\(" verilog-beg-block-re "\\)\\|\\(" | |
2142 verilog-end-block-re "\\)")) | |
2143 | |
2144 (defconst verilog-endcase-re | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2145 (concat verilog-extended-case-re "\\|" |
79545 | 2146 "\\(endcase\\)\\|" |
2147 verilog-defun-re | |
2148 )) | |
2149 | |
2150 (defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----" | |
2151 "String used to mark beginning of excluded text.") | |
2152 (defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */" | |
2153 "String used to mark end of excluded text.") | |
2154 (defconst verilog-preprocessor-re | |
2155 (eval-when-compile | |
2156 (verilog-regexp-words | |
2157 `( | |
2158 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else" | |
2159 )))) | |
2160 | |
2161 (defconst verilog-keywords | |
2162 '( "`case" "`default" "`define" "`else" "`endfor" "`endif" | |
2163 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" | |
2164 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" | |
2165 "`time_scale" "`undef" "`while" | |
2166 | |
2167 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and" | |
2168 "assert" "assign" "assume" "automatic" "before" "begin" "bind" | |
2169 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte" | |
2170 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos" | |
2171 "config" "const" "constraint" "context" "continue" "cover" | |
2172 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam" | |
2173 "design" "disable" "dist" "do" "edge" "else" "end" "endcase" | |
2174 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate" | |
2175 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive" | |
2176 "endprogram" "endproperty" "endspecify" "endsequence" "endtable" | |
2177 "endtask" "enum" "event" "expect" "export" "extends" "extern" | |
2178 "final" "first_match" "for" "force" "foreach" "forever" "fork" | |
2179 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if" | |
2180 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir" | |
2181 "include" "initial" "inout" "input" "inside" "instance" "int" | |
2182 "integer" "interface" "intersect" "join" "join_any" "join_none" | |
2183 "large" "liblist" "library" "local" "localparam" "logic" | |
2184 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module" | |
2185 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not" | |
2186 "notif0" "notif1" "null" "or" "output" "package" "packed" | |
2187 "parameter" "pmos" "posedge" "primitive" "priority" "program" | |
2188 "property" "protected" "pull0" "pull1" "pulldown" "pullup" | |
2189 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
2190 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg" | |
2191 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0" | |
2192 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal" | |
2193 "showcancelled" "signed" "small" "solve" "specify" "specparam" | |
2194 "static" "string" "strong0" "strong1" "struct" "super" "supply0" | |
2195 "supply1" "table" "tagged" "task" "this" "throughout" "time" | |
2196 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri" | |
2197 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union" | |
2198 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" | |
2199 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" | |
2200 "wire" "with" "within" "wor" "xnor" "xor" | |
2201 ) | |
2202 "List of Verilog keywords.") | |
2203 | |
2204 (defconst verilog-comment-start-regexp "//\\|/\\*" | |
2205 "Dual comment value for `comment-start-regexp'.") | |
2206 | |
79810
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2207 (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
|
2208 (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
|
2209 ;; Populate the syntax TABLE. |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2210 (modify-syntax-entry ?\\ "\\" table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2211 (modify-syntax-entry ?+ "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2212 (modify-syntax-entry ?- "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2213 (modify-syntax-entry ?= "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2214 (modify-syntax-entry ?% "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2215 (modify-syntax-entry ?< "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2216 (modify-syntax-entry ?> "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2217 (modify-syntax-entry ?& "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2218 (modify-syntax-entry ?| "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2219 (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
|
2220 (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
|
2221 (modify-syntax-entry ?\' "." table) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2222 |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2223 ;; 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
|
2224 (if (featurep 'xemacs) |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2225 (progn |
606faa750dd7
(verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79801
diff
changeset
|
2226 ;; 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
|
2227 (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
|
2228 (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
|
2229 (modify-syntax-entry ?\n "> b" table)) |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2230 ;; 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
|
2231 (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
|
2232 (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
|
2233 (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
|
2234 table) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2235 "Syntax table used in Verilog mode buffers.") |
79545 | 2236 |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2237 (defvar verilog-font-lock-keywords nil |
79545 | 2238 "Default highlighting for Verilog mode.") |
2239 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2240 (defvar verilog-font-lock-keywords-1 nil |
79545 | 2241 "Subdued level highlighting for Verilog mode.") |
2242 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2243 (defvar verilog-font-lock-keywords-2 nil |
79545 | 2244 "Medium level highlighting for Verilog mode. |
2245 See also `verilog-font-lock-extra-types'.") | |
2246 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2247 (defvar verilog-font-lock-keywords-3 nil |
79545 | 2248 "Gaudy level highlighting for Verilog mode. |
2249 See also `verilog-font-lock-extra-types'.") | |
2250 (defvar verilog-font-lock-translate-off-face | |
2251 'verilog-font-lock-translate-off-face | |
2252 "Font to use for translated off regions.") | |
2253 (defface verilog-font-lock-translate-off-face | |
2254 '((((class color) | |
2255 (background light)) | |
2256 (:background "gray90" :italic t )) | |
2257 (((class color) | |
2258 (background dark)) | |
2259 (:background "gray10" :italic t )) | |
2260 (((class grayscale) (background light)) | |
2261 (:foreground "DimGray" :italic t)) | |
2262 (((class grayscale) (background dark)) | |
2263 (:foreground "LightGray" :italic t)) | |
2264 (t (:italis t))) | |
2265 "Font lock mode face used to background highlight translate-off regions." | |
2266 :group 'font-lock-highlighting-faces) | |
2267 | |
2268 (defvar verilog-font-lock-p1800-face | |
2269 'verilog-font-lock-p1800-face | |
2270 "Font to use for p1800 keywords.") | |
2271 (defface verilog-font-lock-p1800-face | |
2272 '((((class color) | |
2273 (background light)) | |
2274 (:foreground "DarkOrange3" :bold t )) | |
2275 (((class color) | |
2276 (background dark)) | |
2277 (:foreground "orange1" :bold t )) | |
2278 (t (:italic t))) | |
2279 "Font lock mode face used to highlight P1800 keywords." | |
2280 :group 'font-lock-highlighting-faces) | |
2281 | |
2282 (defvar verilog-font-lock-ams-face | |
2283 'verilog-font-lock-ams-face | |
2284 "Font to use for Analog/Mixed Signal keywords.") | |
2285 (defface verilog-font-lock-ams-face | |
2286 '((((class color) | |
2287 (background light)) | |
2288 (:foreground "Purple" :bold t )) | |
2289 (((class color) | |
2290 (background dark)) | |
2291 (:foreground "orange1" :bold t )) | |
2292 (t (:italic t))) | |
2293 "Font lock mode face used to highlight AMS keywords." | |
2294 :group 'font-lock-highlighting-faces) | |
2295 | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2296 (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
|
2297 '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
|
2298 "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
|
2299 (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
|
2300 '((((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2301 (background light)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2302 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2303 (((class color) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2304 (background dark)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2305 (:foreground "red4" :bold t )) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2306 (t (:italic t))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2307 "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
|
2308 :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
|
2309 |
79545 | 2310 (let* ((verilog-type-font-keywords |
2311 (eval-when-compile | |
2312 (verilog-regexp-opt | |
2313 '( | |
2314 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam" | |
2315 "event" "genvar" "inout" "input" "integer" "localparam" | |
2316 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or" | |
2317 "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
2318 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" | |
2319 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply" | |
2320 "supply0" "supply1" "time" "tran" "tranif0" "tranif1" | |
2321 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef" | |
2322 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor" | |
2323 ) nil ))) | |
2324 | |
2325 (verilog-pragma-keywords | |
2326 (eval-when-compile | |
2327 (verilog-regexp-opt | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2328 '("surefire" "synopsys" "rtl_synthesis" "verilint" "leda" "0in") nil |
79545 | 2329 ))) |
2330 | |
2331 (verilog-p1800-keywords | |
2332 (eval-when-compile | |
2333 (verilog-regexp-opt | |
2334 '("alias" "assert" "assume" "automatic" "before" "bind" | |
2335 "bins" "binsof" "break" "byte" "cell" "chandle" "class" | |
2336 "clocking" "config" "const" "constraint" "context" "continue" | |
2337 "cover" "covergroup" "coverpoint" "cross" "deassign" "design" | |
2338 "dist" "do" "edge" "endclass" "endclocking" "endconfig" | |
2339 "endgroup" "endprogram" "endproperty" "endsequence" "enum" | |
2340 "expect" "export" "extends" "extern" "first_match" "foreach" | |
2341 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins" | |
2342 "illegal_bins" "import" "incdir" "include" "inside" "instance" | |
2343 "int" "intersect" "large" "liblist" "library" "local" "longint" | |
2344 "matches" "medium" "modport" "new" "noshowcancelled" "null" | |
2345 "packed" "program" "property" "protected" "pull0" "pull1" | |
2346 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc" | |
2347 "randcase" "randsequence" "ref" "release" "return" "scalared" | |
2348 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve" | |
2349 "specparam" "static" "string" "strong0" "strong1" "struct" | |
2350 "super" "tagged" "this" "throughout" "timeprecision" "timeunit" | |
2351 "type" "union" "unsigned" "use" "var" "virtual" "void" | |
2352 "wait_order" "weak0" "weak1" "wildcard" "with" "within" | |
2353 ) nil ))) | |
2354 | |
2355 (verilog-ams-keywords | |
2356 (eval-when-compile | |
2357 (verilog-regexp-opt | |
2358 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim" | |
2359 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh" | |
2360 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt" | |
2361 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules" | |
2362 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise" | |
2363 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf" | |
2364 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp" | |
2365 "last_crossing" "limexp" "ln" "log" "max" "min" "nature" | |
2366 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin" | |
2367 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise" | |
2368 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil ))) | |
2369 | |
2370 (verilog-font-keywords | |
2371 (eval-when-compile | |
2372 (verilog-regexp-opt | |
2373 '( | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2374 "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
|
2375 "default" "disable" "else" "endcase" "endfunction" |
79545 | 2376 "endgenerate" "endinterface" "endmodule" "endprimitive" |
2377 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break" | |
2378 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial" | |
2379 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge" | |
2380 "package" "endpackage" "always" "always_comb" "always_ff" | |
2381 "always_latch" "posedge" "primitive" "priority" "release" | |
2382 "repeat" "specify" "table" "task" "unique" "wait" "while" | |
2383 "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
|
2384 ) nil ))) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2385 |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2386 (verilog-font-grouping-keywords |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2387 (eval-when-compile |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2388 (verilog-regexp-opt |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2389 '( "begin" "end" ) nil )))) |
79545 | 2390 |
2391 (setq verilog-font-lock-keywords | |
2392 (list | |
2393 ;; Fontify all builtin keywords | |
2394 (concat "\\<\\(" verilog-font-keywords "\\|" | |
2395 ;; 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
|
2396 "\\$[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
|
2397 "\\)\\>") |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2398 ;; Fontify all types |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2399 (if verilog-highlight-grouping-keywords |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2400 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2401 'verilog-font-lock-ams-face) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2402 (cons (concat "\\<\\(" verilog-font-grouping-keywords "\\)\\>") |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2403 'font-lock-type-face)) |
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2404 (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
|
2405 'font-lock-type-face) |
80270
e36e32d01703
(verilog-highlight-grouping-keywords):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80267
diff
changeset
|
2406 ;; Fontify IEEE-P1800 keywords appropriately |
79545 | 2407 (if verilog-highlight-p1800-keywords |
2408 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
2409 'verilog-font-lock-p1800-face) | |
2410 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") | |
2411 'font-lock-type-face)) | |
2412 ;; Fontify Verilog-AMS keywords | |
2413 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2414 'verilog-font-lock-ams-face))) |
79545 | 2415 |
2416 (setq verilog-font-lock-keywords-1 | |
2417 (append verilog-font-lock-keywords | |
2418 (list | |
2419 ;; Fontify module definitions | |
2420 (list | |
2421 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)" | |
2422 '(1 font-lock-keyword-face) | |
2423 '(3 font-lock-function-name-face 'prepend)) | |
2424 ;; Fontify function definitions | |
2425 (list | |
2426 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" ) | |
2427 '(1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2428 '(3 font-lock-reference-face prepend)) |
79545 | 2429 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)" |
2430 (1 font-lock-keyword-face) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2431 (2 font-lock-reference-face append)) |
79545 | 2432 '("\\<function\\>\\s-+\\(\\sw+\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2433 1 'font-lock-reference-face append)))) |
79545 | 2434 |
2435 (setq verilog-font-lock-keywords-2 | |
2436 (append verilog-font-lock-keywords-1 | |
2437 (list | |
2438 ;; Fontify pragmas | |
2439 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)") | |
2440 ;; Fontify escaped names | |
2441 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face) | |
2442 ;; Fontify macro definitions/ uses | |
2443 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face) | |
2444 'font-lock-preprocessor-face | |
2445 'font-lock-type-face)) | |
2446 ;; Fontify delays/numbers | |
2447 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)" | |
2448 0 font-lock-type-face append) | |
2449 ;; Fontify instantiation names | |
2450 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face) | |
2451 ))) | |
2452 | |
2453 (setq verilog-font-lock-keywords-3 | |
2454 (append verilog-font-lock-keywords-2 | |
2455 (when verilog-highlight-translate-off | |
2456 (list | |
2457 ;; 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
|
2458 '(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
|
2459 (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
|
2460 ))))) |
79545 | 2461 |
2462 | |
2463 (defun verilog-inside-comment-p () | |
2464 "Check if point inside a nested comment." | |
2465 (save-excursion | |
2466 (let ((st-point (point)) hitbeg) | |
2467 (or (search-backward "//" (verilog-get-beg-of-line) t) | |
2468 (if (progn | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2469 ;; This is for tricky case //*, we keep searching if /* |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2470 ;; 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
|
2471 (while |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2472 (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
|
2473 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2474 (forward-char 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2475 (search-backward "//" (verilog-get-beg-of-line) t)))) |
79545 | 2476 hitbeg) |
2477 (not (search-forward "*/" st-point t))))))) | |
2478 | |
2479 (defun verilog-declaration-end () | |
2480 (search-forward ";")) | |
2481 | |
2482 (defun verilog-point-text (&optional pointnum) | |
2483 "Return text describing where POINTNUM or current point is (for errors). | |
2484 Use filename, if current buffer being edited shorten to just buffer name." | |
2485 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer)) | |
2486 (buffer-name)) | |
2487 buffer-file-name | |
2488 (buffer-name)) | |
2489 ":" (int-to-string (count-lines (point-min) (or pointnum (point)))))) | |
2490 | |
2491 (defun electric-verilog-backward-sexp () | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2492 "Move backward over one balanced expression." |
79545 | 2493 (interactive) |
2494 ;; 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
|
2495 (verilog-backward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2496 |
79545 | 2497 (defun electric-verilog-forward-sexp () |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2498 "Move forward over one balanced expression." |
79545 | 2499 (interactive) |
2500 ;; 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
|
2501 (verilog-forward-sexp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2502 |
79545 | 2503 ;;;used by hs-minor-mode |
2504 (defun verilog-forward-sexp-function (arg) | |
2505 (if (< arg 0) | |
2506 (verilog-backward-sexp) | |
2507 (verilog-forward-sexp))) | |
2508 | |
2509 | |
2510 (defun verilog-backward-sexp () | |
2511 (let ((reg) | |
2512 (elsec 1) | |
2513 (found nil) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2514 (st (point))) |
79545 | 2515 (if (not (looking-at "\\<")) |
2516 (forward-word -1)) | |
2517 (cond | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2518 ((verilog-skip-backward-comment-or-string)) |
79545 | 2519 ((looking-at "\\<else\\>") |
2520 (setq reg (concat | |
2521 verilog-end-block-re | |
2522 "\\|\\(\\<else\\>\\)" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2523 "\\|\\(\\<if\\>\\)")) |
79545 | 2524 (while (and (not found) |
2525 (verilog-re-search-backward reg nil 'move)) | |
2526 (cond | |
2527 ((match-end 1) ; matched verilog-end-block-re | |
2528 ; try to leap back to matching outward block by striding across | |
2529 ; indent level changing tokens then immediately | |
2530 ; previous line governs indentation. | |
2531 (verilog-leap-to-head)) | |
2532 ((match-end 2) ; else, we're in deep | |
2533 (setq elsec (1+ elsec))) | |
2534 ((match-end 3) ; found it | |
2535 (setq elsec (1- elsec)) | |
2536 (if (= 0 elsec) | |
2537 ;; Now previous line describes syntax | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2538 (setq found 't)))))) |
79545 | 2539 ((looking-at verilog-end-block-re) |
2540 (verilog-leap-to-head)) | |
2541 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)") | |
2542 (cond | |
2543 ((match-end 1) | |
2544 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move)) | |
2545 ((match-end 2) | |
2546 (verilog-re-search-backward "\\<primitive\\>" nil 'move)) | |
2547 ((match-end 3) | |
2548 (verilog-re-search-backward "\\<class\\>" nil 'move)) | |
2549 ((match-end 4) | |
2550 (verilog-re-search-backward "\\<program\\>" nil 'move)) | |
2551 ((match-end 5) | |
2552 (verilog-re-search-backward "\\<interface\\>" nil 'move)) | |
2553 ((match-end 6) | |
2554 (verilog-re-search-backward "\\<package\\>" nil 'move)) | |
2555 (t | |
2556 (goto-char st) | |
2557 (backward-sexp 1)))) | |
2558 (t | |
2559 (goto-char st) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2560 (backward-sexp))))) |
79545 | 2561 |
2562 (defun verilog-forward-sexp () | |
2563 (let ((reg) | |
2564 (md 2) | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2565 (st (point)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2566 (nest 'yes)) |
79545 | 2567 (if (not (looking-at "\\<")) |
2568 (forward-word -1)) | |
2569 (cond | |
2570 ((verilog-skip-forward-comment-or-string) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2571 (verilog-forward-syntactic-ws)) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2572 ((looking-at verilog-beg-block-re-ordered) |
79545 | 2573 (cond |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2574 ((match-end 1); |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2575 ;; Search forward for matching end |
79545 | 2576 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2577 ((match-end 2) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2578 ;; Search forward for matching endcase |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2579 (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
|
2580 (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
|
2581 ) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2582 ((match-end 4) |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2583 ;; might be "disable fork" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2584 (if (or |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2585 (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
|
2586 (and (looking-at "fork") |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2587 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2588 (forward-word -1) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2589 (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
|
2590 (progn |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2591 (goto-char (match-end 0)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2592 (forward-word 1) |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2593 (setq reg nil)) |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2594 (progn |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2595 ;; Search forward for matching join |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2596 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2597 ((match-end 6) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2598 ;; Search forward for matching endclass |
79545 | 2599 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2600 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2601 ((match-end 7) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2602 ;; Search forward for matching endtable |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2603 (setq reg "\\<endtable\\>" ) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2604 (setq nest 'no)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2605 ((match-end 8) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2606 ;; Search forward for matching endspecify |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2607 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2608 ((match-end 9) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2609 ;; Search forward for matching endfunction |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2610 (setq reg "\\<endfunction\\>" ) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2611 (setq nest 'no)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2612 ((match-end 10) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2613 ;; Search forward for matching endfunction |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2614 (setq reg "\\<endfunction\\>" ) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2615 (setq nest 'no)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2616 ((match-end 14) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2617 ;; Search forward for matching endtask |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2618 (setq reg "\\<endtask\\>" ) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2619 (setq nest 'no)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2620 ((match-end 15) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2621 ;; Search forward for matching endtask |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2622 (setq reg "\\<endtask\\>" ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2623 (setq nest 'no)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2624 ((match-end 19) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2625 ;; Search forward for matching endgenerate |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2626 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2627 ((match-end 20) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2628 ;; Search forward for matching endgroup |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2629 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2630 ((match-end 21) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2631 ;; Search forward for matching endproperty |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2632 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2633 ((match-end 25) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2634 ;; Search forward for matching endsequence |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2635 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2636 (setq md 3)) ; 3 to get to endsequence in the reg above |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2637 ((match-end 27) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2638 ;; Search forward for matching endclocking |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2639 (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
|
2640 (if (and reg |
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
2641 (forward-word 1)) |
79545 | 2642 (catch 'skip |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2643 (if (eq nest 'yes) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2644 (let ((depth 1)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2645 (while (verilog-re-search-forward reg nil 'move) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2646 (cond |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2647 ((match-end md) ; the closer in reg, so we are climbing out |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2648 (setq depth (1- depth)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2649 (if (= 0 depth) ; we are out! |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2650 (throw 'skip 1))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2651 ((match-end 1) ; the opener in reg, so we are deeper now |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2652 (setq depth (1+ depth)))))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2653 (if (verilog-re-search-forward reg nil 'move) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
2654 (throw 'skip 1)))))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2655 |
79545 | 2656 ((looking-at (concat |
2657 "\\(\\<\\(macro\\)?module\\>\\)\\|" | |
2658 "\\(\\<primitive\\>\\)\\|" | |
2659 "\\(\\<class\\>\\)\\|" | |
2660 "\\(\\<program\\>\\)\\|" | |
2661 "\\(\\<interface\\>\\)\\|" | |
2662 "\\(\\<package\\>\\)")) | |
2663 (cond | |
2664 ((match-end 1) | |
2665 (verilog-re-search-forward "\\<endmodule\\>" nil 'move)) | |
2666 ((match-end 2) | |
2667 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move)) | |
2668 ((match-end 3) | |
2669 (verilog-re-search-forward "\\<endclass\\>" nil 'move)) | |
2670 ((match-end 4) | |
2671 (verilog-re-search-forward "\\<endprogram\\>" nil 'move)) | |
2672 ((match-end 5) | |
2673 (verilog-re-search-forward "\\<endinterface\\>" nil 'move)) | |
2674 ((match-end 6) | |
2675 (verilog-re-search-forward "\\<endpackage\\>" nil 'move)) | |
2676 (t | |
2677 (goto-char st) | |
2678 (if (= (following-char) ?\) ) | |
2679 (forward-char 1) | |
2680 (forward-sexp 1))))) | |
2681 (t | |
2682 (goto-char st) | |
2683 (if (= (following-char) ?\) ) | |
2684 (forward-char 1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2685 (forward-sexp 1)))))) |
79545 | 2686 |
2687 (defun verilog-declaration-beg () | |
2688 (verilog-re-search-backward verilog-declaration-re (bobp) t)) | |
2689 | |
2690 ;; | |
2691 ;; | |
2692 ;; Mode | |
2693 ;; | |
2694 (defvar verilog-which-tool 1) | |
79546 | 2695 ;;;###autoload |
79545 | 2696 (defun verilog-mode () |
2697 "Major mode for editing Verilog code. | |
2698 \\<verilog-mode-map> | |
2699 See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how | |
2700 AUTOs can improve coding efficiency. | |
2701 | |
2702 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
2703 | |
2704 NEWLINE, TAB indents for Verilog code. | |
2705 Delete converts tabs to spaces as it moves back. | |
2706 | |
2707 Supports highlighting. | |
2708 | |
2709 Turning on Verilog mode calls the value of the variable `verilog-mode-hook' | |
2710 with no args, if that value is non-nil. | |
2711 | |
2712 Variables controlling indentation/edit style: | |
2713 | |
2714 variable `verilog-indent-level' (default 3) | |
2715 Indentation of Verilog statements with respect to containing block. | |
2716 `verilog-indent-level-module' (default 3) | |
2717 Absolute indentation of Module level Verilog statements. | |
2718 Set to 0 to get initial and always statements lined up | |
2719 on the left side of your screen. | |
2720 `verilog-indent-level-declaration' (default 3) | |
2721 Indentation of declarations with respect to containing block. | |
2722 Set to 0 to get them list right under containing block. | |
2723 `verilog-indent-level-behavioral' (default 3) | |
2724 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
|
2725 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
|
2726 function keyword. |
79545 | 2727 `verilog-indent-level-directive' (default 1) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2728 Indentation of `ifdef/`endif blocks. |
79545 | 2729 `verilog-cexp-indent' (default 1) |
2730 Indentation of Verilog statements broken across lines i.e.: | |
2731 if (a) | |
2732 begin | |
2733 `verilog-case-indent' (default 2) | |
2734 Indentation for case statements. | |
2735 `verilog-auto-newline' (default nil) | |
2736 Non-nil means automatically newline after semicolons and the punctuation | |
2737 mark after an end. | |
2738 `verilog-auto-indent-on-newline' (default t) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2739 Non-nil means automatically indent line after newline. |
79545 | 2740 `verilog-tab-always-indent' (default t) |
2741 Non-nil means TAB in Verilog mode should always reindent the current line, | |
2742 regardless of where in the line point is when the TAB command is used. | |
2743 `verilog-indent-begin-after-if' (default t) | |
2744 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
|
2745 if, else, while, for and repeat statements, if any. Otherwise, |
79545 | 2746 the begin is lined up with the preceding token. If t, you get: |
2747 if (a) | |
2748 begin // amount of indent based on `verilog-cexp-indent' | |
2749 otherwise you get: | |
2750 if (a) | |
2751 begin | |
2752 `verilog-auto-endcomments' (default t) | |
2753 Non-nil means a comment /* ... */ is set after the ends which ends | |
2754 cases, tasks, functions and modules. | |
2755 The type and name of the object will be set between the braces. | |
2756 `verilog-minimum-comment-distance' (default 10) | |
2757 Minimum distance (in lines) between begin and end required before a comment | |
2758 will be inserted. Setting this variable to zero results in every | |
2759 end acquiring a comment; the default avoids too many redundant | |
2760 comments in tight quarters. | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2761 `verilog-auto-lineup' (default 'declarations) |
79545 | 2762 List of contexts where auto lineup of code should be done. |
2763 | |
2764 Variables controlling other actions: | |
2765 | |
2766 `verilog-linter' (default surelint) | |
2767 Unix program to call to run the lint checker. This is the default | |
2768 command for \\[compile-command] and \\[verilog-auto-save-compile]. | |
2769 | |
2770 See \\[customize] for the complete list of variables. | |
2771 | |
2772 AUTO expansion functions are, in part: | |
2773 | |
2774 \\[verilog-auto] Expand AUTO statements. | |
2775 \\[verilog-delete-auto] Remove the AUTOs. | |
2776 \\[verilog-inject-auto] Insert AUTOs for the first time. | |
2777 | |
2778 Some other functions are: | |
2779 | |
2780 \\[verilog-complete-word] Complete word with appropriate possibilities. | |
2781 \\[verilog-mark-defun] Mark function. | |
2782 \\[verilog-beg-of-defun] Move to beginning of current function. | |
2783 \\[verilog-end-of-defun] Move to end of current function. | |
2784 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements. | |
2785 | |
2786 \\[verilog-comment-region] Put marked area in a comment. | |
2787 \\[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
|
2788 \\[verilog-insert-block] Insert begin ... end. |
79545 | 2789 \\[verilog-star-comment] Insert /* ... */. |
2790 | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
2791 \\[verilog-sk-always] Insert an always @(AS) begin .. end block. |
79545 | 2792 \\[verilog-sk-begin] Insert a begin .. end block. |
2793 \\[verilog-sk-case] Insert a case block, prompting for details. | |
2794 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details. | |
2795 \\[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
|
2796 \\[verilog-sk-header] Insert a header block at the top of file. |
79545 | 2797 \\[verilog-sk-initial] Insert an initial begin .. end block. |
2798 \\[verilog-sk-fork] Insert a fork begin .. end .. join block. | |
2799 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block. | |
2800 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block. | |
2801 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block. | |
2802 \\[verilog-sk-specify] Insert a specify .. endspecify block. | |
2803 \\[verilog-sk-task] Insert a task .. begin .. end endtask block. | |
2804 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details. | |
2805 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details. | |
2806 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details. | |
2807 \\[verilog-sk-if] Insert an if (..) begin .. end block. | |
2808 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block. | |
2809 \\[verilog-sk-comment] Insert a comment block. | |
2810 \\[verilog-sk-assign] Insert an assign .. = ..; statement. | |
2811 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block. | |
2812 \\[verilog-sk-input] Insert an input declaration, prompting for details. | |
2813 \\[verilog-sk-output] Insert an output declaration, prompting for details. | |
2814 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details. | |
2815 \\[verilog-sk-inout] Insert an inout declaration, prompting for details. | |
2816 \\[verilog-sk-wire] Insert a wire declaration, prompting for details. | |
2817 \\[verilog-sk-reg] Insert a register declaration, prompting for details. | |
2818 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module. | |
2819 | |
2820 All key bindings can be seen in a Verilog-buffer with \\[describe-bindings]. | |
2821 Key bindings specific to `verilog-mode-map' are: | |
2822 | |
2823 \\{verilog-mode-map}" | |
2824 (interactive) | |
2825 (kill-all-local-variables) | |
2826 (use-local-map verilog-mode-map) | |
2827 (setq major-mode 'verilog-mode) | |
2828 (setq mode-name "Verilog") | |
2829 (setq local-abbrev-table verilog-mode-abbrev-table) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2830 (set (make-local-variable 'beginning-of-defun-function) |
79546 | 2831 'verilog-beg-of-defun) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2832 (set (make-local-variable 'end-of-defun-function) |
79546 | 2833 'verilog-end-of-defun) |
79545 | 2834 (set-syntax-table verilog-mode-syntax-table) |
2835 (make-local-variable 'indent-line-function) | |
2836 (setq indent-line-function 'verilog-indent-line-relative) | |
2837 (setq comment-indent-function 'verilog-comment-indent) | |
2838 (make-local-variable 'parse-sexp-ignore-comments) | |
2839 (setq parse-sexp-ignore-comments nil) | |
2840 (make-local-variable 'comment-start) | |
2841 (make-local-variable 'comment-end) | |
2842 (make-local-variable 'comment-multi-line) | |
2843 (make-local-variable 'comment-start-skip) | |
2844 (setq comment-start "// " | |
2845 comment-end "" | |
2846 comment-start-skip "/\\*+ *\\|// *" | |
2847 comment-multi-line nil) | |
2848 ;; Set up for compilation | |
2849 (setq verilog-which-tool 1) | |
2850 (setq verilog-tool 'verilog-linter) | |
2851 (verilog-set-compile-command) | |
2852 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables | |
2853 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t)) | |
2854 | |
2855 ;; Setting up menus | |
79546 | 2856 (when (featurep 'xemacs) |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2857 (easy-menu-add verilog-stmt-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2858 (easy-menu-add verilog-menu) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
2859 (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
|
2860 |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2861 ;; 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
|
2862 (set (make-local-variable 'font-lock-defaults) |
101958
e2dc5f14229e
(verilog-mode): Avoid circular use of syntax-ppss.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101002
diff
changeset
|
2863 `((verilog-font-lock-keywords verilog-font-lock-keywords-1 |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2864 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
|
2865 verilog-font-lock-keywords-3) |
101958
e2dc5f14229e
(verilog-mode): Avoid circular use of syntax-ppss.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101002
diff
changeset
|
2866 nil nil nil |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2867 ,(if (functionp 'syntax-ppss) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2868 ;; verilog-beg-of-defun uses syntax-ppss, and syntax-ppss uses |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2869 ;; font-lock-beginning-of-syntax-function, so |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2870 ;; font-lock-beginning-of-syntax-function, can't use |
101958
e2dc5f14229e
(verilog-mode): Avoid circular use of syntax-ppss.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
101002
diff
changeset
|
2871 ;; verilog-beg-of-defun. |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2872 nil |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2873 'verilog-beg-of-defun))) |
79545 | 2874 ;;------------------------------------------------------------ |
2875 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el) | |
2876 ;; 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
|
2877 (when (featurep 'xemacs) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2878 (make-local-hook 'font-lock-mode-hook) |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
2879 (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
|
2880 (make-local-hook 'after-change-functions)) |
79545 | 2881 (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
|
2882 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in Emacs |
79545 | 2883 (add-hook 'after-change-functions 'verilog-colorize-include-files t t) |
2884 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
2885 ;; Tell imenu how to handle Verilog. |
79545 | 2886 (make-local-variable 'imenu-generic-expression) |
2887 (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
|
2888 ;; 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
|
2889 (when (boundp 'which-function-modes) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2890 (add-to-list 'which-func-modes 'verilog-mode)) |
79545 | 2891 ;; hideshow support |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2892 (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
|
2893 (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
|
2894 (setq hs-special-modes-alist |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2895 (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
|
2896 verilog-forward-sexp-function) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
2897 hs-special-modes-alist)))) |
79545 | 2898 |
2899 ;; Stuff for autos | |
2900 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local | |
2901 (run-hooks 'verilog-mode-hook)) | |
2902 | |
2903 | |
2904 ;; | |
2905 ;; Electric functions | |
2906 ;; | |
2907 (defun electric-verilog-terminate-line (&optional arg) | |
2908 "Terminate line and indent next line. | |
2909 With optional ARG, remove existing end of line comments." | |
2910 (interactive) | |
2911 ;; 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
|
2912 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 2913 (cond |
2914 ((nth 7 state) ; Inside // comment | |
2915 (if (eolp) | |
2916 (progn | |
2917 (delete-horizontal-space) | |
2918 (newline)) | |
2919 (progn | |
2920 (newline) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
2921 (insert "// ") |
79545 | 2922 (beginning-of-line))) |
2923 (verilog-indent-line)) | |
2924 ((nth 4 state) ; Inside any comment (hence /**/) | |
2925 (newline) | |
2926 (verilog-more-comment)) | |
2927 ((eolp) | |
2928 ;; First, check if current line should be indented | |
2929 (if (save-excursion | |
2930 (delete-horizontal-space) | |
2931 (beginning-of-line) | |
2932 (skip-chars-forward " \t") | |
2933 (if (looking-at verilog-auto-end-comment-lines-re) | |
2934 (let ((indent-str (verilog-indent-line))) | |
2935 ;; Maybe we should set some endcomments | |
2936 (if verilog-auto-endcomments | |
2937 (verilog-set-auto-endcomments indent-str arg)) | |
2938 (end-of-line) | |
2939 (delete-horizontal-space) | |
2940 (if arg | |
2941 () | |
2942 (newline)) | |
2943 nil) | |
2944 (progn | |
2945 (end-of-line) | |
2946 (delete-horizontal-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2947 't))) |
79545 | 2948 ;; see if we should line up assignments |
2949 (progn | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2950 (if (or (eq 'all verilog-auto-lineup) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2951 (eq 'assignments verilog-auto-lineup)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2952 (verilog-pretty-expr t "\\(<\\|:\\)?=" )) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2953 (newline)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2954 (forward-line 1)) |
79545 | 2955 ;; Indent next line |
2956 (if verilog-auto-indent-on-newline | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2957 (verilog-indent-line))) |
79545 | 2958 (t |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2959 (newline))))) |
79545 | 2960 |
2961 (defun electric-verilog-terminate-and-indent () | |
2962 "Insert a newline and indent for the next statement." | |
2963 (interactive) | |
2964 (electric-verilog-terminate-line 1)) | |
2965 | |
2966 (defun electric-verilog-semi () | |
2967 "Insert `;' character and reindent the line." | |
2968 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2969 (verilog-insert-last-command-event) |
79545 | 2970 |
2971 (if (or (verilog-in-comment-or-string-p) | |
2972 (verilog-in-escaped-name-p)) | |
2973 () | |
2974 (save-excursion | |
2975 (beginning-of-line) | |
2976 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
2977 (verilog-indent-line)) |
79545 | 2978 (if (and verilog-auto-newline |
2979 (not (verilog-parenthesis-depth))) | |
2980 (electric-verilog-terminate-line)))) | |
2981 | |
2982 (defun electric-verilog-semi-with-comment () | |
2983 "Insert `;' character, reindent the line and indent for comment." | |
2984 (interactive) | |
2985 (insert "\;") | |
2986 (save-excursion | |
2987 (beginning-of-line) | |
2988 (verilog-indent-line)) | |
2989 (indent-for-comment)) | |
2990 | |
2991 (defun electric-verilog-colon () | |
2992 "Insert `:' and do all indentations except line indent on this line." | |
2993 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
2994 (verilog-insert-last-command-event) |
79545 | 2995 ;; Do nothing if within string. |
2996 (if (or | |
2997 (verilog-within-string) | |
2998 (not (verilog-in-case-region-p))) | |
2999 () | |
3000 (save-excursion | |
3001 (let ((p (point)) | |
3002 (lim (progn (verilog-beg-of-statement) (point)))) | |
3003 (goto-char p) | |
3004 (verilog-backward-case-item lim) | |
3005 (verilog-indent-line))) | |
3006 ;; (let ((verilog-tab-always-indent nil)) | |
3007 ;; (verilog-indent-line)) | |
3008 )) | |
3009 | |
3010 ;;(defun electric-verilog-equal () | |
3011 ;; "Insert `=', and do indentation if within block." | |
3012 ;; (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3013 ;; (verilog-insert-last-command-event) |
79545 | 3014 ;; Could auto line up expressions, but not yet |
3015 ;; (if (eq (car (verilog-calculate-indent)) 'block) | |
3016 ;; (let ((verilog-tab-always-indent nil)) | |
3017 ;; (verilog-indent-command))) | |
3018 ;; ) | |
3019 | |
3020 (defun electric-verilog-tick () | |
3021 "Insert back-tick, and indent to column 0 if this is a CPP directive." | |
3022 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3023 (verilog-insert-last-command-event) |
79545 | 3024 (save-excursion |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3025 (if (verilog-in-directive-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3026 (verilog-indent-line)))) |
79545 | 3027 |
3028 (defun electric-verilog-tab () | |
3029 "Function called when TAB is pressed in Verilog mode." | |
3030 (interactive) | |
3031 ;; If verilog-tab-always-indent, indent the beginning of the line. | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3032 (cond |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3033 ;; The region is active, indent it. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3034 ((and (region-active-p) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3035 (not (eq (region-beginning) (region-end)))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3036 (indent-region (region-beginning) (region-end) nil)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3037 ((or verilog-tab-always-indent |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3038 (save-excursion |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3039 (skip-chars-backward " \t") |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3040 (bolp))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3041 (let* ((oldpnt (point)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3042 (boi-point |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3043 (save-excursion |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3044 (beginning-of-line) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3045 (skip-chars-forward " \t") |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3046 (verilog-indent-line) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3047 (back-to-indentation) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3048 (point)))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3049 (if (< (point) boi-point) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3050 (back-to-indentation) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3051 (cond ((not verilog-tab-to-comment)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3052 ((not (eolp)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3053 (end-of-line)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3054 (t |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3055 (indent-for-comment) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3056 (when (and (eolp) (= oldpnt (point))) |
79545 | 3057 ; kill existing comment |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3058 (beginning-of-line) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3059 (re-search-forward comment-start-skip oldpnt 'move) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3060 (goto-char (match-beginning 0)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3061 (skip-chars-backward " \t") |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3062 (kill-region (point) oldpnt))))))) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
3063 (t (progn (insert "\t"))))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3064 |
79545 | 3065 |
3066 | |
3067 ;; | |
3068 ;; Interactive functions | |
3069 ;; | |
3070 | |
3071 (defun verilog-indent-buffer () | |
3072 "Indent-region the entire buffer as Verilog code. | |
3073 To call this from the command line, see \\[verilog-batch-indent]." | |
3074 (interactive) | |
3075 (verilog-mode) | |
3076 (indent-region (point-min) (point-max) nil)) | |
3077 | |
3078 (defun verilog-insert-block () | |
3079 "Insert Verilog begin ... end; block in the code with right indentation." | |
3080 (interactive) | |
3081 (verilog-indent-line) | |
3082 (insert "begin") | |
3083 (electric-verilog-terminate-line) | |
3084 (save-excursion | |
3085 (electric-verilog-terminate-line) | |
3086 (insert "end") | |
3087 (beginning-of-line) | |
3088 (verilog-indent-line))) | |
3089 | |
3090 (defun verilog-star-comment () | |
3091 "Insert Verilog star comment at point." | |
3092 (interactive) | |
3093 (verilog-indent-line) | |
3094 (insert "/*") | |
3095 (save-excursion | |
3096 (newline) | |
3097 (insert " */")) | |
3098 (newline) | |
3099 (insert " * ")) | |
3100 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3101 (defun verilog-insert-1 (fmt max) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3102 "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
|
3103 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
|
3104 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
|
3105 (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
|
3106 (n 0)) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3107 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3108 (while (< n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3109 (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
|
3110 (forward-line 1) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3111 ;; 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
|
3112 ;; shorter than col. |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3113 (if (eobp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3114 (setq n max) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3115 (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
|
3116 (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
|
3117 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3118 (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
|
3119 "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
|
3120 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
|
3121 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
|
3122 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
|
3123 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
|
3124 located after the first 'a' gives: |
79545 | 3125 |
3126 a = b a[ 0] = b | |
3127 a = b a[ 1] = b | |
3128 a = b a[ 2] = b | |
3129 a = b a[ 3] = b | |
3130 a = b ==> insert-indices ==> a[ 4] = b | |
3131 a = b a[ 5] = b | |
3132 a = b a[ 6] = b | |
3133 a = b a[ 7] = b | |
3134 a = b a[ 8] = b" | |
3135 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3136 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3137 (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
|
3138 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3139 (defun verilog-generate-numbers (max) |
79545 | 3140 "Insert a set of generated numbers into a rectangle. |
3141 The upper left corner is defined by point. The numbers are padded to three | |
3142 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
|
3143 is supplied, then the user is prompted for the MAX number. Consider the |
79545 | 3144 following code fragment: |
3145 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3146 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
|
3147 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
|
3148 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
|
3149 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
|
3150 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
|
3151 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
|
3152 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
|
3153 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
|
3154 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
|
3155 |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3156 (interactive "NMAX: ") |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
3157 (verilog-insert-1 "%3.3d" max)) |
79545 | 3158 |
3159 (defun verilog-mark-defun () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3160 "Mark the current Verilog function (or procedure). |
79545 | 3161 This puts the mark at the end, and point at the beginning." |
3162 (interactive) | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3163 (if (featurep 'xemacs) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3164 (progn |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3165 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3166 (verilog-end-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3167 (push-mark (point)) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3168 (verilog-beg-of-defun) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3169 (if (fboundp 'zmacs-activate-region) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3170 (zmacs-activate-region))) |
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
3171 (mark-defun))) |
79545 | 3172 |
3173 (defun verilog-comment-region (start end) | |
3174 ; checkdoc-params: (start end) | |
3175 "Put the region into a Verilog comment. | |
3176 The comments that are in this area are \"deformed\": | |
3177 `*)' becomes `!(*' and `}' becomes `!{'. | |
3178 These deformed comments are returned to normal if you use | |
3179 \\[verilog-uncomment-region] to undo the commenting. | |
3180 | |
3181 The commented area starts with `verilog-exclude-str-start', and ends with | |
3182 `verilog-exclude-str-end'. But if you change these variables, | |
3183 \\[verilog-uncomment-region] won't recognize the comments." | |
3184 (interactive "r") | |
3185 (save-excursion | |
3186 ;; Insert start and endcomments | |
3187 (goto-char end) | |
3188 (if (and (save-excursion (skip-chars-forward " \t") (eolp)) | |
3189 (not (save-excursion (skip-chars-backward " \t") (bolp)))) | |
3190 (forward-line 1) | |
3191 (beginning-of-line)) | |
3192 (insert verilog-exclude-str-end) | |
3193 (setq end (point)) | |
3194 (newline) | |
3195 (goto-char start) | |
3196 (beginning-of-line) | |
3197 (insert verilog-exclude-str-start) | |
3198 (newline) | |
3199 ;; Replace end-comments within commented area | |
3200 (goto-char end) | |
3201 (save-excursion | |
3202 (while (re-search-backward "\\*/" start t) | |
3203 (replace-match "*-/" t t))) | |
3204 (save-excursion | |
3205 (let ((s+1 (1+ start))) | |
3206 (while (re-search-backward "/\\*" s+1 t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3207 (replace-match "/-*" t t)))))) |
79545 | 3208 |
3209 (defun verilog-uncomment-region () | |
3210 "Uncomment a commented area; change deformed comments back to normal. | |
3211 This command does nothing if the pointer is not in a commented | |
3212 area. See also `verilog-comment-region'." | |
3213 (interactive) | |
3214 (save-excursion | |
3215 (let ((start (point)) | |
3216 (end (point))) | |
3217 ;; Find the boundaries of the comment | |
3218 (save-excursion | |
3219 (setq start (progn (search-backward verilog-exclude-str-start nil t) | |
3220 (point))) | |
3221 (setq end (progn (search-forward verilog-exclude-str-end nil t) | |
3222 (point)))) | |
3223 ;; Check if we're really inside a comment | |
3224 (if (or (equal start (point)) (<= end (point))) | |
3225 (message "Not standing within commented area.") | |
3226 (progn | |
3227 ;; Remove endcomment | |
3228 (goto-char end) | |
3229 (beginning-of-line) | |
3230 (let ((pos (point))) | |
3231 (end-of-line) | |
3232 (delete-region pos (1+ (point)))) | |
3233 ;; Change comments back to normal | |
3234 (save-excursion | |
3235 (while (re-search-backward "\\*-/" start t) | |
3236 (replace-match "*/" t t))) | |
3237 (save-excursion | |
3238 (while (re-search-backward "/-\\*" start t) | |
3239 (replace-match "/*" t t))) | |
3240 ;; Remove start comment | |
3241 (goto-char start) | |
3242 (beginning-of-line) | |
3243 (let ((pos (point))) | |
3244 (end-of-line) | |
3245 (delete-region pos (1+ (point))))))))) | |
3246 | |
3247 (defun verilog-beg-of-defun () | |
3248 "Move backward to the beginning of the current function or procedure." | |
3249 (interactive) | |
3250 (verilog-re-search-backward verilog-defun-re nil 'move)) | |
3251 | |
3252 (defun verilog-end-of-defun () | |
3253 "Move forward to the end of the current function or procedure." | |
3254 (interactive) | |
3255 (verilog-re-search-forward verilog-end-defun-re nil 'move)) | |
3256 | |
3257 (defun verilog-get-beg-of-defun (&optional warn) | |
3258 (save-excursion | |
3259 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t) | |
3260 (point)) | |
3261 (t | |
3262 (error "%s: Can't find module beginning" (verilog-point-text)) | |
3263 (point-max))))) | |
3264 (defun verilog-get-end-of-defun (&optional warn) | |
3265 (save-excursion | |
3266 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t) | |
3267 (point)) | |
3268 (t | |
3269 (error "%s: Can't find endmodule" (verilog-point-text)) | |
3270 (point-max))))) | |
3271 | |
3272 (defun verilog-label-be (&optional arg) | |
3273 "Label matching begin ... end, fork ... join and case ... endcase statements. | |
3274 With ARG, first kill any existing labels." | |
3275 (interactive) | |
3276 (let ((cnt 0) | |
3277 (oldpos (point)) | |
3278 (b (progn | |
3279 (verilog-beg-of-defun) | |
3280 (point-marker))) | |
3281 (e (progn | |
3282 (verilog-end-of-defun) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3283 (point-marker)))) |
79545 | 3284 (goto-char (marker-position b)) |
3285 (if (> (- e b) 200) | |
3286 (message "Relabeling module...")) | |
3287 (while (and | |
3288 (> (marker-position e) (point)) | |
3289 (verilog-re-search-forward | |
3290 (concat | |
3291 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>" | |
3292 "\\|\\(`endif\\)\\|\\(`else\\)") | |
3293 nil 'move)) | |
3294 (goto-char (match-beginning 0)) | |
3295 (let ((indent-str (verilog-indent-line))) | |
3296 (verilog-set-auto-endcomments indent-str 't) | |
3297 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3298 (delete-horizontal-space)) |
79545 | 3299 (setq cnt (1+ cnt)) |
3300 (if (= 9 (% cnt 10)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3301 (message "%d..." cnt))) |
79545 | 3302 (goto-char oldpos) |
3303 (if (or | |
3304 (> (- e b) 200) | |
3305 (> cnt 20)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3306 (message "%d lines auto commented" cnt)))) |
79545 | 3307 |
3308 (defun verilog-beg-of-statement () | |
3309 "Move backward to beginning of statement." | |
3310 (interactive) | |
3311 ;; Move back token by token until we see the end | |
3312 ;; of some ealier line. | |
3313 (while | |
3314 ;; If the current point does not begin a new | |
3315 ;; statement, as in the character ahead of us is a ';', or SOF | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
3316 ;; or the string after us unambiguously starts a statement, |
79545 | 3317 ;; or the token before us unambiguously ends a statement, |
3318 ;; then move back a token and test again. | |
3319 (not (or | |
3320 (bolp) | |
3321 (= (preceding-char) ?\;) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3322 (looking-at "\\w+\\W*:\\W*\\(coverpoint\\|cross\\|constraint\\)") |
79545 | 3323 (not (or |
3324 (looking-at "\\<") | |
3325 (forward-word -1))) | |
3326 (and | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
3327 (looking-at verilog-complete-reg) |
79545 | 3328 (not (save-excursion |
3329 (verilog-backward-token) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3330 (looking-at verilog-extended-complete-re)))) |
79545 | 3331 (looking-at verilog-basic-complete-re) |
3332 (save-excursion | |
3333 (verilog-backward-token) | |
3334 (or | |
3335 (looking-at verilog-end-block-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3336 (looking-at verilog-preprocessor-re))))) |
79545 | 3337 (verilog-backward-syntactic-ws) |
3338 (verilog-backward-token)) | |
3339 ;; Now point is where the previous line ended. | |
3340 (verilog-forward-syntactic-ws)) | |
3341 | |
3342 (defun verilog-beg-of-statement-1 () | |
3343 "Move backward to beginning of statement." | |
3344 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3345 (if (verilog-in-comment-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3346 (verilog-backward-syntactic-ws)) |
79545 | 3347 (let ((pt (point))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3348 (catch 'done |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3349 (while (not (looking-at verilog-complete-reg)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3350 (setq pt (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3351 (verilog-backward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3352 (if (or (bolp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3353 (= (preceding-char) ?\;)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3354 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3355 (goto-char pt) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3356 (throw 'done t)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3357 (verilog-backward-token)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3358 (verilog-forward-syntactic-ws))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3359 ; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3360 ; (while (and |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3361 ; (not (looking-at verilog-complete-reg)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3362 ; (not (bolp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3363 ; (not (= (preceding-char) ?\;))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3364 ; (verilog-backward-token) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3365 ; (verilog-backward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3366 ; (setq pt (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3367 ; (goto-char pt) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3368 ; ;(verilog-forward-syntactic-ws) |
79545 | 3369 |
3370 (defun verilog-end-of-statement () | |
3371 "Move forward to end of current statement." | |
3372 (interactive) | |
3373 (let ((nest 0) pos) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3374 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3375 ((verilog-in-directive-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3376 (forward-line 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3377 (backward-char 1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3378 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3379 ((looking-at verilog-beg-block-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3380 (verilog-forward-sexp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3381 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3382 ((equal (char-after) ?\}) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3383 (forward-char)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3384 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3385 ;; Skip to end of statement |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3386 ((condition-case nil |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3387 (setq pos |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3388 (catch 'found |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3389 (while t |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3390 (forward-sexp 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3391 (verilog-skip-forward-comment-or-string) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3392 (if (eolp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3393 (forward-line 1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3394 (cond ((looking-at "[ \t]*;") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3395 (skip-chars-forward "^;") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3396 (forward-char 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3397 (throw 'found (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3398 ((save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3399 (forward-sexp -1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3400 (looking-at verilog-beg-block-re)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3401 (goto-char (match-beginning 0)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3402 (throw 'found nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3403 ((looking-at "[ \t]*)") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3404 (throw 'found (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3405 ((eobp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3406 (throw 'found (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3407 ))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3408 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3409 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3410 (error nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3411 (if (not pos) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3412 ;; Skip a whole block |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3413 (catch 'found |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3414 (while t |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3415 (verilog-re-search-forward verilog-end-statement-re nil 'move) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3416 (setq nest (if (match-end 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3417 (1+ nest) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3418 (1- nest))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3419 (cond ((eobp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3420 (throw 'found (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3421 ((= 0 nest) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3422 (throw 'found (verilog-end-of-statement)))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3423 pos))))) |
79545 | 3424 |
3425 (defun verilog-in-case-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3426 "Return true if in a case region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3427 More specifically, point @ in the line foo : @ begin" |
79545 | 3428 (interactive) |
3429 (save-excursion | |
3430 (if (and | |
3431 (progn (verilog-forward-syntactic-ws) | |
3432 (looking-at "\\<begin\\>")) | |
3433 (progn (verilog-backward-syntactic-ws) | |
3434 (= (preceding-char) ?\:))) | |
3435 (catch 'found | |
3436 (let ((nest 1)) | |
3437 (while t | |
3438 (verilog-re-search-backward | |
3439 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|" | |
3440 "\\(\\<endcase\\>\\)\\>") | |
3441 nil 'move) | |
3442 (cond | |
3443 ((match-end 3) | |
3444 (setq nest (1+ nest))) | |
3445 ((match-end 2) | |
3446 (if (= nest 1) | |
3447 (throw 'found 1)) | |
3448 (setq nest (1- nest))) | |
3449 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3450 (throw 'found (= nest 0))))))) |
79545 | 3451 nil))) |
3452 (defun verilog-in-struct-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3453 "Return true if in a struct region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3454 More specifically, in a list after a struct|union keyword." |
79545 | 3455 (interactive) |
3456 (save-excursion | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
3457 (let* ((state (verilog-syntax-ppss)) |
79545 | 3458 (depth (nth 0 state))) |
3459 (if depth | |
3460 (progn (backward-up-list depth) | |
3461 (verilog-beg-of-statement) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3462 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>")))))) |
79545 | 3463 |
3464 (defun verilog-in-generate-region-p () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3465 "Return true if in a generate region. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3466 More specifically, after a generate and before an endgenerate." |
79545 | 3467 (interactive) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3468 (let ((nest 1)) |
79545 | 3469 (save-excursion |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3470 (catch 'done |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3471 (while (and |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3472 (/= nest 0) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3473 (verilog-re-search-backward |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3474 "\\<\\(module\\)\\|\\(generate\\)\\|\\(endgenerate\\)\\>" nil 'move) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3475 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3476 ((match-end 1) ; module - we have crawled out |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3477 (throw 'done 1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3478 ((match-end 2) ; generate |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3479 (setq nest (1- nest))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3480 ((match-end 3) ; endgenerate |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3481 (setq nest (1+ nest)))))))) |
79545 | 3482 (= nest 0) )) ; return nest |
3483 | |
3484 (defun verilog-in-fork-region-p () | |
3485 "Return true if between a fork and join." | |
3486 (interactive) | |
3487 (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
|
3488 (nest 1)) |
79545 | 3489 (save-excursion |
3490 (while (and | |
3491 (/= nest 0) | |
3492 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move) | |
3493 (cond | |
3494 ((match-end 1) ; fork | |
3495 (setq nest (1- nest))) | |
3496 ((match-end 2) ; join | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3497 (setq nest (1+ nest))))))) |
79545 | 3498 (= nest 0) )) ; return nest |
3499 | |
3500 (defun verilog-backward-case-item (lim) | |
3501 "Skip backward to nearest enclosing case item. | |
3502 Limit search to point LIM." | |
3503 (interactive) | |
3504 (let ((str 'nil) | |
3505 (lim1 | |
3506 (progn | |
3507 (save-excursion | |
3508 (verilog-re-search-backward verilog-endcomment-reason-re | |
3509 lim 'move) | |
3510 (point))))) | |
3511 ;; Try to find the real : | |
3512 (if (save-excursion (search-backward ":" lim1 t)) | |
3513 (let ((colon 0) | |
3514 b e ) | |
3515 (while | |
3516 (and | |
3517 (< colon 1) | |
3518 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)" | |
3519 lim1 'move)) | |
3520 (cond | |
3521 ((match-end 1) ;; [ | |
3522 (setq colon (1+ colon)) | |
3523 (if (>= colon 0) | |
3524 (error "%s: unbalanced [" (verilog-point-text)))) | |
3525 ((match-end 2) ;; ] | |
3526 (setq colon (1- colon))) | |
3527 | |
3528 ((match-end 3) ;; : | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3529 (setq colon (1+ colon))))) |
79545 | 3530 ;; Skip back to beginning of case item |
3531 (skip-chars-backward "\t ") | |
3532 (verilog-skip-backward-comment-or-string) | |
3533 (setq e (point)) | |
3534 (setq b | |
3535 (progn | |
3536 (if | |
3537 (verilog-re-search-backward | |
3538 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move) | |
3539 (progn | |
3540 (cond | |
3541 ((match-end 1) | |
3542 (goto-char (match-end 1)) | |
3543 (verilog-forward-ws&directives) | |
3544 (if (looking-at "(") | |
3545 (progn | |
3546 (forward-sexp) | |
3547 (verilog-forward-ws&directives))) | |
3548 (point)) | |
3549 (t | |
3550 (goto-char (match-end 0)) | |
3551 (verilog-forward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3552 (point)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3553 (error "Malformed case item")))) |
79545 | 3554 (setq str (buffer-substring b e)) |
3555 (if | |
3556 (setq e | |
3557 (string-match | |
3558 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3559 (setq str (concat (substring str 0 e) "..."))) | |
3560 str) | |
3561 'nil))) | |
3562 | |
3563 | |
3564 ;; | |
3565 ;; Other functions | |
3566 ;; | |
3567 | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3568 (defun verilog-kill-existing-comment () |
79545 | 3569 "Kill auto comment on this line." |
3570 (save-excursion | |
3571 (let* ( | |
3572 (e (progn | |
3573 (end-of-line) | |
3574 (point))) | |
3575 (b (progn | |
3576 (beginning-of-line) | |
3577 (search-forward "//" e t)))) | |
3578 (if b | |
3579 (delete-region (- b 2) e))))) | |
3580 | |
3581 (defconst verilog-directive-nest-re | |
3582 (concat "\\(`else\\>\\)\\|" | |
3583 "\\(`endif\\>\\)\\|" | |
3584 "\\(`if\\>\\)\\|" | |
3585 "\\(`ifdef\\>\\)\\|" | |
3586 "\\(`ifndef\\>\\)")) | |
3587 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment) | |
3588 "Add ending comment with given INDENT-STR. | |
3589 With KILL-EXISTING-COMMENT, remove what was there before. | |
3590 Insert `// case: 7 ' or `// NAME ' on this line if appropriate. | |
3591 Insert `// case expr ' if this line ends a case block. | |
3592 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
|
3593 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
|
3594 primitive or interface named NAME." |
79545 | 3595 (save-excursion |
3596 (cond | |
3597 (; Comment close preprocessor directives | |
3598 (and | |
3599 (looking-at "\\(`endif\\)\\|\\(`else\\)") | |
3600 (or kill-existing-comment | |
3601 (not (save-excursion | |
3602 (end-of-line) | |
3603 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3604 (let ((nest 1) b e | |
3605 m | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3606 (else (if (match-end 2) "!" " "))) |
79545 | 3607 (end-of-line) |
3608 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3609 (verilog-kill-existing-comment)) |
79545 | 3610 (delete-horizontal-space) |
3611 (save-excursion | |
3612 (backward-sexp 1) | |
3613 (while (and (/= nest 0) | |
3614 (verilog-re-search-backward verilog-directive-nest-re nil 'move)) | |
3615 (cond | |
3616 ((match-end 1) ; `else | |
3617 (if (= nest 1) | |
3618 (setq else "!"))) | |
3619 ((match-end 2) ; `endif | |
3620 (setq nest (1+ nest))) | |
3621 ((match-end 3) ; `if | |
3622 (setq nest (1- nest))) | |
3623 ((match-end 4) ; `ifdef | |
3624 (setq nest (1- nest))) | |
3625 ((match-end 5) ; `ifndef | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3626 (setq nest (1- nest))))) |
79545 | 3627 (if (match-end 0) |
3628 (setq | |
3629 m (buffer-substring | |
3630 (match-beginning 0) | |
3631 (match-end 0)) | |
3632 b (progn | |
3633 (skip-chars-forward "^ \t") | |
3634 (verilog-forward-syntactic-ws) | |
3635 (point)) | |
3636 e (progn | |
3637 (skip-chars-forward "a-zA-Z0-9_") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3638 (point))))) |
79545 | 3639 (if b |
3640 (if (> (count-lines (point) b) verilog-minimum-comment-distance) | |
3641 (insert (concat " // " else m " " (buffer-substring b e)))) | |
3642 (progn | |
3643 (insert " // unmatched `else or `endif") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3644 (ding 't))))) |
79545 | 3645 |
3646 (; Comment close case/class/function/task/module and named block | |
3647 (and (looking-at "\\<end") | |
3648 (or kill-existing-comment | |
3649 (not (save-excursion | |
3650 (end-of-line) | |
3651 (search-backward "//" (verilog-get-beg-of-line) t))))) | |
3652 (let ((type (car indent-str))) | |
3653 (unless (eq type 'declaration) | |
3654 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends | |
3655 (if (looking-at verilog-end-block-ordered-re) | |
3656 (cond | |
3657 (;- This is a case block; search back for the start of this case | |
3658 (match-end 1) ;; of verilog-end-block-ordered-re | |
3659 | |
3660 (let ((err 't) | |
3661 (str "UNMATCHED!!")) | |
3662 (save-excursion | |
3663 (verilog-leap-to-head) | |
3664 (cond | |
3665 ((looking-at "\\<randcase\\>") | |
3666 (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
|
3667 (setq err nil)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3668 ((looking-at "\\(\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?\\)") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3669 (goto-char (match-end 0)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3670 (setq str (concat (match-string 0) " " (verilog-get-expr))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3671 (setq err nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3672 )) |
79545 | 3673 (end-of-line) |
3674 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3675 (verilog-kill-existing-comment)) |
79545 | 3676 (delete-horizontal-space) |
3677 (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
|
3678 (if err (ding 't)))) |
79545 | 3679 |
3680 (;- This is a begin..end block | |
3681 (match-end 2) ;; of verilog-end-block-ordered-re | |
3682 (let ((str " // UNMATCHED !!") | |
3683 (err 't) | |
3684 (here (point)) | |
3685 there | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3686 cntx) |
79545 | 3687 (save-excursion |
3688 (verilog-leap-to-head) | |
3689 (setq there (point)) | |
3690 (if (not (match-end 0)) | |
3691 (progn | |
3692 (goto-char here) | |
3693 (end-of-line) | |
3694 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3695 (verilog-kill-existing-comment)) |
79545 | 3696 (delete-horizontal-space) |
3697 (insert str) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3698 (ding 't)) |
79545 | 3699 (let ((lim |
3700 (save-excursion (verilog-beg-of-defun) (point))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3701 (here (point))) |
79545 | 3702 (cond |
3703 (;-- handle named block differently | |
3704 (looking-at verilog-named-block-re) | |
3705 (search-forward ":") | |
3706 (setq there (point)) | |
3707 (setq str (verilog-get-expr)) | |
3708 (setq err nil) | |
3709 (setq str (concat " // block: " str ))) | |
3710 | |
3711 ((verilog-in-case-region-p) ;-- handle case item differently | |
3712 (goto-char here) | |
3713 (setq str (verilog-backward-case-item lim)) | |
3714 (setq there (point)) | |
3715 (setq err nil) | |
3716 (setq str (concat " // case: " str ))) | |
3717 | |
3718 (;- try to find "reason" for this begin | |
3719 (cond | |
3720 (; | |
3721 (eq here (progn | |
3722 (verilog-backward-token) | |
3723 (verilog-beg-of-statement-1) | |
3724 (point))) | |
3725 (setq err nil) | |
3726 (setq str "")) | |
3727 ((looking-at verilog-endcomment-reason-re) | |
3728 (setq there (match-end 0)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3729 (setq cntx (concat (match-string 0) " ")) |
79545 | 3730 (cond |
3731 (;- begin | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3732 (match-end 1) |
79545 | 3733 (setq err nil) |
3734 (save-excursion | |
3735 (if (and (verilog-continued-line) | |
3736 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>")) | |
3737 (progn | |
3738 (goto-char (match-end 0)) | |
3739 (setq there (point)) | |
3740 (setq str | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3741 (concat " // " (match-string 0) " " (verilog-get-expr)))) |
79545 | 3742 (setq str "")))) |
3743 | |
3744 (;- else | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3745 (match-end 2) |
79545 | 3746 (let ((nest 0) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3747 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3748 (catch 'skip |
3749 (while (verilog-re-search-backward reg nil 'move) | |
3750 (cond | |
3751 ((match-end 1) ; begin | |
3752 (setq nest (1- nest))) | |
3753 ((match-end 2) ; end | |
3754 (setq nest (1+ nest))) | |
3755 ((match-end 3) | |
3756 (if (= 0 nest) | |
3757 (progn | |
3758 (goto-char (match-end 0)) | |
3759 (setq there (point)) | |
3760 (setq err nil) | |
3761 (setq str (verilog-get-expr)) | |
3762 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3763 (throw 'skip 1))))))))) |
79545 | 3764 |
3765 (;- end else | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3766 (match-end 3) |
79545 | 3767 (goto-char there) |
3768 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3769 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)")) |
79545 | 3770 (catch 'skip |
3771 (while (verilog-re-search-backward reg nil 'move) | |
3772 (cond | |
3773 ((match-end 1) ; begin | |
3774 (setq nest (1- nest))) | |
3775 ((match-end 2) ; end | |
3776 (setq nest (1+ nest))) | |
3777 ((match-end 3) | |
3778 (if (= 0 nest) | |
3779 (progn | |
3780 (goto-char (match-end 0)) | |
3781 (setq there (point)) | |
3782 (setq err nil) | |
3783 (setq str (verilog-get-expr)) | |
3784 (setq str (concat " // else: !if" str )) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3785 (throw 'skip 1))))))))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3786 (; always_comb, always_ff, always_latch |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3787 (or (match-end 4) (match-end 5) (match-end 6)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3788 (goto-char (match-end 0)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3789 (setq there (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3790 (setq err nil) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3791 (setq str (concat " // " cntx ))) |
79545 | 3792 |
3793 (;- task/function/initial et cetera | |
3794 t | |
3795 (match-end 0) | |
3796 (goto-char (match-end 0)) | |
3797 (setq there (point)) | |
3798 (setq err nil) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
3799 (setq str (concat " // " cntx (verilog-get-expr)))) |
79545 | 3800 |
3801 (;-- otherwise... | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3802 (setq str " // auto-endcomment confused ")))) |
79545 | 3803 |
3804 ((and | |
3805 (verilog-in-case-region-p) ;-- handle case item differently | |
3806 (progn | |
3807 (setq there (point)) | |
3808 (goto-char here) | |
3809 (setq str (verilog-backward-case-item lim)))) | |
3810 (setq err nil) | |
3811 (setq str (concat " // case: " str ))) | |
3812 | |
3813 ((verilog-in-fork-region-p) | |
3814 (setq err nil) | |
3815 (setq str " // fork branch" )) | |
3816 | |
3817 ((looking-at "\\<end\\>") | |
3818 ;; HERE | |
3819 (forward-word 1) | |
3820 (verilog-forward-syntactic-ws) | |
3821 (setq err nil) | |
3822 (setq str (verilog-get-expr)) | |
3823 (setq str (concat " // " cntx str ))) | |
3824 | |
3825 )))) | |
3826 (goto-char here) | |
3827 (end-of-line) | |
3828 (if kill-existing-comment | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3829 (verilog-kill-existing-comment)) |
79545 | 3830 (delete-horizontal-space) |
3831 (if (or err | |
3832 (> (count-lines here there) verilog-minimum-comment-distance)) | |
3833 (insert str)) | |
3834 (if err (ding 't)) | |
3835 )))) | |
3836 (;- this is endclass, which can be nested | |
3837 (match-end 11) ;; of verilog-end-block-ordered-re | |
3838 ;;(goto-char there) | |
3839 (let ((nest 0) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3840 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>") |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3841 string) |
79545 | 3842 (save-excursion |
3843 (catch 'skip | |
3844 (while (verilog-re-search-backward reg nil 'move) | |
3845 (cond | |
3846 ((match-end 3) ; endclass | |
3847 (ding 't) | |
3848 (setq string "unmatched endclass") | |
3849 (throw 'skip 1)) | |
3850 | |
3851 ((match-end 2) ; endclass | |
3852 (setq nest (1+ nest))) | |
3853 | |
3854 ((match-end 1) ; class | |
3855 (setq nest (1- nest)) | |
3856 (if (< nest 0) | |
3857 (progn | |
3858 (goto-char (match-end 0)) | |
3859 (let (b e) | |
3860 (setq b (progn | |
3861 (skip-chars-forward "^ \t") | |
3862 (verilog-forward-ws&directives) | |
3863 (point)) | |
3864 e (progn | |
3865 (skip-chars-forward "a-zA-Z0-9_") | |
3866 (point))) | |
3867 (setq string (buffer-substring b e))) | |
3868 (throw 'skip 1)))) | |
3869 )))) | |
3870 (end-of-line) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3871 (insert (concat " // " string )))) |
79545 | 3872 |
3873 (;- this is end{function,generate,task,module,primitive,table,generate} | |
3874 ;- which can not be nested. | |
3875 t | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3876 (let (string reg (name-re nil)) |
79545 | 3877 (end-of-line) |
3878 (if kill-existing-comment | |
3879 (save-match-data | |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
3880 (verilog-kill-existing-comment))) |
79545 | 3881 (delete-horizontal-space) |
3882 (backward-sexp) | |
3883 (cond | |
3884 ((match-end 5) ;; of verilog-end-block-ordered-re | |
3885 (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
|
3886 (setq name-re "\\w+\\s-*(") |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3887 ) |
79545 | 3888 ((match-end 6) ;; of verilog-end-block-ordered-re |
3889 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)")) | |
3890 ((match-end 7) ;; of verilog-end-block-ordered-re | |
3891 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>")) | |
3892 ((match-end 8) ;; of verilog-end-block-ordered-re | |
3893 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3894 ((match-end 9) ;; of verilog-end-block-ordered-re | |
3895 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)")) | |
3896 ((match-end 10) ;; of verilog-end-block-ordered-re | |
3897 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3898 ((match-end 11) ;; of verilog-end-block-ordered-re | |
3899 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3900 ((match-end 12) ;; of verilog-end-block-ordered-re | |
3901 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3902 ((match-end 13) ;; of verilog-end-block-ordered-re | |
3903 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3904 ((match-end 14) ;; of verilog-end-block-ordered-re | |
3905 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)")) | |
3906 ((match-end 15) ;; of verilog-end-block-ordered-re | |
3907 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>")) | |
3908 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3909 (t (error "Problem in verilog-set-auto-endcomments"))) |
79545 | 3910 (let (b e) |
3911 (save-excursion | |
3912 (verilog-re-search-backward reg nil 'move) | |
3913 (cond | |
3914 ((match-end 1) | |
3915 (setq b (progn | |
3916 (skip-chars-forward "^ \t") | |
3917 (verilog-forward-ws&directives) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3918 (if (and name-re (verilog-re-search-forward name-re nil 'move)) |
79545 | 3919 (progn |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
3920 (goto-char (match-beginning 0)) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3921 (verilog-forward-ws&directives))) |
79545 | 3922 (point)) |
3923 e (progn | |
3924 (skip-chars-forward "a-zA-Z0-9_") | |
3925 (point))) | |
3926 (setq string (buffer-substring b e))) | |
3927 (t | |
3928 (ding 't) | |
3929 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)"))))) | |
3930 (end-of-line) | |
3931 (insert (concat " // " string ))) | |
3932 )))))))))) | |
3933 | |
3934 (defun verilog-get-expr() | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
3935 "Grab expression at point, e.g, case ( a | b & (c ^d))." |
79545 | 3936 (let* ((b (progn |
3937 (verilog-forward-syntactic-ws) | |
3938 (skip-chars-forward " \t") | |
3939 (point))) | |
3940 (e (let ((par 1)) | |
3941 (cond | |
3942 ((looking-at "@") | |
3943 (forward-char 1) | |
3944 (verilog-forward-syntactic-ws) | |
3945 (if (looking-at "(") | |
3946 (progn | |
3947 (forward-char 1) | |
3948 (while (and (/= par 0) | |
3949 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3950 (cond | |
3951 ((match-end 1) | |
3952 (setq par (1+ par))) | |
3953 ((match-end 2) | |
3954 (setq par (1- par))))))) | |
3955 (point)) | |
3956 ((looking-at "(") | |
3957 (forward-char 1) | |
3958 (while (and (/= par 0) | |
3959 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move)) | |
3960 (cond | |
3961 ((match-end 1) | |
3962 (setq par (1+ par))) | |
3963 ((match-end 2) | |
3964 (setq par (1- par))))) | |
3965 (point)) | |
3966 ((looking-at "\\[") | |
3967 (forward-char 1) | |
3968 (while (and (/= par 0) | |
3969 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move)) | |
3970 (cond | |
3971 ((match-end 1) | |
3972 (setq par (1+ par))) | |
3973 ((match-end 2) | |
3974 (setq par (1- par))))) | |
3975 (verilog-forward-syntactic-ws) | |
3976 (skip-chars-forward "^ \t\n\f") | |
3977 (point)) | |
3978 ((looking-at "/[/\\*]") | |
3979 b) | |
3980 ('t | |
3981 (skip-chars-forward "^: \t\n\f") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
3982 (point))))) |
79545 | 3983 (str (buffer-substring b e))) |
3984 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str)) | |
3985 (setq str (concat (substring str 0 e) "..."))) | |
3986 str)) | |
3987 | |
3988 (defun verilog-expand-vector () | |
3989 "Take a signal vector on the current line and expand it to multiple lines. | |
3990 Useful for creating tri's and other expanded fields." | |
3991 (interactive) | |
3992 (verilog-expand-vector-internal "[" "]")) | |
3993 | |
3994 (defun verilog-expand-vector-internal (bra ket) | |
3995 "Given BRA, the start brace and KET, the end brace, expand one line into many lines." | |
3996 (save-excursion | |
3997 (forward-line 0) | |
3998 (let ((signal-string (buffer-substring (point) | |
3999 (progn | |
4000 (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
|
4001 (if (string-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4002 (concat "\\(.*\\)" |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4003 (regexp-quote bra) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4004 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4005 (regexp-quote ket) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4006 "\\(.*\\)$") signal-string) |
79545 | 4007 (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
|
4008 (vec-start (string-to-number (match-string 2 signal-string))) |
79545 | 4009 (vec-end (if (= (match-beginning 3) (match-end 3)) |
4010 vec-start | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4011 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4012 (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
|
4013 (match-end 3))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4014 (vec-range |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4015 (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
|
4016 1 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4017 (string-to-number |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4018 (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
|
4019 (match-end 4))))) |
79545 | 4020 (sig-tail (match-string 5 signal-string)) |
4021 vec) | |
4022 ;; Decode vectors | |
4023 (setq vec nil) | |
4024 (if (< vec-range 0) | |
4025 (let ((tmp vec-start)) | |
4026 (setq vec-start vec-end | |
4027 vec-end tmp | |
4028 vec-range (- vec-range)))) | |
4029 (if (< vec-end vec-start) | |
4030 (while (<= vec-end vec-start) | |
4031 (setq vec (append vec (list vec-start))) | |
4032 (setq vec-start (- vec-start vec-range))) | |
4033 (while (<= vec-start vec-end) | |
4034 (setq vec (append vec (list vec-start))) | |
4035 (setq vec-start (+ vec-start vec-range)))) | |
4036 ;; | |
4037 ;; Delete current line | |
4038 (delete-region (point) (progn (forward-line 0) (point))) | |
4039 ;; | |
4040 ;; Expand vector | |
4041 (while vec | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4042 (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
|
4043 (int-to-string (car vec)) ket sig-tail "\n")) |
79545 | 4044 (setq vec (cdr vec))) |
4045 (delete-char -1) | |
4046 ;; | |
4047 ))))) | |
4048 | |
4049 (defun verilog-strip-comments () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4050 "Strip all comments from the Verilog code." |
79545 | 4051 (interactive) |
4052 (goto-char (point-min)) | |
4053 (while (re-search-forward "//" nil t) | |
4054 (if (verilog-within-string) | |
4055 (re-search-forward "\"" nil t) | |
4056 (if (verilog-in-star-comment-p) | |
4057 (re-search-forward "\*/" nil t) | |
4058 (let ((bpt (- (point) 2))) | |
4059 (end-of-line) | |
4060 (delete-region bpt (point)))))) | |
4061 ;; | |
4062 (goto-char (point-min)) | |
4063 (while (re-search-forward "/\\*" nil t) | |
4064 (if (verilog-within-string) | |
4065 (re-search-forward "\"" nil t) | |
4066 (let ((bpt (- (point) 2))) | |
4067 (re-search-forward "\\*/") | |
4068 (delete-region bpt (point)))))) | |
4069 | |
4070 (defun verilog-one-line () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4071 "Convert structural Verilog instances to occupy one line." |
79545 | 4072 (interactive) |
4073 (goto-char (point-min)) | |
4074 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t) | |
4075 (replace-match "\\1 " nil nil))) | |
4076 | |
4077 (defun verilog-linter-name () | |
4078 "Return name of linter, either surelint or verilint." | |
4079 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
4080 compile-command)) | |
4081 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil | |
4082 verilog-linter))) | |
4083 (cond ((equal compile-word1 "surelint") `surelint) | |
4084 ((equal compile-word1 "verilint") `verilint) | |
4085 ((equal lint-word1 "surelint") `surelint) | |
4086 ((equal lint-word1 "verilint") `verilint) | |
4087 (t `surelint)))) ;; back compatibility | |
4088 | |
4089 (defun verilog-lint-off () | |
4090 "Convert a Verilog linter warning line into a disable statement. | |
4091 For example: | |
4092 pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
4093 becomes a comment for the appropriate tool. | |
4094 | |
4095 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
|
4096 variables is used to determine which product is being used. |
79545 | 4097 |
4098 See \\[verilog-surelint-off] and \\[verilog-verilint-off]." | |
4099 (interactive) | |
4100 (let ((linter (verilog-linter-name))) | |
4101 (cond ((equal linter `surelint) | |
4102 (verilog-surelint-off)) | |
4103 ((equal linter `verilint) | |
4104 (verilog-verilint-off)) | |
4105 (t (error "Linter name not set"))))) | |
4106 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4107 (defvar compilation-last-buffer) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4108 (defvar next-error-last-buffer) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4109 |
79545 | 4110 (defun verilog-surelint-off () |
4111 "Convert a SureLint warning line into a disable statement. | |
4112 Run from Verilog source window; assumes there is a *compile* buffer | |
4113 with point set appropriately. | |
4114 | |
4115 For example: | |
4116 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned. | |
4117 becomes: | |
4118 // surefire lint_line_off UDDONX" | |
4119 (interactive) | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4120 (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
|
4121 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
|
4122 compilation-last-buffer))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4123 (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
|
4124 ;; 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
|
4125 (save-excursion |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4126 (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
|
4127 (beginning-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4128 (when |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4129 (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
|
4130 (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
|
4131 (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
|
4132 (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
|
4133 (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
|
4134 dir filename) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4135 (unless buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4136 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4137 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4138 (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
|
4139 (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
|
4140 (or buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4141 (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
|
4142 (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
|
4143 (read-file-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4144 (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
|
4145 file) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4146 dir file t)))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4147 (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
|
4148 (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
|
4149 (setq buffer |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4150 (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
|
4151 (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
|
4152 (switch-to-buffer buffer) |
104774
468b7fa34d2c
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
104682
diff
changeset
|
4153 (goto-char (point-min)) |
468b7fa34d2c
Use forward-line rather than goto-line.
Glenn Morris <rgm@gnu.org>
parents:
104682
diff
changeset
|
4154 (forward-line (- (string-to-number line))) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4155 (end-of-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4156 (catch 'already |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4157 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4158 ((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
|
4159 (re-search-backward "//") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4160 (cond |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4161 ((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
|
4162 (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
|
4163 (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
|
4164 (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
|
4165 (throw 'already t) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4166 (insert (concat " " code))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4167 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4168 ))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4169 ((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
|
4170 (re-search-backward "/\*") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4171 (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
|
4172 (t |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4173 (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
|
4174 ))))))))) |
79545 | 4175 |
4176 (defun verilog-verilint-off () | |
4177 "Convert a Verilint warning line into a disable statement. | |
4178 | |
4179 For example: | |
4180 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_ | |
4181 becomes: | |
4182 //Verilint 240 off // WARNING: Unused input" | |
4183 (interactive) | |
4184 (save-excursion | |
4185 (beginning-of-line) | |
4186 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$") | |
4187 (replace-match (format | |
4188 ;; %3s makes numbers 1-999 line up nicely | |
4189 "\\1//Verilint %3s off // WARNING: \\3" | |
4190 (match-string 2))) | |
4191 (beginning-of-line) | |
4192 (verilog-indent-line)))) | |
4193 | |
4194 (defun verilog-auto-save-compile () | |
4195 "Update automatics with \\[verilog-auto], save the buffer, and compile." | |
4196 (interactive) | |
4197 (verilog-auto) ; Always do it for safety | |
4198 (save-buffer) | |
4199 (compile compile-command)) | |
4200 | |
4201 | |
4202 | |
4203 ;; | |
4204 ;; Batch | |
4205 ;; | |
4206 | |
4207 (defmacro verilog-batch-error-wrapper (&rest body) | |
4208 "Execute BODY and add error prefix to any errors found. | |
4209 This lets programs calling batch mode to easily extract error messages." | |
79546 | 4210 `(condition-case err |
4211 (progn ,@body) | |
4212 (error | |
4213 (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
|
4214 (if (featurep 'xemacs) "\n" ""))))) ;; XEmacs forgets to add a newline |
79545 | 4215 |
4216 (defun verilog-batch-execute-func (funref) | |
4217 "Internal processing of a batch command, running FUNREF on all command arguments." | |
4218 (verilog-batch-error-wrapper | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4219 ;; Setting global variables like that is *VERY NASTY* !!! --Stef |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4220 ;; However, this function is called only when Emacs is being used as |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4221 ;; a standalone language instead of as an editor, so we'll live. |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4222 ;; |
79545 | 4223 ;; General globals needed |
4224 (setq make-backup-files nil) | |
4225 (setq-default make-backup-files nil) | |
4226 (setq enable-local-variables t) | |
4227 (setq enable-local-eval t) | |
4228 ;; Make sure any sub-files we read get proper mode | |
104682
73bff1db57b6
* gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104581
diff
changeset
|
4229 (setq-default major-mode 'verilog-mode) |
79545 | 4230 ;; 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
|
4231 (mapc (lambda (buf) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4232 (when (buffer-file-name buf) |
104682
73bff1db57b6
* gnus/nnheader.el (nnheader-find-file-noselect):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104581
diff
changeset
|
4233 (with-current-buffer buf |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4234 (verilog-mode)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4235 (buffer-list)) |
79545 | 4236 ;; Process the files |
4237 (mapcar '(lambda (buf) | |
4238 (when (buffer-file-name buf) | |
4239 (save-excursion | |
4240 (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
|
4241 (error |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
4242 (concat "File not found: " (buffer-file-name buf)))) |
79545 | 4243 (message (concat "Processing " (buffer-file-name buf))) |
4244 (set-buffer buf) | |
4245 (funcall funref) | |
4246 (save-buffer)))) | |
4247 (buffer-list)))) | |
4248 | |
4249 (defun verilog-batch-auto () | |
4250 "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
|
4251 This sets up the appropriate Verilog mode environment, updates automatics |
79545 | 4252 with \\[verilog-auto] on all command-line files, and saves the buffers. |
4253 For proper results, multiple filenames need to be passed on the command | |
4254 line in bottom-up order." | |
4255 (unless noninteractive | |
4256 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
4257 (verilog-batch-execute-func `verilog-auto)) | |
4258 | |
4259 (defun verilog-batch-delete-auto () | |
4260 "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
|
4261 This sets up the appropriate Verilog mode environment, deletes automatics |
79545 | 4262 with \\[verilog-delete-auto] on all command-line files, and saves the buffers." |
4263 (unless noninteractive | |
4264 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
4265 (verilog-batch-execute-func `verilog-delete-auto)) | |
4266 | |
4267 (defun verilog-batch-inject-auto () | |
4268 "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
|
4269 This sets up the appropriate Verilog mode environment, injects new automatics |
79545 | 4270 with \\[verilog-inject-auto] on all command-line files, and saves the buffers. |
4271 For proper results, multiple filenames need to be passed on the command | |
4272 line in bottom-up order." | |
4273 (unless noninteractive | |
4274 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes | |
4275 (verilog-batch-execute-func `verilog-inject-auto)) | |
4276 | |
4277 (defun verilog-batch-indent () | |
4278 "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
|
4279 This sets up the appropriate Verilog mode environment, calls |
79545 | 4280 \\[verilog-indent-buffer] on all command-line files, and saves the buffers." |
4281 (unless noninteractive | |
4282 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes | |
4283 (verilog-batch-execute-func `verilog-indent-buffer)) | |
4284 | |
4285 | |
4286 ;; | |
4287 ;; Indentation | |
4288 ;; | |
4289 (defconst verilog-indent-alist | |
4290 '((block . (+ ind verilog-indent-level)) | |
4291 (case . (+ ind verilog-case-indent)) | |
4292 (cparenexp . (+ ind verilog-indent-level)) | |
4293 (cexp . (+ ind verilog-cexp-indent)) | |
4294 (defun . verilog-indent-level-module) | |
4295 (declaration . verilog-indent-level-declaration) | |
4296 (directive . (verilog-calculate-indent-directive)) | |
4297 (tf . verilog-indent-level) | |
4298 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module)) | |
4299 (statement . ind) | |
4300 (cpp . 0) | |
4301 (comment . (verilog-comment-indent)) | |
4302 (unknown . 3) | |
4303 (string . 0))) | |
4304 | |
4305 (defun verilog-continued-line-1 (lim) | |
4306 "Return true if this is a continued line. | |
4307 Set point to where line starts. Limit search to point LIM." | |
4308 (let ((continued 't)) | |
4309 (if (eq 0 (forward-line -1)) | |
4310 (progn | |
4311 (end-of-line) | |
4312 (verilog-backward-ws&directives lim) | |
4313 (if (bobp) | |
4314 (setq continued nil) | |
4315 (setq continued (verilog-backward-token)))) | |
4316 (setq continued nil)) | |
4317 continued)) | |
4318 | |
4319 (defun verilog-calculate-indent () | |
4320 "Calculate the indent of the current Verilog line. | |
4321 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
|
4322 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
|
4323 Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)." |
79545 | 4324 (save-excursion |
4325 (let* ((starting_position (point)) | |
4326 (par 0) | |
4327 (begin (looking-at "[ \t]*begin\\>")) | |
4328 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t))) | |
4329 (type (catch 'nesting | |
4330 ;; Keep working backwards until we can figure out | |
4331 ;; what type of statement this is. | |
4332 ;; Basically we need to figure out | |
4333 ;; 1) if this is a continuation of the previous line; | |
4334 ;; 2) are we in a block scope (begin..end) | |
4335 | |
4336 ;; if we are in a comment, done. | |
4337 (if (verilog-in-star-comment-p) | |
4338 (throw 'nesting 'comment)) | |
4339 | |
4340 ;; if we have a directive, done. | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4341 (if (save-excursion (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4342 (and (looking-at verilog-directive-re-1) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4343 (not (or (looking-at "[ \t]*`ovm_") |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4344 (looking-at "[ \t]*`vmm_"))))) |
79545 | 4345 (throw 'nesting 'directive)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4346 ;; indent structs as if there were module level |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4347 (if (verilog-in-struct-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4348 (throw 'nesting 'block)) |
79545 | 4349 |
4350 ;; unless we are in the newfangled coverpoint or constraint blocks | |
4351 ;; if we are in a parenthesized list, and the user likes to indent these, return. | |
4352 (if (and | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4353 verilog-indent-lists |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4354 (verilog-in-paren) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4355 (not (verilog-in-coverage-p)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4356 ) |
79545 | 4357 (progn (setq par 1) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4358 (throw 'nesting 'block))) |
79545 | 4359 |
4360 ;; See if we are continuing a previous line | |
4361 (while t | |
4362 ;; trap out if we crawl off the top of the buffer | |
4363 (if (bobp) (throw 'nesting 'cpp)) | |
4364 | |
4365 (if (verilog-continued-line-1 lim) | |
4366 (let ((sp (point))) | |
4367 (if (and | |
4368 (not (looking-at verilog-complete-reg)) | |
4369 (verilog-continued-line-1 lim)) | |
4370 (progn (goto-char sp) | |
4371 (throw 'nesting 'cexp)) | |
4372 | |
4373 (goto-char sp)) | |
4374 | |
4375 (if (and begin | |
4376 (not verilog-indent-begin-after-if) | |
4377 (looking-at verilog-no-indent-begin-re)) | |
4378 (progn | |
4379 (beginning-of-line) | |
4380 (skip-chars-forward " \t") | |
4381 (throw 'nesting 'statement)) | |
4382 (progn | |
4383 (throw 'nesting 'cexp)))) | |
4384 ;; not a continued line | |
4385 (goto-char starting_position)) | |
4386 | |
4387 (if (looking-at "\\<else\\>") | |
4388 ;; search back for governing if, striding across begin..end pairs | |
4389 ;; appropriately | |
4390 (let ((elsec 1)) | |
4391 (while (verilog-re-search-backward verilog-ends-re nil 'move) | |
4392 (cond | |
4393 ((match-end 1) ; else, we're in deep | |
4394 (setq elsec (1+ elsec))) | |
4395 ((match-end 2) ; if | |
4396 (setq elsec (1- elsec)) | |
4397 (if (= 0 elsec) | |
4398 (if verilog-align-ifelse | |
4399 (throw 'nesting 'statement) | |
4400 (progn ;; back up to first word on this line | |
4401 (beginning-of-line) | |
4402 (verilog-forward-syntactic-ws) | |
4403 (throw 'nesting 'statement))))) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4404 ((match-end 3) ; assert block |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4405 (setq elsec (1- elsec)) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4406 (verilog-beg-of-statement) ;; doesn't get to beginning |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4407 (if (looking-at (concat "\\(" verilog-label-re "\\)?" |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4408 "\\(assert\\|assume\\|cover\\)\\s-+property\\>")) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4409 (throw 'nesting 'statement) ; We don't need an endproperty for these |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4410 (throw 'nesting 'block) ;We still need a endproperty |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4411 )) |
79545 | 4412 (t ; endblock |
4413 ; try to leap back to matching outward block by striding across | |
4414 ; indent level changing tokens then immediately | |
4415 ; previous line governs indentation. | |
4416 (let (( reg) (nest 1)) | |
4417 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup | |
4418 (cond | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4419 ((match-end 4) ; end |
79545 | 4420 ;; Search back for matching begin |
4421 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4422 ((match-end 5) ; endcase |
79545 | 4423 ;; Search back for matching case |
4424 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4425 ((match-end 6) ; endfunction |
79545 | 4426 ;; Search back for matching function |
4427 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4428 ((match-end 7) ; endtask |
79545 | 4429 ;; Search back for matching task |
4430 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4431 ((match-end 8) ; endspecify |
79545 | 4432 ;; Search back for matching specify |
4433 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4434 ((match-end 9) ; endtable |
79545 | 4435 ;; Search back for matching table |
4436 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4437 ((match-end 10) ; endgenerate |
79545 | 4438 ;; Search back for matching generate |
4439 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4440 ((match-end 11) ; joins |
79545 | 4441 ;; Search back for matching fork |
4442 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4443 ((match-end 12) ; class |
79545 | 4444 ;; Search back for matching class |
4445 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4446 ((match-end 13) ; covergroup |
79545 | 4447 ;; Search back for matching covergroup |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4448 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))) |
79545 | 4449 (catch 'skip |
4450 (while (verilog-re-search-backward reg nil 'move) | |
4451 (cond | |
4452 ((match-end 1) ; begin | |
4453 (setq nest (1- nest)) | |
4454 (if (= 0 nest) | |
4455 (throw 'skip 1))) | |
4456 ((match-end 2) ; end | |
4457 (setq nest (1+ nest))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4458 ))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4459 (throw 'nesting (verilog-calc-1))) |
79545 | 4460 );; catch nesting |
4461 );; type | |
4462 ) | |
4463 ;; Return type of block and indent level. | |
4464 (if (not type) | |
4465 (setq type 'cpp)) | |
4466 (if (> par 0) ; Unclosed Parenthesis | |
4467 (list 'cparenexp par) | |
4468 (cond | |
4469 ((eq type 'case) | |
4470 (list type (verilog-case-indent-level))) | |
4471 ((eq type 'statement) | |
4472 (list type (current-column))) | |
4473 ((eq type 'defun) | |
4474 (list type 0)) | |
4475 (t | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4476 (list type (verilog-current-indent-level)))))))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4477 |
79545 | 4478 (defun verilog-wai () |
4479 "Show matching nesting block for debugging." | |
4480 (interactive) | |
4481 (save-excursion | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4482 (let* ((type (verilog-calc-1)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4483 depth) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4484 ;; Return type of block and indent level. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4485 (if (not type) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4486 (setq type 'cpp)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4487 (if (and |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4488 verilog-indent-lists |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4489 (not(or (verilog-in-coverage-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4490 (verilog-in-struct-p))) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4491 (verilog-in-paren)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4492 (setq depth 1) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4493 (cond |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4494 ((eq type 'case) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4495 (setq depth (verilog-case-indent-level))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4496 ((eq type 'statement) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4497 (setq depth (current-column))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4498 ((eq type 'defun) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4499 (setq depth 0)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4500 (t |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4501 (setq depth (verilog-current-indent-level))))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4502 (message "You are at nesting %s depth %d" type depth)))) |
79545 | 4503 |
4504 (defun verilog-calc-1 () | |
4505 (catch 'nesting | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4506 (let ((re (concat "\\({\\|}\\|" verilog-indent-re "\\)"))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4507 (while (verilog-re-search-backward re nil 'move) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4508 (catch 'continue |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4509 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4510 ((equal (char-after) ?\{) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4511 (if (verilog-at-constraint-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4512 (throw 'nesting 'block))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4513 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4514 ((equal (char-after) ?\}) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4515 (let ((there (verilog-at-close-constraint-p))) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4516 (if there ;; we are at the } that closes a constraint. Find the { that opens it |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4517 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4518 (forward-char 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4519 (backward-list 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4520 (verilog-beg-of-statement))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4521 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4522 ((looking-at verilog-beg-block-re-ordered) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4523 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4524 ((match-end 2) ; *sigh* could be "unique case" or "priority casex" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4525 (let ((here (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4526 (verilog-beg-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4527 (if (looking-at verilog-extended-case-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4528 (throw 'nesting 'case) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4529 (goto-char here))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4530 (throw 'nesting 'case)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4531 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4532 ((match-end 4) ; *sigh* could be "disable fork" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4533 (let ((here (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4534 (verilog-beg-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4535 (if (looking-at verilog-disable-fork-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4536 t ; is disable fork, this is a normal statement |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4537 (progn ; or is fork, starts a new block |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4538 (goto-char here) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4539 (throw 'nesting 'block))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4540 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4541 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4542 ;; need to consider typedef struct here... |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4543 ((looking-at "\\<class\\|struct\\|function\\|task\\>") |
79545 | 4544 ; *sigh* These words have an optional prefix: |
4545 ; extern {virtual|protected}? function a(); | |
4546 ; typedef class foo; | |
4547 ; and we don't want to confuse this with | |
4548 ; function a(); | |
4549 ; property | |
4550 ; ... | |
4551 ; endfunction | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4552 (verilog-beg-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4553 (if (looking-at verilog-beg-block-re-ordered) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4554 (throw 'nesting 'block) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4555 (throw 'nesting 'defun))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4556 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4557 ((looking-at "\\<property\\>") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4558 ; *sigh* |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
4559 ; {assert|assume|cover} property (); are complete |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4560 ; and could also be labeled: - foo: assert property |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
4561 ; but |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
4562 ; property ID () ... needs end_property |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4563 (verilog-beg-of-statement) |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4564 (if (looking-at (concat "\\(" verilog-label-re "\\)?" |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4565 "\\(assert\\|assume\\|cover\\)\\s-+property\\>")) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4566 (throw 'continue 'statement) ; We don't need an endproperty for these |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4567 (throw 'nesting 'block) ;We still need a endproperty |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4568 )) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4569 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4570 (t (throw 'nesting 'block)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4571 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4572 ((looking-at verilog-end-block-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4573 (verilog-leap-to-head) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4574 (if (verilog-in-case-region-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4575 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4576 (verilog-leap-to-case-head) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4577 (if (looking-at verilog-extended-case-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4578 (throw 'nesting 'case))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4579 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4580 ((looking-at verilog-defun-level-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4581 (if (looking-at verilog-defun-level-generate-only-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4582 (if (verilog-in-generate-region-p) |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4583 (throw 'continue 'foo) ; always block in a generate - keep looking |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4584 (throw 'nesting 'defun)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4585 (throw 'nesting 'defun))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4586 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4587 ((looking-at verilog-cpp-level-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4588 (throw 'nesting 'cpp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4589 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4590 ((bobp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4591 (throw 'nesting 'cpp))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4592 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4593 (throw 'nesting 'cpp)))) |
79545 | 4594 |
4595 (defun verilog-calculate-indent-directive () | |
4596 "Return indentation level for directive. | |
4597 For speed, the searcher looks at the last directive, not the indent | |
4598 of the appropriate enclosing block." | |
4599 (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
|
4600 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else) |
79545 | 4601 ;; Start at current location, scan back for another directive |
4602 | |
4603 (save-excursion | |
4604 (beginning-of-line) | |
4605 (while (and (< base 0) | |
4606 (verilog-re-search-backward verilog-directive-re nil t)) | |
4607 (cond ((save-excursion (skip-chars-backward " \t") (bolp)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4608 (setq base (current-indentation)))) |
79545 | 4609 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL |
4610 (setq ind (- ind verilog-indent-level-directive))) | |
4611 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL | |
4612 (setq ind (+ ind verilog-indent-level-directive))) | |
4613 ((looking-at verilog-directive-begin) | |
4614 (setq ind (+ ind verilog-indent-level-directive))))) | |
4615 ;; Adjust indent to starting indent of critical line | |
4616 (setq ind (max 0 (+ ind base)))) | |
4617 | |
4618 (save-excursion | |
4619 (beginning-of-line) | |
4620 (skip-chars-forward " \t") | |
4621 (cond ((or (looking-at verilog-directive-middle) | |
4622 (looking-at verilog-directive-end)) | |
4623 (setq ind (max 0 (- ind verilog-indent-level-directive)))))) | |
4624 ind)) | |
4625 | |
4626 (defun verilog-leap-to-case-head () | |
4627 (let ((nest 1)) | |
4628 (while (/= 0 nest) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4629 (verilog-re-search-backward |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4630 (concat |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4631 "\\(\\<randcase\\>\\|\\(\\<unique\\s-+\\|priority\\s-+\\)?\\<case[xz]?\\>\\)" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4632 "\\|\\(\\<endcase\\>\\)" ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4633 nil 'move) |
79545 | 4634 (cond |
4635 ((match-end 1) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4636 (let ((here (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4637 (verilog-beg-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4638 (unless (looking-at verilog-extended-case-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4639 (goto-char here))) |
79545 | 4640 (setq nest (1- nest))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4641 ((match-end 3) |
79545 | 4642 (setq nest (1+ nest))) |
4643 ((bobp) | |
4644 (ding 't) | |
4645 (setq nest 0)))))) | |
4646 | |
4647 (defun verilog-leap-to-head () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4648 "Move point to the head of this block. |
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
4649 Jump from end to matching begin, from endcase to matching case, and so on." |
79545 | 4650 (let ((reg nil) |
4651 snest | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4652 (nesting 'yes) |
79545 | 4653 (nest 1)) |
4654 (cond | |
4655 ((looking-at "\\<end\\>") | |
4656 ;; 1: Search back for matching begin | |
4657 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|" | |
4658 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))) | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4659 ((looking-at "\\<endtask\\>") |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4660 ;; 2: Search back for matching task |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4661 (setq reg "\\(\\<task\\>\\)\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)+\\<task\\>\\)") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4662 (setq nesting 'no)) |
79545 | 4663 ((looking-at "\\<endcase\\>") |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4664 (catch 'nesting |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4665 (verilog-leap-to-case-head) ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4666 (setq reg nil) ; to force skip |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4667 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4668 |
79545 | 4669 ((looking-at "\\<join\\(_any\\|_none\\)?\\>") |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4670 ;; 4: Search back for matching fork |
79545 | 4671 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) |
4672 ((looking-at "\\<endclass\\>") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4673 ;; 5: Search back for matching class |
79545 | 4674 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) |
4675 ((looking-at "\\<endtable\\>") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4676 ;; 6: Search back for matching table |
79545 | 4677 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" )) |
4678 ((looking-at "\\<endspecify\\>") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4679 ;; 7: Search back for matching specify |
79545 | 4680 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" )) |
4681 ((looking-at "\\<endfunction\\>") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4682 ;; 8: Search back for matching function |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4683 (setq reg "\\(\\<function\\>\\)\\|\\(\\(\\(\\<virtual\\>\\s-+\\)\\|\\(\\<protected\\>\\s-+\\)\\)+\\<function\\>\\)") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4684 (setq nesting 'no)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4685 ;;(setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" )) |
79545 | 4686 ((looking-at "\\<endgenerate\\>") |
4687 ;; 8: Search back for matching generate | |
4688 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" )) | |
4689 ((looking-at "\\<endgroup\\>") | |
4690 ;; 10: Search back for matching covergroup | |
4691 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )) | |
4692 ((looking-at "\\<endproperty\\>") | |
4693 ;; 11: Search back for matching property | |
4694 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" )) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4695 ((looking-at verilog-ovm-end-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4696 ;; 12: Search back for matching sequence |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4697 (setq reg (concat "\\(" verilog-ovm-begin-re "\\|" verilog-ovm-end-re "\\)"))) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4698 ((looking-at verilog-vmm-end-re) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4699 ;; 12: Search back for matching sequence |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4700 (setq reg (concat "\\(" verilog-vmm-begin-re "\\|" verilog-vmm-end-re "\\)"))) |
79545 | 4701 ((looking-at "\\<endinterface\\>") |
4702 ;; 12: Search back for matching interface | |
4703 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" )) | |
4704 ((looking-at "\\<endsequence\\>") | |
4705 ;; 12: Search back for matching sequence | |
4706 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )) | |
4707 ((looking-at "\\<endclocking\\>") | |
4708 ;; 12: Search back for matching clocking | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4709 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" ))) |
79545 | 4710 (if reg |
4711 (catch 'skip | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4712 (if (eq nesting 'yes) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4713 (let (sreg) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4714 (while (verilog-re-search-backward reg nil 'move) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4715 (cond |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4716 ((match-end 1) ; begin |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4717 (if (looking-at "fork") |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4718 (let ((here (point))) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4719 (verilog-beg-of-statement) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4720 (unless (looking-at verilog-disable-fork-re) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4721 (goto-char here) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4722 (setq nest (1- nest)))) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4723 (setq nest (1- nest))) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4724 (if (= 0 nest) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4725 ;; Now previous line describes syntax |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4726 (throw 'skip 1)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4727 (if (and snest |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4728 (= snest nest)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4729 (setq reg sreg))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4730 ((match-end 2) ; end |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4731 (setq nest (1+ nest))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4732 ((match-end 3) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4733 ;; endcase, jump to case |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4734 (setq snest nest) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4735 (setq nest (1+ nest)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4736 (setq sreg reg) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4737 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" )) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4738 ((match-end 4) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4739 ;; join, jump to fork |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4740 (setq snest nest) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4741 (setq nest (1+ nest)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4742 (setq sreg reg) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4743 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4744 ))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4745 ;no nesting |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4746 (if (and |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4747 (verilog-re-search-backward reg nil 'move) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4748 (match-end 1)) ; task -> could be virtual and/or protected |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4749 (progn |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4750 (verilog-beg-of-statement) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4751 (throw 'skip 1)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
4752 (throw 'skip 1))))))) |
79545 | 4753 |
4754 (defun verilog-continued-line () | |
4755 "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
|
4756 Set point to where line starts." |
79545 | 4757 (let ((continued 't)) |
4758 (if (eq 0 (forward-line -1)) | |
4759 (progn | |
4760 (end-of-line) | |
4761 (verilog-backward-ws&directives) | |
4762 (if (bobp) | |
4763 (setq continued nil) | |
4764 (while (and continued | |
4765 (save-excursion | |
4766 (skip-chars-backward " \t") | |
4767 (not (bolp)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4768 (setq continued (verilog-backward-token))))) |
79545 | 4769 (setq continued nil)) |
4770 continued)) | |
4771 | |
4772 (defun verilog-backward-token () | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
4773 "Step backward token, returing true if this is a continued line." |
79545 | 4774 (interactive) |
4775 (verilog-backward-syntactic-ws) | |
4776 (cond | |
4777 ((bolp) | |
4778 nil) | |
4779 (;-- Anything ending in a ; is complete | |
4780 (= (preceding-char) ?\;) | |
4781 nil) | |
4782 (; If a "}" is prefixed by a ";", then this is a complete statement | |
4783 ; i.e.: constraint foo { a = b; } | |
4784 (= (preceding-char) ?\}) | |
4785 (progn | |
4786 (backward-char) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4787 (not(verilog-at-close-constraint-p)))) |
79545 | 4788 (;-- constraint foo { a = b } |
4789 ; is a complete statement. *sigh* | |
4790 (= (preceding-char) ?\{) | |
4791 (progn | |
4792 (backward-char) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4793 (not (verilog-at-constraint-p)))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4794 (;" string " |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4795 (= (preceding-char) ?\") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4796 (backward-char) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4797 (verilog-skip-backward-comment-or-string) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4798 nil) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4799 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4800 (; [3:4] |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4801 (= (preceding-char) ?\]) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4802 (backward-char) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4803 (verilog-backward-open-bracket) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4804 t) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4805 |
79545 | 4806 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete |
4807 ; also could be simply '@(foo)' | |
4808 ; or foo u1 #(a=8) | |
4809 ; (b, ... which ISN'T complete | |
4810 ;;;; Do we need this??? | |
4811 (= (preceding-char) ?\)) | |
4812 (progn | |
4813 (backward-char) | |
4814 (backward-up-list 1) | |
4815 (verilog-backward-syntactic-ws) | |
4816 (let ((back (point))) | |
4817 (forward-word -1) | |
4818 (cond | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4819 ;;XX |
79545 | 4820 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>") |
4821 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]"))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4822 ((looking-at verilog-ovm-statement-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4823 nil) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4824 ((looking-at verilog-ovm-begin-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4825 t) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4826 ((looking-at verilog-ovm-end-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4827 t) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4828 ;; JBA find VMM macros |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4829 ((looking-at verilog-vmm-statement-re) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4830 nil ) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4831 ((looking-at verilog-vmm-begin-re) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4832 t) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4833 ((looking-at verilog-vmm-end-re) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4834 nil) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4835 ;; JBA trying to catch macro lines with no ; at end |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4836 ((looking-at "\\<`") |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
4837 nil) |
79545 | 4838 (t |
4839 (goto-char back) | |
4840 (cond | |
4841 ((= (preceding-char) ?\@) | |
4842 (backward-char) | |
4843 (save-excursion | |
4844 (verilog-backward-token) | |
4845 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>")))) | |
4846 ((= (preceding-char) ?\#) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4847 (backward-char)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4848 (t t))))))) |
79545 | 4849 |
4850 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete | |
4851 t | |
4852 (forward-word -1) | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4853 (while (= (preceding-char) ?\_) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
4854 (forward-word -1)) |
79545 | 4855 (cond |
4856 ((looking-at "\\<else\\>") | |
4857 t) | |
80171
97019d686b43
* progmodes/verilog-mode.el (verilog-xemacs-menu): Remove XEmacs
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80165
diff
changeset
|
4858 ((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
|
4859 t) |
79545 | 4860 ((looking-at verilog-indent-re) |
4861 nil) | |
4862 (t | |
4863 (let | |
4864 ((back (point))) | |
4865 (verilog-backward-syntactic-ws) | |
4866 (cond | |
4867 ((= (preceding-char) ?\:) | |
4868 (backward-char) | |
4869 (verilog-backward-syntactic-ws) | |
4870 (backward-sexp) | |
4871 (if (looking-at verilog-nameable-item-re ) | |
4872 nil | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4873 t)) |
79545 | 4874 ((= (preceding-char) ?\#) |
4875 (backward-char) | |
4876 t) | |
4877 ((= (preceding-char) ?\`) | |
4878 (backward-char) | |
4879 t) | |
4880 | |
4881 (t | |
4882 (goto-char back) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4883 t)))))))) |
79545 | 4884 |
4885 (defun verilog-backward-syntactic-ws (&optional bound) | |
4886 "Backward skip over syntactic whitespace for Emacs 19. | |
4887 Optional BOUND limits search." | |
4888 (save-restriction | |
4889 (let* ((bound (or bound (point-min))) (here bound) ) | |
4890 (if (< bound (point)) | |
4891 (progn | |
4892 (narrow-to-region bound (point)) | |
4893 (while (/= here (point)) | |
4894 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4895 (verilog-skip-backward-comments)))))) |
79545 | 4896 t) |
4897 | |
4898 (defun verilog-forward-syntactic-ws (&optional bound) | |
4899 "Forward skip over syntactic whitespace for Emacs 19. | |
4900 Optional BOUND limits search." | |
4901 (save-restriction | |
4902 (let* ((bound (or bound (point-max))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4903 (here bound)) |
79545 | 4904 (if (> bound (point)) |
4905 (progn | |
4906 (narrow-to-region (point) bound) | |
4907 (while (/= here (point)) | |
4908 (setq here (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4909 (forward-comment (buffer-size)))))))) |
79545 | 4910 |
4911 (defun verilog-backward-ws&directives (&optional bound) | |
4912 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4913 Optional BOUND limits search." | |
4914 (save-restriction | |
4915 (let* ((bound (or bound (point-min))) | |
4916 (here bound) | |
4917 (p nil) ) | |
4918 (if (< bound (point)) | |
4919 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4920 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4921 (cond |
4922 ((nth 7 state) ;; in // comment | |
4923 (verilog-re-search-backward "//" nil 'move) | |
4924 (skip-chars-backward "/")) | |
4925 ((nth 4 state) ;; in /* */ comment | |
4926 (verilog-re-search-backward "/\*" nil 'move)))) | |
4927 (narrow-to-region bound (point)) | |
4928 (while (/= here (point)) | |
4929 (setq here (point)) | |
4930 (verilog-skip-backward-comments) | |
4931 (setq p | |
4932 (save-excursion | |
4933 (beginning-of-line) | |
4934 (cond | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4935 ((and verilog-highlight-translate-off |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
4936 (verilog-within-translate-off)) |
79545 | 4937 (verilog-back-to-start-translate-off (point-min))) |
4938 ((looking-at verilog-directive-re-1) | |
4939 (point)) | |
4940 (t | |
4941 nil)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4942 (if p (goto-char p)))))))) |
79545 | 4943 |
4944 (defun verilog-forward-ws&directives (&optional bound) | |
4945 "Forward skip over syntactic whitespace and compiler directives for Emacs 19. | |
4946 Optional BOUND limits search." | |
4947 (save-restriction | |
4948 (let* ((bound (or bound (point-max))) | |
4949 (here bound) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4950 jump) |
79545 | 4951 (if (> bound (point)) |
4952 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4953 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4954 (cond |
4955 ((nth 7 state) ;; in // comment | |
4956 (verilog-re-search-forward "//" nil 'move)) | |
4957 ((nth 4 state) ;; in /* */ comment | |
4958 (verilog-re-search-forward "/\*" nil 'move)))) | |
4959 (narrow-to-region (point) bound) | |
4960 (while (/= here (point)) | |
4961 (setq here (point) | |
4962 jump nil) | |
4963 (forward-comment (buffer-size)) | |
4964 (save-excursion | |
4965 (beginning-of-line) | |
4966 (if (looking-at verilog-directive-re-1) | |
4967 (setq jump t))) | |
4968 (if jump | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
4969 (beginning-of-line 2)))))))) |
79545 | 4970 |
4971 (defun verilog-in-comment-p () | |
4972 "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
|
4973 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4974 (or (nth 4 state) (nth 7 state)))) |
4975 | |
4976 (defun verilog-in-star-comment-p () | |
4977 "Return true if in a star comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4978 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4979 (and |
4980 (nth 4 state) ; t if in a comment of style a // or b /**/ | |
4981 (not | |
4982 (nth 7 state) ; t if in a comment of style b /**/ | |
4983 )))) | |
4984 | |
4985 (defun verilog-in-slash-comment-p () | |
4986 "Return true if in a slash comment." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
4987 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4988 (nth 7 state))) |
4989 | |
4990 (defun verilog-in-comment-or-string-p () | |
4991 "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
|
4992 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 4993 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment) |
4994 | |
4995 (defun verilog-in-escaped-name-p () | |
4996 "Return true if in an escaped name." | |
4997 (save-excursion | |
4998 (backward-char) | |
4999 (skip-chars-backward "^ \t\n\f") | |
5000 (if (equal (char-after (point) ) ?\\ ) | |
5001 t | |
5002 nil))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5003 (defun verilog-in-directive-p () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5004 "Return true if in a star or // comment." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5005 (save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5006 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5007 (looking-at verilog-directive-re-1))) |
79545 | 5008 |
5009 (defun verilog-in-paren () | |
5010 "Return true if in a parenthetical expression." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
5011 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 5012 (> (nth 0 state) 0 ))) |
5013 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5014 (defun verilog-in-struct-p () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5015 "Return true if in a struct declaration." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5016 (interactive) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5017 (save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5018 (if (verilog-in-paren) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5019 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5020 (backward-up-list 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5021 (verilog-at-struct-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5022 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5023 nil))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5024 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5025 (defun verilog-in-coverage-p () |
79545 | 5026 "Return true if in a constraint or coverpoint expression." |
5027 (interactive) | |
5028 (save-excursion | |
5029 (if (verilog-in-paren) | |
5030 (progn | |
5031 (backward-up-list 1) | |
5032 (verilog-at-constraint-p) | |
5033 ) | |
5034 nil))) | |
5035 (defun verilog-at-close-constraint-p () | |
5036 "If at the } that closes a constraint or covergroup, return true." | |
5037 (if (and | |
5038 (equal (char-after) ?\}) | |
5039 (verilog-in-paren)) | |
5040 | |
5041 (save-excursion | |
5042 (verilog-backward-ws&directives) | |
5043 (if (equal (char-before) ?\;) | |
5044 (point) | |
5045 nil)))) | |
5046 | |
5047 (defun verilog-at-constraint-p () | |
5048 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint." | |
5049 (if (save-excursion | |
5050 (and | |
5051 (equal (char-after) ?\{) | |
5052 (forward-list) | |
5053 (progn (backward-char 1) | |
5054 (verilog-backward-ws&directives) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5055 (equal (char-before) ?\;)))) |
79545 | 5056 ;; maybe |
5057 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move) | |
5058 ;; not | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5059 nil)) |
79545 | 5060 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5061 (defun verilog-at-struct-p () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5062 "If at the { of a struct, return true, moving point to struct." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5063 (save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5064 (if (and (equal (char-after) ?\{) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5065 (verilog-backward-token)) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5066 (looking-at "\\<struct\\|union\\|packed\\|\\(un\\)?signed\\>") |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5067 nil))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5068 |
79545 | 5069 (defun verilog-parenthesis-depth () |
5070 "Return non zero if in parenthetical-expression." | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
5071 (save-excursion (nth 1 (verilog-syntax-ppss)))) |
79545 | 5072 |
5073 | |
5074 (defun verilog-skip-forward-comment-or-string () | |
5075 "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
|
5076 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 5077 (cond |
5078 ((nth 3 state) ;Inside string | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
5079 (search-forward "\"") |
79545 | 5080 t) |
5081 ((nth 7 state) ;Inside // comment | |
5082 (forward-line 1) | |
5083 t) | |
5084 ((nth 4 state) ;Inside any comment (hence /**/) | |
5085 (search-forward "*/")) | |
5086 (t | |
5087 nil)))) | |
5088 | |
5089 (defun verilog-skip-backward-comment-or-string () | |
5090 "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
|
5091 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 5092 (cond |
5093 ((nth 3 state) ;Inside string | |
5094 (search-backward "\"") | |
5095 t) | |
5096 ((nth 7 state) ;Inside // comment | |
5097 (search-backward "//") | |
5098 (skip-chars-backward "/") | |
5099 t) | |
5100 ((nth 4 state) ;Inside /* */ comment | |
5101 (search-backward "/*") | |
5102 t) | |
5103 (t | |
5104 nil)))) | |
5105 | |
5106 (defun verilog-skip-backward-comments () | |
5107 "Return true if a comment was skipped." | |
5108 (let ((more t)) | |
5109 (while more | |
5110 (setq more | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
5111 (let ((state (save-excursion (verilog-syntax-ppss)))) |
79545 | 5112 (cond |
5113 ((nth 7 state) ;Inside // comment | |
5114 (search-backward "//") | |
5115 (skip-chars-backward "/") | |
5116 (skip-chars-backward " \t\n\f") | |
5117 t) | |
5118 ((nth 4 state) ;Inside /* */ comment | |
5119 (search-backward "/*") | |
5120 (skip-chars-backward " \t\n\f") | |
5121 t) | |
5122 ((and (not (bobp)) | |
5123 (= (char-before) ?\/) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5124 (= (char-before (1- (point))) ?\*)) |
79545 | 5125 (goto-char (- (point) 2)) |
5126 t) | |
5127 (t | |
5128 (skip-chars-backward " \t\n\f") | |
5129 nil))))))) | |
5130 | |
5131 (defun verilog-skip-forward-comment-p () | |
5132 "If in comment, move to end and return true." | |
5133 (let (state) | |
5134 (progn | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
5135 (setq state (save-excursion (verilog-syntax-ppss))) |
79545 | 5136 (cond |
5137 ((nth 3 state) | |
5138 t) | |
5139 ((nth 7 state) ;Inside // comment | |
5140 (end-of-line) | |
5141 (forward-char 1) | |
5142 t) | |
5143 ((nth 4 state) ;Inside any comment | |
5144 t) | |
5145 (t | |
5146 nil))))) | |
5147 | |
5148 (defun verilog-indent-line-relative () | |
5149 "Cheap version of indent line. | |
5150 Only look at a few lines to determine indent level." | |
5151 (interactive) | |
5152 (let ((indent-str) | |
5153 (sp (point))) | |
5154 (if (looking-at "^[ \t]*$") | |
5155 (cond ;- A blank line; No need to be too smart. | |
5156 ((bobp) | |
5157 (setq indent-str (list 'cpp 0))) | |
5158 ((verilog-continued-line) | |
5159 (let ((sp1 (point))) | |
5160 (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
|
5161 (progn |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5162 (goto-char sp) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5163 (setq indent-str |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5164 (list 'statement (verilog-current-indent-level)))) |
79545 | 5165 (goto-char sp1) |
5166 (setq indent-str (list 'block (verilog-current-indent-level))))) | |
5167 (goto-char sp)) | |
5168 ((goto-char sp) | |
5169 (setq indent-str (verilog-calculate-indent)))) | |
5170 (progn (skip-chars-forward " \t") | |
5171 (setq indent-str (verilog-calculate-indent)))) | |
5172 (verilog-do-indent indent-str))) | |
5173 | |
5174 (defun verilog-indent-line () | |
5175 "Indent for special part of code." | |
5176 (verilog-do-indent (verilog-calculate-indent))) | |
5177 | |
5178 (defun verilog-do-indent (indent-str) | |
5179 (let ((type (car indent-str)) | |
5180 (ind (car (cdr indent-str)))) | |
5181 (cond | |
5182 (; handle continued exp | |
5183 (eq type 'cexp) | |
5184 (let ((here (point))) | |
5185 (verilog-backward-syntactic-ws) | |
5186 (cond | |
5187 ((or | |
5188 (= (preceding-char) ?\,) | |
5189 (= (preceding-char) ?\]) | |
5190 (save-excursion | |
5191 (verilog-beg-of-statement-1) | |
5192 (looking-at verilog-declaration-re))) | |
5193 (let* ( fst | |
5194 (val | |
5195 (save-excursion | |
5196 (backward-char 1) | |
5197 (verilog-beg-of-statement-1) | |
5198 (setq fst (point)) | |
5199 (if (looking-at verilog-declaration-re) | |
5200 (progn ;; we have multiple words | |
5201 (goto-char (match-end 0)) | |
5202 (skip-chars-forward " \t") | |
5203 (cond | |
5204 ((and verilog-indent-declaration-macros | |
5205 (= (following-char) ?\`)) | |
5206 (progn | |
5207 (forward-char 1) | |
5208 (forward-word 1) | |
5209 (skip-chars-forward " \t"))) | |
5210 ((= (following-char) ?\[) | |
5211 (progn | |
5212 (forward-char 1) | |
5213 (backward-up-list -1) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5214 (skip-chars-forward " \t")))) |
79545 | 5215 (current-column)) |
5216 (progn | |
5217 (goto-char fst) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5218 (+ (current-column) verilog-cexp-indent)))))) |
79545 | 5219 (goto-char here) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5220 (indent-line-to val))) |
79545 | 5221 ((= (preceding-char) ?\) ) |
5222 (goto-char here) | |
5223 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
5224 (indent-line-to val))) | |
5225 (t | |
5226 (goto-char here) | |
5227 (let ((val)) | |
5228 (verilog-beg-of-statement-1) | |
5229 (if (and (< (point) here) | |
5230 (verilog-re-search-forward "=[ \\t]*" here 'move)) | |
5231 (setq val (current-column)) | |
5232 (setq val (eval (cdr (assoc type verilog-indent-alist))))) | |
5233 (goto-char here) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5234 (indent-line-to val)))))) |
79545 | 5235 |
5236 (; handle inside parenthetical expressions | |
5237 (eq type 'cparenexp) | |
5238 (let ((val (save-excursion | |
5239 (backward-up-list 1) | |
5240 (forward-char 1) | |
5241 (skip-chars-forward " \t") | |
5242 (current-column)))) | |
5243 (indent-line-to val) | |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
5244 )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5245 |
79545 | 5246 (;-- Handle the ends |
5247 (or | |
5248 (looking-at verilog-end-block-re ) | |
5249 (verilog-at-close-constraint-p)) | |
5250 (let ((val (if (eq type 'statement) | |
5251 (- ind verilog-indent-level) | |
5252 ind))) | |
5253 (indent-line-to val))) | |
5254 | |
5255 (;-- Case -- maybe line 'em up | |
5256 (and (eq type 'case) (not (looking-at "^[ \t]*$"))) | |
5257 (progn | |
5258 (cond | |
5259 ((looking-at "\\<endcase\\>") | |
5260 (indent-line-to ind)) | |
5261 (t | |
5262 (let ((val (eval (cdr (assoc type verilog-indent-alist))))) | |
5263 (indent-line-to val)))))) | |
5264 | |
5265 (;-- defun | |
5266 (and (eq type 'defun) | |
5267 (looking-at verilog-zero-indent-re)) | |
5268 (indent-line-to 0)) | |
5269 | |
5270 (;-- declaration | |
5271 (and (or | |
5272 (eq type 'defun) | |
5273 (eq type 'block)) | |
5274 (looking-at verilog-declaration-re)) | |
5275 (verilog-indent-declaration ind)) | |
5276 | |
5277 (;-- Everything else | |
5278 t | |
5279 (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
|
5280 (indent-line-to val)))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5281 |
79545 | 5282 (if (looking-at "[ \t]+$") |
5283 (skip-chars-forward " \t")) | |
5284 indent-str ; Return indent data | |
5285 )) | |
5286 | |
5287 (defun verilog-current-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5288 "Return the indent-level of the current statement." |
79545 | 5289 (save-excursion |
5290 (let (par-pos) | |
5291 (beginning-of-line) | |
5292 (setq par-pos (verilog-parenthesis-depth)) | |
5293 (while par-pos | |
5294 (goto-char par-pos) | |
5295 (beginning-of-line) | |
5296 (setq par-pos (verilog-parenthesis-depth))) | |
5297 (skip-chars-forward " \t") | |
5298 (current-column)))) | |
5299 | |
5300 (defun verilog-case-indent-level () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5301 "Return the indent-level of the current statement. |
79545 | 5302 Do not count named blocks or case-statements." |
5303 (save-excursion | |
5304 (skip-chars-forward " \t") | |
5305 (cond | |
5306 ((looking-at verilog-named-block-re) | |
5307 (current-column)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5308 ((and (not (looking-at verilog-extended-case-re)) |
79545 | 5309 (looking-at "^[^:;]+[ \t]*:")) |
5310 (verilog-re-search-forward ":" nil t) | |
5311 (skip-chars-forward " \t") | |
5312 (current-column)) | |
5313 (t | |
5314 (current-column))))) | |
5315 | |
5316 (defun verilog-indent-comment () | |
5317 "Indent current line as comment." | |
5318 (let* ((stcol | |
5319 (cond | |
5320 ((verilog-in-star-comment-p) | |
5321 (save-excursion | |
5322 (re-search-backward "/\\*" nil t) | |
5323 (1+(current-column)))) | |
5324 (comment-column | |
5325 comment-column ) | |
5326 (t | |
5327 (save-excursion | |
5328 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5329 (current-column)))))) |
79545 | 5330 (indent-line-to stcol) |
5331 stcol)) | |
5332 | |
5333 (defun verilog-more-comment () | |
5334 "Make more comment lines like the previous." | |
5335 (let* ((star 0) | |
5336 (stcol | |
5337 (cond | |
5338 ((verilog-in-star-comment-p) | |
5339 (save-excursion | |
5340 (setq star 1) | |
5341 (re-search-backward "/\\*" nil t) | |
5342 (1+(current-column)))) | |
5343 (comment-column | |
5344 comment-column ) | |
5345 (t | |
5346 (save-excursion | |
5347 (re-search-backward "//" nil t) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5348 (current-column)))))) |
79545 | 5349 (progn |
5350 (indent-to stcol) | |
5351 (if (and star | |
5352 (save-excursion | |
5353 (forward-line -1) | |
5354 (skip-chars-forward " \t") | |
5355 (looking-at "\*"))) | |
5356 (insert "* "))))) | |
5357 | |
5358 (defun verilog-comment-indent (&optional arg) | |
5359 "Return the column number the line should be indented to. | |
5360 ARG is ignored, for `comment-indent-function' compatibility." | |
5361 (cond | |
5362 ((verilog-in-star-comment-p) | |
5363 (save-excursion | |
5364 (re-search-backward "/\\*" nil t) | |
5365 (1+(current-column)))) | |
5366 ( comment-column | |
5367 comment-column ) | |
5368 (t | |
5369 (save-excursion | |
5370 (re-search-backward "//" nil t) | |
5371 (current-column))))) | |
5372 | |
5373 ;; | |
5374 | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5375 (defun verilog-pretty-declarations (&optional quiet) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5376 "Line up declarations around point. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5377 Be verbose about progress unless optional QUIET set." |
79545 | 5378 (interactive) |
5379 (save-excursion | |
5380 (if (progn | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5381 (verilog-beg-of-statement-1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5382 (and (not (verilog-in-directive-p)) ;; could have `define input foo |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5383 (not (verilog-parenthesis-depth)) ;; could be in a #(param block ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5384 (looking-at verilog-declaration-re))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5385 (let* ((m1 (make-marker)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5386 (e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5387 (r) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5388 (here (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5389 ;; Start of declaration range |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5390 (start |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5391 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5392 (verilog-beg-of-statement-1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5393 (while (and (looking-at verilog-declaration-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5394 (not (bobp))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5395 (skip-chars-backward " \t") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5396 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5397 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5398 (verilog-backward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5399 (backward-char) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5400 (verilog-beg-of-statement-1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5401 e)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5402 ;; End of declaration range |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5403 (end |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5404 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5405 (goto-char here) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5406 (verilog-end-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5407 (setq e (point)) ;Might be on last line |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5408 (verilog-forward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5409 (while (looking-at verilog-declaration-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5410 ;;(beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5411 (verilog-end-of-statement) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5412 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5413 (verilog-forward-syntactic-ws)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5414 e)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5415 (edpos (set-marker (make-marker) end)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5416 (ind) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5417 (base-ind |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5418 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5419 (goto-char start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5420 (verilog-do-indent (verilog-calculate-indent)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5421 (verilog-forward-ws&directives) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5422 (current-column)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5423 (goto-char start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5424 (if (and (not quiet) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5425 (> (- end start) 100)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5426 (message "Lining up declarations..(please stand by)")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5427 ;; Get the beginning of line indent first |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5428 (while (progn (setq e (marker-position edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5429 (< (point) e)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5430 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5431 ( (save-excursion (skip-chars-backward " \t") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5432 (bolp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5433 (verilog-forward-ws&directives) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5434 (indent-line-to base-ind) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5435 (verilog-forward-ws&directives) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5436 (verilog-re-search-forward "[ \t\n\f]" e 'move)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5437 (t |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5438 (just-one-space) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5439 (verilog-re-search-forward "[ \t\n\f]" e 'move))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5440 ;;(forward-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5441 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5442 ;; Now find biggest prefix |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5443 (setq ind (verilog-get-lineup-indent start edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5444 ;; Now indent each line. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5445 (goto-char start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5446 (while (progn (setq e (marker-position edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5447 (setq r (- e (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5448 (> r 0)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5449 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5450 (unless quiet (message "%d" r)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5451 (verilog-indent-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5452 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5453 ((or (and verilog-indent-declaration-macros |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5454 (looking-at verilog-declaration-re-2-macro)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5455 (looking-at verilog-declaration-re-2-no-macro)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5456 (let ((p (match-end 0))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5457 (set-marker m1 p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5458 (if (verilog-re-search-forward "[[#`]" p 'move) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5459 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5460 (forward-char -1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5461 (just-one-space) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5462 (goto-char (marker-position m1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5463 (just-one-space) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5464 (indent-to ind)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5465 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5466 (just-one-space) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5467 (indent-to ind))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5468 ((verilog-continued-line-1 start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5469 (goto-char e) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5470 (indent-line-to ind)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5471 ((verilog-in-struct-p) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5472 ;; could have a declaration of a user defined item |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5473 (goto-char e) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5474 (verilog-end-of-statement)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5475 (t ; Must be comment or white space |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5476 (goto-char e) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5477 (verilog-forward-ws&directives) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5478 (forward-line -1))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5479 (forward-line 1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5480 (unless quiet (message "")))))) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5481 |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5482 (defun verilog-pretty-expr (&optional quiet myre) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5483 "Line up expressions around point, optionally QUIET with regexp MYRE." |
79545 | 5484 (interactive "sRegular Expression: ((<|:)?=) ") |
5485 (save-excursion | |
5486 (if (or (eq myre nil) | |
5487 (string-equal myre "")) | |
5488 (setq myre "\\(<\\|:\\)?=")) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5489 (setq myre (concat "\\(^[^;#:<=>]*\\)\\(" myre "\\)")) |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5490 (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
|
5491 (beginning-of-line) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5492 (if (and (not (looking-at rexp )) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5493 (looking-at myre) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5494 (save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5495 (goto-char (match-beginning 2)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5496 (not (verilog-in-comment-or-string-p)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5497 (let* ((here (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5498 (e) (r) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5499 (start |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5500 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5501 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5502 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5503 (verilog-backward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5504 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5505 (while (and (not (looking-at rexp )) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5506 (looking-at myre) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5507 (not (bobp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5508 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5509 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5510 (verilog-backward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5511 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5512 ) ;Ack, need to grok `define |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5513 e)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5514 (end |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5515 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5516 (goto-char here) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5517 (end-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5518 (setq e (point)) ;Might be on last line |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5519 (verilog-forward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5520 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5521 (while (and |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5522 (not (looking-at rexp )) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5523 (looking-at myre) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5524 (progn |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5525 (end-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5526 (not (eq e (point))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5527 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5528 (verilog-forward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5529 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5530 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5531 e)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5532 (edpos (set-marker (make-marker) end)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5533 (ind) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5534 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5535 (goto-char start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5536 (verilog-do-indent (verilog-calculate-indent)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5537 (if (and (not quiet) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5538 (> (- end start) 100)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5539 (message "Lining up expressions..(please stand by)")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5540 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5541 ;; Set indent to minimum throughout region |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5542 (while (< (point) (marker-position edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5543 (beginning-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5544 (verilog-just-one-space myre) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5545 (end-of-line) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5546 (verilog-forward-syntactic-ws) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5547 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5548 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5549 ;; Now find biggest prefix |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5550 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5551 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5552 ;; Now indent each line. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5553 (goto-char start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5554 (while (progn (setq e (marker-position edpos)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5555 (setq r (- e (point))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5556 (> r 0)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5557 (setq e (point)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5558 (if (not quiet) (message "%d" r)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5559 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5560 ((looking-at myre) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5561 (goto-char (match-beginning 2)) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
5562 (if (not (verilog-parenthesis-depth)) ;; ignore parenthesized exprs |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5563 (if (eq (char-after) ?=) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5564 (indent-to (1+ ind)) ; line up the = of the <= with surrounding = |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5565 (indent-to ind) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5566 ))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5567 ((verilog-continued-line-1 start) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5568 (goto-char e) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5569 (indent-line-to ind)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5570 (t ; Must be comment or white space |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5571 (goto-char e) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5572 (verilog-forward-ws&directives) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5573 (forward-line -1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5574 ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5575 (forward-line 1)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5576 (unless quiet (message "")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5577 ))))) |
79545 | 5578 |
5579 (defun verilog-just-one-space (myre) | |
5580 "Remove extra spaces around regular expression MYRE." | |
5581 (interactive) | |
5582 (if (and (not(looking-at verilog-complete-reg)) | |
5583 (looking-at myre)) | |
5584 (let ((p1 (match-end 1)) | |
5585 (p2 (match-end 2))) | |
5586 (progn | |
5587 (goto-char p2) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5588 (if (looking-at "\\s-") (just-one-space)) |
79545 | 5589 (goto-char p1) |
5590 (forward-char -1) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5591 (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
|
5592 )))) |
79545 | 5593 |
5594 (defun verilog-indent-declaration (baseind) | |
5595 "Indent current lines as declaration. | |
5596 Line up the variable names based on previous declaration's indentation. | |
5597 BASEIND is the base indent to offset everything." | |
5598 (interactive) | |
5599 (let ((pos (point-marker)) | |
5600 (lim (save-excursion | |
5601 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move) | |
5602 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move) | |
5603 (point))) | |
5604 (ind) | |
5605 (val) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5606 (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
|
5607 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5608 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 5609 (indent-line-to val) |
5610 | |
5611 ;; Use previous declaration (in this module) as template. | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5612 (if (or (eq 'all verilog-auto-lineup) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
5613 (eq 'declarations verilog-auto-lineup)) |
79546 | 5614 (if (verilog-re-search-backward |
79545 | 5615 (or (and verilog-indent-declaration-macros |
5616 verilog-declaration-re-1-macro) | |
5617 verilog-declaration-re-1-no-macro) lim t) | |
5618 (progn | |
5619 (goto-char (match-end 0)) | |
5620 (skip-chars-forward " \t") | |
5621 (setq ind (current-column)) | |
5622 (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
|
5623 (setq val |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5624 (+ baseind |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5625 (eval (cdr (assoc 'declaration verilog-indent-alist))))) |
79545 | 5626 (indent-line-to val) |
5627 (if (and verilog-indent-declaration-macros | |
5628 (looking-at verilog-declaration-re-2-macro)) | |
5629 (let ((p (match-end 0))) | |
5630 (set-marker m1 p) | |
5631 (if (verilog-re-search-forward "[[#`]" p 'move) | |
5632 (progn | |
5633 (forward-char -1) | |
5634 (just-one-space) | |
5635 (goto-char (marker-position m1)) | |
5636 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5637 (indent-to ind)) |
79545 | 5638 (if (/= (current-column) ind) |
5639 (progn | |
5640 (just-one-space) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5641 (indent-to ind))))) |
79545 | 5642 (if (looking-at verilog-declaration-re-2-no-macro) |
5643 (let ((p (match-end 0))) | |
5644 (set-marker m1 p) | |
5645 (if (verilog-re-search-forward "[[`#]" p 'move) | |
5646 (progn | |
5647 (forward-char -1) | |
5648 (just-one-space) | |
5649 (goto-char (marker-position m1)) | |
5650 (just-one-space) | |
5651 (indent-to ind)) | |
5652 (if (/= (current-column) ind) | |
5653 (progn | |
5654 (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
|
5655 (indent-to ind)))))))))) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
5656 (goto-char pos))) |
79545 | 5657 |
5658 (defun verilog-get-lineup-indent (b edpos) | |
5659 "Return the indent level that will line up several lines within the region. | |
5660 Region is defined by B and EDPOS." | |
5661 (save-excursion | |
5662 (let ((ind 0) e) | |
5663 (goto-char b) | |
5664 ;; Get rightmost position | |
5665 (while (progn (setq e (marker-position edpos)) | |
5666 (< (point) e)) | |
79546 | 5667 (if (verilog-re-search-forward |
79545 | 5668 (or (and verilog-indent-declaration-macros |
5669 verilog-declaration-re-1-macro) | |
5670 verilog-declaration-re-1-no-macro) e 'move) | |
5671 (progn | |
5672 (goto-char (match-end 0)) | |
5673 (verilog-backward-syntactic-ws) | |
5674 (if (> (current-column) ind) | |
5675 (setq ind (current-column))) | |
5676 (goto-char (match-end 0))))) | |
5677 (if (> ind 0) | |
5678 (1+ ind) | |
5679 ;; No lineup-string found | |
5680 (goto-char b) | |
5681 (end-of-line) | |
5682 (skip-chars-backward " \t") | |
5683 (1+ (current-column)))))) | |
5684 | |
5685 (defun verilog-get-lineup-indent-2 (myre b edpos) | |
5686 "Return the indent level that will line up several lines within the region." | |
5687 (save-excursion | |
5688 (let ((ind 0) e) | |
5689 (goto-char b) | |
5690 ;; Get rightmost position | |
5691 (while (progn (setq e (marker-position edpos)) | |
5692 (< (point) e)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5693 (if (and (verilog-re-search-forward myre e 'move) |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
5694 (not (verilog-parenthesis-depth))) ;; skip parenthesized exprs |
79545 | 5695 (progn |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5696 (goto-char (match-beginning 2)) |
79545 | 5697 (verilog-backward-syntactic-ws) |
5698 (if (> (current-column) ind) | |
5699 (setq ind (current-column))) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5700 (goto-char (match-end 0))) |
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
5701 )) |
79545 | 5702 (if (> ind 0) |
5703 (1+ ind) | |
5704 ;; No lineup-string found | |
5705 (goto-char b) | |
5706 (end-of-line) | |
5707 (skip-chars-backward " \t") | |
5708 (1+ (current-column)))))) | |
5709 | |
5710 (defun verilog-comment-depth (type val) | |
5711 "A useful mode debugging aide. TYPE and VAL are comments for insertion." | |
5712 (save-excursion | |
5713 (let | |
5714 ((b (prog2 | |
5715 (beginning-of-line) | |
5716 (point-marker) | |
5717 (end-of-line))) | |
5718 (e (point-marker))) | |
5719 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t) | |
5720 (progn | |
5721 (replace-match " /* -# ## */") | |
5722 (end-of-line)) | |
5723 (progn | |
5724 (end-of-line) | |
5725 (insert " /* ## ## */")))) | |
5726 (backward-char 6) | |
5727 (insert | |
5728 (format "%s %d" type val)))) | |
5729 | |
5730 ;; | |
5731 ;; | |
5732 ;; Completion | |
5733 ;; | |
5734 (defvar verilog-str nil) | |
5735 (defvar verilog-all nil) | |
5736 (defvar verilog-pred nil) | |
5737 (defvar verilog-buffer-to-use nil) | |
5738 (defvar verilog-flag nil) | |
5739 (defvar verilog-toggle-completions nil | |
5740 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one. | |
5741 Repeated use of \\[verilog-complete-word] will show you all of them. | |
5742 Normally, when there is more than one possible completion, | |
5743 it displays a list of all possible completions.") | |
5744 | |
5745 | |
5746 (defvar verilog-type-keywords | |
5747 '( | |
5748 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input" | |
5749 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0" | |
5750 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup" | |
5751 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0" | |
5752 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1" | |
5753 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor" | |
5754 ) | |
5755 "*Keywords for types used when completing a word in a declaration or parmlist. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5756 \(integer, real, reg...)") |
79545 | 5757 |
5758 (defvar verilog-cpp-keywords | |
5759 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else" | |
5760 "endif") | |
5761 "*Keywords to complete when at first word of a line in declarative scope. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5762 \(initial, always, begin, assign...) |
79545 | 5763 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
|
5764 will be completed at runtime and should not be added to this list.") |
79545 | 5765 |
5766 (defvar verilog-defun-keywords | |
5767 (append | |
5768 '( | |
5769 "always" "always_comb" "always_ff" "always_latch" "assign" | |
5770 "begin" "end" "generate" "endgenerate" "module" "endmodule" | |
5771 "specify" "endspecify" "function" "endfunction" "initial" "final" | |
5772 "task" "endtask" "primitive" "endprimitive" | |
5773 ) | |
5774 verilog-type-keywords) | |
5775 "*Keywords to complete when at first word of a line in declarative scope. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5776 \(initial, always, begin, assign...) |
79545 | 5777 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
|
5778 will be completed at runtime and should not be added to this list.") |
79545 | 5779 |
5780 (defvar verilog-block-keywords | |
5781 '( | |
5782 "begin" "break" "case" "continue" "else" "end" "endfunction" | |
5783 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask" | |
5784 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return" | |
5785 "while") | |
5786 "*Keywords to complete when at first word of a line in behavioral scope. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5787 \(begin, if, then, else, for, fork...) |
79545 | 5788 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
|
5789 will be completed at runtime and should not be added to this list.") |
79545 | 5790 |
5791 (defvar verilog-tf-keywords | |
5792 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat") | |
5793 "*Keywords to complete when at first word of a line in a task or function. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5794 \(begin, if, then, else, for, fork.) |
79545 | 5795 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
|
5796 will be completed at runtime and should not be added to this list.") |
79545 | 5797 |
5798 (defvar verilog-case-keywords | |
5799 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat") | |
5800 "*Keywords to complete when at first word of a line in case scope. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5801 \(begin, if, then, else, for, fork...) |
79545 | 5802 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
|
5803 will be completed at runtime and should not be added to this list.") |
79545 | 5804 |
5805 (defvar verilog-separator-keywords | |
5806 '("else" "then" "begin") | |
5807 "*Keywords to complete when NOT standing at the first word of a statement. | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
5808 \(else, then, begin...) |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
5809 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
|
5810 will be completed at runtime and should not be added to this list.") |
79545 | 5811 |
5812 (defun verilog-string-diff (str1 str2) | |
5813 "Return index of first letter where STR1 and STR2 differs." | |
5814 (catch 'done | |
5815 (let ((diff 0)) | |
5816 (while t | |
5817 (if (or (> (1+ diff) (length str1)) | |
5818 (> (1+ diff) (length str2))) | |
5819 (throw 'done diff)) | |
5820 (or (equal (aref str1 diff) (aref str2 diff)) | |
5821 (throw 'done diff)) | |
5822 (setq diff (1+ diff)))))) | |
5823 | |
5824 ;; Calculate all possible completions for functions if argument is `function', | |
5825 ;; completions for procedures if argument is `procedure' or both functions and | |
5826 ;; procedures otherwise. | |
5827 | |
5828 (defun verilog-func-completion (type) | |
5829 "Build regular expression for module/task/function names. | |
5830 TYPE is 'module, 'tf for task or function, or t if unknown." | |
5831 (if (string= verilog-str "") | |
5832 (setq verilog-str "[a-zA-Z_]")) | |
5833 (let ((verilog-str (concat (cond | |
5834 ((eq type 'module) "\\<\\(module\\)\\s +") | |
5835 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +") | |
5836 (t "\\<\\(task\\|function\\|module\\)\\s +")) | |
5837 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>")) | |
5838 match) | |
5839 | |
5840 (if (not (looking-at verilog-defun-re)) | |
5841 (verilog-re-search-backward verilog-defun-re nil t)) | |
5842 (forward-char 1) | |
5843 | |
5844 ;; Search through all reachable functions | |
5845 (goto-char (point-min)) | |
5846 (while (verilog-re-search-forward verilog-str (point-max) t) | |
5847 (progn (setq match (buffer-substring (match-beginning 2) | |
5848 (match-end 2))) | |
5849 (if (or (null verilog-pred) | |
5850 (funcall verilog-pred match)) | |
5851 (setq verilog-all (cons match verilog-all))))) | |
5852 (if (match-beginning 0) | |
5853 (goto-char (match-beginning 0))))) | |
5854 | |
5855 (defun verilog-get-completion-decl (end) | |
5856 "Macro for searching through current declaration (var, type or const) | |
5857 for matches of `str' and adding the occurrence tp `all' through point END." | |
5858 (let ((re (or (and verilog-indent-declaration-macros | |
5859 verilog-declaration-re-2-macro) | |
5860 verilog-declaration-re-2-no-macro)) | |
5861 decl-end match) | |
5862 ;; Traverse lines | |
5863 (while (and (< (point) end) | |
5864 (verilog-re-search-forward re end t)) | |
5865 ;; Traverse current line | |
5866 (setq decl-end (save-excursion (verilog-declaration-end))) | |
5867 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t) | |
5868 (not (match-end 1))) | |
5869 (setq match (buffer-substring (match-beginning 0) (match-end 0))) | |
5870 (if (string-match (concat "\\<" verilog-str) match) | |
5871 (if (or (null verilog-pred) | |
5872 (funcall verilog-pred match)) | |
5873 (setq verilog-all (cons match verilog-all))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5874 (forward-line 1))) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
5875 verilog-all) |
79545 | 5876 |
5877 (defun verilog-type-completion () | |
5878 "Calculate all possible completions for types." | |
5879 (let ((start (point)) | |
5880 goon) | |
5881 ;; Search for all reachable type declarations | |
5882 (while (or (verilog-beg-of-defun) | |
5883 (setq goon (not goon))) | |
5884 (save-excursion | |
5885 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun) | |
5886 (point)) | |
5887 (forward-char 1))) | |
5888 (verilog-re-search-forward | |
5889 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>" | |
5890 start t) | |
5891 (not (match-end 1))) | |
5892 ;; Check current type declaration | |
5893 (verilog-get-completion-decl start)))))) | |
5894 | |
5895 (defun verilog-var-completion () | |
5896 "Calculate all possible completions for variables (or constants)." | |
5897 (let ((start (point))) | |
5898 ;; Search for all reachable var declarations | |
5899 (verilog-beg-of-defun) | |
5900 (save-excursion | |
5901 ;; Check var declarations | |
5902 (verilog-get-completion-decl start)))) | |
5903 | |
5904 (defun verilog-keyword-completion (keyword-list) | |
5905 "Give list of all possible completions of keywords in KEYWORD-LIST." | |
5906 (mapcar '(lambda (s) | |
5907 (if (string-match (concat "\\<" verilog-str) s) | |
5908 (if (or (null verilog-pred) | |
5909 (funcall verilog-pred s)) | |
5910 (setq verilog-all (cons s verilog-all))))) | |
5911 keyword-list)) | |
5912 | |
5913 | |
5914 (defun verilog-completion (verilog-str verilog-pred verilog-flag) | |
5915 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
5916 Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it | |
5917 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
|
5918 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
|
5919 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
|
5920 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
|
5921 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
|
5922 exact match, nil otherwise." |
79545 | 5923 (save-excursion |
5924 (let ((verilog-all nil)) | |
5925 ;; Set buffer to use for searching labels. This should be set | |
5926 ;; within functions which use verilog-completions | |
5927 (set-buffer verilog-buffer-to-use) | |
5928 | |
5929 ;; Determine what should be completed | |
5930 (let ((state (car (verilog-calculate-indent)))) | |
5931 (cond ((eq state 'defun) | |
5932 (save-excursion (verilog-var-completion)) | |
5933 (verilog-func-completion 'module) | |
5934 (verilog-keyword-completion verilog-defun-keywords)) | |
5935 | |
5936 ((eq state 'behavioral) | |
5937 (save-excursion (verilog-var-completion)) | |
5938 (verilog-func-completion 'module) | |
5939 (verilog-keyword-completion verilog-defun-keywords)) | |
5940 | |
5941 ((eq state 'block) | |
5942 (save-excursion (verilog-var-completion)) | |
5943 (verilog-func-completion 'tf) | |
5944 (verilog-keyword-completion verilog-block-keywords)) | |
5945 | |
5946 ((eq state 'case) | |
5947 (save-excursion (verilog-var-completion)) | |
5948 (verilog-func-completion 'tf) | |
5949 (verilog-keyword-completion verilog-case-keywords)) | |
5950 | |
5951 ((eq state 'tf) | |
5952 (save-excursion (verilog-var-completion)) | |
5953 (verilog-func-completion 'tf) | |
5954 (verilog-keyword-completion verilog-tf-keywords)) | |
5955 | |
5956 ((eq state 'cpp) | |
5957 (save-excursion (verilog-var-completion)) | |
5958 (verilog-keyword-completion verilog-cpp-keywords)) | |
5959 | |
5960 ((eq state 'cparenexp) | |
5961 (save-excursion (verilog-var-completion))) | |
5962 | |
5963 (t;--Anywhere else | |
5964 (save-excursion (verilog-var-completion)) | |
5965 (verilog-func-completion 'both) | |
5966 (verilog-keyword-completion verilog-separator-keywords)))) | |
5967 | |
5968 ;; Now we have built a list of all matches. Give response to caller | |
5969 (verilog-completion-response)))) | |
5970 | |
5971 (defun verilog-completion-response () | |
5972 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag)) | |
5973 ;; This was not called by all-completions | |
5974 (if (null verilog-all) | |
5975 ;; Return nil if there was no matching label | |
5976 nil | |
5977 ;; Get longest string common in the labels | |
5978 (let* ((elm (cdr verilog-all)) | |
5979 (match (car verilog-all)) | |
5980 (min (length match)) | |
5981 tmp) | |
5982 (if (string= match verilog-str) | |
5983 ;; Return t if first match was an exact match | |
5984 (setq match t) | |
5985 (while (not (null elm)) | |
5986 ;; Find longest common string | |
5987 (if (< (setq tmp (verilog-string-diff match (car elm))) min) | |
5988 (progn | |
5989 (setq min tmp) | |
5990 (setq match (substring match 0 min)))) | |
5991 ;; Terminate with match=t if this is an exact match | |
5992 (if (string= (car elm) verilog-str) | |
5993 (progn | |
5994 (setq match t) | |
5995 (setq elm nil)) | |
5996 (setq elm (cdr elm))))) | |
5997 ;; If this is a test just for exact match, return nil ot t | |
5998 (if (and (equal verilog-flag 'lambda) (not (equal match 't))) | |
5999 nil | |
6000 match)))) | |
6001 ;; If flag is t, this was called by all-completions. Return | |
6002 ;; list of all possible completions | |
6003 (verilog-flag | |
6004 verilog-all))) | |
6005 | |
6006 (defvar verilog-last-word-numb 0) | |
6007 (defvar verilog-last-word-shown nil) | |
6008 (defvar verilog-last-completions nil) | |
6009 | |
6010 (defun verilog-complete-word () | |
6011 "Complete word at current point. | |
6012 \(See also `verilog-toggle-completions', `verilog-type-keywords', | |
6013 and `verilog-separator-keywords'.)" | |
6014 (interactive) | |
6015 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
6016 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
6017 (verilog-str (buffer-substring b e)) | |
6018 ;; The following variable is used in verilog-completion | |
6019 (verilog-buffer-to-use (current-buffer)) | |
6020 (allcomp (if (and verilog-toggle-completions | |
6021 (string= verilog-last-word-shown verilog-str)) | |
6022 verilog-last-completions | |
6023 (all-completions verilog-str 'verilog-completion))) | |
6024 (match (if verilog-toggle-completions | |
6025 "" (try-completion | |
6026 verilog-str (mapcar '(lambda (elm) | |
6027 (cons elm 0)) allcomp))))) | |
6028 ;; Delete old string | |
6029 (delete-region b e) | |
6030 | |
6031 ;; Toggle-completions inserts whole labels | |
6032 (if verilog-toggle-completions | |
6033 (progn | |
6034 ;; Update entry number in list | |
6035 (setq verilog-last-completions allcomp | |
6036 verilog-last-word-numb | |
6037 (if (>= verilog-last-word-numb (1- (length allcomp))) | |
6038 0 | |
6039 (1+ verilog-last-word-numb))) | |
6040 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb)) | |
6041 ;; Display next match or same string if no match was found | |
6042 (if (not (null allcomp)) | |
6043 (insert "" verilog-last-word-shown) | |
6044 (insert "" verilog-str) | |
6045 (message "(No match)"))) | |
6046 ;; The other form of completion does not necessarily do that. | |
6047 | |
6048 ;; Insert match if found, or the original string if no match | |
6049 (if (or (null match) (equal match 't)) | |
6050 (progn (insert "" verilog-str) | |
6051 (message "(No match)")) | |
6052 (insert "" match)) | |
6053 ;; Give message about current status of completion | |
6054 (cond ((equal match 't) | |
6055 (if (not (null (cdr allcomp))) | |
6056 (message "(Complete but not unique)") | |
6057 (message "(Sole completion)"))) | |
6058 ;; Display buffer if the current completion didn't help | |
6059 ;; on completing the label. | |
6060 ((and (not (null (cdr allcomp))) (= (length verilog-str) | |
6061 (length match))) | |
6062 (with-output-to-temp-buffer "*Completions*" | |
6063 (display-completion-list allcomp)) | |
6064 ;; Wait for a key press. Then delete *Completion* window | |
6065 (momentary-string-display "" (point)) | |
6066 (delete-window (get-buffer-window (get-buffer "*Completions*"))) | |
6067 ))))) | |
6068 | |
6069 (defun verilog-show-completions () | |
6070 "Show all possible completions at current point." | |
6071 (interactive) | |
6072 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point))) | |
6073 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point))) | |
6074 (verilog-str (buffer-substring b e)) | |
6075 ;; The following variable is used in verilog-completion | |
6076 (verilog-buffer-to-use (current-buffer)) | |
6077 (allcomp (if (and verilog-toggle-completions | |
6078 (string= verilog-last-word-shown verilog-str)) | |
6079 verilog-last-completions | |
6080 (all-completions verilog-str 'verilog-completion)))) | |
6081 ;; Show possible completions in a temporary buffer. | |
6082 (with-output-to-temp-buffer "*Completions*" | |
6083 (display-completion-list allcomp)) | |
6084 ;; Wait for a key press. Then delete *Completion* window | |
6085 (momentary-string-display "" (point)) | |
6086 (delete-window (get-buffer-window (get-buffer "*Completions*"))))) | |
6087 | |
6088 | |
6089 (defun verilog-get-default-symbol () | |
6090 "Return symbol around current point as a string." | |
6091 (save-excursion | |
6092 (buffer-substring (progn | |
6093 (skip-chars-backward " \t") | |
6094 (skip-chars-backward "a-zA-Z0-9_") | |
6095 (point)) | |
6096 (progn | |
6097 (skip-chars-forward "a-zA-Z0-9_") | |
6098 (point))))) | |
6099 | |
6100 (defun verilog-build-defun-re (str &optional arg) | |
6101 "Return function/task/module starting with STR as regular expression. | |
6102 With optional second ARG non-nil, STR is the complete name of the instruction." | |
6103 (if arg | |
6104 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>") | |
6105 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>"))) | |
6106 | |
6107 (defun verilog-comp-defun (verilog-str verilog-pred verilog-flag) | |
6108 "Function passed to `completing-read', `try-completion' or `all-completions'. | |
6109 Returns a completion on any function name based on VERILOG-STR prefix. If | |
6110 VERILOG-PRED is non-nil, it must be a function to be called for every match | |
6111 to check if this should really be a match. If VERILOG-FLAG is t, the | |
6112 function returns a list of all possible completions. If it is nil it | |
6113 returns a string, the longest possible completion, or t if VERILOG-STR is | |
6114 an exact match. If VERILOG-FLAG is 'lambda, the function returns t if | |
6115 VERILOG-STR is an exact match, nil otherwise." | |
6116 (save-excursion | |
6117 (let ((verilog-all nil) | |
6118 match) | |
6119 | |
6120 ;; Set buffer to use for searching labels. This should be set | |
6121 ;; within functions which use verilog-completions | |
6122 (set-buffer verilog-buffer-to-use) | |
6123 | |
6124 (let ((verilog-str verilog-str)) | |
6125 ;; Build regular expression for functions | |
6126 (if (string= verilog-str "") | |
6127 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]")) | |
6128 (setq verilog-str (verilog-build-defun-re verilog-str))) | |
6129 (goto-char (point-min)) | |
6130 | |
6131 ;; Build a list of all possible completions | |
6132 (while (verilog-re-search-forward verilog-str nil t) | |
6133 (setq match (buffer-substring (match-beginning 2) (match-end 2))) | |
6134 (if (or (null verilog-pred) | |
6135 (funcall verilog-pred match)) | |
6136 (setq verilog-all (cons match verilog-all))))) | |
6137 | |
6138 ;; Now we have built a list of all matches. Give response to caller | |
6139 (verilog-completion-response)))) | |
6140 | |
6141 (defun verilog-goto-defun () | |
6142 "Move to specified Verilog module/task/function. | |
6143 The default is a name found in the buffer around point. | |
6144 If search fails, other files are checked based on | |
6145 `verilog-library-flags'." | |
6146 (interactive) | |
6147 (let* ((default (verilog-get-default-symbol)) | |
6148 ;; The following variable is used in verilog-comp-function | |
6149 (verilog-buffer-to-use (current-buffer)) | |
6150 (label (if (not (string= default "")) | |
6151 ;; Do completion with default | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6152 (completing-read (concat "Goto-Label: (default " |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6153 default ") ") |
79545 | 6154 'verilog-comp-defun nil nil "") |
6155 ;; There is no default value. Complete without it | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6156 (completing-read "Goto-Label: " |
79545 | 6157 'verilog-comp-defun nil nil ""))) |
6158 pt) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6159 ;; Make sure library paths are correct, in case need to resolve module |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6160 (verilog-auto-reeval-locals) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6161 (verilog-getopt-flags) |
79545 | 6162 ;; If there was no response on prompt, use default value |
6163 (if (string= label "") | |
6164 (setq label default)) | |
6165 ;; Goto right place in buffer if label is not an empty string | |
6166 (or (string= label "") | |
6167 (progn | |
6168 (save-excursion | |
6169 (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
|
6170 (setq pt |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6171 (re-search-forward (verilog-build-defun-re label t) nil t))) |
79545 | 6172 (when pt |
6173 (goto-char pt) | |
6174 (beginning-of-line)) | |
6175 pt) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6176 (verilog-goto-defun-file label)))) |
79545 | 6177 |
6178 ;; Eliminate compile warning | |
80172
7d8f87158250
(eval-when-compile): Don't define
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80171
diff
changeset
|
6179 (defvar occur-pos-list) |
79545 | 6180 |
6181 (defun verilog-showscopes () | |
6182 "List all scopes in this module." | |
6183 (interactive) | |
6184 (let ((buffer (current-buffer)) | |
6185 (linenum 1) | |
6186 (nlines 0) | |
6187 (first 1) | |
6188 (prevpos (point-min)) | |
6189 (final-context-start (make-marker)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6190 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)")) |
79545 | 6191 (with-output-to-temp-buffer "*Occur*" |
6192 (save-excursion | |
6193 (message (format "Searching for %s ..." regexp)) | |
6194 ;; Find next match, but give up if prev match was at end of buffer. | |
6195 (while (and (not (= prevpos (point-max))) | |
6196 (verilog-re-search-forward regexp nil t)) | |
6197 (goto-char (match-beginning 0)) | |
6198 (beginning-of-line) | |
6199 (save-match-data | |
6200 (setq linenum (+ linenum (count-lines prevpos (point))))) | |
6201 (setq prevpos (point)) | |
6202 (goto-char (match-end 0)) | |
6203 (let* ((start (save-excursion | |
6204 (goto-char (match-beginning 0)) | |
6205 (forward-line (if (< nlines 0) nlines (- nlines))) | |
6206 (point))) | |
6207 (end (save-excursion | |
6208 (goto-char (match-end 0)) | |
6209 (if (> nlines 0) | |
6210 (forward-line (1+ nlines)) | |
6211 (forward-line 1)) | |
6212 (point))) | |
6213 (tag (format "%3d" linenum)) | |
6214 (empty (make-string (length tag) ?\ )) | |
6215 tem) | |
6216 (save-excursion | |
6217 (setq tem (make-marker)) | |
6218 (set-marker tem (point)) | |
6219 (set-buffer standard-output) | |
6220 (setq occur-pos-list (cons tem occur-pos-list)) | |
6221 (or first (zerop nlines) | |
6222 (insert "--------\n")) | |
6223 (setq first nil) | |
6224 (insert-buffer-substring buffer start end) | |
6225 (backward-char (- end start)) | |
6226 (setq tem (if (< nlines 0) (- nlines) nlines)) | |
6227 (while (> tem 0) | |
6228 (insert empty ?:) | |
6229 (forward-line 1) | |
6230 (setq tem (1- tem))) | |
6231 (let ((this-linenum linenum)) | |
6232 (set-marker final-context-start | |
6233 (+ (point) (- (match-end 0) (match-beginning 0)))) | |
6234 (while (< (point) final-context-start) | |
6235 (if (null tag) | |
6236 (setq tag (format "%3d" this-linenum))) | |
6237 (insert tag ?:))))))) | |
6238 (set-buffer-modified-p nil)))) | |
6239 | |
6240 | |
6241 ;; Highlight helper functions | |
6242 (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_") | |
6243 (defun verilog-within-translate-off () | |
6244 "Return point if within translate-off region, else nil." | |
6245 (and (save-excursion | |
6246 (re-search-backward | |
6247 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>") | |
6248 nil t)) | |
6249 (equal "off" (match-string 2)) | |
6250 (point))) | |
6251 | |
6252 (defun verilog-start-translate-off (limit) | |
6253 "Return point before translate-off directive if before LIMIT, else nil." | |
6254 (when (re-search-forward | |
6255 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
6256 limit t) | |
6257 (match-beginning 0))) | |
6258 | |
6259 (defun verilog-back-to-start-translate-off (limit) | |
6260 "Return point before translate-off directive if before LIMIT, else nil." | |
6261 (when (re-search-backward | |
6262 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>") | |
6263 limit t) | |
6264 (match-beginning 0))) | |
6265 | |
6266 (defun verilog-end-translate-off (limit) | |
6267 "Return point after translate-on directive if before LIMIT, else nil." | |
6268 | |
6269 (re-search-forward (concat | |
6270 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t)) | |
6271 | |
6272 (defun verilog-match-translate-off (limit) | |
6273 "Match a translate-off block, setting `match-data' and returning t, else nil. | |
6274 Bound search by LIMIT." | |
6275 (when (< (point) limit) | |
6276 (let ((start (or (verilog-within-translate-off) | |
6277 (verilog-start-translate-off limit))) | |
6278 (case-fold-search t)) | |
6279 (when start | |
6280 (let ((end (or (verilog-end-translate-off limit) limit))) | |
6281 (set-match-data (list start end)) | |
6282 (goto-char end)))))) | |
6283 | |
6284 (defun verilog-font-lock-match-item (limit) | |
6285 "Match, and move over, any declaration item after point. | |
6286 Bound search by LIMIT. Adapted from | |
6287 `font-lock-match-c-style-declaration-item-and-skip-to-next'." | |
6288 (condition-case nil | |
6289 (save-restriction | |
6290 (narrow-to-region (point-min) limit) | |
6291 ;; match item | |
6292 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)") | |
6293 (save-match-data | |
6294 (goto-char (match-end 1)) | |
6295 ;; move to next item | |
6296 (if (looking-at "\\(\\s-*,\\)") | |
6297 (goto-char (match-end 1)) | |
6298 (end-of-line) t)))) | |
6299 (error nil))) | |
6300 | |
6301 | |
6302 ;; Added by Subbu Meiyappan for Header | |
6303 | |
6304 (defun verilog-header () | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6305 "Insert a standard Verilog file header. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6306 See also `verilog-sk-header' for an alternative format." |
79545 | 6307 (interactive) |
6308 (let ((start (point))) | |
6309 (insert "\ | |
6310 //----------------------------------------------------------------------------- | |
6311 // Title : <title> | |
6312 // Project : <project> | |
6313 //----------------------------------------------------------------------------- | |
6314 // File : <filename> | |
6315 // Author : <author> | |
6316 // Created : <credate> | |
6317 // Last modified : <moddate> | |
6318 //----------------------------------------------------------------------------- | |
6319 // Description : | |
6320 // <description> | |
6321 //----------------------------------------------------------------------------- | |
6322 // Copyright (c) <copydate> by <company> This model is the confidential and | |
6323 // proprietary property of <company> and the possession or use of this | |
6324 // file requires a written license from <company>. | |
6325 //------------------------------------------------------------------------------ | |
6326 // Modification history : | |
6327 // <modhist> | |
6328 //----------------------------------------------------------------------------- | |
6329 | |
6330 ") | |
6331 (goto-char start) | |
6332 (search-forward "<filename>") | |
6333 (replace-match (buffer-name) t t) | |
6334 (search-forward "<author>") (replace-match "" t t) | |
6335 (insert (user-full-name)) | |
6336 (insert " <" (user-login-name) "@" (system-name) ">") | |
6337 (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
|
6338 (verilog-insert-date) |
79545 | 6339 (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
|
6340 (verilog-insert-date) |
79545 | 6341 (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
|
6342 (verilog-insert-year) |
79545 | 6343 (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
|
6344 (verilog-insert-date) |
79545 | 6345 (insert " : created") |
6346 (goto-char start) | |
6347 (let (string) | |
6348 (setq string (read-string "title: ")) | |
6349 (search-forward "<title>") | |
6350 (replace-match string t t) | |
6351 (setq string (read-string "project: " verilog-project)) | |
6352 (setq verilog-project string) | |
6353 (search-forward "<project>") | |
6354 (replace-match string t t) | |
6355 (setq string (read-string "Company: " verilog-company)) | |
6356 (setq verilog-company string) | |
6357 (search-forward "<company>") | |
6358 (replace-match string t t) | |
6359 (search-forward "<company>") | |
6360 (replace-match string t t) | |
6361 (search-forward "<company>") | |
6362 (replace-match string t t) | |
6363 (search-backward "<description>") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6364 (replace-match "" t t)))) |
79545 | 6365 |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
6366 ;; 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
|
6367 |
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
6368 (defun verilog-insert-date () |
79545 | 6369 "Insert date from the system." |
6370 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6371 (if verilog-date-scientific-format |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6372 (insert (format-time-string "%Y/%m/%d")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6373 (insert (format-time-string "%d.%m.%Y")))) |
79545 | 6374 |
79554
bc59ec18d036
(verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79552
diff
changeset
|
6375 (defun verilog-insert-year () |
79545 | 6376 "Insert year from the system." |
6377 (interactive) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6378 (insert (format-time-string "%Y"))) |
79545 | 6379 |
6380 | |
6381 ;; | |
6382 ;; Signal list parsing | |
6383 ;; | |
6384 | |
6385 ;; Elements of a signal list | |
6386 (defsubst verilog-sig-name (sig) | |
6387 (car sig)) | |
6388 (defsubst verilog-sig-bits (sig) | |
6389 (nth 1 sig)) | |
6390 (defsubst verilog-sig-comment (sig) | |
6391 (nth 2 sig)) | |
6392 (defsubst verilog-sig-memory (sig) | |
6393 (nth 3 sig)) | |
6394 (defsubst verilog-sig-enum (sig) | |
6395 (nth 4 sig)) | |
6396 (defsubst verilog-sig-signed (sig) | |
6397 (nth 5 sig)) | |
6398 (defsubst verilog-sig-type (sig) | |
6399 (nth 6 sig)) | |
6400 (defsubst verilog-sig-multidim (sig) | |
6401 (nth 7 sig)) | |
6402 (defsubst verilog-sig-multidim-string (sig) | |
6403 (if (verilog-sig-multidim sig) | |
6404 (let ((str "") (args (verilog-sig-multidim sig))) | |
6405 (while args | |
6406 (setq str (concat str (car args))) | |
6407 (setq args (cdr args))) | |
6408 str))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6409 (defsubst verilog-sig-modport (sig) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6410 (nth 8 sig)) |
79545 | 6411 (defsubst verilog-sig-width (sig) |
6412 (verilog-make-width-expression (verilog-sig-bits sig))) | |
6413 | |
6414 (defsubst verilog-alw-get-inputs (sigs) | |
6415 (nth 2 sigs)) | |
6416 (defsubst verilog-alw-get-outputs (sigs) | |
6417 (nth 0 sigs)) | |
6418 (defsubst verilog-alw-get-uses-delayed (sigs) | |
6419 (nth 3 sigs)) | |
6420 | |
6421 (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
|
6422 "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
|
6423 Also remove any duplicates in IN-LIST. |
79545 | 6424 Signals must be in standard (base vector) form." |
6425 (let (out-list) | |
6426 (while in-list | |
6427 (if (not (or (assoc (car (car in-list)) not-list) | |
6428 (assoc (car (car in-list)) out-list))) | |
6429 (setq out-list (cons (car in-list) out-list))) | |
6430 (setq in-list (cdr in-list))) | |
6431 (nreverse out-list))) | |
6432 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
6433 | |
6434 (defun verilog-signals-in (in-list other-list) | |
6435 "Return list of signals in IN-LIST that are also in OTHER-LIST. | |
6436 Signals must be in standard (base vector) form." | |
6437 (let (out-list) | |
6438 (while in-list | |
6439 (if (assoc (car (car in-list)) other-list) | |
6440 (setq out-list (cons (car in-list) out-list))) | |
6441 (setq in-list (cdr in-list))) | |
6442 (nreverse out-list))) | |
6443 ;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" ""))) | |
6444 | |
6445 (defun verilog-signals-memory (in-list) | |
6446 "Return list of signals in IN-LIST that are memoried (multidimensional)." | |
6447 (let (out-list) | |
6448 (while in-list | |
6449 (if (nth 3 (car in-list)) | |
6450 (setq out-list (cons (car in-list) out-list))) | |
6451 (setq in-list (cdr in-list))) | |
6452 out-list)) | |
6453 ;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil))) | |
6454 | |
6455 (defun verilog-signals-sort-compare (a b) | |
6456 "Compare signal A and B for sorting." | |
6457 (string< (car a) (car b))) | |
6458 | |
6459 (defun verilog-signals-not-params (in-list) | |
6460 "Return list of signals in IN-LIST that aren't parameters or numeric constants." | |
6461 (let (out-list) | |
6462 (while in-list | |
6463 (unless (boundp (intern (concat "vh-" (car (car in-list))))) | |
6464 (setq out-list (cons (car in-list) out-list))) | |
6465 (setq in-list (cdr in-list))) | |
6466 (nreverse out-list))) | |
6467 | |
6468 (defun verilog-signals-combine-bus (in-list) | |
6469 "Return a list of signals in IN-LIST, with busses combined. | |
6470 Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]." | |
6471 (let (combo buswarn | |
6472 out-list | |
6473 sig highbit lowbit ; Temp information about current signal | |
6474 sv-name sv-highbit sv-lowbit ; Details about signal we are forming | |
6475 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6476 sv-modport |
79545 | 6477 bus) |
6478 ;; Shove signals so duplicated signals will be adjacent | |
6479 (setq in-list (sort in-list `verilog-signals-sort-compare)) | |
6480 (while in-list | |
6481 (setq sig (car in-list)) | |
6482 ;; No current signal; form from existing details | |
6483 (unless sv-name | |
6484 (setq sv-name (verilog-sig-name sig) | |
6485 sv-highbit nil | |
6486 sv-busstring nil | |
6487 sv-comment (verilog-sig-comment sig) | |
6488 sv-memory (verilog-sig-memory sig) | |
6489 sv-enum (verilog-sig-enum sig) | |
6490 sv-signed (verilog-sig-signed sig) | |
6491 sv-type (verilog-sig-type sig) | |
6492 sv-multidim (verilog-sig-multidim sig) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6493 sv-modport (verilog-sig-modport sig) |
79545 | 6494 combo "" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6495 buswarn "")) |
79545 | 6496 ;; Extract bus details |
6497 (setq bus (verilog-sig-bits sig)) | |
6498 (cond ((and bus | |
6499 (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
|
6500 (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
|
6501 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
|
6502 (match-string 2 bus)))) |
79545 | 6503 (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
|
6504 (setq highbit (string-to-number (match-string 1 bus)) |
79545 | 6505 lowbit highbit)))) |
6506 ;; Combine bits in bus | |
6507 (if sv-highbit | |
6508 (setq sv-highbit (max highbit sv-highbit) | |
6509 sv-lowbit (min lowbit sv-lowbit)) | |
6510 (setq sv-highbit highbit | |
6511 sv-lowbit lowbit))) | |
6512 (bus | |
6513 ;; String, probably something like `preproc:0 | |
6514 (setq sv-busstring bus))) | |
6515 ;; Peek ahead to next signal | |
6516 (setq in-list (cdr in-list)) | |
6517 (setq sig (car in-list)) | |
6518 (cond ((and sig (equal sv-name (verilog-sig-name sig))) | |
6519 ;; 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
|
6520 (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
|
6521 (not (equal sv-busstring (verilog-sig-bits sig)))) |
79545 | 6522 (when nil ;; Debugging |
6523 (message (concat "Warning, can't merge into single bus " | |
6524 sv-name bus | |
6525 ", the AUTOs may be wrong"))) | |
6526 (setq buswarn ", Couldn't Merge")) | |
6527 (if (verilog-sig-comment sig) (setq combo ", ...")) | |
6528 (setq sv-memory (or sv-memory (verilog-sig-memory sig)) | |
6529 sv-enum (or sv-enum (verilog-sig-enum sig)) | |
6530 sv-signed (or sv-signed (verilog-sig-signed sig)) | |
6531 sv-type (or sv-type (verilog-sig-type sig)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6532 sv-multidim (or sv-multidim (verilog-sig-multidim sig)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6533 sv-modport (or sv-modport (verilog-sig-modport sig)))) |
79545 | 6534 ;; Doesn't match next signal, add to queue, zero in prep for next |
6535 ;; Note sig may also be nil for the last signal in the list | |
6536 (t | |
6537 (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
|
6538 (cons |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6539 (list sv-name |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6540 (or sv-busstring |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6541 (if sv-highbit |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6542 (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
|
6543 (int-to-string sv-lowbit) "]"))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6544 (concat sv-comment combo buswarn) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6545 sv-memory sv-enum sv-signed sv-type sv-multidim sv-modport) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6546 out-list) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6547 sv-name nil)))) |
79545 | 6548 ;; |
6549 out-list)) | |
6550 | |
6551 (defun verilog-sig-tieoff (sig &optional no-width) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6552 "Return tieoff expression for given SIG, with appropriate width. |
79545 | 6553 Ignore width if optional NO-WIDTH is set." |
6554 (let* ((width (if no-width nil (verilog-sig-width sig)))) | |
6555 (concat | |
6556 (if (and verilog-active-low-regexp | |
6557 (string-match verilog-active-low-regexp (verilog-sig-name sig))) | |
6558 "~" "") | |
6559 (cond ((not width) | |
6560 "0") | |
6561 ((string-match "^[0-9]+$" width) | |
6562 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0"))) | |
6563 (t | |
6564 (concat "{" width "{1'b0}}")))))) | |
6565 | |
6566 ;; | |
6567 ;; Port/Wire/Etc Reading | |
6568 ;; | |
6569 | |
6570 (defun verilog-read-inst-backward-name () | |
6571 "Internal. Move point back to beginning of inst-name." | |
6572 (verilog-backward-open-paren) | |
6573 (let (done) | |
6574 (while (not done) | |
6575 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary | |
6576 (cond ((looking-at ")") | |
6577 (verilog-backward-open-paren)) | |
6578 (t (setq done t))))) | |
6579 (while (looking-at "\\]") | |
6580 (verilog-backward-open-bracket) | |
6581 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil)) | |
6582 (skip-chars-backward "a-zA-Z0-9`_$")) | |
6583 | |
6584 (defun verilog-read-inst-module () | |
6585 "Return module_name when point is inside instantiation." | |
6586 (save-excursion | |
6587 (verilog-read-inst-backward-name) | |
6588 ;; Skip over instantiation name | |
6589 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary | |
6590 ;; Check for parameterized instantiations | |
6591 (when (looking-at ")") | |
6592 (verilog-backward-open-paren) | |
6593 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)) | |
6594 (skip-chars-backward "a-zA-Z0-9'_$") | |
6595 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6596 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
79545 | 6597 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) |
6598 | |
6599 (defun verilog-read-inst-name () | |
6600 "Return instance_name when point is inside instantiation." | |
6601 (save-excursion | |
6602 (verilog-read-inst-backward-name) | |
6603 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6604 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
79545 | 6605 (buffer-substring-no-properties (match-beginning 0) (match-end 0)))) |
6606 | |
6607 (defun verilog-read-module-name () | |
6608 "Return module name when after its ( or ;." | |
6609 (save-excursion | |
6610 (re-search-backward "[(;]") | |
6611 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil) | |
6612 (skip-chars-backward "a-zA-Z0-9`_$") | |
6613 (looking-at "[a-zA-Z0-9`_\$]+") | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
6614 ;; Important: don't use match string, this must work with Emacs 19 font-lock on |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6615 (verilog-symbol-detick |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6616 (buffer-substring-no-properties (match-beginning 0) (match-end 0)) t))) |
79545 | 6617 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6618 (defun verilog-read-inst-param-value () |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6619 "Return list of parameters and values when point is inside instantiation." |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6620 (save-excursion |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6621 (verilog-read-inst-backward-name) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6622 ;; Skip over instantiation name |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6623 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6624 ;; If there are parameterized instantiations |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6625 (when (looking-at ")") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6626 (let ((end-pt (point)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6627 params |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6628 param-name paren-beg-pt param-value) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6629 (verilog-backward-open-paren) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6630 (while (verilog-re-search-forward-quick "\\." end-pt t) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6631 (verilog-re-search-forward-quick "\\([a-zA-Z0-9`_\$]\\)" nil nil) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6632 (skip-chars-backward "a-zA-Z0-9'_$") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6633 (looking-at "[a-zA-Z0-9`_\$]+") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6634 (setq param-name (buffer-substring-no-properties |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6635 (match-beginning 0) (match-end 0))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6636 (verilog-re-search-forward-quick "(" nil nil) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6637 (setq paren-beg-pt (point)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6638 (verilog-forward-close-paren) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6639 (setq param-value (verilog-string-remove-spaces |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6640 (buffer-substring-no-properties |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6641 paren-beg-pt (1- (point))))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6642 (setq params (cons (list param-name param-value) params))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6643 params)))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
6644 |
79545 | 6645 (defun verilog-read-auto-params (num-param &optional max-param) |
6646 "Return parameter list inside auto. | |
6647 Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters." | |
6648 (let ((olist)) | |
6649 (save-excursion | |
6650 ;; /*AUTOPUNT("parameter", "parameter")*/ | |
6651 (search-backward "(") | |
6652 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?") | |
6653 (setq olist (cons (match-string 1) olist)) | |
6654 (goto-char (match-end 0)))) | |
6655 (or (eq nil num-param) | |
6656 (<= num-param (length olist)) | |
6657 (error "%s: Expected %d parameters" (verilog-point-text) num-param)) | |
6658 (if (eq max-param nil) (setq max-param num-param)) | |
6659 (or (eq nil max-param) | |
6660 (>= max-param (length olist)) | |
6661 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param)) | |
6662 (nreverse olist))) | |
6663 | |
6664 (defun verilog-read-decls () | |
6665 "Compute signal declaration information for the current module at point. | |
6666 Return a array of [outputs inouts inputs wire reg assign const]." | |
6667 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6668 (functask 0) (paren 0) (sig-paren 0) (v2kargs-ok t) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6669 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6670 sigs-gparam sigs-intf |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6671 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6672 modport) |
79545 | 6673 (save-excursion |
6674 (verilog-beg-of-defun) | |
6675 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point)) | |
6676 (while (< (point) end-mod-point) | |
6677 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg))) | |
6678 (cond | |
6679 ((looking-at "//") | |
6680 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6681 (setq enum (match-string 1))) | |
6682 (search-forward "\n")) | |
6683 ((looking-at "/\\*") | |
6684 (forward-char 2) | |
6685 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
6686 (setq enum (match-string 1))) | |
6687 (or (search-forward "*/") | |
6688 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
6689 ((looking-at "(\\*") | |
6690 (forward-char 2) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6691 (or (looking-at "\\s-*)") ; It's an "always @ (*)" |
79545 | 6692 (search-forward "*)") |
6693 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
6694 ((eq ?\" (following-char)) | |
6695 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first | |
6696 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
6697 ((eq ?\; (following-char)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6698 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6699 v2kargs-ok nil) |
79545 | 6700 (forward-char 1)) |
6701 ((eq ?= (following-char)) | |
6702 (setq rvalue t newsig nil) | |
6703 (forward-char 1)) | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6704 ((and (eq ?, (following-char)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6705 (eq paren sig-paren)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6706 (setq rvalue nil) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6707 (forward-char 1)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6708 ;; ,'s can occur inside {} & funcs |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6709 ((looking-at "[{(]") |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6710 (setq paren (1+ paren)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6711 (forward-char 1)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6712 ((looking-at "[})]") |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6713 (setq paren (1- paren)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6714 (forward-char 1) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6715 (when (< paren sig-paren) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6716 (setq expect-signal nil))) ; ) that ends variables inside v2k arg list |
79545 | 6717 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)") |
6718 (goto-char (match-end 0)) | |
6719 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3) | |
6720 (setcar (cdr (cdr (cdr newsig))) (match-string 1))) | |
6721 (vec ;; Multidimensional | |
6722 (setq multidim (cons vec multidim)) | |
6723 (setq vec (verilog-string-replace-matches | |
6724 "\\s-+" "" nil nil (match-string 1)))) | |
6725 (t ;; Bit width | |
6726 (setq vec (verilog-string-replace-matches | |
6727 "\\s-+" "" nil nil (match-string 1)))))) | |
6728 ;; Normal or escaped identifier -- note we remember the \ if escaped | |
6729 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") | |
6730 (goto-char (match-end 0)) | |
6731 (setq keywd (match-string 1)) | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6732 (when (string-match "^\\\\" (match-string 1)) |
79545 | 6733 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6734 ;; Add any :: package names to same identifier |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6735 (while (looking-at "\\s-*::\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)") |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6736 (goto-char (match-end 0)) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6737 (setq keywd (concat keywd "::" (match-string 1))) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6738 (when (string-match "^\\\\" (match-string 1)) |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
6739 (setq keywd (concat keywd " ")))) ;; Escaped ID needs space at end |
79545 | 6740 (cond ((equal keywd "input") |
6741 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6742 expect-signal 'sigs-in io t modport nil)) |
79545 | 6743 ((equal keywd "output") |
6744 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6745 expect-signal 'sigs-out io t modport nil)) |
79545 | 6746 ((equal keywd "inout") |
6747 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6748 expect-signal 'sigs-inout io t modport nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6749 ((equal keywd "parameter") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6750 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6751 expect-signal 'sigs-gparam io t modport nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6752 ((member keywd '("wire" "tri" "tri0" "tri1" "triand" "trior" "wand" "wor")) |
79545 | 6753 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6754 expect-signal 'sigs-wire modport nil))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6755 ((member keywd '("reg" "trireg" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6756 "byte" "shortint" "int" "longint" "integer" "time" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6757 "bit" "logic")) |
79545 | 6758 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6759 expect-signal 'sigs-reg modport nil))) |
79545 | 6760 ((equal keywd "assign") |
6761 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6762 expect-signal 'sigs-assign modport nil)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6763 ((member keywd '("supply0" "supply1" "supply" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6764 "localparam" "genvar")) |
79545 | 6765 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6766 expect-signal 'sigs-const modport nil))) |
79545 | 6767 ((equal keywd "signed") |
6768 (setq signed "signed")) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6769 ((member keywd '("class" "clocking" "covergroup" "function" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6770 "property" "randsequence" "sequence" "task")) |
79545 | 6771 (setq functask (1+ functask))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6772 ((member keywd '("endclass" "endclocking" "endgroup" "endfunction" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6773 "endproperty" "endsequence" "endtask")) |
79545 | 6774 (setq functask (1- functask))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6775 ;; Ifdef? Ignore name of define |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6776 ((member keywd '("`ifdef" "`ifndef")) |
79545 | 6777 (setq rvalue t)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6778 ;; Type? |
79545 | 6779 ((verilog-typedef-name-p keywd) |
6780 (setq typedefed keywd)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6781 ;; Interface with optional modport in v2k arglist? |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6782 ;; Skip over parsing modport, and take the interface name as the type |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6783 ((and v2kargs-ok |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6784 (eq paren 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6785 (looking-at "\\s-*\\(\\.\\(\\s-*[a-zA-Z0-9`_$]+\\)\\|\\)\\s-*[a-zA-Z0-9`_$]+")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6786 (when (match-end 2) (goto-char (match-end 2))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6787 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed keywd multidim nil sig-paren paren |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6788 expect-signal 'sigs-intf io t modport (match-string 2))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6789 ;; New signal, maybe? |
79545 | 6790 ((and expect-signal |
6791 (eq functask 0) | |
6792 (not rvalue) | |
6793 (not (member keywd verilog-keywords))) | |
6794 ;; Add new signal to expect-signal's variable | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6795 (setq newsig (list keywd vec nil nil enum signed typedefed multidim modport)) |
79545 | 6796 (set expect-signal (cons newsig |
6797 (symbol-value expect-signal)))))) | |
6798 (t | |
6799 (forward-char 1))) | |
6800 (skip-syntax-forward " ")) | |
6801 ;; Return arguments | |
6802 (vector (nreverse sigs-out) | |
6803 (nreverse sigs-inout) | |
6804 (nreverse sigs-in) | |
6805 (nreverse sigs-wire) | |
6806 (nreverse sigs-reg) | |
6807 (nreverse sigs-assign) | |
6808 (nreverse sigs-const) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6809 (nreverse sigs-gparam) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6810 (nreverse sigs-intf))))) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6811 |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6812 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6813 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6814 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6815 ;; - 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
|
6816 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
6817 (defvar sigs-inout) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6818 (defvar sigs-out) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6819 (defvar sigs-intf)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6820 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6821 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6822 (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
|
6823 (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
|
6824 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6825 (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
|
6826 (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
|
6827 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6828 |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
6829 ;; 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
|
6830 ;; 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
|
6831 ;; verilog-modi-current function. |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6832 (defsubst verilog-decls-get-outputs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6833 (aref decls 0)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6834 (defsubst verilog-decls-get-inouts (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6835 (aref decls 1)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6836 (defsubst verilog-decls-get-inputs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6837 (aref decls 2)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6838 (defsubst verilog-decls-get-wires (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6839 (aref decls 3)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6840 (defsubst verilog-decls-get-regs (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6841 (aref decls 4)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6842 (defsubst verilog-decls-get-assigns (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6843 (aref decls 5)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6844 (defsubst verilog-decls-get-consts (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6845 (aref decls 6)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6846 (defsubst verilog-decls-get-gparams (decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6847 (aref decls 7)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6848 (defsubst verilog-decls-get-interfaces (decls) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6849 (aref decls 8)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6850 (defsubst verilog-subdecls-get-outputs (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6851 (aref subdecls 0)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6852 (defsubst verilog-subdecls-get-inouts (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6853 (aref subdecls 1)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6854 (defsubst verilog-subdecls-get-inputs (subdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6855 (aref subdecls 2)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6856 (defsubst verilog-subdecls-get-interfaces (subdecls) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6857 (aref subdecls 3)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6858 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6859 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6860 (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
|
6861 "For `verilog-read-sub-decls-line', add a signal." |
79545 | 6862 (let (portdata) |
6863 (when sig | |
6864 (setq port (verilog-symbol-detick-denumber port)) | |
6865 (setq sig (verilog-symbol-detick-denumber sig)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6866 (if sig (setq sig (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil sig))) |
79545 | 6867 (if vec (setq vec (verilog-symbol-detick-denumber vec))) |
6868 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim))) | |
6869 (unless (or (not sig) | |
6870 (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
|
6871 (cond ((setq portdata (assoc port (verilog-decls-get-inouts submoddecls))) |
79545 | 6872 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil |
6873 (verilog-sig-signed portdata) | |
6874 (verilog-sig-type portdata) | |
6875 multidim) | |
6876 sigs-inout))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6877 ((setq portdata (assoc port (verilog-decls-get-outputs submoddecls))) |
79545 | 6878 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil |
6879 (verilog-sig-signed portdata) | |
6880 (verilog-sig-type portdata) | |
6881 multidim) | |
6882 sigs-out))) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6883 ((setq portdata (assoc port (verilog-decls-get-inputs submoddecls))) |
79545 | 6884 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil |
6885 (verilog-sig-signed portdata) | |
6886 (verilog-sig-type portdata) | |
6887 multidim) | |
6888 sigs-in))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6889 ((setq portdata (assoc port (verilog-decls-get-interfaces submoddecls))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6890 (setq sigs-intf (cons (list sig vec (concat "To/From " comment) nil nil |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6891 (verilog-sig-signed portdata) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6892 (verilog-sig-type portdata) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6893 multidim) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6894 sigs-intf))) |
79545 | 6895 ;; (t -- warning pin isn't defined.) ; Leave for lint tool |
6896 ))))) | |
6897 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6898 (defun verilog-read-sub-decls-expr (submoddecls comment port expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6899 "For `verilog-read-sub-decls-line', parse a subexpression and add signals." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6900 ;;(message "vrsde: '%s'" expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6901 ;; Replace special /*[....]*/ comments inserted by verilog-auto-inst-port |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6902 (setq expr (verilog-string-replace-matches "/\\*\\(\\[[^*]+\\]\\)\\*/" "\\1" nil nil expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6903 ;; Remove front operators |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6904 (setq expr (verilog-string-replace-matches "^\\s-*[---+~!|&]+\\s-*" "" nil nil expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6905 ;; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6906 (cond |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6907 ;; {..., a, b} requires us to recurse on a,b |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6908 ((string-match "^\\s-*{\\([^{}]*\\)}\\s-*$" expr) |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6909 (unless verilog-auto-ignore-concat |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6910 (let ((mlst (split-string (match-string 1 expr) ",")) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6911 mstr) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6912 (while (setq mstr (pop mlst)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
6913 (verilog-read-sub-decls-expr submoddecls comment port mstr))))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6914 (t |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6915 (let (sig vec multidim) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6916 (cond ;; Find \signal. Final space is part of escaped signal name |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6917 ((string-match "^\\s-*\\(\\\\[^ \t\n\f]+\\s-\\)" expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6918 ;;(message "vrsde-s: '%s'" (match-string 1 expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6919 (setq sig (match-string 1 expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6920 expr (substring expr (match-end 0)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6921 ;; Find signal |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6922 ((string-match "^\\s-*\\([^[({).\\]+\\)" expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6923 ;;(message "vrsde-s: '%s'" (match-string 1 expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6924 (setq sig (verilog-string-remove-spaces (match-string 1 expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6925 expr (substring expr (match-end 0))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6926 ;; Find [vector] or [multi][multi][multi][vector] |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6927 (while (string-match "^\\s-*\\(\\[[^]]+\\]\\)" expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6928 ;;(message "vrsde-v: '%s'" (match-string 1 expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6929 (when vec (setq multidim (cons vec multidim))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6930 (setq vec (match-string 1 expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6931 expr (substring expr (match-end 0)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6932 ;; If found signal, and nothing unrecognized, add the signal |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6933 ;;(message "vrsde-rem: '%s'" expr) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6934 (when (and sig (string-match "^\\s-*$" expr)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6935 (verilog-read-sub-decls-sig submoddecls comment port sig vec multidim)))))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6936 |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
6937 (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
|
6938 "For `verilog-read-sub-decls', read lines of port defs until none match anymore. |
79545 | 6939 Return the list of signals found, using submodi to look up each port." |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6940 (let (done port) |
79545 | 6941 (save-excursion |
6942 (forward-line 1) | |
6943 (while (not done) | |
6944 ;; Get port name | |
6945 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*") | |
6946 (setq port (match-string 1)) | |
6947 (goto-char (match-end 0))) | |
6948 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*") | |
6949 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space | |
6950 (goto-char (match-end 0))) | |
6951 ((looking-at "\\s-*\\.[^(]*(") | |
6952 (setq port nil) ;; skip this line | |
6953 (goto-char (match-end 0))) | |
6954 (t | |
6955 (setq port nil done t))) ;; Unknown, ignore rest of line | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6956 ;; Get signal name. Point is at the first-non-space after ( |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6957 ;; We intentionally ignore (non-escaped) signals with .s in them |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6958 ;; this prevents AUTOWIRE etc from noticing hierarchical sigs. |
79545 | 6959 (when port |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6960 (cond ((looking-at "\\([^[({).\\]*\\)\\s-*)") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6961 (verilog-read-sub-decls-sig |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6962 submoddecls comment port |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6963 (verilog-string-remove-spaces (match-string 1)) ; sig |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6964 nil nil)) ; vec multidim |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6965 ;; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6966 ((looking-at "\\([^[({).\\]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6967 (verilog-read-sub-decls-sig |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6968 submoddecls comment port |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6969 (verilog-string-remove-spaces (match-string 1)) ; sig |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6970 (match-string 2) nil)) ; vec multidim |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6971 ;; Fastpath was above looking-at's. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6972 ;; For something more complicated invoke a parser |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6973 ((looking-at "[^)]+") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6974 (verilog-read-sub-decls-expr |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6975 submoddecls comment port |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6976 (buffer-substring |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6977 (point) (1- (progn (backward-char 1) ; start at ( |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
6978 (forward-sexp 1) (point)))))))) ; expr |
79545 | 6979 ;; |
6980 (forward-line 1))))) | |
6981 | |
6982 (defun verilog-read-sub-decls () | |
6983 "Internally parse signals going to modules under this module. | |
6984 Return a array of [ outputs inouts inputs ] signals for modules that are | |
6985 instantiated in this module. For example if declare A A (.B(SIG)) and SIG | |
6986 is a output, then SIG will be included in the list. | |
6987 | |
6988 This only works on instantiations created with /*AUTOINST*/ converted by | |
6989 \\[verilog-auto-inst]. Otherwise, it would have to read in the whole | |
6990 component library to determine connectivity of the design. | |
6991 | |
6992 One work around for this problem is to manually create // Inputs and // | |
6993 Outputs comments above subcell signals, for example: | |
6994 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
6995 module ModuleName ( |
79545 | 6996 // Outputs |
6997 .out (out), | |
6998 // Inputs | |
6999 .in (in));" | |
7000 (save-excursion | |
7001 (let ((end-mod-point (verilog-get-end-of-defun t)) | |
7002 st-point end-inst-point | |
7003 ;; below 3 modified by verilog-read-sub-decls-line | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7004 sigs-out sigs-inout sigs-in sigs-intf) |
79545 | 7005 (verilog-beg-of-defun) |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
7006 (while (verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t) |
79545 | 7007 (save-excursion |
7008 (goto-char (match-beginning 0)) | |
7009 (unless (verilog-inside-comment-p) | |
7010 ;; Attempt to snarf a comment | |
7011 (let* ((submod (verilog-read-inst-module)) | |
7012 (inst (verilog-read-inst-name)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7013 (comment (concat inst " of " submod ".v")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7014 submodi submoddecls) |
79545 | 7015 (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
|
7016 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 7017 ;; This could have used a list created by verilog-auto-inst |
7018 ;; However I want it to be runnable even on user's manually added signals | |
7019 (verilog-backward-open-paren) | |
7020 (setq end-inst-point (save-excursion (forward-sexp 1) (point)) | |
7021 st-point (point)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7022 (while (re-search-forward "\\s *(?\\s *// Interfaces" end-inst-point t) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7023 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7024 (goto-char st-point) |
79545 | 7025 (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
|
7026 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-out |
79545 | 7027 (goto-char st-point) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7028 (while (re-search-forward "\\s *(?\\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
|
7029 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-inout |
79545 | 7030 (goto-char st-point) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7031 (while (re-search-forward "\\s *(?\\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
|
7032 (verilog-read-sub-decls-line submoddecls comment)) ;; Modifies sigs-in |
79545 | 7033 ))))) |
7034 ;; Combine duplicate bits | |
7035 ;;(setq rr (vector sigs-out sigs-inout sigs-in)) | |
7036 (vector (verilog-signals-combine-bus (nreverse sigs-out)) | |
7037 (verilog-signals-combine-bus (nreverse sigs-inout)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7038 (verilog-signals-combine-bus (nreverse sigs-in)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7039 (verilog-signals-combine-bus (nreverse sigs-intf)))))) |
79545 | 7040 |
7041 (defun verilog-read-inst-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7042 "Return an array of [ pins ] for the current instantiation at point. |
79545 | 7043 For example if declare A A (.B(SIG)) then B will be included in the list." |
7044 (save-excursion | |
7045 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point | |
7046 pins pin) | |
7047 (verilog-backward-open-paren) | |
7048 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t) | |
7049 (setq pin (match-string 1)) | |
7050 (unless (verilog-inside-comment-p) | |
7051 (setq pins (cons (list pin) pins)) | |
7052 (when (looking-at "(") | |
7053 (forward-sexp 1)))) | |
7054 (vector pins)))) | |
7055 | |
7056 (defun verilog-read-arg-pins () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7057 "Return an array of [ pins ] for the current argument declaration at point." |
79545 | 7058 (save-excursion |
7059 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point | |
7060 pins pin) | |
7061 (verilog-backward-open-paren) | |
7062 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t) | |
7063 (setq pin (match-string 1)) | |
7064 (unless (verilog-inside-comment-p) | |
7065 (setq pins (cons (list pin) pins)))) | |
7066 (vector pins)))) | |
7067 | |
7068 (defun verilog-read-auto-constants (beg end-mod-point) | |
7069 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT." | |
7070 ;; Insert new | |
7071 (save-excursion | |
7072 (let (sig-list tpl-end-pt) | |
7073 (goto-char beg) | |
7074 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t) | |
7075 (if (not (looking-at "\\s *(")) | |
7076 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text))) | |
7077 (search-forward "(" end-mod-point) | |
7078 (setq tpl-end-pt (save-excursion | |
7079 (backward-char 1) | |
7080 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
7081 (backward-char 1) | |
7082 (point))) | |
7083 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t) | |
7084 (setq sig-list (cons (list (match-string 1) nil nil) sig-list)))) | |
7085 sig-list))) | |
7086 | |
7087 (defun verilog-read-auto-lisp (start end) | |
7088 "Look for and evaluate a AUTO_LISP between START and END." | |
7089 (save-excursion | |
7090 (goto-char start) | |
7091 (while (re-search-forward "\\<AUTO_LISP(" end t) | |
7092 (backward-char) | |
7093 (let* ((beg-pt (prog1 (point) | |
7094 (forward-sexp 1))) ;; Closing paren | |
7095 (end-pt (point))) | |
7096 (eval-region beg-pt end-pt nil))))) | |
7097 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7098 (eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7099 ;; Prevent compile warnings; these are let's, not globals |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7100 ;; Do not remove the eval-when-compile |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7101 ;; - 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
|
7102 (defvar sigs-in) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7103 (defvar sigs-out) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7104 (defvar got-sig) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7105 (defvar got-rvalue) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7106 (defvar uses-delayed) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7107 (defvar vector-skip-list)) |
79545 | 7108 |
7109 (defun verilog-read-always-signals-recurse | |
7110 (exit-keywd rvalue ignore-next) | |
7111 "Recursive routine for parentheses/bracket matching. | |
7112 EXIT-KEYWD is expression to stop at, nil if top level. | |
7113 RVALUE is true if at right hand side of equal. | |
7114 IGNORE-NEXT is true to ignore next token, fake from inside case statement." | |
7115 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue | |
7116 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check) | |
7117 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next)))) | |
7118 (while (not (or (eobp) gotend)) | |
7119 (cond | |
7120 ((looking-at "//") | |
7121 (search-forward "\n")) | |
7122 ((looking-at "/\\*") | |
7123 (or (search-forward "*/") | |
7124 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
7125 ((looking-at "(\\*") | |
7126 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
7127 (search-forward "*)") | |
7128 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point)))) | |
7129 (t (setq keywd (buffer-substring-no-properties | |
7130 (point) | |
7131 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
7132 (forward-char 1)) | |
7133 (point))) | |
7134 sig-last-tolk sig-tolk | |
7135 sig-tolk nil) | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7136 ;;(if dbg (setq dbg (concat dbg (format "\tPt=%S %S\trv=%S in=%S ee=%S gs=%S\n" (point) keywd rvalue ignore-next end-else-check got-sig)))) |
79545 | 7137 (cond |
7138 ((equal keywd "\"") | |
7139 (or (re-search-forward "[^\\]\"" nil t) | |
7140 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point)))) | |
7141 ;; else at top level loop, keep parsing | |
7142 ((and end-else-check (equal keywd "else")) | |
7143 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd)))) | |
7144 ;; no forward movement, want to see else in lower loop | |
7145 (setq end-else-check nil)) | |
7146 ;; End at top level loop | |
7147 ((and end-else-check (looking-at "[^ \t\n\f]")) | |
7148 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd)))) | |
7149 (setq gotend t)) | |
7150 ;; Final statement? | |
7151 ((and exit-keywd (equal keywd exit-keywd)) | |
7152 (setq gotend t) | |
7153 (forward-char (length keywd))) | |
7154 ;; Standard tokens... | |
7155 ((equal keywd ";") | |
7156 (setq ignore-next nil rvalue semi-rvalue) | |
7157 ;; Final statement at top level loop? | |
7158 (when (not exit-keywd) | |
7159 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd)))) | |
7160 (setq end-else-check t)) | |
7161 (forward-char 1)) | |
7162 ((equal keywd "'") | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7163 (if (looking-at "'[sS]?[hdxboHDXBO]?[ \t]*[0-9a-fA-F_xzXZ?]+") |
79545 | 7164 (goto-char (match-end 0)) |
7165 (forward-char 1))) | |
7166 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z | |
7167 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next | |
7168 (setq ignore-next nil rvalue nil)) | |
7169 ((equal "?" exit-keywd) ;; x?y:z rvalue | |
7170 ) ;; NOP | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7171 ((equal "]" exit-keywd) ;; [x:y] rvalue |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7172 ) ;; NOP |
79545 | 7173 (got-sig ;; label: statement |
7174 (setq ignore-next nil rvalue semi-rvalue got-sig nil)) | |
7175 ((not rvalue) ;; begin label | |
7176 (setq ignore-next t rvalue nil))) | |
7177 (forward-char 1)) | |
7178 ((equal keywd "=") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7179 (if (and (eq (char-before) ?< ) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7180 (not rvalue)) |
79545 | 7181 (setq uses-delayed 1)) |
7182 (setq ignore-next nil rvalue t) | |
7183 (forward-char 1)) | |
7184 ((equal keywd "?") | |
7185 (forward-char 1) | |
7186 (verilog-read-always-signals-recurse ":" rvalue nil)) | |
7187 ((equal keywd "[") | |
7188 (forward-char 1) | |
7189 (verilog-read-always-signals-recurse "]" t nil)) | |
7190 ((equal keywd "(") | |
7191 (forward-char 1) | |
7192 (cond (sig-last-tolk ;; Function call; zap last signal | |
7193 (setq got-sig nil))) | |
7194 (cond ((equal last-keywd "for") | |
7195 (verilog-read-always-signals-recurse ";" nil nil) | |
7196 (verilog-read-always-signals-recurse ";" t nil) | |
7197 (verilog-read-always-signals-recurse ")" nil nil)) | |
7198 (t (verilog-read-always-signals-recurse ")" t nil)))) | |
7199 ((equal keywd "begin") | |
7200 (skip-syntax-forward "w_") | |
7201 (verilog-read-always-signals-recurse "end" nil nil) | |
7202 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd)))) | |
7203 (setq ignore-next nil rvalue semi-rvalue) | |
7204 (if (not exit-keywd) (setq end-else-check t))) | |
7205 ((or (equal keywd "case") | |
7206 (equal keywd "casex") | |
7207 (equal keywd "casez")) | |
7208 (skip-syntax-forward "w_") | |
7209 (verilog-read-always-signals-recurse "endcase" t nil) | |
7210 (setq ignore-next nil rvalue semi-rvalue) | |
7211 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end | |
7212 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent | |
7213 (cond ((or (equal keywd "`ifdef") | |
7214 (equal keywd "`ifndef")) | |
7215 (setq ignore-next t)) | |
7216 ((or ignore-next | |
7217 (member keywd verilog-keywords) | |
7218 (string-match "^\\$" keywd)) ;; PLI task | |
7219 (setq ignore-next nil)) | |
7220 (t | |
7221 (setq keywd (verilog-symbol-detick-denumber keywd)) | |
7222 (when got-sig | |
7223 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
7224 (setq sigs-out (cons got-sig sigs-out))) | |
7225 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
7226 ) | |
7227 (setq got-rvalue rvalue | |
7228 got-sig (if (or (not keywd) | |
7229 (assoc keywd (if got-rvalue sigs-in sigs-out))) | |
7230 nil (list keywd nil nil)) | |
7231 sig-tolk t))) | |
7232 (skip-chars-forward "a-zA-Z0-9$_.%`")) | |
7233 (t | |
7234 (forward-char 1))) | |
7235 ;; End of non-comment token | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7236 (setq last-keywd keywd))) |
79545 | 7237 (skip-syntax-forward " ")) |
7238 ;; Append the final pending signal | |
7239 (when got-sig | |
7240 (if got-rvalue (setq sigs-in (cons got-sig sigs-in)) | |
7241 (setq sigs-out (cons got-sig sigs-out))) | |
7242 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue)))) | |
7243 (setq got-sig nil)) | |
7244 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd)))) | |
7245 )) | |
7246 | |
7247 (defun verilog-read-always-signals () | |
7248 "Parse always block at point and return list of (outputs inout inputs)." | |
7249 ;; Insert new | |
7250 (save-excursion | |
7251 (let* (;;(dbg "") | |
7252 sigs-in sigs-out | |
7253 uses-delayed) ;; Found signal/rvalue; push if not function | |
7254 (search-forward ")") | |
7255 (verilog-read-always-signals-recurse nil nil nil) | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7256 ;;(if dbg (with-current-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg "")) |
79545 | 7257 ;; Return what was found |
7258 (list sigs-out nil sigs-in uses-delayed)))) | |
7259 | |
7260 (defun verilog-read-instants () | |
7261 "Parse module at point and return list of ( ( file instance ) ... )." | |
7262 (verilog-beg-of-defun) | |
7263 (let* ((end-mod-point (verilog-get-end-of-defun t)) | |
7264 (state nil) | |
7265 (instants-list nil)) | |
7266 (save-excursion | |
7267 (while (< (point) end-mod-point) | |
7268 ;; Stay at level 0, no comments | |
7269 (while (progn | |
7270 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil)) | |
7271 (or (> (car state) 0) ; in parens | |
7272 (nth 5 state) ; comment | |
7273 )) | |
7274 (forward-line 1)) | |
7275 (beginning-of-line) | |
7276 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(") | |
7277 ;;(if (looking-at "^\\(.+\\)$") | |
7278 (let ((module (match-string 1)) | |
7279 (instant (match-string 2))) | |
7280 (if (not (member module verilog-keywords)) | |
7281 (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
|
7282 (forward-line 1))) |
79545 | 7283 instants-list)) |
7284 | |
7285 | |
7286 (defun verilog-read-auto-template (module) | |
7287 "Look for a auto_template for the instantiation of the given MODULE. | |
7288 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
|
7289 list of ( (signal_name connection_name)... )." |
79545 | 7290 (save-excursion |
7291 ;; Find beginning | |
7292 (let ((tpl-regexp "\\([0-9]+\\)") | |
7293 (lineno 0) | |
7294 (templateno 0) | |
7295 tpl-sig-list tpl-wild-list tpl-end-pt rep) | |
7296 (cond ((or | |
7297 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t) | |
7298 (progn | |
7299 (goto-char (point-min)) | |
7300 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t))) | |
7301 (goto-char (match-end 0)) | |
7302 ;; Parse "REGEXP" | |
7303 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7304 (when (looking-at "\\s-*\"\\([^\"]*\\)\"") |
79545 | 7305 (setq tpl-regexp (match-string 1)) |
7306 (goto-char (match-end 0))) | |
7307 (search-forward "(") | |
7308 ;; Parse lines in the template | |
7309 (when verilog-auto-inst-template-numbers | |
7310 (save-excursion | |
7311 (goto-char (point-min)) | |
7312 (while (search-forward "AUTO_TEMPLATE" nil t) | |
7313 (setq templateno (1+ templateno))))) | |
7314 (setq tpl-end-pt (save-excursion | |
7315 (backward-char 1) | |
7316 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
7317 (backward-char 1) | |
7318 (point))) | |
7319 ;; | |
7320 (while (< (point) tpl-end-pt) | |
7321 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") | |
7322 (setq tpl-sig-list (cons (list | |
7323 (match-string-no-properties 1) | |
7324 (match-string-no-properties 2) | |
7325 templateno lineno) | |
7326 tpl-sig-list)) | |
7327 (goto-char (match-end 0))) | |
7328 ;; Regexp form?? | |
7329 ((looking-at | |
93066
f35f15ba549f
(verilog-syntax-ppss): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92692
diff
changeset
|
7330 ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last |
79545 | 7331 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)") |
7332 (setq rep (match-string-no-properties 3)) | |
7333 (goto-char (match-end 0)) | |
7334 (setq tpl-wild-list | |
7335 (cons (list | |
7336 (concat "^" | |
7337 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil | |
7338 (match-string 1)) | |
7339 "$") | |
7340 rep | |
7341 templateno lineno) | |
7342 tpl-wild-list))) | |
7343 ((looking-at "[ \t\f]+") | |
7344 (goto-char (match-end 0))) | |
7345 ((looking-at "\n") | |
7346 (setq lineno (1+ lineno)) | |
7347 (goto-char (match-end 0))) | |
7348 ((looking-at "//") | |
7349 (search-forward "\n")) | |
7350 ((looking-at "/\\*") | |
7351 (forward-char 2) | |
7352 (or (search-forward "*/") | |
7353 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point)))) | |
7354 (t | |
7355 (error "%s: AUTO_TEMPLATE parsing error: %s" | |
7356 (verilog-point-text) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7357 (progn (looking-at ".*$") (match-string 0)))))) |
79545 | 7358 ;; Return |
7359 (vector tpl-regexp | |
7360 (list tpl-sig-list tpl-wild-list))) | |
7361 ;; If no template found | |
7362 (t (vector tpl-regexp nil)))))) | |
7363 ;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry")) | |
7364 | |
7365 (defun verilog-set-define (defname defvalue &optional buffer enumname) | |
7366 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER. | |
7367 Optionally associate it with the specified enumeration ENUMNAME." | |
105813
df4934f25eef
* textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104774
diff
changeset
|
7368 (with-current-buffer (or buffer (current-buffer)) |
79545 | 7369 (let ((mac (intern (concat "vh-" defname)))) |
7370 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
7371 ;; Need to define to a constant if no value given | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7372 (set (make-local-variable mac) |
79545 | 7373 (if (equal defvalue "") "1" defvalue))) |
7374 (if enumname | |
7375 (let ((enumvar (intern (concat "venum-" enumname)))) | |
7376 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7377 (unless (boundp enumvar) (set enumvar nil)) |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7378 (make-local-variable enumvar) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7379 (add-to-list enumvar defname))))) |
79545 | 7380 |
7381 (defun verilog-read-defines (&optional filename recurse subcall) | |
7382 "Read `defines and parameters for the current file, or optional FILENAME. | |
7383 If the filename is provided, `verilog-library-flags' will be used to | |
7384 resolve it. If optional RECURSE is non-nil, recurse through `includes. | |
7385 | |
7386 Parameters must be simple assignments to constants, or have their own | |
7387 \"parameter\" label rather than a list of parameters. Thus: | |
7388 | |
7389 parameter X = 5, Y = 10; // Ok | |
7390 parameter X = {1'b1, 2'h2}; // Ok | |
7391 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines | |
7392 | |
7393 Defines must be simple text substitutions, one on a line, starting | |
7394 at the beginning of the line. Any ifdefs or multiline comments around the | |
7395 define are ignored. | |
7396 | |
7397 Defines are stored inside Emacs variables using the name vh-{definename}. | |
7398 | |
7399 This function is useful for setting vh-* variables. The file variables | |
7400 feature can be used to set defines that `verilog-mode' can see; put at the | |
7401 *END* of your file something like: | |
7402 | |
7403 // Local Variables: | |
7404 // vh-macro:\"macro_definition\" | |
7405 // End: | |
7406 | |
7407 If macros are defined earlier in the same file and you want their values, | |
7408 you can read them automatically (provided `enable-local-eval' is on): | |
7409 | |
7410 // Local Variables: | |
7411 // eval:(verilog-read-defines) | |
7412 // eval:(verilog-read-defines \"group_standard_includes.v\") | |
7413 // End: | |
7414 | |
7415 Note these are only read when the file is first visited, you must use | |
7416 \\[find-alternate-file] RET to have these take effect after editing them! | |
7417 | |
7418 If you want to disable the \"Process `eval' or hook local variables\" | |
7419 warning message, you need to add to your .emacs file: | |
7420 | |
7421 (setq enable-local-eval t)" | |
7422 (let ((origbuf (current-buffer))) | |
7423 (save-excursion | |
7424 (unless subcall (verilog-getopt-flags)) | |
7425 (when filename | |
7426 (let ((fns (verilog-library-filenames filename (buffer-file-name)))) | |
7427 (if fns | |
7428 (set-buffer (find-file-noselect (car fns))) | |
7429 (error (concat (verilog-point-text) | |
7430 ": Can't find verilog-read-defines file: " filename))))) | |
7431 (when recurse | |
7432 (goto-char (point-min)) | |
7433 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
7434 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1)))) | |
7435 (unless (verilog-inside-comment-p) | |
7436 (verilog-read-defines inc recurse t))))) | |
7437 ;; Read `defines | |
7438 ;; note we don't use verilog-re... it's faster this way, and that | |
7439 ;; function has problems when comments are at the end of the define | |
7440 (goto-char (point-min)) | |
7441 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t) | |
7442 (let ((defname (match-string-no-properties 1)) | |
7443 (defvalue (match-string-no-properties 2))) | |
7444 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue)) | |
7445 (verilog-set-define defname defvalue origbuf))) | |
7446 ;; Hack: Read parameters | |
7447 (goto-char (point-min)) | |
7448 (while (re-search-forward | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7449 "^\\s-*\\(parameter\\|localparam\\)\\(\\s-*\\[[^]]*\\]\\)?\\s-+" nil t) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7450 (let (enumname) |
79545 | 7451 ;; The primary way of getting defines is verilog-read-decls |
7452 ;; However, that isn't called yet for included files, so we'll add another scheme | |
7453 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)") | |
7454 (setq enumname (match-string-no-properties 1))) | |
7455 (forward-comment 999) | |
7456 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*") | |
7457 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname) | |
7458 (goto-char (match-end 0)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7459 (forward-comment 999))))))) |
79545 | 7460 |
7461 (defun verilog-read-includes () | |
7462 "Read `includes for the current file. | |
7463 This will find all of the `includes which are at the beginning of lines, | |
7464 ignoring any ifdefs or multiline comments around them. | |
7465 `verilog-read-defines' is then performed on the current and each included | |
7466 file. | |
7467 | |
7468 It is often useful put at the *END* of your file something like: | |
7469 | |
7470 // Local Variables: | |
7471 // eval:(verilog-read-defines) | |
7472 // eval:(verilog-read-includes) | |
7473 // End: | |
7474 | |
7475 Note includes are only read when the file is first visited, you must use | |
7476 \\[find-alternate-file] RET to have these take effect after editing them! | |
7477 | |
7478 It is good to get in the habit of including all needed files in each .v | |
7479 file that needs it, rather than waiting for compile time. This will aid | |
7480 this process, Verilint, and readability. To prevent defining the same | |
7481 variable over and over when many modules are compiled together, put a test | |
7482 around the inside each include file: | |
7483 | |
7484 foo.v (a include): | |
7485 `ifdef _FOO_V // include if not already included | |
7486 `else | |
7487 `define _FOO_V | |
7488 ... contents of file | |
7489 `endif // _FOO_V" | |
7490 ;;slow: (verilog-read-defines nil t)) | |
7491 (save-excursion | |
7492 (verilog-getopt-flags) | |
7493 (goto-char (point-min)) | |
7494 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t) | |
7495 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1)))) | |
7496 (verilog-read-defines inc nil t))))) | |
7497 | |
7498 (defun verilog-read-signals (&optional start end) | |
7499 "Return a simple list of all possible signals in the file. | |
7500 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
|
7501 Some macros and such are also found and included. For dinotrace.el." |
79545 | 7502 (let (sigs-all keywd) |
7503 (progn;save-excursion | |
7504 (goto-char (or start (point-min))) | |
7505 (setq end (or end (point-max))) | |
7506 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t) | |
7507 (forward-char -1) | |
7508 (cond | |
7509 ((looking-at "//") | |
7510 (search-forward "\n")) | |
7511 ((looking-at "/\\*") | |
7512 (search-forward "*/")) | |
7513 ((looking-at "(\\*") | |
7514 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)" | |
7515 (search-forward "*)"))) | |
7516 ((eq ?\" (following-char)) | |
7517 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first | |
7518 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)") | |
7519 (goto-char (match-end 0)) | |
7520 (setq keywd (match-string-no-properties 1)) | |
7521 (or (member keywd verilog-keywords) | |
7522 (member keywd sigs-all) | |
7523 (setq sigs-all (cons keywd sigs-all)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7524 (t (forward-char 1)))) |
79545 | 7525 ;; Return list |
7526 sigs-all))) | |
7527 | |
7528 ;; | |
7529 ;; Argument file parsing | |
7530 ;; | |
7531 | |
7532 (defun verilog-getopt (arglist) | |
7533 "Parse -f, -v etc arguments in ARGLIST list or string." | |
7534 (unless (listp arglist) (setq arglist (list arglist))) | |
7535 (let ((space-args '()) | |
7536 arg next-param) | |
7537 ;; Split on spaces, so users can pass whole command lines | |
7538 (while arglist | |
7539 (setq arg (car arglist) | |
7540 arglist (cdr arglist)) | |
7541 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg) | |
7542 (setq space-args (append space-args | |
7543 (list (match-string-no-properties 1 arg)))) | |
7544 (setq arg (match-string 2 arg)))) | |
7545 ;; Parse arguments | |
7546 (while space-args | |
7547 (setq arg (car space-args) | |
7548 space-args (cdr space-args)) | |
7549 (cond | |
7550 ;; Need another arg | |
7551 ((equal arg "-f") | |
7552 (setq next-param arg)) | |
7553 ((equal arg "-v") | |
7554 (setq next-param arg)) | |
7555 ((equal arg "-y") | |
7556 (setq next-param arg)) | |
7557 ;; +libext+(ext1)+(ext2)... | |
7558 ((string-match "^\\+libext\\+\\(.*\\)" arg) | |
7559 (setq arg (match-string 1 arg)) | |
7560 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg) | |
7561 (verilog-add-list-unique `verilog-library-extensions | |
7562 (match-string 1 arg)) | |
7563 (setq arg (match-string 2 arg)))) | |
7564 ;; | |
7565 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val | |
7566 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine | |
7567 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val | |
7568 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define | |
7569 (verilog-set-define (match-string 1 arg) (match-string 2 arg))) | |
7570 ;; | |
7571 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir | |
7572 (string-match "^-I\\(.*\\)" arg)) ;; -Idir | |
7573 (verilog-add-list-unique `verilog-library-directories | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7574 (match-string 1 (substitute-in-file-name arg)))) |
79545 | 7575 ;; Ignore |
7576 ((equal "+librescan" arg)) | |
7577 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine | |
7578 ;; Second parameters | |
7579 ((equal next-param "-f") | |
7580 (setq next-param nil) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7581 (verilog-getopt-file (substitute-in-file-name arg))) |
79545 | 7582 ((equal next-param "-v") |
7583 (setq next-param nil) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7584 (verilog-add-list-unique `verilog-library-files |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7585 (substitute-in-file-name arg))) |
79545 | 7586 ((equal next-param "-y") |
7587 (setq next-param nil) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7588 (verilog-add-list-unique `verilog-library-directories |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7589 (substitute-in-file-name arg))) |
79545 | 7590 ;; Filename |
7591 ((string-match "^[^-+]" arg) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7592 (verilog-add-list-unique `verilog-library-files |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7593 (substitute-in-file-name arg))) |
79545 | 7594 ;; Default - ignore; no warning |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7595 )))) |
79545 | 7596 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir")) |
7597 | |
7598 (defun verilog-getopt-file (filename) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7599 "Read Verilog options from the specified FILENAME." |
79545 | 7600 (save-excursion |
7601 (let ((fns (verilog-library-filenames filename (buffer-file-name))) | |
7602 (orig-buffer (current-buffer)) | |
7603 line) | |
7604 (if fns | |
7605 (set-buffer (find-file-noselect (car fns))) | |
7606 (error (concat (verilog-point-text) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7607 ": Can't find verilog-getopt-file -f file: " filename))) |
79545 | 7608 (goto-char (point-min)) |
7609 (while (not (eobp)) | |
7610 (setq line (buffer-substring (point) | |
7611 (save-excursion (end-of-line) (point)))) | |
7612 (forward-line 1) | |
7613 (when (string-match "//" line) | |
7614 (setq line (substring line 0 (match-beginning 0)))) | |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7615 (with-current-buffer orig-buffer ; Variables are buffer-local, so need right context. |
79545 | 7616 (verilog-getopt line)))))) |
7617 | |
7618 (defun verilog-getopt-flags () | |
7619 "Convert `verilog-library-flags' into standard library variables." | |
7620 ;; If the flags are local, then all the outputs should be local also | |
7621 (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
|
7622 (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
|
7623 verilog-library-directories |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7624 verilog-library-files |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7625 verilog-library-flags))) |
79545 | 7626 ;; Allow user to customize |
7627 (run-hooks 'verilog-before-getopt-flags-hook) | |
7628 ;; Process arguments | |
7629 (verilog-getopt verilog-library-flags) | |
7630 ;; Allow user to customize | |
7631 (run-hooks 'verilog-getopt-flags-hook)) | |
7632 | |
7633 (defun verilog-add-list-unique (varref object) | |
7634 "Append to VARREF list the given OBJECT, | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7635 unless it is already a member of the variable's list." |
79545 | 7636 (unless (member object (symbol-value varref)) |
7637 (set varref (append (symbol-value varref) (list object)))) | |
7638 varref) | |
7639 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l) | |
7640 | |
7641 | |
7642 ;; | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7643 ;; Cached directory support |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7644 ;; |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7645 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7646 (defvar verilog-dir-cache-preserving nil |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7647 "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
|
7648 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
|
7649 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7650 ;; 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
|
7651 (defvar verilog-dir-cache-list nil |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7652 "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
|
7653 (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
|
7654 "Cached data for `verilog-library-filenames'.") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7655 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7656 (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
|
7657 "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
|
7658 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
|
7659 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
|
7660 `(let ((verilog-dir-cache-preserving t) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7661 verilog-dir-cache-list |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7662 verilog-dir-cache-lib-filenames) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7663 (progn ,@body))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7664 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7665 (defun verilog-dir-files (dirname) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7666 "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
|
7667 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
|
7668 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
|
7669 (unless verilog-dir-cache-preserving |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7670 (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
|
7671 ;; 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
|
7672 (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
|
7673 (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
|
7674 exp-dirname data) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7675 (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
|
7676 (nth 1 fass)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7677 (t |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7678 (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
|
7679 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
|
7680 (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
|
7681 ;; 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
|
7682 (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
|
7683 verilog-dir-cache-list)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7684 data)))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7685 ;; Miss-and-hit test: |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7686 ;;(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
|
7687 ;; (prin1 (verilog-dir-files ".")) nil) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7688 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7689 (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
|
7690 "Return true if FILENAME exists. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7691 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
|
7692 `verilog-preserve-dir-cache'." |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7693 (let* ((dirname (file-name-directory filename)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7694 ;; 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
|
7695 (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
|
7696 default-directory dirname)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7697 (flist (verilog-dir-files dirnamed))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7698 (and flist |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7699 (member (file-name-nondirectory filename) flist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7700 t))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7701 ;;(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
|
7702 ;;(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
|
7703 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7704 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7705 ;; |
79545 | 7706 ;; Module name lookup |
7707 ;; | |
7708 | |
7709 (defun verilog-module-inside-filename-p (module filename) | |
7710 "Return point if MODULE is specified inside FILENAME, else nil. | |
7711 Allows version control to check out the file if need be." | |
7712 (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
|
7713 (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
|
7714 (vc-backend filename))) |
79545 | 7715 (let (pt) |
105813
df4934f25eef
* textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
104774
diff
changeset
|
7716 (with-current-buffer (find-file-noselect filename) |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7717 (save-excursion |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7718 (goto-char (point-min)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7719 (while (and |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7720 ;; It may be tempting to look for verilog-defun-re, |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7721 ;; don't, it slows things down a lot! |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7722 (verilog-re-search-forward-quick "\\<module\\>" nil t) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7723 (verilog-re-search-forward-quick "[(;]" nil t)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7724 (if (equal module (verilog-read-module-name)) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7725 (setq pt (point)))) |
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
7726 pt))))) |
79545 | 7727 |
7728 (defun verilog-is-number (symbol) | |
7729 "Return true if SYMBOL is number-like." | |
7730 (or (string-match "^[0-9 \t:]+$" symbol) | |
7731 (string-match "^[---]*[0-9]+$" symbol) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7732 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol))) |
79545 | 7733 |
7734 (defun verilog-symbol-detick (symbol wing-it) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7735 "Return an expanded SYMBOL name without any defines. |
79545 | 7736 If the variable vh-{symbol} is defined, return that value. |
7737 If undefined, and WING-IT, return just SYMBOL without the tick, else nil." | |
7738 (while (and symbol (string-match "^`" symbol)) | |
7739 (setq symbol (substring symbol 1)) | |
7740 (setq symbol | |
7741 (if (boundp (intern (concat "vh-" symbol))) | |
7742 ;; Emacs has a bug where boundp on a buffer-local | |
7743 ;; variable in only one buffer returns t in another. | |
7744 ;; This can confuse, so check for nil. | |
7745 (let ((val (eval (intern (concat "vh-" symbol))))) | |
7746 (if (eq val nil) | |
7747 (if wing-it symbol nil) | |
7748 val)) | |
7749 (if wing-it symbol nil)))) | |
7750 symbol) | |
7751 ;;(verilog-symbol-detick "`mod" nil) | |
7752 | |
7753 (defun verilog-symbol-detick-denumber (symbol) | |
7754 "Return SYMBOL with defines converted and any numbers dropped to nil." | |
7755 (when (string-match "^`" symbol) | |
7756 ;; This only will work if the define is a simple signal, not | |
7757 ;; something like a[b]. Sorry, it should be substituted into the parser | |
7758 (setq symbol | |
7759 (verilog-string-replace-matches | |
7760 "\[[^0-9: \t]+\]" "" nil nil | |
7761 (or (verilog-symbol-detick symbol nil) | |
7762 (if verilog-auto-sense-defines-constant | |
7763 "0" | |
7764 symbol))))) | |
7765 (if (verilog-is-number symbol) | |
7766 nil | |
7767 symbol)) | |
7768 | |
7769 (defun verilog-symbol-detick-text (text) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7770 "Return TEXT without any known defines. |
79545 | 7771 If the variable vh-{symbol} is defined, substitute that value." |
7772 (let ((ok t) symbol val) | |
7773 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text)) | |
7774 (setq symbol (match-string 1 text)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
7775 ;;(message symbol) |
79545 | 7776 (cond ((and |
7777 (boundp (intern (concat "vh-" symbol))) | |
7778 ;; Emacs has a bug where boundp on a buffer-local | |
7779 ;; variable in only one buffer returns t in another. | |
7780 ;; This can confuse, so check for nil. | |
7781 (setq val (eval (intern (concat "vh-" symbol))))) | |
7782 (setq text (replace-match val nil nil text))) | |
7783 (t (setq ok nil))))) | |
7784 text) | |
7785 ;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed")) | |
7786 | |
7787 (defun verilog-expand-dirnames (&optional dirnames) | |
7788 "Return a list of existing directories given a list of wildcarded DIRNAMES. | |
7789 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
|
7790 ;; Note this function is performance critical. |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7791 ;; Do not call anything that requires disk access that cannot be cached. |
79545 | 7792 (interactive) |
7793 (unless dirnames (error "`verilog-library-directories' should include at least '.'")) | |
7794 (setq dirnames (reverse dirnames)) ; not nreverse | |
7795 (let ((dirlist nil) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7796 pattern dirfile dirfiles dirname root filename rest basefile) |
79545 | 7797 (while dirnames |
7798 (setq dirname (substitute-in-file-name (car dirnames)) | |
7799 dirnames (cdr dirnames)) | |
7800 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root | |
7801 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *? | |
7802 "\\(.*\\)") ;; rest | |
7803 dirname) | |
7804 (setq root (match-string 1 dirname) | |
7805 filename (match-string 2 dirname) | |
7806 rest (match-string 3 dirname) | |
7807 pattern filename) | |
7808 ;; now replace those * and ? with .+ and . | |
7809 ;; use ^ and /> to get only whole file names | |
7810 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern) | |
7811 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
|
7812 pattern (concat "^" pattern "$") |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7813 dirfiles (verilog-dir-files root)) |
79545 | 7814 (while dirfiles |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7815 (setq basefile (car dirfiles) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7816 dirfile (expand-file-name (concat root basefile rest)) |
79545 | 7817 dirfiles (cdr dirfiles)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7818 (if (and (string-match pattern basefile) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7819 ;; 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
|
7820 (not (equal basefile ".")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7821 (not (equal basefile "..")) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7822 (file-directory-p dirfile)) |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7823 (setq dirlist (cons dirfile dirlist))))) |
79545 | 7824 ;; Defaults |
7825 (t | |
7826 (if (file-directory-p dirname) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7827 (setq dirlist (cons dirname dirlist)))))) |
79545 | 7828 dirlist)) |
7829 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v")) | |
7830 | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7831 (defun verilog-library-filenames (filename &optional current check-ext) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7832 "Return a search path to find the given FILENAME or module name. |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7833 Uses the optional CURRENT filename or buffer-file-name, plus |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7834 `verilog-library-directories' and `verilog-library-extensions' |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7835 variables to build the path. With optional CHECK-EXT also check |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7836 `verilog-library-extensions'." |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
7837 (unless current (setq current (buffer-file-name))) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7838 (unless verilog-dir-cache-preserving |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7839 (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
|
7840 (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
|
7841 (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
|
7842 chkdirs chkdir chkexts fn outlist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7843 (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
|
7844 (nth 1 fass)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7845 (t |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7846 ;; 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
|
7847 ;; 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
|
7848 (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
|
7849 (while chkdirs |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7850 (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
|
7851 (file-name-directory current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7852 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
|
7853 (while chkexts |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7854 (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
|
7855 chkdir)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7856 ;;(message "Check for %s" fn) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7857 (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
|
7858 (setq outlist (cons (expand-file-name |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7859 fn (file-name-directory current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7860 outlist))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7861 (setq chkexts (cdr chkexts))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7862 (setq chkdirs (cdr chkdirs))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7863 (setq outlist (nreverse outlist)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7864 (setq verilog-dir-cache-lib-filenames |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7865 (cons (list cache-key outlist) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7866 verilog-dir-cache-lib-filenames)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7867 outlist)))) |
79545 | 7868 |
7869 (defun verilog-module-filenames (module current) | |
7870 "Return a search path to find the given MODULE name. | |
7871 Uses the CURRENT filename, `verilog-library-extensions', | |
7872 `verilog-library-directories' and `verilog-library-files' | |
7873 variables to build the path." | |
7874 ;; Return search locations for it | |
7875 (append (list current) ; first, current buffer | |
7876 (verilog-library-filenames module current t) | |
7877 verilog-library-files)) ; finally, any libraries | |
7878 | |
7879 ;; | |
7880 ;; Module Information | |
7881 ;; | |
7882 ;; Many of these functions work on "modi" a module information structure | |
7883 ;; A modi is: [module-name-string file-name begin-point] | |
7884 | |
7885 (defvar verilog-cache-enabled t | |
7886 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!") | |
7887 | |
7888 (defvar verilog-modi-cache-list nil | |
7889 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)... | |
7890 For speeding up verilog-modi-get-* commands. | |
7891 Buffer-local.") | |
7892 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
7893 (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
|
7894 |
79545 | 7895 (defvar verilog-modi-cache-preserve-tick nil |
7896 "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
|
7897 Use `verilog-preserve-modi-cache' to set it.") |
79545 | 7898 (defvar verilog-modi-cache-preserve-buffer nil |
7899 "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
|
7900 Use `verilog-preserve-modi-cache' to set it.") |
79545 | 7901 |
7902 (defun verilog-modi-current () | |
7903 "Return the modi structure for the module currently at point." | |
7904 (let* (name pt) | |
7905 ;; read current module's name | |
7906 (save-excursion | |
7907 (verilog-re-search-backward-quick verilog-defun-re nil nil) | |
7908 (verilog-re-search-forward-quick "(" nil nil) | |
7909 (setq name (verilog-read-module-name)) | |
7910 (setq pt (point))) | |
7911 ;; return | |
7912 (vector name (or (buffer-file-name) (current-buffer)) pt))) | |
7913 | |
7914 (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.") | |
7915 (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.") | |
7916 (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.") | |
7917 (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.") | |
7918 | |
7919 (defun verilog-modi-lookup (module allow-cache &optional ignore-error) | |
7920 "Find the file and point at which MODULE is defined. | |
7921 If ALLOW-CACHE is set, check and remember cache of previous lookups. | |
7922 Return modi if successful, else print message unless IGNORE-ERROR is true." | |
7923 (let* ((current (or (buffer-file-name) (current-buffer)))) | |
7924 (cond ((and verilog-modi-lookup-last-modi | |
7925 verilog-cache-enabled | |
7926 allow-cache | |
7927 (equal verilog-modi-lookup-last-mod module) | |
7928 (equal verilog-modi-lookup-last-current current) | |
7929 (equal verilog-modi-lookup-last-tick (buffer-modified-tick))) | |
7930 ;; ok as is | |
7931 ) | |
7932 (t (let* ((realmod (verilog-symbol-detick module t)) | |
7933 (orig-filenames (verilog-module-filenames realmod current)) | |
7934 (filenames orig-filenames) | |
7935 pt) | |
7936 (while (and filenames (not pt)) | |
7937 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames)))) | |
7938 (setq filenames (cdr filenames)))) | |
7939 (cond (pt (setq verilog-modi-lookup-last-modi | |
7940 (vector realmod (car filenames) pt))) | |
7941 (t (setq verilog-modi-lookup-last-modi nil) | |
7942 (or ignore-error | |
7943 (error (concat (verilog-point-text) | |
7944 ": Can't locate " module " module definition" | |
7945 (if (not (equal module realmod)) | |
7946 (concat " (Expanded macro to " realmod ")") | |
7947 "") | |
7948 "\n Check the verilog-library-directories variable." | |
7949 "\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
|
7950 (mapconcat 'concat orig-filenames "\n\t")))))) |
79545 | 7951 (setq verilog-modi-lookup-last-mod module |
7952 verilog-modi-lookup-last-current current | |
7953 verilog-modi-lookup-last-tick (buffer-modified-tick))))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
7954 verilog-modi-lookup-last-modi)) |
79545 | 7955 |
7956 (defsubst verilog-modi-name (modi) | |
7957 (aref modi 0)) | |
7958 (defsubst verilog-modi-file-or-buffer (modi) | |
7959 (aref modi 1)) | |
7960 (defsubst verilog-modi-point (modi) | |
7961 (aref modi 2)) | |
7962 | |
7963 (defun verilog-modi-filename (modi) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
7964 "Filename of MODI, or name of buffer if it's never been saved." |
79545 | 7965 (if (bufferp (verilog-modi-file-or-buffer modi)) |
7966 (or (buffer-file-name (verilog-modi-file-or-buffer modi)) | |
7967 (buffer-name (verilog-modi-file-or-buffer modi))) | |
7968 (verilog-modi-file-or-buffer modi))) | |
7969 | |
7970 (defun verilog-modi-goto (modi) | |
7971 "Move point/buffer to specified MODI." | |
7972 (or modi (error "Passed unfound modi to goto, check earlier")) | |
7973 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi)) | |
7974 (verilog-modi-file-or-buffer modi) | |
7975 (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
|
7976 (or (equal major-mode `verilog-mode) ;; Put into Verilog mode to get syntax |
79545 | 7977 (verilog-mode)) |
7978 (goto-char (verilog-modi-point modi))) | |
7979 | |
7980 (defun verilog-goto-defun-file (module) | |
7981 "Move point to the file at which a given MODULE is defined." | |
7982 (interactive "sGoto File for Module: ") | |
7983 (let* ((modi (verilog-modi-lookup module nil))) | |
7984 (when modi | |
7985 (verilog-modi-goto modi) | |
7986 (switch-to-buffer (current-buffer))))) | |
7987 | |
7988 (defun verilog-modi-cache-results (modi function) | |
7989 "Run on MODI the given FUNCTION. Locate the module in a file. | |
7990 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
|
7991 (let (fass) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7992 (save-excursion ;; Cache is buffer-local so can't avoid this. |
79545 | 7993 (verilog-modi-goto modi) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
7994 (if (and (setq fass (assoc (list modi function) |
79545 | 7995 verilog-modi-cache-list)) |
7996 ;; Destroy caching when incorrect; Modified or file changed | |
7997 (not (and verilog-cache-enabled | |
7998 (or (equal (buffer-modified-tick) (nth 1 fass)) | |
7999 (and verilog-modi-cache-preserve-tick | |
8000 (<= verilog-modi-cache-preserve-tick (nth 1 fass)) | |
8001 (equal verilog-modi-cache-preserve-buffer (current-buffer)))) | |
8002 (equal (visited-file-modtime) (nth 2 fass))))) | |
8003 (setq verilog-modi-cache-list nil | |
8004 fass nil)) | |
8005 (cond (fass | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8006 ;; Return data from cache hit |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8007 (nth 3 fass)) |
79545 | 8008 (t |
8009 ;; Read from file | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
8010 ;; Clear then restore any highlighting to make emacs19 happy |
79545 | 8011 (let ((fontlocked (when (and (boundp 'font-lock-mode) |
8012 font-lock-mode) | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8013 (font-lock-mode 0) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8014 t)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8015 func-returns) |
79545 | 8016 (setq func-returns (funcall function)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8017 (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
|
8018 ;; Cache for next time |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8019 (setq verilog-modi-cache-list |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8020 (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
|
8021 (buffer-modified-tick) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8022 (visited-file-modtime) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8023 func-returns) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8024 verilog-modi-cache-list)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8025 func-returns)))))) |
79545 | 8026 |
8027 (defun verilog-modi-cache-add (modi function element sig-list) | |
8028 "Add function return results to the module cache. | |
8029 Update MODI's cache for given FUNCTION so that the return ELEMENT of that | |
8030 function now contains the additional SIG-LIST parameters." | |
8031 (let (fass) | |
8032 (save-excursion | |
8033 (verilog-modi-goto modi) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8034 (if (setq fass (assoc (list modi function) |
79545 | 8035 verilog-modi-cache-list)) |
8036 (let ((func-returns (nth 3 fass))) | |
8037 (aset func-returns element | |
8038 (append sig-list (aref func-returns element)))))))) | |
8039 | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8040 (defmacro verilog-preserve-modi-cache (&rest body) |
79545 | 8041 "Execute the BODY forms, allowing cache preservation within BODY. |
8042 This means that changes to the buffer will not result in the cache being | |
8043 flushed. If the changes affect the modsig state, they must call the | |
8044 modsig-cache-add-* function, else the results of later calls may be | |
8045 incorrect. Without this, changes are assumed to be adding/removing signals | |
8046 and invalidating the cache." | |
8047 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick)) | |
8048 (verilog-modi-cache-preserve-buffer (current-buffer))) | |
8049 (progn ,@body))) | |
8050 | |
8051 | |
8052 (defun verilog-signals-matching-enum (in-list enum) | |
8053 "Return all signals in IN-LIST matching the given ENUM." | |
8054 (let (out-list) | |
8055 (while in-list | |
8056 (if (equal (verilog-sig-enum (car in-list)) enum) | |
8057 (setq out-list (cons (car in-list) out-list))) | |
8058 (setq in-list (cdr in-list))) | |
8059 ;; New scheme | |
8060 (let* ((enumvar (intern (concat "venum-" enum))) | |
8061 (enumlist (and (boundp enumvar) (eval enumvar)))) | |
8062 (while enumlist | |
8063 (add-to-list 'out-list (list (car enumlist))) | |
8064 (setq enumlist (cdr enumlist)))) | |
8065 (nreverse out-list))) | |
8066 | |
93195 | 8067 (defun verilog-signals-matching-regexp (in-list regexp) |
8068 "Return all signals in IN-LIST matching the given REGEXP, if non-nil." | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8069 (if (or (not regexp) (equal regexp "")) |
93195 | 8070 in-list |
8071 (let (out-list) | |
8072 (while in-list | |
8073 (if (string-match regexp (verilog-sig-name (car in-list))) | |
8074 (setq out-list (cons (car in-list) out-list))) | |
8075 (setq in-list (cdr in-list))) | |
8076 (nreverse out-list)))) | |
8077 | |
79545 | 8078 (defun verilog-signals-not-matching-regexp (in-list regexp) |
8079 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8080 (if (or (not regexp) (equal regexp "")) |
79545 | 8081 in-list |
8082 (let (out-list) | |
8083 (while in-list | |
8084 (if (not (string-match regexp (verilog-sig-name (car in-list)))) | |
8085 (setq out-list (cons (car in-list) out-list))) | |
8086 (setq in-list (cdr in-list))) | |
8087 (nreverse out-list)))) | |
8088 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8089 (defun verilog-signals-matching-dir-re (in-list decl-type regexp) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8090 "Return all signals in IN-LIST matching the given DECL-TYPE and REGEXP, |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8091 if non-nil." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8092 (if (or (not regexp) (equal regexp "")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8093 in-list |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8094 (let (out-list to-match) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8095 (while in-list |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8096 ;; Note verilog-insert-one-definition matches on this order |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8097 (setq to-match (concat |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8098 decl-type |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8099 " " (verilog-sig-signed (car in-list)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8100 " " (verilog-sig-multidim (car in-list)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8101 (verilog-sig-bits (car in-list)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8102 (if (string-match regexp to-match) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8103 (setq out-list (cons (car in-list) out-list))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8104 (setq in-list (cdr in-list))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8105 (nreverse out-list)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8106 |
79545 | 8107 ;; Combined |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8108 (defun verilog-decls-get-signals (decls) |
79545 | 8109 (append |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8110 (verilog-decls-get-outputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8111 (verilog-decls-get-inouts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8112 (verilog-decls-get-inputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8113 (verilog-decls-get-wires decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8114 (verilog-decls-get-regs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8115 (verilog-decls-get-assigns decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8116 (verilog-decls-get-consts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8117 (verilog-decls-get-gparams decls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8118 |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8119 (defun verilog-decls-get-ports (decls) |
79545 | 8120 (append |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8121 (verilog-decls-get-outputs decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8122 (verilog-decls-get-inouts decls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8123 (verilog-decls-get-inputs decls))) |
79545 | 8124 |
8125 (defsubst verilog-modi-cache-add-outputs (modi sig-list) | |
8126 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list)) | |
8127 (defsubst verilog-modi-cache-add-inouts (modi sig-list) | |
8128 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list)) | |
8129 (defsubst verilog-modi-cache-add-inputs (modi sig-list) | |
8130 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list)) | |
8131 (defsubst verilog-modi-cache-add-wires (modi sig-list) | |
8132 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list)) | |
8133 (defsubst verilog-modi-cache-add-regs (modi sig-list) | |
8134 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list)) | |
8135 | |
8136 (defun verilog-signals-from-signame (signame-list) | |
8137 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names." | |
8138 (mapcar (function (lambda (name) (list name nil nil))) | |
8139 signame-list)) | |
8140 | |
8141 ;; | |
8142 ;; Auto creation utilities | |
8143 ;; | |
8144 | |
93095
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
8145 (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
|
8146 "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
|
8147 (goto-char (point-min)) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
8148 (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
|
8149 (funcall func))) |
c67e7bd43423
(verilog-easy-menu-filter): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93066
diff
changeset
|
8150 |
79545 | 8151 (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
|
8152 "Print out a definition for SIG of the given TYPE, |
79545 | 8153 with appropriate INDENT-PT indentation." |
8154 (indent-to indent-pt) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8155 ;; Note verilog-signals-matching-dir-re matches on this order |
79545 | 8156 (insert type) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8157 (when (verilog-sig-modport sig) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8158 (insert "." (verilog-sig-modport sig))) |
79545 | 8159 (when (verilog-sig-signed sig) |
8160 (insert " " (verilog-sig-signed sig))) | |
8161 (when (verilog-sig-multidim sig) | |
8162 (insert " " (verilog-sig-multidim-string sig))) | |
8163 (when (verilog-sig-bits sig) | |
8164 (insert " " (verilog-sig-bits sig))) | |
8165 (indent-to (max 24 (+ indent-pt 16))) | |
8166 (unless (= (char-syntax (preceding-char)) ?\ ) | |
8167 (insert " ")) ; Need space between "]name" if indent-to did nothing | |
8168 (insert (verilog-sig-name sig))) | |
8169 | |
8170 (defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort) | |
8171 "Print out a definition for a list of SIGS of the given DIRECTION, | |
8172 with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O | |
8173 format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output." | |
8174 (or dont-sort | |
8175 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) | |
8176 (while sigs | |
8177 (let ((sig (car sigs))) | |
8178 (verilog-insert-one-definition | |
8179 sig | |
8180 ;; Want "type x" or "output type x", not "wire type x" | |
8181 (cond ((verilog-sig-type sig) | |
8182 (concat | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8183 (if (not (member direction '("wire" "interface"))) |
79545 | 8184 (concat direction " ")) |
8185 (verilog-sig-type sig))) | |
8186 (t direction)) | |
8187 indent-pt) | |
8188 (insert (if v2k "," ";")) | |
8189 (if (or (not (verilog-sig-comment sig)) | |
8190 (equal "" (verilog-sig-comment sig))) | |
8191 (insert "\n") | |
8192 (indent-to (max 48 (+ indent-pt 40))) | |
8193 (insert (concat "// " (verilog-sig-comment sig) "\n"))) | |
8194 (setq sigs (cdr sigs))))) | |
8195 | |
8196 (eval-when-compile | |
8197 (if (not (boundp 'indent-pt)) | |
8198 (defvar indent-pt nil "Local used by insert-indent"))) | |
8199 | |
8200 (defun verilog-insert-indent (&rest stuff) | |
8201 "Indent to position stored in local `indent-pt' variable, then insert STUFF. | |
8202 Presumes that any newlines end a list element." | |
8203 (let ((need-indent t)) | |
8204 (while stuff | |
8205 (if need-indent (indent-to indent-pt)) | |
8206 (setq need-indent nil) | |
8207 (insert (car stuff)) | |
8208 (setq need-indent (string-match "\n$" (car stuff)) | |
8209 stuff (cdr stuff))))) | |
8210 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n")) | |
8211 | |
8212 (defun verilog-repair-open-comma () | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8213 "Insert comma if previous argument is other than a open parenthesis or endif." |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8214 ;; We can't just search backward for ) as it might be inside another expression. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8215 ;; Also want "`ifdef X input foo `endif" to just leave things to the human to deal with |
79545 | 8216 (save-excursion |
8217 (verilog-backward-syntactic-ws) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8218 (when (and (not (save-excursion ;; Not beginning (, or existing , |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8219 (backward-char 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8220 (looking-at "[(,]"))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8221 (not (save-excursion ;; Not `endif, or user define |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8222 (backward-char 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8223 (skip-chars-backward "[a-zA-Z0-9_`]") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8224 (looking-at "`")))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8225 (insert ",")))) |
79545 | 8226 |
8227 (defun verilog-repair-close-comma () | |
8228 "If point is at a comma followed by a close parenthesis, fix it. | |
8229 This repairs those mis-inserted by a AUTOARG." | |
8230 ;; It would be much nicer if Verilog allowed extra commas like Perl does! | |
8231 (save-excursion | |
8232 (verilog-forward-close-paren) | |
8233 (backward-char 1) | |
8234 (verilog-backward-syntactic-ws) | |
8235 (backward-char 1) | |
8236 (when (looking-at ",") | |
8237 (delete-char 1)))) | |
8238 | |
8239 (defun verilog-get-list (start end) | |
8240 "Return the elements of a comma separated list between START and END." | |
8241 (interactive) | |
8242 (let ((my-list (list)) | |
8243 my-string) | |
8244 (save-excursion | |
8245 (while (< (point) end) | |
8246 (when (re-search-forward "\\([^,{]+\\)" end t) | |
8247 (setq my-string (verilog-string-remove-spaces (match-string 1))) | |
8248 (setq my-list (nconc my-list (list my-string) )) | |
8249 (goto-char (match-end 0)))) | |
8250 my-list))) | |
8251 | |
8252 (defun verilog-make-width-expression (range-exp) | |
8253 "Return an expression calculating the length of a range [x:y] in RANGE-EXP." | |
8254 ;; strip off the [] | |
8255 (cond ((not range-exp) | |
8256 "1") | |
8257 (t | |
8258 (if (string-match "^\\[\\(.*\\)\\]$" range-exp) | |
8259 (setq range-exp (match-string 1 range-exp))) | |
8260 (cond ((not range-exp) | |
8261 "1") | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8262 ;; [#:#] We can compute a numeric result |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8263 ((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
|
8264 range-exp) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8265 (int-to-string |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
8266 (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
|
8267 (string-to-number (match-string 2 range-exp))))))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8268 ;; [PARAM-1:0] can just return PARAM |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8269 ((string-match "^\\s *\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\s *-\\s *1\\s *:\\s *0\\s *$" range-exp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8270 (match-string 1 range-exp)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8271 ;; [arbitrary] need math |
79545 | 8272 ((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
|
8273 (concat "(1+(" (match-string 1 range-exp) ")" |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8274 (if (equal "0" (match-string 2 range-exp)) |
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8275 "" ;; Don't bother with -(0) |
79545 | 8276 (concat "-(" (match-string 2 range-exp) ")")) |
8277 ")")) | |
8278 (t nil))))) | |
8279 ;;(verilog-make-width-expression "`A:`B") | |
8280 | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8281 (defun verilog-simplify-range-expression (range-exp) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8282 "Return a simplified range expression with constants eliminated from RANGE-EXP." |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8283 (let ((out range-exp) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8284 (last-pass "")) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8285 (while (not (equal last-pass out)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8286 (setq last-pass out) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8287 (while (string-match "(\\<\\([0-9A-Z-az_]+\\)\\>)" out) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8288 (setq out (replace-match "\\1" nil nil out))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8289 (while (string-match "\\<\\([0-9]+\\)\\>\\s *\\+\\s *\\<\\([0-9]+\\)\\>" out) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8290 (setq out (replace-match |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8291 (int-to-string (+ (string-to-number (match-string 1 out)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8292 (string-to-number (match-string 2 out)))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8293 nil nil out))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8294 (while (string-match "\\<\\([0-9]+\\)\\>\\s *\\-\\s *\\<\\([0-9]+\\)\\>" out) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8295 (setq out (replace-match |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8296 (int-to-string (- (string-to-number (match-string 1 out)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8297 (string-to-number (match-string 2 out)))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8298 nil nil out)))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8299 out)) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8300 ;;(verilog-simplify-range-expression "1") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8301 ;;(verilog-simplify-range-expression "(((16)+1)-3)") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8302 |
79545 | 8303 (defun verilog-typedef-name-p (variable-name) |
8304 "Return true if the VARIABLE-NAME is a type definition." | |
8305 (when verilog-typedef-regexp | |
8306 (string-match verilog-typedef-regexp variable-name))) | |
8307 | |
8308 ;; | |
8309 ;; Auto deletion | |
8310 ;; | |
8311 | |
8312 (defun verilog-delete-autos-lined () | |
8313 "Delete autos that occupy multiple lines, between begin and end comments." | |
8314 (let ((pt (point))) | |
8315 (forward-line 1) | |
8316 (when (and | |
8317 (looking-at "\\s-*// Beginning") | |
8318 (search-forward "// End of automatic" nil t)) | |
8319 ;; End exists | |
8320 (end-of-line) | |
8321 (delete-region pt (point)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8322 (forward-line 1)))) |
79545 | 8323 |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8324 (defun verilog-delete-empty-auto-pair () |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8325 "Delete begin/end auto pair at point, if empty." |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8326 (forward-line 0) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8327 (when (looking-at (concat "\\s-*// Beginning of automatic.*\n" |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8328 "\\s-*// End of automatics\n")) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8329 (delete-region (point) (save-excursion (forward-line 2) (point))))) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8330 |
79545 | 8331 (defun verilog-forward-close-paren () |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8332 "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
|
8333 Ignore other close parenthesis with matching open parens." |
79545 | 8334 (let ((parens 1)) |
8335 (while (> parens 0) | |
8336 (unless (verilog-re-search-forward-quick "[()]" nil t) | |
8337 (error "%s: Mismatching ()" (verilog-point-text))) | |
8338 (cond ((= (preceding-char) ?\( ) | |
8339 (setq parens (1+ parens))) | |
8340 ((= (preceding-char) ?\) ) | |
8341 (setq parens (1- parens))))))) | |
8342 | |
8343 (defun verilog-backward-open-paren () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8344 "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
|
8345 Ignore other open parenthesis with matching close parens." |
79545 | 8346 (let ((parens 1)) |
8347 (while (> parens 0) | |
8348 (unless (verilog-re-search-backward-quick "[()]" nil t) | |
8349 (error "%s: Mismatching ()" (verilog-point-text))) | |
8350 (cond ((= (following-char) ?\) ) | |
8351 (setq parens (1+ parens))) | |
8352 ((= (following-char) ?\( ) | |
8353 (setq parens (1- parens))))))) | |
8354 | |
8355 (defun verilog-backward-open-bracket () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8356 "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
|
8357 Ignore other open bracket with matching close bracket." |
79545 | 8358 (let ((parens 1)) |
8359 (while (> parens 0) | |
8360 (unless (verilog-re-search-backward-quick "[][]" nil t) | |
8361 (error "%s: Mismatching []" (verilog-point-text))) | |
8362 (cond ((= (following-char) ?\] ) | |
8363 (setq parens (1+ parens))) | |
8364 ((= (following-char) ?\[ ) | |
8365 (setq parens (1- parens))))))) | |
8366 | |
8367 (defun verilog-delete-to-paren () | |
8368 "Delete the automatic inst/sense/arg created by autos. | |
8369 Deletion stops at the matching end parenthesis." | |
8370 (delete-region (point) | |
8371 (save-excursion | |
8372 (verilog-backward-open-paren) | |
8373 (forward-sexp 1) ;; Moves to paren that closes argdecl's | |
8374 (backward-char 1) | |
8375 (point)))) | |
8376 | |
8377 (defun verilog-auto-star-safe () | |
8378 "Return if a .* AUTOINST is safe to delete or expand. | |
8379 It was created by the AUTOS themselves, or by the user." | |
8380 (and verilog-auto-star-expand | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8381 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\|Interfaces\\)\\)"))) |
79545 | 8382 |
8383 (defun verilog-delete-auto-star-all () | |
8384 "Delete a .* AUTOINST, if it is safe." | |
8385 (when (verilog-auto-star-safe) | |
8386 (verilog-delete-to-paren))) | |
8387 | |
8388 (defun verilog-delete-auto-star-implicit () | |
8389 "Delete all .* implicit connections created by `verilog-auto-star'. | |
8390 This function will be called automatically at save unless | |
8391 `verilog-auto-star-save' is set, any non-templated expanded pins will be | |
8392 removed." | |
8393 (interactive) | |
8394 (let (paren-pt indent have-close-paren) | |
8395 (save-excursion | |
8396 (goto-char (point-min)) | |
8397 ;; We need to match these even outside of comments. | |
8398 ;; For reasonable performance, we don't check if inside comments, sorry. | |
8399 (while (re-search-forward "// Implicit \\.\\*" nil t) | |
8400 (setq paren-pt (point)) | |
8401 (beginning-of-line) | |
8402 (setq have-close-paren | |
8403 (save-excursion | |
8404 (when (search-forward ");" paren-pt t) | |
8405 (setq indent (current-indentation)) | |
8406 t))) | |
8407 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR | |
8408 (when have-close-paren | |
8409 ;; Delete extra commentary | |
8410 (save-excursion | |
8411 (while (progn | |
8412 (forward-line -1) | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8413 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\|Interfaces\\)\n")) |
79545 | 8414 (delete-region (match-beginning 0) (match-end 0)))) |
8415 ;; If it is simple, we can put the ); on the same line as the last text | |
8416 (let ((rtn-pt (point))) | |
8417 (save-excursion | |
8418 (while (progn (backward-char 1) | |
8419 (looking-at "[ \t\n\f]"))) | |
8420 (when (looking-at ",") | |
8421 (delete-region (+ 1 (point)) rtn-pt)))) | |
8422 (when (bolp) | |
8423 (indent-to indent)) | |
8424 (insert ");\n") | |
8425 ;; Still need to kill final comma - always is one as we put one after the .* | |
8426 (re-search-backward ",") | |
8427 (delete-char 1)))))) | |
8428 | |
8429 (defun verilog-delete-auto () | |
8430 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto]. | |
8431 Use \\[verilog-auto] to re-insert the updated AUTOs. | |
8432 | |
8433 The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are | |
8434 called before and after this function, respectively." | |
8435 (interactive) | |
8436 (save-excursion | |
8437 (if (buffer-file-name) | |
8438 (find-file-noselect (buffer-file-name))) ;; To check we have latest version | |
8439 ;; Allow user to customize | |
8440 (run-hooks 'verilog-before-delete-auto-hook) | |
8441 | |
93195 | 8442 ;; Remove those that have multi-line insertions, possibly with parameters |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8443 (verilog-auto-re-search-do |
93195 | 8444 (concat "/\\*" |
8445 (eval-when-compile | |
8446 (verilog-regexp-words | |
8447 `("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE" | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8448 "AUTOINOUT" "AUTOINOUTCOMP" "AUTOINOUTMODULE" |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8449 "AUTOINPUT" "AUTOINSERTLISP" "AUTOOUTPUT" "AUTOOUTPUTEVERY" |
93195 | 8450 "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF" |
8451 "AUTOUNUSED" "AUTOWIRE"))) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8452 ;; Optional parens or quoted parameter or .* for (((...))) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
8453 "\\(\\|([^)]*)\\|(\"[^\"]*\")\\).*?" |
93195 | 8454 "\\*/") |
8455 'verilog-delete-autos-lined) | |
79545 | 8456 ;; Remove those that are in parenthesis |
93195 | 8457 (verilog-auto-re-search-do |
8458 (concat "/\\*" | |
8459 (eval-when-compile | |
8460 (verilog-regexp-words | |
8461 `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM" | |
8462 "AUTOSENSE"))) | |
8463 "\\*/") | |
8464 'verilog-delete-to-paren) | |
79545 | 8465 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments |
8466 (verilog-auto-re-search-do "\\.\\*" | |
8467 'verilog-delete-auto-star-all) | |
8468 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed | |
8469 (goto-char (point-min)) | |
8470 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t) | |
8471 (replace-match "")) | |
8472 | |
8473 ;; Final customize | |
8474 (run-hooks 'verilog-delete-auto-hook))) | |
8475 | |
8476 ;; | |
8477 ;; Auto inject | |
8478 ;; | |
8479 | |
8480 (defun verilog-inject-auto () | |
8481 "Examine legacy non-AUTO code and insert AUTOs in appropriate places. | |
8482 | |
8483 Any always @ blocks with sensitivity lists that match computed lists will | |
8484 be replaced with /*AS*/ comments. | |
8485 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8486 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
|
8487 Pins with have identical names will be deleted. |
79545 | 8488 |
8489 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to | |
8490 support adding new ports. You may wish to delete older ports yourself. | |
8491 | |
8492 For example: | |
8493 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8494 module ExampInject (i, o); |
79545 | 8495 input i; |
8496 input j; | |
8497 output o; | |
8498 always @ (i or j) | |
8499 o = i | j; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8500 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8501 (.foobar(baz), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8502 j(j)); |
79545 | 8503 endmodule |
8504 | |
8505 Typing \\[verilog-inject-auto] will make this into: | |
8506 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8507 module ExampInject (i, o/*AUTOARG*/ |
79545 | 8508 // Inputs |
8509 j); | |
8510 input i; | |
8511 output o; | |
8512 always @ (/*AS*/i or j) | |
8513 o = i | j; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8514 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8515 (.foobar(baz), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8516 /*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8517 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8518 j(j)); |
79545 | 8519 endmodule" |
8520 (interactive) | |
8521 (verilog-auto t)) | |
8522 | |
8523 (defun verilog-inject-arg () | |
8524 "Inject AUTOARG into new code. See `verilog-inject-auto'." | |
8525 ;; Presume one module per file. | |
8526 (save-excursion | |
8527 (goto-char (point-min)) | |
8528 (while (verilog-re-search-forward-quick "\\<module\\>" nil t) | |
8529 (let ((endmodp (save-excursion | |
8530 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t) | |
8531 (point)))) | |
8532 ;; See if there's already a comment .. inside a comment so not verilog-re-search | |
8533 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t)) | |
8534 (verilog-re-search-forward-quick ";" nil t) | |
8535 (backward-char 1) | |
8536 (verilog-backward-syntactic-ws) | |
8537 (backward-char 1) ; Moves to paren that closes argdecl's | |
8538 (when (looking-at ")") | |
8539 (insert "/*AUTOARG*/"))))))) | |
8540 | |
8541 (defun verilog-inject-sense () | |
8542 "Inject AUTOSENSE into new code. See `verilog-inject-auto'." | |
8543 (save-excursion | |
8544 (goto-char (point-min)) | |
8545 (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
|
8546 (let* ((start-pt (point)) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8547 (modi (verilog-modi-current)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8548 (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
|
8549 pre-sigs |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
8550 got-sigs) |
79545 | 8551 (backward-char 1) |
8552 (forward-sexp 1) | |
8553 (backward-char 1) ;; End ) | |
8554 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t)) | |
8555 (setq pre-sigs (verilog-signals-from-signame | |
8556 (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
|
8557 got-sigs (verilog-auto-sense-sigs moddecls nil)) |
79545 | 8558 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal? |
8559 (verilog-signals-not-in got-sigs pre-sigs))) | |
8560 (delete-region start-pt (point)) | |
8561 (insert "/*AS*/"))))))) | |
8562 | |
8563 (defun verilog-inject-inst () | |
8564 "Inject AUTOINST into new code. See `verilog-inject-auto'." | |
8565 (save-excursion | |
8566 (goto-char (point-min)) | |
8567 ;; It's hard to distinguish modules; we'll instead search for pins. | |
8568 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t) | |
8569 (verilog-backward-open-paren) ;; Inst start | |
8570 (cond | |
8571 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip. | |
8572 (forward-char 1) | |
8573 (verilog-forward-close-paren)) ;; Parameters done | |
8574 (t | |
8575 (forward-char 1) | |
8576 (let ((indent-pt (+ (current-column))) | |
8577 (end-pt (save-excursion (verilog-forward-close-paren) (point)))) | |
8578 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t) | |
8579 (goto-char end-pt)) ;; Already there, continue search with next instance | |
8580 (t | |
8581 ;; Delete identical interconnect | |
8582 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc | |
8583 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t) | |
8584 (delete-region (match-beginning 0) (match-end 0)) | |
8585 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct | |
8586 (while (or (looking-at "[ \t\n\f,]+") | |
8587 (looking-at "//[^\n]*")) | |
8588 (delete-region (match-beginning 0) (match-end 0)) | |
8589 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0))))))) | |
8590 (verilog-forward-close-paren) | |
8591 (backward-char 1) | |
8592 ;; Not verilog-re-search, as we don't want to strip comments | |
8593 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t) | |
8594 (delete-region (match-beginning 0) (match-end 0))) | |
8595 (insert "\n") | |
8596 (indent-to indent-pt) | |
8597 (insert "/*AUTOINST*/"))))))))) | |
8598 | |
8599 ;; | |
8600 ;; Auto save | |
8601 ;; | |
8602 | |
8603 (defun verilog-auto-save-check () | |
8604 "On saving see if we need auto update." | |
8605 (cond ((not verilog-auto-save-policy)) ; disabled | |
8606 ((not (save-excursion | |
8607 (save-match-data | |
8608 (let ((case-fold-search nil)) | |
8609 (goto-char (point-min)) | |
8610 (re-search-forward "AUTO" nil t)))))) | |
8611 ((eq verilog-auto-save-policy 'force) | |
8612 (verilog-auto)) | |
8613 ((not (buffer-modified-p))) | |
8614 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date | |
8615 ((eq verilog-auto-save-policy 'detect) | |
8616 (verilog-auto)) | |
8617 (t | |
8618 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ") | |
8619 (verilog-auto)) | |
8620 ;; Don't ask again if didn't update | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8621 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)))) |
79545 | 8622 (when (not verilog-auto-star-save) |
8623 (verilog-delete-auto-star-implicit)) | |
8624 nil) ;; Always return nil -- we don't write the file ourselves | |
8625 | |
8626 (defun verilog-auto-read-locals () | |
8627 "Return file local variable segment at bottom of file." | |
8628 (save-excursion | |
8629 (goto-char (point-max)) | |
8630 (if (re-search-backward "Local Variables:" nil t) | |
8631 (buffer-substring-no-properties (point) (point-max)) | |
8632 ""))) | |
8633 | |
8634 (defun verilog-auto-reeval-locals (&optional force) | |
8635 "Read file local variable segment at bottom of file if it has changed. | |
8636 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
|
8637 (make-local-variable 'verilog-auto-last-file-locals) |
79545 | 8638 (let ((curlocal (verilog-auto-read-locals))) |
8639 (when (or force (not (equal verilog-auto-last-file-locals curlocal))) | |
8640 (setq verilog-auto-last-file-locals curlocal) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8641 ;; Note this may cause this function to be recursively invoked, |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8642 ;; because hack-local-variables may call (verilog-mode) |
79545 | 8643 ;; The above when statement will prevent it from recursing forever. |
8644 (hack-local-variables) | |
8645 t))) | |
8646 | |
8647 ;; | |
8648 ;; Auto creation | |
8649 ;; | |
8650 | |
8651 (defun verilog-auto-arg-ports (sigs message indent-pt) | |
8652 "Print a list of ports for a AUTOINST. | |
8653 Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT." | |
8654 (when sigs | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8655 (when verilog-auto-arg-sort |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8656 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare))) |
79545 | 8657 (insert "\n") |
8658 (indent-to indent-pt) | |
8659 (insert message) | |
8660 (insert "\n") | |
8661 (let ((space "")) | |
8662 (indent-to indent-pt) | |
8663 (while sigs | |
8664 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column) | |
8665 (insert "\n") | |
8666 (indent-to indent-pt)) | |
8667 (t (insert space))) | |
8668 (insert (verilog-sig-name (car sigs)) ",") | |
8669 (setq sigs (cdr sigs) | |
8670 space " "))))) | |
8671 | |
8672 (defun verilog-auto-arg () | |
8673 "Expand AUTOARG statements. | |
8674 Replace the argument declarations at the beginning of the | |
8675 module with ones automatically derived from input and output | |
8676 statements. This can be dangerous if the module is instantiated | |
8677 using position-based connections, so use only name-based when | |
8678 instantiating the resulting module. Long lines are split based | |
8679 on the `fill-column', see \\[set-fill-column]. | |
8680 | |
8681 Limitations: | |
8682 Concatenation and outputting partial busses is not supported. | |
8683 | |
8684 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8685 | |
8686 For example: | |
8687 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8688 module ExampArg (/*AUTOARG*/); |
79545 | 8689 input i; |
8690 output o; | |
8691 endmodule | |
8692 | |
8693 Typing \\[verilog-auto] will make this into: | |
8694 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8695 module ExampArg (/*AUTOARG*/ |
79545 | 8696 // Outputs |
8697 o, | |
8698 // Inputs | |
8699 i | |
8700 ); | |
8701 input i; | |
8702 output o; | |
8703 endmodule | |
8704 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8705 The argument declarations may be printed in declaration order to best suit |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8706 order based instantiations, or alphabetically, based on the |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8707 `verilog-auto-arg-sort' variable. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8708 |
79545 | 8709 Any ports declared between the ( and /*AUTOARG*/ are presumed to be |
8710 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
|
8711 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
|
8712 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
|
8713 to choose the comma yourself. |
79545 | 8714 |
8715 Avoid declaring ports manually, as it makes code harder to maintain." | |
8716 (save-excursion | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8717 (let* ((modi (verilog-modi-current)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
8718 (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
|
8719 (skip-pins (aref (verilog-read-arg-pins) 0))) |
79545 | 8720 (verilog-repair-open-comma) |
8721 (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
|
8722 (verilog-decls-get-outputs moddecls) |
79545 | 8723 skip-pins) |
8724 "// Outputs" | |
8725 verilog-indent-level-declaration) | |
8726 (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
|
8727 (verilog-decls-get-inouts moddecls) |
79545 | 8728 skip-pins) |
8729 "// Inouts" | |
8730 verilog-indent-level-declaration) | |
8731 (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
|
8732 (verilog-decls-get-inputs moddecls) |
79545 | 8733 skip-pins) |
8734 "// Inputs" | |
8735 verilog-indent-level-declaration) | |
8736 (verilog-repair-close-comma) | |
8737 (unless (eq (char-before) ?/ ) | |
8738 (insert "\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8739 (indent-to verilog-indent-level-declaration)))) |
79545 | 8740 |
8741 (defun verilog-auto-inst-port-map (port-st) | |
8742 nil) | |
8743 | |
8744 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8745 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8746 (defvar vl-modport nil "See `verilog-auto-inst'.") ; Prevent compile warning |
79545 | 8747 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning |
8748 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8749 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning | |
8750 | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8751 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star par-values) |
79545 | 8752 "Print out a instantiation connection for this PORT-ST. |
8753 Insert to INDENT-PT, use template TPL-LIST. | |
8754 @ are instantiation numbers, replaced with TPL-NUM. | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
8755 @\"(expression @)\" are evaluated, with @ as a variable. |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8756 If FOR-STAR add comment it is a .* expansion. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8757 If PAR-VALUES replace final strings with these parameter values." |
79545 | 8758 (let* ((port (verilog-sig-name port-st)) |
8759 (tpl-ass (or (assoc port (car tpl-list)) | |
8760 (verilog-auto-inst-port-map port-st))) | |
8761 ;; vl-* are documented for user use | |
8762 (vl-name (verilog-sig-name port-st)) | |
8763 (vl-width (verilog-sig-width port-st)) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8764 (vl-modport (verilog-sig-modport port-st)) |
79545 | 8765 (vl-bits (if (or verilog-auto-inst-vector |
8766 (not (assoc port vector-skip-list)) | |
8767 (not (equal (verilog-sig-bits port-st) | |
8768 (verilog-sig-bits (assoc port vector-skip-list))))) | |
8769 (or (verilog-sig-bits port-st) "") | |
8770 "")) | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8771 (case-fold-search nil) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8772 (check-values par-values) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8773 tpl-net) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8774 ;; Replace parameters in bit-width |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8775 (when (and check-values |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8776 (not (equal vl-bits ""))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8777 (while check-values |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8778 (setq vl-bits (verilog-string-replace-matches |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8779 (concat "\\<" (nth 0 (car check-values)) "\\>") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8780 (concat "(" (nth 1 (car check-values)) ")") |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8781 t t vl-bits) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8782 check-values (cdr check-values))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8783 (setq vl-bits (verilog-simplify-range-expression vl-bits))) ; Not in the loop for speed |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
8784 ;; Default net value if not found |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8785 (setq tpl-net (concat port |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8786 (if vl-modport (concat "." vl-modport) "") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8787 (if (verilog-sig-multidim port-st) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8788 (concat "/*" (verilog-sig-multidim-string port-st) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8789 vl-bits "*/") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
8790 (concat vl-bits)))) |
79545 | 8791 ;; Find template |
8792 (cond (tpl-ass ; Template of exact port name | |
8793 (setq tpl-net (nth 1 tpl-ass))) | |
8794 ((nth 1 tpl-list) ; Wildcards in template, search them | |
8795 (let ((wildcards (nth 1 tpl-list))) | |
8796 (while wildcards | |
8797 (when (string-match (nth 0 (car wildcards)) port) | |
8798 (setq tpl-ass (car wildcards) ; so allow @ parsing | |
8799 tpl-net (replace-match (nth 1 (car wildcards)) | |
8800 t nil port))) | |
8801 (setq wildcards (cdr wildcards)))))) | |
8802 ;; Parse Templated variable | |
8803 (when tpl-ass | |
8804 ;; Evaluate @"(lispcode)" | |
8805 (when (string-match "@\".*[^\\]\"" tpl-net) | |
8806 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net) | |
8807 (setq tpl-net | |
8808 (concat | |
8809 (substring tpl-net 0 (match-beginning 0)) | |
8810 (save-match-data | |
8811 (let* ((expr (match-string 1 tpl-net)) | |
8812 (value | |
8813 (progn | |
8814 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr)) | |
8815 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr)) | |
8816 (prin1 (eval (car (read-from-string expr))) | |
8817 (lambda (ch) ()))))) | |
8818 (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
|
8819 value)) |
79545 | 8820 (substring tpl-net (match-end 0)))))) |
8821 ;; Replace @ and [] magic variables in final output | |
8822 (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
|
8823 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net))) |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8824 ;; Insert it |
79545 | 8825 (indent-to indent-pt) |
8826 (insert "." port) | |
8827 (indent-to verilog-auto-inst-column) | |
8828 (insert "(" tpl-net "),") | |
8829 (cond (tpl-ass | |
8830 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
8831 verilog-auto-inst-column)) | |
8832 (insert " // Templated") | |
8833 (when verilog-auto-inst-template-numbers | |
8834 (insert " T" (int-to-string (nth 2 tpl-ass)) | |
8835 " L" (int-to-string (nth 3 tpl-ass))))) | |
8836 (for-star | |
8837 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16) | |
8838 verilog-auto-inst-column)) | |
8839 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped... | |
8840 (insert "\n"))) | |
8841 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3") | |
8842 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]") | |
8843 ;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));") | |
8844 | |
8845 (defun verilog-auto-inst-first () | |
8846 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]." | |
8847 ;; Do we need a trailing comma? | |
8848 ;; There maybe a ifdef or something similar before us. What a mess. Thus | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
8849 ;; to avoid trouble we only insert on preceding ) or *. |
79545 | 8850 ;; Insert first port on new line |
8851 (insert "\n") ;; Must insert before search, so point will move forward if insert comma | |
8852 (save-excursion | |
8853 (verilog-re-search-backward "[^ \t\n\f]" nil nil) | |
8854 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure | |
8855 (forward-char 1) | |
8856 (insert ",")))) | |
8857 | |
8858 (defun verilog-auto-star () | |
8859 "Expand SystemVerilog .* pins, as part of \\[verilog-auto]. | |
8860 | |
8861 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
|
8862 AUTOINST statements, otherwise they are ignored. For safety, Verilog mode |
79545 | 8863 will also ignore any .* that are not last in your pin list (this prevents |
8864 it from deleting pins following the .* when it expands the AUTOINST.) | |
8865 | |
8866 On writing your file, unless `verilog-auto-star-save' is set, any | |
8867 non-templated expanded pins will be removed. You may do this at any time | |
8868 with \\[verilog-delete-auto-star-implicit]. | |
8869 | |
8870 If you are converting a module to use .* for the first time, you may wish | |
8871 to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*. | |
8872 | |
8873 See `verilog-auto-inst' for examples, templates, and more information." | |
8874 (when (verilog-auto-star-safe) | |
8875 (verilog-auto-inst))) | |
8876 | |
8877 (defun verilog-auto-inst () | |
8878 "Expand AUTOINST statements, as part of \\[verilog-auto]. | |
8879 Replace the pin connections to an instantiation with ones | |
8880 automatically derived from the module header of the instantiated netlist. | |
8881 | |
8882 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports, | |
8883 and delete them before saving unless `verilog-auto-star-save' is set. | |
8884 See `verilog-auto-star' for more information. | |
8885 | |
8886 Limitations: | |
8887 Module names must be resolvable to filenames by adding a | |
8888 `verilog-library-extensions', and being found in the same directory, or | |
8889 by changing the variable `verilog-library-flags' or | |
8890 `verilog-library-directories'. Macros `modname are translated through the | |
8891 vh-{name} Emacs variable, if that is not found, it just ignores the `. | |
8892 | |
8893 In templates you must have one signal per line, ending in a ), or ));, | |
8894 and have proper () nesting, including a final ); to end the template. | |
8895 | |
8896 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
8897 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8898 SystemVerilog multidimensional input/output has only experimental support. |
79545 | 8899 |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8900 Parameters referenced by the instantiation will remain symbolic, unless |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8901 `verilog-auto-inst-param-value' is set. |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
8902 |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8903 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
|
8904 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8905 module InstModule (o,i) |
79545 | 8906 output [31:0] o; |
8907 input i; | |
8908 wire [31:0] o = {32{i}}; | |
8909 endmodule | |
8910 | |
8911 This is then used in a upper level module: | |
8912 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8913 module ExampInst (o,i) |
79545 | 8914 output o; |
8915 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8916 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8917 (/*AUTOINST*/); |
79545 | 8918 endmodule |
8919 | |
8920 Typing \\[verilog-auto] will make this into: | |
8921 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8922 module ExampInst (o,i) |
79545 | 8923 output o; |
8924 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8925 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8926 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8927 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8928 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8929 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8930 .i (i)); |
79545 | 8931 endmodule |
8932 | |
8933 Where the list of inputs and outputs came from the inst module. | |
8934 | |
8935 Exceptions: | |
8936 | |
8937 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
|
8938 something trivial like an adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY. |
79545 | 8939 It just makes for unmaintainable code. To sanitize signal names, try |
104029
55ba5af4bf3a
Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents:
103980
diff
changeset
|
8940 vrename from URL `http://www.veripool.org'. |
79545 | 8941 |
8942 When you need to violate this suggestion there are two ways to list | |
8943 exceptions, placing them before the AUTOINST, or using templates. | |
8944 | |
8945 Any ports defined before the /*AUTOINST*/ are not included in the list of | |
8946 automatics. This is similar to making a template as described below, but | |
8947 is restricted to simple connections just like you normally make. Also note | |
8948 that any signals before the AUTOINST will only be picked up by AUTOWIRE if | |
8949 you have the appropriate // Input or // Output comment, and exactly the | |
8950 same line formatting as AUTOINST itself uses. | |
8951 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8952 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8953 (// Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8954 .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
|
8955 /*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8956 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8957 .ov (ov[31:0])); |
79545 | 8958 |
8959 | |
8960 Templates: | |
8961 | |
8962 For multiple instantiations based upon a single template, create a | |
8963 commented out template: | |
8964 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8965 /* InstModule AUTO_TEMPLATE ( |
79545 | 8966 .sig3 (sigz[]), |
8967 ); | |
8968 */ | |
8969 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
8970 Templates go ABOVE the instantiation(s). When an instantiation is |
79545 | 8971 expanded `verilog-mode' simply searches up for the closest template. |
8972 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
|
8973 between the template for an instantiation and the instantiation itself. |
79545 | 8974 |
8975 The module name must be the same as the name of the module in the | |
8976 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact | |
8977 words and capitalized. Only signals that must be different for each | |
8978 instantiation need to be listed. | |
8979 | |
8980 Inside a template, a [] in a connection name (with nothing else inside | |
8981 the brackets) will be replaced by the same bus subscript as it is being | |
8982 connected to, or the [] will be removed if it is a single bit signal. | |
8983 Generally it is a good idea to do this for all connections in a template, | |
8984 as then they will work for any width signal, and with AUTOWIRE. See | |
8985 PTL_BUS becoming PTL_BUSNEW below. | |
8986 | |
8987 If you have a complicated template, set `verilog-auto-inst-template-numbers' | |
8988 to see which regexps are matching. Don't leave that mode set after | |
8989 debugging is completed though, it will result in lots of extra differences | |
8990 and merge conflicts. | |
8991 | |
8992 For example: | |
8993 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8994 /* InstModule AUTO_TEMPLATE ( |
79545 | 8995 .ptl_bus (ptl_busnew[]), |
8996 ); | |
8997 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
8998 InstModule ms2m (/*AUTOINST*/); |
79545 | 8999 |
9000 Typing \\[verilog-auto] will make this into: | |
9001 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9002 InstModule ms2m (/*AUTOINST*/ |
79545 | 9003 // Outputs |
9004 .NotInTemplate (NotInTemplate), | |
9005 .ptl_bus (ptl_busnew[3:0]), // Templated | |
9006 .... | |
9007 | |
9008 @ Templates: | |
9009 | |
9010 It is common to instantiate a cell multiple times, so templates make it | |
9011 trivial to substitute part of the cell name into the connection name. | |
9012 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9013 /* InstName AUTO_TEMPLATE <optional \"REGEXP\"> ( |
79545 | 9014 .sig1 (sigx[@]), |
9015 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]), | |
9016 ); | |
9017 */ | |
9018 | |
9019 If no regular expression is provided immediately after the AUTO_TEMPLATE | |
9020 keyword, then the @ character in any connection names will be replaced | |
9021 with the instantiation number; the first digits found in the cell's | |
9022 instantiation name. | |
9023 | |
9024 If a regular expression is provided, the @ character will be replaced | |
9025 with the first \(\) grouping that matches against the cell name. Using a | |
9026 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no | |
9027 regexp is provided. If you use multiple layers of parenthesis, | |
9028 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number | |
9029 characters after test and before _, whereas | |
9030 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire | |
9031 match. | |
9032 | |
9033 For example: | |
9034 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9035 /* InstModule AUTO_TEMPLATE ( |
79545 | 9036 .ptl_mapvalidx (ptl_mapvalid[@]), |
9037 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]), | |
9038 ); | |
9039 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9040 InstModule ms2m (/*AUTOINST*/); |
79545 | 9041 |
9042 Typing \\[verilog-auto] will make this into: | |
9043 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9044 InstModule ms2m (/*AUTOINST*/ |
79545 | 9045 // Outputs |
9046 .ptl_mapvalidx (ptl_mapvalid[2]), | |
9047 .ptl_mapvalidp1x (ptl_mapvalid[3])); | |
9048 | |
9049 Note the @ character was replaced with the 2 from \"ms2m\". | |
9050 | |
9051 Alternatively, using a regular expression for @: | |
9052 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9053 /* InstModule AUTO_TEMPLATE \"_\\([a-z]+\\)\" ( |
79545 | 9054 .ptl_mapvalidx (@_ptl_mapvalid), |
9055 .ptl_mapvalidp1x (ptl_mapvalid_@), | |
9056 ); | |
9057 */ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9058 InstModule ms2_FOO (/*AUTOINST*/); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9059 InstModule ms2_BAR (/*AUTOINST*/); |
79545 | 9060 |
9061 Typing \\[verilog-auto] will make this into: | |
9062 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9063 InstModule ms2_FOO (/*AUTOINST*/ |
79545 | 9064 // Outputs |
9065 .ptl_mapvalidx (FOO_ptl_mapvalid), | |
9066 .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
|
9067 InstModule ms2_BAR (/*AUTOINST*/ |
79545 | 9068 // Outputs |
9069 .ptl_mapvalidx (BAR_ptl_mapvalid), | |
9070 .ptl_mapvalidp1x (ptl_mapvalid_BAR)); | |
9071 | |
9072 | |
9073 Regexp Templates: | |
9074 | |
9075 A template entry of the form | |
9076 | |
9077 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]), | |
9078 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9079 will apply an Emacs style regular expression search for any port beginning |
79545 | 9080 in pci_req followed by numbers and ending in _l and connecting that to |
9081 the pci_req_jtag_[] net, with the bus subscript coming from what matches | |
9082 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2]. | |
9083 | |
9084 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9085 does the same thing. (Note a @ in the connection/replacement text is |
79545 | 9086 completely different -- still use \\1 there!) Thus this is the same as |
9087 the above template: | |
9088 | |
9089 .pci_req@_l (pci_req_jtag_[\\1]), | |
9090 | |
9091 Here's another example to remove the _l, useful when naming conventions | |
9092 specify _ alone to mean active low. Note the use of [] to keep the bus | |
9093 subscript: | |
9094 | |
9095 .\\(.*\\)_l (\\1_[]), | |
9096 | |
9097 Lisp Templates: | |
9098 | |
9099 First any regular expression template is expanded. | |
9100 | |
9101 If the syntax @\"( ... )\" is found in a connection, the expression in | |
9102 quotes will be evaluated as a Lisp expression, with @ replaced by the | |
9103 instantiation number. The MAPVALIDP1X example above would put @+1 modulo | |
9104 4 into the brackets. Quote all double-quotes inside the expression with | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9105 a leading backslash (\\\"...\\\"); or if the Lisp template is also a |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9106 regexp template backslash the backslash quote (\\\\\"...\\\\\"). |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9107 |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9108 There are special variables defined that are useful in these |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9109 Lisp functions: |
79545 | 9110 |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9111 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
|
9112 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
|
9113 vl-width Width of the input/output port ('3' for [2:0]). |
79545 | 9114 May be a (...) expression if bits isn't a constant. |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9115 vl-dir Direction of the pin input/output/inout/interface. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9116 vl-modport The modport, if an interface with a modport. |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9117 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
|
9118 vl-cell-name Instance name of the cell ('instName'). |
79545 | 9119 |
9120 Normal Lisp variables may be used in expressions. See | |
9121 `verilog-read-defines' which can set vh-{definename} variables for use | |
9122 here. Also, any comments of the form: | |
9123 | |
9124 /*AUTO_LISP(setq foo 1)*/ | |
9125 | |
9126 will evaluate any Lisp expression inside the parenthesis between the | |
9127 beginning of the buffer and the point of the AUTOINST. This allows | |
9128 functions to be defined or variables to be changed between instantiations. | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9129 (See also `verilog-auto-insert-lisp' if you want the output from your |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9130 lisp function to be inserted.) |
79545 | 9131 |
9132 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
|
9133 number; you may need to use the standard Emacs Lisp functions |
79545 | 9134 `number-to-string' and `string-to-number'. |
9135 | |
9136 After the evaluation is completed, @ substitution and [] substitution | |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9137 occur. |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9138 |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9139 For more information see the \\[verilog-faq] and forums at URL |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
9140 `http://www.veripool.org'." |
79545 | 9141 (save-excursion |
9142 ;; Find beginning | |
9143 (let* ((pt (point)) | |
9144 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*"))) | |
9145 (indent-pt (save-excursion (verilog-backward-open-paren) | |
9146 (1+ (current-column)))) | |
9147 (verilog-auto-inst-column (max verilog-auto-inst-column | |
9148 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
9149 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9150 (moddecls (verilog-modi-get-decls modi)) |
79545 | 9151 (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
|
9152 (verilog-decls-get-signals moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9153 submod submodi submoddecls |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9154 inst skip-pins tpl-list tpl-num did-first par-values) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9155 |
79545 | 9156 ;; Find module name that is instantiated |
9157 (setq submod (verilog-read-inst-module) | |
9158 inst (verilog-read-inst-name) | |
9159 vl-cell-type submod | |
9160 vl-cell-name inst | |
9161 skip-pins (aref (verilog-read-inst-pins) 0)) | |
9162 | |
9163 ;; Parse any AUTO_LISP() before here | |
9164 (verilog-read-auto-lisp (point-min) pt) | |
9165 | |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9166 ;; Read parameters (after AUTO_LISP) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9167 (setq par-values (and verilog-auto-inst-param-value |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9168 (verilog-read-inst-param-value))) |
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9169 |
79545 | 9170 ;; Lookup position, etc of submodule |
9171 ;; Note this may raise an error | |
9172 (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
|
9173 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 9174 ;; If there's a number in the instantiation, it may be a argument to the |
9175 ;; automatic variable instantiation program. | |
9176 (let* ((tpl-info (verilog-read-auto-template submod)) | |
9177 (tpl-regexp (aref tpl-info 0))) | |
9178 (setq tpl-num (if (string-match tpl-regexp inst) | |
9179 (match-string 1 inst) | |
9180 "") | |
9181 tpl-list (aref tpl-info 1))) | |
9182 ;; Find submodule's signals and dump | |
9183 (let ((sig-list (verilog-signals-not-in | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9184 (verilog-decls-get-interfaces submoddecls) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9185 skip-pins)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9186 (vl-dir "interface")) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9187 (when sig-list |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9188 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9189 (indent-to indent-pt) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9190 ;; Note these are searched for in verilog-read-sub-decls. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9191 (insert "// Interfaces\n") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9192 (mapc (lambda (port) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9193 (verilog-auto-inst-port port indent-pt |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9194 tpl-list tpl-num for-star par-values)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9195 sig-list))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9196 (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
|
9197 (verilog-decls-get-outputs submoddecls) |
79545 | 9198 skip-pins)) |
9199 (vl-dir "output")) | |
9200 (when sig-list | |
9201 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
9202 (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
|
9203 (insert "// Outputs\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9204 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9205 (verilog-auto-inst-port port indent-pt |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9206 tpl-list tpl-num for-star par-values)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9207 sig-list))) |
79545 | 9208 (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
|
9209 (verilog-decls-get-inouts submoddecls) |
79545 | 9210 skip-pins)) |
9211 (vl-dir "inout")) | |
9212 (when sig-list | |
9213 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
9214 (indent-to indent-pt) | |
9215 (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
|
9216 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9217 (verilog-auto-inst-port port indent-pt |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9218 tpl-list tpl-num for-star par-values)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9219 sig-list))) |
79545 | 9220 (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
|
9221 (verilog-decls-get-inputs submoddecls) |
79545 | 9222 skip-pins)) |
9223 (vl-dir "input")) | |
9224 (when sig-list | |
9225 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
9226 (indent-to indent-pt) | |
9227 (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
|
9228 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9229 (verilog-auto-inst-port port indent-pt |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9230 tpl-list tpl-num for-star par-values)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9231 sig-list))) |
79545 | 9232 ;; Kill extra semi |
9233 (save-excursion | |
9234 (cond (did-first | |
9235 (re-search-backward "," pt t) | |
9236 (delete-char 1) | |
9237 (insert ");") | |
9238 (search-forward "\n") ;; Added by inst-port | |
9239 (delete-backward-char 1) | |
9240 (if (search-forward ")" nil t) ;; From user, moved up a line | |
9241 (delete-backward-char 1)) | |
9242 (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
|
9243 (delete-backward-char 1))))))))) |
79545 | 9244 |
9245 (defun verilog-auto-inst-param () | |
9246 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto]. | |
9247 Replace the parameter connections to an instantiation with ones | |
9248 automatically derived from the module header of the instantiated netlist. | |
9249 | |
9250 See \\[verilog-auto-inst] for limitations, and templates to customize the | |
9251 output. | |
9252 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9253 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
|
9254 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9255 module InstModule (o,i) |
79545 | 9256 parameter PAR; |
9257 endmodule | |
9258 | |
9259 This is then used in a upper level module: | |
9260 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9261 module ExampInst (o,i) |
79545 | 9262 parameter PAR; |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9263 InstModule #(/*AUTOINSTPARAM*/) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9264 instName (/*AUTOINST*/); |
79545 | 9265 endmodule |
9266 | |
9267 Typing \\[verilog-auto] will make this into: | |
9268 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9269 module ExampInst (o,i) |
79545 | 9270 output o; |
9271 input i; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9272 InstModule #(/*AUTOINSTPARAM*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9273 // Parameters |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9274 .PAR (PAR)); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9275 instName (/*AUTOINST*/); |
79545 | 9276 endmodule |
9277 | |
9278 Where the list of parameter connections come from the inst module. | |
9279 | |
9280 Templates: | |
9281 | |
9282 You can customize the parameter connections using AUTO_TEMPLATEs, | |
9283 just as you would with \\[verilog-auto-inst]." | |
9284 (save-excursion | |
9285 ;; Find beginning | |
9286 (let* ((pt (point)) | |
9287 (indent-pt (save-excursion (verilog-backward-open-paren) | |
9288 (1+ (current-column)))) | |
9289 (verilog-auto-inst-column (max verilog-auto-inst-column | |
9290 (+ 16 (* 8 (/ (+ indent-pt 7) 8))))) | |
9291 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9292 (moddecls (verilog-modi-get-decls modi)) |
79545 | 9293 (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
|
9294 (verilog-decls-get-signals moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9295 submod submodi submoddecls |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9296 inst skip-pins tpl-list tpl-num did-first) |
79545 | 9297 ;; Find module name that is instantiated |
9298 (setq submod (save-excursion | |
9299 ;; Get to the point where AUTOINST normally is to read the module | |
9300 (verilog-re-search-forward-quick "[(;]" nil nil) | |
9301 (verilog-read-inst-module)) | |
9302 inst (save-excursion | |
9303 ;; Get to the point where AUTOINST normally is to read the module | |
9304 (verilog-re-search-forward-quick "[(;]" nil nil) | |
9305 (verilog-read-inst-name)) | |
9306 vl-cell-type submod | |
9307 vl-cell-name inst | |
9308 skip-pins (aref (verilog-read-inst-pins) 0)) | |
9309 | |
9310 ;; Parse any AUTO_LISP() before here | |
9311 (verilog-read-auto-lisp (point-min) pt) | |
9312 | |
9313 ;; Lookup position, etc of submodule | |
9314 ;; Note this may raise an error | |
9315 (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
|
9316 (setq submoddecls (verilog-modi-get-decls submodi)) |
79545 | 9317 ;; If there's a number in the instantiation, it may be a argument to the |
9318 ;; automatic variable instantiation program. | |
9319 (let* ((tpl-info (verilog-read-auto-template submod)) | |
9320 (tpl-regexp (aref tpl-info 0))) | |
9321 (setq tpl-num (if (string-match tpl-regexp inst) | |
9322 (match-string 1 inst) | |
9323 "") | |
9324 tpl-list (aref tpl-info 1))) | |
9325 ;; Find submodule's signals and dump | |
9326 (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
|
9327 (verilog-decls-get-gparams submoddecls) |
79545 | 9328 skip-pins)) |
9329 (vl-dir "parameter")) | |
9330 (when sig-list | |
9331 (when (not did-first) (verilog-auto-inst-first) (setq did-first t)) | |
9332 (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
|
9333 ;; 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
|
9334 (insert "// Parameters\n") |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9335 (mapc (lambda (port) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9336 (verilog-auto-inst-port port indent-pt |
97107
138e8a4ee5a6
* verilog-mode.el (verilog-do-indent): Remove special indent for
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94760
diff
changeset
|
9337 tpl-list tpl-num nil nil)) |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
9338 sig-list))) |
79545 | 9339 ;; Kill extra semi |
9340 (save-excursion | |
9341 (cond (did-first | |
9342 (re-search-backward "," pt t) | |
9343 (delete-char 1) | |
9344 (insert ")") | |
9345 (search-forward "\n") ;; Added by inst-port | |
9346 (delete-backward-char 1) | |
9347 (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
|
9348 (delete-backward-char 1))))))))) |
79545 | 9349 |
9350 (defun verilog-auto-reg () | |
9351 "Expand AUTOREG statements, as part of \\[verilog-auto]. | |
9352 Make reg statements for any output that isn't already declared, | |
9353 and isn't a wire output from a block. | |
9354 | |
9355 Limitations: | |
9356 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
9357 | |
9358 This does NOT work on memories, declare those yourself. | |
9359 | |
9360 An example: | |
9361 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9362 module ExampReg (o,i) |
79545 | 9363 output o; |
9364 input i; | |
9365 /*AUTOREG*/ | |
9366 always o = i; | |
9367 endmodule | |
9368 | |
9369 Typing \\[verilog-auto] will make this into: | |
9370 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9371 module ExampReg (o,i) |
79545 | 9372 output o; |
9373 input i; | |
9374 /*AUTOREG*/ | |
9375 // 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
|
9376 reg o; |
79545 | 9377 // End of automatics |
9378 always o = i; | |
9379 endmodule" | |
9380 (save-excursion | |
9381 ;; Point must be at insertion point. | |
9382 (let* ((indent-pt (current-indentation)) | |
9383 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9384 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9385 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9386 (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
|
9387 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9388 (append (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9389 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9390 (verilog-decls-get-assigns moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9391 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9392 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9393 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9394 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 9395 (forward-line 1) |
9396 (when sig-list | |
9397 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n") | |
9398 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
9399 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9400 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9401 |
9402 (defun verilog-auto-reg-input () | |
9403 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto]. | |
9404 Make reg statements instantiation inputs that aren't already declared. | |
9405 This is useful for making a top level shell for testing the module that is | |
9406 to be instantiated. | |
9407 | |
9408 Limitations: | |
9409 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
9410 | |
9411 This does NOT work on memories, declare those yourself. | |
9412 | |
9413 An example (see `verilog-auto-inst' for what else is going on here): | |
9414 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9415 module ExampRegInput (o,i) |
79545 | 9416 output o; |
9417 input i; | |
9418 /*AUTOREGINPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9419 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9420 (/*AUTOINST*/); |
79545 | 9421 endmodule |
9422 | |
9423 Typing \\[verilog-auto] will make this into: | |
9424 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9425 module ExampRegInput (o,i) |
79545 | 9426 output o; |
9427 input i; | |
9428 /*AUTOREGINPUT*/ | |
9429 // 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
|
9430 reg [31:0] iv; // From inst of inst.v |
79545 | 9431 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9432 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9433 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9434 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9435 .o (o[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9436 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9437 .iv (iv)); |
79545 | 9438 endmodule" |
9439 (save-excursion | |
9440 ;; Point must be at insertion point. | |
9441 (let* ((indent-pt (current-indentation)) | |
9442 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9443 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9444 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9445 (sig-list (verilog-signals-combine-bus |
9446 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9447 (append (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9448 (verilog-subdecls-get-inouts modsubdecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9449 (verilog-decls-get-signals moddecls))))) |
79545 | 9450 (forward-line 1) |
9451 (when sig-list | |
9452 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n") | |
9453 (verilog-insert-definition sig-list "reg" indent-pt nil) | |
9454 (verilog-modi-cache-add-regs modi sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9455 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 9456 |
9457 (defun verilog-auto-wire () | |
9458 "Expand AUTOWIRE statements, as part of \\[verilog-auto]. | |
9459 Make wire statements for instantiations outputs that aren't | |
9460 already declared. | |
9461 | |
9462 Limitations: | |
9463 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'), | |
9464 and all busses must have widths, such as those from AUTOINST, or using [] | |
9465 in AUTO_TEMPLATEs. | |
9466 | |
9467 This does NOT work on memories or SystemVerilog .name connections, | |
9468 declare those yourself. | |
9469 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
9470 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
|
9471 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
|
9472 non-numeric or non-sequential bus subscripts. If Verilog mode |
79545 | 9473 mis-guessed, you'll have to declare them yourself. |
9474 | |
9475 An example (see `verilog-auto-inst' for what else is going on here): | |
9476 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9477 module ExampWire (o,i) |
79545 | 9478 output o; |
9479 input i; | |
9480 /*AUTOWIRE*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9481 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9482 (/*AUTOINST*/); |
79545 | 9483 endmodule |
9484 | |
9485 Typing \\[verilog-auto] will make this into: | |
9486 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9487 module ExampWire (o,i) |
79545 | 9488 output o; |
9489 input i; | |
9490 /*AUTOWIRE*/ | |
9491 // Beginning of automatic wires | |
9492 wire [31:0] ov; // From inst of inst.v | |
9493 // End of automatics | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9494 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9495 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9496 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9497 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9498 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9499 .i (i)); |
79545 | 9500 wire o = | ov; |
9501 endmodule" | |
9502 (save-excursion | |
9503 ;; Point must be at insertion point. | |
9504 (let* ((indent-pt (current-indentation)) | |
9505 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9506 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9507 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9508 (sig-list (verilog-signals-combine-bus |
9509 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9510 (append (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9511 (verilog-subdecls-get-inouts modsubdecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9512 (verilog-decls-get-signals moddecls))))) |
79545 | 9513 (forward-line 1) |
9514 (when sig-list | |
9515 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n") | |
9516 (verilog-insert-definition sig-list "wire" indent-pt nil) | |
9517 (verilog-modi-cache-add-wires modi sig-list) | |
9518 (verilog-insert-indent "// End of automatics\n") | |
9519 (when nil ;; Too slow on huge modules, plus makes everyone's module change | |
9520 (beginning-of-line) | |
9521 (setq pnt (point)) | |
80024
9231505e5076
* progmodes/verilog-mode.el (verilog-declaration-core-re):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79986
diff
changeset
|
9522 (verilog-pretty-declarations quiet) |
79545 | 9523 (goto-char pnt) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9524 (verilog-pretty-expr t "//")))))) |
79545 | 9525 |
93195 | 9526 (defun verilog-auto-output (&optional with-params) |
79545 | 9527 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. |
9528 Make output statements for any output signal from an /*AUTOINST*/ that | |
9529 isn't a input to another AUTOINST. This is useful for modules which | |
9530 only instantiate other modules. | |
9531 | |
9532 Limitations: | |
9533 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
9534 | |
9535 If placed inside the parenthesis of a module declaration, it creates | |
9536 Verilog 2001 style, else uses Verilog 1995 style. | |
9537 | |
9538 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
9539 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
9540 | |
9541 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
9542 | |
9543 Signals matching `verilog-auto-output-ignore-regexp' are not included. | |
9544 | |
9545 An example (see `verilog-auto-inst' for what else is going on here): | |
9546 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9547 module ExampOutput (ov,i) |
79545 | 9548 input i; |
9549 /*AUTOOUTPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9550 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9551 (/*AUTOINST*/); |
79545 | 9552 endmodule |
9553 | |
9554 Typing \\[verilog-auto] will make this into: | |
9555 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9556 module ExampOutput (ov,i) |
79545 | 9557 input i; |
9558 /*AUTOOUTPUT*/ | |
9559 // 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
|
9560 output [31:0] ov; // From inst of inst.v |
79545 | 9561 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9562 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9563 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9564 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9565 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9566 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9567 .i (i)); |
93195 | 9568 endmodule |
9569 | |
9570 You may also provide an optional regular expression, in which case only | |
9571 signals matching the regular expression will be included. For example the | |
9572 same expansion will result from only extracting outputs starting with ov: | |
9573 | |
9574 /*AUTOOUTPUT(\"^ov\")*/" | |
79545 | 9575 (save-excursion |
9576 ;; Point must be at insertion point. | |
9577 (let* ((indent-pt (current-indentation)) | |
93195 | 9578 (regexp (and with-params |
9579 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 9580 (v2k (verilog-in-paren)) |
9581 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9582 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9583 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9584 (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
|
9585 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9586 (append (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9587 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9588 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9589 (verilog-subdecls-get-inouts modsubdecls))))) |
93195 | 9590 (when regexp |
9591 (setq sig-list (verilog-signals-matching-regexp | |
9592 sig-list regexp))) | |
79545 | 9593 (setq sig-list (verilog-signals-not-matching-regexp |
9594 sig-list verilog-auto-output-ignore-regexp)) | |
9595 (forward-line 1) | |
9596 (when v2k (verilog-repair-open-comma)) | |
9597 (when sig-list | |
9598 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n") | |
9599 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
9600 (verilog-modi-cache-add-outputs modi sig-list) | |
9601 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9602 (when v2k (verilog-repair-close-comma))))) |
79545 | 9603 |
9604 (defun verilog-auto-output-every () | |
9605 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto]. | |
9606 Make output statements for any signals that aren't primary inputs or | |
9607 outputs already. This makes every signal in the design a output. This is | |
9608 useful to get Synopsys to preserve every signal in the design, since it | |
9609 won't optimize away the outputs. | |
9610 | |
9611 An example: | |
9612 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9613 module ExampOutputEvery (o,i,tempa,tempb) |
79545 | 9614 output o; |
9615 input i; | |
9616 /*AUTOOUTPUTEVERY*/ | |
9617 wire tempa = i; | |
9618 wire tempb = tempa; | |
9619 wire o = tempb; | |
9620 endmodule | |
9621 | |
9622 Typing \\[verilog-auto] will make this into: | |
9623 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9624 module ExampOutputEvery (o,i,tempa,tempb) |
79545 | 9625 output o; |
9626 input i; | |
9627 /*AUTOOUTPUTEVERY*/ | |
9628 // 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
|
9629 output tempb; |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9630 output tempa; |
79545 | 9631 // End of automatics |
9632 wire tempa = i; | |
9633 wire tempb = tempa; | |
9634 wire o = tempb; | |
9635 endmodule" | |
9636 (save-excursion | |
9637 ;;Point must be at insertion point | |
9638 (let* ((indent-pt (current-indentation)) | |
9639 (v2k (verilog-in-paren)) | |
9640 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9641 (moddecls (verilog-modi-get-decls modi)) |
79545 | 9642 (sig-list (verilog-signals-combine-bus |
9643 (verilog-signals-not-in | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9644 (verilog-decls-get-signals moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9645 (verilog-decls-get-ports moddecls))))) |
79545 | 9646 (forward-line 1) |
9647 (when v2k (verilog-repair-open-comma)) | |
9648 (when sig-list | |
9649 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n") | |
9650 (verilog-insert-definition sig-list "output" indent-pt v2k) | |
9651 (verilog-modi-cache-add-outputs modi sig-list) | |
9652 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9653 (when v2k (verilog-repair-close-comma))))) |
79545 | 9654 |
93195 | 9655 (defun verilog-auto-input (&optional with-params) |
79545 | 9656 "Expand AUTOINPUT statements, as part of \\[verilog-auto]. |
9657 Make input statements for any input signal into an /*AUTOINST*/ that | |
9658 isn't declared elsewhere inside the module. This is useful for modules which | |
9659 only instantiate other modules. | |
9660 | |
9661 Limitations: | |
9662 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
9663 | |
9664 If placed inside the parenthesis of a module declaration, it creates | |
9665 Verilog 2001 style, else uses Verilog 1995 style. | |
9666 | |
9667 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
9668 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
9669 | |
9670 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
9671 | |
9672 Signals matching `verilog-auto-input-ignore-regexp' are not included. | |
9673 | |
9674 An example (see `verilog-auto-inst' for what else is going on here): | |
9675 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9676 module ExampInput (ov,i) |
79545 | 9677 output [31:0] ov; |
9678 /*AUTOINPUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9679 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9680 (/*AUTOINST*/); |
79545 | 9681 endmodule |
9682 | |
9683 Typing \\[verilog-auto] will make this into: | |
9684 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9685 module ExampInput (ov,i) |
79545 | 9686 output [31:0] ov; |
9687 /*AUTOINPUT*/ | |
9688 // 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
|
9689 input i; // From inst of inst.v |
79545 | 9690 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9691 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9692 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9693 // Outputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9694 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9695 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9696 .i (i)); |
93195 | 9697 endmodule |
9698 | |
9699 You may also provide an optional regular expression, in which case only | |
9700 signals matching the regular expression will be included. For example the | |
9701 same expansion will result from only extracting inputs starting with i: | |
9702 | |
9703 /*AUTOINPUT(\"^i\")*/" | |
79545 | 9704 (save-excursion |
9705 (let* ((indent-pt (current-indentation)) | |
93195 | 9706 (regexp (and with-params |
9707 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 9708 (v2k (verilog-in-paren)) |
9709 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9710 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9711 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9712 (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
|
9713 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9714 (append (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9715 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9716 (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9717 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9718 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9719 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9720 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9721 (verilog-subdecls-get-inouts modsubdecls))))) |
93195 | 9722 (when regexp |
9723 (setq sig-list (verilog-signals-matching-regexp | |
9724 sig-list regexp))) | |
79545 | 9725 (setq sig-list (verilog-signals-not-matching-regexp |
9726 sig-list verilog-auto-input-ignore-regexp)) | |
9727 (forward-line 1) | |
9728 (when v2k (verilog-repair-open-comma)) | |
9729 (when sig-list | |
9730 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n") | |
9731 (verilog-insert-definition sig-list "input" indent-pt v2k) | |
9732 (verilog-modi-cache-add-inputs modi sig-list) | |
9733 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9734 (when v2k (verilog-repair-close-comma))))) |
79545 | 9735 |
93195 | 9736 (defun verilog-auto-inout (&optional with-params) |
79545 | 9737 "Expand AUTOINOUT statements, as part of \\[verilog-auto]. |
9738 Make inout statements for any inout signal in an /*AUTOINST*/ that | |
9739 isn't declared elsewhere inside the module. | |
9740 | |
9741 Limitations: | |
9742 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'). | |
9743 | |
9744 If placed inside the parenthesis of a module declaration, it creates | |
9745 Verilog 2001 style, else uses Verilog 1995 style. | |
9746 | |
9747 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's | |
9748 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE). | |
9749 | |
9750 Typedefs must match `verilog-typedef-regexp', which is disabled by default. | |
9751 | |
9752 Signals matching `verilog-auto-inout-ignore-regexp' are not included. | |
9753 | |
9754 An example (see `verilog-auto-inst' for what else is going on here): | |
9755 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9756 module ExampInout (ov,i) |
79545 | 9757 input i; |
9758 /*AUTOINOUT*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9759 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9760 (/*AUTOINST*/); |
79545 | 9761 endmodule |
9762 | |
9763 Typing \\[verilog-auto] will make this into: | |
9764 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9765 module ExampInout (ov,i) |
79545 | 9766 input i; |
9767 /*AUTOINOUT*/ | |
9768 // 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
|
9769 inout [31:0] ov; // From inst of inst.v |
79545 | 9770 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9771 InstModule instName |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9772 (/*AUTOINST*/ |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9773 // Inouts |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9774 .ov (ov[31:0]), |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9775 // Inputs |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9776 .i (i)); |
93195 | 9777 endmodule |
9778 | |
9779 You may also provide an optional regular expression, in which case only | |
9780 signals matching the regular expression will be included. For example the | |
9781 same expansion will result from only extracting inouts starting with i: | |
9782 | |
9783 /*AUTOINOUT(\"^i\")*/" | |
79545 | 9784 (save-excursion |
9785 ;; Point must be at insertion point. | |
9786 (let* ((indent-pt (current-indentation)) | |
93195 | 9787 (regexp (and with-params |
9788 (nth 0 (verilog-read-auto-params 1)))) | |
79545 | 9789 (v2k (verilog-in-paren)) |
9790 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9791 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9792 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 9793 (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
|
9794 (verilog-subdecls-get-inouts modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9795 (append (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9796 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9797 (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9798 (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9799 (verilog-subdecls-get-outputs modsubdecls))))) |
93195 | 9800 (when regexp |
9801 (setq sig-list (verilog-signals-matching-regexp | |
9802 sig-list regexp))) | |
79545 | 9803 (setq sig-list (verilog-signals-not-matching-regexp |
9804 sig-list verilog-auto-inout-ignore-regexp)) | |
9805 (forward-line 1) | |
9806 (when v2k (verilog-repair-open-comma)) | |
9807 (when sig-list | |
9808 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n") | |
9809 (verilog-insert-definition sig-list "inout" indent-pt v2k) | |
9810 (verilog-modi-cache-add-inouts modi sig-list) | |
9811 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9812 (when v2k (verilog-repair-close-comma))))) |
79545 | 9813 |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9814 (defun verilog-auto-inout-module (&optional complement) |
79545 | 9815 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto]. |
9816 Take input/output/inout statements from the specified module and insert | |
9817 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
|
9818 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
|
9819 Any I/O which are already defined in this module will not be redefined. |
79545 | 9820 |
9821 Limitations: | |
9822 If placed inside the parenthesis of a module declaration, it creates | |
9823 Verilog 2001 style, else uses Verilog 1995 style. | |
9824 | |
9825 Concatenation and outputting partial busses is not supported. | |
9826 | |
9827 Module names must be resolvable to filenames. See `verilog-auto-inst'. | |
9828 | |
9829 Signals are not inserted in the same order as in the original module, | |
9830 though they will appear to be in the same order to a AUTOINST | |
9831 instantiating either module. | |
9832 | |
9833 An example: | |
9834 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9835 module ExampShell (/*AUTOARG*/) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9836 /*AUTOINOUTMODULE(\"ExampMain\")*/ |
79545 | 9837 endmodule |
9838 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9839 module ExampMain (i,o,io) |
79545 | 9840 input i; |
9841 output o; | |
9842 inout io; | |
9843 endmodule | |
9844 | |
9845 Typing \\[verilog-auto] will make this into: | |
9846 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9847 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
|
9848 /*AUTOINOUTMODULE(\"ExampMain\")*/ |
79545 | 9849 // Beginning of automatic in/out/inouts (from specific module) |
9850 output o; | |
9851 inout io; | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9852 input i; |
79545 | 9853 // End of automatics |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9854 endmodule |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9855 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9856 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
|
9857 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
|
9858 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
|
9859 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9860 /*AUTOINOUTMODULE(\"ExampMain\",\"^i\")*/ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9861 |
105864
c6d77597d0f2
* verilog-mode.el (verilog-getopt-file, verilog-set-define):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105813
diff
changeset
|
9862 You may also provide an optional second regular expression, in |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9863 which case only signals which have that pin direction and data |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9864 type will be included. This matches against everything before |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9865 the signal name in the declaration, for example against |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9866 \"input\" (single bit), \"output logic\" (direction and type) or |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9867 \"output [1:0]\" (direction and implicit type). You also |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9868 probably want to skip spaces in your regexp. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9869 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9870 For example, the below will result in matching the output \"o\" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9871 against the previous example's module: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9872 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9873 /*AUTOINOUTMODULE(\"ExampMain\",\"\",\"^output.*\")*/" |
79545 | 9874 (save-excursion |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9875 (let* ((params (verilog-read-auto-params 1 3)) |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9876 (submod (nth 0 params)) |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9877 (regexp (nth 1 params)) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9878 (direction-re (nth 2 params)) |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
9879 submodi) |
79545 | 9880 ;; Lookup position, etc of co-module |
9881 ;; Note this may raise an error | |
9882 (when (setq submodi (verilog-modi-lookup submod t)) | |
9883 (let* ((indent-pt (current-indentation)) | |
9884 (v2k (verilog-in-paren)) | |
9885 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9886 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9887 (submoddecls (verilog-modi-get-decls submodi)) |
79545 | 9888 (sig-list-i (verilog-signals-not-in |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9889 (if complement |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9890 (verilog-decls-get-outputs submoddecls) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9891 (verilog-decls-get-inputs submoddecls)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9892 (append (verilog-decls-get-inputs moddecls)))) |
79545 | 9893 (sig-list-o (verilog-signals-not-in |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9894 (if complement |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9895 (verilog-decls-get-inputs submoddecls) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9896 (verilog-decls-get-outputs submoddecls)) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
9897 (append (verilog-decls-get-outputs moddecls)))) |
79545 | 9898 (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
|
9899 (verilog-decls-get-inouts submoddecls) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9900 (append (verilog-decls-get-inouts moddecls)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9901 (sig-list-if (verilog-signals-not-in |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9902 (verilog-decls-get-interfaces submoddecls) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9903 (append (verilog-decls-get-interfaces moddecls))))) |
79545 | 9904 (forward-line 1) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9905 (setq sig-list-i (verilog-signals-matching-dir-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9906 (verilog-signals-matching-regexp sig-list-i regexp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9907 "input" direction-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9908 sig-list-o (verilog-signals-matching-dir-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9909 (verilog-signals-matching-regexp sig-list-o regexp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9910 "output" direction-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9911 sig-list-io (verilog-signals-matching-dir-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9912 (verilog-signals-matching-regexp sig-list-io regexp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9913 "inout" direction-re) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9914 sig-list-if (verilog-signals-matching-dir-re |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9915 (verilog-signals-matching-regexp sig-list-if regexp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9916 "interface" direction-re)) |
79545 | 9917 (when v2k (verilog-repair-open-comma)) |
9918 (when (or sig-list-i sig-list-o sig-list-io) | |
9919 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n") | |
9920 ;; Don't sort them so a upper AUTOINST will match the main module | |
9921 (verilog-insert-definition sig-list-o "output" indent-pt v2k t) | |
9922 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t) | |
9923 (verilog-insert-definition sig-list-i "input" indent-pt v2k t) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9924 (verilog-insert-definition sig-list-if "interface" indent-pt v2k t) |
79545 | 9925 (verilog-modi-cache-add-inputs modi sig-list-i) |
9926 (verilog-modi-cache-add-outputs modi sig-list-o) | |
9927 (verilog-modi-cache-add-inouts modi sig-list-io) | |
9928 (verilog-insert-indent "// End of automatics\n")) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
9929 (when v2k (verilog-repair-close-comma))))))) |
79545 | 9930 |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9931 (defun verilog-auto-inout-comp () |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9932 "Expand AUTOINOUTCOMP statements, as part of \\[verilog-auto]. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9933 Take input/output/inout statements from the specified module and |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9934 insert the inverse into the current module (inputs become outputs |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9935 and vice-versa.) This is useful for making test and stimulus |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9936 modules which need to have complementing I/O with another module. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9937 Any I/O which are already defined in this module will not be |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9938 redefined. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9939 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9940 Limitations: |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9941 If placed inside the parenthesis of a module declaration, it creates |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9942 Verilog 2001 style, else uses Verilog 1995 style. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9943 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9944 Concatenation and outputting partial busses is not supported. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9945 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9946 Module names must be resolvable to filenames. See `verilog-auto-inst'. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9947 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9948 Signals are not inserted in the same order as in the original module, |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9949 though they will appear to be in the same order to a AUTOINST |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9950 instantiating either module. |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9951 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9952 An example: |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9953 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9954 module ExampShell (/*AUTOARG*/) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9955 /*AUTOINOUTCOMP(\"ExampMain\")*/ |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9956 endmodule |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9957 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9958 module ExampMain (i,o,io) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9959 input i; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9960 output o; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9961 inout io; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9962 endmodule |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9963 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9964 Typing \\[verilog-auto] will make this into: |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9965 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9966 module ExampShell (/*AUTOARG*/i,o,io) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9967 /*AUTOINOUTCOMP(\"ExampMain\")*/ |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9968 // Beginning of automatic in/out/inouts (from specific module) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9969 output i; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9970 inout io; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9971 input o; |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9972 // End of automatics |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9973 endmodule |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9974 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9975 You may also provide an optional regular expression, in which case only |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9976 signals matching the regular expression will be included. For example the |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9977 same expansion will result from only extracting signals starting with i: |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9978 |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9979 /*AUTOINOUTCOMP(\"ExampMain\",\"^i\")*/" |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9980 (verilog-auto-inout-module t)) |
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
9981 |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9982 (defun verilog-auto-insert-lisp () |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9983 "Expand AUTOINSERTLISP statements, as part of \\[verilog-auto]. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9984 The Lisp code provided is called, and the Lisp code calls |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9985 `insert` to insert text into the current file beginning on the |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9986 line after the AUTOINSERTLISP. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9987 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9988 See also AUTO_LISP, which takes a Lisp expression and evaluates |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9989 it during `verilog-auto-inst' but does not insert any text. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9990 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9991 An example: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9992 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9993 module ExampInsertLisp; |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9994 /*AUTOINSERTLISP(my-verilog-insert-hello \"world\")*/ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9995 endmodule |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9996 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9997 // For this example we declare the function in the |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9998 // module's file itself. Often you'd define it instead |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
9999 // in a site-start.el or .emacs file. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10000 /* |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10001 Local Variables: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10002 eval: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10003 (defun my-verilog-insert-hello (who) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10004 (insert (concat \"initial $write(\\\"hello \" who \"\\\");\\n\"))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10005 End: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10006 */ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10007 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10008 Typing \\[verilog-auto] will call my-verilog-insert-hello and |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10009 expand the above into: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10010 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10011 // Beginning of automatic insert lisp |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10012 initial $write(\"hello world\"); |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10013 // End of automatics |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10014 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10015 You can also call an external program and insert the returned |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10016 text: |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10017 |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10018 /*AUTOINSERTLISP(insert (shell-command-to-string \"echo //hello\"))*/ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10019 // Beginning of automatic insert lisp |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10020 //hello |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10021 // End of automatics" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10022 (save-excursion |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10023 ;; Point is at end of /*AUTO...*/ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10024 (let* ((indent-pt (current-indentation)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10025 (cmd-end-pt (save-excursion (search-backward ")") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10026 (forward-char) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10027 (point))) ;; Closing paren |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10028 (cmd-beg-pt (save-excursion (goto-char cmd-end-pt) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10029 (backward-sexp 1) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10030 (point))) ;; Beginning paren |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10031 (cmd (buffer-substring-no-properties cmd-beg-pt cmd-end-pt))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10032 (forward-line 1) |
106265
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10033 ;; Some commands don't move point (like insert-file) so we always |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10034 ;; add the begin/end comments, then delete it if not needed |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10035 (verilog-insert-indent "// Beginning of automatic insert lisp\n") |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10036 (verilog-insert-indent "// End of automatics\n") |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10037 (forward-line -1) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10038 (eval (read cmd)) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10039 (forward-line -1) |
fbb51bb535e8
* verilog-mode.el (verilog-at-struct-p): Support "signed" and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105864
diff
changeset
|
10040 (verilog-delete-empty-auto-pair)))) |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10041 |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10042 (defun verilog-auto-sense-sigs (moddecls presense-sigs) |
79545 | 10043 "Return list of signals for current AUTOSENSE block." |
10044 (let* ((sigss (verilog-read-always-signals)) | |
10045 (sig-list (verilog-signals-not-params | |
10046 (verilog-signals-not-in (verilog-alw-get-inputs sigss) | |
10047 (append (and (not verilog-auto-sense-include-inputs) | |
10048 (verilog-alw-get-outputs sigss)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10049 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10050 (verilog-decls-get-gparams moddecls) |
79545 | 10051 presense-sigs))))) |
10052 sig-list)) | |
10053 | |
10054 (defun verilog-auto-sense () | |
10055 "Expand AUTOSENSE statements, as part of \\[verilog-auto]. | |
10056 Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short) | |
10057 with one automatically derived from all inputs declared in the always | |
10058 statement. Signals that are generated within the same always block are NOT | |
10059 placed into the sensitivity list (see `verilog-auto-sense-include-inputs'). | |
10060 Long lines are split based on the `fill-column', see \\[set-fill-column]. | |
10061 | |
10062 Limitations: | |
10063 Verilog does not allow memories (multidimensional arrays) in sensitivity | |
10064 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment. | |
10065 | |
10066 Constant signals: | |
10067 AUTOSENSE cannot always determine if a `define is a constant or a signal | |
10068 (it could be in a include file for example). If a `define or other signal | |
10069 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT | |
10070 declaration anywhere in the module (parenthesis are required): | |
10071 | |
10072 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */ | |
10073 | |
10074 Better yet, use a parameter, which will be understood to be constant | |
10075 automatically. | |
10076 | |
10077 OOps! | |
10078 If AUTOSENSE makes a mistake, please report it. (First try putting | |
10079 a begin/end after your always!) As a workaround, if a signal that | |
10080 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above. | |
10081 If a signal should be in the sensitivity list wasn't, placing it before | |
10082 the /*AUTOSENSE*/ comment will prevent it from being deleted when the | |
10083 autos are updated (or added if it occurs there already). | |
10084 | |
10085 An example: | |
10086 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10087 always @ (/*AS*/) begin |
79545 | 10088 /* AUTO_CONSTANT (`constant) */ |
10089 outin = ina | inb | `constant; | |
10090 out = outin; | |
10091 end | |
10092 | |
10093 Typing \\[verilog-auto] will make this into: | |
10094 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10095 always @ (/*AS*/ina or inb) begin |
79545 | 10096 /* AUTO_CONSTANT (`constant) */ |
10097 outin = ina | inb | `constant; | |
10098 out = outin; | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10099 end |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10100 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10101 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
|
10102 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
|
10103 |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10104 always @* begin |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10105 outin = ina | inb | `constant; |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10106 out = outin; |
79545 | 10107 end" |
10108 (save-excursion | |
10109 ;; Find beginning | |
10110 (let* ((start-pt (save-excursion | |
10111 (verilog-re-search-backward "(" nil t) | |
10112 (point))) | |
10113 (indent-pt (save-excursion | |
10114 (or (and (goto-char start-pt) (1+ (current-column))) | |
10115 (current-indentation)))) | |
10116 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10117 (moddecls (verilog-modi-get-decls modi)) |
79545 | 10118 (sig-memories (verilog-signals-memory |
10119 (append | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10120 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10121 (verilog-decls-get-wires moddecls)))) |
79545 | 10122 sig-list not-first presense-sigs) |
10123 ;; Read signals in always, eliminate outputs from sense list | |
10124 (setq presense-sigs (verilog-signals-from-signame | |
10125 (save-excursion | |
10126 (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
|
10127 (setq sig-list (verilog-auto-sense-sigs moddecls presense-sigs)) |
79545 | 10128 (when sig-memories |
10129 (let ((tlen (length sig-list))) | |
10130 (setq sig-list (verilog-signals-not-in sig-list sig-memories)) | |
10131 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ ")))) | |
10132 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/" | |
10133 (save-excursion (goto-char (point)) | |
10134 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
10135 (verilog-re-search-backward "\\s-" start-pt t) | |
10136 (while (looking-at "\\s-`endif") | |
10137 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t) | |
10138 (verilog-re-search-backward "\\s-" start-pt t)) | |
10139 (not (looking-at "\\s-or\\b")))) | |
10140 (setq not-first t)) | |
10141 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
10142 (while sig-list | |
10143 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or | |
10144 (insert "\n") | |
10145 (indent-to indent-pt) | |
10146 (if not-first (insert "or "))) | |
10147 (not-first (insert " or "))) | |
10148 (insert (verilog-sig-name (car sig-list))) | |
10149 (setq sig-list (cdr sig-list) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10150 not-first t))))) |
79545 | 10151 |
10152 (defun verilog-auto-reset () | |
10153 "Expand AUTORESET statements, as part of \\[verilog-auto]. | |
10154 Replace the /*AUTORESET*/ comment with code to initialize all | |
10155 registers set elsewhere in the always block. | |
10156 | |
10157 Limitations: | |
10158 AUTORESET will not clear memories. | |
10159 | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
10160 AUTORESET uses <= if there are any <= assignments in the block, |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10161 else it uses =. |
79545 | 10162 |
10163 /*AUTORESET*/ presumes that any signals mentioned between the previous | |
10164 begin/case/if statement and the AUTORESET comment are being reset manually | |
10165 and should not be automatically reset. This includes omitting any signals | |
10166 used on the right hand side of assignments. | |
10167 | |
10168 By default, AUTORESET will include the width of the signal in the autos, | |
10169 this is a recent change. To control this behavior, see | |
10170 `verilog-auto-reset-widths'. | |
10171 | |
10172 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
10173 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
10174 them to a one. | |
10175 | |
10176 An example: | |
10177 | |
10178 always @(posedge clk or negedge reset_l) begin | |
10179 if (!reset_l) begin | |
10180 c <= 1; | |
10181 /*AUTORESET*/ | |
10182 end | |
10183 else begin | |
10184 a <= in_a; | |
10185 b <= in_b; | |
10186 c <= in_c; | |
10187 end | |
10188 end | |
10189 | |
10190 Typing \\[verilog-auto] will make this into: | |
10191 | |
10192 always @(posedge core_clk or negedge reset_l) begin | |
10193 if (!reset_l) begin | |
10194 c <= 1; | |
10195 /*AUTORESET*/ | |
10196 // Beginning of autoreset for uninitialized flops | |
10197 a <= 0; | |
10198 b <= 0; | |
10199 // End of automatics | |
10200 end | |
10201 else begin | |
10202 a <= in_a; | |
10203 b <= in_b; | |
10204 c <= in_c; | |
10205 end | |
10206 end" | |
10207 | |
10208 (interactive) | |
10209 (save-excursion | |
10210 ;; Find beginning | |
10211 (let* ((indent-pt (current-indentation)) | |
10212 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10213 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10214 (all-list (verilog-decls-get-signals moddecls)) |
79545 | 10215 sigss sig-list prereset-sigs assignment-str) |
10216 ;; Read signals in always, eliminate outputs from reset list | |
10217 (setq prereset-sigs (verilog-signals-from-signame | |
10218 (save-excursion | |
10219 (verilog-read-signals | |
10220 (save-excursion | |
10221 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t) | |
10222 (point)) | |
10223 (point))))) | |
10224 (save-excursion | |
10225 (verilog-re-search-backward "@" nil t) | |
10226 (setq sigss (verilog-read-always-signals))) | |
10227 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss) | |
10228 (concat " <= " verilog-assignment-delay) | |
10229 " = ")) | |
10230 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss) | |
10231 prereset-sigs)) | |
10232 (setq sig-list (sort sig-list `verilog-signals-sort-compare)) | |
10233 (when sig-list | |
10234 (insert "\n"); | |
10235 (indent-to indent-pt) | |
10236 (insert "// Beginning of autoreset for uninitialized flops\n"); | |
10237 (indent-to indent-pt) | |
10238 (while sig-list | |
10239 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths | |
10240 (car sig-list)))) | |
10241 (insert (verilog-sig-name sig) | |
10242 assignment-str | |
10243 (verilog-sig-tieoff sig (not verilog-auto-reset-widths)) | |
10244 ";\n") | |
10245 (indent-to indent-pt) | |
10246 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10247 (insert "// End of automatics"))))) |
79545 | 10248 |
10249 (defun verilog-auto-tieoff () | |
10250 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto]. | |
10251 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output | |
10252 signals to deasserted. | |
10253 | |
10254 /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same | |
10255 input/output list as another module, but no internals. Specifically, it | |
10256 finds all outputs in the module, and if that input is not otherwise declared | |
10257 as a register or wire, creates a tieoff. | |
10258 | |
10259 AUTORESET ties signals to deasserted, which is presumed to be zero. | |
10260 Signals that match `verilog-active-low-regexp' will be deasserted by tieing | |
10261 them to a one. | |
10262 | |
10263 An example of making a stub for another module: | |
10264 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10265 module ExampStub (/*AUTOINST*/); |
79545 | 10266 /*AUTOINOUTMODULE(\"Foo\")*/ |
10267 /*AUTOTIEOFF*/ | |
10268 // verilator lint_off UNUSED | |
10269 wire _unused_ok = &{1'b0, | |
10270 /*AUTOUNUSED*/ | |
10271 1'b0}; | |
10272 // verilator lint_on UNUSED | |
10273 endmodule | |
10274 | |
10275 Typing \\[verilog-auto] will make this into: | |
10276 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10277 module ExampStub (/*AUTOINST*/...); |
79545 | 10278 /*AUTOINOUTMODULE(\"Foo\")*/ |
10279 // Beginning of autotieoff | |
10280 output [2:0] foo; | |
10281 // End of automatics | |
10282 | |
10283 /*AUTOTIEOFF*/ | |
10284 // Beginning of autotieoff | |
10285 wire [2:0] foo = 3'b0; | |
10286 // End of automatics | |
10287 ... | |
10288 endmodule" | |
10289 (interactive) | |
10290 (save-excursion | |
10291 ;; Find beginning | |
10292 (let* ((indent-pt (current-indentation)) | |
10293 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10294 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10295 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 10296 (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
|
10297 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10298 (append (verilog-decls-get-wires moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10299 (verilog-decls-get-regs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10300 (verilog-decls-get-assigns moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10301 (verilog-decls-get-consts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10302 (verilog-decls-get-gparams moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10303 (verilog-subdecls-get-outputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10304 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 10305 (when sig-list |
10306 (forward-line 1) | |
10307 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n") | |
10308 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
10309 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list | |
10310 (while sig-list | |
10311 (let ((sig (car sig-list))) | |
10312 (verilog-insert-one-definition sig "wire" indent-pt) | |
10313 (indent-to (max 48 (+ indent-pt 40))) | |
10314 (insert "= " (verilog-sig-tieoff sig) | |
10315 ";\n") | |
10316 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10317 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 10318 |
10319 (defun verilog-auto-unused () | |
10320 "Expand AUTOUNUSED statements, as part of \\[verilog-auto]. | |
10321 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused | |
10322 input and inout signals. | |
10323 | |
10324 /*AUTOUNUSED*/ is used to make stub modules; modules that have the same | |
10325 input/output list as another module, but no internals. Specifically, it | |
10326 finds all inputs and inouts in the module, and if that input is not otherwise | |
10327 used, adds it to a comma separated list. | |
10328 | |
10329 The comma separated list is intended to be used to create a _unused_ok | |
10330 signal. Using the exact name \"_unused_ok\" for name of the temporary | |
10331 signal is recommended as it will insure maximum forward compatibility, it | |
10332 also makes lint warnings easy to understand; ignore any unused warnings | |
10333 with \"unused\" in the signal name. | |
10334 | |
10335 To reduce simulation time, the _unused_ok signal should be forced to a | |
10336 constant to prevent wiggling. The easiest thing to do is use a | |
10337 reduction-and with 1'b0 as shown. | |
10338 | |
10339 This way all unused signals are in one place, making it convenient to add | |
10340 your tool's specific pragmas around the assignment to disable any unused | |
10341 warnings. | |
10342 | |
10343 You can add signals you do not want included in AUTOUNUSED with | |
10344 `verilog-auto-unused-ignore-regexp'. | |
10345 | |
10346 An example of making a stub for another module: | |
10347 | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10348 module ExampStub (/*AUTOINST*/); |
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10349 /*AUTOINOUTMODULE(\"Examp\")*/ |
79545 | 10350 /*AUTOTIEOFF*/ |
10351 // verilator lint_off UNUSED | |
10352 wire _unused_ok = &{1'b0, | |
10353 /*AUTOUNUSED*/ | |
10354 1'b0}; | |
10355 // verilator lint_on UNUSED | |
10356 endmodule | |
10357 | |
10358 Typing \\[verilog-auto] will make this into: | |
10359 | |
10360 ... | |
10361 // verilator lint_off UNUSED | |
10362 wire _unused_ok = &{1'b0, | |
10363 /*AUTOUNUSED*/ | |
10364 // Beginning of automatics | |
10365 unused_input_a, | |
10366 unused_input_b, | |
10367 unused_input_c, | |
10368 // End of automatics | |
10369 1'b0}; | |
10370 // verilator lint_on UNUSED | |
10371 endmodule" | |
10372 (interactive) | |
10373 (save-excursion | |
10374 ;; Find beginning | |
10375 (let* ((indent-pt (progn (search-backward "/*") (current-column))) | |
10376 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10377 (moddecls (verilog-modi-get-decls modi)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10378 (modsubdecls (verilog-modi-get-sub-decls modi)) |
79545 | 10379 (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
|
10380 (append (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10381 (verilog-decls-get-inouts moddecls)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10382 (append (verilog-subdecls-get-inputs modsubdecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10383 (verilog-subdecls-get-inouts modsubdecls))))) |
79545 | 10384 (setq sig-list (verilog-signals-not-matching-regexp |
10385 sig-list verilog-auto-unused-ignore-regexp)) | |
10386 (when sig-list | |
10387 (forward-line 1) | |
10388 (verilog-insert-indent "// Beginning of automatic unused inputs\n") | |
10389 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare)) | |
10390 (while sig-list | |
10391 (let ((sig (car sig-list))) | |
10392 (indent-to indent-pt) | |
10393 (insert (verilog-sig-name sig) ",\n") | |
10394 (setq sig-list (cdr sig-list)))) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10395 (verilog-insert-indent "// End of automatics\n"))))) |
79545 | 10396 |
10397 (defun verilog-enum-ascii (signm elim-regexp) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10398 "Convert an enum name SIGNM to an ascii string for insertion. |
79545 | 10399 Remove user provided prefix ELIM-REGEXP." |
10400 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_")) | |
10401 (let ((case-fold-search t)) | |
10402 ;; All upper becomes all lower for readability | |
10403 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm)))) | |
10404 | |
10405 (defun verilog-auto-ascii-enum () | |
10406 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto]. | |
10407 Create a register to contain the ASCII decode of a enumerated signal type. | |
10408 This will allow trace viewers to show the ASCII name of states. | |
10409 | |
10410 First, parameters are built into a enumeration using the synopsys enum | |
10411 comment. The comment must be between the keyword and the symbol. | |
79546 | 10412 \(Annoying, but that's what Synopsys's dc_shell FSM reader requires.) |
79545 | 10413 |
10414 Next, registers which that enum applies to are also tagged with the same | |
10415 enum. Synopsys also suggests labeling state vectors, but `verilog-mode' | |
10416 doesn't care. | |
10417 | |
10418 Finally, a AUTOASCIIENUM command is used. | |
10419 | |
10420 The first parameter is the name of the signal to be decoded. | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10421 If and only if the first parameter width is 2^(number of states |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10422 in enum) and does NOT match the width of the enum, the signal |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10423 is assumed to be a one hot decode. Otherwise, it's a normal |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10424 encoded state vector. |
79545 | 10425 |
10426 The second parameter is the name to store the ASCII code into. For the | |
10427 signal foo, I suggest the name _foo__ascii, where the leading _ indicates | |
10428 a signal that is just for simulation, and the magic characters _ascii | |
10429 tell viewers like Dinotrace to display in ASCII format. | |
10430 | |
10431 The final optional parameter is a string which will be removed from the | |
10432 state names. | |
10433 | |
10434 An example: | |
10435 | |
10436 //== State enumeration | |
10437 parameter [2:0] // synopsys enum state_info | |
10438 SM_IDLE = 3'b000, | |
10439 SM_SEND = 3'b001, | |
10440 SM_WAIT1 = 3'b010; | |
10441 //== State variables | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10442 reg [2:0] /* synopsys enum state_info */ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10443 state_r; /* synopsys state_vector state_r */ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10444 reg [2:0] /* synopsys enum state_info */ |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10445 state_e1; |
79545 | 10446 |
10447 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
10448 | |
10449 Typing \\[verilog-auto] will make this into: | |
10450 | |
10451 ... same front matter ... | |
10452 | |
10453 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/ | |
10454 // Beginning of automatic ASCII enum decoding | |
10455 reg [39:0] state_ascii_r; // Decode of state_r | |
10456 always @(state_r) begin | |
10457 case ({state_r}) | |
10458 SM_IDLE: state_ascii_r = \"idle \"; | |
10459 SM_SEND: state_ascii_r = \"send \"; | |
10460 SM_WAIT1: state_ascii_r = \"wait1\"; | |
10461 default: state_ascii_r = \"%Erro\"; | |
10462 endcase | |
10463 end | |
10464 // End of automatics" | |
10465 (save-excursion | |
10466 (let* ((params (verilog-read-auto-params 2 3)) | |
10467 (undecode-name (nth 0 params)) | |
10468 (ascii-name (nth 1 params)) | |
10469 (elim-regexp (nth 2 params)) | |
10470 ;; | |
10471 (indent-pt (current-indentation)) | |
10472 (modi (verilog-modi-current)) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10473 (moddecls (verilog-modi-get-decls modi)) |
79545 | 10474 ;; |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10475 (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
|
10476 (verilog-decls-get-gparams moddecls))) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10477 (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
|
10478 (verilog-decls-get-outputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10479 (verilog-decls-get-inouts moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10480 (verilog-decls-get-inputs moddecls) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10481 (verilog-decls-get-wires moddecls))) |
79545 | 10482 ;; |
10483 (undecode-sig (or (assoc undecode-name sig-list-all) | |
10484 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name))) | |
10485 (undecode-enum (or (verilog-sig-enum undecode-sig) | |
10486 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name))) | |
10487 ;; | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10488 (enum-sigs (verilog-signals-not-in |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10489 (or (verilog-signals-matching-enum sig-list-consts undecode-enum) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10490 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10491 nil)) |
79545 | 10492 ;; |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10493 (one-hot (and ;; width(enum) != width(sig) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10494 (or (not (verilog-sig-bits (car enum-sigs))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10495 (not (equal (verilog-sig-width (car enum-sigs)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10496 (verilog-sig-width undecode-sig)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10497 ;; count(enums) == width(sig) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10498 (equal (number-to-string (length enum-sigs)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10499 (verilog-sig-width undecode-sig)))) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10500 (enum-chars 0) |
79545 | 10501 (ascii-chars 0)) |
10502 ;; | |
10503 ;; Find number of ascii chars needed | |
10504 (let ((tmp-sigs enum-sigs)) | |
10505 (while tmp-sigs | |
10506 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs)))) | |
10507 ascii-chars (max ascii-chars (length (verilog-enum-ascii | |
10508 (verilog-sig-name (car tmp-sigs)) | |
10509 elim-regexp))) | |
10510 tmp-sigs (cdr tmp-sigs)))) | |
10511 ;; | |
10512 (forward-line 1) | |
10513 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n") | |
10514 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1)) | |
10515 (concat "Decode of " undecode-name) nil nil)))) | |
10516 (verilog-insert-definition decode-sig-list "reg" indent-pt nil) | |
10517 (verilog-modi-cache-add-regs modi decode-sig-list)) | |
10518 ;; | |
10519 (verilog-insert-indent "always @(" undecode-name ") begin\n") | |
10520 (setq indent-pt (+ indent-pt verilog-indent-level)) | |
10521 (indent-to indent-pt) | |
10522 (insert "case ({" undecode-name "})\n") | |
10523 (setq indent-pt (+ indent-pt verilog-case-indent)) | |
10524 ;; | |
10525 (let ((tmp-sigs enum-sigs) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10526 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10527 (+ (if one-hot 9 1) (max 8 enum-chars)) |
79545 | 10528 ascii-name ascii-chars)) |
10529 (errname (substring "%Error" 0 (min 6 ascii-chars)))) | |
10530 (while tmp-sigs | |
10531 (verilog-insert-indent | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10532 (concat |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10533 (format chrfmt |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10534 (concat (if one-hot "(") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10535 (if one-hot (verilog-sig-width undecode-sig)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10536 ;; We use a shift instead of var[index] |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10537 ;; so that a non-one hot value will show as error. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10538 (if one-hot "'b1<<") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10539 (verilog-sig-name (car tmp-sigs)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10540 (if one-hot ")") ":") |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10541 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs)) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10542 elim-regexp)))) |
79545 | 10543 (setq tmp-sigs (cdr tmp-sigs))) |
10544 (verilog-insert-indent (format chrfmt "default:" errname))) | |
10545 ;; | |
10546 (setq indent-pt (- indent-pt verilog-case-indent)) | |
10547 (verilog-insert-indent "endcase\n") | |
10548 (setq indent-pt (- indent-pt verilog-indent-level)) | |
10549 (verilog-insert-indent "end\n" | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10550 "// End of automatics\n")))) |
79545 | 10551 |
10552 (defun verilog-auto-templated-rel () | |
10553 "Replace Templated relative line numbers with absolute line numbers. | |
10554 Internal use only. This hacks around the line numbers in AUTOINST Templates | |
10555 being different from the final output's line numbering." | |
10556 (let ((templateno 0) (template-line (list 0))) | |
10557 ;; Find line number each template is on | |
10558 (goto-char (point-min)) | |
10559 (while (search-forward "AUTO_TEMPLATE" nil t) | |
10560 (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
|
10561 (setq template-line |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10562 (cons (count-lines (point-min) (point)) template-line))) |
79545 | 10563 (setq template-line (nreverse template-line)) |
10564 ;; Replace T# L# with absolute line number | |
10565 (goto-char (point-min)) | |
10566 (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
|
10567 (replace-match |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10568 (concat " Templated " |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10569 (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
|
10570 template-line) |
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
10571 (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
|
10572 t t)))) |
79545 | 10573 |
10574 | |
10575 ;; | |
10576 ;; Auto top level | |
10577 ;; | |
10578 | |
10579 (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg | |
10580 "Expand AUTO statements. | |
10581 Look for any /*AUTO...*/ commands in the code, as used in | |
10582 instantiations or argument headers. Update the list of signals | |
10583 following the /*AUTO...*/ command. | |
10584 | |
10585 Use \\[verilog-delete-auto] to remove the AUTOs. | |
10586 | |
10587 Use \\[verilog-inject-auto] to insert AUTOs for the first time. | |
10588 | |
10589 Use \\[verilog-faq] for a pointer to frequently asked questions. | |
10590 | |
10591 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are | |
10592 called before and after this function, respectively. | |
10593 | |
10594 For example: | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10595 module ModuleName (/*AUTOARG*/) |
79545 | 10596 /*AUTOINPUT*/ |
10597 /*AUTOOUTPUT*/ | |
10598 /*AUTOWIRE*/ | |
10599 /*AUTOREG*/ | |
93340
971b85f6050d
* progmodes/verilog-mode.el (verilog-auto-inout-module):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93195
diff
changeset
|
10600 InstMod instName #(/*AUTOINSTPARAM*/) (/*AUTOINST*/); |
79545 | 10601 |
10602 You can also update the AUTOs from the shell using: | |
10603 emacs --batch <filenames.v> -f verilog-batch-auto | |
10604 Or fix indentation with: | |
10605 emacs --batch <filenames.v> -f verilog-batch-indent | |
10606 Likewise, you can delete or inject AUTOs with: | |
10607 emacs --batch <filenames.v> -f verilog-batch-delete-auto | |
10608 emacs --batch <filenames.v> -f verilog-batch-inject-auto | |
10609 | |
10610 Using \\[describe-function], see also: | |
10611 `verilog-auto-arg' for AUTOARG module instantiations | |
10612 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
10613 `verilog-auto-inout-comp' for AUTOINOUTCOMP copy complemented i/o |
79545 | 10614 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere |
10615 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts | |
10616 `verilog-auto-input' for AUTOINPUT making hierarchy inputs | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10617 `verilog-auto-insert-lisp' for AUTOINSERTLISP insert code from lisp function |
79545 | 10618 `verilog-auto-inst' for AUTOINST instantiation pins |
10619 `verilog-auto-star' for AUTOINST .* SystemVerilog pins | |
10620 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params | |
10621 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs | |
10622 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs | |
10623 `verilog-auto-reg' for AUTOREG registers | |
10624 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers | |
10625 `verilog-auto-reset' for AUTORESET flop resets | |
10626 `verilog-auto-sense' for AUTOSENSE always sensitivity lists | |
10627 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs | |
10628 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts | |
10629 `verilog-auto-wire' for AUTOWIRE instantiation wires | |
10630 | |
10631 `verilog-read-defines' for reading `define values | |
10632 `verilog-read-includes' for reading `includes | |
10633 | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10634 If you have bugs with these autos, please file an issue at |
104029
55ba5af4bf3a
Kevin Ryde <user42 at zip.com.au>
Glenn Morris <rgm@gnu.org>
parents:
103980
diff
changeset
|
10635 URL `http://www.veripool.org/verilog-mode' or contact the AUTOAUTHOR |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10636 Wilson Snyder (wsnyder@wsnyder.org)." |
79545 | 10637 (interactive) |
10638 (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
|
10639 (if (fboundp 'dinotrace-unannotate-all) |
79545 | 10640 (dinotrace-unannotate-all)) |
10641 (let ((oldbuf (if (not (buffer-modified-p)) | |
10642 (buffer-string))) | |
10643 ;; Before version 20, match-string with font-lock returns a | |
10644 ;; vector that is not equal to the string. IE if on "input" | |
10645 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0))) | |
10646 (fontlocked (when (and (boundp 'font-lock-mode) | |
10647 font-lock-mode) | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
10648 (font-lock-mode 0) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10649 t)) |
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10650 ;; 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
|
10651 (verilog-dir-cache-preserving t)) |
79545 | 10652 (unwind-protect |
10653 (save-excursion | |
10654 ;; If we're not in verilog-mode, change syntax table so parsing works right | |
10655 (unless (eq major-mode `verilog-mode) (verilog-mode)) | |
10656 ;; Allow user to customize | |
10657 (run-hooks 'verilog-before-auto-hook) | |
10658 ;; Try to save the user from needing to revert-file to reread file local-variables | |
10659 (verilog-auto-reeval-locals) | |
10660 (verilog-read-auto-lisp (point-min) (point-max)) | |
10661 (verilog-getopt-flags) | |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10662 ;; 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
|
10663 (verilog-preserve-dir-cache |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10664 ;; 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
|
10665 (when verilog-auto-read-includes |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10666 (verilog-read-includes) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10667 (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
|
10668 ;; This particular ordering is important |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10669 ;; 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
|
10670 (verilog-preserve-modi-cache |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10671 ;; 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
|
10672 (verilog-delete-auto) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10673 ;; Injection if appropriate |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10674 (when inject |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10675 (verilog-inject-inst) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10676 (verilog-inject-sense) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10677 (verilog-inject-arg)) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10678 ;; |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10679 ;; Do user inserts first, so their code can insert AUTOs |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10680 ;; We may provide a AUTOINSERTLISPLAST if another cleanup pass is needed |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10681 (verilog-auto-re-search-do "/\\*AUTOINSERTLISP(.*?)\\*/" |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10682 'verilog-auto-insert-lisp) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10683 ;; Expand instances before need the signals the instances input/output |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10684 (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
|
10685 (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
|
10686 (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
|
10687 ;; 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
|
10688 (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
|
10689 (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
|
10690 ;; 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
|
10691 (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
|
10692 ;; |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10693 ;; 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
|
10694 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
10695 (verilog-auto-re-search-do "/\\*AUTOINOUTCOMP([^)]*)\\*/" 'verilog-auto-inout-comp) |
94760
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10696 ;; 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
|
10697 (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
|
10698 '(lambda () (verilog-auto-output t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10699 (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
|
10700 (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
|
10701 '(lambda () (verilog-auto-input t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10702 (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
|
10703 (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
|
10704 '(lambda () (verilog-auto-inout t))) |
e087ad93ebd1
(verilog-type-font-keywords): Add leda and 0in
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94691
diff
changeset
|
10705 (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
|
10706 ;; 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
|
10707 (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
|
10708 ;; 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
|
10709 (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
|
10710 (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
|
10711 (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
|
10712 ;; outputevery needs AUTOOUTPUTs done first |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10713 (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
|
10714 ;; 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
|
10715 (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
|
10716 ;; 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
|
10717 (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
|
10718 ;; Fix line numbers (comments only) |
94691
54ad2e16eccb
(verilog-getopt-file): Cleanup warning message format.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94673
diff
changeset
|
10719 (verilog-auto-templated-rel))) |
79545 | 10720 ;; |
10721 (run-hooks 'verilog-auto-hook) | |
10722 ;; | |
10723 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick)) | |
10724 ;; | |
10725 ;; If end result is same as when started, clear modified flag | |
10726 (cond ((and oldbuf (equal oldbuf (buffer-string))) | |
10727 (set-buffer-modified-p nil) | |
10728 (unless noninteractive (message "Updating AUTOs...done (no changes)"))) | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
10729 (t (unless noninteractive (message "Updating AUTOs...done"))))) |
79545 | 10730 ;; Unwind forms |
10731 (progn | |
10732 ;; Restore font-lock | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
10733 (when fontlocked (font-lock-mode t)))))) |
79545 | 10734 |
10735 | |
10736 ;; | |
10737 ;; Skeleton based code insertion | |
10738 ;; | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
10739 (defvar verilog-template-map |
79546 | 10740 (let ((map (make-sparse-keymap))) |
10741 (define-key map "a" 'verilog-sk-always) | |
10742 (define-key map "b" 'verilog-sk-begin) | |
10743 (define-key map "c" 'verilog-sk-case) | |
10744 (define-key map "f" 'verilog-sk-for) | |
10745 (define-key map "g" 'verilog-sk-generate) | |
10746 (define-key map "h" 'verilog-sk-header) | |
10747 (define-key map "i" 'verilog-sk-initial) | |
10748 (define-key map "j" 'verilog-sk-fork) | |
10749 (define-key map "m" 'verilog-sk-module) | |
10750 (define-key map "p" 'verilog-sk-primitive) | |
10751 (define-key map "r" 'verilog-sk-repeat) | |
10752 (define-key map "s" 'verilog-sk-specify) | |
10753 (define-key map "t" 'verilog-sk-task) | |
10754 (define-key map "w" 'verilog-sk-while) | |
10755 (define-key map "x" 'verilog-sk-casex) | |
10756 (define-key map "z" 'verilog-sk-casez) | |
10757 (define-key map "?" 'verilog-sk-if) | |
10758 (define-key map ":" 'verilog-sk-else-if) | |
10759 (define-key map "/" 'verilog-sk-comment) | |
10760 (define-key map "A" 'verilog-sk-assign) | |
10761 (define-key map "F" 'verilog-sk-function) | |
10762 (define-key map "I" 'verilog-sk-input) | |
10763 (define-key map "O" 'verilog-sk-output) | |
10764 (define-key map "S" 'verilog-sk-state-machine) | |
10765 (define-key map "=" 'verilog-sk-inout) | |
10766 (define-key map "W" 'verilog-sk-wire) | |
10767 (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
|
10768 (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
|
10769 map) |
79545 | 10770 "Keymap used in Verilog mode for smart template operations.") |
10771 | |
10772 | |
10773 ;; | |
10774 ;; Place the templates into Verilog Mode. They may be inserted under any key. | |
10775 ;; C-c C-t will be the default. If you use templates a lot, you | |
10776 ;; may want to consider moving the binding to another key in your .emacs | |
10777 ;; file. | |
10778 ;; | |
10779 ;(define-key verilog-mode-map "\C-ct" verilog-template-map) | |
10780 (define-key verilog-mode-map "\C-c\C-t" verilog-template-map) | |
10781 | |
10782 ;;; ---- statement skeletons ------------------------------------------ | |
10783 | |
10784 (define-skeleton verilog-sk-prompt-condition | |
10785 "Prompt for the loop condition." | |
10786 "[condition]: " str ) | |
10787 | |
10788 (define-skeleton verilog-sk-prompt-init | |
10789 "Prompt for the loop init statement." | |
10790 "[initial statement]: " str ) | |
10791 | |
10792 (define-skeleton verilog-sk-prompt-inc | |
10793 "Prompt for the loop increment statement." | |
10794 "[increment statement]: " str ) | |
10795 | |
10796 (define-skeleton verilog-sk-prompt-name | |
10797 "Prompt for the name of something." | |
10798 "[name]: " str) | |
10799 | |
10800 (define-skeleton verilog-sk-prompt-clock | |
10801 "Prompt for the name of something." | |
10802 "name and edge of clock(s): " str) | |
10803 | |
10804 (defvar verilog-sk-reset nil) | |
10805 (defun verilog-sk-prompt-reset () | |
10806 "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
|
10807 (setq verilog-sk-reset (read-string "name of reset: " "rst"))) |
79545 | 10808 |
10809 | |
10810 (define-skeleton verilog-sk-prompt-state-selector | |
10811 "Prompt for the name of a state machine selector." | |
10812 "name of selector (eg {a,b,c,d}): " str ) | |
10813 | |
10814 (define-skeleton verilog-sk-prompt-output | |
10815 "Prompt for the name of something." | |
10816 "output: " str) | |
10817 | |
10818 (define-skeleton verilog-sk-prompt-msb | |
10819 "Prompt for least significant bit specification." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10820 "msb:" str & ?: & '(verilog-sk-prompt-lsb) | -1 ) |
79545 | 10821 |
10822 (define-skeleton verilog-sk-prompt-lsb | |
10823 "Prompt for least significant bit specification." | |
10824 "lsb:" str ) | |
10825 | |
10826 (defvar verilog-sk-p nil) | |
10827 (define-skeleton verilog-sk-prompt-width | |
10828 "Prompt for a width specification." | |
10829 () | |
10830 (progn | |
10831 (setq verilog-sk-p (point)) | |
10832 (verilog-sk-prompt-msb) | |
10833 (if (> (point) verilog-sk-p) "] " " "))) | |
10834 | |
10835 (defun verilog-sk-header () | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10836 "Insert a descriptive header at the top of the file. |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10837 See also `verilog-header' for an alternative format." |
79545 | 10838 (interactive "*") |
10839 (save-excursion | |
10840 (goto-char (point-min)) | |
10841 (verilog-sk-header-tmpl))) | |
10842 | |
10843 (define-skeleton verilog-sk-header-tmpl | |
10844 "Insert a comment block containing the module title, author, etc." | |
10845 "[Description]: " | |
10846 "// -*- Mode: Verilog -*-" | |
10847 "\n// Filename : " (buffer-name) | |
10848 "\n// Description : " str | |
10849 "\n// Author : " (user-full-name) | |
10850 "\n// Created On : " (current-time-string) | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10851 "\n// Last Modified By: " (user-full-name) |
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10852 "\n// Last Modified On: " (current-time-string) |
79545 | 10853 "\n// Update Count : 0" |
10854 "\n// Status : Unknown, Use with caution!" | |
10855 "\n") | |
10856 | |
10857 (define-skeleton verilog-sk-module | |
10858 "Insert a module definition." | |
10859 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10860 > "module " '(verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n |
79545 | 10861 > _ \n |
10862 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil)) | |
10863 | |
10864 (define-skeleton verilog-sk-primitive | |
10865 "Insert a task definition." | |
10866 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10867 > "primitive " '(verilog-sk-prompt-name) " ( " '(verilog-sk-prompt-output) ("input:" ", " str ) " );"\n |
79545 | 10868 > _ \n |
10869 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil)) | |
10870 | |
10871 (define-skeleton verilog-sk-task | |
10872 "Insert a task definition." | |
10873 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10874 > "task " '(verilog-sk-prompt-name) & ?; \n |
79545 | 10875 > _ \n |
10876 > "begin" \n | |
10877 > \n | |
10878 > (- verilog-indent-level-behavioral) "end" \n | |
10879 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil)) | |
10880 | |
10881 (define-skeleton verilog-sk-function | |
10882 "Insert a function definition." | |
10883 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10884 > "function [" '(verilog-sk-prompt-width) | -1 '(verilog-sk-prompt-name) ?; \n |
79545 | 10885 > _ \n |
10886 > "begin" \n | |
10887 > \n | |
10888 > (- verilog-indent-level-behavioral) "end" \n | |
10889 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil)) | |
10890 | |
10891 (define-skeleton verilog-sk-always | |
10892 "Insert always block. Uses the minibuffer to prompt | |
10893 for sensitivity list." | |
10894 () | |
10895 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
10896 > _ \n | |
10897 > (- verilog-indent-level-behavioral) "end" \n > | |
10898 ) | |
10899 | |
10900 (define-skeleton verilog-sk-initial | |
10901 "Insert an initial block." | |
10902 () | |
10903 > "initial begin\n" | |
10904 > _ \n | |
10905 > (- verilog-indent-level-behavioral) "end" \n > ) | |
10906 | |
10907 (define-skeleton verilog-sk-specify | |
10908 "Insert specify block. " | |
10909 () | |
10910 > "specify\n" | |
10911 > _ \n | |
10912 > (- verilog-indent-level-behavioral) "endspecify" \n > ) | |
10913 | |
10914 (define-skeleton verilog-sk-generate | |
10915 "Insert generate block. " | |
10916 () | |
10917 > "generate\n" | |
10918 > _ \n | |
10919 > (- verilog-indent-level-behavioral) "endgenerate" \n > ) | |
10920 | |
10921 (define-skeleton verilog-sk-begin | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10922 "Insert begin end block. Uses the minibuffer to prompt for name." |
79545 | 10923 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10924 > "begin" '(verilog-sk-prompt-name) \n |
79545 | 10925 > _ \n |
10926 > (- verilog-indent-level-behavioral) "end" | |
10927 ) | |
10928 | |
10929 (define-skeleton verilog-sk-fork | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10930 "Insert a fork join block." |
79545 | 10931 () |
10932 > "fork\n" | |
10933 > "begin" \n | |
10934 > _ \n | |
10935 > (- verilog-indent-level-behavioral) "end" \n | |
10936 > "begin" \n | |
10937 > \n | |
10938 > (- verilog-indent-level-behavioral) "end" \n | |
10939 > (- verilog-indent-level-behavioral) "join" \n | |
10940 > ) | |
10941 | |
10942 | |
10943 (define-skeleton verilog-sk-case | |
10944 "Build skeleton case statement, prompting for the selector expression, | |
10945 and the case items." | |
10946 "[selector expression]: " | |
10947 > "case (" str ") " \n | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10948 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n > ) |
79545 | 10949 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) |
10950 | |
10951 (define-skeleton verilog-sk-casex | |
10952 "Build skeleton casex statement, prompting for the selector expression, | |
10953 and the case items." | |
10954 "[selector expression]: " | |
10955 > "casex (" str ") " \n | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10956 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n > ) |
79545 | 10957 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) |
10958 | |
10959 (define-skeleton verilog-sk-casez | |
10960 "Build skeleton casez statement, prompting for the selector expression, | |
10961 and the case items." | |
10962 "[selector expression]: " | |
10963 > "casez (" str ") " \n | |
103616
af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
101958
diff
changeset
|
10964 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n > ) |
79545 | 10965 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)) |
10966 | |
10967 (define-skeleton verilog-sk-if | |
10968 "Insert a skeleton if statement." | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10969 > "if (" '(verilog-sk-prompt-condition) & ")" " begin" \n |
79545 | 10970 > _ \n |
10971 > (- verilog-indent-level-behavioral) "end " \n ) | |
10972 | |
10973 (define-skeleton verilog-sk-else-if | |
10974 "Insert a skeleton else if statement." | |
10975 > (verilog-indent-line) "else if (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10976 (progn (setq verilog-sk-p (point)) nil) '(verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n |
79545 | 10977 > _ \n |
10978 > "end" (progn (electric-verilog-terminate-line) nil)) | |
10979 | |
10980 (define-skeleton verilog-sk-datadef | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
10981 "Common routine to get data definition." |
79545 | 10982 () |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10983 '(verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n) |
79545 | 10984 |
10985 (define-skeleton verilog-sk-input | |
10986 "Insert an input definition." | |
10987 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10988 > "input [" '(verilog-sk-datadef)) |
79545 | 10989 |
10990 (define-skeleton verilog-sk-output | |
10991 "Insert an output definition." | |
10992 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10993 > "output [" '(verilog-sk-datadef)) |
79545 | 10994 |
10995 (define-skeleton verilog-sk-inout | |
10996 "Insert an inout definition." | |
10997 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
10998 > "inout [" '(verilog-sk-datadef)) |
79545 | 10999 |
11000 (defvar verilog-sk-signal nil) | |
11001 (define-skeleton verilog-sk-def-reg | |
11002 "Insert a reg definition." | |
11003 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11004 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) ) |
79545 | 11005 |
11006 (defun verilog-sk-define-signal () | |
11007 "Insert a definition of signal under point at top of module." | |
11008 (interactive "*") | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11009 (let* ((sig-re "[a-zA-Z0-9_]*") |
79545 | 11010 (v1 (buffer-substring |
11011 (save-excursion | |
11012 (skip-chars-backward sig-re) | |
11013 (point)) | |
11014 (save-excursion | |
11015 (skip-chars-forward sig-re) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11016 (point))))) |
79545 | 11017 (if (not (member v1 verilog-keywords)) |
11018 (save-excursion | |
11019 (setq verilog-sk-signal v1) | |
11020 (verilog-beg-of-defun) | |
11021 (verilog-end-of-statement) | |
11022 (verilog-forward-syntactic-ws) | |
11023 (verilog-sk-def-reg) | |
11024 (message "signal at point is %s" v1)) | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11025 (message "object at point (%s) is a keyword" v1)))) |
79545 | 11026 |
11027 (define-skeleton verilog-sk-wire | |
11028 "Insert a wire definition." | |
11029 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11030 > "wire [" '(verilog-sk-datadef)) |
79545 | 11031 |
11032 (define-skeleton verilog-sk-reg | |
11033 "Insert a reg definition." | |
11034 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11035 > "reg [" '(verilog-sk-datadef)) |
79545 | 11036 |
11037 (define-skeleton verilog-sk-assign | |
11038 "Insert a skeleton assign statement." | |
11039 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11040 > "assign " '(verilog-sk-prompt-name) " = " _ ";" \n) |
79545 | 11041 |
11042 (define-skeleton verilog-sk-while | |
11043 "Insert a skeleton while loop statement." | |
11044 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11045 > "while (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 11046 > _ \n |
11047 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
11048 | |
11049 (define-skeleton verilog-sk-repeat | |
11050 "Insert a skeleton repeat loop statement." | |
11051 () | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11052 > "repeat (" '(verilog-sk-prompt-condition) ") begin" \n |
79545 | 11053 > _ \n |
11054 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
11055 | |
11056 (define-skeleton verilog-sk-for | |
11057 "Insert a skeleton while loop statement." | |
11058 () | |
11059 > "for (" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11060 '(verilog-sk-prompt-init) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11061 '(verilog-sk-prompt-condition) "; " |
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11062 '(verilog-sk-prompt-inc) |
79545 | 11063 ") begin" \n |
11064 > _ \n | |
11065 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil)) | |
11066 | |
11067 (define-skeleton verilog-sk-comment | |
11068 "Inserts three comment lines, making a display comment." | |
11069 () | |
11070 > "/*\n" | |
11071 > "* " _ \n | |
11072 > "*/") | |
11073 | |
11074 (define-skeleton verilog-sk-state-machine | |
11075 "Insert a state machine definition." | |
11076 "Name of state variable: " | |
11077 '(setq input "state") | |
11078 > "// State registers for " str | -23 \n | |
11079 '(setq verilog-sk-state str) | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11080 > "reg [" '(verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n |
79545 | 11081 '(setq input nil) |
11082 > \n | |
11083 > "// State FF for " verilog-sk-state \n | |
11084 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n | |
11085 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n | |
11086 > verilog-sk-state " = next_" verilog-sk-state ?; \n | |
11087 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil) | |
11088 > \n | |
11089 > "// Next State Logic for " verilog-sk-state \n | |
11090 > "always @ ( /*AUTOSENSE*/ ) begin\n" | |
79986
c592638ac955
(verilog-sk-prompt-msb)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79810
diff
changeset
|
11091 > "case (" '(verilog-sk-prompt-state-selector) ") " \n |
79545 | 11092 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n ) |
11093 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil) | |
11094 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)) | |
11095 | |
11096 | |
11097 ;; | |
11098 ;; Include file loading with mouse/return event | |
11099 ;; | |
11100 ;; idea & first impl.: M. Rouat (eldo-mode.el) | |
11101 ;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el) | |
11102 | |
11103 (if (featurep 'xemacs) | |
104581
03bf18369e45
(top-level): Don't require lucid (and hence run-time cl).
Glenn Morris <rgm@gnu.org>
parents:
104029
diff
changeset
|
11104 (require 'overlay)) |
79545 | 11105 |
11106 (defconst verilog-include-file-regexp | |
11107 "^`include\\s-+\"\\([^\n\"]*\\)\"" | |
11108 "Regexp that matches the include file.") | |
11109 | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11110 (defvar verilog-mode-mouse-map |
79545 | 11111 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map |
11112 (set-keymap-parent map verilog-mode-map) | |
11113 ;; mouse button bindings | |
11114 (define-key map "\r" 'verilog-load-file-at-point) | |
11115 (if (featurep 'xemacs) | |
11116 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ? | |
11117 (define-key map [mouse-2] 'verilog-load-file-at-mouse)) | |
11118 (if (featurep 'xemacs) | |
11119 (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
|
11120 (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
|
11121 map) |
79546 | 11122 "Map containing mouse bindings for `verilog-mode'.") |
11123 | |
79545 | 11124 |
11125 (defun verilog-colorize-include-files (beg end old-len) | |
11126 "This function colorizes included files when the mouse passes over them. | |
11127 Clicking on the middle-mouse button loads them in a buffer (as in dired)." | |
11128 (save-excursion | |
11129 (save-match-data | |
11130 (let (end-point) | |
11131 (goto-char end) | |
11132 (setq end-point (verilog-get-end-of-line)) | |
11133 (goto-char beg) | |
11134 (beginning-of-line) ; scan entire line ! | |
11135 ;; delete overlays existing on this line | |
11136 (let ((overlays (overlays-in (point) end-point))) | |
11137 (while overlays | |
11138 (if (and | |
11139 (overlay-get (car overlays) 'detachable) | |
11140 (overlay-get (car overlays) 'verilog-include-file)) | |
11141 (delete-overlay (car overlays))) | |
11142 (setq overlays (cdr overlays)))) ; let | |
11143 ;; make new ones, could reuse deleted one ? | |
11144 (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
|
11145 (let (ov) |
79545 | 11146 (goto-char (match-beginning 1)) |
79550
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
11147 (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
|
11148 (overlay-put ov 'start-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
11149 (overlay-put ov 'end-closed 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
11150 (overlay-put ov 'evaporate 't) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
11151 (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
|
11152 (overlay-put ov 'mouse-face 'highlight) |
7f3b93a179a2
* progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79549
diff
changeset
|
11153 (overlay-put ov 'local-map verilog-mode-mouse-map))))))) |
79545 | 11154 |
11155 | |
11156 (defun verilog-colorize-include-files-buffer () | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
11157 "Colorize an include file." |
79545 | 11158 (interactive) |
11159 ;; delete overlays | |
11160 (let ((overlays (overlays-in (point-min) (point-max)))) | |
11161 (while overlays | |
11162 (if (and | |
11163 (overlay-get (car overlays) 'detachable) | |
11164 (overlay-get (car overlays) 'verilog-include-file)) | |
11165 (delete-overlay (car overlays))) | |
11166 (setq overlays (cdr overlays)))) ; let | |
11167 ;; remake overlays | |
11168 (verilog-colorize-include-files (point-min) (point-max) nil)) | |
11169 | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
11170 ;; ffap-at-mouse isn't useful for Verilog mode. It uses library paths. |
79545 | 11171 ;; so define this function to do more or less the same as ffap-at-mouse |
11172 ;; but first resolve filename... | |
11173 (defun verilog-load-file-at-mouse (event) | |
11174 "Load file under button 2 click's EVENT. | |
11175 Files are checked based on `verilog-library-directories'." | |
11176 (interactive "@e") | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
11177 (save-excursion ;; implement a Verilog specific ffap-at-mouse |
79545 | 11178 (mouse-set-point event) |
11179 (beginning-of-line) | |
11180 (if (looking-at verilog-include-file-regexp) | |
11181 (if (and (car (verilog-library-filenames | |
11182 (match-string 1) (buffer-file-name))) | |
11183 (file-readable-p (car (verilog-library-filenames | |
11184 (match-string 1) (buffer-file-name))))) | |
11185 (find-file (car (verilog-library-filenames | |
11186 (match-string 1) (buffer-file-name)))) | |
11187 (progn | |
11188 (message | |
11189 "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
|
11190 (match-string 1))))))) |
79545 | 11191 |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
11192 ;; ffap isn't useable for Verilog mode. It uses library paths. |
79545 | 11193 ;; so define this function to do more or less the same as ffap |
11194 ;; but first resolve filename... | |
11195 (defun verilog-load-file-at-point () | |
11196 "Load file under point. | |
11197 Files are checked based on `verilog-library-directories'." | |
11198 (interactive) | |
80165
411da0873a97
Re-commit doc fixes accidentally reverted.
Juanma Barranquero <lekktu@gmail.com>
parents:
80163
diff
changeset
|
11199 (save-excursion ;; implement a Verilog specific ffap |
79545 | 11200 (beginning-of-line) |
11201 (if (looking-at verilog-include-file-regexp) | |
11202 (if (and | |
11203 (car (verilog-library-filenames | |
11204 (match-string 1) (buffer-file-name))) | |
11205 (file-readable-p (car (verilog-library-filenames | |
11206 (match-string 1) (buffer-file-name))))) | |
11207 (find-file (car (verilog-library-filenames | |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11208 (match-string 1) (buffer-file-name)))))))) |
79545 | 11209 |
11210 | |
11211 ;; | |
11212 ;; Bug reporting | |
11213 ;; | |
11214 | |
11215 (defun verilog-faq () | |
11216 "Tell the user their current version, and where to get the FAQ etc." | |
11217 (interactive) | |
11218 (with-output-to-temp-buffer "*verilog-mode help*" | |
11219 (princ (format "You are using verilog-mode %s\n" verilog-mode-version)) | |
11220 (princ "\n") | |
11221 (princ "For new releases, see http://www.verilog.com\n") | |
11222 (princ "\n") | |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
11223 (princ "For frequently asked questions, see http://www.veripool.org/verilog-mode-faq.html\n") |
79545 | 11224 (princ "\n") |
11225 (princ "To submit a bug, use M-x verilog-submit-bug-report\n") | |
11226 (princ "\n"))) | |
11227 | |
79691
d3e3c91e18f6
* progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79555
diff
changeset
|
11228 (autoload 'reporter-submit-bug-report "reporter") |
79799
57956dd69d3f
(top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79717
diff
changeset
|
11229 (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
|
11230 |
79545 | 11231 (defun verilog-submit-bug-report () |
11232 "Submit via mail a bug report on verilog-mode.el." | |
11233 (interactive) | |
11234 (let ((reporter-prompt-for-summary-p t)) | |
11235 (reporter-submit-bug-report | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11236 "mac@verilog.com, wsnyder@wsnyder.org" |
79545 | 11237 (concat "verilog-mode v" verilog-mode-version) |
11238 '( | |
11239 verilog-align-ifelse | |
11240 verilog-auto-endcomments | |
11241 verilog-auto-hook | |
11242 verilog-auto-indent-on-newline | |
11243 verilog-auto-inst-vector | |
11244 verilog-auto-inst-template-numbers | |
11245 verilog-auto-lineup | |
11246 verilog-auto-newline | |
11247 verilog-auto-save-policy | |
11248 verilog-auto-sense-defines-constant | |
11249 verilog-auto-sense-include-inputs | |
11250 verilog-before-auto-hook | |
11251 verilog-case-indent | |
11252 verilog-cexp-indent | |
11253 verilog-compiler | |
11254 verilog-coverage | |
11255 verilog-highlight-translate-off | |
11256 verilog-indent-begin-after-if | |
11257 verilog-indent-declaration-macros | |
11258 verilog-indent-level | |
11259 verilog-indent-level-behavioral | |
11260 verilog-indent-level-declaration | |
11261 verilog-indent-level-directive | |
11262 verilog-indent-level-module | |
11263 verilog-indent-lists | |
11264 verilog-library-flags | |
11265 verilog-library-directories | |
11266 verilog-library-extensions | |
11267 verilog-library-files | |
11268 verilog-linter | |
11269 verilog-minimum-comment-distance | |
11270 verilog-mode-hook | |
11271 verilog-simulator | |
11272 verilog-tab-always-indent | |
11273 verilog-tab-to-comment | |
11274 ) | |
11275 nil nil | |
11276 (concat "Hi Mac, | |
11277 | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11278 I want to report a bug. |
79545 | 11279 |
11280 Before I go further, I want to say that Verilog mode has changed my life. | |
11281 I save so much time, my files are colored nicely, my co workers respect | |
11282 my coding ability... until now. I'd really appreciate anything you | |
11283 could do to help me out with this minor deficiency in the product. | |
11284 | |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11285 I've taken a look at the Verilog-Mode FAQ at |
98007
883843ca3292
* verilog-mode.el (verilog-library-extensions): Enable .sv
Dan Nicolaescu <dann@ics.uci.edu>
parents:
97107
diff
changeset
|
11286 http://www.veripool.org/verilog-mode-faq.html. |
79545 | 11287 |
106534
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11288 And, I've considered filing the bug on the issue tracker at |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11289 http://www.veripool.org/verilog-mode-bugs |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11290 since I realize that public bugs are easier for you to track, |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11291 and for others to search, but would prefer to email. |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11292 |
cad98e90ecc5
* verilog-mode.el (verilog-vmm-begin-re, verilog-vmm-end-re,
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106265
diff
changeset
|
11293 So, 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
|
11294 -no-init-file -no-site-file'. In a new buffer, in Verilog mode, type |
79545 | 11295 the code included below. |
11296 | |
11297 Given those lines, I expected [[Fill in here]] to happen; | |
11298 but instead, [[Fill in here]] happens!. | |
11299 | |
11300 == The code: ==")))) | |
11301 | |
79546 | 11302 (provide 'verilog-mode) |
11303 | |
79545 | 11304 ;; Local Variables: |
11305 ;; checkdoc-permit-comma-termination-flag:t | |
11306 ;; checkdoc-force-docstrings-flag:nil | |
11307 ;; End: | |
11308 | |
79552 | 11309 ;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f |
79545 | 11310 ;;; verilog-mode.el ends here |