annotate lisp/progmodes/verilog-mode.el @ 88071:1fcb6b1de8dc

*** empty log message ***
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 29 Jan 2008 21:13:00 +0000
parents 5d58981e6690
children 5c60e04e322f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1 ;; verilog-mode.el --- major mode for editing verilog source in Emacs
79551
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
2
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
79717
a1342e6e097a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79691
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6 ;; Author: Michael McNamara (mac@verilog.com)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7 ;; http://www.verilog.com
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9 ;; AUTO features, signal, modsig; by: Wilson Snyder
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10 ;; (wsnyder@wsnyder.org)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
11 ;; http://www.veripool.com
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
12 ;; Keywords: languages
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
13
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
14 ;; This code supports Emacs 21.1 and later
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
15 ;; And XEmacs 21.1 and later
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
16 ;; Please do not make changes that break Emacs 21. Thanks!
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
17 ;;
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
18 ;;
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
19
79551
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
20 ;; This file is part of GNU Emacs.
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
21
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
22 ;; GNU Emacs is free software; you can redistribute it and/or modify
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
23 ;; it under the terms of the GNU General Public License as published by
79551
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
24 ;; the Free Software Foundation; either version 3, or (at your option)
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
25 ;; any later version.
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
26
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
27 ;; GNU Emacs is distributed in the hope that it will be useful,
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
28 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
29 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
30 ;; GNU General Public License for more details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
31
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
32 ;; You should have received a copy of the GNU General Public License
79551
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
33 ;; along with GNU Emacs; see the file COPYING. If not, write to the
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
34 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
ae0b1b4444b5 Fix copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79550
diff changeset
35 ;; Boston, MA 02110-1301, USA.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
36
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
37 ;;; Commentary:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
38
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
39 ;; This mode borrows heavily from the Pascal-mode and the cc-mode of Emacs
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
40
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
41 ;; USAGE
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
42 ;; =====
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
43
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
44 ;; A major mode for editing Verilog HDL source code. When you have
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
45 ;; entered Verilog mode, you may get more info by pressing C-h m. You
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
46 ;; may also get online help describing various functions by: C-h f
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
47 ;; <Name of function you want described>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
48
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
49 ;; KNOWN BUGS / BUG REPORTS
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
50 ;; =======================
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
51
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
52 ;; Verilog is a rapidly evolving language, and hence this mode is
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
53 ;; under continuous development. Hence this is beta code, and likely
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
54 ;; has bugs. Please report any and all bugs to me at mac@verilog.com.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
55 ;; Please use verilog-submit-bug-report to submit a report; type C-c
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
56 ;; C-b to invoke this and as a result I will have a much easier time
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
57 ;; of reproducing the bug you find, and hence fixing it.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
58
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
59 ;; INSTALLING THE MODE
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
60 ;; ===================
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
61
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
62 ;; An older version of this mode may be already installed as a part of
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
63 ;; your environment, and one method of updating would be to update
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
64 ;; your Emacs environment. Sometimes this is difficult for local
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
65 ;; political/control reasons, and hence you can always install a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
66 ;; private copy (or even a shared copy) which overrides the system
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
67 ;; default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
68
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
69 ;; You can get step by step help in installing this file by going to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
70 ;; <http://www.verilog.com/emacs_install.html>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
71
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
72 ;; The short list of installation instructions are: To set up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
73 ;; automatic verilog mode, put this file in your load path, and put
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
74 ;; the following in code (please un comment it first!) in your
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
75 ;; .emacs, or in your site's site-load.el
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
76
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
77 ; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
78 ; (setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
79 ; (setq auto-mode-alist (cons '("\\.dv\\'" . verilog-mode) auto-mode-alist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
80
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
81 ;; If you want to customize Verilog mode to fit your needs better,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
82 ;; you may add these lines (the values of the variables presented
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
83 ;; here are the defaults). Note also that if you use an Emacs that
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
84 ;; supports custom, it's probably better to use the custom menu to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
85 ;; edit these.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
86 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
87 ;; Be sure to examine at the help for verilog-auto, and the other
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
88 ;; verilog-auto-* functions for some major coding time savers.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
89 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
90 ; ;; User customization for Verilog mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
91 ; (setq verilog-indent-level 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
92 ; verilog-indent-level-module 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
93 ; verilog-indent-level-declaration 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
94 ; verilog-indent-level-behavioral 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
95 ; verilog-indent-level-directive 1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
96 ; verilog-case-indent 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
97 ; verilog-auto-newline t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
98 ; verilog-auto-indent-on-newline t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
99 ; verilog-tab-always-indent t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
100 ; verilog-auto-endcomments t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
101 ; verilog-minimum-comment-distance 40
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
102 ; verilog-indent-begin-after-if t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
103 ; verilog-auto-lineup '(all)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
104 ; verilog-highlight-p1800-keywords nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
105 ; verilog-linter "my_lint_shell_command"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
106 ; )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
107
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
108 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
109
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
110 ;;; History:
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
111 ;;
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
112 ;; See commit history at http://www.veripool.com/verilog-mode.html
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
113 ;; (This section is required to appease checkdoc.)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
114
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
115 ;;; Code:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
116
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
117 ;; This variable will always hold the version number of the mode
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
118 (defconst verilog-mode-version "383"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
119 "Version of this verilog mode.")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
120 (defconst verilog-mode-release-date "2008-01-07-GNU"
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
121 "Release date of this verilog mode.")
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
122 (defconst verilog-mode-release-emacs t
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
123 "If non-nil, this version of verilog mode was released with Emacs itself.")
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
124
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
125 (defun verilog-version ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
126 "Inform caller of the version of this file."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
127 (interactive)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
128 (message "Using verilog-mode version %s" verilog-mode-version))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
129
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
130 ;; Insure we have certain packages, and deal with it if we don't
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
131 ;; Be sure to note which Emacs flavor and version added each feature.
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
132 (eval-when-compile
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
133 ;; The below were disabled when GNU Emacs 22 was released;
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
134 ;; perhaps some still need to be there to support Emacs 21.
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
135 (when (featurep 'xemacs)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
136 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
137 (require 'easymenu)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
138 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
139 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
140 (require 'regexp-opt)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
141 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
142 ;; Bug in 19.28 through 19.30 skeleton.el, not provided.
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
143 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
144 (load "skeleton")
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
145 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
146 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
147 (if (fboundp 'when)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
148 nil ;; fab
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
149 (defmacro when (cond &rest body)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
150 (list 'if cond (cons 'progn body))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
151 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
152 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
153 (if (fboundp 'unless)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
154 nil ;; fab
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
155 (defmacro unless (cond &rest body)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
156 (cons 'if (cons cond (cons nil body)))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
157 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
158 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
159 (if (fboundp 'store-match-data)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
160 nil ;; fab
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
161 (defmacro store-match-data (&rest args) nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
162 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
163 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
164 (if (boundp 'current-menubar)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
165 nil ;; great
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
166 (progn
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
167 (defmacro add-submenu (&rest args) nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
168 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
169 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
170 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
171 (if (fboundp 'char-before)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
172 nil ;; great
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
173 (defmacro char-before (&rest body)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
174 (char-after (1- (point)))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
175 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
176 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
177 (require 'custom)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
178 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
179 (condition-case nil
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
180 (if (fboundp 'match-string-no-properties)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
181 nil ;; great
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
182 (defsubst match-string-no-properties (num &optional string)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
183 "Return string of text matched by last search, without text properties.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
184 NUM specifies which parenthesized expression in the last regexp.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
185 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
186 Zero means the entire text matched by the whole regexp or whole string.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
187 STRING should be given if the last search was by `string-match' on STRING."
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
188 (if (match-beginning num)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
189 (if string
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
190 (let ((result
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
191 (substring string
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
192 (match-beginning num) (match-end num))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
193 (set-text-properties 0 (length result) nil result)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
194 result)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
195 (buffer-substring-no-properties (match-beginning num)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
196 (match-end num)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
197 (current-buffer)))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
198 )
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
199 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
200 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
201 nil ;; We've got what we needed
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
202 ;; We have the old custom-library, hack around it!
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
203 (defmacro defgroup (&rest args) nil)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
204 (defmacro customize (&rest args)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
205 (message
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
206 "Sorry, Customize is not available with this version of emacs"))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
207 (defmacro defcustom (var value doc &rest args)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
208 `(defvar ,var ,value ,doc))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
209 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
210 (if (fboundp 'defface)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
211 nil ; great!
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
212 (defmacro defface (var values doc &rest args)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
213 `(make-face ,var))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
214 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
215
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
216 (if (and (featurep 'custom) (fboundp 'customize-group))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
217 nil ;; We've got what we needed
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
218 ;; We have an intermediate custom-library, hack around it!
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
219 (defmacro customize-group (var &rest args)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
220 `(customize ,var))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
221 )))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
222
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
223 ;; Provide a regular expression optimization routine, using regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
224 ;; if provided by the user's elisp libraries
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
225 (eval-and-compile
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
226 ;; The below were disabled when GNU Emacs 22 was released;
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
227 ;; perhaps some still need to be there to support Emacs 21.
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
228 (if (featurep 'xemacs)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
229 (if (fboundp 'regexp-opt)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
230 ;; regexp-opt is defined, does it take 3 or 2 arguments?
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
231 (if (fboundp 'function-max-args)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
232 (let ((args (function-max-args `regexp-opt)))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
233 (cond
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
234 ((eq args 3) ;; It takes 3
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
235 (condition-case nil ; Hide this defun from emacses
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
236 ;with just a two input regexp
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
237 (defun verilog-regexp-opt (a b)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
238 "Deal with differing number of required arguments for `regexp-opt'.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
239 Call 'regexp-opt' on A and B."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
240 (regexp-opt a b 't))
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
241 (error nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
242 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
243 ((eq args 2) ;; It takes 2
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
244 (defun verilog-regexp-opt (a b)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
245 "Call 'regexp-opt' on A and B."
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
246 (regexp-opt a b))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
247 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
248 (t nil)))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
249 ;; We can't tell; assume it takes 2
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
250 (defun verilog-regexp-opt (a b)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
251 "Call 'regexp-opt' on A and B."
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
252 (regexp-opt a b))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
253 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
254 ;; There is no regexp-opt, provide our own
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
255 (defun verilog-regexp-opt (strings &optional paren shy)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
256 (let ((open (if paren "\\(" "")) (close (if paren "\\)" "")))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
257 (concat open (mapconcat 'regexp-quote strings "\\|") close)))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
258 )
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
259 ;; Emacs.
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
260 (defalias 'verilog-regexp-opt 'regexp-opt)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
261
79555
52d2889ab3d8 (set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79554
diff changeset
262 (eval-when-compile
52d2889ab3d8 (set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79554
diff changeset
263 (defun verilog-regexp-words (a)
52d2889ab3d8 (set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79554
diff changeset
264 "Call 'regexp-opt' with word delimiters for the words A."
52d2889ab3d8 (set-buffer-menubar): Remove unused
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79554
diff changeset
265 (concat "\\<" (verilog-regexp-opt a t) "\\>")))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
266
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
267 (defun verilog-customize ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
268 "Link to customize screen for Verilog."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
269 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
270 (customize-group 'verilog-mode))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
271
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
272 (defun verilog-font-customize ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
273 "Link to customize fonts used for Verilog."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
274 (interactive)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
275 (if (fboundp 'customize-apropos)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
276 (customize-apropos "font-lock-*" 'faces)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
277
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
278 (defun verilog-booleanp (value)
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
279 "Return t if VALUE is boolean.
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
280 This implements GNU Emacs 22.1's `booleanp' function in earlier Emacs.
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
281 This function may be removed when Emacs 21 is no longer supported."
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
282 (or (equal value t) (equal value nil)))
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
283
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
284 (defgroup verilog-mode nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
285 "Facilitates easy editing of Verilog source text"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
286 :group 'languages)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
287
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
288 ; (defgroup verilog-mode-fonts nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
289 ; "Facilitates easy customization fonts used in Verilog source text"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
290 ; :link '(customize-apropos "font-lock-*" 'faces)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
291 ; :group 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
292
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
293 (defgroup verilog-mode-indent nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
294 "Customize indentation and highlighting of verilog source text"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
295 :group 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
296
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
297 (defgroup verilog-mode-actions nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
298 "Customize actions on verilog source text"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
299 :group 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
300
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
301 (defgroup verilog-mode-auto nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
302 "Customize AUTO actions when expanding verilog source text"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
303 :group 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
304
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
305 (defcustom verilog-linter
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
306 "echo 'No verilog-linter set, see \"M-x describe-variable verilog-linter\"'"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
307 "*Unix program and arguments to call to run a lint checker on verilog source.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
308 Depending on the `verilog-set-compile-command', this may be invoked when
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
309 you type \\[compile]. When the compile completes, \\[next-error] will take
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
310 you to the next lint error."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
311 :type 'string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
312 :group 'verilog-mode-actions)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
313 ;; We don't mark it safe, as it's used as a shell command
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
314
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
315 (defcustom verilog-coverage
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
316 "echo 'No verilog-coverage set, see \"M-x describe-variable verilog-coverage\"'"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
317 "*Program and arguments to use to annotate for coverage verilog source.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
318 Depending on the `verilog-set-compile-command', this may be invoked when
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
319 you type \\[compile]. When the compile completes, \\[next-error] will take
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
320 you to the next lint error."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
321 :type 'string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
322 :group 'verilog-mode-actions)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
323 ;; We don't mark it safe, as it's used as a shell command
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
324
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
325 (defcustom verilog-simulator
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
326 "echo 'No verilog-simulator set, see \"M-x describe-variable verilog-simulator\"'"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
327 "*Program and arguments to use to interpret verilog source.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
328 Depending on the `verilog-set-compile-command', this may be invoked when
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
329 you type \\[compile]. When the compile completes, \\[next-error] will take
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
330 you to the next lint error."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
331 :type 'string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
332 :group 'verilog-mode-actions)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
333 ;; We don't mark it safe, as it's used as a shell command
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
334
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
335 (defcustom verilog-compiler
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
336 "echo 'No verilog-compiler set, see \"M-x describe-variable verilog-compiler\"'"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
337 "*Program and arguments to use to compile verilog source.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
338 Depending on the `verilog-set-compile-command', this may be invoked when
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
339 you type \\[compile]. When the compile completes, \\[next-error] will take
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
340 you to the next lint error."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
341 :type 'string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
342 :group 'verilog-mode-actions)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
343 ;; We don't mark it safe, as it's used as a shell command
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
344
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
345 (defvar verilog-tool 'verilog-linter
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
346 "Which tool to use for building compiler-command.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
347 Either nil, `verilog-linter, `verilog-coverage, `verilog-simulator, or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
348 `verilog-compiler. Alternatively use the \"Choose Compilation Action\"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
349 menu. See `verilog-set-compile-command' for more information.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
350
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
351 (defcustom verilog-highlight-translate-off nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
352 "*Non-nil means background-highlight code excluded from translation.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
353 That is, all code between \"// synopsys translate_off\" and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
354 \"// synopsys translate_on\" is highlighted using a different background color
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
355 \(face `verilog-font-lock-translate-off-face').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
356
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
357 Note: This will slow down on-the-fly fontification (and thus editing).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
358
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
359 Note: Activate the new setting in a Verilog buffer by re-fontifying it (menu
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
360 entry \"Fontify Buffer\"). XEmacs: turn off and on font locking."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
361 :type 'boolean
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
362 :group 'verilog-mode-indent)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
363 ;; Note we don't use :safe, as that would break on Emacsen before 22.0.
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
364 (put 'verilog-highlight-translate-off 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
365
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
366 (defcustom verilog-indent-level 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
367 "*Indentation of Verilog statements with respect to containing block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
368 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
369 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
370 (put 'verilog-indent-level 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
371
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
372 (defcustom verilog-indent-level-module 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
373 "*Indentation of Module level Verilog statements. (eg always, initial)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
374 Set to 0 to get initial and always statements lined up on the left side of
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
375 your screen."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
376 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
377 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
378 (put 'verilog-indent-level-module 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
379
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
380 (defcustom verilog-indent-level-declaration 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
381 "*Indentation of declarations with respect to containing block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
382 Set to 0 to get them list right under containing block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
383 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
384 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
385 (put 'verilog-indent-level-declaration 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
386
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
387 (defcustom verilog-indent-declaration-macros nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
388 "*How to treat macro expansions in a declaration.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
389 If nil, indent as:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
390 input [31:0] a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
391 input `CP;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
392 output c;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
393 If non nil, treat as:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
394 input [31:0] a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
395 input `CP ;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
396 output c;"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
397 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
398 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
399 (put 'verilog-indent-declaration-macros 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
400
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
401 (defcustom verilog-indent-lists t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
402 "*How to treat indenting items in a list.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
403 If t (the default), indent as:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
404 always @( posedge a or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
405 reset ) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
406
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
407 If nil, treat as:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
408 always @( posedge a or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
409 reset ) begin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
410 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
411 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
412 (put 'verilog-indent-lists 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
413
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
414 (defcustom verilog-indent-level-behavioral 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
415 "*Absolute indentation of first begin in a task or function block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
416 Set to 0 to get such code to start at the left side of the screen."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
417 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
418 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
419 (put 'verilog-indent-level-behavioral 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
420
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
421 (defcustom verilog-indent-level-directive 1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
422 "*Indentation to add to each level of `ifdef declarations.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
423 Set to 0 to have all directives start at the left side of the screen."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
424 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
425 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
426 (put 'verilog-indent-level-directive 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
427
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
428 (defcustom verilog-cexp-indent 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
429 "*Indentation of Verilog statements split across lines."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
430 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
431 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
432 (put 'verilog-cexp-indent 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
433
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
434 (defcustom verilog-case-indent 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
435 "*Indentation for case statements."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
436 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
437 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
438 (put 'verilog-case-indent 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
439
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
440 (defcustom verilog-auto-newline t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
441 "*True means automatically newline after semicolons."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
442 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
443 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
444 (put 'verilog-auto-newline 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
445
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
446 (defcustom verilog-auto-indent-on-newline t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
447 "*True means automatically indent line after newline."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
448 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
449 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
450 (put 'verilog-auto-indent-on-newline 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
451
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
452 (defcustom verilog-tab-always-indent t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
453 "*True means TAB should always re-indent the current line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
454 Nil means TAB will only reindent when at the beginning of the line."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
455 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
456 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
457 (put 'verilog-tab-always-indent 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
458
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
459 (defcustom verilog-tab-to-comment nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
460 "*True means TAB moves to the right hand column in preparation for a comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
461 :group 'verilog-mode-actions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
462 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
463 (put 'verilog-tab-to-comment 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
464
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
465 (defcustom verilog-indent-begin-after-if t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
466 "*If true, indent begin statements following if, else, while, for and repeat.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
467 Otherwise, line them up."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
468 :group 'verilog-mode-indent
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
469 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
470 (put 'verilog-indent-begin-after-if 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
471
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
472
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
473 (defcustom verilog-align-ifelse nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
474 "*If true, align `else' under matching `if'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
475 Otherwise else is lined up with first character on line holding matching if."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
476 :group 'verilog-mode-indent
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
477 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
478 (put 'verilog-align-ifelse 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
479
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
480 (defcustom verilog-minimum-comment-distance 10
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
481 "*Minimum distance (in lines) between begin and end required before a comment.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
482 Setting this variable to zero results in every end acquiring a comment; the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
483 default avoids too many redundant comments in tight quarters"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
484 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
485 :type 'integer)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
486 (put 'verilog-minimum-comment-distance 'safe-local-variable 'integerp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
487
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
488 (defcustom verilog-auto-lineup '(declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
489 "*Algorithm for lining up statements on multiple lines.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
490
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
491 If this list contains the symbol 'all', then all line ups described below
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
492 are done.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
493
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
494 If this list contains the symbol 'declaration', then declarations are lined up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
495 with any preceding declarations, taking into account widths and the like, so
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
496 for example the code:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
497 reg [31:0] a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
498 reg b;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
499 would become
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
500 reg [31:0] a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
501 reg b;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
502
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
503 If this list contains the symbol 'assignment', then assignments are lined up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
504 with any preceding assignments, so for example the code
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
505 a_long_variable = b + c;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
506 d = e + f;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
507 would become
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
508 a_long_variable = b + c;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
509 d = e + f;"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
510
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
511 ;; The following is not implemented:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
512 ;If this list contains the symbol 'case', then case items are lined up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
513 ;with any preceding case items, so for example the code
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
514 ; case (a) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
515 ; a_long_state : a = 3;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
516 ; b: a = 4;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
517 ; endcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
518 ;would become
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
519 ; case (a) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
520 ; a_long_state : a = 3;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
521 ; b : a = 4;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
522 ; endcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
523 ;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
524
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
525 :group 'verilog-mode-indent
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
526 :type 'list)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
527 (put 'verilog-auto-lineup 'safe-local-variable 'listp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
528
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
529 (defcustom verilog-highlight-p1800-keywords nil
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
530 "*True means highlight words newly reserved by IEEE-1800.
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
531 These will appear in `verilog-font-lock-p1800-face' in order to gently
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
532 suggest changing where these words are used as variables to something else.
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
533 Nil means highlight these words as appropriate for the SystemVerilog
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
534 IEEE-1800 standard. Note that changing this will require restarting Emacs
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
535 to see the effect as font color choices are cached by Emacs"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
536 :group 'verilog-mode-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
537 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
538 (put 'verilog-highlight-p1800-keywords 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
539
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
540 (defcustom verilog-auto-endcomments t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
541 "*True means insert a comment /* ... */ after 'end's.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
542 The name of the function or case will be set between the braces."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
543 :group 'verilog-mode-actions
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
544 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
545 (put 'verilog-auto-endcomments 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
546
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
547 (defcustom verilog-auto-read-includes nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
548 "*True means to automatically read includes before AUTOs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
549 This will do a `verilog-read-defines' and `verilog-read-includes' before
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
550 each AUTO expansion. This makes it easier to embed defines and includes,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
551 but can result in very slow reading times if there are many or large
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
552 include files."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
553 :group 'verilog-mode-actions
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
554 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
555 (put 'verilog-auto-read-includes 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
556
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
557 (defcustom verilog-auto-save-policy nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
558 "*Non-nil indicates action to take when saving a Verilog buffer with AUTOs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
559 A value of `force' will always do a \\[verilog-auto] automatically if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
560 needed on every save. A value of `detect' will do \\[verilog-auto]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
561 automatically when it thinks necessary. A value of `ask' will query the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
562 user when it thinks updating is needed.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
563
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
564 You should not rely on the 'ask or 'detect policies, they are safeguards
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
565 only. They do not detect when AUTOINSTs need to be updated because a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
566 sub-module's port list has changed."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
567 :group 'verilog-mode-actions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
568 :type '(choice (const nil) (const ask) (const detect) (const force)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
569
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
570 (defcustom verilog-auto-star-expand t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
571 "*Non-nil indicates to expand a SystemVerilog .* instance ports.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
572 They will be expanded in the same way as if there was a AUTOINST in the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
573 instantiation. See also `verilog-auto-star' and `verilog-auto-star-save'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
574 :group 'verilog-mode-actions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
575 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
576 (put 'verilog-auto-star-expand 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
577
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
578 (defcustom verilog-auto-star-save nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
579 "*Non-nil indicates to save to disk SystemVerilog .* instance expansions.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
580 Nil indicates direct connections will be removed before saving. Only
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
581 meaningful to those created due to `verilog-auto-star-expand' being set.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
582
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
583 Instead of setting this, you may want to use /*AUTOINST*/, which will
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
584 always be saved."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
585 :group 'verilog-mode-actions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
586 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
587 (put 'verilog-auto-star-save 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
588
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
589 (defvar verilog-auto-update-tick nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
590 "Modification tick at which autos were last performed.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
591
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
592 (defvar verilog-auto-last-file-locals nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
593 "Text from file-local-variables during last evaluation.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
594
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
595 (defvar verilog-error-regexp-add-didit nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
596 (defvar verilog-error-regexp nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
597 (setq verilog-error-regexp-add-didit nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
598 verilog-error-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
599 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
600 ; SureLint
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
601 ;; ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
602 ; Most SureFire tools
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
603 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
604 ("\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
605 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
606 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
607 ; xsim
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
608 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
609 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
610 ; vcs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
611 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
612 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
613 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
614 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
615 ; Verilator
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
616 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
617 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
618 ; vxl
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
619 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
620 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
621 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
622 ; nc-verilog
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
623 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
624 ; Leda
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
625 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
626 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
627 ; "*List of regexps for verilog compilers, like verilint. See compilation-error-regexp-alist for the formatting."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
628 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
629
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
630 (defvar verilog-error-font-lock-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
631 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
632 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
633 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
634
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
635 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
636 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
637
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
638 ("\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
639 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
640 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
641 ("\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
642 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
643 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
644
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
645 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
646 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 3 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
647
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
648 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
649 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 4 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
650
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
651 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
652 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
653
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
654 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
655 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 3 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
656
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
657 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
658 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
659 ; vxl
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
660 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
661 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
662
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
663 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
664 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
665
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
666 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
667 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
668 ; nc-verilog
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
669 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
670 (".*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
671 ; Leda
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
672 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
673 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 2 bold t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
674 )
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
675 "*Keywords to also highlight in Verilog *compilation* buffers.")
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
676
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
677 (defcustom verilog-library-flags '("")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
678 "*List of standard Verilog arguments to use for /*AUTOINST*/.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
679 These arguments are used to find files for `verilog-auto', and match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
680 the flags accepted by a standard Verilog-XL simulator.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
681
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
682 -f filename Reads more `verilog-library-flags' from the filename.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
683 +incdir+dir Adds the directory to `verilog-library-directories'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
684 -Idir Adds the directory to `verilog-library-directories'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
685 -y dir Adds the directory to `verilog-library-directories'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
686 +libext+.v Adds the extensions to `verilog-library-extensions'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
687 -v filename Adds the filename to `verilog-library-files'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
688
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
689 filename Adds the filename to `verilog-library-files'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
690 This is not recommended, -v is a better choice.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
691
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
692 You might want these defined in each file; put at the *END* of your file
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
693 something like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
694
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
695 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
696 // verilog-library-flags:(\"-y dir -y otherdir\")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
697 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
698
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
699 Verilog-mode attempts to detect changes to this local variable, but they
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
700 are only insured to be correct when the file is first visited. Thus if you
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
701 have problems, use \\[find-alternate-file] RET to have these take effect.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
702
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
703 See also the variables mentioned above."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
704 :group 'verilog-mode-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
705 :type '(repeat string))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
706 (put 'verilog-library-flags 'safe-local-variable 'listp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
707
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
708 (defcustom verilog-library-directories '(".")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
709 "*List of directories when looking for files for /*AUTOINST*/.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
710 The directory may be relative to the current file, or absolute.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
711 Environment variables are also expanded in the directory names.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
712 Having at least the current directory is a good idea.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
713
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
714 You might want these defined in each file; put at the *END* of your file
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
715 something like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
716
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
717 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
718 // verilog-library-directories:(\".\" \"subdir\" \"subdir2\")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
719 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
720
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
721 Verilog-mode attempts to detect changes to this local variable, but they
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
722 are only insured to be correct when the file is first visited. Thus if you
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
723 have problems, use \\[find-alternate-file] RET to have these take effect.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
724
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
725 See also `verilog-library-flags', `verilog-library-files'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
726 and `verilog-library-extensions'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
727 :group 'verilog-mode-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
728 :type '(repeat file))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
729 (put 'verilog-library-directories 'safe-local-variable 'listp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
730
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
731 (defcustom verilog-library-files '()
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
732 "*List of files to search for modules.
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
733 AUTOINST will use this when it needs to resolve a module name.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
734 This is a complete path, usually to a technology file with many standard
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
735 cells defined in it.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
736
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
737 You might want these defined in each file; put at the *END* of your file
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
738 something like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
739
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
740 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
741 // verilog-library-files:(\"/some/path/technology.v\" \"/some/path/tech2.v\")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
742 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
743
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
744 Verilog-mode attempts to detect changes to this local variable, but they
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
745 are only insured to be correct when the file is first visited. Thus if you
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
746 have problems, use \\[find-alternate-file] RET to have these take effect.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
747
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
748 See also `verilog-library-flags', `verilog-library-directories'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
749 :group 'verilog-mode-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
750 :type '(repeat directory))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
751 (put 'verilog-library-files 'safe-local-variable 'listp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
752
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
753 (defcustom verilog-library-extensions '(".v")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
754 "*List of extensions to use when looking for files for /*AUTOINST*/.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
755 See also `verilog-library-flags', `verilog-library-directories'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
756 :type '(repeat string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
757 :group 'verilog-mode-auto)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
758 (put 'verilog-library-extensions 'safe-local-variable 'listp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
759
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
760 (defcustom verilog-active-low-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
761 "*If set, treat signals matching this regexp as active low.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
762 This is used for AUTORESET and AUTOTIEOFF. For proper behavior,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
763 you will probably also need `verilog-auto-reset-widths' set."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
764 :group 'verilog-mode-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
765 :type 'string)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
766 (put 'verilog-active-low-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
767
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
768 (defcustom verilog-auto-sense-include-inputs nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
769 "*If true, AUTOSENSE should include all inputs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
770 If nil, only inputs that are NOT output signals in the same block are
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
771 included."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
772 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
773 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
774 (put 'verilog-auto-sense-include-inputs 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
775
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
776 (defcustom verilog-auto-sense-defines-constant nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
777 "*If true, AUTOSENSE should assume all defines represent constants.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
778 When true, the defines will not be included in sensitivity lists. To
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
779 maintain compatibility with other sites, this should be set at the bottom
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
780 of each verilog file that requires it, rather than being set globally."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
781 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
782 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
783 (put 'verilog-auto-sense-defines-constant 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
784
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
785 (defcustom verilog-auto-reset-widths t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
786 "*If true, AUTORESET should determine the width of signals.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
787 This is then used to set the width of the zero (32'h0 for example). This
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
788 is required by some lint tools that aren't smart enough to ignore widths of
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
789 the constant zero. This may result in ugly code when parameters determine
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
790 the MSB or LSB of a signal inside a AUTORESET."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
791 :type 'boolean
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
792 :group 'verilog-mode-auto)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
793 (put 'verilog-auto-reset-widths 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
794
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
795 (defcustom verilog-assignment-delay ""
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
796 "*Text used for delays in delayed assignments. Add a trailing space if set."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
797 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
798 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
799 (put 'verilog-assignment-delay 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
800
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
801 (defcustom verilog-auto-inst-vector t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
802 "*If true, when creating default ports with AUTOINST, use bus subscripts.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
803 If nil, skip the subscript when it matches the entire bus as declared in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
804 the module (AUTOWIRE signals always are subscripted, you must manually
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
805 declare the wire to have the subscripts removed.) Nil may speed up some
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
806 simulators, but is less general and harder to read, so avoid."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
807 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
808 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
809 (put 'verilog-auto-inst-vector 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
810
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
811 (defcustom verilog-auto-inst-template-numbers nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
812 "*If true, when creating templated ports with AUTOINST, add a comment.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
813 The comment will add the line number of the template that was used for that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
814 port declaration. Setting this aids in debugging, but nil is suggested for
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
815 regular use to prevent large numbers of merge conflicts."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
816 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
817 :type 'boolean)
79801
1fc1252447c5 * progmodes/verilog-mode.el (verilog-booleanp): New function for
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79799
diff changeset
818 (put 'verilog-auto-inst-template-numbers 'safe-local-variable 'verilog-booleanp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
819
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
820 (defvar verilog-auto-inst-column 40
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
821 "Column number for first part of auto-inst.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
822
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
823 (defcustom verilog-auto-input-ignore-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
824 "*If set, when creating AUTOINPUT list, ignore signals matching this regexp.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
825 See the \\[verilog-faq] for examples on using this."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
826 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
827 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
828 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
829
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
830 (defcustom verilog-auto-inout-ignore-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
831 "*If set, when creating AUTOINOUT list, ignore signals matching this regexp.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
832 See the \\[verilog-faq] for examples on using this."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
833 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
834 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
835 (put 'verilog-auto-inout-ignore-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
836
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
837 (defcustom verilog-auto-output-ignore-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
838 "*If set, when creating AUTOOUTPUT list, ignore signals matching this regexp.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
839 See the \\[verilog-faq] for examples on using this."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
840 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
841 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
842 (put 'verilog-auto-output-ignore-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
843
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
844 (defcustom verilog-auto-unused-ignore-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
845 "*If set, when creating AUTOUNUSED list, ignore signals matching this regexp.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
846 See the \\[verilog-faq] for examples on using this."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
847 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
848 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
849 (put 'verilog-auto-unused-ignore-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
850
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
851 (defcustom verilog-typedef-regexp nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
852 "*If non-nil, regular expression that matches Verilog-2001 typedef names.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
853 For example, \"_t$\" matches typedefs named with _t, as in the C language."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
854 :group 'verilog-mode-auto
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
855 :type 'string)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
856 (put 'verilog-typedef-regexp 'safe-local-variable 'stringp)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
857
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
858 (defcustom verilog-mode-hook 'verilog-set-compile-command
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
859 "*Hook (List of functions) run after verilog mode is loaded."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
860 :type 'hook
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
861 :group 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
862
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
863 (defcustom verilog-auto-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
864 "*Hook run after `verilog-mode' updates AUTOs."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
865 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
866 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
867
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
868 (defcustom verilog-before-auto-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
869 "*Hook run before `verilog-mode' updates AUTOs."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
870 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
871 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
872
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
873 (defcustom verilog-delete-auto-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
874 "*Hook run after `verilog-mode' deletes AUTOs."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
875 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
876 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
877
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
878 (defcustom verilog-before-delete-auto-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
879 "*Hook run before `verilog-mode' deletes AUTOs."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
880 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
881 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
882
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
883 (defcustom verilog-getopt-flags-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
884 "*Hook run after `verilog-getopt-flags' determines the Verilog option lists."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
885 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
886 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
887
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
888 (defcustom verilog-before-getopt-flags-hook nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
889 "*Hook run before `verilog-getopt-flags' determines the Verilog option lists."
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
890 :group 'verilog-mode-auto
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
891 :type 'hook)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
892
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
893 (defvar verilog-imenu-generic-expression
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
894 '((nil "^\\s-*\\(\\(m\\(odule\\|acromodule\\)\\)\\|primitive\\)\\s-+\\([a-zA-Z0-9_.:]+\\)" 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
895 ("*Vars*" "^\\s-*\\(reg\\|wire\\)\\s-+\\(\\|\\[[^]]+\\]\\s-+\\)\\([A-Za-z0-9_]+\\)" 3))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
896 "Imenu expression for Verilog-mode. See `imenu-generic-expression'.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
897
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
898 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
899 ;; provide a verilog-header function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
900 ;; Customization variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
901 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
902 (defvar verilog-date-scientific-format nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
903 "*If non-nil, dates are written in scientific format (e.g. 1997/09/17).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
904 If nil, in European format (e.g. 17.09.1997). The brain-dead American
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
905 format (e.g. 09/17/1997) is not supported.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
906
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
907 (defvar verilog-company nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
908 "*Default name of Company for verilog header.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
909 If set will become buffer local.")
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
910 (make-variable-buffer-local 'verilog-company)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
911
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
912 (defvar verilog-project nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
913 "*Default name of Project for verilog header.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
914 If set will become buffer local.")
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
915 (make-variable-buffer-local 'verilog-project)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
916
79549
d9595ed9b084 * progmodes/verilog-mode.el (verilog-mode-map): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79547
diff changeset
917 (defvar verilog-mode-map
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
918 (let ((map (make-sparse-keymap)))
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
919 (define-key map ";" 'electric-verilog-semi)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
920 (define-key map [(control 59)] 'electric-verilog-semi-with-comment)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
921 (define-key map ":" 'electric-verilog-colon)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
922 ;;(define-key map "=" 'electric-verilog-equal)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
923 (define-key map "\`" 'electric-verilog-tick)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
924 (define-key map "\t" 'electric-verilog-tab)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
925 (define-key map "\r" 'electric-verilog-terminate-line)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
926 ;; backspace/delete key bindings
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
927 (define-key map [backspace] 'backward-delete-char-untabify)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
928 (unless (boundp 'delete-key-deletes-forward) ; XEmacs variable
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
929 (define-key map [delete] 'delete-char)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
930 (define-key map [(meta delete)] 'kill-word))
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
931 (define-key map "\M-\C-b" 'electric-verilog-backward-sexp)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
932 (define-key map "\M-\C-f" 'electric-verilog-forward-sexp)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
933 (define-key map "\M-\r" `electric-verilog-terminate-and-indent)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
934 (define-key map "\M-\t" 'verilog-complete-word)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
935 (define-key map "\M-?" 'verilog-show-completions)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
936 (define-key map "\C-c\`" 'verilog-lint-off)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
937 (define-key map "\C-c\*" 'verilog-delete-auto-star-implicit)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
938 (define-key map "\C-c\C-r" 'verilog-label-be)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
939 (define-key map "\C-c\C-i" 'verilog-pretty-declarations)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
940 (define-key map "\C-c=" 'verilog-pretty-expr)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
941 (define-key map "\C-c\C-b" 'verilog-submit-bug-report)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
942 (define-key map "\M-*" 'verilog-star-comment)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
943 (define-key map "\C-c\C-c" 'verilog-comment-region)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
944 (define-key map "\C-c\C-u" 'verilog-uncomment-region)
79810
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
945 (when (featurep 'xemacs)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
946 (define-key map [(meta control h)] 'verilog-mark-defun)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
947 (define-key map "\M-\C-a" 'verilog-beg-of-defun)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
948 (define-key map "\M-\C-e" 'verilog-end-of-defun))
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
949 (define-key map "\C-c\C-d" 'verilog-goto-defun)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
950 (define-key map "\C-c\C-k" 'verilog-delete-auto)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
951 (define-key map "\C-c\C-a" 'verilog-auto)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
952 (define-key map "\C-c\C-s" 'verilog-auto-save-compile)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
953 (define-key map "\C-c\C-z" 'verilog-inject-auto)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
954 (define-key map "\C-c\C-e" 'verilog-expand-vector)
79550
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
955 (define-key map "\C-c\C-h" 'verilog-header)
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
956 map)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
957 "Keymap used in Verilog mode.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
958
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
959 ;; menus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
960 (defvar verilog-xemacs-menu
79810
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
961 `("Verilog"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
962 ("Choose Compilation Action"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
963 ["None"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
964 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
965 (setq verilog-tool nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
966 (verilog-set-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
967 :style radio
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
968 :selected (equal verilog-tool nil)]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
969 ["Lint"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
970 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
971 (setq verilog-tool 'verilog-linter)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
972 (verilog-set-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
973 :style radio
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
974 :selected (equal verilog-tool `verilog-linter)]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
975 ["Coverage"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
976 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
977 (setq verilog-tool 'verilog-coverage)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
978 (verilog-set-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
979 :style radio
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
980 :selected (equal verilog-tool `verilog-coverage)]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
981 ["Simulator"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
982 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
983 (setq verilog-tool 'verilog-simulator)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
984 (verilog-set-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
985 :style radio
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
986 :selected (equal verilog-tool `verilog-simulator)]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
987 ["Compiler"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
988 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
989 (setq verilog-tool 'verilog-compiler)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
990 (verilog-set-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
991 :style radio
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
992 :selected (equal verilog-tool `verilog-compiler)]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
993 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
994 ("Move"
79810
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
995 ,(if (featurep 'xemacs)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
996 (progn
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
997 ["Beginning of function" verilog-beg-of-defun t]
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
998 ["End of function" verilog-end-of-defun t]
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
999 ["Mark function" verilog-mark-defun t])
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1000 ["Beginning of function" beginning-of-defun t]
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1001 ["End of function" end-of-defun t]
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1002 ["Mark function" mark-defun t])
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1003
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1004 ["Goto function/module" verilog-goto-defun t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1005 ["Move to beginning of block" electric-verilog-backward-sexp t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1006 ["Move to end of block" electric-verilog-forward-sexp t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1007 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1008 ("Comments"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1009 ["Comment Region" verilog-comment-region t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1010 ["UnComment Region" verilog-uncomment-region t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1011 ["Multi-line comment insert" verilog-star-comment t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1012 ["Lint error to comment" verilog-lint-off t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1013 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1014 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1015 ["Compile" compile t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1016 ["AUTO, Save, Compile" verilog-auto-save-compile t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1017 ["Next Compile Error" next-error t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1018 ["Ignore Lint Warning at point" verilog-lint-off t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1019 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1020 ["Line up declarations around point" verilog-pretty-declarations t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1021 ["Line up equations around point" verilog-pretty-expr t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1022 ["Redo/insert comments on every end" verilog-label-be t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1023 ["Expand [x:y] vector line" verilog-expand-vector t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1024 ["Insert begin-end block" verilog-insert-block t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1025 ["Complete word" verilog-complete-word t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1026 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1027 ["Recompute AUTOs" verilog-auto t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1028 ["Kill AUTOs" verilog-delete-auto t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1029 ["Inject AUTOs" verilog-inject-auto t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1030 ("AUTO Help..."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1031 ["AUTO General" (describe-function 'verilog-auto) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1032 ["AUTO Library Flags" (describe-variable 'verilog-library-flags) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1033 ["AUTO Library Path" (describe-variable 'verilog-library-directories) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1034 ["AUTO Library Files" (describe-variable 'verilog-library-files) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1035 ["AUTO Library Extensions" (describe-variable 'verilog-library-extensions) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1036 ["AUTO `define Reading" (describe-function 'verilog-read-defines) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1037 ["AUTO `include Reading" (describe-function 'verilog-read-includes) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1038 ["AUTOARG" (describe-function 'verilog-auto-arg) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1039 ["AUTOASCIIENUM" (describe-function 'verilog-auto-ascii-enum) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1040 ["AUTOINOUTMODULE" (describe-function 'verilog-auto-inout-module) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1041 ["AUTOINOUT" (describe-function 'verilog-auto-inout) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1042 ["AUTOINPUT" (describe-function 'verilog-auto-input) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1043 ["AUTOINST" (describe-function 'verilog-auto-inst) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1044 ["AUTOINST (.*)" (describe-function 'verilog-auto-star) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1045 ["AUTOINSTPARAM" (describe-function 'verilog-auto-inst-param) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1046 ["AUTOOUTPUT" (describe-function 'verilog-auto-output) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1047 ["AUTOOUTPUTEVERY" (describe-function 'verilog-auto-output-every) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1048 ["AUTOREG" (describe-function 'verilog-auto-reg) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1049 ["AUTOREGINPUT" (describe-function 'verilog-auto-reg-input) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1050 ["AUTORESET" (describe-function 'verilog-auto-reset) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1051 ["AUTOSENSE" (describe-function 'verilog-auto-sense) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1052 ["AUTOTIEOFF" (describe-function 'verilog-auto-tieoff) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1053 ["AUTOUNUSED" (describe-function 'verilog-auto-unused) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1054 ["AUTOWIRE" (describe-function 'verilog-auto-wire) t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1055 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1056 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1057 ["Submit bug report" verilog-submit-bug-report t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1058 ["Version and FAQ" verilog-faq t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1059 ["Customize Verilog Mode..." verilog-customize t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1060 ["Customize Verilog Fonts & Colors" verilog-font-customize t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1061 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1062 "Emacs menu for VERILOG mode."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1063 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1064 (defvar verilog-statement-menu
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1065 '("Statements"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1066 ["Header" verilog-sk-header t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1067 ["Comment" verilog-sk-comment t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1068 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1069 ["Module" verilog-sk-module t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1070 ["Primitive" verilog-sk-primitive t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1071 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1072 ["Input" verilog-sk-input t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1073 ["Output" verilog-sk-output t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1074 ["Inout" verilog-sk-inout t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1075 ["Wire" verilog-sk-wire t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1076 ["Reg" verilog-sk-reg t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1077 ["Define thing under point as a register" verilog-sk-define-signal t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1078 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1079 ["Initial" verilog-sk-initial t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1080 ["Always" verilog-sk-always t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1081 ["Function" verilog-sk-function t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1082 ["Task" verilog-sk-task t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1083 ["Specify" verilog-sk-specify t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1084 ["Generate" verilog-sk-generate t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1085 "----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1086 ["Begin" verilog-sk-begin t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1087 ["If" verilog-sk-if t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1088 ["(if) else" verilog-sk-else-if t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1089 ["For" verilog-sk-for t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1090 ["While" verilog-sk-while t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1091 ["Fork" verilog-sk-fork t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1092 ["Repeat" verilog-sk-repeat t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1093 ["Case" verilog-sk-case t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1094 ["Casex" verilog-sk-casex t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1095 ["Casez" verilog-sk-casez t]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1096 )
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1097 "Menu for statement templates in Verilog.")
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1098
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1099 (easy-menu-define verilog-menu verilog-mode-map "Menu for Verilog mode"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1100 verilog-xemacs-menu)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1101 (easy-menu-define verilog-stmt-menu verilog-mode-map "Menu for statement templates in Verilog."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1102 verilog-statement-menu)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1103
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1104 (defvar verilog-mode-abbrev-table nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1105 "Abbrev table in use in Verilog-mode buffers.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1106
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1107 (define-abbrev-table 'verilog-mode-abbrev-table ())
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1108
79547
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1109 ;;
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1110 ;; Macros
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1111 ;;
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1112
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1113 (defsubst verilog-string-replace-matches (from-string to-string fixedcase literal string)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1114 "Replace occurrences of FROM-STRING with TO-STRING.
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1115 FIXEDCASE and LITERAL as in `replace-match`. STRING is what to replace.
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1116 The case (verilog-string-replace-matches \"o\" \"oo\" nil nil \"foobar\")
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1117 will break, as the o's continuously replace. xa -> x works ok though."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1118 ;; Hopefully soon to a emacs built-in
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1119 (let ((start 0))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1120 (while (string-match from-string string start)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1121 (setq string (replace-match to-string fixedcase literal string)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1122 start (min (length string) (match-end 0))))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1123 string))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1124
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1125 (defsubst verilog-string-remove-spaces (string)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1126 "Remove spaces surrounding STRING."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1127 (save-match-data
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1128 (setq string (verilog-string-replace-matches "^\\s-+" "" nil nil string))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1129 (setq string (verilog-string-replace-matches "\\s-+$" "" nil nil string))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1130 string))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1131
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1132 (defsubst verilog-re-search-forward (REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1133 ; checkdoc-params: (REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1134 "Like `re-search-forward', but skips over match in comments or strings."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1135 (store-match-data '(nil nil))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1136 (while (and
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1137 (re-search-forward REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1138 (and (verilog-skip-forward-comment-or-string)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1139 (progn
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1140 (store-match-data '(nil nil))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1141 (if BOUND
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1142 (< (point) BOUND)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1143 t)))))
79547
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1144 (match-end 0))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1145
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1146 (defsubst verilog-re-search-backward (REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1147 ; checkdoc-params: (REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1148 "Like `re-search-backward', but skips over match in comments or strings."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1149 (store-match-data '(nil nil))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1150 (while (and
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1151 (re-search-backward REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1152 (and (verilog-skip-backward-comment-or-string)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1153 (progn
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1154 (store-match-data '(nil nil))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1155 (if BOUND
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1156 (> (point) BOUND)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1157 t)))))
79547
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1158 (match-end 0))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1159
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1160 (defsubst verilog-re-search-forward-quick (regexp bound noerror)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1161 "Like `verilog-re-search-forward', including use of REGEXP BOUND and NOERROR,
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1162 but trashes match data and is faster for REGEXP that doesn't match often.
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1163 This may at some point use text properties to ignore comments,
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1164 so there may be a large up front penalty for the first search."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1165 (let (pt)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1166 (while (and (not pt)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1167 (re-search-forward regexp bound noerror))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1168 (if (not (verilog-inside-comment-p))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1169 (setq pt (match-end 0))))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1170 pt))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1171
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1172 (defsubst verilog-re-search-backward-quick (regexp bound noerror)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1173 ; checkdoc-params: (REGEXP BOUND NOERROR)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1174 "Like `verilog-re-search-backward', including use of REGEXP BOUND and NOERROR,
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1175 but trashes match data and is faster for REGEXP that doesn't match often.
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1176 This may at some point use text properties to ignore comments,
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1177 so there may be a large up front penalty for the first search."
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1178 (let (pt)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1179 (while (and (not pt)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1180 (re-search-backward regexp bound noerror))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1181 (if (not (verilog-inside-comment-p))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1182 (setq pt (match-end 0))))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1183 pt))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1184
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1185 (defsubst verilog-get-beg-of-line (&optional arg)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1186 (save-excursion
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1187 (beginning-of-line arg)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1188 (point)))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1189
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1190 (defsubst verilog-get-end-of-line (&optional arg)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1191 (save-excursion
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1192 (end-of-line arg)
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1193 (point)))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1194
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1195 (defsubst verilog-within-string ()
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1196 (save-excursion
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1197 (nth 3 (parse-partial-sexp (verilog-get-beg-of-line) (point)))))
46725aa288e8 (verilog-string-replace-matches)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79546
diff changeset
1198
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1199 (defvar compile-command)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1200
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1201 ;; compilation program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1202 (defun verilog-set-compile-command ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1203 "Function to compute shell command to compile verilog.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1204
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1205 This reads `verilog-tool' and sets `compile-command'. This specifies the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1206 program that executes when you type \\[compile] or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1207 \\[verilog-auto-save-compile].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1208
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1209 By default `verilog-tool' uses a Makefile if one exists in the current
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1210 directory. If not, it is set to the `verilog-linter', `verilog-coverage',
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1211 `verilog-simulator', or `verilog-compiler' variables, as selected with the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1212 Verilog -> \"Choose Compilation Action\" menu.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1213
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1214 You should set `verilog-tool' or the other variables to the path and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1215 arguments for your Verilog simulator. For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1216 \"vcs -p123 -O\"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1217 or a string like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1218 \"(cd /tmp; surecov %s)\".
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1219
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1220 In the former case, the path to the current buffer is concat'ed to the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1221 value of `verilog-tool'; in the later, the path to the current buffer is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1222 substituted for the %s.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1223
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1224 Where __FILE__ appears in the string, the buffer-file-name of the current
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1225 buffer, without the directory portion, will be substituted."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1226 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1227 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1228 ((or (file-exists-p "makefile") ;If there is a makefile, use it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1229 (file-exists-p "Makefile"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1230 (make-local-variable 'compile-command)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1231 (setq compile-command "make "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1232 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1233 (make-local-variable 'compile-command)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1234 (setq compile-command
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1235 (if verilog-tool
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1236 (if (string-match "%s" (eval verilog-tool))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1237 (format (eval verilog-tool) (or buffer-file-name ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1238 (concat (eval verilog-tool) " " (or buffer-file-name "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1239 ""))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1240 (verilog-modify-compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1241
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1242 (defun verilog-modify-compile-command ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1243 "Replace meta-information in `compile-command'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1244 Where __FILE__ appears in the string, the current buffer's file-name,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1245 without the directory portion, will be substituted."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1246 (when (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1247 (stringp compile-command)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1248 (string-match "\\b__FILE__\\b" compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1249 (make-local-variable 'compile-command)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1250 (setq compile-command
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1251 (verilog-string-replace-matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1252 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1253 t t compile-command))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1254
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1255 ;; Following code only gets called from compilation-mode-hook.
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1256 (defvar compilation-error-regexp-alist)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1257
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1258 (defun verilog-error-regexp-add ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1259 "Add the messages to the `compilation-error-regexp-alist'.
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1260 Called by `compilation-mode-hook'. This allows \\[next-error] to
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1261 find the errors."
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1262 (if (not verilog-error-regexp-add-didit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1263 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1264 (setq verilog-error-regexp-add-didit t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1265 (setq-default compilation-error-regexp-alist
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1266 (append verilog-error-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1267 (default-value 'compilation-error-regexp-alist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1268 ;; Could be buffer local at this point; maybe also in let; change all three
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1269 (setq compilation-error-regexp-alist
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1270 (default-value 'compilation-error-regexp-alist))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1271 (set (make-local-variable 'compilation-error-regexp-alist)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1272 (default-value 'compilation-error-regexp-alist)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1273
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1274 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1275
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1276 (defconst verilog-directive-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1277 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1278 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1279 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1280 ;; "`time_scale" "`undef" "`while"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1281 "\\<`\\(case\\|def\\(ault\\|ine\\(\\)?\\)\\|e\\(lse\\|nd\\(for\\|if\\|protect\\|switch\\|while\\)\\)\\|for\\(mat\\)?\\|i\\(f\\(def\\|ndef\\)?\\|nclude\\)\\|let\\|protect\\|switch\\|time\\(_scale\\|scale\\)\\|undef\\|while\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1282
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1283 (defconst verilog-directive-begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1284 "\\<`\\(for\\|i\\(f\\|fdef\\|fndef\\)\\|switch\\|while\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1285
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1286 (defconst verilog-directive-middle
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1287 "\\<`\\(else\\|default\\|case\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1288
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1289 (defconst verilog-directive-end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1290 "`\\(endfor\\|endif\\|endswitch\\|endwhile\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1291
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1292 (defconst verilog-directive-re-1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1293 (concat "[ \t]*" verilog-directive-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1294
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1295 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1296 ;; Regular expressions used to calculate indent, etc.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1297 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1298 (defconst verilog-symbol-re "\\<[a-zA-Z_][a-zA-Z_0-9.]*\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1299 (defconst verilog-case-re "\\(\\<case[xz]?\\>\\|\\<randcase\\>\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1300 ;; Want to match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1301 ;; aa :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1302 ;; aa,bb :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1303 ;; a[34:32] :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1304 ;; a,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1305 ;; b :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1306
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1307 (defconst verilog-no-indent-begin-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1308 "\\<\\(if\\|else\\|while\\|for\\|repeat\\|always\\|always_comb\\|always_ff\\|always_latch\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1309
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1310 (defconst verilog-ends-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1311 ;; Parenthesis indicate type of keyword found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1312 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1313 "\\(\\<else\\>\\)\\|" ; 1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1314 "\\(\\<if\\>\\)\\|" ; 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1315 "\\(\\<end\\>\\)\\|" ; 3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1316 "\\(\\<endcase\\>\\)\\|" ; 4
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1317 "\\(\\<endfunction\\>\\)\\|" ; 5
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1318 "\\(\\<endtask\\>\\)\\|" ; 6
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1319 "\\(\\<endspecify\\>\\)\\|" ; 7
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1320 "\\(\\<endtable\\>\\)\\|" ; 8
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1321 "\\(\\<endgenerate\\>\\)\\|" ; 9
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1322 "\\(\\<join\\(_any\\|_none\\)?\\>\\)\\|" ; 10
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1323 "\\(\\<endclass\\>\\)\\|" ; 11
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1324 "\\(\\<endgroup\\>\\)" ; 12
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1325 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1326
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1327 (defconst verilog-auto-end-comment-lines-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1328 ;; Matches to names in this list cause auto-end-commentation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1329 (concat "\\("
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1330 verilog-directive-re "\\)\\|\\("
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1331 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1332 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1333 `( "begin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1334 "else"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1335 "end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1336 "endcase"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1337 "endclass"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1338 "endclocking"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1339 "endgroup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1340 "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1341 "endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1342 "endprogram"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1343 "endprimitive"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1344 "endinterface"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1345 "endpackage"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1346 "endsequence"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1347 "endspecify"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1348 "endtable"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1349 "endtask"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1350 "join"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1351 "join_any"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1352 "join_none"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1353 "module"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1354 "macromodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1355 "primitive"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1356 "interface"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1357 "package")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1358 "\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1359
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1360 ;;; NOTE: verilog-leap-to-head expects that verilog-end-block-re and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1361 ;;; verilog-end-block-ordered-re matches exactly the same strings.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1362 (defconst verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1363 ;; Parenthesis indicate type of keyword found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1364 (concat "\\(\\<endcase\\>\\)\\|" ; 1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1365 "\\(\\<end\\>\\)\\|" ; 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1366 "\\(\\<end" ; 3, but not used
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1367 "\\(" ; 4, but not used
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1368 "\\(function\\)\\|" ; 5
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1369 "\\(task\\)\\|" ; 6
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1370 "\\(module\\)\\|" ; 7
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1371 "\\(primitive\\)\\|" ; 8
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1372 "\\(interface\\)\\|" ; 9
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1373 "\\(package\\)\\|" ; 10
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1374 "\\(class\\)\\|" ; 11
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1375 "\\(group\\)\\|" ; 12
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1376 "\\(program\\)\\|" ; 13
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1377 "\\(sequence\\)\\|" ; 14
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1378 "\\(clocking\\)\\|" ; 15
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1379 "\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1380 (defconst verilog-end-block-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1381 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1382 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1383
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1384 `("end" ;; closes begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1385 "endcase" ;; closes any of case, casex casez or randcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1386 "join" "join_any" "join_none" ;; closes fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1387 "endclass"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1388 "endtable"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1389 "endspecify"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1390 "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1391 "endgenerate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1392 "endtask"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1393 "endgroup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1394 "endproperty"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1395 "endinterface"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1396 "endpackage"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1397 "endprogram"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1398 "endsequence"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1399 "endclocking"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1400 ))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1401
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1402
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1403 (defconst verilog-endcomment-reason-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1404 ;; Parenthesis indicate type of keyword found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1405 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1406 "\\(\\<fork\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1407 "\\(\\<begin\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1408 "\\(\\<if\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1409 "\\(\\<clocking\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1410 "\\(\\<else\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1411 "\\(\\<end\\>.*\\<else\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1412 "\\(\\<task\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1413 "\\(\\<function\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1414 "\\(\\<initial\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1415 "\\(\\<interface\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1416 "\\(\\<package\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1417 "\\(\\<final\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1418 "\\(\\<always\\>\\(\[ \t\]*@\\)?\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1419 "\\(\\<always_comb\\>\\(\[ \t\]*@\\)?\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1420 "\\(\\<always_ff\\>\\(\[ \t\]*@\\)?\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1421 "\\(\\<always_latch\\>\\(\[ \t\]*@\\)?\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1422 "\\(@\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1423 "\\(\\<while\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1424 "\\(\\<for\\(ever\\|each\\)?\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1425 "\\(\\<repeat\\>\\)\\|\\(\\<wait\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1426 "#"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1427
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1428 (defconst verilog-named-block-re "begin[ \t]*:")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1429
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1430 ;; These words begin a block which can occur inside a module which should be indented,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1431 ;; and closed with the respective word from the end-block list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1432
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1433 (defconst verilog-beg-block-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1434 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1435 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1436 `("begin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1437 "case" "casex" "casez" "randcase"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1438 "clocking"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1439 "generate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1440 "fork"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1441 "function"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1442 "property"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1443 "specify"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1444 "table"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1445 "task"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1446 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1447 ;; These are the same words, in a specific order in the regular
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1448 ;; expression so that matching will work nicely for
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1449 ;; verilog-forward-sexp and verilog-calc-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1450
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1451 (defconst verilog-beg-block-re-ordered
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1452 ( concat "\\<"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1453 "\\(begin\\)" ;1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1454 "\\|\\(randcase\\|\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?\\)" ; 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1455 ;; "\\|\\(randcase\\|case[xz]?\\)" ; 2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1456 "\\|\\(fork\\)" ;3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1457 "\\|\\(class\\)" ;4
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1458 "\\|\\(table\\)" ;5
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1459 "\\|\\(specify\\)" ;6
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1460 "\\|\\(function\\)" ;7
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1461 "\\|\\(task\\)" ;8
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1462 "\\|\\(generate\\)" ;9
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1463 "\\|\\(covergroup\\)" ;10
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1464 "\\|\\(property\\)" ;11
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1465 "\\|\\(\\(rand\\)?sequence\\)" ;12
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1466 "\\|\\(clocking\\)" ;13
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1467 "\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1468
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1469 (defconst verilog-end-block-ordered-rry
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1470 [ "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1471 "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1472 "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1473 "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1474 "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1475 "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1476 "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1477 "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1478 "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1479 "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1480 "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1481 "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1482 "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1483 ] )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1484
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1485 (defconst verilog-nameable-item-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1486 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1487 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1488 `("begin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1489 "fork"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1490 "join" "join_any" "join_none"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1491 "end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1492 "endcase"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1493 "endconfig"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1494 "endclass"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1495 "endclocking"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1496 "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1497 "endgenerate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1498 "endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1499 "endprimative"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1500 "endinterface"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1501 "endpackage"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1502 "endspecify"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1503 "endtable"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1504 "endtask" )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1505 )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1506
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1507 (defconst verilog-declaration-opener
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1508 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1509 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1510 `("module" "begin" "task" "function"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1511
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1512 (defconst verilog-declaration-prefix-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1513 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1514 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1515 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1516 ;; port direction
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
1517 "inout" "input" "output" "ref"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1518 ;; changeableness
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1519 "const" "static" "protected" "local"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1520 ;; parameters
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
1521 "localparam" "parameter" "var"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1522 ;; type creation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1523 "typedef"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1524 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1525 (defconst verilog-declaration-core-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1526 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1527 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1528 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1529 ;; integer_atom_type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1530 "byte" "shortint" "int" "longint" "integer" "time"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1531 ;; integer_vector_type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1532 "bit" "logic" "reg"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1533 ;; non_integer_type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1534 "shortreal" "real" "realtime"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1535 ;; net_type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1536 "supply0" "supply1" "tri" "triand" "trior" "trireg" "tri0" "tri1" "uwire" "wire" "wand" "wor"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1537 ;; misc
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1538 "string" "event" "chandle" "virtual" "enum" "genvar"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1539 "struct" "union"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1540 ;; builtin classes
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
1541 "mailbox" "semaphore"
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1542 ))))
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
1543 (defconst verilog-declaration-re
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1544 (concat "\\(" verilog-declaration-prefix-re "\\s-*\\)?" verilog-declaration-core-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1545 (defconst verilog-range-re "\\(\\[[^]]*\\]\\s-*\\)+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1546 (defconst verilog-optional-signed-re "\\s-*\\(signed\\)?")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1547 (defconst verilog-optional-signed-range-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1548 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1549 "\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<signed\\>\\s-*\\)?\\(" verilog-range-re "\\)?"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1550 (defconst verilog-macroexp-re "`\\sw+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1551
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1552 (defconst verilog-delay-re "#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1553 (defconst verilog-declaration-re-2-no-macro
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1554 (concat "\\s-*" verilog-declaration-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1555 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1556 "\\)?"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1557 (defconst verilog-declaration-re-2-macro
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1558 (concat "\\s-*" verilog-declaration-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1559 "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1560 "\\|\\(" verilog-macroexp-re "\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1561 "\\)?"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1562 (defconst verilog-declaration-re-1-macro
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1563 (concat "^" verilog-declaration-re-2-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1564
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1565 (defconst verilog-declaration-re-1-no-macro (concat "^" verilog-declaration-re-2-no-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1566
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1567 (defconst verilog-defun-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1568 (eval-when-compile (verilog-regexp-words `("macromodule" "module" "class" "program" "interface" "package" "primitive" "config"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1569 (defconst verilog-end-defun-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1570 (eval-when-compile (verilog-regexp-words `("endmodule" "endclass" "endprogram" "endinterface" "endpackage" "endprimitive" "endconfig"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1571 (defconst verilog-zero-indent-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1572 (concat verilog-defun-re "\\|" verilog-end-defun-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1573
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1574 (defconst verilog-behavioral-block-beg-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1575 (concat "\\(\\<initial\\>\\|\\<final\\>\\|\\<always\\>\\|\\<always_comb\\>\\|\\<always_ff\\>\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1576 "\\<always_latch\\>\\|\\<function\\>\\|\\<task\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1577
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1578 (defconst verilog-indent-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1579 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1580 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1581 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1582 "{"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1583 "always" "always_latch" "always_ff" "always_comb"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1584 "begin" "end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1585 ; "unique" "priority"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1586 "case" "casex" "casez" "randcase" "endcase"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1587 "class" "endclass"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1588 "clocking" "endclocking"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1589 "config" "endconfig"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1590 "covergroup" "endgroup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1591 "fork" "join" "join_any" "join_none"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1592 "function" "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1593 "final"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1594 "generate" "endgenerate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1595 "initial"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1596 "interface" "endinterface"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1597 "module" "macromodule" "endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1598 "package" "endpackage"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1599 "primitive" "endprimative"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1600 "program" "endprogram"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1601 "property" "endproperty"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1602 "sequence" "randsequence" "endsequence"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1603 "specify" "endspecify"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1604 "table" "endtable"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1605 "task" "endtask"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1606 "`case"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1607 "`default"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1608 "`define" "`undef"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1609 "`if" "`ifdef" "`ifndef" "`else" "`endif"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1610 "`while" "`endwhile"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1611 "`for" "`endfor"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1612 "`format"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1613 "`include"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1614 "`let"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1615 "`protect" "`endprotect"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1616 "`switch" "`endswitch"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1617 "`timescale"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1618 "`time_scale"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1619 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1620
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1621 (defconst verilog-defun-level-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1622 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1623 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1624 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1625 "module" "macromodule" "primitive" "class" "program" "initial" "final" "always" "always_comb"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1626 "always_ff" "always_latch" "endtask" "endfunction" "interface" "package"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1627 "config"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1628
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1629 (defconst verilog-defun-level-not-generate-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1630 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1631 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1632 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1633 "module" "macromodule" "primitive" "class" "program" "interface" "package" "config"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1634
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1635 (defconst verilog-cpp-level-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1636 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1637 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1638 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1639 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1640 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1641 (defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1642 (defconst verilog-extended-complete-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1643 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1644 "\\|\\(\\<typedef\\>\\s-+\\)*\\(\\<struct\\>\\|\\<union\\>\\|\\<class\\>\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1645 "\\|" verilog-extended-case-re ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1646 (defconst verilog-basic-complete-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1647 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1648 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1649 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1650 "always" "assign" "always_latch" "always_ff" "always_comb" "constraint"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1651 "import" "initial" "final" "module" "macromodule" "repeat" "randcase" "while"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1652 "if" "for" "forever" "foreach" "else" "parameter" "do"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1653 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1654 (defconst verilog-complete-reg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1655 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1656 verilog-extended-complete-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1657 "\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1658 verilog-basic-complete-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1659
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1660 (defconst verilog-end-statement-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1661 (concat "\\(" verilog-beg-block-re "\\)\\|\\("
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1662 verilog-end-block-re "\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1663
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1664 (defconst verilog-endcase-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1665 (concat verilog-case-re "\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1666 "\\(endcase\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1667 verilog-defun-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1668 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1669
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1670 (defconst verilog-exclude-str-start "/* -----\\/----- EXCLUDED -----\\/-----"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1671 "String used to mark beginning of excluded text.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1672 (defconst verilog-exclude-str-end " -----/\\----- EXCLUDED -----/\\----- */"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1673 "String used to mark end of excluded text.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1674 (defconst verilog-preprocessor-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1675 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1676 (verilog-regexp-words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1677 `(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1678 "`define" "`include" "`ifdef" "`ifndef" "`if" "`endif" "`else"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1679 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1680
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1681 (defconst verilog-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1682 '( "`case" "`default" "`define" "`else" "`endfor" "`endif"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1683 "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1684 "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1685 "`time_scale" "`undef" "`while"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1686
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1687 "after" "alias" "always" "always_comb" "always_ff" "always_latch" "and"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1688 "assert" "assign" "assume" "automatic" "before" "begin" "bind"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1689 "bins" "binsof" "bit" "break" "buf" "bufif0" "bufif1" "byte"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1690 "case" "casex" "casez" "cell" "chandle" "class" "clocking" "cmos"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1691 "config" "const" "constraint" "context" "continue" "cover"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1692 "covergroup" "coverpoint" "cross" "deassign" "default" "defparam"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1693 "design" "disable" "dist" "do" "edge" "else" "end" "endcase"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1694 "endclass" "endclocking" "endconfig" "endfunction" "endgenerate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1695 "endgroup" "endinterface" "endmodule" "endpackage" "endprimitive"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1696 "endprogram" "endproperty" "endspecify" "endsequence" "endtable"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1697 "endtask" "enum" "event" "expect" "export" "extends" "extern"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1698 "final" "first_match" "for" "force" "foreach" "forever" "fork"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1699 "forkjoin" "function" "generate" "genvar" "highz0" "highz1" "if"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1700 "iff" "ifnone" "ignore_bins" "illegal_bins" "import" "incdir"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1701 "include" "initial" "inout" "input" "inside" "instance" "int"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1702 "integer" "interface" "intersect" "join" "join_any" "join_none"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1703 "large" "liblist" "library" "local" "localparam" "logic"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1704 "longint" "macromodule" "mailbox" "matches" "medium" "modport" "module"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1705 "nand" "negedge" "new" "nmos" "nor" "noshowcancelled" "not"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1706 "notif0" "notif1" "null" "or" "output" "package" "packed"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1707 "parameter" "pmos" "posedge" "primitive" "priority" "program"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1708 "property" "protected" "pull0" "pull1" "pulldown" "pullup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1709 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1710 "randcase" "randsequence" "rcmos" "real" "realtime" "ref" "reg"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1711 "release" "repeat" "return" "rnmos" "rpmos" "rtran" "rtranif0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1712 "rtranif1" "scalared" "semaphore" "sequence" "shortint" "shortreal"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1713 "showcancelled" "signed" "small" "solve" "specify" "specparam"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1714 "static" "string" "strong0" "strong1" "struct" "super" "supply0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1715 "supply1" "table" "tagged" "task" "this" "throughout" "time"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1716 "timeprecision" "timeunit" "tran" "tranif0" "tranif1" "tri"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1717 "tri0" "tri1" "triand" "trior" "trireg" "type" "typedef" "union"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1718 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1719 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1720 "wire" "with" "within" "wor" "xnor" "xor"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1721 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1722 "List of Verilog keywords.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1723
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1724 (defconst verilog-comment-start-regexp "//\\|/\\*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1725 "Dual comment value for `comment-start-regexp'.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1726
79810
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1727 (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
1728 (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
1729 ;; Populate the syntax TABLE.
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1730 (modify-syntax-entry ?\\ "\\" table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1731 (modify-syntax-entry ?+ "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1732 (modify-syntax-entry ?- "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1733 (modify-syntax-entry ?= "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1734 (modify-syntax-entry ?% "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1735 (modify-syntax-entry ?< "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1736 (modify-syntax-entry ?> "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1737 (modify-syntax-entry ?& "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1738 (modify-syntax-entry ?| "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1739 (modify-syntax-entry ?` "w" table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1740 (modify-syntax-entry ?_ "w" table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1741 (modify-syntax-entry ?\' "." table)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1742
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1743 ;; 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
1744 (if (featurep 'xemacs)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1745 (progn
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1746 ;; 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
1747 (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
1748 (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
1749 (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
1750 ;; Emacs 19 does things differently, but we can work with it
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
1751 (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
1752 (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
1753 (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
1754 table)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1755 "Syntax table used in `verilog-mode' buffers.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1756
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1757 (defvar verilog-font-lock-keywords nil
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1758 "Default highlighting for Verilog mode.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1759
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1760 (defvar verilog-font-lock-keywords-1 nil
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1761 "Subdued level highlighting for Verilog mode.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1762
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1763 (defvar verilog-font-lock-keywords-2 nil
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1764 "Medium level highlighting for Verilog mode.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1765 See also `verilog-font-lock-extra-types'.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1766
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1767 (defvar verilog-font-lock-keywords-3 nil
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1768 "Gaudy level highlighting for Verilog mode.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1769 See also `verilog-font-lock-extra-types'.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1770 (defvar verilog-font-lock-translate-off-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1771 'verilog-font-lock-translate-off-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1772 "Font to use for translated off regions.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1773 (defface verilog-font-lock-translate-off-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1774 '((((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1775 (background light))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1776 (:background "gray90" :italic t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1777 (((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1778 (background dark))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1779 (:background "gray10" :italic t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1780 (((class grayscale) (background light))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1781 (:foreground "DimGray" :italic t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1782 (((class grayscale) (background dark))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1783 (:foreground "LightGray" :italic t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1784 (t (:italis t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1785 "Font lock mode face used to background highlight translate-off regions."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1786 :group 'font-lock-highlighting-faces)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1787
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1788 (defvar verilog-font-lock-p1800-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1789 'verilog-font-lock-p1800-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1790 "Font to use for p1800 keywords.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1791 (defface verilog-font-lock-p1800-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1792 '((((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1793 (background light))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1794 (:foreground "DarkOrange3" :bold t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1795 (((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1796 (background dark))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1797 (:foreground "orange1" :bold t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1798 (t (:italic t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1799 "Font lock mode face used to highlight P1800 keywords."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1800 :group 'font-lock-highlighting-faces)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1801
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1802 (defvar verilog-font-lock-ams-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1803 'verilog-font-lock-ams-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1804 "Font to use for Analog/Mixed Signal keywords.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1805 (defface verilog-font-lock-ams-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1806 '((((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1807 (background light))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1808 (:foreground "Purple" :bold t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1809 (((class color)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1810 (background dark))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1811 (:foreground "orange1" :bold t ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1812 (t (:italic t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1813 "Font lock mode face used to highlight AMS keywords."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1814 :group 'font-lock-highlighting-faces)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1815
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1816 (let* ((verilog-type-font-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1817 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1818 (verilog-regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1819 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1820 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1821 "event" "genvar" "inout" "input" "integer" "localparam"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1822 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1823 "output" "parameter" "pmos" "pull0" "pull1" "pullup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1824 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1825 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1826 "supply0" "supply1" "time" "tran" "tranif0" "tranif1"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1827 "tri" "tri0" "tri1" "triand" "trior" "trireg" "typedef"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1828 "uwire" "vectored" "wand" "wire" "wor" "xnor" "xor"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1829 ) nil )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1830
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1831 (verilog-pragma-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1832 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1833 (verilog-regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1834 '("surefire" "synopsys" "rtl_synthesis" "verilint" ) nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1835 )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1836
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1837 (verilog-p1800-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1838 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1839 (verilog-regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1840 '("alias" "assert" "assume" "automatic" "before" "bind"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1841 "bins" "binsof" "break" "byte" "cell" "chandle" "class"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1842 "clocking" "config" "const" "constraint" "context" "continue"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1843 "cover" "covergroup" "coverpoint" "cross" "deassign" "design"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1844 "dist" "do" "edge" "endclass" "endclocking" "endconfig"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1845 "endgroup" "endprogram" "endproperty" "endsequence" "enum"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1846 "expect" "export" "extends" "extern" "first_match" "foreach"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1847 "forkjoin" "genvar" "highz0" "highz1" "ifnone" "ignore_bins"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1848 "illegal_bins" "import" "incdir" "include" "inside" "instance"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1849 "int" "intersect" "large" "liblist" "library" "local" "longint"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1850 "matches" "medium" "modport" "new" "noshowcancelled" "null"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1851 "packed" "program" "property" "protected" "pull0" "pull1"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1852 "pulsestyle_onevent" "pulsestyle_ondetect" "pure" "rand" "randc"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1853 "randcase" "randsequence" "ref" "release" "return" "scalared"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1854 "sequence" "shortint" "shortreal" "showcancelled" "small" "solve"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1855 "specparam" "static" "string" "strong0" "strong1" "struct"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1856 "super" "tagged" "this" "throughout" "timeprecision" "timeunit"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1857 "type" "union" "unsigned" "use" "var" "virtual" "void"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1858 "wait_order" "weak0" "weak1" "wildcard" "with" "within"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1859 ) nil )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1860
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1861 (verilog-ams-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1862 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1863 (verilog-regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1864 '("above" "abs" "absdelay" "acos" "acosh" "ac_stim"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1865 "aliasparam" "analog" "analysis" "asin" "asinh" "atan" "atan2" "atanh"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1866 "branch" "ceil" "connectmodule" "connectrules" "cos" "cosh" "ddt"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1867 "ddx" "discipline" "driver_update" "enddiscipline" "endconnectrules"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1868 "endnature" "endparamset" "exclude" "exp" "final_step" "flicker_noise"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1869 "floor" "flow" "from" "ground" "hypot" "idt" "idtmod" "inf"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1870 "initial_step" "laplace_nd" "laplace_np" "laplace_zd" "laplace_zp"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1871 "last_crossing" "limexp" "ln" "log" "max" "min" "nature"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1872 "net_resolution" "noise_table" "paramset" "potential" "pow" "sin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1873 "sinh" "slew" "sqrt" "tan" "tanh" "timer" "transition" "white_noise"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1874 "wreal" "zi_nd" "zi_np" "zi_zd" ) nil )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1875
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1876 (verilog-font-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1877 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1878 (verilog-regexp-opt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1879 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1880 "assign" "begin" "case" "casex" "casez" "randcase" "deassign"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1881 "default" "disable" "else" "end" "endcase" "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1882 "endgenerate" "endinterface" "endmodule" "endprimitive"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1883 "endspecify" "endtable" "endtask" "final" "for" "force" "return" "break"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1884 "continue" "forever" "fork" "function" "generate" "if" "iff" "initial"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1885 "interface" "join" "join_any" "join_none" "macromodule" "module" "negedge"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1886 "package" "endpackage" "always" "always_comb" "always_ff"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1887 "always_latch" "posedge" "primitive" "priority" "release"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1888 "repeat" "specify" "table" "task" "unique" "wait" "while"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1889 "class" "program" "endclass" "endprogram"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1890 ) nil ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1891
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1892 (setq verilog-font-lock-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1893 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1894 ;; Fontify all builtin keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1895 (concat "\\<\\(" verilog-font-keywords "\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1896 ;; And user/system tasks and functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1897 "\\$[a-zA-Z][a-zA-Z0-9_\\$]*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1898 "\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1899 ;; Fontify all types
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1900 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1901 'font-lock-type-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1902 ;; Fontify IEEE-P1800 keywords appropriately
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1903 (if verilog-highlight-p1800-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1904 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1905 'verilog-font-lock-p1800-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1906 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1907 'font-lock-type-face))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1908 ;; Fontify Verilog-AMS keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1909 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1910 'verilog-font-lock-ams-face)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1911
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1912 (setq verilog-font-lock-keywords-1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1913 (append verilog-font-lock-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1914 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1915 ;; Fontify module definitions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1916 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1917 "\\<\\(\\(macro\\)?module\\|primitive\\|class\\|program\\|interface\\|package\\|task\\)\\>\\s-*\\(\\sw+\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1918 '(1 font-lock-keyword-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1919 '(3 font-lock-function-name-face 'prepend))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1920 ;; Fontify function definitions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1921 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1922 (concat "\\<function\\>\\s-+\\(integer\\|real\\(time\\)?\\|time\\)\\s-+\\(\\sw+\\)" )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1923 '(1 font-lock-keyword-face)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1924 '(3 font-lock-reference-face prepend))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1925 '("\\<function\\>\\s-+\\(\\[[^]]+\\]\\)\\s-+\\(\\sw+\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1926 (1 font-lock-keyword-face)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1927 (2 font-lock-reference-face append))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1928 '("\\<function\\>\\s-+\\(\\sw+\\)"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1929 1 'font-lock-reference-face append))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1930
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1931 (setq verilog-font-lock-keywords-2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1932 (append verilog-font-lock-keywords-1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1933 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1934 ;; Fontify pragmas
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1935 (concat "\\(//\\s-*" verilog-pragma-keywords "\\s-.*\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1936 ;; Fontify escaped names
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1937 '("\\(\\\\\\S-*\\s-\\)" 0 font-lock-function-name-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1938 ;; Fontify macro definitions/ uses
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1939 '("`\\s-*[A-Za-z][A-Za-z0-9_]*" 0 (if (boundp 'font-lock-preprocessor-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1940 'font-lock-preprocessor-face
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1941 'font-lock-type-face))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1942 ;; Fontify delays/numbers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1943 '("\\(@\\)\\|\\(#\\s-*\\(\\(\[0-9_.\]+\\('s?[hdxbo][0-9a-fA-F_xz]*\\)?\\)\\|\\(([^()]+)\\|\\sw+\\)\\)\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1944 0 font-lock-type-face append)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1945 ;; Fontify instantiation names
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1946 '("\\([A-Za-z][A-Za-z0-9_]+\\)\\s-*(" 1 font-lock-function-name-face)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1947 )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1948
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1949 (setq verilog-font-lock-keywords-3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1950 (append verilog-font-lock-keywords-2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1951 (when verilog-highlight-translate-off
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1952 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1953 ;; 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
1954 '(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
1955 (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
1956 )))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1957
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1958
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1959 (defun verilog-inside-comment-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1960 "Check if point inside a nested comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1961 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1962 (let ((st-point (point)) hitbeg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1963 (or (search-backward "//" (verilog-get-beg-of-line) t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1964 (if (progn
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1965 ;; This is for tricky case //*, we keep searching if /*
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1966 ;; 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
1967 (while
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1968 (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
1969 (progn
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1970 (forward-char 1)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
1971 (search-backward "//" (verilog-get-beg-of-line) t))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1972 hitbeg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1973 (not (search-forward "*/" st-point t)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1974
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1975 (defun verilog-declaration-end ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1976 (search-forward ";"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1977
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1978 (defun verilog-point-text (&optional pointnum)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1979 "Return text describing where POINTNUM or current point is (for errors).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1980 Use filename, if current buffer being edited shorten to just buffer name."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1981 (concat (or (and (equal (window-buffer (selected-window)) (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1982 (buffer-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1983 buffer-file-name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1984 (buffer-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1985 ":" (int-to-string (count-lines (point-min) (or pointnum (point))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1986
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1987 (defun electric-verilog-backward-sexp ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1988 "Move backward over a sexp."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1989 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1990 ;; 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
1991 (verilog-backward-sexp))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1992
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1993 (defun electric-verilog-forward-sexp ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1994 "Move backward over a sexp."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1995 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1996 ;; 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
1997 (verilog-forward-sexp))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
1998
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1999 ;;;used by hs-minor-mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2000 (defun verilog-forward-sexp-function (arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2001 (if (< arg 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2002 (verilog-backward-sexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2003 (verilog-forward-sexp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2004
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2005
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2006 (defun verilog-backward-sexp ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2007 (let ((reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2008 (elsec 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2009 (found nil)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2010 (st (point)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2011 (if (not (looking-at "\\<"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2012 (forward-word -1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2013 (cond
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2014 ((verilog-skip-backward-comment-or-string))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2015 ((looking-at "\\<else\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2016 (setq reg (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2017 verilog-end-block-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2018 "\\|\\(\\<else\\>\\)"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2019 "\\|\\(\\<if\\>\\)"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2020 (while (and (not found)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2021 (verilog-re-search-backward reg nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2022 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2023 ((match-end 1) ; matched verilog-end-block-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2024 ; try to leap back to matching outward block by striding across
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2025 ; indent level changing tokens then immediately
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2026 ; previous line governs indentation.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2027 (verilog-leap-to-head))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2028 ((match-end 2) ; else, we're in deep
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2029 (setq elsec (1+ elsec)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2030 ((match-end 3) ; found it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2031 (setq elsec (1- elsec))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2032 (if (= 0 elsec)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2033 ;; Now previous line describes syntax
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2034 (setq found 't))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2035 ((looking-at verilog-end-block-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2036 (verilog-leap-to-head))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2037 ((looking-at "\\(endmodule\\>\\)\\|\\(\\<endprimitive\\>\\)\\|\\(\\<endclass\\>\\)\\|\\(\\<endprogram\\>\\)\\|\\(\\<endinterface\\>\\)\\|\\(\\<endpackage\\>\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2038 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2039 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2040 (verilog-re-search-backward "\\<\\(macro\\)?module\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2041 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2042 (verilog-re-search-backward "\\<primitive\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2043 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2044 (verilog-re-search-backward "\\<class\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2045 ((match-end 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2046 (verilog-re-search-backward "\\<program\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2047 ((match-end 5)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2048 (verilog-re-search-backward "\\<interface\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2049 ((match-end 6)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2050 (verilog-re-search-backward "\\<package\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2051 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2052 (goto-char st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2053 (backward-sexp 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2054 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2055 (goto-char st)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2056 (backward-sexp)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2057
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2058 (defun verilog-forward-sexp ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2059 (let ((reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2060 (md 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2061 (st (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2062 (if (not (looking-at "\\<"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2063 (forward-word -1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2064 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2065 ((verilog-skip-forward-comment-or-string)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2066 (verilog-forward-syntactic-ws))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2067 ((looking-at verilog-beg-block-re-ordered);; begin|case|fork|class|table|specify|function|task|generate|covergroup|property|sequence|clocking
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2068 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2069 ((match-end 1) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2070 ;; Search forward for matching begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2071 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2072 ((match-end 2) ; endcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2073 ;; Search forward for matching case
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2074 (setq reg "\\(\\<randcase\\>\\|\\(\\<unique\\>\\s-+\\|\\<priority\\>\\s-+\\)?\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2075 ((match-end 3) ; join
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2076 ;; Search forward for matching fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2077 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2078 ((match-end 4) ; endclass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2079 ;; Search forward for matching class
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2080 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2081 ((match-end 5) ; endtable
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2082 ;; Search forward for matching table
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2083 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2084 ((match-end 6) ; endspecify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2085 ;; Search forward for matching specify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2086 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2087 ((match-end 7) ; endfunction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2088 ;; Search forward for matching function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2089 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2090 ((match-end 8) ; endtask
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2091 ;; Search forward for matching task
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2092 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2093 ((match-end 9) ; endgenerate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2094 ;; Search forward for matching generate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2095 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2096 ((match-end 10) ; endgroup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2097 ;; Search forward for matching covergroup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2098 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2099 ((match-end 11) ; endproperty
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2100 ;; Search forward for matching property
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2101 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2102 ((match-end 12) ; endsequence
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2103 ;; Search forward for matching sequence
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2104 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" )
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2105 (setq md 3)) ; 3 to get to endsequence in the reg above
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2106 ((match-end 13) ; endclocking
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2107 ;; Search forward for matching clocking
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2108 (setq reg "\\(\\<clocking\\>\\)\\|\\(\\<endclocking\\>\\)" )))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2109 (if (forward-word 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2110 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2111 (let ((nest 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2112 (while (verilog-re-search-forward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2113 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2114 ((match-end md) ; the closer in reg, so we are climbing out
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2115 (setq nest (1- nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2116 (if (= 0 nest) ; we are out!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2117 (throw 'skip 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2118 ((match-end 1) ; the opener in reg, so we are deeper now
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2119 (setq nest (1+ nest)))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2120 ((looking-at (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2121 "\\(\\<\\(macro\\)?module\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2122 "\\(\\<primitive\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2123 "\\(\\<class\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2124 "\\(\\<program\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2125 "\\(\\<interface\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2126 "\\(\\<package\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2127 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2128 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2129 (verilog-re-search-forward "\\<endmodule\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2130 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2131 (verilog-re-search-forward "\\<endprimitive\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2132 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2133 (verilog-re-search-forward "\\<endclass\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2134 ((match-end 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2135 (verilog-re-search-forward "\\<endprogram\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2136 ((match-end 5)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2137 (verilog-re-search-forward "\\<endinterface\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2138 ((match-end 6)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2139 (verilog-re-search-forward "\\<endpackage\\>" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2140 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2141 (goto-char st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2142 (if (= (following-char) ?\) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2143 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2144 (forward-sexp 1)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2145 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2146 (goto-char st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2147 (if (= (following-char) ?\) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2148 (forward-char 1)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2149 (forward-sexp 1))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2150
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2151 (defun verilog-declaration-beg ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2152 (verilog-re-search-backward verilog-declaration-re (bobp) t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2153
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2154 (defun verilog-font-lock-init ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2155 "Initialize fontification."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2156 ;; highlight keywords and standardized types, attributes, enumeration
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2157 ;; values, and subprograms
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2158 (setq verilog-font-lock-keywords-3
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2159 (append verilog-font-lock-keywords-2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2160 (when verilog-highlight-translate-off
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2161 (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2162 ;; 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
2163 '(verilog-match-translate-off
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2164 (0 'verilog-font-lock-translate-off-face prepend))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2165 (put 'verilog-mode 'font-lock-defaults
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2166 '((verilog-font-lock-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2167 verilog-font-lock-keywords-1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2168 verilog-font-lock-keywords-2
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2169 verilog-font-lock-keywords-3)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2170 nil ; nil means highlight strings & comments as well as keywords
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2171 nil ; nil means keywords must match case
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2172 nil ; syntax table handled elsewhere
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2173 ;; Function to move to beginning of reasonable region to highlight
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2174 verilog-beg-of-defun)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2175
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2176 ;; initialize fontification for Verilog Mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2177 (verilog-font-lock-init)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2178
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2179 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2180 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2181 ;; Mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2182 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2183 (defvar verilog-which-tool 1)
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2184 ;;;###autoload
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2185 (defun verilog-mode ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2186 "Major mode for editing Verilog code.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2187 \\<verilog-mode-map>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2188 See \\[describe-function] verilog-auto (\\[verilog-auto]) for details on how
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2189 AUTOs can improve coding efficiency.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2190
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2191 Use \\[verilog-faq] for a pointer to frequently asked questions.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2192
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2193 NEWLINE, TAB indents for Verilog code.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2194 Delete converts tabs to spaces as it moves back.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2195
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2196 Supports highlighting.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2197
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2198 Turning on Verilog mode calls the value of the variable `verilog-mode-hook'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2199 with no args, if that value is non-nil.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2200
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2201 Variables controlling indentation/edit style:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2202
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2203 variable `verilog-indent-level' (default 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2204 Indentation of Verilog statements with respect to containing block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2205 `verilog-indent-level-module' (default 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2206 Absolute indentation of Module level Verilog statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2207 Set to 0 to get initial and always statements lined up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2208 on the left side of your screen.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2209 `verilog-indent-level-declaration' (default 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2210 Indentation of declarations with respect to containing block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2211 Set to 0 to get them list right under containing block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2212 `verilog-indent-level-behavioral' (default 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2213 Indentation of first begin in a task or function block
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2214 Set to 0 to get such code to lined up underneath the task or function keyword
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2215 `verilog-indent-level-directive' (default 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2216 Indentation of `ifdef/`endif blocks
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2217 `verilog-cexp-indent' (default 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2218 Indentation of Verilog statements broken across lines i.e.:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2219 if (a)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2220 begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2221 `verilog-case-indent' (default 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2222 Indentation for case statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2223 `verilog-auto-newline' (default nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2224 Non-nil means automatically newline after semicolons and the punctuation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2225 mark after an end.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2226 `verilog-auto-indent-on-newline' (default t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2227 Non-nil means automatically indent line after newline
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2228 `verilog-tab-always-indent' (default t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2229 Non-nil means TAB in Verilog mode should always reindent the current line,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2230 regardless of where in the line point is when the TAB command is used.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2231 `verilog-indent-begin-after-if' (default t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2232 Non-nil means to indent begin statements following a preceding
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2233 if, else, while, for and repeat statements, if any. otherwise,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2234 the begin is lined up with the preceding token. If t, you get:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2235 if (a)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2236 begin // amount of indent based on `verilog-cexp-indent'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2237 otherwise you get:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2238 if (a)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2239 begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2240 `verilog-auto-endcomments' (default t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2241 Non-nil means a comment /* ... */ is set after the ends which ends
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2242 cases, tasks, functions and modules.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2243 The type and name of the object will be set between the braces.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2244 `verilog-minimum-comment-distance' (default 10)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2245 Minimum distance (in lines) between begin and end required before a comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2246 will be inserted. Setting this variable to zero results in every
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2247 end acquiring a comment; the default avoids too many redundant
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2248 comments in tight quarters.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2249 `verilog-auto-lineup' (default `(all))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2250 List of contexts where auto lineup of code should be done.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2251
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2252 Variables controlling other actions:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2253
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2254 `verilog-linter' (default surelint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2255 Unix program to call to run the lint checker. This is the default
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2256 command for \\[compile-command] and \\[verilog-auto-save-compile].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2257
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2258 See \\[customize] for the complete list of variables.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2259
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2260 AUTO expansion functions are, in part:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2261
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2262 \\[verilog-auto] Expand AUTO statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2263 \\[verilog-delete-auto] Remove the AUTOs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2264 \\[verilog-inject-auto] Insert AUTOs for the first time.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2265
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2266 Some other functions are:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2267
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2268 \\[verilog-complete-word] Complete word with appropriate possibilities.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2269 \\[verilog-mark-defun] Mark function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2270 \\[verilog-beg-of-defun] Move to beginning of current function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2271 \\[verilog-end-of-defun] Move to end of current function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2272 \\[verilog-label-be] Label matching begin ... end, fork ... join, etc statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2273
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2274 \\[verilog-comment-region] Put marked area in a comment.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2275 \\[verilog-uncomment-region] Uncomment an area commented with \\[verilog-comment-region].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2276 \\[verilog-insert-block] Insert begin ... end;.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2277 \\[verilog-star-comment] Insert /* ... */.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2278
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2279 \\[verilog-sk-always] Insert a always @(AS) begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2280 \\[verilog-sk-begin] Insert a begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2281 \\[verilog-sk-case] Insert a case block, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2282 \\[verilog-sk-for] Insert a for (...) begin .. end block, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2283 \\[verilog-sk-generate] Insert a generate .. endgenerate block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2284 \\[verilog-sk-header] Insert a nice header block at the top of file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2285 \\[verilog-sk-initial] Insert an initial begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2286 \\[verilog-sk-fork] Insert a fork begin .. end .. join block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2287 \\[verilog-sk-module] Insert a module .. (/*AUTOARG*/);.. endmodule block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2288 \\[verilog-sk-primitive] Insert a primitive .. (.. );.. endprimitive block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2289 \\[verilog-sk-repeat] Insert a repeat (..) begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2290 \\[verilog-sk-specify] Insert a specify .. endspecify block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2291 \\[verilog-sk-task] Insert a task .. begin .. end endtask block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2292 \\[verilog-sk-while] Insert a while (...) begin .. end block, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2293 \\[verilog-sk-casex] Insert a casex (...) item: begin.. end endcase block, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2294 \\[verilog-sk-casez] Insert a casez (...) item: begin.. end endcase block, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2295 \\[verilog-sk-if] Insert an if (..) begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2296 \\[verilog-sk-else-if] Insert an else if (..) begin .. end block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2297 \\[verilog-sk-comment] Insert a comment block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2298 \\[verilog-sk-assign] Insert an assign .. = ..; statement.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2299 \\[verilog-sk-function] Insert a function .. begin .. end endfunction block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2300 \\[verilog-sk-input] Insert an input declaration, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2301 \\[verilog-sk-output] Insert an output declaration, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2302 \\[verilog-sk-state-machine] Insert a state machine definition, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2303 \\[verilog-sk-inout] Insert an inout declaration, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2304 \\[verilog-sk-wire] Insert a wire declaration, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2305 \\[verilog-sk-reg] Insert a register declaration, prompting for details.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2306 \\[verilog-sk-define-signal] Define signal under point as a register at the top of the module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2307
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2308 All key bindings can be seen in a Verilog-buffer with \\[describe-bindings].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2309 Key bindings specific to `verilog-mode-map' are:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2310
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2311 \\{verilog-mode-map}"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2312 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2313 (kill-all-local-variables)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2314 (use-local-map verilog-mode-map)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2315 (setq major-mode 'verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2316 (setq mode-name "Verilog")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2317 (setq local-abbrev-table verilog-mode-abbrev-table)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2318 (set (make-local-variable 'beginning-of-defun-function)
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2319 'verilog-beg-of-defun)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2320 (set (make-local-variable 'end-of-defun-function)
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2321 'verilog-end-of-defun)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2322 (set-syntax-table verilog-mode-syntax-table)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2323 (make-local-variable 'indent-line-function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2324 (setq indent-line-function 'verilog-indent-line-relative)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2325 (setq comment-indent-function 'verilog-comment-indent)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2326 (make-local-variable 'parse-sexp-ignore-comments)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2327 (setq parse-sexp-ignore-comments nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2328 (make-local-variable 'comment-start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2329 (make-local-variable 'comment-end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2330 (make-local-variable 'comment-multi-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2331 (make-local-variable 'comment-start-skip)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2332 (setq comment-start "// "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2333 comment-end ""
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2334 comment-start-skip "/\\*+ *\\|// *"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2335 comment-multi-line nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2336 ;; Set up for compilation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2337 (setq verilog-which-tool 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2338 (setq verilog-tool 'verilog-linter)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2339 (verilog-set-compile-command)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2340 (when (boundp 'hack-local-variables-hook) ;; Also modify any file-local-variables
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2341 (add-hook 'hack-local-variables-hook 'verilog-modify-compile-command t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2342
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2343 ;; Setting up menus
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2344 (when (featurep 'xemacs)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2345 (when (and current-menubar
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2346 (not (assoc "Verilog" current-menubar)))
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2347 ;; (set-buffer-menubar (copy-sequence current-menubar))
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2348 (add-submenu nil verilog-xemacs-menu)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2349 (add-submenu nil verilog-stmt-menu)))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2350
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2351 ;; 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
2352 (set (make-local-variable 'font-lock-defaults)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2353 '((verilog-font-lock-keywords verilog-font-lock-keywords-1
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2354 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
2355 verilog-font-lock-keywords-3)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2356 nil nil nil verilog-beg-of-defun))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2357 ;;------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2358 ;; now hook in 'verilog-colorize-include-files (eldo-mode.el&spice-mode.el)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2359 ;; 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
2360 (when (featurep 'xemacs)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2361 (make-local-hook 'font-lock-mode-hook)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2362 (make-local-hook 'font-lock-after-fontify-buffer-hook); doesn't exist in emacs 20
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2363 (make-local-hook 'after-change-functions))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2364 (add-hook 'font-lock-mode-hook 'verilog-colorize-include-files-buffer t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2365 (add-hook 'font-lock-after-fontify-buffer-hook 'verilog-colorize-include-files-buffer t t) ; not in emacs 20
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2366 (add-hook 'after-change-functions 'verilog-colorize-include-files t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2367
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2368 ;; Tell imenu how to handle verilog.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2369 (make-local-variable 'imenu-generic-expression)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2370 (setq imenu-generic-expression verilog-imenu-generic-expression)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2371 ;; hideshow support
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2372 (unless (assq 'verilog-mode hs-special-modes-alist)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2373 (setq hs-special-modes-alist
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2374 (cons '(verilog-mode-mode "\\<begin\\>" "\\<end\\>" nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2375 verilog-forward-sexp-function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2376 hs-special-modes-alist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2377
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2378 ;; Stuff for autos
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2379 (add-hook 'write-contents-hooks 'verilog-auto-save-check) ; already local
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2380 ;; (verilog-auto-reeval-locals t) ; Save locals in case user changes them
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2381 ;; (verilog-getopt-flags)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2382 (run-hooks 'verilog-mode-hook))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2383
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2384
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2385 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2386 ;; Electric functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2387 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2388 (defun electric-verilog-terminate-line (&optional arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2389 "Terminate line and indent next line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2390 With optional ARG, remove existing end of line comments."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2391 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2392 ;; before that see if we are in a comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2393 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2394 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2395 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2396 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2397 ((nth 7 state) ; Inside // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2398 (if (eolp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2399 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2400 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2401 (newline))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2402 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2403 (newline)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2404 (insert "// ")
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2405 (beginning-of-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2406 (verilog-indent-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2407 ((nth 4 state) ; Inside any comment (hence /**/)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2408 (newline)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2409 (verilog-more-comment))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2410 ((eolp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2411 ;; First, check if current line should be indented
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2412 (if (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2413 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2414 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2415 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2416 (if (looking-at verilog-auto-end-comment-lines-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2417 (let ((indent-str (verilog-indent-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2418 ;; Maybe we should set some endcomments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2419 (if verilog-auto-endcomments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2420 (verilog-set-auto-endcomments indent-str arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2421 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2422 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2423 (if arg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2424 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2425 (newline))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2426 nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2427 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2428 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2429 (delete-horizontal-space)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2430 't)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2431 ;; see if we should line up assignments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2432 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2433 (if (or (memq 'all verilog-auto-lineup)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2434 (memq 'assignments verilog-auto-lineup))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2435 (verilog-pretty-expr))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2436 (newline))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2437 (forward-line 1))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2438 ;; Indent next line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2439 (if verilog-auto-indent-on-newline
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2440 (verilog-indent-line)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2441 (t
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2442 (newline)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2443
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2444 (defun electric-verilog-terminate-and-indent ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2445 "Insert a newline and indent for the next statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2446 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2447 (electric-verilog-terminate-line 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2448
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2449 (defun electric-verilog-semi ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2450 "Insert `;' character and reindent the line."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2451 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2452 (insert last-command-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2453
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2454 (if (or (verilog-in-comment-or-string-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2455 (verilog-in-escaped-name-p))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2456 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2457 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2458 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2459 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2460 (verilog-indent-line))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2461 (if (and verilog-auto-newline
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2462 (not (verilog-parenthesis-depth)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2463 (electric-verilog-terminate-line))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2464
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2465 (defun electric-verilog-semi-with-comment ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2466 "Insert `;' character, reindent the line and indent for comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2467 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2468 (insert "\;")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2469 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2470 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2471 (verilog-indent-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2472 (indent-for-comment))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2473
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2474 (defun electric-verilog-colon ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2475 "Insert `:' and do all indentations except line indent on this line."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2476 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2477 (insert last-command-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2478 ;; Do nothing if within string.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2479 (if (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2480 (verilog-within-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2481 (not (verilog-in-case-region-p)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2482 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2483 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2484 (let ((p (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2485 (lim (progn (verilog-beg-of-statement) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2486 (goto-char p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2487 (verilog-backward-case-item lim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2488 (verilog-indent-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2489 ;; (let ((verilog-tab-always-indent nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2490 ;; (verilog-indent-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2491 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2492
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2493 ;;(defun electric-verilog-equal ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2494 ;; "Insert `=', and do indentation if within block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2495 ;; (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2496 ;; (insert last-command-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2497 ;; Could auto line up expressions, but not yet
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2498 ;; (if (eq (car (verilog-calculate-indent)) 'block)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2499 ;; (let ((verilog-tab-always-indent nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2500 ;; (verilog-indent-command)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2501 ;; )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2502
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2503 (defun electric-verilog-tick ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2504 "Insert back-tick, and indent to column 0 if this is a CPP directive."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2505 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2506 (insert last-command-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2507 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2508 (if (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2509 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2510 (looking-at verilog-directive-re-1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2511 (verilog-indent-line))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2512
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2513 (defun electric-verilog-tab ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2514 "Function called when TAB is pressed in Verilog mode."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2515 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2516 ;; If verilog-tab-always-indent, indent the beginning of the line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2517 (if (or verilog-tab-always-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2518 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2519 (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2520 (bolp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2521 (let* ((oldpnt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2522 (boi-point
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2523 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2524 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2525 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2526 (verilog-indent-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2527 (back-to-indentation)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2528 (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2529 (if (< (point) boi-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2530 (back-to-indentation)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2531 (cond ((not verilog-tab-to-comment))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2532 ((not (eolp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2533 (end-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2534 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2535 (indent-for-comment)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2536 (when (and (eolp) (= oldpnt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2537 ; kill existing comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2538 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2539 (re-search-forward comment-start-skip oldpnt 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2540 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2541 (skip-chars-backward " \t")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2542 (kill-region (point) oldpnt))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2543 (progn (insert "\t"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2544
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2546
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2547 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2548 ;; Interactive functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2549 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2550
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2551 (defun verilog-indent-buffer ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2552 "Indent-region the entire buffer as Verilog code.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2553 To call this from the command line, see \\[verilog-batch-indent]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2554 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2555 (verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2556 (indent-region (point-min) (point-max) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2557
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2558 (defun verilog-insert-block ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2559 "Insert Verilog begin ... end; block in the code with right indentation."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2560 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2561 (verilog-indent-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2562 (insert "begin")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2563 (electric-verilog-terminate-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2564 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2565 (electric-verilog-terminate-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2566 (insert "end")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2567 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2568 (verilog-indent-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2569
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2570 (defun verilog-star-comment ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2571 "Insert Verilog star comment at point."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2572 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2573 (verilog-indent-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2574 (insert "/*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2575 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2576 (newline)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2577 (insert " */"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2578 (newline)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2579 (insert " * "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2580
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2581 (defun verilog-insert-1 (fmt max)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2582 "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
2583 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
2584 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
2585 (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
2586 (n 0))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2587 (save-excursion
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2588 (while (< n max)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2589 (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
2590 (forward-line 1)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2591 ;; 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
2592 ;; shorter than col.
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2593 (if (eobp)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2594 (setq n max)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2595 (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
2596 (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
2597
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2598 (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
2599 "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
2600 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
2601 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
2602 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
2603 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
2604 located after the first 'a' gives:
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2605
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2606 a = b a[ 0] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2607 a = b a[ 1] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2608 a = b a[ 2] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2609 a = b a[ 3] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2610 a = b ==> insert-indices ==> a[ 4] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2611 a = b a[ 5] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2612 a = b a[ 6] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2613 a = b a[ 7] = b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2614 a = b a[ 8] = b"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2615
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2616 (interactive "NMAX: ")
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2617 (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
2618
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2619 (defun verilog-generate-numbers (max)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2620 "Insert a set of generated numbers into a rectangle.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2621 The upper left corner is defined by point. The numbers are padded to three
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2622 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
2623 is supplied, then the user is prompted for the MAX number. Consider the
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2624 following code fragment:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2625
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2626 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
2627 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
2628 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
2629 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
2630 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
2631 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
2632 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
2633 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
2634 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
2635
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2636 (interactive "NMAX: ")
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
2637 (verilog-insert-1 "%3.3d" max))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2638
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2639 (defun verilog-mark-defun ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2640 "Mark the current verilog function (or procedure).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2641 This puts the mark at the end, and point at the beginning."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2642 (interactive)
79810
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2643 (when (featurep 'xemacs)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2644 (push-mark (point))
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2645 (verilog-end-of-defun)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2646 (push-mark (point))
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2647 (verilog-beg-of-defun)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2648 (if (fboundp 'zmacs-activate-region)
606faa750dd7 (verilog-mode-map): Don't bind C-M-a,
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79801
diff changeset
2649 (zmacs-activate-region))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2650
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2651 (defun verilog-comment-region (start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2652 ; checkdoc-params: (start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2653 "Put the region into a Verilog comment.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2654 The comments that are in this area are \"deformed\":
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2655 `*)' becomes `!(*' and `}' becomes `!{'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2656 These deformed comments are returned to normal if you use
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2657 \\[verilog-uncomment-region] to undo the commenting.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2658
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2659 The commented area starts with `verilog-exclude-str-start', and ends with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2660 `verilog-exclude-str-end'. But if you change these variables,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2661 \\[verilog-uncomment-region] won't recognize the comments."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2662 (interactive "r")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2663 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2664 ;; Insert start and endcomments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2665 (goto-char end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2666 (if (and (save-excursion (skip-chars-forward " \t") (eolp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2667 (not (save-excursion (skip-chars-backward " \t") (bolp))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2668 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2669 (beginning-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2670 (insert verilog-exclude-str-end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2671 (setq end (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2672 (newline)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2673 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2674 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2675 (insert verilog-exclude-str-start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2676 (newline)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2677 ;; Replace end-comments within commented area
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2678 (goto-char end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2679 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2680 (while (re-search-backward "\\*/" start t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2681 (replace-match "*-/" t t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2682 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2683 (let ((s+1 (1+ start)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2684 (while (re-search-backward "/\\*" s+1 t)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2685 (replace-match "/-*" t t))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2686
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2687 (defun verilog-uncomment-region ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2688 "Uncomment a commented area; change deformed comments back to normal.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2689 This command does nothing if the pointer is not in a commented
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2690 area. See also `verilog-comment-region'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2691 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2692 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2693 (let ((start (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2694 (end (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2695 ;; Find the boundaries of the comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2696 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2697 (setq start (progn (search-backward verilog-exclude-str-start nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2698 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2699 (setq end (progn (search-forward verilog-exclude-str-end nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2700 (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2701 ;; Check if we're really inside a comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2702 (if (or (equal start (point)) (<= end (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2703 (message "Not standing within commented area.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2704 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2705 ;; Remove endcomment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2706 (goto-char end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2707 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2708 (let ((pos (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2709 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2710 (delete-region pos (1+ (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2711 ;; Change comments back to normal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2712 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2713 (while (re-search-backward "\\*-/" start t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2714 (replace-match "*/" t t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2715 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2716 (while (re-search-backward "/-\\*" start t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2717 (replace-match "/*" t t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2718 ;; Remove start comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2719 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2720 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2721 (let ((pos (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2722 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2723 (delete-region pos (1+ (point)))))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2724
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2725 (defun verilog-beg-of-defun ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2726 "Move backward to the beginning of the current function or procedure."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2727 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2728 (verilog-re-search-backward verilog-defun-re nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2729
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2730 (defun verilog-end-of-defun ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2731 "Move forward to the end of the current function or procedure."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2732 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2733 (verilog-re-search-forward verilog-end-defun-re nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2734
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2735 (defun verilog-get-beg-of-defun (&optional warn)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2736 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2737 (cond ((verilog-re-search-forward-quick verilog-defun-re nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2738 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2739 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2740 (error "%s: Can't find module beginning" (verilog-point-text))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2741 (point-max)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2742 (defun verilog-get-end-of-defun (&optional warn)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2743 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2744 (cond ((verilog-re-search-forward-quick verilog-end-defun-re nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2745 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2746 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2747 (error "%s: Can't find endmodule" (verilog-point-text))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2748 (point-max)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2749
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2750 (defun verilog-label-be (&optional arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2751 "Label matching begin ... end, fork ... join and case ... endcase statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2752 With ARG, first kill any existing labels."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2753 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2754 (let ((cnt 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2755 (oldpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2756 (b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2757 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2758 (point-marker)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2759 (e (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2760 (verilog-end-of-defun)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2761 (point-marker))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2762 (goto-char (marker-position b))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2763 (if (> (- e b) 200)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2764 (message "Relabeling module..."))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2765 (while (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2766 (> (marker-position e) (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2767 (verilog-re-search-forward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2768 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2769 "\\<end\\(\\(function\\)\\|\\(task\\)\\|\\(module\\)\\|\\(primitive\\)\\|\\(interface\\)\\|\\(package\\)\\|\\(case\\)\\)?\\>"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2770 "\\|\\(`endif\\)\\|\\(`else\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2771 nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2772 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2773 (let ((indent-str (verilog-indent-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2774 (verilog-set-auto-endcomments indent-str 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2775 (end-of-line)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2776 (delete-horizontal-space))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2777 (setq cnt (1+ cnt))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2778 (if (= 9 (% cnt 10))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2779 (message "%d..." cnt)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2780 (goto-char oldpos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2781 (if (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2782 (> (- e b) 200)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2783 (> cnt 20))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2784 (message "%d lines auto commented" cnt))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2785
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2786 (defun verilog-beg-of-statement ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2787 "Move backward to beginning of statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2788 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2789 ;; Move back token by token until we see the end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2790 ;; of some ealier line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2791 (while
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2792 ;; If the current point does not begin a new
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2793 ;; statement, as in the character ahead of us is a ';', or SOF
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2794 ;; or the string after us unambiguosly starts a statement,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2795 ;; or the token before us unambiguously ends a statement,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2796 ;; then move back a token and test again.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2797 (not (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2798 (bolp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2799 (= (preceding-char) ?\;)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2800 (not (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2801 (looking-at "\\<")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2802 (forward-word -1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2803 (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2804 (looking-at verilog-extended-complete-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2805 (not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2806 (verilog-backward-token)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2807 (looking-at verilog-extended-complete-re))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2808 (looking-at verilog-basic-complete-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2809 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2810 (verilog-backward-token)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2811 (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2812 (looking-at verilog-end-block-re)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2813 (looking-at verilog-preprocessor-re)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2814 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2815 (verilog-backward-token))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2816 ;; Now point is where the previous line ended.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2817 (verilog-forward-syntactic-ws))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2818
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2819 (defun verilog-beg-of-statement-1 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2820 "Move backward to beginning of statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2821 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2822 (let ((pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2823
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2824 (while (and (not (looking-at verilog-complete-reg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2825 (setq pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2826 (verilog-backward-token)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2827 (not (looking-at verilog-complete-reg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2828 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2829 (setq pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2830 (not (bolp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2831 (not (= (preceding-char) ?\;))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2832 (goto-char pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2833 (verilog-forward-ws&directives)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2834
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2835 (defun verilog-end-of-statement ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2836 "Move forward to end of current statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2837 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2838 (let ((nest 0) pos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2839 (or (looking-at verilog-beg-block-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2840 ;; Skip to end of statement
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2841 (setq pos (catch 'found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2842 (while t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2843 (forward-sexp 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2844 (verilog-skip-forward-comment-or-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2845 (cond ((looking-at "[ \t]*;")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2846 (skip-chars-forward "^;")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2847 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2848 (throw 'found (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2849 ((save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2850 (forward-sexp -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2851 (looking-at verilog-beg-block-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2852 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2853 (throw 'found nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2854 ((looking-at "[ \t]*)")
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
2855 (throw 'found (point)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2856 ((eobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2857 (throw 'found (point))))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2858 (if (not pos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2859 ;; Skip a whole block
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2860 (catch 'found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2861 (while t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2862 (verilog-re-search-forward verilog-end-statement-re nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2863 (setq nest (if (match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2864 (1+ nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2865 (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2866 (cond ((eobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2867 (throw 'found (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2868 ((= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2869 (throw 'found (verilog-end-of-statement))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2870 pos)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2871
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2872 (defun verilog-in-case-region-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2873 "Return TRUE if in a case region;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2874 more specifically, point @ in the line foo : @ begin"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2875 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2876 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2877 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2878 (progn (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2879 (looking-at "\\<begin\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2880 (progn (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2881 (= (preceding-char) ?\:)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2882 (catch 'found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2883 (let ((nest 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2884 (while t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2885 (verilog-re-search-backward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2886 (concat "\\(\\<module\\>\\)\\|\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2887 "\\(\\<endcase\\>\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2888 nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2889 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2890 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2891 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2892 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2893 (if (= nest 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2894 (throw 'found 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2895 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2896 (t
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2897 (throw 'found (= nest 0)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2898 nil)))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2899
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2900 (defun verilog-in-struct-region-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2901 "Return TRUE if in a struct region;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2902 more specifically, in a list after a struct|union keyword"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2903 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2904 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2905 (let* ((state (parse-partial-sexp (point-min) (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2906 (depth (nth 0 state)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2907 (if depth
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2908 (progn (backward-up-list depth)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2909 (verilog-beg-of-statement)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2910 (looking-at "\\<typedef\\>?\\s-*\\<struct\\|union\\>"))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2911
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2912 (defun verilog-in-generate-region-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2913 "Return TRUE if in a generate region;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2914 more specifically, after a generate and before an endgenerate"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2915 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2916 (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
2917 (nest 1))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2918 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2919 (while (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2920 (/= nest 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2921 (verilog-re-search-backward "\\<\\(generate\\)\\|\\(endgenerate\\)\\>" lim 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2922 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2923 ((match-end 1) ; generate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2924 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2925 ((match-end 2) ; endgenerate
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2926 (setq nest (1+ nest)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2927 (= nest 0) )) ; return nest
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2928
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2929 (defun verilog-in-fork-region-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2930 "Return true if between a fork and join."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2931 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2932 (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
2933 (nest 1))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2934 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2935 (while (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2936 (/= nest 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2937 (verilog-re-search-backward "\\<\\(fork\\)\\|\\(join\\(_any\\|_none\\)?\\)\\>" lim 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2938 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2939 ((match-end 1) ; fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2940 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2941 ((match-end 2) ; join
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2942 (setq nest (1+ nest)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2943 (= nest 0) )) ; return nest
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2944
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2945 (defun verilog-backward-case-item (lim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2946 "Skip backward to nearest enclosing case item.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2947 Limit search to point LIM."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2948 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2949 (let ((str 'nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2950 (lim1
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2951 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2952 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2953 (verilog-re-search-backward verilog-endcomment-reason-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2954 lim 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2955 (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2956 ;; Try to find the real :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2957 (if (save-excursion (search-backward ":" lim1 t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2958 (let ((colon 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2959 b e )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2960 (while
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2961 (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2962 (< colon 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2963 (verilog-re-search-backward "\\(\\[\\)\\|\\(\\]\\)\\|\\(:\\)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2964 lim1 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2965 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2966 ((match-end 1) ;; [
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2967 (setq colon (1+ colon))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2968 (if (>= colon 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2969 (error "%s: unbalanced [" (verilog-point-text))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2970 ((match-end 2) ;; ]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2971 (setq colon (1- colon)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2972
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2973 ((match-end 3) ;; :
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2974 (setq colon (1+ colon)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2975 ;; Skip back to beginning of case item
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2976 (skip-chars-backward "\t ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2977 (verilog-skip-backward-comment-or-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2978 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2979 (setq b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2980 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2981 (if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2982 (verilog-re-search-backward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2983 "\\<\\(case[zx]?\\)\\>\\|;\\|\\<end\\>" nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2984 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2985 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2986 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2987 (goto-char (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2988 (verilog-forward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2989 (if (looking-at "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2990 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2991 (forward-sexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2992 (verilog-forward-ws&directives)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2993 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2994 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2995 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2996 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2997 (point))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
2998 (error "Malformed case item"))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2999 (setq str (buffer-substring b e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3000 (if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3001 (setq e
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3002 (string-match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3003 "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3004 (setq str (concat (substring str 0 e) "...")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3005 str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3006 'nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3007
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3008
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3009 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3010 ;; Other functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3011 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3012
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3013 (defun verilog-kill-existing-comment ()
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3014 "Kill auto comment on this line."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3015 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3016 (let* (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3017 (e (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3018 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3019 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3020 (b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3021 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3022 (search-forward "//" e t))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3023 (if b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3024 (delete-region (- b 2) e)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3025
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3026 (defconst verilog-directive-nest-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3027 (concat "\\(`else\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3028 "\\(`endif\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3029 "\\(`if\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3030 "\\(`ifdef\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3031 "\\(`ifndef\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3032 (defun verilog-set-auto-endcomments (indent-str kill-existing-comment)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3033 "Add ending comment with given INDENT-STR.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3034 With KILL-EXISTING-COMMENT, remove what was there before.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3035 Insert `// case: 7 ' or `// NAME ' on this line if appropriate.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3036 Insert `// case expr ' if this line ends a case block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3037 Insert `// ifdef FOO ' if this line ends code conditional on FOO.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3038 Insert `// NAME ' if this line ends a function, task, module, primitive or interface named NAME."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3039 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3040 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3041 (; Comment close preprocessor directives
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3042 (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3043 (looking-at "\\(`endif\\)\\|\\(`else\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3044 (or kill-existing-comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3045 (not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3046 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3047 (search-backward "//" (verilog-get-beg-of-line) t)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3048 (let ((nest 1) b e
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3049 m
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3050 (else (if (match-end 2) "!" " ")))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3051 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3052 (if kill-existing-comment
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3053 (verilog-kill-existing-comment))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3054 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3055 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3056 (backward-sexp 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3057 (while (and (/= nest 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3058 (verilog-re-search-backward verilog-directive-nest-re nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3059 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3060 ((match-end 1) ; `else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3061 (if (= nest 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3062 (setq else "!")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3063 ((match-end 2) ; `endif
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3064 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3065 ((match-end 3) ; `if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3066 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3067 ((match-end 4) ; `ifdef
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3068 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3069 ((match-end 5) ; `ifndef
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3070 (setq nest (1- nest)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3071 (if (match-end 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3072 (setq
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3073 m (buffer-substring
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3074 (match-beginning 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3075 (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3076 b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3077 (skip-chars-forward "^ \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3078 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3079 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3080 e (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3081 (skip-chars-forward "a-zA-Z0-9_")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3082 (point)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3083 (if b
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3084 (if (> (count-lines (point) b) verilog-minimum-comment-distance)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3085 (insert (concat " // " else m " " (buffer-substring b e))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3086 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3087 (insert " // unmatched `else or `endif")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3088 (ding 't)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3089
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3090 (; Comment close case/class/function/task/module and named block
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3091 (and (looking-at "\\<end")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3092 (or kill-existing-comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3093 (not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3094 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3095 (search-backward "//" (verilog-get-beg-of-line) t)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3096 (let ((type (car indent-str)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3097 (unless (eq type 'declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3098 (unless (looking-at (concat "\\(" verilog-end-block-ordered-re "\\)[ \t]*:")) ;; ignore named ends
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3099 (if (looking-at verilog-end-block-ordered-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3100 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3101 (;- This is a case block; search back for the start of this case
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3102 (match-end 1) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3103
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3104 (let ((err 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3105 (str "UNMATCHED!!"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3106 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3107 (verilog-leap-to-head)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3108 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3109 ((looking-at "\\<randcase\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3110 (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
3111 (setq err nil))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3112 ((match-end 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3113 (goto-char (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3114 (if nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3115 (let (s f)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3116 (setq s (match-beginning 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3117 (setq f (progn (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3118 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3119 (setq str (buffer-substring s f)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3120 (setq err nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3121 (setq str (concat (buffer-substring (match-beginning 1) (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3122 " "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3123 (verilog-get-expr))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3124 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3125 (if kill-existing-comment
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3126 (verilog-kill-existing-comment))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3127 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3128 (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
3129 (if err (ding 't))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3130
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3131 (;- This is a begin..end block
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3132 (match-end 2) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3133 (let ((str " // UNMATCHED !!")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3134 (err 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3135 (here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3136 there
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3137 cntx)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3138 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3139 (verilog-leap-to-head)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3140 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3141 (if (not (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3142 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3143 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3144 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3145 (if kill-existing-comment
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3146 (verilog-kill-existing-comment))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3147 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3148 (insert str)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3149 (ding 't))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3150 (let ((lim
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3151 (save-excursion (verilog-beg-of-defun) (point)))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3152 (here (point)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3153 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3154 (;-- handle named block differently
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3155 (looking-at verilog-named-block-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3156 (search-forward ":")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3157 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3158 (setq str (verilog-get-expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3159 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3160 (setq str (concat " // block: " str )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3161
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3162 ((verilog-in-case-region-p) ;-- handle case item differently
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3163 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3164 (setq str (verilog-backward-case-item lim))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3165 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3166 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3167 (setq str (concat " // case: " str )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3168
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3169 (;- try to find "reason" for this begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3170 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3171 (;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3172 (eq here (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3173 (verilog-backward-token)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3174 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3175 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3176 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3177 (setq str ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3178 ((looking-at verilog-endcomment-reason-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3179 (setq there (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3180 (setq cntx (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3181 (buffer-substring (match-beginning 0) (match-end 0)) " "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3182 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3183 (;- begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3184 (match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3185 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3186 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3187 (if (and (verilog-continued-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3188 (looking-at "\\<repeat\\>\\|\\<wait\\>\\|\\<always\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3189 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3190 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3191 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3192 (setq str
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3193 (concat " // "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3194 (buffer-substring (match-beginning 0) (match-end 0)) " "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3195 (verilog-get-expr))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3196 (setq str ""))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3197
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3198 (;- else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3199 (match-end 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3200 (let ((nest 0)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3201 ( reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3202 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3203 (while (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3204 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3205 ((match-end 1) ; begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3206 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3207 ((match-end 2) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3208 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3209 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3210 (if (= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3211 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3212 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3213 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3214 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3215 (setq str (verilog-get-expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3216 (setq str (concat " // else: !if" str ))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3217 (throw 'skip 1)))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3218
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3219 (;- end else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3220 (match-end 5)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3221 (goto-char there)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3222 (let ((nest 0)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3223 (reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|\\(\\<if\\>\\)"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3224 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3225 (while (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3226 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3227 ((match-end 1) ; begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3228 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3229 ((match-end 2) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3230 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3231 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3232 (if (= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3233 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3234 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3235 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3236 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3237 (setq str (verilog-get-expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3238 (setq str (concat " // else: !if" str ))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3239 (throw 'skip 1)))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3240
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3241 (;- task/function/initial et cetera
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3242 t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3243 (match-end 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3244 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3245 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3246 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3247 (setq str (verilog-get-expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3248 (setq str (concat " // " cntx str )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3249
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3250 (;-- otherwise...
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3251 (setq str " // auto-endcomment confused "))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3252
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3253 ((and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3254 (verilog-in-case-region-p) ;-- handle case item differently
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3255 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3256 (setq there (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3257 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3258 (setq str (verilog-backward-case-item lim))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3259 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3260 (setq str (concat " // case: " str )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3261
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3262 ((verilog-in-fork-region-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3263 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3264 (setq str " // fork branch" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3265
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3266 ((looking-at "\\<end\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3267 ;; HERE
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3268 (forward-word 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3269 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3270 (setq err nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3271 (setq str (verilog-get-expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3272 (setq str (concat " // " cntx str )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3273
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3274 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3275 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3276 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3277 (if kill-existing-comment
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3278 (verilog-kill-existing-comment))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3279 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3280 (if (or err
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3281 (> (count-lines here there) verilog-minimum-comment-distance))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3282 (insert str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3283 (if err (ding 't))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3284 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3285 (;- this is endclass, which can be nested
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3286 (match-end 11) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3287 ;;(goto-char there)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3288 (let ((nest 0)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3289 (reg "\\<\\(class\\)\\|\\(endclass\\)\\|\\(package\\|primitive\\|\\(macro\\)?module\\)\\>")
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3290 string)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3291 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3292 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3293 (while (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3294 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3295 ((match-end 3) ; endclass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3296 (ding 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3297 (setq string "unmatched endclass")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3298 (throw 'skip 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3299
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3300 ((match-end 2) ; endclass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3301 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3302
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3303 ((match-end 1) ; class
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3304 (setq nest (1- nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3305 (if (< nest 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3306 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3307 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3308 (let (b e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3309 (setq b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3310 (skip-chars-forward "^ \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3311 (verilog-forward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3312 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3313 e (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3314 (skip-chars-forward "a-zA-Z0-9_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3315 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3316 (setq string (buffer-substring b e)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3317 (throw 'skip 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3318 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3319 (end-of-line)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3320 (insert (concat " // " string ))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3321
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3322 (;- this is end{function,generate,task,module,primitive,table,generate}
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3323 ;- which can not be nested.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3324 t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3325 (let (string reg (width nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3326 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3327 (if kill-existing-comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3328 (save-match-data
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
3329 (verilog-kill-existing-comment)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3330 (delete-horizontal-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3331 (backward-sexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3332 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3333 ((match-end 5) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3334 (setq reg "\\(\\<function\\>\\)\\|\\(\\<\\(endfunction\\|task\\|\\(macro\\)?module\\|primitive\\)\\>\\)")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3335 (setq width "\\(\\s-*\\(\\[[^]]*\\]\\)\\|\\(real\\(time\\)?\\)\\|\\(integer\\)\\|\\(time\\)\\)?"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3336 ((match-end 6) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3337 (setq reg "\\(\\<task\\>\\)\\|\\(\\<\\(endtask\\|function\\|\\(macro\\)?module\\|primitive\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3338 ((match-end 7) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3339 (setq reg "\\(\\<\\(macro\\)?module\\>\\)\\|\\<endmodule\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3340 ((match-end 8) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3341 (setq reg "\\(\\<primitive\\>\\)\\|\\(\\<\\(endprimitive\\|package\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3342 ((match-end 9) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3343 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<\\(endinterface\\|package\\|primitive\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3344 ((match-end 10) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3345 (setq reg "\\(\\<package\\>\\)\\|\\(\\<\\(endpackage\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3346 ((match-end 11) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3347 (setq reg "\\(\\<class\\>\\)\\|\\(\\<\\(endclass\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3348 ((match-end 12) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3349 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<\\(endcovergroup\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3350 ((match-end 13) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3351 (setq reg "\\(\\<program\\>\\)\\|\\(\\<\\(endprogram\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3352 ((match-end 14) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3353 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<\\(endsequence\\|primitive\\|interface\\|\\(macro\\)?module\\)\\>\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3354 ((match-end 15) ;; of verilog-end-block-ordered-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3355 (setq reg "\\(\\<clocking\\>\\)\\|\\<endclocking\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3356
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3357 (t (error "Problem in verilog-set-auto-endcomments")))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3358 (let (b e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3359 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3360 (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3361 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3362 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3363 (setq b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3364 (skip-chars-forward "^ \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3365 (verilog-forward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3366 (if (and width (looking-at width))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3367 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3368 (goto-char (match-end 0))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3369 (verilog-forward-ws&directives)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3370 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3371 e (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3372 (skip-chars-forward "a-zA-Z0-9_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3373 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3374 (setq string (buffer-substring b e)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3375 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3376 (ding 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3377 (setq string "unmatched end(function|task|module|primitive|interface|package|class|clocking)")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3378 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3379 (insert (concat " // " string )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3380 ))))))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3381
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3382 (defun verilog-get-expr()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3383 "Grab expression at point, e.g, case ( a | b & (c ^d))"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3384 (let* ((b (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3385 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3386 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3387 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3388 (e (let ((par 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3389 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3390 ((looking-at "@")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3391 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3392 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3393 (if (looking-at "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3394 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3395 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3396 (while (and (/= par 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3397 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3398 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3399 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3400 (setq par (1+ par)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3401 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3402 (setq par (1- par)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3403 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3404 ((looking-at "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3405 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3406 (while (and (/= par 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3407 (verilog-re-search-forward "\\((\\)\\|\\()\\)" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3408 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3409 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3410 (setq par (1+ par)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3411 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3412 (setq par (1- par)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3413 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3414 ((looking-at "\\[")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3415 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3416 (while (and (/= par 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3417 (verilog-re-search-forward "\\(\\[\\)\\|\\(\\]\\)" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3418 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3419 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3420 (setq par (1+ par)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3421 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3422 (setq par (1- par)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3423 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3424 (skip-chars-forward "^ \t\n\f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3425 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3426 ((looking-at "/[/\\*]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3427 b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3428 ('t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3429 (skip-chars-forward "^: \t\n\f")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3430 (point)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3431 (str (buffer-substring b e)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3432 (if (setq e (string-match "[ \t]*\\(\\(\n\\)\\|\\(//\\)\\|\\(/\\*\\)\\)" str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3433 (setq str (concat (substring str 0 e) "...")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3434 str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3435
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3436 (defun verilog-expand-vector ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3437 "Take a signal vector on the current line and expand it to multiple lines.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3438 Useful for creating tri's and other expanded fields."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3439 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3440 (verilog-expand-vector-internal "[" "]"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3441
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3442 (defun verilog-expand-vector-internal (bra ket)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3443 "Given BRA, the start brace and KET, the end brace, expand one line into many lines."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3444 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3445 (forward-line 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3446 (let ((signal-string (buffer-substring (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3447 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3448 (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
3449 (if (string-match
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3450 (concat "\\(.*\\)"
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3451 (regexp-quote bra)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3452 "\\([0-9]*\\)\\(:[0-9]*\\|\\)\\(::[0-9---]*\\|\\)"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3453 (regexp-quote ket)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3454 "\\(.*\\)$") signal-string)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3455 (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
3456 (vec-start (string-to-number (match-string 2 signal-string)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3457 (vec-end (if (= (match-beginning 3) (match-end 3))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3458 vec-start
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3459 (string-to-number
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3460 (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
3461 (match-end 3)))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3462 (vec-range
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3463 (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
3464 1
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3465 (string-to-number
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3466 (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
3467 (match-end 4)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3468 (sig-tail (match-string 5 signal-string))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3469 vec)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3470 ;; Decode vectors
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3471 (setq vec nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3472 (if (< vec-range 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3473 (let ((tmp vec-start))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3474 (setq vec-start vec-end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3475 vec-end tmp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3476 vec-range (- vec-range))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3477 (if (< vec-end vec-start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3478 (while (<= vec-end vec-start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3479 (setq vec (append vec (list vec-start)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3480 (setq vec-start (- vec-start vec-range)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3481 (while (<= vec-start vec-end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3482 (setq vec (append vec (list vec-start)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3483 (setq vec-start (+ vec-start vec-range))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3484 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3485 ;; Delete current line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3486 (delete-region (point) (progn (forward-line 0) (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3487 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3488 ;; Expand vector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3489 (while vec
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3490 (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
3491 (int-to-string (car vec)) ket sig-tail "\n"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3492 (setq vec (cdr vec)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3493 (delete-char -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3494 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3495 )))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3496
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3497 (defun verilog-strip-comments ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3498 "Strip all comments from the verilog code."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3499 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3500 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3501 (while (re-search-forward "//" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3502 (if (verilog-within-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3503 (re-search-forward "\"" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3504 (if (verilog-in-star-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3505 (re-search-forward "\*/" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3506 (let ((bpt (- (point) 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3507 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3508 (delete-region bpt (point))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3509 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3510 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3511 (while (re-search-forward "/\\*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3512 (if (verilog-within-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3513 (re-search-forward "\"" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3514 (let ((bpt (- (point) 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3515 (re-search-forward "\\*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3516 (delete-region bpt (point))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3517
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3518 (defun verilog-one-line ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3519 "Convert structural verilog instances to occupy one line."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3520 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3521 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3522 (while (re-search-forward "\\([^;]\\)[ \t]*\n[ \t]*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3523 (replace-match "\\1 " nil nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3524
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3525 (defun verilog-linter-name ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3526 "Return name of linter, either surelint or verilint."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3527 (let ((compile-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3528 compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3529 (lint-word1 (verilog-string-replace-matches "\\s .*$" "" nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3530 verilog-linter)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3531 (cond ((equal compile-word1 "surelint") `surelint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3532 ((equal compile-word1 "verilint") `verilint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3533 ((equal lint-word1 "surelint") `surelint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3534 ((equal lint-word1 "verilint") `verilint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3535 (t `surelint)))) ;; back compatibility
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3536
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3537 (defun verilog-lint-off ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3538 "Convert a Verilog linter warning line into a disable statement.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3539 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3540 pci_bfm_null.v, line 46: Unused input: pci_rst_
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3541 becomes a comment for the appropriate tool.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3542
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3543 The first word of the `compile-command' or `verilog-linter'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3544 variables are used to determine which product is being used.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3546 See \\[verilog-surelint-off] and \\[verilog-verilint-off]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3547 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3548 (let ((linter (verilog-linter-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3549 (cond ((equal linter `surelint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3550 (verilog-surelint-off))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3551 ((equal linter `verilint)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3552 (verilog-verilint-off))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3553 (t (error "Linter name not set")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3554
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3555 (defvar compilation-last-buffer)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3556
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3557 (defun verilog-surelint-off ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3558 "Convert a SureLint warning line into a disable statement.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3559 Run from Verilog source window; assumes there is a *compile* buffer
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3560 with point set appropriately.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3561
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3562 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3563 WARNING [STD-UDDONX]: xx.v, line 8: output out is never assigned.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3564 becomes:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3565 // surefire lint_line_off UDDONX"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3566 (interactive)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3567 (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
3568 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
3569 compilation-last-buffer)))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3570 (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
3571 ;; 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
3572 (save-excursion
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3573 (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
3574 (beginning-of-line)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3575 (when
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3576 (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
3577 (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
3578 (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
3579 (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
3580 (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
3581 dir filename)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3582 (unless buffer
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3583 (progn
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3584 (setq buffer
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3585 (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
3586 (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
3587 (or buffer
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3588 (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
3589 (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
3590 (read-file-name
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3591 (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
3592 file)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3593 dir file t))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3594 (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
3595 (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
3596 (setq buffer
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3597 (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
3598 (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
3599 (switch-to-buffer buffer)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3600 (goto-line (string-to-number line))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3601 (end-of-line)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3602 (catch 'already
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3603 (cond
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3604 ((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
3605 (re-search-backward "//")
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3606 (cond
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3607 ((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
3608 (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
3609 (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
3610 (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
3611 (throw 'already t)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3612 (insert (concat " " code)))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3613 (t
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3614 )))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3615 ((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
3616 (re-search-backward "/\*")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3617 (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
3618 (t
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3619 (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
3620 )))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3621
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3622 (defun verilog-verilint-off ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3623 "Convert a Verilint warning line into a disable statement.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3624
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3625 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3626 (W240) pci_bfm_null.v, line 46: Unused input: pci_rst_
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3627 becomes:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3628 //Verilint 240 off // WARNING: Unused input"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3629 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3630 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3631 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3632 (when (looking-at "\\(.*\\)([WE]\\([0-9A-Z]+\\)).*,\\s +line\\s +[0-9]+:\\s +\\([^:\n]+\\):?.*$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3633 (replace-match (format
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3634 ;; %3s makes numbers 1-999 line up nicely
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3635 "\\1//Verilint %3s off // WARNING: \\3"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3636 (match-string 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3637 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3638 (verilog-indent-line))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3639
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3640 (defun verilog-auto-save-compile ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3641 "Update automatics with \\[verilog-auto], save the buffer, and compile."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3642 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3643 (verilog-auto) ; Always do it for safety
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3644 (save-buffer)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3645 (compile compile-command))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3646
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3647
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3648
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3649 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3650 ;; Batch
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3651 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3652
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3653 (defmacro verilog-batch-error-wrapper (&rest body)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3654 "Execute BODY and add error prefix to any errors found.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3655 This lets programs calling batch mode to easily extract error messages."
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
3656 `(condition-case err
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
3657 (progn ,@body)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
3658 (error
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
3659 (error "%%Error: %s%s" (error-message-string err)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
3660 (if (featurep 'xemacs) "\n" ""))))) ;; xemacs forgets to add a newline
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3661
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3662 (defun verilog-batch-execute-func (funref)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3663 "Internal processing of a batch command, running FUNREF on all command arguments."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3664 (verilog-batch-error-wrapper
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3665 ;; General globals needed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3666 (setq make-backup-files nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3667 (setq-default make-backup-files nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3668 (setq enable-local-variables t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3669 (setq enable-local-eval t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3670 ;; Make sure any sub-files we read get proper mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3671 (setq default-major-mode `verilog-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3672 ;; 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
3673 (mapc (lambda (buf)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3674 (when (buffer-file-name buf)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3675 (save-excursion
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3676 (set-buffer buf)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3677 (verilog-mode))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3678 (buffer-list))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3679 ;; Process the files
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3680 (mapcar '(lambda (buf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3681 (when (buffer-file-name buf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3682 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3683 (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
3684 (error
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3685 (concat "File not found: " (buffer-file-name buf))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3686 (message (concat "Processing " (buffer-file-name buf)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3687 (set-buffer buf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3688 (funcall funref)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3689 (save-buffer))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3690 (buffer-list))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3691
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3692 (defun verilog-batch-auto ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3693 "For use with --batch, perform automatic expansions as a stand-alone tool.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3694 This sets up the appropriate Verilog-Mode environment, updates automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3695 with \\[verilog-auto] on all command-line files, and saves the buffers.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3696 For proper results, multiple filenames need to be passed on the command
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3697 line in bottom-up order."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3698 (unless noninteractive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3699 (error "Use verilog-batch-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3700 (verilog-batch-execute-func `verilog-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3701
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3702 (defun verilog-batch-delete-auto ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3703 "For use with --batch, perform automatic deletion as a stand-alone tool.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3704 This sets up the appropriate Verilog-Mode environment, deletes automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3705 with \\[verilog-delete-auto] on all command-line files, and saves the buffers."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3706 (unless noninteractive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3707 (error "Use verilog-batch-delete-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3708 (verilog-batch-execute-func `verilog-delete-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3709
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3710 (defun verilog-batch-inject-auto ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3711 "For use with --batch, perform automatic injection as a stand-alone tool.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3712 This sets up the appropriate Verilog-Mode environment, injects new automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3713 with \\[verilog-inject-auto] on all command-line files, and saves the buffers.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3714 For proper results, multiple filenames need to be passed on the command
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3715 line in bottom-up order."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3716 (unless noninteractive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3717 (error "Use verilog-batch-inject-auto only with --batch")) ;; Otherwise we'd mess up buffer modes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3718 (verilog-batch-execute-func `verilog-inject-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3719
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3720 (defun verilog-batch-indent ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3721 "For use with --batch, reindent an a entire file as a stand-alone tool.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3722 This sets up the appropriate Verilog-Mode environment, calls
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3723 \\[verilog-indent-buffer] on all command-line files, and saves the buffers."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3724 (unless noninteractive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3725 (error "Use verilog-batch-indent only with --batch")) ;; Otherwise we'd mess up buffer modes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3726 (verilog-batch-execute-func `verilog-indent-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3727
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3728
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3729 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3730 ;; Indentation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3731 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3732 (defconst verilog-indent-alist
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3733 '((block . (+ ind verilog-indent-level))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3734 (case . (+ ind verilog-case-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3735 (cparenexp . (+ ind verilog-indent-level))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3736 (cexp . (+ ind verilog-cexp-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3737 (defun . verilog-indent-level-module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3738 (declaration . verilog-indent-level-declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3739 (directive . (verilog-calculate-indent-directive))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3740 (tf . verilog-indent-level)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3741 (behavioral . (+ verilog-indent-level-behavioral verilog-indent-level-module))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3742 (statement . ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3743 (cpp . 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3744 (comment . (verilog-comment-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3745 (unknown . 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3746 (string . 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3747
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3748 (defun verilog-continued-line-1 (lim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3749 "Return true if this is a continued line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3750 Set point to where line starts. Limit search to point LIM."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3751 (let ((continued 't))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3752 (if (eq 0 (forward-line -1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3753 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3754 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3755 (verilog-backward-ws&directives lim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3756 (if (bobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3757 (setq continued nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3758 (setq continued (verilog-backward-token))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3759 (setq continued nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3760 continued))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3761
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3762 (defun verilog-calculate-indent ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3763 "Calculate the indent of the current Verilog line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3764 Examine previous lines. Once a line is found that is definitive as to the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3765 type of the current line, return that lines' indent level and its
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3766 type. Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3767 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3768 (let* ((starting_position (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3769 (par 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3770 (begin (looking-at "[ \t]*begin\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3771 (lim (save-excursion (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)" nil t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3772 (type (catch 'nesting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3773 ;; Keep working backwards until we can figure out
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3774 ;; what type of statement this is.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3775 ;; Basically we need to figure out
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3776 ;; 1) if this is a continuation of the previous line;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3777 ;; 2) are we in a block scope (begin..end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3778
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3779 ;; if we are in a comment, done.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3780 (if (verilog-in-star-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3781 (throw 'nesting 'comment))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3782
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3783 ;; if we have a directive, done.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3784 (if (save-excursion (beginning-of-line) (looking-at verilog-directive-re-1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3785 (throw 'nesting 'directive))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3786
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3787 ;; unless we are in the newfangled coverpoint or constraint blocks
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3788 ;; if we are in a parenthesized list, and the user likes to indent these, return.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3789 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3790 verilog-indent-lists
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3791 (not (verilog-in-coverage))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3792 (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3793 (progn (setq par 1)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3794 (throw 'nesting 'block)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3795
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3796 ;; See if we are continuing a previous line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3797 (while t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3798 ;; trap out if we crawl off the top of the buffer
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3799 (if (bobp) (throw 'nesting 'cpp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3800
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3801 (if (verilog-continued-line-1 lim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3802 (let ((sp (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3803 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3804 (not (looking-at verilog-complete-reg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3805 (verilog-continued-line-1 lim))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3806 (progn (goto-char sp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3807 (throw 'nesting 'cexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3808
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3809 (goto-char sp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3810
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3811 (if (and begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3812 (not verilog-indent-begin-after-if)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3813 (looking-at verilog-no-indent-begin-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3814 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3815 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3816 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3817 (throw 'nesting 'statement))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3818 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3819 (throw 'nesting 'cexp))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3820 ;; not a continued line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3821 (goto-char starting_position))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3822
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3823 (if (looking-at "\\<else\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3824 ;; search back for governing if, striding across begin..end pairs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3825 ;; appropriately
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3826 (let ((elsec 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3827 (while (verilog-re-search-backward verilog-ends-re nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3828 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3829 ((match-end 1) ; else, we're in deep
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3830 (setq elsec (1+ elsec)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3831 ((match-end 2) ; if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3832 (setq elsec (1- elsec))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3833 (if (= 0 elsec)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3834 (if verilog-align-ifelse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3835 (throw 'nesting 'statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3836 (progn ;; back up to first word on this line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3837 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3838 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3839 (throw 'nesting 'statement)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3840 (t ; endblock
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3841 ; try to leap back to matching outward block by striding across
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3842 ; indent level changing tokens then immediately
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3843 ; previous line governs indentation.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3844 (let (( reg) (nest 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3845 ;; verilog-ends => else|if|end|join(_any|_none|)|endcase|endclass|endtable|endspecify|endfunction|endtask|endgenerate|endgroup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3846 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3847 ((match-end 3) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3848 ;; Search back for matching begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3849 (setq reg "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3850 ((match-end 4) ; endcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3851 ;; Search back for matching case
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3852 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3853 ((match-end 5) ; endfunction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3854 ;; Search back for matching function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3855 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3856 ((match-end 6) ; endtask
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3857 ;; Search back for matching task
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3858 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3859 ((match-end 7) ; endspecify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3860 ;; Search back for matching specify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3861 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3862 ((match-end 8) ; endtable
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3863 ;; Search back for matching table
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3864 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3865 ((match-end 9) ; endgenerate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3866 ;; Search back for matching generate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3867 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3868 ((match-end 10) ; joins
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3869 ;; Search back for matching fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3870 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|none\\)?\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3871 ((match-end 11) ; class
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3872 ;; Search back for matching class
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3873 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3874 ((match-end 12) ; covergroup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3875 ;; Search back for matching covergroup
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3876 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" )))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3877 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3878 (while (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3879 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3880 ((match-end 1) ; begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3881 (setq nest (1- nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3882 (if (= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3883 (throw 'skip 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3884 ((match-end 2) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3885 (setq nest (1+ nest)))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3886 )))))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3887 (throw 'nesting (verilog-calc-1)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3888 );; catch nesting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3889 );; type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3890 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3891 ;; Return type of block and indent level.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3892 (if (not type)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3893 (setq type 'cpp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3894 (if (> par 0) ; Unclosed Parenthesis
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3895 (list 'cparenexp par)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3896 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3897 ((eq type 'case)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3898 (list type (verilog-case-indent-level)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3899 ((eq type 'statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3900 (list type (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3901 ((eq type 'defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3902 (list type 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3903 (t
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3904 (list type (verilog-current-indent-level))))))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3905
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3906 (defun verilog-wai ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3907 "Show matching nesting block for debugging."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3908 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3909 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3910 (let ((nesting (verilog-calc-1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3911 (message "You are at nesting %s" nesting))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3912
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3913 (defun verilog-calc-1 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3914 (catch 'nesting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3915 (while (verilog-re-search-backward (concat "\\({\\|}\\|" verilog-indent-re "\\)") nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3916 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3917 ((equal (char-after) ?\{)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3918 (if (verilog-at-constraint-p)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3919 (throw 'nesting 'block)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3920 ((equal (char-after) ?\})
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3921
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3922 (let ((there (verilog-at-close-constraint-p)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3923 (if there (goto-char there))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3924
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3925 ((looking-at verilog-beg-block-re-ordered)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3926 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3927 ((match-end 2) ; *sigh* could be "unique case" or "priority casex"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3928 (let ((here (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3929 (verilog-beg-of-statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3930 (if (looking-at verilog-extended-case-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3931 (throw 'nesting 'case)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3932 (goto-char here)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3933 (throw 'nesting 'case))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3934
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3935 ;; need to consider typedef struct here...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3936 ((looking-at "\\<class\\|struct\\|function\\|task\\|property\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3937 ; *sigh* These words have an optional prefix:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3938 ; extern {virtual|protected}? function a();
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3939 ; assert property (p_1);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3940 ; typedef class foo;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3941 ; and we don't want to confuse this with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3942 ; function a();
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3943 ; property
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3944 ; ...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3945 ; endfunction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3946 (let ((here (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3947 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3948 (verilog-beg-of-statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3949 (if (= (point) here)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3950 (throw 'nesting 'block)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3951 (t (throw 'nesting 'block))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3952
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3953 ((looking-at verilog-end-block-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3954 (verilog-leap-to-head)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3955 (if (verilog-in-case-region-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3956 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3957 (verilog-leap-to-case-head)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3958 (if (looking-at verilog-case-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3959 (throw 'nesting 'case)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3960
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3961 ((looking-at (if (verilog-in-generate-region-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3962 verilog-defun-level-not-generate-re
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3963 verilog-defun-level-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3964 (throw 'nesting 'defun))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3965
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3966 ((looking-at verilog-cpp-level-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3967 (throw 'nesting 'cpp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3968
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3969 ((bobp)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3970 (throw 'nesting 'cpp))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
3971 (throw 'nesting 'cpp)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3972
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3973 (defun verilog-calculate-indent-directive ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3974 "Return indentation level for directive.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3975 For speed, the searcher looks at the last directive, not the indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3976 of the appropriate enclosing block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3977 (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
3978 (ind 0)) ;; Relative offset caused by other directives (like `endif on same line as `else)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3979 ;; Start at current location, scan back for another directive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3980
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3981 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3982 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3983 (while (and (< base 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3984 (verilog-re-search-backward verilog-directive-re nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3985 (cond ((save-excursion (skip-chars-backward " \t") (bolp))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
3986 (setq base (current-indentation))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3987 (cond ((and (looking-at verilog-directive-end) (< base 0)) ;; Only matters when not at BOL
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3988 (setq ind (- ind verilog-indent-level-directive)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3989 ((and (looking-at verilog-directive-middle) (>= base 0)) ;; Only matters when at BOL
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3990 (setq ind (+ ind verilog-indent-level-directive)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3991 ((looking-at verilog-directive-begin)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3992 (setq ind (+ ind verilog-indent-level-directive)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3993 ;; Adjust indent to starting indent of critical line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3994 (setq ind (max 0 (+ ind base))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3995
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3996 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3997 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3998 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3999 (cond ((or (looking-at verilog-directive-middle)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4000 (looking-at verilog-directive-end))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4001 (setq ind (max 0 (- ind verilog-indent-level-directive))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4002 ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4003
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4004 (defun verilog-leap-to-case-head ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4005 (let ((nest 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4006 (while (/= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4007 (verilog-re-search-backward "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4008 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4009 ((match-end 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4010 (setq nest (1- nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4011 ((match-end 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4012 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4013 ((bobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4014 (ding 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4015 (setq nest 0))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4016
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4017 (defun verilog-leap-to-head ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4018 "Move point to the head of this block; jump from end to matching begin,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4019 from endcase to matching case, and so on."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4020 (let ((reg nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4021 snest
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4022 (nest 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4023 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4024 ((looking-at "\\<end\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4025 ;; 1: Search back for matching begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4026 (setq reg (concat "\\(\\<begin\\>\\)\\|\\(\\<end\\>\\)\\|"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4027 "\\(\\<endcase\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4028 ((looking-at "\\<endcase\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4029 ;; 2: Search back for matching case
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4030 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>\\)\\|\\(\\<endcase\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4031 ((looking-at "\\<join\\(_any\\|_none\\)?\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4032 ;; 3: Search back for matching fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4033 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4034 ((looking-at "\\<endclass\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4035 ;; 4: Search back for matching class
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4036 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4037 ((looking-at "\\<endtable\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4038 ;; 5: Search back for matching table
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4039 (setq reg "\\(\\<table\\>\\)\\|\\(\\<endtable\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4040 ((looking-at "\\<endspecify\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4041 ;; 6: Search back for matching specify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4042 (setq reg "\\(\\<specify\\>\\)\\|\\(\\<endspecify\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4043 ((looking-at "\\<endfunction\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4044 ;; 7: Search back for matching function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4045 (setq reg "\\(\\<function\\>\\)\\|\\(\\<endfunction\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4046 ((looking-at "\\<endgenerate\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4047 ;; 8: Search back for matching generate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4048 (setq reg "\\(\\<generate\\>\\)\\|\\(\\<endgenerate\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4049 ((looking-at "\\<endtask\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4050 ;; 9: Search back for matching task
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4051 (setq reg "\\(\\<task\\>\\)\\|\\(\\<endtask\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4052 ((looking-at "\\<endgroup\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4053 ;; 10: Search back for matching covergroup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4054 (setq reg "\\(\\<covergroup\\>\\)\\|\\(\\<endgroup\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4055 ((looking-at "\\<endproperty\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4056 ;; 11: Search back for matching property
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4057 (setq reg "\\(\\<property\\>\\)\\|\\(\\<endproperty\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4058 ((looking-at "\\<endinterface\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4059 ;; 12: Search back for matching interface
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4060 (setq reg "\\(\\<interface\\>\\)\\|\\(\\<endinterface\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4061 ((looking-at "\\<endsequence\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4062 ;; 12: Search back for matching sequence
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4063 (setq reg "\\(\\<\\(rand\\)?sequence\\>\\)\\|\\(\\<endsequence\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4064 ((looking-at "\\<endclocking\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4065 ;; 12: Search back for matching clocking
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4066 (setq reg "\\(\\<clocking\\)\\|\\(\\<endclocking\\>\\)" )))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4067 (if reg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4068 (catch 'skip
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4069 (let (sreg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4070 (while (verilog-re-search-backward reg nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4071 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4072 ((match-end 1) ; begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4073 (setq nest (1- nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4074 (if (= 0 nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4075 ;; Now previous line describes syntax
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4076 (throw 'skip 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4077 (if (and snest
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4078 (= snest nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4079 (setq reg sreg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4080 ((match-end 2) ; end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4081 (setq nest (1+ nest)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4082 ((match-end 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4083 ;; endcase, jump to case
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4084 (setq snest nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4085 (setq nest (1+ nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4086 (setq sreg reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4087 (setq reg "\\(\\<randcase\\>\\|\\<case[xz]?\\>[^:]\\)\\|\\(\\<endcase\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4088 ((match-end 4)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4089 ;; join, jump to fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4090 (setq snest nest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4091 (setq nest (1+ nest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4092 (setq sreg reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4093 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4094 )))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4095
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4096 (defun verilog-continued-line ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4097 "Return true if this is a continued line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4098 Set point to where line starts"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4099 (let ((continued 't))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4100 (if (eq 0 (forward-line -1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4101 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4102 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4103 (verilog-backward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4104 (if (bobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4105 (setq continued nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4106 (while (and continued
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4107 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4108 (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4109 (not (bolp))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4110 (setq continued (verilog-backward-token)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4111 (setq continued nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4112 continued))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4113
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4114 (defun verilog-backward-token ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4115 "Step backward token, returning true if we are now at an end of line token."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4116 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4117 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4118 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4119 ((bolp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4120 nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4121 (;-- Anything ending in a ; is complete
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4122 (= (preceding-char) ?\;)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4123 nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4124 (; If a "}" is prefixed by a ";", then this is a complete statement
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4125 ; i.e.: constraint foo { a = b; }
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4126 (= (preceding-char) ?\})
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4127 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4128 (backward-char)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4129 (verilog-at-close-constraint-p)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4130 (;-- constraint foo { a = b }
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4131 ; is a complete statement. *sigh*
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4132 (= (preceding-char) ?\{)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4133 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4134 (backward-char)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4135 (not (verilog-at-constraint-p))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4136 (;-- Could be 'case (foo)' or 'always @(bar)' which is complete
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4137 ; also could be simply '@(foo)'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4138 ; or foo u1 #(a=8)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4139 ; (b, ... which ISN'T complete
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4140 ;;;; Do we need this???
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4141 (= (preceding-char) ?\))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4142 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4143 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4144 (backward-up-list 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4145 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4146 (let ((back (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4147 (forward-word -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4148 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4149 ((looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|case\\(\\|[xz]\\)\\|for\\(\\|each\\|ever\\)\\|i\\(f\\|nitial\\)\\|repeat\\|while\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4150 (not (looking-at "\\<randcase\\>\\|\\<case[xz]?\\>[^:]")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4151 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4152 (goto-char back)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4153 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4154 ((= (preceding-char) ?\@)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4155 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4156 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4157 (verilog-backward-token)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4158 (not (looking-at "\\<\\(always\\(_latch\\|_ff\\|_comb\\)?\\|initial\\|while\\)\\>"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4159 ((= (preceding-char) ?\#)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4160 (backward-char))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4161 (t t)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4162
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4163 (;-- any of begin|initial|while are complete statements; 'begin : foo' is also complete
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4164 t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4165 (forward-word -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4166 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4167 ((looking-at "\\<else\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4168 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4169 ((looking-at verilog-indent-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4170 nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4171 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4172 (let
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4173 ((back (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4174 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4175 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4176 ((= (preceding-char) ?\:)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4177 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4178 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4179 (backward-sexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4180 (if (looking-at verilog-nameable-item-re )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4181 nil
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4182 t))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4183 ((= (preceding-char) ?\#)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4184 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4185 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4186 ((= (preceding-char) ?\`)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4187 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4188 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4189
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4190 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4191 (goto-char back)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4192 t))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4193
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4194 (defun verilog-backward-syntactic-ws (&optional bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4195 "Backward skip over syntactic whitespace for Emacs 19.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4196 Optional BOUND limits search."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4197 (save-restriction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4198 (let* ((bound (or bound (point-min))) (here bound) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4199 (if (< bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4200 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4201 (narrow-to-region bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4202 (while (/= here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4203 (setq here (point))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4204 (verilog-skip-backward-comments))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4205 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4206
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4207 (defun verilog-forward-syntactic-ws (&optional bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4208 "Forward skip over syntactic whitespace for Emacs 19.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4209 Optional BOUND limits search."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4210 (save-restriction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4211 (let* ((bound (or bound (point-max)))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4212 (here bound))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4213 (if (> bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4214 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4215 (narrow-to-region (point) bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4216 (while (/= here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4217 (setq here (point))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4218 (forward-comment (buffer-size))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4219
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4220 (defun verilog-backward-ws&directives (&optional bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4221 "Backward skip over syntactic whitespace and compiler directives for Emacs 19.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4222 Optional BOUND limits search."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4223 (save-restriction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4224 (let* ((bound (or bound (point-min)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4225 (here bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4226 (p nil) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4227 (if (< bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4228 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4229 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4230 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4231 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4232 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4233 ((nth 7 state) ;; in // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4234 (verilog-re-search-backward "//" nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4235 (skip-chars-backward "/"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4236 ((nth 4 state) ;; in /* */ comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4237 (verilog-re-search-backward "/\*" nil 'move))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4238 (narrow-to-region bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4239 (while (/= here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4240 (setq here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4241 (verilog-skip-backward-comments)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4242 (setq p
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4243 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4244 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4245 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4246 ((verilog-within-translate-off)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4247 (verilog-back-to-start-translate-off (point-min)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4248 ((looking-at verilog-directive-re-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4249 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4250 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4251 nil))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4252 (if p (goto-char p))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4253
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4254 (defun verilog-forward-ws&directives (&optional bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4255 "Forward skip over syntactic whitespace and compiler directives for Emacs 19.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4256 Optional BOUND limits search."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4257 (save-restriction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4258 (let* ((bound (or bound (point-max)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4259 (here bound)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4260 jump)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4261 (if (> bound (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4262 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4263 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4264 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4265 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4266 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4267 ((nth 7 state) ;; in // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4268 (verilog-re-search-forward "//" nil 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4269 ((nth 4 state) ;; in /* */ comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4270 (verilog-re-search-forward "/\*" nil 'move))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4271 (narrow-to-region (point) bound)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4272 (while (/= here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4273 (setq here (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4274 jump nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4275 (forward-comment (buffer-size))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4276 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4277 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4278 (if (looking-at verilog-directive-re-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4279 (setq jump t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4280 (if jump
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4281 (beginning-of-line 2))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4282
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4283 (defun verilog-in-comment-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4284 "Return true if in a star or // comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4285 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4286 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4287 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4288 (or (nth 4 state) (nth 7 state))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4289
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4290 (defun verilog-in-star-comment-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4291 "Return true if in a star comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4292 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4293 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4294 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4295 (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4296 (nth 4 state) ; t if in a comment of style a // or b /**/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4297 (not
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4298 (nth 7 state) ; t if in a comment of style b /**/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4299 ))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4300
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4301 (defun verilog-in-slash-comment-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4302 "Return true if in a slash comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4303 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4304 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4305 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4306 (nth 7 state)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4307
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4308 (defun verilog-in-comment-or-string-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4309 "Return true if in a string or comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4310 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4311 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4312 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4313 (or (nth 3 state) (nth 4 state) (nth 7 state)))) ; Inside string or comment)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4314
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4315 (defun verilog-in-escaped-name-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4316 "Return true if in an escaped name."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4317 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4318 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4319 (skip-chars-backward "^ \t\n\f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4320 (if (equal (char-after (point) ) ?\\ )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4321 t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4322 nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4323
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4324 (defun verilog-in-paren ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4325 "Return true if in a parenthetical expression."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4326 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4327 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4328 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4329 (> (nth 0 state) 0 )))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4330
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4331 (defun verilog-in-coverage ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4332 "Return true if in a constraint or coverpoint expression."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4333 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4334 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4335 (if (verilog-in-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4336 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4337 (backward-up-list 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4338 (verilog-at-constraint-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4339 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4340 nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4341 (defun verilog-at-close-constraint-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4342 "If at the } that closes a constraint or covergroup, return true."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4343 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4344 (equal (char-after) ?\})
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4345 (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4346
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4347 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4348 (verilog-backward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4349 (if (equal (char-before) ?\;)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4350 (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4351 nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4352
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4353 (defun verilog-at-constraint-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4354 "If at the { of a constraint or coverpoint definition, return true, moving point to constraint."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4355 (if (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4356 (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4357 (equal (char-after) ?\{)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4358 (forward-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4359 (progn (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4360 (verilog-backward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4361 (equal (char-before) ?\;))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4362 ;; maybe
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4363 (verilog-re-search-backward "\\<constraint\\|coverpoint\\|cross\\>" nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4364 ;; not
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4365 nil))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4366
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4367 (defun verilog-parenthesis-depth ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4368 "Return non zero if in parenthetical-expression."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4369 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4370 (nth 1 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4371
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4372
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4373 (defun verilog-skip-forward-comment-or-string ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4374 "Return true if in a string or comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4375 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4376 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4377 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4378 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4379 ((nth 3 state) ;Inside string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4380 (goto-char (nth 3 state))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4381 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4382 ((nth 7 state) ;Inside // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4383 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4384 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4385 ((nth 4 state) ;Inside any comment (hence /**/)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4386 (search-forward "*/"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4387 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4388 nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4389
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4390 (defun verilog-skip-backward-comment-or-string ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4391 "Return true if in a string or comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4392 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4393 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4394 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4395 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4396 ((nth 3 state) ;Inside string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4397 (search-backward "\"")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4398 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4399 ((nth 7 state) ;Inside // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4400 (search-backward "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4401 (skip-chars-backward "/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4402 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4403 ((nth 4 state) ;Inside /* */ comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4404 (search-backward "/*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4405 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4406 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4407 nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4408
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4409 (defun verilog-skip-backward-comments ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4410 "Return true if a comment was skipped."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4411 (let ((more t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4412 (while more
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4413 (setq more
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4414 (let ((state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4415 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4416 (parse-partial-sexp (point-min) (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4417 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4418 ((nth 7 state) ;Inside // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4419 (search-backward "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4420 (skip-chars-backward "/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4421 (skip-chars-backward " \t\n\f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4422 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4423 ((nth 4 state) ;Inside /* */ comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4424 (search-backward "/*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4425 (skip-chars-backward " \t\n\f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4426 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4427 ((and (not (bobp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4428 (= (char-before) ?\/)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4429 (= (char-before (1- (point))) ?\*))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4430 (goto-char (- (point) 2))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4431 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4432 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4433 (skip-chars-backward " \t\n\f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4434 nil)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4435
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4436 (defun verilog-skip-forward-comment-p ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4437 "If in comment, move to end and return true."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4438 (let (state)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4439 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4440 (setq state
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4441 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4442 (parse-partial-sexp (point-min) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4443 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4444 ((nth 3 state)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4445 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4446 ((nth 7 state) ;Inside // comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4447 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4448 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4449 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4450 ((nth 4 state) ;Inside any comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4451 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4452 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4453 nil)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4454
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4455 (defun verilog-indent-line-relative ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4456 "Cheap version of indent line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4457 Only look at a few lines to determine indent level."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4458 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4459 (let ((indent-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4460 (sp (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4461 (if (looking-at "^[ \t]*$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4462 (cond ;- A blank line; No need to be too smart.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4463 ((bobp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4464 (setq indent-str (list 'cpp 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4465 ((verilog-continued-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4466 (let ((sp1 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4467 (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
4468 (progn
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4469 (goto-char sp)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4470 (setq indent-str
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4471 (list 'statement (verilog-current-indent-level))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4472 (goto-char sp1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4473 (setq indent-str (list 'block (verilog-current-indent-level)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4474 (goto-char sp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4475 ((goto-char sp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4476 (setq indent-str (verilog-calculate-indent))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4477 (progn (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4478 (setq indent-str (verilog-calculate-indent))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4479 (verilog-do-indent indent-str)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4480
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4481 (defun verilog-indent-line ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4482 "Indent for special part of code."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4483 (verilog-do-indent (verilog-calculate-indent)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4484
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4485 (defun verilog-do-indent (indent-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4486 (let ((type (car indent-str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4487 (ind (car (cdr indent-str))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4488 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4489 (; handle continued exp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4490 (eq type 'cexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4491 (let ((here (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4492 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4493 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4494 ((or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4495 (= (preceding-char) ?\,)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4496 (= (preceding-char) ?\])
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4497 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4498 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4499 (looking-at verilog-declaration-re)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4500 (let* ( fst
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4501 (val
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4502 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4503 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4504 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4505 (setq fst (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4506 (if (looking-at verilog-declaration-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4507 (progn ;; we have multiple words
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4508 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4509 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4510 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4511 ((and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4512 (= (following-char) ?\`))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4513 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4514 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4515 (forward-word 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4516 (skip-chars-forward " \t")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4517 ((= (following-char) ?\[)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4518 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4519 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4520 (backward-up-list -1)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4521 (skip-chars-forward " \t"))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4522 (current-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4523 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4524 (goto-char fst)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4525 (+ (current-column) verilog-cexp-indent))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4526 (goto-char here)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4527 (indent-line-to val)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4528 ((= (preceding-char) ?\) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4529 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4530 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4531 (indent-line-to val)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4532 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4533 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4534 (let ((val))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4535 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4536 (if (and (< (point) here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4537 (verilog-re-search-forward "=[ \\t]*" here 'move))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4538 (setq val (current-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4539 (setq val (eval (cdr (assoc type verilog-indent-alist)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4540 (goto-char here)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4541 (indent-line-to val))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4542
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4543 (; handle inside parenthetical expressions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4544 (eq type 'cparenexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4545 (let ((val (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4546 (backward-up-list 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4547 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4548 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4549 (current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4550 (indent-line-to val)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4551 (if (and (not (verilog-in-struct-region-p))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4552 (looking-at verilog-declaration-re))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4553 (verilog-indent-declaration ind))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4554
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4555 (;-- Handle the ends
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4556 (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4557 (looking-at verilog-end-block-re )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4558 (verilog-at-close-constraint-p))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4559 (let ((val (if (eq type 'statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4560 (- ind verilog-indent-level)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4561 ind)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4562 (indent-line-to val)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4563
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4564 (;-- Case -- maybe line 'em up
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4565 (and (eq type 'case) (not (looking-at "^[ \t]*$")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4566 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4567 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4568 ((looking-at "\\<endcase\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4569 (indent-line-to ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4570 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4571 (let ((val (eval (cdr (assoc type verilog-indent-alist)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4572 (indent-line-to val))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4573
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4574 (;-- defun
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4575 (and (eq type 'defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4576 (looking-at verilog-zero-indent-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4577 (indent-line-to 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4578
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4579 (;-- declaration
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4580 (and (or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4581 (eq type 'defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4582 (eq type 'block))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4583 (looking-at verilog-declaration-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4584 (verilog-indent-declaration ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4585
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4586 (;-- Everything else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4587 t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4588 (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
4589 (indent-line-to val))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4590
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4591 (if (looking-at "[ \t]+$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4592 (skip-chars-forward " \t"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4593 indent-str ; Return indent data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4594 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4595
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4596 (defun verilog-current-indent-level ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4597 "Return the indent-level the current statement has."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4598 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4599 (let (par-pos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4600 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4601 (setq par-pos (verilog-parenthesis-depth))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4602 (while par-pos
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4603 (goto-char par-pos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4604 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4605 (setq par-pos (verilog-parenthesis-depth)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4606 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4607 (current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4608
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4609 (defun verilog-case-indent-level ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4610 "Return the indent-level the current statement has.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4611 Do not count named blocks or case-statements."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4612 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4613 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4614 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4615 ((looking-at verilog-named-block-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4616 (current-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4617 ((and (not (looking-at verilog-case-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4618 (looking-at "^[^:;]+[ \t]*:"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4619 (verilog-re-search-forward ":" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4620 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4621 (current-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4622 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4623 (current-column)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4624
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4625 (defun verilog-indent-comment ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4626 "Indent current line as comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4627 (let* ((stcol
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4628 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4629 ((verilog-in-star-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4630 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4631 (re-search-backward "/\\*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4632 (1+(current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4633 (comment-column
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4634 comment-column )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4635 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4636 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4637 (re-search-backward "//" nil t)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4638 (current-column))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4639 (indent-line-to stcol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4640 stcol))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4641
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4642 (defun verilog-more-comment ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4643 "Make more comment lines like the previous."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4644 (let* ((star 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4645 (stcol
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4646 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4647 ((verilog-in-star-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4648 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4649 (setq star 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4650 (re-search-backward "/\\*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4651 (1+(current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4652 (comment-column
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4653 comment-column )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4654 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4655 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4656 (re-search-backward "//" nil t)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4657 (current-column))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4658 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4659 (indent-to stcol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4660 (if (and star
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4661 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4662 (forward-line -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4663 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4664 (looking-at "\*")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4665 (insert "* ")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4666
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4667 (defun verilog-comment-indent (&optional arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4668 "Return the column number the line should be indented to.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4669 ARG is ignored, for `comment-indent-function' compatibility."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4670 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4671 ((verilog-in-star-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4672 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4673 (re-search-backward "/\\*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4674 (1+(current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4675 ( comment-column
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4676 comment-column )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4677 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4678 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4679 (re-search-backward "//" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4680 (current-column)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4681
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4682 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4683
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4684 (defun verilog-pretty-declarations ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4685 "Line up declarations around point."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4686 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4687 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4688 (if (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4689 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4690 (looking-at verilog-declaration-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4691 (let* ((m1 (make-marker))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4692 (e) (r)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4693 (here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4694 ;; Start of declaration range
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4695 (start
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4696 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4697 (verilog-beg-of-statement-1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4698 (while (looking-at verilog-declaration-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4699 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4700 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4701 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4702 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4703 (verilog-beg-of-statement-1)) ;Ack, need to grok `define
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4704 e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4705 ;; End of declaration range
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4706 (end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4707 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4708 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4709 (verilog-end-of-statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4710 (setq e (point)) ;Might be on last line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4711 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4712 (while (looking-at verilog-declaration-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4713 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4714 (verilog-end-of-statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4715 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4716 (verilog-forward-syntactic-ws))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4717 e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4718 (edpos (set-marker (make-marker) end))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4719 (ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4720 (base-ind
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4721 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4722 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4723 (verilog-do-indent (verilog-calculate-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4724 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4725 (current-column))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4726 (goto-char end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4727 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4728 (if (> (- end start) 100)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4729 (message "Lining up declarations..(please stand by)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4730 ;; Get the beginning of line indent first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4731 (while (progn (setq e (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4732 (< (point) e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4733 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4734 ( (save-excursion (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4735 (bolp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4736 (verilog-forward-ws&directives)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4737 (indent-line-to base-ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4738 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4739 (verilog-re-search-forward "[ \t\n\f]" e 'move))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4740 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4741 (just-one-space)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4742 (verilog-re-search-forward "[ \t\n\f]" e 'move)))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4743 ;;(forward-line)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4744 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4745 ;; Now find biggest prefix
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4746 (setq ind (verilog-get-lineup-indent start edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4747 ;; Now indent each line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4748 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4749 (while (progn (setq e (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4750 (setq r (- e (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4751 (> r 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4752 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4753 (message "%d" r)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4754 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4755 ((or (and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4756 (looking-at verilog-declaration-re-1-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4757 (looking-at verilog-declaration-re-1-no-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4758 (let ((p (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4759 (set-marker m1 p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4760 (if (verilog-re-search-forward "[[#`]" p 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4761 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4762 (forward-char -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4763 (just-one-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4764 (goto-char (marker-position m1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4765 (just-one-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4766 (indent-to ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4767 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4768 (just-one-space)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4769 (indent-to ind)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4770 ((verilog-continued-line-1 start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4771 (goto-char e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4772 (indent-line-to ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4773 (t ; Must be comment or white space
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4774 (goto-char e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4775 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4776 (forward-line -1)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4777 (forward-line 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4778 (message "")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4779
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4780 (defun verilog-pretty-expr (&optional myre)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4781 "Line up expressions around point, or optional regexp MYRE."
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4782 (interactive "sRegular Expression: ((<|:)?=) ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4783 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4784 (if (or (eq myre nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4785 (string-equal myre ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4786 (setq myre "\\(<\\|:\\)?="))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4787 ; (setq myre (concat "\\(^[^;" myre "]*\\)\\([" myre "]\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4788 (setq myre (concat "\\(^[^;#:?=]*\\)\\([" myre "]\\)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4789 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4790 (if (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4791 (looking-at myre))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4792 (let* ((here (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4793 (e) (r)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4794 (start
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4795 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4796 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4797 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4798 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4799 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4800 (while (and (not (looking-at (concat "^\\s-*" verilog-complete-reg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4801 (looking-at myre)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4802 (not (bobp)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4803 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4804 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4805 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4806 ) ;Ack, need to grok `define
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4807 e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4808 (end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4809 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4810 (goto-char here)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4811 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4812 (setq e (point)) ;Might be on last line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4813 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4814 (beginning-of-line)
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4815 (while (and (not (looking-at
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4816 (concat "^\\s-*" verilog-complete-reg)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4817 (looking-at myre))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4818 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4819 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4820 (verilog-forward-syntactic-ws)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4821 (beginning-of-line))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4822 e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4823 (edpos (set-marker (make-marker) end))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4824 (ind))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4825 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4826 (verilog-do-indent (verilog-calculate-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4827 (if (> (- end start) 100)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4828 (message "Lining up expressions..(please stand by)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4829
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4830 ;; Set indent to minimum throughout region
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4831 (while (< (point) (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4832 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4833 (verilog-just-one-space myre)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4834 (end-of-line)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4835 (verilog-forward-syntactic-ws))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4836
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4837 ;; Now find biggest prefix
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4838 (setq ind (verilog-get-lineup-indent-2 myre start edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4839
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4840 ;; Now indent each line.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4841 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4842 (while (progn (setq e (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4843 (setq r (- e (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4844 (> r 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4845 (setq e (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4846 (message "%d" r)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4847 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4848 ((looking-at myre)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4849 (goto-char (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4850 (if (eq (char-after) ?=)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4851 (indent-to (1+ ind)) ; line up the = of the <= with surrounding =
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4852 (indent-to ind)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4853 ((verilog-continued-line-1 start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4854 (goto-char e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4855 (indent-line-to ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4856 (t ; Must be comment or white space
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4857 (goto-char e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4858 (verilog-forward-ws&directives)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4859 (forward-line -1)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4860 (forward-line 1))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4861 (message "")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4862
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4863 (defun verilog-just-one-space (myre)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4864 "Remove extra spaces around regular expression MYRE."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4865 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4866 (if (and (not(looking-at verilog-complete-reg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4867 (looking-at myre))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4868 (let ((p1 (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4869 (p2 (match-end 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4870 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4871 (goto-char p2)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4872 (if (looking-at "\\s-") (just-one-space))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4873 (goto-char p1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4874 (forward-char -1)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4875 (if (looking-at "\\s-") (just-one-space)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4876 (message ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4877
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4878 (defun verilog-indent-declaration (baseind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4879 "Indent current lines as declaration.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4880 Line up the variable names based on previous declaration's indentation.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4881 BASEIND is the base indent to offset everything."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4882 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4883 (let ((pos (point-marker))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4884 (lim (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4885 ;; (verilog-re-search-backward verilog-declaration-opener nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4886 (verilog-re-search-backward "\\(\\<begin\\>\\)\\|\\(\\<module\\>\\)\\|\\(\\<task\\>\\)" nil 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4887 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4888 (ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4889 (val)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4890 (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
4891 (setq val
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4892 (+ baseind (eval (cdr (assoc 'declaration verilog-indent-alist)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4893 (indent-line-to val)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4894
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4895 ;; Use previous declaration (in this module) as template.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4896 (if (or (memq 'all verilog-auto-lineup)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4897 (memq 'declaration verilog-auto-lineup))
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
4898 (if (verilog-re-search-backward
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4899 (or (and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4900 verilog-declaration-re-1-macro)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4901 verilog-declaration-re-1-no-macro) lim t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4902 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4903 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4904 (skip-chars-forward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4905 (setq ind (current-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4906 (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
4907 (setq val
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4908 (+ baseind
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4909 (eval (cdr (assoc 'declaration verilog-indent-alist)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4910 (indent-line-to val)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4911 (if (and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4912 (looking-at verilog-declaration-re-2-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4913 (let ((p (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4914 (set-marker m1 p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4915 (if (verilog-re-search-forward "[[#`]" p 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4916 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4917 (forward-char -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4918 (just-one-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4919 (goto-char (marker-position m1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4920 (just-one-space)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4921 (indent-to ind))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4922 (if (/= (current-column) ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4923 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4924 (just-one-space)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
4925 (indent-to ind)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4926 (if (looking-at verilog-declaration-re-2-no-macro)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4927 (let ((p (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4928 (set-marker m1 p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4929 (if (verilog-re-search-forward "[[`#]" p 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4930 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4931 (forward-char -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4932 (just-one-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4933 (goto-char (marker-position m1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4934 (just-one-space)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4935 (indent-to ind))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4936 (if (/= (current-column) ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4937 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4938 (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
4939 (indent-to ind))))))))))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
4940 (goto-char pos)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4941
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4942 (defun verilog-get-lineup-indent (b edpos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4943 "Return the indent level that will line up several lines within the region.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4944 Region is defined by B and EDPOS."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4945 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4946 (let ((ind 0) e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4947 (goto-char b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4948 ;; Get rightmost position
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4949 (while (progn (setq e (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4950 (< (point) e))
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
4951 (if (verilog-re-search-forward
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4952 (or (and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4953 verilog-declaration-re-1-macro)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4954 verilog-declaration-re-1-no-macro) e 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4955 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4956 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4957 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4958 (if (> (current-column) ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4959 (setq ind (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4960 (goto-char (match-end 0)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4961 (if (> ind 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4962 (1+ ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4963 ;; No lineup-string found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4964 (goto-char b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4965 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4966 (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4967 (1+ (current-column))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4968
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4969 (defun verilog-get-lineup-indent-2 (myre b edpos)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4970 "Return the indent level that will line up several lines within the region."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4971 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4972 (let ((ind 0) e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4973 (goto-char b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4974 ;; Get rightmost position
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4975 (while (progn (setq e (marker-position edpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4976 (< (point) e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4977 (if (verilog-re-search-forward myre e 'move)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4978 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4979 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4980 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4981 (if (> (current-column) ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4982 (setq ind (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4983 (goto-char (match-end 0)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4984 (if (> ind 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4985 (1+ ind)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4986 ;; No lineup-string found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4987 (goto-char b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4988 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4989 (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4990 (1+ (current-column))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4991
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4992 (defun verilog-comment-depth (type val)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4993 "A useful mode debugging aide. TYPE and VAL are comments for insertion."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4994 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4995 (let
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4996 ((b (prog2
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4997 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4998 (point-marker)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4999 (end-of-line)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5000 (e (point-marker)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5001 (if (re-search-backward " /\\* \[#-\]# \[a-zA-Z\]+ \[0-9\]+ ## \\*/" b t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5002 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5003 (replace-match " /* -# ## */")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5004 (end-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5005 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5006 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5007 (insert " /* ## ## */"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5008 (backward-char 6)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5009 (insert
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5010 (format "%s %d" type val))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5011
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5012 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5013 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5014 ;; Completion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5015 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5016 (defvar verilog-str nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5017 (defvar verilog-all nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5018 (defvar verilog-pred nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5019 (defvar verilog-buffer-to-use nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5020 (defvar verilog-flag nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5021 (defvar verilog-toggle-completions nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5022 "*True means \\<verilog-mode-map>\\[verilog-complete-word] should try all possible completions one by one.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5023 Repeated use of \\[verilog-complete-word] will show you all of them.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5024 Normally, when there is more than one possible completion,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5025 it displays a list of all possible completions.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5026
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5027
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5028 (defvar verilog-type-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5029 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5030 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5031 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5032 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5033 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5034 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5035 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5036 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5037 "*Keywords for types used when completing a word in a declaration or parmlist.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5038 \(eg. integer, real, reg...)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5039
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5040 (defvar verilog-cpp-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5041 '("module" "macromodule" "primitive" "timescale" "define" "ifdef" "ifndef" "else"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5042 "endif")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5043 "*Keywords to complete when at first word of a line in declarative scope.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5044 \(eg. initial, always, begin, assign.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5045 The procedures and variables defined within the Verilog program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5046 will be completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5047
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5048 (defvar verilog-defun-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5049 (append
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5050 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5051 "always" "always_comb" "always_ff" "always_latch" "assign"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5052 "begin" "end" "generate" "endgenerate" "module" "endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5053 "specify" "endspecify" "function" "endfunction" "initial" "final"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5054 "task" "endtask" "primitive" "endprimitive"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5055 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5056 verilog-type-keywords)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5057 "*Keywords to complete when at first word of a line in declarative scope.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5058 \(eg. initial, always, begin, assign.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5059 The procedures and variables defined within the Verilog program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5060 will be completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5061
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5062 (defvar verilog-block-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5063 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5064 "begin" "break" "case" "continue" "else" "end" "endfunction"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5065 "endgenerate" "endinterface" "endpackage" "endspecify" "endtask"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5066 "for" "fork" "if" "join" "join_any" "join_none" "repeat" "return"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5067 "while")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5068 "*Keywords to complete when at first word of a line in behavioral scope.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5069 \(eg. begin, if, then, else, for, fork.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5070 The procedures and variables defined within the Verilog program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5071 will be completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5072
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5073 (defvar verilog-tf-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5074 '("begin" "break" "fork" "join" "join_any" "join_none" "case" "end" "endtask" "endfunction" "if" "else" "for" "while" "repeat")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5075 "*Keywords to complete when at first word of a line in a task or function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5076 \(eg. begin, if, then, else, for, fork.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5077 The procedures and variables defined within the Verilog program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5078 will be completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5079
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5080 (defvar verilog-case-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5081 '("begin" "fork" "join" "join_any" "join_none" "case" "end" "endcase" "if" "else" "for" "repeat")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5082 "*Keywords to complete when at first word of a line in case scope.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5083 \(eg. begin, if, then, else, for, fork.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5084 The procedures and variables defined within the Verilog program
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5085 will be completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5086
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5087 (defvar verilog-separator-keywords
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5088 '("else" "then" "begin")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5089 "*Keywords to complete when NOT standing at the first word of a statement.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5090 \(eg. else, then.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5091 Variables and function names defined within the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5092 Verilog program are completed runtime and should not be added to this list.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5093
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5094 (defun verilog-string-diff (str1 str2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5095 "Return index of first letter where STR1 and STR2 differs."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5096 (catch 'done
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5097 (let ((diff 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5098 (while t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5099 (if (or (> (1+ diff) (length str1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5100 (> (1+ diff) (length str2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5101 (throw 'done diff))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5102 (or (equal (aref str1 diff) (aref str2 diff))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5103 (throw 'done diff))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5104 (setq diff (1+ diff))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5105
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5106 ;; Calculate all possible completions for functions if argument is `function',
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5107 ;; completions for procedures if argument is `procedure' or both functions and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5108 ;; procedures otherwise.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5109
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5110 (defun verilog-func-completion (type)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5111 "Build regular expression for module/task/function names.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5112 TYPE is 'module, 'tf for task or function, or t if unknown."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5113 (if (string= verilog-str "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5114 (setq verilog-str "[a-zA-Z_]"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5115 (let ((verilog-str (concat (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5116 ((eq type 'module) "\\<\\(module\\)\\s +")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5117 ((eq type 'tf) "\\<\\(task\\|function\\)\\s +")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5118 (t "\\<\\(task\\|function\\|module\\)\\s +"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5119 "\\<\\(" verilog-str "[a-zA-Z0-9_.]*\\)\\>"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5120 match)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5121
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5122 (if (not (looking-at verilog-defun-re))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5123 (verilog-re-search-backward verilog-defun-re nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5124 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5125
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5126 ;; Search through all reachable functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5127 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5128 (while (verilog-re-search-forward verilog-str (point-max) t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5129 (progn (setq match (buffer-substring (match-beginning 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5130 (match-end 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5131 (if (or (null verilog-pred)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5132 (funcall verilog-pred match))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5133 (setq verilog-all (cons match verilog-all)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5134 (if (match-beginning 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5135 (goto-char (match-beginning 0)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5136
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5137 (defun verilog-get-completion-decl (end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5138 "Macro for searching through current declaration (var, type or const)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5139 for matches of `str' and adding the occurrence tp `all' through point END."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5140 (let ((re (or (and verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5141 verilog-declaration-re-2-macro)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5142 verilog-declaration-re-2-no-macro))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5143 decl-end match)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5144 ;; Traverse lines
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5145 (while (and (< (point) end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5146 (verilog-re-search-forward re end t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5147 ;; Traverse current line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5148 (setq decl-end (save-excursion (verilog-declaration-end)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5149 (while (and (verilog-re-search-forward verilog-symbol-re decl-end t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5150 (not (match-end 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5151 (setq match (buffer-substring (match-beginning 0) (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5152 (if (string-match (concat "\\<" verilog-str) match)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5153 (if (or (null verilog-pred)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5154 (funcall verilog-pred match))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5155 (setq verilog-all (cons match verilog-all)))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5156 (forward-line 1)))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5157 verilog-all)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5158
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5159 (defun verilog-type-completion ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5160 "Calculate all possible completions for types."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5161 (let ((start (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5162 goon)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5163 ;; Search for all reachable type declarations
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5164 (while (or (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5165 (setq goon (not goon)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5166 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5167 (if (and (< start (prog1 (save-excursion (verilog-end-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5168 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5169 (forward-char 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5170 (verilog-re-search-forward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5171 "\\<type\\>\\|\\<\\(begin\\|function\\|procedure\\)\\>"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5172 start t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5173 (not (match-end 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5174 ;; Check current type declaration
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5175 (verilog-get-completion-decl start))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5176
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5177 (defun verilog-var-completion ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5178 "Calculate all possible completions for variables (or constants)."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5179 (let ((start (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5180 ;; Search for all reachable var declarations
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5181 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5182 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5183 ;; Check var declarations
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5184 (verilog-get-completion-decl start))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5185
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5186 (defun verilog-keyword-completion (keyword-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5187 "Give list of all possible completions of keywords in KEYWORD-LIST."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5188 (mapcar '(lambda (s)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5189 (if (string-match (concat "\\<" verilog-str) s)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5190 (if (or (null verilog-pred)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5191 (funcall verilog-pred s))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5192 (setq verilog-all (cons s verilog-all)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5193 keyword-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5194
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5195
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5196 (defun verilog-completion (verilog-str verilog-pred verilog-flag)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5197 "Function passed to `completing-read', `try-completion' or `all-completions'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5198 Called to get completion on VERILOG-STR. If VERILOG-PRED is non-nil, it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5199 must be a function to be called for every match to check if this should
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5200 really be a match. If VERILOG-FLAG is t, the function returns a list of all
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5201 possible completions. If VERILOG-FLAG is nil it returns a string, the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5202 longest possible completion, or t if STR is an exact match. If VERILOG-FLAG
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5203 is 'lambda, the function returns t if STR is an exact match, nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5204 otherwise."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5205 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5206 (let ((verilog-all nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5207 ;; Set buffer to use for searching labels. This should be set
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5208 ;; within functions which use verilog-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5209 (set-buffer verilog-buffer-to-use)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5210
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5211 ;; Determine what should be completed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5212 (let ((state (car (verilog-calculate-indent))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5213 (cond ((eq state 'defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5214 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5215 (verilog-func-completion 'module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5216 (verilog-keyword-completion verilog-defun-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5217
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5218 ((eq state 'behavioral)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5219 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5220 (verilog-func-completion 'module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5221 (verilog-keyword-completion verilog-defun-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5222
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5223 ((eq state 'block)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5224 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5225 (verilog-func-completion 'tf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5226 (verilog-keyword-completion verilog-block-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5227
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5228 ((eq state 'case)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5229 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5230 (verilog-func-completion 'tf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5231 (verilog-keyword-completion verilog-case-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5232
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5233 ((eq state 'tf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5234 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5235 (verilog-func-completion 'tf)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5236 (verilog-keyword-completion verilog-tf-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5237
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5238 ((eq state 'cpp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5239 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5240 (verilog-keyword-completion verilog-cpp-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5241
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5242 ((eq state 'cparenexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5243 (save-excursion (verilog-var-completion)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5244
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5245 (t;--Anywhere else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5246 (save-excursion (verilog-var-completion))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5247 (verilog-func-completion 'both)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5248 (verilog-keyword-completion verilog-separator-keywords))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5249
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5250 ;; Now we have built a list of all matches. Give response to caller
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5251 (verilog-completion-response))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5252
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5253 (defun verilog-completion-response ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5254 (cond ((or (equal verilog-flag 'lambda) (null verilog-flag))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5255 ;; This was not called by all-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5256 (if (null verilog-all)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5257 ;; Return nil if there was no matching label
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5258 nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5259 ;; Get longest string common in the labels
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5260 (let* ((elm (cdr verilog-all))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5261 (match (car verilog-all))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5262 (min (length match))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5263 tmp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5264 (if (string= match verilog-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5265 ;; Return t if first match was an exact match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5266 (setq match t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5267 (while (not (null elm))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5268 ;; Find longest common string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5269 (if (< (setq tmp (verilog-string-diff match (car elm))) min)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5270 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5271 (setq min tmp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5272 (setq match (substring match 0 min))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5273 ;; Terminate with match=t if this is an exact match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5274 (if (string= (car elm) verilog-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5275 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5276 (setq match t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5277 (setq elm nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5278 (setq elm (cdr elm)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5279 ;; If this is a test just for exact match, return nil ot t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5280 (if (and (equal verilog-flag 'lambda) (not (equal match 't)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5281 nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5282 match))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5283 ;; If flag is t, this was called by all-completions. Return
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5284 ;; list of all possible completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5285 (verilog-flag
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5286 verilog-all)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5287
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5288 (defvar verilog-last-word-numb 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5289 (defvar verilog-last-word-shown nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5290 (defvar verilog-last-completions nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5291
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5292 (defun verilog-complete-word ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5293 "Complete word at current point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5294 \(See also `verilog-toggle-completions', `verilog-type-keywords',
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5295 and `verilog-separator-keywords'.)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5296 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5297 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5298 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5299 (verilog-str (buffer-substring b e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5300 ;; The following variable is used in verilog-completion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5301 (verilog-buffer-to-use (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5302 (allcomp (if (and verilog-toggle-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5303 (string= verilog-last-word-shown verilog-str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5304 verilog-last-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5305 (all-completions verilog-str 'verilog-completion)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5306 (match (if verilog-toggle-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5307 "" (try-completion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5308 verilog-str (mapcar '(lambda (elm)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5309 (cons elm 0)) allcomp)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5310 ;; Delete old string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5311 (delete-region b e)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5312
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5313 ;; Toggle-completions inserts whole labels
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5314 (if verilog-toggle-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5315 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5316 ;; Update entry number in list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5317 (setq verilog-last-completions allcomp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5318 verilog-last-word-numb
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5319 (if (>= verilog-last-word-numb (1- (length allcomp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5320 0
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5321 (1+ verilog-last-word-numb)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5322 (setq verilog-last-word-shown (elt allcomp verilog-last-word-numb))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5323 ;; Display next match or same string if no match was found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5324 (if (not (null allcomp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5325 (insert "" verilog-last-word-shown)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5326 (insert "" verilog-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5327 (message "(No match)")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5328 ;; The other form of completion does not necessarily do that.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5329
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5330 ;; Insert match if found, or the original string if no match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5331 (if (or (null match) (equal match 't))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5332 (progn (insert "" verilog-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5333 (message "(No match)"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5334 (insert "" match))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5335 ;; Give message about current status of completion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5336 (cond ((equal match 't)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5337 (if (not (null (cdr allcomp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5338 (message "(Complete but not unique)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5339 (message "(Sole completion)")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5340 ;; Display buffer if the current completion didn't help
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5341 ;; on completing the label.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5342 ((and (not (null (cdr allcomp))) (= (length verilog-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5343 (length match)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5344 (with-output-to-temp-buffer "*Completions*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5345 (display-completion-list allcomp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5346 ;; Wait for a key press. Then delete *Completion* window
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5347 (momentary-string-display "" (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5348 (delete-window (get-buffer-window (get-buffer "*Completions*")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5349 )))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5350
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5351 (defun verilog-show-completions ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5352 "Show all possible completions at current point."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5353 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5354 (let* ((b (save-excursion (skip-chars-backward "a-zA-Z0-9_") (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5355 (e (save-excursion (skip-chars-forward "a-zA-Z0-9_") (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5356 (verilog-str (buffer-substring b e))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5357 ;; The following variable is used in verilog-completion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5358 (verilog-buffer-to-use (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5359 (allcomp (if (and verilog-toggle-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5360 (string= verilog-last-word-shown verilog-str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5361 verilog-last-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5362 (all-completions verilog-str 'verilog-completion))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5363 ;; Show possible completions in a temporary buffer.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5364 (with-output-to-temp-buffer "*Completions*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5365 (display-completion-list allcomp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5366 ;; Wait for a key press. Then delete *Completion* window
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5367 (momentary-string-display "" (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5368 (delete-window (get-buffer-window (get-buffer "*Completions*")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5369
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5370
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5371 (defun verilog-get-default-symbol ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5372 "Return symbol around current point as a string."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5373 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5374 (buffer-substring (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5375 (skip-chars-backward " \t")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5376 (skip-chars-backward "a-zA-Z0-9_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5377 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5378 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5379 (skip-chars-forward "a-zA-Z0-9_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5380 (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5381
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5382 (defun verilog-build-defun-re (str &optional arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5383 "Return function/task/module starting with STR as regular expression.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5384 With optional second ARG non-nil, STR is the complete name of the instruction."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5385 (if arg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5386 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5387 (concat "^\\(function\\|task\\|module\\)[ \t]+\\(" str "[a-zA-Z0-9_]*\\)\\>")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5388
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5389 (defun verilog-comp-defun (verilog-str verilog-pred verilog-flag)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5390 "Function passed to `completing-read', `try-completion' or `all-completions'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5391 Returns a completion on any function name based on VERILOG-STR prefix. If
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5392 VERILOG-PRED is non-nil, it must be a function to be called for every match
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5393 to check if this should really be a match. If VERILOG-FLAG is t, the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5394 function returns a list of all possible completions. If it is nil it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5395 returns a string, the longest possible completion, or t if VERILOG-STR is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5396 an exact match. If VERILOG-FLAG is 'lambda, the function returns t if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5397 VERILOG-STR is an exact match, nil otherwise."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5398 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5399 (let ((verilog-all nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5400 match)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5401
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5402 ;; Set buffer to use for searching labels. This should be set
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5403 ;; within functions which use verilog-completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5404 (set-buffer verilog-buffer-to-use)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5405
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5406 (let ((verilog-str verilog-str))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5407 ;; Build regular expression for functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5408 (if (string= verilog-str "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5409 (setq verilog-str (verilog-build-defun-re "[a-zA-Z_]"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5410 (setq verilog-str (verilog-build-defun-re verilog-str)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5411 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5412
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5413 ;; Build a list of all possible completions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5414 (while (verilog-re-search-forward verilog-str nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5415 (setq match (buffer-substring (match-beginning 2) (match-end 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5416 (if (or (null verilog-pred)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5417 (funcall verilog-pred match))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5418 (setq verilog-all (cons match verilog-all)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5419
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5420 ;; Now we have built a list of all matches. Give response to caller
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5421 (verilog-completion-response))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5422
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5423 (defun verilog-goto-defun ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5424 "Move to specified Verilog module/task/function.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5425 The default is a name found in the buffer around point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5426 If search fails, other files are checked based on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5427 `verilog-library-flags'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5428 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5429 (let* ((default (verilog-get-default-symbol))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5430 ;; The following variable is used in verilog-comp-function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5431 (verilog-buffer-to-use (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5432 (label (if (not (string= default ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5433 ;; Do completion with default
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5434 (completing-read (concat "Label: (default " default ") ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5435 'verilog-comp-defun nil nil "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5436 ;; There is no default value. Complete without it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5437 (completing-read "Label: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5438 'verilog-comp-defun nil nil "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5439 pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5440 ;; If there was no response on prompt, use default value
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5441 (if (string= label "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5442 (setq label default))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5443 ;; Goto right place in buffer if label is not an empty string
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5444 (or (string= label "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5445 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5446 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5447 (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
5448 (setq pt
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
5449 (re-search-forward (verilog-build-defun-re label t) nil t)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5450 (when pt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5451 (goto-char pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5452 (beginning-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5453 pt)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5454 (verilog-goto-defun-file label))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5455
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5456 ;; Eliminate compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5457 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5458 (if (not (boundp 'occur-pos-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5459 (defvar occur-pos-list nil "Backward compatibility occur positions.")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5460
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5461 (defun verilog-showscopes ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5462 "List all scopes in this module."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5463 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5464 (let ((buffer (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5465 (linenum 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5466 (nlines 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5467 (first 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5468 (prevpos (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5469 (final-context-start (make-marker))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5470 (regexp "\\(module\\s-+\\w+\\s-*(\\)\\|\\(\\w+\\s-+\\w+\\s-*(\\)"))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5471 (with-output-to-temp-buffer "*Occur*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5472 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5473 (message (format "Searching for %s ..." regexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5474 ;; Find next match, but give up if prev match was at end of buffer.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5475 (while (and (not (= prevpos (point-max)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5476 (verilog-re-search-forward regexp nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5477 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5478 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5479 (save-match-data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5480 (setq linenum (+ linenum (count-lines prevpos (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5481 (setq prevpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5482 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5483 (let* ((start (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5484 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5485 (forward-line (if (< nlines 0) nlines (- nlines)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5486 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5487 (end (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5488 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5489 (if (> nlines 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5490 (forward-line (1+ nlines))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5491 (forward-line 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5492 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5493 (tag (format "%3d" linenum))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5494 (empty (make-string (length tag) ?\ ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5495 tem)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5496 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5497 (setq tem (make-marker))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5498 (set-marker tem (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5499 (set-buffer standard-output)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5500 (setq occur-pos-list (cons tem occur-pos-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5501 (or first (zerop nlines)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5502 (insert "--------\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5503 (setq first nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5504 (insert-buffer-substring buffer start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5505 (backward-char (- end start))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5506 (setq tem (if (< nlines 0) (- nlines) nlines))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5507 (while (> tem 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5508 (insert empty ?:)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5509 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5510 (setq tem (1- tem)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5511 (let ((this-linenum linenum))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5512 (set-marker final-context-start
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5513 (+ (point) (- (match-end 0) (match-beginning 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5514 (while (< (point) final-context-start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5515 (if (null tag)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5516 (setq tag (format "%3d" this-linenum)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5517 (insert tag ?:)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5518 (set-buffer-modified-p nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5519
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5520
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5521 ;; Highlight helper functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5522 (defconst verilog-directive-regexp "\\(translate\\|coverage\\|lint\\)_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5523 (defun verilog-within-translate-off ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5524 "Return point if within translate-off region, else nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5525 (and (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5526 (re-search-backward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5527 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "\\(on\\|off\\)\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5528 nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5529 (equal "off" (match-string 2))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5530 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5531
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5532 (defun verilog-start-translate-off (limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5533 "Return point before translate-off directive if before LIMIT, else nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5534 (when (re-search-forward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5535 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5536 limit t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5537 (match-beginning 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5538
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5539 (defun verilog-back-to-start-translate-off (limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5540 "Return point before translate-off directive if before LIMIT, else nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5541 (when (re-search-backward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5542 (concat "//\\s-*.*\\s-*" verilog-directive-regexp "off\\>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5543 limit t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5544 (match-beginning 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5546 (defun verilog-end-translate-off (limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5547 "Return point after translate-on directive if before LIMIT, else nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5548
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5549 (re-search-forward (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5550 "//\\s-*.*\\s-*" verilog-directive-regexp "on\\>") limit t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5551
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5552 (defun verilog-match-translate-off (limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5553 "Match a translate-off block, setting `match-data' and returning t, else nil.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5554 Bound search by LIMIT."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5555 (when (< (point) limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5556 (let ((start (or (verilog-within-translate-off)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5557 (verilog-start-translate-off limit)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5558 (case-fold-search t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5559 (when start
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5560 (let ((end (or (verilog-end-translate-off limit) limit)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5561 (set-match-data (list start end))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5562 (goto-char end))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5563
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5564 (defun verilog-font-lock-match-item (limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5565 "Match, and move over, any declaration item after point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5566 Bound search by LIMIT. Adapted from
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5567 `font-lock-match-c-style-declaration-item-and-skip-to-next'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5568 (condition-case nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5569 (save-restriction
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5570 (narrow-to-region (point-min) limit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5571 ;; match item
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5572 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5573 (save-match-data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5574 (goto-char (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5575 ;; move to next item
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5576 (if (looking-at "\\(\\s-*,\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5577 (goto-char (match-end 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5578 (end-of-line) t))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5579 (error nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5580
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5581
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5582 ;; Added by Subbu Meiyappan for Header
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5583
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5584 (defun verilog-header ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5585 "Insert a standard Verilog file header."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5586 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5587 (let ((start (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5588 (insert "\
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5589 //-----------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5590 // Title : <title>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5591 // Project : <project>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5592 //-----------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5593 // File : <filename>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5594 // Author : <author>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5595 // Created : <credate>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5596 // Last modified : <moddate>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5597 //-----------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5598 // Description :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5599 // <description>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5600 //-----------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5601 // Copyright (c) <copydate> by <company> This model is the confidential and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5602 // proprietary property of <company> and the possession or use of this
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5603 // file requires a written license from <company>.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5604 //------------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5605 // Modification history :
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5606 // <modhist>
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5607 //-----------------------------------------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5608
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5609 ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5610 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5611 (search-forward "<filename>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5612 (replace-match (buffer-name) t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5613 (search-forward "<author>") (replace-match "" t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5614 (insert (user-full-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5615 (insert " <" (user-login-name) "@" (system-name) ">")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5616 (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
5617 (verilog-insert-date)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5618 (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
5619 (verilog-insert-date)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5620 (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
5621 (verilog-insert-year)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5622 (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
5623 (verilog-insert-date)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5624 (insert " : created")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5625 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5626 (let (string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5627 (setq string (read-string "title: "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5628 (search-forward "<title>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5629 (replace-match string t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5630 (setq string (read-string "project: " verilog-project))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5631 (setq verilog-project string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5632 (search-forward "<project>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5633 (replace-match string t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5634 (setq string (read-string "Company: " verilog-company))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5635 (setq verilog-company string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5636 (search-forward "<company>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5637 (replace-match string t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5638 (search-forward "<company>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5639 (replace-match string t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5640 (search-forward "<company>")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5641 (replace-match string t t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5642 (search-backward "<description>")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5643 (replace-match "" t t))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5644
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
5645 ;; 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
5646
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
5647 (defun verilog-insert-date ()
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5648 "Insert date from the system."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5649 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5650 (let ((timpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5651 (setq timpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5652 (if verilog-date-scientific-format
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5653 (shell-command "date \"+@%Y/%m/%d\"" t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5654 (shell-command "date \"+@%d.%m.%Y\"" t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5655 (search-forward "@")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5656 (delete-region timpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5657 (end-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5658 (delete-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5659
79554
bc59ec18d036 (verilog-kill-existing-comment, verilog-insert-date)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79552
diff changeset
5660 (defun verilog-insert-year ()
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5661 "Insert year from the system."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5662 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5663 (let ((timpos))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5664 (setq timpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5665 (shell-command "date \"+@%Y\"" t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5666 (search-forward "@")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5667 (delete-region timpos (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5668 (end-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5669 (delete-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5670
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5671
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5672 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5673 ;; Signal list parsing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5674 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5675
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5676 ;; Elements of a signal list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5677 (defsubst verilog-sig-name (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5678 (car sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5679 (defsubst verilog-sig-bits (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5680 (nth 1 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5681 (defsubst verilog-sig-comment (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5682 (nth 2 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5683 (defsubst verilog-sig-memory (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5684 (nth 3 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5685 (defsubst verilog-sig-enum (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5686 (nth 4 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5687 (defsubst verilog-sig-signed (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5688 (nth 5 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5689 (defsubst verilog-sig-type (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5690 (nth 6 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5691 (defsubst verilog-sig-multidim (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5692 (nth 7 sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5693 (defsubst verilog-sig-multidim-string (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5694 (if (verilog-sig-multidim sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5695 (let ((str "") (args (verilog-sig-multidim sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5696 (while args
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5697 (setq str (concat str (car args)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5698 (setq args (cdr args)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5699 str)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5700 (defsubst verilog-sig-width (sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5701 (verilog-make-width-expression (verilog-sig-bits sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5702
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5703 (defsubst verilog-alw-get-inputs (sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5704 (nth 2 sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5705 (defsubst verilog-alw-get-outputs (sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5706 (nth 0 sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5707 (defsubst verilog-alw-get-uses-delayed (sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5708 (nth 3 sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5709
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5710 (defun verilog-signals-not-in (in-list not-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5711 "Return list of signals in IN-LIST that aren't also in NOT-LIST,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5712 and also remove any duplicates in IN-LIST.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5713 Signals must be in standard (base vector) form."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5714 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5715 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5716 (if (not (or (assoc (car (car in-list)) not-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5717 (assoc (car (car in-list)) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5718 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5719 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5720 (nreverse out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5721 ;;(verilog-signals-not-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5722
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5723 (defun verilog-signals-in (in-list other-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5724 "Return list of signals in IN-LIST that are also in OTHER-LIST.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5725 Signals must be in standard (base vector) form."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5726 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5727 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5728 (if (assoc (car (car in-list)) other-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5729 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5730 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5731 (nreverse out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5732 ;;(verilog-signals-in '(("A" "") ("B" "") ("DEL" "[2:3]")) '(("DEL" "") ("EXT" "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5733
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5734 (defun verilog-signals-memory (in-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5735 "Return list of signals in IN-LIST that are memoried (multidimensional)."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5736 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5737 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5738 (if (nth 3 (car in-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5739 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5740 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5741 out-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5742 ;;(verilog-signals-memory '(("A" nil nil "[3:0]")) '(("B" nil nil nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5743
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5744 (defun verilog-signals-sort-compare (a b)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5745 "Compare signal A and B for sorting."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5746 (string< (car a) (car b)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5747
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5748 (defun verilog-signals-not-params (in-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5749 "Return list of signals in IN-LIST that aren't parameters or numeric constants."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5750 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5751 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5752 (unless (boundp (intern (concat "vh-" (car (car in-list)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5753 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5754 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5755 (nreverse out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5756
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5757 (defun verilog-signals-combine-bus (in-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5758 "Return a list of signals in IN-LIST, with busses combined.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5759 Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5760 (let (combo buswarn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5761 out-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5762 sig highbit lowbit ; Temp information about current signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5763 sv-name sv-highbit sv-lowbit ; Details about signal we are forming
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5764 sv-comment sv-memory sv-enum sv-signed sv-type sv-multidim sv-busstring
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5765 bus)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5766 ;; Shove signals so duplicated signals will be adjacent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5767 (setq in-list (sort in-list `verilog-signals-sort-compare))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5768 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5769 (setq sig (car in-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5770 ;; No current signal; form from existing details
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5771 (unless sv-name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5772 (setq sv-name (verilog-sig-name sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5773 sv-highbit nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5774 sv-busstring nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5775 sv-comment (verilog-sig-comment sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5776 sv-memory (verilog-sig-memory sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5777 sv-enum (verilog-sig-enum sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5778 sv-signed (verilog-sig-signed sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5779 sv-type (verilog-sig-type sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5780 sv-multidim (verilog-sig-multidim sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5781 combo ""
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5782 buswarn ""))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5783 ;; Extract bus details
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5784 (setq bus (verilog-sig-bits sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5785 (cond ((and bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5786 (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
5787 (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
5788 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
5789 (match-string 2 bus))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5790 (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
5791 (setq highbit (string-to-number (match-string 1 bus))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5792 lowbit highbit))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5793 ;; Combine bits in bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5794 (if sv-highbit
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5795 (setq sv-highbit (max highbit sv-highbit)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5796 sv-lowbit (min lowbit sv-lowbit))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5797 (setq sv-highbit highbit
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5798 sv-lowbit lowbit)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5799 (bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5800 ;; String, probably something like `preproc:0
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5801 (setq sv-busstring bus)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5802 ;; Peek ahead to next signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5803 (setq in-list (cdr in-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5804 (setq sig (car in-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5805 (cond ((and sig (equal sv-name (verilog-sig-name sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5806 ;; 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
5807 (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
5808 (not (equal sv-busstring (verilog-sig-bits sig))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5809 (when nil ;; Debugging
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5810 (message (concat "Warning, can't merge into single bus "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5811 sv-name bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5812 ", the AUTOs may be wrong")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5813 (setq buswarn ", Couldn't Merge"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5814 (if (verilog-sig-comment sig) (setq combo ", ..."))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5815 (setq sv-memory (or sv-memory (verilog-sig-memory sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5816 sv-enum (or sv-enum (verilog-sig-enum sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5817 sv-signed (or sv-signed (verilog-sig-signed sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5818 sv-type (or sv-type (verilog-sig-type sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5819 sv-multidim (or sv-multidim (verilog-sig-multidim sig))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5820 ;; Doesn't match next signal, add to queue, zero in prep for next
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5821 ;; Note sig may also be nil for the last signal in the list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5822 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5823 (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
5824 (cons
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
5825 (list sv-name
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
5826 (or sv-busstring
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
5827 (if sv-highbit
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
5828 (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
5829 (int-to-string sv-lowbit) "]")))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5830 (concat sv-comment combo buswarn)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5831 sv-memory sv-enum sv-signed sv-type sv-multidim)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5832 out-list)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5833 sv-name nil))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5834 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5835 out-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5836
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5837 (defun verilog-sig-tieoff (sig &optional no-width)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5838 "Return tieoff expression for given SIG, with appropriate width.
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5839 Ignore width if optional NO-WIDTH is set."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5840 (let* ((width (if no-width nil (verilog-sig-width sig))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5841 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5842 (if (and verilog-active-low-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5843 (string-match verilog-active-low-regexp (verilog-sig-name sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5844 "~" "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5845 (cond ((not width)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5846 "0")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5847 ((string-match "^[0-9]+$" width)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5848 (concat width (if (verilog-sig-signed sig) "'sh0" "'h0")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5849 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5850 (concat "{" width "{1'b0}}"))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5851
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5852 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5853 ;; Port/Wire/Etc Reading
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5854 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5855
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5856 (defun verilog-read-inst-backward-name ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5857 "Internal. Move point back to beginning of inst-name."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5858 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5859 (let (done)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5860 (while (not done)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5861 (verilog-re-search-backward-quick "\\()\\|\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil) ; ] isn't word boundary
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5862 (cond ((looking-at ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5863 (verilog-backward-open-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5864 (t (setq done t)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5865 (while (looking-at "\\]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5866 (verilog-backward-open-bracket)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5867 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|\\]\\)" nil nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5868 (skip-chars-backward "a-zA-Z0-9`_$"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5869
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5870 (defun verilog-read-inst-module ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5871 "Return module_name when point is inside instantiation."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5872 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5873 (verilog-read-inst-backward-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5874 ;; Skip over instantiation name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5875 (verilog-re-search-backward-quick "\\(\\b[a-zA-Z0-9`_\$]\\|)\\)" nil nil) ; ) isn't word boundary
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5876 ;; Check for parameterized instantiations
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5877 (when (looking-at ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5878 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5879 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5880 (skip-chars-backward "a-zA-Z0-9'_$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5881 (looking-at "[a-zA-Z0-9`_\$]+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5882 ;; Important: don't use match string, this must work with emacs 19 font-lock on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5883 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5884
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5885 (defun verilog-read-inst-name ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5886 "Return instance_name when point is inside instantiation."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5887 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5888 (verilog-read-inst-backward-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5889 (looking-at "[a-zA-Z0-9`_\$]+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5890 ;; Important: don't use match string, this must work with emacs 19 font-lock on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5891 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5892
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5893 (defun verilog-read-module-name ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5894 "Return module name when after its ( or ;."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5895 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5896 (re-search-backward "[(;]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5897 (verilog-re-search-backward-quick "\\b[a-zA-Z0-9`_\$]" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5898 (skip-chars-backward "a-zA-Z0-9`_$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5899 (looking-at "[a-zA-Z0-9`_\$]+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5900 ;; Important: don't use match string, this must work with emacs 19 font-lock on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5901 (buffer-substring-no-properties (match-beginning 0) (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5902
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5903 (defun verilog-read-auto-params (num-param &optional max-param)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5904 "Return parameter list inside auto.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5905 Optional NUM-PARAM and MAX-PARAM check for a specific number of parameters."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5906 (let ((olist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5907 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5908 ;; /*AUTOPUNT("parameter", "parameter")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5909 (search-backward "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5910 (while (looking-at "(?\\s *\"\\([^\"]*\\)\"\\s *,?")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5911 (setq olist (cons (match-string 1) olist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5912 (goto-char (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5913 (or (eq nil num-param)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5914 (<= num-param (length olist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5915 (error "%s: Expected %d parameters" (verilog-point-text) num-param))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5916 (if (eq max-param nil) (setq max-param num-param))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5917 (or (eq nil max-param)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5918 (>= max-param (length olist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5919 (error "%s: Expected <= %d parameters" (verilog-point-text) max-param))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5920 (nreverse olist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5921
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5922 (defun verilog-read-decls ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5923 "Compute signal declaration information for the current module at point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5924 Return a array of [outputs inouts inputs wire reg assign const]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5925 (let ((end-mod-point (or (verilog-get-end-of-defun t) (point-max)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5926 (functask 0) (paren 0) (sig-paren 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5927 sigs-in sigs-out sigs-inout sigs-wire sigs-reg sigs-assign sigs-const sigs-gparam
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5928 vec expect-signal keywd newsig rvalue enum io signed typedefed multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5929 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5930 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5931 (setq sigs-const (verilog-read-auto-constants (point) end-mod-point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5932 (while (< (point) end-mod-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5933 ;;(if dbg (setq dbg (cons (format "Pt %s Vec %s Kwd'%s'\n" (point) vec keywd) dbg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5934 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5935 ((looking-at "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5936 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5937 (setq enum (match-string 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5938 (search-forward "\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5939 ((looking-at "/\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5940 (forward-char 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5941 (if (looking-at "[^*]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5942 (setq enum (match-string 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5943 (or (search-forward "*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5944 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5945 ((looking-at "(\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5946 (forward-char 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5947 (or (looking-at "\\s-*)") ; It's a "always @ (*)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5948 (search-forward "*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5949 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5950 ((eq ?\" (following-char))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5951 (or (re-search-forward "[^\\]\"" nil t) ;; don't forward-char first, since we look for a non backslash first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5952 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5953 ((eq ?\; (following-char))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5954 (setq vec nil io nil expect-signal nil newsig nil paren 0 rvalue nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5955 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5956 ((eq ?= (following-char))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5957 (setq rvalue t newsig nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5958 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5959 ((and (or rvalue sig-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5960 (cond ((and (eq ?, (following-char))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5961 (eq paren sig-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5962 (setq rvalue nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5963 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5964 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5965 ;; ,'s can occur inside {} & funcs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5966 ((looking-at "[{(]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5967 (setq paren (1+ paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5968 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5969 t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5970 ((looking-at "[})]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5971 (setq paren (1- paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5972 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5973 (when (< paren sig-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5974 (setq expect-signal nil)) ; ) that ends variables inside v2k arg list
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
5975 t))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5976 ((looking-at "\\s-*\\(\\[[^]]+\\]\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5977 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5978 (cond (newsig ; Memory, not just width. Patch last signal added's memory (nth 3)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5979 (setcar (cdr (cdr (cdr newsig))) (match-string 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5980 (vec ;; Multidimensional
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5981 (setq multidim (cons vec multidim))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5982 (setq vec (verilog-string-replace-matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5983 "\\s-+" "" nil nil (match-string 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5984 (t ;; Bit width
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5985 (setq vec (verilog-string-replace-matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5986 "\\s-+" "" nil nil (match-string 1))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5987 ;; Normal or escaped identifier -- note we remember the \ if escaped
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5988 ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5989 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5990 (setq keywd (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5991 (when (string-match "^\\\\" keywd)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5992 (setq keywd (concat keywd " "))) ;; Escaped ID needs space at end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5993 (cond ((equal keywd "input")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5994 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5995 expect-signal 'sigs-in io t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5996 ((equal keywd "output")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5997 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5998 expect-signal 'sigs-out io t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5999 ((equal keywd "inout")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6000 (setq vec nil enum nil rvalue nil newsig nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6001 expect-signal 'sigs-inout io t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6002 ((or (equal keywd "wire")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6003 (equal keywd "tri")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6004 (equal keywd "tri0")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6005 (equal keywd "tri1"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6006 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6007 expect-signal 'sigs-wire)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6008 ((or (equal keywd "reg")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6009 (equal keywd "trireg"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6010 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6011 expect-signal 'sigs-reg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6012 ((equal keywd "assign")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6013 (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6014 expect-signal 'sigs-assign))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6015 ((or (equal keywd "supply0")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6016 (equal keywd "supply1")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6017 (equal keywd "supply")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6018 (equal keywd "localparam"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6019 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6020 expect-signal 'sigs-const)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6021 ((or (equal keywd "parameter"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6022 (unless io (setq vec nil enum nil rvalue nil signed nil typedefed nil multidim nil sig-paren paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6023 expect-signal 'sigs-gparam)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6024 ((equal keywd "signed")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6025 (setq signed "signed"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6026 ((or (equal keywd "function")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6027 (equal keywd "task"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6028 (setq functask (1+ functask)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6029 ((or (equal keywd "endfunction")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6030 (equal keywd "endtask"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6031 (setq functask (1- functask)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6032 ((or (equal keywd "`ifdef")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6033 (equal keywd "`ifndef"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6034 (setq rvalue t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6035 ((verilog-typedef-name-p keywd)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6036 (setq typedefed keywd))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6037 ((and expect-signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6038 (eq functask 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6039 (not rvalue)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6040 (eq paren sig-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6041 (not (member keywd verilog-keywords)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6042 ;; Add new signal to expect-signal's variable
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6043 (setq newsig (list keywd vec nil nil enum signed typedefed multidim))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6044 (set expect-signal (cons newsig
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6045 (symbol-value expect-signal))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6046 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6047 (forward-char 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6048 (skip-syntax-forward " "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6049 ;; Return arguments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6050 (vector (nreverse sigs-out)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6051 (nreverse sigs-inout)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6052 (nreverse sigs-in)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6053 (nreverse sigs-wire)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6054 (nreverse sigs-reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6055 (nreverse sigs-assign)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6056 (nreverse sigs-const)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6057 (nreverse sigs-gparam)))))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6058
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6059 (eval-when-compile
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6060 ;; Prevent compile warnings; these are let's, not globals
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6061 ;; Do not remove the eval-when-compile
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6062 ;; - 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
6063 (defvar sigs-in)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6064 (defvar sigs-inout)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6065 (defvar sigs-out))
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6066
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6067
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6068 (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
6069 (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
6070
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6071 (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
6072 (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
6073
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6074
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6075 ;; 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
6076 ;; 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
6077 ;; verilog-modi-current function.
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6078 (defsubst verilog-modi-get-outputs (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6079 (aref (verilog-modi-get-decls modi) 0))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6080 (defsubst verilog-modi-get-inouts (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6081 (aref (verilog-modi-get-decls modi) 1))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6082 (defsubst verilog-modi-get-inputs (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6083 (aref (verilog-modi-get-decls modi) 2))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6084 (defsubst verilog-modi-get-wires (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6085 (aref (verilog-modi-get-decls modi) 3))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6086 (defsubst verilog-modi-get-regs (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6087 (aref (verilog-modi-get-decls modi) 4))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6088 (defsubst verilog-modi-get-assigns (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6089 (aref (verilog-modi-get-decls modi) 5))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6090 (defsubst verilog-modi-get-consts (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6091 (aref (verilog-modi-get-decls modi) 6))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6092 (defsubst verilog-modi-get-gparams (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6093 (aref (verilog-modi-get-decls modi) 7))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6094 (defsubst verilog-modi-get-sub-outputs (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6095 (aref (verilog-modi-get-sub-decls modi) 0))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6096 (defsubst verilog-modi-get-sub-inouts (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6097 (aref (verilog-modi-get-sub-decls modi) 1))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6098 (defsubst verilog-modi-get-sub-inputs (modi)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6099 (aref (verilog-modi-get-sub-decls modi) 2))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6100
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6101
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6102 (defun verilog-read-sub-decls-sig (submodi comment port sig vec multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6103 "For verilog-read-sub-decls-line, add a signal."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6104 (let (portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6105 (when sig
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6106 (setq port (verilog-symbol-detick-denumber port))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6107 (setq sig (verilog-symbol-detick-denumber sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6108 (if sig (setq sig (verilog-string-replace-matches "^[---+~!|&]+" "" nil nil sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6109 (if vec (setq vec (verilog-symbol-detick-denumber vec)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6110 (if multidim (setq multidim (mapcar `verilog-symbol-detick-denumber multidim)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6111 (unless (or (not sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6112 (equal sig "")) ;; Ignore .foo(1'b1) assignments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6113 (cond ((setq portdata (assoc port (verilog-modi-get-inouts submodi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6114 (setq sigs-inout (cons (list sig vec (concat "To/From " comment) nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6115 (verilog-sig-signed portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6116 (verilog-sig-type portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6117 multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6118 sigs-inout)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6119 ((setq portdata (assoc port (verilog-modi-get-outputs submodi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6120 (setq sigs-out (cons (list sig vec (concat "From " comment) nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6121 (verilog-sig-signed portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6122 (verilog-sig-type portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6123 multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6124 sigs-out)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6125 ((setq portdata (assoc port (verilog-modi-get-inputs submodi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6126 (setq sigs-in (cons (list sig vec (concat "To " comment) nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6127 (verilog-sig-signed portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6128 (verilog-sig-type portdata)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6129 multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6130 sigs-in)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6131 ;; (t -- warning pin isn't defined.) ; Leave for lint tool
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6132 )))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6133
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6134 (defun verilog-read-sub-decls-line (submodi comment)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6135 "For read-sub-decls, read lines of port defs until none match anymore.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6136 Return the list of signals found, using submodi to look up each port."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6137 (let (done port sig vec multidim)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6138 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6139 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6140 (while (not done)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6141 ;; Get port name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6142 (cond ((looking-at "\\s-*\\.\\s-*\\([a-zA-Z0-9`_$]*\\)\\s-*(\\s-*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6143 (setq port (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6144 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6145 ((looking-at "\\s-*\\.\\s-*\\(\\\\[^ \t\n\f]*\\)\\s-*(\\s-*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6146 (setq port (concat (match-string 1) " ")) ;; escaped id's need trailing space
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6147 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6148 ((looking-at "\\s-*\\.[^(]*(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6149 (setq port nil) ;; skip this line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6150 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6151 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6152 (setq port nil done t))) ;; Unknown, ignore rest of line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6153 ;; Get signal name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6154 (when port
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6155 (setq multidim nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6156 (cond ((looking-at "\\(\\\\[^ \t\n\f]*\\)\\s-*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6157 (setq sig (concat (match-string 1) " ") ;; escaped id's need trailing space
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6158 vec nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6159 ; We intentionally ignore (non-escaped) signals with .s in them
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6160 ; this prevents AUTOWIRE etc from noticing hierarchical sigs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6161 ((looking-at "\\([^[({).]*\\)\\s-*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6162 (setq sig (verilog-string-remove-spaces (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6163 vec nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6164 ((looking-at "\\([^[({).]*\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6165 (setq sig (verilog-string-remove-spaces (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6166 vec (match-string 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6167 ((looking-at "\\([^[({).]*\\)\\s-*/\\*\\(\\[[^*]+\\]\\)\\*/\\s-*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6168 (setq sig (verilog-string-remove-spaces (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6169 vec nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6170 (let ((parse (match-string 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6171 (while (string-match "^\\(\\[[^]]+\\]\\)\\(.*\\)$" parse)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6172 (when vec (setq multidim (cons vec multidim)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6173 (setq vec (match-string 1 parse))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6174 (setq parse (match-string 2 parse)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6175 ((looking-at "{\\(.*\\)}.*\\s-*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6176 (let ((mlst (split-string (match-string 1) ","))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6177 mstr)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6178 (while (setq mstr (pop mlst))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6179 ;;(unless noninteractive (message "sig: %s " mstr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6180 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6181 ((string-match "\\(['`a-zA-Z0-9_$]+\\)\\s-*$" mstr)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6182 (setq sig (verilog-string-remove-spaces (match-string 1 mstr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6183 vec nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6184 ;;(unless noninteractive (message "concat sig1: %s %s" mstr (match-string 1 mstr)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6185 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6186 ((string-match "\\([^[({).]+\\)\\s-*\\(\\[[^]]+\\]\\)\\s-*" mstr)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6187 (setq sig (verilog-string-remove-spaces (match-string 1 mstr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6188 vec (match-string 2 mstr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6189 ;;(unless noninteractive (message "concat sig2: '%s' '%s' '%s'" mstr (match-string 1 mstr) (match-string 2 mstr)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6190 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6191 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6192 (setq sig nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6193 ;; Process signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6194 (verilog-read-sub-decls-sig submodi comment port sig vec multidim))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6195 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6196 (setq sig nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6197 ;; Process signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6198 (verilog-read-sub-decls-sig submodi comment port sig vec multidim))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6199 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6200 (forward-line 1)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6201
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6202 (defun verilog-read-sub-decls ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6203 "Internally parse signals going to modules under this module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6204 Return a array of [ outputs inouts inputs ] signals for modules that are
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6205 instantiated in this module. For example if declare A A (.B(SIG)) and SIG
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6206 is a output, then SIG will be included in the list.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6207
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6208 This only works on instantiations created with /*AUTOINST*/ converted by
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6209 \\[verilog-auto-inst]. Otherwise, it would have to read in the whole
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6210 component library to determine connectivity of the design.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6211
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6212 One work around for this problem is to manually create // Inputs and //
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6213 Outputs comments above subcell signals, for example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6214
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6215 module1 instance1x (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6216 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6217 .out (out),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6218 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6219 .in (in));"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6220 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6221 (let ((end-mod-point (verilog-get-end-of-defun t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6222 st-point end-inst-point
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6223 ;; below 3 modified by verilog-read-sub-decls-line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6224 sigs-out sigs-inout sigs-in)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6225 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6226 (while (re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-mod-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6227 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6228 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6229 (unless (verilog-inside-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6230 ;; Attempt to snarf a comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6231 (let* ((submod (verilog-read-inst-module))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6232 (inst (verilog-read-inst-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6233 (comment (concat inst " of " submod ".v")) submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6234 (when (setq submodi (verilog-modi-lookup submod t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6235 ;; This could have used a list created by verilog-auto-inst
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6236 ;; However I want it to be runnable even on user's manually added signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6237 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6238 (setq end-inst-point (save-excursion (forward-sexp 1) (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6239 st-point (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6240 (while (re-search-forward "\\s *(?\\s *// Outputs" end-inst-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6241 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-out
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6242 (goto-char st-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6243 (while (re-search-forward "\\s *// Inouts" end-inst-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6244 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-inout
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6245 (goto-char st-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6246 (while (re-search-forward "\\s *// Inputs" end-inst-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6247 (verilog-read-sub-decls-line submodi comment)) ;; Modifies sigs-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6248 )))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6249 ;; Combine duplicate bits
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6250 ;;(setq rr (vector sigs-out sigs-inout sigs-in))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6251 (vector (verilog-signals-combine-bus (nreverse sigs-out))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6252 (verilog-signals-combine-bus (nreverse sigs-inout))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6253 (verilog-signals-combine-bus (nreverse sigs-in))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6254
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6255 (defun verilog-read-inst-pins ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6256 "Return a array of [ pins ] for the current instantiation at point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6257 For example if declare A A (.B(SIG)) then B will be included in the list."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6258 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6259 (let ((end-mod-point (point)) ;; presume at /*AUTOINST*/ point
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6260 pins pin)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6261 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6262 (while (re-search-forward "\\.\\([^(,) \t\n\f]*\\)\\s-*" end-mod-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6263 (setq pin (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6264 (unless (verilog-inside-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6265 (setq pins (cons (list pin) pins))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6266 (when (looking-at "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6267 (forward-sexp 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6268 (vector pins))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6269
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6270 (defun verilog-read-arg-pins ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6271 "Return a array of [ pins ] for the current argument declaration at point."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6272 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6273 (let ((end-mod-point (point)) ;; presume at /*AUTOARG*/ point
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6274 pins pin)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6275 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6276 (while (re-search-forward "\\([a-zA-Z0-9$_.%`]+\\)" end-mod-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6277 (setq pin (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6278 (unless (verilog-inside-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6279 (setq pins (cons (list pin) pins))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6280 (vector pins))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6281
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6282 (defun verilog-read-auto-constants (beg end-mod-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6283 "Return a list of AUTO_CONSTANTs used in the region from BEG to END-MOD-POINT."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6284 ;; Insert new
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6285 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6286 (let (sig-list tpl-end-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6287 (goto-char beg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6288 (while (re-search-forward "\\<AUTO_CONSTANT" end-mod-point t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6289 (if (not (looking-at "\\s *("))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6290 (error "%s: Missing () after AUTO_CONSTANT" (verilog-point-text)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6291 (search-forward "(" end-mod-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6292 (setq tpl-end-pt (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6293 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6294 (forward-sexp 1) ;; Moves to paren that closes argdecl's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6295 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6296 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6297 (while (re-search-forward "\\s-*\\([\"a-zA-Z0-9$_.%`]+\\)\\s-*,*" tpl-end-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6298 (setq sig-list (cons (list (match-string 1) nil nil) sig-list))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6299 sig-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6300
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6301 (defun verilog-read-auto-lisp (start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6302 "Look for and evaluate a AUTO_LISP between START and END."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6303 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6304 (goto-char start)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6305 (while (re-search-forward "\\<AUTO_LISP(" end t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6306 (backward-char)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6307 (let* ((beg-pt (prog1 (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6308 (forward-sexp 1))) ;; Closing paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6309 (end-pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6310 (eval-region beg-pt end-pt nil)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6311
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6312 (eval-when-compile
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6313 ;; Prevent compile warnings; these are let's, not globals
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6314 ;; Do not remove the eval-when-compile
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6315 ;; - 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
6316 (defvar sigs-in)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6317 (defvar sigs-out)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6318 (defvar got-sig)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6319 (defvar got-rvalue)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6320 (defvar uses-delayed)
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6321 (defvar vector-skip-list))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6322
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6323 (defun verilog-read-always-signals-recurse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6324 (exit-keywd rvalue ignore-next)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6325 "Recursive routine for parentheses/bracket matching.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6326 EXIT-KEYWD is expression to stop at, nil if top level.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6327 RVALUE is true if at right hand side of equal.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6328 IGNORE-NEXT is true to ignore next token, fake from inside case statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6329 (let* ((semi-rvalue (equal "endcase" exit-keywd)) ;; true if after a ; we are looking for rvalue
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6330 keywd last-keywd sig-tolk sig-last-tolk gotend got-sig got-rvalue end-else-check)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6331 ;;(if dbg (setq dbg (concat dbg (format "Recursion %S %S %S\n" exit-keywd rvalue ignore-next))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6332 (while (not (or (eobp) gotend))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6333 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6334 ((looking-at "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6335 (search-forward "\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6336 ((looking-at "/\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6337 (or (search-forward "*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6338 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6339 ((looking-at "(\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6340 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6341 (search-forward "*)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6342 (error "%s: Unmatched (* *), at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6343 (t (setq keywd (buffer-substring-no-properties
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6344 (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6345 (save-excursion (when (eq 0 (skip-chars-forward "a-zA-Z0-9$_.%`"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6346 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6347 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6348 sig-last-tolk sig-tolk
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6349 sig-tolk nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6350 ;;(if dbg (setq dbg (concat dbg (format "\tPt=%S %S\trv=%S in=%S ee=%S\n" (point) keywd rvalue ignore-next end-else-check))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6351 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6352 ((equal keywd "\"")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6353 (or (re-search-forward "[^\\]\"" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6354 (error "%s: Unmatched quotes, at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6355 ;; else at top level loop, keep parsing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6356 ((and end-else-check (equal keywd "else"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6357 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else %s\n" keywd))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6358 ;; no forward movement, want to see else in lower loop
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6359 (setq end-else-check nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6360 ;; End at top level loop
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6361 ((and end-else-check (looking-at "[^ \t\n\f]"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6362 ;;(if dbg (setq dbg (concat dbg (format "\tif-check-else-other %s\n" keywd))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6363 (setq gotend t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6364 ;; Final statement?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6365 ((and exit-keywd (equal keywd exit-keywd))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6366 (setq gotend t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6367 (forward-char (length keywd)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6368 ;; Standard tokens...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6369 ((equal keywd ";")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6370 (setq ignore-next nil rvalue semi-rvalue)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6371 ;; Final statement at top level loop?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6372 (when (not exit-keywd)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6373 ;;(if dbg (setq dbg (concat dbg (format "\ttop-end-check %s\n" keywd))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6374 (setq end-else-check t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6375 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6376 ((equal keywd "'")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6377 (if (looking-at "'s?[hdxbo][0-9a-fA-F_xz? \t]*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6378 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6379 (forward-char 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6380 ((equal keywd ":") ;; Case statement, begin/end label, x?y:z
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6381 (cond ((equal "endcase" exit-keywd) ;; case x: y=z; statement next
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6382 (setq ignore-next nil rvalue nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6383 ((equal "?" exit-keywd) ;; x?y:z rvalue
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6384 ) ;; NOP
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6385 (got-sig ;; label: statement
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6386 (setq ignore-next nil rvalue semi-rvalue got-sig nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6387 ((not rvalue) ;; begin label
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6388 (setq ignore-next t rvalue nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6389 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6390 ((equal keywd "=")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6391 (if (eq (char-before) ?< )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6392 (setq uses-delayed 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6393 (setq ignore-next nil rvalue t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6394 (forward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6395 ((equal keywd "?")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6396 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6397 (verilog-read-always-signals-recurse ":" rvalue nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6398 ((equal keywd "[")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6399 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6400 (verilog-read-always-signals-recurse "]" t nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6401 ((equal keywd "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6402 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6403 (cond (sig-last-tolk ;; Function call; zap last signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6404 (setq got-sig nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6405 (cond ((equal last-keywd "for")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6406 (verilog-read-always-signals-recurse ";" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6407 (verilog-read-always-signals-recurse ";" t nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6408 (verilog-read-always-signals-recurse ")" nil nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6409 (t (verilog-read-always-signals-recurse ")" t nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6410 ((equal keywd "begin")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6411 (skip-syntax-forward "w_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6412 (verilog-read-always-signals-recurse "end" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6413 ;;(if dbg (setq dbg (concat dbg (format "\tgot-end %s\n" exit-keywd))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6414 (setq ignore-next nil rvalue semi-rvalue)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6415 (if (not exit-keywd) (setq end-else-check t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6416 ((or (equal keywd "case")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6417 (equal keywd "casex")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6418 (equal keywd "casez"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6419 (skip-syntax-forward "w_")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6420 (verilog-read-always-signals-recurse "endcase" t nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6421 (setq ignore-next nil rvalue semi-rvalue)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6422 (if (not exit-keywd) (setq gotend t))) ;; top level begin/end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6423 ((string-match "^[$`a-zA-Z_]" keywd) ;; not exactly word constituent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6424 (cond ((or (equal keywd "`ifdef")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6425 (equal keywd "`ifndef"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6426 (setq ignore-next t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6427 ((or ignore-next
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6428 (member keywd verilog-keywords)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6429 (string-match "^\\$" keywd)) ;; PLI task
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6430 (setq ignore-next nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6431 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6432 (setq keywd (verilog-symbol-detick-denumber keywd))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6433 (when got-sig
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6434 (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6435 (setq sigs-out (cons got-sig sigs-out)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6436 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6437 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6438 (setq got-rvalue rvalue
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6439 got-sig (if (or (not keywd)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6440 (assoc keywd (if got-rvalue sigs-in sigs-out)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6441 nil (list keywd nil nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6442 sig-tolk t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6443 (skip-chars-forward "a-zA-Z0-9$_.%`"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6444 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6445 (forward-char 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6446 ;; End of non-comment token
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6447 (setq last-keywd keywd)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6448 (skip-syntax-forward " "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6449 ;; Append the final pending signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6450 (when got-sig
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6451 (if got-rvalue (setq sigs-in (cons got-sig sigs-in))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6452 (setq sigs-out (cons got-sig sigs-out)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6453 ;;(if dbg (setq dbg (concat dbg (format "\t\tgot-sig=%S rv=%S\n" got-sig got-rvalue))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6454 (setq got-sig nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6455 ;;(if dbg (setq dbg (concat dbg (format "ENDRecursion %s\n" exit-keywd))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6456 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6457
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6458 (defun verilog-read-always-signals ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6459 "Parse always block at point and return list of (outputs inout inputs)."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6460 ;; Insert new
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6461 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6462 (let* (;;(dbg "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6463 sigs-in sigs-out
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6464 uses-delayed) ;; Found signal/rvalue; push if not function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6465 (search-forward ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6466 (verilog-read-always-signals-recurse nil nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6467 ;;(if dbg (save-excursion (set-buffer (get-buffer-create "*vl-dbg*")) (delete-region (point-min) (point-max)) (insert dbg) (setq dbg "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6468 ;; Return what was found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6469 (list sigs-out nil sigs-in uses-delayed))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6470
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6471 (defun verilog-read-instants ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6472 "Parse module at point and return list of ( ( file instance ) ... )."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6473 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6474 (let* ((end-mod-point (verilog-get-end-of-defun t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6475 (state nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6476 (instants-list nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6477 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6478 (while (< (point) end-mod-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6479 ;; Stay at level 0, no comments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6480 (while (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6481 (setq state (parse-partial-sexp (point) end-mod-point 0 t nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6482 (or (> (car state) 0) ; in parens
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6483 (nth 5 state) ; comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6484 ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6485 (forward-line 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6486 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6487 (if (looking-at "^\\s-*\\([a-zA-Z0-9`_$]+\\)\\s-+\\([a-zA-Z0-9`_$]+\\)\\s-*(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6488 ;;(if (looking-at "^\\(.+\\)$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6489 (let ((module (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6490 (instant (match-string 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6491 (if (not (member module verilog-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6492 (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
6493 (forward-line 1)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6494 instants-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6495
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6496
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6497 (defun verilog-read-auto-template (module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6498 "Look for a auto_template for the instantiation of the given MODULE.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6499 If found returns the signal name connections. Return REGEXP and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6500 list of ( (signal_name connection_name)... )"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6501 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6502 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6503 (let ((tpl-regexp "\\([0-9]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6504 (lineno 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6505 (templateno 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6506 tpl-sig-list tpl-wild-list tpl-end-pt rep)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6507 (cond ((or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6508 (re-search-backward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6509 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6510 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6511 (re-search-forward (concat "^\\s-*/?\\*?\\s-*" module "\\s-+AUTO_TEMPLATE") nil t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6512 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6513 ;; Parse "REGEXP"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6514 ;; We reserve @"..." for future lisp expressions that evaluate once-per-AUTOINST
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6515 (when (looking-at "\\s-*\"\\([^\"]*)\\)\"")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6516 (setq tpl-regexp (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6517 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6518 (search-forward "(")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6519 ;; Parse lines in the template
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6520 (when verilog-auto-inst-template-numbers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6521 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6522 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6523 (while (search-forward "AUTO_TEMPLATE" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6524 (setq templateno (1+ templateno)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6525 (setq tpl-end-pt (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6526 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6527 (forward-sexp 1) ;; Moves to paren that closes argdecl's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6528 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6529 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6530 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6531 (while (< (point) tpl-end-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6532 (cond ((looking-at "\\s-*\\.\\([a-zA-Z0-9`_$]+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6533 (setq tpl-sig-list (cons (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6534 (match-string-no-properties 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6535 (match-string-no-properties 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6536 templateno lineno)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6537 tpl-sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6538 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6539 ;; Regexp form??
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6540 ((looking-at
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6541 ;; Regexp bug in xemacs disallows ][ inside [], and wants + last
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6542 "\\s-*\\.\\(\\([a-zA-Z0-9`_$+@^.*?|---]+\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6543 (setq rep (match-string-no-properties 3))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6544 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6545 (setq tpl-wild-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6546 (cons (list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6547 (concat "^"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6548 (verilog-string-replace-matches "@" "\\\\([0-9]+\\\\)" nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6549 (match-string 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6550 "$")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6551 rep
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6552 templateno lineno)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6553 tpl-wild-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6554 ((looking-at "[ \t\f]+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6555 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6556 ((looking-at "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6557 (setq lineno (1+ lineno))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6558 (goto-char (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6559 ((looking-at "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6560 (search-forward "\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6561 ((looking-at "/\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6562 (forward-char 2)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6563 (or (search-forward "*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6564 (error "%s: Unmatched /* */, at char %d" (verilog-point-text) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6565 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6566 (error "%s: AUTO_TEMPLATE parsing error: %s"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6567 (verilog-point-text)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6568 (progn (looking-at ".*$") (match-string 0))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6569 ;; Return
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6570 (vector tpl-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6571 (list tpl-sig-list tpl-wild-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6572 ;; If no template found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6573 (t (vector tpl-regexp nil))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6574 ;;(progn (find-file "auto-template.v") (verilog-read-auto-template "ptl_entry"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6575
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6576 (defun verilog-set-define (defname defvalue &optional buffer enumname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6577 "Set the definition DEFNAME to the DEFVALUE in the given BUFFER.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6578 Optionally associate it with the specified enumeration ENUMNAME."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6579 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6580 (set-buffer (or buffer (current-buffer)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6581 (let ((mac (intern (concat "vh-" defname))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6582 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6583 ;; Need to define to a constant if no value given
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6584 (set (make-variable-buffer-local mac)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6585 (if (equal defvalue "") "1" defvalue)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6586 (if enumname
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6587 (let ((enumvar (intern (concat "venum-" enumname))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6588 ;;(message "Define %s=%s" defname defvalue) (sleep-for 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6589 (make-variable-buffer-local enumvar)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6590 (add-to-list enumvar defname)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6591
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6592 (defun verilog-read-defines (&optional filename recurse subcall)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6593 "Read `defines and parameters for the current file, or optional FILENAME.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6594 If the filename is provided, `verilog-library-flags' will be used to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6595 resolve it. If optional RECURSE is non-nil, recurse through `includes.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6596
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6597 Parameters must be simple assignments to constants, or have their own
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6598 \"parameter\" label rather than a list of parameters. Thus:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6599
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6600 parameter X = 5, Y = 10; // Ok
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6601 parameter X = {1'b1, 2'h2}; // Ok
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6602 parameter X = {1'b1, 2'h2}, Y = 10; // Bad, make into 2 parameter lines
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6603
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6604 Defines must be simple text substitutions, one on a line, starting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6605 at the beginning of the line. Any ifdefs or multiline comments around the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6606 define are ignored.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6607
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6608 Defines are stored inside Emacs variables using the name vh-{definename}.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6609
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6610 This function is useful for setting vh-* variables. The file variables
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6611 feature can be used to set defines that `verilog-mode' can see; put at the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6612 *END* of your file something like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6613
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6614 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6615 // vh-macro:\"macro_definition\"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6616 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6617
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6618 If macros are defined earlier in the same file and you want their values,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6619 you can read them automatically (provided `enable-local-eval' is on):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6620
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6621 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6622 // eval:(verilog-read-defines)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6623 // eval:(verilog-read-defines \"group_standard_includes.v\")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6624 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6625
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6626 Note these are only read when the file is first visited, you must use
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6627 \\[find-alternate-file] RET to have these take effect after editing them!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6628
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6629 If you want to disable the \"Process `eval' or hook local variables\"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6630 warning message, you need to add to your .emacs file:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6631
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6632 (setq enable-local-eval t)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6633 (let ((origbuf (current-buffer)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6634 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6635 (unless subcall (verilog-getopt-flags))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6636 (when filename
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6637 (let ((fns (verilog-library-filenames filename (buffer-file-name))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6638 (if fns
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6639 (set-buffer (find-file-noselect (car fns)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6640 (error (concat (verilog-point-text)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6641 ": Can't find verilog-read-defines file: " filename)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6642 (when recurse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6643 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6644 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6645 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string-no-properties 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6646 (unless (verilog-inside-comment-p)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6647 (verilog-read-defines inc recurse t)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6648 ;; Read `defines
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6649 ;; note we don't use verilog-re... it's faster this way, and that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6650 ;; function has problems when comments are at the end of the define
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6651 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6652 (while (re-search-forward "^\\s-*`define\\s-+\\([a-zA-Z0-9_$]+\\)\\s-+\\(.*\\)$" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6653 (let ((defname (match-string-no-properties 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6654 (defvalue (match-string-no-properties 2)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6655 (setq defvalue (verilog-string-replace-matches "\\s-*/[/*].*$" "" nil nil defvalue))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6656 (verilog-set-define defname defvalue origbuf)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6657 ;; Hack: Read parameters
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6658 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6659 (while (re-search-forward
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6660 "^\\s-*\\(parameter\\|localparam\\)\\(\\(\\s-*\\[[^]]*\\]\\|\\)\\s-+\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\|\\)\\s-*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6661 (let ((var (match-string-no-properties 4))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6662 (val (match-string-no-properties 5))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6663 enumname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6664 ;; The primary way of getting defines is verilog-read-decls
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6665 ;; However, that isn't called yet for included files, so we'll add another scheme
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6666 (if (looking-at "[^\n]*synopsys\\s +enum\\s +\\([a-zA-Z0-9_]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6667 (setq enumname (match-string-no-properties 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6668 (if var
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6669 (verilog-set-define var val origbuf enumname))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6670 (forward-comment 999)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6671 (while (looking-at "\\s-*,?\\s-*\\([a-zA-Z0-9_$]+\\)\\s-*=\\s-*\\([^;,]*\\),?\\s-*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6672 (verilog-set-define (match-string-no-properties 1) (match-string-no-properties 2) origbuf enumname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6673 (goto-char (match-end 0))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6674 (forward-comment 999)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6675
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6676 (defun verilog-read-includes ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6677 "Read `includes for the current file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6678 This will find all of the `includes which are at the beginning of lines,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6679 ignoring any ifdefs or multiline comments around them.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6680 `verilog-read-defines' is then performed on the current and each included
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6681 file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6682
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6683 It is often useful put at the *END* of your file something like:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6684
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6685 // Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6686 // eval:(verilog-read-defines)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6687 // eval:(verilog-read-includes)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6688 // End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6689
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6690 Note includes are only read when the file is first visited, you must use
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6691 \\[find-alternate-file] RET to have these take effect after editing them!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6692
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6693 It is good to get in the habit of including all needed files in each .v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6694 file that needs it, rather than waiting for compile time. This will aid
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6695 this process, Verilint, and readability. To prevent defining the same
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6696 variable over and over when many modules are compiled together, put a test
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6697 around the inside each include file:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6698
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6699 foo.v (a include):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6700 `ifdef _FOO_V // include if not already included
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6701 `else
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6702 `define _FOO_V
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6703 ... contents of file
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6704 `endif // _FOO_V"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6705 ;;slow: (verilog-read-defines nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6706 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6707 (verilog-getopt-flags)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6708 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6709 (while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6710 (let ((inc (verilog-string-replace-matches "\"" "" nil nil (match-string 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6711 (verilog-read-defines inc nil t)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6712
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6713 (defun verilog-read-signals (&optional start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6714 "Return a simple list of all possible signals in the file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6715 Bounded by optional region from START to END. Overly aggressive but fast.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6716 Some macros and such are also found and included. For dinotrace.el"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6717 (let (sigs-all keywd)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6718 (progn;save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6719 (goto-char (or start (point-min)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6720 (setq end (or end (point-max)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6721 (while (re-search-forward "[\"/a-zA-Z_.%`]" end t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6722 (forward-char -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6723 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6724 ((looking-at "//")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6725 (search-forward "\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6726 ((looking-at "/\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6727 (search-forward "*/"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6728 ((looking-at "(\\*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6729 (or (looking-at "(\\*\\s-*)") ; It's a "always @ (*)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6730 (search-forward "*)")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6731 ((eq ?\" (following-char))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6732 (re-search-forward "[^\\]\"")) ;; don't forward-char first, since we look for a non backslash first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6733 ((looking-at "\\s-*\\([a-zA-Z0-9$_.%`]+\\)")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6734 (goto-char (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6735 (setq keywd (match-string-no-properties 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6736 (or (member keywd verilog-keywords)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6737 (member keywd sigs-all)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6738 (setq sigs-all (cons keywd sigs-all))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6739 (t (forward-char 1))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6740 ;; Return list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6741 sigs-all)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6742
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6743 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6744 ;; Argument file parsing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6745 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6746
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6747 (defun verilog-getopt (arglist)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6748 "Parse -f, -v etc arguments in ARGLIST list or string."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6749 (unless (listp arglist) (setq arglist (list arglist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6750 (let ((space-args '())
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6751 arg next-param)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6752 ;; Split on spaces, so users can pass whole command lines
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6753 (while arglist
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6754 (setq arg (car arglist)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6755 arglist (cdr arglist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6756 (while (string-match "^\\([^ \t\n\f]+\\)[ \t\n\f]*\\(.*$\\)" arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6757 (setq space-args (append space-args
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6758 (list (match-string-no-properties 1 arg))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6759 (setq arg (match-string 2 arg))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6760 ;; Parse arguments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6761 (while space-args
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6762 (setq arg (car space-args)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6763 space-args (cdr space-args))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6764 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6765 ;; Need another arg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6766 ((equal arg "-f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6767 (setq next-param arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6768 ((equal arg "-v")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6769 (setq next-param arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6770 ((equal arg "-y")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6771 (setq next-param arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6772 ;; +libext+(ext1)+(ext2)...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6773 ((string-match "^\\+libext\\+\\(.*\\)" arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6774 (setq arg (match-string 1 arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6775 (while (string-match "\\([^+]+\\)\\+?\\(.*\\)" arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6776 (verilog-add-list-unique `verilog-library-extensions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6777 (match-string 1 arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6778 (setq arg (match-string 2 arg))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6779 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6780 ((or (string-match "^-D\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; -Ddefine=val
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6781 (string-match "^-D\\([^+=]*\\)\\(\\)" arg) ;; -Ddefine
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6782 (string-match "^\\+define\\([^+=]*\\)[+=]\\(.*\\)" arg) ;; +define+val
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6783 (string-match "^\\+define\\([^+=]*\\)\\(\\)" arg)) ;; +define+define
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6784 (verilog-set-define (match-string 1 arg) (match-string 2 arg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6785 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6786 ((or (string-match "^\\+incdir\\+\\(.*\\)" arg) ;; +incdir+dir
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6787 (string-match "^-I\\(.*\\)" arg)) ;; -Idir
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6788 (verilog-add-list-unique `verilog-library-directories
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6789 (match-string 1 arg)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6790 ;; Ignore
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6791 ((equal "+librescan" arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6792 ((string-match "^-U\\(.*\\)" arg)) ;; -Udefine
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6793 ;; Second parameters
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6794 ((equal next-param "-f")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6795 (setq next-param nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6796 (verilog-getopt-file arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6797 ((equal next-param "-v")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6798 (setq next-param nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6799 (verilog-add-list-unique `verilog-library-files arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6800 ((equal next-param "-y")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6801 (setq next-param nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6802 (verilog-add-list-unique `verilog-library-directories arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6803 ;; Filename
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6804 ((string-match "^[^-+]" arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6805 (verilog-add-list-unique `verilog-library-files arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6806 ;; Default - ignore; no warning
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6807 ))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6808 ;;(verilog-getopt (list "+libext+.a+.b" "+incdir+foodir" "+define+a+aval" "-f" "otherf" "-v" "library" "-y" "dir"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6809
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6810 (defun verilog-getopt-file (filename)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6811 "Read verilog options from the specified FILENAME."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6812 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6813 (let ((fns (verilog-library-filenames filename (buffer-file-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6814 (orig-buffer (current-buffer))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6815 line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6816 (if fns
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6817 (set-buffer (find-file-noselect (car fns)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6818 (error (concat (verilog-point-text)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6819 "Can't find verilog-getopt-file -f file: " filename)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6820 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6821 (while (not (eobp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6822 (setq line (buffer-substring (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6823 (save-excursion (end-of-line) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6824 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6825 (when (string-match "//" line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6826 (setq line (substring line 0 (match-beginning 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6827 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6828 (set-buffer orig-buffer) ; Variables are buffer-local, so need right context.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6829 (verilog-getopt line))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6830
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6831 (defun verilog-getopt-flags ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6832 "Convert `verilog-library-flags' into standard library variables."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6833 ;; If the flags are local, then all the outputs should be local also
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6834 (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
6835 (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
6836 verilog-library-directories
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6837 verilog-library-files
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
6838 verilog-library-flags)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6839 ;; Allow user to customize
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6840 (run-hooks 'verilog-before-getopt-flags-hook)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6841 ;; Process arguments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6842 (verilog-getopt verilog-library-flags)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6843 ;; Allow user to customize
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6844 (run-hooks 'verilog-getopt-flags-hook))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6845
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6846 (defun verilog-add-list-unique (varref object)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6847 "Append to VARREF list the given OBJECT,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6848 unless it is already a member of the variable's list"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6849 (unless (member object (symbol-value varref))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6850 (set varref (append (symbol-value varref) (list object))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6851 varref)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6852 ;;(progn (setq l '()) (verilog-add-list-unique `l "a") (verilog-add-list-unique `l "a") l)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6853
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6854
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6855 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6856 ;; Module name lookup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6857 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6858
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6859 (defun verilog-module-inside-filename-p (module filename)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6860 "Return point if MODULE is specified inside FILENAME, else nil.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6861 Allows version control to check out the file if need be."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6862 (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
6863 (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
6864 (vc-backend filename)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6865 (let (pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6866 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6867 (set-buffer (find-file-noselect filename))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6868 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6869 (while (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6870 ;; It may be tempting to look for verilog-defun-re, don't, it slows things down a lot!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6871 (verilog-re-search-forward-quick "\\<module\\>" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6872 (verilog-re-search-forward-quick "[(;]" nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6873 (if (equal module (verilog-read-module-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6874 (setq pt (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6875 pt))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6876
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6877 (defun verilog-is-number (symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6878 "Return true if SYMBOL is number-like."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6879 (or (string-match "^[0-9 \t:]+$" symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6880 (string-match "^[---]*[0-9]+$" symbol)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6881 (string-match "^[0-9 \t]+'s?[hdxbo][0-9a-fA-F_xz? \t]*$" symbol)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6882
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6883 (defun verilog-symbol-detick (symbol wing-it)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6884 "Return a expanded SYMBOL name without any defines.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6885 If the variable vh-{symbol} is defined, return that value.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6886 If undefined, and WING-IT, return just SYMBOL without the tick, else nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6887 (while (and symbol (string-match "^`" symbol))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6888 (setq symbol (substring symbol 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6889 (setq symbol
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6890 (if (boundp (intern (concat "vh-" symbol)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6891 ;; Emacs has a bug where boundp on a buffer-local
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6892 ;; variable in only one buffer returns t in another.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6893 ;; This can confuse, so check for nil.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6894 (let ((val (eval (intern (concat "vh-" symbol)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6895 (if (eq val nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6896 (if wing-it symbol nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6897 val))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6898 (if wing-it symbol nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6899 symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6900 ;;(verilog-symbol-detick "`mod" nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6901
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6902 (defun verilog-symbol-detick-denumber (symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6903 "Return SYMBOL with defines converted and any numbers dropped to nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6904 (when (string-match "^`" symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6905 ;; This only will work if the define is a simple signal, not
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6906 ;; something like a[b]. Sorry, it should be substituted into the parser
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6907 (setq symbol
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6908 (verilog-string-replace-matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6909 "\[[^0-9: \t]+\]" "" nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6910 (or (verilog-symbol-detick symbol nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6911 (if verilog-auto-sense-defines-constant
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6912 "0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6913 symbol)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6914 (if (verilog-is-number symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6915 nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6916 symbol))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6917
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6918 (defun verilog-symbol-detick-text (text)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6919 "Return TEXT with any without any known defines.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6920 If the variable vh-{symbol} is defined, substitute that value."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6921 (let ((ok t) symbol val)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6922 (while (and ok (string-match "`\\([a-zA-Z0-9_]+\\)" text))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6923 (setq symbol (match-string 1 text))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6924 (message symbol)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6925 (cond ((and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6926 (boundp (intern (concat "vh-" symbol)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6927 ;; Emacs has a bug where boundp on a buffer-local
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6928 ;; variable in only one buffer returns t in another.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6929 ;; This can confuse, so check for nil.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6930 (setq val (eval (intern (concat "vh-" symbol)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6931 (setq text (replace-match val nil nil text)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6932 (t (setq ok nil)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6933 text)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6934 ;;(progn (setq vh-mod "`foo" vh-foo "bar") (verilog-symbol-detick-text "bar `mod `undefed"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6935
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6936 (defun verilog-expand-dirnames (&optional dirnames)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6937 "Return a list of existing directories given a list of wildcarded DIRNAMES.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6938 Or, just the existing dirnames themselves if there are no wildcards."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6939 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6940 (unless dirnames (error "`verilog-library-directories' should include at least '.'"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6941 (setq dirnames (reverse dirnames)) ; not nreverse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6942 (let ((dirlist nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6943 pattern dirfile dirfiles dirname root filename rest)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6944 (while dirnames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6945 (setq dirname (substitute-in-file-name (car dirnames))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6946 dirnames (cdr dirnames))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6947 (cond ((string-match (concat "^\\(\\|[/\\]*[^*?]*[/\\]\\)" ;; root
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6948 "\\([^/\\]*[*?][^/\\]*\\)" ;; filename with *?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6949 "\\(.*\\)") ;; rest
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6950 dirname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6951 (setq root (match-string 1 dirname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6952 filename (match-string 2 dirname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6953 rest (match-string 3 dirname)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6954 pattern filename)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6955 ;; now replace those * and ? with .+ and .
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6956 ;; use ^ and /> to get only whole file names
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6957 ;;verilog-string-replace-matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6958 (setq pattern (verilog-string-replace-matches "[*]" ".+" nil nil pattern)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6959 pattern (verilog-string-replace-matches "[?]" "." nil nil pattern)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6960
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6961 ;; Unfortunately allows abc/*/rtl to match abc/rtl
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6962 ;; because abc/.. shows up in dirfiles. Solutions welcome.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6963 dirfiles (if (file-directory-p root) ; Ignore version control external
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6964 (directory-files root t pattern nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6965 (while dirfiles
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6966 (setq dirfile (expand-file-name (concat (car dirfiles) rest))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6967 dirfiles (cdr dirfiles))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6968 (if (file-directory-p dirfile)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6969 (setq dirlist (cons dirfile dirlist)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6970 ;; Defaults
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6971 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6972 (if (file-directory-p dirname)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
6973 (setq dirlist (cons dirname dirlist))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6974 dirlist))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6975 ;;(verilog-expand-dirnames (list "." ".." "nonexist" "../*" "/home/wsnyder/*/v"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6976
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6977 (defun verilog-library-filenames (filename current &optional check-ext)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6978 "Return a search path to find the given FILENAME name.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6979 Uses the CURRENT filename, `verilog-library-directories' and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6980 `verilog-library-extensions' variables to build the path.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6981 With optional CHECK-EXT also check `verilog-library-extensions'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6982 (let ((ckdir (verilog-expand-dirnames verilog-library-directories))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6983 fn outlist)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6984 (while ckdir
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6985 (let ((ckext (if check-ext verilog-library-extensions `(""))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6986 (while ckext
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6987 (setq fn (expand-file-name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6988 (concat filename (car ckext))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6989 (expand-file-name (car ckdir) (file-name-directory current))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6990 (if (file-exists-p fn)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6991 (setq outlist (cons fn outlist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6992 (setq ckext (cdr ckext))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6993 (setq ckdir (cdr ckdir)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6994 (nreverse outlist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6995
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6996 (defun verilog-module-filenames (module current)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6997 "Return a search path to find the given MODULE name.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6998 Uses the CURRENT filename, `verilog-library-extensions',
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6999 `verilog-library-directories' and `verilog-library-files'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7000 variables to build the path."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7001 ;; Return search locations for it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7002 (append (list current) ; first, current buffer
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7003 (verilog-library-filenames module current t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7004 verilog-library-files)) ; finally, any libraries
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7005
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7006 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7007 ;; Module Information
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7008 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7009 ;; Many of these functions work on "modi" a module information structure
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7010 ;; A modi is: [module-name-string file-name begin-point]
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7011
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7012 (defvar verilog-cache-enabled t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7013 "If true, enable caching of signals, etc. Set to nil for debugging to make things SLOW!")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7014
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7015 (defvar verilog-modi-cache-list nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7016 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7017 For speeding up verilog-modi-get-* commands.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7018 Buffer-local.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7019
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
7020 (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
7021
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7022 (defvar verilog-modi-cache-preserve-tick nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7023 "Modification tick after which the cache is still considered valid.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7024 Use verilog-preserve-cache's to set")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7025 (defvar verilog-modi-cache-preserve-buffer nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7026 "Modification tick after which the cache is still considered valid.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7027 Use verilog-preserve-cache's to set")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7028
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7029 (defun verilog-modi-current ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7030 "Return the modi structure for the module currently at point."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7031 (let* (name pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7032 ;; read current module's name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7033 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7034 (verilog-re-search-backward-quick verilog-defun-re nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7035 (verilog-re-search-forward-quick "(" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7036 (setq name (verilog-read-module-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7037 (setq pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7038 ;; return
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7039 (vector name (or (buffer-file-name) (current-buffer)) pt)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7040
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7041 (defvar verilog-modi-lookup-last-mod nil "Cache of last module looked up.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7042 (defvar verilog-modi-lookup-last-modi nil "Cache of last modi returned.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7043 (defvar verilog-modi-lookup-last-current nil "Cache of last `current-buffer' looked up.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7044 (defvar verilog-modi-lookup-last-tick nil "Cache of last `buffer-modified-tick' looked up.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7045
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7046 (defun verilog-modi-lookup (module allow-cache &optional ignore-error)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7047 "Find the file and point at which MODULE is defined.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7048 If ALLOW-CACHE is set, check and remember cache of previous lookups.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7049 Return modi if successful, else print message unless IGNORE-ERROR is true."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7050 (let* ((current (or (buffer-file-name) (current-buffer))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7051 (cond ((and verilog-modi-lookup-last-modi
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7052 verilog-cache-enabled
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7053 allow-cache
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7054 (equal verilog-modi-lookup-last-mod module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7055 (equal verilog-modi-lookup-last-current current)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7056 (equal verilog-modi-lookup-last-tick (buffer-modified-tick)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7057 ;; ok as is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7058 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7059 (t (let* ((realmod (verilog-symbol-detick module t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7060 (orig-filenames (verilog-module-filenames realmod current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7061 (filenames orig-filenames)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7062 pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7063 (while (and filenames (not pt))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7064 (if (not (setq pt (verilog-module-inside-filename-p realmod (car filenames))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7065 (setq filenames (cdr filenames))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7066 (cond (pt (setq verilog-modi-lookup-last-modi
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7067 (vector realmod (car filenames) pt)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7068 (t (setq verilog-modi-lookup-last-modi nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7069 (or ignore-error
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7070 (error (concat (verilog-point-text)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7071 ": Can't locate " module " module definition"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7072 (if (not (equal module realmod))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7073 (concat " (Expanded macro to " realmod ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7074 "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7075 "\n Check the verilog-library-directories variable."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7076 "\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
7077 (mapconcat 'concat orig-filenames "\n\t"))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7078 (setq verilog-modi-lookup-last-mod module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7079 verilog-modi-lookup-last-current current
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7080 verilog-modi-lookup-last-tick (buffer-modified-tick)))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7081 verilog-modi-lookup-last-modi))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7082
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7083 (defsubst verilog-modi-name (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7084 (aref modi 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7085 (defsubst verilog-modi-file-or-buffer (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7086 (aref modi 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7087 (defsubst verilog-modi-point (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7088 (aref modi 2))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7089
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7090 (defun verilog-modi-filename (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7091 "Filename of MODI, or name of buffer if its never been saved."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7092 (if (bufferp (verilog-modi-file-or-buffer modi))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7093 (or (buffer-file-name (verilog-modi-file-or-buffer modi))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7094 (buffer-name (verilog-modi-file-or-buffer modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7095 (verilog-modi-file-or-buffer modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7096
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7097 (defun verilog-modi-goto (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7098 "Move point/buffer to specified MODI."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7099 (or modi (error "Passed unfound modi to goto, check earlier"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7100 (set-buffer (if (bufferp (verilog-modi-file-or-buffer modi))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7101 (verilog-modi-file-or-buffer modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7102 (find-file-noselect (verilog-modi-file-or-buffer modi))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7103 (or (equal major-mode `verilog-mode) ;; Put into verilog mode to get syntax
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7104 (verilog-mode))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7105 (goto-char (verilog-modi-point modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7106
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7107 (defun verilog-goto-defun-file (module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7108 "Move point to the file at which a given MODULE is defined."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7109 (interactive "sGoto File for Module: ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7110 (let* ((modi (verilog-modi-lookup module nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7111 (when modi
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7112 (verilog-modi-goto modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7113 (switch-to-buffer (current-buffer)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7114
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7115 (defun verilog-modi-cache-results (modi function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7116 "Run on MODI the given FUNCTION. Locate the module in a file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7117 Cache the output of function so next call may have faster access."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7118 (let (func-returns fass)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7119 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7120 (verilog-modi-goto modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7121 (if (and (setq fass (assoc (list (verilog-modi-name modi) function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7122 verilog-modi-cache-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7123 ;; Destroy caching when incorrect; Modified or file changed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7124 (not (and verilog-cache-enabled
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7125 (or (equal (buffer-modified-tick) (nth 1 fass))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7126 (and verilog-modi-cache-preserve-tick
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7127 (<= verilog-modi-cache-preserve-tick (nth 1 fass))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7128 (equal verilog-modi-cache-preserve-buffer (current-buffer))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7129 (equal (visited-file-modtime) (nth 2 fass)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7130 (setq verilog-modi-cache-list nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7131 fass nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7132 (cond (fass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7133 ;; Found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7134 (setq func-returns (nth 3 fass)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7135 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7136 ;; Read from file
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7137 ;; Clear then restore any hilighting to make emacs19 happy
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7138 (let ((fontlocked (when (and (boundp 'font-lock-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7139 font-lock-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7140 (font-lock-mode nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7141 t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7142 (setq func-returns (funcall function))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7143 (when fontlocked (font-lock-mode t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7144 ;; Cache for next time
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7145 (setq verilog-modi-cache-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7146 (cons (list (list (verilog-modi-name modi) function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7147 (buffer-modified-tick)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7148 (visited-file-modtime)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7149 func-returns)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7150 verilog-modi-cache-list)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7151 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7152 func-returns))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7153
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7154 (defun verilog-modi-cache-add (modi function element sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7155 "Add function return results to the module cache.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7156 Update MODI's cache for given FUNCTION so that the return ELEMENT of that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7157 function now contains the additional SIG-LIST parameters."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7158 (let (fass)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7159 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7160 (verilog-modi-goto modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7161 (if (setq fass (assoc (list (verilog-modi-name modi) function)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7162 verilog-modi-cache-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7163 (let ((func-returns (nth 3 fass)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7164 (aset func-returns element
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7165 (append sig-list (aref func-returns element))))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7166
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7167 (defmacro verilog-preserve-cache (&rest body)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7168 "Execute the BODY forms, allowing cache preservation within BODY.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7169 This means that changes to the buffer will not result in the cache being
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7170 flushed. If the changes affect the modsig state, they must call the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7171 modsig-cache-add-* function, else the results of later calls may be
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7172 incorrect. Without this, changes are assumed to be adding/removing signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7173 and invalidating the cache."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7174 `(let ((verilog-modi-cache-preserve-tick (buffer-modified-tick))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7175 (verilog-modi-cache-preserve-buffer (current-buffer)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7176 (progn ,@body)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7177
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7178
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7179 (defun verilog-signals-matching-enum (in-list enum)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7180 "Return all signals in IN-LIST matching the given ENUM."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7181 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7182 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7183 (if (equal (verilog-sig-enum (car in-list)) enum)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7184 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7185 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7186 ;; New scheme
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7187 (let* ((enumvar (intern (concat "venum-" enum)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7188 (enumlist (and (boundp enumvar) (eval enumvar))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7189 (while enumlist
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7190 (add-to-list 'out-list (list (car enumlist)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7191 (setq enumlist (cdr enumlist))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7192 (nreverse out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7193
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7194 (defun verilog-signals-not-matching-regexp (in-list regexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7195 "Return all signals in IN-LIST not matching the given REGEXP, if non-nil."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7196 (if (not regexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7197 in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7198 (let (out-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7199 (while in-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7200 (if (not (string-match regexp (verilog-sig-name (car in-list))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7201 (setq out-list (cons (car in-list) out-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7202 (setq in-list (cdr in-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7203 (nreverse out-list))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7204
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7205 ;; Combined
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7206 (defun verilog-modi-get-signals (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7207 (append
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7208 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7209 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7210 (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7211 (verilog-modi-get-wires modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7212 (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7213 (verilog-modi-get-assigns modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7214 (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7215 (verilog-modi-get-gparams modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7216
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7217 (defun verilog-modi-get-ports (modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7218 (append
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7219 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7220 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7221 (verilog-modi-get-inputs modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7222
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7223 (defsubst verilog-modi-cache-add-outputs (modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7224 (verilog-modi-cache-add modi 'verilog-read-decls 0 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7225 (defsubst verilog-modi-cache-add-inouts (modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7226 (verilog-modi-cache-add modi 'verilog-read-decls 1 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7227 (defsubst verilog-modi-cache-add-inputs (modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7228 (verilog-modi-cache-add modi 'verilog-read-decls 2 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7229 (defsubst verilog-modi-cache-add-wires (modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7230 (verilog-modi-cache-add modi 'verilog-read-decls 3 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7231 (defsubst verilog-modi-cache-add-regs (modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7232 (verilog-modi-cache-add modi 'verilog-read-decls 4 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7233
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7234 (defun verilog-signals-from-signame (signame-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7235 "Return signals in standard form from SIGNAME-LIST, a simple list of signal names."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7236 (mapcar (function (lambda (name) (list name nil nil)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7237 signame-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7238
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7239 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7240 ;; Auto creation utilities
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7241 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7242
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7243 (defun verilog-auto-search-do (search-for func)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7244 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7245 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7246 (while (search-forward search-for nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7247 (if (not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7248 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7249 (verilog-inside-comment-p)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7250 (funcall func))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7251
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7252 (defun verilog-auto-re-search-do (search-for func)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7253 "Search for the given auto text SEARCH-FOR, and perform FUNC where it occurs."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7254 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7255 (while (re-search-forward search-for nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7256 (if (not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7257 (goto-char (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7258 (verilog-inside-comment-p)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7259 (funcall func))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7260
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7261 (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
7262 "Print out a definition for SIG of the given TYPE,
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7263 with appropriate INDENT-PT indentation."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7264 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7265 (insert type)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7266 (when (verilog-sig-signed sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7267 (insert " " (verilog-sig-signed sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7268 (when (verilog-sig-multidim sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7269 (insert " " (verilog-sig-multidim-string sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7270 (when (verilog-sig-bits sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7271 (insert " " (verilog-sig-bits sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7272 (indent-to (max 24 (+ indent-pt 16)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7273 (unless (= (char-syntax (preceding-char)) ?\ )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7274 (insert " ")) ; Need space between "]name" if indent-to did nothing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7275 (insert (verilog-sig-name sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7276
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7277 (defun verilog-insert-definition (sigs direction indent-pt v2k &optional dont-sort)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7278 "Print out a definition for a list of SIGS of the given DIRECTION,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7279 with appropriate INDENT-PT indentation. If V2K, use Verilog 2001 I/O
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7280 format. Sort unless DONT-SORT. DIRECTION is normally wire/reg/output."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7281 (or dont-sort
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7282 (setq sigs (sort (copy-alist sigs) `verilog-signals-sort-compare)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7283 (while sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7284 (let ((sig (car sigs)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7285 (verilog-insert-one-definition
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7286 sig
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7287 ;; Want "type x" or "output type x", not "wire type x"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7288 (cond ((verilog-sig-type sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7289 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7290 (if (not (equal direction "wire"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7291 (concat direction " "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7292 (verilog-sig-type sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7293 (t direction))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7294 indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7295 (insert (if v2k "," ";"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7296 (if (or (not (verilog-sig-comment sig))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7297 (equal "" (verilog-sig-comment sig)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7298 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7299 (indent-to (max 48 (+ indent-pt 40)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7300 (insert (concat "// " (verilog-sig-comment sig) "\n")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7301 (setq sigs (cdr sigs)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7302
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7303 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7304 (if (not (boundp 'indent-pt))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7305 (defvar indent-pt nil "Local used by insert-indent")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7306
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7307 (defun verilog-insert-indent (&rest stuff)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7308 "Indent to position stored in local `indent-pt' variable, then insert STUFF.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7309 Presumes that any newlines end a list element."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7310 (let ((need-indent t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7311 (while stuff
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7312 (if need-indent (indent-to indent-pt))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7313 (setq need-indent nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7314 (insert (car stuff))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7315 (setq need-indent (string-match "\n$" (car stuff))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7316 stuff (cdr stuff)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7317 ;;(let ((indent-pt 10)) (verilog-insert-indent "hello\n" "addon" "there\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7318
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7319 (defun verilog-repair-open-comma ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7320 "If backwards-from-point is other than a open parenthesis insert comma."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7321 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7322 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7323 (when (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7324 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7325 (and (not (looking-at "[(,]"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7326 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7327 (verilog-re-search-backward "[(`]" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7328 (looking-at "("))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7329 (insert ","))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7330
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7331 (defun verilog-repair-close-comma ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7332 "If point is at a comma followed by a close parenthesis, fix it.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7333 This repairs those mis-inserted by a AUTOARG."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7334 ;; It would be much nicer if Verilog allowed extra commas like Perl does!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7335 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7336 (verilog-forward-close-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7337 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7338 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7339 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7340 (when (looking-at ",")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7341 (delete-char 1))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7342
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7343 (defun verilog-get-list (start end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7344 "Return the elements of a comma separated list between START and END."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7345 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7346 (let ((my-list (list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7347 my-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7348 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7349 (while (< (point) end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7350 (when (re-search-forward "\\([^,{]+\\)" end t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7351 (setq my-string (verilog-string-remove-spaces (match-string 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7352 (setq my-list (nconc my-list (list my-string) ))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7353 (goto-char (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7354 my-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7355
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7356 (defun verilog-make-width-expression (range-exp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7357 "Return an expression calculating the length of a range [x:y] in RANGE-EXP."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7358 ;; strip off the []
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7359 (cond ((not range-exp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7360 "1")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7361 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7362 (if (string-match "^\\[\\(.*\\)\\]$" range-exp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7363 (setq range-exp (match-string 1 range-exp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7364 (cond ((not range-exp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7365 "1")
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
7366 ((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
7367 range-exp)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
7368 (int-to-string
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
7369 (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
7370 (string-to-number (match-string 2 range-exp)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7371 ((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
7372 (concat "(1+(" (match-string 1 range-exp) ")"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7373 (if (equal "0" (match-string 2 range-exp))
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7374 "" ;; Don't bother with -(0)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7375 (concat "-(" (match-string 2 range-exp) ")"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7376 ")"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7377 (t nil)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7378 ;;(verilog-make-width-expression "`A:`B")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7379
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7380 (defun verilog-typedef-name-p (variable-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7381 "Return true if the VARIABLE-NAME is a type definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7382 (when verilog-typedef-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7383 (string-match verilog-typedef-regexp variable-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7384
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7385 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7386 ;; Auto deletion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7387 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7388
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7389 (defun verilog-delete-autos-lined ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7390 "Delete autos that occupy multiple lines, between begin and end comments."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7391 (let ((pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7392 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7393 (when (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7394 (looking-at "\\s-*// Beginning")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7395 (search-forward "// End of automatic" nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7396 ;; End exists
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7397 (end-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7398 (delete-region pt (point))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7399 (forward-line 1))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7400
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7401 (defun verilog-forward-close-paren ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7402 "Find the close parenthesis that match the current point,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7403 ignore other close parenthesis with matching open parens"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7404 (let ((parens 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7405 (while (> parens 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7406 (unless (verilog-re-search-forward-quick "[()]" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7407 (error "%s: Mismatching ()" (verilog-point-text)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7408 (cond ((= (preceding-char) ?\( )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7409 (setq parens (1+ parens)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7410 ((= (preceding-char) ?\) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7411 (setq parens (1- parens)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7412
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7413 (defun verilog-backward-open-paren ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7414 "Find the open parenthesis that match the current point,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7415 ignore other open parenthesis with matching close parens"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7416 (let ((parens 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7417 (while (> parens 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7418 (unless (verilog-re-search-backward-quick "[()]" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7419 (error "%s: Mismatching ()" (verilog-point-text)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7420 (cond ((= (following-char) ?\) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7421 (setq parens (1+ parens)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7422 ((= (following-char) ?\( )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7423 (setq parens (1- parens)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7424
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7425 (defun verilog-backward-open-bracket ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7426 "Find the open bracket that match the current point,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7427 ignore other open bracket with matching close bracket"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7428 (let ((parens 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7429 (while (> parens 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7430 (unless (verilog-re-search-backward-quick "[][]" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7431 (error "%s: Mismatching []" (verilog-point-text)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7432 (cond ((= (following-char) ?\] )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7433 (setq parens (1+ parens)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7434 ((= (following-char) ?\[ )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7435 (setq parens (1- parens)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7436
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7437 (defun verilog-delete-to-paren ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7438 "Delete the automatic inst/sense/arg created by autos.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7439 Deletion stops at the matching end parenthesis."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7440 (delete-region (point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7441 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7442 (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7443 (forward-sexp 1) ;; Moves to paren that closes argdecl's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7444 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7445 (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7446
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7447 (defun verilog-auto-star-safe ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7448 "Return if a .* AUTOINST is safe to delete or expand.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7449 It was created by the AUTOS themselves, or by the user."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7450 (and verilog-auto-star-expand
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7451 (looking-at "[ \t\n\f,]*\\([)]\\|// \\(Outputs\\|Inouts\\|Inputs\\)\\)")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7452
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7453 (defun verilog-delete-auto-star-all ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7454 "Delete a .* AUTOINST, if it is safe."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7455 (when (verilog-auto-star-safe)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7456 (verilog-delete-to-paren)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7457
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7458 (defun verilog-delete-auto-star-implicit ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7459 "Delete all .* implicit connections created by `verilog-auto-star'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7460 This function will be called automatically at save unless
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7461 `verilog-auto-star-save' is set, any non-templated expanded pins will be
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7462 removed."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7463 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7464 (let (paren-pt indent have-close-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7465 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7466 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7467 ;; We need to match these even outside of comments.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7468 ;; For reasonable performance, we don't check if inside comments, sorry.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7469 (while (re-search-forward "// Implicit \\.\\*" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7470 (setq paren-pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7471 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7472 (setq have-close-paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7473 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7474 (when (search-forward ");" paren-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7475 (setq indent (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7476 t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7477 (delete-region (point) (+ 1 paren-pt)) ; Nuke line incl CR
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7478 (when have-close-paren
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7479 ;; Delete extra commentary
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7480 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7481 (while (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7482 (forward-line -1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7483 (looking-at "\\s *//\\s *\\(Outputs\\|Inouts\\|Inputs\\)\n"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7484 (delete-region (match-beginning 0) (match-end 0))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7485 ;; If it is simple, we can put the ); on the same line as the last text
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7486 (let ((rtn-pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7487 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7488 (while (progn (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7489 (looking-at "[ \t\n\f]")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7490 (when (looking-at ",")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7491 (delete-region (+ 1 (point)) rtn-pt))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7492 (when (bolp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7493 (indent-to indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7494 (insert ");\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7495 ;; Still need to kill final comma - always is one as we put one after the .*
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7496 (re-search-backward ",")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7497 (delete-char 1))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7498
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7499 (defun verilog-delete-auto ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7500 "Delete the automatic outputs, regs, and wires created by \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7501 Use \\[verilog-auto] to re-insert the updated AUTOs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7502
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7503 The hooks `verilog-before-delete-auto-hook' and `verilog-delete-auto-hook' are
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7504 called before and after this function, respectively."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7505 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7506 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7507 (if (buffer-file-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7508 (find-file-noselect (buffer-file-name))) ;; To check we have latest version
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7509 ;; Allow user to customize
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7510 (run-hooks 'verilog-before-delete-auto-hook)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7511
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7512 ;; Remove those that have multi-line insertions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7513 (verilog-auto-re-search-do "/\\*AUTO\\(OUTPUTEVERY\\|CONCATCOMMENT\\|WIRE\\|REG\\|DEFINEVALUE\\|REGINPUT\\|INPUT\\|OUTPUT\\|INOUT\\|RESET\\|TIEOFF\\|UNUSED\\)\\*/"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7514 'verilog-delete-autos-lined)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7515 ;; Remove those that have multi-line insertions with parameters
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7516 (verilog-auto-re-search-do "/\\*AUTO\\(INOUTMODULE\\|ASCIIENUM\\)([^)]*)\\*/"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7517 'verilog-delete-autos-lined)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7518 ;; Remove those that are in parenthesis
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7519 (verilog-auto-re-search-do "/\\*\\(AS\\|AUTO\\(ARG\\|CONCATWIDTH\\|INST\\|INSTPARAM\\|SENSE\\)\\)\\*/"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7520 'verilog-delete-to-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7521 ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7522 (verilog-auto-re-search-do "\\.\\*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7523 'verilog-delete-auto-star-all)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7524 ;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7525 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7526 (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)[ \tLT0-9]*$" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7527 (replace-match ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7528
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7529 ;; Final customize
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7530 (run-hooks 'verilog-delete-auto-hook)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7531
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7532 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7533 ;; Auto inject
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7534 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7535
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7536 (defun verilog-inject-auto ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7537 "Examine legacy non-AUTO code and insert AUTOs in appropriate places.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7538
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7539 Any always @ blocks with sensitivity lists that match computed lists will
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7540 be replaced with /*AS*/ comments.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7541
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7542 Any cells will get /*AUTOINST*/ added to the end of the pin list. Pins with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7543 have identical names will be deleted.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7544
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7545 Argument lists will not be deleted, /*AUTOARG*/ will only be inserted to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7546 support adding new ports. You may wish to delete older ports yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7547
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7548 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7549
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7550 module ex_inject (i, o);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7551 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7552 input j;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7553 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7554 always @ (i or j)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7555 o = i | j;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7556 cell cell (.foobar(baz),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7557 .j(j));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7558 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7559
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7560 Typing \\[verilog-inject-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7561
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7562 module ex_inject (i, o/*AUTOARG*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7563 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7564 j);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7565 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7566 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7567 always @ (/*AS*/i or j)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7568 o = i | j;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7569 cell cell (.foobar(baz),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7570 /*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7571 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7572 .j(j));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7573 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7574 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7575 (verilog-auto t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7576
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7577 (defun verilog-inject-arg ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7578 "Inject AUTOARG into new code. See `verilog-inject-auto'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7579 ;; Presume one module per file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7580 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7581 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7582 (while (verilog-re-search-forward-quick "\\<module\\>" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7583 (let ((endmodp (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7584 (verilog-re-search-forward-quick "\\<endmodule\\>" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7585 (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7586 ;; See if there's already a comment .. inside a comment so not verilog-re-search
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7587 (when (not (re-search-forward "/\\*AUTOARG\\*/" endmodp t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7588 (verilog-re-search-forward-quick ";" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7589 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7590 (verilog-backward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7591 (backward-char 1) ; Moves to paren that closes argdecl's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7592 (when (looking-at ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7593 (insert "/*AUTOARG*/")))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7594
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7595 (defun verilog-inject-sense ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7596 "Inject AUTOSENSE into new code. See `verilog-inject-auto'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7597 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7598 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7599 (while (verilog-re-search-forward-quick "\\<always\\s *@\\s *(" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7600 (let ((start-pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7601 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7602 pre-sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7603 got-sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7604 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7605 (forward-sexp 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7606 (backward-char 1) ;; End )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7607 (when (not (verilog-re-search-backward "/\\*\\(AUTOSENSE\\|AS\\)\\*/" start-pt t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7608 (setq pre-sigs (verilog-signals-from-signame
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7609 (verilog-read-signals start-pt (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7610 got-sigs (verilog-auto-sense-sigs modi nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7611 (when (not (or (verilog-signals-not-in pre-sigs got-sigs) ; Both are equal?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7612 (verilog-signals-not-in got-sigs pre-sigs)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7613 (delete-region start-pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7614 (insert "/*AS*/")))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7615
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7616 (defun verilog-inject-inst ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7617 "Inject AUTOINST into new code. See `verilog-inject-auto'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7618 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7619 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7620 ;; It's hard to distinguish modules; we'll instead search for pins.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7621 (while (verilog-re-search-forward-quick "\\.\\s *[a-zA-Z0-9`_\$]+\\s *(\\s *[a-zA-Z0-9`_\$]+\\s *)" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7622 (verilog-backward-open-paren) ;; Inst start
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7623 (cond
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7624 ((= (preceding-char) ?\#) ;; #(...) parameter section, not pin. Skip.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7625 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7626 (verilog-forward-close-paren)) ;; Parameters done
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7627 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7628 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7629 (let ((indent-pt (+ (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7630 (end-pt (save-excursion (verilog-forward-close-paren) (point))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7631 (cond ((verilog-re-search-forward "\\(/\\*AUTOINST\\*/\\|\\.\\*\\)" end-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7632 (goto-char end-pt)) ;; Already there, continue search with next instance
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7633 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7634 ;; Delete identical interconnect
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7635 (let ((case-fold-search nil)) ;; So we don't convert upper-to-lower, etc
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7636 (while (verilog-re-search-forward "\\.\\s *\\([a-zA-Z0-9`_\$]+\\)*\\s *(\\s *\\1\\s *)\\s *" end-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7637 (delete-region (match-beginning 0) (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7638 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))) ;; Keep it correct
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7639 (while (or (looking-at "[ \t\n\f,]+")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7640 (looking-at "//[^\n]*"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7641 (delete-region (match-beginning 0) (match-end 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7642 (setq end-pt (- end-pt (- (match-end 0) (match-beginning 0)))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7643 (verilog-forward-close-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7644 (backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7645 ;; Not verilog-re-search, as we don't want to strip comments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7646 (while (re-search-backward "[ \t\n\f]+" (- (point) 1) t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7647 (delete-region (match-beginning 0) (match-end 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7648 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7649 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7650 (insert "/*AUTOINST*/")))))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7651
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7652 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7653 ;; Auto save
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7654 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7655
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7656 (defun verilog-auto-save-check ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7657 "On saving see if we need auto update."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7658 (cond ((not verilog-auto-save-policy)) ; disabled
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7659 ((not (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7660 (save-match-data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7661 (let ((case-fold-search nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7662 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7663 (re-search-forward "AUTO" nil t))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7664 ((eq verilog-auto-save-policy 'force)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7665 (verilog-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7666 ((not (buffer-modified-p)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7667 ((eq verilog-auto-update-tick (buffer-modified-tick))) ; up-to-date
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7668 ((eq verilog-auto-save-policy 'detect)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7669 (verilog-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7670 (t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7671 (when (yes-or-no-p "AUTO statements not recomputed, do it now? ")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7672 (verilog-auto))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7673 ;; Don't ask again if didn't update
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7674 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7675 (when (not verilog-auto-star-save)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7676 (verilog-delete-auto-star-implicit))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7677 nil) ;; Always return nil -- we don't write the file ourselves
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7678
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7679 (defun verilog-auto-read-locals ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7680 "Return file local variable segment at bottom of file."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7681 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7682 (goto-char (point-max))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7683 (if (re-search-backward "Local Variables:" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7684 (buffer-substring-no-properties (point) (point-max))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7685 "")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7686
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7687 (defun verilog-auto-reeval-locals (&optional force)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7688 "Read file local variable segment at bottom of file if it has changed.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7689 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
7690 (make-local-variable 'verilog-auto-last-file-locals)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7691 (let ((curlocal (verilog-auto-read-locals)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7692 (when (or force (not (equal verilog-auto-last-file-locals curlocal)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7693 (setq verilog-auto-last-file-locals curlocal)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7694 ;; Note this may cause this function to be recursively invoked.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7695 ;; The above when statement will prevent it from recursing forever.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7696 (hack-local-variables)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7697 t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7698
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7699 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7700 ;; Auto creation
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7701 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7702
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7703 (defun verilog-auto-arg-ports (sigs message indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7704 "Print a list of ports for a AUTOINST.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7705 Takes SIGS list, adds MESSAGE to front and inserts each at INDENT-PT."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7706 (when sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7707 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7708 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7709 (insert message)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7710 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7711 (let ((space ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7712 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7713 (while sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7714 (cond ((> (+ 2 (current-column) (length (verilog-sig-name (car sigs)))) fill-column)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7715 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7716 (indent-to indent-pt))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7717 (t (insert space)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7718 (insert (verilog-sig-name (car sigs)) ",")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7719 (setq sigs (cdr sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7720 space " ")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7721
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7722 (defun verilog-auto-arg ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7723 "Expand AUTOARG statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7724 Replace the argument declarations at the beginning of the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7725 module with ones automatically derived from input and output
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7726 statements. This can be dangerous if the module is instantiated
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7727 using position-based connections, so use only name-based when
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7728 instantiating the resulting module. Long lines are split based
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7729 on the `fill-column', see \\[set-fill-column].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7730
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7731 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7732 Concatenation and outputting partial busses is not supported.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7733
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7734 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7735
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7736 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7737
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7738 module ex_arg (/*AUTOARG*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7739 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7740 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7741 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7742
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7743 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7744
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7745 module ex_arg (/*AUTOARG*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7746 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7747 o,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7748 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7749 i
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7750 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7751 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7752 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7753 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7754
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7755 Any ports declared between the ( and /*AUTOARG*/ are presumed to be
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7756 predeclared and are not redeclared by AUTOARG. AUTOARG will make a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7757 conservative guess on adding a comma for the first signal, if you have any
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7758 ifdefs or complicated expressions before the AUTOARG you will need to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7759 choose the comma yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7760
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7761 Avoid declaring ports manually, as it makes code harder to maintain."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7762 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7763 (let ((modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7764 (skip-pins (aref (verilog-read-arg-pins) 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7765 (verilog-repair-open-comma)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7766 (verilog-auto-arg-ports (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7767 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7768 skip-pins)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7769 "// Outputs"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7770 verilog-indent-level-declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7771 (verilog-auto-arg-ports (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7772 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7773 skip-pins)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7774 "// Inouts"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7775 verilog-indent-level-declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7776 (verilog-auto-arg-ports (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7777 (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7778 skip-pins)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7779 "// Inputs"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7780 verilog-indent-level-declaration)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7781 (verilog-repair-close-comma)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7782 (unless (eq (char-before) ?/ )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7783 (insert "\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7784 (indent-to verilog-indent-level-declaration))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7785
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7786 (defun verilog-auto-inst-port-map (port-st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7787 nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7788
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7789 (defvar vl-cell-type nil "See `verilog-auto-inst'.") ; Prevent compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7790 (defvar vl-cell-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7791 (defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7792 (defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7793 (defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7794
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7795 (defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7796 "Print out a instantiation connection for this PORT-ST.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7797 Insert to INDENT-PT, use template TPL-LIST.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7798 @ are instantiation numbers, replaced with TPL-NUM.
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7799 @\"(expression @)\" are evaluated, with @ as a variable.
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
7800 If FOR-STAR add comment it is a .* expansion."
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7801 (let* ((port (verilog-sig-name port-st))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7802 (tpl-ass (or (assoc port (car tpl-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7803 (verilog-auto-inst-port-map port-st)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7804 ;; vl-* are documented for user use
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7805 (vl-name (verilog-sig-name port-st))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7806 (vl-width (verilog-sig-width port-st))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7807 (vl-bits (if (or verilog-auto-inst-vector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7808 (not (assoc port vector-skip-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7809 (not (equal (verilog-sig-bits port-st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7810 (verilog-sig-bits (assoc port vector-skip-list)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7811 (or (verilog-sig-bits port-st) "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7812 ""))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7813 ;; Default if not found
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7814 (tpl-net (if (verilog-sig-multidim port-st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7815 (concat port "/*" (verilog-sig-multidim-string port-st)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7816 vl-bits "*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7817 (concat port vl-bits)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7818 (case-fold-search nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7819 ;; Find template
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7820 (cond (tpl-ass ; Template of exact port name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7821 (setq tpl-net (nth 1 tpl-ass)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7822 ((nth 1 tpl-list) ; Wildcards in template, search them
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7823 (let ((wildcards (nth 1 tpl-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7824 (while wildcards
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7825 (when (string-match (nth 0 (car wildcards)) port)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7826 (setq tpl-ass (car wildcards) ; so allow @ parsing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7827 tpl-net (replace-match (nth 1 (car wildcards))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7828 t nil port)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7829 (setq wildcards (cdr wildcards))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7830 ;; Parse Templated variable
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7831 (when tpl-ass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7832 ;; Evaluate @"(lispcode)"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7833 (when (string-match "@\".*[^\\]\"" tpl-net)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7834 (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7835 (setq tpl-net
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7836 (concat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7837 (substring tpl-net 0 (match-beginning 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7838 (save-match-data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7839 (let* ((expr (match-string 1 tpl-net))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7840 (value
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7841 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7842 (setq expr (verilog-string-replace-matches "\\\\\"" "\"" nil nil expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7843 (setq expr (verilog-string-replace-matches "@" tpl-num nil nil expr))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7844 (prin1 (eval (car (read-from-string expr)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7845 (lambda (ch) ())))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7846 (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
7847 value))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7848 (substring tpl-net (match-end 0))))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7849 ;; Replace @ and [] magic variables in final output
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7850 (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
7851 (setq tpl-net (verilog-string-replace-matches "\\[\\]" vl-bits nil nil tpl-net)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7852 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7853 (insert "." port)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7854 (indent-to verilog-auto-inst-column)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7855 (insert "(" tpl-net "),")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7856 (cond (tpl-ass
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7857 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7858 verilog-auto-inst-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7859 (insert " // Templated")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7860 (when verilog-auto-inst-template-numbers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7861 (insert " T" (int-to-string (nth 2 tpl-ass))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7862 " L" (int-to-string (nth 3 tpl-ass)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7863 (for-star
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7864 (indent-to (+ (if (< verilog-auto-inst-column 48) 24 16)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7865 verilog-auto-inst-column))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7866 (insert " // Implicit .\*"))) ;For some reason the . or * must be escaped...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7867 (insert "\n")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7868 ;;(verilog-auto-inst-port (list "foo" "[5:0]") 10 (list (list "foo" "a@\"(% (+ @ 1) 4)\"a")) "3")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7869 ;;(x "incom[@\"(+ (* 8 @) 7)\":@\"(* 8 @)\"]")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7870 ;;(x ".out (outgo[@\"(concat (+ (* 8 @) 7) \\\":\\\" ( * 8 @))\"]));")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7871
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7872 (defun verilog-auto-inst-first ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7873 "Insert , etc before first ever port in this instant, as part of \\[verilog-auto-inst]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7874 ;; Do we need a trailing comma?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7875 ;; There maybe a ifdef or something similar before us. What a mess. Thus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7876 ;; to avoid trouble we only insert on preceeding ) or *.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7877 ;; Insert first port on new line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7878 (insert "\n") ;; Must insert before search, so point will move forward if insert comma
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7879 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7880 (verilog-re-search-backward "[^ \t\n\f]" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7881 (when (looking-at ")\\|\\*") ;; Generally don't insert, unless we are fairly sure
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7882 (forward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7883 (insert ","))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7884
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7885 (defun verilog-auto-star ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7886 "Expand SystemVerilog .* pins, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7887
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7888 If `verilog-auto-star-expand' is set, .* pins are treated if they were
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7889 AUTOINST statements, otherwise they are ignored. For safety, Verilog-Mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7890 will also ignore any .* that are not last in your pin list (this prevents
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7891 it from deleting pins following the .* when it expands the AUTOINST.)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7892
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7893 On writing your file, unless `verilog-auto-star-save' is set, any
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7894 non-templated expanded pins will be removed. You may do this at any time
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7895 with \\[verilog-delete-auto-star-implicit].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7896
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7897 If you are converting a module to use .* for the first time, you may wish
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7898 to use \\[verilog-inject-auto] and then replace the created AUTOINST with .*.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7899
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7900 See `verilog-auto-inst' for examples, templates, and more information."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7901 (when (verilog-auto-star-safe)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7902 (verilog-auto-inst)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7903
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7904 (defun verilog-auto-inst ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7905 "Expand AUTOINST statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7906 Replace the pin connections to an instantiation with ones
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7907 automatically derived from the module header of the instantiated netlist.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7908
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7909 If `verilog-auto-star-expand' is set, also expand SystemVerilog .* ports,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7910 and delete them before saving unless `verilog-auto-star-save' is set.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7911 See `verilog-auto-star' for more information.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7912
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7913 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7914 Module names must be resolvable to filenames by adding a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7915 `verilog-library-extensions', and being found in the same directory, or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7916 by changing the variable `verilog-library-flags' or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7917 `verilog-library-directories'. Macros `modname are translated through the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7918 vh-{name} Emacs variable, if that is not found, it just ignores the `.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7919
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7920 In templates you must have one signal per line, ending in a ), or ));,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7921 and have proper () nesting, including a final ); to end the template.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7922
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7923 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7924
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7925 SystemVerilog multidimmensional input/output has only experimental support.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7926
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7927 For example, first take the submodule inst.v:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7928
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7929 module inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7930 output [31:0] o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7931 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7932 wire [31:0] o = {32{i}};
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7933 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7934
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7935 This is then used in a upper level module:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7936
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7937 module ex_inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7938 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7939 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7940 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7941 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7942
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7943 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7944
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7945 module ex_inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7946 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7947 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7948 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7949 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7950 .ov (ov[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7951 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7952 .i (i));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7953 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7954
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7955 Where the list of inputs and outputs came from the inst module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7956
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7957 Exceptions:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7958
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7959 Unless you are instantiating a module multiple times, or the module is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7960 something trivial like a adder, DO NOT CHANGE SIGNAL NAMES ACROSS HIERARCHY.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7961 It just makes for unmaintainable code. To sanitize signal names, try
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7962 vrename from http://www.veripool.com
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7963
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7964 When you need to violate this suggestion there are two ways to list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7965 exceptions, placing them before the AUTOINST, or using templates.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7966
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7967 Any ports defined before the /*AUTOINST*/ are not included in the list of
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7968 automatics. This is similar to making a template as described below, but
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7969 is restricted to simple connections just like you normally make. Also note
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7970 that any signals before the AUTOINST will only be picked up by AUTOWIRE if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7971 you have the appropriate // Input or // Output comment, and exactly the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7972 same line formatting as AUTOINST itself uses.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7973
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7974 inst inst (// Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7975 .i (my_i_dont_mess_with_it),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7976 /*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7977 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7978 .ov (ov[31:0]));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7979
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7980
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7981 Templates:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7982
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7983 For multiple instantiations based upon a single template, create a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7984 commented out template:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7985
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7986 /* instantiating_module_name AUTO_TEMPLATE (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7987 .sig3 (sigz[]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7988 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7989 */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7990
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7991 Templates go ABOVE the instantiation(s). When a instantiation is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7992 expanded `verilog-mode' simply searches up for the closest template.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7993 Thus you can have multiple templates for the same module, just alternate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7994 between the template for a instantiation and the instantiation itself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7995
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7996 The module name must be the same as the name of the module in the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7997 instantiation name, and the code \"AUTO_TEMPLATE\" must be in these exact
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7998 words and capitalized. Only signals that must be different for each
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7999 instantiation need to be listed.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8000
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8001 Inside a template, a [] in a connection name (with nothing else inside
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8002 the brackets) will be replaced by the same bus subscript as it is being
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8003 connected to, or the [] will be removed if it is a single bit signal.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8004 Generally it is a good idea to do this for all connections in a template,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8005 as then they will work for any width signal, and with AUTOWIRE. See
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8006 PTL_BUS becoming PTL_BUSNEW below.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8007
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8008 If you have a complicated template, set `verilog-auto-inst-template-numbers'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8009 to see which regexps are matching. Don't leave that mode set after
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8010 debugging is completed though, it will result in lots of extra differences
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8011 and merge conflicts.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8012
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8013 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8014
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8015 /* psm_mas AUTO_TEMPLATE (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8016 .ptl_bus (ptl_busnew[]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8017 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8018 */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8019 psm_mas ms2m (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8020
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8021 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8022
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8023 psm_mas ms2m (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8024 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8025 .NotInTemplate (NotInTemplate),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8026 .ptl_bus (ptl_busnew[3:0]), // Templated
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8027 ....
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8028
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8029 @ Templates:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8030
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8031 It is common to instantiate a cell multiple times, so templates make it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8032 trivial to substitute part of the cell name into the connection name.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8033
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8034 /* cell_type AUTO_TEMPLATE <optional \"REGEXP\"> (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8035 .sig1 (sigx[@]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8036 .sig2 (sigy[@\"(% (+ 1 @) 4)\"]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8037 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8038 */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8039
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8040 If no regular expression is provided immediately after the AUTO_TEMPLATE
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8041 keyword, then the @ character in any connection names will be replaced
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8042 with the instantiation number; the first digits found in the cell's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8043 instantiation name.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8044
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8045 If a regular expression is provided, the @ character will be replaced
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8046 with the first \(\) grouping that matches against the cell name. Using a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8047 regexp of \"\\([0-9]+\\)\" provides identical values for @ as when no
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8048 regexp is provided. If you use multiple layers of parenthesis,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8049 \"test\\([^0-9]+\\)_\\([0-9]+\\)\" would replace @ with non-number
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8050 characters after test and before _, whereas
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8051 \"\\(test\\([a-z]+\\)_\\([0-9]+\\)\\)\" would replace @ with the entire
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8052 match.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8053
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8054 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8055
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8056 /* psm_mas AUTO_TEMPLATE (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8057 .ptl_mapvalidx (ptl_mapvalid[@]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8058 .ptl_mapvalidp1x (ptl_mapvalid[@\"(% (+ 1 @) 4)\"]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8059 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8060 */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8061 psm_mas ms2m (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8062
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8063 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8064
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8065 psm_mas ms2m (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8066 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8067 .ptl_mapvalidx (ptl_mapvalid[2]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8068 .ptl_mapvalidp1x (ptl_mapvalid[3]));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8069
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8070 Note the @ character was replaced with the 2 from \"ms2m\".
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8071
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8072 Alternatively, using a regular expression for @:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8073
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8074 /* psm_mas AUTO_TEMPLATE \"_\\([a-z]+\\)\" (
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8075 .ptl_mapvalidx (@_ptl_mapvalid),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8076 .ptl_mapvalidp1x (ptl_mapvalid_@),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8077 );
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8078 */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8079 psm_mas ms2_FOO (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8080 psm_mas ms2_BAR (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8081
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8082 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8083
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8084 psm_mas ms2_FOO (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8085 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8086 .ptl_mapvalidx (FOO_ptl_mapvalid),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8087 .ptl_mapvalidp1x (ptl_mapvalid_FOO));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8088 psm_mas ms2_BAR (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8089 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8090 .ptl_mapvalidx (BAR_ptl_mapvalid),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8091 .ptl_mapvalidp1x (ptl_mapvalid_BAR));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8092
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8093
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8094 Regexp Templates:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8095
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8096 A template entry of the form
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8097
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8098 .pci_req\\([0-9]+\\)_l (pci_req_jtag_[\\1]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8099
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8100 will apply a Emacs style regular expression search for any port beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8101 in pci_req followed by numbers and ending in _l and connecting that to
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8102 the pci_req_jtag_[] net, with the bus subscript coming from what matches
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8103 inside the first set of \\( \\). Thus pci_req2_l becomes pci_req_jtag_[2].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8104
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8105 Since \\([0-9]+\\) is so common and ugly to read, a @ in the port name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8106 does the same thing. (Note a @ in the connection/replacement text is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8107 completely different -- still use \\1 there!) Thus this is the same as
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8108 the above template:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8109
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8110 .pci_req@_l (pci_req_jtag_[\\1]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8111
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8112 Here's another example to remove the _l, useful when naming conventions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8113 specify _ alone to mean active low. Note the use of [] to keep the bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8114 subscript:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8115
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8116 .\\(.*\\)_l (\\1_[]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8117
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8118 Lisp Templates:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8119
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8120 First any regular expression template is expanded.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8121
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8122 If the syntax @\"( ... )\" is found in a connection, the expression in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8123 quotes will be evaluated as a Lisp expression, with @ replaced by the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8124 instantiation number. The MAPVALIDP1X example above would put @+1 modulo
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8125 4 into the brackets. Quote all double-quotes inside the expression with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8126 a leading backslash (\\\"). There are special variables defined that are
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8127 useful in these Lisp functions:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8128
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8129 vl-name Name portion of the input/output port
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8130 vl-bits Bus bits portion of the input/output port ('[2:0]')
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8131 vl-width Width of the input/output port ('3' for [2:0])
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8132 May be a (...) expression if bits isn't a constant.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8133 vl-dir Direction of the pin input/output/inout.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8134 vl-cell-type Module name/type of the cell ('psm_mas')
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8135 vl-cell-name Instance name of the cell ('ms2m')
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8136
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8137 Normal Lisp variables may be used in expressions. See
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8138 `verilog-read-defines' which can set vh-{definename} variables for use
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8139 here. Also, any comments of the form:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8140
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8141 /*AUTO_LISP(setq foo 1)*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8142
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8143 will evaluate any Lisp expression inside the parenthesis between the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8144 beginning of the buffer and the point of the AUTOINST. This allows
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8145 functions to be defined or variables to be changed between instantiations.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8146
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8147 Note that when using lisp expressions errors may occur when @ is not a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8148 number, you may need to use the standard Emacs Lisp functions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8149 `number-to-string' and `string-to-number'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8150
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8151 After the evaluation is completed, @ substitution and [] substitution
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8152 occur."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8153 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8154 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8155 (let* ((pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8156 (for-star (save-excursion (backward-char 2) (looking-at "\\.\\*")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8157 (indent-pt (save-excursion (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8158 (1+ (current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8159 (verilog-auto-inst-column (max verilog-auto-inst-column
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8160 (+ 16 (* 8 (/ (+ indent-pt 7) 8)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8161 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8162 (vector-skip-list (unless verilog-auto-inst-vector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8163 (verilog-modi-get-signals modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8164 submod submodi inst skip-pins tpl-list tpl-num did-first)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8165 ;; Find module name that is instantiated
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8166 (setq submod (verilog-read-inst-module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8167 inst (verilog-read-inst-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8168 vl-cell-type submod
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8169 vl-cell-name inst
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8170 skip-pins (aref (verilog-read-inst-pins) 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8171
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8172 ;; Parse any AUTO_LISP() before here
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8173 (verilog-read-auto-lisp (point-min) pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8174
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8175 ;; Lookup position, etc of submodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8176 ;; Note this may raise an error
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8177 (when (setq submodi (verilog-modi-lookup submod t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8178 ;; If there's a number in the instantiation, it may be a argument to the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8179 ;; automatic variable instantiation program.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8180 (let* ((tpl-info (verilog-read-auto-template submod))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8181 (tpl-regexp (aref tpl-info 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8182 (setq tpl-num (if (string-match tpl-regexp inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8183 (match-string 1 inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8184 "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8185 tpl-list (aref tpl-info 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8186 ;; Find submodule's signals and dump
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8187 (let ((sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8188 (verilog-modi-get-outputs submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8189 skip-pins))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8190 (vl-dir "output"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8191 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8192 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8193 (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
8194 ;; 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
8195 (insert "// Outputs\n")
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8196 (mapc (lambda (port)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8197 (verilog-auto-inst-port port indent-pt
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8198 tpl-list tpl-num for-star))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8199 sig-list)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8200 (let ((sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8201 (verilog-modi-get-inouts submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8202 skip-pins))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8203 (vl-dir "inout"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8204 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8205 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8206 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8207 (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
8208 (mapc (lambda (port)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8209 (verilog-auto-inst-port port indent-pt
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8210 tpl-list tpl-num for-star))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8211 sig-list)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8212 (let ((sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8213 (verilog-modi-get-inputs submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8214 skip-pins))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8215 (vl-dir "input"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8216 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8217 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8218 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8219 (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
8220 (mapc (lambda (port)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8221 (verilog-auto-inst-port port indent-pt
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8222 tpl-list tpl-num for-star))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8223 sig-list)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8224 ;; Kill extra semi
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8225 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8226 (cond (did-first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8227 (re-search-backward "," pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8228 (delete-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8229 (insert ");")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8230 (search-forward "\n") ;; Added by inst-port
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8231 (delete-backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8232 (if (search-forward ")" nil t) ;; From user, moved up a line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8233 (delete-backward-char 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8234 (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
8235 (delete-backward-char 1)))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8236
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8237 (defun verilog-auto-inst-param ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8238 "Expand AUTOINSTPARAM statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8239 Replace the parameter connections to an instantiation with ones
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8240 automatically derived from the module header of the instantiated netlist.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8241
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8242 See \\[verilog-auto-inst] for limitations, and templates to customize the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8243 output.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8244
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8245 For example, first take the submodule inst.v:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8246
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8247 module inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8248 parameter PAR;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8249 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8250
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8251 This is then used in a upper level module:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8252
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8253 module ex_inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8254 parameter PAR;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8255 inst #(/*AUTOINSTPARAM*/)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8256 inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8257 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8258
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8259 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8260
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8261 module ex_inst (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8262 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8263 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8264 inst (/*AUTOINSTPARAM*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8265 // Parameters
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8266 .PAR (PAR));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8267 inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8268 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8269
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8270 Where the list of parameter connections come from the inst module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8271
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8272 Templates:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8273
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8274 You can customize the parameter connections using AUTO_TEMPLATEs,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8275 just as you would with \\[verilog-auto-inst]."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8276 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8277 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8278 (let* ((pt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8279 (indent-pt (save-excursion (verilog-backward-open-paren)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8280 (1+ (current-column))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8281 (verilog-auto-inst-column (max verilog-auto-inst-column
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8282 (+ 16 (* 8 (/ (+ indent-pt 7) 8)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8283 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8284 (vector-skip-list (unless verilog-auto-inst-vector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8285 (verilog-modi-get-signals modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8286 submod submodi inst skip-pins tpl-list tpl-num did-first)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8287 ;; Find module name that is instantiated
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8288 (setq submod (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8289 ;; Get to the point where AUTOINST normally is to read the module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8290 (verilog-re-search-forward-quick "[(;]" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8291 (verilog-read-inst-module))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8292 inst (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8293 ;; Get to the point where AUTOINST normally is to read the module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8294 (verilog-re-search-forward-quick "[(;]" nil nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8295 (verilog-read-inst-name))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8296 vl-cell-type submod
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8297 vl-cell-name inst
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8298 skip-pins (aref (verilog-read-inst-pins) 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8299
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8300 ;; Parse any AUTO_LISP() before here
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8301 (verilog-read-auto-lisp (point-min) pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8302
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8303 ;; Lookup position, etc of submodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8304 ;; Note this may raise an error
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8305 (when (setq submodi (verilog-modi-lookup submod t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8306 ;; If there's a number in the instantiation, it may be a argument to the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8307 ;; automatic variable instantiation program.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8308 (let* ((tpl-info (verilog-read-auto-template submod))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8309 (tpl-regexp (aref tpl-info 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8310 (setq tpl-num (if (string-match tpl-regexp inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8311 (match-string 1 inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8312 "")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8313 tpl-list (aref tpl-info 1)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8314 ;; Find submodule's signals and dump
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8315 (let ((sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8316 (verilog-modi-get-gparams submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8317 skip-pins))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8318 (vl-dir "parameter"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8319 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8320 (when (not did-first) (verilog-auto-inst-first) (setq did-first t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8321 (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
8322 ;; 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
8323 (insert "// Parameters\n")
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8324 (mapc (lambda (port)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8325 (verilog-auto-inst-port port indent-pt
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8326 tpl-list tpl-num nil))
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
8327 sig-list)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8328 ;; Kill extra semi
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8329 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8330 (cond (did-first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8331 (re-search-backward "," pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8332 (delete-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8333 (insert ")")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8334 (search-forward "\n") ;; Added by inst-port
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8335 (delete-backward-char 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8336 (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
8337 (delete-backward-char 1)))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8338
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8339 (defun verilog-auto-reg ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8340 "Expand AUTOREG statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8341 Make reg statements for any output that isn't already declared,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8342 and isn't a wire output from a block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8343
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8344 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8345 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8346
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8347 This does NOT work on memories, declare those yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8348
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8349 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8350
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8351 module ex_reg (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8352 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8353 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8354 /*AUTOREG*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8355 always o = i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8356 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8357
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8358 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8359
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8360 module ex_reg (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8361 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8362 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8363 /*AUTOREG*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8364 // Beginning of automatic regs (for this module's undeclared outputs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8365 reg o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8366 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8367 always o = i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8368 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8369 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8370 ;; Point must be at insertion point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8371 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8372 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8373 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8374 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8375 (append (verilog-modi-get-wires modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8376 (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8377 (verilog-modi-get-assigns modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8378 (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8379 (verilog-modi-get-gparams modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8380 (verilog-modi-get-sub-outputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8381 (verilog-modi-get-sub-inouts modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8382 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8383 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8384 (verilog-insert-indent "// Beginning of automatic regs (for this module's undeclared outputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8385 (verilog-insert-definition sig-list "reg" indent-pt nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8386 (verilog-modi-cache-add-regs modi sig-list)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8387 (verilog-insert-indent "// End of automatics\n")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8388
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8389 (defun verilog-auto-reg-input ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8390 "Expand AUTOREGINPUT statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8391 Make reg statements instantiation inputs that aren't already declared.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8392 This is useful for making a top level shell for testing the module that is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8393 to be instantiated.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8394
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8395 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8396 This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8397
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8398 This does NOT work on memories, declare those yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8399
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8400 An example (see `verilog-auto-inst' for what else is going on here):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8401
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8402 module ex_reg_input (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8403 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8404 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8405 /*AUTOREGINPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8406 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8407 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8408
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8409 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8410
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8411 module ex_reg_input (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8412 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8413 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8414 /*AUTOREGINPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8415 // Beginning of automatic reg inputs (for undeclared ...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8416 reg [31:0] iv; // From inst of inst.v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8417 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8418 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8419 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8420 .o (o[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8421 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8422 .iv (iv));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8423 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8424 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8425 ;; Point must be at insertion point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8426 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8427 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8428 (sig-list (verilog-signals-combine-bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8429 (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8430 (append (verilog-modi-get-sub-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8431 (verilog-modi-get-sub-inouts modi))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8432 (verilog-modi-get-signals modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8433 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8434 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8435 (verilog-insert-indent "// Beginning of automatic reg inputs (for undeclared instantiated-module inputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8436 (verilog-insert-definition sig-list "reg" indent-pt nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8437 (verilog-modi-cache-add-regs modi sig-list)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8438 (verilog-insert-indent "// End of automatics\n")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8439
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8440 (defun verilog-auto-wire ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8441 "Expand AUTOWIRE statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8442 Make wire statements for instantiations outputs that aren't
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8443 already declared.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8444
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8445 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8446 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls'),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8447 and all busses must have widths, such as those from AUTOINST, or using []
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8448 in AUTO_TEMPLATEs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8449
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8450 This does NOT work on memories or SystemVerilog .name connections,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8451 declare those yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8452
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8453 Verilog-mode will add \"Couldn't Merge\" comments to signals it cannot
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8454 determine how to bus together. This occurs when you have ports with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8455 non-numeric or non-sequential bus subscripts. If Verilog-Mode
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8456 mis-guessed, you'll have to declare them yourself.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8457
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8458 An example (see `verilog-auto-inst' for what else is going on here):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8459
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8460 module ex_wire (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8461 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8462 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8463 /*AUTOWIRE*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8464 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8465 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8466
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8467 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8468
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8469 module ex_wire (o,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8470 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8471 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8472 /*AUTOWIRE*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8473 // Beginning of automatic wires
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8474 wire [31:0] ov; // From inst of inst.v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8475 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8476 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8477 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8478 .ov (ov[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8479 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8480 .i (i));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8481 wire o = | ov;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8482 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8483 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8484 ;; Point must be at insertion point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8485 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8486 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8487 (sig-list (verilog-signals-combine-bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8488 (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8489 (append (verilog-modi-get-sub-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8490 (verilog-modi-get-sub-inouts modi))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8491 (verilog-modi-get-signals modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8492 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8493 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8494 (verilog-insert-indent "// Beginning of automatic wires (for undeclared instantiated-module outputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8495 (verilog-insert-definition sig-list "wire" indent-pt nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8496 (verilog-modi-cache-add-wires modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8497 (verilog-insert-indent "// End of automatics\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8498 (when nil ;; Too slow on huge modules, plus makes everyone's module change
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8499 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8500 (setq pnt (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8501 (verilog-pretty-declarations)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8502 (goto-char pnt)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8503 (verilog-pretty-expr "//"))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8504
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8505 (defun verilog-auto-output ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8506 "Expand AUTOOUTPUT statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8507 Make output statements for any output signal from an /*AUTOINST*/ that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8508 isn't a input to another AUTOINST. This is useful for modules which
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8509 only instantiate other modules.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8510
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8511 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8512 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8513
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8514 If placed inside the parenthesis of a module declaration, it creates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8515 Verilog 2001 style, else uses Verilog 1995 style.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8516
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8517 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8518 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8519
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8520 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8521
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8522 Signals matching `verilog-auto-output-ignore-regexp' are not included.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8523
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8524 An example (see `verilog-auto-inst' for what else is going on here):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8525
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8526 module ex_output (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8527 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8528 /*AUTOOUTPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8529 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8530 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8531
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8532 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8533
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8534 module ex_output (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8535 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8536 /*AUTOOUTPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8537 // Beginning of automatic outputs (from unused autoinst outputs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8538 output [31:0] ov; // From inst of inst.v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8539 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8540 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8541 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8542 .ov (ov[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8543 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8544 .i (i));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8545 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8546 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8547 ;; Point must be at insertion point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8548 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8549 (v2k (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8550 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8551 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8552 (verilog-modi-get-sub-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8553 (append (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8554 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8555 (verilog-modi-get-sub-inputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8556 (verilog-modi-get-sub-inouts modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8557 (setq sig-list (verilog-signals-not-matching-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8558 sig-list verilog-auto-output-ignore-regexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8559 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8560 (when v2k (verilog-repair-open-comma))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8561 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8562 (verilog-insert-indent "// Beginning of automatic outputs (from unused autoinst outputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8563 (verilog-insert-definition sig-list "output" indent-pt v2k)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8564 (verilog-modi-cache-add-outputs modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8565 (verilog-insert-indent "// End of automatics\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8566 (when v2k (verilog-repair-close-comma)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8567
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8568 (defun verilog-auto-output-every ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8569 "Expand AUTOOUTPUTEVERY statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8570 Make output statements for any signals that aren't primary inputs or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8571 outputs already. This makes every signal in the design a output. This is
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8572 useful to get Synopsys to preserve every signal in the design, since it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8573 won't optimize away the outputs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8574
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8575 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8576
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8577 module ex_output_every (o,i,tempa,tempb)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8578 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8579 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8580 /*AUTOOUTPUTEVERY*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8581 wire tempa = i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8582 wire tempb = tempa;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8583 wire o = tempb;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8584 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8585
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8586 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8587
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8588 module ex_output_every (o,i,tempa,tempb)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8589 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8590 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8591 /*AUTOOUTPUTEVERY*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8592 // Beginning of automatic outputs (every signal)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8593 output tempb;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8594 output tempa;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8595 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8596 wire tempa = i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8597 wire tempb = tempa;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8598 wire o = tempb;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8599 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8600 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8601 ;;Point must be at insertion point
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8602 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8603 (v2k (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8604 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8605 (sig-list (verilog-signals-combine-bus
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8606 (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8607 (verilog-modi-get-signals modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8608 (verilog-modi-get-ports modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8609 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8610 (when v2k (verilog-repair-open-comma))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8611 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8612 (verilog-insert-indent "// Beginning of automatic outputs (every signal)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8613 (verilog-insert-definition sig-list "output" indent-pt v2k)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8614 (verilog-modi-cache-add-outputs modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8615 (verilog-insert-indent "// End of automatics\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8616 (when v2k (verilog-repair-close-comma)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8617
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8618 (defun verilog-auto-input ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8619 "Expand AUTOINPUT statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8620 Make input statements for any input signal into an /*AUTOINST*/ that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8621 isn't declared elsewhere inside the module. This is useful for modules which
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8622 only instantiate other modules.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8623
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8624 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8625 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8626
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8627 If placed inside the parenthesis of a module declaration, it creates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8628 Verilog 2001 style, else uses Verilog 1995 style.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8629
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8630 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8631 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8632
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8633 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8634
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8635 Signals matching `verilog-auto-input-ignore-regexp' are not included.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8636
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8637 An example (see `verilog-auto-inst' for what else is going on here):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8638
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8639 module ex_input (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8640 output [31:0] ov;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8641 /*AUTOINPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8642 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8643 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8644
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8645 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8646
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8647 module ex_input (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8648 output [31:0] ov;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8649 /*AUTOINPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8650 // Beginning of automatic inputs (from unused autoinst inputs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8651 input i; // From inst of inst.v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8652 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8653 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8654 // Outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8655 .ov (ov[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8656 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8657 .i (i));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8658 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8659 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8660 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8661 (v2k (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8662 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8663 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8664 (verilog-modi-get-sub-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8665 (append (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8666 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8667 (verilog-modi-get-wires modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8668 (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8669 (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8670 (verilog-modi-get-gparams modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8671 (verilog-modi-get-sub-outputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8672 (verilog-modi-get-sub-inouts modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8673 (setq sig-list (verilog-signals-not-matching-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8674 sig-list verilog-auto-input-ignore-regexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8675 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8676 (when v2k (verilog-repair-open-comma))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8677 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8678 (verilog-insert-indent "// Beginning of automatic inputs (from unused autoinst inputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8679 (verilog-insert-definition sig-list "input" indent-pt v2k)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8680 (verilog-modi-cache-add-inputs modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8681 (verilog-insert-indent "// End of automatics\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8682 (when v2k (verilog-repair-close-comma)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8683
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8684 (defun verilog-auto-inout ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8685 "Expand AUTOINOUT statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8686 Make inout statements for any inout signal in an /*AUTOINST*/ that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8687 isn't declared elsewhere inside the module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8688
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8689 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8690 This ONLY detects outputs of AUTOINSTants (see `verilog-read-sub-decls').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8691
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8692 If placed inside the parenthesis of a module declaration, it creates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8693 Verilog 2001 style, else uses Verilog 1995 style.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8694
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8695 If any concatenation, or bit-subscripts are missing in the AUTOINSTant's
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8696 instantiation, all bets are off. (For example due to a AUTO_TEMPLATE).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8697
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8698 Typedefs must match `verilog-typedef-regexp', which is disabled by default.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8699
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8700 Signals matching `verilog-auto-inout-ignore-regexp' are not included.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8701
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8702 An example (see `verilog-auto-inst' for what else is going on here):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8703
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8704 module ex_inout (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8705 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8706 /*AUTOINOUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8707 inst inst (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8708 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8709
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8710 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8711
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8712 module ex_inout (ov,i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8713 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8714 /*AUTOINOUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8715 // Beginning of automatic inouts (from unused autoinst inouts)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8716 inout [31:0] ov; // From inst of inst.v
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8717 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8718 inst inst (/*AUTOINST*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8719 // Inouts
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8720 .ov (ov[31:0]),
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8721 // Inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8722 .i (i));
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8723 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8724 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8725 ;; Point must be at insertion point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8726 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8727 (v2k (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8728 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8729 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8730 (verilog-modi-get-sub-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8731 (append (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8732 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8733 (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8734 (verilog-modi-get-sub-inputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8735 (verilog-modi-get-sub-outputs modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8736 (setq sig-list (verilog-signals-not-matching-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8737 sig-list verilog-auto-inout-ignore-regexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8738 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8739 (when v2k (verilog-repair-open-comma))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8740 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8741 (verilog-insert-indent "// Beginning of automatic inouts (from unused autoinst inouts)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8742 (verilog-insert-definition sig-list "inout" indent-pt v2k)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8743 (verilog-modi-cache-add-inouts modi sig-list)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8744 (verilog-insert-indent "// End of automatics\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8745 (when v2k (verilog-repair-close-comma)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8746
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8747 (defun verilog-auto-inout-module ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8748 "Expand AUTOINOUTMODULE statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8749 Take input/output/inout statements from the specified module and insert
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8750 into the current module. This is useful for making null templates and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8751 shell modules which need to have identical I/O with another module. Any
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8752 I/O which are already defined in this module will not be redefined.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8753
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8754 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8755 If placed inside the parenthesis of a module declaration, it creates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8756 Verilog 2001 style, else uses Verilog 1995 style.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8757
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8758 Concatenation and outputting partial busses is not supported.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8759
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8760 Module names must be resolvable to filenames. See `verilog-auto-inst'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8761
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8762 Signals are not inserted in the same order as in the original module,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8763 though they will appear to be in the same order to a AUTOINST
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8764 instantiating either module.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8765
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8766 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8767
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8768 module ex_shell (/*AUTOARG*/)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8769 /*AUTOINOUTMODULE(\"ex_main\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8770 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8771
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8772 module ex_main (i,o,io)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8773 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8774 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8775 inout io;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8776 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8777
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8778 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8779
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8780 module ex_shell (/*AUTOARG*/i,o,io)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8781 /*AUTOINOUTMODULE(\"ex_main\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8782 // Beginning of automatic in/out/inouts (from specific module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8783 input i;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8784 output o;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8785 inout io;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8786 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8787 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8788 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8789 (let* ((submod (car (verilog-read-auto-params 1))) submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8790 ;; Lookup position, etc of co-module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8791 ;; Note this may raise an error
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8792 (when (setq submodi (verilog-modi-lookup submod t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8793 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8794 (v2k (verilog-in-paren))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8795 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8796 (sig-list-i (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8797 (verilog-modi-get-inputs submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8798 (append (verilog-modi-get-inputs modi))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8799 (sig-list-o (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8800 (verilog-modi-get-outputs submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8801 (append (verilog-modi-get-outputs modi))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8802 (sig-list-io (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8803 (verilog-modi-get-inouts submodi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8804 (append (verilog-modi-get-inouts modi)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8805 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8806 (when v2k (verilog-repair-open-comma))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8807 (when (or sig-list-i sig-list-o sig-list-io)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8808 (verilog-insert-indent "// Beginning of automatic in/out/inouts (from specific module)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8809 ;; Don't sort them so a upper AUTOINST will match the main module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8810 (verilog-insert-definition sig-list-o "output" indent-pt v2k t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8811 (verilog-insert-definition sig-list-io "inout" indent-pt v2k t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8812 (verilog-insert-definition sig-list-i "input" indent-pt v2k t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8813 (verilog-modi-cache-add-inputs modi sig-list-i)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8814 (verilog-modi-cache-add-outputs modi sig-list-o)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8815 (verilog-modi-cache-add-inouts modi sig-list-io)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8816 (verilog-insert-indent "// End of automatics\n"))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8817 (when v2k (verilog-repair-close-comma)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8818
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8819 (defun verilog-auto-sense-sigs (modi presense-sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8820 "Return list of signals for current AUTOSENSE block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8821 (let* ((sigss (verilog-read-always-signals))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8822 (sig-list (verilog-signals-not-params
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8823 (verilog-signals-not-in (verilog-alw-get-inputs sigss)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8824 (append (and (not verilog-auto-sense-include-inputs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8825 (verilog-alw-get-outputs sigss))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8826 (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8827 (verilog-modi-get-gparams modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8828 presense-sigs)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8829 sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8830
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8831 (defun verilog-auto-sense ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8832 "Expand AUTOSENSE statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8833 Replace the always (/*AUTOSENSE*/) sensitivity list (/*AS*/ for short)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8834 with one automatically derived from all inputs declared in the always
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8835 statement. Signals that are generated within the same always block are NOT
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8836 placed into the sensitivity list (see `verilog-auto-sense-include-inputs').
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8837 Long lines are split based on the `fill-column', see \\[set-fill-column].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8838
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8839 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8840 Verilog does not allow memories (multidimensional arrays) in sensitivity
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8841 lists. AUTOSENSE will thus exclude them, and add a /*memory or*/ comment.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8842
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8843 Constant signals:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8844 AUTOSENSE cannot always determine if a `define is a constant or a signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8845 (it could be in a include file for example). If a `define or other signal
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8846 is put into the AUTOSENSE list and is not desired, use the AUTO_CONSTANT
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8847 declaration anywhere in the module (parenthesis are required):
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8848
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8849 /* AUTO_CONSTANT ( `this_is_really_constant_dont_autosense_it ) */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8850
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8851 Better yet, use a parameter, which will be understood to be constant
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8852 automatically.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8853
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8854 OOps!
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8855 If AUTOSENSE makes a mistake, please report it. (First try putting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8856 a begin/end after your always!) As a workaround, if a signal that
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8857 shouldn't be in the sensitivity list was, use the AUTO_CONSTANT above.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8858 If a signal should be in the sensitivity list wasn't, placing it before
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8859 the /*AUTOSENSE*/ comment will prevent it from being deleted when the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8860 autos are updated (or added if it occurs there already).
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8861
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8862 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8863
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8864 always @ (/*AUTOSENSE*/) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8865 /* AUTO_CONSTANT (`constant) */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8866 outin = ina | inb | `constant;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8867 out = outin;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8868 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8869
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8870 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8871
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8872 always @ (/*AUTOSENSE*/ina or inb) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8873 /* AUTO_CONSTANT (`constant) */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8874 outin = ina | inb | `constant;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8875 out = outin;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8876 end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8877 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8878 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8879 (let* ((start-pt (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8880 (verilog-re-search-backward "(" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8881 (point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8882 (indent-pt (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8883 (or (and (goto-char start-pt) (1+ (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8884 (current-indentation))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8885 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8886 (sig-memories (verilog-signals-memory
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8887 (append
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8888 (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8889 (verilog-modi-get-wires modi))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8890 sig-list not-first presense-sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8891 ;; Read signals in always, eliminate outputs from sense list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8892 (setq presense-sigs (verilog-signals-from-signame
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8893 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8894 (verilog-read-signals start-pt (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8895 (setq sig-list (verilog-auto-sense-sigs modi presense-sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8896 (when sig-memories
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8897 (let ((tlen (length sig-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8898 (setq sig-list (verilog-signals-not-in sig-list sig-memories))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8899 (if (not (eq tlen (length sig-list))) (insert " /*memory or*/ "))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8900 (if (and presense-sigs ;; Add a "or" if not "(.... or /*AUTOSENSE*/"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8901 (save-excursion (goto-char (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8902 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8903 (verilog-re-search-backward "\\s-" start-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8904 (while (looking-at "\\s-`endif")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8905 (verilog-re-search-backward "[a-zA-Z0-9$_.%`]+" start-pt t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8906 (verilog-re-search-backward "\\s-" start-pt t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8907 (not (looking-at "\\s-or\\b"))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8908 (setq not-first t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8909 (setq sig-list (sort sig-list `verilog-signals-sort-compare))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8910 (while sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8911 (cond ((> (+ 4 (current-column) (length (verilog-sig-name (car sig-list)))) fill-column) ;+4 for width of or
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8912 (insert "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8913 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8914 (if not-first (insert "or ")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8915 (not-first (insert " or ")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8916 (insert (verilog-sig-name (car sig-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8917 (setq sig-list (cdr sig-list)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
8918 not-first t)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8919
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8920 (defun verilog-auto-reset ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8921 "Expand AUTORESET statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8922 Replace the /*AUTORESET*/ comment with code to initialize all
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8923 registers set elsewhere in the always block.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8924
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8925 Limitations:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8926 AUTORESET will not clear memories.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8927
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8928 AUTORESET uses <= if there are any <= in the block, else it uses =.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8929
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8930 /*AUTORESET*/ presumes that any signals mentioned between the previous
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8931 begin/case/if statement and the AUTORESET comment are being reset manually
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8932 and should not be automatically reset. This includes omitting any signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8933 used on the right hand side of assignments.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8934
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8935 By default, AUTORESET will include the width of the signal in the autos,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8936 this is a recent change. To control this behavior, see
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8937 `verilog-auto-reset-widths'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8938
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8939 AUTORESET ties signals to deasserted, which is presumed to be zero.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8940 Signals that match `verilog-active-low-regexp' will be deasserted by tieing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8941 them to a one.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8942
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8943 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8944
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8945 always @(posedge clk or negedge reset_l) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8946 if (!reset_l) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8947 c <= 1;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8948 /*AUTORESET*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8949 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8950 else begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8951 a <= in_a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8952 b <= in_b;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8953 c <= in_c;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8954 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8955 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8956
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8957 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8958
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8959 always @(posedge core_clk or negedge reset_l) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8960 if (!reset_l) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8961 c <= 1;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8962 /*AUTORESET*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8963 // Beginning of autoreset for uninitialized flops
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8964 a <= 0;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8965 b <= 0;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8966 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8967 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8968 else begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8969 a <= in_a;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8970 b <= in_b;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8971 c <= in_c;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8972 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8973 end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8974
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8975 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8976 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8977 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8978 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8979 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8980 (all-list (verilog-modi-get-signals modi))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8981 sigss sig-list prereset-sigs assignment-str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8982 ;; Read signals in always, eliminate outputs from reset list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8983 (setq prereset-sigs (verilog-signals-from-signame
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8984 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8985 (verilog-read-signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8986 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8987 (verilog-re-search-backward "\\(@\\|\\<begin\\>\\|\\<if\\>\\|\\<case\\>\\)" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8988 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8989 (point)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8990 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8991 (verilog-re-search-backward "@" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8992 (setq sigss (verilog-read-always-signals)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8993 (setq assignment-str (if (verilog-alw-get-uses-delayed sigss)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8994 (concat " <= " verilog-assignment-delay)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8995 " = "))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8996 (setq sig-list (verilog-signals-not-in (verilog-alw-get-outputs sigss)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8997 prereset-sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8998 (setq sig-list (sort sig-list `verilog-signals-sort-compare))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8999 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9000 (insert "\n");
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9001 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9002 (insert "// Beginning of autoreset for uninitialized flops\n");
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9003 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9004 (while sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9005 (let ((sig (or (assoc (verilog-sig-name (car sig-list)) all-list) ;; As sig-list has no widths
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9006 (car sig-list))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9007 (insert (verilog-sig-name sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9008 assignment-str
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9009 (verilog-sig-tieoff sig (not verilog-auto-reset-widths))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9010 ";\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9011 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9012 (setq sig-list (cdr sig-list))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9013 (insert "// End of automatics")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9014
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9015 (defun verilog-auto-tieoff ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9016 "Expand AUTOTIEOFF statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9017 Replace the /*AUTOTIEOFF*/ comment with code to wire-tie all unused output
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9018 signals to deasserted.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9019
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9020 /*AUTOTIEOFF*/ is used to make stub modules; modules that have the same
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9021 input/output list as another module, but no internals. Specifically, it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9022 finds all outputs in the module, and if that input is not otherwise declared
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9023 as a register or wire, creates a tieoff.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9024
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9025 AUTORESET ties signals to deasserted, which is presumed to be zero.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9026 Signals that match `verilog-active-low-regexp' will be deasserted by tieing
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9027 them to a one.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9028
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9029 An example of making a stub for another module:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9030
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9031 module FooStub (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9032 /*AUTOINOUTMODULE(\"Foo\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9033 /*AUTOTIEOFF*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9034 // verilator lint_off UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9035 wire _unused_ok = &{1'b0,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9036 /*AUTOUNUSED*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9037 1'b0};
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9038 // verilator lint_on UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9039 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9040
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9041 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9042
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9043 module FooStub (/*AUTOINST*/...);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9044 /*AUTOINOUTMODULE(\"Foo\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9045 // Beginning of autotieoff
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9046 output [2:0] foo;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9047 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9048
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9049 /*AUTOTIEOFF*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9050 // Beginning of autotieoff
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9051 wire [2:0] foo = 3'b0;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9052 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9053 ...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9054 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9055 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9056 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9057 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9058 (let* ((indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9059 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9060 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9061 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9062 (append (verilog-modi-get-wires modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9063 (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9064 (verilog-modi-get-assigns modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9065 (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9066 (verilog-modi-get-gparams modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9067 (verilog-modi-get-sub-outputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9068 (verilog-modi-get-sub-inouts modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9069 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9070 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9071 (verilog-insert-indent "// Beginning of automatic tieoffs (for this module's unterminated outputs)\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9072 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9073 (verilog-modi-cache-add-wires modi sig-list) ; Before we trash list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9074 (while sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9075 (let ((sig (car sig-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9076 (verilog-insert-one-definition sig "wire" indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9077 (indent-to (max 48 (+ indent-pt 40)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9078 (insert "= " (verilog-sig-tieoff sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9079 ";\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9080 (setq sig-list (cdr sig-list))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9081 (verilog-insert-indent "// End of automatics\n")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9082
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9083 (defun verilog-auto-unused ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9084 "Expand AUTOUNUSED statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9085 Replace the /*AUTOUNUSED*/ comment with a comma separated list of all unused
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9086 input and inout signals.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9087
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9088 /*AUTOUNUSED*/ is used to make stub modules; modules that have the same
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9089 input/output list as another module, but no internals. Specifically, it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9090 finds all inputs and inouts in the module, and if that input is not otherwise
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9091 used, adds it to a comma separated list.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9092
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9093 The comma separated list is intended to be used to create a _unused_ok
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9094 signal. Using the exact name \"_unused_ok\" for name of the temporary
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9095 signal is recommended as it will insure maximum forward compatibility, it
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9096 also makes lint warnings easy to understand; ignore any unused warnings
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9097 with \"unused\" in the signal name.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9098
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9099 To reduce simulation time, the _unused_ok signal should be forced to a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9100 constant to prevent wiggling. The easiest thing to do is use a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9101 reduction-and with 1'b0 as shown.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9102
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9103 This way all unused signals are in one place, making it convenient to add
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9104 your tool's specific pragmas around the assignment to disable any unused
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9105 warnings.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9106
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9107 You can add signals you do not want included in AUTOUNUSED with
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9108 `verilog-auto-unused-ignore-regexp'.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9109
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9110 An example of making a stub for another module:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9111
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9112 module FooStub (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9113 /*AUTOINOUTMODULE(\"Foo\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9114 /*AUTOTIEOFF*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9115 // verilator lint_off UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9116 wire _unused_ok = &{1'b0,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9117 /*AUTOUNUSED*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9118 1'b0};
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9119 // verilator lint_on UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9120 endmodule
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9121
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9122 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9123
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9124 ...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9125 // verilator lint_off UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9126 wire _unused_ok = &{1'b0,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9127 /*AUTOUNUSED*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9128 // Beginning of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9129 unused_input_a,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9130 unused_input_b,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9131 unused_input_c,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9132 // End of automatics
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9133 1'b0};
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9134 // verilator lint_on UNUSED
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9135 endmodule"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9136 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9137 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9138 ;; Find beginning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9139 (let* ((indent-pt (progn (search-backward "/*") (current-column)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9140 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9141 (sig-list (verilog-signals-not-in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9142 (append (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9143 (verilog-modi-get-inouts modi))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9144 (append (verilog-modi-get-sub-inputs modi)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9145 (verilog-modi-get-sub-inouts modi)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9146 (setq sig-list (verilog-signals-not-matching-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9147 sig-list verilog-auto-unused-ignore-regexp))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9148 (when sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9149 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9150 (verilog-insert-indent "// Beginning of automatic unused inputs\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9151 (setq sig-list (sort (copy-alist sig-list) `verilog-signals-sort-compare))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9152 (while sig-list
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9153 (let ((sig (car sig-list)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9154 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9155 (insert (verilog-sig-name sig) ",\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9156 (setq sig-list (cdr sig-list))))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9157 (verilog-insert-indent "// End of automatics\n")))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9158
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9159 (defun verilog-enum-ascii (signm elim-regexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9160 "Convert a enum name SIGNM to a ascii string for insertion.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9161 Remove user provided prefix ELIM-REGEXP."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9162 (or elim-regexp (setq elim-regexp "_ DONT MATCH IT_"))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9163 (let ((case-fold-search t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9164 ;; All upper becomes all lower for readability
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9165 (downcase (verilog-string-replace-matches elim-regexp "" nil nil signm))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9166
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9167 (defun verilog-auto-ascii-enum ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9168 "Expand AUTOASCIIENUM statements, as part of \\[verilog-auto].
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9169 Create a register to contain the ASCII decode of a enumerated signal type.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9170 This will allow trace viewers to show the ASCII name of states.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9171
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9172 First, parameters are built into a enumeration using the synopsys enum
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9173 comment. The comment must be between the keyword and the symbol.
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9174 \(Annoying, but that's what Synopsys's dc_shell FSM reader requires.)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9175
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9176 Next, registers which that enum applies to are also tagged with the same
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9177 enum. Synopsys also suggests labeling state vectors, but `verilog-mode'
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9178 doesn't care.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9179
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9180 Finally, a AUTOASCIIENUM command is used.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9181
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9182 The first parameter is the name of the signal to be decoded.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9183
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9184 The second parameter is the name to store the ASCII code into. For the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9185 signal foo, I suggest the name _foo__ascii, where the leading _ indicates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9186 a signal that is just for simulation, and the magic characters _ascii
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9187 tell viewers like Dinotrace to display in ASCII format.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9188
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9189 The final optional parameter is a string which will be removed from the
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9190 state names.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9191
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9192 An example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9193
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9194 //== State enumeration
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9195 parameter [2:0] // synopsys enum state_info
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9196 SM_IDLE = 3'b000,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9197 SM_SEND = 3'b001,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9198 SM_WAIT1 = 3'b010;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9199 //== State variables
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9200 reg [2:0] /* synopsys enum state_info */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9201 state_r; /* synopsys state_vector state_r */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9202 reg [2:0] /* synopsys enum state_info */
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9203 state_e1;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9204
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9205 //== ASCII state decoding
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9206
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9207 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9208
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9209 Typing \\[verilog-auto] will make this into:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9210
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9211 ... same front matter ...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9212
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9213 /*AUTOASCIIENUM(\"state_r\", \"state_ascii_r\", \"SM_\")*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9214 // Beginning of automatic ASCII enum decoding
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9215 reg [39:0] state_ascii_r; // Decode of state_r
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9216 always @(state_r) begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9217 case ({state_r})
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9218 SM_IDLE: state_ascii_r = \"idle \";
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9219 SM_SEND: state_ascii_r = \"send \";
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9220 SM_WAIT1: state_ascii_r = \"wait1\";
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9221 default: state_ascii_r = \"%Erro\";
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9222 endcase
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9223 end
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9224 // End of automatics"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9225 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9226 (let* ((params (verilog-read-auto-params 2 3))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9227 (undecode-name (nth 0 params))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9228 (ascii-name (nth 1 params))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9229 (elim-regexp (nth 2 params))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9230 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9231 (indent-pt (current-indentation))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9232 (modi (verilog-modi-current))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9233 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9234 (sig-list-consts (append (verilog-modi-get-consts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9235 (verilog-modi-get-gparams modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9236 (sig-list-all (append (verilog-modi-get-regs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9237 (verilog-modi-get-outputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9238 (verilog-modi-get-inouts modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9239 (verilog-modi-get-inputs modi)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9240 (verilog-modi-get-wires modi)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9241 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9242 (undecode-sig (or (assoc undecode-name sig-list-all)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9243 (error "%s: Signal %s not found in design" (verilog-point-text) undecode-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9244 (undecode-enum (or (verilog-sig-enum undecode-sig)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9245 (error "%s: Signal %s does not have a enum tag" (verilog-point-text) undecode-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9246 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9247 (enum-sigs (or (verilog-signals-matching-enum sig-list-consts undecode-enum)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9248 (error "%s: No state definitions for %s" (verilog-point-text) undecode-enum)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9249 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9250 (enum-chars 0)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9251 (ascii-chars 0))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9252 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9253 ;; Find number of ascii chars needed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9254 (let ((tmp-sigs enum-sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9255 (while tmp-sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9256 (setq enum-chars (max enum-chars (length (verilog-sig-name (car tmp-sigs))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9257 ascii-chars (max ascii-chars (length (verilog-enum-ascii
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9258 (verilog-sig-name (car tmp-sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9259 elim-regexp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9260 tmp-sigs (cdr tmp-sigs))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9261 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9262 (forward-line 1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9263 (verilog-insert-indent "// Beginning of automatic ASCII enum decoding\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9264 (let ((decode-sig-list (list (list ascii-name (format "[%d:0]" (- (* ascii-chars 8) 1))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9265 (concat "Decode of " undecode-name) nil nil))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9266 (verilog-insert-definition decode-sig-list "reg" indent-pt nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9267 (verilog-modi-cache-add-regs modi decode-sig-list))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9268 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9269 (verilog-insert-indent "always @(" undecode-name ") begin\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9270 (setq indent-pt (+ indent-pt verilog-indent-level))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9271 (indent-to indent-pt)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9272 (insert "case ({" undecode-name "})\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9273 (setq indent-pt (+ indent-pt verilog-case-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9274 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9275 (let ((tmp-sigs enum-sigs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9276 (chrfmt (format "%%-%ds %s = \"%%-%ds\";\n" (1+ (max 8 enum-chars))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9277 ascii-name ascii-chars))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9278 (errname (substring "%Error" 0 (min 6 ascii-chars))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9279 (while tmp-sigs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9280 (verilog-insert-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9281 (format chrfmt (concat (verilog-sig-name (car tmp-sigs)) ":")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9282 (verilog-enum-ascii (verilog-sig-name (car tmp-sigs))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9283 elim-regexp)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9284 (setq tmp-sigs (cdr tmp-sigs)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9285 (verilog-insert-indent (format chrfmt "default:" errname)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9286 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9287 (setq indent-pt (- indent-pt verilog-case-indent))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9288 (verilog-insert-indent "endcase\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9289 (setq indent-pt (- indent-pt verilog-indent-level))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9290 (verilog-insert-indent "end\n"
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9291 "// End of automatics\n"))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9292
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9293 (defun verilog-auto-templated-rel ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9294 "Replace Templated relative line numbers with absolute line numbers.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9295 Internal use only. This hacks around the line numbers in AUTOINST Templates
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9296 being different from the final output's line numbering."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9297 (let ((templateno 0) (template-line (list 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9298 ;; Find line number each template is on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9299 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9300 (while (search-forward "AUTO_TEMPLATE" nil t)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9301 (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
9302 (setq template-line
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
9303 (cons (count-lines (point-min) (point)) template-line)))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9304 (setq template-line (nreverse template-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9305 ;; Replace T# L# with absolute line number
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9306 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9307 (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
9308 (replace-match
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
9309 (concat " Templated "
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
9310 (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
9311 template-line)
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
9312 (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
9313 t t))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9314
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9315
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9316 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9317 ;; Auto top level
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9318 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9319
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9320 (defun verilog-auto (&optional inject) ; Use verilog-inject-auto instead of passing a arg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9321 "Expand AUTO statements.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9322 Look for any /*AUTO...*/ commands in the code, as used in
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9323 instantiations or argument headers. Update the list of signals
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9324 following the /*AUTO...*/ command.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9325
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9326 Use \\[verilog-delete-auto] to remove the AUTOs.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9327
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9328 Use \\[verilog-inject-auto] to insert AUTOs for the first time.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9329
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9330 Use \\[verilog-faq] for a pointer to frequently asked questions.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9331
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9332 The hooks `verilog-before-auto-hook' and `verilog-auto-hook' are
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9333 called before and after this function, respectively.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9334
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9335 For example:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9336 module (/*AUTOARG*/)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9337 /*AUTOINPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9338 /*AUTOOUTPUT*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9339 /*AUTOWIRE*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9340 /*AUTOREG*/
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9341 somesub sub #(/*AUTOINSTPARAM*/) (/*AUTOINST*/);
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9342
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9343 You can also update the AUTOs from the shell using:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9344 emacs --batch <filenames.v> -f verilog-batch-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9345 Or fix indentation with:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9346 emacs --batch <filenames.v> -f verilog-batch-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9347 Likewise, you can delete or inject AUTOs with:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9348 emacs --batch <filenames.v> -f verilog-batch-delete-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9349 emacs --batch <filenames.v> -f verilog-batch-inject-auto
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9350
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9351 Using \\[describe-function], see also:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9352 `verilog-auto-arg' for AUTOARG module instantiations
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9353 `verilog-auto-ascii-enum' for AUTOASCIIENUM enumeration decoding
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9354 `verilog-auto-inout-module' for AUTOINOUTMODULE copying i/o from elsewhere
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9355 `verilog-auto-inout' for AUTOINOUT making hierarchy inouts
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9356 `verilog-auto-input' for AUTOINPUT making hierarchy inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9357 `verilog-auto-inst' for AUTOINST instantiation pins
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9358 `verilog-auto-star' for AUTOINST .* SystemVerilog pins
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9359 `verilog-auto-inst-param' for AUTOINSTPARAM instantiation params
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9360 `verilog-auto-output' for AUTOOUTPUT making hierarchy outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9361 `verilog-auto-output-every' for AUTOOUTPUTEVERY making all outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9362 `verilog-auto-reg' for AUTOREG registers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9363 `verilog-auto-reg-input' for AUTOREGINPUT instantiation registers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9364 `verilog-auto-reset' for AUTORESET flop resets
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9365 `verilog-auto-sense' for AUTOSENSE always sensitivity lists
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9366 `verilog-auto-tieoff' for AUTOTIEOFF output tieoffs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9367 `verilog-auto-unused' for AUTOUNUSED unused inputs/inouts
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9368 `verilog-auto-wire' for AUTOWIRE instantiation wires
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9369
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9370 `verilog-read-defines' for reading `define values
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9371 `verilog-read-includes' for reading `includes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9372
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9373 If you have bugs with these autos, try contacting the AUTOAUTHOR
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9374 Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9375 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9376 (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
9377 (if (fboundp 'dinotrace-unannotate-all)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9378 (dinotrace-unannotate-all))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9379 (let ((oldbuf (if (not (buffer-modified-p))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9380 (buffer-string)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9381 ;; Before version 20, match-string with font-lock returns a
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9382 ;; vector that is not equal to the string. IE if on "input"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9383 ;; nil==(equal "input" (progn (looking-at "input") (match-string 0)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9384 (fontlocked (when (and (boundp 'font-lock-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9385 font-lock-mode)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9386 (font-lock-mode nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9387 t)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9388 (unwind-protect
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9389 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9390 ;; If we're not in verilog-mode, change syntax table so parsing works right
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9391 (unless (eq major-mode `verilog-mode) (verilog-mode))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9392 ;; Allow user to customize
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9393 (run-hooks 'verilog-before-auto-hook)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9394 ;; Try to save the user from needing to revert-file to reread file local-variables
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9395 (verilog-auto-reeval-locals)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9396 (verilog-read-auto-lisp (point-min) (point-max))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9397 (verilog-getopt-flags)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9398 ;; These two may seem obvious to do always, but on large includes it can be way too slow
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9399 (when verilog-auto-read-includes
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9400 (verilog-read-includes)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9401 (verilog-read-defines nil nil t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9402 ;; This particular ordering is important
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9403 ;; INST: Lower modules correct, no internal dependencies, FIRST
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9404 (verilog-preserve-cache
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9405 ;; Clear existing autos else we'll be screwed by existing ones
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9406 (verilog-delete-auto)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9407 ;; Injection if appropriate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9408 (when inject
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9409 (verilog-inject-inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9410 (verilog-inject-sense)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9411 (verilog-inject-arg))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9412 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9413 (verilog-auto-search-do "/*AUTOINSTPARAM*/" 'verilog-auto-inst-param)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9414 (verilog-auto-search-do "/*AUTOINST*/" 'verilog-auto-inst)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9415 (verilog-auto-search-do ".*" 'verilog-auto-star)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9416 ;; Doesn't matter when done, but combine it with a common changer
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9417 (verilog-auto-re-search-do "/\\*\\(AUTOSENSE\\|AS\\)\\*/" 'verilog-auto-sense)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9418 (verilog-auto-re-search-do "/\\*AUTORESET\\*/" 'verilog-auto-reset)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9419 ;; Must be done before autoin/out as creates a reg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9420 (verilog-auto-re-search-do "/\\*AUTOASCIIENUM([^)]*)\\*/" 'verilog-auto-ascii-enum)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9421 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9422 ;; first in/outs from other files
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9423 (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9424 ;; next in/outs which need previous sucked inputs first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9425 (verilog-auto-search-do "/*AUTOOUTPUT*/" 'verilog-auto-output)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9426 (verilog-auto-search-do "/*AUTOINPUT*/" 'verilog-auto-input)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9427 (verilog-auto-search-do "/*AUTOINOUT*/" 'verilog-auto-inout)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9428 ;; Then tie off those in/outs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9429 (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9430 ;; Wires/regs must be after inputs/outputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9431 (verilog-auto-search-do "/*AUTOWIRE*/" 'verilog-auto-wire)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9432 (verilog-auto-search-do "/*AUTOREG*/" 'verilog-auto-reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9433 (verilog-auto-search-do "/*AUTOREGINPUT*/" 'verilog-auto-reg-input)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9434 ;; outputevery needs AUTOOUTPUTs done first
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9435 (verilog-auto-search-do "/*AUTOOUTPUTEVERY*/" 'verilog-auto-output-every)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9436 ;; After we've created all new variables
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9437 (verilog-auto-search-do "/*AUTOUNUSED*/" 'verilog-auto-unused)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9438 ;; Must be after all inputs outputs are generated
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9439 (verilog-auto-search-do "/*AUTOARG*/" 'verilog-auto-arg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9440 ;; Fix line numbers (comments only)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9441 (verilog-auto-templated-rel))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9442 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9443 (run-hooks 'verilog-auto-hook)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9444 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9445 (set (make-local-variable 'verilog-auto-update-tick) (buffer-modified-tick))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9446 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9447 ;; If end result is same as when started, clear modified flag
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9448 (cond ((and oldbuf (equal oldbuf (buffer-string)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9449 (set-buffer-modified-p nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9450 (unless noninteractive (message "Updating AUTOs...done (no changes)")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9451 (t (unless noninteractive (message "Updating AUTOs...done")))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9452 ;; Unwind forms
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9453 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9454 ;; Restore font-lock
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9455 (when fontlocked (font-lock-mode t))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9456
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9457
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9458 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9459 ;; Skeleton based code insertion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9460 ;;
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9461 (defvar verilog-template-map
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9462 (let ((map (make-sparse-keymap)))
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9463 (define-key map "a" 'verilog-sk-always)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9464 (define-key map "b" 'verilog-sk-begin)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9465 (define-key map "c" 'verilog-sk-case)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9466 (define-key map "f" 'verilog-sk-for)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9467 (define-key map "g" 'verilog-sk-generate)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9468 (define-key map "h" 'verilog-sk-header)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9469 (define-key map "i" 'verilog-sk-initial)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9470 (define-key map "j" 'verilog-sk-fork)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9471 (define-key map "m" 'verilog-sk-module)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9472 (define-key map "p" 'verilog-sk-primitive)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9473 (define-key map "r" 'verilog-sk-repeat)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9474 (define-key map "s" 'verilog-sk-specify)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9475 (define-key map "t" 'verilog-sk-task)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9476 (define-key map "w" 'verilog-sk-while)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9477 (define-key map "x" 'verilog-sk-casex)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9478 (define-key map "z" 'verilog-sk-casez)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9479 (define-key map "?" 'verilog-sk-if)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9480 (define-key map ":" 'verilog-sk-else-if)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9481 (define-key map "/" 'verilog-sk-comment)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9482 (define-key map "A" 'verilog-sk-assign)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9483 (define-key map "F" 'verilog-sk-function)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9484 (define-key map "I" 'verilog-sk-input)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9485 (define-key map "O" 'verilog-sk-output)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9486 (define-key map "S" 'verilog-sk-state-machine)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9487 (define-key map "=" 'verilog-sk-inout)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9488 (define-key map "W" 'verilog-sk-wire)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9489 (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
9490 (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
9491 map)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9492 "Keymap used in Verilog mode for smart template operations.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9493
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9494
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9495 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9496 ;; Place the templates into Verilog Mode. They may be inserted under any key.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9497 ;; C-c C-t will be the default. If you use templates a lot, you
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9498 ;; may want to consider moving the binding to another key in your .emacs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9499 ;; file.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9500 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9501 ;(define-key verilog-mode-map "\C-ct" verilog-template-map)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9502 (define-key verilog-mode-map "\C-c\C-t" verilog-template-map)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9503
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9504 ;;; ---- statement skeletons ------------------------------------------
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9505
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9506 (define-skeleton verilog-sk-prompt-condition
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9507 "Prompt for the loop condition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9508 "[condition]: " str )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9509
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9510 (define-skeleton verilog-sk-prompt-init
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9511 "Prompt for the loop init statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9512 "[initial statement]: " str )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9513
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9514 (define-skeleton verilog-sk-prompt-inc
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9515 "Prompt for the loop increment statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9516 "[increment statement]: " str )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9517
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9518 (define-skeleton verilog-sk-prompt-name
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9519 "Prompt for the name of something."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9520 "[name]: " str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9521
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9522 (define-skeleton verilog-sk-prompt-clock
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9523 "Prompt for the name of something."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9524 "name and edge of clock(s): " str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9525
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9526 (defvar verilog-sk-reset nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9527 (defun verilog-sk-prompt-reset ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9528 "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
9529 (setq verilog-sk-reset (read-string "name of reset: " "rst")))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9530
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9531
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9532 (define-skeleton verilog-sk-prompt-state-selector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9533 "Prompt for the name of a state machine selector."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9534 "name of selector (eg {a,b,c,d}): " str )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9535
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9536 (define-skeleton verilog-sk-prompt-output
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9537 "Prompt for the name of something."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9538 "output: " str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9539
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9540 (define-skeleton verilog-sk-prompt-msb
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9541 "Prompt for least significant bit specification."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9542 "msb:" str & ?: & (verilog-sk-prompt-lsb) | -1 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9543
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9544 (define-skeleton verilog-sk-prompt-lsb
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9545 "Prompt for least significant bit specification."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9546 "lsb:" str )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9547
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9548 (defvar verilog-sk-p nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9549 (define-skeleton verilog-sk-prompt-width
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9550 "Prompt for a width specification."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9551 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9552 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9553 (setq verilog-sk-p (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9554 (verilog-sk-prompt-msb)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9555 (if (> (point) verilog-sk-p) "] " " ")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9556
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9557 (defun verilog-sk-header ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9558 "Insert a descriptive header at the top of the file."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9559 (interactive "*")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9560 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9561 (goto-char (point-min))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9562 (verilog-sk-header-tmpl)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9563
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9564 (define-skeleton verilog-sk-header-tmpl
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9565 "Insert a comment block containing the module title, author, etc."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9566 "[Description]: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9567 "// -*- Mode: Verilog -*-"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9568 "\n// Filename : " (buffer-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9569 "\n// Description : " str
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9570 "\n// Author : " (user-full-name)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9571 "\n// Created On : " (current-time-string)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9572 "\n// Last Modified By: ."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9573 "\n// Last Modified On: ."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9574 "\n// Update Count : 0"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9575 "\n// Status : Unknown, Use with caution!"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9576 "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9577
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9578 (define-skeleton verilog-sk-module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9579 "Insert a module definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9580 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9581 > "module " (verilog-sk-prompt-name) " (/*AUTOARG*/ ) ;" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9582 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9583 > (- verilog-indent-level-behavioral) "endmodule" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9584
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9585 (define-skeleton verilog-sk-primitive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9586 "Insert a task definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9587 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9588 > "primitive " (verilog-sk-prompt-name) " ( " (verilog-sk-prompt-output) ("input:" ", " str ) " );"\n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9589 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9590 > (- verilog-indent-level-behavioral) "endprimitive" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9591
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9592 (define-skeleton verilog-sk-task
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9593 "Insert a task definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9594 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9595 > "task " (verilog-sk-prompt-name) & ?; \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9596 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9597 > "begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9598 > \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9599 > (- verilog-indent-level-behavioral) "end" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9600 > (- verilog-indent-level-behavioral) "endtask" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9601
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9602 (define-skeleton verilog-sk-function
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9603 "Insert a function definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9604 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9605 > "function [" (verilog-sk-prompt-width) | -1 (verilog-sk-prompt-name) ?; \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9606 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9607 > "begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9608 > \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9609 > (- verilog-indent-level-behavioral) "end" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9610 > (- verilog-indent-level-behavioral) "endfunction" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9611
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9612 (define-skeleton verilog-sk-always
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9613 "Insert always block. Uses the minibuffer to prompt
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9614 for sensitivity list."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9615 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9616 > "always @ ( /*AUTOSENSE*/ ) begin\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9617 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9618 > (- verilog-indent-level-behavioral) "end" \n >
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9619 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9620
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9621 (define-skeleton verilog-sk-initial
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9622 "Insert an initial block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9623 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9624 > "initial begin\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9625 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9626 > (- verilog-indent-level-behavioral) "end" \n > )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9627
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9628 (define-skeleton verilog-sk-specify
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9629 "Insert specify block. "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9630 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9631 > "specify\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9632 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9633 > (- verilog-indent-level-behavioral) "endspecify" \n > )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9634
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9635 (define-skeleton verilog-sk-generate
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9636 "Insert generate block. "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9637 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9638 > "generate\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9639 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9640 > (- verilog-indent-level-behavioral) "endgenerate" \n > )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9641
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9642 (define-skeleton verilog-sk-begin
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9643 "Insert begin end block. Uses the minibuffer to prompt for name"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9644 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9645 > "begin" (verilog-sk-prompt-name) \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9646 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9647 > (- verilog-indent-level-behavioral) "end"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9648 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9649
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9650 (define-skeleton verilog-sk-fork
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9651 "Insert an fork join block."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9652 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9653 > "fork\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9654 > "begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9655 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9656 > (- verilog-indent-level-behavioral) "end" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9657 > "begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9658 > \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9659 > (- verilog-indent-level-behavioral) "end" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9660 > (- verilog-indent-level-behavioral) "join" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9661 > )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9662
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9663
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9664 (define-skeleton verilog-sk-case
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9665 "Build skeleton case statement, prompting for the selector expression,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9666 and the case items."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9667 "[selector expression]: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9668 > "case (" str ") " \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9669 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9670 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9671
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9672 (define-skeleton verilog-sk-casex
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9673 "Build skeleton casex statement, prompting for the selector expression,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9674 and the case items."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9675 "[selector expression]: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9676 > "casex (" str ") " \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9677 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9678 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9679
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9680 (define-skeleton verilog-sk-casez
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9681 "Build skeleton casez statement, prompting for the selector expression,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9682 and the case items."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9683 "[selector expression]: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9684 > "casez (" str ") " \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9685 > ("case selector: " str ": begin" \n > _ \n > (- verilog-indent-level-behavioral) "end" \n )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9686 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9687
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9688 (define-skeleton verilog-sk-if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9689 "Insert a skeleton if statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9690 > "if (" (verilog-sk-prompt-condition) & ")" " begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9691 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9692 > (- verilog-indent-level-behavioral) "end " \n )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9693
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9694 (define-skeleton verilog-sk-else-if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9695 "Insert a skeleton else if statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9696 > (verilog-indent-line) "else if ("
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9697 (progn (setq verilog-sk-p (point)) nil) (verilog-sk-prompt-condition) (if (> (point) verilog-sk-p) ") " -1 ) & " begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9698 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9699 > "end" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9700
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9701 (define-skeleton verilog-sk-datadef
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9702 "Common routine to get data definition"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9703 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9704 (verilog-sk-prompt-width) | -1 ("name (RET to end):" str ", ") -2 ";" \n)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9705
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9706 (define-skeleton verilog-sk-input
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9707 "Insert an input definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9708 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9709 > "input [" (verilog-sk-datadef))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9710
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9711 (define-skeleton verilog-sk-output
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9712 "Insert an output definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9713 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9714 > "output [" (verilog-sk-datadef))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9715
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9716 (define-skeleton verilog-sk-inout
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9717 "Insert an inout definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9718 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9719 > "inout [" (verilog-sk-datadef))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9720
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9721 (defvar verilog-sk-signal nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9722 (define-skeleton verilog-sk-def-reg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9723 "Insert a reg definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9724 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9725 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-signal ";" \n (verilog-pretty-declarations) )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9726
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9727 (defun verilog-sk-define-signal ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9728 "Insert a definition of signal under point at top of module."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9729 (interactive "*")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9730 (let* ((sig-re "[a-zA-Z0-9_]*")
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9731 (v1 (buffer-substring
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9732 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9733 (skip-chars-backward sig-re)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9734 (point))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9735 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9736 (skip-chars-forward sig-re)
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9737 (point)))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9738 (if (not (member v1 verilog-keywords))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9739 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9740 (setq verilog-sk-signal v1)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9741 (verilog-beg-of-defun)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9742 (verilog-end-of-statement)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9743 (verilog-forward-syntactic-ws)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9744 (verilog-sk-def-reg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9745 (message "signal at point is %s" v1))
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9746 (message "object at point (%s) is a keyword" v1))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9747
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9748 (define-skeleton verilog-sk-wire
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9749 "Insert a wire definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9750 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9751 > "wire [" (verilog-sk-datadef))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9752
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9753 (define-skeleton verilog-sk-reg
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9754 "Insert a reg definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9755 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9756 > "reg [" (verilog-sk-datadef))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9757
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9758 (define-skeleton verilog-sk-assign
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9759 "Insert a skeleton assign statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9760 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9761 > "assign " (verilog-sk-prompt-name) " = " _ ";" \n)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9762
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9763 (define-skeleton verilog-sk-while
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9764 "Insert a skeleton while loop statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9765 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9766 > "while (" (verilog-sk-prompt-condition) ") begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9767 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9768 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9769
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9770 (define-skeleton verilog-sk-repeat
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9771 "Insert a skeleton repeat loop statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9772 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9773 > "repeat (" (verilog-sk-prompt-condition) ") begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9774 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9775 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9776
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9777 (define-skeleton verilog-sk-for
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9778 "Insert a skeleton while loop statement."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9779 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9780 > "for ("
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9781 (verilog-sk-prompt-init) "; "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9782 (verilog-sk-prompt-condition) "; "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9783 (verilog-sk-prompt-inc)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9784 ") begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9785 > _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9786 > (- verilog-indent-level-behavioral) "end " (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9787
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9788 (define-skeleton verilog-sk-comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9789 "Inserts three comment lines, making a display comment."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9790 ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9791 > "/*\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9792 > "* " _ \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9793 > "*/")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9794
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9795 (define-skeleton verilog-sk-state-machine
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9796 "Insert a state machine definition."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9797 "Name of state variable: "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9798 '(setq input "state")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9799 > "// State registers for " str | -23 \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9800 '(setq verilog-sk-state str)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9801 > "reg [" (verilog-sk-prompt-width) | -1 verilog-sk-state ", next_" verilog-sk-state ?; \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9802 '(setq input nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9803 > \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9804 > "// State FF for " verilog-sk-state \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9805 > "always @ ( " (read-string "clock:" "posedge clk") " or " (verilog-sk-prompt-reset) " ) begin" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9806 > "if ( " verilog-sk-reset " ) " verilog-sk-state " = 0; else" \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9807 > verilog-sk-state " = next_" verilog-sk-state ?; \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9808 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9809 > \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9810 > "// Next State Logic for " verilog-sk-state \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9811 > "always @ ( /*AUTOSENSE*/ ) begin\n"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9812 > "case (" (verilog-sk-prompt-state-selector) ") " \n
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9813 > ("case selector: " str ": begin" \n > "next_" verilog-sk-state " = " _ ";" \n > (- verilog-indent-level-behavioral) "end" \n )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9814 resume: > (- verilog-case-indent) "endcase" (progn (electric-verilog-terminate-line) nil)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9815 > (- verilog-indent-level-behavioral) "end" (progn (electric-verilog-terminate-line) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9816
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9817 ;; Eliminate compile warning
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9818 (eval-when-compile
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9819 (if (not (boundp 'mode-popup-menu))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9820 (defvar mode-popup-menu nil "Compatibility with XEmacs.")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9821
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9822 ;; ---- add menu 'Statements' in Verilog mode (MH)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9823 (defun verilog-add-statement-menu ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9824 "Add the menu 'Statements' to the menu bar in Verilog mode."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9825 (if (featurep 'xemacs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9826 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9827 (easy-menu-add verilog-stmt-menu)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9828 (easy-menu-add verilog-menu)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9829 (setq mode-popup-menu (cons "Verilog Mode" verilog-stmt-menu)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9830
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9831 (add-hook 'verilog-mode-hook 'verilog-add-statement-menu)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9832
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9833
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9834
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9835 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9836 ;; Include file loading with mouse/return event
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9837 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9838 ;; idea & first impl.: M. Rouat (eldo-mode.el)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9839 ;; second (emacs/xemacs) impl.: G. Van der Plas (spice-mode.el)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9840
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9841 (if (featurep 'xemacs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9842 (require 'overlay)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9843 (require 'lucid)) ;; what else can we do ??
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9844
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9845 (defconst verilog-include-file-regexp
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9846 "^`include\\s-+\"\\([^\n\"]*\\)\""
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9847 "Regexp that matches the include file.")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9848
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9849 (defvar verilog-mode-mouse-map
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9850 (let ((map (make-sparse-keymap))) ; as described in info pages, make a map
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9851 (set-keymap-parent map verilog-mode-map)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9852 ;; mouse button bindings
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9853 (define-key map "\r" 'verilog-load-file-at-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9854 (if (featurep 'xemacs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9855 (define-key map 'button2 'verilog-load-file-at-mouse);ffap-at-mouse ?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9856 (define-key map [mouse-2] 'verilog-load-file-at-mouse))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9857 (if (featurep 'xemacs)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9858 (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
9859 (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
9860 map)
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9861 "Map containing mouse bindings for `verilog-mode'.")
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
9862
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9863
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9864 (defun verilog-colorize-include-files (beg end old-len)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9865 "This function colorizes included files when the mouse passes over them.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9866 Clicking on the middle-mouse button loads them in a buffer (as in dired)."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9867 (save-excursion
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9868 (save-match-data
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9869 (let (end-point)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9870 (goto-char end)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9871 (setq end-point (verilog-get-end-of-line))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9872 (goto-char beg)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9873 (beginning-of-line) ; scan entire line !
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9874 ;; delete overlays existing on this line
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9875 (let ((overlays (overlays-in (point) end-point)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9876 (while overlays
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9877 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9878 (overlay-get (car overlays) 'detachable)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9879 (overlay-get (car overlays) 'verilog-include-file))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9880 (delete-overlay (car overlays)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9881 (setq overlays (cdr overlays)))) ; let
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9882 ;; make new ones, could reuse deleted one ?
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9883 (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
9884 (let (ov)
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9885 (goto-char (match-beginning 1))
79550
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
9886 (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
9887 (overlay-put ov 'start-closed 't)
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
9888 (overlay-put ov 'end-closed 't)
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
9889 (overlay-put ov 'evaporate 't)
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
9890 (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
9891 (overlay-put ov 'mouse-face 'highlight)
7f3b93a179a2 * progmodes/verilog-mode.el (verilog-mode-map)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79549
diff changeset
9892 (overlay-put ov 'local-map verilog-mode-mouse-map)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9893
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9894
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9895 (defun verilog-colorize-include-files-buffer ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9896 "Colorize a include file."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9897 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9898 ;; delete overlays
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9899 (let ((overlays (overlays-in (point-min) (point-max))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9900 (while overlays
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9901 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9902 (overlay-get (car overlays) 'detachable)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9903 (overlay-get (car overlays) 'verilog-include-file))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9904 (delete-overlay (car overlays)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9905 (setq overlays (cdr overlays)))) ; let
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9906 ;; remake overlays
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9907 (verilog-colorize-include-files (point-min) (point-max) nil))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9908
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9909 ;; ffap-at-mouse isn't useful for verilog mode. It uses library paths.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9910 ;; so define this function to do more or less the same as ffap-at-mouse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9911 ;; but first resolve filename...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9912 (defun verilog-load-file-at-mouse (event)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9913 "Load file under button 2 click's EVENT.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9914 Files are checked based on `verilog-library-directories'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9915 (interactive "@e")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9916 (save-excursion ;; implement a verilog specific ffap-at-mouse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9917 (mouse-set-point event)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9918 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9919 (if (looking-at verilog-include-file-regexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9920 (if (and (car (verilog-library-filenames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9921 (match-string 1) (buffer-file-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9922 (file-readable-p (car (verilog-library-filenames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9923 (match-string 1) (buffer-file-name)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9924 (find-file (car (verilog-library-filenames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9925 (match-string 1) (buffer-file-name))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9926 (progn
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9927 (message
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9928 "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
9929 (match-string 1)))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9930
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9931 ;; ffap isn't useable for verilog mode. It uses library paths.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9932 ;; so define this function to do more or less the same as ffap
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9933 ;; but first resolve filename...
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9934 (defun verilog-load-file-at-point ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9935 "Load file under point.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9936 Files are checked based on `verilog-library-directories'."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9937 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9938 (save-excursion ;; implement a verilog specific ffap
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9939 (beginning-of-line)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9940 (if (looking-at verilog-include-file-regexp)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9941 (if (and
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9942 (car (verilog-library-filenames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9943 (match-string 1) (buffer-file-name)))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9944 (file-readable-p (car (verilog-library-filenames
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9945 (match-string 1) (buffer-file-name)))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9946 (find-file (car (verilog-library-filenames
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9947 (match-string 1) (buffer-file-name))))))))
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9948
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9949
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9950 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9951 ;; Bug reporting
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9952 ;;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9953
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9954 (defun verilog-faq ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9955 "Tell the user their current version, and where to get the FAQ etc."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9956 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9957 (with-output-to-temp-buffer "*verilog-mode help*"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9958 (princ (format "You are using verilog-mode %s\n" verilog-mode-version))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9959 (princ "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9960 (princ "For new releases, see http://www.verilog.com\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9961 (princ "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9962 (princ "For frequently asked questions, see http://www.veripool.com/verilog-mode-faq.html\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9963 (princ "\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9964 (princ "To submit a bug, use M-x verilog-submit-bug-report\n")
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9965 (princ "\n")))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9966
79691
d3e3c91e18f6 * progmodes/verilog-mode.el (top-level): Don't require compile.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79555
diff changeset
9967 (autoload 'reporter-submit-bug-report "reporter")
79799
57956dd69d3f (top-level): Fix spacing.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79717
diff changeset
9968 (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
9969
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9970 (defun verilog-submit-bug-report ()
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9971 "Submit via mail a bug report on verilog-mode.el."
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9972 (interactive)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9973 (let ((reporter-prompt-for-summary-p t))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9974 (reporter-submit-bug-report
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9975 "mac@verilog.com"
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9976 (concat "verilog-mode v" verilog-mode-version)
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9977 '(
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9978 verilog-align-ifelse
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9979 verilog-auto-endcomments
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9980 verilog-auto-hook
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9981 verilog-auto-indent-on-newline
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9982 verilog-auto-inst-vector
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9983 verilog-auto-inst-template-numbers
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9984 verilog-auto-lineup
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9985 verilog-auto-newline
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9986 verilog-auto-save-policy
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9987 verilog-auto-sense-defines-constant
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9988 verilog-auto-sense-include-inputs
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9989 verilog-before-auto-hook
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9990 verilog-case-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9991 verilog-cexp-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9992 verilog-compiler
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9993 verilog-coverage
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9994 verilog-highlight-translate-off
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9995 verilog-indent-begin-after-if
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9996 verilog-indent-declaration-macros
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9997 verilog-indent-level
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9998 verilog-indent-level-behavioral
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9999 verilog-indent-level-declaration
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10000 verilog-indent-level-directive
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10001 verilog-indent-level-module
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10002 verilog-indent-lists
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10003 verilog-library-flags
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10004 verilog-library-directories
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10005 verilog-library-extensions
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10006 verilog-library-files
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10007 verilog-linter
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10008 verilog-minimum-comment-distance
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10009 verilog-mode-hook
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10010 verilog-simulator
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10011 verilog-tab-always-indent
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10012 verilog-tab-to-comment
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10013 )
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10014 nil nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10015 (concat "Hi Mac,
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10016
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10017 I want to report a bug. I've read the `Bugs' section of `Info' on
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10018 Emacs, so I know how to make a clear and unambiguous report. To get
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10019 to that Info section, I typed
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10020
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10021 M-x info RET m " invocation-name " RET m bugs RET
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10022
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10023 Before I go further, I want to say that Verilog mode has changed my life.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10024 I save so much time, my files are colored nicely, my co workers respect
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10025 my coding ability... until now. I'd really appreciate anything you
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10026 could do to help me out with this minor deficiency in the product.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10027
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10028 If you have bugs with the AUTO functions, please CC the AUTOAUTHOR Wilson
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10029 Snyder (wsnyder@wsnyder.org) and/or see http://www.veripool.com.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10030 You may also want to look at the Verilog-Mode FAQ, see
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10031 http://www.veripool.com/verilog-mode-faq.html.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10032
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10033 To reproduce the bug, start a fresh Emacs via " invocation-name "
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10034 -no-init-file -no-site-file'. In a new buffer, in verilog mode, type
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10035 the code included below.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10036
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10037 Given those lines, I expected [[Fill in here]] to happen;
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10038 but instead, [[Fill in here]] happens!.
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10039
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10040 == The code: =="))))
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10041
79546
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
10042 (provide 'verilog-mode)
0413a70bb454 (verilog-mode-version)
Dan Nicolaescu <dann@ics.uci.edu>
parents: 79545
diff changeset
10043
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10044 ;; Local Variables:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10045 ;; checkdoc-permit-comma-termination-flag:t
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10046 ;; checkdoc-force-docstrings-flag:nil
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10047 ;; End:
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10048
79552
23c53aca1e84 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 79551
diff changeset
10049 ;; arch-tag: 87923725-57b3-41b5-9494-be21118c6a6f
79545
176f1495425c New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10050 ;;; verilog-mode.el ends here