1 ;;; vhdl-mode.el --- major mode for editing VHDL code
3 ;; Copyright (C) 1992-2016 Free Software Foundation, Inc.
5 ;; Authors: Reto Zimmermann <reto@gnu.org>
6 ;; Rodney J. Whitby <software.vhdl-mode@rwhitby.net>
7 ;; Maintainer: Reto Zimmermann <reto@gnu.org>
8 ;; Keywords: languages vhdl
9 ;; WWW: http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html
11 ;; Yoni Rabkin <yoni@rabkins.net> contacted the maintainer of this
12 ;; file on 18/3/2008, and the maintainer agreed that when a bug is
13 ;; filed in the Emacs bug reporting system against this file, a copy
14 ;; of the bug report be sent to the maintainer's email address.
16 (defconst vhdl-version
"3.38.1"
17 "VHDL Mode version number.")
19 (defconst vhdl-time-stamp
"2015-03-12"
20 "VHDL Mode time stamp for last update.")
22 ;; This file is part of GNU Emacs.
24 ;; GNU Emacs is free software: you can redistribute it and/or modify
25 ;; it under the terms of the GNU General Public License as published by
26 ;; the Free Software Foundation, either version 3 of the License, or
27 ;; (at your option) any later version.
29 ;; GNU Emacs is distributed in the hope that it will be useful,
30 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
31 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 ;; GNU General Public License for more details.
34 ;; You should have received a copy of the GNU General Public License
35 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ;; This package provides an Emacs major mode for editing VHDL code.
42 ;; It includes the following features:
44 ;; - Syntax highlighting
46 ;; - Template insertion (electrification)
47 ;; - Insertion of file headers
48 ;; - Insertion of user-specified models
49 ;; - Port translation / testbench generation
50 ;; - Structural composition
51 ;; - Configuration generation
52 ;; - Sensitivity list updating
54 ;; - Design hierarchy browser
55 ;; - Source file compilation (syntax analysis)
56 ;; - Makefile generation
58 ;; - Word/keyword completion
60 ;; - Code fixing/alignment/beautification
61 ;; - PostScript printing
62 ;; - VHDL'87/'93/'02/'08 and VHDL-AMS supported
63 ;; - Comprehensive menu
64 ;; - Fully customizable
65 ;; - Works under GNU Emacs (recommended) and XEmacs
67 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70 ;; See comment string of function `vhdl-mode' or type `C-c C-h' in Emacs.
72 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75 ;; this updated version was only tested on: GNU Emacs 24.1
77 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80 ;; Prerequisites: GNU Emacs 20/21/22/23/24, XEmacs 20/21.
82 ;; Put `vhdl-mode.el' into the `site-lisp' directory of your Emacs installation
83 ;; or into an arbitrary directory that is added to the load path by the
84 ;; following line in your Emacs start-up file `.emacs':
86 ;; (push (expand-file-name "<directory-name>") load-path)
88 ;; If you already have the compiled `vhdl-mode.elc' file, put it in the same
89 ;; directory. Otherwise, byte-compile the source file:
90 ;; Emacs: M-x byte-compile-file RET vhdl-mode.el RET
91 ;; Unix: emacs -batch -q -no-site-file -f batch-byte-compile vhdl-mode.el
93 ;; Add the following lines to the `site-start.el' file in the `site-lisp'
94 ;; directory of your Emacs installation or to your Emacs start-up file `.emacs'
95 ;; (not required in Emacs 20 and higher):
97 ;; (autoload 'vhdl-mode "vhdl-mode" "VHDL Mode" t)
98 ;; (push '("\\.vhdl?\\'" . vhdl-mode) auto-mode-alist)
100 ;; More detailed installation instructions are included in the official
101 ;; VHDL Mode distribution.
103 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
106 ;; Electrification ideas by Bob Pack <rlpst@cislabs.pitt.edu>
109 ;; Fontification approach suggested by Ken Wood <ken@eda.com.au>.
110 ;; Ideas about alignment from John Wiegley <johnw@gnu.org>.
112 ;; Many thanks to all the users who sent me bug reports and enhancement
114 ;; Thanks to Colin Marquardt for his serious beta testing, his innumerable
115 ;; enhancement suggestions and the fruitful discussions.
116 ;; Thanks to Dan Nicolaescu for reviewing the code and for his valuable hints.
117 ;; Thanks to Ulf Klaperski for the indentation speedup hint.
119 ;; Special thanks go to Wolfgang Fichtner and the crew from the Integrated
120 ;; Systems Laboratory, Swiss Federal Institute of Technology Zurich, for
121 ;; giving me the opportunity to develop this code.
122 ;; This work has been funded in part by MICROSWISS, a Microelectronics Program
123 ;; of the Swiss Government.
125 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
129 ;; Emacs 21+ handling
130 (defconst vhdl-emacs-21
(and (<= 21 emacs-major-version
) (not (featurep 'xemacs
)))
131 "Non-nil if GNU Emacs 21, 22, ... is used.")
132 ;; Emacs 22+ handling
133 (defconst vhdl-emacs-22
(and (<= 22 emacs-major-version
) (not (featurep 'xemacs
)))
134 "Non-nil if GNU Emacs 22, ... is used.")
136 (defvar compilation-file-regexp-alist
)
141 (defvar itimer-version
)
142 (defvar lazy-lock-defer-contextually
)
143 (defvar lazy-lock-defer-on-scrolling
)
144 (defvar lazy-lock-defer-on-the-fly
)
145 (defvar speedbar-attached-frame
)
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
152 ;; help function for user options
153 (defun vhdl-custom-set (variable value
&rest functions
)
154 "Set variables as in `custom-set-default' and call FUNCTIONS afterwards."
155 (if (fboundp 'custom-set-default
)
156 (custom-set-default variable value
)
157 (set-default variable value
))
159 (when (fboundp (car functions
)) (funcall (car functions
)))
160 (setq functions
(cdr functions
))))
162 (defun vhdl-widget-directory-validate (widget)
163 "Check that the value of WIDGET is a valid directory entry (i.e. ends with
165 (let ((val (widget-value widget
)))
166 (unless (string-match "^\\(\\|.*/\\)$" val
)
167 (widget-put widget
:error
"Invalid directory entry: must end with `/'")
170 ;; help string for user options
171 (defconst vhdl-name-doc-string
"
173 FROM REGEXP is a regular expression matching the original name:
174 \".*\" matches the entire string
175 \"\\(...\\)\" matches a substring
176 TO STRING specifies the string to be inserted as new name:
177 \"\\&\" means substitute entire matched text
178 \"\\N\" means substitute what matched the Nth \"\\(...\\)\"
180 \".*\" \"\\&\" inserts original string
181 \".*\" \"\\&_i\" attaches \"_i\" to original string
182 \"\\(.*\\)_[io]$\" \"\\1\" strips off \"_i\" or \"_o\" from original string
183 \".*\" \"foo\" inserts constant string \"foo\"
184 \".*\" \"\" inserts empty string")
186 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
187 ;; User variables (customization options)
190 "Customizations for VHDL Mode."
193 ; :version "21.2" ; comment out for XEmacs
196 (defgroup vhdl-mode nil
197 "Customizations for modes."
200 (defcustom vhdl-indent-tabs-mode nil
201 "Non-nil means indentation can insert tabs.
202 Overrides local variable `indent-tabs-mode'."
207 (defgroup vhdl-compile nil
208 "Customizations for compilation."
211 (defcustom vhdl-compiler-alist
213 ;; 60: docal <= false;
215 ;; [Error] Assignment error: variable is illegal target of signal assignment
216 ("ADVance MS" "vacom" "-work \\1" "make" "-f \\1"
217 nil
"valib \\1; vamap \\2 \\1" "./" "work/" "Makefile" "adms"
218 ("^\\s-+\\([0-9]+\\):\\s-+" nil
1 nil
) ("^Compiling file \\(.+\\)" 1)
219 ("ENTI/\\1.vif" "ARCH/\\1-\\2.vif" "CONF/\\1.vif"
220 "PACK/\\1.vif" "BODY/\\1.vif" upcase
))
222 ;; COMP96 ERROR COMP96_0018: "Identifier expected." "test.vhd" 66 3
223 ("Aldec" "vcom" "-work \\1" "make" "-f \\1"
224 nil
"vlib \\1; vmap \\2 \\1" "./" "work/" "Makefile" "aldec"
225 ("^.* ERROR [^:]+: \".*\" \"\\([^ \t\n]+\\)\" \\([0-9]+\\) \\([0-9]+\\)" 1 2 3) ("" 0)
227 ;; Cadence Leapfrog: cv -file test.vhd
228 ;; duluth: *E,430 (test.vhd,13): identifier (POSITIV) is not declared
229 ("Cadence Leapfrog" "cv" "-work \\1 -file" "make" "-f \\1"
230 nil
"mkdir \\1" "./" "work/" "Makefile" "leapfrog"
231 ("^duluth: \\*E,[0-9]+ (\\([^ \t\n]+\\),\\([0-9]+\\)):" 1 2 nil
) ("" 0)
232 ("\\1/entity" "\\2/\\1" "\\1/configuration"
233 "\\1/package" "\\1/body" downcase
))
234 ;; Cadence Affirma NC vhdl: ncvhdl test.vhd
235 ;; ncvhdl_p: *E,IDENTU (test.vhd,13|25): identifier
236 ;; (PLL_400X_TOP) is not declared [10.3].
237 ("Cadence NC" "ncvhdl" "-work \\1" "make" "-f \\1"
238 nil
"mkdir \\1" "./" "work/" "Makefile" "ncvhdl"
239 ("^ncvhdl_p: \\*E,\\w+ (\\([^ \t\n]+\\),\\([0-9]+\\)|\\([0-9]+\\)):" 1 2 3) ("" 0)
240 ("\\1/entity/pc.db" "\\2/\\1/pc.db" "\\1/configuration/pc.db"
241 "\\1/package/pc.db" "\\1/body/pc.db" downcase
))
243 ;; ghdl -a bad_counter.vhdl
244 ;; bad_counter.vhdl:13:14: operator "=" is overloaded
245 ("GHDL" "ghdl" "-i --workdir=\\1 --ieee=synopsys -fexplicit " "make" "-f \\1"
246 nil
"mkdir \\1" "./" "work/" "Makefile" "ghdl"
247 ("^ghdl_p: \\*E,\\w+ (\\([^ \t\n]+\\),\\([0-9]+\\)|\\([0-9]+\\)):" 1 2 3) ("" 0)
248 ("\\1/entity" "\\2/\\1" "\\1/configuration"
249 "\\1/package" "\\1/body" downcase
))
251 ;; 00 COACHDL* | [CCHDL-1]: File: adder.vhd, line.column: 120.6
252 ("IBM Compiler" "g2tvc" "-src" "precomp" "\\1"
253 nil
"mkdir \\1" "./" "work/" "Makefile" "ibm"
254 ("^[0-9]+ COACHDL.*: File: \\([^ \t\n]+\\), *line.column: \\([0-9]+\\).\\([0-9]+\\)" 1 2 3) (" " 0)
256 ;; Ikos Voyager: analyze test.vhd
258 ;; E L4/C5: this library unit is inaccessible
259 ("Ikos" "analyze" "-l \\1" "make" "-f \\1"
260 nil
"mkdir \\1" "./" "work/" "Makefile" "ikos"
261 ("^E L\\([0-9]+\\)/C\\([0-9]+\\):" nil
1 2)
262 ("^analyze +\\(.+ +\\)*\\(.+\\)$" 2)
264 ;; ModelSim, Model Technology: vcom test.vhd
265 ;; ERROR: test.vhd(14): Unknown identifier: positiv
266 ;; WARNING[2]: test.vhd(85): Possible infinite loop
267 ;; ** Warning: [4] ../src/emacsvsim.vhd(43): An abstract ...
268 ;; ** Error: adder.vhd(190): Unknown identifier: ctl_numb
269 ;; ** Error: counter_rtl.vhd(18): Nonresolved signal 'hallo' has multiple sources.
271 ;; counter_rtl.vhd(27):Conditional signal assignment line__27
272 ;; counter_rtl.vhd(29):Conditional signal assignment line__29
273 ("ModelSim" "vcom" "-93 -work \\1" "make" "-f \\1"
274 nil
"vlib \\1; vmap \\2 \\1" "./" "work/" "Makefile" "modelsim"
275 ("\\(ERROR:\\|WARNING\\[[0-9]+\\]:\\|\\*\\* Error:\\|\\*\\* Warning: \\[[0-9]+\\]\\| +\\) \\([^ ]+\\)(\\([0-9]+\\)):" 2 3 nil
)
277 ("\\1/_primary.dat" "\\2/\\1.dat" "\\1/_primary.dat"
278 "\\1/_primary.dat" "\\1/body.dat" downcase
))
279 ;; ProVHDL, Synopsys LEDA: provhdl -w work -f test.vhd
280 ;; test.vhd:34: error message
281 ("LEDA ProVHDL" "provhdl" "-w \\1 -f" "make" "-f \\1"
282 nil
"mkdir \\1" "./" "work/" "Makefile" "provhdl"
283 ("^\\([^ \t\n:]+\\):\\([0-9]+\\): " 1 2 nil
) ("" 0)
284 ("ENTI/\\1.vif" "ARCH/\\1-\\2.vif" "CONF/\\1.vif"
285 "PACK/\\1.vif" "BODY/BODY-\\1.vif" upcase
))
287 ;; Error: VHDL error at dvi2sdi.vhd(473): object k2_alto_out_lvl is used
288 ;; Error: Verilog HDL syntax error at otsuif_v1_top.vhd(147) near text
289 ;; Error: VHDL syntax error at otsuif_v1_top.vhd(147): clk_ is an illegal
290 ;; Error: VHDL Use Clause error at otsuif_v1_top.vhd(455): design library
291 ;; Warning: VHDL Process Statement warning at dvi2sdi_tst.vhd(172): ...
292 ("Quartus" "make" "-work \\1" "make" "-f \\1"
293 nil
"mkdir \\1" "./" "work/" "Makefile" "quartus"
294 ("^\\(Error\\|Warning\\): .* \\([^ \t\n]+\\)(\\([0-9]+\\))" 2 3 nil
) ("" 0)
296 ;; QuickHDL, Mentor Graphics: qvhcom test.vhd
297 ;; ERROR: test.vhd(24): near "dnd": expecting: END
298 ;; WARNING[4]: test.vhd(30): A space is required between ...
299 ("QuickHDL" "qvhcom" "-work \\1" "make" "-f \\1"
300 nil
"mkdir \\1" "./" "work/" "Makefile" "quickhdl"
301 ("^\\(ERROR\\|WARNING\\)[^:]*: \\([^ \t\n]+\\)(\\([0-9]+\\)):" 2 3 nil
) ("" 0)
302 ("\\1/_primary.dat" "\\2/\\1.dat" "\\1/_primary.dat"
303 "\\1/_primary.dat" "\\1/body.dat" downcase
))
304 ;; Savant: scram -publish-cc test.vhd
305 ;; test.vhd:87: _set_passed_through_out_port(IIR_Boolean) not defined for
306 ("Savant" "scram" "-publish-cc -design-library-name \\1" "make" "-f \\1"
307 nil
"mkdir \\1" "./" "work._savant_lib/" "Makefile" "savant"
308 ("^\\([^ \t\n:]+\\):\\([0-9]+\\): " 1 2 nil
) ("" 0)
309 ("\\1_entity.vhdl" "\\2_secondary_units._savant_lib/\\2_\\1.vhdl"
310 "\\1_config.vhdl" "\\1_package.vhdl"
311 "\\1_secondary_units._savant_lib/\\1_package_body.vhdl" downcase
))
312 ;; Simili: vhdlp -work test.vhd
313 ;; Error: CSVHDL0002: test.vhd: (line 97): Invalid prefix
314 ("Simili" "vhdlp" "-work \\1" "make" "-f \\1"
315 nil
"mkdir \\1" "./" "work/" "Makefile" "simili"
316 ("^\\(Error\\|Warning\\): \\w+: \\([^ \t\n]+\\): (line \\([0-9]+\\)): " 2 3 nil
) ("" 0)
317 ("\\1/prim.var" "\\2/_\\1.var" "\\1/prim.var"
318 "\\1/prim.var" "\\1/_body.var" downcase
))
319 ;; Speedwave (Innoveda): analyze -libfile vsslib.ini -src test.vhd
320 ;; ERROR[11]::File test.vhd Line 100: Use of undeclared identifier
321 ("Speedwave" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
322 nil
"mkdir \\1" "./" "work/" "Makefile" "speedwave"
323 ("^ *ERROR\\[[0-9]+]::File \\([^ \t\n]+\\) Line \\([0-9]+\\):" 1 2 nil
) ("" 0)
325 ;; Synopsys, VHDL Analyzer (sim): vhdlan -nc test.vhd
326 ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
327 ("Synopsys" "vhdlan" "-nc -work \\1" "make" "-f \\1"
328 nil
"mkdir \\1" "./" "work/" "Makefile" "synopsys"
329 ("^\\*\\*Error: vhdlan,[0-9]+ \\([^ \t\n]+\\)(\\([0-9]+\\)):" 1 2 nil
) ("" 0)
330 ("\\1.sim" "\\2__\\1.sim" "\\1.sim" "\\1.sim" "\\1__.sim" upcase
))
331 ;; Synopsys, VHDL Analyzer (syn): vhdlan -nc -spc test.vhd
332 ;; **Error: vhdlan,703 test.vhd(22): OTHERS is not legal in this context.
333 ("Synopsys Design Compiler" "vhdlan" "-nc -spc -work \\1" "make" "-f \\1"
334 nil
"mkdir \\1" "./" "work/" "Makefile" "synopsys_dc"
335 ("^\\*\\*Error: vhdlan,[0-9]+ \\([^ \t\n]+\\)(\\([0-9]+\\)):" 1 2 nil
) ("" 0)
336 ("\\1.syn" "\\2__\\1.syn" "\\1.syn" "\\1.syn" "\\1__.syn" upcase
))
338 ;; @W:"test.vhd":57:8:57:9|Optimizing register bit count_x(5) to a constant 0
339 ("Synplify" "n/a" "n/a" "make" "-f \\1"
340 nil
"mkdir \\1" "./" "work/" "Makefile" "synplify"
341 ("^@[EWN]:\"\\([^ \t\n]+\\)\":\\([0-9]+\\):\\([0-9]+\\):" 1 2 3) ("" 0)
343 ;; Vantage: analyze -libfile vsslib.ini -src test.vhd
344 ;; Compiling "test.vhd" line 1...
345 ;; **Error: LINE 49 *** No aggregate value is valid in this context.
346 ("Vantage" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
347 nil
"mkdir \\1" "./" "work/" "Makefile" "vantage"
348 ("^\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil
1 nil
)
349 ("^ *Compiling \"\\(.+\\)\" " 1)
351 ;; VeriBest: vc vhdl test.vhd
352 ;; (no file name printed out!)
353 ;; 32: Z <= A and BitA ;
355 ;; [Error] Name BITA is unknown
356 ("VeriBest" "vc" "vhdl" "make" "-f \\1"
357 nil
"mkdir \\1" "./" "work/" "Makefile" "veribest"
358 ("^ +\\([0-9]+\\): +[^ ]" nil
1 nil
) ("" 0)
360 ;; Viewlogic: analyze -libfile vsslib.ini -src test.vhd
361 ;; Compiling "test.vhd" line 1...
362 ;; **Error: LINE 49 *** No aggregate value is valid in this context.
363 ("Viewlogic" "analyze" "-libfile vsslib.ini -src" "make" "-f \\1"
364 nil
"mkdir \\1" "./" "work/" "Makefile" "viewlogic"
365 ("^\\*\\*Error: LINE \\([0-9]+\\) \\*\\*\\*" nil
1 nil
)
366 ("^ *Compiling \"\\(.+\\)\" " 1)
369 ;; ERROR:HDLParsers:164 - "test.vhd" Line 3. parse error
370 ("Xilinx XST" "xflow" "" "make" "-f \\1"
371 nil
"mkdir \\1" "./" "work/" "Makefile" "xilinx"
372 ("^ERROR:HDLParsers:[0-9]+ - \"\\([^ \t\n]+\\)\" Line \\([0-9]+\\)\\." 1 2 nil
) ("" 0)
375 "List of available VHDL compilers and their properties.
376 Each list entry specifies the following items for a compiler:
378 Compiler name : name used in option `vhdl-compiler' to choose compiler
379 Compile command : command used for source file compilation
380 Compile options : compile options (\"\\1\" inserts library name)
381 Make command : command used for compilation using a Makefile
382 Make options : make options (\"\\1\" inserts Makefile name)
383 Generate Makefile: use built-in function or command to generate a Makefile
384 (\"\\1\" inserts Makefile name, \"\\2\" inserts library name)
385 Library command : command to create library directory (\"\\1\" inserts
386 library directory, \"\\2\" inserts library name)
387 Compile directory: where compilation is run and the Makefile is placed
388 Library directory: directory of default library
389 Makefile name : name of Makefile (default is \"Makefile\")
390 ID string : compiler identification string (see `vhdl-project-alist')
392 Regexp : regular expression to match error messages (*)
393 File subexp index: index of subexpression that matches the file name
394 Line subexp index: index of subexpression that matches the line number
395 Column subexp idx: index of subexpression that matches the column number
397 Regexp : regular expression to match a file name message
398 File subexp index: index of subexpression that matches the file name
399 Unit-to-file name mapping: mapping of library unit names to names of files
400 generated by the compiler (used for Makefile generation)
401 To string : string a name is mapped to (\"\\1\" inserts the unit name,
402 \"\\2\" inserts the entity name for architectures,
403 \"\\3\" inserts the library name)
404 Case adjustment : adjust case of inserted unit names
406 \(*) The regular expression must match the error message starting from the
407 beginning of the line (but not necessarily to the end of the line).
409 Compile options allows insertion of the library name (see `vhdl-project-alist')
410 in order to set the compilers library option (e.g. \"vcom -work my_lib\").
412 For Makefile generation, the built-in function can be used (requires
413 specification of the unit-to-file name mapping). Alternatively, an
414 external command can be specified. Work directory allows specification of
415 an alternative \"work\" library path (e.g. \"WORK/\" instead of \"work/\",
416 used for Makefile generation). To use another library name than \"work\",
417 customize `vhdl-project-alist'. The library command is inserted in Makefiles
418 to automatically create the library directory if not existent.
420 Compile options, compile directory, library directory, and Makefile name are
421 overwritten by the project settings if a project is defined (see
422 `vhdl-project-alist'). Directory paths are relative to the source file
425 Some compilers do not include the file name in the error message, but print
426 out a file name message in advance. In this case, set \"File Subexp Index\"
427 under \"Error Message\" to 0 and fill out the \"File Message\" entries.
428 If no file name at all is printed out, set both \"File Message\" entries to 0
429 \(a default file name message will be printed out instead, does not work in
432 A compiler is selected for syntax analysis (`\\[vhdl-compile]') by
433 assigning its name to option `vhdl-compiler'.
435 Please send any missing or erroneous compiler properties to the maintainer for
438 NOTE: Activate new error and file message regexps and reflect the new setting
439 in the choice list of option `vhdl-compiler' by restarting Emacs."
441 (list :tag
"Compiler" :indent
2
442 (string :tag
"Compiler name ")
443 (string :tag
"Compile command ")
444 (string :tag
"Compile options " "-work \\1")
445 (string :tag
"Make command " "make")
446 (string :tag
"Make options " "-f \\1")
447 (choice :tag
"Generate Makefile "
448 (const :tag
"Built-in function" nil
)
449 (string :tag
"Command" "vmake \\2 > \\1"))
450 (string :tag
"Library command " "mkdir \\1")
451 (directory :tag
"Compile directory "
452 :validate vhdl-widget-directory-validate
"./")
453 (directory :tag
"Library directory "
454 :validate vhdl-widget-directory-validate
"work/")
455 (file :tag
"Makefile name " "Makefile")
456 (string :tag
"ID string ")
457 (list :tag
"Error message" :indent
4
458 (regexp :tag
"Regexp ")
459 (choice :tag
"File subexp "
460 (integer :tag
"Index")
461 (const :tag
"No file name" nil
))
462 (integer :tag
"Line subexp index")
463 (choice :tag
"Column subexp "
464 (integer :tag
"Index")
465 (const :tag
"No column number" nil
)))
466 (list :tag
"File message" :indent
4
467 (regexp :tag
"Regexp ")
468 (integer :tag
"File subexp index"))
469 (choice :tag
"Unit-to-file name mapping"
470 :format
"%t: %[Value Menu%] %v\n"
471 (const :tag
"Not defined" nil
)
472 (list :tag
"To string" :indent
4
473 (string :tag
"Entity " "\\1.vhd")
474 (string :tag
"Architecture " "\\2_\\1.vhd")
475 (string :tag
"Configuration " "\\1.vhd")
476 (string :tag
"Package " "\\1.vhd")
477 (string :tag
"Package Body " "\\1_body.vhd")
478 (choice :tag
"Case adjustment "
479 (const :tag
"None" identity
)
480 (const :tag
"Upcase" upcase
)
481 (const :tag
"Downcase" downcase
))))))
482 :set
(lambda (variable value
)
483 (vhdl-custom-set variable value
'vhdl-update-mode-menu
))
485 :group
'vhdl-compile
)
487 (defcustom vhdl-compiler
"GHDL"
488 "Specifies the VHDL compiler to be used for syntax analysis.
489 Select a compiler name from the ones defined in option `vhdl-compiler-alist'."
490 :type
(let ((alist vhdl-compiler-alist
) list
)
492 (push (list 'const
(caar alist
)) list
)
493 (setq alist
(cdr alist
)))
494 (append '(choice) (nreverse list
)))
495 :group
'vhdl-compile
)
497 (defcustom vhdl-compile-use-local-error-regexp nil
498 "Non-nil means use buffer-local `compilation-error-regexp-alist'.
499 In this case, only error message regexps for VHDL compilers are active if
500 compilation is started from a VHDL buffer. Otherwise, the error message
501 regexps are appended to the predefined global regexps, and all regexps are
502 active all the time. Note that by doing that, the predefined global regexps
503 might result in erroneous parsing of error messages for some VHDL compilers.
505 NOTE: Activate the new setting by restarting Emacs."
506 :version
"25.1" ; t -> nil
508 :group
'vhdl-compile
)
510 (defcustom vhdl-makefile-default-targets
'("all" "clean" "library")
511 "List of default target names in Makefiles.
512 Automatically generated Makefiles include three default targets to compile
513 the entire design, clean the entire design and to create the design library.
514 This option allows you to change the names of these targets to avoid conflicts
515 with other user Makefiles."
516 :type
'(list (string :tag
"Compile entire design")
517 (string :tag
"Clean entire design ")
518 (string :tag
"Create design library"))
520 :group
'vhdl-compile
)
522 (defcustom vhdl-makefile-generation-hook nil
523 "Functions to run at the end of Makefile generation.
524 Allows you to insert user specific parts into a Makefile.
528 (re-search-backward \"^# Rule for compiling entire design\")
529 (insert \"# My target\\n\\n.MY_TARGET :\\n\\n\\n\"))"
531 :group
'vhdl-compile
)
533 (defcustom vhdl-default-library
"work"
534 "Name of default library.
535 Is overwritten by project settings if a project is active."
537 :group
'vhdl-compile
)
540 (defgroup vhdl-project nil
541 "Customizations for projects."
544 (defcustom vhdl-project-alist
545 '(("Example 1" "Source files in two directories, custom library name, VHDL'87"
546 "~/example1/" ("src/system/" "src/components/") ""
547 (("ModelSim" "-87 \\2" "-f \\1 top_level" nil
)
548 ("Synopsys" "-vhdl87 \\2" "-f \\1 top_level" ((".*/datapath/.*" .
"-optimize \\3") (".*_tb\\.vhd" . nil
))))
549 "lib/" "example3_lib" "lib/example3/" "Makefile_\\2" "")
550 ("Example 2" "Individual source files, multiple compilers in different directories"
551 "$EXAMPLE2/" ("vhdl/system.vhd" "vhdl/component_*.vhd") ""
552 nil
"\\1/" "work" "\\1/work/" "Makefile" "")
553 ("Example 3" "Source files in a directory tree, multiple compilers in same directory"
554 "/home/me/example3/" ("-r ./*/vhdl/") "/CVS/"
555 nil
"./" "work" "work-\\1/" "Makefile-\\1" "\
556 -------------------------------------------------------------------------------
557 -- This is a multi-line project description
558 -- that can be used as a project dependent part of the file header.
560 "List of projects and their properties.
561 Name : name used in option `vhdl-project' to choose project
562 Title : title of project (single-line string)
563 Default directory: default project directory (absolute path)
564 Sources : a) source files : path + \"/\" + file name
565 b) directory : path + \"/\"
566 c) directory tree: \"-r \" + path + \"/\"
567 Exclude regexp : matches file/directory names to be excluded as sources
568 Compile options : project-specific options for each compiler
569 Compiler name : name of compiler for which these options are valid
570 Compile options: project-specific compiler options
571 (\"\\1\" inserts library name, \"\\2\" default options)
572 Make options: project-specific make options
573 (\"\\1\" inserts Makefile name, \"\\2\" default options)
574 Exceptions : file-specific exceptions
575 File name regexp: matches file names for which exceptions are valid
576 - Options : file-specific compiler options string
577 (\"\\1\" inserts library name, \"\\2\" default options,
578 \"\\3\" project-specific options)
579 - Do not compile: do not compile this file (in Makefile)
580 Compile directory: where compilation is run and the Makefile is placed
581 (\"\\1\" inserts compiler ID string)
582 Library name : name of library (default is \"work\")
583 Library directory: path to library (\"\\1\" inserts compiler ID string)
584 Makefile name : name of Makefile
585 (\"\\1\" inserts compiler ID string, \"\\2\" library name)
586 Description : description of project (multi-line string)
588 Project title and description are used to insert into the file header (see
589 option `vhdl-file-header').
591 The default directory must have an absolute path (use `M-TAB' for completion).
592 All other paths can be absolute or relative to the default directory. All
593 paths must end with `/'.
595 The design units found in the sources (files and directories) are shown in the
596 hierarchy browser. Path and file name can contain wildcards `*' and `?' as
597 well as \"./\" and \"../\" (\"sh\" syntax). Paths can also be absolute.
598 Environment variables (e.g. \"$EXAMPLE2\") are resolved. If no sources are
599 specified, the default directory is taken as source directory. Otherwise,
600 the default directory is only taken as source directory if there is a sources
601 entry with the empty string or \"./\". Exclude regexp allows you to filter
602 out specific file and directory names from the list of sources (e.g. CVS
605 Files are compiled in the compile directory. Makefiles are also placed into
606 the compile directory. Library directory specifies which directory the
607 compiler compiles into (used to generate the Makefile).
609 Since different compile/library directories and Makefiles may exist for
610 different compilers within one project, these paths and names allow the
611 insertion of a compiler-dependent ID string (defined in `vhdl-compiler-alist').
612 Compile options, compile directory, library directory, and Makefile name
613 overwrite the settings of the current compiler.
615 File-specific compiler options (highest priority) overwrite project-specific
616 options which overwrite default options (lowest priority). Lower priority
617 options can be inserted in higher priority options. This allows you to reuse
618 default options (e.g. \"-file\") in project- or file-specific options (e.g.
621 NOTE: Reflect the new setting in the choice list of option `vhdl-project'
622 by restarting Emacs."
624 (list :tag
"Project" :indent
2
625 (string :tag
"Name ")
626 (string :tag
"Title ")
627 (directory :tag
"Default directory"
628 :validate vhdl-widget-directory-validate
629 ,(abbreviate-file-name default-directory
))
630 (repeat :tag
"Sources " :indent
4
631 (directory :format
" %v" "./"))
632 (regexp :tag
"Exclude regexp ")
634 :tag
"Compile options " :indent
4
635 (list :tag
"Compiler" :indent
6
636 ,(let ((alist vhdl-compiler-alist
) list
)
638 (push (list 'const
(caar alist
)) list
)
639 (setq alist
(cdr alist
)))
640 (append '(choice :tag
"Compiler name")
642 (string :tag
"Compile options" "\\2")
643 (string :tag
"Make options " "\\2")
645 :tag
"Exceptions " :indent
8
647 (regexp :tag
"File name regexp ")
648 (choice :format
"%[Value Menu%] %v"
649 (string :tag
"Options" "\\3")
650 (const :tag
"Do not compile" nil
))))))
651 (directory :tag
"Compile directory"
652 :validate vhdl-widget-directory-validate
"./")
653 (string :tag
"Library name " "work")
654 (directory :tag
"Library directory"
655 :validate vhdl-widget-directory-validate
"work/")
656 (file :tag
"Makefile name " "Makefile")
657 (string :tag
"Description: (type `C-j' for newline)"
658 :format
"%t\n%v\n")))
659 :set
(lambda (variable value
)
660 (vhdl-custom-set variable value
661 'vhdl-update-mode-menu
662 'vhdl-speedbar-refresh
))
663 :group
'vhdl-project
)
665 (defcustom vhdl-project nil
666 "Specifies the default for the current project.
667 Select a project name from the ones defined in option `vhdl-project-alist'.
668 Is used to determine the project title and description to be inserted in file
669 headers and the source files/directories to be scanned in the hierarchy
670 browser. The current project can also be changed temporarily in the menu."
671 :type
(let ((alist vhdl-project-alist
) list
)
673 (push (list 'const
(caar alist
)) list
)
674 (setq alist
(cdr alist
)))
675 (append '(choice (const :tag
"None" nil
) (const :tag
"--"))
677 :group
'vhdl-project
)
679 (defcustom vhdl-project-file-name
'("\\1.prj")
680 "List of file names/paths for importing/exporting project setups.
681 \"\\1\" is replaced by the project name (SPC is replaced by `_'), \"\\2\" is
682 replaced by the user name (allows you to have user-specific project setups).
683 The first entry is used as file name to import/export individual project
684 setups. All entries are used to automatically import project setups at
685 startup (see option `vhdl-project-auto-load'). Projects loaded from the
686 first entry are automatically made current. Hint: specify local project
687 setups in first entry, global setups in following entries; loading a local
688 project setup will make it current, while loading the global setups
689 is done without changing the current project.
690 Names can also have an absolute path (i.e. project setups can be stored
691 in global directories)."
692 :type
'(repeat (string :tag
"File name" "\\1.prj"))
693 :group
'vhdl-project
)
695 (defcustom vhdl-project-auto-load
'(startup)
696 "Automatically load project setups from files.
697 All project setup files that match the file names specified in option
698 `vhdl-project-file-name' are automatically loaded. The project of the
699 \(alphabetically) last loaded setup of the first `vhdl-project-file-name'
701 A project setup file can be obtained by exporting a project (see menu).
702 At startup: project setup file is loaded at Emacs startup"
703 :type
'(set (const :tag
"At startup" startup
))
704 :group
'vhdl-project
)
706 (defcustom vhdl-project-sort t
707 "Non-nil means projects are displayed in alphabetical order."
709 :group
'vhdl-project
)
712 (defgroup vhdl-style nil
713 "Customizations for coding styles."
715 :group
'vhdl-template
717 :group
'vhdl-compose
)
719 (defcustom vhdl-standard
'(93 nil
)
720 "VHDL standards used.
722 VHDL'87 : IEEE Std 1076-1987
723 VHDL'93/02 : IEEE Std 1076-1993/2002
724 VHDL'08 : IEEE Std 1076-2008
725 Additional standards:
726 VHDL-AMS : IEEE Std 1076.1 (analog-mixed-signal)
727 Math packages: IEEE Std 1076.2 (`math_real', `math_complex')
729 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
730 \"Activate Options\"."
731 :type
'(list (choice :tag
"Basic standard"
732 (const :tag
"VHDL'87" 87)
733 (const :tag
"VHDL'93/02" 93)
734 (const :tag
"VHDL'08" 08))
735 (set :tag
"Additional standards" :indent
2
736 (const :tag
"VHDL-AMS" ams
)
737 (const :tag
"Math packages" math
)))
738 :set
(lambda (variable value
)
739 (vhdl-custom-set variable value
740 'vhdl-template-map-init
741 'vhdl-mode-abbrev-table-init
742 'vhdl-template-construct-alist-init
743 'vhdl-template-package-alist-init
744 'vhdl-update-mode-menu
745 'vhdl-words-init
'vhdl-font-lock-init
))
748 (defcustom vhdl-basic-offset
2
749 "Amount of basic offset used for indentation.
750 This value is used by + and - symbols in `vhdl-offsets-alist'."
754 (defcustom vhdl-upper-case-keywords nil
755 "Non-nil means convert keywords to upper case.
756 This is done when typed or expanded or by the fix case functions."
758 :set
(lambda (variable value
)
759 (vhdl-custom-set variable value
'vhdl-abbrev-list-init
))
762 (defcustom vhdl-upper-case-types nil
763 "Non-nil means convert standardized types to upper case.
764 This is done when expanded or by the fix case functions."
766 :set
(lambda (variable value
)
767 (vhdl-custom-set variable value
'vhdl-abbrev-list-init
))
770 (defcustom vhdl-upper-case-attributes nil
771 "Non-nil means convert standardized attributes to upper case.
772 This is done when expanded or by the fix case functions."
774 :set
(lambda (variable value
)
775 (vhdl-custom-set variable value
'vhdl-abbrev-list-init
))
778 (defcustom vhdl-upper-case-enum-values nil
779 "Non-nil means convert standardized enumeration values to upper case.
780 This is done when expanded or by the fix case functions."
782 :set
(lambda (variable value
)
783 (vhdl-custom-set variable value
'vhdl-abbrev-list-init
))
786 (defcustom vhdl-upper-case-constants t
787 "Non-nil means convert standardized constants to upper case.
788 This is done when expanded."
790 :set
(lambda (variable value
)
791 (vhdl-custom-set variable value
'vhdl-abbrev-list-init
))
794 (defcustom vhdl-use-direct-instantiation
'standard
795 "Non-nil means use VHDL'93 direct component instantiation.
797 Standard: only in VHDL standards that allow it (VHDL'93 and higher)
799 :type
'(choice (const :tag
"Never" never
)
800 (const :tag
"Standard" standard
)
801 (const :tag
"Always" always
))
804 (defcustom vhdl-array-index-record-field-in-sensitivity-list t
805 "Non-nil means include array indices / record fields in sensitivity list.
806 If a signal read in a process is a record field or pointed to by an array
807 index, the record field or array index is included with the record name in
808 the sensitivity list (e.g. \"in1(0)\", \"in2.f0\").
809 Otherwise, only the record name is included (e.g. \"in1\", \"in2\")."
814 (defgroup vhdl-naming nil
815 "Customizations for naming conventions."
818 (defcustom vhdl-entity-file-name
'(".*" .
"\\&")
820 "Specifies how the entity file name is obtained.
821 The entity file name can be obtained by modifying the entity name (e.g.
822 attaching or stripping off a substring). The file extension is automatically
823 taken from the file name of the current buffer."
824 vhdl-name-doc-string
)
825 :type
'(cons (regexp :tag
"From regexp")
826 (string :tag
"To string "))
828 :group
'vhdl-compose
)
830 (defcustom vhdl-architecture-file-name
'("\\(.*\\) \\(.*\\)" .
"\\1_\\2")
832 "Specifies how the architecture file name is obtained.
833 The architecture file name can be obtained by modifying the entity
834 and/or architecture name (e.g. attaching or stripping off a substring). The
835 file extension is automatically taken from the file name of the current
836 buffer. The string that is matched against the regexp is the concatenation
837 of the entity and the architecture name separated by a space. This gives
838 access to both names (see default setting as example)."
839 vhdl-name-doc-string
)
840 :type
'(cons (regexp :tag
"From regexp")
841 (string :tag
"To string "))
843 :group
'vhdl-compose
)
845 (defcustom vhdl-configuration-file-name
'(".*" .
"\\&")
847 "Specifies how the configuration file name is obtained.
848 The configuration file name can be obtained by modifying the configuration
849 name (e.g. attaching or stripping off a substring). The file extension is
850 automatically taken from the file name of the current buffer."
851 vhdl-name-doc-string
)
852 :type
'(cons (regexp :tag
"From regexp")
853 (string :tag
"To string "))
855 :group
'vhdl-compose
)
857 (defcustom vhdl-package-file-name
'(".*" .
"\\&")
859 "Specifies how the package file name is obtained.
860 The package file name can be obtained by modifying the package name (e.g.
861 attaching or stripping off a substring). The file extension is automatically
862 taken from the file name of the current buffer. Package files can be created
863 in a different directory by prepending a relative or absolute path to the
865 vhdl-name-doc-string
)
866 :type
'(cons (regexp :tag
"From regexp")
867 (string :tag
"To string "))
869 :group
'vhdl-compose
)
871 (defcustom vhdl-file-name-case
'identity
872 "Specifies how to change case for obtaining file names.
873 When deriving a file name from a VHDL unit name, case can be changed as
875 As Is: case is not changed (taken as is)
876 Lower Case: whole name is changed to lower case
877 Upper Case: whole name is changed to upper case
878 Capitalize: first letter of each word in name is capitalized"
879 :type
'(choice (const :tag
"As Is" identity
)
880 (const :tag
"Lower Case" downcase
)
881 (const :tag
"Upper Case" upcase
)
882 (const :tag
"Capitalize" capitalize
))
884 :group
'vhdl-compose
)
887 (defgroup vhdl-template nil
888 "Customizations for electrification."
891 (defcustom vhdl-electric-keywords
'(vhdl user
)
892 "Type of keywords for which electrification is enabled.
893 VHDL keywords: invoke built-in templates
894 User keywords: invoke user models (see option `vhdl-model-alist')"
895 :type
'(set (const :tag
"VHDL keywords" vhdl
)
896 (const :tag
"User model keywords" user
))
897 :set
(lambda (variable value
)
898 (vhdl-custom-set variable value
'vhdl-mode-abbrev-table-init
))
899 :group
'vhdl-template
)
901 (defcustom vhdl-optional-labels
'process
902 "Constructs for which labels are to be queried.
903 Template generators prompt for optional labels for:
905 Processes only: processes only (also procedurals in VHDL-AMS)
906 All constructs: all constructs with optional labels and keyword END"
907 :type
'(choice (const :tag
"None" none
)
908 (const :tag
"Processes only" process
)
909 (const :tag
"All constructs" all
))
910 :group
'vhdl-template
)
912 (defcustom vhdl-insert-empty-lines
'unit
913 "Specifies whether to insert empty lines in some templates.
914 This improves readability of code. Empty lines are inserted in:
916 Design units only: entities, architectures, configurations, packages only
917 All constructs : also all constructs with BEGIN...END parts
919 Replaces option `vhdl-additional-empty-lines'."
920 :type
'(choice (const :tag
"None" none
)
921 (const :tag
"Design units only" unit
)
922 (const :tag
"All constructs" all
))
923 :group
'vhdl-template
925 :group
'vhdl-compose
)
927 (defcustom vhdl-argument-list-indent nil
928 "Non-nil means indent argument lists relative to opening parenthesis.
929 That is, argument, association, and port lists start on the same line as the
930 opening parenthesis and subsequent lines are indented accordingly.
931 Otherwise, lists start on a new line and are indented as normal code."
933 :group
'vhdl-template
935 :group
'vhdl-compose
)
937 (defcustom vhdl-association-list-with-formals t
938 "Non-nil means write association lists with formal parameters.
939 Templates prompt for formal and actual parameters (ports/generics).
940 When pasting component instantiations, formals are included.
941 If nil, only a list of actual parameters is entered."
943 :group
'vhdl-template
945 :group
'vhdl-compose
)
947 (defcustom vhdl-conditions-in-parenthesis nil
948 "Non-nil means place parenthesis around condition expressions."
950 :group
'vhdl-template
)
952 (defcustom vhdl-sensitivity-list-all t
953 "Non-nil means use `all' keyword in sensitivity list."
956 :group
'vhdl-template
)
958 (defcustom vhdl-zero-string
"'0'"
959 "String to use for a logic zero."
961 :group
'vhdl-template
)
963 (defcustom vhdl-one-string
"'1'"
964 "String to use for a logic one."
966 :group
'vhdl-template
)
969 (defgroup vhdl-header nil
970 "Customizations for file header."
971 :group
'vhdl-template
972 :group
'vhdl-compose
)
974 (defcustom vhdl-file-header
"\
975 -------------------------------------------------------------------------------
976 -- Title : <title string>
977 -- Project : <project>
978 -------------------------------------------------------------------------------
981 -- Company : <company>
983 -- Last update: <date>
984 -- Platform : <platform>
985 -- Standard : <standard>
986 <projectdesc>-------------------------------------------------------------------------------
987 -- Description: <cursor>
988 <copyright>-------------------------------------------------------------------------------
990 -- Date Version Author Description
991 -- <date> 1.0 <login>\tCreated
992 -------------------------------------------------------------------------------
995 "String or file to insert as file header.
996 If the string specifies an existing file name, the contents of the file is
997 inserted, otherwise the string itself is inserted as file header.
998 Type `C-j' for newlines.
999 If the header contains RCS keywords, they may be written as <RCS>Keyword<RCS>
1000 if the header needs to be version controlled.
1002 The following keywords for template generation are supported:
1003 <filename> : replaced by the name of the buffer
1004 <author> : replaced by the user name and email address
1005 (`user-full-name',`mail-host-address', `user-mail-address')
1006 <authorfull> : replaced by the user full name (`user-full-name')
1007 <login> : replaced by user login name (`user-login-name')
1008 <company> : replaced by contents of option `vhdl-company-name'
1009 <date> : replaced by the current date
1010 <year> : replaced by the current year
1011 <project> : replaced by title of current project (`vhdl-project')
1012 <projectdesc> : replaced by description of current project (`vhdl-project')
1013 <copyright> : replaced by copyright string (`vhdl-copyright-string')
1014 <platform> : replaced by contents of option `vhdl-platform-spec'
1015 <standard> : replaced by the VHDL language standard(s) used
1016 <... string> : replaced by a queried string (\"...\" is the prompt word)
1017 <title string>: replaced by file title in automatically generated files
1018 <cursor> : final cursor position
1020 The (multi-line) project description <projectdesc> can be used as a project
1021 dependent part of the file header and can also contain the above keywords."
1023 :group
'vhdl-header
)
1025 (defcustom vhdl-file-footer
""
1026 "String or file to insert as file footer.
1027 If the string specifies an existing file name, the contents of the file is
1028 inserted, otherwise the string itself is inserted as file footer (i.e. at
1029 the end of the file).
1030 Type `C-j' for newlines.
1031 The same keywords as in option `vhdl-file-header' can be used."
1033 :group
'vhdl-header
)
1035 (defcustom vhdl-company-name
""
1036 "Name of company to insert in file header.
1037 See option `vhdl-file-header'."
1039 :group
'vhdl-header
)
1041 (defcustom vhdl-copyright-string
"\
1042 -------------------------------------------------------------------------------
1043 -- Copyright (c) <year> <company>
1045 "Copyright string to insert in file header.
1046 Can be multi-line string (type `C-j' for newline) and contain other file
1047 header keywords (see option `vhdl-file-header')."
1049 :group
'vhdl-header
)
1051 (defcustom vhdl-platform-spec
""
1052 "Specification of VHDL platform to insert in file header.
1053 The platform specification should contain names and versions of the
1054 simulation and synthesis tools used.
1055 See option `vhdl-file-header'."
1057 :group
'vhdl-header
)
1059 (defcustom vhdl-date-format
"%Y-%m-%d"
1060 "Specifies the date format to use in the header.
1061 This string is passed as argument to the command `format-time-string'.
1062 For more information on format strings, see the documentation for the
1063 `format-time-string' command (C-h f `format-time-string')."
1065 :group
'vhdl-header
)
1067 (defcustom vhdl-modify-date-prefix-string
"-- Last update: "
1068 "Prefix string of modification date in VHDL file header.
1069 If actualization of the modification date is called (menu,
1070 `\\[vhdl-template-modify]'), this string is searched and the rest
1071 of the line replaced by the current date."
1073 :group
'vhdl-header
)
1075 (defcustom vhdl-modify-date-on-saving t
1076 "Non-nil means update the modification date when the buffer is saved.
1077 Calls function `\\[vhdl-template-modify]').
1079 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1080 \"Activate Options\"."
1082 :group
'vhdl-header
)
1085 (defgroup vhdl-sequential-process nil
1086 "Customizations for sequential processes."
1087 :group
'vhdl-template
)
1089 (defcustom vhdl-reset-kind
'async
1090 "Specifies which kind of reset to use in sequential processes."
1091 :type
'(choice (const :tag
"None" none
)
1092 (const :tag
"Synchronous" sync
)
1093 (const :tag
"Asynchronous" async
)
1094 (const :tag
"Query" query
))
1095 :group
'vhdl-sequential-process
)
1097 (defcustom vhdl-reset-active-high nil
1098 "Non-nil means reset in sequential processes is active high.
1099 Otherwise, reset is active low."
1101 :group
'vhdl-sequential-process
)
1103 (defcustom vhdl-clock-rising-edge t
1104 "Non-nil means rising edge of clock triggers sequential processes.
1105 Otherwise, falling edge triggers."
1107 :group
'vhdl-sequential-process
)
1109 (defcustom vhdl-clock-edge-condition
'standard
1110 "Syntax of the clock edge condition.
1111 Standard: \"clk\\='event and clk = \\='1\\='\"
1112 Function: \"rising_edge(clk)\""
1113 :type
'(choice (const :tag
"Standard" standard
)
1114 (const :tag
"Function" function
))
1115 :group
'vhdl-sequential-process
)
1117 (defcustom vhdl-clock-name
""
1118 "Name of clock signal to use in templates."
1120 :group
'vhdl-sequential-process
)
1122 (defcustom vhdl-reset-name
""
1123 "Name of reset signal to use in templates."
1125 :group
'vhdl-sequential-process
)
1128 (defgroup vhdl-model nil
1129 "Customizations for user models."
1132 (defcustom vhdl-model-alist
1134 "<label> : process (<clock>, <reset>)
1135 begin -- process <label>
1136 if <reset> = '0' then -- asynchronous reset (active low)
1138 elsif <clock>'event and <clock> = '1' then -- rising clock edge
1139 if <enable> = '1' then -- synchronous load
1143 end process <label>;"
1145 "List of user models.
1146 VHDL models (templates) can be specified by the user in this list. They can be
1147 invoked from the menu, through key bindings (`C-c C-m ...'), or by keyword
1148 electrification (i.e. overriding existing or creating new keywords, see
1149 option `vhdl-electric-keywords').
1150 Name : name of model (string of words and spaces)
1151 String : string or name of file to be inserted as model (newline: `C-j')
1152 Key Binding: key binding to invoke model, added to prefix `C-c C-m'
1153 (must be in double-quotes, examples: \"i\", \"\\C-p\", \"\\M-s\")
1154 Keyword : keyword to invoke model
1156 The models can contain prompts to be queried. A prompt is of the form \"<...>\".
1157 A prompt that appears several times is queried once and replaced throughout
1158 the model. Special prompts are:
1159 <clock> : name specified in `vhdl-clock-name' (if not empty)
1160 <reset> : name specified in `vhdl-reset-name' (if not empty)
1161 <cursor>: final cursor position
1162 File header prompts (see variable `vhdl-file-header') are automatically
1163 replaced, so that user models can also be used to insert different types of
1166 If the string specifies an existing file name, the contents of the file is
1167 inserted, otherwise the string itself is inserted.
1168 The code within the models should be correctly indented.
1169 Type `C-j' for newlines.
1171 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1172 \"Activate Options\"."
1173 :type
'(repeat (list :tag
"Model" :indent
2
1174 (string :tag
"Name ")
1175 (string :tag
"String : (type `C-j' for newline)"
1177 (sexp :tag
"Key binding" x
)
1178 (string :tag
"Keyword " :format
"%t: %v\n")))
1179 :set
(lambda (variable value
)
1180 (vhdl-custom-set variable value
1181 'vhdl-model-map-init
1183 'vhdl-mode-abbrev-table-init
1184 'vhdl-update-mode-menu
))
1188 (defgroup vhdl-compose nil
1189 "Customizations for structural composition."
1192 (defcustom vhdl-compose-architecture-name
'(".*" .
"str")
1194 "Specifies how the component architecture name is obtained.
1195 The component architecture name can be obtained by modifying the entity name
1196 \(e.g. attaching or stripping off a substring).
1197 If TO STRING is empty, the architecture name is queried."
1198 vhdl-name-doc-string
)
1199 :type
'(cons (regexp :tag
"From regexp")
1200 (string :tag
"To string "))
1201 :group
'vhdl-compose
)
1203 (defcustom vhdl-compose-configuration-name
1204 '("\\(.*\\) \\(.*\\)" .
"\\1_\\2_cfg")
1206 "Specifies how the configuration name is obtained.
1207 The configuration name can be obtained by modifying the entity and/or
1208 architecture name (e.g. attaching or stripping off a substring). The string
1209 that is matched against the regexp is the concatenation of the entity and the
1210 architecture name separated by a space. This gives access to both names (see
1211 default setting as example)."
1212 vhdl-name-doc-string
)
1213 :type
'(cons (regexp :tag
"From regexp")
1214 (string :tag
"To string "))
1215 :group
'vhdl-compose
)
1217 (defcustom vhdl-components-package-name
1218 '((".*" .
"\\&_components") .
"components")
1220 "Specifies how the name for the components package is obtained.
1221 The components package is a package containing all component declarations for
1222 the current design. Its name can be obtained by modifying the project name
1223 \(e.g. attaching or stripping off a substring). If no project is defined, the
1224 DIRECTORY entry is chosen."
1225 vhdl-name-doc-string
)
1226 :type
'(cons (cons :tag
"Project" :indent
2
1227 (regexp :tag
"From regexp")
1228 (string :tag
"To string "))
1229 (string :tag
"Directory:\n String "))
1230 :group
'vhdl-compose
)
1232 (defcustom vhdl-use-components-package nil
1233 "Non-nil means use a separate components package for component declarations.
1234 Otherwise, component declarations are inserted and searched for in the
1235 architecture declarative parts."
1237 :group
'vhdl-compose
)
1239 (defcustom vhdl-compose-include-header t
1240 "Non-nil means include a header in automatically generated files."
1242 :group
'vhdl-compose
)
1244 (defcustom vhdl-compose-create-files
'single
1245 "Specifies whether new files should be created for the new component.
1246 The component's entity and architecture are inserted:
1247 None : in current buffer
1248 Single file : in new single file
1249 Separate files: in two separate files
1250 The file names are obtained from variables `vhdl-entity-file-name' and
1251 `vhdl-architecture-file-name'."
1252 :type
'(choice (const :tag
"None" none
)
1253 (const :tag
"Single file" single
)
1254 (const :tag
"Separate files" separate
))
1255 :group
'vhdl-compose
)
1257 (defcustom vhdl-compose-configuration-create-file nil
1258 "Specifies whether a new file should be created for the configuration.
1259 If non-nil, a new file is created for the configuration.
1260 The file name is obtained from variable `vhdl-configuration-file-name'."
1262 :group
'vhdl-compose
)
1264 (defcustom vhdl-compose-configuration-hierarchical t
1265 "Specifies whether hierarchical configurations should be created.
1266 If non-nil, automatically created configurations are hierarchical and include
1267 the whole hierarchy of subcomponents. Otherwise the configuration only
1268 includes one level of subcomponents."
1270 :group
'vhdl-compose
)
1272 (defcustom vhdl-compose-configuration-use-subconfiguration t
1273 "Specifies whether subconfigurations should be used inside configurations.
1274 If non-nil, automatically created configurations use configurations in binding
1275 indications for subcomponents, if such configurations exist. Otherwise,
1276 entities are used in binding indications for subcomponents."
1278 :group
'vhdl-compose
)
1281 (defgroup vhdl-port nil
1282 "Customizations for port translation functions."
1284 :group
'vhdl-compose
)
1286 (defcustom vhdl-include-port-comments nil
1287 "Non-nil means include port comments when a port is pasted."
1291 (defcustom vhdl-include-direction-comments nil
1292 "Non-nil means include port direction in instantiations as comments."
1296 (defcustom vhdl-include-type-comments nil
1297 "Non-nil means include generic/port type in instantiations as comments."
1301 (defcustom vhdl-include-group-comments
'never
1302 "Specifies whether to include group comments and spacings.
1303 The comments and empty lines between groups of ports are pasted:
1305 Declarations: in entity/component/constant/signal declarations only
1306 Always : also in generic/port maps"
1307 :type
'(choice (const :tag
"Never" never
)
1308 (const :tag
"Declarations" decl
)
1309 (const :tag
"Always" always
))
1312 (defcustom vhdl-actual-generic-name
'(".*" .
"\\&")
1314 "Specifies how actual generic names are obtained from formal generic names.
1315 In a component instantiation, an actual generic name can be
1316 obtained by modifying the formal generic name (e.g. attaching or stripping
1318 vhdl-name-doc-string
)
1319 :type
'(cons (regexp :tag
"From regexp")
1320 (string :tag
"To string "))
1324 (defcustom vhdl-actual-port-name
'(".*" .
"\\&")
1326 "Specifies how actual port names are obtained from formal port names.
1327 In a component instantiation, an actual port name can be obtained by
1328 modifying the formal port name (e.g. attaching or stripping off a substring)."
1329 vhdl-name-doc-string
)
1330 :type
'(cons (regexp :tag
"From regexp")
1331 (string :tag
"To string "))
1334 (defcustom vhdl-instance-name
'(".*" .
"\\&_%d")
1336 "Specifies how an instance name is obtained.
1337 The instance name can be obtained by modifying the name of the component to be
1338 instantiated (e.g. attaching or stripping off a substring). \"%d\" is replaced
1339 by a unique number (starting with 1).
1340 If TO STRING is empty, the instance name is queried."
1341 vhdl-name-doc-string
)
1342 :type
'(cons (regexp :tag
"From regexp")
1343 (string :tag
"To string "))
1347 (defgroup vhdl-testbench nil
1348 "Customizations for testbench generation."
1351 (defcustom vhdl-testbench-entity-name
'(".*" .
"\\&_tb")
1353 "Specifies how the testbench entity name is obtained.
1354 The entity name of a testbench can be obtained by modifying the name of
1355 the component to be tested (e.g. attaching or stripping off a substring)."
1356 vhdl-name-doc-string
)
1357 :type
'(cons (regexp :tag
"From regexp")
1358 (string :tag
"To string "))
1359 :group
'vhdl-testbench
)
1361 (defcustom vhdl-testbench-architecture-name
'(".*" .
"")
1363 "Specifies how the testbench architecture name is obtained.
1364 The testbench architecture name can be obtained by modifying the name of
1365 the component to be tested (e.g. attaching or stripping off a substring).
1366 If TO STRING is empty, the architecture name is queried."
1367 vhdl-name-doc-string
)
1368 :type
'(cons (regexp :tag
"From regexp")
1369 (string :tag
"To string "))
1370 :group
'vhdl-testbench
)
1372 (defcustom vhdl-testbench-configuration-name vhdl-compose-configuration-name
1374 "Specifies how the testbench configuration name is obtained.
1375 The configuration name of a testbench can be obtained by modifying the entity
1376 and/or architecture name (e.g. attaching or stripping off a substring). The
1377 string that is matched against the regexp is the concatenation of the entity
1378 and the architecture name separated by a space. This gives access to both
1379 names (see default setting as example)."
1380 vhdl-name-doc-string
)
1381 :type
'(cons (regexp :tag
"From regexp")
1382 (string :tag
"To string "))
1383 :group
'vhdl-testbench
)
1385 (defcustom vhdl-testbench-dut-name
'(".*" .
"DUT")
1387 "Specifies how a DUT instance name is obtained.
1388 The design-under-test instance name (i.e. the component instantiated in the
1389 testbench) can be obtained by modifying the component name (e.g. attaching
1390 or stripping off a substring)."
1391 vhdl-name-doc-string
)
1392 :type
'(cons (regexp :tag
"From regexp")
1393 (string :tag
"To string "))
1394 :group
'vhdl-testbench
)
1396 (defcustom vhdl-testbench-include-header t
1397 "Non-nil means include a header in automatically generated files."
1399 :group
'vhdl-testbench
)
1401 (defcustom vhdl-testbench-declarations
"\
1403 signal Clk : std_logic := '1';
1405 "String or file to be inserted in the testbench declarative part.
1406 If the string specifies an existing file name, the contents of the file is
1407 inserted, otherwise the string itself is inserted in the testbench
1408 architecture before the BEGIN keyword.
1409 Type `C-j' for newlines."
1411 :group
'vhdl-testbench
)
1413 (defcustom vhdl-testbench-statements
"\
1415 Clk <= not Clk after 10 ns;
1417 -- waveform generation
1418 WaveGen_Proc: process
1420 -- insert signal assignments here
1422 wait until Clk = '1';
1423 end process WaveGen_Proc;
1425 "String or file to be inserted in the testbench statement part.
1426 If the string specifies an existing file name, the contents of the file is
1427 inserted, otherwise the string itself is inserted in the testbench
1428 architecture before the END keyword.
1429 Type `C-j' for newlines."
1431 :group
'vhdl-testbench
)
1433 (defcustom vhdl-testbench-initialize-signals nil
1434 "Non-nil means initialize signals with `0' when declared in testbench."
1436 :group
'vhdl-testbench
)
1438 (defcustom vhdl-testbench-include-library t
1439 "Non-nil means a library/use clause for std_logic_1164 is included."
1441 :group
'vhdl-testbench
)
1443 (defcustom vhdl-testbench-include-configuration t
1444 "Non-nil means a testbench configuration is attached at the end."
1446 :group
'vhdl-testbench
)
1448 (defcustom vhdl-testbench-create-files
'single
1449 "Specifies whether new files should be created for the testbench.
1450 testbench entity and architecture are inserted:
1451 None : in current buffer
1452 Single file : in new single file
1453 Separate files: in two separate files
1454 The file names are obtained from variables `vhdl-testbench-entity-file-name'
1455 and `vhdl-testbench-architecture-file-name'."
1456 :type
'(choice (const :tag
"None" none
)
1457 (const :tag
"Single file" single
)
1458 (const :tag
"Separate files" separate
))
1459 :group
'vhdl-testbench
)
1461 (defcustom vhdl-testbench-entity-file-name vhdl-entity-file-name
1463 "Specifies how the testbench entity file name is obtained.
1464 The entity file name can be obtained by modifying the testbench entity name
1465 \(e.g. attaching or stripping off a substring). The file extension is
1466 automatically taken from the file name of the current buffer. Testbench
1467 files can be created in a different directory by prepending a relative or
1468 absolute path to the file name."
1469 vhdl-name-doc-string
)
1470 :type
'(cons (regexp :tag
"From regexp")
1471 (string :tag
"To string "))
1472 :group
'vhdl-testbench
)
1474 (defcustom vhdl-testbench-architecture-file-name vhdl-architecture-file-name
1476 "Specifies how the testbench architecture file name is obtained.
1477 The architecture file name can be obtained by modifying the testbench entity
1478 and/or architecture name (e.g. attaching or stripping off a substring). The
1479 string that is matched against the regexp is the concatenation of the entity
1480 and the architecture name separated by a space. This gives access to both
1481 names (see default setting as example). Testbench files can be created in
1482 a different directory by prepending a relative or absolute path to the file
1484 vhdl-name-doc-string
)
1485 :type
'(cons (regexp :tag
"From regexp")
1486 (string :tag
"To string "))
1487 :group
'vhdl-testbench
)
1490 (defgroup vhdl-comment nil
1491 "Customizations for comments."
1494 (defcustom vhdl-self-insert-comments t
1495 "Non-nil means various templates automatically insert help comments."
1497 :group
'vhdl-comment
)
1499 (defcustom vhdl-prompt-for-comments t
1500 "Non-nil means various templates prompt for user definable comments."
1502 :group
'vhdl-comment
)
1504 (defcustom vhdl-inline-comment-column
40
1505 "Column to indent and align inline comments to.
1506 Overrides local option `comment-column'.
1508 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1509 \"Activate Options\"."
1511 :group
'vhdl-comment
)
1513 (defcustom vhdl-end-comment-column
79
1514 "End of comment column.
1515 Comments that exceed this column number are wrapped.
1517 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1518 \"Activate Options\"."
1520 :group
'vhdl-comment
)
1522 (defvar end-comment-column
)
1525 (defgroup vhdl-beautify nil
1526 "Customizations for beautification."
1529 (defcustom vhdl-auto-align t
1530 "Non-nil means align some templates automatically after generation."
1532 :group
'vhdl-beautify
)
1534 (defcustom vhdl-align-groups t
1535 "Non-nil means align groups of code lines separately.
1536 A group of code lines is a region of consecutive lines between two lines that
1537 match the regexp in option `vhdl-align-group-separate'."
1539 :group
'vhdl-beautify
)
1541 (defcustom vhdl-align-group-separate
"^\\s-*$"
1542 "Regexp for matching a line that separates groups of lines for alignment.
1544 \"^\\s-*$\": matches an empty line
1545 \"^\\s-*\\(--.*\\)?$\": matches an empty line or a comment-only line"
1547 :group
'vhdl-beautify
)
1549 (defcustom vhdl-align-same-indent t
1550 "Non-nil means align blocks with same indent separately.
1551 When a region or the entire buffer is aligned, the code is divided into
1552 blocks of same indent which are aligned separately (except for argument/port
1553 lists). This gives nicer alignment in most cases.
1554 Option `vhdl-align-groups' still applies within these blocks."
1556 :group
'vhdl-beautify
)
1558 (defcustom vhdl-beautify-options
'(t t t t t
)
1559 "List of options for beautifying code.
1560 Allows you to disable individual features of code beautification."
1561 :type
'(list (boolean :tag
"Whitespace cleanup ")
1562 (boolean :tag
"Single statement per line")
1563 (boolean :tag
"Indentation ")
1564 (boolean :tag
"Alignment ")
1565 (boolean :tag
"Case fixing "))
1566 :group
'vhdl-beautify
1570 (defgroup vhdl-highlight nil
1571 "Customizations for highlighting."
1574 (defcustom vhdl-highlight-keywords t
1575 "Non-nil means highlight VHDL keywords and other standardized words.
1576 The following faces are used:
1577 `font-lock-keyword-face' : keywords
1578 `font-lock-type-face' : standardized types
1579 `vhdl-font-lock-attribute-face': standardized attributes
1580 `vhdl-font-lock-enumvalue-face': standardized enumeration values
1581 `vhdl-font-lock-function-face' : standardized function and package names
1583 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1584 entry \"Fontify Buffer\")."
1586 :set
(lambda (variable value
)
1587 (vhdl-custom-set variable value
'vhdl-font-lock-init
))
1588 :group
'vhdl-highlight
)
1590 (defcustom vhdl-highlight-names t
1591 "Non-nil means highlight declaration names and construct labels.
1592 The following faces are used:
1593 `font-lock-function-name-face' : names in declarations of units,
1594 subprograms, components, as well as labels of VHDL constructs
1595 `font-lock-type-face' : names in type/nature declarations
1596 `vhdl-font-lock-attribute-face': names in attribute declarations
1597 `font-lock-variable-name-face' : names in declarations of signals,
1598 variables, constants, subprogram parameters, generics, and ports
1600 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1601 entry \"Fontify Buffer\")."
1603 :set
(lambda (variable value
)
1604 (vhdl-custom-set variable value
'vhdl-font-lock-init
))
1605 :group
'vhdl-highlight
)
1607 (defcustom vhdl-highlight-special-words nil
1608 "Non-nil means highlight words with special syntax.
1609 The words with syntax and color specified in option `vhdl-special-syntax-alist'
1610 are highlighted accordingly.
1611 Can be used for visual support of naming conventions.
1613 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1614 entry \"Fontify Buffer\")."
1616 :set
(lambda (variable value
)
1617 (vhdl-custom-set variable value
'vhdl-font-lock-init
))
1618 :group
'vhdl-highlight
)
1620 (defcustom vhdl-highlight-forbidden-words nil
1621 "Non-nil means highlight forbidden words.
1622 The reserved words specified in option `vhdl-forbidden-words' or having the
1623 syntax specified in option `vhdl-forbidden-syntax' are highlighted in a
1624 warning color (face `vhdl-font-lock-reserved-words-face') to indicate not to
1627 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1628 entry \"Fontify Buffer\")."
1630 :set
(lambda (variable value
)
1631 (vhdl-custom-set variable value
1632 'vhdl-words-init
'vhdl-font-lock-init
))
1633 :group
'vhdl-highlight
)
1635 (defcustom vhdl-highlight-verilog-keywords nil
1636 "Non-nil means highlight Verilog keywords as reserved words.
1637 Verilog keywords are highlighted in a warning color (face
1638 `vhdl-font-lock-reserved-words-face') to indicate not to use them.
1640 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1641 entry \"Fontify Buffer\")."
1643 :set
(lambda (variable value
)
1644 (vhdl-custom-set variable value
1645 'vhdl-words-init
'vhdl-font-lock-init
))
1646 :group
'vhdl-highlight
)
1648 (defcustom vhdl-highlight-translate-off nil
1649 "Non-nil means background-highlight code excluded from translation.
1650 That is, all code between \"-- pragma translate_off\" and
1651 \"-- pragma translate_on\" is highlighted using a different background color
1652 \(face `vhdl-font-lock-translate-off-face').
1653 Note: this might slow down on-the-fly fontification (and thus editing).
1655 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1656 entry \"Fontify Buffer\")."
1658 :set
(lambda (variable value
)
1659 (vhdl-custom-set variable value
'vhdl-font-lock-init
))
1660 :group
'vhdl-highlight
)
1662 (defcustom vhdl-highlight-case-sensitive nil
1663 "Non-nil means consider case for highlighting.
1665 non-nil also upper-case VHDL words are highlighted, but case of words with
1666 special syntax is not considered
1667 nil only lower-case VHDL words are highlighted, but case of words with
1668 special syntax is considered
1669 Overrides local option `font-lock-keywords-case-fold-search'.
1671 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1672 entry \"Fontify Buffer\")."
1674 :group
'vhdl-highlight
)
1676 (defcustom vhdl-special-syntax-alist
1677 '(("generic/constant" "\\<\\w+_[cg]\\>" "Gold3" "BurlyWood1" nil
)
1678 ("type" "\\<\\w+_t\\>" "ForestGreen" "PaleGreen" nil
)
1679 ("variable" "\\<\\w+_v\\>" "Grey50" "Grey80" nil
))
1680 "List of special syntax to be highlighted.
1681 If option `vhdl-highlight-special-words' is non-nil, words with the specified
1682 syntax (as regular expression) are highlighted in the corresponding color.
1684 Name : string of words and spaces
1685 Regexp : regular expression describing word syntax
1686 (e.g., `\\=\\<\\w+_c\\>' matches word with suffix `_c')
1687 expression must start with `\\=\\<' and end with `\\>'
1688 if only whole words should be matched (no substrings)
1689 Color (light): foreground color for light background
1690 (matching color examples: Gold3, Grey50, LimeGreen, Tomato,
1691 LightSeaGreen, DodgerBlue, Gold, PaleVioletRed)
1692 Color (dark) : foreground color for dark background
1693 (matching color examples: BurlyWood1, Grey80, Green, Coral,
1694 AquaMarine2, LightSkyBlue1, Yellow, PaleVioletRed1)
1695 In comments : If non-nil, words are also highlighted inside comments
1697 Can be used for visual support of naming conventions, such as highlighting
1698 different kinds of signals (e.g. `Clk50', `Rst_n') or objects (e.g.
1699 `Signal_s', `Variable_v', `Constant_c') by distinguishing them using
1700 common substrings or name suffices.
1701 For each entry, a new face is generated with the specified colors and name
1702 `vhdl-font-lock-' + name + `-face'.
1704 NOTE: Activate a changed regexp in a VHDL buffer by re-fontifying it (menu
1705 entry `Fontify Buffer'). All other changes require restarting Emacs."
1706 :type
'(repeat (list :tag
"Face" :indent
2
1707 (string :tag
"Name ")
1708 (regexp :tag
"Regexp " "\\w+_")
1709 (string :tag
"Color (light)")
1710 (string :tag
"Color (dark) ")
1711 (boolean :tag
"In comments ")))
1712 :set
(lambda (variable value
)
1713 (vhdl-custom-set variable value
'vhdl-font-lock-init
))
1714 :group
'vhdl-highlight
)
1716 (defcustom vhdl-forbidden-words
'()
1717 "List of forbidden words to be highlighted.
1718 If option `vhdl-highlight-forbidden-words' is non-nil, these reserved
1719 words are highlighted in a warning color to indicate not to use them.
1721 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1722 entry \"Fontify Buffer\")."
1723 :type
'(repeat (string :format
"%v"))
1724 :set
(lambda (variable value
)
1725 (vhdl-custom-set variable value
1726 'vhdl-words-init
'vhdl-font-lock-init
))
1727 :group
'vhdl-highlight
)
1729 (defcustom vhdl-forbidden-syntax
""
1730 "Syntax of forbidden words to be highlighted.
1731 If option `vhdl-highlight-forbidden-words' is non-nil, words with this
1732 syntax are highlighted in a warning color to indicate not to use them.
1733 Can be used to highlight too long identifiers (e.g. \"\\w\\w\\w\\w\\w\\w\\w\\w\\w\\w+\"
1734 highlights identifiers with 10 or more characters).
1736 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1737 entry \"Fontify Buffer\")."
1739 :set
(lambda (variable value
)
1740 (vhdl-custom-set variable value
1741 'vhdl-words-init
'vhdl-font-lock-init
))
1742 :group
'vhdl-highlight
)
1744 (defcustom vhdl-directive-keywords
'("psl" "pragma" "synopsys")
1745 "List of compiler directive keywords recognized for highlighting.
1747 NOTE: Activate the new setting in a VHDL buffer by re-fontifying it (menu
1748 entry \"Fontify Buffer\")."
1749 :type
'(repeat (string :format
"%v"))
1750 :set
(lambda (variable value
)
1751 (vhdl-custom-set variable value
1752 'vhdl-words-init
'vhdl-font-lock-init
))
1753 :group
'vhdl-highlight
)
1756 (defgroup vhdl-speedbar nil
1757 "Customizations for speedbar."
1760 (defcustom vhdl-speedbar-auto-open nil
1761 "Non-nil means automatically open speedbar at startup.
1762 Alternatively, the speedbar can be opened from the VHDL menu."
1764 :group
'vhdl-speedbar
)
1766 (defcustom vhdl-speedbar-display-mode
'files
1767 "Specifies the default displaying mode when opening speedbar.
1768 Alternatively, the displaying mode can be selected from the speedbar menu or
1769 by typing `f' (files), `h' (directory hierarchy) or `H' (project hierarchy)."
1770 :type
'(choice (const :tag
"Files" files
)
1771 (const :tag
"Directory hierarchy" directory
)
1772 (const :tag
"Project hierarchy" project
))
1773 :group
'vhdl-speedbar
)
1775 (defcustom vhdl-speedbar-scan-limit
'(10000000 (1000000 50))
1776 "Limits scanning of large files and netlists.
1777 Design units: maximum file size to scan for design units
1778 Hierarchy (instances of subcomponents):
1779 File size: maximum file size to scan for instances (in bytes)
1780 Instances per arch: maximum number of instances to scan per architecture
1782 \"None\" always means that there is no limit.
1783 In case of files not or incompletely scanned, a warning message and the file
1784 names are printed out.
1785 Background: scanning for instances is considerably slower than scanning for
1786 design units, especially when there are many instances. These limits should
1787 prevent the scanning of large netlists."
1788 :type
'(list (choice :tag
"Design units"
1789 :format
"%t : %[Value Menu%] %v"
1790 (const :tag
"None" nil
)
1791 (integer :tag
"File size"))
1792 (list :tag
"Hierarchy" :indent
2
1793 (choice :tag
"File size"
1794 :format
"%t : %[Value Menu%] %v"
1795 (const :tag
"None" nil
)
1796 (integer :tag
"Size "))
1797 (choice :tag
"Instances per arch"
1798 (const :tag
"None" nil
)
1799 (integer :tag
"Number "))))
1800 :group
'vhdl-speedbar
)
1802 (defcustom vhdl-speedbar-jump-to-unit t
1803 "Non-nil means jump to the design unit code when opened in a buffer.
1804 The buffer cursor position is left unchanged otherwise."
1806 :group
'vhdl-speedbar
)
1808 (defcustom vhdl-speedbar-update-on-saving t
1809 "Automatically update design hierarchy when buffer is saved."
1811 :group
'vhdl-speedbar
)
1813 (defcustom vhdl-speedbar-save-cache
'(hierarchy display
)
1814 "Automatically save modified hierarchy caches when exiting Emacs.
1815 Hierarchy: design hierarchy information
1816 Display: displaying information (which design units to expand)"
1817 :type
'(set (const :tag
"Hierarchy" hierarchy
)
1818 (const :tag
"Display" display
))
1819 :group
'vhdl-speedbar
)
1821 (defcustom vhdl-speedbar-cache-file-name
".emacs-vhdl-cache-\\1-\\2"
1822 "Name of file for saving hierarchy cache.
1823 \"\\1\" is replaced by the project name if a project is specified,
1824 \"directory\" otherwise. \"\\2\" is replaced by the user name (allows for
1825 different users to have cache files in the same directory). Can also have
1826 an absolute path (i.e. all caches can be stored in one global directory)."
1828 :group
'vhdl-speedbar
)
1831 (defgroup vhdl-menu nil
1832 "Customizations for menus."
1835 (defcustom vhdl-index-menu nil
1836 "Non-nil means add an index menu for a source file when loading.
1837 Alternatively, the speedbar can be used. Note that the index menu scans a file
1838 when it is opened, while speedbar only scans the file upon request."
1842 (defcustom vhdl-source-file-menu nil
1843 "Non-nil means add a menu of all source files in current directory.
1844 Alternatively, the speedbar can be used."
1848 (defcustom vhdl-hideshow-menu nil
1849 "Non-nil means add hideshow menu and functionality at startup.
1850 Hideshow can also be enabled from the VHDL Mode menu.
1851 Hideshow allows hiding code of various VHDL constructs.
1853 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1854 \"Activate Options\"."
1858 (defcustom vhdl-hide-all-init nil
1859 "Non-nil means hide all design units initially after a file is loaded."
1864 (defgroup vhdl-print nil
1865 "Customizations for printing."
1868 (defcustom vhdl-print-two-column t
1869 "Non-nil means print code in two columns and landscape format.
1870 Adjusts settings in a way that PostScript printing (\"File\" menu, `ps-print')
1871 prints VHDL files in a nice two-column landscape style.
1873 NOTE: Activate the new setting by restarting Emacs.
1874 Overrides `ps-print' settings locally."
1878 (defcustom vhdl-print-customize-faces t
1879 "Non-nil means use an optimized set of faces for PostScript printing.
1881 NOTE: Activate the new setting by restarting Emacs.
1882 Overrides `ps-print' settings locally."
1887 (defgroup vhdl-misc nil
1888 "Miscellaneous customizations."
1891 (defcustom vhdl-intelligent-tab t
1892 "Non-nil means `TAB' does indentation, word completion and tab insertion.
1893 That is, if preceding character is part of a word then complete word,
1894 else if not at beginning of line then insert tab,
1895 else if last command was a `TAB' or `RET' then dedent one step,
1896 else indent current line (i.e. `TAB' is bound to `vhdl-electric-tab').
1897 If nil, TAB always indents current line (i.e. `TAB' is bound to
1898 `indent-according-to-mode').
1900 NOTE: Activate the new setting in a VHDL buffer by using the menu entry
1901 \"Activate Options\"."
1905 (defcustom vhdl-indent-syntax-based t
1906 "Non-nil means indent lines of code based on their syntactic context.
1907 Otherwise, a line is indented like the previous nonblank line. This can be
1908 useful in large files where syntax-based indentation gets very slow."
1912 (defcustom vhdl-indent-comment-like-next-code-line t
1913 "Non-nil means comment lines are indented like the following code line.
1914 Otherwise, comment lines are indented like the preceding code line.
1915 Indenting comment lines like the following code line gives nicer indentation
1916 when comments precede the code that they refer to."
1921 (defcustom vhdl-word-completion-case-sensitive nil
1922 "Non-nil means word completion using `TAB' is case sensitive.
1923 That is, `TAB' completes words that start with the same letters and case.
1924 Otherwise, case is ignored."
1928 (defcustom vhdl-word-completion-in-minibuffer t
1929 "Non-nil enables word completion in minibuffer (for template prompts).
1931 NOTE: Activate the new setting by restarting Emacs."
1935 (defcustom vhdl-underscore-is-part-of-word nil
1936 "Non-nil means consider the underscore character `_' as part of word.
1937 An identifier containing underscores is then treated as a single word in
1938 select and move operations. All parts of an identifier separated by underscore
1939 are treated as single words otherwise."
1942 (make-obsolete-variable 'vhdl-underscore-is-part-of-word
1943 'superword-mode
"24.4")
1946 (defgroup vhdl-related nil
1947 "Related general customizations."
1950 ;; add related general customizations
1951 (custom-add-to-group 'vhdl-related
'hideshow
'custom-group
)
1952 (if (featurep 'xemacs
)
1953 (custom-add-to-group 'vhdl-related
'paren-mode
'custom-variable
)
1954 (custom-add-to-group 'vhdl-related
'paren-showing
'custom-group
))
1955 (custom-add-to-group 'vhdl-related
'ps-print
'custom-group
)
1956 (custom-add-to-group 'vhdl-related
'speedbar
'custom-group
)
1957 (custom-add-to-group 'vhdl-related
'comment-style
'custom-variable
)
1958 (custom-add-to-group 'vhdl-related
'line-number-mode
'custom-variable
)
1959 (unless (featurep 'xemacs
)
1960 (custom-add-to-group 'vhdl-related
'transient-mark-mode
'custom-variable
))
1961 (custom-add-to-group 'vhdl-related
'user-full-name
'custom-variable
)
1962 (custom-add-to-group 'vhdl-related
'mail-host-address
'custom-variable
)
1963 (custom-add-to-group 'vhdl-related
'user-mail-address
'custom-variable
)
1965 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1966 ;; Hidden user variables
1968 (defvar vhdl-compile-absolute-path nil
1969 "If non-nil, use absolute instead of relative path for compiled files.")
1971 (defvar vhdl-comment-display-line-char ?-
1972 "Character to use in comment display line.")
1974 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1975 ;; Internal variables
1977 (defvar vhdl-menu-max-size
20
1978 "Specifies the maximum size of a menu before splitting it into submenus.")
1980 (defvar vhdl-progress-interval
1
1981 "Interval used to update progress status during long operations.
1982 If a number, percentage complete gets updated after each interval of
1983 that many seconds. To inhibit all messages, set this option to nil.")
1985 (defvar vhdl-inhibit-startup-warnings-p nil
1986 "If non-nil, inhibits start up compatibility warnings.")
1988 (defvar vhdl-strict-syntax-p nil
1989 "If non-nil, all syntactic symbols must be found in `vhdl-offsets-alist'.
1990 If the syntactic symbol for a particular line does not match a symbol
1991 in the offsets alist, an error is generated, otherwise no error is
1992 reported and the syntactic symbol is ignored.")
1994 (defvar vhdl-echo-syntactic-information-p nil
1995 "If non-nil, syntactic info is echoed when the line is indented.")
1997 (defconst vhdl-offsets-alist-default
2003 (statement-cont . vhdl-lineup-statement-cont
)
2004 (statement-block-intro .
+)
2005 (statement-case-intro .
+)
2006 (case-alternative .
+)
2007 (comment . vhdl-lineup-comment
)
2010 (arglist-cont-nonempty . vhdl-lineup-arglist
)
2011 (arglist-close . vhdl-lineup-arglist
)
2020 "Default settings for offsets of syntactic elements.
2021 Do not change this constant! See the variable `vhdl-offsets-alist' for
2024 (defvar vhdl-offsets-alist
(copy-alist vhdl-offsets-alist-default
)
2025 "Association list of syntactic element symbols and indentation offsets.
2026 As described below, each cons cell in this list has the form:
2028 (SYNTACTIC-SYMBOL . OFFSET)
2030 When a line is indented, `vhdl-mode' first determines the syntactic
2031 context of the line by generating a list of symbols called syntactic
2032 elements. This list can contain more than one syntactic element and
2033 the global variable `vhdl-syntactic-context' contains the context list
2034 for the line being indented. Each element in this list is actually a
2035 cons cell of the syntactic symbol and a buffer position. This buffer
2036 position is call the relative indent point for the line. Some
2037 syntactic symbols may not have a relative indent point associated with
2040 After the syntactic context list for a line is generated, `vhdl-mode'
2041 calculates the absolute indentation for the line by looking at each
2042 syntactic element in the list. First, it compares the syntactic
2043 element against the SYNTACTIC-SYMBOL's in `vhdl-offsets-alist'. When it
2044 finds a match, it adds the OFFSET to the column of the relative indent
2045 point. The sum of this calculation for each element in the syntactic
2046 list is the absolute offset for line being indented.
2048 If the syntactic element does not match any in the `vhdl-offsets-alist',
2049 an error is generated if `vhdl-strict-syntax-p' is non-nil, otherwise
2050 the element is ignored.
2052 Actually, OFFSET can be an integer, a function, a variable, or one of
2053 the following symbols: `+', `-', `++', or `--'. These latter
2054 designate positive or negative multiples of `vhdl-basic-offset',
2055 respectively: *1, *-1, *2, and *-2. If OFFSET is a function, it is
2056 called with a single argument containing the cons of the syntactic
2057 element symbol and the relative indent point. The function should
2058 return an integer offset.
2060 Here is the current list of valid syntactic element symbols:
2062 string -- inside multi-line string
2063 block-open -- statement block open
2064 block-close -- statement block close
2065 statement -- a VHDL statement
2066 statement-cont -- a continuation of a VHDL statement
2067 statement-block-intro -- the first line in a new statement block
2068 statement-case-intro -- the first line in a case alternative block
2069 case-alternative -- a case statement alternative clause
2070 comment -- a line containing only a comment
2071 arglist-intro -- the first line in an argument list
2072 arglist-cont -- subsequent argument list lines when no
2073 arguments follow on the same line as
2074 the arglist opening paren
2075 arglist-cont-nonempty -- subsequent argument list lines when at
2076 least one argument follows on the same
2077 line as the arglist opening paren
2078 arglist-close -- the solo close paren of an argument list
2079 entity -- inside an entity declaration
2080 configuration -- inside a configuration declaration
2081 package -- inside a package declaration
2082 architecture -- inside an architecture body
2083 package-body -- inside a package body
2084 context -- inside a context declaration")
2086 (defvar vhdl-comment-only-line-offset
0
2087 "Extra offset for line which contains only the start of a comment.
2088 Can contain an integer or a cons cell of the form:
2090 (NON-ANCHORED-OFFSET . ANCHORED-OFFSET)
2092 Where NON-ANCHORED-OFFSET is the amount of offset given to
2093 non-column-zero anchored comment-only lines, and ANCHORED-OFFSET is
2094 the amount of offset to give column-zero anchored comment-only lines.
2095 Just an integer as value is equivalent to (<val> . 0)")
2097 (defvar vhdl-special-indent-hook nil
2098 "Hook for user defined special indentation adjustments.
2099 This hook gets called after a line is indented by the mode.")
2101 (defvar vhdl-style-alist
2103 (vhdl-basic-offset .
4)
2104 (vhdl-offsets-alist .
())))
2105 "Styles of Indentation.
2106 Elements of this alist are of the form:
2108 (STYLE-STRING (VARIABLE . VALUE) [(VARIABLE . VALUE) ...])
2110 where STYLE-STRING is a short descriptive string used to select a
2111 style, VARIABLE is any `vhdl-mode' variable, and VALUE is the intended
2112 value for that variable when using the selected style.
2114 There is one special case when VARIABLE is `vhdl-offsets-alist'. In this
2115 case, the VALUE is a list containing elements of the form:
2117 (SYNTACTIC-SYMBOL . VALUE)
2119 as described in `vhdl-offsets-alist'. These are passed directly to
2120 `vhdl-set-offset' so there is no need to set every syntactic symbol in
2121 your style, only those that are different from the default.")
2123 ;; dynamically append the default value of most variables
2124 (or (assoc "Default" vhdl-style-alist
)
2125 (let* ((varlist '(vhdl-inhibit-startup-warnings-p
2126 vhdl-strict-syntax-p
2127 vhdl-echo-syntactic-information-p
2130 vhdl-comment-only-line-offset
))
2131 (default (cons "Default"
2135 (cons var
(symbol-value var
))))
2137 (push default vhdl-style-alist
)))
2139 (defvar vhdl-mode-hook nil
2140 "Hook called by `vhdl-mode'.")
2143 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2144 ;;; Required packages
2145 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2148 (require 'compile
) ; XEmacs
2150 (require 'hippie-exp
)
2152 ;; optional (minimize warning messages during compile)
2153 (unless (featurep 'xemacs
)
2155 (require 'font-lock
)
2157 (require 'speedbar
))) ; for speedbar-with-writable
2159 (defun vhdl-aput (alist-symbol key
&optional value
)
2160 "Insert a key-value pair into an alist.
2161 The alist is referenced by ALIST-SYMBOL. The key-value pair is made
2162 from KEY and VALUE. If the key-value pair referenced by KEY can be
2163 found in the alist, the value of KEY will be set to VALUE. If the
2164 key-value pair cannot be found in the alist, it will be inserted into
2165 the head of the alist."
2166 (let* ((alist (symbol-value alist-symbol
))
2167 (elem (assoc key alist
)))
2170 (set alist-symbol
(cons (cons key value
) alist
)))))
2172 (defun vhdl-adelete (alist-symbol key
)
2173 "Delete a key-value pair from the alist.
2174 Alist is referenced by ALIST-SYMBOL and the key-value pair to remove
2175 is pair matching KEY."
2176 (let ((alist (symbol-value alist-symbol
)) alist-cdr
)
2177 (while (equal key
(caar alist
))
2178 (setq alist
(cdr alist
))
2179 (set alist-symbol alist
))
2180 (while (setq alist-cdr
(cdr alist
))
2181 (if (equal key
(caar alist-cdr
))
2182 (setcdr alist
(cdr alist-cdr
))
2183 (setq alist alist-cdr
)))))
2185 (defun vhdl-aget (alist key
)
2186 "Return the value in ALIST that is associated with KEY. If KEY is
2187 not found, then nil is returned."
2188 (cdr (assoc key alist
)))
2190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2192 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2194 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2195 ;; XEmacs compatibility
2198 (defun vhdl-keep-region-active ()
2199 "Do whatever is necessary to keep the region active in XEmacs.
2200 Ignore byte-compiler warnings you might see."
2201 (and (featurep 'xemacs
)
2202 (setq zmacs-region-stays t
)))
2204 ;; `wildcard-to-regexp' is included only in XEmacs 21
2205 (unless (fboundp 'wildcard-to-regexp
)
2206 (defun wildcard-to-regexp (wildcard)
2207 "Simplified version of `wildcard-to-regexp' from Emacs's `files.el'."
2208 (let* ((i (string-match "[*?]" wildcard
))
2209 (result (substring wildcard
0 i
))
2210 (len (length wildcard
)))
2213 (let ((ch (aref wildcard i
)))
2214 (setq result
(concat result
2215 (cond ((eq ch ?
*) "[^\000]*")
2216 ((eq ch ??
) "[^\000]")
2217 (t (char-to-string ch
)))))
2219 (concat "\\`" result
"\\'"))))
2221 ;; `regexp-opt' undefined (`xemacs-devel' not installed)
2222 ;; `regexp-opt' accelerates fontification by 10-20%
2223 (unless (fboundp 'regexp-opt
)
2224 ; (vhdl-warning-when-idle "Please install `xemacs-devel' package.")
2225 (defun regexp-opt (strings &optional paren
)
2226 (let ((open (if paren
"\\(" "")) (close (if paren
"\\)" "")))
2227 (concat open
(mapconcat 'regexp-quote strings
"\\|") close
))))
2229 ;; `match-string-no-properties' undefined (XEmacs, what else?)
2230 (unless (fboundp 'match-string-no-properties
)
2231 (defalias 'match-string-no-properties
'match-string
))
2233 ;; `subst-char-in-string' undefined (XEmacs)
2234 (unless (fboundp 'subst-char-in-string
)
2235 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
2236 (let ((i (length string
))
2237 (newstr (if inplace string
(copy-sequence string
))))
2240 (if (eq (aref newstr i
) fromchar
) (aset newstr i tochar
)))
2243 ;; `itimer.el': idle timer bug fix in version 1.09 (XEmacs 21.1.9)
2244 (when (and (featurep 'xemacs
) (string< itimer-version
"1.09")
2245 (not noninteractive
))
2247 (when (string< itimer-version
"1.09")
2248 (message "WARNING: Install included `itimer.el' patch first (see INSTALL file)")
2249 (beep) (sit-for 5)))
2251 ;; `file-expand-wildcards' undefined (XEmacs)
2252 (unless (fboundp 'file-expand-wildcards
)
2253 (defun file-expand-wildcards (pattern &optional full
)
2254 "Taken from Emacs's `files.el'."
2255 (let* ((nondir (file-name-nondirectory pattern
))
2256 (dirpart (file-name-directory pattern
))
2257 (dirs (if (and dirpart
(string-match "[[*?]" dirpart
))
2258 (mapcar 'file-name-as-directory
2259 (file-expand-wildcards (directory-file-name dirpart
)))
2263 (when (or (null (car dirs
)) ; Possible if DIRPART is not wild.
2264 (file-directory-p (directory-file-name (car dirs
))))
2265 (let ((this-dir-contents
2267 (mapcar #'(lambda (name)
2268 (unless (string-match "\\`\\.\\.?\\'"
2269 (file-name-nondirectory name
))
2271 (directory-files (or (car dirs
) ".") full
2272 (wildcard-to-regexp nondir
))))))
2275 (if (and (car dirs
) (not full
))
2276 (mapcar (function (lambda (name) (concat (car dirs
) name
)))
2280 (setq dirs
(cdr dirs
)))
2283 ;; `member-ignore-case' undefined (XEmacs)
2284 (unless (fboundp 'member-ignore-case
)
2285 (defalias 'member-ignore-case
'member
))
2287 ;; `last-input-char' obsolete in Emacs 24, `last-input-event' different
2288 ;; behavior in XEmacs
2289 (defvar vhdl-last-input-event
)
2290 (if (featurep 'xemacs
)
2291 (defvaralias 'vhdl-last-input-event
'last-input-char
)
2292 (defvaralias 'vhdl-last-input-event
'last-input-event
))
2294 ;; `help-print-return-message' changed to `print-help-return-message' in Emacs
2295 ;;;(unless (fboundp 'help-print-return-message)
2296 ;;; (defalias 'help-print-return-message 'print-help-return-message))
2298 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2299 ;; Compatibility with older VHDL Mode versions
2301 (defvar vhdl-warnings nil
2302 "Warnings to tell the user during start up.")
2304 (defun vhdl-run-when-idle (secs repeat function
)
2305 "Wait until idle, then run FUNCTION."
2306 (if (fboundp 'start-itimer
)
2307 (start-itimer "vhdl-mode" function secs repeat t
)
2308 ;; explicitly activate timer (necessary when Emacs is already idle)
2309 (aset (run-with-idle-timer secs repeat function
) 0 nil
)))
2311 (defun vhdl-warning-when-idle (&rest args
)
2312 "Wait until idle, then print out warning STRING and beep."
2313 (let ((message (apply #'format-message args
)))
2315 (vhdl-warning message t
)
2316 (unless vhdl-warnings
2317 (vhdl-run-when-idle .1 nil
'vhdl-print-warnings
))
2318 (push message vhdl-warnings
))))
2320 (defun vhdl-warning (string &optional nobeep
)
2321 "Print out warning STRING and beep."
2322 (message "WARNING: %s" string
)
2323 (unless (or nobeep noninteractive
) (beep)))
2325 (defun vhdl-print-warnings ()
2326 "Print out messages in variable `vhdl-warnings'."
2327 (let ((no-warnings (length vhdl-warnings
)))
2328 (setq vhdl-warnings
(nreverse vhdl-warnings
))
2329 (while vhdl-warnings
2330 (message "WARNING: %s" (car vhdl-warnings
))
2331 (setq vhdl-warnings
(cdr vhdl-warnings
)))
2333 (when (> no-warnings
1)
2334 (message "WARNING: See warnings in message buffer (type `C-c M-m')."))))
2336 ;; Backward compatibility checks and fixes
2337 ;; option `vhdl-compiler' changed format
2338 (unless (stringp vhdl-compiler
)
2339 (setq vhdl-compiler
"ModelSim")
2340 (vhdl-warning-when-idle "Option `vhdl-compiler' has changed format; customize again"))
2342 ;; option `vhdl-standard' changed format
2343 (unless (listp vhdl-standard
)
2344 (setq vhdl-standard
'(87 nil
))
2345 (vhdl-warning-when-idle "Option `vhdl-standard' has changed format; customize again"))
2347 ;; option `vhdl-model-alist' changed format
2348 (when (= (length (car vhdl-model-alist
)) 3)
2349 (let ((old-alist vhdl-model-alist
)
2352 (push (append (car old-alist
) '("")) new-alist
)
2353 (setq old-alist
(cdr old-alist
)))
2354 (setq vhdl-model-alist
(nreverse new-alist
)))
2355 (customize-save-variable 'vhdl-model-alist vhdl-model-alist
))
2357 ;; option `vhdl-project-alist' changed format
2358 (when (= (length (car vhdl-project-alist
)) 3)
2359 (let ((old-alist vhdl-project-alist
)
2362 (push (append (car old-alist
) '("")) new-alist
)
2363 (setq old-alist
(cdr old-alist
)))
2364 (setq vhdl-project-alist
(nreverse new-alist
)))
2365 (customize-save-variable 'vhdl-project-alist vhdl-project-alist
))
2367 ;; option `vhdl-project-alist' changed format (3.31.1)
2368 (when (= (length (car vhdl-project-alist
)) 4)
2369 (let ((old-alist vhdl-project-alist
)
2372 (setq elem
(car old-alist
))
2374 (cons (list (nth 0 elem
) (nth 1 elem
) "" (nth 2 elem
)
2375 nil
"./" "work" "work/" "Makefile" (nth 3 elem
))
2377 (setq old-alist
(cdr old-alist
)))
2378 (setq vhdl-project-alist
(nreverse new-alist
)))
2379 (vhdl-warning-when-idle "Option `vhdl-project-alist' changed format; please re-customize"))
2381 ;; option `vhdl-project-alist' changed format (3.31.12)
2382 (when (= (length (car vhdl-project-alist
)) 10)
2383 (let ((tmp-alist vhdl-project-alist
))
2385 (setcdr (nthcdr 3 (car tmp-alist
))
2386 (cons "" (nthcdr 4 (car tmp-alist
))))
2387 (setq tmp-alist
(cdr tmp-alist
))))
2388 (customize-save-variable 'vhdl-project-alist vhdl-project-alist
))
2390 ;; option `vhdl-compiler-alist' changed format (3.31.1)
2391 (when (= (length (car vhdl-compiler-alist
)) 7)
2392 (let ((old-alist vhdl-compiler-alist
)
2395 (setq elem
(car old-alist
))
2397 (cons (list (nth 0 elem
) (nth 1 elem
) "" "make -f \\1"
2398 (if (equal (nth 3 elem
) "") nil
(nth 3 elem
))
2399 (nth 4 elem
) "work/" "Makefile" (downcase (nth 0 elem
))
2400 (nth 5 elem
) (nth 6 elem
) nil
)
2402 (setq old-alist
(cdr old-alist
)))
2403 (setq vhdl-compiler-alist
(nreverse new-alist
)))
2404 (vhdl-warning-when-idle "Option `vhdl-compiler-alist' changed; please reset and re-customize"))
2406 ;; option `vhdl-compiler-alist' changed format (3.31.10)
2407 (when (= (length (car vhdl-compiler-alist
)) 12)
2408 (let ((tmp-alist vhdl-compiler-alist
))
2410 (setcdr (nthcdr 4 (car tmp-alist
))
2411 (cons "mkdir \\1" (nthcdr 5 (car tmp-alist
))))
2412 (setq tmp-alist
(cdr tmp-alist
))))
2413 (customize-save-variable 'vhdl-compiler-alist vhdl-compiler-alist
))
2415 ;; option `vhdl-compiler-alist' changed format (3.31.11)
2416 (when (= (length (car vhdl-compiler-alist
)) 13)
2417 (let ((tmp-alist vhdl-compiler-alist
))
2419 (setcdr (nthcdr 3 (car tmp-alist
))
2420 (cons "" (nthcdr 4 (car tmp-alist
))))
2421 (setq tmp-alist
(cdr tmp-alist
))))
2422 (customize-save-variable 'vhdl-compiler-alist vhdl-compiler-alist
))
2424 ;; option `vhdl-compiler-alist' changed format (3.32.7)
2425 (when (= (length (nth 11 (car vhdl-compiler-alist
))) 3)
2426 (let ((tmp-alist vhdl-compiler-alist
))
2428 (setcdr (nthcdr 2 (nth 11 (car tmp-alist
)))
2430 (setq tmp-alist
(cdr tmp-alist
))))
2431 (customize-save-variable 'vhdl-compiler-alist vhdl-compiler-alist
))
2433 ;; option `vhdl-project': empty value changed from "" to nil (3.31.1)
2434 (when (equal vhdl-project
"")
2435 (setq vhdl-project nil
)
2436 (customize-save-variable 'vhdl-project vhdl-project
))
2438 ;; option `vhdl-project-file-name': changed format (3.31.17 beta)
2439 (when (stringp vhdl-project-file-name
)
2440 (setq vhdl-project-file-name
(list vhdl-project-file-name
))
2441 (customize-save-variable 'vhdl-project-file-name vhdl-project-file-name
))
2443 ;; option `speedbar-indentation-width': introduced in speedbar 0.10
2444 (if (not (boundp 'speedbar-indentation-width
))
2445 (defvar speedbar-indentation-width
2)
2446 ;; set default to 2 if not already customized
2447 (unless (get 'speedbar-indentation-width
'saved-value
)
2448 (setq speedbar-indentation-width
2)))
2450 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2451 ;;; Help functions / inline substitutions / macros
2452 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2454 (defun vhdl-standard-p (standard)
2455 "Check if STANDARD is specified as used standard."
2456 (or (eq standard
(car vhdl-standard
))
2457 (memq standard
(cadr vhdl-standard
))))
2459 (defun vhdl-project-p (&optional warning
)
2460 "Return non-nil if a project is displayed, i.e. directories or files are
2462 (if (assoc vhdl-project vhdl-project-alist
)
2464 (when (and vhdl-project warning
)
2465 (vhdl-warning-when-idle "Project does not exist: \"%s\"" vhdl-project
))
2468 (defun vhdl-resolve-env-variable (string)
2469 "Resolve environment variables in STRING."
2470 (while (string-match "\\(.*\\)${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)" string
)
2471 (setq string
(concat (match-string 1 string
)
2472 (getenv (match-string 2 string
))
2473 (match-string 4 string
))))
2476 (defun vhdl-default-directory ()
2477 "Return the default directory of the current project or the directory of the
2478 current buffer if no project is defined."
2479 (if (vhdl-project-p)
2480 (expand-file-name (vhdl-resolve-env-variable
2481 (nth 1 (vhdl-aget vhdl-project-alist vhdl-project
))))
2484 (defmacro vhdl-prepare-search-1
(&rest body
)
2485 "Enable case insensitive search and switch to syntax table that includes `_',
2486 then execute BODY, and finally restore the old environment. Used for
2487 consistent searching."
2488 `(let ((case-fold-search t
)) ; case insensitive search
2489 ;; use extended syntax table
2490 (with-syntax-table vhdl-mode-ext-syntax-table
2493 (defmacro vhdl-prepare-search-2
(&rest body
)
2494 "Enable case insensitive search, switch to syntax table that includes `_',
2495 arrange to ignore `intangible' overlays, then execute BODY, and finally restore
2496 the old environment. Used for consistent searching."
2497 `(let ((case-fold-search t
) ; case insensitive search
2498 (current-syntax-table (syntax-table))
2499 (inhibit-point-motion-hooks t
))
2500 ;; use extended syntax table
2501 (set-syntax-table vhdl-mode-ext-syntax-table
)
2502 ;; execute BODY safely
2505 ;; restore syntax table
2506 (set-syntax-table current-syntax-table
))))
2508 (defmacro vhdl-visit-file
(file-name issue-error
&rest body
)
2509 "Visit file FILE-NAME and execute BODY."
2510 `(if (null ,file-name
)
2512 (unless (file-directory-p ,file-name
)
2513 (let ((source-buffer (current-buffer))
2514 (visiting-buffer (find-buffer-visiting ,file-name
))
2516 (when (or (and visiting-buffer
(set-buffer visiting-buffer
))
2518 (progn (set-buffer (create-file-buffer ,file-name
))
2519 (setq file-opened t
)
2520 (vhdl-insert-file-contents ,file-name
)
2521 ;; FIXME: This modifies a global syntax-table!
2522 (modify-syntax-entry ?\-
". 12" (syntax-table))
2523 (modify-syntax-entry ?
\n ">" (syntax-table))
2524 (modify-syntax-entry ?\^M
">" (syntax-table))
2525 (modify-syntax-entry ?_
"w" (syntax-table))
2530 (when file-opened
(kill-buffer (current-buffer)))
2531 (set-buffer source-buffer
)
2532 (error "ERROR: File cannot be opened: \"%s\"" ,file-name
))
2533 (vhdl-warning (format "File cannot be opened: \"%s\"" ,file-name
) t
)
2535 (condition-case info
2540 (when file-opened
(kill-buffer (current-buffer)))
2541 (set-buffer source-buffer
)
2542 (error (cadr info
)))
2543 (vhdl-warning (cadr info
))))))
2544 (when file-opened
(kill-buffer (current-buffer)))
2545 (set-buffer source-buffer
)))))
2547 (defun vhdl-insert-file-contents (filename)
2548 "Nicked from `insert-file-contents-literally', but allow coding system
2550 (let ((format-alist nil
)
2551 (after-insert-file-functions nil
)
2552 (jka-compr-compression-info-list nil
))
2553 (insert-file-contents filename t
)))
2555 (defun vhdl-sort-alist (alist)
2557 (sort alist
(function (lambda (a b
) (string< (car a
) (car b
))))))
2559 (defun vhdl-get-subdirs (directory)
2560 "Recursively get subdirectories of DIRECTORY."
2561 (let ((dir-list (list (file-name-as-directory directory
)))
2563 (setq file-list
(vhdl-directory-files directory t
"\\w.*"))
2565 (when (file-directory-p (car file-list
))
2566 (setq dir-list
(append dir-list
(vhdl-get-subdirs (car file-list
)))))
2567 (setq file-list
(cdr file-list
)))
2570 (defun vhdl-aput-delete-if-nil (alist-symbol key
&optional value
)
2571 "As `aput', but delete key-value pair if VALUE is nil."
2573 (vhdl-aput alist-symbol key value
)
2574 (vhdl-adelete alist-symbol key
)))
2576 (defun vhdl-delete (elt list
)
2577 "Delete by side effect the first occurrence of ELT as a member of LIST."
2580 (while (and (cdr list1
) (not (equal elt
(cadr list1
))))
2581 (setq list1
(cdr list1
)))
2583 (setcdr list1
(cddr list1
))))
2586 (declare-function speedbar-refresh
"speedbar" (&optional arg
))
2587 (declare-function speedbar-do-function-pointer
"speedbar" ())
2589 (defun vhdl-speedbar-refresh (&optional key
)
2590 "Refresh directory or project with name KEY."
2591 (when (and (boundp 'speedbar-frame
)
2592 (frame-live-p speedbar-frame
))
2594 (last-frame (selected-frame)))
2597 (select-frame speedbar-frame
)
2598 (when (save-excursion
2599 (goto-char (point-min))
2600 (re-search-forward (concat "^\\([0-9]+:\\s-*<\\)->\\s-+" key
"$") nil t
))
2601 (goto-char (match-end 1))
2602 (speedbar-do-function-pointer)
2604 (speedbar-do-function-pointer)
2605 (message "Refreshing speedbar...done"))
2606 (select-frame last-frame
)))))
2608 (defun vhdl-show-messages ()
2609 "Get *Messages* buffer to show recent messages."
2611 (display-buffer (if (featurep 'xemacs
) " *Message-Log*" "*Messages*")))
2613 (defun vhdl-use-direct-instantiation ()
2614 "Return whether direct instantiation is used."
2615 (or (eq vhdl-use-direct-instantiation
'always
)
2616 (and (eq vhdl-use-direct-instantiation
'standard
)
2617 (not (vhdl-standard-p '87)))))
2619 (defun vhdl-max-marker (marker1 marker2
)
2620 "Return larger marker."
2621 (if (> marker1 marker2
) marker1 marker2
))
2623 (defun vhdl-goto-marker (marker)
2624 "Goto marker in appropriate buffer."
2625 (when (markerp marker
)
2626 (set-buffer (marker-buffer marker
)))
2629 (defun vhdl-menu-split (list title
)
2630 "Split menu LIST into several submenus, if number of
2631 elements > `vhdl-menu-max-size'."
2632 (if (> (length list
) vhdl-menu-max-size
)
2639 (push (car remain
) sublist
)
2640 (setq remain
(cdr remain
))
2642 (if (= i vhdl-menu-max-size
)
2644 (push (cons (format "%s %s" title menuno
)
2645 (nreverse sublist
)) result
)
2647 (setq menuno
(+ menuno
1))
2648 (setq sublist
'()))))
2650 (push (cons (format "%s %s" title menuno
)
2651 (nreverse sublist
)) result
))
2656 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2658 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2660 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2663 (defvar vhdl-template-map nil
2664 "Keymap for VHDL templates.")
2666 (defun vhdl-template-map-init ()
2667 "Initialize `vhdl-template-map'."
2668 (setq vhdl-template-map
(make-sparse-keymap))
2669 ;; key bindings for VHDL templates
2670 (define-key vhdl-template-map
"al" 'vhdl-template-alias
)
2671 (define-key vhdl-template-map
"ar" 'vhdl-template-architecture
)
2672 (define-key vhdl-template-map
"at" 'vhdl-template-assert
)
2673 (define-key vhdl-template-map
"ad" 'vhdl-template-attribute-decl
)
2674 (define-key vhdl-template-map
"as" 'vhdl-template-attribute-spec
)
2675 (define-key vhdl-template-map
"bl" 'vhdl-template-block
)
2676 (define-key vhdl-template-map
"ca" 'vhdl-template-case-is
)
2677 (define-key vhdl-template-map
"cd" 'vhdl-template-component-decl
)
2678 (define-key vhdl-template-map
"ci" 'vhdl-template-component-inst
)
2679 (define-key vhdl-template-map
"cs" 'vhdl-template-conditional-signal-asst
)
2680 (define-key vhdl-template-map
"Cb" 'vhdl-template-block-configuration
)
2681 (define-key vhdl-template-map
"Cc" 'vhdl-template-component-conf
)
2682 (define-key vhdl-template-map
"Cd" 'vhdl-template-configuration-decl
)
2683 (define-key vhdl-template-map
"Cs" 'vhdl-template-configuration-spec
)
2684 (define-key vhdl-template-map
"co" 'vhdl-template-constant
)
2685 (define-key vhdl-template-map
"ct" 'vhdl-template-context
)
2686 (define-key vhdl-template-map
"di" 'vhdl-template-disconnect
)
2687 (define-key vhdl-template-map
"el" 'vhdl-template-else
)
2688 (define-key vhdl-template-map
"ei" 'vhdl-template-elsif
)
2689 (define-key vhdl-template-map
"en" 'vhdl-template-entity
)
2690 (define-key vhdl-template-map
"ex" 'vhdl-template-exit
)
2691 (define-key vhdl-template-map
"fi" 'vhdl-template-file
)
2692 (define-key vhdl-template-map
"fg" 'vhdl-template-for-generate
)
2693 (define-key vhdl-template-map
"fl" 'vhdl-template-for-loop
)
2694 (define-key vhdl-template-map
"\C-f" 'vhdl-template-footer
)
2695 (define-key vhdl-template-map
"fb" 'vhdl-template-function-body
)
2696 (define-key vhdl-template-map
"fd" 'vhdl-template-function-decl
)
2697 (define-key vhdl-template-map
"ge" 'vhdl-template-generic
)
2698 (define-key vhdl-template-map
"gd" 'vhdl-template-group-decl
)
2699 (define-key vhdl-template-map
"gt" 'vhdl-template-group-template
)
2700 (define-key vhdl-template-map
"\C-h" 'vhdl-template-header
)
2701 (define-key vhdl-template-map
"ig" 'vhdl-template-if-generate
)
2702 (define-key vhdl-template-map
"it" 'vhdl-template-if-then
)
2703 (define-key vhdl-template-map
"li" 'vhdl-template-library
)
2704 (define-key vhdl-template-map
"lo" 'vhdl-template-bare-loop
)
2705 (define-key vhdl-template-map
"\C-m" 'vhdl-template-modify
)
2706 (define-key vhdl-template-map
"\C-t" 'vhdl-template-insert-date
)
2707 (define-key vhdl-template-map
"ma" 'vhdl-template-map
)
2708 (define-key vhdl-template-map
"ne" 'vhdl-template-next
)
2709 (define-key vhdl-template-map
"ot" 'vhdl-template-others
)
2710 (define-key vhdl-template-map
"Pd" 'vhdl-template-package-decl
)
2711 (define-key vhdl-template-map
"Pb" 'vhdl-template-package-body
)
2712 (define-key vhdl-template-map
"(" 'vhdl-template-paired-parens
)
2713 (define-key vhdl-template-map
"po" 'vhdl-template-port
)
2714 (define-key vhdl-template-map
"pb" 'vhdl-template-procedure-body
)
2715 (define-key vhdl-template-map
"pd" 'vhdl-template-procedure-decl
)
2716 (define-key vhdl-template-map
"pc" 'vhdl-template-process-comb
)
2717 (define-key vhdl-template-map
"ps" 'vhdl-template-process-seq
)
2718 (define-key vhdl-template-map
"rp" 'vhdl-template-report
)
2719 (define-key vhdl-template-map
"rt" 'vhdl-template-return
)
2720 (define-key vhdl-template-map
"ss" 'vhdl-template-selected-signal-asst
)
2721 (define-key vhdl-template-map
"si" 'vhdl-template-signal
)
2722 (define-key vhdl-template-map
"su" 'vhdl-template-subtype
)
2723 (define-key vhdl-template-map
"ty" 'vhdl-template-type
)
2724 (define-key vhdl-template-map
"us" 'vhdl-template-use
)
2725 (define-key vhdl-template-map
"va" 'vhdl-template-variable
)
2726 (define-key vhdl-template-map
"wa" 'vhdl-template-wait
)
2727 (define-key vhdl-template-map
"wl" 'vhdl-template-while-loop
)
2728 (define-key vhdl-template-map
"wi" 'vhdl-template-with
)
2729 (define-key vhdl-template-map
"wc" 'vhdl-template-clocked-wait
)
2730 (define-key vhdl-template-map
"\C-pb" 'vhdl-template-package-numeric-bit
)
2731 (define-key vhdl-template-map
"\C-pn" 'vhdl-template-package-numeric-std
)
2732 (define-key vhdl-template-map
"\C-ps" 'vhdl-template-package-std-logic-1164
)
2733 (define-key vhdl-template-map
"\C-pA" 'vhdl-template-package-std-logic-arith
)
2734 (define-key vhdl-template-map
"\C-pM" 'vhdl-template-package-std-logic-misc
)
2735 (define-key vhdl-template-map
"\C-pS" 'vhdl-template-package-std-logic-signed
)
2736 (define-key vhdl-template-map
"\C-pT" 'vhdl-template-package-std-logic-textio
)
2737 (define-key vhdl-template-map
"\C-pU" 'vhdl-template-package-std-logic-unsigned
)
2738 (define-key vhdl-template-map
"\C-pt" 'vhdl-template-package-textio
)
2739 (define-key vhdl-template-map
"\C-dn" 'vhdl-template-directive-translate-on
)
2740 (define-key vhdl-template-map
"\C-df" 'vhdl-template-directive-translate-off
)
2741 (define-key vhdl-template-map
"\C-dN" 'vhdl-template-directive-synthesis-on
)
2742 (define-key vhdl-template-map
"\C-dF" 'vhdl-template-directive-synthesis-off
)
2743 (define-key vhdl-template-map
"\C-q" 'vhdl-template-search-prompt
)
2744 (when (vhdl-standard-p 'ams
)
2745 (define-key vhdl-template-map
"br" 'vhdl-template-break
)
2746 (define-key vhdl-template-map
"cu" 'vhdl-template-case-use
)
2747 (define-key vhdl-template-map
"iu" 'vhdl-template-if-use
)
2748 (define-key vhdl-template-map
"lm" 'vhdl-template-limit
)
2749 (define-key vhdl-template-map
"na" 'vhdl-template-nature
)
2750 (define-key vhdl-template-map
"pa" 'vhdl-template-procedural
)
2751 (define-key vhdl-template-map
"qf" 'vhdl-template-quantity-free
)
2752 (define-key vhdl-template-map
"qb" 'vhdl-template-quantity-branch
)
2753 (define-key vhdl-template-map
"qs" 'vhdl-template-quantity-source
)
2754 (define-key vhdl-template-map
"sn" 'vhdl-template-subnature
)
2755 (define-key vhdl-template-map
"te" 'vhdl-template-terminal
)
2757 (when (vhdl-standard-p 'math
)
2758 (define-key vhdl-template-map
"\C-pc" 'vhdl-template-package-math-complex
)
2759 (define-key vhdl-template-map
"\C-pr" 'vhdl-template-package-math-real
)
2762 ;; initialize template map for VHDL Mode
2763 (vhdl-template-map-init)
2765 (defun vhdl-function-name (prefix string
&optional postfix
)
2766 "Generate a Lisp function name.
2767 PREFIX, STRING and optional POSTFIX are concatenated by `-' and spaces in
2768 STRING are replaced by `-' and substrings are converted to lower case."
2769 (let ((name prefix
))
2770 (while (string-match "\\(\\w+\\)\\s-*\\(.*\\)" string
)
2772 (concat name
"-" (downcase (substring string
0 (match-end 1)))))
2773 (setq string
(substring string
(match-beginning 2))))
2774 (when postfix
(setq name
(concat name
"-" postfix
)))
2777 (defvar vhdl-model-map nil
2778 "Keymap for VHDL models.")
2780 (defun vhdl-model-map-init ()
2781 "Initialize `vhdl-model-map'."
2782 (setq vhdl-model-map
(make-sparse-keymap))
2783 ;; key bindings for VHDL models
2784 (let ((model-alist vhdl-model-alist
) model
)
2786 (setq model
(car model-alist
))
2787 (define-key vhdl-model-map
(nth 2 model
)
2788 (vhdl-function-name "vhdl-model" (nth 0 model
)))
2789 (setq model-alist
(cdr model-alist
)))))
2791 ;; initialize user model map for VHDL Mode
2792 (vhdl-model-map-init)
2794 (defvar vhdl-mode-map nil
2795 "Keymap for VHDL Mode.")
2797 (defun vhdl-mode-map-init ()
2798 "Initialize `vhdl-mode-map'."
2799 (setq vhdl-mode-map
(make-sparse-keymap))
2800 ;; template key bindings
2801 (define-key vhdl-mode-map
"\C-c\C-t" vhdl-template-map
)
2802 ;; model key bindings
2803 (define-key vhdl-mode-map
"\C-c\C-m" vhdl-model-map
)
2804 ;; standard key bindings
2805 (define-key vhdl-mode-map
"\M-a" 'vhdl-beginning-of-statement
)
2806 (define-key vhdl-mode-map
"\M-e" 'vhdl-end-of-statement
)
2807 (define-key vhdl-mode-map
"\M-\C-f" 'vhdl-forward-sexp
)
2808 (define-key vhdl-mode-map
"\M-\C-b" 'vhdl-backward-sexp
)
2809 (define-key vhdl-mode-map
"\M-\C-u" 'vhdl-backward-up-list
)
2810 (define-key vhdl-mode-map
"\M-\C-a" 'vhdl-backward-same-indent
)
2811 (define-key vhdl-mode-map
"\M-\C-e" 'vhdl-forward-same-indent
)
2812 (unless (featurep 'xemacs
) ; would override `M-backspace' in XEmacs
2813 (define-key vhdl-mode-map
"\M-\C-h" 'vhdl-mark-defun
))
2814 (define-key vhdl-mode-map
"\M-\C-q" 'vhdl-indent-sexp
)
2815 (define-key vhdl-mode-map
"\M-^" 'vhdl-delete-indentation
)
2816 ;; mode specific key bindings
2817 (define-key vhdl-mode-map
"\C-c\C-m\C-e" 'vhdl-electric-mode
)
2818 (define-key vhdl-mode-map
"\C-c\C-m\C-s" 'vhdl-stutter-mode
)
2819 (define-key vhdl-mode-map
"\C-c\C-s\C-p" 'vhdl-set-project
)
2820 (define-key vhdl-mode-map
"\C-c\C-p\C-d" 'vhdl-duplicate-project
)
2821 (define-key vhdl-mode-map
"\C-c\C-p\C-m" 'vhdl-import-project
)
2822 (define-key vhdl-mode-map
"\C-c\C-p\C-x" 'vhdl-export-project
)
2823 (define-key vhdl-mode-map
"\C-c\C-s\C-k" 'vhdl-set-compiler
)
2824 (define-key vhdl-mode-map
"\C-c\C-k" 'vhdl-compile
)
2825 (define-key vhdl-mode-map
"\C-c\M-\C-k" 'vhdl-make
)
2826 (define-key vhdl-mode-map
"\C-c\M-k" 'vhdl-generate-makefile
)
2827 (define-key vhdl-mode-map
"\C-c\C-p\C-w" 'vhdl-port-copy
)
2828 (define-key vhdl-mode-map
"\C-c\C-p\M-w" 'vhdl-port-copy
)
2829 (define-key vhdl-mode-map
"\C-c\C-p\C-e" 'vhdl-port-paste-entity
)
2830 (define-key vhdl-mode-map
"\C-c\C-p\C-c" 'vhdl-port-paste-component
)
2831 (define-key vhdl-mode-map
"\C-c\C-p\C-i" 'vhdl-port-paste-instance
)
2832 (define-key vhdl-mode-map
"\C-c\C-p\C-s" 'vhdl-port-paste-signals
)
2833 (define-key vhdl-mode-map
"\C-c\C-p\M-c" 'vhdl-port-paste-constants
)
2834 (if (featurep 'xemacs
) ; `... C-g' not allowed in XEmacs
2835 (define-key vhdl-mode-map
"\C-c\C-p\M-g" 'vhdl-port-paste-generic-map
)
2836 (define-key vhdl-mode-map
"\C-c\C-p\C-g" 'vhdl-port-paste-generic-map
))
2837 (define-key vhdl-mode-map
"\C-c\C-p\C-z" 'vhdl-port-paste-initializations
)
2838 (define-key vhdl-mode-map
"\C-c\C-p\C-t" 'vhdl-port-paste-testbench
)
2839 (define-key vhdl-mode-map
"\C-c\C-p\C-f" 'vhdl-port-flatten
)
2840 (define-key vhdl-mode-map
"\C-c\C-p\C-r" 'vhdl-port-reverse-direction
)
2841 (define-key vhdl-mode-map
"\C-c\C-s\C-w" 'vhdl-subprog-copy
)
2842 (define-key vhdl-mode-map
"\C-c\C-s\M-w" 'vhdl-subprog-copy
)
2843 (define-key vhdl-mode-map
"\C-c\C-s\C-d" 'vhdl-subprog-paste-declaration
)
2844 (define-key vhdl-mode-map
"\C-c\C-s\C-b" 'vhdl-subprog-paste-body
)
2845 (define-key vhdl-mode-map
"\C-c\C-s\C-c" 'vhdl-subprog-paste-call
)
2846 (define-key vhdl-mode-map
"\C-c\C-s\C-f" 'vhdl-subprog-flatten
)
2847 (define-key vhdl-mode-map
"\C-c\C-m\C-n" 'vhdl-compose-new-component
)
2848 (define-key vhdl-mode-map
"\C-c\C-m\C-p" 'vhdl-compose-place-component
)
2849 (define-key vhdl-mode-map
"\C-c\C-m\C-w" 'vhdl-compose-wire-components
)
2850 (define-key vhdl-mode-map
"\C-c\C-m\C-f" 'vhdl-compose-configuration
)
2851 (define-key vhdl-mode-map
"\C-c\C-m\C-k" 'vhdl-compose-components-package
)
2852 (define-key vhdl-mode-map
"\C-c\C-c" 'vhdl-comment-uncomment-region
)
2853 (define-key vhdl-mode-map
"\C-c-" 'vhdl-comment-append-inline
)
2854 (define-key vhdl-mode-map
"\C-c\M--" 'vhdl-comment-display-line
)
2855 (define-key vhdl-mode-map
"\C-c\C-i\C-l" 'indent-according-to-mode
)
2856 (define-key vhdl-mode-map
"\C-c\C-i\C-g" 'vhdl-indent-group
)
2857 (define-key vhdl-mode-map
"\M-\C-\\" 'vhdl-indent-region
)
2858 (define-key vhdl-mode-map
"\C-c\C-i\C-b" 'vhdl-indent-buffer
)
2859 (define-key vhdl-mode-map
"\C-c\C-a\C-g" 'vhdl-align-group
)
2860 (define-key vhdl-mode-map
"\C-c\C-a\C-a" 'vhdl-align-group
)
2861 (define-key vhdl-mode-map
"\C-c\C-a\C-i" 'vhdl-align-same-indent
)
2862 (define-key vhdl-mode-map
"\C-c\C-a\C-l" 'vhdl-align-list
)
2863 (define-key vhdl-mode-map
"\C-c\C-a\C-d" 'vhdl-align-declarations
)
2864 (define-key vhdl-mode-map
"\C-c\C-a\M-a" 'vhdl-align-region
)
2865 (define-key vhdl-mode-map
"\C-c\C-a\C-b" 'vhdl-align-buffer
)
2866 (define-key vhdl-mode-map
"\C-c\C-a\C-c" 'vhdl-align-inline-comment-group
)
2867 (define-key vhdl-mode-map
"\C-c\C-a\M-c" 'vhdl-align-inline-comment-region
)
2868 (define-key vhdl-mode-map
"\C-c\C-f\C-l" 'vhdl-fill-list
)
2869 (define-key vhdl-mode-map
"\C-c\C-f\C-f" 'vhdl-fill-list
)
2870 (define-key vhdl-mode-map
"\C-c\C-f\C-g" 'vhdl-fill-group
)
2871 (define-key vhdl-mode-map
"\C-c\C-f\C-i" 'vhdl-fill-same-indent
)
2872 (define-key vhdl-mode-map
"\C-c\C-f\M-f" 'vhdl-fill-region
)
2873 (define-key vhdl-mode-map
"\C-c\C-l\C-w" 'vhdl-line-kill
)
2874 (define-key vhdl-mode-map
"\C-c\C-l\M-w" 'vhdl-line-copy
)
2875 (define-key vhdl-mode-map
"\C-c\C-l\C-y" 'vhdl-line-yank
)
2876 (define-key vhdl-mode-map
"\C-c\C-l\t" 'vhdl-line-expand
)
2877 (define-key vhdl-mode-map
"\C-c\C-l\C-n" 'vhdl-line-transpose-next
)
2878 (define-key vhdl-mode-map
"\C-c\C-l\C-p" 'vhdl-line-transpose-previous
)
2879 (define-key vhdl-mode-map
"\C-c\C-l\C-o" 'vhdl-line-open
)
2880 (define-key vhdl-mode-map
"\C-c\C-l\C-g" 'goto-line
)
2881 (define-key vhdl-mode-map
"\C-c\C-l\C-c" 'vhdl-comment-uncomment-line
)
2882 (define-key vhdl-mode-map
"\C-c\C-x\C-s" 'vhdl-fix-statement-region
)
2883 (define-key vhdl-mode-map
"\C-c\C-x\M-s" 'vhdl-fix-statement-buffer
)
2884 (define-key vhdl-mode-map
"\C-c\C-x\C-p" 'vhdl-fix-clause
)
2885 (define-key vhdl-mode-map
"\C-c\C-x\M-c" 'vhdl-fix-case-region
)
2886 (define-key vhdl-mode-map
"\C-c\C-x\C-c" 'vhdl-fix-case-buffer
)
2887 (define-key vhdl-mode-map
"\C-c\C-x\M-w" 'vhdl-fixup-whitespace-region
)
2888 (define-key vhdl-mode-map
"\C-c\C-x\C-w" 'vhdl-fixup-whitespace-buffer
)
2889 (define-key vhdl-mode-map
"\C-c\M-b" 'vhdl-beautify-region
)
2890 (define-key vhdl-mode-map
"\C-c\C-b" 'vhdl-beautify-buffer
)
2891 (define-key vhdl-mode-map
"\C-c\C-u\C-s" 'vhdl-update-sensitivity-list-process
)
2892 (define-key vhdl-mode-map
"\C-c\C-u\M-s" 'vhdl-update-sensitivity-list-buffer
)
2893 (define-key vhdl-mode-map
"\C-c\C-i\C-f" 'vhdl-fontify-buffer
)
2894 (define-key vhdl-mode-map
"\C-c\C-i\C-s" 'vhdl-statistics-buffer
)
2895 (define-key vhdl-mode-map
"\C-c\M-m" 'vhdl-show-messages
)
2896 (define-key vhdl-mode-map
"\C-c\C-h" 'vhdl-doc-mode
)
2897 (define-key vhdl-mode-map
"\C-c\C-v" 'vhdl-version
)
2898 (define-key vhdl-mode-map
"\M-\t" 'insert-tab
)
2899 ;; insert commands bindings
2900 (define-key vhdl-mode-map
"\C-c\C-i\C-t" 'vhdl-template-insert-construct
)
2901 (define-key vhdl-mode-map
"\C-c\C-i\C-p" 'vhdl-template-insert-package
)
2902 (define-key vhdl-mode-map
"\C-c\C-i\C-d" 'vhdl-template-insert-directive
)
2903 (define-key vhdl-mode-map
"\C-c\C-i\C-m" 'vhdl-model-insert
)
2904 ;; electric key bindings
2905 (define-key vhdl-mode-map
" " 'vhdl-electric-space
)
2906 (when vhdl-intelligent-tab
2907 (define-key vhdl-mode-map
"\t" 'vhdl-electric-tab
))
2908 (define-key vhdl-mode-map
"\r" 'vhdl-electric-return
)
2909 (define-key vhdl-mode-map
"-" 'vhdl-electric-dash
)
2910 (define-key vhdl-mode-map
"[" 'vhdl-electric-open-bracket
)
2911 (define-key vhdl-mode-map
"]" 'vhdl-electric-close-bracket
)
2912 (define-key vhdl-mode-map
"'" 'vhdl-electric-quote
)
2913 (define-key vhdl-mode-map
";" 'vhdl-electric-semicolon
)
2914 (define-key vhdl-mode-map
"," 'vhdl-electric-comma
)
2915 (define-key vhdl-mode-map
"." 'vhdl-electric-period
)
2916 (when (vhdl-standard-p 'ams
)
2917 (define-key vhdl-mode-map
"=" 'vhdl-electric-equal
)))
2919 ;; initialize mode map for VHDL Mode
2920 (vhdl-mode-map-init)
2922 ;; define special minibuffer keymap for enabling word completion in minibuffer
2923 ;; (useful in template generator prompts)
2924 (defvar vhdl-minibuffer-local-map
2925 (let ((map (make-sparse-keymap)))
2926 (set-keymap-parent map minibuffer-local-map
)
2927 (when vhdl-word-completion-in-minibuffer
2928 (define-key map
"\t" 'vhdl-minibuffer-tab
))
2930 "Keymap for minibuffer used in VHDL Mode.")
2932 ;; set up electric character functions to work with
2933 ;; `delete-selection-mode' (Emacs) and `pending-delete-mode' (XEmacs)
2937 (put sym
'delete-selection t
) ; for `delete-selection-mode' (Emacs)
2938 (put sym
'pending-delete t
))) ; for `pending-delete-mode' (XEmacs)
2939 '(vhdl-electric-space
2941 vhdl-electric-return
2943 vhdl-electric-open-bracket
2944 vhdl-electric-close-bracket
2946 vhdl-electric-semicolon
2948 vhdl-electric-period
2949 vhdl-electric-equal
))
2951 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2954 (defvar vhdl-mode-syntax-table
2955 (let ((st (make-syntax-table)))
2956 ;; define punctuation
2957 (modify-syntax-entry ?\
# "." st
)
2958 (modify-syntax-entry ?\$
"." st
)
2959 (modify-syntax-entry ?\%
"." st
)
2960 (modify-syntax-entry ?\
& "." st
)
2961 (modify-syntax-entry ?
\' "." st
)
2962 (modify-syntax-entry ?\
* "." st
)
2963 (modify-syntax-entry ?\
+ "." st
)
2964 (modify-syntax-entry ?\.
"." st
)
2965 ;;; (modify-syntax-entry ?\/ "." st)
2966 (modify-syntax-entry ?\
: "." st
)
2967 (modify-syntax-entry ?\
; "." st)
2968 (modify-syntax-entry ?\
< "." st
)
2969 (modify-syntax-entry ?\
= "." st
)
2970 (modify-syntax-entry ?\
> "." st
)
2971 (modify-syntax-entry ?
\\ "." st
)
2972 (modify-syntax-entry ?\|
"." st
)
2974 (modify-syntax-entry ?
\" "\"" st
)
2975 ;; define underscore
2976 (modify-syntax-entry ?\_
(if vhdl-underscore-is-part-of-word
"w" "_") st
)
2977 ;; single-line comments
2978 (modify-syntax-entry ?\-
". 12b" st
)
2979 ;; multi-line comments
2980 (modify-syntax-entry ?\
/ ". 14b" st
)
2981 (modify-syntax-entry ?
* ". 23" st
)
2982 (modify-syntax-entry ?
\n "> b" st
)
2983 (modify-syntax-entry ?\^M
"> b" st
)
2984 ;; define parentheses to match
2985 (modify-syntax-entry ?\
( "()" st
)
2986 (modify-syntax-entry ?\
) ")(" st
)
2987 (modify-syntax-entry ?\
[ "(]" st
)
2988 (modify-syntax-entry ?\
] ")[" st
)
2989 (modify-syntax-entry ?\
{ "(}" st
)
2990 (modify-syntax-entry ?\
} "){" st
)
2992 "Syntax table used in `vhdl-mode' buffers.")
2994 (defvar vhdl-mode-ext-syntax-table
2995 ;; Extended syntax table including '_' (for simpler search regexps).
2996 (let ((st (copy-syntax-table vhdl-mode-syntax-table
)))
2997 (modify-syntax-entry ?_
"w" st
)
2999 "Syntax table extended by `_' used in `vhdl-mode' buffers.")
3001 (defvar vhdl-syntactic-context nil
3002 "Buffer local variable containing syntactic analysis list.")
3003 (make-variable-buffer-local 'vhdl-syntactic-context
)
3005 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3006 ;; Abbrev hook bindings
3008 (defvar vhdl-mode-abbrev-table nil
3009 "Abbrev table to use in `vhdl-mode' buffers.")
3011 (defun vhdl-mode-abbrev-table-init ()
3012 "Initialize `vhdl-mode-abbrev-table'."
3013 (define-abbrev-table 'vhdl-mode-abbrev-table
3015 (when (memq 'vhdl vhdl-electric-keywords
)
3017 (mapcar (if (featurep 'xemacs
)
3018 (lambda (x) (list (car x
) "" (cdr x
) 0))
3019 (lambda (x) (list (car x
) "" (cdr x
) 0 'system
)))
3021 ("--" . vhdl-template-display-comment-hook
)
3022 ("abs" . vhdl-template-default-hook
)
3023 ("access" . vhdl-template-default-hook
)
3024 ("after" . vhdl-template-default-hook
)
3025 ("alias" . vhdl-template-alias-hook
)
3026 ("all" . vhdl-template-default-hook
)
3027 ("and" . vhdl-template-default-hook
)
3028 ("arch" . vhdl-template-architecture-hook
)
3029 ("architecture" . vhdl-template-architecture-hook
)
3030 ("array" . vhdl-template-default-hook
)
3031 ("assert" . vhdl-template-assert-hook
)
3032 ("attr" . vhdl-template-attribute-hook
)
3033 ("attribute" . vhdl-template-attribute-hook
)
3034 ("begin" . vhdl-template-default-indent-hook
)
3035 ("block" . vhdl-template-block-hook
)
3036 ("body" . vhdl-template-default-hook
)
3037 ("buffer" . vhdl-template-default-hook
)
3038 ("bus" . vhdl-template-default-hook
)
3039 ("case" . vhdl-template-case-hook
)
3040 ("comp" . vhdl-template-component-hook
)
3041 ("component" . vhdl-template-component-hook
)
3042 ("cond" . vhdl-template-conditional-signal-asst-hook
)
3043 ("conditional" . vhdl-template-conditional-signal-asst-hook
)
3044 ("conf" . vhdl-template-configuration-hook
)
3045 ("configuration" . vhdl-template-configuration-hook
)
3046 ("cons" . vhdl-template-constant-hook
)
3047 ("constant" . vhdl-template-constant-hook
)
3048 ("context" . vhdl-template-context-hook
)
3049 ("disconnect" . vhdl-template-disconnect-hook
)
3050 ("downto" . vhdl-template-default-hook
)
3051 ("else" . vhdl-template-else-hook
)
3052 ("elseif" . vhdl-template-elsif-hook
)
3053 ("elsif" . vhdl-template-elsif-hook
)
3054 ("end" . vhdl-template-default-indent-hook
)
3055 ("entity" . vhdl-template-entity-hook
)
3056 ("exit" . vhdl-template-exit-hook
)
3057 ("file" . vhdl-template-file-hook
)
3058 ("for" . vhdl-template-for-hook
)
3059 ("func" . vhdl-template-function-hook
)
3060 ("function" . vhdl-template-function-hook
)
3061 ("generic" . vhdl-template-generic-hook
)
3062 ("group" . vhdl-template-group-hook
)
3063 ("guarded" . vhdl-template-default-hook
)
3064 ("if" . vhdl-template-if-hook
)
3065 ("impure" . vhdl-template-default-hook
)
3066 ("in" . vhdl-template-default-hook
)
3067 ("inertial" . vhdl-template-default-hook
)
3068 ("inout" . vhdl-template-default-hook
)
3069 ("inst" . vhdl-template-instance-hook
)
3070 ("instance" . vhdl-template-instance-hook
)
3071 ("is" . vhdl-template-default-hook
)
3072 ("label" . vhdl-template-default-hook
)
3073 ("library" . vhdl-template-library-hook
)
3074 ("linkage" . vhdl-template-default-hook
)
3075 ("literal" . vhdl-template-default-hook
)
3076 ("loop" . vhdl-template-bare-loop-hook
)
3077 ("map" . vhdl-template-map-hook
)
3078 ("mod" . vhdl-template-default-hook
)
3079 ("nand" . vhdl-template-default-hook
)
3080 ("new" . vhdl-template-default-hook
)
3081 ("next" . vhdl-template-next-hook
)
3082 ("nor" . vhdl-template-default-hook
)
3083 ("not" . vhdl-template-default-hook
)
3084 ("null" . vhdl-template-default-hook
)
3085 ("of" . vhdl-template-default-hook
)
3086 ("on" . vhdl-template-default-hook
)
3087 ("open" . vhdl-template-default-hook
)
3088 ("or" . vhdl-template-default-hook
)
3089 ("others" . vhdl-template-others-hook
)
3090 ("out" . vhdl-template-default-hook
)
3091 ("pack" . vhdl-template-package-hook
)
3092 ("package" . vhdl-template-package-hook
)
3093 ("port" . vhdl-template-port-hook
)
3094 ("postponed" . vhdl-template-default-hook
)
3095 ("procedure" . vhdl-template-procedure-hook
)
3096 ("process" . vhdl-template-process-hook
)
3097 ("pure" . vhdl-template-default-hook
)
3098 ("range" . vhdl-template-default-hook
)
3099 ("record" . vhdl-template-default-hook
)
3100 ("register" . vhdl-template-default-hook
)
3101 ("reject" . vhdl-template-default-hook
)
3102 ("rem" . vhdl-template-default-hook
)
3103 ("report" . vhdl-template-report-hook
)
3104 ("return" . vhdl-template-return-hook
)
3105 ("rol" . vhdl-template-default-hook
)
3106 ("ror" . vhdl-template-default-hook
)
3107 ("select" . vhdl-template-selected-signal-asst-hook
)
3108 ("severity" . vhdl-template-default-hook
)
3109 ("shared" . vhdl-template-default-hook
)
3110 ("sig" . vhdl-template-signal-hook
)
3111 ("signal" . vhdl-template-signal-hook
)
3112 ("sla" . vhdl-template-default-hook
)
3113 ("sll" . vhdl-template-default-hook
)
3114 ("sra" . vhdl-template-default-hook
)
3115 ("srl" . vhdl-template-default-hook
)
3116 ("subtype" . vhdl-template-subtype-hook
)
3117 ("then" . vhdl-template-default-hook
)
3118 ("to" . vhdl-template-default-hook
)
3119 ("transport" . vhdl-template-default-hook
)
3120 ("type" . vhdl-template-type-hook
)
3121 ("unaffected" . vhdl-template-default-hook
)
3122 ("units" . vhdl-template-default-hook
)
3123 ("until" . vhdl-template-default-hook
)
3124 ("use" . vhdl-template-use-hook
)
3125 ("var" . vhdl-template-variable-hook
)
3126 ("variable" . vhdl-template-variable-hook
)
3127 ("wait" . vhdl-template-wait-hook
)
3128 ("when" . vhdl-template-when-hook
)
3129 ("while" . vhdl-template-while-loop-hook
)
3130 ("with" . vhdl-template-with-hook
)
3131 ("xnor" . vhdl-template-default-hook
)
3132 ("xor" . vhdl-template-default-hook
)
3134 ;; VHDL-AMS keywords
3135 (when (and (memq 'vhdl vhdl-electric-keywords
) (vhdl-standard-p 'ams
))
3136 (mapcar (if (featurep 'xemacs
)
3137 (lambda (x) (list (car x
) "" (cdr x
) 0))
3138 (lambda (x) (list (car x
) "" (cdr x
) 0 'system
)))
3140 ("across" . vhdl-template-default-hook
)
3141 ("break" . vhdl-template-break-hook
)
3142 ("limit" . vhdl-template-limit-hook
)
3143 ("nature" . vhdl-template-nature-hook
)
3144 ("noise" . vhdl-template-default-hook
)
3145 ("procedural" . vhdl-template-procedural-hook
)
3146 ("quantity" . vhdl-template-quantity-hook
)
3147 ("reference" . vhdl-template-default-hook
)
3148 ("spectrum" . vhdl-template-default-hook
)
3149 ("subnature" . vhdl-template-subnature-hook
)
3150 ("terminal" . vhdl-template-terminal-hook
)
3151 ("through" . vhdl-template-default-hook
)
3152 ("tolerance" . vhdl-template-default-hook
)
3154 ;; user model keywords
3155 (when (memq 'user vhdl-electric-keywords
)
3156 (let (abbrev-list keyword
)
3157 (dolist (elem vhdl-model-alist
)
3158 (setq keyword
(nth 3 elem
))
3159 (unless (equal keyword
"")
3160 (push (list keyword
""
3162 "vhdl-model" (nth 0 elem
) "hook") 0 'system
)
3166 ;; initialize abbrev table for VHDL Mode
3167 (vhdl-mode-abbrev-table-init)
3169 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3170 ;; Template completion lists
3172 (defvar vhdl-template-construct-alist nil
3173 "List of built-in construct templates.")
3175 (defun vhdl-template-construct-alist-init ()
3176 "Initialize `vhdl-template-construct-alist'."
3178 vhdl-template-construct-alist
3181 ("alias declaration" vhdl-template-alias
)
3182 ("architecture body" vhdl-template-architecture
)
3183 ("assertion" vhdl-template-assert
)
3184 ("attribute declaration" vhdl-template-attribute-decl
)
3185 ("attribute specification" vhdl-template-attribute-spec
)
3186 ("block configuration" vhdl-template-block-configuration
)
3187 ("block statement" vhdl-template-block
)
3188 ("case statement" vhdl-template-case-is
)
3189 ("component configuration" vhdl-template-component-conf
)
3190 ("component declaration" vhdl-template-component-decl
)
3191 ("component instantiation statement" vhdl-template-component-inst
)
3192 ("conditional signal assignment" vhdl-template-conditional-signal-asst
)
3193 ("configuration declaration" vhdl-template-configuration-decl
)
3194 ("configuration specification" vhdl-template-configuration-spec
)
3195 ("constant declaration" vhdl-template-constant
)
3196 ("context declaration" vhdl-template-context
)
3197 ("disconnection specification" vhdl-template-disconnect
)
3198 ("entity declaration" vhdl-template-entity
)
3199 ("exit statement" vhdl-template-exit
)
3200 ("file declaration" vhdl-template-file
)
3201 ("generate statement" vhdl-template-generate
)
3202 ("generic clause" vhdl-template-generic
)
3203 ("group declaration" vhdl-template-group-decl
)
3204 ("group template declaration" vhdl-template-group-template
)
3205 ("if statement" vhdl-template-if-then
)
3206 ("library clause" vhdl-template-library
)
3207 ("loop statement" vhdl-template-loop
)
3208 ("next statement" vhdl-template-next
)
3209 ("package declaration" vhdl-template-package-decl
)
3210 ("package body" vhdl-template-package-body
)
3211 ("port clause" vhdl-template-port
)
3212 ("process statement" vhdl-template-process
)
3213 ("report statement" vhdl-template-report
)
3214 ("return statement" vhdl-template-return
)
3215 ("selected signal assignment" vhdl-template-selected-signal-asst
)
3216 ("signal declaration" vhdl-template-signal
)
3217 ("subprogram declaration" vhdl-template-subprogram-decl
)
3218 ("subprogram body" vhdl-template-subprogram-body
)
3219 ("subtype declaration" vhdl-template-subtype
)
3220 ("type declaration" vhdl-template-type
)
3221 ("use clause" vhdl-template-use
)
3222 ("variable declaration" vhdl-template-variable
)
3223 ("wait statement" vhdl-template-wait
)
3225 (when (vhdl-standard-p 'ams
)
3227 ("break statement" vhdl-template-break
)
3228 ("nature declaration" vhdl-template-nature
)
3229 ("quantity declaration" vhdl-template-quantity
)
3230 ("simultaneous case statement" vhdl-template-case-use
)
3231 ("simultaneous if statement" vhdl-template-if-use
)
3232 ("simultaneous procedural statement" vhdl-template-procedural
)
3233 ("step limit specification" vhdl-template-limit
)
3234 ("subnature declaration" vhdl-template-subnature
)
3235 ("terminal declaration" vhdl-template-terminal
)
3238 ;; initialize for VHDL Mode
3239 (vhdl-template-construct-alist-init)
3241 (defvar vhdl-template-package-alist nil
3242 "List of built-in package templates.")
3244 (defun vhdl-template-package-alist-init ()
3245 "Initialize `vhdl-template-package-alist'."
3247 vhdl-template-package-alist
3250 ("numeric_bit" vhdl-template-package-numeric-bit
)
3251 ("numeric_std" vhdl-template-package-numeric-std
)
3252 ("std_logic_1164" vhdl-template-package-std-logic-1164
)
3253 ("std_logic_arith" vhdl-template-package-std-logic-arith
)
3254 ("std_logic_misc" vhdl-template-package-std-logic-misc
)
3255 ("std_logic_signed" vhdl-template-package-std-logic-signed
)
3256 ("std_logic_textio" vhdl-template-package-std-logic-textio
)
3257 ("std_logic_unsigned" vhdl-template-package-std-logic-unsigned
)
3258 ("textio" vhdl-template-package-textio
)
3260 (when (vhdl-standard-p 'math
)
3262 ("math_complex" vhdl-template-package-math-complex
)
3263 ("math_real" vhdl-template-package-math-real
)
3266 ;; initialize for VHDL Mode
3267 (vhdl-template-package-alist-init)
3269 (defvar vhdl-template-directive-alist
3271 ("translate_on" vhdl-template-directive-translate-on
)
3272 ("translate_off" vhdl-template-directive-translate-off
)
3273 ("synthesis_on" vhdl-template-directive-synthesis-on
)
3274 ("synthesis_off" vhdl-template-directive-synthesis-off
)
3276 "List of built-in directive templates.")
3279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3281 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3283 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3284 ;; VHDL menu (using `easy-menu.el')
3286 (defun vhdl-customize ()
3287 "Call the customize function with `vhdl' as argument."
3289 (customize-browse 'vhdl
))
3291 (defun vhdl-create-mode-menu ()
3292 "Create VHDL Mode menu."
3296 ["None" (vhdl-set-project "")
3297 :style radio
:selected
(null vhdl-project
)]
3299 ;; add menu entries for defined projects
3300 (let ((project-alist vhdl-project-alist
) menu-list name
)
3301 (while project-alist
3302 (setq name
(caar project-alist
))
3304 (cons `[,name
(vhdl-set-project ,name
)
3305 :style radio
:selected
(equal ,name vhdl-project
)]
3307 (setq project-alist
(cdr project-alist
)))
3309 (if vhdl-project-sort
3311 (function (lambda (a b
) (string< (elt a
0) (elt b
0)))))
3312 (nreverse menu-list
)))
3313 (vhdl-menu-split menu-list
"Project"))
3315 ["Select Project..." vhdl-set-project t
]
3316 ["Set As Default Project" vhdl-set-default-project t
]
3318 ["Duplicate Project" vhdl-duplicate-project vhdl-project
]
3319 ["Import Project..." vhdl-import-project
3320 :keys
"C-c C-p C-m" :active t
]
3321 ["Export Project" vhdl-export-project vhdl-project
]
3323 ["Customize Project..." (customize-option 'vhdl-project-alist
) t
]))
3326 ["Compile Buffer" vhdl-compile t
]
3327 ["Stop Compilation" kill-compilation t
]
3329 ["Make" vhdl-make t
]
3330 ["Generate Makefile" vhdl-generate-makefile t
]
3332 ["Next Error" next-error t
]
3333 ["Previous Error" previous-error t
]
3334 ["First Error" first-error t
]
3338 ;; add menu entries for defined compilers
3339 (let ((comp-alist vhdl-compiler-alist
) menu-list name
)
3341 (setq name
(caar comp-alist
))
3343 (cons `[,name
(setq vhdl-compiler
,name
)
3344 :style radio
:selected
(equal ,name vhdl-compiler
)]
3346 (setq comp-alist
(cdr comp-alist
)))
3347 (setq menu-list
(nreverse menu-list
))
3348 (vhdl-menu-split menu-list
"Compiler"))
3350 ["Select Compiler..." vhdl-set-compiler t
]
3352 ["Customize Compiler..."
3353 (customize-option 'vhdl-compiler-alist
) t
])))
3358 ["Alias" vhdl-template-alias t
]
3359 ["Architecture" vhdl-template-architecture t
]
3360 ["Assert" vhdl-template-assert t
]
3361 ["Attribute (Decl)" vhdl-template-attribute-decl t
]
3362 ["Attribute (Spec)" vhdl-template-attribute-spec t
]
3363 ["Block" vhdl-template-block t
]
3364 ["Case" vhdl-template-case-is t
]
3365 ["Component (Decl)" vhdl-template-component-decl t
]
3366 ["(Component) Instance" vhdl-template-component-inst t
]
3367 ["Conditional (Signal Asst)" vhdl-template-conditional-signal-asst t
]
3368 ["Configuration (Block)" vhdl-template-block-configuration t
]
3369 ["Configuration (Comp)" vhdl-template-component-conf t
]
3370 ["Configuration (Decl)" vhdl-template-configuration-decl t
]
3371 ["Configuration (Spec)" vhdl-template-configuration-spec t
]
3372 ["Constant" vhdl-template-constant t
]
3373 ["Context" vhdl-template-context t
]
3374 ["Disconnect" vhdl-template-disconnect t
]
3375 ["Else" vhdl-template-else t
]
3376 ["Elsif" vhdl-template-elsif t
]
3377 ["Entity" vhdl-template-entity t
]
3378 ["Exit" vhdl-template-exit t
]
3379 ["File" vhdl-template-file t
]
3380 ["For (Generate)" vhdl-template-for-generate t
]
3381 ["For (Loop)" vhdl-template-for-loop t
]
3382 ["Function (Body)" vhdl-template-function-body t
]
3383 ["Function (Decl)" vhdl-template-function-decl t
]
3384 ["Generic" vhdl-template-generic t
]
3385 ["Group (Decl)" vhdl-template-group-decl t
]
3386 ["Group (Template)" vhdl-template-group-template t
])
3388 ["If (Generate)" vhdl-template-if-generate t
]
3389 ["If (Then)" vhdl-template-if-then t
]
3390 ["Library" vhdl-template-library t
]
3391 ["Loop" vhdl-template-bare-loop t
]
3392 ["Map" vhdl-template-map t
]
3393 ["Next" vhdl-template-next t
]
3394 ["Others (Aggregate)" vhdl-template-others t
]
3395 ["Package (Decl)" vhdl-template-package-decl t
]
3396 ["Package (Body)" vhdl-template-package-body t
]
3397 ["Port" vhdl-template-port t
]
3398 ["Procedure (Body)" vhdl-template-procedure-body t
]
3399 ["Procedure (Decl)" vhdl-template-procedure-decl t
]
3400 ["Process (Comb)" vhdl-template-process-comb t
]
3401 ["Process (Seq)" vhdl-template-process-seq t
]
3402 ["Report" vhdl-template-report t
]
3403 ["Return" vhdl-template-return t
]
3404 ["Select" vhdl-template-selected-signal-asst t
]
3405 ["Signal" vhdl-template-signal t
]
3406 ["Subtype" vhdl-template-subtype t
]
3407 ["Type" vhdl-template-type t
]
3408 ["Use" vhdl-template-use t
]
3409 ["Variable" vhdl-template-variable t
]
3410 ["Wait" vhdl-template-wait t
]
3411 ["(Clocked Wait)" vhdl-template-clocked-wait t
]
3412 ["When" vhdl-template-when t
]
3413 ["While (Loop)" vhdl-template-while-loop t
]
3414 ["With" vhdl-template-with t
]))
3415 (when (vhdl-standard-p 'ams
)
3416 '(("VHDL-AMS Construct"
3417 ["Break" vhdl-template-break t
]
3418 ["Case (Use)" vhdl-template-case-use t
]
3419 ["If (Use)" vhdl-template-if-use t
]
3420 ["Limit" vhdl-template-limit t
]
3421 ["Nature" vhdl-template-nature t
]
3422 ["Procedural" vhdl-template-procedural t
]
3423 ["Quantity (Free)" vhdl-template-quantity-free t
]
3424 ["Quantity (Branch)" vhdl-template-quantity-branch t
]
3425 ["Quantity (Source)" vhdl-template-quantity-source t
]
3426 ["Subnature" vhdl-template-subnature t
]
3427 ["Terminal" vhdl-template-terminal t
])))
3428 '(["Insert Construct..." vhdl-template-insert-construct
3429 :keys
"C-c C-i C-t"]
3434 '(["numeric_bit" vhdl-template-package-numeric-bit t
]
3435 ["numeric_std" vhdl-template-package-numeric-std t
]
3436 ["std_logic_1164" vhdl-template-package-std-logic-1164 t
]
3437 ["textio" vhdl-template-package-textio t
]
3439 ["std_logic_arith" vhdl-template-package-std-logic-arith t
]
3440 ["std_logic_signed" vhdl-template-package-std-logic-signed t
]
3441 ["std_logic_unsigned" vhdl-template-package-std-logic-unsigned t
]
3442 ["std_logic_misc" vhdl-template-package-std-logic-misc t
]
3443 ["std_logic_textio" vhdl-template-package-std-logic-textio t
]
3445 (when (vhdl-standard-p 'ams
)
3446 '(["fundamental_constants" vhdl-template-package-fundamental-constants t
]
3447 ["material_constants" vhdl-template-package-material-constants t
]
3448 ["energy_systems" vhdl-template-package-energy-systems t
]
3449 ["electrical_systems" vhdl-template-package-electrical-systems t
]
3450 ["mechanical_systems" vhdl-template-package-mechanical-systems t
]
3451 ["radiant_systems" vhdl-template-package-radiant-systems t
]
3452 ["thermal_systems" vhdl-template-package-thermal-systems t
]
3453 ["fluidic_systems" vhdl-template-package-fluidic-systems t
]
3455 (when (vhdl-standard-p 'math
)
3456 '(["math_complex" vhdl-template-package-math-complex t
]
3457 ["math_real" vhdl-template-package-math-real t
]
3459 '(["Insert Package..." vhdl-template-insert-package
3460 :keys
"C-c C-i C-p"])))
3462 ["translate_on" vhdl-template-directive-translate-on t
]
3463 ["translate_off" vhdl-template-directive-translate-off t
]
3464 ["synthesis_on" vhdl-template-directive-synthesis-on t
]
3465 ["synthesis_off" vhdl-template-directive-synthesis-off t
]
3467 ["Insert Directive..." vhdl-template-insert-directive
3468 :keys
"C-c C-i C-d"])
3470 ["Insert Header" vhdl-template-header
:keys
"C-c C-t C-h"]
3471 ["Insert Footer" vhdl-template-footer t
]
3472 ["Insert Date" vhdl-template-insert-date t
]
3473 ["Modify Date" vhdl-template-modify
:keys
"C-c C-t C-m"]
3475 ["Query Next Prompt" vhdl-template-search-prompt t
]))
3478 ;; add menu entries for defined models
3479 (let ((model-alist vhdl-model-alist
) menu-list model
)
3481 (setq model
(car model-alist
))
3486 (vhdl-function-name "vhdl-model" (nth 0 model
))
3487 :keys
(concat "C-c C-m " (key-description (nth 2 model
))))
3489 (setq model-alist
(cdr model-alist
)))
3490 (setq menu-list
(nreverse menu-list
))
3491 (vhdl-menu-split menu-list
"Model"))
3493 ["Insert Model..." vhdl-model-insert
:keys
"C-c C-i C-m"]
3494 ["Customize Model..." (customize-option 'vhdl-model-alist
) t
]))
3496 ["Copy" vhdl-port-copy t
]
3498 ["Paste As Entity" vhdl-port-paste-entity vhdl-port-list
]
3499 ["Paste As Component" vhdl-port-paste-component vhdl-port-list
]
3500 ["Paste As Instance" vhdl-port-paste-instance
3501 :keys
"C-c C-p C-i" :active vhdl-port-list
]
3502 ["Paste As Signals" vhdl-port-paste-signals vhdl-port-list
]
3503 ["Paste As Constants" vhdl-port-paste-constants vhdl-port-list
]
3504 ["Paste As Generic Map" vhdl-port-paste-generic-map vhdl-port-list
]
3505 ["Paste As Initializations" vhdl-port-paste-initializations vhdl-port-list
]
3507 ["Paste As Testbench" vhdl-port-paste-testbench vhdl-port-list
]
3509 ["Flatten" vhdl-port-flatten
3510 :style toggle
:selected vhdl-port-flattened
:active vhdl-port-list
]
3511 ["Reverse Direction" vhdl-port-reverse-direction
3512 :style toggle
:selected vhdl-port-reversed-direction
:active vhdl-port-list
])
3514 ["New Component" vhdl-compose-new-component t
]
3515 ["Copy Component" vhdl-port-copy t
]
3516 ["Place Component" vhdl-compose-place-component vhdl-port-list
]
3517 ["Wire Components" vhdl-compose-wire-components t
]
3519 ["Generate Configuration" vhdl-compose-configuration t
]
3520 ["Generate Components Package" vhdl-compose-components-package t
])
3522 ["Copy" vhdl-subprog-copy t
]
3524 ["Paste As Declaration" vhdl-subprog-paste-declaration vhdl-subprog-list
]
3525 ["Paste As Body" vhdl-subprog-paste-body vhdl-subprog-list
]
3526 ["Paste As Call" vhdl-subprog-paste-call vhdl-subprog-list
]
3528 ["Flatten" vhdl-subprog-flatten
3529 :style toggle
:selected vhdl-subprog-flattened
:active vhdl-subprog-list
])
3532 ["(Un)Comment Out Region" vhdl-comment-uncomment-region
(mark)]
3534 ["Insert Inline Comment" vhdl-comment-append-inline t
]
3535 ["Insert Horizontal Line" vhdl-comment-display-line t
]
3536 ["Insert Display Comment" vhdl-comment-display t
]
3538 ["Fill Comment" fill-paragraph t
]
3539 ["Fill Comment Region" fill-region
(mark)]
3540 ["Kill Comment Region" vhdl-comment-kill-region
(mark)]
3541 ["Kill Inline Comment Region" vhdl-comment-kill-inline-region
(mark)])
3543 ["Kill" vhdl-line-kill t
]
3544 ["Copy" vhdl-line-copy t
]
3545 ["Yank" vhdl-line-yank t
]
3546 ["Expand" vhdl-line-expand t
]
3548 ["Transpose Next" vhdl-line-transpose-next t
]
3549 ["Transpose Prev" vhdl-line-transpose-previous t
]
3550 ["Open" vhdl-line-open t
]
3551 ["Join" vhdl-delete-indentation t
]
3553 ["Goto" goto-line t
]
3554 ["(Un)Comment Out" vhdl-comment-uncomment-line t
])
3556 ["Forward Statement" vhdl-end-of-statement t
]
3557 ["Backward Statement" vhdl-beginning-of-statement t
]
3558 ["Forward Expression" vhdl-forward-sexp t
]
3559 ["Backward Expression" vhdl-backward-sexp t
]
3560 ["Forward Same Indent" vhdl-forward-same-indent t
]
3561 ["Backward Same Indent" vhdl-backward-same-indent t
]
3562 ["Forward Function" vhdl-end-of-defun
t]
3563 ["Backward Function" vhdl-beginning-of-defun
t]
3564 ["Mark Function" vhdl-mark-defun
t])
3567 ["Line" indent-according-to-mode
:keys
"C-c C-i C-l"]
3568 ["Group" vhdl-indent-group
:keys
"C-c C-i C-g"]
3569 ["Region" vhdl-indent-region
(mark)]
3570 ["Buffer" vhdl-indent-buffer
:keys
"C-c C-i C-b"])
3572 ["Group" vhdl-align-group t
]
3573 ["Same Indent" vhdl-align-same-indent
:keys
"C-c C-a C-i"]
3574 ["List" vhdl-align-list t
]
3575 ["Declarations" vhdl-align-declarations t
]
3576 ["Region" vhdl-align-region
(mark)]
3577 ["Buffer" vhdl-align-buffer t
]
3579 ["Inline Comment Group" vhdl-align-inline-comment-group t
]
3580 ["Inline Comment Region" vhdl-align-inline-comment-region
(mark)]
3581 ["Inline Comment Buffer" vhdl-align-inline-comment-buffer t
])
3583 ["List" vhdl-fill-list t
]
3584 ["Group" vhdl-fill-group t
]
3585 ["Same Indent" vhdl-fill-same-indent
:keys
"C-c C-f C-i"]
3586 ["Region" vhdl-fill-region
(mark)])
3588 ["Region" vhdl-beautify-region
(mark)]
3589 ["Buffer" vhdl-beautify-buffer t
])
3591 ["Generic/Port Clause" vhdl-fix-clause t
]
3592 ["Generic/Port Clause Buffer" vhdl-fix-clause t
]
3594 ["Case Region" vhdl-fix-case-region
(mark)]
3595 ["Case Buffer" vhdl-fix-case-buffer t
]
3597 ["Whitespace Region" vhdl-fixup-whitespace-region
(mark)]
3598 ["Whitespace Buffer" vhdl-fixup-whitespace-buffer t
]
3600 ["Statement Region" vhdl-fix-statement-region
(mark)]
3601 ["Statement Buffer" vhdl-fix-statement-buffer t
]
3603 ["Trailing Spaces Buffer" vhdl-remove-trailing-spaces t
])
3605 ["Sensitivity List" vhdl-update-sensitivity-list-process t
]
3606 ["Sensitivity List Buffer" vhdl-update-sensitivity-list-buffer t
])
3608 ["Fontify Buffer" vhdl-fontify-buffer t
]
3609 ["Statistics Buffer" vhdl-statistics-buffer t
]
3610 ["Show Messages" vhdl-show-messages t
]
3611 ["Syntactic Info" vhdl-show-syntactic-information t
]
3613 ["Speedbar" vhdl-speedbar t
]
3614 ["Hide/Show" vhdl-hs-minor-mode t
]
3617 ["VHDL Mode" vhdl-doc-mode
:keys
"C-c C-h"]
3618 ["Release Notes" (vhdl-doc-variable 'vhdl-doc-release-notes
) t
]
3619 ["Reserved Words" (vhdl-doc-variable 'vhdl-doc-keywords
) t
]
3620 ["Coding Style" (vhdl-doc-variable 'vhdl-doc-coding-style
) t
])
3621 ["Version" vhdl-version t
]
3622 ["Bug Report..." vhdl-submit-bug-report t
]
3627 (progn (customize-set-variable 'vhdl-electric-mode
3628 (not vhdl-electric-mode
))
3629 (vhdl-mode-line-update))
3630 :style toggle
:selected vhdl-electric-mode
:keys
"C-c C-m C-e"]
3632 (progn (customize-set-variable 'vhdl-stutter-mode
3633 (not vhdl-stutter-mode
))
3634 (vhdl-mode-line-update))
3635 :style toggle
:selected vhdl-stutter-mode
:keys
"C-c C-m C-s"]
3637 (progn (customize-set-variable 'vhdl-indent-tabs-mode
3638 (not vhdl-indent-tabs-mode
))
3639 (setq indent-tabs-mode vhdl-indent-tabs-mode
))
3640 :style toggle
:selected vhdl-indent-tabs-mode
]
3642 ["Customize Group..." (customize-group 'vhdl-mode
) t
])
3644 ["Project Setup..." (customize-option 'vhdl-project-alist
) t
]
3646 '("Selected Project at Startup"
3647 ["None" (progn (customize-set-variable 'vhdl-project nil
)
3648 (vhdl-set-project ""))
3649 :style radio
:selected
(null vhdl-project
)]
3651 ;; add menu entries for defined projects
3652 (let ((project-alist vhdl-project-alist
) menu-list name
)
3653 (while project-alist
3654 (setq name
(caar project-alist
))
3656 (cons `[,name
(progn (customize-set-variable
3657 'vhdl-project
,name
)
3658 (vhdl-set-project ,name
))
3659 :style radio
:selected
(equal ,name vhdl-project
)]
3661 (setq project-alist
(cdr project-alist
)))
3662 (setq menu-list
(nreverse menu-list
))
3663 (vhdl-menu-split menu-list
"Project")))
3664 ["Setup File Name..." (customize-option 'vhdl-project-file-name
) t
]
3665 ("Auto Load Setup File"
3667 (customize-set-variable 'vhdl-project-auto-load
3668 (if (memq 'startup vhdl-project-auto-load
)
3669 (delq 'startup vhdl-project-auto-load
)
3670 (cons 'startup vhdl-project-auto-load
)))
3671 :style toggle
:selected
(memq 'startup vhdl-project-auto-load
)])
3673 (customize-set-variable 'vhdl-project-sort
(not vhdl-project-sort
))
3674 :style toggle
:selected vhdl-project-sort
]
3676 ["Customize Group..." (customize-group 'vhdl-project
) t
])
3678 ["Compiler Setup..." (customize-option 'vhdl-compiler-alist
) t
]
3680 '("Selected Compiler at Startup")
3681 ;; add menu entries for defined compilers
3682 (let ((comp-alist vhdl-compiler-alist
) menu-list name
)
3684 (setq name
(caar comp-alist
))
3686 (cons `[,name
(customize-set-variable 'vhdl-compiler
,name
)
3687 :style radio
:selected
(equal ,name vhdl-compiler
)]
3689 (setq comp-alist
(cdr comp-alist
)))
3690 (setq menu-list
(nreverse menu-list
))
3691 (vhdl-menu-split menu-list
"Compiler")))
3692 ["Use Local Error Regexp"
3693 (customize-set-variable 'vhdl-compile-use-local-error-regexp
3694 (not vhdl-compile-use-local-error-regexp
))
3695 :style toggle
:selected vhdl-compile-use-local-error-regexp
]
3696 ["Makefile Default Targets..."
3697 (customize-option 'vhdl-makefile-default-targets
) t
]
3698 ["Makefile Generation Hook..."
3699 (customize-option 'vhdl-makefile-generation-hook
) t
]
3700 ["Default Library Name" (customize-option 'vhdl-default-library
) t
]
3702 ["Customize Group..." (customize-group 'vhdl-compiler
) t
])
3706 (progn (customize-set-variable 'vhdl-standard
3707 (list '87 (cadr vhdl-standard
)))
3708 (vhdl-activate-customizations))
3709 :style radio
:selected
(eq '87 (car vhdl-standard
))]
3711 (progn (customize-set-variable 'vhdl-standard
3712 (list '93 (cadr vhdl-standard
)))
3713 (vhdl-activate-customizations))
3714 :style radio
:selected
(eq '93 (car vhdl-standard
))]
3716 (progn (customize-set-variable 'vhdl-standard
3717 (list '08 (cadr vhdl-standard
)))
3718 (vhdl-activate-customizations))
3719 :style radio
:selected
(eq '08 (car vhdl-standard
))]
3722 (progn (customize-set-variable
3723 'vhdl-standard
(list (car vhdl-standard
)
3724 (if (memq 'ams
(cadr vhdl-standard
))
3725 (delq 'ams
(cadr vhdl-standard
))
3726 (cons 'ams
(cadr vhdl-standard
)))))
3727 (vhdl-activate-customizations))
3728 :style toggle
:selected
(memq 'ams
(cadr vhdl-standard
))]
3730 (progn (customize-set-variable
3731 'vhdl-standard
(list (car vhdl-standard
)
3732 (if (memq 'math
(cadr vhdl-standard
))
3733 (delq 'math
(cadr vhdl-standard
))
3734 (cons 'math
(cadr vhdl-standard
)))))
3735 (vhdl-activate-customizations))
3736 :style toggle
:selected
(memq 'math
(cadr vhdl-standard
))])
3737 ["Indentation Offset..." (customize-option 'vhdl-basic-offset
) t
]
3738 ["Upper Case Keywords"
3739 (customize-set-variable 'vhdl-upper-case-keywords
3740 (not vhdl-upper-case-keywords
))
3741 :style toggle
:selected vhdl-upper-case-keywords
]
3743 (customize-set-variable 'vhdl-upper-case-types
3744 (not vhdl-upper-case-types
))
3745 :style toggle
:selected vhdl-upper-case-types
]
3746 ["Upper Case Attributes"
3747 (customize-set-variable 'vhdl-upper-case-attributes
3748 (not vhdl-upper-case-attributes
))
3749 :style toggle
:selected vhdl-upper-case-attributes
]
3750 ["Upper Case Enumeration Values"
3751 (customize-set-variable 'vhdl-upper-case-enum-values
3752 (not vhdl-upper-case-enum-values
))
3753 :style toggle
:selected vhdl-upper-case-enum-values
]
3754 ["Upper Case Constants"
3755 (customize-set-variable 'vhdl-upper-case-constants
3756 (not vhdl-upper-case-constants
))
3757 :style toggle
:selected vhdl-upper-case-constants
]
3758 ("Use Direct Instantiation"
3760 (customize-set-variable 'vhdl-use-direct-instantiation
'never
)
3761 :style radio
:selected
(eq 'never vhdl-use-direct-instantiation
)]
3763 (customize-set-variable 'vhdl-use-direct-instantiation
'standard
)
3764 :style radio
:selected
(eq 'standard vhdl-use-direct-instantiation
)]
3766 (customize-set-variable 'vhdl-use-direct-instantiation
'always
)
3767 :style radio
:selected
(eq 'always vhdl-use-direct-instantiation
)])
3768 ["Include Array Index and Record Field in Sensitivity List"
3769 (customize-set-variable 'vhdl-array-index-record-field-in-sensitivity-list
3770 (not vhdl-array-index-record-field-in-sensitivity-list
))
3771 :style toggle
:selected vhdl-array-index-record-field-in-sensitivity-list
]
3773 ["Customize Group..." (customize-group 'vhdl-style
) t
])
3775 ["Entity File Name..." (customize-option 'vhdl-entity-file-name
) t
]
3776 ["Architecture File Name..."
3777 (customize-option 'vhdl-architecture-file-name
) t
]
3778 ["Configuration File Name..."
3779 (customize-option 'vhdl-configuration-file-name
) t
]
3780 ["Package File Name..." (customize-option 'vhdl-package-file-name
) t
]
3783 (customize-set-variable 'vhdl-file-name-case
'identity
)
3784 :style radio
:selected
(eq 'identity vhdl-file-name-case
)]
3786 (customize-set-variable 'vhdl-file-name-case
'downcase
)
3787 :style radio
:selected
(eq 'downcase vhdl-file-name-case
)]
3789 (customize-set-variable 'vhdl-file-name-case
'upcase
)
3790 :style radio
:selected
(eq 'upcase vhdl-file-name-case
)]
3792 (customize-set-variable 'vhdl-file-name-case
'capitalize
)
3793 :style radio
:selected
(eq 'capitalize vhdl-file-name-case
)])
3795 ["Customize Group..." (customize-group 'vhdl-naming
) t
])
3797 ("Electric Keywords"
3799 (customize-set-variable 'vhdl-electric-keywords
3800 (if (memq 'vhdl vhdl-electric-keywords
)
3801 (delq 'vhdl vhdl-electric-keywords
)
3802 (cons 'vhdl vhdl-electric-keywords
)))
3803 :style toggle
:selected
(memq 'vhdl vhdl-electric-keywords
)]
3804 ["User Model Keywords"
3805 (customize-set-variable 'vhdl-electric-keywords
3806 (if (memq 'user vhdl-electric-keywords
)
3807 (delq 'user vhdl-electric-keywords
)
3808 (cons 'user vhdl-electric-keywords
)))
3809 :style toggle
:selected
(memq 'user vhdl-electric-keywords
)])
3810 ("Insert Optional Labels"
3812 (customize-set-variable 'vhdl-optional-labels
'none
)
3813 :style radio
:selected
(eq 'none vhdl-optional-labels
)]
3815 (customize-set-variable 'vhdl-optional-labels
'process
)
3816 :style radio
:selected
(eq 'process vhdl-optional-labels
)]
3818 (customize-set-variable 'vhdl-optional-labels
'all
)
3819 :style radio
:selected
(eq 'all vhdl-optional-labels
)])
3820 ("Insert Empty Lines"
3822 (customize-set-variable 'vhdl-insert-empty-lines
'none
)
3823 :style radio
:selected
(eq 'none vhdl-insert-empty-lines
)]
3824 ["Design Units Only"
3825 (customize-set-variable 'vhdl-insert-empty-lines
'unit
)
3826 :style radio
:selected
(eq 'unit vhdl-insert-empty-lines
)]
3828 (customize-set-variable 'vhdl-insert-empty-lines
'all
)
3829 :style radio
:selected
(eq 'all vhdl-insert-empty-lines
)])
3830 ["Argument List Indent"
3831 (customize-set-variable 'vhdl-argument-list-indent
3832 (not vhdl-argument-list-indent
))
3833 :style toggle
:selected vhdl-argument-list-indent
]
3834 ["Association List with Formals"
3835 (customize-set-variable 'vhdl-association-list-with-formals
3836 (not vhdl-association-list-with-formals
))
3837 :style toggle
:selected vhdl-association-list-with-formals
]
3838 ["Conditions in Parenthesis"
3839 (customize-set-variable 'vhdl-conditions-in-parenthesis
3840 (not vhdl-conditions-in-parenthesis
))
3841 :style toggle
:selected vhdl-conditions-in-parenthesis
]
3842 ["Sensitivity List uses 'all'"
3843 (customize-set-variable 'vhdl-sensitivity-list-all
3844 (not vhdl-sensitivity-list-all
))
3845 :style toggle
:selected vhdl-sensitivity-list-all
]
3846 ["Zero String..." (customize-option 'vhdl-zero-string
) t
]
3847 ["One String..." (customize-option 'vhdl-one-string
) t
]
3849 ["Header String..." (customize-option 'vhdl-file-header
) t
]
3850 ["Footer String..." (customize-option 'vhdl-file-footer
) t
]
3851 ["Company Name..." (customize-option 'vhdl-company-name
) t
]
3852 ["Copyright String..." (customize-option 'vhdl-copyright-string
) t
]
3853 ["Platform Specification..." (customize-option 'vhdl-platform-spec
) t
]
3854 ["Date Format..." (customize-option 'vhdl-date-format
) t
]
3855 ["Modify Date Prefix String..."
3856 (customize-option 'vhdl-modify-date-prefix-string
) t
]
3857 ["Modify Date on Saving"
3858 (progn (customize-set-variable 'vhdl-modify-date-on-saving
3859 (not vhdl-modify-date-on-saving
))
3860 (vhdl-activate-customizations))
3861 :style toggle
:selected vhdl-modify-date-on-saving
])
3862 ("Sequential Process"
3865 (customize-set-variable 'vhdl-reset-kind
'none
)
3866 :style radio
:selected
(eq 'none vhdl-reset-kind
)]
3868 (customize-set-variable 'vhdl-reset-kind
'sync
)
3869 :style radio
:selected
(eq 'sync vhdl-reset-kind
)]
3871 (customize-set-variable 'vhdl-reset-kind
'async
)
3872 :style radio
:selected
(eq 'async vhdl-reset-kind
)]
3874 (customize-set-variable 'vhdl-reset-kind
'query
)
3875 :style radio
:selected
(eq 'query vhdl-reset-kind
)])
3876 ["Reset is Active High"
3877 (customize-set-variable 'vhdl-reset-active-high
3878 (not vhdl-reset-active-high
))
3879 :style toggle
:selected vhdl-reset-active-high
]
3880 ["Use Rising Clock Edge"
3881 (customize-set-variable 'vhdl-clock-rising-edge
3882 (not vhdl-clock-rising-edge
))
3883 :style toggle
:selected vhdl-clock-rising-edge
]
3884 ("Clock Edge Condition"
3886 (customize-set-variable 'vhdl-clock-edge-condition
'standard
)
3887 :style radio
:selected
(eq 'standard vhdl-clock-edge-condition
)]
3888 ["Function \"rising_edge\""
3889 (customize-set-variable 'vhdl-clock-edge-condition
'function
)
3890 :style radio
:selected
(eq 'function vhdl-clock-edge-condition
)])
3891 ["Clock Name..." (customize-option 'vhdl-clock-name
) t
]
3892 ["Reset Name..." (customize-option 'vhdl-reset-name
) t
])
3894 ["Customize Group..." (customize-group 'vhdl-template
) t
])
3896 ["Model Definition..." (customize-option 'vhdl-model-alist
) t
])
3898 ["Include Port Comments"
3899 (customize-set-variable 'vhdl-include-port-comments
3900 (not vhdl-include-port-comments
))
3901 :style toggle
:selected vhdl-include-port-comments
]
3902 ["Include Direction Comments"
3903 (customize-set-variable 'vhdl-include-direction-comments
3904 (not vhdl-include-direction-comments
))
3905 :style toggle
:selected vhdl-include-direction-comments
]
3906 ["Include Type Comments"
3907 (customize-set-variable 'vhdl-include-type-comments
3908 (not vhdl-include-type-comments
))
3909 :style toggle
:selected vhdl-include-type-comments
]
3910 ("Include Group Comments"
3912 (customize-set-variable 'vhdl-include-group-comments
'never
)
3913 :style radio
:selected
(eq 'never vhdl-include-group-comments
)]
3915 (customize-set-variable 'vhdl-include-group-comments
'decl
)
3916 :style radio
:selected
(eq 'decl vhdl-include-group-comments
)]
3918 (customize-set-variable 'vhdl-include-group-comments
'always
)
3919 :style radio
:selected
(eq 'always vhdl-include-group-comments
)])
3920 ["Actual Generic Name..." (customize-option 'vhdl-actual-generic-name
) t
]
3921 ["Actual Port Name..." (customize-option 'vhdl-actual-port-name
) t
]
3922 ["Instance Name..." (customize-option 'vhdl-instance-name
) t
]
3924 ["Entity Name..." (customize-option 'vhdl-testbench-entity-name
) t
]
3925 ["Architecture Name..."
3926 (customize-option 'vhdl-testbench-architecture-name
) t
]
3927 ["Configuration Name..."
3928 (customize-option 'vhdl-testbench-configuration-name
) t
]
3929 ["DUT Name..." (customize-option 'vhdl-testbench-dut-name
) t
]
3931 (customize-set-variable 'vhdl-testbench-include-header
3932 (not vhdl-testbench-include-header
))
3933 :style toggle
:selected vhdl-testbench-include-header
]
3934 ["Declarations..." (customize-option 'vhdl-testbench-declarations
) t
]
3935 ["Statements..." (customize-option 'vhdl-testbench-statements
) t
]
3936 ["Initialize Signals"
3937 (customize-set-variable 'vhdl-testbench-initialize-signals
3938 (not vhdl-testbench-initialize-signals
))
3939 :style toggle
:selected vhdl-testbench-initialize-signals
]
3940 ["Include Library Clause"
3941 (customize-set-variable 'vhdl-testbench-include-library
3942 (not vhdl-testbench-include-library
))
3943 :style toggle
:selected vhdl-testbench-include-library
]
3944 ["Include Configuration"
3945 (customize-set-variable 'vhdl-testbench-include-configuration
3946 (not vhdl-testbench-include-configuration
))
3947 :style toggle
:selected vhdl-testbench-include-configuration
]
3950 (customize-set-variable 'vhdl-testbench-create-files
'none
)
3951 :style radio
:selected
(eq 'none vhdl-testbench-create-files
)]
3953 (customize-set-variable 'vhdl-testbench-create-files
'single
)
3954 :style radio
:selected
(eq 'single vhdl-testbench-create-files
)]
3956 (customize-set-variable 'vhdl-testbench-create-files
'separate
)
3957 :style radio
:selected
(eq 'separate vhdl-testbench-create-files
)])
3958 ["Testbench Entity File Name..."
3959 (customize-option 'vhdl-testbench-entity-file-name
) t
]
3960 ["Testbench Architecture File Name..."
3961 (customize-option 'vhdl-testbench-architecture-file-name
) t
])
3963 ["Customize Group..." (customize-group 'vhdl-port
) t
])
3965 ["Architecture Name..."
3966 (customize-option 'vhdl-compose-architecture-name
) t
]
3967 ["Configuration Name..."
3968 (customize-option 'vhdl-compose-configuration-name
) t
]
3969 ["Components Package Name..."
3970 (customize-option 'vhdl-components-package-name
) t
]
3971 ["Use Components Package"
3972 (customize-set-variable 'vhdl-use-components-package
3973 (not vhdl-use-components-package
))
3974 :style toggle
:selected vhdl-use-components-package
]
3976 (customize-set-variable 'vhdl-compose-include-header
3977 (not vhdl-compose-include-header
))
3978 :style toggle
:selected vhdl-compose-include-header
]
3979 ("Create Entity/Architecture Files"
3981 (customize-set-variable 'vhdl-compose-create-files
'none
)
3982 :style radio
:selected
(eq 'none vhdl-compose-create-files
)]
3984 (customize-set-variable 'vhdl-compose-create-files
'single
)
3985 :style radio
:selected
(eq 'single vhdl-compose-create-files
)]
3987 (customize-set-variable 'vhdl-compose-create-files
'separate
)
3988 :style radio
:selected
(eq 'separate vhdl-compose-create-files
)])
3989 ["Create Configuration File"
3990 (customize-set-variable 'vhdl-compose-configuration-create-file
3991 (not vhdl-compose-configuration-create-file
))
3992 :style toggle
:selected vhdl-compose-configuration-create-file
]
3993 ["Hierarchical Configuration"
3994 (customize-set-variable 'vhdl-compose-configuration-hierarchical
3995 (not vhdl-compose-configuration-hierarchical
))
3996 :style toggle
:selected vhdl-compose-configuration-hierarchical
]
3997 ["Use Subconfiguration"
3998 (customize-set-variable 'vhdl-compose-configuration-use-subconfiguration
3999 (not vhdl-compose-configuration-use-subconfiguration
))
4000 :style toggle
:selected vhdl-compose-configuration-use-subconfiguration
]
4002 ["Customize Group..." (customize-group 'vhdl-compose
) t
])
4004 ["Self Insert Comments"
4005 (customize-set-variable 'vhdl-self-insert-comments
4006 (not vhdl-self-insert-comments
))
4007 :style toggle
:selected vhdl-self-insert-comments
]
4008 ["Prompt for Comments"
4009 (customize-set-variable 'vhdl-prompt-for-comments
4010 (not vhdl-prompt-for-comments
))
4011 :style toggle
:selected vhdl-prompt-for-comments
]
4012 ["Inline Comment Column..."
4013 (customize-option 'vhdl-inline-comment-column
) t
]
4014 ["End Comment Column..." (customize-option 'vhdl-end-comment-column
) t
]
4016 ["Customize Group..." (customize-group 'vhdl-comment
) t
])
4018 ["Auto Align Templates"
4019 (customize-set-variable 'vhdl-auto-align
(not vhdl-auto-align
))
4020 :style toggle
:selected vhdl-auto-align
]
4021 ["Align Line Groups"
4022 (customize-set-variable 'vhdl-align-groups
(not vhdl-align-groups
))
4023 :style toggle
:selected vhdl-align-groups
]
4024 ["Group Separation String..."
4025 (customize-option 'vhdl-align-group-separate
) t
]
4026 ["Align Lines with Same Indent"
4027 (customize-set-variable 'vhdl-align-same-indent
4028 (not vhdl-align-same-indent
))
4029 :style toggle
:selected vhdl-align-same-indent
]
4030 ["Beautify Options..." (customize-option 'vhdl-beautify-options
) t
]
4032 ["Customize Group..." (customize-group 'vhdl-beautify
) t
])
4034 ["Highlighting On/Off..."
4036 (if (fboundp 'global-font-lock-mode
)
4037 'global-font-lock-mode
'font-lock-auto-fontify
)) t
]
4038 ["Highlight Keywords"
4039 (progn (customize-set-variable 'vhdl-highlight-keywords
4040 (not vhdl-highlight-keywords
))
4041 (vhdl-fontify-buffer))
4042 :style toggle
:selected vhdl-highlight-keywords
]
4044 (progn (customize-set-variable 'vhdl-highlight-names
4045 (not vhdl-highlight-names
))
4046 (vhdl-fontify-buffer))
4047 :style toggle
:selected vhdl-highlight-names
]
4048 ["Highlight Special Words"
4049 (progn (customize-set-variable 'vhdl-highlight-special-words
4050 (not vhdl-highlight-special-words
))
4051 (vhdl-fontify-buffer))
4052 :style toggle
:selected vhdl-highlight-special-words
]
4053 ["Highlight Forbidden Words"
4054 (progn (customize-set-variable 'vhdl-highlight-forbidden-words
4055 (not vhdl-highlight-forbidden-words
))
4056 (vhdl-fontify-buffer))
4057 :style toggle
:selected vhdl-highlight-forbidden-words
]
4058 ["Highlight Verilog Keywords"
4059 (progn (customize-set-variable 'vhdl-highlight-verilog-keywords
4060 (not vhdl-highlight-verilog-keywords
))
4061 (vhdl-fontify-buffer))
4062 :style toggle
:selected vhdl-highlight-verilog-keywords
]
4063 ["Highlight \"translate_off\""
4064 (progn (customize-set-variable 'vhdl-highlight-translate-off
4065 (not vhdl-highlight-translate-off
))
4066 (vhdl-fontify-buffer))
4067 :style toggle
:selected vhdl-highlight-translate-off
]
4068 ["Case Sensitive Highlighting"
4069 (progn (customize-set-variable 'vhdl-highlight-case-sensitive
4070 (not vhdl-highlight-case-sensitive
))
4071 (vhdl-fontify-buffer))
4072 :style toggle
:selected vhdl-highlight-case-sensitive
]
4073 ["Special Syntax Definition..."
4074 (customize-option 'vhdl-special-syntax-alist
) t
]
4075 ["Forbidden Words..." (customize-option 'vhdl-forbidden-words
) t
]
4076 ["Forbidden Syntax..." (customize-option 'vhdl-forbidden-syntax
) t
]
4077 ["Directive Keywords..." (customize-option 'vhdl-directive-keywords
) t
]
4078 ["Colors..." (customize-group 'vhdl-highlight-faces
) t
]
4080 ["Customize Group..." (customize-group 'vhdl-highlight
) t
])
4082 ["Auto Open at Startup"
4083 (customize-set-variable 'vhdl-speedbar-auto-open
4084 (not vhdl-speedbar-auto-open
))
4085 :style toggle
:selected vhdl-speedbar-auto-open
]
4086 ("Default Displaying Mode"
4088 (customize-set-variable 'vhdl-speedbar-display-mode
'files
)
4089 :style radio
:selected
(eq 'files vhdl-speedbar-display-mode
)]
4090 ["Directory Hierarchy"
4091 (customize-set-variable 'vhdl-speedbar-display-mode
'directory
)
4092 :style radio
:selected
(eq 'directory vhdl-speedbar-display-mode
)]
4093 ["Project Hierarchy"
4094 (customize-set-variable 'vhdl-speedbar-display-mode
'project
)
4095 :style radio
:selected
(eq 'project vhdl-speedbar-display-mode
)])
4096 ["Indentation Offset..."
4097 (customize-option 'speedbar-indentation-width
) t
]
4098 ["Scan Size Limits..." (customize-option 'vhdl-speedbar-scan-limit
) t
]
4099 ["Jump to Unit when Opening"
4100 (customize-set-variable 'vhdl-speedbar-jump-to-unit
4101 (not vhdl-speedbar-jump-to-unit
))
4102 :style toggle
:selected vhdl-speedbar-jump-to-unit
]
4103 ["Update Hierarchy on File Saving"
4104 (customize-set-variable 'vhdl-speedbar-update-on-saving
4105 (not vhdl-speedbar-update-on-saving
))
4106 :style toggle
:selected vhdl-speedbar-update-on-saving
]
4107 ("Save in Cache File"
4108 ["Hierarchy Information"
4109 (customize-set-variable 'vhdl-speedbar-save-cache
4110 (if (memq 'hierarchy vhdl-speedbar-save-cache
)
4111 (delq 'hierarchy vhdl-speedbar-save-cache
)
4112 (cons 'hierarchy vhdl-speedbar-save-cache
)))
4113 :style toggle
:selected
(memq 'hierarchy vhdl-speedbar-save-cache
)]
4114 ["Displaying Status"
4115 (customize-set-variable 'vhdl-speedbar-save-cache
4116 (if (memq 'display vhdl-speedbar-save-cache
)
4117 (delq 'display vhdl-speedbar-save-cache
)
4118 (cons 'display vhdl-speedbar-save-cache
)))
4119 :style toggle
:selected
(memq 'display vhdl-speedbar-save-cache
)])
4120 ["Cache File Name..."
4121 (customize-option 'vhdl-speedbar-cache-file-name
) t
]
4123 ["Customize Group..." (customize-group 'vhdl-speedbar
) t
])
4125 ["Add Index Menu when Loading File"
4126 (progn (customize-set-variable 'vhdl-index-menu
(not vhdl-index-menu
))
4127 (vhdl-index-menu-init))
4128 :style toggle
:selected vhdl-index-menu
]
4129 ["Add Source File Menu when Loading File"
4130 (progn (customize-set-variable 'vhdl-source-file-menu
4131 (not vhdl-source-file-menu
))
4132 (vhdl-add-source-files-menu))
4133 :style toggle
:selected vhdl-source-file-menu
]
4134 ["Add Hideshow Menu at Startup"
4135 (progn (customize-set-variable 'vhdl-hideshow-menu
4136 (not vhdl-hideshow-menu
))
4137 (vhdl-activate-customizations))
4138 :style toggle
:selected vhdl-hideshow-menu
]
4139 ["Hide Everything Initially"
4140 (customize-set-variable 'vhdl-hide-all-init
(not vhdl-hide-all-init
))
4141 :style toggle
:selected vhdl-hide-all-init
]
4143 ["Customize Group..." (customize-group 'vhdl-menu
) t
])
4145 ["In Two Column Format"
4146 (progn (customize-set-variable 'vhdl-print-two-column
4147 (not vhdl-print-two-column
))
4148 (message "Activate new setting by saving options and restarting Emacs"))
4149 :style toggle
:selected vhdl-print-two-column
]
4150 ["Use Customized Faces"
4151 (progn (customize-set-variable 'vhdl-print-customize-faces
4152 (not vhdl-print-customize-faces
))
4153 (message "Activate new setting by saving options and restarting Emacs"))
4154 :style toggle
:selected vhdl-print-customize-faces
]
4156 ["Customize Group..." (customize-group 'vhdl-print
) t
])
4158 ["Use Intelligent Tab"
4159 (progn (customize-set-variable 'vhdl-intelligent-tab
4160 (not vhdl-intelligent-tab
))
4161 (vhdl-activate-customizations))
4162 :style toggle
:selected vhdl-intelligent-tab
]
4163 ["Indent Syntax-Based"
4164 (customize-set-variable 'vhdl-indent-syntax-based
4165 (not vhdl-indent-syntax-based
))
4166 :style toggle
:selected vhdl-indent-syntax-based
]
4167 ["Indent Comments Like Next Code Line"
4168 (customize-set-variable 'vhdl-indent-comment-like-next-code-line
4169 (not vhdl-indent-comment-like-next-code-line
))
4170 :style toggle
:selected vhdl-indent-comment-like-next-code-line
]
4171 ["Word Completion is Case Sensitive"
4172 (customize-set-variable 'vhdl-word-completion-case-sensitive
4173 (not vhdl-word-completion-case-sensitive
))
4174 :style toggle
:selected vhdl-word-completion-case-sensitive
]
4175 ["Word Completion in Minibuffer"
4176 (progn (customize-set-variable 'vhdl-word-completion-in-minibuffer
4177 (not vhdl-word-completion-in-minibuffer
))
4178 (message "Activate new setting by saving options and restarting Emacs"))
4179 :style toggle
:selected vhdl-word-completion-in-minibuffer
]
4180 ["Underscore is Part of Word"
4181 (progn (customize-set-variable 'vhdl-underscore-is-part-of-word
4182 (not vhdl-underscore-is-part-of-word
))
4183 (vhdl-activate-customizations))
4184 :style toggle
:selected vhdl-underscore-is-part-of-word
]
4186 ["Customize Group..." (customize-group 'vhdl-misc
) t
])
4187 ["Related..." (customize-browse 'vhdl-related
) t
]
4189 ["Save Options" customize-save-customized t
]
4190 ["Activate Options" vhdl-activate-customizations t
]
4191 ["Browse Options..." vhdl-customize t
])))
4193 (defvar vhdl-mode-menu-list
(vhdl-create-mode-menu)
4196 (defun vhdl-update-mode-menu ()
4197 "Update VHDL Mode menu."
4199 (easy-menu-remove vhdl-mode-menu-list
) ; for XEmacs
4200 (setq vhdl-mode-menu-list
(vhdl-create-mode-menu))
4201 (easy-menu-add vhdl-mode-menu-list
) ; for XEmacs
4202 (easy-menu-define vhdl-mode-menu vhdl-mode-map
4203 "Menu keymap for VHDL Mode." vhdl-mode-menu-list
))
4205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4206 ;; Index menu (using `imenu.el'), also used for speedbar (using `speedbar.el')
4208 (defconst vhdl-imenu-generic-expression
4211 "^\\s-*\\(\\(\\(impure\\|pure\\)\\s-+\\|\\)function\\|procedure\\)\\s-+\\(\"?\\(\\w\\|\\s_\\)+\"?\\)"
4214 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\s-*:\\(\\s-\\|\n\\)*\\(entity\\s-+\\(\\w\\|\\s_\\)+\\.\\)?\\(\\w\\|\\s_\\)+\\)\\(\\s-\\|\n\\)+\\(generic\\|port\\)\\s-+map\\>"
4217 "^\\s-*\\(component\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
4220 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\)\\s-*:\\(\\s-\\|\n\\)*\\(procedural\\)"
4223 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\)\\s-*:\\(\\s-\\|\n\\)*\\(\\(postponed\\s-+\\|\\)process\\)"
4226 "^\\s-*\\(\\(\\w\\|\\s_\\)+\\)\\s-*:\\(\\s-\\|\n\\)*\\(block\\)"
4229 "^\\s-*\\(package\\( body\\|\\)\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
4232 "^\\s-*\\(configuration\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
4235 "^\\s-*\\(architecture\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\s-+of\\s-+\\(\\w\\|\\s_\\)+\\)"
4238 "^\\s-*\\(entity\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
4241 "^\\s-*\\(context\\)\\s-+\\(\\(\\w\\|\\s_\\)+\\)"
4244 "Imenu generic expression for VHDL Mode. See `imenu-generic-expression'.")
4246 (defun vhdl-index-menu-init ()
4247 "Initialize index menu."
4248 (set (make-local-variable 'imenu-case-fold-search
) t
)
4249 (set (make-local-variable 'imenu-generic-expression
)
4250 vhdl-imenu-generic-expression
)
4251 (when (and vhdl-index-menu
(fboundp 'imenu
))
4252 (imenu-add-to-menubar "Index")))
4254 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4255 ;; Source file menu (using `easy-menu.el')
4257 (defvar vhdl-sources-menu nil
)
4259 (defun vhdl-directory-files (directory &optional full match
)
4260 "Call `directory-files' if DIRECTORY exists, otherwise generate error
4262 (if (not (file-directory-p directory
))
4263 (vhdl-warning-when-idle "No such directory: \"%s\"" directory
)
4264 (let ((dir (directory-files directory full match
)))
4265 (setq dir
(delete "." dir
))
4266 (setq dir
(delete ".." dir
))
4269 (defun vhdl-get-source-files (&optional full directory
)
4270 "Get list of VHDL source files in DIRECTORY or current directory."
4271 (let ((mode-alist auto-mode-alist
)
4273 ;; create regular expressions for matching file names
4274 (setq filename-regexp
"\\`[^.].*\\(")
4276 (when (eq (cdar mode-alist
) 'vhdl-mode
)
4277 (setq filename-regexp
4278 (concat filename-regexp
(caar mode-alist
) "\\|")))
4279 (setq mode-alist
(cdr mode-alist
)))
4280 (setq filename-regexp
4281 (concat (substring filename-regexp
0
4282 (string-match "\\\\|$" filename-regexp
)) "\\)"))
4284 (vhdl-directory-files
4285 (or directory default-directory
) full filename-regexp
)))
4287 (defun vhdl-add-source-files-menu ()
4288 "Scan directory for all VHDL source files and generate menu.
4289 The directory of the current source file is scanned."
4291 (message "Scanning directory for source files ...")
4292 (let ((newmap (current-local-map))
4293 (file-list (vhdl-get-source-files))
4295 ;; Create list for menu
4299 (push (vector (car file-list
) (list 'find-file
(car file-list
)) t
)
4301 (setq file-list
(cdr file-list
)))
4302 (setq menu-list
(vhdl-menu-split menu-list
"Sources"))
4303 (when found
(push "--" menu-list
))
4304 (push ["*Rescan*" vhdl-add-source-files-menu t
] menu-list
)
4305 (push "Sources" menu-list
)
4307 (easy-menu-add menu-list
)
4308 (easy-menu-define vhdl-sources-menu newmap
4309 "VHDL source files menu" menu-list
))
4313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4315 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4316 ;; performs all buffer local initializations
4319 (define-derived-mode vhdl-mode prog-mode
4320 '("VHDL" (vhdl-electric-mode "/" (vhdl-stutter-mode "/"))
4321 (vhdl-electric-mode "e")
4322 (vhdl-stutter-mode "s"))
4323 "Major mode for editing VHDL code.
4328 TEMPLATE INSERTION (electrification):
4329 After typing a VHDL keyword and entering `SPC', you are prompted for
4330 arguments while a template is generated for that VHDL construct. Typing
4331 `RET' or `C-g' at the first (mandatory) prompt aborts the current
4332 template generation. Optional arguments are indicated by square
4333 brackets and removed if the queried string is left empty. Prompts for
4334 mandatory arguments remain in the code if the queried string is left
4335 empty. They can be queried again by `C-c C-t C-q'. Enabled
4336 electrification is indicated by `/e' in the mode line.
4338 Typing `M-SPC' after a keyword inserts a space without calling the
4339 template generator. Automatic template generation (i.e.
4340 electrification) can be disabled (enabled) by typing `C-c C-m C-e' or by
4341 setting option `vhdl-electric-mode' (see OPTIONS).
4343 Template generators can be invoked from the VHDL menu, by key
4344 bindings, by typing `C-c C-i C-c' and choosing a construct, or by typing
4345 the keyword (i.e. first word of menu entry not in parenthesis) and
4346 `SPC'. The following abbreviations can also be used: arch, attr, cond,
4347 conf, comp, cons, func, inst, pack, sig, var.
4349 Template styles can be customized in customization group
4350 `vhdl-template' (see OPTIONS).
4354 A file header can be inserted by `C-c C-t C-h'. A file footer
4355 (template at the end of the file) can be inserted by `C-c C-t C-f'.
4356 See customization group `vhdl-header'.
4360 Double striking of some keys inserts cumbersome VHDL syntax elements.
4361 Stuttering can be disabled (enabled) by typing `C-c C-m C-s' or by
4362 option `vhdl-stutter-mode'. Enabled stuttering is indicated by `/s' in
4363 the mode line. The stuttering keys and their effects are:
4365 ;; --> \" : \" [ --> ( -- --> comment
4366 ;;; --> \" := \" [[ --> [ --CR --> comment-out code
4367 .. --> \" => \" ] --> ) --- --> horizontal line
4368 ,, --> \" <= \" ]] --> ] ---- --> display comment
4369 == --> \" == \" \\='\\=' --> \\\"
4373 Typing `TAB' after a (not completed) word looks for a VHDL keyword or a
4374 word in the buffer that starts alike, inserts it and adjusts case.
4375 Re-typing `TAB' toggles through alternative word completions. This also
4376 works in the minibuffer (i.e. in template generator prompts).
4378 Typing `TAB' after `(' looks for and inserts complete parenthesized
4379 expressions (e.g. for array index ranges). All keywords as well as
4380 standard types and subprograms of VHDL have predefined abbreviations
4381 (e.g., type \"std\" and `TAB' will toggle through all standard types
4382 beginning with \"std\").
4384 Typing `TAB' after a non-word character indents the line if at the
4385 beginning of a line (i.e. no preceding non-blank characters), and
4386 inserts a tabulator stop otherwise. `M-TAB' always inserts a tabulator
4391 `--' puts a single comment.
4392 `---' draws a horizontal line for separating code segments.
4393 `----' inserts a display comment, i.e. two horizontal lines
4394 with a comment in between.
4395 `--CR' comments out code on that line. Re-hitting CR comments
4396 out following lines.
4397 `C-c C-c' comments out a region if not commented out,
4398 uncomments a region if already commented out. Option
4399 `comment-style' defines where the comment characters
4400 should be placed (beginning of line, indent, etc.).
4402 You are prompted for comments after object definitions (i.e. signals,
4403 variables, constants, ports) and after subprogram and process
4404 specifications if option `vhdl-prompt-for-comments' is non-nil.
4405 Comments are automatically inserted as additional labels (e.g. after
4406 begin statements) and as help comments if `vhdl-self-insert-comments' is
4409 Inline comments (i.e. comments after a piece of code on the same line)
4410 are indented at least to `vhdl-inline-comment-column'. Comments go at
4411 maximum to `vhdl-end-comment-column'. `RET' after a space in a comment
4412 will open a new comment line. Typing beyond `vhdl-end-comment-column'
4413 in a comment automatically opens a new comment line. `M-q' re-fills
4414 multi-line comments.
4418 `TAB' indents a line if at the beginning of the line. The amount of
4419 indentation is specified by option `vhdl-basic-offset'. `C-c C-i C-l'
4420 always indents the current line (is bound to `TAB' if option
4421 `vhdl-intelligent-tab' is nil). If a region is active, `TAB' indents
4424 Indentation can be done for a group of lines (`C-c C-i C-g'), a region
4425 (`M-C-\\') or the entire buffer (menu). Argument and port lists are
4426 indented normally (nil) or relative to the opening parenthesis (non-nil)
4427 according to option `vhdl-argument-list-indent'.
4429 If option `vhdl-indent-tabs-mode' is nil, spaces are used instead of
4430 tabs. `\\[tabify]' and `\\[untabify]' allow the conversion of spaces to
4431 tabs and vice versa.
4433 Syntax-based indentation can be very slow in large files. Option
4434 `vhdl-indent-syntax-based' allows you to use faster but simpler indentation.
4436 Option `vhdl-indent-comment-like-next-code-line' controls whether
4437 comment lines are indented like the preceding or like the following code
4442 The alignment functions align operators, keywords, and inline comments
4443 to beautify the code. `C-c C-a C-a' aligns a group of consecutive lines
4444 separated by blank lines, `C-c C-a C-i' a block of lines with same
4445 indent. `C-c C-a C-l' aligns all lines belonging to a list enclosed by
4446 a pair of parentheses (e.g. port clause/map, argument list), and `C-c
4447 C-a C-d' all lines within the declarative part of a design unit. `C-c
4448 C-a M-a' aligns an entire region. `C-c C-a C-c' aligns inline comments
4449 for a group of lines, and `C-c C-a M-c' for a region.
4451 If option `vhdl-align-groups' is non-nil, groups of code lines
4452 separated by special lines (see option `vhdl-align-group-separate') are
4453 aligned individually. If option `vhdl-align-same-indent' is non-nil,
4454 blocks of lines with same indent are aligned separately. Some templates
4455 are automatically aligned after generation if option `vhdl-auto-align'
4458 Alignment tries to align inline comments at
4459 `vhdl-inline-comment-column' and tries inline comment not to exceed
4460 `vhdl-end-comment-column'.
4462 `C-c C-x M-w' fixes up whitespace in a region. That is, operator
4463 symbols are surrounded by one space, and multiple spaces are eliminated.
4467 Code filling allows you to condense code (e.g. sensitivity lists or port
4468 maps) by removing comments and newlines and re-wrapping so that all
4469 lines are maximally filled (block filling). `C-c C-f C-f' fills a list
4470 enclosed by parenthesis, `C-c C-f C-g' a group of lines separated by
4471 blank lines, `C-c C-f C-i' a block of lines with same indent, and
4472 `C-c C-f M-f' an entire region.
4475 CODE BEAUTIFICATION:
4476 `C-c M-b' and `C-c C-b' beautify the code of a region or of the entire
4477 buffer respectively. This includes indentation, alignment, and case
4478 fixing. Code beautification can also be run non-interactively using the
4481 emacs -batch -l ~/.emacs filename.vhd -f vhdl-beautify-buffer
4485 Generic and port clauses from entity or component declarations can be
4486 copied (`C-c C-p C-w') and pasted as entity and component declarations,
4487 as component instantiations and corresponding internal constants and
4488 signals, as a generic map with constants as actual generics, and as
4489 internal signal initializations (menu).
4491 To include formals in component instantiations, see option
4492 `vhdl-association-list-with-formals'. To include comments in pasting,
4493 see options `vhdl-include-...-comments'.
4495 A clause with several generic/port names on the same line can be
4496 flattened (`C-c C-p C-f') so that only one name per line exists. The
4497 direction of ports can be reversed (`C-c C-p C-r'), i.e., inputs become
4498 outputs and vice versa, which can be useful in testbenches. (This
4499 reversion is done on the internal data structure and is only reflected
4500 in subsequent paste operations.)
4502 Names for actual ports, instances, testbenches, and
4503 design-under-test instances can be derived from existing names according
4504 to options `vhdl-...-name'. See customization group `vhdl-port'.
4507 SUBPROGRAM TRANSLATION:
4508 Similar functionality exists for copying/pasting the interface of
4509 subprograms (function/procedure). A subprogram interface can be copied
4510 and then pasted as a subprogram declaration, body or call (uses
4511 association list with formals).
4514 TESTBENCH GENERATION:
4515 A copied port can also be pasted as a testbench. The generated
4516 testbench includes an entity, an architecture, and an optional
4517 configuration. The architecture contains the component declaration and
4518 instantiation of the DUT as well as internal constant and signal
4519 declarations. Additional user-defined templates can be inserted. The
4520 names used for entity/architecture/configuration/DUT as well as the file
4521 structure to be generated can be customized. See customization group
4526 Key bindings (`C-c ...') exist for most commands (see in menu).
4530 All commands can be found in the VHDL menu including their key bindings.
4534 The speedbar allows browsing of directories and file contents. It can
4535 be accessed from the VHDL menu and is automatically opened if option
4536 `vhdl-speedbar-auto-open' is non-nil.
4538 In speedbar, open files and directories with `mouse-2' on the name and
4539 browse/rescan their contents with `mouse-2'/`S-mouse-2' on the `+'.
4542 DESIGN HIERARCHY BROWSER:
4543 The speedbar can also be used for browsing the hierarchy of design units
4544 contained in the source files of the current directory or the specified
4545 projects (see option `vhdl-project-alist').
4547 The speedbar can be switched between file, directory hierarchy and
4548 project hierarchy browsing mode in the speedbar menu or by typing `f',
4549 `h' or `H' in speedbar.
4551 In speedbar, open design units with `mouse-2' on the name and browse
4552 their hierarchy with `mouse-2' on the `+'. Ports can directly be copied
4553 from entities and components (in packages). Individual design units and
4554 complete designs can directly be compiled (\"Make\" menu entry).
4556 The hierarchy is automatically updated upon saving a modified source
4557 file when option `vhdl-speedbar-update-on-saving' is non-nil. The
4558 hierarchy is only updated for projects that have been opened once in the
4559 speedbar. The hierarchy is cached between Emacs sessions in a file (see
4560 options in group `vhdl-speedbar').
4562 Simple design consistency checks are done during scanning, such as
4563 multiple declarations of the same unit or missing primary units that are
4564 required by secondary units.
4567 STRUCTURAL COMPOSITION:
4568 Enables simple structural composition. `C-c C-m C-n' creates a skeleton
4569 for a new component. Subcomponents (i.e. component declaration and
4570 instantiation) can be automatically placed from a previously read port
4571 (`C-c C-m C-p') or directly from the hierarchy browser (`P'). Finally,
4572 all subcomponents can be automatically connected using internal signals
4573 and ports (`C-c C-m C-w') following these rules:
4574 - subcomponent actual ports with same name are considered to be
4575 connected by a signal (internal signal or port)
4576 - signals that are only inputs to subcomponents are considered as
4577 inputs to this component -> input port created
4578 - signals that are only outputs from subcomponents are considered as
4579 outputs from this component -> output port created
4580 - signals that are inputs to AND outputs from subcomponents are
4581 considered as internal connections -> internal signal created
4583 Purpose: With appropriate naming conventions it is possible to
4584 create higher design levels with only a few mouse clicks or key
4585 strokes. A new design level can be created by simply generating a new
4586 component, placing the required subcomponents from the hierarchy
4587 browser, and wiring everything automatically.
4589 Note: Automatic wiring only works reliably on templates of new
4590 components and component instantiations that were created by VHDL mode.
4592 Component declarations can be placed in a components package (option
4593 `vhdl-use-components-package') which can be automatically generated for
4594 an entire directory or project (`C-c C-m M-p'). The VHDL'93 direct
4595 component instantiation is also supported (option
4596 `vhdl-use-direct-instantiation').
4598 Configuration declarations can automatically be generated either from
4599 the menu (`C-c C-m C-f') (for the architecture the cursor is in) or from
4600 the speedbar menu (for the architecture under the cursor). The
4601 configurations can optionally be hierarchical (i.e. include all
4602 component levels of a hierarchical design, option
4603 `vhdl-compose-configuration-hierarchical') or include subconfigurations
4604 (option `vhdl-compose-configuration-use-subconfiguration'). For
4605 subcomponents in hierarchical configurations, the most-recently-analyzed
4606 (mra) architecture is selected. If another architecture is desired, it
4607 can be marked as most-recently-analyzed (speedbar menu) before
4608 generating the configuration.
4610 Note: Configurations of subcomponents (i.e. hierarchical configuration
4611 declarations) are currently not considered when displaying
4612 configurations in speedbar.
4614 See the options group `vhdl-compose' for all relevant user options.
4617 SOURCE FILE COMPILATION:
4618 The syntax of the current buffer can be analyzed by calling a VHDL
4619 compiler (menu, `C-c C-k'). The compiler to be used is specified by
4620 option `vhdl-compiler'. The available compilers are listed in option
4621 `vhdl-compiler-alist' including all required compilation command,
4622 command options, compilation directory, and error message syntax
4623 information. New compilers can be added.
4625 All the source files of an entire design can be compiled by the `make'
4626 command (menu, `C-c M-C-k') if an appropriate Makefile exists.
4629 MAKEFILE GENERATION:
4630 Makefiles can be generated automatically by an internal generation
4631 routine (`C-c M-k'). The library unit dependency information is
4632 obtained from the hierarchy browser. Makefile generation can be
4633 customized for each compiler in option `vhdl-compiler-alist'.
4635 Makefile generation can also be run non-interactively using the
4638 emacs -batch -l ~/.emacs -l vhdl-mode
4639 [-compiler compilername] [-project projectname]
4640 -f vhdl-generate-makefile
4642 The Makefile's default target \"all\" compiles the entire design, the
4643 target \"clean\" removes it and the target \"library\" creates the
4644 library directory if not existent. These target names can be customized
4645 by option `vhdl-makefile-default-targets'. The Makefile also includes a
4646 target for each primary library unit which allows selective compilation
4647 of this unit, its secondary units and its subhierarchy (example:
4648 compilation of a design specified by a configuration). User specific
4649 parts can be inserted into a Makefile with option
4650 `vhdl-makefile-generation-hook'.
4653 - Only library units and dependencies within the current library are
4654 considered. Makefiles for designs that span multiple libraries are
4655 not (yet) supported.
4656 - Only one-level configurations are supported (also hierarchical),
4657 but configurations that go down several levels are not.
4658 - The \"others\" keyword in configurations is not supported.
4662 Projects can be defined in option `vhdl-project-alist' and a current
4663 project be selected using option `vhdl-project' (permanently) or from
4664 the menu or speedbar (temporarily). For each project, title and
4665 description strings (for the file headers), source files/directories
4666 (for the hierarchy browser and Makefile generation), library name, and
4667 compiler-dependent options, exceptions and compilation directory can be
4668 specified. Compilation settings overwrite the settings of option
4669 `vhdl-compiler-alist'.
4671 Project setups can be exported (i.e. written to a file) and imported.
4672 Imported setups are not automatically saved in `vhdl-project-alist' but
4673 can be saved afterwards in its customization buffer. When starting
4674 Emacs with VHDL Mode (i.e. load a VHDL file or use \"emacs -l
4675 vhdl-mode\") in a directory with an existing project setup file, it is
4676 automatically loaded and its project activated if option
4677 `vhdl-project-auto-load' is non-nil. Names/paths of the project setup
4678 files can be specified in option `vhdl-project-file-name'. Multiple
4679 project setups can be automatically loaded from global directories.
4680 This is an alternative to specifying project setups with option
4681 `vhdl-project-alist'.
4685 As an alternative to the speedbar, an index menu can be added (set
4686 option `vhdl-index-menu' to non-nil) or made accessible as a mouse menu
4687 (e.g. add \"(global-set-key [S-down-mouse-3] \\='imenu)\" to your start-up
4688 file) for browsing the file contents (is not populated if buffer is
4689 larger than 256000). Also, a source file menu can be
4690 added (set option `vhdl-source-file-menu' to non-nil) for browsing the
4691 current directory for VHDL source files.
4695 The VHDL standards to be used are specified in option `vhdl-standard'.
4696 Available standards are: VHDL'87/'93(02)/'08, VHDL-AMS, and Math Packages.
4700 Lower and upper case for keywords and standardized types, attributes,
4701 and enumeration values is supported. If the option
4702 `vhdl-upper-case-keywords' is set to non-nil, keywords can be typed in
4703 lower case and are converted into upper case automatically (not for
4704 types, attributes, and enumeration values). The case of keywords,
4705 types, attributes,and enumeration values can be fixed for an entire
4706 region (menu) or buffer (`C-c C-x C-c') according to the options
4707 `vhdl-upper-case-{keywords,types,attributes,enum-values}'.
4710 HIGHLIGHTING (fontification):
4711 Keywords and standardized types, attributes, enumeration values, and
4712 function names (controlled by option `vhdl-highlight-keywords'), as well
4713 as comments, strings, and template prompts are highlighted using
4714 different colors. Unit, subprogram, signal, variable, constant,
4715 parameter and generic/port names in declarations as well as labels are
4716 highlighted if option `vhdl-highlight-names' is non-nil.
4718 Additional reserved words or words with a forbidden syntax (e.g. words
4719 that should be avoided) can be specified in option
4720 `vhdl-forbidden-words' or `vhdl-forbidden-syntax' and be highlighted in
4721 a warning color (option `vhdl-highlight-forbidden-words'). Verilog
4722 keywords are highlighted as forbidden words if option
4723 `vhdl-highlight-verilog-keywords' is non-nil.
4725 Words with special syntax can be highlighted by specifying their
4726 syntax and color in option `vhdl-special-syntax-alist' and by setting
4727 option `vhdl-highlight-special-words' to non-nil. This allows you to
4728 establish some naming conventions (e.g. to distinguish different kinds
4729 of signals or other objects by using name suffices) and to support them
4732 Option `vhdl-highlight-case-sensitive' can be set to non-nil in order
4733 to support case-sensitive highlighting. However, keywords are then only
4734 highlighted if written in lower case.
4736 Code between \"translate_off\" and \"translate_on\" pragmas is
4737 highlighted using a different background color if option
4738 `vhdl-highlight-translate-off' is non-nil.
4740 For documentation and customization of the used colors see
4741 customization group `vhdl-highlight-faces' (`\\[customize-group]'). For
4742 highlighting of matching parenthesis, see customization group
4743 `paren-showing'. Automatic buffer highlighting is turned on/off by
4744 option `global-font-lock-mode' (`font-lock-auto-fontify' in XEmacs).
4748 VHDL models (templates) can be specified by the user and made accessible
4749 in the menu, through key bindings (`C-c C-m ...'), or by keyword
4750 electrification. See option `vhdl-model-alist'.
4754 The code of blocks, processes, subprograms, component declarations and
4755 instantiations, generic/port clauses, and configuration declarations can
4756 be hidden using the `Hide/Show' menu or by pressing `S-mouse-2' within
4757 the code (see customization group `vhdl-menu'). XEmacs: limited
4758 functionality due to old `hideshow.el' package.
4762 - Sensitivity List: `C-c C-u C-s' updates the sensitivity list of the
4763 current process, `C-c C-u M-s' of all processes in the current buffer.
4765 - Only declared local signals (ports, signals declared in
4766 architecture and blocks) are automatically inserted.
4767 - Global signals declared in packages are not automatically inserted.
4768 Insert them once manually (will be kept afterwards).
4769 - Out parameters of procedures are considered to be read.
4770 Use option `vhdl-entity-file-name' to specify the entity file name
4771 (used to obtain the port names).
4772 Use option `vhdl-array-index-record-field-in-sensitivity-list' to
4773 specify whether to include array indices and record fields in
4778 `C-c C-x C-p' fixes the closing parenthesis of a generic/port clause
4779 (e.g., if the closing parenthesis is on the wrong line or is missing).
4783 PostScript printing with different faces (an optimized set of faces is
4784 used if `vhdl-print-customize-faces' is non-nil) or colors (if
4785 `ps-print-color-p' is non-nil) is possible using the standard Emacs
4786 PostScript printing commands. Option `vhdl-print-two-column' defines
4787 appropriate default settings for nice landscape two-column printing.
4788 The paper format can be set by option `ps-paper-type'. Do not forget to
4789 switch `ps-print-color-p' to nil for printing on black-and-white
4794 User options allow customization of VHDL Mode. All options are
4795 accessible from the \"Options\" menu entry. Simple options (switches
4796 and choices) can directly be changed, while for complex options a
4797 customization buffer is opened. Changed options can be saved for future
4798 sessions using the \"Save Options\" menu entry.
4800 Options and their detailed descriptions can also be accessed by using
4801 the \"Customize\" menu entry or the command `\\[customize-option]'
4802 (`\\[customize-group]' for groups). Some customizations only take effect
4803 after some action (read the NOTE in the option documentation).
4804 Customization can also be done globally (i.e. site-wide, read the
4807 Not all options are described in this documentation, so go and see
4808 what other useful user options there are (`\\[vhdl-customize]' or menu)!
4812 As default, files with extensions \".vhd\" and \".vhdl\" are
4813 automatically recognized as VHDL source files. To add an extension
4814 \".xxx\", add the following line to your Emacs start-up file (`.emacs'):
4816 (push \\='(\"\\\\.xxx\\\\\\='\" . vhdl-mode) auto-mode-alist)
4820 - To start Emacs with open VHDL hierarchy browser without having to load
4821 a VHDL file first, use the command:
4823 emacs -l vhdl-mode -f speedbar-frame-mode
4825 - Type `C-g C-g' to interrupt long operations or if Emacs hangs.
4827 - Some features only work on properly indented code.
4831 See also the release notes (menu) for added features in new releases.
4837 To submit a bug report, enter `\\[vhdl-submit-bug-report]' within VHDL Mode.
4838 Add a description of the problem and include a reproducible test case.
4840 Questions and enhancement requests can be sent to <reto@gnu.org>.
4842 The `vhdl-mode-announce' mailing list informs about new VHDL Mode releases.
4843 The `vhdl-mode-victims' mailing list informs about new VHDL Mode beta
4844 releases. You are kindly invited to participate in beta testing. Subscribe
4845 to above mailing lists by sending an email to <reto@gnu.org>.
4847 VHDL Mode is officially distributed at
4848 http://www.iis.ee.ethz.ch/~zimmi/emacs/vhdl-mode.html
4849 where the latest version can be found.
4855 - XEmacs: Incorrect start-up when automatically opening speedbar.
4856 - XEmacs: Indentation in XEmacs 21.4 (and higher).
4857 - Indentation incorrect for new 'postponed' VHDL keyword.
4858 - Indentation incorrect for 'protected body' construct.
4861 The VHDL Mode Authors
4862 Reto Zimmermann and Rod Whitby
4868 :abbrev-table vhdl-mode-abbrev-table
4870 ;; set local variables
4871 (set (make-local-variable 'paragraph-start
)
4872 "\\s-*\\(--+\\s-*$\\|$\\)")
4873 (set (make-local-variable 'paragraph-separate
) paragraph-start
)
4874 (set (make-local-variable 'paragraph-ignore-fill-prefix
) t
)
4875 (set (make-local-variable 'parse-sexp-ignore-comments
) t
)
4876 (set (make-local-variable 'indent-line-function
) 'vhdl-indent-line
)
4877 (set (make-local-variable 'comment-start
) "--")
4878 (set (make-local-variable 'comment-end
) "")
4879 (set (make-local-variable 'comment-column
) vhdl-inline-comment-column
)
4880 (set (make-local-variable 'end-comment-column
) vhdl-end-comment-column
)
4881 (set (make-local-variable 'comment-start-skip
) "--+\\s-*")
4882 (set (make-local-variable 'comment-multi-line
) nil
)
4883 (set (make-local-variable 'indent-tabs-mode
) vhdl-indent-tabs-mode
)
4884 (set (make-local-variable 'hippie-expand-verbose
) nil
)
4886 ;; setup the comment indent variable in a Emacs version portable way
4887 ;; ignore any byte compiler warnings you might get here
4888 (when (boundp 'comment-indent-function
)
4889 (set (make-local-variable 'comment-indent-function
) 'vhdl-comment-indent
))
4891 ;; initialize font locking
4892 (set (make-local-variable 'font-lock-defaults
)
4894 '(nil vhdl-font-lock-keywords
) nil
4895 (not vhdl-highlight-case-sensitive
) '((?\_ .
"w")) 'beginning-of-line
))
4896 (if (eval-when-compile (fboundp 'syntax-propertize-rules
))
4897 (set (make-local-variable 'syntax-propertize-function
)
4898 (syntax-propertize-rules
4899 ;; Mark single quotes as having string quote syntax in
4901 ("\\('\\).\\('\\)" (1 "\"'") (2 "\"'"))))
4902 (set (make-local-variable 'font-lock-syntactic-keywords
)
4903 vhdl-font-lock-syntactic-keywords
))
4904 (unless vhdl-emacs-21
4905 (set (make-local-variable 'font-lock-support-mode
) 'lazy-lock-mode
)
4906 (set (make-local-variable 'lazy-lock-defer-contextually
) nil
)
4907 (set (make-local-variable 'lazy-lock-defer-on-the-fly
) t
)
4908 (set (make-local-variable 'lazy-lock-defer-on-scrolling
) t
))
4910 ;; variables for source file compilation
4911 (when vhdl-compile-use-local-error-regexp
4912 (set (make-local-variable 'compilation-error-regexp-alist
) nil
)
4913 (set (make-local-variable 'compilation-file-regexp-alist
) nil
))
4916 (vhdl-index-menu-init)
4917 ;; add source file menu
4918 (if vhdl-source-file-menu
(vhdl-add-source-files-menu))
4920 (easy-menu-add vhdl-mode-menu-list
) ; for XEmacs
4921 (easy-menu-define vhdl-mode-menu vhdl-mode-map
4922 "Menu keymap for VHDL Mode." vhdl-mode-menu-list
)
4923 ;; initialize hideshow and add menu
4924 (vhdl-hideshow-init)
4925 (run-hooks 'menu-bar-update-hook
)
4928 (vhdl-ps-print-init)
4929 (vhdl-write-file-hooks-init)
4930 (message "VHDL Mode %s.%s" vhdl-version
4931 (if noninteractive
"" " See menu for documentation and release notes.")))
4933 (defun vhdl-activate-customizations ()
4934 "Activate all customizations on local variables."
4936 (vhdl-mode-map-init)
4937 (use-local-map vhdl-mode-map
)
4938 (set-syntax-table vhdl-mode-syntax-table
)
4939 (setq comment-column vhdl-inline-comment-column
)
4940 (setq end-comment-column vhdl-end-comment-column
)
4941 (vhdl-write-file-hooks-init)
4942 (vhdl-update-mode-menu)
4943 (vhdl-hideshow-init)
4944 (run-hooks 'menu-bar-update-hook
))
4946 (defun vhdl-write-file-hooks-init ()
4947 "Add/remove hooks when buffer is saved."
4948 (if vhdl-modify-date-on-saving
4949 (add-hook 'local-write-file-hooks
'vhdl-template-modify-noerror nil t
)
4950 (remove-hook 'local-write-file-hooks
'vhdl-template-modify-noerror t
))
4951 (if (featurep 'xemacs
) (make-local-hook 'after-save-hook
))
4952 (add-hook 'after-save-hook
'vhdl-add-modified-file nil t
))
4954 (defun vhdl-process-command-line-option (option)
4955 "Process command line options for VHDL Mode."
4958 ((equal option
"-compiler")
4959 (vhdl-set-compiler (car command-line-args-left
))
4960 (setq command-line-args-left
(cdr command-line-args-left
)))
4962 ((equal option
"-project")
4963 (vhdl-set-project (car command-line-args-left
))
4964 (setq command-line-args-left
(cdr command-line-args-left
)))))
4966 ;; make Emacs process VHDL Mode options
4967 (setq command-switch-alist
4968 (append command-switch-alist
4969 '(("-compiler" . vhdl-process-command-line-option
)
4970 ("-project" . vhdl-process-command-line-option
))))
4973 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4974 ;;; Keywords and standardized words
4975 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4977 (defconst vhdl-02-keywords
4979 "abs" "access" "after" "alias" "all" "and" "architecture" "array"
4980 "assert" "attribute"
4981 "begin" "block" "body" "buffer" "bus"
4982 "case" "component" "configuration" "constant"
4983 "disconnect" "downto"
4984 "else" "elsif" "end" "entity" "exit"
4985 "file" "for" "function"
4986 "generate" "generic" "group" "guarded"
4987 "if" "impure" "in" "inertial" "inout" "is"
4988 "label" "library" "linkage" "literal" "loop"
4990 "nand" "new" "next" "nor" "not" "null"
4991 "of" "on" "open" "or" "others" "out"
4992 "package" "port" "postponed" "procedure" "process" "protected" "pure"
4993 "range" "record" "register" "reject" "rem" "report" "return"
4995 "select" "severity" "shared" "signal" "sla" "sll" "sra" "srl" "subtype"
4996 "then" "to" "transport" "type"
4997 "unaffected" "units" "until" "use"
4999 "wait" "when" "while" "with"
5002 "List of VHDL'02 keywords.")
5004 (defconst vhdl-08-keywords
5006 "context" "force" "property" "release" "sequence"
5008 "List of VHDL'08 keywords.")
5010 (defconst vhdl-ams-keywords
5012 "across" "break" "limit" "nature" "noise" "procedural" "quantity"
5013 "reference" "spectrum" "subnature" "terminal" "through"
5016 "List of VHDL-AMS keywords.")
5018 (defconst vhdl-verilog-keywords
5020 "`define" "`else" "`endif" "`ifdef" "`include" "`timescale" "`undef"
5021 "always" "and" "assign" "begin" "buf" "bufif0" "bufif1"
5022 "case" "casex" "casez" "cmos" "deassign" "default" "defparam" "disable"
5023 "edge" "else" "end" "endattribute" "endcase" "endfunction" "endmodule"
5024 "endprimitive" "endspecify" "endtable" "endtask" "event"
5025 "for" "force" "forever" "fork" "function"
5026 "highz0" "highz1" "if" "initial" "inout" "input" "integer" "join" "large"
5027 "macromodule" "makefile" "medium" "module"
5028 "nand" "negedge" "nmos" "nor" "not" "notif0" "notif1" "or" "output"
5029 "parameter" "pmos" "posedge" "primitive" "pull0" "pull1" "pulldown"
5031 "rcmos" "real" "realtime" "reg" "release" "repeat" "rnmos" "rpmos" "rtran"
5032 "rtranif0" "rtranif1"
5033 "scalared" "signed" "small" "specify" "specparam" "strength" "strong0"
5034 "strong1" "supply" "supply0" "supply1"
5035 "table" "task" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1"
5036 "triand" "trior" "trireg"
5037 "vectored" "wait" "wand" "weak0" "weak1" "while" "wire" "wor" "xnor" "xor"
5039 "List of Verilog keywords as candidate for additional reserved words.")
5041 (defconst vhdl-02-types
5043 "boolean" "bit" "bit_vector" "character" "severity_level" "integer"
5044 "real" "time" "natural" "positive" "string" "line" "text" "side"
5045 "unsigned" "signed" "delay_length" "file_open_kind" "file_open_status"
5046 "std_logic" "std_logic_vector"
5047 "std_ulogic" "std_ulogic_vector"
5049 "List of VHDL'02 standardized types.")
5051 (defconst vhdl-08-types
5053 "boolean_vector" "integer_vector" "real_vector" "time_vector"
5055 "List of VHDL'08 standardized types.")
5057 (defconst vhdl-ams-types
5058 ;; standards: IEEE Std 1076.1-2007, IEEE Std 1076.1.1-2004
5060 ;; package `standard'
5061 "domain_type" "real_vector"
5062 ;; package `energy_systems'
5063 "energy" "power" "periodicity" "real_across" "real_through" "unspecified"
5064 "unspecified_vector" "energy_vector" "power_vector" "periodicity_vector"
5065 "real_across_vector" "real_through_vector"
5066 ;; package `electrical_systems'
5067 "voltage" "current" "charge" "resistance" "conductance" "capacitance"
5068 "mmf" "electric_flux" "electric_flux_density" "electric_field_strength"
5069 "magnetic_flux" "magnetic_flux_density" "magnetic_field_strength"
5070 "inductance" "reluctance" "electrical" "electrical_vector" "magnetic"
5071 "magnetic_vector" "voltage_vector" "current_vector" "mmf_vector"
5072 "magnetic_flux_vector" "charge_vector" "resistance_vector"
5073 "conductance_vector" "capacitance_vector" "electric_flux_vector"
5074 "electric_flux_density_vector" "electric_field_strength_vector"
5075 "magnetic_flux_density_vector" "magnetic_field_strength_vector"
5076 "inductance_vector" "reluctance_vector" "ground"
5077 ;; package `mechanical_systems'
5078 "displacement" "force" "velocity" "acceleration" "mass" "stiffness"
5079 "damping" "momentum" "angle" "torque" "angular_velocity"
5080 "angular_acceleration" "moment_inertia" "angular_momentum"
5081 "angular_stiffness" "angular_damping" "translational"
5082 "translational_vector" "translational_velocity"
5083 "translational_velocity_vector" "rotational" "rotational_vector"
5084 "rotational_velocity" "rotational_velocity_vector" "displacement_vector"
5085 "force_vector" "velocity_vector" "force_velocity_vector" "angle_vector"
5086 "torque_vector" "angular_velocity_vector" "torque_velocity_vector"
5087 "acceleration_vector" "mass_vector" "stiffness_vector" "damping_vector"
5088 "momentum_vector" "angular_acceleration_vector" "moment_inertia_vector"
5089 "angular_momentum_vector" "angular_stiffness_vector"
5090 "angular_damping_vector" "anchor" "translational_v_ref"
5091 "rotational_v_ref" "translational_v" "rotational_v"
5092 ;; package `radiant_systems'
5093 "illuminance" "luminous_flux" "luminous_intensity" "irradiance" "radiant"
5094 "radiant_vector" "luminous_intensity_vector" "luminous_flux_vector"
5095 "illuminance_vector" "irradiance_vector"
5096 ;; package `thermal_systems'
5097 "temperature" "heat_flow" "thermal_capacitance" "thermal_resistance"
5098 "thermal_conductance" "thermal" "thermal_vector" "temperature_vector"
5099 "heat_flow_vector" "thermal_capacitance_vector"
5100 "thermal_resistance_vector" "thermal_conductance_vector"
5101 ;; package `fluidic_systems'
5102 "pressure" "vflow_rate" "mass_flow_rate" "volume" "density" "viscosity"
5103 "fresistance" "fconductance" "fcapacitance" "inertance" "cfresistance"
5104 "cfcapacitance" "cfinertance" "cfconductance" "fluidic" "fluidic_vector"
5105 "compressible_fluidic" "compressible_fluidic_vector" "pressure_vector"
5106 "vflow_rate_vector" "mass_flow_rate_vector" "volume_vector"
5107 "density_vector" "viscosity_vector" "fresistance_vector"
5108 "fconductance_vector" "fcapacitance_vector" "inertance_vector"
5109 "cfresistance_vector" "cfconductance_vector" "cfcapacitance_vector"
5110 "cfinertance_vector"
5112 "List of VHDL-AMS standardized types.")
5114 (defconst vhdl-math-types
5116 "complex" "complex_polar" "positive_real" "principal_value"
5118 "List of Math Packages standardized types.")
5120 (defconst vhdl-02-attributes
5122 "base" "left" "right" "high" "low" "pos" "val" "succ"
5123 "pred" "leftof" "rightof" "range" "reverse_range"
5124 "length" "delayed" "stable" "quiet" "transaction"
5125 "event" "active" "last_event" "last_active" "last_value"
5126 "driving" "driving_value" "ascending" "value" "image"
5127 "simple_name" "instance_name" "path_name"
5130 "List of VHDL'02 standardized attributes.")
5132 (defconst vhdl-08-attributes
5134 "instance_name" "path_name"
5136 "List of VHDL'08 standardized attributes.")
5138 (defconst vhdl-ams-attributes
5141 "reference" "contribution" "tolerance"
5142 "dot" "integ" "delayed" "above" "zoh" "ltf" "ztf"
5145 "List of VHDL-AMS standardized attributes.")
5147 (defconst vhdl-02-enum-values
5150 "note" "warning" "error" "failure"
5151 "read_mode" "write_mode" "append_mode"
5152 "open_ok" "status_error" "name_error" "mode_error"
5153 "fs" "ps" "ns" "us" "ms" "sec" "min" "hr"
5156 "List of VHDL'02 standardized enumeration values.")
5158 (defconst vhdl-ams-enum-values
5160 "quiescent_domain" "time_domain" "frequency_domain"
5161 ;; from `nature_pkg' package
5162 "eps0" "mu0" "ground" "mecvf_gnd" "mecpf_gnd" "rot_gnd" "fld_gnd"
5164 "List of VHDL-AMS standardized enumeration values.")
5166 (defconst vhdl-ams-constants
5167 ;; standard: IEEE Std 1076.1.1-2004
5169 ;; package `fundamental_constants'
5170 "phys_q" "phys_eps0" "phys_mu0" "phys_k" "phys_gravity" "phys_ctok"
5171 "phys_c" "phys_h" "phys_h_over_2_pi" "yocto" "zepto" "atto" "femto"
5172 "pico" "nano" "micro" "milli" "centi" "deci" "deka" "hecto" "kilo" "mega"
5173 "giga" "tera" "peta" "exa" "zetta" "yotta" "deca"
5174 ;; package `material_constants'
5175 "phys_eps_si" "phys_eps_sio2" "phys_e_si" "phys_e_sio2" "phys_e_poly"
5176 "phys_nu_si" "phys_nu_poly" "phys_rho_poly" "phys_rho_sio2"
5177 "ambient_temperature" "ambient_pressure" "ambient_illuminance"
5179 "List of VHDL-AMS standardized constants.")
5181 (defconst vhdl-math-constants
5182 ;; standard: IEEE Std 1076.2-1996
5184 "math_1_over_e" "math_1_over_pi" "math_1_over_sqrt_2" "math_2_pi"
5185 "math_3_pi_over_2" "math_cbase_1" "math_cbase_j" "math_czero"
5186 "math_deg_to_rad" "math_e" "math_log10_of_e" "math_log2_of_e"
5187 "math_log_of_10" "math_log_of_2" "math_pi" "math_pi_over_2"
5188 "math_pi_over_3" "math_pi_over_4" "math_rad_to_deg" "math_sqrt_2"
5191 "List of Math Packages standardized constants.")
5193 (defconst vhdl-02-functions
5195 "now" "resolved" "rising_edge" "falling_edge"
5196 "read" "readline" "hread" "oread" "write" "writeline" "hwrite" "owrite"
5198 "resize" "is_X" "std_match"
5199 "shift_left" "shift_right" "rotate_left" "rotate_right"
5200 "to_unsigned" "to_signed" "to_integer"
5201 "to_stdLogicVector" "to_stdULogic" "to_stdULogicVector"
5202 "to_bit" "to_bitVector" "to_X01" "to_X01Z" "to_UX01" "to_01"
5203 "conv_unsigned" "conv_signed" "conv_integer" "conv_std_logic_vector"
5204 "shl" "shr" "ext" "sxt"
5207 "List of VHDL'02 standardized functions.")
5209 (defconst vhdl-08-functions
5211 "finish" "flush" "justify" "maximum" "minimum"
5212 "resolution_limit" "rising_edge" "stop" "swrite"
5213 "tee" "to_binarystring" "to_bstring" "to_hexstring" "to_hstring"
5214 "to_octalstring" "to_ostring" "to_string"
5216 "List of VHDL'08 standardized functions.")
5218 (defconst vhdl-ams-functions
5220 ;; package `standard'
5223 "List of VHDL-AMS standardized functions.")
5225 (defconst vhdl-math-functions
5226 ;; standard: IEEE Std 1076.2-1996
5228 "arccos" "arccosh" "arcsin" "arcsinh" "arctan" "arctanh" "arg"
5229 "cbrt" "ceil" "cmplx" "complex_to_polar" "conj" "cos" "cosh" "exp"
5230 "floor" "get_principal_value" "log" "log10" "log2" "polar_to_complex"
5231 "realmax" "realmin" "round" "sign" "sin" "sinh" "sqrt"
5232 "tan" "tanh" "trunc" "uniform"
5234 "List of Math Packages standardized functions.")
5236 (defconst vhdl-02-packages
5238 "std_logic_1164" "numeric_std" "numeric_bit"
5240 "std_logic_arith" "std_logic_signed" "std_logic_unsigned"
5241 "std_logic_misc" "std_logic_textio"
5244 "List of VHDL'02 standardized packages and libraries.")
5246 (defconst vhdl-08-packages
5248 "env" "numeric_std_signed" "numeric_std_unsigned"
5249 "ieee_bit_context" "ieee_std_context" ;; contexts
5251 "List of VHDL'08 standardized packages and libraries.")
5253 (defconst vhdl-ams-packages
5255 "fundamental_constants" "material_constants" "energy_systems"
5256 "electrical_systems" "mechanical_systems" "radiant_systems"
5257 "thermal_systems" "fluidic_systems"
5259 "List of VHDL-AMS standardized packages and libraries.")
5261 (defconst vhdl-math-packages
5263 "math_real" "math_complex"
5265 "List of Math Packages standardized packages and libraries.")
5267 (defconst vhdl-08-directives
5269 "author" "author_info" "begin" "begin_protected" "comment"
5270 "data_block" "data_keyname" "data_keyowner" "data_method"
5271 "decrypt_license" "digest_block" "digest_key_method" "digest_keyname"
5272 "digest_keyowner" "digest_method"
5273 "encoding" "encrypt_agent" "encrypt_agent_info" "end" "end_protected"
5274 "key_block" "key_keyname" "key_keyowner" "key_method"
5275 "runtime_license" "viewport"
5277 "List of VHDL'08 standardized tool directives.")
5279 (defvar vhdl-keywords nil
5280 "List of VHDL keywords.")
5282 (defvar vhdl-types nil
5283 "List of VHDL standardized types.")
5285 (defvar vhdl-attributes nil
5286 "List of VHDL standardized attributes.")
5288 (defvar vhdl-enum-values nil
5289 "List of VHDL standardized enumeration values.")
5291 (defvar vhdl-constants nil
5292 "List of VHDL standardized constants.")
5294 (defvar vhdl-functions nil
5295 "List of VHDL standardized functions.")
5297 (defvar vhdl-packages nil
5298 "List of VHDL standardized packages and libraries.")
5300 (defvar vhdl-directives nil
5301 "List of VHDL standardized packages and libraries.")
5303 (defvar vhdl-reserved-words nil
5304 "List of additional reserved words.")
5306 (defvar vhdl-keywords-regexp nil
5307 "Regexp for VHDL keywords.")
5309 (defvar vhdl-types-regexp nil
5310 "Regexp for VHDL standardized types.")
5312 (defvar vhdl-attributes-regexp nil
5313 "Regexp for VHDL standardized attributes.")
5315 (defvar vhdl-enum-values-regexp nil
5316 "Regexp for VHDL standardized enumeration values.")
5318 (defvar vhdl-constants-regexp nil
5319 "Regexp for VHDL standardized constants.")
5321 (defvar vhdl-functions-regexp nil
5322 "Regexp for VHDL standardized functions.")
5324 (defvar vhdl-packages-regexp nil
5325 "Regexp for VHDL standardized packages and libraries.")
5327 (defvar vhdl-reserved-words-regexp nil
5328 "Regexp for additional reserved words.")
5330 (defvar vhdl-directive-keywords-regexp nil
5331 "Regexp for compiler directive keywords.")
5333 (defun vhdl-upcase-list (condition list
)
5334 "Upcase all elements in LIST based on CONDITION."
5336 (let ((tmp-list list
))
5338 (setcar tmp-list
(upcase (car tmp-list
)))
5339 (setq tmp-list
(cdr tmp-list
)))))
5342 (defun vhdl-words-init ()
5343 "Initialize reserved words."
5346 (and vhdl-highlight-case-sensitive vhdl-upper-case-keywords
)
5347 (append vhdl-02-keywords
5348 (when (vhdl-standard-p '08) vhdl-08-keywords
)
5349 (when (vhdl-standard-p 'ams
) vhdl-ams-keywords
))))
5352 (and vhdl-highlight-case-sensitive vhdl-upper-case-types
)
5353 (append vhdl-02-types
5354 (when (vhdl-standard-p '08) vhdl-08-types
)
5355 (when (vhdl-standard-p 'ams
) vhdl-ams-types
)
5356 (when (vhdl-standard-p 'math
) vhdl-math-types
))))
5357 (setq vhdl-attributes
5359 (and vhdl-highlight-case-sensitive vhdl-upper-case-attributes
)
5360 (append vhdl-02-attributes
5361 (when (vhdl-standard-p '08) vhdl-08-attributes
)
5362 (when (vhdl-standard-p 'ams
) vhdl-ams-attributes
))))
5363 (setq vhdl-enum-values
5365 (and vhdl-highlight-case-sensitive vhdl-upper-case-enum-values
)
5366 (append vhdl-02-enum-values
5367 (when (vhdl-standard-p 'ams
) vhdl-ams-enum-values
))))
5368 (setq vhdl-constants
5370 (and vhdl-highlight-case-sensitive vhdl-upper-case-constants
)
5371 (append (when (vhdl-standard-p 'ams
) vhdl-ams-constants
)
5372 (when (vhdl-standard-p 'math
) vhdl-math-constants
)
5374 (setq vhdl-functions
5375 (append vhdl-02-functions
5376 (when (vhdl-standard-p '08) vhdl-08-functions
)
5377 (when (vhdl-standard-p 'ams
) vhdl-ams-functions
)
5378 (when (vhdl-standard-p 'math
) vhdl-math-functions
)))
5380 (append vhdl-02-packages
5381 (when (vhdl-standard-p '08) vhdl-08-packages
)
5382 (when (vhdl-standard-p 'ams
) vhdl-ams-packages
)
5383 (when (vhdl-standard-p 'math
) vhdl-math-packages
)))
5384 (setq vhdl-directives
5385 (append (when (vhdl-standard-p '08) vhdl-08-directives
)))
5386 (setq vhdl-reserved-words
5387 (append (when vhdl-highlight-forbidden-words vhdl-forbidden-words
)
5388 (when vhdl-highlight-verilog-keywords vhdl-verilog-keywords
)
5390 (setq vhdl-keywords-regexp
5391 (concat "\\<\\(" (regexp-opt vhdl-keywords
) "\\)\\>"))
5392 (setq vhdl-types-regexp
5393 (concat "\\<\\(" (regexp-opt vhdl-types
) "\\)\\>"))
5394 (setq vhdl-attributes-regexp
5395 (concat "\\<\\(" (regexp-opt vhdl-attributes
) "\\)\\>"))
5396 (setq vhdl-enum-values-regexp
5397 (concat "\\<\\(" (regexp-opt vhdl-enum-values
) "\\)\\>"))
5398 (setq vhdl-constants-regexp
5399 (concat "\\<\\(" (regexp-opt vhdl-constants
) "\\)\\>"))
5400 (setq vhdl-functions-regexp
5401 (concat "\\<\\(" (regexp-opt vhdl-functions
) "\\)\\>"))
5402 (setq vhdl-packages-regexp
5403 (concat "\\<\\(" (regexp-opt vhdl-packages
) "\\)\\>"))
5404 (setq vhdl-reserved-words-regexp
5406 (unless (equal vhdl-forbidden-syntax
"")
5407 (concat vhdl-forbidden-syntax
"\\|"))
5408 (regexp-opt vhdl-reserved-words
)
5410 (setq vhdl-directive-keywords-regexp
5411 (concat "\\<\\(" (mapconcat 'regexp-quote
5412 vhdl-directive-keywords
"\\|") "\\)\\>"))
5413 (vhdl-abbrev-list-init))
5415 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5418 (defvar vhdl-abbrev-list nil
5419 "Predefined abbreviations for VHDL.")
5421 (defun vhdl-abbrev-list-init ()
5422 (setq vhdl-abbrev-list
5424 (list vhdl-upper-case-keywords
) vhdl-keywords
5425 (list vhdl-upper-case-types
) vhdl-types
5426 (list vhdl-upper-case-attributes
) vhdl-attributes
5427 (list vhdl-upper-case-enum-values
) vhdl-enum-values
5428 (list vhdl-upper-case-constants
) vhdl-constants
5429 (list nil
) vhdl-functions
5430 (list nil
) vhdl-packages
5431 (list nil
) vhdl-directives
)))
5433 ;; initialize reserved words for VHDL Mode
5437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5439 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5441 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5444 ;; constant regular expressions for looking at various constructs
5446 (defconst vhdl-symbol-key
"\\(\\w\\|\\s_\\)+"
5447 "Regexp describing a VHDL symbol.
5448 We cannot use just `word' syntax class since `_' cannot be in word
5449 class. Putting underscore in word class breaks forward word movement
5450 behavior that users are familiar with.")
5452 (defconst vhdl-case-header-key
"case[( \t\n\r\f][^;=>]+[) \t\n\r\f]is"
5453 "Regexp describing a case statement header key.")
5455 (defconst vhdl-label-key
5456 (concat "\\(" vhdl-symbol-key
"\\s-*:\\)[^=]")
5457 "Regexp describing a VHDL label.")
5459 ;; Macro definitions:
5461 (defmacro vhdl-point
(position)
5462 "Return the value of point at certain commonly referenced POSITIONs.
5463 POSITION can be one of the following symbols:
5465 bol -- beginning of line
5467 bod -- beginning of defun
5468 boi -- back to indentation
5469 eoi -- last whitespace on line
5470 ionl -- indentation of next line
5471 iopl -- indentation of previous line
5472 bonl -- beginning of next line
5473 bopl -- beginning of previous line
5475 This function does not modify point or mark."
5476 (or (and (eq 'quote
(car-safe position
))
5477 (null (cddr position
)))
5478 (error "ERROR: Bad buffer position requested: %s" position
))
5479 (setq position
(nth 1 position
))
5480 `(let ((here (point)))
5482 ((eq position
'bol
) '((beginning-of-line)))
5483 ((eq position
'eol
) '((end-of-line)))
5484 ((eq position
'bod
) '((save-match-data
5485 (vhdl-beginning-of-defun))))
5486 ((eq position
'boi
) '((back-to-indentation)))
5487 ((eq position
'eoi
) '((end-of-line) (skip-chars-backward " \t")))
5488 ((eq position
'bonl
) '((forward-line 1)))
5489 ((eq position
'bopl
) '((forward-line -
1)))
5490 ((eq position
'iopl
)
5492 (back-to-indentation)))
5493 ((eq position
'ionl
)
5495 (back-to-indentation)))
5496 (t (error "ERROR: Unknown buffer position requested: %s" position
))
5501 ;; workaround for an Emacs18 bug -- blech! Well, at least it
5502 ;; doesn't hurt for v19
5506 (defmacro vhdl-safe
(&rest body
)
5507 "Safely execute BODY, return nil if an error occurred."
5508 `(condition-case nil
5512 (defmacro vhdl-add-syntax
(symbol &optional relpos
)
5513 "A simple macro to append the syntax in SYMBOL to the syntax list.
5514 Try to increase performance by using this macro."
5515 `(setq vhdl-syntactic-context
5516 (cons (cons ,symbol
,relpos
) vhdl-syntactic-context
)))
5518 (defmacro vhdl-has-syntax
(symbol)
5519 "A simple macro to return check the syntax list.
5520 Try to increase performance by using this macro."
5521 `(assoc ,symbol vhdl-syntactic-context
))
5523 ;; Syntactic element offset manipulation:
5525 (defun vhdl-read-offset (langelem)
5526 "Read new offset value for LANGELEM from minibuffer.
5527 Return a valid value only."
5528 (let ((oldoff (format "%s" (cdr-safe (assq langelem vhdl-offsets-alist
))))
5529 (errmsg "Offset must be int, func, var, or one of +, -, ++, --: ")
5531 offset input interned
)
5533 (setq input
(read-string prompt oldoff
)
5534 offset
(cond ((string-equal "+" input
) '+)
5535 ((string-equal "-" input
) '-
)
5536 ((string-equal "++" input
) '++)
5537 ((string-equal "--" input
) '--
)
5538 ((string-match "^-?[0-9]+$" input
)
5539 (string-to-number input
))
5540 ((fboundp (setq interned
(intern input
)))
5542 ((boundp interned
) interned
)
5543 ;; error, but don't signal one, keep trying
5544 ;; to read an input value
5546 (setq prompt errmsg
)
5550 (defun vhdl-set-offset (symbol offset
&optional add-p
)
5551 "Change the value of a syntactic element symbol in `vhdl-offsets-alist'.
5552 SYMBOL is the syntactic element symbol to change and OFFSET is the new
5553 offset for that syntactic element. Optional ADD-P says to add SYMBOL to
5554 `vhdl-offsets-alist' if it doesn't already appear there."
5557 (intern (completing-read
5558 (concat "Syntactic symbol to change"
5559 (if current-prefix-arg
" or add" "")
5564 (cons (format "%s" (car langelem
)) nil
)))
5566 nil
(not current-prefix-arg
)
5567 ;; initial contents tries to be the last element
5568 ;; on the syntactic analysis list for the current
5570 (let* ((syntax (vhdl-get-syntactic-context))
5571 (len (length syntax
))
5572 (ic (format "%s" (car (nth (1- len
) syntax
)))))
5575 (offset (vhdl-read-offset langelem
)))
5576 (list langelem offset current-prefix-arg
)))
5577 ;; sanity check offset
5585 (error "ERROR: Offset must be int, func, var, or one of +, -, ++, --: %s"
5587 (let ((entry (assq symbol vhdl-offsets-alist
)))
5589 (setcdr entry offset
)
5591 (setq vhdl-offsets-alist
5592 (cons (cons symbol offset
) vhdl-offsets-alist
))
5593 (error "ERROR: %s is not a valid syntactic symbol" symbol
))))
5594 (vhdl-keep-region-active))
5596 (defun vhdl-set-style (style &optional local
)
5597 "Set `vhdl-mode' variables to use one of several different indentation styles.
5598 STYLE is a string representing the desired style and optional LOCAL is
5599 a flag which, if non-nil, means to make the style variables being
5600 changed buffer local, instead of the default, which is to set the
5601 global variables. Interactively, the flag comes from the prefix
5602 argument. The styles are chosen from the `vhdl-style-alist' variable."
5603 (interactive (list (completing-read "Use which VHDL indentation style? "
5604 vhdl-style-alist nil t
)
5605 current-prefix-arg
))
5606 (let ((vars (cdr (assoc style vhdl-style-alist
))))
5608 (error "ERROR: Invalid VHDL indentation style `%s'" style
))
5609 ;; set all the variables
5613 (let ((var (car varentry
))
5614 (val (cdr varentry
)))
5615 ;; special case for vhdl-offsets-alist
5616 (if (not (eq var
'vhdl-offsets-alist
))
5617 (set (if local
(make-local-variable var
) var
) val
)
5618 ;; reset vhdl-offsets-alist to the default value first
5619 (set (if local
(make-local-variable var
) var
)
5620 (copy-alist vhdl-offsets-alist-default
))
5621 ;; now set the langelems that are different
5625 (let ((langelem (car langentry
))
5626 (offset (cdr langentry
)))
5627 (vhdl-set-offset langelem offset
)
5632 (vhdl-keep-region-active))
5634 (defun vhdl-get-offset (langelem)
5635 "Get offset from LANGELEM which is a cons cell of the form:
5636 \(SYMBOL . RELPOS). The symbol is matched against
5637 vhdl-offsets-alist and the offset found there is either returned,
5638 or added to the indentation at RELPOS. If RELPOS is nil, then
5639 the offset is simply returned."
5640 (let* ((symbol (car langelem
))
5641 (relpos (cdr langelem
))
5642 (match (assq symbol vhdl-offsets-alist
))
5643 (offset (cdr-safe match
)))
5644 ;; offset can be a number, a function, a variable, or one of the
5648 (if vhdl-strict-syntax-p
5649 (error "ERROR: Don't know how to indent a %s" symbol
)
5652 ((eq offset
'+) (setq offset vhdl-basic-offset
))
5653 ((eq offset
'-
) (setq offset
(- vhdl-basic-offset
)))
5654 ((eq offset
'++) (setq offset
(* 2 vhdl-basic-offset
)))
5655 ((eq offset
'--
) (setq offset
(* 2 (- vhdl-basic-offset
))))
5656 ((and (not (numberp offset
))
5658 (setq offset
(funcall offset langelem
)))
5659 ((not (numberp offset
))
5660 (setq offset
(eval offset
)))
5663 (< relpos
(vhdl-point 'bol
)))
5670 ;; Syntactic support functions:
5672 (defun vhdl-in-comment-p (&optional pos
)
5673 "Check if point is in a comment (include multi-line comments)."
5674 (let ((parse (lambda (p)
5675 (let ((c (char-after p
)))
5676 (or (and c
(eq (char-syntax c
) ?
<))
5677 (nth 4 (parse-partial-sexp
5679 (beginning-of-defun)
5682 (goto-char (or pos
(point)))
5683 (or (funcall parse
(point))
5684 ;; `parse-partial-sexp's notion of comments doesn't span lines
5686 (back-to-indentation)
5689 (funcall parse
(point))))))))
5691 (defun vhdl-in-string-p ()
5692 "Check if point is in a string."
5693 (eq (vhdl-in-literal) 'string
))
5695 (defun vhdl-in-quote-p ()
5696 "Check if point is in a quote ('x')."
5697 (or (and (> (point) (point-min))
5698 (< (1+ (point)) (point-max))
5699 (= (char-before (point)) ?
\')
5700 (= (char-after (1+ (point))) ?
\'))
5701 (and (> (1- (point)) (point-min))
5702 (< (point) (point-max))
5703 (= (char-before (1- (point))) ?
\')
5704 (= (char-after (point)) ?
\'))))
5706 (defun vhdl-in-literal ()
5707 "Determine if point is in a VHDL literal."
5709 (let ((state (parse-partial-sexp (vhdl-point 'bol
) (point))))
5711 ((nth 3 state
) 'string
)
5712 ((nth 4 state
) 'comment
)
5713 ((vhdl-beginning-of-macro) 'pound
)
5714 ((vhdl-beginning-of-directive) 'directive
)
5715 ;; for multi-line comments
5716 ((and (vhdl-standard-p '08) (vhdl-in-comment-p)) 'comment
)
5719 (defun vhdl-in-extended-identifier-p ()
5720 "Determine if point is inside extended identifier (delimited by `\\')."
5722 (and (save-excursion (re-search-backward "\\\\" (vhdl-point 'bol
) t
))
5723 (save-excursion (re-search-forward "\\\\" (vhdl-point 'eol
) t
)))))
5725 (defun vhdl-forward-comment (&optional direction
)
5726 "Skip all comments (including whitespace). Skip backwards if DIRECTION is
5727 negative, skip forward otherwise."
5729 (if (and direction
(< direction
0))
5732 (skip-chars-backward " \t\n\r\f")
5733 (while (re-search-backward "^[^\"-]*\\(\\(-?\"[^\"]*\"\\|-[^\"-]\\)[^\"-]*\\)*\\(--\\)" (vhdl-point 'bol
) t
)
5734 (goto-char (match-beginning 3))
5735 (skip-chars-backward " \t\n\r\f")))
5737 (skip-chars-forward " \t\n\r\f")
5738 (while (looking-at "--.*")
5739 (goto-char (match-end 0))
5740 (skip-chars-forward " \t\n\r\f"))))
5742 ;; XEmacs hack: work around buggy `forward-comment' in XEmacs 21.4+
5743 (unless (and (featurep 'xemacs
) (string< "21.2" emacs-version
))
5744 (defalias 'vhdl-forward-comment
'forward-comment
))
5746 (defun vhdl-back-to-indentation ()
5747 "Move point to the first non-whitespace character on this line."
5749 (beginning-of-line 1)
5750 (skip-syntax-forward " " (vhdl-point 'eol
)))
5752 ;; XEmacs hack: work around old `back-to-indentation' in XEmacs
5753 (when (featurep 'xemacs
)
5754 (defalias 'back-to-indentation
'vhdl-back-to-indentation
))
5756 ;; This is the best we can do in Win-Emacs.
5757 (defun vhdl-win-il (&optional lim
)
5758 "Determine if point is in a VHDL literal."
5760 (let* ((here (point))
5763 (lim (or lim
(vhdl-point 'bod
))))
5765 (while (< (point) here
)
5767 (and (re-search-forward "--\\|[\"']\\|`"
5769 (buffer-substring (match-beginning 0) (match-end 0))))
5774 ;; looking at the opening of a VHDL style comment
5775 ((string= "--" match
)
5776 (if (<= here
(progn (end-of-line) (point))) 'comment
))
5777 ;; looking at a directive
5778 ((string= "`" match
)
5779 (if (<= here
(progn (end-of-line) (point))) 'directive
))
5780 ;; looking at the opening of a double quote string
5781 ((string= "\"" match
)
5782 (if (not (save-restriction
5783 ;; this seems to be necessary since the
5784 ;; re-search-forward will not work without it
5785 (narrow-to-region (point) here
)
5787 ;; this regexp matches a double quote
5788 ;; which is preceded by an even number
5789 ;; of backslashes, including zero
5790 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)*\"" here
'move
)))
5792 ;; looking at the opening of a single quote string
5793 ((string= "'" match
)
5794 (if (not (save-restriction
5795 ;; see comments from above
5796 (narrow-to-region (point) here
)
5798 ;; this matches a single quote which is
5799 ;; preceded by zero or two backslashes.
5800 "\\([^\\]\\|^\\)\\(\\\\\\\\\\)?'"
5807 (and (string-match "Win-Emacs" emacs-version
)
5808 (fset 'vhdl-in-literal
'vhdl-win-il
))
5810 ;; Skipping of "syntactic whitespace". Syntactic whitespace is
5811 ;; defined as lexical whitespace or comments. Search no farther back
5812 ;; or forward than optional LIM. If LIM is omitted, (point-min) is
5813 ;; used for backward skipping, (point-max) is used for forward
5816 (defun vhdl-forward-syntactic-ws (&optional lim
)
5817 "Forward skip of syntactic whitespace."
5818 (let* ((here (point-max))
5819 (hugenum (point-max)))
5820 (while (/= here
(point))
5822 (vhdl-forward-comment hugenum
)
5823 ;; skip preprocessor directives
5824 (when (and (or (eq (char-after) ?
#) (eq (char-after) ?
`))
5825 (= (vhdl-point 'boi
) (point)))
5826 (while (and (eq (char-before (vhdl-point 'eol
)) ?
\\)
5827 (= (forward-line 1) 0)))
5829 (if lim
(goto-char (min (point) lim
)))))
5832 ;; This is the best we can do in Win-Emacs.
5833 (defun vhdl-win-fsws (&optional lim
)
5834 "Forward skip syntactic whitespace for Win-Emacs."
5835 (let ((lim (or lim
(point-max)))
5838 (skip-chars-forward " \t\n\r\f" lim
)
5841 ((looking-at "--") (end-of-line))
5842 ;; none of the above
5843 (t (setq stop t
))))))
5845 (and (string-match "Win-Emacs" emacs-version
)
5846 (fset 'vhdl-forward-syntactic-ws
'vhdl-win-fsws
))
5848 (defun vhdl-beginning-of-macro (&optional lim
)
5849 "Go to the beginning of a cpp macro definition (nicked from `cc-engine')."
5850 (let ((here (point)))
5852 (while (eq (char-before (1- (point))) ?
\\)
5854 (back-to-indentation)
5855 (if (and (<= (point) here
)
5856 (eq (char-after) ?
#))
5861 (defun vhdl-beginning-of-directive (&optional lim
)
5862 "Go to the beginning of a directive (nicked from `cc-engine')."
5863 (let ((here (point)))
5865 (while (eq (char-before (1- (point))) ?
\\)
5867 (back-to-indentation)
5868 (if (and (<= (point) here
)
5869 (eq (char-after) ?
`))
5874 (defun vhdl-backward-syntactic-ws (&optional lim
)
5875 "Backward skip over syntactic whitespace."
5876 (let* ((here (point-min))
5877 (hugenum (- (point-max))))
5878 (while (/= here
(point))
5880 (vhdl-forward-comment hugenum
)
5881 (vhdl-beginning-of-macro))
5882 (if lim
(goto-char (max (point) lim
)))))
5884 ;; This is the best we can do in Win-Emacs.
5885 (defun vhdl-win-bsws (&optional lim
)
5886 "Backward skip syntactic whitespace for Win-Emacs."
5887 (let ((lim (or lim
(vhdl-point 'bod
)))
5890 (skip-chars-backward " \t\n\r\f" lim
)
5893 ((eq (vhdl-in-literal) 'comment
)
5894 (skip-chars-backward "^-" lim
)
5895 (skip-chars-backward "-" lim
)
5896 (while (not (or (and (= (following-char) ?-
)
5897 (= (char-after (1+ (point))) ?-
))
5899 (skip-chars-backward "^-" lim
)
5900 (skip-chars-backward "-" lim
)))
5901 ;; none of the above
5902 (t (setq stop t
))))))
5904 (and (string-match "Win-Emacs" emacs-version
)
5905 (fset 'vhdl-backward-syntactic-ws
'vhdl-win-bsws
))
5907 ;; Functions to help finding the correct indentation column:
5909 (defun vhdl-first-word (point)
5910 "If the keyword at POINT is at boi, then return (current-column) at
5911 that point, else nil."
5913 (and (goto-char point
)
5914 (eq (point) (vhdl-point 'boi
))
5917 (defun vhdl-last-word (point)
5918 "If the keyword at POINT is at eoi, then return (current-column) at
5919 that point, else nil."
5921 (and (goto-char point
)
5922 (save-excursion (or (eq (progn (forward-sexp) (point))
5924 (looking-at "\\s-*\\(--\\)?")))
5927 ;; Core syntactic evaluation functions:
5929 (defconst vhdl-libunit-re
5930 "\\b\\(architecture\\|configuration\\|context\\|entity\\|package\\)\\b[^_]")
5932 (defun vhdl-libunit-p ()
5936 (skip-chars-forward " \t\n\r\f")
5937 (not (looking-at "is\\b[^_]")))
5940 (and (not (looking-at "use\\b[^_]"))
5943 (vhdl-forward-syntactic-ws)
5944 (/= (following-char) ?
:))))
5947 (defconst vhdl-defun-re
5948 "\\b\\(architecture\\|block\\|configuration\\|context\\|entity\\|package\\|process\\|procedural\\|procedure\\|function\\)\\b[^_]")
5950 (defun vhdl-defun-p ()
5952 (if (looking-at "block\\|process\\|procedural")
5953 ;; "block", "process", "procedural":
5956 (not (looking-at "end\\s-+\\w")))
5957 ;; "architecture", "configuration", "context", "entity",
5958 ;; "package", "procedure", "function":
5961 (defun vhdl-corresponding-defun ()
5962 "If the word at the current position corresponds to a \"defun\"
5963 keyword, then return a string that can be used to find the
5964 corresponding \"begin\" keyword, else return nil."
5966 (and (looking-at vhdl-defun-re
)
5968 (if (looking-at "block\\|process\\|procedural")
5969 ;; "block", "process". "procedural:
5970 (buffer-substring (match-beginning 0) (match-end 0))
5971 ;; "architecture", "configuration", "context", "entity", "package",
5972 ;; "procedure", "function":
5975 (defconst vhdl-begin-fwd-re
5976 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\(\\s-+body\\)?\\|units\\|use\\|record\\|protected\\(\\s-+body\\)?\\|for\\)\\b\\([^_]\\|\\'\\)"
5977 "A regular expression for searching forward that matches all known
5978 \"begin\" keywords.")
5980 (defconst vhdl-begin-bwd-re
5981 "\\b\\(is\\|begin\\|block\\|component\\|generate\\|then\\|else\\|loop\\|process\\|procedural\\(\\s-+body\\)?\\|units\\|use\\|record\\|protected\\(\\s-+body\\)?\\|for\\)\\b[^_]"
5982 "A regular expression for searching backward that matches all known
5983 \"begin\" keywords.")
5985 (defun vhdl-begin-p (&optional lim
)
5986 "Return t if we are looking at a real \"begin\" keyword.
5987 Assumes that the caller will make sure that we are looking at
5988 vhdl-begin-fwd-re, and are not inside a literal, and that we are not in
5989 the middle of an identifier that just happens to contain a \"begin\"
5992 ;; "[architecture|case|configuration|context|entity|package|
5993 ;; procedure|function] ... is":
5994 ((and (looking-at "i")
5996 ;; Skip backward over first sexp (needed to skip over a
5997 ;; procedure interface list, and is harmless in other
5998 ;; situations). Note that we need "return" in the
5999 ;; following search list so that we don't run into
6000 ;; semicolons in the function interface list.
6002 (skip-chars-forward "(")
6004 (while (and (not foundp
)
6006 ";\\|\\b\\(architecture\\|case\\|configuration\\|context\\|entity\\|package\\|procedure\\|return\\|is\\|begin\\|process\\|procedural\\|block\\)\\b[^_]"
6008 (if (or (= (preceding-char) ?_
)
6012 (and (/= (following-char) ?\
;)
6013 (not (looking-at "is\\|begin\\|process\\|procedural\\|block")))))
6015 ;; "begin", "then", "use":
6016 ((looking-at "be\\|t\\|use")
6019 ((and (looking-at "e")
6020 ;; make sure that the "else" isn't inside a
6021 ;; conditional signal assignment.
6023 (vhdl-re-search-backward ";\\|\\bwhen\\b[^_]" lim
'move
)
6024 (or (eq (following-char) ?\
;)
6027 ;; "block", "generate", "loop", "process", "procedural",
6028 ;; "units", "record", "protected body":
6029 ((and (looking-at "block\\|generate\\|loop\\|process\\|procedural\\|protected\\(\\s-+body\\)?\\|units\\|record")
6032 (not (looking-at "end\\s-+\\w"))))
6035 ((and (looking-at "c")
6038 (not (looking-at "end\\s-+\\w")))
6039 ;; look out for the dreaded entity class in an attribute
6041 (vhdl-backward-syntactic-ws lim
)
6042 (/= (preceding-char) ?
:)))
6044 ;; "for" (inside configuration declaration):
6045 ((and (looking-at "f")
6048 (not (looking-at "end\\s-+\\w")))
6049 (vhdl-has-syntax 'configuration
))
6053 (defun vhdl-corresponding-mid (&optional lim
)
6055 ((looking-at "is\\|block\\|generate\\|process\\|procedural")
6057 ((looking-at "then\\|use")
6062 (defun vhdl-corresponding-end (&optional lim
)
6063 "If the word at the current position corresponds to a \"begin\"
6064 keyword, then return a vector containing enough information to find
6065 the corresponding \"end\" keyword, else return nil. The keyword to
6066 search forward for is aref 0. The column in which the keyword must
6067 appear is aref 1 or nil if any column is suitable.
6068 Assumes that the caller will make sure that we are not in the middle
6069 of an identifier that just happens to contain a \"begin\" keyword."
6071 (and (looking-at vhdl-begin-fwd-re
)
6072 (or (not (looking-at "\\<use\\>"))
6073 (save-excursion (back-to-indentation)
6074 (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
6075 (/= (preceding-char) ?_
)
6076 (not (vhdl-in-literal))
6079 ;; "is", "generate", "loop":
6080 ((looking-at "[igl]")
6082 (and (vhdl-last-word (point))
6083 (or (vhdl-first-word (point))
6085 (vhdl-beginning-of-statement-1 lim
)
6086 (vhdl-backward-skip-label lim
)
6087 (vhdl-first-word (point)))))))
6088 ;; "begin", "else", "for":
6089 ((looking-at "be\\|[ef]")
6091 (and (vhdl-last-word (point))
6092 (or (vhdl-first-word (point))
6094 (vhdl-beginning-of-statement-1 lim
)
6095 (vhdl-backward-skip-label lim
)
6096 (vhdl-first-word (point)))))))
6097 ;; "component", "units", "record", "protected body":
6098 ((looking-at "component\\|units\\|protected\\(\\s-+body\\)?\\|record")
6099 ;; The first end found will close the block
6101 ;; "block", "process", "procedural":
6102 ((looking-at "bl\\|p")
6104 (or (vhdl-first-word (point))
6106 (vhdl-beginning-of-statement-1 lim
)
6107 (vhdl-backward-skip-label lim
)
6108 (vhdl-first-word (point))))))
6110 ((looking-at "t\\|use")
6111 (vector "elsif\\|else\\|end\\s-+\\(if\\|use\\)"
6112 (and (vhdl-last-word (point))
6113 (or (vhdl-first-word (point))
6115 (vhdl-beginning-of-statement-1 lim
)
6116 (vhdl-backward-skip-label lim
)
6117 (vhdl-first-word (point)))))))
6120 (defconst vhdl-end-fwd-re
"\\b\\(end\\|else\\|elsif\\)\\b\\([^_]\\|\\'\\)")
6122 (defconst vhdl-end-bwd-re
"\\b\\(end\\|else\\|elsif\\)\\b[^_]")
6124 (defun vhdl-end-p (&optional lim
)
6125 "Return t if we are looking at a real \"end\" keyword.
6126 Assumes that the caller will make sure that we are looking at
6127 vhdl-end-fwd-re, and are not inside a literal, and that we are not in
6128 the middle of an identifier that just happens to contain an \"end\"
6130 (or (not (looking-at "else"))
6131 ;; make sure that the "else" isn't inside a conditional signal
6134 (re-search-backward ";\\|\\bwhen\\b[^_]" lim
'move
)
6135 (or (eq (following-char) ?\
;)
6137 (vhdl-in-literal)))))
6139 (defun vhdl-corresponding-begin (&optional lim
)
6140 "If the word at the current position corresponds to an \"end\"
6141 keyword, then return a vector containing enough information to find
6142 the corresponding \"begin\" keyword, else return nil. The keyword to
6143 search backward for is aref 0. The column in which the keyword must
6144 appear is aref 1 or nil if any column is suitable. The supplementary
6145 keyword to search forward for is aref 2 or nil if this is not
6146 required. If aref 3 is t, then the \"begin\" keyword may be found in
6147 the middle of a statement.
6148 Assumes that the caller will make sure that we are not in the middle
6149 of an identifier that just happens to contain an \"end\" keyword."
6152 (if (and (looking-at vhdl-end-fwd-re
)
6153 (not (vhdl-in-literal))
6155 (if (looking-at "el")
6157 (vector "if\\|elsif" (vhdl-first-word (point)) "then\\|use" nil
)
6161 (skip-chars-forward " \t\n\r\f")
6164 ((looking-at "if\\b[^_]")
6165 (vector "else\\|elsif\\|if"
6166 (vhdl-first-word pos
)
6167 "else\\|then\\|use" nil
))
6169 ((looking-at "component\\b[^_]")
6170 (vector (buffer-substring (match-beginning 1)
6172 (vhdl-first-word pos
)
6174 ;; "end units", "end record", "end protected":
6175 ((looking-at "\\(units\\|record\\|protected\\(\\s-+body\\)?\\)\\b[^_]")
6176 (vector (buffer-substring (match-beginning 1)
6178 (vhdl-first-word pos
)
6180 ;; "end block", "end process", "end procedural":
6181 ((looking-at "\\(block\\|process\\|procedural\\)\\b[^_]")
6182 (vector "begin" (vhdl-first-word pos
) nil nil
))
6184 ((looking-at "case\\b[^_]")
6185 (vector "case" (vhdl-first-word pos
) "is" nil
))
6187 ((looking-at "generate\\b[^_]")
6188 (vector "generate\\|for\\|if"
6189 (vhdl-first-word pos
)
6192 ((looking-at "loop\\b[^_]")
6193 (vector "loop\\|while\\|for"
6194 (vhdl-first-word pos
)
6196 ;; "end for" (inside configuration declaration):
6197 ((looking-at "for\\b[^_]")
6198 (vector "for" (vhdl-first-word pos
) nil nil
))
6201 (vector "begin\\|architecture\\|configuration\\|context\\|entity\\|package\\|procedure\\|function"
6202 (vhdl-first-word pos
)
6203 ;; return an alist of (statement . keyword) mappings
6205 ;; "begin ... end [id]":
6207 ;; "architecture ... is ... begin ... end [id]":
6208 ("architecture" .
"is")
6209 ;; "configuration ... is ... end [id]":
6210 ("configuration" .
"is")
6211 ;; "context ... is ... end [id]":
6213 ;; "entity ... is ... end [id]":
6215 ;; "package ... is ... end [id]":
6217 ;; "procedure ... is ... begin ... end [id]":
6218 ("procedure" .
"is")
6219 ;; "function ... is ... begin ... end [id]":
6226 (defconst vhdl-leader-re
6227 "\\b\\(block\\|component\\|process\\|procedural\\|for\\)\\b[^_]")
6229 (defun vhdl-end-of-leader ()
6231 (cond ((looking-at "block\\|process\\|procedural")
6234 (skip-chars-forward " \t\n\r\f")
6235 (= (following-char) ?\
())
6238 (when (looking-at "[ \t\n\r\f]*is")
6239 (goto-char (match-end 0)))
6241 ((looking-at "component")
6243 (when (looking-at "[ \t\n\r\f]*is")
6244 (goto-char (match-end 0)))
6248 (skip-chars-forward " \t\n\r\f")
6249 (while (looking-at "[,:(]")
6251 (skip-chars-forward " \t\n\r\f"))
6256 (defconst vhdl-trailer-re
6257 "\\b\\(is\\|then\\|generate\\|loop\\|record\\|protected\\(\\s-+body\\)?\\|use\\)\\b[^_]")
6259 (defconst vhdl-statement-fwd-re
6260 "\\b\\(if\\|for\\|while\\|loop\\)\\b\\([^_]\\|\\'\\)"
6261 "A regular expression for searching forward that matches all known
6262 \"statement\" keywords.")
6264 (defconst vhdl-statement-bwd-re
6265 "\\b\\(if\\|for\\|while\\|loop\\)\\b[^_]"
6266 "A regular expression for searching backward that matches all known
6267 \"statement\" keywords.")
6269 (defun vhdl-statement-p (&optional lim
)
6270 "Return t if we are looking at a real \"statement\" keyword.
6271 Assumes that the caller will make sure that we are looking at
6272 vhdl-statement-fwd-re, and are not inside a literal, and that we are not
6273 in the middle of an identifier that just happens to contain a
6274 \"statement\" keyword."
6276 ;; "for" ... "generate":
6277 ((and (looking-at "f")
6278 ;; Make sure it's the start of a parameter specification.
6281 (skip-chars-forward " \t\n\r\f")
6282 (looking-at "in\\b[^_]"))
6283 ;; Make sure it's not an "end for".
6286 (not (looking-at "end\\s-+\\w"))))
6288 ;; "if" ... "then", "if" ... "generate", "if" ... "loop":
6289 ((and (looking-at "i")
6290 ;; Make sure it's not an "end if".
6293 (not (looking-at "end\\s-+\\w"))))
6295 ;; "while" ... "loop":
6300 (defconst vhdl-case-alternative-re
"when[( \t\n\r\f][^;=>]+=>"
6301 "Regexp describing a case statement alternative key.")
6303 (defun vhdl-case-alternative-p (&optional lim
)
6304 "Return t if we are looking at a real case alternative.
6305 Assumes that the caller will make sure that we are looking at
6306 vhdl-case-alternative-re, and are not inside a literal, and that
6307 we are not in the middle of an identifier that just happens to
6308 contain a \"when\" keyword."
6311 (while (and (not foundp
)
6312 (re-search-backward ";\\|<=" lim
'move
))
6313 (if (or (= (preceding-char) ?_
)
6317 (or (eq (following-char) ?\
;)
6321 ;; Core syntactic movement functions:
6323 (defconst vhdl-b-t-b-re
6324 (concat vhdl-begin-bwd-re
"\\|" vhdl-end-bwd-re
))
6326 (defun vhdl-backward-to-block (&optional lim
)
6327 "Move backward to the previous \"begin\" or \"end\" keyword."
6329 (while (and (not foundp
)
6330 (re-search-backward vhdl-b-t-b-re lim
'move
))
6331 (if (or (= (preceding-char) ?_
)
6336 ((and (looking-at vhdl-begin-fwd-re
)
6337 (or (not (looking-at "\\<use\\>"))
6338 (save-excursion (back-to-indentation)
6339 (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
6340 (/= (preceding-char) ?_
)
6342 (setq foundp
'begin
))
6344 ((and (looking-at vhdl-end-fwd-re
)
6345 (/= (preceding-char) ?_
)
6353 (defun vhdl-forward-sexp (&optional count lim
)
6354 "Move forward across one balanced expression (sexp).
6355 With COUNT, do it that many times."
6357 (let ((count (or count
1))
6358 (case-fold-search t
)
6363 (skip-chars-forward " \t\n\r\f")
6364 ;; Check for an unbalanced "end" keyword
6365 (if (and (looking-at vhdl-end-fwd-re
)
6366 (/= (preceding-char) ?_
)
6367 (not (vhdl-in-literal))
6369 (not (looking-at "else")))
6371 "ERROR: Containing expression ends prematurely in vhdl-forward-sexp"))
6372 ;; If the current keyword is a "begin" keyword, then find the
6373 ;; corresponding "end" keyword.
6374 (if (setq end-vec
(vhdl-corresponding-end lim
))
6376 ;; end-re is the statement keyword to search for
6378 (concat "\\b\\(" (aref end-vec
0) "\\)\\b\\([^_]\\|\\'\\)"))
6379 ;; column is either the statement keyword target column
6381 (column (aref end-vec
1))
6382 (eol (vhdl-point 'eol
))
6383 foundp literal placeholder
)
6384 ;; Look for the statement keyword.
6385 (while (and (not foundp
)
6386 (re-search-forward end-re nil t
)
6387 (setq placeholder
(match-end 1))
6388 (goto-char (match-beginning 0)))
6389 ;; If we are in a literal, or not in the right target
6390 ;; column and not on the same line as the begin, then
6393 (/= (current-indentation) column
)
6395 (= (preceding-char) ?_
)
6396 (setq literal
(vhdl-in-literal)))
6397 (if (eq literal
'comment
)
6400 ;; An "else" keyword corresponds to both the opening brace
6401 ;; of the following sexp and the closing brace of the
6403 (if (not (looking-at "else"))
6404 (goto-char placeholder
))
6408 (error "ERROR: Unbalanced keywords in vhdl-forward-sexp"))
6410 ;; If the current keyword is not a "begin" keyword, then just
6411 ;; perform the normal forward-sexp.
6414 (setq count
(1- count
))
6416 (setq target
(point)))
6420 (defun vhdl-backward-sexp (&optional count lim
)
6421 "Move backward across one balanced expression (sexp).
6422 With COUNT, do it that many times. LIM bounds any required backward
6425 (let ((count (or count
1))
6426 (case-fold-search t
)
6430 ;; Perform the normal backward-sexp, unless we are looking at
6431 ;; "else" - an "else" keyword corresponds to both the opening brace
6432 ;; of the following sexp and the closing brace of the previous sexp.
6433 (if (and (looking-at "else\\b\\([^_]\\|\\'\\)")
6434 (/= (preceding-char) ?_
)
6435 (not (vhdl-in-literal)))
6438 (if (and (looking-at vhdl-begin-fwd-re
)
6439 (or (not (looking-at "\\<use\\>"))
6441 (back-to-indentation)
6442 (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
6443 (/= (preceding-char) ?_
)
6444 (not (vhdl-in-literal))
6446 (error "ERROR: Containing expression ends prematurely in vhdl-backward-sexp")))
6447 ;; If the current keyword is an "end" keyword, then find the
6448 ;; corresponding "begin" keyword.
6449 (if (and (setq begin-vec
(vhdl-corresponding-begin lim
))
6450 (/= (preceding-char) ?_
))
6452 ;; begin-re is the statement keyword to search for
6454 (concat "\\b\\(" (aref begin-vec
0) "\\)\\b[^_]"))
6455 ;; column is either the statement keyword target column
6457 (column (aref begin-vec
1))
6458 ;; internal-p controls where the statement keyword can
6460 (internal-p (aref begin-vec
3))
6461 (last-backward (point)) last-forward
6462 foundp literal keyword
)
6463 ;; Look for the statement keyword.
6464 (while (and (not foundp
)
6465 (re-search-backward begin-re lim t
)
6467 (buffer-substring (match-beginning 1)
6469 ;; If we are in a literal or in the wrong column,
6472 (and (/= (current-indentation) column
)
6473 ;; possibly accept current-column as
6474 ;; well as current-indentation.
6475 (or (not internal-p
)
6476 (/= (current-column) column
))))
6477 (= (preceding-char) ?_
)
6480 ;; If there is a supplementary keyword, then
6481 ;; search forward for it.
6482 (if (and (setq begin-re
(aref begin-vec
2))
6483 (or (not (listp begin-re
))
6484 ;; If begin-re is an alist, then find the
6485 ;; element corresponding to the actual
6486 ;; keyword that we found.
6489 (assoc keyword begin-re
))
6491 (setq begin-re
(cdr begin-re
))))))
6494 (concat "\\b\\(" begin-re
"\\)\\b[^_]"))
6496 (setq last-forward
(point))
6497 ;; Look for the supplementary keyword
6498 ;; (bounded by the backward search start
6500 (while (and (not foundp
)
6501 (re-search-forward begin-re
6503 (goto-char (match-beginning 1)))
6504 ;; If we are in a literal, then try again.
6505 (if (or (= (preceding-char) ?_
)
6508 (if (eq literal
'comment
)
6510 (min (vhdl-point 'eol
) last-backward
))
6512 ;; We have found the supplementary keyword.
6513 ;; Save the position of the keyword in foundp.
6514 (setq foundp
(point)))
6517 ;; If the supplementary keyword was found, then
6518 ;; move point to the supplementary keyword.
6520 ;; If there was no supplementary keyword, then
6521 ;; point is already at the statement keyword.
6523 ) ; end of the search for the statement keyword
6525 (error "ERROR: Unbalanced keywords in vhdl-backward-sexp"))
6527 (setq count
(1- count
))
6529 (setq target
(point)))
6533 (defun vhdl-backward-up-list (&optional count limit
)
6534 "Move backward out of one level of blocks.
6535 With argument, do this that many times."
6537 (let ((count (or count
1))
6541 (if (looking-at vhdl-defun-re
)
6542 (error "ERROR: Unbalanced blocks"))
6543 (vhdl-backward-to-block limit
)
6544 (setq count
(1- count
)))
6545 (setq target
(point)))
6546 (goto-char target
)))
6548 (defun vhdl-end-of-defun (&optional count
)
6549 "Move forward to the end of a VHDL defun."
6551 (let ((case-fold-search t
))
6552 (vhdl-beginning-of-defun)
6553 (if (not (looking-at "block\\|process\\|procedural"))
6554 (re-search-forward "\\bis\\b"))
6555 (vhdl-forward-sexp)))
6557 (defun vhdl-mark-defun ()
6558 "Put mark at end of this \"defun\", point at beginning."
6560 (let ((case-fold-search t
))
6562 (vhdl-beginning-of-defun)
6564 (if (not (looking-at "block\\|process\\|procedural"))
6565 (re-search-forward "\\bis\\b"))
6567 (exchange-point-and-mark)))
6569 (defun vhdl-beginning-of-libunit ()
6570 "Move backward to the beginning of a VHDL library unit.
6571 Returns the location of the corresponding begin keyword, unless search
6572 stops due to beginning or end of buffer.
6573 Note that if point is between the \"libunit\" keyword and the
6574 corresponding \"begin\" keyword, then that libunit will not be
6575 recognized, and the search will continue backwards. If point is
6576 at the \"begin\" keyword, then the defun will be recognized. The
6577 returned point is at the first character of the \"libunit\" keyword."
6578 (let ((last-forward (point))
6580 ;; Just in case we are actually sitting on the "begin"
6581 ;; keyword, allow for the keyword and an extra character,
6582 ;; as this will be used when looking forward for the
6584 (save-excursion (forward-word-strictly 1) (1+ (point))))
6585 foundp literal placeholder
)
6586 ;; Find the "libunit" keyword.
6587 (while (and (not foundp
)
6588 (re-search-backward vhdl-libunit-re nil
'move
))
6589 ;; If we are in a literal, or not at a real libunit, then try again.
6590 (if (or (= (preceding-char) ?_
)
6592 (not (vhdl-libunit-p)))
6594 ;; Find the corresponding "begin" keyword.
6595 (setq last-forward
(point))
6596 (while (and (not foundp
)
6597 (re-search-forward "\\bis\\b[^_]" last-backward t
)
6598 (setq placeholder
(match-beginning 0)))
6599 (if (or (= (preceding-char) ?_
)
6600 (setq literal
(vhdl-in-literal)))
6601 ;; It wasn't a real keyword, so keep searching.
6602 (if (eq literal
'comment
)
6604 (min (vhdl-point 'eol
) last-backward
))
6606 ;; We have found the begin keyword, loop will exit.
6607 (setq foundp placeholder
)))
6608 ;; Go back to the libunit keyword
6609 (goto-char last-forward
)))
6612 (defun vhdl-beginning-of-defun (&optional count
)
6613 "Move backward to the beginning of a VHDL defun.
6614 With argument, do it that many times.
6615 Returns the location of the corresponding begin keyword, unless search
6616 stops due to beginning or end of buffer."
6617 ;; Note that if point is between the "defun" keyword and the
6618 ;; corresponding "begin" keyword, then that defun will not be
6619 ;; recognized, and the search will continue backwards. If point is
6620 ;; at the "begin" keyword, then the defun will be recognized. The
6621 ;; returned point is at the first character of the "defun" keyword.
6623 (let ((count (or count
1))
6624 (case-fold-search t
)
6625 (last-forward (point))
6629 (goto-char last-forward
)
6630 (let ((last-backward
6631 ;; Just in case we are actually sitting on the "begin"
6632 ;; keyword, allow for the keyword and an extra character,
6633 ;; as this will be used when looking forward for the
6635 (save-excursion (forward-word-strictly 1) (1+ (point))))
6636 begin-string literal
)
6637 (while (and (not foundp
)
6638 (re-search-backward vhdl-defun-re nil
'move
))
6639 ;; If we are in a literal, then try again.
6640 (if (or (= (preceding-char) ?_
)
6643 (if (setq begin-string
(vhdl-corresponding-defun))
6644 ;; This is a real defun keyword.
6645 ;; Find the corresponding "begin" keyword.
6646 ;; Look for the begin keyword.
6648 ;; Save the search start point.
6649 (setq last-forward
(point))
6650 (while (and (not foundp
)
6651 (search-forward begin-string last-backward t
))
6652 (if (or (= (preceding-char) ?_
)
6654 (setq literal
(vhdl-in-literal))))
6655 ;; It wasn't a real keyword, so keep searching.
6656 (if (eq literal
'comment
)
6658 (min (vhdl-point 'eol
) last-backward
))
6660 ;; We have found the begin keyword, loop will exit.
6661 (setq foundp
(match-beginning 0)))
6663 ;; Go back to the defun keyword
6664 (goto-char last-forward
)) ; end search for begin keyword
6666 ) ; end of the search for the defun keyword
6668 (setq count
(1- count
))
6670 (vhdl-keep-region-active)
6673 (defun vhdl-beginning-of-statement (&optional count lim interactive
)
6674 "Go to the beginning of the innermost VHDL statement.
6675 With prefix arg, go back N - 1 statements. If already at the
6676 beginning of a statement then go to the beginning of the preceding
6677 one. If within a string or comment, or next to a comment (only
6678 whitespace between), move by sentences instead of statements.
6680 When called from a program, this function takes 3 optional args: the
6681 prefix arg, a buffer position limit which is the farthest back to
6682 search, and an argument indicating an interactive call."
6683 (interactive "p\np")
6684 (let ((count (or count
1))
6685 (case-fold-search t
)
6686 (lim (or lim
(point-min)))
6691 (setq state
(parse-partial-sexp (point) here nil nil
)))
6692 (if (and interactive
6695 (looking-at (concat "[ \t]*" comment-start-skip
))))
6696 (forward-sentence (- count
))
6698 (vhdl-beginning-of-statement-1 lim
)
6699 (setq count
(1- count
))))
6700 ;; its possible we've been left up-buf of lim
6701 (goto-char (max (point) lim
))
6703 (vhdl-keep-region-active))
6705 (defconst vhdl-e-o-s-re
6706 (concat ";\\|" vhdl-begin-fwd-re
"\\|" vhdl-statement-fwd-re
))
6708 (defun vhdl-end-of-statement ()
6709 "Very simple implementation."
6711 (re-search-forward vhdl-e-o-s-re
))
6713 (defconst vhdl-b-o-s-re
6714 (concat ";[^_]\\|([^_]\\|)[^_]\\|\\bwhen\\b[^_]\\|"
6715 vhdl-begin-bwd-re
"\\|" vhdl-statement-bwd-re
))
6717 (defun vhdl-beginning-of-statement-1 (&optional lim
)
6718 "Move to the start of the current statement, or the previous
6719 statement if already at the beginning of one."
6720 (let ((lim (or lim
(point-min)))
6724 ;; go backwards one balanced expression, but be careful of
6725 ;; unbalanced paren being reached
6726 (if (not (vhdl-safe (progn (backward-sexp) t
)))
6728 (backward-up-list 1)
6730 (vhdl-forward-syntactic-ws here
)
6732 (while (and (not donep
)
6734 ;; look backwards for a statement boundary
6735 (progn (forward-char) (re-search-backward vhdl-b-o-s-re lim
'move
)))
6736 (if (or (= (preceding-char) ?_
)
6740 ;; If we are looking at an open paren, then stop after it
6741 ((eq (following-char) ?\
()
6743 (vhdl-forward-syntactic-ws here
)
6745 ;; If we are looking at a close paren, then skip it
6746 ((eq (following-char) ?\
))
6751 (progn (goto-char pos
)
6752 (vhdl-forward-syntactic-ws here
)
6754 ;; If we are looking at a semicolon, then stop
6755 ((and (eq (following-char) ?\
;) (not (vhdl-in-quote-p)))
6758 (vhdl-forward-syntactic-ws here
)
6760 ;; If we are looking at a "begin", then stop
6761 ((and (looking-at vhdl-begin-fwd-re
)
6762 (or (not (looking-at "\\<use\\>"))
6764 (back-to-indentation)
6765 (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
6766 (/= (preceding-char) ?_
)
6768 ;; If it's a leader "begin", then find the
6770 (if (looking-at vhdl-leader-re
)
6772 ;; set a default stop point at the begin
6774 ;; is the start point inside the leader area ?
6775 (goto-char (vhdl-end-of-leader))
6776 (vhdl-forward-syntactic-ws here
)
6777 (if (< (point) here
)
6778 ;; start point was not inside leader area
6779 ;; set stop point at word after leader
6780 (setq pos
(point))))
6781 (unless (looking-at "\\<else\\s-+generate\\>")
6782 (forward-word-strictly 1))
6783 (vhdl-forward-syntactic-ws here
)
6787 ;; If we are looking at a "statement", then stop
6788 ((and (looking-at vhdl-statement-fwd-re
)
6789 (/= (preceding-char) ?_
)
6790 (vhdl-statement-p nil
))
6792 ;; If we are looking at a case alternative key, then stop
6793 ((and (looking-at vhdl-case-alternative-re
)
6794 (vhdl-case-alternative-p lim
))
6796 ;; set a default stop point at the when
6798 ;; is the start point inside the case alternative key ?
6799 (looking-at vhdl-case-alternative-re
)
6800 (goto-char (match-end 0))
6801 (vhdl-forward-syntactic-ws here
)
6802 (if (< (point) here
)
6803 ;; start point was not inside the case alternative key
6804 ;; set stop point at word after case alternative keyleader
6805 (setq pos
(point))))
6808 ;; Bogus find, continue
6813 ;; Defuns for calculating the current syntactic state:
6815 (defun vhdl-get-library-unit (bod placeholder
)
6816 "If there is an enclosing library unit at BOD, with its \"begin\"
6817 keyword at PLACEHOLDER, then return the library unit type."
6818 (let ((here (vhdl-point 'bol
)))
6820 (goto-char placeholder
)
6821 (vhdl-safe (vhdl-forward-sexp 1 bod
))
6826 ((looking-at "e") 'entity
)
6827 ((looking-at "a") 'architecture
)
6828 ((looking-at "conf") 'configuration
)
6829 ((looking-at "cont") 'context
)
6834 (vhdl-forward-syntactic-ws here
)
6835 (if (looking-at "body\\b[^_]")
6836 'package-body
'package
))))))
6839 (defun vhdl-get-block-state (&optional lim
)
6840 "Finds and records all the closest opens.
6841 LIM is the furthest back we need to search (it should be the
6842 previous libunit keyword)."
6843 (let ((here (point))
6844 (lim (or lim
(point-min)))
6845 keyword sexp-start sexp-mid sexp-end
6846 preceding-sexp containing-sexp
6847 containing-begin containing-mid containing-paren
)
6849 ;; Find the containing-paren, and use that as the limit
6850 (if (setq containing-paren
6852 (narrow-to-region lim
(point))
6853 (vhdl-safe (scan-lists (point) -
1 1))))
6854 (setq lim containing-paren
))
6855 ;; Look backwards for "begin" and "end" keywords.
6856 (while (and (> (point) lim
)
6857 (not containing-sexp
))
6858 (setq keyword
(vhdl-backward-to-block lim
))
6860 ((eq keyword
'begin
)
6861 ;; Found a "begin" keyword
6862 (setq sexp-start
(point))
6863 (setq sexp-mid
(vhdl-corresponding-mid lim
))
6864 (setq sexp-end
(vhdl-safe
6866 (vhdl-forward-sexp 1 lim
) (point))))
6867 (if (and sexp-end
(<= sexp-end here
))
6868 ;; we want to record this sexp, but we only want to
6869 ;; record the last-most of any of them before here
6871 (setq preceding-sexp sexp-start
))
6872 ;; we're contained in this sexp so put sexp-start on
6874 (setq containing-sexp sexp-start
)
6875 (setq containing-mid sexp-mid
)
6876 (setq containing-begin t
)))
6878 ;; Found an "end" keyword
6880 (setq sexp-end
(point))
6883 (or (vhdl-safe (vhdl-backward-sexp 1 lim
) (point))
6884 (progn (backward-sexp) (point))))
6885 ;; we want to record this sexp, but we only want to
6886 ;; record the last-most of any of them before here
6888 (setq preceding-sexp sexp-start
)))
6890 ;; Check if the containing-paren should be the containing-sexp
6891 (if (and containing-paren
6892 (or (null containing-sexp
)
6893 (< containing-sexp containing-paren
)))
6894 (setq containing-sexp containing-paren
6896 containing-begin nil
6897 containing-mid nil
))
6898 (vector containing-sexp preceding-sexp containing-begin containing-mid
)
6902 (defconst vhdl-s-c-a-re
6903 (concat vhdl-case-alternative-re
"\\|" vhdl-case-header-key
))
6905 (defun vhdl-skip-case-alternative (&optional lim
)
6906 "Skip forward over case/when bodies, with optional maximal
6907 limit. If no next case alternative is found, nil is returned and
6908 point is not moved."
6909 (let ((lim (or lim
(point-max)))
6912 (while (and (< (point) lim
)
6914 (if (and (re-search-forward vhdl-s-c-a-re lim
'move
)
6916 (not (vhdl-in-literal)))
6917 (/= (match-beginning 0) here
))
6919 (goto-char (match-beginning 0))
6921 ((and (looking-at "case")
6922 (re-search-forward "\\bis[^_]" lim t
))
6924 (vhdl-forward-sexp))
6932 (defun vhdl-backward-skip-label (&optional lim
)
6933 "Skip backward over a label, with optional maximal
6934 limit. If label is not found, nil is returned and point
6936 (let ((lim (or lim
(point-min)))
6939 (vhdl-backward-syntactic-ws lim
)
6940 (and (eq (preceding-char) ?
:)
6943 (setq placeholder
(point))
6944 (looking-at vhdl-label-key
))))
6945 (goto-char placeholder
))
6948 (defun vhdl-forward-skip-label (&optional lim
)
6949 "Skip forward over a label, with optional maximal
6950 limit. If label is not found, nil is returned and point
6952 (let ((lim (or lim
(point-max))))
6953 (if (looking-at vhdl-label-key
)
6955 (goto-char (match-end 0))
6956 (vhdl-forward-syntactic-ws lim
)))
6959 (defun vhdl-get-syntactic-context ()
6960 "Guess the syntactic description of the current line of VHDL code."
6964 (let* ((indent-point (point))
6965 (case-fold-search t
)
6966 vec literal containing-sexp preceding-sexp
6967 containing-begin containing-mid containing-leader
6968 char-before-ip char-after-ip begin-after-ip end-after-ip
6969 placeholder lim library-unit
6972 ;; Reset the syntactic context
6973 (setq vhdl-syntactic-context nil
)
6976 ;; Move to the start of the previous library unit, and
6977 ;; record the position of the "begin" keyword.
6978 (setq placeholder
(vhdl-beginning-of-libunit))
6979 ;; The position of the "libunit" keyword gives us a gross
6984 ;; If there is a previous library unit, and we are enclosed by
6985 ;; it, then set the syntax accordingly.
6987 (setq library-unit
(vhdl-get-library-unit lim placeholder
))
6988 (vhdl-add-syntax library-unit lim
))
6990 ;; Find the surrounding state.
6991 (if (setq vec
(vhdl-get-block-state lim
))
6993 (setq containing-sexp
(aref vec
0))
6994 (setq preceding-sexp
(aref vec
1))
6995 (setq containing-begin
(aref vec
2))
6996 (setq containing-mid
(aref vec
3))
6999 ;; set the limit on the farthest back we need to search
7000 (setq lim
(if containing-sexp
7002 (goto-char containing-sexp
)
7003 ;; set containing-leader if required
7004 (if (looking-at vhdl-leader-re
)
7005 (setq containing-leader
(vhdl-end-of-leader)))
7009 ;; cache char before and after indent point, and move point to
7010 ;; the most likely position to perform the majority of tests
7011 (goto-char indent-point
)
7012 (skip-chars-forward " \t")
7013 (setq literal
(vhdl-in-literal))
7014 (setq char-after-ip
(following-char))
7015 (setq begin-after-ip
(and
7017 (looking-at vhdl-begin-fwd-re
)
7018 (or (not (looking-at "\\<use\\>"))
7020 (back-to-indentation)
7021 (looking-at "\\(\\w+\\s-*:\\s-*\\)?\\<\\(case\\|elsif\\|if\\)\\>")))
7023 (setq end-after-ip
(and
7025 (looking-at vhdl-end-fwd-re
)
7027 (vhdl-backward-syntactic-ws lim
)
7028 (setq char-before-ip
(preceding-char))
7029 (goto-char indent-point
)
7030 (skip-chars-forward " \t")
7032 ;; now figure out syntactic qualities of the current line
7034 ;; CASE 1: in a string or comment.
7035 ((memq literal
'(string comment
))
7036 (vhdl-add-syntax literal
(vhdl-point 'bopl
)))
7037 ;; CASE 2: Line is at top level.
7038 ((null containing-sexp
)
7039 ;; Find the point to which indentation will be relative
7041 (if (null preceding-sexp
)
7043 ;; no preceding-sexp -> use the preceding statement
7044 (vhdl-beginning-of-statement-1 lim
)
7046 ;; if there is a preceding-sexp then indent relative to it
7047 (goto-char preceding-sexp
)
7048 ;; if not at boi, then the block-opening keyword is
7049 ;; probably following a label, so we need a different
7051 (if (/= (point) (vhdl-point 'boi
))
7053 (vhdl-beginning-of-statement-1 lim
)))
7054 ;; v-b-o-s could have left us at point-min
7057 (vhdl-forward-syntactic-ws indent-point
))
7058 (setq placeholder
(point)))
7060 ;; CASE 2A : we are looking at a block-open
7062 (vhdl-add-syntax 'block-open placeholder
))
7063 ;; CASE 2B: we are looking at a block-close
7065 (vhdl-add-syntax 'block-close placeholder
))
7066 ;; CASE 2C: we are looking at a top-level statement
7068 (vhdl-backward-syntactic-ws lim
)
7070 (and (= (preceding-char) ?\
;)
7071 (not (vhdl-in-quote-p)))))
7072 (vhdl-add-syntax 'statement placeholder
))
7073 ;; CASE 2D: we are looking at a top-level statement-cont
7075 (vhdl-beginning-of-statement-1 lim
)
7076 ;; v-b-o-s could have left us at point-min
7079 (vhdl-forward-syntactic-ws indent-point
))
7080 (vhdl-add-syntax 'statement-cont
(point)))
7082 ;; CASE 3: line is inside parentheses. Most likely we are
7083 ;; either in a subprogram argument (interface) list, or a
7084 ;; continued expression containing parentheses.
7085 ((null containing-begin
)
7086 (vhdl-backward-syntactic-ws containing-sexp
)
7088 ;; CASE 3A: we are looking at the arglist closing paren
7089 ((eq char-after-ip ?\
))
7090 (goto-char containing-sexp
)
7091 (vhdl-add-syntax 'arglist-close
(vhdl-point 'boi
)))
7092 ;; CASE 3B: we are looking at the first argument in an empty
7094 ((eq char-before-ip ?\
()
7095 (goto-char containing-sexp
)
7096 (vhdl-add-syntax 'arglist-intro
(vhdl-point 'boi
)))
7097 ;; CASE 3C: we are looking at an arglist continuation line,
7098 ;; but the preceding argument is on the same line as the
7099 ;; opening paren. This case includes multi-line
7100 ;; expression paren groupings.
7101 ((and (save-excursion
7102 (goto-char (1+ containing-sexp
))
7103 (skip-chars-forward " \t")
7105 (not (looking-at "--\\|`")))
7107 (vhdl-beginning-of-statement-1 containing-sexp
)
7108 (skip-chars-backward " \t(")
7109 (while (and (= (preceding-char) ?\
;)
7110 (not (vhdl-in-quote-p)))
7111 (vhdl-beginning-of-statement-1 containing-sexp
)
7112 (skip-chars-backward " \t("))
7113 (<= (point) containing-sexp
)))
7114 (goto-char containing-sexp
)
7115 (vhdl-add-syntax 'arglist-cont-nonempty
(vhdl-point 'boi
)))
7116 ;; CASE 3D: we are looking at just a normal arglist
7117 ;; continuation line
7118 (t (vhdl-beginning-of-statement-1 containing-sexp
)
7119 (vhdl-forward-syntactic-ws indent-point
)
7120 (vhdl-add-syntax 'arglist-cont
(vhdl-point 'boi
)))
7122 ;; CASE 4: A block mid open
7123 ((and begin-after-ip
7124 (looking-at containing-mid
))
7125 (goto-char containing-sexp
)
7126 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
7127 (if (looking-at vhdl-trailer-re
)
7129 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil
)))
7130 (vhdl-backward-skip-label (vhdl-point 'boi
))
7131 (vhdl-add-syntax 'block-open
(point)))
7132 ;; CASE 5: block close brace
7134 (goto-char containing-sexp
)
7135 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
7136 (if (looking-at vhdl-trailer-re
)
7138 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil
)))
7139 (vhdl-backward-skip-label (vhdl-point 'boi
))
7140 (vhdl-add-syntax 'block-close
(point)))
7141 ;; CASE 6: A continued statement
7142 ((and (/= char-before-ip ?\
;)
7143 ;; check it's not a trailer begin keyword, or a begin
7144 ;; keyword immediately following a label.
7145 (not (and begin-after-ip
7146 (or (looking-at vhdl-trailer-re
)
7148 (vhdl-backward-skip-label containing-sexp
)))))
7149 ;; check it's not a statement keyword
7150 (not (and (looking-at vhdl-statement-fwd-re
)
7151 (vhdl-statement-p)))
7152 ;; see if the b-o-s is before the indent point
7155 (vhdl-beginning-of-statement-1 containing-sexp
)
7156 ;; If we ended up after a leader, then this will
7157 ;; move us forward to the start of the first
7158 ;; statement. Note that a containing sexp here is
7159 ;; always a keyword, not a paren, so this will
7160 ;; have no effect if we hit the containing-sexp.
7161 (vhdl-forward-syntactic-ws indent-point
)
7162 (setq placeholder
(point))))
7163 ;; check it's not a block-intro
7164 (/= placeholder containing-sexp
)
7165 ;; check it's not a case block-intro
7167 (goto-char placeholder
)
7168 (or (not (looking-at vhdl-case-alternative-re
))
7169 (> (match-end 0) indent-point
))))
7170 ;; Make placeholder skip a label, but only if it puts us
7171 ;; before the indent point at the start of a line.
7172 (let ((new placeholder
))
7173 (if (and (> indent-point
7175 (goto-char placeholder
)
7176 (vhdl-forward-skip-label indent-point
)
7177 (setq new
(point))))
7180 (eq new
(progn (back-to-indentation) (point)))))
7181 (setq placeholder new
)))
7182 (vhdl-add-syntax 'statement-cont placeholder
)
7184 (vhdl-add-syntax 'block-open
)))
7185 ;; Statement. But what kind?
7186 ;; CASE 7: A case alternative key
7187 ((and (looking-at vhdl-case-alternative-re
)
7188 (vhdl-case-alternative-p containing-sexp
))
7189 ;; for a case alternative key, we set relpos to the first
7190 ;; non-whitespace char on the line containing the "case"
7192 (goto-char containing-sexp
)
7193 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
7194 (if (looking-at vhdl-trailer-re
)
7195 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil
)))
7196 (vhdl-add-syntax 'case-alternative
(vhdl-point 'boi
)))
7197 ;; CASE 8: statement catchall
7199 ;; we know its a statement, but we need to find out if it is
7200 ;; the first statement in a block
7201 (if containing-leader
7202 (goto-char containing-leader
)
7203 (goto-char containing-sexp
)
7204 ;; Note that a containing sexp here is always a keyword,
7205 ;; not a paren, so skip over the keyword.
7207 ;; move to the start of the first statement
7208 (vhdl-forward-syntactic-ws indent-point
)
7209 (setq placeholder
(point))
7210 ;; we want to ignore case alternatives keys when skipping forward
7212 (while (looking-at vhdl-case-alternative-re
)
7213 (setq incase-p
(point))
7214 ;; we also want to skip over the body of the
7215 ;; case/when statement if that doesn't put us at
7216 ;; after the indent-point
7217 (while (vhdl-skip-case-alternative indent-point
))
7218 ;; set up the match end
7219 (looking-at vhdl-case-alternative-re
)
7220 (goto-char (match-end 0))
7221 ;; move to the start of the first case alternative statement
7222 (vhdl-forward-syntactic-ws indent-point
)
7223 (setq placeholder
(point)))
7225 ;; CASE 8A: we saw a case/when statement so we must be
7226 ;; in a switch statement. find out if we are at the
7227 ;; statement just after a case alternative key
7229 (= (point) indent-point
))
7230 ;; relpos is the "when" keyword
7231 (vhdl-add-syntax 'statement-case-intro incase-p
))
7232 ;; CASE 8B: any old statement
7233 ((< (point) indent-point
)
7234 ;; relpos is the first statement of the block
7235 (vhdl-add-syntax 'statement placeholder
)
7237 (vhdl-add-syntax 'block-open
)))
7238 ;; CASE 8C: first statement in a block
7240 (goto-char containing-sexp
)
7241 ;; If the \"begin\" keyword is a trailer, then find v-b-o-s
7242 (if (looking-at vhdl-trailer-re
)
7243 (progn (forward-sexp) (vhdl-beginning-of-statement-1 nil
)))
7244 (vhdl-backward-skip-label (vhdl-point 'boi
))
7245 (vhdl-add-syntax 'statement-block-intro
(point))
7247 (vhdl-add-syntax 'block-open
)))
7251 ;; now we need to look at any modifiers
7252 (goto-char indent-point
)
7253 (skip-chars-forward " \t")
7254 (if (or (looking-at "--") (looking-at "/\\*"))
7255 (vhdl-add-syntax 'comment
))
7256 (if (looking-at "`")
7257 (vhdl-add-syntax 'directive
))
7258 (if (eq literal
'pound
)
7259 (vhdl-add-syntax 'cpp-macro
))
7260 ;; return the syntax
7261 vhdl-syntactic-context
))))
7263 ;; Standard indentation line-ups:
7265 (defun vhdl-lineup-arglist (langelem)
7266 "Lineup the current arglist line with the arglist appearing just
7267 after the containing paren which starts the arglist."
7269 (let* ((containing-sexp
7271 ;; arglist-cont-nonempty gives relpos ==
7272 ;; to boi of containing-sexp paren. This
7273 ;; is good when offset is +, but bad
7274 ;; when it is vhdl-lineup-arglist, so we
7275 ;; have to special case a kludge here.
7276 (if (memq (car langelem
) '(arglist-intro arglist-cont-nonempty
))
7279 (backward-up-list 1)
7280 (skip-chars-forward " \t" (vhdl-point 'eol
)))
7281 (goto-char (cdr langelem
)))
7283 (cs-curcol (save-excursion
7284 (goto-char (cdr langelem
))
7288 (looking-at "[ \t]*)"))
7289 (progn (goto-char (match-end 0))
7292 (vhdl-forward-syntactic-ws)
7293 (- (current-column) cs-curcol
))
7294 (goto-char containing-sexp
)
7296 (let ((eol (vhdl-point 'eol
))
7299 (skip-chars-forward " \t")
7301 (vhdl-forward-syntactic-ws)
7304 (- (current-column) cs-curcol
)
7307 (defun vhdl-lineup-arglist-intro (langelem)
7308 "Lineup an arglist-intro line to just after the open paren."
7310 (let ((cs-curcol (save-excursion
7311 (goto-char (cdr langelem
))
7313 (ce-curcol (save-excursion
7315 (backward-up-list 1)
7316 (skip-chars-forward " \t" (vhdl-point 'eol
))
7318 (- ce-curcol cs-curcol -
1))))
7320 (defun vhdl-lineup-comment (langelem)
7321 "Support old behavior for comment indentation. We look at
7322 vhdl-comment-only-line-offset to decide how to indent comment
7325 (back-to-indentation)
7326 ;; at or to the right of comment-column
7327 (if (>= (current-column) comment-column
)
7328 (vhdl-comment-indent)
7329 ;; otherwise, indent as specified by vhdl-comment-only-line-offset
7331 ;; inside multi-line comment
7332 (if (looking-at "\\*")
7335 (or (car-safe vhdl-comment-only-line-offset
)
7336 vhdl-comment-only-line-offset
))
7337 (or (cdr-safe vhdl-comment-only-line-offset
)
7338 (car-safe vhdl-comment-only-line-offset
)
7339 -
1000 ;jam it against the left side
7342 (defun vhdl-lineup-statement-cont (langelem)
7343 "Line up statement-cont after the assignment operator."
7345 (let* ((relpos (cdr langelem
))
7346 (assignp (save-excursion
7347 (goto-char (vhdl-point 'boi
))
7348 (and (re-search-forward "\\(<\\|:\\|=\\)="
7349 (vhdl-point 'eol
) t
)
7350 (- (point) (vhdl-point 'boi
)))))
7355 (while (and (not foundp
)
7356 (< (point) (vhdl-point 'eol
)))
7357 (re-search-forward "\\(<\\|:\\|=\\)=\\|(" (vhdl-point 'eol
) 'move
)
7358 (if (vhdl-in-literal)
7360 (if (= (preceding-char) ?\
()
7361 ;; skip over any parenthesized expressions
7362 (goto-char (min (vhdl-point 'eol
)
7363 (scan-lists (point) 1 1)))
7364 ;; found an assignment operator (not at eol)
7365 (setq foundp
(not (looking-at "\\s-*$"))))))
7367 ;; there's no assignment operator on the line
7369 ;; calculate indentation column after assign and ws, unless
7370 ;; our line contains an assignment operator
7374 (skip-chars-forward " \t")
7376 (- (current-column) assignp curcol
))
7379 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7380 ;; Progress reporting
7382 (defvar vhdl-progress-info nil
7383 "Array variable for progress information: 0 begin, 1 end, 2 time.")
7385 (defun vhdl-update-progress-info (string pos
)
7386 "Update progress information."
7387 (when (and vhdl-progress-info
(not noninteractive
)
7388 (< vhdl-progress-interval
7389 (- (nth 1 (current-time)) (aref vhdl-progress-info
2))))
7390 (let ((delta (- (aref vhdl-progress-info
1)
7391 (aref vhdl-progress-info
0))))
7392 (message "%s... (%2d%%)" string
7395 (floor (* 100.0 (- pos
(aref vhdl-progress-info
0)))
7397 (aset vhdl-progress-info
2 (nth 1 (current-time)))))
7399 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7400 ;; Indentation commands
7402 (defun vhdl-electric-tab (&optional prefix-arg
)
7403 "If preceding character is part of a word or a paren then hippie-expand,
7404 else if right of non whitespace on line then insert tab,
7405 else if last command was a tab or return then dedent one step or if a comment
7406 toggle between normal indent and inline comment indent,
7407 else indent `correctly'."
7409 (vhdl-prepare-search-2
7411 ;; indent region if region is active
7412 ((and (not (featurep 'xemacs
)) (use-region-p))
7413 (vhdl-indent-region (region-beginning) (region-end) nil
))
7415 ((= (char-syntax (preceding-char)) ?w
)
7416 (let ((case-fold-search (not vhdl-word-completion-case-sensitive
))
7418 (hippie-expand-only-buffers
7419 (or (and (boundp 'hippie-expand-only-buffers
)
7420 hippie-expand-only-buffers
)
7422 (vhdl-expand-abbrev prefix-arg
)))
7423 ;; expand parenthesis
7424 ((or (= (preceding-char) ?\
() (= (preceding-char) ?\
)))
7425 (let ((case-fold-search (not vhdl-word-completion-case-sensitive
))
7427 (vhdl-expand-paren prefix-arg
)))
7429 ((> (current-column) (current-indentation))
7431 ;; toggle comment indent
7432 ((and (looking-at "--")
7433 (or (eq last-command
'vhdl-electric-tab
)
7434 (eq last-command
'vhdl-electric-return
)))
7435 (cond ((= (current-indentation) 0) ; no indent
7437 (indent-according-to-mode))
7438 ((< (current-indentation) comment-column
) ; normal indent
7439 (indent-to comment-column
)
7440 (indent-according-to-mode))
7441 (t ; inline comment indent
7442 (delete-region (line-beginning-position) (point)))))
7444 ((and (>= (current-indentation) vhdl-basic-offset
)
7445 (or (eq last-command
'vhdl-electric-tab
)
7446 (eq last-command
'vhdl-electric-return
)))
7447 (backward-delete-char-untabify vhdl-basic-offset nil
))
7449 (t (indent-according-to-mode)))
7450 (setq this-command
'vhdl-electric-tab
)))
7452 (defun vhdl-electric-return ()
7453 "newline-and-indent or indent-new-comment-line if in comment and preceding
7454 character is a space."
7456 (if (and (= (preceding-char) ?
) (vhdl-in-comment-p))
7457 (indent-new-comment-line)
7458 (when (and (>= (preceding-char) ?a
) (<= (preceding-char) ?z
)
7459 (not (vhdl-in-comment-p)))
7460 (vhdl-fix-case-word -
1))
7461 (newline-and-indent)))
7463 (defun vhdl-indent-line ()
7464 "Indent the current line as VHDL code. Returns the amount of
7465 indentation change."
7467 (let* ((syntax (and vhdl-indent-syntax-based
(vhdl-get-syntactic-context)))
7468 (pos (- (point-max) (point)))
7472 ;; indent syntax-based
7473 (if (and (eq (caar syntax
) 'comment
)
7474 (>= (vhdl-get-offset (car syntax
)) comment-column
))
7475 ;; special case: comments at or right of comment-column
7476 (vhdl-get-offset (car syntax
))
7477 ;; align comments like following code line
7478 (when vhdl-indent-comment-like-next-code-line
7480 (while (eq (caar syntax
) 'comment
)
7482 (beginning-of-line 2)
7483 (setq syntax
(vhdl-get-syntactic-context)))))
7485 (push (cons 'comment nil
) syntax
))
7486 (apply '+ (mapcar 'vhdl-get-offset syntax
)))
7487 ;; indent like previous nonblank line
7488 (save-excursion (beginning-of-line)
7489 (re-search-backward "^[^\n]" nil t
)
7490 (current-indentation))))
7491 (shift-amt (- indent
(current-indentation))))
7492 (and vhdl-echo-syntactic-information-p
7493 (message "syntax: %s, indent= %d" syntax indent
))
7495 (save-excursion (beginning-of-line) (looking-at "\\s-*\f"))))
7496 (when (or (not (zerop shift-amt
)) has-formfeed
)
7497 (delete-region (vhdl-point 'bol
) (vhdl-point 'boi
))
7499 (when has-formfeed
(insert "\f"))
7500 (indent-to indent
)))
7501 (if (< (point) (vhdl-point 'boi
))
7502 (back-to-indentation)
7503 ;; If initial point was within line's indentation, position after
7504 ;; the indentation. Else stay at same point in text.
7505 (when (> (- (point-max) pos
) (point))
7506 (goto-char (- (point-max) pos
))))
7507 (run-hooks 'vhdl-special-indent-hook
)
7508 (vhdl-update-progress-info "Indenting" (vhdl-current-line))
7511 (defun vhdl-indent-region (beg end
&optional column
)
7512 "Indent region as VHDL code.
7513 Adds progress reporting to `indent-region'."
7514 (interactive "r\nP")
7515 (when vhdl-progress-interval
7516 (setq vhdl-progress-info
(vector (count-lines (point-min) beg
)
7517 (count-lines (point-min) end
) 0)))
7518 (indent-region beg end column
)
7519 (when vhdl-progress-interval
(message "Indenting...done"))
7520 (setq vhdl-progress-info nil
))
7522 (defun vhdl-indent-buffer ()
7523 "Indent whole buffer as VHDL code.
7524 Calls `indent-region' for whole buffer and adds progress reporting."
7526 (vhdl-indent-region (point-min) (point-max)))
7528 (defun vhdl-indent-group ()
7529 "Indent group of lines between empty lines."
7531 (let ((beg (save-excursion
7532 (if (re-search-backward vhdl-align-group-separate nil t
)
7534 (point-min-marker))))
7535 (end (save-excursion
7536 (if (re-search-forward vhdl-align-group-separate nil t
)
7538 (point-max-marker)))))
7539 (vhdl-indent-region beg end
)))
7541 (defun vhdl-indent-sexp (&optional endpos
)
7542 "Indent each line of the list starting just after point.
7543 If optional arg ENDPOS is given, indent each line, stopping when
7544 ENDPOS is encountered."
7548 (end (progn (vhdl-forward-sexp nil endpos
) (point))))
7549 (indent-region beg end nil
))))
7551 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7552 ;; Miscellaneous commands
7554 (defun vhdl-show-syntactic-information ()
7555 "Show syntactic information for current line."
7557 (message "Syntactic analysis: %s" (vhdl-get-syntactic-context))
7558 (vhdl-keep-region-active))
7560 ;; Verification and regression functions:
7562 (defun vhdl-regress-line (&optional arg
)
7563 "Check syntactic information for current line."
7565 (let ((expected (save-excursion
7567 (when (search-backward " -- ((" (vhdl-point 'bol
) t
)
7569 (read (current-buffer)))))
7570 (actual (vhdl-get-syntactic-context))
7572 ;; remove the library unit symbols
7576 (if (memq (car elt
) '(entity configuration context package
7577 package-body architecture
))
7579 (setq expurgated
(append expurgated
(list elt
))))))
7581 (if (and (not arg
) expected
(listp expected
))
7582 (if (not (equal expected expurgated
))
7583 (error "ERROR: Should be: %s, is: %s" expected expurgated
))
7586 (when (not (looking-at "^\\s-*\\(--.*\\)?$"))
7588 (if (search-backward " -- ((" (vhdl-point 'bol
) t
)
7589 (delete-region (point) (line-end-position)))
7591 (insert (format "%s" expurgated
))))))
7592 (vhdl-keep-region-active))
7595 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7596 ;;; Alignment, beautifying
7597 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7599 (defconst vhdl-align-alist
7601 ;; after some keywords
7602 (vhdl-mode "^\\s-*\\(across\\|constant\\|quantity\\|signal\\|subtype\\|terminal\\|through\\|type\\|variable\\)[ \t]"
7603 "^\\s-*\\(across\\|constant\\|quantity\\|signal\\|subtype\\|terminal\\|through\\|type\\|variable\\)\\([ \t]+\\)" 2)
7605 (vhdl-mode ":[^=]" "\\([ \t]*\\):[^=]")
7606 ;; after direction specifications
7607 (vhdl-mode ":[ \t]*\\(in\\|out\\|inout\\|buffer\\|\\)\\>"
7608 ":[ \t]*\\(in\\|out\\|inout\\|buffer\\|\\)\\([ \t]+\\)" 2)
7609 ;; before "==", ":=", "=>", and "<="
7610 (vhdl-mode "[<:=]=" "\\([ \t]*\\)\\??[<:=]=" 1) ; since "<= ... =>" can occur
7611 (vhdl-mode "=>" "\\([ \t]*\\)=>" 1)
7612 (vhdl-mode "[<:=]=" "\\([ \t]*\\)\\??[<:=]=" 1) ; since "=> ... <=" can occur
7613 ;; before some keywords
7614 (vhdl-mode "[ \t]after\\>" "[^ \t]\\([ \t]+\\)after\\>" 1)
7615 (vhdl-mode "[ \t]when\\>" "[^ \t]\\([ \t]+\\)when\\>" 1)
7616 (vhdl-mode "[ \t]else\\>" "[^ \t]\\([ \t]+\\)else\\>" 1)
7617 (vhdl-mode "[ \t]across\\>" "[^ \t]\\([ \t]+\\)across\\>" 1)
7618 (vhdl-mode "[ \t]through\\>" "[^ \t]\\([ \t]+\\)through\\>" 1)
7619 ;; before "=>" since "when/else ... =>" can occur
7620 (vhdl-mode "=>" "\\([ \t]*\\)=>" 1)
7622 "The format of this alist is (MODES [or MODE] REGEXP ALIGN-PATTERN SUBEXP).
7623 It is searched in order. If REGEXP is found anywhere in the first
7624 line of a region to be aligned, ALIGN-PATTERN will be used for that
7625 region. ALIGN-PATTERN must include the whitespace to be expanded or
7626 contracted. It may also provide regexps for the text surrounding the
7627 whitespace. SUBEXP specifies which sub-expression of
7628 ALIGN-PATTERN matches the white space to be expanded/contracted.")
7630 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7633 (defvar vhdl-align-try-all-clauses t
7634 "If REGEXP is not found on the first line of the region that clause
7635 is ignored. If this variable is non-nil, then the clause is tried anyway.")
7637 (defun vhdl-do-group (function &optional spacing
)
7638 "Apply FUNCTION on group of lines between empty lines."
7640 ;; search for group beginning
7641 ((beg (save-excursion
7642 (if (re-search-backward vhdl-align-group-separate nil t
)
7643 (progn (beginning-of-line 2) (back-to-indentation) (point))
7645 ;; search for group end
7646 (end (save-excursion
7647 (if (re-search-forward vhdl-align-group-separate nil t
)
7648 (progn (beginning-of-line) (point))
7651 (funcall function beg end spacing
)))
7653 (defun vhdl-do-list (function &optional spacing
)
7654 "Apply FUNCTION to the lines of a list surrounded by a balanced group of
7658 ;; search for beginning of balanced group of parentheses
7659 (setq beg
(vhdl-re-search-backward "[()]" nil t
))
7660 (while (looking-at ")")
7661 (forward-char) (backward-sexp)
7662 (setq beg
(vhdl-re-search-backward "[()]" nil t
)))
7663 ;; search for end of balanced group of parentheses
7667 (goto-char (1+ beg
))
7668 (skip-chars-forward " \t\n\r\f")
7669 (setq beg
(point))))
7672 (funcall function beg end spacing
)
7673 (error "ERROR: Not within a list enclosed by a pair of parentheses"))))
7675 (defun vhdl-do-same-indent (function &optional spacing
)
7676 "Apply FUNCTION to block of lines with same indent."
7677 (let ((indent (current-indentation))
7679 ;; search for first line with same indent
7681 (while (and (not (bobp))
7682 (or (looking-at "^\\s-*\\(--.*\\)?$")
7683 (= (current-indentation) indent
)))
7684 (unless (looking-at "^\\s-*$")
7685 (back-to-indentation) (setq beg
(point)))
7686 (beginning-of-line -
0)))
7687 ;; search for last line with same indent
7689 (while (and (not (eobp))
7690 (or (looking-at "^\\s-*\\(--.*\\)?$")
7691 (= (current-indentation) indent
)))
7692 (if (looking-at "^\\s-*$")
7693 (beginning-of-line 2)
7694 (beginning-of-line 2)
7695 (setq end
(point)))))
7697 (funcall function beg end spacing
)))
7699 (defun vhdl-align-region-1 (begin end
&optional spacing alignment-list indent
)
7700 "Attempt to align a range of lines based on the content of the
7701 lines. The definition of `alignment-list' determines the matching
7702 order and the manner in which the lines are aligned. If ALIGNMENT-LIST
7703 is not specified `vhdl-align-alist' is used. If INDENT is non-nil,
7704 indentation is done before aligning."
7705 (interactive "r\np")
7706 (setq alignment-list
(or alignment-list vhdl-align-alist
))
7707 (setq spacing
(or spacing
1))
7711 (setq end
(point-marker))
7713 (setq bol
(setq begin
(progn (beginning-of-line) (point))))
7715 (indent-region bol end nil
))))
7716 (let ((copy (copy-alist alignment-list
)))
7717 (vhdl-prepare-search-2
7722 (eol (point-at-eol)))
7723 (setq element
(nth 0 copy
))
7724 (when (and (or (and (listp (car element
))
7725 (memq major-mode
(car element
)))
7726 (eq major-mode
(car element
)))
7727 (or vhdl-align-try-all-clauses
7728 (re-search-forward (car (cdr element
)) eol t
)))
7729 (vhdl-align-region-2 begin end
(car (cdr (cdr element
)))
7730 (car (cdr (cdr (cdr element
)))) spacing
))
7731 (setq copy
(cdr copy
))))))))
7733 (defun vhdl-align-region-2 (begin end match
&optional substr spacing
)
7734 "Align a range of lines from BEGIN to END. The regular expression
7735 MATCH must match exactly one field: the whitespace to be
7736 contracted/expanded. The alignment column will equal the
7737 rightmost column of the widest whitespace block. SPACING is
7738 the amount of extra spaces to add to the calculated maximum required.
7739 SPACING defaults to 1 so that at least one space is inserted after
7740 the token in MATCH."
7741 (setq spacing
(or spacing
1))
7742 (setq substr
(or substr
1))
7744 (let (distance (max 0) (lines 0) bol eol width
)
7745 ;; Determine the greatest whitespace distance to the alignment
7748 (setq eol
(point-at-eol)
7749 bol
(setq begin
(progn (beginning-of-line) (point))))
7752 (when (and (vhdl-re-search-forward match eol t
)
7754 (goto-char (match-beginning 0))
7756 (and (not (vhdl-in-literal))
7757 (not (vhdl-in-quote-p))
7758 (not (vhdl-in-extended-identifier-p))))
7759 (not (looking-at "\\s-*$")))
7760 (setq distance
(- (match-beginning substr
) bol
))
7761 (when (> distance max
)
7762 (setq max distance
))))
7766 (setq lines
(1+ lines
)))
7767 ;; Now insert enough maxs to push each assignment operator to
7768 ;; the same column. We need to use 'lines' as a counter, since
7769 ;; the location of the mark may change
7770 (goto-char (setq bol begin
))
7771 (setq eol
(point-at-eol))
7773 (when (and (vhdl-re-search-forward match eol t
)
7775 (goto-char (match-beginning 0))
7777 (and (not (vhdl-in-literal))
7778 (not (vhdl-in-quote-p))
7779 (not (vhdl-in-extended-identifier-p))))
7780 (not (looking-at "\\s-*$"))
7781 (> (match-beginning 0) ; not if at boi
7782 (save-excursion (back-to-indentation) (point))))
7783 (setq width
(- (match-end substr
) (match-beginning substr
)))
7784 (setq distance
(- (match-beginning substr
) bol
))
7785 (goto-char (match-beginning substr
))
7787 (insert-char ?
(+ (- max distance
) spacing
)))
7792 (setq lines
(1- lines
))))))
7794 (defun vhdl-align-region-groups (beg end
&optional spacing
7795 no-message no-comments
)
7796 "Align region, treat groups of lines separately."
7797 (interactive "r\nP")
7802 (setq orig
(point-marker))
7805 (setq end
(point-marker))
7808 (when vhdl-progress-interval
7809 (setq vhdl-progress-info
(vector (count-lines (point-min) beg
)
7810 (count-lines (point-min) end
) 0))))
7811 (when (nth 0 vhdl-beautify-options
)
7812 (vhdl-fixup-whitespace-region beg end t
))
7814 (if (not vhdl-align-groups
)
7815 ;; align entire region
7816 (progn (vhdl-align-region-1 beg end spacing
)
7818 (vhdl-align-inline-comment-region-1 beg end
)))
7820 (while (and (< beg end
)
7821 (re-search-forward vhdl-align-group-separate end t
))
7822 (setq pos
(point-marker))
7823 (vhdl-align-region-1 beg pos spacing
)
7824 (unless no-comments
(vhdl-align-inline-comment-region-1 beg pos
))
7825 (vhdl-update-progress-info "Aligning" (vhdl-current-line))
7830 (vhdl-align-region-1 beg end spacing
)
7831 (unless no-comments
(vhdl-align-inline-comment-region-1 beg end
))
7832 (vhdl-update-progress-info "Aligning" (vhdl-current-line))))
7833 (when vhdl-indent-tabs-mode
7836 (when vhdl-progress-interval
(message "Aligning...done"))
7837 (setq vhdl-progress-info nil
)))))
7839 (defun vhdl-align-region (beg end
&optional spacing
)
7840 "Align region, treat blocks with same indent and argument lists separately."
7841 (interactive "r\nP")
7842 (if (not vhdl-align-same-indent
)
7843 ;; align entire region
7844 (vhdl-align-region-groups beg end spacing
)
7845 ;; align blocks with same indent and argument lists
7849 (when vhdl-progress-interval
7850 (setq vhdl-progress-info
(vector (count-lines (point-min) beg
)
7851 (count-lines (point-min) end
) 0)))
7853 (setq end
(point-marker))
7855 (while (< (point) end
)
7856 ;; is argument list opening?
7857 (if (setq cur-beg
(nth 1 (save-excursion (parse-partial-sexp
7858 (point) (vhdl-point 'eol
)))))
7859 ;; determine region for argument list
7860 (progn (goto-char cur-beg
)
7862 (setq cur-end
(point))
7863 (beginning-of-line 2))
7864 ;; determine region with same indent
7865 (setq indent
(current-indentation))
7866 (setq cur-beg
(point))
7867 (setq cur-end
(vhdl-point 'bonl
))
7868 (beginning-of-line 2)
7869 (while (and (< (point) end
)
7870 (or (looking-at "^\\s-*\\(--.*\\)?$")
7871 (= (current-indentation) indent
))
7873 (nth 0 (parse-partial-sexp
7874 (point) (vhdl-point 'eol
)))) 0))
7875 (unless (looking-at "^\\s-*$")
7876 (setq cur-end
(vhdl-point 'bonl
)))
7877 (beginning-of-line 2)))
7879 (vhdl-align-region-groups cur-beg cur-end spacing t t
))
7880 (vhdl-align-inline-comment-region beg end spacing noninteractive
)
7881 (when vhdl-progress-interval
(message "Aligning...done"))
7882 (setq vhdl-progress-info nil
)))))
7884 (defun vhdl-align-group (&optional spacing
)
7885 "Align group of lines between empty lines."
7887 (vhdl-do-group 'vhdl-align-region spacing
))
7889 (defun vhdl-align-list (&optional spacing
)
7890 "Align the lines of a list surrounded by a balanced group of parentheses."
7892 (vhdl-do-list 'vhdl-align-region-groups spacing
))
7894 (defun vhdl-align-same-indent (&optional spacing
)
7895 "Align block of lines with same indent."
7897 (vhdl-do-same-indent 'vhdl-align-region-groups spacing
))
7899 (defun vhdl-align-declarations (&optional spacing
)
7900 "Align the lines within the declarative part of a design unit."
7903 (vhdl-prepare-search-2
7905 ;; search for declarative part
7906 (when (and (re-search-backward "^\\(architecture\\|begin\\|configuration\\|context\\|end\\|entity\\|package\\)\\>" nil t
)
7907 (not (member (upcase (match-string 1)) '("BEGIN" "END"))))
7909 (re-search-forward "^\\(begin\\|end\\)\\>" nil t
)
7910 (setq end
(point)))))
7912 (vhdl-align-region-groups beg end spacing
)
7913 (error "ERROR: Not within the declarative part of a design unit"))))
7915 (defun vhdl-align-buffer ()
7918 (vhdl-align-region (point-min) (point-max)))
7920 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7921 ;; Align inline comments
7923 (defun vhdl-align-inline-comment-region-1 (beg end
&optional spacing
)
7924 "Align inline comments in region."
7926 (let ((start-max comment-column
)
7928 comment-list start-list tmp-list start length
7929 cur-start prev-start no-code
)
7930 (setq spacing
(or spacing
2))
7931 (vhdl-prepare-search-2
7933 ;; search for comment start positions and lengths
7934 (while (< (point) end
)
7935 (when (and (not (looking-at "^\\s-*\\(begin\\|end\\)\\>"))
7936 (looking-at "^\\(.*?[^ \t\n\r\f-]+\\)\\s-*\\(--.*\\)$")
7937 (not (save-excursion (goto-char (match-beginning 2))
7938 (vhdl-in-literal))))
7939 (setq start
(+ (- (match-end 1) (match-beginning 1)) spacing
))
7940 (setq length
(- (match-end 2) (match-beginning 2)))
7941 (setq start-max
(max start start-max
))
7942 (setq length-max
(max length length-max
))
7943 (push (cons start length
) comment-list
))
7944 (beginning-of-line 2))
7946 (sort comment-list
(function (lambda (a b
) (> (car a
) (car b
))))))
7947 ;; reduce start positions
7948 (setq start-list
(list (caar comment-list
)))
7949 (setq comment-list
(cdr comment-list
))
7951 (unless (or (= (caar comment-list
) (car start-list
))
7952 (<= (+ (car start-list
) (cdar comment-list
))
7953 end-comment-column
))
7954 (push (caar comment-list
) start-list
))
7955 (setq comment-list
(cdr comment-list
)))
7956 ;; align lines as nicely as possible
7958 (while (< (point) end
)
7959 (setq cur-start nil
)
7960 (when (and (not (looking-at "^\\s-*\\(begin\\|end\\)\\>"))
7961 (or (and (looking-at "^\\(.*?[^ \t\n\r\f-]+\\)\\(\\s-*\\)\\(--.*\\)$")
7962 (not (save-excursion
7963 (goto-char (match-beginning 3))
7964 (vhdl-in-literal))))
7965 (and (looking-at "^\\(\\)\\(\\s-*\\)\\(--.*\\)$")
7966 (>= (- (match-end 2) (match-beginning 2))
7968 (setq start
(+ (- (match-end 1) (match-beginning 1)) spacing
))
7969 (setq length
(- (match-end 3) (match-beginning 3)))
7970 (setq no-code
(= (match-beginning 1) (match-end 1)))
7971 ;; insert minimum whitespace
7972 (goto-char (match-end 2))
7973 (delete-region (match-beginning 2) (match-end 2))
7974 (insert-char ?\ spacing
)
7975 (setq tmp-list start-list
)
7976 ;; insert additional whitespace to align
7979 ;; align comment-only line to inline comment of previous line
7980 ((and no-code prev-start
7981 (<= length
(- end-comment-column prev-start
)))
7983 ;; align all comments at `start-max' if this is possible
7984 ((<= (+ start-max length-max
) end-comment-column
)
7986 ;; align at `comment-column' if possible
7987 ((and (<= start comment-column
)
7988 (<= length
(- end-comment-column comment-column
)))
7990 ;; align at left-most possible start position otherwise
7992 (while (and tmp-list
(< (car tmp-list
) start
))
7993 (setq tmp-list
(cdr tmp-list
)))
7995 (indent-to cur-start
))
7996 (setq prev-start cur-start
)
7997 (beginning-of-line 2))))))
7999 (defun vhdl-align-inline-comment-region (beg end
&optional spacing no-message
)
8000 "Align inline comments within a region. Groups of code lines separated by
8001 empty lines are aligned individually, if `vhdl-align-groups' is non-nil."
8002 (interactive "r\nP")
8007 (setq orig
(point-marker))
8010 (setq end
(point-marker))
8012 (unless no-message
(message "Aligning inline comments..."))
8014 (if (not vhdl-align-groups
)
8015 ;; align entire region
8016 (vhdl-align-inline-comment-region-1 beg end spacing
)
8018 (while (and (< beg end
)
8019 (re-search-forward vhdl-align-group-separate end t
))
8020 (setq pos
(point-marker))
8021 (vhdl-align-inline-comment-region-1 beg pos spacing
)
8026 (vhdl-align-inline-comment-region-1 beg end spacing
)))
8027 (when vhdl-indent-tabs-mode
8029 (unless no-message
(message "Aligning inline comments...done")))))
8031 (defun vhdl-align-inline-comment-group (&optional spacing
)
8032 "Align inline comments within a group of lines between empty lines."
8035 (let ((start (point))
8037 (setq end
(if (re-search-forward vhdl-align-group-separate nil t
)
8038 (point-marker) (point-max)))
8040 (setq beg
(if (re-search-backward vhdl-align-group-separate nil t
)
8041 (point) (point-min)))
8043 (message "Aligning inline comments...")
8044 (vhdl-align-inline-comment-region-1 beg end
)
8045 (when vhdl-indent-tabs-mode
8047 (message "Aligning inline comments...done"))))
8049 (defun vhdl-align-inline-comment-buffer ()
8050 "Align inline comments within buffer. Groups of code lines separated by
8051 empty lines are aligned individually, if `vhdl-align-groups' is non-nil."
8053 (vhdl-align-inline-comment-region (point-min) (point-max)))
8055 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8058 (defun vhdl-fixup-whitespace-region (beg end
&optional no-message
)
8059 "Fixup whitespace in region. Surround operator symbols by one space,
8060 eliminate multiple spaces (except at beginning of line), eliminate spaces at
8061 end of line, do nothing in comments and strings."
8063 (unless no-message
(message "Fixing up whitespace..."))
8066 (setq end
(point-marker))
8067 ;; have no space before and one space after `,' and ';'
8069 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|'.'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\(\\s-*\\([,;]\\)\\)" end t
)
8070 (if (match-string 1)
8071 (goto-char (match-end 1))
8072 (replace-match "\\3 " nil nil nil
2)))
8073 ;; have no space after `('
8075 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|'.'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\((\\)\\s-+" end t
)
8076 (if (match-string 1)
8077 (goto-char (match-end 1))
8078 (replace-match "\\2")))
8079 ;; have no space before `)'
8081 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|'.'\\|\\\\[^\\\n]*[\\\n]\\|^\\s-+\\)\\|\\s-+\\()\\)" end t
)
8082 (if (match-string 1)
8083 (goto-char (match-end 1))
8084 (replace-match "\\2")))
8085 ;; surround operator symbols by one space
8087 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\|'.'\\|\\\\[^\\\n]*[\\\n]\\)\\|\\(\\([^/:<>=\n]\\)\\(:\\|\\??=\\|\\??<<\\|\\??>>\\|\\??<\\|\\??>\\|:=\\|\\??<=\\|\\??>=\\|=>\\|\\??/=\\|\\?\\?\\)\\([^=>\n]\\|$\\)\\)" end t
)
8088 (if (or (match-string 1)
8089 (<= (match-beginning 0) ; not if at boi
8090 (save-excursion (back-to-indentation) (point))))
8091 (goto-char (match-end 0))
8092 (replace-match "\\3 \\4 \\5")
8093 (goto-char (match-end 2))))
8094 ;; eliminate multiple spaces and spaces at end of line
8096 (while (or (and (looking-at "--.*\n") (re-search-forward "--.*\n" end t
))
8097 (and (looking-at "--.*") (re-search-forward "--.*" end t
))
8098 (and (looking-at "\"") (re-search-forward "\"[^\"\n]*[\"\n]" end t
))
8099 (and (looking-at "\\s-+$") (re-search-forward "\\s-+$" end t
)
8100 (progn (replace-match "" nil nil
) t
))
8101 (and (looking-at "\\s-+;") (re-search-forward "\\s-+;" end t
)
8102 (progn (replace-match ";" nil nil
) t
))
8103 (and (looking-at "^\\s-+") (re-search-forward "^\\s-+" end t
))
8104 (and (looking-at "\\s-+--") (re-search-forward "\\s-+" end t
)
8105 (progn (replace-match " " nil nil
) t
))
8106 (and (looking-at "\\s-+") (re-search-forward "\\s-+" end t
)
8107 (progn (replace-match " " nil nil
) t
))
8108 (and (looking-at "-") (re-search-forward "-" end t
))
8109 (re-search-forward "[^ \t\"-]+" end t
))))
8110 (unless no-message
(message "Fixing up whitespace...done")))
8112 (defun vhdl-fixup-whitespace-buffer ()
8113 "Fixup whitespace in buffer. Surround operator symbols by one space,
8114 eliminate multiple spaces (except at beginning of line), eliminate spaces at
8115 end of line, do nothing in comments."
8117 (vhdl-fixup-whitespace-region (point-min) (point-max)))
8119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8122 (defun vhdl-fix-case-region-1 (beg end upper-case word-regexp
&optional count
)
8123 "Convert all words matching WORD-REGEXP in region to lower or upper case,
8124 depending on parameter UPPER-CASE."
8125 (let ((case-replace nil
)
8127 (vhdl-prepare-search-2
8130 (setq end
(point-marker))
8132 (while (re-search-forward word-regexp end t
)
8133 (or (vhdl-in-literal)
8136 (downcase-word -
1)))
8137 (when (and count vhdl-progress-interval
(not noninteractive
)
8138 (< vhdl-progress-interval
8139 (- (nth 1 (current-time)) last-update
)))
8140 (message "Fixing case... (%2d%s)"
8141 (+ (* count
20) (/ (* 20 (- (point) beg
)) (- end beg
)))
8143 (setq last-update
(nth 1 (current-time)))))
8146 (defun vhdl-fix-case-region (beg end
&optional arg
)
8147 "Convert all VHDL words in region to lower or upper case, depending on
8148 options vhdl-upper-case-{keywords,types,attributes,enum-values}."
8149 (interactive "r\nP")
8150 (vhdl-fix-case-region-1
8151 beg end vhdl-upper-case-keywords vhdl-keywords-regexp
0)
8152 (vhdl-fix-case-region-1
8153 beg end vhdl-upper-case-types vhdl-types-regexp
1)
8154 (vhdl-fix-case-region-1
8155 beg end vhdl-upper-case-attributes
(concat "'" vhdl-attributes-regexp
) 2)
8156 (vhdl-fix-case-region-1
8157 beg end vhdl-upper-case-enum-values vhdl-enum-values-regexp
3)
8158 (vhdl-fix-case-region-1
8159 beg end vhdl-upper-case-constants vhdl-constants-regexp
4)
8160 (when vhdl-progress-interval
(message "Fixing case...done")))
8162 (defun vhdl-fix-case-buffer ()
8163 "Convert all VHDL words in buffer to lower or upper case, depending on
8164 options vhdl-upper-case-{keywords,types,attributes,enum-values}."
8166 (vhdl-fix-case-region (point-min) (point-max)))
8168 (defun vhdl-fix-case-word (&optional arg
)
8169 "Convert word after cursor to upper case if necessary."
8172 (when arg
(backward-word 1))
8173 (vhdl-prepare-search-1
8174 (when (and vhdl-upper-case-keywords
8175 (looking-at vhdl-keywords-regexp
))
8177 (when (and vhdl-upper-case-types
8178 (looking-at vhdl-types-regexp
))
8180 (when (and vhdl-upper-case-attributes
8181 (looking-at vhdl-attributes-regexp
))
8183 (when (and vhdl-upper-case-enum-values
8184 (looking-at vhdl-enum-values-regexp
))
8186 (when (and vhdl-upper-case-constants
8187 (looking-at vhdl-constants-regexp
))
8190 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8192 ;; - force each statement to be on a separate line except when on same line
8193 ;; with 'end' keyword
8195 (defun vhdl-fix-statement-region (beg end
&optional arg
)
8196 "Force statements in region on separate line except when on same line
8197 with `end' keyword (necessary for correct indentation).
8198 Currently supported keywords: `begin', `if'."
8199 (interactive "r\nP")
8200 (vhdl-prepare-search-2
8204 (setq end
(point-marker))
8207 (while (re-search-forward
8208 "^\\s-*[^ \t\n].*?\\(\\<begin\\>\\)\\(.*\\<end\\>\\)?" end t
)
8209 (goto-char (match-end 0))
8210 (setq point
(point-marker))
8211 (when (and (match-string 1)
8212 (or (not (match-string 2))
8213 (save-excursion (goto-char (match-end 2))
8215 (not (save-excursion (goto-char (match-beginning 1))
8216 (vhdl-in-literal))))
8217 (goto-char (match-beginning 1))
8219 (indent-according-to-mode))
8222 ;; `for', `if' keywords
8223 (while (re-search-forward "\\<\\(for\\|if\\)\\>" end t
)
8224 (goto-char (match-end 1))
8225 (setq point
(point-marker))
8226 ;; exception: in literal or preceded by `end', `wait' or label
8227 (when (and (not (save-excursion (goto-char (match-beginning 1))
8230 (beginning-of-line 1)
8232 (and (re-search-forward "^\\s-*\\([^ \t\n].*\\)"
8233 (match-beginning 1) t
)
8235 "\\(\\<end\\>\\|\\<wait .*\\|\\w+\\s-*:\\)\\s-*$"
8236 (match-string 1)))))))
8237 (goto-char (match-beginning 1))
8239 (indent-according-to-mode))
8240 (goto-char point
))))))
8242 (defun vhdl-fix-statement-buffer ()
8243 "Force statements in buffer on separate line except when on same line
8244 with `end' keyword (necessary for correct indentation)."
8246 (vhdl-fix-statement-region (point-min) (point-max)))
8248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8251 (defun vhdl-remove-trailing-spaces-region (beg end
&optional arg
)
8252 "Remove trailing spaces in region."
8253 (interactive "r\nP")
8256 (setq end
(point-marker))
8258 (while (re-search-forward "[ \t]+$" end t
)
8259 (unless (vhdl-in-literal)
8260 (replace-match "" nil nil
)))))
8262 (defun vhdl-remove-trailing-spaces ()
8263 "Remove trailing spaces in buffer."
8265 (vhdl-remove-trailing-spaces-region (point-min) (point-max)))
8267 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8270 (defun vhdl-beautify-region (beg end
)
8271 "Beautify region by applying indentation, whitespace fixup, alignment, and
8272 case fixing to a region. Calls functions `vhdl-indent-buffer',
8273 `vhdl-align-buffer' (option `vhdl-align-groups' set to non-nil), and
8274 `vhdl-fix-case-buffer'."
8276 (setq end
(save-excursion (goto-char end
) (point-marker)))
8277 (save-excursion ; remove DOS EOL characters in UNIX file
8279 (while (search-forward "\r" nil t
)
8280 (replace-match "" nil t
)))
8281 (when (nth 0 vhdl-beautify-options
) (vhdl-fixup-whitespace-region beg end t
))
8282 (when (nth 1 vhdl-beautify-options
) (vhdl-fix-statement-region beg end
))
8283 (when (nth 2 vhdl-beautify-options
) (vhdl-indent-region beg end
))
8284 (when (nth 3 vhdl-beautify-options
)
8285 (let ((vhdl-align-groups t
)) (vhdl-align-region beg end
)))
8286 (when (nth 4 vhdl-beautify-options
) (vhdl-fix-case-region beg end
))
8287 (when (nth 0 vhdl-beautify-options
)
8288 (vhdl-remove-trailing-spaces-region beg end
)
8289 (if vhdl-indent-tabs-mode
(tabify beg end
) (untabify beg end
))))
8291 (defun vhdl-beautify-buffer ()
8292 "Beautify buffer by applying indentation, whitespace fixup, alignment, and
8293 case fixing to entire buffer. Calls `vhdl-beautify-region' for the entire
8296 (vhdl-beautify-region (point-min) (point-max))
8297 (when noninteractive
(save-buffer)))
8299 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8302 (defun vhdl-fill-region (beg end
&optional arg
)
8303 "Fill lines for a region of code."
8304 (interactive "r\np")
8307 (let ((margin (if arg
(current-indentation) (current-column))))
8309 (setq end
(point-marker))
8310 ;; remove inline comments, newlines and whitespace
8311 (vhdl-comment-kill-region beg end
)
8312 (vhdl-comment-kill-inline-region beg end
)
8313 (subst-char-in-region beg
(1- end
) ?
\n ?\
)
8314 (vhdl-fixup-whitespace-region beg end
)
8315 ;; wrap and end-comment-column
8317 (while (re-search-forward "\\s-" end t
)
8318 (when(> (current-column) vhdl-end-comment-column
)
8320 (when (re-search-backward "\\s-" beg t
)
8321 (replace-match "\n")
8322 (indent-to margin
)))))))
8324 (defun vhdl-fill-group ()
8325 "Fill group of lines between empty lines."
8327 (vhdl-do-group 'vhdl-fill-region
))
8329 (defun vhdl-fill-list ()
8330 "Fill the lines of a list surrounded by a balanced group of parentheses."
8332 (vhdl-do-list 'vhdl-fill-region
))
8334 (defun vhdl-fill-same-indent ()
8335 "Fill the lines of block of lines with same indent."
8337 (vhdl-do-same-indent 'vhdl-fill-region
))
8340 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8341 ;;; Code updating/fixing
8342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8344 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8345 ;; Sensitivity list update
8348 ;; - no sensitivity list is generated for processes with wait statements
8349 ;; - otherwise, do the following:
8350 ;; 1. scan for all local signals (ports, signals declared in arch./blocks)
8351 ;; 2. scan for all signals already in the sensitivity list (in order to catch
8352 ;; manually entered global signals)
8353 ;; 3. signals from 1. and 2. form the list of visible signals
8354 ;; 4. search for if/elsif conditions containing an event (sequential code)
8355 ;; 5. scan for strings that are within syntactical regions where signals are
8356 ;; read but not within sequential code, and that correspond to visible
8358 ;; 6. replace sensitivity list by list of signals from 5.
8360 (defun vhdl-update-sensitivity-list-process ()
8361 "Update sensitivity list of current process."
8364 (vhdl-prepare-search-2
8366 ;; look whether in process
8367 (if (not (and (re-search-backward "^\\s-*\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(process\\|end\\s-+process\\)\\>" nil t
)
8368 (equal (upcase (match-string 2)) "PROCESS")
8369 (save-excursion (re-search-forward "^\\s-*end\\s-+process\\>" nil t
))))
8370 (error "ERROR: Not within a process")
8371 (message "Updating sensitivity list...")
8372 (vhdl-update-sensitivity-list)
8373 (message "Updating sensitivity list...done")))))
8375 (defun vhdl-update-sensitivity-list-buffer ()
8376 "Update sensitivity list of all processes in current buffer."
8379 (vhdl-prepare-search-2
8380 (goto-char (point-min))
8381 (message "Updating sensitivity lists...")
8382 (while (re-search-forward "^\\s-*\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?process\\>" nil t
)
8383 (goto-char (match-beginning 0))
8384 (condition-case nil
(vhdl-update-sensitivity-list) (error "")))
8385 (message "Updating sensitivity lists...done")))
8386 (when noninteractive
(save-buffer)))
8388 (defun vhdl-update-sensitivity-list ()
8389 "Update sensitivity list."
8390 (let ((proc-beg (point))
8391 (proc-end (re-search-forward "^\\s-*end\\s-+process\\>" nil t
))
8392 (proc-mid (vhdl-re-search-backward
8393 "\\(\\(\\<begin\\>\\)\\|^\\s-*process\\>\\)" nil t
))
8396 ;; error if 'begin' keyword missing
8397 ((not (match-string 2))
8398 (error "ERROR: No 'begin' keyword found"))
8399 ;; search for wait statement (no sensitivity list allowed)
8400 ((progn (goto-char proc-mid
)
8401 (vhdl-re-search-forward "\\<wait\\>" proc-end t
))
8402 (error "ERROR: Process with wait statement, sensitivity list not generated"))
8403 ;; combinational process (update sensitivity list)
8406 ;; scan for visible signals
8407 ((visible-list (vhdl-get-visible-signals))
8408 ;; define syntactic regions where signals are read
8410 '(;; right-hand side of signal/variable assignment
8411 ;; (special case: "<=" is relational operator in a condition)
8412 ((vhdl-re-search-forward "[<:]=" proc-end t
)
8413 (vhdl-re-search-forward ";\\|\\<\\(then\\|loop\\|report\\|severity\\|is\\)\\>" proc-end t
))
8415 ((vhdl-re-search-forward "^\\s-*if\\>" proc-end t
)
8416 (vhdl-re-search-forward "\\<then\\>" proc-end t
))
8418 ((vhdl-re-search-forward "\\<elsif\\>" proc-end t
)
8419 (vhdl-re-search-forward "\\<then\\>" proc-end t
))
8420 ;; while loop condition
8421 ((vhdl-re-search-forward "^\\s-*while\\>" proc-end t
)
8422 (vhdl-re-search-forward "\\<loop\\>" proc-end t
))
8423 ;; exit/next condition
8424 ((vhdl-re-search-forward "\\<\\(exit\\|next\\)\\s-+\\w+\\s-+when\\>" proc-end t
)
8425 (vhdl-re-search-forward ";" proc-end t
))
8427 ((vhdl-re-search-forward "\\<assert\\>" proc-end t
)
8428 (vhdl-re-search-forward "\\(\\<report\\>\\|\\<severity\\>\\|;\\)" proc-end t
))
8430 ((vhdl-re-search-forward "^\\s-*case\\>" proc-end t
)
8431 (vhdl-re-search-forward "\\<is\\>" proc-end t
))
8432 ;; parameter list of procedure call, array index
8433 ((and (re-search-forward "^\\s-*\\(\\w\\|\\.\\)+[ \t\n\r\f]*(" proc-end t
)
8435 (progn (backward-char) (forward-sexp)
8436 (while (looking-at "(") (forward-sexp)) (point)))))
8437 name field read-list sens-list signal-list tmp-list
8438 sens-beg sens-end beg end margin
)
8439 ;; scan for signals in old sensitivity list
8440 (goto-char proc-beg
)
8441 (vhdl-re-search-forward "\\<process\\>" proc-mid t
)
8442 (if (not (looking-at "[ \t\n\r\f]*("))
8443 (setq sens-beg
(point))
8444 (setq sens-beg
(vhdl-re-search-forward "\\([ \t\n\r\f]*\\)([ \t\n\r\f]*" nil t
))
8445 (goto-char (match-end 1))
8447 (setq sens-end
(1- (point)))
8448 (goto-char sens-beg
)
8449 (while (and (vhdl-re-search-forward "\\(\\w+\\)" sens-end t
)
8451 (cons (downcase (match-string 0)) sens-list
))
8452 (vhdl-re-search-forward "\\s-*,\\s-*" sens-end t
))))
8453 (setq signal-list
(append visible-list sens-list
))
8454 ;; search for sequential parts
8455 (goto-char proc-mid
)
8456 (while (setq beg
(re-search-forward "^\\s-*\\(els\\)?if\\>" proc-end t
))
8457 (setq end
(vhdl-re-search-forward "\\<then\\>" proc-end t
))
8458 (when (vhdl-re-search-backward "\\('event\\|\\<\\(falling\\|rising\\)_edge\\)\\>" beg t
)
8460 (backward-word-strictly 1)
8462 (push (cons end
(point)) seq-region-list
)
8463 (beginning-of-line)))
8464 ;; scan for signals read in process
8465 (while scan-regions-list
8466 (goto-char proc-mid
)
8467 (while (and (setq beg
(eval (nth 0 (car scan-regions-list
))))
8468 (setq end
(eval (nth 1 (car scan-regions-list
)))))
8470 (unless (or (vhdl-in-literal)
8471 (and seq-region-list
8472 (let ((tmp-list seq-region-list
))
8473 (while (and tmp-list
8474 (< (point) (caar tmp-list
)))
8475 (setq tmp-list
(cdr tmp-list
)))
8476 (and tmp-list
(< (point) (cdar tmp-list
))))))
8477 (while (vhdl-re-search-forward "[^'\".]\\<\\([a-zA-Z]\\w*\\)\\(\\(\\.\\w+\\|[ \t\n\r\f]*([^)]*)\\)*\\)[ \t\n\r\f]*\\('\\(\\w+\\)\\|\\(=>\\)\\)?" end t
)
8478 (setq name
(match-string 1))
8479 ;; get array index range
8480 (when vhdl-array-index-record-field-in-sensitivity-list
8481 (setq field
(match-string 2))
8482 ;; not use if it includes a variable name
8484 (setq tmp-list visible-list
)
8485 (while (and field tmp-list
)
8487 (concat "\\<" (car tmp-list
) "\\>") field
)
8489 (setq tmp-list
(cdr tmp-list
)))))
8490 (when (and (not (match-string 6)) ; not when formal parameter
8491 (not (and (match-string 5) ; not event attribute
8492 (not (member (downcase (match-string 5))
8493 '("event" "last_event" "transaction")))))
8494 (member (downcase name
) signal-list
))
8495 ;; not add if name or name+field already exists
8497 (or (member-ignore-case name read-list
)
8498 (member-ignore-case (concat name field
) read-list
))
8499 (push (concat name field
) read-list
))
8500 (setq tmp-list read-list
)
8501 ;; remove existing name+field if name is added
8504 (when (string-match (concat "^" name field
"[(.]")
8506 (setq read-list
(delete (car tmp-list
) read-list
)))
8507 (setq tmp-list
(cdr tmp-list
)))))
8508 (goto-char (match-end 1)))))
8509 (setq scan-regions-list
(cdr scan-regions-list
)))
8510 ;; update sensitivity list
8511 (goto-char sens-beg
)
8513 (delete-region sens-beg sens-end
)
8515 (insert " ()") (backward-char)))
8516 (setq read-list
(sort read-list
'string
<))
8518 (setq margin
(current-column))
8519 (insert (car read-list
))
8520 (setq read-list
(cdr read-list
))
8523 (if (<= (+ (current-column) (length (car read-list
)) 2)
8526 (insert "\n") (indent-to margin
))
8527 (insert (car read-list
))
8528 (setq read-list
(cdr read-list
)))))))))
8530 (defun vhdl-get-visible-signals ()
8531 "Get all signals visible in the current block."
8532 (let (beg end signal-list entity-name file-name
)
8533 (vhdl-prepare-search-2
8536 (unless (and (re-search-backward "^\\(architecture\\s-+\\w+\\s-+of\\s-+\\(\\w+\\)\\|end\\)\\>" nil t
)
8537 (not (equal "END" (upcase (match-string 1))))
8538 (setq entity-name
(match-string 2)))
8539 (error "ERROR: Not within an architecture")))
8540 ;; search for signals declared in entity port clause
8542 (goto-char (point-min))
8543 (unless (re-search-forward (concat "^entity\\s-+" entity-name
"\\>") nil t
)
8545 (concat (vhdl-replace-string vhdl-entity-file-name entity-name t
)
8546 "." (file-name-extension (buffer-file-name)))))
8549 (vhdl-prepare-search-2
8550 (goto-char (point-min))
8551 (if (not (re-search-forward (concat "^entity\\s-+" entity-name
"\\>") nil t
))
8552 (error "ERROR: Entity \"%s\" not found:\n --> see option `vhdl-entity-file-name'" entity-name
)
8553 (when (setq beg
(vhdl-re-search-forward
8554 "\\<port[ \t\n\r\f]*("
8556 (re-search-forward "^end\\>" nil t
)) t
))
8557 (setq end
(save-excursion
8558 (backward-char) (forward-sexp) (point)))
8559 (vhdl-forward-syntactic-ws)
8560 (while (< (point) end
)
8561 (when (looking-at "signal[ \t\n\r\f]+")
8562 (goto-char (match-end 0)))
8563 (while (looking-at "\\([a-zA-Z]\\w*\\)[ \t\n\r\f,]+")
8565 (cons (downcase (match-string 1)) signal-list
))
8566 (goto-char (match-end 0))
8567 (vhdl-forward-syntactic-ws))
8568 (re-search-forward ";" end
1)
8569 (vhdl-forward-syntactic-ws)))))))
8570 ;; search for signals declared in architecture declarative part
8572 (if (not (and (setq beg
(re-search-backward "^\\(architecture\\s-+\\w+\\s-+of\\s-+\\(\\w+\\)\\|end\\)\\>" nil t
))
8573 (not (equal "END" (upcase (match-string 1))))
8574 (setq end
(re-search-forward "^begin\\>" nil t
))))
8575 (error "ERROR: No architecture declarative part found")
8576 ;; scan for all declared signal and alias names
8578 (while (re-search-forward "^\\s-*\\(\\(signal\\)\\|alias\\)\\>" end t
)
8579 (when (= 0 (nth 0 (parse-partial-sexp beg
(point))))
8580 (if (match-string 2)
8582 (while (looking-at "[ \t\n\r\f,]+\\([a-zA-Z]\\w*\\)")
8584 (cons (downcase (match-string 1)) signal-list
))
8585 (goto-char (match-end 0)))
8586 ;; scan alias name, check is alias of (declared) signal
8587 (when (and (looking-at "[ \t\n\r\f]+\\([a-zA-Z]\\w*\\)[^;]*\\<is[ \t\n\r\f]+\\([a-zA-Z]\\w*\\)")
8588 (member (downcase (match-string 2)) signal-list
))
8590 (cons (downcase (match-string 1)) signal-list
))
8591 (goto-char (match-end 0))))
8592 (setq beg
(point))))))
8593 ;; search for signals declared in surrounding block declarative parts
8595 (while (and (progn (while (and (setq beg
(re-search-backward "^\\s-*\\(\\w+\\s-*:\\s-*\\(block\\|\\(for\\|if\\).*\\<generate\\>\\)\\|\\(end\\)\\s-+block\\)\\>" nil t
))
8597 (goto-char (match-end 4))
8598 (vhdl-backward-sexp)
8599 (re-search-backward "^\\s-*\\w+\\s-*:\\s-*\\(block\\|generate\\)\\>" nil t
))
8601 (setq end
(re-search-forward "^\\s-*begin\\>" nil t
)))
8602 ;; scan for all declared signal names
8604 (while (re-search-forward "^\\s-*\\(\\(signal\\)\\|alias\\)\\>" end t
)
8605 (when (= 0 (nth 0 (parse-partial-sexp beg
(point))))
8606 (if (match-string 2)
8608 (while (looking-at "[ \t\n,]+\\(\\w+\\)")
8610 (cons (downcase (match-string 1)) signal-list
))
8611 (goto-char (match-end 0)))
8612 ;; scan alias name, check is alias of (declared) signal
8613 (when (and (looking-at "[ \t\n]+\\(\\w+\\)[^;]*\\<is[ \t\n]+\\(\\w+\\)")
8614 (member (downcase (match-string 2)) signal-list
))
8616 (cons (downcase (match-string 1)) signal-list
))
8617 (goto-char (match-end 0))))))
8621 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8622 ;; Generic/port clause fixing
8624 (defun vhdl-fix-clause-buffer ()
8625 "Fix all generic/port clauses in current buffer."
8628 (vhdl-prepare-search-2
8629 (goto-char (point-min))
8630 (message "Fixing generic/port clauses...")
8631 (while (re-search-forward "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(" nil t
)
8632 (goto-char (match-end 0))
8633 (condition-case nil
(vhdl-fix-clause) (error "")))
8634 (message "Fixing generic/port clauses...done"))))
8636 (defun vhdl-fix-clause ()
8637 "Fix closing parenthesis within generic/port clause."
8640 (vhdl-prepare-search-2
8644 (if (not (re-search-backward "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(" nil t
))
8645 (error "ERROR: Not within a generic/port clause")
8646 ;; search for end of clause
8647 (goto-char (match-end 0))
8648 (setq beg
(1- (point)))
8649 (vhdl-forward-syntactic-ws)
8650 (while (looking-at "\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*[ \t\n\r\f]*:[ \t\n\r\f]*\\w+[^;]*;")
8651 (goto-char (1- (match-end 0)))
8652 (setq end
(point-marker))
8654 (vhdl-forward-syntactic-ws))
8656 (when (> pos
(point-at-eol))
8657 (error "ERROR: Not within a generic/port clause"))
8658 ;; delete closing parenthesis on separate line (not supported style)
8659 (when (save-excursion (beginning-of-line) (looking-at "^\\s-*);"))
8661 (vhdl-backward-syntactic-ws)
8662 (setq end
(point-marker))
8664 ;; delete superfluous parentheses
8665 (while (progn (goto-char beg
)
8666 (condition-case () (forward-sexp)
8667 (error (goto-char (point-max))))
8670 ;; add closing parenthesis
8671 (when (> (point) end
)
8676 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8678 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8680 (defconst vhdl-template-prompt-syntax
"[^ =<>][^<>@.\n]*[^ =<>]"
8681 "Syntax of prompt inserted by template generators.")
8683 (defvar vhdl-template-invoked-by-hook nil
8684 "Indicates whether a template has been invoked by a hook or by key or menu.
8685 Used for undoing after template abortion.")
8687 ;; correct different behavior of function `unread-command-events' in XEmacs
8688 (defun vhdl-character-to-event (arg))
8689 (defalias 'vhdl-character-to-event
8690 (if (fboundp 'character-to-event
) 'character-to-event
'identity
))
8692 (defun vhdl-work-library ()
8693 "Return the working library name of the current project or \"work\" if no
8694 project is defined."
8695 (vhdl-resolve-env-variable
8696 (or (nth 6 (vhdl-aget vhdl-project-alist vhdl-project
))
8697 vhdl-default-library
)))
8699 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8700 ;; Enabling/disabling
8702 (define-minor-mode vhdl-electric-mode
8703 "Toggle VHDL electric mode.
8704 With a prefix argument ARG, enable the mode if ARG is positive,
8705 and disable it otherwise. If called from Lisp, enable it if ARG
8707 :global t
:group
'vhdl-mode
)
8709 (define-minor-mode vhdl-stutter-mode
8710 "Toggle VHDL stuttering mode.
8711 With a prefix argument ARG, enable the mode if ARG is positive,
8712 and disable it otherwise. If called from Lisp, enable it if ARG
8714 :global t
:group
'vhdl-mode
)
8716 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8719 (defun vhdl-electric-dash (count)
8720 "-- starts a comment, --- draws a horizontal line,
8721 ---- starts a display comment."
8723 (if (and vhdl-stutter-mode
(not (vhdl-in-literal)))
8725 ((and abbrev-start-location
(= abbrev-start-location
(point)))
8726 (setq abbrev-start-location nil
)
8727 (goto-char last-abbrev-location
)
8728 (beginning-of-line nil
)
8729 (vhdl-comment-display))
8730 ((/= (preceding-char) ?-
) ; standard dash (minus)
8731 (self-insert-command count
))
8732 (t (self-insert-command count
)
8733 (message "Enter '-' for horiz. line, 'CR' for commenting-out code, else enter comment")
8734 (let ((next-input (read-char)))
8735 (if (= next-input ?-
) ; triple dash
8737 (vhdl-comment-display-line)
8739 "Enter '-' for display comment, else continue coding")
8740 (let ((next-input (read-char)))
8741 (if (= next-input ?-
) ; four dashes
8742 (vhdl-comment-display t
)
8743 (push (vhdl-character-to-event next-input
)
8745 unread-command-events
))))
8746 (push (vhdl-character-to-event next-input
) ; pushback the char
8747 unread-command-events
)
8748 (vhdl-comment-insert)))))
8749 (self-insert-command count
)))
8751 (defun vhdl-electric-open-bracket (count) "`[' --> `(', `([' --> `['"
8753 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8754 (if (= (preceding-char) ?\
()
8755 (progn (delete-char -
1) (insert-char ?\
[ 1))
8756 (insert-char ?\
( 1))
8757 (self-insert-command count
)))
8759 (defun vhdl-electric-close-bracket (count) "`]' --> `)', `)]' --> `]'"
8761 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8763 (if (= (preceding-char) ?\
))
8764 (progn (delete-char -
1) (insert-char ?\
] 1))
8765 (insert-char ?\
) 1))
8766 (blink-matching-open))
8767 (self-insert-command count
)))
8769 (defun vhdl-electric-quote (count) "\\='\\=' --> \""
8771 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8772 (if (= (preceding-char) vhdl-last-input-event
)
8773 (progn (delete-char -
1) (insert-char ?
\" 1))
8774 (insert-char ?
\' 1))
8775 (self-insert-command count
)))
8777 (defun vhdl-electric-semicolon (count) "`;;' --> ` : ', `: ;' --> ` := '"
8779 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8780 (cond ((= (preceding-char) vhdl-last-input-event
)
8781 (progn (delete-char -
1)
8782 (unless (eq (preceding-char) ?
) (insert " "))
8784 (setq this-command
'vhdl-electric-colon
)))
8786 (eq last-command
'vhdl-electric-colon
) (= (preceding-char) ?
))
8787 (progn (delete-char -
1) (insert "= ")))
8788 (t (insert-char ?\
; 1)))
8789 (self-insert-command count
)))
8791 (defun vhdl-electric-comma (count) "`,,' --> ` <= '"
8793 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8794 (cond ((= (preceding-char) vhdl-last-input-event
)
8795 (progn (delete-char -
1)
8796 (unless (eq (preceding-char) ?
) (insert " "))
8798 (t (insert-char ?\
, 1)))
8799 (self-insert-command count
)))
8801 (defun vhdl-electric-period (count) "`..' --> ` => '"
8803 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8804 (cond ((= (preceding-char) vhdl-last-input-event
)
8805 (progn (delete-char -
1)
8806 (unless (eq (preceding-char) ?
) (insert " "))
8808 (t (insert-char ?\.
1)))
8809 (self-insert-command count
)))
8811 (defun vhdl-electric-equal (count) "`==' --> ` == '"
8813 (if (and vhdl-stutter-mode
(= count
1) (not (vhdl-in-literal)))
8814 (cond ((= (preceding-char) vhdl-last-input-event
)
8815 (progn (delete-char -
1)
8816 (unless (eq (preceding-char) ?
) (insert " "))
8818 (t (insert-char ?\
= 1)))
8819 (self-insert-command count
)))
8821 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8824 (defun vhdl-template-paired-parens ()
8825 "Insert a pair of round parentheses, placing point between them."
8830 (defun vhdl-template-alias ()
8831 "Insert alias declaration."
8833 (let ((start (point)))
8834 (vhdl-insert-keyword "ALIAS ")
8835 (when (vhdl-template-field "name" nil t start
(point))
8837 (unless (vhdl-template-field
8838 (concat "[type" (and (vhdl-standard-p 'ams
) " or nature") "]")
8841 (vhdl-insert-keyword " IS ")
8842 (vhdl-template-field "name" ";")
8843 (vhdl-comment-insert-inline))))
8845 (defun vhdl-template-architecture ()
8846 "Insert architecture."
8848 (let ((margin (current-indentation))
8851 (vhdl-insert-keyword "ARCHITECTURE ")
8852 (when (setq arch-name
8853 (vhdl-template-field "name" nil t start
(point)))
8854 (vhdl-insert-keyword " OF ")
8856 (vhdl-prepare-search-1
8857 (vhdl-re-search-backward "\\<entity \\(\\w+\\) is\\>" nil t
)))
8858 (insert (match-string 1))
8859 (vhdl-template-field "entity name"))
8860 (vhdl-insert-keyword " IS\n")
8861 (vhdl-template-begin-end
8862 (unless (vhdl-standard-p '87) "ARCHITECTURE") arch-name margin
8863 (memq vhdl-insert-empty-lines
'(unit all
))))))
8865 (defun vhdl-template-array (kind &optional secondary
)
8866 "Insert array type definition."
8868 (let ((start (point)))
8869 (vhdl-insert-keyword "ARRAY (")
8870 (when (or (vhdl-template-field "range" nil
(not secondary
) start
(point))
8872 (vhdl-insert-keyword ") OF ")
8873 (vhdl-template-field (if (eq kind
'type
) "type" "nature"))
8874 (vhdl-insert-keyword ";"))))
8876 (defun vhdl-template-assert ()
8877 "Insert an assertion statement."
8879 (let ((start (point)))
8880 (vhdl-insert-keyword "ASSERT ")
8881 (when vhdl-conditions-in-parenthesis
(insert "("))
8882 (when (vhdl-template-field "condition (negated)" nil t start
(point))
8883 (when vhdl-conditions-in-parenthesis
(insert ")"))
8884 (setq start
(point))
8885 (vhdl-insert-keyword " REPORT ")
8886 (unless (vhdl-template-field "string expression" nil nil nil nil t
)
8887 (delete-region start
(point)))
8888 (setq start
(point))
8889 (vhdl-insert-keyword " SEVERITY ")
8890 (unless (vhdl-template-field "[NOTE | WARNING | ERROR | FAILURE]" nil t
)
8891 (delete-region start
(point)))
8894 (defun vhdl-template-attribute ()
8895 "Insert an attribute declaration or specification."
8897 (if (eq (vhdl-decision-query
8898 "attribute" "(d)eclaration or (s)pecification?" t
) ?s
)
8899 (vhdl-template-attribute-spec)
8900 (vhdl-template-attribute-decl)))
8902 (defun vhdl-template-attribute-decl ()
8903 "Insert an attribute declaration."
8905 (let ((start (point)))
8906 (vhdl-insert-keyword "ATTRIBUTE ")
8907 (when (vhdl-template-field "name" " : " t start
(point))
8908 (vhdl-template-field "type" ";")
8909 (vhdl-comment-insert-inline))))
8911 (defun vhdl-template-attribute-spec ()
8912 "Insert an attribute specification."
8914 (let ((start (point)))
8915 (vhdl-insert-keyword "ATTRIBUTE ")
8916 (when (vhdl-template-field "name" nil t start
(point))
8917 (vhdl-insert-keyword " OF ")
8918 (vhdl-template-field "entity names | OTHERS | ALL" " : ")
8919 (vhdl-template-field "entity class")
8920 (vhdl-insert-keyword " IS ")
8921 (vhdl-template-field "expression" ";"))))
8923 (defun vhdl-template-block ()
8926 (let ((margin (current-indentation))
8929 (vhdl-insert-keyword ": BLOCK ")
8931 (when (setq label
(vhdl-template-field "label" nil t start
(+ (point) 8)))
8932 (forward-word-strictly 1)
8935 (if (vhdl-template-field "[guard expression]" nil t
)
8938 (unless (vhdl-standard-p '87) (vhdl-insert-keyword " IS"))
8940 (vhdl-template-begin-end "BLOCK" label margin
)
8941 (vhdl-comment-block))))
8943 (defun vhdl-template-block-configuration ()
8944 "Insert a block configuration statement."
8946 (let ((margin (current-indentation))
8948 (vhdl-insert-keyword "FOR ")
8949 (when (vhdl-template-field "block name" nil t start
(point))
8950 (vhdl-insert-keyword "\n\n")
8952 (vhdl-insert-keyword "END FOR;")
8954 (indent-to (+ margin vhdl-basic-offset
)))))
8956 (defun vhdl-template-break ()
8957 "Insert a break statement."
8960 (vhdl-insert-keyword "BREAK")
8961 (setq position
(point))
8964 (progn (vhdl-insert-keyword "FOR ")
8965 (if (vhdl-template-field "[quantity name]" " USE " t
)
8966 (progn (vhdl-template-field "quantity name" " => ") t
)
8967 (delete-region (point)
8968 (progn (forward-word-strictly -
1) (point)))
8970 (vhdl-template-field "[quantity name]" " => " t
))
8971 (vhdl-template-field "expression")
8972 (setq position
(point))
8974 (delete-region position
(point))
8975 (unless (vhdl-sequential-statement-p)
8976 (vhdl-insert-keyword " ON ")
8977 (if (vhdl-template-field "[sensitivity list]" nil t
)
8978 (setq position
(point))
8979 (delete-region position
(point))))
8980 (vhdl-insert-keyword " WHEN ")
8981 (when vhdl-conditions-in-parenthesis
(insert "("))
8982 (if (vhdl-template-field "[condition]" nil t
)
8983 (when vhdl-conditions-in-parenthesis
(insert ")"))
8984 (delete-region position
(point)))
8987 (defun vhdl-template-case (&optional kind
)
8988 "Insert a case statement."
8990 (let ((margin (current-indentation))
8993 (unless kind
(setq kind
(if (or (vhdl-sequential-statement-p)
8994 (not (vhdl-standard-p 'ams
))) 'is
'use
)))
8995 (if (or (not (eq vhdl-optional-labels
'all
)) (vhdl-standard-p '87))
8996 (vhdl-insert-keyword "CASE ")
8997 (vhdl-insert-keyword ": CASE ")
8999 (setq label
(vhdl-template-field "[label]" nil t
))
9000 (unless label
(delete-char 2))
9001 (forward-word-strictly 1)
9003 (when (vhdl-template-field "expression" nil t start
(point))
9004 (vhdl-insert-keyword (concat " " (if (eq kind
'is
) "IS" "USE") "\n\n"))
9006 (vhdl-insert-keyword "END CASE")
9007 (when label
(insert " " label
))
9010 (indent-to (+ margin vhdl-basic-offset
))
9011 (vhdl-insert-keyword "WHEN ")
9012 (let ((position (point)))
9014 (indent-to (+ margin vhdl-basic-offset
))
9015 (vhdl-insert-keyword "WHEN OTHERS => null;")
9016 (goto-char position
)))))
9018 (defun vhdl-template-case-is ()
9019 "Insert a sequential case statement."
9021 (vhdl-template-case 'is
))
9023 (defun vhdl-template-case-use ()
9024 "Insert a simultaneous case statement."
9026 (vhdl-template-case 'use
))
9028 (defun vhdl-template-component ()
9029 "Insert a component declaration."
9031 (vhdl-template-component-decl))
9033 (defun vhdl-template-component-conf ()
9034 "Insert a component configuration (uses `vhdl-template-configuration-spec'
9035 since these are almost equivalent)."
9037 (let ((margin (current-indentation))
9038 (result (vhdl-template-configuration-spec t
)))
9042 (vhdl-insert-keyword "END FOR;")
9043 (when (eq result
'no-use
)
9044 (end-of-line -
0)))))
9046 (defun vhdl-template-component-decl ()
9047 "Insert a component declaration."
9049 (let ((margin (current-indentation))
9052 (vhdl-insert-keyword "COMPONENT ")
9053 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9054 (unless (vhdl-standard-p '87) (vhdl-insert-keyword " IS"))
9057 (vhdl-insert-keyword "END COMPONENT")
9058 (unless (vhdl-standard-p '87) (insert " " name
))
9060 (setq end-column
(current-column))
9062 (indent-to (+ margin vhdl-basic-offset
))
9063 (vhdl-template-generic-list t t
)
9065 (indent-to (+ margin vhdl-basic-offset
))
9066 (vhdl-template-port-list t
)
9067 (beginning-of-line 2)
9068 (forward-char end-column
))))
9070 (defun vhdl-template-component-inst ()
9071 "Insert a component instantiation statement."
9073 (let ((margin (current-indentation))
9076 (when (vhdl-template-field "instance label" nil t start
(point))
9078 (if (not (vhdl-use-direct-instantiation))
9079 (vhdl-template-field "component name")
9080 ;; direct instantiation
9081 (setq unit
(vhdl-template-field
9082 "[COMPONENT | ENTITY | CONFIGURATION]" " " t
))
9083 (setq unit
(upcase (or unit
"")))
9084 (cond ((equal unit
"ENTITY")
9085 (let ((begin (point)))
9086 (vhdl-template-field "library name" "." t begin
(point) nil
9087 (vhdl-work-library))
9088 (vhdl-template-field "entity name" "(")
9089 (if (vhdl-template-field "[architecture name]" nil t
)
9092 ((equal unit
"CONFIGURATION")
9093 (vhdl-template-field "library name" "." nil nil nil nil
9094 (vhdl-work-library))
9095 (vhdl-template-field "configuration name"))
9096 (t (vhdl-template-field "component name"))))
9098 (indent-to (+ margin vhdl-basic-offset
))
9099 (setq position
(point))
9100 (vhdl-insert-keyword "GENERIC ")
9101 (when (vhdl-template-map position t t
)
9103 (indent-to (+ margin vhdl-basic-offset
)))
9104 (setq position
(point))
9105 (vhdl-insert-keyword "PORT ")
9106 (unless (vhdl-template-map position t t
)
9107 (delete-region (line-beginning-position) (point))
9111 (defun vhdl-template-conditional-signal-asst ()
9112 "Insert a conditional signal assignment."
9114 (when (vhdl-template-field "target signal")
9116 (let ((margin (current-column))
9119 (vhdl-template-field "waveform")
9120 (setq position
(point))
9121 (vhdl-insert-keyword " WHEN ")
9122 (when vhdl-conditions-in-parenthesis
(insert "("))
9123 (while (and (vhdl-template-field "[condition]" nil t
)
9125 (when vhdl-conditions-in-parenthesis
(insert ")"))
9126 (setq position
(point))
9127 (vhdl-insert-keyword " ELSE")
9130 (vhdl-template-field "[waveform]" nil t
)))
9131 (setq position
(point))
9132 (vhdl-insert-keyword " WHEN ")
9133 (when vhdl-conditions-in-parenthesis
(insert "(")))
9134 (delete-region position
(point))
9136 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1)))))
9138 (defun vhdl-template-configuration ()
9139 "Insert a configuration specification if within an architecture,
9140 a block or component configuration if within a configuration declaration,
9141 a configuration declaration if not within a design unit."
9143 (vhdl-prepare-search-1
9145 ((and (save-excursion ; architecture body
9146 (re-search-backward "^\\(architecture\\|end\\)\\>" nil t
))
9147 (equal "ARCHITECTURE" (upcase (match-string 1))))
9148 (vhdl-template-configuration-spec))
9149 ((and (save-excursion ; configuration declaration
9150 (re-search-backward "^\\(configuration\\|end\\)\\>" nil t
))
9151 (equal "CONFIGURATION" (upcase (match-string 1))))
9152 (if (eq (vhdl-decision-query
9153 "configuration" "(b)lock or (c)omponent configuration?" t
) ?c
)
9154 (vhdl-template-component-conf)
9155 (vhdl-template-block-configuration)))
9156 (t (vhdl-template-configuration-decl))))) ; otherwise
9158 (defun vhdl-template-configuration-spec (&optional optional-use
)
9159 "Insert a configuration specification."
9161 (let ((margin (current-indentation))
9164 (vhdl-insert-keyword "FOR ")
9165 (when (vhdl-template-field "instance names | OTHERS | ALL" " : "
9167 (vhdl-template-field "component name" "\n")
9168 (indent-to (+ margin vhdl-basic-offset
))
9169 (setq start
(point))
9170 (vhdl-insert-keyword "USE ")
9171 (if (and optional-use
9172 (not (setq aspect
(vhdl-template-field
9173 "[ENTITY | CONFIGURATION | OPEN]" " " t
))))
9174 (progn (delete-region start
(point)) 'no-use
)
9175 (unless optional-use
9176 (setq aspect
(vhdl-template-field
9177 "ENTITY | CONFIGURATION | OPEN" " ")))
9178 (setq aspect
(upcase (or aspect
"")))
9179 (cond ((equal aspect
"ENTITY")
9180 (vhdl-template-field "library name" "." nil nil nil nil
9181 (vhdl-work-library))
9182 (vhdl-template-field "entity name" "(")
9183 (if (vhdl-template-field "[architecture name]" nil t
)
9187 (indent-to (+ margin
(* 2 vhdl-basic-offset
)))
9188 (setq position
(point))
9189 (vhdl-insert-keyword "GENERIC ")
9190 (when (vhdl-template-map position t t
)
9192 (indent-to (+ margin
(* 2 vhdl-basic-offset
))))
9193 (setq position
(point))
9194 (vhdl-insert-keyword "PORT ")
9195 (unless (vhdl-template-map position t t
)
9196 (delete-region (line-beginning-position) (point))
9200 ((equal aspect
"CONFIGURATION")
9201 (vhdl-template-field "library name" "." nil nil nil nil
9202 (vhdl-work-library))
9203 (vhdl-template-field "configuration name" ";"))
9204 (t (delete-char -
1) (insert ";") t
))))))
9207 (defun vhdl-template-configuration-decl ()
9208 "Insert a configuration declaration."
9210 (let ((margin (current-indentation))
9212 entity-exists string name position
)
9213 (vhdl-insert-keyword "CONFIGURATION ")
9214 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9215 (vhdl-insert-keyword " OF ")
9217 (vhdl-prepare-search-1
9218 (setq entity-exists
(vhdl-re-search-backward
9219 "\\<entity \\(\\w*\\) is\\>" nil t
))
9220 (setq string
(match-string 1))))
9221 (if (and entity-exists
(not (equal string
"")))
9223 (vhdl-template-field "entity name"))
9224 (vhdl-insert-keyword " IS\n")
9225 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9226 (indent-to (+ margin vhdl-basic-offset
))
9227 (setq position
(point))
9229 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9231 (vhdl-insert-keyword "END ")
9232 (unless (vhdl-standard-p '87)
9233 (vhdl-insert-keyword "CONFIGURATION "))
9235 (goto-char position
))))
9237 (defun vhdl-template-constant ()
9238 "Insert a constant declaration."
9240 (let ((start (point))
9241 (in-arglist (vhdl-in-argument-list-p)))
9242 (vhdl-insert-keyword "CONSTANT ")
9243 (when (vhdl-template-field "name" nil t start
(point))
9245 (when in-arglist
(vhdl-insert-keyword "IN "))
9246 (vhdl-template-field "type")
9249 (vhdl-comment-insert-inline))
9250 (let ((position (point)))
9252 (unless (vhdl-template-field "[initialization]" nil t
)
9253 (delete-region position
(point)))
9255 (vhdl-comment-insert-inline))))))
9257 (defun vhdl-template-context ()
9258 "Insert a context declaration."
9260 (let ((margin (current-indentation))
9262 entity-exists string name position
)
9263 (vhdl-insert-keyword "CONTEXT ")
9264 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9265 (vhdl-insert-keyword " IS\n")
9266 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9267 (indent-to (+ margin vhdl-basic-offset
))
9268 (setq position
(point))
9270 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9272 (vhdl-insert-keyword "END ")
9273 (unless (vhdl-standard-p '87)
9274 (vhdl-insert-keyword "CONTEXT "))
9276 (goto-char position
))))
9278 (defun vhdl-template-default ()
9283 (backward-word-strictly 1)
9287 (defun vhdl-template-default-indent ()
9288 "Insert nothing and indent."
9292 (backward-word-strictly 1)
9295 (indent-according-to-mode))
9297 (defun vhdl-template-disconnect ()
9298 "Insert a disconnect statement."
9300 (let ((start (point)))
9301 (vhdl-insert-keyword "DISCONNECT ")
9302 (when (vhdl-template-field "signal names | OTHERS | ALL"
9303 " : " t start
(point))
9304 (vhdl-template-field "type")
9305 (vhdl-insert-keyword " AFTER ")
9306 (vhdl-template-field "time expression" ";"))))
9308 (defun vhdl-template-else ()
9309 "Insert an else statement."
9312 (vhdl-prepare-search-1
9313 (vhdl-insert-keyword "ELSE")
9314 (if (and (save-excursion (vhdl-re-search-backward "\\(\\(\\<when\\>\\)\\|;\\)" nil t
))
9317 (unless (vhdl-sequential-statement-p)
9318 (vhdl-insert-keyword " GENERATE"))
9319 (indent-according-to-mode)
9320 (setq margin
(current-indentation))
9322 (indent-to (+ margin vhdl-basic-offset
))))))
9324 (defun vhdl-template-elsif ()
9325 "Insert an elsif statement."
9327 (let ((start (point))
9329 (vhdl-insert-keyword "ELSIF ")
9330 (when vhdl-conditions-in-parenthesis
(insert "("))
9331 (when (vhdl-template-field "condition" nil t start
(point))
9332 (when vhdl-conditions-in-parenthesis
(insert ")"))
9333 (indent-according-to-mode)
9334 (setq margin
(current-indentation))
9335 (vhdl-insert-keyword
9336 (concat " " (cond ((vhdl-sequential-statement-p) "THEN")
9337 ((vhdl-standard-p 'ams
) "USE")
9338 (t "GENERATE")) "\n"))
9339 (indent-to (+ margin vhdl-basic-offset
)))))
9341 (defun vhdl-template-entity ()
9344 (let ((margin (current-indentation))
9347 (vhdl-insert-keyword "ENTITY ")
9348 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9349 (vhdl-insert-keyword " IS\n\n")
9351 (vhdl-insert-keyword "END ")
9352 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "ENTITY "))
9354 (setq end-column
(current-column))
9356 (indent-to (+ margin vhdl-basic-offset
))
9357 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9358 (indent-to (+ margin vhdl-basic-offset
))
9359 (when (vhdl-template-generic-list t
)
9360 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n")))
9362 (indent-to (+ margin vhdl-basic-offset
))
9363 (when (vhdl-template-port-list t
)
9364 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n")))
9365 (beginning-of-line 2)
9366 (forward-char end-column
))))
9368 (defun vhdl-template-exit ()
9369 "Insert an exit statement."
9371 (let ((start (point)))
9372 (vhdl-insert-keyword "EXIT ")
9373 (if (vhdl-template-field "[loop label]" nil t start
(point))
9374 (let ((position (point)))
9375 (vhdl-insert-keyword " WHEN ")
9376 (when vhdl-conditions-in-parenthesis
(insert "("))
9377 (if (vhdl-template-field "[condition]" nil t
)
9378 (when vhdl-conditions-in-parenthesis
(insert ")"))
9379 (delete-region position
(point))))
9383 (defun vhdl-template-file ()
9384 "Insert a file declaration."
9386 (let ((start (point)))
9387 (vhdl-insert-keyword "FILE ")
9388 (when (vhdl-template-field "name" nil t start
(point))
9390 (vhdl-template-field "type")
9391 (unless (vhdl-standard-p '87)
9392 (vhdl-insert-keyword " OPEN ")
9393 (unless (vhdl-template-field "[READ_MODE | WRITE_MODE | APPEND_MODE]"
9396 (vhdl-insert-keyword " IS ")
9397 (when (vhdl-standard-p '87)
9398 (vhdl-template-field "[IN | OUT]" " " t
))
9399 (vhdl-template-field "filename-string" nil nil nil nil t
)
9401 (vhdl-comment-insert-inline))))
9403 (defun vhdl-template-for ()
9404 "Insert a block or component configuration if within a configuration
9405 declaration, a configuration specification if within an architecture
9406 declarative part (and not within a subprogram), a for-loop if within a
9407 sequential statement part (subprogram or process), and a for-generate
9410 (vhdl-prepare-search-1
9412 ((vhdl-sequential-statement-p) ; sequential statement
9413 (vhdl-template-for-loop))
9414 ((and (save-excursion ; configuration declaration
9415 (re-search-backward "^\\(configuration\\|end\\)\\>" nil t
))
9416 (equal "CONFIGURATION" (upcase (match-string 1))))
9417 (if (eq (vhdl-decision-query
9418 "for" "(b)lock or (c)omponent configuration?" t
) ?c
)
9419 (vhdl-template-component-conf)
9420 (vhdl-template-block-configuration)))
9421 ((and (save-excursion
9422 (re-search-backward ; architecture declarative part
9423 "^\\(architecture\\|entity\\|begin\\|end\\)\\>" nil t
))
9424 (equal "ARCHITECTURE" (upcase (match-string 1))))
9425 (vhdl-template-configuration-spec))
9426 (t (vhdl-template-for-generate))))) ; concurrent statement
9428 (defun vhdl-template-for-generate ()
9429 "Insert a for-generate."
9431 (let ((margin (current-indentation))
9434 (vhdl-insert-keyword ": FOR ")
9435 (setq position
(point-marker))
9437 (when (setq label
(vhdl-template-field "label" nil t start position
))
9438 (goto-char position
)
9439 (vhdl-template-field "loop variable")
9440 (vhdl-insert-keyword " IN ")
9441 (vhdl-template-field "range")
9442 (vhdl-template-generate-body margin label
))))
9444 (defun vhdl-template-for-loop ()
9445 "Insert a for loop."
9447 (let ((margin (current-indentation))
9450 (if (not (eq vhdl-optional-labels
'all
))
9451 (vhdl-insert-keyword "FOR ")
9452 (vhdl-insert-keyword ": FOR ")
9454 (setq label
(vhdl-template-field "[label]" nil t
))
9455 (unless label
(delete-char 2))
9456 (forward-word-strictly 1)
9458 (when (setq index
(vhdl-template-field "loop variable"
9459 nil t start
(point)))
9460 (vhdl-insert-keyword " IN ")
9461 (vhdl-template-field "range")
9462 (vhdl-insert-keyword " LOOP\n\n")
9464 (vhdl-insert-keyword "END LOOP")
9466 (insert " " label
";")
9468 (when vhdl-self-insert-comments
(insert " -- " index
)))
9470 (indent-to (+ margin vhdl-basic-offset
)))))
9472 (defun vhdl-template-function (&optional kind
)
9473 "Insert a function declaration or body."
9475 (let ((margin (current-indentation))
9478 (vhdl-insert-keyword "FUNCTION ")
9479 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9480 (vhdl-template-argument-list t
)
9481 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))
9484 (indent-to (+ margin vhdl-basic-offset
))
9485 (vhdl-insert-keyword "RETURN ")
9486 (vhdl-template-field "type")
9487 (if (if kind
(eq kind
'body
)
9488 (eq (vhdl-decision-query nil
"(d)eclaration or (b)ody?") ?b
))
9489 (progn (vhdl-insert-keyword " IS\n")
9490 (vhdl-template-begin-end
9491 (unless (vhdl-standard-p '87) "FUNCTION") name margin
)
9492 (vhdl-comment-block))
9495 (defun vhdl-template-function-decl ()
9496 "Insert a function declaration."
9498 (vhdl-template-function 'decl
))
9500 (defun vhdl-template-function-body ()
9501 "Insert a function declaration."
9503 (vhdl-template-function 'body
))
9505 (defun vhdl-template-generate ()
9506 "Insert a generation scheme."
9508 (if (eq (vhdl-decision-query nil
"(f)or or (i)f?" t
) ?i
)
9509 (vhdl-template-if-generate)
9510 (vhdl-template-for-generate)))
9512 (defun vhdl-template-generic ()
9513 "Insert generic declaration, or generic map in instantiation statements."
9515 (let ((start (point)))
9516 (vhdl-prepare-search-1
9518 ((and (save-excursion ; entity declaration
9519 (re-search-backward "^\\(entity\\|end\\)\\>" nil t
))
9520 (equal "ENTITY" (upcase (match-string 1))))
9521 (vhdl-template-generic-list nil
))
9522 ((or (save-excursion
9523 (or (beginning-of-line)
9524 (looking-at "^\\s-*\\w+\\s-*:\\s-*\\w+")))
9525 (equal 'statement-cont
(caar (vhdl-get-syntactic-context))))
9526 (vhdl-insert-keyword "GENERIC ")
9527 (vhdl-template-map start
))
9528 (t (vhdl-template-generic-list nil t
))))))
9530 (defun vhdl-template-group ()
9531 "Insert group or group template declaration."
9533 (let ((start (point)))
9534 (if (eq (vhdl-decision-query
9535 "group" "(d)eclaration or (t)emplate declaration?" t
) ?t
)
9536 (vhdl-template-group-template)
9537 (vhdl-template-group-decl))))
9539 (defun vhdl-template-group-decl ()
9540 "Insert group declaration."
9542 (let ((start (point)))
9543 (vhdl-insert-keyword "GROUP ")
9544 (when (vhdl-template-field "name" " : " t start
(point))
9545 (vhdl-template-field "template name" " (")
9546 (vhdl-template-field "constituent list" ");")
9547 (vhdl-comment-insert-inline))))
9549 (defun vhdl-template-group-template ()
9550 "Insert group template declaration."
9552 (let ((start (point)))
9553 (vhdl-insert-keyword "GROUP ")
9554 (when (vhdl-template-field "template name" nil t start
(point))
9555 (vhdl-insert-keyword " IS (")
9556 (vhdl-template-field "entity class list" ");")
9557 (vhdl-comment-insert-inline))))
9559 (defun vhdl-template-if ()
9560 "Insert a sequential if statement or an if-generate statement."
9562 (if (vhdl-sequential-statement-p)
9563 (vhdl-template-if-then)
9564 (if (and (vhdl-standard-p 'ams
)
9565 (eq (vhdl-decision-query "if" "(g)enerate or (u)se?" t
) ?u
))
9566 (vhdl-template-if-use)
9567 (vhdl-template-if-generate))))
9569 (defun vhdl-template-if-generate ()
9570 "Insert an if-generate."
9572 (let ((margin (current-indentation))
9575 (vhdl-insert-keyword ": IF ")
9576 (setq position
(point-marker))
9578 (when (setq label
(vhdl-template-field "label" nil t start position
))
9579 (goto-char position
)
9580 (when vhdl-conditions-in-parenthesis
(insert "("))
9581 (vhdl-template-field "condition")
9582 (when vhdl-conditions-in-parenthesis
(insert ")"))
9583 (vhdl-template-generate-body margin label
))))
9585 (defun vhdl-template-if-then-use (kind)
9586 "Insert a sequential if statement."
9588 (let ((margin (current-indentation))
9591 (if (or (not (eq vhdl-optional-labels
'all
)) (vhdl-standard-p '87))
9592 (vhdl-insert-keyword "IF ")
9593 (vhdl-insert-keyword ": IF ")
9595 (setq label
(vhdl-template-field "[label]" nil t
))
9596 (unless label
(delete-char 2))
9597 (forward-word-strictly 1)
9599 (when vhdl-conditions-in-parenthesis
(insert "("))
9600 (when (vhdl-template-field "condition" nil t start
(point))
9601 (when vhdl-conditions-in-parenthesis
(insert ")"))
9602 (vhdl-insert-keyword
9603 (concat " " (if (eq kind
'then
) "THEN" "USE") "\n\n"))
9605 (vhdl-insert-keyword (concat "END " (if (eq kind
'then
) "IF" "USE")))
9606 (when label
(insert " " label
))
9609 (indent-to (+ margin vhdl-basic-offset
)))))
9611 (defun vhdl-template-if-then ()
9612 "Insert a sequential if statement."
9614 (vhdl-template-if-then-use 'then
))
9616 (defun vhdl-template-if-use ()
9617 "Insert a simultaneous if statement."
9619 (vhdl-template-if-then-use 'use
))
9621 (defun vhdl-template-instance ()
9622 "Insert a component instantiation statement."
9624 (vhdl-template-component-inst))
9626 (defun vhdl-template-library ()
9627 "Insert a library specification."
9629 (let ((margin (current-indentation))
9632 (vhdl-insert-keyword "LIBRARY ")
9633 (when (setq name
(vhdl-template-field "names" nil t start
(point)))
9635 (unless (string-match "," name
)
9636 (setq end-pos
(point))
9639 (vhdl-insert-keyword "USE ")
9641 (vhdl-insert-keyword "..ALL;")
9643 (if (vhdl-template-field "package name")
9645 (delete-region end-pos
(+ (point) 5)))))))
9647 (defun vhdl-template-limit ()
9650 (let ((start (point)))
9651 (vhdl-insert-keyword "LIMIT ")
9652 (when (vhdl-template-field "quantity names | OTHERS | ALL" " : "
9654 (vhdl-template-field "type")
9655 (vhdl-insert-keyword " WITH ")
9656 (vhdl-template-field "real expression" ";"))))
9658 (defun vhdl-template-loop ()
9661 (let ((char (vhdl-decision-query nil
"(w)hile, (f)or, or (b)are?" t
)))
9663 (vhdl-template-while-loop))
9665 (vhdl-template-for-loop))
9666 (t (vhdl-template-bare-loop)))))
9668 (defun vhdl-template-bare-loop ()
9671 (let ((margin (current-indentation))
9674 (if (not (eq vhdl-optional-labels
'all
))
9675 (vhdl-insert-keyword "LOOP ")
9676 (vhdl-insert-keyword ": LOOP ")
9678 (setq label
(vhdl-template-field "[label]" nil t
))
9679 (unless label
(delete-char 2))
9680 (forward-word-strictly 1)
9684 (vhdl-insert-keyword "END LOOP")
9685 (insert (if label
(concat " " label
";") ";"))
9687 (indent-to (+ margin vhdl-basic-offset
))))
9689 (defun vhdl-template-map (&optional start optional secondary
)
9690 "Insert a map specification with association list."
9692 (let ((start (or start
(point)))
9694 (vhdl-insert-keyword "MAP (")
9695 (if (not vhdl-association-list-with-formals
)
9696 (if (vhdl-template-field
9697 (concat (and optional
"[") "association list" (and optional
"]"))
9698 ")" (or (not secondary
) optional
)
9699 (and (not secondary
) start
) (point))
9701 (if (and optional secondary
) (delete-region start
(point)))
9703 (if vhdl-argument-list-indent
9704 (setq margin
(current-column))
9705 (setq margin
(+ (current-indentation) vhdl-basic-offset
))
9708 (if (vhdl-template-field
9709 (concat (and optional
"[") "formal" (and optional
"]"))
9710 " => " (or (not secondary
) optional
)
9711 (and (not secondary
) start
) (point))
9713 (vhdl-template-field "actual" ",")
9714 (setq end-pos
(point))
9717 (while (vhdl-template-field "[formal]" " => " t
)
9718 (vhdl-template-field "actual" ",")
9719 (setq end-pos
(point))
9722 (delete-region end-pos
(point))
9725 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))
9727 (when (and optional secondary
) (delete-region start
(point)))
9730 (defun vhdl-template-modify (&optional noerror
)
9731 "Actualize modification date."
9733 (vhdl-prepare-search-2
9735 (goto-char (point-min))
9736 (if (re-search-forward vhdl-modify-date-prefix-string nil t
)
9737 (progn (delete-region (point) (progn (end-of-line) (point)))
9738 (vhdl-template-insert-date))
9740 (error "ERROR: Modification date prefix string \"%s\" not found"
9741 vhdl-modify-date-prefix-string
))))))
9744 (defun vhdl-template-modify-noerror ()
9745 "Call `vhdl-template-modify' with NOERROR non-nil."
9746 (vhdl-template-modify t
))
9748 (defun vhdl-template-nature ()
9749 "Insert a nature declaration."
9751 (let ((start (point))
9752 name mid-pos end-pos
)
9753 (vhdl-insert-keyword "NATURE ")
9754 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9755 (vhdl-insert-keyword " IS ")
9758 (or (vhdl-template-field
9759 "across type | ARRAY | RECORD")
9761 (cond ((equal definition
"")
9763 ((equal definition
"ARRAY")
9764 (delete-region (point) (progn (forward-word-strictly -
1)
9766 (vhdl-template-array 'nature t
))
9767 ((equal definition
"RECORD")
9768 (setq mid-pos
(point-marker))
9769 (delete-region (point) (progn (forward-word-strictly -
1)
9771 (vhdl-template-record 'nature name t
))
9773 (vhdl-insert-keyword " ACROSS ")
9774 (vhdl-template-field "through type")
9775 (vhdl-insert-keyword " THROUGH ")
9776 (vhdl-template-field "reference name")
9777 (vhdl-insert-keyword " REFERENCE;")))
9779 (setq end-pos
(point-marker))
9782 (vhdl-comment-insert-inline)
9783 (when end-pos
(goto-char end-pos
))))))
9785 (defun vhdl-template-next ()
9786 "Insert a next statement."
9788 (let ((start (point)))
9789 (vhdl-insert-keyword "NEXT ")
9790 (if (vhdl-template-field "[loop label]" nil t start
(point))
9791 (let ((position (point)))
9792 (vhdl-insert-keyword " WHEN ")
9793 (when vhdl-conditions-in-parenthesis
(insert "("))
9794 (if (vhdl-template-field "[condition]" nil t
)
9795 (when vhdl-conditions-in-parenthesis
(insert ")"))
9796 (delete-region position
(point))))
9800 (defun vhdl-template-others ()
9801 "Insert an others aggregate."
9803 (let ((start (point)))
9804 (if (or (= (preceding-char) ?\
() (not vhdl-template-invoked-by-hook
))
9805 (progn (unless vhdl-template-invoked-by-hook
(insert "("))
9806 (vhdl-insert-keyword "OTHERS => '")
9807 (when (vhdl-template-field "value" nil t start
(point))
9809 (vhdl-insert-keyword "OTHERS "))))
9811 (defun vhdl-template-package (&optional kind
)
9812 "Insert a package specification or body."
9814 (let ((margin (current-indentation))
9817 (vhdl-insert-keyword "PACKAGE ")
9818 (setq body
(if kind
(eq kind
'body
)
9819 (eq (vhdl-decision-query nil
"(d)eclaration or (b)ody?") ?b
)))
9821 (vhdl-insert-keyword "BODY ")
9822 (when (save-excursion
9823 (vhdl-prepare-search-1
9824 (vhdl-re-search-backward "\\<package \\(\\w+\\) is\\>" nil t
)))
9825 (insert (setq name
(match-string 1)))))
9827 (setq name
(vhdl-template-field "name" nil t start
(point))))
9828 (vhdl-insert-keyword " IS\n")
9829 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9830 (indent-to (+ margin vhdl-basic-offset
))
9831 (setq position
(point))
9833 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
9835 (vhdl-insert-keyword "END ")
9836 (unless (vhdl-standard-p '87)
9837 (vhdl-insert-keyword (concat "PACKAGE " (and body
"BODY "))))
9838 (insert (or name
"") ";")
9839 (goto-char position
))))
9841 (defun vhdl-template-package-decl ()
9842 "Insert a package specification."
9844 (vhdl-template-package 'decl
))
9846 (defun vhdl-template-package-body ()
9847 "Insert a package body."
9849 (vhdl-template-package 'body
))
9851 (defun vhdl-template-port ()
9852 "Insert a port declaration, or port map in instantiation statements."
9854 (let ((start (point)))
9855 (vhdl-prepare-search-1
9857 ((and (save-excursion ; entity declaration
9858 (re-search-backward "^\\(entity\\|end\\)\\>" nil t
))
9859 (equal "ENTITY" (upcase (match-string 1))))
9860 (vhdl-template-port-list nil
))
9861 ((or (save-excursion
9862 (or (beginning-of-line)
9863 (looking-at "^\\s-*\\w+\\s-*:\\s-*\\w+")))
9864 (equal 'statement-cont
(caar (vhdl-get-syntactic-context))))
9865 (vhdl-insert-keyword "PORT ")
9866 (vhdl-template-map start
))
9867 (t (vhdl-template-port-list nil
))))))
9869 (defun vhdl-template-procedural ()
9870 "Insert a procedural."
9872 (let ((margin (current-indentation))
9874 (case-fold-search t
)
9876 (vhdl-insert-keyword "PROCEDURAL ")
9877 (when (memq vhdl-optional-labels
'(process all
))
9881 (setq label
(vhdl-template-field "[label]" nil t
))
9882 (unless label
(delete-char 2))
9883 (forward-word-strictly 1)
9885 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "IS"))
9887 (vhdl-template-begin-end "PROCEDURAL" label margin
)
9888 (vhdl-comment-block)))
9890 (defun vhdl-template-procedure (&optional kind
)
9891 "Insert a procedure declaration or body."
9893 (let ((margin (current-indentation))
9896 (vhdl-insert-keyword "PROCEDURE ")
9897 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
9898 (vhdl-template-argument-list)
9899 (if (if kind
(eq kind
'body
)
9900 (eq (vhdl-decision-query nil
"(d)eclaration or (b)ody?") ?b
))
9901 (progn (vhdl-insert-keyword " IS")
9902 (when vhdl-auto-align
9903 (vhdl-align-region-groups start
(point) 1))
9904 (end-of-line) (insert "\n")
9905 (vhdl-template-begin-end
9906 (unless (vhdl-standard-p '87) "PROCEDURE")
9908 (vhdl-comment-block))
9910 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))
9913 (defun vhdl-template-procedure-decl ()
9914 "Insert a procedure declaration."
9916 (vhdl-template-procedure 'decl
))
9918 (defun vhdl-template-procedure-body ()
9919 "Insert a procedure body."
9921 (vhdl-template-procedure 'body
))
9923 (defun vhdl-template-process (&optional kind
)
9926 (let ((margin (current-indentation))
9928 (reset-kind vhdl-reset-kind
)
9929 label seq input-signals clock reset final-pos
)
9930 (setq seq
(if kind
(eq kind
'seq
)
9931 (eq (vhdl-decision-query
9932 "process" "(c)ombinational or (s)equential?" t
) ?s
)))
9933 (vhdl-insert-keyword "PROCESS ")
9934 (when (memq vhdl-optional-labels
'(process all
))
9938 (setq label
(vhdl-template-field "[label]" nil t
))
9939 (unless label
(delete-char 2))
9940 (forward-word-strictly 1)
9944 (unless (or (and (vhdl-standard-p '08) vhdl-sensitivity-list-all
9945 (progn (insert "all)") (setq input-signals
"all")))
9947 (vhdl-template-field "[sensitivity list]" ")" t
)))
9948 (setq input-signals
"")
9950 (setq clock
(or (and (not (equal "" vhdl-clock-name
))
9951 (progn (insert vhdl-clock-name
) vhdl-clock-name
))
9952 (vhdl-template-field "clock name") "<clock>"))
9953 (when (eq reset-kind
'query
)
9955 (if (eq (vhdl-decision-query
9956 "" "(a)synchronous or (s)ynchronous reset?" t
) ?a
)
9959 (when (eq reset-kind
'async
)
9961 (setq reset
(or (and (not (equal "" vhdl-reset-name
))
9962 (progn (insert vhdl-reset-name
) vhdl-reset-name
))
9963 (vhdl-template-field "reset name") "<reset>")))
9965 (unless (vhdl-standard-p '87) (vhdl-insert-keyword " IS"))
9967 (vhdl-template-begin-end "PROCESS" label margin
)
9968 (when seq
(setq reset
(vhdl-template-seq-process clock reset reset-kind
)))
9969 (when vhdl-prompt-for-comments
9970 (setq final-pos
(point-marker))
9971 (vhdl-prepare-search-2
9972 (when (and (vhdl-re-search-backward "\\<begin\\>" nil t
)
9973 (vhdl-re-search-backward "\\<process\\>" nil t
))
9976 (progn (insert "\n") (forward-line -
1))
9979 (insert "-- purpose: ")
9980 (if (not (vhdl-template-field "[description]" nil t
))
9981 (vhdl-line-kill-entire)
9984 (insert "-- type : ")
9985 (insert (if seq
"sequential" "combinational") "\n")
9987 (insert "-- inputs : ")
9989 (insert input-signals
)
9991 (when reset
(insert reset
", "))
9992 (unless (vhdl-template-field "[signal names]" nil t
)
9996 (insert "-- outputs: ")
9997 (vhdl-template-field "[signal names]" nil t
))))
9998 (goto-char final-pos
))))
10000 (defun vhdl-template-process-comb ()
10001 "Insert a combinational process."
10003 (vhdl-template-process 'comb
))
10005 (defun vhdl-template-process-seq ()
10006 "Insert a sequential process."
10008 (vhdl-template-process 'seq
))
10010 (defun vhdl-template-quantity ()
10011 "Insert a quantity declaration."
10013 (if (vhdl-in-argument-list-p)
10014 (let ((start (point)))
10015 (vhdl-insert-keyword "QUANTITY ")
10016 (when (vhdl-template-field "names" nil t start
(point))
10018 (vhdl-template-field "[IN | OUT]" " " t
)
10019 (vhdl-template-field "type")
10021 (vhdl-comment-insert-inline)))
10022 (let ((char (vhdl-decision-query
10023 "quantity" "(f)ree, (b)ranch, or (s)ource quantity?" t
)))
10024 (cond ((eq char ?f
) (vhdl-template-quantity-free))
10025 ((eq char ?b
) (vhdl-template-quantity-branch))
10026 ((eq char ?s
) (vhdl-template-quantity-source))
10027 (t (vhdl-template-undo (point) (point)))))))
10029 (defun vhdl-template-quantity-free ()
10030 "Insert a free quantity declaration."
10032 (vhdl-insert-keyword "QUANTITY ")
10033 (vhdl-template-field "names")
10035 (vhdl-template-field "type")
10036 (let ((position (point)))
10038 (unless (vhdl-template-field "[initialization]" nil t
)
10039 (delete-region position
(point)))
10041 (vhdl-comment-insert-inline)))
10043 (defun vhdl-template-quantity-branch ()
10044 "Insert a branch quantity declaration."
10047 (vhdl-insert-keyword "QUANTITY ")
10048 (when (vhdl-template-field "[across names]" " " t
)
10049 (vhdl-insert-keyword "ACROSS "))
10050 (when (vhdl-template-field "[through names]" " " t
)
10051 (vhdl-insert-keyword "THROUGH "))
10052 (vhdl-template-field "plus terminal name")
10053 (setq position
(point))
10054 (vhdl-insert-keyword " TO ")
10055 (unless (vhdl-template-field "[minus terminal name]" nil t
)
10056 (delete-region position
(point)))
10058 (vhdl-comment-insert-inline)))
10060 (defun vhdl-template-quantity-source ()
10061 "Insert a source quantity declaration."
10063 (vhdl-insert-keyword "QUANTITY ")
10064 (vhdl-template-field "names")
10066 (vhdl-template-field "type" " ")
10067 (if (eq (vhdl-decision-query nil
"(s)pectrum or (n)oise?") ?n
)
10068 (progn (vhdl-insert-keyword "NOISE ")
10069 (vhdl-template-field "power expression"))
10070 (vhdl-insert-keyword "SPECTRUM ")
10071 (vhdl-template-field "magnitude expression" ", ")
10072 (vhdl-template-field "phase expression"))
10074 (vhdl-comment-insert-inline))
10076 (defun vhdl-template-record (kind &optional name secondary
)
10077 "Insert a record type declaration."
10079 (let ((margin (current-indentation))
10082 (vhdl-insert-keyword "RECORD\n")
10083 (indent-to (+ margin vhdl-basic-offset
))
10084 (when (or (vhdl-template-field "element names"
10085 nil
(not secondary
) start
(point))
10087 (while (or first
(vhdl-template-field "[element names]" nil t
))
10089 (vhdl-template-field (if (eq kind
'type
) "type" "nature") ";")
10090 (vhdl-comment-insert-inline)
10092 (indent-to (+ margin vhdl-basic-offset
))
10094 (delete-region (line-beginning-position) (point))
10096 (vhdl-insert-keyword "END RECORD")
10097 (unless (vhdl-standard-p '87) (and name
(insert " " name
)))
10099 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1)))))
10101 (defun vhdl-template-report ()
10102 "Insert a report statement."
10104 (let ((start (point)))
10105 (vhdl-insert-keyword "REPORT ")
10106 (if (equal "\"\"" (vhdl-template-field
10107 "string expression" nil t start
(point) t
))
10109 (setq start
(point))
10110 (vhdl-insert-keyword " SEVERITY ")
10111 (unless (vhdl-template-field "[NOTE | WARNING | ERROR | FAILURE]" nil t
)
10112 (delete-region start
(point)))
10115 (defun vhdl-template-return ()
10116 "Insert a return statement."
10118 (let ((start (point)))
10119 (vhdl-insert-keyword "RETURN ")
10120 (unless (vhdl-template-field "[expression]" nil t start
(point))
10124 (defun vhdl-template-selected-signal-asst ()
10125 "Insert a selected signal assignment."
10127 (let ((margin (current-indentation))
10130 (let ((position (point)))
10131 (vhdl-insert-keyword " SELECT ")
10132 (goto-char position
))
10133 (vhdl-insert-keyword "WITH ")
10134 (when (vhdl-template-field "selector expression"
10135 nil t start
(+ (point) 7))
10136 (forward-word-strictly 1)
10139 (indent-to (+ margin vhdl-basic-offset
))
10140 (vhdl-template-field "target signal" " <= ")
10142 (indent-to (+ margin vhdl-basic-offset
))
10143 (vhdl-template-field "waveform")
10144 (vhdl-insert-keyword " WHEN ")
10145 (vhdl-template-field "choices" ",")
10147 (indent-to (+ margin vhdl-basic-offset
))
10148 (while (and choices
(vhdl-template-field "[waveform]" nil t
))
10149 (vhdl-insert-keyword " WHEN ")
10150 (if (setq choices
(vhdl-template-field "[choices]" "," t
))
10151 (progn (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
10152 (vhdl-insert-keyword "OTHERS")))
10157 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1)))))
10159 (defun vhdl-template-signal ()
10160 "Insert a signal declaration."
10162 (let ((start (point))
10163 (in-arglist (vhdl-in-argument-list-p)))
10164 (vhdl-insert-keyword "SIGNAL ")
10165 (when (vhdl-template-field "names" nil t start
(point))
10167 (when in-arglist
(vhdl-template-field "[IN | OUT | INOUT]" " " t
))
10168 (vhdl-template-field "type")
10170 (progn (insert ";")
10171 (vhdl-comment-insert-inline))
10172 (let ((position (point)))
10174 (unless (vhdl-template-field "[initialization]" nil t
)
10175 (delete-region position
(point)))
10177 (vhdl-comment-insert-inline))))))
10179 (defun vhdl-template-subnature ()
10180 "Insert a subnature declaration."
10182 (let ((start (point))
10184 (vhdl-insert-keyword "SUBNATURE ")
10185 (when (vhdl-template-field "name" nil t start
(point))
10186 (vhdl-insert-keyword " IS ")
10187 (vhdl-template-field "nature" " (")
10188 (if (vhdl-template-field "[index range]" nil t
)
10191 (setq position
(point))
10192 (vhdl-insert-keyword " TOLERANCE ")
10193 (if (equal "\"\"" (vhdl-template-field "[string expression]"
10195 (delete-region position
(point))
10196 (vhdl-insert-keyword " ACROSS ")
10197 (vhdl-template-field "string expression" nil nil nil nil t
)
10198 (vhdl-insert-keyword " THROUGH"))
10200 (vhdl-comment-insert-inline))))
10202 (defun vhdl-template-subprogram-body ()
10203 "Insert a subprogram body."
10205 (if (eq (vhdl-decision-query nil
"(p)rocedure or (f)unction?" t
) ?f
)
10206 (vhdl-template-function-body)
10207 (vhdl-template-procedure-body)))
10209 (defun vhdl-template-subprogram-decl ()
10210 "Insert a subprogram declaration."
10212 (if (eq (vhdl-decision-query nil
"(p)rocedure or (f)unction?" t
) ?f
)
10213 (vhdl-template-function-decl)
10214 (vhdl-template-procedure-decl)))
10216 (defun vhdl-template-subtype ()
10217 "Insert a subtype declaration."
10219 (let ((start (point)))
10220 (vhdl-insert-keyword "SUBTYPE ")
10221 (when (vhdl-template-field "name" nil t start
(point))
10222 (vhdl-insert-keyword " IS ")
10223 (vhdl-template-field "type" " ")
10225 (vhdl-template-field "[RANGE value range | ( index range )]" nil t
)
10228 (vhdl-comment-insert-inline))))
10230 (defun vhdl-template-terminal ()
10231 "Insert a terminal declaration."
10233 (let ((start (point)))
10234 (vhdl-insert-keyword "TERMINAL ")
10235 (when (vhdl-template-field "names" nil t start
(point))
10237 (vhdl-template-field "nature")
10239 (vhdl-comment-insert-inline))))
10241 (defun vhdl-template-type ()
10242 "Insert a type declaration."
10244 (let ((start (point))
10245 name mid-pos end-pos
)
10246 (vhdl-insert-keyword "TYPE ")
10247 (when (setq name
(vhdl-template-field "name" nil t start
(point)))
10248 (vhdl-insert-keyword " IS ")
10251 (or (vhdl-template-field
10252 "[scalar type | ARRAY | RECORD | ACCESS | FILE | ENUM]" nil t
)
10254 (cond ((equal definition
"")
10257 ((equal definition
"ARRAY")
10258 (delete-region (point) (progn (forward-word-strictly -
1)
10260 (vhdl-template-array 'type t
))
10261 ((equal definition
"RECORD")
10262 (setq mid-pos
(point-marker))
10263 (delete-region (point) (progn (forward-word-strictly -
1)
10265 (vhdl-template-record 'type name t
))
10266 ((equal definition
"ACCESS")
10268 (vhdl-template-field "type" ";"))
10269 ((equal definition
"FILE")
10270 (vhdl-insert-keyword " OF ")
10271 (vhdl-template-field "type" ";"))
10272 ((equal definition
"ENUM")
10275 (setq end-pos
(point-marker))
10279 (setq end-pos
(point-marker))
10280 (goto-char mid-pos
)
10282 (vhdl-comment-insert-inline)
10283 (when end-pos
(goto-char end-pos
))))))
10285 (defun vhdl-template-use ()
10286 "Insert a use clause."
10288 (let ((start (point)))
10289 (vhdl-prepare-search-1
10290 (vhdl-insert-keyword "USE ")
10291 (when (save-excursion (beginning-of-line) (looking-at "^\\s-*use\\>"))
10292 (vhdl-insert-keyword "..ALL;")
10294 (when (vhdl-template-field "library name" nil t start
(+ (point) 6))
10296 (vhdl-template-field "package name")
10297 (forward-char 5))))))
10299 (defun vhdl-template-variable ()
10300 "Insert a variable declaration."
10302 (let ((start (point))
10303 (in-arglist (vhdl-in-argument-list-p)))
10304 (vhdl-prepare-search-2
10305 (if (or (save-excursion
10306 (progn (vhdl-beginning-of-block)
10307 (looking-at "\\s-*\\(\\w+\\s-*:\\s-*\\)?\\<\\(\\<function\\|procedure\\|process\\|procedural\\)\\>")))
10308 (save-excursion (backward-word-strictly 1)
10309 (looking-at "\\<shared\\>")))
10310 (vhdl-insert-keyword "VARIABLE ")
10311 (if (vhdl-standard-p '87)
10312 (error "ERROR: Not within sequential block")
10313 (vhdl-insert-keyword "SHARED VARIABLE "))))
10314 (when (vhdl-template-field "names" nil t start
(point))
10316 (when in-arglist
(vhdl-template-field "[IN | OUT | INOUT]" " " t
))
10317 (vhdl-template-field "type")
10319 (progn (insert ";")
10320 (vhdl-comment-insert-inline))
10321 (let ((position (point)))
10323 (unless (vhdl-template-field "[initialization]" nil t
)
10324 (delete-region position
(point)))
10326 (vhdl-comment-insert-inline))))))
10328 (defun vhdl-template-wait ()
10329 "Insert a wait statement."
10331 (vhdl-insert-keyword "WAIT ")
10332 (unless (vhdl-template-field
10333 "[ON sensitivity list] [UNTIL condition] [FOR time expression]"
10338 (defun vhdl-template-when ()
10339 "Indent correctly if within a case statement."
10341 (let ((position (point))
10343 (vhdl-prepare-search-2
10344 (if (and (= (current-column) (current-indentation))
10345 (vhdl-re-search-forward "\\<end\\>" nil t
)
10346 (looking-at "\\s-*\\<case\\>"))
10348 (setq margin
(current-indentation))
10349 (goto-char position
)
10350 (delete-horizontal-space)
10351 (indent-to (+ margin vhdl-basic-offset
)))
10352 (goto-char position
)))
10353 (vhdl-insert-keyword "WHEN ")))
10355 (defun vhdl-template-while-loop ()
10356 "Insert a while loop."
10358 (let* ((margin (current-indentation))
10361 (if (not (eq vhdl-optional-labels
'all
))
10362 (vhdl-insert-keyword "WHILE ")
10363 (vhdl-insert-keyword ": WHILE ")
10365 (setq label
(vhdl-template-field "[label]" nil t
))
10366 (unless label
(delete-char 2))
10367 (forward-word-strictly 1)
10369 (when vhdl-conditions-in-parenthesis
(insert "("))
10370 (when (vhdl-template-field "condition" nil t start
(point))
10371 (when vhdl-conditions-in-parenthesis
(insert ")"))
10372 (vhdl-insert-keyword " LOOP\n\n")
10374 (vhdl-insert-keyword "END LOOP")
10375 (insert (if label
(concat " " label
";") ";"))
10377 (indent-to (+ margin vhdl-basic-offset
)))))
10379 (defun vhdl-template-with ()
10380 "Insert a with statement (i.e. selected signal assignment)."
10382 (vhdl-prepare-search-1
10383 (if (and (save-excursion (vhdl-re-search-backward "\\(\\<limit\\>\\|;\\)"))
10384 (equal ";" (match-string 1)))
10385 (vhdl-template-selected-signal-asst)
10386 (vhdl-insert-keyword "WITH "))))
10388 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10389 ;; Special templates
10391 (defun vhdl-template-clocked-wait ()
10392 "Insert a wait statement for rising/falling clock edge."
10394 (let ((start (point))
10396 (vhdl-insert-keyword "WAIT UNTIL ")
10398 (or (and (not (equal "" vhdl-clock-name
))
10399 (progn (insert vhdl-clock-name
) vhdl-clock-name
))
10400 (vhdl-template-field "clock name" nil t start
(point))))
10402 (vhdl-insert-keyword " AND ")
10405 " = " (if vhdl-clock-rising-edge vhdl-one-string vhdl-zero-string
) ";")
10406 (vhdl-comment-insert-inline
10407 (concat (if vhdl-clock-rising-edge
"rising" "falling")
10410 (defun vhdl-template-seq-process (clock reset reset-kind
)
10411 "Insert a template for the body of a sequential process."
10412 (let ((margin (current-indentation))
10414 (vhdl-insert-keyword "IF ")
10415 (when vhdl-conditions-in-parenthesis
(insert "("))
10416 (when (eq reset-kind
'async
)
10417 (insert reset
" = "
10418 (if vhdl-reset-active-high vhdl-one-string vhdl-zero-string
))
10419 (when vhdl-conditions-in-parenthesis
(insert ")"))
10420 (vhdl-insert-keyword " THEN")
10421 (vhdl-comment-insert-inline
10422 (concat "asynchronous reset (active "
10423 (if vhdl-reset-active-high
"high" "low") ")"))
10424 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
10425 (setq position
(point))
10426 (insert "\n") (indent-to margin
)
10427 (vhdl-insert-keyword "ELSIF ")
10428 (when vhdl-conditions-in-parenthesis
(insert "(")))
10429 (if (eq vhdl-clock-edge-condition
'function
)
10430 (insert (if vhdl-clock-rising-edge
"rising" "falling")
10431 "_edge(" clock
")")
10432 (insert clock
"'event")
10433 (vhdl-insert-keyword " AND ")
10434 (insert clock
" = "
10435 (if vhdl-clock-rising-edge vhdl-one-string vhdl-zero-string
)))
10436 (when vhdl-conditions-in-parenthesis
(insert ")"))
10437 (vhdl-insert-keyword " THEN")
10438 (vhdl-comment-insert-inline
10439 (concat (if vhdl-clock-rising-edge
"rising" "falling") " clock edge"))
10440 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
10441 (when (eq reset-kind
'sync
)
10442 (vhdl-insert-keyword "IF ")
10443 (when vhdl-conditions-in-parenthesis
(insert "("))
10444 (setq reset
(or (and (not (equal "" vhdl-reset-name
))
10445 (progn (insert vhdl-reset-name
) vhdl-reset-name
))
10446 (vhdl-template-field "reset name") "<reset>"))
10448 (if vhdl-reset-active-high vhdl-one-string vhdl-zero-string
))
10449 (when vhdl-conditions-in-parenthesis
(insert ")"))
10450 (vhdl-insert-keyword " THEN")
10451 (vhdl-comment-insert-inline
10452 (concat "synchronous reset (active "
10453 (if vhdl-reset-active-high
"high" "low") ")"))
10454 (insert "\n") (indent-to (+ margin
(* 2 vhdl-basic-offset
)))
10455 (setq position
(point))
10456 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
10457 (vhdl-insert-keyword "ELSE")
10458 (insert "\n") (indent-to (+ margin
(* 2 vhdl-basic-offset
)))
10459 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
10460 (vhdl-insert-keyword "END IF;"))
10461 (when (eq reset-kind
'none
)
10462 (setq position
(point)))
10463 (insert "\n") (indent-to margin
)
10464 (vhdl-insert-keyword "END IF;")
10465 (goto-char position
)
10468 (defun vhdl-template-standard-package (library package
)
10469 "Insert specification of a standard package. Include a library
10470 specification, if not already there."
10471 (let ((margin (current-indentation)))
10472 (unless (equal library
"std")
10473 (unless (or (save-excursion
10474 (vhdl-prepare-search-1
10476 (re-search-backward
10477 (concat "^\\s-*\\(\\(library\\)\\s-+\\(\\w+\\s-*,\\s-*\\)*"
10478 library
"\\|end\\)\\>") nil t
)
10479 (match-string 2))))
10480 (equal (downcase library
) "work"))
10481 (vhdl-insert-keyword "LIBRARY ")
10482 (insert library
";")
10485 (indent-to margin
))))
10487 (vhdl-insert-keyword "USE ")
10488 (insert library
"." package
)
10489 (vhdl-insert-keyword ".ALL;"))))
10491 (defun vhdl-template-package-numeric-bit ()
10492 "Insert specification of `numeric_bit' package."
10494 (vhdl-template-standard-package "ieee" "numeric_bit"))
10496 (defun vhdl-template-package-numeric-std ()
10497 "Insert specification of `numeric_std' package."
10499 (vhdl-template-standard-package "ieee" "numeric_std"))
10501 (defun vhdl-template-package-std-logic-1164 ()
10502 "Insert specification of `std_logic_1164' package."
10504 (vhdl-template-standard-package "ieee" "std_logic_1164"))
10506 (defun vhdl-template-package-std-logic-arith ()
10507 "Insert specification of `std_logic_arith' package."
10509 (vhdl-template-standard-package "ieee" "std_logic_arith"))
10511 (defun vhdl-template-package-std-logic-misc ()
10512 "Insert specification of `std_logic_misc' package."
10514 (vhdl-template-standard-package "ieee" "std_logic_misc"))
10516 (defun vhdl-template-package-std-logic-signed ()
10517 "Insert specification of `std_logic_signed' package."
10519 (vhdl-template-standard-package "ieee" "std_logic_signed"))
10521 (defun vhdl-template-package-std-logic-textio ()
10522 "Insert specification of `std_logic_textio' package."
10524 (vhdl-template-standard-package "ieee" "std_logic_textio"))
10526 (defun vhdl-template-package-std-logic-unsigned ()
10527 "Insert specification of `std_logic_unsigned' package."
10529 (vhdl-template-standard-package "ieee" "std_logic_unsigned"))
10531 (defun vhdl-template-package-textio ()
10532 "Insert specification of `textio' package."
10534 (vhdl-template-standard-package "std" "textio"))
10536 (defun vhdl-template-package-fundamental-constants ()
10537 "Insert specification of `fundamental_constants' package."
10539 (vhdl-template-standard-package "ieee" "fundamental_constants"))
10541 (defun vhdl-template-package-material-constants ()
10542 "Insert specification of `material_constants' package."
10544 (vhdl-template-standard-package "ieee" "material_constants"))
10546 (defun vhdl-template-package-energy-systems ()
10547 "Insert specification of `energy_systems' package."
10549 (vhdl-template-standard-package "ieee" "energy_systems"))
10551 (defun vhdl-template-package-electrical-systems ()
10552 "Insert specification of `electrical_systems' package."
10554 (vhdl-template-standard-package "ieee" "electrical_systems"))
10556 (defun vhdl-template-package-mechanical-systems ()
10557 "Insert specification of `mechanical_systems' package."
10559 (vhdl-template-standard-package "ieee" "mechanical_systems"))
10561 (defun vhdl-template-package-radiant-systems ()
10562 "Insert specification of `radiant_systems' package."
10564 (vhdl-template-standard-package "ieee" "radiant_systems"))
10566 (defun vhdl-template-package-thermal-systems ()
10567 "Insert specification of `thermal_systems' package."
10569 (vhdl-template-standard-package "ieee" "thermal_systems"))
10571 (defun vhdl-template-package-fluidic-systems ()
10572 "Insert specification of `fluidic_systems' package."
10574 (vhdl-template-standard-package "ieee" "fluidic_systems"))
10576 (defun vhdl-template-package-math-complex ()
10577 "Insert specification of `math_complex' package."
10579 (vhdl-template-standard-package "ieee" "math_complex"))
10581 (defun vhdl-template-package-math-real ()
10582 "Insert specification of `math_real' package."
10584 (vhdl-template-standard-package "ieee" "math_real"))
10586 (defun vhdl-template-directive (directive)
10587 "Insert directive."
10588 (unless (= (current-indentation) (current-column))
10589 (delete-horizontal-space)
10591 (insert "-- pragma " directive
))
10593 (defun vhdl-template-directive-translate-on ()
10594 "Insert directive `translate_on'."
10596 (vhdl-template-directive "translate_on"))
10598 (defun vhdl-template-directive-translate-off ()
10599 "Insert directive `translate_off'."
10601 (vhdl-template-directive "translate_off"))
10603 (defun vhdl-template-directive-synthesis-on ()
10604 "Insert directive `synthesis_on'."
10606 (vhdl-template-directive "synthesis_on"))
10608 (defun vhdl-template-directive-synthesis-off ()
10609 "Insert directive `synthesis_off'."
10611 (vhdl-template-directive "synthesis_off"))
10613 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10614 ;; Header and footer templates
10616 (defun vhdl-template-header (&optional file-title
)
10617 "Insert a VHDL file header."
10619 (unless (equal vhdl-file-header
"")
10622 (goto-char (point-min))
10623 (vhdl-insert-string-or-file vhdl-file-header
)
10624 (setq pos
(point-marker)))
10625 (vhdl-template-replace-header-keywords
10626 (point-min-marker) pos file-title
))))
10628 (defun vhdl-template-footer ()
10629 "Insert a VHDL file footer."
10631 (unless (equal vhdl-file-footer
"")
10634 (goto-char (point-max))
10635 (setq pos
(point-marker))
10636 (vhdl-insert-string-or-file vhdl-file-footer
)
10637 (unless (= (preceding-char) ?
\n)
10639 (vhdl-template-replace-header-keywords pos
(point-max-marker)))))
10641 (defun vhdl-template-replace-header-keywords (beg end
&optional file-title
10643 "Replace keywords in header and footer."
10644 (let ((project-title (or (nth 0 (vhdl-aget vhdl-project-alist vhdl-project
))
10646 (project-desc (or (nth 9 (vhdl-aget vhdl-project-alist vhdl-project
))
10649 (vhdl-prepare-search-2
10652 (while (search-forward "<projectdesc>" end t
)
10653 (replace-match project-desc t t
))
10655 (while (search-forward "<filename>" end t
)
10656 (replace-match (buffer-name) t t
))
10658 (while (search-forward "<copyright>" end t
)
10659 (replace-match vhdl-copyright-string t t
))
10661 (while (search-forward "<author>" end t
)
10662 (replace-match "" t t
)
10663 (insert (user-full-name))
10664 (when user-mail-address
(insert " <" user-mail-address
">")))
10666 (while (search-forward "<authorfull>" end t
)
10667 (replace-match (user-full-name) t t
))
10669 (while (search-forward "<login>" end t
)
10670 (replace-match (user-login-name) t t
))
10672 (while (search-forward "<project>" end t
)
10673 (replace-match project-title t t
))
10675 (while (search-forward "<company>" end t
)
10676 (replace-match vhdl-company-name t t
))
10678 (while (search-forward "<platform>" end t
)
10679 (replace-match vhdl-platform-spec t t
))
10681 (while (search-forward "<standard>" end t
)
10683 (concat "VHDL" (cond ((vhdl-standard-p '87) "'87")
10684 ((vhdl-standard-p '93) "'93/02")
10685 ((vhdl-standard-p '08) "'08"))
10686 (when (vhdl-standard-p 'ams
) ", VHDL-AMS")
10687 (when (vhdl-standard-p 'math
) ", Math Packages")) t t
))
10689 ;; Replace <RCS> with $, so that RCS for the source is
10690 ;; not over-enthusiastic with replacements
10691 (while (search-forward "<RCS>" end t
)
10692 (replace-match "$" nil t
))
10694 (while (search-forward "<date>" end t
)
10695 (replace-match "" t t
)
10696 (vhdl-template-insert-date))
10698 (while (search-forward "<year>" end t
)
10699 (replace-match (format-time-string "%Y" nil
) t t
))
10702 (while (search-forward "<title string>" end t
)
10703 (replace-match file-title t t
))
10706 (while (re-search-forward "<\\(\\(\\w\\|\\s_\\)*\\) string>" end t
)
10708 (setq string
(read-string (concat (match-string 1) ": "))))
10709 (replace-match string t t
)))
10711 (when (and (not is-model
) (search-forward "<cursor>" end t
))
10712 (replace-match "" t t
)
10713 (setq pos
(point))))
10714 (when pos
(goto-char pos
))
10716 (when (or (not project-title
) (equal project-title
""))
10717 (message "You can specify a project title in user option `vhdl-project-alist'"))
10718 (when (or (not project-desc
) (equal project-desc
""))
10719 (message "You can specify a project description in user option `vhdl-project-alist'"))
10720 (when (equal vhdl-platform-spec
"")
10721 (message "You can specify a platform in user option `vhdl-platform-spec'"))
10722 (when (equal vhdl-company-name
"")
10723 (message "You can specify a company name in user option `vhdl-company-name'"))))))
10725 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10726 ;; Comment templates and functions
10728 (defun vhdl-comment-indent ()
10730 (let* ((position (point))
10734 (if (re-search-forward "--" position t
)
10735 (- (current-column) 2) ; existing comment at bol stays there
10736 (goto-char position
)
10737 (skip-chars-backward " \t")
10738 (max comment-column
; else indent to comment column
10739 (1+ (current-column))))))) ; except leave at least one space
10740 (goto-char position
)
10743 (defun vhdl-comment-insert ()
10744 "Start a comment at the end of the line.
10745 If on line with code, indent at least `comment-column'.
10746 If starting after end-comment-column, start a new line."
10748 (when (> (current-column) end-comment-column
) (newline-and-indent))
10749 (if (or (looking-at "\\s-*$") ; end of line
10750 (and (not unread-command-events
) ; called with key binding or menu
10751 (not (end-of-line))))
10753 (while (= (preceding-char) ?-
) (delete-char -
1))
10754 (setq margin
(current-column))
10755 (delete-horizontal-space)
10757 (progn (indent-to margin
) (insert "--"))
10759 (indent-to comment-column
)
10761 (if (not unread-command-events
) (insert " ")))
10762 ;; else code following current point implies commenting out code
10763 (let (next-input code
)
10764 (while (= (preceding-char) ?-
) (delete-char -
2))
10765 (while (= (setq next-input
(read-char)) 13) ; CR
10766 (insert "--") ; or have a space after it?
10769 (message "Enter CR if commenting out a line of code.")
10772 (insert "--")) ; hardwire to 1 space or use vhdl-basic-offset?
10773 (push (vhdl-character-to-event next-input
) ; pushback the char
10774 unread-command-events
))))
10776 (defun vhdl-comment-display (&optional line-exists
)
10777 "Add 2 comment lines at the current indent, making a display comment."
10779 (let ((margin (current-indentation)))
10780 (unless line-exists
(vhdl-comment-display-line))
10781 (insert "\n") (indent-to margin
)
10782 (insert "\n") (indent-to margin
)
10783 (vhdl-comment-display-line)
10787 (defun vhdl-comment-display-line ()
10788 "Displays one line of dashes."
10790 (while (= (preceding-char) ?-
) (delete-char -
2))
10792 (let* ((col (current-column))
10793 (len (- end-comment-column col
)))
10794 (insert-char vhdl-comment-display-line-char len
)))
10796 (defun vhdl-comment-append-inline ()
10797 "Append empty inline comment to current line."
10800 (delete-horizontal-space)
10802 (indent-to comment-column
)
10805 (defun vhdl-comment-insert-inline (&optional string always-insert
)
10806 "Insert inline comment."
10807 (when (or (and string
(or vhdl-self-insert-comments always-insert
))
10808 (and (not string
) vhdl-prompt-for-comments
))
10809 (let ((position (point)))
10811 (indent-to comment-column
)
10813 (if (not (or (and string
(progn (insert string
) t
))
10814 (vhdl-template-field "[comment]" nil t
)))
10815 (delete-region position
(point))
10816 (while (= (preceding-char) ?\
) (delete-char -
1))))))
10818 (defun vhdl-comment-block ()
10819 "Insert comment for code block."
10820 (when vhdl-prompt-for-comments
10821 (let ((final-pos (point-marker)))
10822 (vhdl-prepare-search-2
10823 (when (and (re-search-backward "^\\s-*begin\\>" nil t
)
10824 (re-search-backward "\\<\\(architecture\\|block\\|function\\|procedure\\|process\\|procedural\\)\\>" nil t
))
10826 (back-to-indentation)
10827 (setq margin
(current-column))
10830 (progn (insert "\n") (forward-line -
1))
10833 (insert "-- purpose: ")
10834 (unless (vhdl-template-field "[description]" nil t
)
10835 (vhdl-line-kill-entire)))))
10836 (goto-char final-pos
))))
10838 (defun vhdl-comment-uncomment-region (beg end
&optional arg
)
10839 "Comment out region if not commented out, uncomment otherwise."
10840 (interactive "r\nP")
10842 (goto-char (1- end
))
10844 (setq end
(point-marker))
10846 (beginning-of-line)
10848 (if (looking-at (concat "\\s-*" comment-start
))
10849 (comment-region beg end
'(4))
10850 (comment-region beg end
))))
10852 (defun vhdl-comment-uncomment-line (&optional arg
)
10853 "Comment out line if not commented out, uncomment otherwise."
10856 (beginning-of-line)
10857 (let ((position (point)))
10858 (forward-line (or arg
1))
10859 (vhdl-comment-uncomment-region position
(point)))))
10861 (defun vhdl-comment-kill-region (beg end
)
10862 "Kill comments in region."
10866 (setq end
(point-marker))
10868 (beginning-of-line)
10869 (while (< (point) end
)
10870 (if (looking-at "^\\(\\s-*--.*\n\\)")
10871 (progn (delete-region (match-beginning 1) (match-end 1)))
10872 (beginning-of-line 2)))))
10874 (defun vhdl-comment-kill-inline-region (beg end
)
10875 "Kill inline comments in region."
10879 (setq end
(point-marker))
10881 (beginning-of-line)
10882 (while (< (point) end
)
10883 (when (looking-at "^.*[^ \t\n\r\f-]+\\(\\s-*--.*\\)$")
10884 (delete-region (match-beginning 1) (match-end 1)))
10885 (beginning-of-line 2))))
10887 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10890 (defun vhdl-template-begin-end (construct name margin
&optional empty-lines
)
10891 "Insert a begin ... end pair with optional name after the end.
10892 Point is left between them."
10894 (when (or empty-lines
(eq vhdl-insert-empty-lines
'all
)) (insert "\n"))
10896 (vhdl-insert-keyword "BEGIN")
10897 (when (and (or construct name
) vhdl-self-insert-comments
)
10899 (when construct
(insert " ") (vhdl-insert-keyword construct
))
10900 (when name
(insert " " name
)))
10902 (when (or empty-lines
(eq vhdl-insert-empty-lines
'all
)) (insert "\n"))
10903 (indent-to (+ margin vhdl-basic-offset
))
10904 (setq position
(point))
10906 (when (or empty-lines
(eq vhdl-insert-empty-lines
'all
)) (insert "\n"))
10908 (vhdl-insert-keyword "END")
10909 (when construct
(insert " ") (vhdl-insert-keyword construct
))
10910 (insert (if name
(concat " " name
) "") ";")
10911 (goto-char position
)))
10913 (defun vhdl-template-argument-list (&optional is-function
)
10914 "Read from user a procedure or function argument list."
10916 (let ((margin (current-column))
10919 not-empty interface semicolon-pos
)
10920 (unless vhdl-argument-list-indent
10921 (setq margin
(+ (current-indentation) vhdl-basic-offset
))
10923 (indent-to margin
))
10924 (setq interface
(vhdl-template-field
10925 (concat "[CONSTANT | SIGNAL"
10926 (unless is-function
" | VARIABLE") "]") " " t
))
10927 (while (vhdl-template-field "[names]" nil t
)
10930 (unless is-function
10931 (if (and interface
(equal (upcase interface
) "CONSTANT"))
10932 (vhdl-insert-keyword "IN ")
10933 (vhdl-template-field "[IN | OUT | INOUT]" " " t
)))
10934 (vhdl-template-field "type")
10935 (setq semicolon-pos
(point))
10937 (vhdl-comment-insert-inline)
10938 (setq end-pos
(point))
10941 (setq interface
(vhdl-template-field
10942 (concat "[CONSTANT | SIGNAL"
10943 (unless is-function
" | VARIABLE") "]") " " t
)))
10944 (delete-region end-pos
(point))
10945 (when semicolon-pos
(goto-char semicolon-pos
))
10947 (progn (delete-char 1) (insert ")"))
10948 (delete-char -
2))))
10950 (defun vhdl-template-generic-list (optional &optional no-value
)
10951 "Read from user a generic spec argument list."
10954 (vhdl-insert-keyword "GENERIC (")
10955 (setq margin
(current-column))
10956 (unless vhdl-argument-list-indent
10957 (let ((position (point)))
10958 (back-to-indentation)
10959 (setq margin
(+ (current-column) vhdl-basic-offset
))
10960 (goto-char position
)
10962 (indent-to margin
)))
10963 (let ((vhdl-generics (vhdl-template-field
10964 (concat (and optional
"[") "name"
10965 (and no-value
"s") (and optional
"]"))
10967 (if (not vhdl-generics
)
10969 (progn (vhdl-line-kill-entire) (end-of-line -
0)
10970 (unless vhdl-argument-list-indent
10971 (vhdl-line-kill-entire) (end-of-line -
0)))
10972 (vhdl-template-undo start
(point))
10975 (let (semicolon-pos end-pos
)
10976 (while vhdl-generics
10977 (vhdl-template-field "type")
10979 (progn (setq semicolon-pos
(point))
10982 (unless (vhdl-template-field "[value]" nil t
)
10984 (setq semicolon-pos
(point))
10986 (vhdl-comment-insert-inline)
10987 (setq end-pos
(point))
10990 (setq vhdl-generics
(vhdl-template-field
10991 (concat "[name" (and no-value
"s") "]")
10993 (delete-region end-pos
(point))
10994 (goto-char semicolon-pos
)
10997 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))
11000 (defun vhdl-template-port-list (optional)
11001 "Read from user a port spec argument list."
11002 (let ((start (point))
11003 margin vhdl-ports object
)
11004 (vhdl-insert-keyword "PORT (")
11005 (setq margin
(current-column))
11006 (unless vhdl-argument-list-indent
11007 (let ((position (point)))
11008 (back-to-indentation)
11009 (setq margin
(+ (current-column) vhdl-basic-offset
))
11010 (goto-char position
)
11012 (indent-to margin
)))
11013 (when (vhdl-standard-p 'ams
)
11014 (setq object
(vhdl-template-field "[SIGNAL | TERMINAL | QUANTITY]"
11016 (setq vhdl-ports
(vhdl-template-field
11017 (concat (and optional
"[") "names" (and optional
"]"))
11019 (if (not vhdl-ports
)
11021 (progn (vhdl-line-kill-entire) (end-of-line -
0)
11022 (unless vhdl-argument-list-indent
11023 (vhdl-line-kill-entire) (end-of-line -
0)))
11024 (vhdl-template-undo start
(point))
11027 (let (semicolon-pos end-pos
)
11029 (cond ((or (null object
) (equal "SIGNAL" (upcase object
)))
11030 (vhdl-template-field "IN | OUT | INOUT" " "))
11031 ((equal "QUANTITY" (upcase object
))
11032 (vhdl-template-field "[IN | OUT]" " " t
)))
11033 (vhdl-template-field
11034 (if (and object
(equal "TERMINAL" (upcase object
)))
11036 (setq semicolon-pos
(point))
11038 (vhdl-comment-insert-inline)
11039 (setq end-pos
(point))
11042 (when (vhdl-standard-p 'ams
)
11043 (setq object
(vhdl-template-field "[SIGNAL | TERMINAL | QUANTITY]"
11045 (setq vhdl-ports
(vhdl-template-field "[names]" " : " t
)))
11046 (delete-region end-pos
(point))
11047 (goto-char semicolon-pos
)
11050 (when vhdl-auto-align
(vhdl-align-region-groups start end-pos
1))
11053 (defun vhdl-template-generate-body (margin label
)
11054 "Insert body for generate template."
11055 (vhdl-insert-keyword " GENERATE")
11058 (vhdl-insert-keyword "END GENERATE ")
11061 (indent-to (+ margin vhdl-basic-offset
)))
11063 (defun vhdl-template-insert-date ()
11064 "Insert date in appropriate format."
11068 ;; 'american, 'european, 'scientific kept for backward compatibility
11069 ((eq vhdl-date-format
'american
) (format-time-string "%m/%d/%Y" nil
))
11070 ((eq vhdl-date-format
'european
) (format-time-string "%d.%m.%Y" nil
))
11071 ((eq vhdl-date-format
'scientific
) (format-time-string "%Y/%m/%d" nil
))
11072 (t (format-time-string vhdl-date-format nil
)))))
11074 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11077 (defun vhdl-electric-space (count)
11078 "Expand abbreviations and self-insert space(s), do indent-new-comment-line
11079 if in comment and past end-comment-column."
11081 (cond ((vhdl-in-comment-p)
11082 (self-insert-command count
)
11083 (cond ((>= (current-column) (+ 2 end-comment-column
))
11085 (skip-chars-backward "^ \t\n\r\f")
11086 (indent-new-comment-line)
11087 (skip-chars-forward "^ \t\n\r\f")
11089 ((>= (current-column) end-comment-column
)
11090 (indent-new-comment-line))
11092 ((or (and (>= (preceding-char) ?a
) (<= (preceding-char) ?z
))
11093 (and (>= (preceding-char) ?A
) (<= (preceding-char) ?Z
)))
11094 (vhdl-prepare-search-1
11095 (or (expand-abbrev) (vhdl-fix-case-word -
1)))
11096 (self-insert-command count
))
11097 (t (self-insert-command count
))))
11099 (defun vhdl-template-field (prompt &optional follow-string optional
11100 begin end is-string default
)
11101 "Prompt for string and insert it in buffer with optional FOLLOW-STRING.
11102 If OPTIONAL is nil, the prompt is left if an empty string is inserted. If
11103 an empty string is inserted, return nil and call `vhdl-template-undo' for
11104 the region between BEGIN and END. IS-STRING indicates whether a string
11105 with double-quotes is to be inserted. DEFAULT specifies a default string."
11106 (let ((position (point))
11108 (insert "<" prompt
">")
11111 (read-from-minibuffer (concat prompt
": ")
11112 (or (and is-string
'("\"\"" .
2)) default
)
11113 vhdl-minibuffer-local-map
)
11114 (quit (if (and optional begin end
)
11116 (keyboard-quit)))))
11117 (when (or (not (equal string
"")) optional
)
11118 (delete-region position
(point)))
11119 (when (and (equal string
"") optional begin end
)
11120 (vhdl-template-undo begin end
)
11121 (message "Template aborted"))
11122 (unless (equal string
"")
11124 (vhdl-fix-case-region-1 position
(point) vhdl-upper-case-keywords
11125 vhdl-keywords-regexp
)
11126 (vhdl-fix-case-region-1 position
(point) vhdl-upper-case-types
11128 (vhdl-fix-case-region-1 position
(point) vhdl-upper-case-attributes
11129 (concat "'" vhdl-attributes-regexp
))
11130 (vhdl-fix-case-region-1 position
(point) vhdl-upper-case-enum-values
11131 vhdl-enum-values-regexp
)
11132 (vhdl-fix-case-region-1 position
(point) vhdl-upper-case-constants
11133 vhdl-constants-regexp
))
11134 (when (or (not (equal string
"")) (not optional
))
11135 (insert (or follow-string
"")))
11136 (if (equal string
"") nil string
)))
11138 (defun vhdl-decision-query (string prompt
&optional optional
)
11139 "Query a decision from the user."
11140 (let ((start (point)))
11141 (when string
(vhdl-insert-keyword (concat string
" ")))
11142 (message "%s" (or prompt
""))
11143 (let ((char (read-char)))
11144 (delete-region start
(point))
11145 (if (and optional
(eq char ?
\r))
11146 (progn (insert " ")
11148 (throw 'abort
"ERROR: Template aborted"))
11151 (defun vhdl-insert-keyword (keyword)
11152 "Insert KEYWORD and adjust case."
11153 (insert (if vhdl-upper-case-keywords
(upcase keyword
) (downcase keyword
))))
11155 (defun vhdl-case-keyword (keyword)
11156 "Adjust case of KEYWORD."
11157 (if vhdl-upper-case-keywords
(upcase keyword
) (downcase keyword
)))
11159 (defun vhdl-case-word (num)
11160 "Adjust case of following NUM words."
11161 (if vhdl-upper-case-keywords
(upcase-word num
) (downcase-word num
)))
11163 (defun vhdl-minibuffer-tab (&optional prefix-arg
)
11164 "If preceding character is part of a word or a paren then hippie-expand,
11165 else insert tab (used for word completion in VHDL minibuffer)."
11169 ((= (char-syntax (preceding-char)) ?w
)
11170 (let ((case-fold-search (not vhdl-word-completion-case-sensitive
))
11172 (hippie-expand-only-buffers
11173 (or (and (boundp 'hippie-expand-only-buffers
)
11174 hippie-expand-only-buffers
)
11176 (vhdl-expand-abbrev prefix-arg
)))
11177 ;; expand parenthesis
11178 ((or (= (preceding-char) ?\
() (= (preceding-char) ?\
)))
11179 (let ((case-fold-search (not vhdl-word-completion-case-sensitive
))
11180 (case-replace nil
))
11181 (vhdl-expand-paren prefix-arg
)))
11185 (defun vhdl-template-search-prompt ()
11186 "Search for left out template prompts and query again."
11188 (vhdl-prepare-search-2
11189 (when (or (re-search-forward
11190 (concat "<\\(" vhdl-template-prompt-syntax
"\\)>") nil t
)
11191 (re-search-backward
11192 (concat "<\\(" vhdl-template-prompt-syntax
"\\)>") nil t
))
11193 (let ((string (match-string 1)))
11195 (vhdl-template-field string
)))))
11197 (defun vhdl-template-undo (begin end
)
11198 "Undo aborted template by deleting region and unexpanding the keyword."
11199 (cond (vhdl-template-invoked-by-hook
11202 (delete-region begin end
)
11204 (t (delete-region begin end
))))
11206 (defun vhdl-insert-string-or-file (string)
11207 "Insert STRING or file contents if STRING is an existing file name."
11208 (unless (equal string
"")
11210 (progn (string-match "^\\([^\n]+\\)" string
)
11211 (vhdl-resolve-env-variable (match-string 1 string
)))))
11212 (if (file-exists-p file-name
)
11213 (forward-char (cadr (insert-file-contents file-name
)))
11214 (insert string
)))))
11216 (defun vhdl-beginning-of-block ()
11217 "Move cursor to the beginning of the enclosing block."
11219 (vhdl-prepare-search-2
11221 (beginning-of-line)
11222 ;; search backward for block beginning or end
11223 (while (or (while (and (setq pos
(re-search-backward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|context\\|entity\\|package\\(\\s-+body\\)?\\|type[ \t\n\r\f]+\\w+[ \t\n\r\f]+is[ \t\n\r\f]+\\(record\\|protected\\(\\s-+body\\)?\\)\\|units\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(postponed[ \t\n\r\f]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\|loop\\)\\)\\>" nil t
))
11224 ;; not consider subprogram declarations
11225 (or (and (match-string 5)
11228 (goto-char (match-end 5))
11229 (forward-word-strictly 1)
11230 (vhdl-forward-syntactic-ws)
11231 (when (looking-at "(")
11233 (re-search-forward "\\<is\\>\\|\\(;\\)" nil t
))
11235 ;; not consider configuration specifications
11236 (and (match-string 6)
11239 (vhdl-end-of-block)
11240 (beginning-of-line)
11241 (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
11243 ;; skip subblock if block end found
11244 (vhdl-beginning-of-block))))
11245 (when pos
(goto-char pos
))))
11247 (defun vhdl-end-of-block ()
11248 "Move cursor to the end of the enclosing block."
11250 (vhdl-prepare-search-2
11253 ;; search forward for block beginning or end
11254 (while (or (while (and (setq pos
(re-search-forward "^\\s-*\\(\\(end\\)\\|\\(\\(impure\\|pure\\)[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(for\\)\\|\\(architecture\\|component\\|configuration\\|context\\|entity\\|package\\(\\s-+body\\)?\\|type[ \t\n\r\f]+\\w+[ \t\n\r\f]+is[ \t\n\r\f]+\\(record\\|protected\\(\\s-+body\\)?\\)\\|units\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(postponed[ \t\n\r\f]+\\)?\\(block\\|case\\|for\\|if\\|procedural\\|process\\|while\\|loop\\)\\)\\>" nil t
))
11255 ;; not consider subprogram declarations
11256 (or (and (match-string 5)
11258 (save-excursion (re-search-forward "\\<is\\>\\|\\(;\\)" nil t
))
11260 ;; not consider configuration specifications
11261 (and (match-string 6)
11264 (vhdl-end-of-block)
11265 (beginning-of-line)
11266 (not (looking-at "^\\s-*end\\s-+\\(for\\|generate\\|loop\\)\\>"))))))))
11267 (not (match-string 2)))
11268 ;; skip subblock if block beginning found
11269 (vhdl-end-of-block))))
11270 (when pos
(goto-char pos
))))
11272 (defun vhdl-sequential-statement-p ()
11273 "Check if point is within sequential statement part."
11274 (let ((start (point)))
11276 (vhdl-prepare-search-2
11277 ;; is sequential statement if ...
11278 (and (re-search-backward "^\\s-*begin\\>" nil t
)
11279 ;; ... point is between "begin" and "end" of ...
11280 (progn (vhdl-end-of-block)
11282 ;; ... a sequential block
11283 (progn (vhdl-beginning-of-block)
11284 (looking-at "^\\s-*\\(\\(\\w+[ \t\n\r\f]+\\)?\\(function\\|procedure\\)\\|\\(\\w+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(\\w+[ \t\n\r\f]+\\)?\\(procedural\\|process\\)\\)\\>")))))))
11286 (defun vhdl-in-argument-list-p ()
11287 "Check if within an argument list."
11289 (vhdl-prepare-search-2
11290 (or (string-match "arglist"
11291 (format "%s" (caar (vhdl-get-syntactic-context))))
11292 (progn (beginning-of-line)
11293 (looking-at "^\\s-*\\(generic\\|port\\|\\(\\(impure\\|pure\\)\\s-+\\|\\)function\\|procedure\\)\\>\\s-*\\(\\w+\\s-*\\)?("))))))
11295 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11298 (defun vhdl-hooked-abbrev (func)
11299 "Do function, if syntax says abbrev is a keyword, invoked by hooked abbrev,
11300 but not if inside a comment or quote."
11301 (if (or (vhdl-in-literal)
11303 (forward-word-strictly -
1)
11304 (and (looking-at "\\<end\\>") (not (looking-at "\\<end;")))))
11308 (backward-word-strictly 1)
11311 (if (not vhdl-electric-mode
)
11315 (backward-word-strictly 1)
11318 (let ((invoke-char vhdl-last-input-event
)
11320 (vhdl-template-invoked-by-hook t
))
11321 (let ((caught (catch 'abort
11323 (when (stringp caught
) (message "%s" caught
)))
11324 (when (= invoke-char ?-
) (setq abbrev-start-location
(point)))
11325 ;; delete CR which is still in event queue
11326 (if (fboundp 'enqueue-eval-event
)
11327 (enqueue-eval-event 'delete-char -
1)
11328 (push (vhdl-character-to-event ?
\177) ; push back a delete char
11329 unread-command-events
))))))
11331 (defun vhdl-template-alias-hook ()
11332 (vhdl-hooked-abbrev 'vhdl-template-alias
))
11333 (defun vhdl-template-architecture-hook ()
11334 (vhdl-hooked-abbrev 'vhdl-template-architecture
))
11335 (defun vhdl-template-assert-hook ()
11336 (vhdl-hooked-abbrev 'vhdl-template-assert
))
11337 (defun vhdl-template-attribute-hook ()
11338 (vhdl-hooked-abbrev 'vhdl-template-attribute
))
11339 (defun vhdl-template-block-hook ()
11340 (vhdl-hooked-abbrev 'vhdl-template-block
))
11341 (defun vhdl-template-break-hook ()
11342 (vhdl-hooked-abbrev 'vhdl-template-break
))
11343 (defun vhdl-template-case-hook ()
11344 (vhdl-hooked-abbrev 'vhdl-template-case
))
11345 (defun vhdl-template-component-hook ()
11346 (vhdl-hooked-abbrev 'vhdl-template-component
))
11347 (defun vhdl-template-instance-hook ()
11348 (vhdl-hooked-abbrev 'vhdl-template-instance
))
11349 (defun vhdl-template-conditional-signal-asst-hook ()
11350 (vhdl-hooked-abbrev 'vhdl-template-conditional-signal-asst
))
11351 (defun vhdl-template-configuration-hook ()
11352 (vhdl-hooked-abbrev 'vhdl-template-configuration
))
11353 (defun vhdl-template-constant-hook ()
11354 (vhdl-hooked-abbrev 'vhdl-template-constant
))
11355 (defun vhdl-template-context-hook ()
11356 (vhdl-hooked-abbrev 'vhdl-template-context
))
11357 (defun vhdl-template-disconnect-hook ()
11358 (vhdl-hooked-abbrev 'vhdl-template-disconnect
))
11359 (defun vhdl-template-display-comment-hook ()
11360 (vhdl-hooked-abbrev 'vhdl-comment-display
))
11361 (defun vhdl-template-else-hook ()
11362 (vhdl-hooked-abbrev 'vhdl-template-else
))
11363 (defun vhdl-template-elsif-hook ()
11364 (vhdl-hooked-abbrev 'vhdl-template-elsif
))
11365 (defun vhdl-template-entity-hook ()
11366 (vhdl-hooked-abbrev 'vhdl-template-entity
))
11367 (defun vhdl-template-exit-hook ()
11368 (vhdl-hooked-abbrev 'vhdl-template-exit
))
11369 (defun vhdl-template-file-hook ()
11370 (vhdl-hooked-abbrev 'vhdl-template-file
))
11371 (defun vhdl-template-for-hook ()
11372 (vhdl-hooked-abbrev 'vhdl-template-for
))
11373 (defun vhdl-template-function-hook ()
11374 (vhdl-hooked-abbrev 'vhdl-template-function
))
11375 (defun vhdl-template-generic-hook ()
11376 (vhdl-hooked-abbrev 'vhdl-template-generic
))
11377 (defun vhdl-template-group-hook ()
11378 (vhdl-hooked-abbrev 'vhdl-template-group
))
11379 (defun vhdl-template-library-hook ()
11380 (vhdl-hooked-abbrev 'vhdl-template-library
))
11381 (defun vhdl-template-limit-hook ()
11382 (vhdl-hooked-abbrev 'vhdl-template-limit
))
11383 (defun vhdl-template-if-hook ()
11384 (vhdl-hooked-abbrev 'vhdl-template-if
))
11385 (defun vhdl-template-bare-loop-hook ()
11386 (vhdl-hooked-abbrev 'vhdl-template-bare-loop
))
11387 (defun vhdl-template-map-hook ()
11388 (vhdl-hooked-abbrev 'vhdl-template-map
))
11389 (defun vhdl-template-nature-hook ()
11390 (vhdl-hooked-abbrev 'vhdl-template-nature
))
11391 (defun vhdl-template-next-hook ()
11392 (vhdl-hooked-abbrev 'vhdl-template-next
))
11393 (defun vhdl-template-others-hook ()
11394 (vhdl-hooked-abbrev 'vhdl-template-others
))
11395 (defun vhdl-template-package-hook ()
11396 (vhdl-hooked-abbrev 'vhdl-template-package
))
11397 (defun vhdl-template-port-hook ()
11398 (vhdl-hooked-abbrev 'vhdl-template-port
))
11399 (defun vhdl-template-procedural-hook ()
11400 (vhdl-hooked-abbrev 'vhdl-template-procedural
))
11401 (defun vhdl-template-procedure-hook ()
11402 (vhdl-hooked-abbrev 'vhdl-template-procedure
))
11403 (defun vhdl-template-process-hook ()
11404 (vhdl-hooked-abbrev 'vhdl-template-process
))
11405 (defun vhdl-template-quantity-hook ()
11406 (vhdl-hooked-abbrev 'vhdl-template-quantity
))
11407 (defun vhdl-template-report-hook ()
11408 (vhdl-hooked-abbrev 'vhdl-template-report
))
11409 (defun vhdl-template-return-hook ()
11410 (vhdl-hooked-abbrev 'vhdl-template-return
))
11411 (defun vhdl-template-selected-signal-asst-hook ()
11412 (vhdl-hooked-abbrev 'vhdl-template-selected-signal-asst
))
11413 (defun vhdl-template-signal-hook ()
11414 (vhdl-hooked-abbrev 'vhdl-template-signal
))
11415 (defun vhdl-template-subnature-hook ()
11416 (vhdl-hooked-abbrev 'vhdl-template-subnature
))
11417 (defun vhdl-template-subtype-hook ()
11418 (vhdl-hooked-abbrev 'vhdl-template-subtype
))
11419 (defun vhdl-template-terminal-hook ()
11420 (vhdl-hooked-abbrev 'vhdl-template-terminal
))
11421 (defun vhdl-template-type-hook ()
11422 (vhdl-hooked-abbrev 'vhdl-template-type
))
11423 (defun vhdl-template-use-hook ()
11424 (vhdl-hooked-abbrev 'vhdl-template-use
))
11425 (defun vhdl-template-variable-hook ()
11426 (vhdl-hooked-abbrev 'vhdl-template-variable
))
11427 (defun vhdl-template-wait-hook ()
11428 (vhdl-hooked-abbrev 'vhdl-template-wait
))
11429 (defun vhdl-template-when-hook ()
11430 (vhdl-hooked-abbrev 'vhdl-template-when
))
11431 (defun vhdl-template-while-loop-hook ()
11432 (vhdl-hooked-abbrev 'vhdl-template-while-loop
))
11433 (defun vhdl-template-with-hook ()
11434 (vhdl-hooked-abbrev 'vhdl-template-with
))
11435 (defun vhdl-template-and-hook ()
11436 (vhdl-hooked-abbrev 'vhdl-template-and
))
11437 (defun vhdl-template-or-hook ()
11438 (vhdl-hooked-abbrev 'vhdl-template-or
))
11439 (defun vhdl-template-nand-hook ()
11440 (vhdl-hooked-abbrev 'vhdl-template-nand
))
11441 (defun vhdl-template-nor-hook ()
11442 (vhdl-hooked-abbrev 'vhdl-template-nor
))
11443 (defun vhdl-template-xor-hook ()
11444 (vhdl-hooked-abbrev 'vhdl-template-xor
))
11445 (defun vhdl-template-xnor-hook ()
11446 (vhdl-hooked-abbrev 'vhdl-template-xnor
))
11447 (defun vhdl-template-not-hook ()
11448 (vhdl-hooked-abbrev 'vhdl-template-not
))
11450 (defun vhdl-template-default-hook ()
11451 (vhdl-hooked-abbrev 'vhdl-template-default
))
11452 (defun vhdl-template-default-indent-hook ()
11453 (vhdl-hooked-abbrev 'vhdl-template-default-indent
))
11455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11456 ;; Template insertion from completion list
11458 (defun vhdl-template-insert-construct (name)
11459 "Insert the built-in construct template with NAME."
11461 (list (let ((completion-ignore-case t
))
11462 (completing-read "Construct name: "
11463 vhdl-template-construct-alist nil t
))))
11464 (vhdl-template-insert-fun
11465 (cadr (assoc name vhdl-template-construct-alist
))))
11467 (defun vhdl-template-insert-package (name)
11468 "Insert the built-in package template with NAME."
11470 (list (let ((completion-ignore-case t
))
11471 (completing-read "Package name: "
11472 vhdl-template-package-alist nil t
))))
11473 (vhdl-template-insert-fun
11474 (cadr (assoc name vhdl-template-package-alist
))))
11476 (defun vhdl-template-insert-directive (name)
11477 "Insert the built-in directive template with NAME."
11479 (list (let ((completion-ignore-case t
))
11480 (completing-read "Directive name: "
11481 vhdl-template-directive-alist nil t
))))
11482 (vhdl-template-insert-fun
11483 (cadr (assoc name vhdl-template-directive-alist
))))
11485 (defun vhdl-template-insert-fun (fun)
11486 "Call FUN to insert a built-in template."
11487 (let ((caught (catch 'abort
(when fun
(funcall fun
)))))
11488 (when (stringp caught
) (message "%s" caught
))))
11491 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11493 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11495 (defun vhdl-model-insert (model-name)
11496 "Insert the user model with name MODEL-NAME."
11498 (let ((completion-ignore-case t
))
11499 (list (completing-read "Model name: " vhdl-model-alist
))))
11500 (indent-according-to-mode)
11501 (let ((start (point-marker))
11502 (margin (current-indentation))
11503 model position prompt string end
)
11504 (vhdl-prepare-search-2
11505 (when (setq model
(assoc model-name vhdl-model-alist
))
11507 (beginning-of-line)
11508 (delete-horizontal-space)
11510 (vhdl-insert-string-or-file (nth 1 model
))
11511 (setq end
(point-marker))
11514 (beginning-of-line)
11515 (while (< (point) end
)
11516 (unless (looking-at "^$")
11517 (insert-char ? margin
))
11518 (beginning-of-line 2))
11521 (unless (equal "" vhdl-clock-name
)
11522 (while (re-search-forward "<clock>" end t
)
11523 (replace-match vhdl-clock-name
)))
11526 (unless (equal "" vhdl-reset-name
)
11527 (while (re-search-forward "<reset>" end t
)
11528 (replace-match vhdl-reset-name
)))
11529 ;; replace header prompts
11530 (vhdl-template-replace-header-keywords start end nil t
)
11532 ;; query other prompts
11533 (while (re-search-forward
11534 (concat "<\\(" vhdl-template-prompt-syntax
"\\)>") end t
)
11535 (unless (equal "cursor" (match-string 1))
11536 (setq position
(match-beginning 1))
11537 (setq prompt
(match-string 1))
11539 (setq string
(vhdl-template-field prompt nil t
))
11540 ;; replace occurrences of same prompt
11541 (while (re-search-forward (concat "<\\(" prompt
"\\)>") end t
)
11542 (replace-match (or string
"")))
11543 (goto-char position
)))
11545 ;; goto final position
11546 (if (re-search-forward "<cursor>" end t
)
11548 (goto-char end
))))))
11550 (defun vhdl-model-defun ()
11551 "Define help and hook functions for user models."
11552 (let ((model-alist vhdl-model-alist
)
11553 model-name model-keyword
)
11555 ;; define functions for user models that can be invoked from menu and key
11556 ;; bindings and which themselves call `vhdl-model-insert' with the model
11557 ;; name as argument
11558 (setq model-name
(nth 0 (car model-alist
)))
11559 (eval `(defun ,(vhdl-function-name "vhdl-model" model-name
) ()
11560 ,(concat "Insert model for \"" model-name
"\".")
11562 (vhdl-model-insert ,model-name
)))
11563 ;; define hooks for user models that are invoked from keyword abbrevs
11564 (setq model-keyword
(nth 3 (car model-alist
)))
11565 (unless (equal model-keyword
"")
11567 ,(vhdl-function-name
11568 "vhdl-model" model-name
"hook") ()
11569 (vhdl-hooked-abbrev
11570 ',(vhdl-function-name "vhdl-model" model-name
)))))
11571 (setq model-alist
(cdr model-alist
)))))
11576 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11577 ;;; Port translation
11578 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11580 (defvar vhdl-port-list nil
11581 "Variable to hold last port map parsed.")
11582 ;; structure: (parenthesized expression means list of such entries)
11584 ;; ((generic-names) generic-type generic-init generic-comment group-comment)
11585 ;; ((port-names) port-object port-direct port-type port-comment group-comment)
11586 ;; (lib-name pack-key))
11588 (defun vhdl-parse-string (string &optional optional
)
11589 "Check that the text following point matches the regexp in STRING."
11590 (if (looking-at string
)
11591 (progn (goto-char (match-end 0))
11592 (when (vhdl-in-literal)
11596 (throw 'parse
(format "ERROR: Syntax error near line %s, expecting \"%s\""
11597 (vhdl-current-line) string
)))
11600 (defun vhdl-replace-string (regexp-cons string
&optional adjust-case
)
11601 "Replace STRING from car of REGEXP-CONS to cdr of REGEXP-CONS."
11602 (vhdl-prepare-search-1
11603 (if (string-match (car regexp-cons
) string
)
11605 (funcall vhdl-file-name-case
11606 (replace-match (cdr regexp-cons
) t nil string
))
11607 (replace-match (cdr regexp-cons
) t nil string
))
11610 (defun vhdl-parse-group-comment ()
11611 "Parse comment and empty lines between groups of lines."
11612 (let ((start (point))
11614 (vhdl-forward-comment (point-max))
11615 (setq string
(buffer-substring-no-properties start
(point)))
11616 (vhdl-forward-syntactic-ws)
11617 ;; strip off leading blanks and first newline
11618 (while (string-match "^\\(\\s-+\\)" string
)
11619 (setq string
(concat (substring string
0 (match-beginning 1))
11620 (substring string
(match-end 1)))))
11621 (if (and (not (equal string
"")) (equal (substring string
0 1) "\n"))
11622 (substring string
1)
11625 (defun vhdl-paste-group-comment (string indent
)
11626 "Paste comment and empty lines from STRING between groups of lines
11628 (let ((pos (point-marker)))
11630 (while (string-match "^\\(--\\)" string
)
11631 (setq string
(concat (substring string
0 (match-beginning 1))
11632 (make-string indent ?
)
11633 (substring string
(match-beginning 1))))))
11634 (beginning-of-line)
11638 (defvar vhdl-port-flattened nil
11639 "Indicates whether a port has been flattened.")
11641 (defun vhdl-port-flatten (&optional as-alist
)
11642 "Flatten port list so that only one generic/port exists per line.
11643 This operation is performed on an internally stored port and is only
11644 reflected in a subsequent paste operation."
11646 (if (not vhdl-port-list
)
11647 (error "ERROR: No port has been read")
11648 (message "Flattening port for next paste...")
11649 (let ((new-vhdl-port-list (list (car vhdl-port-list
)))
11650 (old-vhdl-port-list (cdr vhdl-port-list
))
11651 old-port-list new-port-list old-port new-port names
)
11652 ;; traverse port list and flatten entries
11653 (while (cdr old-vhdl-port-list
)
11654 (setq old-port-list
(car old-vhdl-port-list
))
11655 (setq new-port-list nil
)
11656 (while old-port-list
11657 (setq old-port
(car old-port-list
))
11658 (setq names
(car old-port
))
11660 (setq new-port
(cons (if as-alist
(car names
) (list (car names
)))
11662 (setq new-port-list
(append new-port-list
(list new-port
)))
11663 (setq names
(cdr names
)))
11664 (setq old-port-list
(cdr old-port-list
)))
11665 (setq old-vhdl-port-list
(cdr old-vhdl-port-list
))
11666 (setq new-vhdl-port-list
(append new-vhdl-port-list
11667 (list new-port-list
))))
11668 (setq vhdl-port-list
11669 (append new-vhdl-port-list
(list old-vhdl-port-list
))
11670 vhdl-port-flattened t
)
11671 (message "Flattening port for next paste...done"))))
11673 (defvar vhdl-port-reversed-direction nil
11674 "Indicates whether port directions are reversed.")
11676 (defun vhdl-port-reverse-direction ()
11677 "Reverse direction for all ports (useful in testbenches).
11678 This operation is performed on an internally stored port and is only
11679 reflected in a subsequent paste operation."
11681 (if (not vhdl-port-list
)
11682 (error "ERROR: No port has been read")
11683 (message "Reversing port directions for next paste...")
11684 (let ((port-list (nth 2 vhdl-port-list
))
11685 port-dir-car port-dir
)
11686 ;; traverse port list and reverse directions
11688 (setq port-dir-car
(cddr (car port-list
))
11689 port-dir
(car port-dir-car
))
11690 (setcar port-dir-car
11691 (cond ((equal port-dir
"in") "out")
11692 ((equal port-dir
"IN") "OUT")
11693 ((equal port-dir
"out") "in")
11694 ((equal port-dir
"OUT") "IN")
11696 (setq port-list
(cdr port-list
)))
11697 (setq vhdl-port-reversed-direction
(not vhdl-port-reversed-direction
))
11698 (message "Reversing port directions for next paste...done"))))
11700 (defun vhdl-port-copy ()
11701 "Get generic and port information from an entity or component declaration."
11704 (let (parse-error end-of-list
11705 decl-type name generic-list port-list context-clause
11706 object names direct type init comment group-comment
)
11707 (vhdl-prepare-search-2
11711 ;; check if within entity or component declaration
11713 (when (or (not (re-search-backward
11714 "^\\s-*\\(component\\|entity\\|end\\)\\>" nil t
))
11715 (equal "END" (upcase (match-string 1))))
11716 (throw 'parse
"ERROR: Not within an entity or component declaration"))
11717 (setq decl-type
(downcase (match-string-no-properties 1)))
11718 (forward-word-strictly 1)
11719 (vhdl-parse-string "\\s-+\\(\\w+\\)\\(\\s-+is\\>\\)?")
11720 (setq name
(match-string-no-properties 1))
11721 (message "Reading port of %s \"%s\"..." decl-type name
)
11722 (vhdl-forward-syntactic-ws)
11723 ;; parse generic clause
11724 (when (vhdl-parse-string "generic[ \t\n\r\f]*(" t
)
11725 ;; parse group comment and spacing
11726 (setq group-comment
(vhdl-parse-group-comment))
11727 (setq end-of-list
(vhdl-parse-string ")[ \t\n\r\f]*;[ \t\n\r\f]*" t
))
11728 (while (not end-of-list
)
11729 ;; parse names (accept extended identifiers)
11730 (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
11731 (setq names
(list (match-string-no-properties 1)))
11732 (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t
)
11734 (append names
(list (match-string-no-properties 1)))))
11736 (vhdl-parse-string ":[ \t\n\r\f]*\\([^():;\n]+\\)")
11737 (setq type
(match-string-no-properties 1))
11738 (when (vhdl-in-comment-p) ; if stuck in comment
11739 (setq type
(concat type
(and (vhdl-parse-string ".*")
11740 (match-string-no-properties 0)))))
11742 (while (looking-at "(")
11745 (buffer-substring-no-properties
11746 (point) (progn (forward-sexp) (point)))
11747 (and (vhdl-parse-string "\\([^():;\n]*\\)" t
)
11748 (match-string-no-properties 1)))))
11749 ;; special case: closing parenthesis is on separate line
11750 (when (and type
(string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" type
))
11751 (setq comment
(substring type
(match-beginning 2)))
11752 (setq type
(substring type
0 (match-beginning 1))))
11753 ;; strip of trailing group-comment
11754 (string-match "\\(\\(\\s-*\\S-+\\)+\\)\\s-*" type
)
11755 (setq type
(substring type
0 (match-end 1)))
11756 ;; parse initialization expression
11758 (when (vhdl-parse-string ":=[ \t\n\r\f]*" t
)
11759 (vhdl-parse-string "\\([^();\n]*\\)")
11760 (setq init
(match-string-no-properties 1))
11761 (while (looking-at "(")
11764 (buffer-substring-no-properties
11765 (point) (progn (forward-sexp) (point)))
11766 (and (vhdl-parse-string "\\([^();\n]*\\)" t
)
11767 (match-string-no-properties 1))))))
11768 ;; special case: closing parenthesis is on separate line
11769 (when (and init
(string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" init
))
11770 (setq comment
(substring init
(match-beginning 2)))
11771 (setq init
(substring init
0 (match-beginning 1)))
11772 (vhdl-forward-syntactic-ws))
11773 (skip-chars-forward " \t")
11774 ;; parse inline comment, special case: as above, no initial.
11776 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
11777 (match-string-no-properties 1))))
11778 (vhdl-forward-syntactic-ws)
11779 (setq end-of-list
(vhdl-parse-string ")" t
))
11780 (vhdl-parse-string "\\s-*;\\s-*")
11781 ;; parse inline comment
11783 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
11784 (match-string-no-properties 1))))
11785 ;; save everything in list
11786 (setq generic-list
(append generic-list
11787 (list (list names type init
11788 comment group-comment
))))
11789 ;; parse group comment and spacing
11790 (setq group-comment
(vhdl-parse-group-comment))))
11791 ;; parse port clause
11792 (when (vhdl-parse-string "port[ \t\n\r\f]*(" t
)
11793 ;; parse group comment and spacing
11794 (setq group-comment
(vhdl-parse-group-comment))
11795 (setq end-of-list
(vhdl-parse-string ")[ \t\n\r\f]*;[ \t\n\r\f]*" t
))
11796 (while (not end-of-list
)
11799 (and (vhdl-parse-string "\\<\\(signal\\|quantity\\|terminal\\)\\>[ \t\n\r\f]*" t
)
11800 (match-string-no-properties 1)))
11801 ;; parse names (accept extended identifiers)
11802 (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
11803 (setq names
(list (match-string-no-properties 1)))
11804 (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t
)
11805 (setq names
(append names
(list (match-string-no-properties 1)))))
11807 (vhdl-parse-string ":[ \t\n\r\f]*")
11809 (and (vhdl-parse-string "\\<\\(in\\|out\\|inout\\|buffer\\|linkage\\)\\>[ \t\n\r\f]+" t
)
11810 (match-string-no-properties 1)))
11812 (vhdl-parse-string "\\([^();\n]+\\)")
11813 (setq type
(match-string-no-properties 1))
11814 (when (vhdl-in-comment-p) ; if stuck in comment
11815 (setq type
(concat type
(and (vhdl-parse-string ".*")
11816 (match-string-no-properties 0)))))
11818 (while (looking-at "(")
11819 (setq type
(concat type
11820 (buffer-substring-no-properties
11821 (point) (progn (forward-sexp) (point)))
11822 (and (vhdl-parse-string "\\([^();\n]*\\)" t
)
11823 (match-string-no-properties 1)))))
11824 ;; special case: closing parenthesis is on separate line
11825 (when (and type
(string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" type
))
11826 (setq comment
(substring type
(match-beginning 2)))
11827 (setq type
(substring type
0 (match-beginning 1))))
11828 ;; strip of trailing group-comment
11829 (string-match "\\(\\(\\s-*\\S-+\\)+\\)\\s-*" type
)
11830 (setq type
(substring type
0 (match-end 1)))
11831 (vhdl-forward-syntactic-ws)
11832 (setq end-of-list
(vhdl-parse-string ")" t
))
11833 (vhdl-parse-string "\\s-*;\\s-*")
11834 ;; parse inline comment
11836 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
11837 (match-string-no-properties 1))))
11838 ;; save everything in list
11839 (setq port-list
(append port-list
11840 (list (list names object direct type
11841 comment group-comment
))))
11842 ;; parse group comment and spacing
11843 (setq group-comment
(vhdl-parse-group-comment))))
11844 ;; parse context clause
11845 (setq context-clause
(vhdl-scan-context-clause))
11846 ; ;; add surrounding package to context clause
11847 ; (when (and (equal decl-type "component")
11848 ; (re-search-backward "^\\s-*package\\s-+\\(\\w+\\)" nil t))
11849 ; (setq context-clause
11850 ; (append context-clause
11851 ; (list (cons (vhdl-work-library)
11852 ; (match-string-no-properties 1))))))
11853 (message "Reading port of %s \"%s\"...done" decl-type name
)
11857 (error parse-error
)
11858 (setq vhdl-port-list
(list name generic-list port-list context-clause
)
11859 vhdl-port-reversed-direction nil
11860 vhdl-port-flattened nil
)))))
11862 (defun vhdl-port-paste-context-clause (&optional exclude-pack-name
)
11863 "Paste a context clause."
11864 (let ((margin (current-indentation))
11865 (clause-list (nth 3 vhdl-port-list
))
11868 (setq clause
(car clause-list
))
11869 (unless (or (and exclude-pack-name
(equal (downcase (cdr clause
))
11870 (downcase exclude-pack-name
)))
11872 (re-search-backward
11873 (concat "^\\s-*use\\s-+" (car clause
)
11874 "." (cdr clause
) "\\>") nil t
)))
11875 (vhdl-template-standard-package (car clause
) (cdr clause
))
11877 (setq clause-list
(cdr clause-list
)))))
11879 (defun vhdl-port-paste-generic (&optional no-init
)
11880 "Paste a generic clause."
11881 (let ((margin (current-indentation))
11882 (generic-list (nth 1 vhdl-port-list
))
11883 list-margin start names generic
)
11884 ;; paste generic clause
11886 (setq start
(point))
11887 (vhdl-insert-keyword "GENERIC (")
11888 (unless vhdl-argument-list-indent
11889 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
11890 (setq list-margin
(current-column))
11891 (while generic-list
11892 (setq generic
(car generic-list
))
11893 ;; paste group comment and spacing
11894 (when (memq vhdl-include-group-comments
'(decl always
))
11895 (vhdl-paste-group-comment (nth 4 generic
) list-margin
))
11897 (setq names
(nth 0 generic
))
11899 (insert (car names
))
11900 (setq names
(cdr names
))
11901 (when names
(insert ", ")))
11903 (insert " : " (nth 1 generic
))
11904 ;; paste initialization
11905 (when (and (not no-init
) (nth 2 generic
))
11906 (insert " := " (nth 2 generic
)))
11907 (unless (cdr generic-list
) (insert ")"))
11910 (when (and vhdl-include-port-comments
(nth 3 generic
))
11911 (vhdl-comment-insert-inline (nth 3 generic
) t
))
11912 (setq generic-list
(cdr generic-list
))
11913 (when generic-list
(insert "\n") (indent-to list-margin
)))
11914 ;; align generic clause
11915 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1 t
)))))
11917 (defun vhdl-port-paste-port ()
11918 "Paste a port clause."
11919 (let ((margin (current-indentation))
11920 (port-list (nth 2 vhdl-port-list
))
11921 list-margin start names port
)
11922 ;; paste port clause
11924 (setq start
(point))
11925 (vhdl-insert-keyword "PORT (")
11926 (unless vhdl-argument-list-indent
11927 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
11928 (setq list-margin
(current-column))
11930 (setq port
(car port-list
))
11931 ;; paste group comment and spacing
11932 (when (memq vhdl-include-group-comments
'(decl always
))
11933 (vhdl-paste-group-comment (nth 5 port
) list-margin
))
11935 (when (nth 1 port
) (insert (nth 1 port
) " "))
11937 (setq names
(nth 0 port
))
11939 (insert (car names
))
11940 (setq names
(cdr names
))
11941 (when names
(insert ", ")))
11944 (when (nth 2 port
) (insert (nth 2 port
) " "))
11946 (insert (nth 3 port
))
11947 (unless (cdr port-list
) (insert ")"))
11950 (when (and vhdl-include-port-comments
(nth 4 port
))
11951 (vhdl-comment-insert-inline (nth 4 port
) t
))
11952 (setq port-list
(cdr port-list
))
11953 (when port-list
(insert "\n") (indent-to list-margin
)))
11954 ;; align port clause
11955 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1)))))
11957 (defun vhdl-port-paste-declaration (kind &optional no-indent
)
11958 "Paste as an entity or component declaration."
11959 (unless no-indent
(indent-according-to-mode))
11960 (let ((margin (current-indentation))
11961 (name (nth 0 vhdl-port-list
)))
11962 (vhdl-insert-keyword (if (eq kind
'entity
) "ENTITY " "COMPONENT "))
11964 (when (or (eq kind
'entity
) (not (vhdl-standard-p '87)))
11965 (vhdl-insert-keyword " IS"))
11966 ;; paste generic and port clause
11967 (when (nth 1 vhdl-port-list
)
11969 (when (and (memq vhdl-insert-empty-lines
'(unit all
)) (eq kind
'entity
))
11971 (indent-to (+ margin vhdl-basic-offset
))
11972 (vhdl-port-paste-generic (eq kind
'component
)))
11973 (when (nth 2 vhdl-port-list
)
11975 (when (and (memq vhdl-insert-empty-lines
'(unit all
))
11978 (indent-to (+ margin vhdl-basic-offset
)))
11979 (vhdl-port-paste-port)
11981 (when (and (memq vhdl-insert-empty-lines
'(unit all
)) (eq kind
'entity
))
11984 (vhdl-insert-keyword "END")
11985 (if (eq kind
'entity
)
11987 (unless (vhdl-standard-p '87) (vhdl-insert-keyword " ENTITY"))
11989 (vhdl-insert-keyword " COMPONENT")
11990 (unless (vhdl-standard-p '87) (insert " " name
)))
11993 (defun vhdl-port-paste-entity (&optional no-indent
)
11994 "Paste as an entity declaration."
11996 (if (not vhdl-port-list
)
11997 (error "ERROR: No port read")
11998 (message "Pasting port as entity \"%s\"..." (car vhdl-port-list
))
11999 (vhdl-port-paste-declaration 'entity no-indent
)
12000 (message "Pasting port as entity \"%s\"...done" (car vhdl-port-list
))))
12002 (defun vhdl-port-paste-component (&optional no-indent
)
12003 "Paste as a component declaration."
12005 (if (not vhdl-port-list
)
12006 (error "ERROR: No port read")
12007 (message "Pasting port as component \"%s\"..." (car vhdl-port-list
))
12008 (vhdl-port-paste-declaration 'component no-indent
)
12009 (message "Pasting port as component \"%s\"...done" (car vhdl-port-list
))))
12011 (defun vhdl-port-paste-generic-map (&optional secondary no-constants
)
12012 "Paste as a generic map."
12014 (unless secondary
(indent-according-to-mode))
12015 (let ((margin (current-indentation))
12016 list-margin start generic
12017 (generic-list (nth 1 vhdl-port-list
)))
12019 (setq start
(point))
12020 (vhdl-insert-keyword "GENERIC MAP (")
12021 (if (not vhdl-association-list-with-formals
)
12022 ;; paste list of actual generics
12023 (while generic-list
12024 (insert (if no-constants
12025 (car (nth 0 (car generic-list
)))
12026 (or (nth 2 (car generic-list
)) " ")))
12027 (setq generic-list
(cdr generic-list
))
12028 (insert (if generic-list
", " ")"))
12029 (when (and (not generic-list
) secondary
12030 (null (nth 2 vhdl-port-list
)))
12032 (unless vhdl-argument-list-indent
12033 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
12034 (setq list-margin
(current-column))
12035 (while generic-list
12036 (setq generic
(car generic-list
))
12037 ;; paste group comment and spacing
12038 (when (eq vhdl-include-group-comments
'always
)
12039 (vhdl-paste-group-comment (nth 4 generic
) list-margin
))
12040 ;; paste formal and actual generic
12041 (insert (car (nth 0 generic
)) " => "
12043 (vhdl-replace-string vhdl-actual-generic-name
12044 (car (nth 0 generic
)))
12045 (or (nth 2 generic
) "")))
12046 (setq generic-list
(cdr generic-list
))
12047 (insert (if generic-list
"," ")"))
12048 (when (and (not generic-list
) secondary
12049 (null (nth 2 vhdl-port-list
)))
12052 (when (or vhdl-include-type-comments
12053 (and vhdl-include-port-comments
(nth 3 generic
)))
12054 (vhdl-comment-insert-inline
12056 (when vhdl-include-type-comments
12057 (concat "[" (nth 1 generic
) "] "))
12058 (when vhdl-include-port-comments
(nth 3 generic
))) t
))
12059 (when generic-list
(insert "\n") (indent-to list-margin
)))
12060 ;; align generic map
12061 (when vhdl-auto-align
12062 (vhdl-align-region-groups start
(point) 1 t
))))))
12064 (defun vhdl-port-paste-port-map ()
12065 "Paste as a port map."
12066 (let ((margin (current-indentation))
12067 list-margin start port
12068 (port-list (nth 2 vhdl-port-list
)))
12070 (setq start
(point))
12071 (vhdl-insert-keyword "PORT MAP (")
12072 (if (not vhdl-association-list-with-formals
)
12073 ;; paste list of actual ports
12075 (insert (vhdl-replace-string vhdl-actual-port-name
12076 (car (nth 0 (car port-list
)))))
12077 (setq port-list
(cdr port-list
))
12078 (insert (if port-list
", " ")")))
12079 (unless vhdl-argument-list-indent
12080 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
12081 (setq list-margin
(current-column))
12083 (setq port
(car port-list
))
12084 ;; paste group comment and spacing
12085 (when (eq vhdl-include-group-comments
'always
)
12086 (vhdl-paste-group-comment (nth 5 port
) list-margin
))
12087 ;; paste formal and actual port
12088 (insert (car (nth 0 port
)) " => ")
12089 (insert (vhdl-replace-string vhdl-actual-port-name
12090 (car (nth 0 port
))))
12091 (setq port-list
(cdr port-list
))
12092 (insert (if port-list
"," ");"))
12094 (when (or (and vhdl-include-direction-comments
(nth 2 port
))
12095 vhdl-include-type-comments
12096 (and vhdl-include-port-comments
(nth 4 port
)))
12097 (vhdl-comment-insert-inline
12099 (cond ((and vhdl-include-direction-comments
12100 vhdl-include-type-comments
)
12101 (concat "[" (format "%-4s" (concat (nth 2 port
) " "))
12102 (nth 3 port
) "] "))
12103 ((and vhdl-include-direction-comments
(nth 2 port
))
12104 (format "%-6s" (concat "[" (nth 2 port
) "] ")))
12105 (vhdl-include-direction-comments " ")
12106 (vhdl-include-type-comments
12107 (concat "[" (nth 3 port
) "] ")))
12108 (when vhdl-include-port-comments
(nth 4 port
))) t
))
12109 (when port-list
(insert "\n") (indent-to list-margin
)))
12110 ;; align port clause
12111 (when vhdl-auto-align
12112 (vhdl-align-region-groups start
(point) 1))))))
12114 (defun vhdl-port-paste-instance (&optional name no-indent title
)
12115 "Paste as an instantiation."
12117 (if (not vhdl-port-list
)
12118 (error "ERROR: No port read")
12119 (let ((orig-vhdl-port-list vhdl-port-list
))
12120 ;; flatten local copy of port list (must be flat for port mapping)
12121 (vhdl-port-flatten)
12122 (unless no-indent
(indent-according-to-mode))
12123 (let ((margin (current-indentation)))
12124 ;; paste instantiation
12127 ((equal (cdr vhdl-instance-name
) "")
12128 (setq name
(vhdl-template-field "instance name")))
12129 ((string-match "%d" (cdr vhdl-instance-name
))
12131 (while (save-excursion
12132 (setq name
(format (vhdl-replace-string
12134 (nth 0 vhdl-port-list
)) n
))
12135 (goto-char (point-min))
12136 (vhdl-re-search-forward name nil t
))
12139 (t (insert (vhdl-replace-string vhdl-instance-name
12140 (nth 0 vhdl-port-list
)))))
12141 (message "Pasting port as instantiation \"%s\"..." name
)
12145 (beginning-of-line)
12146 (indent-to vhdl-basic-offset
)
12147 (insert "-- instance \"" name
"\"\n")))
12148 (if (not (vhdl-use-direct-instantiation))
12149 (insert (nth 0 vhdl-port-list
))
12150 (vhdl-insert-keyword "ENTITY ")
12151 (insert (vhdl-work-library) "." (nth 0 vhdl-port-list
)))
12152 (when (nth 1 vhdl-port-list
)
12153 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
12154 (vhdl-port-paste-generic-map t t
))
12155 (when (nth 2 vhdl-port-list
)
12156 (insert "\n") (indent-to (+ margin vhdl-basic-offset
))
12157 (vhdl-port-paste-port-map))
12158 (unless (or (nth 1 vhdl-port-list
) (nth 2 vhdl-port-list
))
12160 (message "Pasting port as instantiation \"%s\"...done" name
))
12161 (setq vhdl-port-list orig-vhdl-port-list
))))
12163 (defun vhdl-port-paste-constants (&optional no-indent
)
12164 "Paste generics as constants."
12166 (if (not vhdl-port-list
)
12167 (error "ERROR: No port read")
12168 (let ((orig-vhdl-port-list vhdl-port-list
))
12169 (message "Pasting port as constants...")
12170 ;; flatten local copy of port list (must be flat for constant initial.)
12171 (vhdl-port-flatten)
12172 (unless no-indent
(indent-according-to-mode))
12173 (let ((margin (current-indentation))
12175 (generic-list (nth 1 vhdl-port-list
)))
12177 (setq start
(point))
12178 (while generic-list
12179 (setq generic
(car generic-list
))
12180 ;; paste group comment and spacing
12181 (when (memq vhdl-include-group-comments
'(decl always
))
12182 (vhdl-paste-group-comment (nth 4 generic
) margin
))
12183 (vhdl-insert-keyword "CONSTANT ")
12184 ;; paste generic constants
12185 (setq name
(nth 0 generic
))
12187 (insert (vhdl-replace-string vhdl-actual-generic-name
(car name
)))
12189 (insert " : " (nth 1 generic
))
12190 ;; paste initialization
12191 (when (nth 2 generic
)
12192 (insert " := " (nth 2 generic
)))
12195 (when (and vhdl-include-port-comments
(nth 3 generic
))
12196 (vhdl-comment-insert-inline (nth 3 generic
) t
))
12197 (setq generic-list
(cdr generic-list
))
12198 (when generic-list
(insert "\n") (indent-to margin
))))
12199 ;; align signal list
12200 (when vhdl-auto-align
12201 (vhdl-align-region-groups start
(point) 1))))
12202 (message "Pasting port as constants...done")
12203 (setq vhdl-port-list orig-vhdl-port-list
))))
12205 (defun vhdl-port-paste-signals (&optional initialize no-indent
)
12206 "Paste ports as internal signals."
12208 (if (not vhdl-port-list
)
12209 (error "ERROR: No port read")
12210 (message "Pasting port as signals...")
12211 (unless no-indent
(indent-according-to-mode))
12212 (let ((margin (current-indentation))
12213 start port names type generic-list port-name constant-name pos
12214 (port-list (nth 2 vhdl-port-list
)))
12216 (setq start
(point))
12218 (setq port
(car port-list
))
12219 ;; paste group comment and spacing
12220 (when (memq vhdl-include-group-comments
'(decl always
))
12221 (vhdl-paste-group-comment (nth 5 port
) margin
))
12224 (insert (nth 1 port
) " ")
12225 (vhdl-insert-keyword "SIGNAL "))
12226 ;; paste actual port signals
12227 (setq names
(nth 0 port
))
12229 (insert (vhdl-replace-string vhdl-actual-port-name
(car names
)))
12230 (setq names
(cdr names
))
12231 (when names
(insert ", ")))
12233 (setq type
(nth 3 port
))
12234 (setq generic-list
(nth 1 vhdl-port-list
))
12235 (vhdl-prepare-search-1
12237 ;; replace formal by actual generics
12238 (while generic-list
12239 (setq port-name
(car (nth 0 (car generic-list
))))
12240 (while (string-match (concat "\\<" port-name
"\\>") type pos
)
12241 (setq constant-name
12242 (save-match-data (vhdl-replace-string
12243 vhdl-actual-generic-name port-name
)))
12244 (setq type
(replace-match constant-name t nil type
))
12245 (setq pos
(match-end 0)))
12246 (setq generic-list
(cdr generic-list
))))
12247 (insert " : " type
)
12248 ;; paste initialization (inputs only)
12249 (when (and initialize
(nth 2 port
) (equal "IN" (upcase (nth 2 port
))))
12251 (cond ((string-match "integer" (nth 3 port
)) "0")
12252 ((string-match "natural" (nth 3 port
)) "0")
12253 ((string-match "positive" (nth 3 port
)) "0")
12254 ((string-match "real" (nth 3 port
)) "0.0")
12255 ((string-match "(.+)" (nth 3 port
)) "(others => '0')")
12259 (when (or (and vhdl-include-direction-comments
(nth 2 port
))
12260 (and vhdl-include-port-comments
(nth 4 port
)))
12261 (vhdl-comment-insert-inline
12263 (cond ((and vhdl-include-direction-comments
(nth 2 port
))
12264 (format "%-6s" (concat "[" (nth 2 port
) "] ")))
12265 (vhdl-include-direction-comments " "))
12266 (when vhdl-include-port-comments
(nth 4 port
))) t
))
12267 (setq port-list
(cdr port-list
))
12268 (when port-list
(insert "\n") (indent-to margin
)))
12269 ;; align signal list
12270 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))))
12271 (message "Pasting port as signals...done")))
12273 (defun vhdl-port-paste-initializations (&optional no-indent
)
12274 "Paste ports as signal initializations."
12276 (if (not vhdl-port-list
)
12277 (error "ERROR: No port read")
12278 (let ((orig-vhdl-port-list vhdl-port-list
))
12279 (message "Pasting port as initializations...")
12280 ;; flatten local copy of port list (must be flat for signal initial.)
12281 (vhdl-port-flatten)
12282 (unless no-indent
(indent-according-to-mode))
12283 (let ((margin (current-indentation))
12285 (port-list (nth 2 vhdl-port-list
)))
12287 (setq start
(point))
12289 (setq port
(car port-list
))
12290 ;; paste actual port signal (inputs only)
12291 (when (equal "IN" (upcase (nth 2 port
)))
12292 (setq name
(car (nth 0 port
)))
12293 (insert (vhdl-replace-string vhdl-actual-port-name name
))
12294 ;; paste initialization
12296 (cond ((string-match "integer" (nth 3 port
)) "0")
12297 ((string-match "natural" (nth 3 port
)) "0")
12298 ((string-match "positive" (nth 3 port
)) "0")
12299 ((string-match "real" (nth 3 port
)) "0.0")
12300 ((string-match "(.+)" (nth 3 port
)) "(others => '0')")
12303 (setq port-list
(cdr port-list
))
12304 (when (and port-list
12305 (equal "IN" (upcase (nth 2 (car port-list
)))))
12306 (insert "\n") (indent-to margin
)))
12307 ;; align signal list
12308 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1))))
12309 (message "Pasting port as initializations...done")
12310 (setq vhdl-port-list orig-vhdl-port-list
))))
12312 (defun vhdl-port-paste-testbench ()
12313 "Paste as a bare-bones testbench."
12315 (if (not vhdl-port-list
)
12316 (error "ERROR: No port read")
12317 (let ((case-fold-search t
)
12318 (ent-name (vhdl-replace-string vhdl-testbench-entity-name
12319 (nth 0 vhdl-port-list
)))
12320 (source-buffer (current-buffer))
12321 arch-name config-name ent-file-name arch-file-name
12322 ent-buffer arch-buffer position
)
12323 ;; open entity file
12324 (unless (eq vhdl-testbench-create-files
'none
)
12325 (setq ent-file-name
12326 (concat (vhdl-replace-string vhdl-testbench-entity-file-name
12328 "." (file-name-extension (buffer-file-name))))
12329 (if (file-exists-p ent-file-name
)
12331 (concat "File \"" ent-file-name
"\" exists; overwrite? "))
12332 (progn (find-file ent-file-name
)
12334 (set-buffer-modified-p nil
))
12335 (if (eq vhdl-testbench-create-files
'separate
)
12336 (setq ent-file-name nil
)
12337 (error "ERROR: Pasting port as testbench...aborted")))
12338 (find-file ent-file-name
)))
12339 (unless (and (eq vhdl-testbench-create-files
'separate
)
12340 (null ent-file-name
))
12341 ;; paste entity header
12342 (if vhdl-testbench-include-header
12343 (progn (vhdl-template-header
12344 (concat "Testbench for design \""
12345 (nth 0 vhdl-port-list
) "\""))
12346 (goto-char (point-max)))
12347 (vhdl-comment-display-line) (insert "\n\n"))
12348 ;; paste std_logic_1164 package
12349 (when vhdl-testbench-include-library
12350 (vhdl-template-package-std-logic-1164)
12351 (insert "\n\n") (vhdl-comment-display-line) (insert "\n\n"))
12352 ;; paste entity declaration
12353 (vhdl-insert-keyword "ENTITY ")
12355 (vhdl-insert-keyword " IS")
12356 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
12358 (vhdl-insert-keyword "END ")
12359 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "ENTITY "))
12360 (insert ent-name
";")
12362 (vhdl-comment-display-line) (insert "\n"))
12363 ;; get architecture name
12364 (setq arch-name
(if (equal (cdr vhdl-testbench-architecture-name
) "")
12365 (read-from-minibuffer "architecture name: "
12366 nil vhdl-minibuffer-local-map
)
12367 (vhdl-replace-string vhdl-testbench-architecture-name
12368 (nth 0 vhdl-port-list
))))
12369 (message "Pasting port as testbench \"%s(%s)\"..." ent-name arch-name
)
12370 ;; open architecture file
12371 (if (not (eq vhdl-testbench-create-files
'separate
))
12373 (setq ent-buffer
(current-buffer))
12374 (setq arch-file-name
12375 (concat (vhdl-replace-string vhdl-testbench-architecture-file-name
12376 (concat ent-name
" " arch-name
) t
)
12377 "." (file-name-extension (buffer-file-name))))
12378 (when (and (file-exists-p arch-file-name
)
12379 (not (y-or-n-p (concat "File \"" arch-file-name
12380 "\" exists; overwrite? "))))
12381 (error "ERROR: Pasting port as testbench...aborted"))
12382 (find-file arch-file-name
)
12384 (set-buffer-modified-p nil
)
12385 ;; paste architecture header
12386 (if vhdl-testbench-include-header
12387 (progn (vhdl-template-header
12388 (concat "Testbench architecture for design \""
12389 (nth 0 vhdl-port-list
) "\""))
12390 (goto-char (point-max)))
12391 (vhdl-comment-display-line) (insert "\n\n")))
12392 ;; paste architecture body
12393 (vhdl-insert-keyword "ARCHITECTURE ")
12395 (vhdl-insert-keyword " OF ")
12397 (vhdl-insert-keyword " IS")
12398 (insert "\n\n") (indent-to vhdl-basic-offset
)
12399 ;; paste component declaration
12400 (unless (vhdl-use-direct-instantiation)
12401 (vhdl-port-paste-component t
)
12402 (insert "\n\n") (indent-to vhdl-basic-offset
))
12404 (when (nth 1 vhdl-port-list
)
12405 (insert "-- component generics\n") (indent-to vhdl-basic-offset
)
12406 (vhdl-port-paste-constants t
)
12407 (insert "\n\n") (indent-to vhdl-basic-offset
))
12408 ;; paste internal signals
12409 (insert "-- component ports\n") (indent-to vhdl-basic-offset
)
12410 (vhdl-port-paste-signals vhdl-testbench-initialize-signals t
)
12412 ;; paste custom declarations
12413 (unless (equal "" vhdl-testbench-declarations
)
12415 (setq position
(point))
12416 (vhdl-insert-string-or-file vhdl-testbench-declarations
)
12417 (vhdl-indent-region position
(point)))
12418 (setq position
(point))
12420 (vhdl-comment-display-line) (insert "\n")
12421 (when vhdl-testbench-include-configuration
12422 (setq config-name
(vhdl-replace-string
12423 vhdl-testbench-configuration-name
12424 (concat ent-name
" " arch-name
)))
12426 (vhdl-insert-keyword "CONFIGURATION ") (insert config-name
)
12427 (vhdl-insert-keyword " OF ") (insert ent-name
)
12428 (vhdl-insert-keyword " IS\n")
12429 (indent-to vhdl-basic-offset
)
12430 (vhdl-insert-keyword "FOR ") (insert arch-name
"\n")
12431 (indent-to vhdl-basic-offset
)
12432 (vhdl-insert-keyword "END FOR;\n")
12433 (vhdl-insert-keyword "END ") (insert config-name
";\n\n")
12434 (vhdl-comment-display-line) (insert "\n"))
12435 (goto-char position
)
12436 (vhdl-template-begin-end
12437 (unless (vhdl-standard-p '87) "ARCHITECTURE") arch-name
0 t
)
12438 ;; paste instantiation
12439 (insert "-- component instantiation\n") (indent-to vhdl-basic-offset
)
12440 (vhdl-port-paste-instance
12441 (vhdl-replace-string vhdl-testbench-dut-name
(nth 0 vhdl-port-list
)) t
)
12443 ;; paste custom statements
12444 (unless (equal "" vhdl-testbench-statements
)
12446 (setq position
(point))
12447 (vhdl-insert-string-or-file vhdl-testbench-statements
)
12448 (vhdl-indent-region position
(point)))
12450 (indent-to vhdl-basic-offset
)
12451 (unless (eq vhdl-testbench-create-files
'none
)
12452 (setq arch-buffer
(current-buffer))
12453 (when ent-buffer
(set-buffer ent-buffer
) (save-buffer))
12454 (set-buffer arch-buffer
) (save-buffer))
12456 (concat (format "Pasting port as testbench \"%s(%s)\"...done"
12457 ent-name arch-name
)
12459 (format "\n File created: \"%s\"" ent-file-name
))
12460 (and arch-file-name
12461 (format "\n File created: \"%s\"" arch-file-name
)))))))
12464 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12465 ;;; Subprogram interface translation
12466 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12468 (defvar vhdl-subprog-list nil
12469 "Variable to hold last subprogram interface parsed.")
12470 ;; structure: (parenthesized expression means list of such entries)
12471 ;; (subprog-name kind
12472 ;; ((names) object direct type init comment group-comment)
12473 ;; return-type return-comment group-comment)
12475 (defvar vhdl-subprog-flattened nil
12476 "Indicates whether an subprogram interface has been flattened.")
12478 (defun vhdl-subprog-flatten ()
12479 "Flatten interface list so that only one parameter exists per line."
12481 (if (not vhdl-subprog-list
)
12482 (error "ERROR: No subprogram interface has been read")
12483 (message "Flattening subprogram interface...")
12484 (let ((old-subprog-list (nth 2 vhdl-subprog-list
))
12485 new-subprog-list old-subprog new-subprog names
)
12486 ;; traverse parameter list and flatten entries
12487 (while old-subprog-list
12488 (setq old-subprog
(car old-subprog-list
))
12489 (setq names
(car old-subprog
))
12491 (setq new-subprog
(cons (list (car names
)) (cdr old-subprog
)))
12492 (setq new-subprog-list
(append new-subprog-list
(list new-subprog
)))
12493 (setq names
(cdr names
)))
12494 (setq old-subprog-list
(cdr old-subprog-list
)))
12495 (setq vhdl-subprog-list
12496 (list (nth 0 vhdl-subprog-list
) (nth 1 vhdl-subprog-list
)
12497 new-subprog-list
(nth 3 vhdl-subprog-list
)
12498 (nth 4 vhdl-subprog-list
) (nth 5 vhdl-subprog-list
))
12499 vhdl-subprog-flattened t
)
12500 (message "Flattening subprogram interface...done"))))
12502 (defun vhdl-subprog-copy ()
12503 "Get interface information from a subprogram specification."
12506 (let (parse-error pos end-of-list
12507 name kind param-list object names direct type init
12508 comment group-comment
12509 return-type return-comment return-group-comment
)
12510 (vhdl-prepare-search-2
12514 ;; check if within function declaration
12517 (when (looking-at "[ \t\n\r\f]*\\((\\|;\\|is\\>\\)") (goto-char (match-end 0)))
12518 (unless (and (re-search-backward "^\\s-*\\(\\(procedure\\)\\|\\(\\(pure\\|impure\\)\\s-+\\)?function\\)\\s-+\\(\"?\\w+\"?\\)[ \t\n\r\f]*\\(\\((\\)\\|;\\|is\\>\\)" nil t
)
12519 (goto-char (match-end 0))
12520 (save-excursion (backward-char)
12523 (throw 'parse
"ERROR: Not within a subprogram specification"))
12524 (setq name
(match-string-no-properties 5))
12525 (setq kind
(if (match-string 2) 'procedure
'function
))
12526 (setq end-of-list
(not (match-string 7)))
12527 (message "Reading interface of subprogram \"%s\"..." name
)
12528 ;; parse parameter list
12529 (setq group-comment
(vhdl-parse-group-comment))
12530 (setq end-of-list
(or end-of-list
12531 (vhdl-parse-string ")[ \t\n\r\f]*\\(;\\|\\(is\\|return\\)\\>\\)" t
)))
12532 (while (not end-of-list
)
12535 (and (vhdl-parse-string "\\(constant\\|signal\\|variable\\|file\\|quantity\\|terminal\\)[ \t\n\r\f]*" t
)
12536 (match-string-no-properties 1)))
12537 ;; parse names (accept extended identifiers)
12538 (vhdl-parse-string "\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*")
12539 (setq names
(list (match-string-no-properties 1)))
12540 (while (vhdl-parse-string ",[ \t\n\r\f]*\\(\\\\[^\\]+\\\\\\|\\w+\\)[ \t\n\r\f]*" t
)
12541 (setq names
(append names
(list (match-string-no-properties 1)))))
12543 (vhdl-parse-string ":[ \t\n\r\f]*")
12545 (and (vhdl-parse-string "\\(in\\|out\\|inout\\|buffer\\|linkage\\)[ \t\n\r\f]+" t
)
12546 (match-string-no-properties 1)))
12548 (vhdl-parse-string "\\([^():;\n]+\\)")
12549 (setq type
(match-string-no-properties 1))
12551 (while (looking-at "(")
12554 (buffer-substring-no-properties
12555 (point) (progn (forward-sexp) (point)))
12556 (and (vhdl-parse-string "\\([^():;\n]*\\)" t
)
12557 (match-string-no-properties 1)))))
12558 ;; special case: closing parenthesis is on separate line
12559 (when (and type
(string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" type
))
12560 (setq comment
(substring type
(match-beginning 2)))
12561 (setq type
(substring type
0 (match-beginning 1))))
12562 ;; strip off trailing group-comment
12563 (string-match "\\(\\(\\s-*\\S-+\\)+\\)\\s-*" type
)
12564 (setq type
(substring type
0 (match-end 1)))
12565 ;; parse initialization expression
12567 (when (vhdl-parse-string ":=[ \t\n\r\f]*" t
)
12568 (vhdl-parse-string "\\([^();\n]*\\)")
12569 (setq init
(match-string-no-properties 1))
12570 (while (looking-at "(")
12573 (buffer-substring-no-properties
12574 (point) (progn (forward-sexp) (point)))
12575 (and (vhdl-parse-string "\\([^();\n]*\\)" t
)
12576 (match-string-no-properties 1))))))
12577 ;; special case: closing parenthesis is on separate line
12578 (when (and init
(string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" init
))
12579 (setq comment
(substring init
(match-beginning 2)))
12580 (setq init
(substring init
0 (match-beginning 1)))
12581 (vhdl-forward-syntactic-ws))
12582 (skip-chars-forward " \t")
12583 ;; parse inline comment, special case: as above, no initial.
12585 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
12586 (match-string-no-properties 1))))
12587 (vhdl-forward-syntactic-ws)
12588 (setq end-of-list
(vhdl-parse-string ")\\s-*" t
))
12589 ;; parse inline comment
12591 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
12592 (match-string-no-properties 1))))
12593 (setq return-group-comment
(vhdl-parse-group-comment))
12594 (vhdl-parse-string "\\(;\\|\\(is\\|\\(return\\)\\)\\>\\)\\s-*")
12595 ;; parse return type
12596 (when (match-string 3)
12597 (vhdl-parse-string "[ \t\n\r\f]*\\(.+\\)[ \t\n\r\f]*\\(;\\|is\\>\\)\\s-*")
12598 (setq return-type
(match-string-no-properties 1))
12599 (when (and return-type
12600 (string-match "\\(\\s-*--\\s-*\\)\\(.*\\)" return-type
))
12601 (setq return-comment
(substring return-type
(match-beginning 2)))
12602 (setq return-type
(substring return-type
0 (match-beginning 1))))
12603 ;; strip of trailing group-comment
12604 (string-match "\\(\\(\\s-*\\S-+\\)+\\)\\s-*" return-type
)
12605 (setq return-type
(substring return-type
0 (match-end 1)))
12606 ;; parse return comment
12607 (unless return-comment
12608 (setq return-comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
12609 (match-string-no-properties 1)))))
12610 ;; parse inline comment
12612 (setq comment
(and (vhdl-parse-string "--\\s-*\\([^\n]*\\)" t
)
12613 (match-string-no-properties 1))))
12614 ;; save everything in list
12615 (setq param-list
(append param-list
12616 (list (list names object direct type init
12617 comment group-comment
))))
12618 ;; parse group comment and spacing
12619 (setq group-comment
(vhdl-parse-group-comment)))
12620 (message "Reading interface of subprogram \"%s\"...done" name
)
12624 (error parse-error
)
12625 (setq vhdl-subprog-list
12626 (list name kind param-list return-type return-comment
12627 return-group-comment
)
12628 vhdl-subprog-flattened nil
)))))
12630 (defun vhdl-subprog-paste-specification (kind)
12631 "Paste as a subprogram specification."
12632 (indent-according-to-mode)
12633 (let ((margin (current-column))
12634 (param-list (nth 2 vhdl-subprog-list
))
12635 list-margin start names param
)
12636 ;; paste keyword and name
12637 (vhdl-insert-keyword
12638 (if (eq (nth 1 vhdl-subprog-list
) 'procedure
) "PROCEDURE " "FUNCTION "))
12639 (insert (nth 0 vhdl-subprog-list
))
12640 (if (not param-list
)
12641 (if (eq kind
'decl
) (insert ";") (vhdl-insert-keyword " is"))
12642 (setq start
(point))
12643 ;; paste parameter list
12645 (unless vhdl-argument-list-indent
12646 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
12647 (setq list-margin
(current-column))
12649 (setq param
(car param-list
))
12650 ;; paste group comment and spacing
12651 (when (memq vhdl-include-group-comments
(list kind
'always
))
12652 (vhdl-paste-group-comment (nth 6 param
) list-margin
))
12654 (when (nth 1 param
) (insert (nth 1 param
) " "))
12656 (setq names
(nth 0 param
))
12658 (insert (car names
))
12659 (setq names
(cdr names
))
12660 (when names
(insert ", ")))
12663 (when (nth 2 param
) (insert (nth 2 param
) " "))
12665 (insert (nth 3 param
))
12666 ;; paste initialization
12667 (when (nth 4 param
) (insert " := " (nth 4 param
)))
12669 (if (cdr param-list
)
12672 (when (null (nth 3 vhdl-subprog-list
))
12673 (if (eq kind
'decl
) (insert ";") (vhdl-insert-keyword " is"))))
12675 (when (and vhdl-include-port-comments
(nth 5 param
))
12676 (vhdl-comment-insert-inline (nth 5 param
) t
))
12677 (setq param-list
(cdr param-list
))
12678 (when param-list
(insert "\n") (indent-to list-margin
)))
12679 (when (nth 3 vhdl-subprog-list
)
12680 (insert "\n") (indent-to list-margin
)
12681 ;; paste group comment and spacing
12682 (when (memq vhdl-include-group-comments
(list kind
'always
))
12683 (vhdl-paste-group-comment (nth 5 vhdl-subprog-list
) list-margin
))
12684 ;; paste return type
12685 (insert "return " (nth 3 vhdl-subprog-list
))
12686 (if (eq kind
'decl
) (insert ";") (vhdl-insert-keyword " is"))
12687 (when (and vhdl-include-port-comments
(nth 4 vhdl-subprog-list
))
12688 (vhdl-comment-insert-inline (nth 4 vhdl-subprog-list
) t
)))
12689 ;; align parameter list
12690 (when vhdl-auto-align
(vhdl-align-region-groups start
(point) 1 t
)))
12692 (when (eq kind
'body
)
12694 (vhdl-template-begin-end
12695 (unless (vhdl-standard-p '87)
12696 (if (eq (nth 1 vhdl-subprog-list
) 'procedure
) "PROCEDURE" "FUNCTION"))
12697 (nth 0 vhdl-subprog-list
) margin
))))
12699 (defun vhdl-subprog-paste-declaration ()
12700 "Paste as a subprogram declaration."
12702 (if (not vhdl-subprog-list
)
12703 (error "ERROR: No subprogram interface read")
12704 (message "Pasting interface as subprogram declaration \"%s\"..."
12705 (car vhdl-subprog-list
))
12706 ;; paste specification
12707 (vhdl-subprog-paste-specification 'decl
)
12708 (message "Pasting interface as subprogram declaration \"%s\"...done"
12709 (car vhdl-subprog-list
))))
12711 (defun vhdl-subprog-paste-body ()
12712 "Paste as a subprogram body."
12714 (if (not vhdl-subprog-list
)
12715 (error "ERROR: No subprogram interface read")
12716 (message "Pasting interface as subprogram body \"%s\"..."
12717 (car vhdl-subprog-list
))
12718 ;; paste specification and body
12719 (vhdl-subprog-paste-specification 'body
)
12720 (message "Pasting interface as subprogram body \"%s\"...done"
12721 (car vhdl-subprog-list
))))
12723 (defun vhdl-subprog-paste-call ()
12724 "Paste as a subprogram call."
12726 (if (not vhdl-subprog-list
)
12727 (error "ERROR: No subprogram interface read")
12728 (let ((orig-vhdl-subprog-list vhdl-subprog-list
)
12729 param-list margin list-margin param start
)
12730 ;; flatten local copy of interface list (must be flat for parameter mapping)
12731 (vhdl-subprog-flatten)
12732 (setq param-list
(nth 2 vhdl-subprog-list
))
12733 (indent-according-to-mode)
12734 (setq margin
(current-indentation))
12735 (message "Pasting interface as subprogram call \"%s\"..."
12736 (car vhdl-subprog-list
))
12738 (insert (nth 0 vhdl-subprog-list
))
12739 (if (not param-list
)
12741 (setq start
(point))
12742 ;; paste parameter list
12744 (unless vhdl-argument-list-indent
12745 (insert "\n") (indent-to (+ margin vhdl-basic-offset
)))
12746 (setq list-margin
(current-column))
12748 (setq param
(car param-list
))
12749 ;; paste group comment and spacing
12750 (when (eq vhdl-include-group-comments
'always
)
12751 (vhdl-paste-group-comment (nth 6 param
) list-margin
))
12752 ;; paste formal port
12753 (insert (car (nth 0 param
)) " => ")
12754 (setq param-list
(cdr param-list
))
12755 (insert (if param-list
"," ");"))
12757 (when (and vhdl-include-port-comments
(nth 5 param
))
12758 (vhdl-comment-insert-inline (nth 5 param
)))
12759 (when param-list
(insert "\n") (indent-to list-margin
)))
12760 ;; align parameter list
12761 (when vhdl-auto-align
12762 (vhdl-align-region-groups start
(point) 1)))
12763 (message "Pasting interface as subprogram call \"%s\"...done"
12764 (car vhdl-subprog-list
))
12765 (setq vhdl-subprog-list orig-vhdl-subprog-list
))))
12768 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12770 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12772 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12773 ;; Hippie expand customization
12775 (defvar vhdl-expand-upper-case nil
)
12777 (defun vhdl-try-expand-abbrev (old)
12778 "Try expanding abbreviations from `vhdl-abbrev-list'."
12780 (he-init-string (he-dabbrev-beg) (point))
12781 (setq he-expand-list
12782 (let ((abbrev-list vhdl-abbrev-list
)
12783 (sel-abbrev-list '()))
12785 (when (or (not (stringp (car abbrev-list
)))
12787 (concat "^" he-search-string
) (car abbrev-list
)))
12788 (setq sel-abbrev-list
12789 (cons (car abbrev-list
) sel-abbrev-list
)))
12790 (setq abbrev-list
(cdr abbrev-list
)))
12791 (nreverse sel-abbrev-list
))))
12792 (while (and he-expand-list
12793 (or (not (stringp (car he-expand-list
)))
12794 (he-string-member (car he-expand-list
) he-tried-table t
)))
12795 (unless (stringp (car he-expand-list
))
12796 (setq vhdl-expand-upper-case
(car he-expand-list
)))
12797 (setq he-expand-list
(cdr he-expand-list
)))
12798 (if (null he-expand-list
)
12799 (progn (when old
(he-reset-string))
12801 (he-substitute-string
12802 (if vhdl-expand-upper-case
12803 (upcase (car he-expand-list
))
12804 (car he-expand-list
))
12806 (setq he-expand-list
(cdr he-expand-list
))
12809 (defun vhdl-he-list-beg ()
12810 "Also looks at the word before `(' in order to better match parenthesized
12811 expressions (e.g. for index ranges of types and signals)."
12814 (progn (backward-up-list 1)
12815 (skip-syntax-backward "w_")) ; crashes in `viper-mode'
12819 ;; override `he-list-beg' from `hippie-exp'
12820 (unless (and (boundp 'viper-mode
) viper-mode
)
12821 (defalias 'he-list-beg
'vhdl-he-list-beg
))
12823 ;; function for expanding abbrevs and dabbrevs
12824 (defalias 'vhdl-expand-abbrev
(make-hippie-expand-function
12825 '(try-expand-dabbrev
12826 try-expand-dabbrev-all-buffers
12827 vhdl-try-expand-abbrev
)))
12829 ;; function for expanding parenthesis
12830 (defalias 'vhdl-expand-paren
(make-hippie-expand-function
12832 try-expand-list-all-buffers
)))
12834 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12835 ;; Line handling functions
12837 (defun vhdl-current-line ()
12838 "Return the line number of the line containing point."
12841 (1+ (count-lines (point-min) (point-at-bol)))))
12843 (defun vhdl-line-kill-entire (&optional arg
)
12844 "Delete entire line."
12846 (beginning-of-line)
12847 (kill-line (or arg
1)))
12849 (defun vhdl-line-kill (&optional arg
)
12850 "Kill current line."
12852 (vhdl-line-kill-entire arg
))
12854 (defun vhdl-line-copy (&optional arg
)
12855 "Copy current line."
12858 (let ((position (point-at-bol)))
12859 (forward-line (or arg
1))
12860 (copy-region-as-kill position
(point)))))
12862 (defun vhdl-line-yank ()
12863 "Yank entire line."
12865 (beginning-of-line)
12868 (defun vhdl-line-expand (&optional prefix-arg
)
12869 "Hippie-expand current line."
12871 (require 'hippie-exp
)
12872 (let ((case-fold-search t
) (case-replace nil
)
12873 (hippie-expand-try-functions-list
12874 '(try-expand-line try-expand-line-all-buffers
)))
12875 (hippie-expand prefix-arg
)))
12877 (defun vhdl-line-transpose-next (&optional arg
)
12878 "Interchange this line with next line."
12881 (transpose-lines (or arg
1))
12884 (defun vhdl-line-transpose-previous (&optional arg
)
12885 "Interchange this line with previous line."
12888 (transpose-lines (- 0 (or arg
0)))
12891 (defun vhdl-line-open ()
12892 "Open a new line and indent."
12895 (newline-and-indent))
12897 (defun vhdl-delete-indentation ()
12898 "Join lines. That is, call `delete-indentation' with `fill-prefix' so that
12899 it works within comments too."
12901 (let ((fill-prefix "-- "))
12902 (delete-indentation)))
12904 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12907 (defun vhdl-forward-same-indent ()
12908 "Move forward to next line with same indent."
12910 (let ((pos (point))
12911 (indent (current-indentation)))
12912 (beginning-of-line 2)
12913 (while (and (not (eobp))
12914 (or (looking-at "^\\s-*\\(--.*\\)?$")
12915 (> (current-indentation) indent
)))
12916 (beginning-of-line 2))
12917 (if (= (current-indentation) indent
)
12918 (back-to-indentation)
12919 (message "No following line with same indent found in this block")
12923 (defun vhdl-backward-same-indent ()
12924 "Move backward to previous line with same indent."
12926 (let ((pos (point))
12927 (indent (current-indentation)))
12928 (beginning-of-line -
0)
12929 (while (and (not (bobp))
12930 (or (looking-at "^\\s-*\\(--.*\\)?$")
12931 (> (current-indentation) indent
)))
12932 (beginning-of-line -
0))
12933 (if (= (current-indentation) indent
)
12934 (back-to-indentation)
12935 (message "No preceding line with same indent found in this block")
12939 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12942 (defun vhdl-statistics-buffer ()
12943 "Get some file statistics."
12950 (no-lines (count-lines (point-min) (point-max))))
12952 ;; count statements
12953 (goto-char (point-min))
12954 (while (re-search-forward "\\(--.*\n\\|\"[^\"\n]*[\"\n]\\)\\|;" nil t
)
12955 (if (match-string 1)
12956 (goto-char (match-end 1))
12957 (setq no-stats
(1+ no-stats
))))
12958 ;; count code lines
12959 (goto-char (point-min))
12960 (while (not (eobp))
12961 (unless (looking-at "^\\s-*\\(--.*\\)?$")
12962 (setq no-code-lines
(1+ no-code-lines
)))
12963 (beginning-of-line 2))
12964 ;; count empty lines
12965 (goto-char (point-min))
12966 (while (and (re-search-forward "^\\s-*$" nil t
)
12967 (not (eq (point) (point-max))))
12968 (if (match-string 1)
12969 (goto-char (match-end 1))
12970 (setq no-empty-lines
(1+ no-empty-lines
))
12971 (unless (eq (point) (point-max))
12973 ;; count comment-only lines
12974 (goto-char (point-min))
12975 (while (re-search-forward "^\\s-*--.*" nil t
)
12976 (if (match-string 1)
12977 (goto-char (match-end 1))
12978 (setq no-comm-lines
(1+ no-comm-lines
))))
12980 (goto-char (point-min))
12981 (while (re-search-forward "--.*" nil t
)
12982 (if (match-string 1)
12983 (goto-char (match-end 1))
12984 (setq no-comments
(1+ no-comments
)))))
12987 File statistics: \"%s\"\n\
12988 -----------------------\n\
12989 # statements : %5d\n\
12990 # code lines : %5d\n\
12991 # empty lines : %5d\n\
12992 # comment lines : %5d\n\
12993 # comments : %5d\n\
12994 # total lines : %5d\n"
12995 (buffer-file-name) no-stats no-code-lines no-empty-lines
12996 no-comm-lines no-comments no-lines
)
12997 (unless vhdl-emacs-21
(vhdl-show-messages))))
12999 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13002 (defun vhdl-re-search-forward (regexp &optional bound noerror count
)
13003 "Like `re-search-forward', but does not match within literals."
13006 (while (and (setq pos
(re-search-forward regexp bound noerror count
))
13007 (save-match-data (vhdl-in-literal)))))
13008 (when pos
(goto-char pos
))
13011 (defun vhdl-re-search-backward (regexp &optional bound noerror count
)
13012 "Like `re-search-backward', but does not match within literals."
13015 (while (and (setq pos
(re-search-backward regexp bound noerror count
))
13016 (save-match-data (vhdl-in-literal)))))
13017 (when pos
(goto-char pos
))
13021 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13023 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13025 (defun vhdl-set-project (name)
13026 "Set current project to NAME."
13028 (list (let ((completion-ignore-case t
))
13029 (completing-read "Project name: " vhdl-project-alist nil t
))))
13030 (cond ((equal name
"")
13031 (setq vhdl-project nil
)
13032 (message "Current VHDL project: None"))
13033 ((assoc name vhdl-project-alist
)
13034 (setq vhdl-project name
)
13035 (message "Current VHDL project: \"%s\"" name
))
13037 (vhdl-warning (format "Unknown VHDL project: \"%s\"" name
))))
13038 (vhdl-speedbar-update-current-project))
13040 (defun vhdl-set-default-project ()
13041 "Set current project as default on startup."
13043 (customize-set-variable 'vhdl-project vhdl-project
)
13044 (customize-save-customized))
13046 (defun vhdl-toggle-project (name token indent
)
13047 "Set current project to NAME or unset if NAME is current project."
13048 (vhdl-set-project (if (equal name vhdl-project
) "" name
)))
13050 (defun vhdl-export-project (file-name)
13051 "Write project setup for current project."
13053 (let ((name (vhdl-resolve-env-variable
13054 (vhdl-replace-string
13055 (cons "\\(.*\\) \\(.*\\)" (car vhdl-project-file-name
))
13056 (concat (subst-char-in-string
13057 ? ?_
(or (vhdl-project-p)
13058 (error "ERROR: No current project")))
13059 " " (user-login-name))))))
13060 (list (read-file-name
13061 "Write project file: "
13062 (when (file-name-absolute-p name
) "") nil nil name
))))
13063 (setq file-name
(abbreviate-file-name file-name
))
13064 (let ((orig-buffer (current-buffer)))
13065 (unless (file-exists-p (file-name-directory file-name
))
13066 (make-directory (file-name-directory file-name
) t
))
13067 (if (not (file-writable-p file-name
))
13068 (error "ERROR: File not writable: \"%s\"" file-name
)
13069 (set-buffer (find-file-noselect file-name t t
))
13071 (insert ";; -*- Emacs-Lisp -*-\n\n"
13072 ";;; " (file-name-nondirectory file-name
)
13073 " - project setup file for Emacs VHDL Mode " vhdl-version
"\n\n"
13074 ";; Project : " vhdl-project
"\n"
13075 ";; Saved : " (format-time-string "%Y-%m-%d %T ")
13076 (user-login-name) "\n\n\n"
13077 ";; project name\n"
13078 "(setq vhdl-project \"" vhdl-project
"\")\n\n"
13079 ";; project setup\n"
13080 "(vhdl-aput 'vhdl-project-alist vhdl-project\n'")
13081 (pp (vhdl-aget vhdl-project-alist vhdl-project
) (current-buffer))
13084 (kill-buffer (current-buffer))
13085 (set-buffer orig-buffer
))))
13087 (defun vhdl-import-project (file-name &optional auto not-make-current
)
13088 "Read project setup and set current project."
13090 (let ((name (vhdl-resolve-env-variable
13091 (vhdl-replace-string
13092 (cons "\\(.*\\) \\(.*\\)" (car vhdl-project-file-name
))
13093 (concat "" " " (user-login-name))))))
13094 (list (read-file-name
13095 "Read project file: " (when (file-name-absolute-p name
) "") nil t
13096 (file-name-directory name
)))))
13097 (when (file-exists-p file-name
)
13099 (let ((current-project vhdl-project
))
13100 (load-file file-name
)
13101 (when (/= (length (vhdl-aget vhdl-project-alist vhdl-project
)) 10)
13102 (vhdl-adelete 'vhdl-project-alist vhdl-project
)
13104 (if not-make-current
13105 (setq vhdl-project current-project
)
13106 (setq vhdl-compiler
13107 (caar (nth 4 (vhdl-aget vhdl-project-alist vhdl-project
)))))
13108 (vhdl-update-mode-menu)
13109 (vhdl-speedbar-refresh)
13110 (unless not-make-current
13111 (message "Current VHDL project: \"%s\"; compiler: \"%s\"%s"
13112 vhdl-project vhdl-compiler
(if auto
" (auto-loaded)" ""))))
13113 (error (vhdl-warning
13114 (format "ERROR: Invalid project setup file: \"%s\"" file-name
))))))
13116 (defun vhdl-duplicate-project ()
13117 "Duplicate setup of current project."
13119 (let ((new-name (read-from-minibuffer "New project name: "))
13120 (project-entry (vhdl-aget vhdl-project-alist vhdl-project
)))
13121 (setq vhdl-project-alist
13122 (append vhdl-project-alist
13123 (list (cons new-name project-entry
))))
13124 (vhdl-update-mode-menu)))
13126 (defun vhdl-auto-load-project ()
13127 "Automatically load project setup at startup."
13128 (let ((file-name-list vhdl-project-file-name
)
13129 file-list list-length
)
13130 (while file-name-list
13133 (file-expand-wildcards
13134 (vhdl-resolve-env-variable
13135 (vhdl-replace-string
13136 (cons "\\(.*\\) \\(.*\\)" (car file-name-list
))
13137 (concat "* " (user-login-name)))))))
13138 (setq list-length
(or list-length
(length file-list
)))
13139 (setq file-name-list
(cdr file-name-list
)))
13141 (vhdl-import-project (expand-file-name (car file-list
)) t
13142 (not (> list-length
0)))
13143 (setq list-length
(1- list-length
))
13144 (setq file-list
(cdr file-list
)))))
13146 ;; automatically load project setup when idle after startup
13147 (when (memq 'startup vhdl-project-auto-load
)
13149 (vhdl-auto-load-project)
13150 (vhdl-run-when-idle .1 nil
'vhdl-auto-load-project
)))
13153 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13156 ;; (using `hideshow.el')
13158 (defconst vhdl-hs-start-regexp
13161 ;; generic/port clause
13162 "\\(generic\\|port\\)[ \t\n\r\f]*(\\|"
13165 ;; component instantiation
13166 "\\(\\w\\|\\s_\\)+[ \t\n\r\f]*:[ \t\n\r\f]*"
13167 "\\(\\(component\\|configuration\\|entity\\)[ \t\n\r\f]+\\)?"
13168 "\\(\\w\\|\\s_\\)+\\([ \t\n\r\f]*(\\(\\w\\|\\s_\\)+)\\)?[ \t\n\r\f]*"
13169 "\\(generic\\|port\\)[ \t\n\r\f]+map[ \t\n\r\f]*(\\|"
13171 "\\(function\\|procedure\\)\\>\\|"
13173 "\\(\\(\\w\\|\\s_\\)+[ \t\n\r\f]*:[ \t\n\r\f]*\\)?\\(process\\|block\\)\\>\\|"
13174 ;; configuration declaration
13177 "Regexp to match start of construct to hide.")
13179 (defun vhdl-hs-forward-sexp-func (count)
13180 "Find end of construct to hide (for hideshow). Only searches forward."
13181 (let ((pos (point)))
13182 (vhdl-prepare-search-2
13183 (beginning-of-line)
13185 ;; generic/port clause
13186 ((looking-at "^\\s-*\\(generic\\|port\\)[ \t\n\r\f]*(")
13187 (goto-char (match-end 0))
13190 ;; component declaration
13191 ((looking-at "^\\s-*component\\>")
13192 (re-search-forward "^\\s-*end\\s-+component\\>" nil t
))
13193 ;; component instantiation
13196 "^\\s-*\\w+\\s-*:[ \t\n\r\f]*"
13197 "\\(\\(component\\|configuration\\|entity\\)[ \t\n\r\f]+\\)?"
13198 "\\w+\\(\\s-*(\\w+)\\)?[ \t\n\r\f]*"
13199 "\\(generic\\|port\\)\\s-+map[ \t\n\r\f]*("))
13200 (goto-char (match-end 0))
13204 (vhdl-forward-syntactic-ws)
13205 (when (looking-at "port\\s-+map[ \t\n\r\f]*(")
13206 (goto-char (match-end 0))
13209 (setq pos
(point)))
13211 ;; subprogram declaration/body
13212 ((looking-at "^\\s-*\\(function\\|procedure\\)\\s-+\\(\\w+\\|\".+\"\\)")
13213 (goto-char (match-end 0))
13214 (vhdl-forward-syntactic-ws)
13215 (when (looking-at "(")
13217 (while (and (re-search-forward "\\(;\\)\\|\\(\\<is\\>\\)" nil t
)
13218 (vhdl-in-literal)))
13220 (when (match-string 2)
13221 (re-search-forward "^\\s-*\\<begin\\>" nil t
)
13222 (backward-word-strictly 1)
13223 (vhdl-forward-sexp)))
13224 ;; block (recursive)
13225 ((looking-at "^\\s-*\\w+\\s-*:\\s-*block\\>")
13226 (goto-char (match-end 0))
13227 (while (and (re-search-forward "^\\s-*\\(\\(\\w+\\s-*:\\s-*block\\>\\)\\|\\(end\\s-+block\\>\\)\\)" nil t
)
13228 (match-beginning 2))
13229 (vhdl-hs-forward-sexp-func count
)))
13231 ((looking-at "^\\s-*\\(\\w+\\s-*:\\s-*\\)?process\\>")
13232 (re-search-forward "^\\s-*end\\s-+process\\>" nil t
))
13233 ;; configuration declaration
13234 ((looking-at "^\\s-*configuration\\>")
13235 (forward-word-strictly 4)
13236 (vhdl-forward-sexp))
13237 (t (goto-char pos
))))))
13239 (defun vhdl-hideshow-init ()
13240 "Initialize `hideshow'."
13241 (when vhdl-hideshow-menu
13242 (vhdl-hs-minor-mode 1)))
13244 (defun vhdl-hs-minor-mode (&optional arg
)
13245 "Toggle hideshow minor mode and update menu bar."
13247 (require 'hideshow
)
13248 ;; check for hideshow version 5.x
13249 (if (not (boundp 'hs-block-start-mdata-select
))
13250 (vhdl-warning-when-idle "Install included `hideshow.el' patch first (see INSTALL file)")
13251 ;; initialize hideshow
13252 (unless (assoc 'vhdl-mode hs-special-modes-alist
)
13253 (setq hs-special-modes-alist
13254 (cons (list 'vhdl-mode vhdl-hs-start-regexp nil
"--\\( \\|$\\)"
13255 'vhdl-hs-forward-sexp-func nil
)
13256 hs-special-modes-alist
)))
13257 (if (featurep 'xemacs
) (make-local-hook 'hs-minor-mode-hook
))
13258 (if vhdl-hide-all-init
13259 (add-hook 'hs-minor-mode-hook
'hs-hide-all nil t
)
13260 (remove-hook 'hs-minor-mode-hook
'hs-hide-all t
))
13261 (hs-minor-mode arg
)
13262 (force-mode-line-update))) ; hack to update menu bar
13265 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13267 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13268 ;; (using `font-lock.el')
13270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13273 (defun vhdl-within-translate-off ()
13274 "Return point if within translate-off region, else nil."
13275 (and (save-excursion
13276 (re-search-backward
13277 "^\\s-*--\\s-*pragma\\s-*translate_\\(on\\|off\\)\\s-*\n" nil t
))
13278 (equal "off" (match-string 1))
13281 (defun vhdl-start-translate-off (limit)
13282 "Return point before translate-off pragma if before LIMIT, else nil."
13283 (when (re-search-forward
13284 "^\\s-*--\\s-*pragma\\s-*translate_off\\s-*\n" limit t
)
13285 (match-beginning 0)))
13287 (defun vhdl-end-translate-off (limit)
13288 "Return point after translate-on pragma if before LIMIT, else nil."
13289 (re-search-forward "^\\s-*--\\s-*pragma\\s-*translate_on\\s-*\n" limit t
))
13291 (defun vhdl-match-translate-off (limit)
13292 "Match a translate-off block, setting match-data and returning t, else nil."
13293 (when (< (point) limit
)
13294 (let ((start (or (vhdl-within-translate-off)
13295 (vhdl-start-translate-off limit
)))
13296 (case-fold-search t
))
13298 (let ((end (or (vhdl-end-translate-off limit
) limit
)))
13299 (set-match-data (list start end
))
13300 (goto-char end
))))))
13302 (defun vhdl-font-lock-match-item (limit)
13303 "Match, and move over, any declaration item after point. Adapted from
13304 `font-lock-match-c-style-declaration-item-and-skip-to-next'."
13305 (condition-case nil
13307 (narrow-to-region (point-min) limit
)
13309 (when (looking-at "\\s-*\\([a-zA-Z]\\w*\\)")
13311 (goto-char (match-end 1))
13312 ;; move to next item
13313 (if (looking-at "\\(\\s-*,\\)")
13314 (goto-char (match-end 1))
13315 (end-of-line) t
))))
13318 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13319 ;; Syntax definitions
13321 (defconst vhdl-font-lock-syntactic-keywords
13322 '(("\\('\\).\\('\\)" (1 (7 . ?
\')) (2 (7 . ?
\'))))
13323 "Mark single quotes as having string quote syntax in `c' instances.")
13325 (defvar vhdl-font-lock-keywords nil
13326 "Regular expressions to highlight in VHDL Mode.")
13328 (defvar vhdl-font-lock-keywords-0
13329 ;; set in `vhdl-font-lock-init' because dependent on user options
13330 "For consideration as a value of `vhdl-font-lock-keywords'.
13331 This does highlighting of template prompts and directives (pragmas).")
13333 (defvar vhdl-font-lock-keywords-1 nil
13334 ;; set in `vhdl-font-lock-init' because dependent on user options
13335 "For consideration as a value of `vhdl-font-lock-keywords'.
13336 This does highlighting of keywords and standard identifiers.")
13338 (defconst vhdl-font-lock-keywords-2
13340 ;; highlight names of units, subprograms, and components when declared
13344 "architecture\\|configuration\\|context\\|entity\\|package"
13345 "\\(\\s-+body\\)?\\|"
13346 "\\(\\(impure\\|pure\\)\\s-+\\)?function\\|procedure\\|component"
13347 "\\)\\s-+\\(\\w+\\)")
13348 5 'font-lock-function-name-face
)
13350 ;; highlight entity names of architectures and configurations
13352 "^\\s-*\\(architecture\\|configuration\\)\\s-+\\w+\\s-+of\\s-+\\(\\w+\\)"
13353 2 'font-lock-function-name-face
)
13355 ;; highlight labels of common constructs
13358 "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*\\(\\("
13359 "assert\\|block\\|case\\|exit\\|for\\|if\\|loop\\|next\\|null\\|"
13360 "postponed\\|process\\|"
13361 (when (vhdl-standard-p 'ams
) "procedural\\|")
13363 "\\)\\>\\|\\w+\\s-*\\(([^\n]*)\\|\\.\\w+\\)*\\s-*<=\\)")
13364 1 'font-lock-function-name-face
)
13366 ;; highlight label and component name of component instantiations
13369 "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]*"
13370 "\\(--[^\n]*[ \t\n\r\f]+\\)*\\(generic\\|port\\)\\s-+map\\>")
13371 '(1 font-lock-function-name-face
) '(2 font-lock-function-name-face
))
13373 ;; highlight label and instantiated unit of component instantiations
13376 "^\\s-*\\(\\w+\\)\\s-*:[ \t\n\r\f]*"
13377 "\\(component\\|configuration\\|entity\\)\\s-+"
13378 "\\(\\w+\\)\\(\\.\\(\\w+\\)\\)?\\(\\s-*(\\(\\w+\\))\\)?")
13379 '(1 font-lock-function-name-face
) '(3 font-lock-function-name-face
)
13380 '(5 font-lock-function-name-face nil t
)
13381 '(7 font-lock-function-name-face nil t
))
13383 ;; highlight names and labels at end of constructs
13386 "^\\s-*end\\s-+\\(\\("
13387 "architecture\\|block\\|case\\|component\\|configuration\\|context\\|"
13388 "entity\\|for\\|function\\|generate\\|if\\|loop\\|package"
13389 "\\(\\s-+body\\)?\\|procedure\\|\\(postponed\\s-+\\)?process\\|"
13390 (when (vhdl-standard-p 'ams
) "procedural\\|")
13392 "\\)\\s-+\\)?\\(\\w*\\)")
13393 5 'font-lock-function-name-face
)
13395 ;; highlight labels in exit and next statements
13398 "^\\s-*\\(\\w+\\s-*:\\s-*\\)?\\(exit\\|next\\)\\s-+\\(\\w*\\)")
13399 3 'font-lock-function-name-face
)
13401 ;; highlight entity name in attribute specifications
13404 "^\\s-*attribute\\s-+\\w+\\s-+of\\s-+\\(\\w+\\(,\\s-*\\w+\\)*\\)\\s-*:")
13405 1 'font-lock-function-name-face
)
13407 ;; highlight labels in block and component specifications
13410 "^\\s-*for\\s-+\\(\\w+\\(,\\s-*\\w+\\)*\\)\\>\\s-*"
13411 "\\(:[ \t\n\r\f]*\\(\\w+\\)\\|[^i \t]\\)")
13412 '(1 font-lock-function-name-face
) '(4 font-lock-function-name-face nil t
))
13414 ;; highlight names in library clauses
13415 (list "^\\s-*library\\>"
13416 '(vhdl-font-lock-match-item nil nil
(1 font-lock-function-name-face
)))
13418 ;; highlight names in use clauses
13421 "\\<\\(context\\|use\\)\\s-+\\(\\(entity\\|configuration\\)\\s-+\\)?"
13422 "\\(\\w+\\)\\(\\.\\(\\w+\\)\\)?\\((\\(\\w+\\))\\)?")
13423 '(4 font-lock-function-name-face
) '(6 font-lock-function-name-face nil t
)
13424 '(8 font-lock-function-name-face nil t
))
13426 ;; highlight attribute name in attribute declarations/specifications
13429 "^\\s-*attribute\\s-+\\(\\w+\\)")
13430 1 'vhdl-font-lock-attribute-face
)
13432 ;; highlight type/nature name in (sub)type/(sub)nature declarations
13435 "^\\s-*\\(\\(sub\\)?\\(nature\\|type\\)\\|end\\s-+\\(record\\|protected\\)\\)\\s-+\\(\\w+\\)")
13436 5 'font-lock-type-face
)
13438 ;; highlight signal/variable/constant declaration names
13439 (list "\\(:[^=]\\)"
13440 '(vhdl-font-lock-match-item
13441 (progn (goto-char (match-beginning 1))
13442 (skip-syntax-backward " ")
13443 (skip-syntax-backward "w_")
13444 (skip-syntax-backward " ")
13445 (while (= (preceding-char) ?
,)
13447 (skip-syntax-backward " ")
13448 (skip-syntax-backward "w_")
13449 (skip-syntax-backward " ")))
13450 (goto-char (match-end 1)) (1 font-lock-variable-name-face
)))
13452 ;; highlight formal parameters in component instantiations and subprogram
13455 '(vhdl-font-lock-match-item
13456 (progn (goto-char (match-beginning 1))
13457 (skip-syntax-backward " ")
13458 (while (= (preceding-char) ?\
)) (backward-sexp))
13459 (skip-syntax-backward "w_")
13460 (skip-syntax-backward " ")
13461 (when (memq (preceding-char) '(?n ?N ?|
))
13462 (goto-char (point-max))))
13463 (goto-char (match-end 1)) (1 font-lock-variable-name-face
)))
13465 ;; highlight alias/group/quantity declaration names and for-loop/-generate
13467 (list "\\<\\(alias\\|for\\|group\\|quantity\\)\\s-+\\w+\\s-+\\(across\\|in\\|is\\)\\>"
13468 '(vhdl-font-lock-match-item
13469 (progn (goto-char (match-end 1)) (match-beginning 2))
13470 nil
(1 font-lock-variable-name-face
)))
13472 ;; highlight tool directives
13475 "^\\s-*\\(`\\w+\\)")
13476 1 'font-lock-preprocessor-face
)
13478 "For consideration as a value of `vhdl-font-lock-keywords'.
13479 This does context sensitive highlighting of names and labels.")
13481 (defvar vhdl-font-lock-keywords-3 nil
13482 ;; set in `vhdl-font-lock-init' because dependent on user options
13483 "For consideration as a value of `vhdl-font-lock-keywords'.
13484 This does highlighting of words with special syntax.")
13486 (defvar vhdl-font-lock-keywords-4 nil
13487 ;; set in `vhdl-font-lock-init' because dependent on user options
13488 "For consideration as a value of `vhdl-font-lock-keywords'.
13489 This does highlighting of additional reserved words.")
13491 (defconst vhdl-font-lock-keywords-5
13492 ;; background highlight translate-off regions
13493 '((vhdl-match-translate-off (0 vhdl-font-lock-translate-off-face append
)))
13494 "For consideration as a value of `vhdl-font-lock-keywords'.
13495 This does background highlighting of translate-off regions.")
13497 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13498 ;; Font and color definitions
13500 (defvar vhdl-font-lock-prompt-face
'vhdl-font-lock-prompt-face
13501 "Face name to use for prompts.")
13503 (defvar vhdl-font-lock-attribute-face
'vhdl-font-lock-attribute-face
13504 "Face name to use for standardized attributes.")
13506 (defvar vhdl-font-lock-enumvalue-face
'vhdl-font-lock-enumvalue-face
13507 "Face name to use for standardized enumeration values.")
13509 (defvar vhdl-font-lock-function-face
'vhdl-font-lock-function-face
13510 "Face name to use for standardized functions and packages.")
13512 (defvar vhdl-font-lock-directive-face
'vhdl-font-lock-directive-face
13513 "Face name to use for directives.")
13515 (defvar vhdl-font-lock-reserved-words-face
'vhdl-font-lock-reserved-words-face
13516 "Face name to use for additional reserved words.")
13518 (defvar vhdl-font-lock-translate-off-face
'vhdl-font-lock-translate-off-face
13519 "Face name to use for translate-off regions.")
13521 ;; face names to use for words with special syntax.
13522 (let ((syntax-alist vhdl-special-syntax-alist
)
13524 (while syntax-alist
13525 (setq name
(vhdl-function-name
13526 "vhdl-font-lock" (nth 0 (car syntax-alist
)) "face"))
13527 (eval `(defvar ,name
',name
13528 ,(concat "Face name to use for "
13529 (nth 0 (car syntax-alist
)) ".")))
13530 (setq syntax-alist
(cdr syntax-alist
))))
13532 (defgroup vhdl-highlight-faces nil
13533 "Faces for highlighting."
13534 :group
'vhdl-highlight
)
13536 ;; add faces used from `font-lock'
13537 (custom-add-to-group
13538 'vhdl-highlight-faces
'font-lock-comment-face
'custom-face
)
13539 (custom-add-to-group
13540 'vhdl-highlight-faces
'font-lock-string-face
'custom-face
)
13541 (custom-add-to-group
13542 'vhdl-highlight-faces
'font-lock-keyword-face
'custom-face
)
13543 (custom-add-to-group
13544 'vhdl-highlight-faces
'font-lock-type-face
'custom-face
)
13545 (custom-add-to-group
13546 'vhdl-highlight-faces
'font-lock-function-name-face
'custom-face
)
13547 (custom-add-to-group
13548 'vhdl-highlight-faces
'font-lock-variable-name-face
'custom-face
)
13550 (defface vhdl-font-lock-prompt-face
13551 '((((min-colors 88) (class color
) (background light
))
13552 (:foreground
"Red1" :bold t
))
13553 (((class color
) (background light
)) (:foreground
"Red" :bold t
))
13554 (((class color
) (background dark
)) (:foreground
"Pink" :bold t
))
13555 (t (:inverse-video t
)))
13556 "Font lock mode face used to highlight prompts."
13557 :group
'vhdl-highlight-faces
)
13559 (defface vhdl-font-lock-attribute-face
13560 '((((class color
) (background light
)) (:foreground
"Orchid"))
13561 (((class color
) (background dark
)) (:foreground
"LightSteelBlue"))
13562 (t (:italic t
:bold t
)))
13563 "Font lock mode face used to highlight standardized attributes."
13564 :group
'vhdl-highlight-faces
)
13566 (defface vhdl-font-lock-enumvalue-face
13567 '((((class color
) (background light
)) (:foreground
"SaddleBrown"))
13568 (((class color
) (background dark
)) (:foreground
"BurlyWood"))
13569 (t (:italic t
:bold t
)))
13570 "Font lock mode face used to highlight standardized enumeration values."
13571 :group
'vhdl-highlight-faces
)
13573 (defface vhdl-font-lock-function-face
13574 '((((class color
) (background light
)) (:foreground
"Cyan4"))
13575 (((class color
) (background dark
)) (:foreground
"Orchid1"))
13576 (t (:italic t
:bold t
)))
13577 "Font lock mode face used to highlight standardized functions and packages."
13578 :group
'vhdl-highlight-faces
)
13580 (defface vhdl-font-lock-directive-face
13581 '((((class color
) (background light
)) (:foreground
"CadetBlue"))
13582 (((class color
) (background dark
)) (:foreground
"Aquamarine"))
13583 (t (:italic t
:bold t
)))
13584 "Font lock mode face used to highlight directives."
13585 :group
'vhdl-highlight-faces
)
13587 (defface vhdl-font-lock-reserved-words-face
13588 '((((class color
) (background light
)) (:foreground
"Orange" :bold t
))
13589 (((min-colors 88) (class color
) (background dark
))
13590 (:foreground
"Yellow1" :bold t
))
13591 (((class color
) (background dark
)) (:foreground
"Yellow" :bold t
))
13593 "Font lock mode face used to highlight additional reserved words."
13594 :group
'vhdl-highlight-faces
)
13596 (defface vhdl-font-lock-translate-off-face
13597 '((((class color
) (background light
)) (:background
"LightGray"))
13598 (((class color
) (background dark
)) (:background
"DimGray"))
13600 "Font lock mode face used to background highlight translate-off regions."
13601 :group
'vhdl-highlight-faces
)
13603 ;; font lock mode faces used to highlight words with special syntax.
13604 (let ((syntax-alist vhdl-special-syntax-alist
))
13605 (while syntax-alist
13606 (eval `(defface ,(vhdl-function-name
13607 "vhdl-font-lock" (caar syntax-alist
) "face")
13608 '((((class color
) (background light
))
13609 (:foreground
,(nth 2 (car syntax-alist
))))
13610 (((class color
) (background dark
))
13611 (:foreground
,(nth 3 (car syntax-alist
))))
13613 ,(concat "Font lock mode face used to highlight "
13614 (nth 0 (car syntax-alist
)) ".")
13615 :group
'vhdl-highlight-faces
))
13616 (setq syntax-alist
(cdr syntax-alist
))))
13618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13619 ;; Font lock initialization
13621 (defun vhdl-font-lock-init ()
13622 "Initialize fontification."
13623 ;; highlight template prompts and directives
13624 (setq vhdl-font-lock-keywords-0
13625 (list (list (concat "\\(^\\|[ \t(.']\\)\\(<"
13626 vhdl-template-prompt-syntax
">\\)")
13627 2 'vhdl-font-lock-prompt-face t
)
13628 (list (concat "--\\s-*"
13629 vhdl-directive-keywords-regexp
"\\s-+\\(.*\\)$")
13630 2 'vhdl-font-lock-directive-face t
)
13631 ;; highlight c-preprocessor directives
13632 (list "^#[ \t]*\\(\\w+\\)\\([ \t]+\\(\\w+\\)\\)?"
13633 '(1 font-lock-builtin-face
)
13634 '(3 font-lock-variable-name-face nil t
))))
13635 ;; highlight keywords and standardized types, attributes, enumeration
13636 ;; values, and subprograms
13637 (setq vhdl-font-lock-keywords-1
13639 (list (concat "'" vhdl-attributes-regexp
)
13640 1 'vhdl-font-lock-attribute-face
)
13641 (list vhdl-types-regexp
1 'font-lock-type-face
)
13642 (list vhdl-functions-regexp
1 'vhdl-font-lock-function-face
)
13643 (list vhdl-packages-regexp
1 'vhdl-font-lock-function-face
)
13644 (list vhdl-enum-values-regexp
1 'vhdl-font-lock-enumvalue-face
)
13645 (list vhdl-constants-regexp
1 'font-lock-constant-face
)
13646 (list vhdl-keywords-regexp
1 'font-lock-keyword-face
)))
13647 ;; highlight words with special syntax.
13648 (setq vhdl-font-lock-keywords-3
13649 (let ((syntax-alist vhdl-special-syntax-alist
)
13651 (while syntax-alist
13654 (list (concat "\\(" (nth 1 (car syntax-alist
)) "\\)") 1
13655 (vhdl-function-name
13656 "vhdl-font-lock" (nth 0 (car syntax-alist
)) "face")
13657 (nth 4 (car syntax-alist
)))
13659 (setq syntax-alist
(cdr syntax-alist
)))
13661 ;; highlight additional reserved words
13662 (setq vhdl-font-lock-keywords-4
13663 (list (list vhdl-reserved-words-regexp
1
13664 'vhdl-font-lock-reserved-words-face
)))
13665 ;; highlight everything together
13666 (setq vhdl-font-lock-keywords
13668 vhdl-font-lock-keywords-0
13669 (when vhdl-highlight-keywords vhdl-font-lock-keywords-1
)
13670 (when (or vhdl-highlight-forbidden-words
13671 vhdl-highlight-verilog-keywords
) vhdl-font-lock-keywords-4
)
13672 (when vhdl-highlight-special-words vhdl-font-lock-keywords-3
)
13673 (when vhdl-highlight-names vhdl-font-lock-keywords-2
)
13674 (when vhdl-highlight-translate-off vhdl-font-lock-keywords-5
))))
13676 ;; initialize fontification for VHDL Mode
13677 (vhdl-font-lock-init)
13679 (defun vhdl-fontify-buffer ()
13680 "Re-initialize fontification and fontify buffer."
13682 (setq font-lock-defaults
13683 `(vhdl-font-lock-keywords
13684 nil
,(not vhdl-highlight-case-sensitive
) ((?\_ .
"w"))
13685 beginning-of-line
))
13686 (when (fboundp 'font-lock-unset-defaults
)
13687 (font-lock-unset-defaults)) ; not implemented in XEmacs
13688 (font-lock-set-defaults)
13689 (font-lock-mode nil
)
13690 (font-lock-mode t
))
13692 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13693 ;; Initialization for PostScript printing
13695 (defun vhdl-ps-print-settings ()
13696 "Initialize custom face and page settings for PostScript printing."
13697 ;; define custom face settings
13698 (unless (or (not vhdl-print-customize-faces
)
13700 (set (make-local-variable 'ps-bold-faces
)
13701 '(font-lock-keyword-face
13702 font-lock-type-face
13703 vhdl-font-lock-attribute-face
13704 vhdl-font-lock-enumvalue-face
13705 vhdl-font-lock-directive-face
))
13706 (set (make-local-variable 'ps-italic-faces
)
13707 '(font-lock-comment-face
13708 font-lock-function-name-face
13709 font-lock-type-face
13710 vhdl-font-lock-attribute-face
13711 vhdl-font-lock-enumvalue-face
13712 vhdl-font-lock-directive-face
))
13713 (set (make-local-variable 'ps-underlined-faces
)
13714 '(font-lock-string-face))
13715 (setq ps-always-build-face-reference t
))
13716 ;; define page settings, so that a line containing 79 characters (default)
13717 ;; fits into one column
13718 (when vhdl-print-two-column
13719 (set (make-local-variable 'ps-landscape-mode
) t
)
13720 (set (make-local-variable 'ps-number-of-columns
) 2)
13721 (set (make-local-variable 'ps-font-size
) 7.0)
13722 (set (make-local-variable 'ps-header-title-font-size
) 10.0)
13723 (set (make-local-variable 'ps-header-font-size
) 9.0)
13724 (set (make-local-variable 'ps-header-offset
) 12.0)
13725 (when (eq ps-paper-type
'letter
)
13726 (set (make-local-variable 'ps-inter-column
) 40.0)
13727 (set (make-local-variable 'ps-left-margin
) 40.0)
13728 (set (make-local-variable 'ps-right-margin
) 40.0))))
13730 (defun vhdl-ps-print-init ()
13731 "Initialize PostScript printing."
13732 (if (featurep 'xemacs
)
13733 (when (boundp 'ps-print-color-p
)
13734 (vhdl-ps-print-settings))
13735 (if (featurep 'xemacs
) (make-local-hook 'ps-print-hook
))
13736 (add-hook 'ps-print-hook
'vhdl-ps-print-settings nil t
)))
13739 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13740 ;;; Hierarchy browser (using `speedbar.el')
13741 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13742 ;; Allows displaying the hierarchy of all VHDL design units contained in a
13743 ;; directory by using the speedbar.
13745 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13748 (defvar vhdl-entity-alist nil
13749 "Cache with entities and corresponding architectures for each
13750 project/directory.")
13751 ;; structure: (parenthesized expression means list of such entries)
13753 ;; (ent-key ent-name ent-file ent-line
13754 ;; (arch-key arch-name arch-file arch-line
13755 ;; (inst-key inst-name inst-file inst-line inst-comp-name inst-ent-key
13756 ;; inst-arch-key inst-conf-key inst-lib-key inst-path)
13757 ;; (lib-name pack-key))
13758 ;; mra-key (lib-name pack-key))
13760 (defvar vhdl-config-alist nil
13761 "Cache with configurations for each project/directory.")
13762 ;; structure: (parenthesized expression means list of such entries)
13764 ;; (conf-key conf-name conf-file conf-line ent-key arch-key
13765 ;; (inst-key inst-comp-name inst-ent-key inst-arch-key
13766 ;; inst-conf-key inst-lib-key)
13767 ;; (lib-name pack-key)))
13769 (defvar vhdl-package-alist nil
13770 "Cache with packages for each project/directory.")
13771 ;; structure: (parenthesized expression means list of such entries)
13773 ;; (pack-key pack-name pack-file pack-line
13774 ;; (comp-key comp-name comp-file comp-line)
13775 ;; (func-key func-name func-file func-line)
13776 ;; (lib-name pack-key)
13777 ;; pack-body-file pack-body-line
13778 ;; (func-key func-name func-body-file func-body-line)
13779 ;; (lib-name pack-key)))
13781 (defvar vhdl-ent-inst-alist nil
13782 "Cache with instantiated entities for each project/directory.")
13783 ;; structure: (parenthesized expression means list of such entries)
13784 ;; (cache-key (inst-ent-key))
13786 (defvar vhdl-file-alist nil
13787 "Cache with design units in each file for each project/directory.")
13788 ;; structure: (parenthesized expression means list of such entries)
13790 ;; (file-name (ent-list) (arch-list) (arch-ent-list) (conf-list)
13791 ;; (pack-list) (pack-body-list) (inst-list) (inst-ent-list))
13793 (defvar vhdl-directory-alist nil
13794 "Cache with source directories for each project.")
13795 ;; structure: (parenthesized expression means list of such entries)
13796 ;; (cache-key (directory))
13798 (defvar vhdl-speedbar-shown-unit-alist nil
13799 "Alist of design units simultaneously open in the current speedbar for each
13800 directory and project.")
13802 (defvar vhdl-speedbar-shown-project-list nil
13803 "List of projects simultaneously open in the current speedbar.")
13805 (defvar vhdl-updated-project-list nil
13806 "List of projects and directories with updated files.")
13808 (defvar vhdl-modified-file-list nil
13809 "List of modified files to be rescanned for hierarchy updating.")
13811 (defvar vhdl-speedbar-hierarchy-depth
0
13812 "Depth of instantiation hierarchy to display.")
13814 (defvar vhdl-speedbar-show-projects nil
13815 "Non-nil means project hierarchy is displayed in speedbar, directory
13816 hierarchy otherwise.")
13818 (defun vhdl-get-end-of-unit ()
13819 "Return position of end of current unit."
13820 (let ((pos (point)))
13822 (while (and (re-search-forward "^[ \t]*\\(architecture\\|configuration\\|context\\|entity\\|package\\)\\>" nil
1)
13824 (goto-char (match-beginning 0))
13825 (vhdl-backward-syntactic-ws)
13826 (and (/= (preceding-char) ?\
;) (not (bobp))))))
13827 (re-search-backward "^[ \t]*end\\>" pos
1)
13830 (defun vhdl-match-string-downcase (num &optional string
)
13831 "Like `match-string-no-properties' with down-casing."
13832 (let ((match (match-string-no-properties num string
)))
13833 (and match
(downcase match
))))
13836 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13839 (defun vhdl-scan-context-clause ()
13840 "Scan the context clause that precedes a design unit."
13843 (when (re-search-backward "^[ \t]*\\(architecture\\|configuration\\|context\\|entity\\|package\\)\\>" nil t
)
13844 (while (and (re-search-backward "^[ \t]*\\(end\\|use\\)\\>" nil t
)
13845 (equal "USE" (upcase (match-string 1))))
13846 (when (looking-at "^[ \t]*use[ \t\n\r\f]*\\(\\w+\\)\\.\\(\\w+\\)\\.\\w+")
13847 (push (cons (match-string-no-properties 1)
13848 (vhdl-match-string-downcase 2))
13852 (defun vhdl-scan-directory-contents (name &optional project update num-string
13854 "Scan contents of VHDL files in directory or file pattern NAME."
13855 (string-match "\\(.*[/\\]\\)\\(.*\\)" name
)
13856 (let* ((dir-name (match-string 1 name
))
13857 (file-pattern (match-string 2 name
))
13858 (is-directory (= 0 (length file-pattern
)))
13863 (vhdl-get-source-files t dir-name
)
13864 (vhdl-directory-files
13865 dir-name t
(wildcard-to-regexp file-pattern
)))))
13866 (key (or project dir-name
))
13867 (file-exclude-regexp
13868 (or (nth 3 (vhdl-aget vhdl-project-alist project
)) ""))
13869 (limit-design-file-size (nth 0 vhdl-speedbar-scan-limit
))
13870 (limit-hier-file-size (nth 0 (nth 1 vhdl-speedbar-scan-limit
)))
13871 (limit-hier-inst-no (nth 1 (nth 1 vhdl-speedbar-scan-limit
)))
13872 ent-alist conf-alist pack-alist ent-inst-list file-alist
13873 tmp-list tmp-entry no-files files-exist big-files
)
13874 (when (or project update
)
13875 (setq ent-alist
(vhdl-aget vhdl-entity-alist key
)
13876 conf-alist
(vhdl-aget vhdl-config-alist key
)
13877 pack-alist
(vhdl-aget vhdl-package-alist key
)
13878 ent-inst-list
(car (vhdl-aget vhdl-ent-inst-alist key
))
13879 file-alist
(vhdl-aget vhdl-file-alist key
)))
13880 (when (and (not is-directory
) (null file-list
))
13881 (message "No such file: \"%s\"" name
))
13882 (setq files-exist file-list
)
13884 (setq no-files
(length file-list
))
13885 (message "Scanning %s %s\"%s\"..."
13886 (if is-directory
"directory" "files") (or num-string
"") name
)
13888 (unless (equal file-exclude-regexp
"")
13889 (let ((case-fold-search nil
)
13892 (unless (string-match file-exclude-regexp
(car file-list
))
13893 (push (car file-list
) file-tmp-list
))
13894 (setq file-list
(cdr file-list
)))
13895 (setq file-list
(nreverse file-tmp-list
))))
13896 ;; do for all files
13898 (unless noninteractive
13899 (message "Scanning %s %s\"%s\"... (%2d%%)"
13900 (if is-directory
"directory" "files")
13901 (or num-string
"") name
13902 (floor (* 100.0 (- no-files
(length file-list
))) no-files
)))
13903 (let ((file-name (abbreviate-file-name (car file-list
)))
13904 ent-list arch-list arch-ent-list conf-list
13905 pack-list pack-body-list inst-list inst-ent-list
)
13909 (vhdl-prepare-search-2
13911 ;; scan for design units
13912 (if (and limit-design-file-size
13913 (< limit-design-file-size
(buffer-size)))
13914 (progn (message "WARNING: Scan limit (design units: file size) reached in file:\n \"%s\"" file-name
)
13915 (setq big-files t
))
13916 ;; scan for entities
13917 (goto-char (point-min))
13918 (while (re-search-forward "^[ \t]*entity[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
13919 (let* ((ent-name (match-string-no-properties 1))
13920 (ent-key (downcase ent-name
))
13921 (ent-entry (vhdl-aget ent-alist ent-key
))
13922 (lib-alist (vhdl-scan-context-clause)))
13923 (if (nth 1 ent-entry
)
13924 (vhdl-warning-when-idle
13925 "Entity declared twice (used 1.): \"%s\"\n 1. in \"%s\" (line %d)\n 2. in \"%s\" (line %d)"
13926 ent-name
(nth 1 ent-entry
) (nth 2 ent-entry
)
13927 file-name
(vhdl-current-line))
13928 (push ent-key ent-list
)
13929 (vhdl-aput 'ent-alist ent-key
13930 (list ent-name file-name
(vhdl-current-line)
13931 (nth 3 ent-entry
) (nth 4 ent-entry
)
13933 ;; scan for architectures
13934 (goto-char (point-min))
13935 (while (re-search-forward "^[ \t]*architecture[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
13936 (let* ((arch-name (match-string-no-properties 1))
13937 (arch-key (downcase arch-name
))
13938 (ent-name (match-string-no-properties 2))
13939 (ent-key (downcase ent-name
))
13940 (ent-entry (vhdl-aget ent-alist ent-key
))
13941 (arch-alist (nth 3 ent-entry
))
13942 (arch-entry (vhdl-aget arch-alist arch-key
))
13943 (lib-arch-alist (vhdl-scan-context-clause)))
13945 (vhdl-warning-when-idle
13946 "Architecture declared twice (used 1.): \"%s\" of \"%s\"\n 1. in \"%s\" (line %d)\n 2. in \"%s\" (line %d)"
13947 arch-name ent-name
(nth 1 arch-entry
)
13948 (nth 2 arch-entry
) file-name
(vhdl-current-line))
13949 (setq arch-list
(cons arch-key arch-list
)
13950 arch-ent-list
(cons ent-key arch-ent-list
))
13951 (vhdl-aput 'arch-alist arch-key
13952 (list arch-name file-name
(vhdl-current-line)
13953 nil lib-arch-alist
))
13954 (vhdl-aput 'ent-alist ent-key
13955 (list (or (nth 0 ent-entry
) ent-name
)
13956 (nth 1 ent-entry
) (nth 2 ent-entry
)
13957 (vhdl-sort-alist arch-alist
)
13958 arch-key
(nth 5 ent-entry
))))))
13959 ;; scan for configurations
13960 (goto-char (point-min))
13961 (while (re-search-forward "^[ \t]*configuration[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
13962 (let* ((conf-name (match-string-no-properties 1))
13963 (conf-key (downcase conf-name
))
13964 (conf-entry (vhdl-aget conf-alist conf-key
))
13965 (ent-name (match-string-no-properties 2))
13966 (ent-key (downcase ent-name
))
13967 (lib-alist (vhdl-scan-context-clause))
13968 (conf-line (vhdl-current-line))
13969 (end-of-unit (vhdl-get-end-of-unit))
13970 arch-key comp-conf-list inst-key-list
13971 inst-comp-key inst-ent-key inst-arch-key
13972 inst-conf-key inst-lib-key
)
13973 (when (vhdl-re-search-forward "\\<for[ \t\n\r\f]+\\(\\w+\\)")
13974 (setq arch-key
(vhdl-match-string-downcase 1)))
13976 (vhdl-warning-when-idle
13977 "Configuration declared twice (used 1.): \"%s\" of \"%s\"\n 1. in \"%s\" (line %d)\n 2. in \"%s\" (line %d)"
13978 conf-name ent-name
(nth 1 conf-entry
)
13979 (nth 2 conf-entry
) file-name conf-line
)
13980 (push conf-key conf-list
)
13981 ;; scan for subconfigurations and subentities
13982 (while (re-search-forward "^[ \t]*for[ \t\n\r\f]+\\(\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]+" end-of-unit t
)
13983 (setq inst-comp-key
(vhdl-match-string-downcase 3)
13984 inst-key-list
(split-string
13985 (vhdl-match-string-downcase 1)
13986 "[ \t\n\r\f]*,[ \t\n\r\f]*"))
13987 (vhdl-forward-syntactic-ws)
13988 (when (looking-at "use[ \t\n\r\f]+\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\w+\\)\\.\\(\\w+\\)[ \t\n\r\f]*\\((\\(\\w+\\))\\)?")
13990 inst-lib-key
(vhdl-match-string-downcase 3)
13991 inst-ent-key
(and (match-string 2)
13992 (vhdl-match-string-downcase 4))
13993 inst-arch-key
(and (match-string 2)
13994 (vhdl-match-string-downcase 6))
13995 inst-conf-key
(and (not (match-string 2))
13996 (vhdl-match-string-downcase 4)))
13997 (while inst-key-list
13998 (setq comp-conf-list
13999 (cons (list (car inst-key-list
)
14000 inst-comp-key inst-ent-key
14001 inst-arch-key inst-conf-key
14004 (setq inst-key-list
(cdr inst-key-list
)))))
14005 (vhdl-aput 'conf-alist conf-key
14006 (list conf-name file-name conf-line ent-key
14007 arch-key comp-conf-list lib-alist
)))))
14008 ;; scan for packages
14009 (goto-char (point-min))
14010 (while (re-search-forward "^[ \t]*package[ \t\n\r\f]+\\(body[ \t\n\r\f]+\\)?\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
14011 (let* ((pack-name (match-string-no-properties 2))
14012 (pack-key (downcase pack-name
))
14013 (is-body (match-string-no-properties 1))
14014 (pack-entry (vhdl-aget pack-alist pack-key
))
14015 (pack-line (vhdl-current-line))
14016 (end-of-unit (vhdl-get-end-of-unit))
14017 comp-name func-name comp-alist func-alist lib-alist
)
14018 (if (if is-body
(nth 6 pack-entry
) (nth 1 pack-entry
))
14019 (vhdl-warning-when-idle
14020 "Package%s declared twice (used 1.): \"%s\"\n 1. in \"%s\" (line %d)\n 2. in \"%s\" (line %d)"
14021 (if is-body
" body" "") pack-name
14022 (if is-body
(nth 6 pack-entry
) (nth 1 pack-entry
))
14023 (if is-body
(nth 7 pack-entry
) (nth 2 pack-entry
))
14024 file-name
(vhdl-current-line))
14025 ;; scan for context clauses
14026 (setq lib-alist
(vhdl-scan-context-clause))
14027 ;; scan for component and subprogram declarations/bodies
14028 (while (re-search-forward "^[ \t]*\\(component\\|function\\|procedure\\)[ \t\n\r\f]+\\(\\w+\\|\".*\"\\)" end-of-unit t
)
14029 (if (equal (upcase (match-string 1)) "COMPONENT")
14030 (setq comp-name
(match-string-no-properties 2)
14032 (cons (list (downcase comp-name
) comp-name
14033 file-name
(vhdl-current-line))
14035 (setq func-name
(match-string-no-properties 2)
14037 (cons (list (downcase func-name
) func-name
14038 file-name
(vhdl-current-line))
14040 (setq func-alist
(nreverse func-alist
))
14041 (setq comp-alist
(nreverse comp-alist
))
14043 (push pack-key pack-body-list
)
14044 (push pack-key pack-list
))
14046 'pack-alist pack-key
14048 (list (or (nth 0 pack-entry
) pack-name
)
14049 (nth 1 pack-entry
) (nth 2 pack-entry
)
14050 (nth 3 pack-entry
) (nth 4 pack-entry
)
14052 file-name pack-line func-alist lib-alist
)
14053 (list pack-name file-name pack-line
14054 comp-alist func-alist lib-alist
14055 (nth 6 pack-entry
) (nth 7 pack-entry
)
14056 (nth 8 pack-entry
) (nth 9 pack-entry
))))))))
14057 ;; scan for hierarchy
14058 (if (and limit-hier-file-size
14059 (< limit-hier-file-size
(buffer-size)))
14060 (progn (message "WARNING: Scan limit (hierarchy: file size) reached in file:\n \"%s\"" file-name
)
14061 (setq big-files t
))
14062 ;; scan for architectures
14063 (goto-char (point-min))
14064 (while (re-search-forward "^[ \t]*architecture[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
14065 (let* ((ent-name (match-string-no-properties 2))
14066 (ent-key (downcase ent-name
))
14067 (arch-name (match-string-no-properties 1))
14068 (arch-key (downcase arch-name
))
14069 (ent-entry (vhdl-aget ent-alist ent-key
))
14070 (arch-alist (nth 3 ent-entry
))
14071 (arch-entry (vhdl-aget arch-alist arch-key
))
14072 (beg-of-unit (point))
14073 (end-of-unit (vhdl-get-end-of-unit))
14075 inst-alist inst-path
)
14076 ;; scan for contained instantiations
14077 (while (and (re-search-forward
14078 (concat "^[ \t]*\\(\\w+\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\("
14079 "\\(\\w+\\)[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(generic\\|port\\)[ \t\n\r\f]+map\\>\\|"
14080 "component[ \t\n\r\f]+\\(\\w+\\)\\|"
14081 "\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?\\|"
14082 "\\(\\(for\\|if\\)\\>[^;:]+\\<generate\\>\\|block\\>\\)\\)\\|"
14083 "\\(^[ \t]*end[ \t\n\r\f]+\\(generate\\|block\\)\\>\\)") end-of-unit t
)
14084 (or (not limit-hier-inst-no
)
14085 (<= (if (or (match-string 14)
14088 (setq inst-no
(1+ inst-no
)))
14089 limit-hier-inst-no
)))
14091 ;; block/generate beginning found
14094 (cons (match-string-no-properties 1) inst-path
)))
14095 ;; block/generate end found
14097 (setq inst-path
(cdr inst-path
)))
14098 ;; instantiation found
14100 (let* ((inst-name (match-string-no-properties 1))
14101 (inst-key (downcase inst-name
))
14103 (or (match-string-no-properties 3)
14104 (match-string-no-properties 6)))
14106 (or (and (match-string 8)
14107 (vhdl-match-string-downcase 11))
14108 (and inst-comp-name
14109 (downcase inst-comp-name
))))
14110 (inst-arch-key (vhdl-match-string-downcase 13))
14112 (and (not (match-string 8))
14113 (vhdl-match-string-downcase 11)))
14114 (inst-lib-key (vhdl-match-string-downcase 10)))
14115 (goto-char (match-end 1))
14116 (setq inst-list
(cons inst-key inst-list
)
14118 (cons inst-ent-key inst-ent-list
))
14122 (list (list inst-key inst-name file-name
14123 (vhdl-current-line) inst-comp-name
14124 inst-ent-key inst-arch-key
14125 inst-conf-key inst-lib-key
14126 (reverse inst-path
)))))))))
14127 ;; scan for contained configuration specifications
14128 (goto-char beg-of-unit
)
14129 (while (re-search-forward
14130 (concat "^[ \t]*for[ \t\n\r\f]+\\(\\w+\\([ \t\n\r\f]*,[ \t\n\r\f]*\\w+\\)*\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\(\\w+\\)[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*"
14131 "use[ \t\n\r\f]+\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?") end-of-unit t
)
14132 (let* ((inst-comp-name (match-string-no-properties 3))
14134 (and (match-string 6)
14135 (vhdl-match-string-downcase 9)))
14136 (inst-arch-key (vhdl-match-string-downcase 11))
14138 (and (not (match-string 6))
14139 (vhdl-match-string-downcase 9)))
14140 (inst-lib-key (vhdl-match-string-downcase 8))
14142 (split-string (vhdl-match-string-downcase 1)
14143 "[ \t\n\r\f]*,[ \t\n\r\f]*"))
14144 (tmp-inst-alist inst-alist
)
14146 (while tmp-inst-alist
14147 (when (and (or (equal "all" (car inst-key-list
))
14148 (member (nth 0 (car tmp-inst-alist
))
14152 (or (nth 4 (car tmp-inst-alist
)) ""))
14153 (downcase inst-comp-name
)))
14154 (setq inst-entry
(car tmp-inst-alist
))
14155 (setq inst-ent-list
14156 (cons (or inst-ent-key
(nth 5 inst-entry
))
14158 (nth 5 inst-entry
) inst-ent-list
)))
14160 (list (nth 0 inst-entry
) (nth 1 inst-entry
)
14161 (nth 2 inst-entry
) (nth 3 inst-entry
)
14163 (or inst-ent-key
(nth 5 inst-entry
))
14164 (or inst-arch-key
(nth 6 inst-entry
))
14165 inst-conf-key inst-lib-key
))
14166 (setcar tmp-inst-alist inst-entry
))
14167 (setq tmp-inst-alist
(cdr tmp-inst-alist
)))))
14169 (vhdl-aput 'arch-alist arch-key
14170 (list (nth 0 arch-entry
) (nth 1 arch-entry
)
14171 (nth 2 arch-entry
) inst-alist
14172 (nth 4 arch-entry
)))
14173 (vhdl-aput 'ent-alist ent-key
14174 (list (nth 0 ent-entry
) (nth 1 ent-entry
)
14176 (vhdl-sort-alist arch-alist
)
14177 (nth 4 ent-entry
) (nth 5 ent-entry
)))
14178 (when (and limit-hier-inst-no
14179 (> inst-no limit-hier-inst-no
))
14180 (message "WARNING: Scan limit (hierarchy: instances per architecture) reached in file:\n \"%s\"" file-name
)
14181 (setq big-files t
))
14182 (goto-char end-of-unit
))))
14183 ;; remember design units for this file
14184 (vhdl-aput 'file-alist file-name
14185 (list ent-list arch-list arch-ent-list conf-list
14186 pack-list pack-body-list
14187 inst-list inst-ent-list
))
14188 (setq ent-inst-list
(append inst-ent-list ent-inst-list
))))))
14189 (setq file-list
(cdr file-list
))))
14190 (when (or (and (not project
) files-exist
)
14191 (and project
(not non-final
)))
14192 ;; consistency checks:
14193 ;; check whether each architecture has a corresponding entity
14194 (setq tmp-list ent-alist
)
14196 (when (null (nth 2 (car tmp-list
)))
14197 (setq tmp-entry
(car (nth 4 (car tmp-list
))))
14198 (vhdl-warning-when-idle
14199 "Architecture of non-existing entity: \"%s\" of \"%s\"\n in \"%s\" (line %d)"
14200 (nth 1 tmp-entry
) (nth 1 (car tmp-list
)) (nth 2 tmp-entry
)
14201 (nth 3 tmp-entry
)))
14202 (setq tmp-list
(cdr tmp-list
)))
14203 ;; check whether configuration has a corresponding entity/architecture
14204 (setq tmp-list conf-alist
)
14206 (if (setq tmp-entry
(vhdl-aget ent-alist
(nth 4 (car tmp-list
))))
14207 (unless (vhdl-aget (nth 3 tmp-entry
) (nth 5 (car tmp-list
)))
14208 (setq tmp-entry
(car tmp-list
))
14209 (vhdl-warning-when-idle
14210 "Configuration of non-existing architecture: \"%s\" of \"%s(%s)\"\n in \"%s\" (line %d)"
14211 (nth 1 tmp-entry
) (nth 4 tmp-entry
) (nth 5 tmp-entry
)
14212 (nth 2 tmp-entry
) (nth 3 tmp-entry
)))
14213 (setq tmp-entry
(car tmp-list
))
14214 (vhdl-warning-when-idle
14215 "Configuration of non-existing entity: \"%s\" of \"%s\"\n in \"%s\" (line %d)"
14216 (nth 1 tmp-entry
) (nth 4 tmp-entry
)
14217 (nth 2 tmp-entry
) (nth 3 tmp-entry
)))
14218 (setq tmp-list
(cdr tmp-list
)))
14219 ;; check whether each package body has a package declaration
14220 (setq tmp-list pack-alist
)
14222 (when (null (nth 2 (car tmp-list
)))
14223 (setq tmp-entry
(car tmp-list
))
14224 (vhdl-warning-when-idle
14225 "Package body of non-existing package: \"%s\"\n in \"%s\" (line %d)"
14226 (nth 1 tmp-entry
) (nth 7 tmp-entry
) (nth 8 tmp-entry
)))
14227 (setq tmp-list
(cdr tmp-list
)))
14229 (setq ent-alist
(vhdl-sort-alist ent-alist
))
14230 (setq conf-alist
(vhdl-sort-alist conf-alist
))
14231 (setq pack-alist
(vhdl-sort-alist pack-alist
))
14232 ;; remember updated directory/project
14233 (add-to-list 'vhdl-updated-project-list
(or project dir-name
)))
14234 ;; clear directory alists
14236 (vhdl-adelete 'vhdl-entity-alist key
)
14237 (vhdl-adelete 'vhdl-config-alist key
)
14238 (vhdl-adelete 'vhdl-package-alist key
)
14239 (vhdl-adelete 'vhdl-ent-inst-alist key
)
14240 (vhdl-adelete 'vhdl-file-alist key
))
14241 ;; put directory contents into cache
14242 (vhdl-aput 'vhdl-entity-alist key ent-alist
)
14243 (vhdl-aput 'vhdl-config-alist key conf-alist
)
14244 (vhdl-aput 'vhdl-package-alist key pack-alist
)
14245 (vhdl-aput 'vhdl-ent-inst-alist key
(list ent-inst-list
))
14246 (vhdl-aput 'vhdl-file-alist key file-alist
)
14248 (message "Scanning %s %s\"%s\"...done"
14249 (if is-directory
"directory" "files") (or num-string
"") name
)
14250 (unless project
(message "Scanning directory...done"))
14252 (vhdl-warning-when-idle "Scanning is incomplete.\n --> see user option `vhdl-speedbar-scan-limit'"))
14253 ;; save cache when scanned non-interactively
14254 (when (or (not project
) (not non-final
))
14255 (when (and noninteractive vhdl-speedbar-save-cache
)
14256 (vhdl-save-cache key
)))
14259 (defun vhdl-scan-project-contents (project)
14260 "Scan the contents of all VHDL files found in the directories and files
14262 (let ((dir-list (or (nth 2 (vhdl-aget vhdl-project-alist project
)) '("")))
14263 (default-dir (vhdl-resolve-env-variable
14264 (nth 1 (vhdl-aget vhdl-project-alist project
))))
14265 (file-exclude-regexp
14266 (or (nth 3 (vhdl-aget vhdl-project-alist project
)) ""))
14267 dir-list-tmp dir dir-name num-dir act-dir recursive
)
14268 ;; clear project alists
14269 (vhdl-adelete 'vhdl-entity-alist project
)
14270 (vhdl-adelete 'vhdl-config-alist project
)
14271 (vhdl-adelete 'vhdl-package-alist project
)
14272 (vhdl-adelete 'vhdl-ent-inst-alist project
)
14273 (vhdl-adelete 'vhdl-file-alist project
)
14274 ;; expand directory names by default-directory
14275 (message "Collecting source files...")
14277 (setq dir
(vhdl-resolve-env-variable (car dir-list
)))
14278 (string-match "\\(\\(-r \\)?\\)\\(.*\\)" dir
)
14279 (setq recursive
(match-string 1 dir
)
14280 dir-name
(match-string 3 dir
))
14282 (cons (concat recursive
14283 (if (file-name-absolute-p dir-name
) "" default-dir
)
14286 (setq dir-list
(cdr dir-list
)))
14287 ;; resolve path wildcards
14288 (setq dir-list-tmp
(vhdl-resolve-paths dir-list-tmp
))
14289 ;; expand directories
14290 (while dir-list-tmp
14291 (setq dir
(car dir-list-tmp
))
14292 ;; get subdirectories
14293 (if (string-match "-r \\(.*[/\\]\\)" dir
)
14294 (setq dir-list
(append dir-list
(vhdl-get-subdirs
14295 (match-string 1 dir
))))
14296 (setq dir-list
(append dir-list
(list dir
))))
14297 (setq dir-list-tmp
(cdr dir-list-tmp
)))
14299 (unless (equal file-exclude-regexp
"")
14300 (let ((case-fold-search nil
))
14302 (unless (string-match file-exclude-regexp
(car dir-list
))
14303 (push (car dir-list
) dir-list-tmp
))
14304 (setq dir-list
(cdr dir-list
)))
14305 (setq dir-list
(nreverse dir-list-tmp
))))
14306 (message "Collecting source files...done")
14307 ;; scan for design units for each directory in DIR-LIST
14308 (setq dir-list-tmp nil
14309 num-dir
(length dir-list
)
14312 (setq dir-name
(abbreviate-file-name
14313 (expand-file-name (car dir-list
))))
14314 (vhdl-scan-directory-contents dir-name project nil
14315 (format "(%s/%s) " act-dir num-dir
)
14317 (add-to-list 'dir-list-tmp
(file-name-directory dir-name
))
14318 (setq dir-list
(cdr dir-list
)
14319 act-dir
(1+ act-dir
)))
14320 (vhdl-aput 'vhdl-directory-alist project
(list (nreverse dir-list-tmp
)))
14321 (message "Scanning project \"%s\"...done" project
)))
14323 (defun vhdl-update-file-contents (file-name)
14324 "Update hierarchy information by contents of current buffer."
14325 (setq file-name
(abbreviate-file-name file-name
))
14326 (let* ((dir-name (file-name-directory file-name
))
14327 (directory-alist vhdl-directory-alist
)
14329 (while directory-alist
14330 (when (member dir-name
(nth 1 (car directory-alist
)))
14331 (let* ((vhdl-project (nth 0 (car directory-alist
)))
14332 (project (vhdl-project-p))
14333 (ent-alist (vhdl-aget vhdl-entity-alist
14334 (or project dir-name
)))
14335 (conf-alist (vhdl-aget vhdl-config-alist
14336 (or project dir-name
)))
14337 (pack-alist (vhdl-aget vhdl-package-alist
14338 (or project dir-name
)))
14339 (ent-inst-list (car (vhdl-aget vhdl-ent-inst-alist
14340 (or project dir-name
))))
14341 (file-alist (vhdl-aget vhdl-file-alist
(or project dir-name
)))
14342 (file-entry (vhdl-aget file-alist file-name
))
14343 (ent-list (nth 0 file-entry
))
14344 (arch-list (nth 1 file-entry
))
14345 (arch-ent-list (nth 2 file-entry
))
14346 (conf-list (nth 3 file-entry
))
14347 (pack-list (nth 4 file-entry
))
14348 (pack-body-list (nth 5 file-entry
))
14349 (inst-ent-list (nth 7 file-entry
))
14350 (cache-key (or project dir-name
))
14351 arch-alist key ent-key entry
)
14352 ;; delete design units previously contained in this file:
14355 (setq key
(car ent-list
)
14356 entry
(vhdl-aget ent-alist key
))
14357 (when (equal file-name
(nth 1 entry
))
14359 (vhdl-aput 'ent-alist key
14360 (list (nth 0 entry
) nil nil
(nth 3 entry
) nil
))
14361 (vhdl-adelete 'ent-alist key
)))
14362 (setq ent-list
(cdr ent-list
)))
14365 (setq key
(car arch-list
)
14366 ent-key
(car arch-ent-list
)
14367 entry
(vhdl-aget ent-alist ent-key
)
14368 arch-alist
(nth 3 entry
))
14369 (when (equal file-name
(nth 1 (vhdl-aget arch-alist key
)))
14370 (vhdl-adelete 'arch-alist key
)
14371 (if (or (nth 1 entry
) arch-alist
)
14372 (vhdl-aput 'ent-alist ent-key
14373 (list (nth 0 entry
) (nth 1 entry
) (nth 2 entry
)
14374 arch-alist
(nth 4 entry
) (nth 5 entry
)))
14375 (vhdl-adelete 'ent-alist ent-key
)))
14376 (setq arch-list
(cdr arch-list
)
14377 arch-ent-list
(cdr arch-ent-list
)))
14380 (setq key
(car conf-list
))
14381 (when (equal file-name
(nth 1 (vhdl-aget conf-alist key
)))
14382 (vhdl-adelete 'conf-alist key
))
14383 (setq conf-list
(cdr conf-list
)))
14384 ;; package declarations
14386 (setq key
(car pack-list
)
14387 entry
(vhdl-aget pack-alist key
))
14388 (when (equal file-name
(nth 1 entry
))
14390 (vhdl-aput 'pack-alist key
14391 (list (nth 0 entry
) nil nil nil nil nil
14392 (nth 6 entry
) (nth 7 entry
) (nth 8 entry
)
14394 (vhdl-adelete 'pack-alist key
)))
14395 (setq pack-list
(cdr pack-list
)))
14397 (while pack-body-list
14398 (setq key
(car pack-body-list
)
14399 entry
(vhdl-aget pack-alist key
))
14400 (when (equal file-name
(nth 6 entry
))
14402 (vhdl-aput 'pack-alist key
14403 (list (nth 0 entry
) (nth 1 entry
) (nth 2 entry
)
14404 (nth 3 entry
) (nth 4 entry
) (nth 5 entry
)
14406 (vhdl-adelete 'pack-alist key
)))
14407 (setq pack-body-list
(cdr pack-body-list
)))
14408 ;; instantiated entities
14409 (while inst-ent-list
14410 (setq ent-inst-list
14411 (vhdl-delete (car inst-ent-list
) ent-inst-list
))
14412 (setq inst-ent-list
(cdr inst-ent-list
)))
14414 (vhdl-aput-delete-if-nil 'vhdl-entity-alist cache-key ent-alist
)
14415 (vhdl-aput-delete-if-nil 'vhdl-config-alist cache-key conf-alist
)
14416 (vhdl-aput-delete-if-nil 'vhdl-package-alist cache-key pack-alist
)
14417 (vhdl-aput-delete-if-nil 'vhdl-ent-inst-alist cache-key
(list ent-inst-list
))
14419 (vhdl-scan-directory-contents file-name project t
)
14420 (when (or (and vhdl-speedbar-show-projects project
)
14421 (and (not vhdl-speedbar-show-projects
) (not project
)))
14422 (vhdl-speedbar-refresh project
))
14424 (setq directory-alist
(cdr directory-alist
)))
14427 (defun vhdl-update-hierarchy ()
14428 "Update directory and hierarchy information in speedbar."
14429 (let ((file-list (reverse vhdl-modified-file-list
))
14431 (when (and vhdl-speedbar-update-on-saving file-list
)
14434 (or (vhdl-update-file-contents (car file-list
))
14436 (setq file-list
(cdr file-list
)))
14437 (setq vhdl-modified-file-list nil
)
14438 (vhdl-speedbar-update-current-unit)
14439 (when updated
(message "Updating hierarchy...done")))))
14441 ;; structure (parenthesized expression means list of such entries)
14442 ;; (inst-key inst-file-marker comp-ent-key comp-ent-file-marker
14443 ;; comp-arch-key comp-arch-file-marker comp-conf-key comp-conf-file-marker
14444 ;; comp-lib-name level)
14445 (defun vhdl-get-hierarchy (ent-alist conf-alist ent-key arch-key conf-key
14446 conf-inst-alist level indent
14447 &optional include-top ent-hier
)
14448 "Get instantiation hierarchy beginning in architecture ARCH-KEY of
14450 (let* ((ent-entry (vhdl-aget ent-alist ent-key
))
14451 (arch-entry (if arch-key
(vhdl-aget (nth 3 ent-entry
) arch-key
)
14452 (cdar (last (nth 3 ent-entry
)))))
14453 (inst-alist (nth 3 arch-entry
))
14454 inst-entry inst-ent-entry inst-arch-entry inst-conf-entry comp-entry
14455 hier-list subcomp-list tmp-list inst-key inst-comp-name
14456 inst-ent-key inst-arch-key inst-conf-key inst-lib-key
)
14457 (when (= level
0) (message "Extract design hierarchy..."))
14459 (setq level
(1+ level
)))
14460 (when (member ent-key ent-hier
)
14461 (error "ERROR: Instantiation loop detected, component instantiates itself: \"%s\"" ent-key
))
14462 ;; process all instances
14464 (setq inst-entry
(car inst-alist
)
14465 inst-key
(nth 0 inst-entry
)
14466 inst-comp-name
(nth 4 inst-entry
)
14467 inst-conf-key
(nth 7 inst-entry
))
14468 ;; search entry in configuration's instantiations list
14469 (setq tmp-list conf-inst-alist
)
14470 (while (and tmp-list
14471 (not (and (member (nth 0 (car tmp-list
))
14472 (list "all" inst-key
))
14473 (equal (nth 1 (car tmp-list
))
14474 (downcase (or inst-comp-name
""))))))
14475 (setq tmp-list
(cdr tmp-list
)))
14476 (setq inst-conf-key
(or (nth 4 (car tmp-list
)) inst-conf-key
))
14477 (setq inst-conf-entry
(vhdl-aget conf-alist inst-conf-key
))
14478 (when (and inst-conf-key
(not inst-conf-entry
))
14479 (vhdl-warning-when-idle "Configuration not found: \"%s\"" inst-conf-key
))
14480 ;; determine entity
14482 (or (nth 2 (car tmp-list
)) ; from configuration
14483 (nth 3 inst-conf-entry
) ; from subconfiguration
14484 (nth 3 (vhdl-aget conf-alist
(nth 7 inst-entry
)))
14485 ; from configuration spec.
14486 (nth 5 inst-entry
))) ; from direct instantiation
14487 (setq inst-ent-entry
(vhdl-aget ent-alist inst-ent-key
))
14488 ;; determine architecture
14489 (setq inst-arch-key
14490 (or (nth 3 (car tmp-list
)) ; from configuration
14491 (nth 4 inst-conf-entry
) ; from subconfiguration
14492 (nth 6 inst-entry
) ; from direct instantiation
14493 (nth 4 (vhdl-aget conf-alist
(nth 7 inst-entry
)))
14494 ; from configuration spec.
14495 (nth 4 inst-ent-entry
) ; MRA
14496 (caar (nth 3 inst-ent-entry
)))) ; first alphabetically
14497 (setq inst-arch-entry
(vhdl-aget (nth 3 inst-ent-entry
) inst-arch-key
))
14500 (or (nth 5 (car tmp-list
)) ; from configuration
14501 (nth 8 inst-entry
))) ; from direct instantiation
14502 ;; gather information for this instance
14504 (list (nth 1 inst-entry
)
14505 (cons (nth 2 inst-entry
) (nth 3 inst-entry
))
14506 (or (nth 0 inst-ent-entry
) (nth 4 inst-entry
))
14507 (cons (nth 1 inst-ent-entry
) (nth 2 inst-ent-entry
))
14508 (or (nth 0 inst-arch-entry
) inst-arch-key
)
14509 (cons (nth 1 inst-arch-entry
) (nth 2 inst-arch-entry
))
14510 (or (nth 0 inst-conf-entry
) inst-conf-key
)
14511 (cons (nth 1 inst-conf-entry
) (nth 2 inst-conf-entry
))
14512 inst-lib-key level
))
14513 ;; get subcomponent hierarchy
14514 (setq subcomp-list
(vhdl-get-hierarchy
14515 ent-alist conf-alist
14516 inst-ent-key inst-arch-key inst-conf-key
14517 (nth 5 inst-conf-entry
)
14518 (1+ level
) indent nil
(cons ent-key ent-hier
)))
14520 (setq hier-list
(append hier-list
(list comp-entry
) subcomp-list
))
14521 (setq inst-alist
(cdr inst-alist
)))
14524 (cons (list nil nil
(nth 0 ent-entry
)
14525 (cons (nth 1 ent-entry
) (nth 2 ent-entry
))
14527 (cons (nth 1 arch-entry
) (nth 2 arch-entry
))
14531 (when (or (= level
0) (and include-top
(= level
1))) (message ""))
14534 (defun vhdl-get-instantiations (ent-key indent
)
14535 "Get all instantiations of entity ENT-KEY."
14536 (let ((ent-alist (vhdl-aget vhdl-entity-alist
14537 (vhdl-speedbar-line-key indent
)))
14538 arch-alist inst-alist ent-inst-list
14539 ent-entry arch-entry inst-entry
)
14541 (setq ent-entry
(car ent-alist
))
14542 (setq arch-alist
(nth 4 ent-entry
))
14544 (setq arch-entry
(car arch-alist
))
14545 (setq inst-alist
(nth 4 arch-entry
))
14547 (setq inst-entry
(car inst-alist
))
14548 (when (equal ent-key
(nth 5 inst-entry
))
14549 (setq ent-inst-list
14550 (cons (list (nth 1 inst-entry
)
14551 (cons (nth 2 inst-entry
) (nth 3 inst-entry
))
14553 (cons (nth 2 ent-entry
) (nth 3 ent-entry
))
14555 (cons (nth 2 arch-entry
) (nth 3 arch-entry
)))
14557 (setq inst-alist
(cdr inst-alist
)))
14558 (setq arch-alist
(cdr arch-alist
)))
14559 (setq ent-alist
(cdr ent-alist
)))
14560 (nreverse ent-inst-list
)))
14562 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14565 (defun vhdl-save-caches ()
14566 "Save all updated hierarchy caches to file."
14568 (condition-case nil
14569 (when vhdl-speedbar-save-cache
14570 ;; update hierarchy
14571 (vhdl-update-hierarchy)
14572 (let ((project-list vhdl-updated-project-list
))
14573 (message "Saving hierarchy caches...")
14574 ;; write updated project caches
14575 (while project-list
14576 (vhdl-save-cache (car project-list
))
14577 (setq project-list
(cdr project-list
)))
14578 (message "Saving hierarchy caches...done")))
14579 (error (progn (vhdl-warning "ERROR: An error occurred while saving the hierarchy caches")
14582 (defun vhdl-save-cache (key)
14583 "Save current hierarchy cache to file."
14584 (let* ((orig-buffer (current-buffer))
14586 (project (vhdl-project-p))
14587 (default-directory key
)
14588 (directory (abbreviate-file-name (vhdl-default-directory)))
14589 (file-name (vhdl-resolve-env-variable
14590 (vhdl-replace-string
14591 (cons "\\(.*\\) \\(.*\\)" vhdl-speedbar-cache-file-name
)
14593 (subst-char-in-string ? ?_
(or project
"dir"))
14594 " " (user-login-name)))))
14595 (file-dir-name (expand-file-name file-name directory
))
14596 (cache-key (or project directory
))
14597 (key (if project
"project" "directory")))
14598 (unless (file-exists-p (file-name-directory file-dir-name
))
14599 (make-directory (file-name-directory file-dir-name
) t
))
14600 (if (not (file-writable-p file-dir-name
))
14601 (progn (vhdl-warning (format "File not writable: \"%s\""
14602 (abbreviate-file-name file-dir-name
)))
14604 (message "Saving cache: \"%s\"" file-dir-name
)
14605 (set-buffer (find-file-noselect file-dir-name t t
))
14607 (insert ";; -*- Emacs-Lisp -*-\n\n"
14608 ";;; " (file-name-nondirectory file-name
)
14609 " - design hierarchy cache file for Emacs VHDL Mode "
14611 (insert "\n;; " (if project
"Project " "Directory") " : ")
14612 (if project
(insert project
) (prin1 directory
(current-buffer)))
14613 (insert "\n;; Saved : " (format-time-string "%Y-%m-%d %T ")
14614 (user-login-name) "\n\n"
14615 "\n;; version number\n"
14616 "(setq vhdl-cache-version \"" vhdl-version
"\")\n"
14617 "\n;; " (if project
"project" "directory") " name"
14618 "\n(setq " key
" ")
14619 (prin1 (or project directory
) (current-buffer))
14621 (when (member 'hierarchy vhdl-speedbar-save-cache
)
14622 (insert "\n;; entity and architecture cache\n"
14623 "(vhdl-aput 'vhdl-entity-alist " key
" '")
14624 (print (vhdl-aget vhdl-entity-alist cache-key
) (current-buffer))
14625 (insert ")\n\n;; configuration cache\n"
14626 "(vhdl-aput 'vhdl-config-alist " key
" '")
14627 (print (vhdl-aget vhdl-config-alist cache-key
) (current-buffer))
14628 (insert ")\n\n;; package cache\n"
14629 "(vhdl-aput 'vhdl-package-alist " key
" '")
14630 (print (vhdl-aget vhdl-package-alist cache-key
) (current-buffer))
14631 (insert ")\n\n;; instantiated entities cache\n"
14632 "(vhdl-aput 'vhdl-ent-inst-alist " key
" '")
14633 (print (vhdl-aget vhdl-ent-inst-alist cache-key
) (current-buffer))
14634 (insert ")\n\n;; design units per file cache\n"
14635 "(vhdl-aput 'vhdl-file-alist " key
" '")
14636 (print (vhdl-aget vhdl-file-alist cache-key
) (current-buffer))
14638 (insert ")\n\n;; source directories in project cache\n"
14639 "(vhdl-aput 'vhdl-directory-alist " key
" '")
14640 (print (vhdl-aget vhdl-directory-alist cache-key
) (current-buffer)))
14642 (when (member 'display vhdl-speedbar-save-cache
)
14643 (insert "\n;; shown design units cache\n"
14644 "(vhdl-aput 'vhdl-speedbar-shown-unit-alist " key
" '")
14645 (print (vhdl-aget vhdl-speedbar-shown-unit-alist cache-key
)
14648 (setq vhdl-updated-project-list
14649 (delete cache-key vhdl-updated-project-list
))
14651 (kill-buffer (current-buffer))
14652 (set-buffer orig-buffer
))))
14654 (defun vhdl-load-cache (key)
14655 "Load hierarchy cache information from file."
14656 (let* ((vhdl-project key
)
14657 (default-directory key
)
14658 (directory (vhdl-default-directory))
14659 (file-name (vhdl-resolve-env-variable
14660 (vhdl-replace-string
14661 (cons "\\(.*\\) \\(.*\\)" vhdl-speedbar-cache-file-name
)
14663 (subst-char-in-string ? ?_
(or (vhdl-project-p) "dir"))
14664 " " (user-login-name)))))
14665 (file-dir-name (expand-file-name file-name directory
))
14666 vhdl-cache-version
)
14667 (unless (memq 'vhdl-save-caches kill-emacs-hook
)
14668 (add-hook 'kill-emacs-hook
'vhdl-save-caches
))
14669 (when (file-exists-p file-dir-name
)
14671 (progn (load-file file-dir-name
)
14672 (string< (mapconcat
14673 (lambda (a) (format "%3d" (string-to-number a
)))
14674 (split-string "3.33" "\\.") "")
14676 (lambda (a) (format "%3d" (string-to-number a
)))
14677 (split-string vhdl-cache-version
"\\.") "")))
14678 (error (progn (vhdl-warning (format "ERROR: Corrupted cache file: \"%s\"" file-dir-name
))
14681 (defun vhdl-require-hierarchy-info ()
14682 "Make sure that hierarchy information is available. Load cache or scan files
14684 (if (vhdl-project-p)
14685 (unless (or (assoc vhdl-project vhdl-file-alist
)
14686 (vhdl-load-cache vhdl-project
))
14687 (vhdl-scan-project-contents vhdl-project
))
14688 (let ((directory (abbreviate-file-name default-directory
)))
14689 (unless (or (assoc directory vhdl-file-alist
)
14690 (vhdl-load-cache directory
))
14691 (vhdl-scan-directory-contents directory
)))))
14693 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14694 ;; Add hierarchy browser functionality to speedbar
14696 (defvar vhdl-speedbar-mode-map nil
14697 "Keymap used when in the VHDL hierarchy browser mode.")
14699 (defvar vhdl-speedbar-menu-items nil
14700 "Additional menu-items to add to speedbar frame.")
14702 (declare-function speedbar-add-supported-extension
"speedbar" (extension))
14703 (declare-function speedbar-add-mode-functions-list
"speedbar" (new-list))
14704 (declare-function speedbar-make-specialized-keymap
"speedbar" ())
14705 (declare-function speedbar-change-initial-expansion-list
"speedbar"
14707 (declare-function speedbar-add-expansion-list
"speedbar" (new-list))
14709 (defun vhdl-speedbar-initialize ()
14710 "Initialize speedbar."
14711 ;; general settings
14712 ;; VHDL file extensions (extracted from `auto-mode-alist')
14713 (let ((mode-alist auto-mode-alist
))
14715 (when (eq (cdar mode-alist
) 'vhdl-mode
)
14716 (speedbar-add-supported-extension (caar mode-alist
)))
14717 (setq mode-alist
(cdr mode-alist
))))
14718 ;; hierarchy browser settings
14719 (when (boundp 'speedbar-mode-functions-list
)
14720 ;; special functions
14721 (speedbar-add-mode-functions-list
14723 (speedbar-item-info . vhdl-speedbar-item-info
)
14724 (speedbar-line-directory . speedbar-files-line-path
)))
14725 (speedbar-add-mode-functions-list
14727 (speedbar-item-info . vhdl-speedbar-item-info
)
14728 (speedbar-line-directory . vhdl-speedbar-line-project
)))
14730 (unless vhdl-speedbar-mode-map
14731 (setq vhdl-speedbar-mode-map
(speedbar-make-specialized-keymap))
14732 (define-key vhdl-speedbar-mode-map
"e" 'speedbar-edit-line
)
14733 (define-key vhdl-speedbar-mode-map
"\C-m" 'speedbar-edit-line
)
14734 (define-key vhdl-speedbar-mode-map
"+" 'speedbar-expand-line
)
14735 (define-key vhdl-speedbar-mode-map
"=" 'speedbar-expand-line
)
14736 (define-key vhdl-speedbar-mode-map
"-" 'vhdl-speedbar-contract-level
)
14737 (define-key vhdl-speedbar-mode-map
"_" 'vhdl-speedbar-contract-all
)
14738 (define-key vhdl-speedbar-mode-map
"C" 'vhdl-speedbar-port-copy
)
14739 (define-key vhdl-speedbar-mode-map
"P" 'vhdl-speedbar-place-component
)
14740 (define-key vhdl-speedbar-mode-map
"F" 'vhdl-speedbar-configuration
)
14741 (define-key vhdl-speedbar-mode-map
"A" 'vhdl-speedbar-select-mra
)
14742 (define-key vhdl-speedbar-mode-map
"K" 'vhdl-speedbar-make-design
)
14743 (define-key vhdl-speedbar-mode-map
"R" 'vhdl-speedbar-rescan-hierarchy
)
14744 (define-key vhdl-speedbar-mode-map
"S" 'vhdl-save-caches
)
14747 (define-key vhdl-speedbar-mode-map
(int-to-string key
)
14748 `(lambda () (interactive) (vhdl-speedbar-set-depth ,key
)))
14749 (setq key
(1+ key
)))))
14750 (define-key speedbar-mode-map
"h"
14751 (lambda () (interactive)
14752 (speedbar-change-initial-expansion-list "vhdl directory")))
14753 (define-key speedbar-mode-map
"H"
14754 (lambda () (interactive)
14755 (speedbar-change-initial-expansion-list "vhdl project")))
14757 (unless vhdl-speedbar-menu-items
14759 vhdl-speedbar-menu-items
14760 `(["Edit" speedbar-edit-line t
]
14761 ["Expand" speedbar-expand-line
14762 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *.\\+. "))]
14763 ["Contract" vhdl-speedbar-contract-level t
]
14764 ["Expand All" vhdl-speedbar-expand-all t
]
14765 ["Contract All" vhdl-speedbar-contract-all t
]
14766 ,(let ((key 0) (menu-list '("Hierarchy Depth")))
14769 (cons `[,(if (= key
0) "All" (int-to-string key
))
14770 (vhdl-speedbar-set-depth ,key
)
14772 :selected
(= vhdl-speedbar-hierarchy-depth
,key
)
14773 :keys
,(int-to-string key
)]
14775 (setq key
(1+ key
)))
14776 (nreverse menu-list
))
14778 ["Copy Port/Subprogram" vhdl-speedbar-port-copy
14779 (or (vhdl-speedbar-check-unit 'entity
)
14780 (vhdl-speedbar-check-unit 'subprogram
))]
14781 ["Place Component" vhdl-speedbar-place-component
14782 (vhdl-speedbar-check-unit 'entity
)]
14783 ["Generate Configuration" vhdl-speedbar-configuration
14784 (vhdl-speedbar-check-unit 'architecture
)]
14785 ["Select as MRA" vhdl-speedbar-select-mra
14786 (vhdl-speedbar-check-unit 'architecture
)]
14787 ["Make" vhdl-speedbar-make-design
14788 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))]
14789 ["Generate Makefile" vhdl-speedbar-generate-makefile
14790 (save-excursion (beginning-of-line) (looking-at "[0-9]+:"))]
14791 ["Rescan Directory" vhdl-speedbar-rescan-hierarchy
14792 :active
(save-excursion (beginning-of-line) (looking-at "[0-9]+:"))
14793 ,(if (featurep 'xemacs
) :active
:visible
) (not vhdl-speedbar-show-projects
)]
14794 ["Rescan Project" vhdl-speedbar-rescan-hierarchy
14795 :active
(save-excursion (beginning-of-line) (looking-at "[0-9]+:"))
14796 ,(if (featurep 'xemacs
) :active
:visible
) vhdl-speedbar-show-projects
]
14797 ["Save Caches" vhdl-save-caches vhdl-updated-project-list
])))
14799 (speedbar-add-expansion-list
14800 '("vhdl directory" vhdl-speedbar-menu-items vhdl-speedbar-mode-map
14801 vhdl-speedbar-display-directory
))
14802 (speedbar-add-expansion-list
14803 '("vhdl project" vhdl-speedbar-menu-items vhdl-speedbar-mode-map
14804 vhdl-speedbar-display-projects
))
14805 (setq speedbar-stealthy-function-list
14807 '(("vhdl directory" vhdl-speedbar-update-current-unit
)
14808 ("vhdl project" vhdl-speedbar-update-current-project
14809 vhdl-speedbar-update-current-unit
))
14810 speedbar-stealthy-function-list
))
14811 (when (eq vhdl-speedbar-display-mode
'directory
)
14812 (setq speedbar-initial-expansion-list-name
"vhdl directory"))
14813 (when (eq vhdl-speedbar-display-mode
'project
)
14814 (setq speedbar-initial-expansion-list-name
"vhdl project"))
14815 (add-hook 'speedbar-timer-hook
'vhdl-update-hierarchy
)))
14817 (defun vhdl-speedbar (&optional arg
)
14818 "Open/close speedbar."
14820 (if (not (fboundp 'speedbar
))
14821 (error "WARNING: Speedbar is not available or not installed")
14823 (speedbar-frame-mode arg
)
14824 (error (error "WARNING: An error occurred while opening speedbar")))))
14826 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14827 ;; Display functions
14829 (defvar vhdl-speedbar-last-selected-project nil
14830 "Name of last selected project.")
14832 ;; macros must be defined in the file they are used (copied from `speedbar.el')
14833 ;;; (defmacro speedbar-with-writable (&rest forms)
14834 ;;; "Allow the buffer to be writable and evaluate FORMS."
14835 ;;; (list 'let '((inhibit-read-only t))
14836 ;;; (cons 'progn forms)))
14837 ;;; (put 'speedbar-with-writable 'lisp-indent-function 0)
14839 (declare-function speedbar-extension-list-to-regex
"speedbar" (extlist))
14840 (declare-function speedbar-directory-buttons
"speedbar" (directory _index
))
14841 (declare-function speedbar-file-lists
"speedbar" (directory))
14843 (defun vhdl-speedbar-display-directory (directory depth
&optional rescan
)
14844 "Display directory and hierarchy information in speedbar."
14845 (setq vhdl-speedbar-show-projects nil
)
14846 (setq speedbar-ignored-directory-regexp
14847 (speedbar-extension-list-to-regex speedbar-ignored-directory-expressions
))
14848 (setq directory
(abbreviate-file-name (file-name-as-directory directory
)))
14849 (setq speedbar-last-selected-file nil
)
14850 (speedbar-with-writable
14851 (condition-case nil
14853 ;; insert directory path
14854 (speedbar-directory-buttons directory depth
)
14855 ;; insert subdirectories
14856 (vhdl-speedbar-insert-dirs (speedbar-file-lists directory
) depth
)
14857 ;; scan and insert hierarchy of current directory
14858 (vhdl-speedbar-insert-dir-hierarchy directory depth
14859 speedbar-power-click
)
14860 ;; expand subdirectories
14861 (when (= depth
0) (vhdl-speedbar-expand-dirs directory
)))
14862 (error (vhdl-warning-when-idle "ERROR: Invalid hierarchy information, unable to display correctly")))))
14864 (defun vhdl-speedbar-display-projects (project depth
&optional rescan
)
14865 "Display projects and hierarchy information in speedbar."
14866 (setq vhdl-speedbar-show-projects t
)
14867 (setq speedbar-ignored-directory-regexp
".")
14868 (setq speedbar-last-selected-file nil
)
14869 (setq vhdl-speedbar-last-selected-project nil
)
14870 (speedbar-with-writable
14871 (condition-case nil
14873 (vhdl-speedbar-insert-projects)
14874 (error (vhdl-warning-when-idle "ERROR: Invalid hierarchy information, unable to display correctly"))))
14875 (setq speedbar-full-text-cache nil
)) ; prevent caching
14877 (declare-function speedbar-make-tag-line
"speedbar"
14878 (type char func data tag tfunc tdata tface depth
))
14880 (defun vhdl-speedbar-insert-projects ()
14881 "Insert all projects in speedbar."
14882 (vhdl-speedbar-make-title-line "Projects:")
14883 (let ((project-alist (if vhdl-project-sort
14884 (vhdl-sort-alist (copy-alist vhdl-project-alist
))
14885 vhdl-project-alist
))
14886 (vhdl-speedbar-update-current-unit nil
))
14888 (while project-alist
14889 (speedbar-make-tag-line
14890 'angle ?
+ 'vhdl-speedbar-expand-project
14891 (caar project-alist
) (caar project-alist
)
14892 'vhdl-toggle-project
(caar project-alist
) 'speedbar-directory-face
0)
14893 (setq project-alist
(cdr project-alist
)))
14894 (setq project-alist vhdl-project-alist
)
14896 (while project-alist
14897 (when (member (caar project-alist
) vhdl-speedbar-shown-project-list
)
14898 (goto-char (point-min))
14899 (when (re-search-forward
14900 (concat "^\\([0-9]+:\\s-*<\\)[+]>\\s-+" (caar project-alist
) "$") nil t
)
14901 (goto-char (match-end 1))
14902 (speedbar-do-function-pointer)))
14903 (setq project-alist
(cdr project-alist
)))))
14905 (defun vhdl-speedbar-insert-project-hierarchy (project indent
&optional rescan
)
14906 "Insert hierarchy of PROJECT. Rescan directories if RESCAN is non-nil,
14907 otherwise use cached data."
14908 (when (or rescan
(and (not (assoc project vhdl-file-alist
))
14909 (not (vhdl-load-cache project
))))
14910 (vhdl-scan-project-contents project
))
14911 ;; insert design hierarchy
14912 (vhdl-speedbar-insert-hierarchy
14913 (vhdl-aget vhdl-entity-alist project
)
14914 (vhdl-aget vhdl-config-alist project
)
14915 (vhdl-aget vhdl-package-alist project
)
14916 (car (vhdl-aget vhdl-ent-inst-alist project
)) indent
)
14917 (insert (int-to-string indent
) ":\n")
14918 (put-text-property (- (point) 3) (1- (point)) 'invisible t
)
14919 (put-text-property (1- (point)) (point) 'invisible nil
)
14920 ;; expand design units
14921 (vhdl-speedbar-expand-units project
))
14923 (defun vhdl-speedbar-insert-dir-hierarchy (directory depth
&optional rescan
)
14924 "Insert hierarchy of DIRECTORY. Rescan directory if RESCAN is non-nil,
14925 otherwise use cached data."
14926 (when (or rescan
(and (not (assoc directory vhdl-file-alist
))
14927 (not (vhdl-load-cache directory
))))
14928 (vhdl-scan-directory-contents directory
))
14929 ;; insert design hierarchy
14930 (vhdl-speedbar-insert-hierarchy
14931 (vhdl-aget vhdl-entity-alist directory
)
14932 (vhdl-aget vhdl-config-alist directory
)
14933 (vhdl-aget vhdl-package-alist directory
)
14934 (car (vhdl-aget vhdl-ent-inst-alist directory
)) depth
)
14935 ;; expand design units
14936 (vhdl-speedbar-expand-units directory
)
14937 (vhdl-aput 'vhdl-directory-alist directory
(list (list directory
))))
14939 (defun vhdl-speedbar-insert-hierarchy (ent-alist conf-alist pack-alist
14940 ent-inst-list depth
)
14941 "Insert hierarchy of ENT-ALIST, CONF-ALIST, and PACK-ALIST."
14942 (if (not (or ent-alist conf-alist pack-alist
))
14943 (vhdl-speedbar-make-title-line "No VHDL design units!" depth
)
14944 (let (ent-entry conf-entry pack-entry
)
14946 (when ent-alist
(vhdl-speedbar-make-title-line "Entities:" depth
))
14948 (setq ent-entry
(car ent-alist
))
14949 (speedbar-make-tag-line
14950 'bracket ?
+ 'vhdl-speedbar-expand-entity
(nth 0 ent-entry
)
14951 (nth 1 ent-entry
) 'vhdl-speedbar-find-file
14952 (cons (nth 2 ent-entry
) (nth 3 ent-entry
))
14953 'vhdl-speedbar-entity-face depth
)
14954 (unless (nth 2 ent-entry
)
14955 (end-of-line 0) (insert "!") (forward-char 1))
14956 (unless (member (nth 0 ent-entry
) ent-inst-list
)
14957 (end-of-line 0) (insert " (top)") (forward-char 1))
14958 (setq ent-alist
(cdr ent-alist
)))
14959 ;; insert configurations
14960 (when conf-alist
(vhdl-speedbar-make-title-line "Configurations:" depth
))
14962 (setq conf-entry
(car conf-alist
))
14963 (speedbar-make-tag-line
14964 'bracket ?
+ 'vhdl-speedbar-expand-config
(nth 0 conf-entry
)
14965 (nth 1 conf-entry
) 'vhdl-speedbar-find-file
14966 (cons (nth 2 conf-entry
) (nth 3 conf-entry
))
14967 'vhdl-speedbar-configuration-face depth
)
14968 (setq conf-alist
(cdr conf-alist
)))
14970 (when pack-alist
(vhdl-speedbar-make-title-line "Packages:" depth
))
14972 (setq pack-entry
(car pack-alist
))
14973 (vhdl-speedbar-make-pack-line
14974 (nth 0 pack-entry
) (nth 1 pack-entry
)
14975 (cons (nth 2 pack-entry
) (nth 3 pack-entry
))
14976 (cons (nth 7 pack-entry
) (nth 8 pack-entry
))
14978 (setq pack-alist
(cdr pack-alist
))))))
14980 (declare-function speedbar-line-directory
"speedbar" (&optional depth
))
14982 (defun vhdl-speedbar-rescan-hierarchy ()
14983 "Rescan hierarchy for the directory or project under the cursor."
14988 (vhdl-speedbar-show-projects
14989 (setq key
(vhdl-speedbar-line-project))
14990 (vhdl-scan-project-contents key
))
14991 ;; top-level directory
14992 ((save-excursion (beginning-of-line) (looking-at "[^0-9]"))
14993 (re-search-forward "[0-9]+:" nil t
)
14994 (vhdl-scan-directory-contents
14995 (abbreviate-file-name (speedbar-line-directory))))
14996 ;; current directory
14997 (t (setq path
(speedbar-line-directory))
14998 (string-match "^\\(.+[/\\]\\)" path
)
14999 (vhdl-scan-directory-contents
15000 (abbreviate-file-name (match-string 1 path
)))))
15001 (vhdl-speedbar-refresh key
)))
15003 (declare-function speedbar-goto-this-file
"speedbar" (file))
15005 (defun vhdl-speedbar-expand-dirs (directory)
15006 "Expand subdirectories in DIRECTORY according to
15007 `speedbar-shown-directories'."
15008 ;; (nicked from `speedbar-default-directory-list')
15009 (let ((sf (cdr (reverse speedbar-shown-directories
)))
15010 (vhdl-speedbar-update-current-unit nil
))
15011 (setq speedbar-shown-directories
15012 (list (expand-file-name default-directory
)))
15014 (when (speedbar-goto-this-file (car sf
))
15015 (beginning-of-line)
15016 (when (looking-at "[0-9]+:\\s-*<")
15017 (goto-char (match-end 0))
15018 (speedbar-do-function-pointer)))
15019 (setq sf
(cdr sf
))))
15020 (vhdl-speedbar-update-current-unit nil t
))
15022 (defun vhdl-speedbar-expand-units (key)
15023 "Expand design units in directory/project KEY according to
15024 `vhdl-speedbar-shown-unit-alist'."
15025 (let ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
))
15026 (vhdl-speedbar-update-current-unit nil
)
15027 vhdl-updated-project-list
)
15028 (vhdl-adelete 'vhdl-speedbar-shown-unit-alist key
)
15029 (vhdl-prepare-search-1
15030 (while unit-alist
; expand units
15031 (vhdl-speedbar-goto-this-unit key
(caar unit-alist
))
15032 (beginning-of-line)
15033 (let ((arch-alist (nth 1 (car unit-alist
)))
15035 (when (looking-at "^[0-9]+:\\s-*\\[")
15036 (goto-char (match-end 0))
15037 (setq position
(point))
15038 (speedbar-do-function-pointer)
15039 (select-frame speedbar-frame
)
15040 (while arch-alist
; expand architectures
15041 (goto-char position
)
15042 (when (re-search-forward
15043 (concat "^[0-9]+:\\s-*\\(\\[\\|{.}\\s-+"
15044 (car arch-alist
) "\\>\\)") nil t
)
15045 (beginning-of-line)
15046 (when (looking-at "^[0-9]+:\\s-*{")
15047 (goto-char (match-end 0))
15048 (speedbar-do-function-pointer)
15049 (select-frame speedbar-frame
)))
15050 (setq arch-alist
(cdr arch-alist
))))
15051 (setq unit-alist
(cdr unit-alist
))))))
15052 (vhdl-speedbar-update-current-unit nil t
))
15054 (declare-function speedbar-center-buffer-smartly
"speedbar" ())
15056 (defun vhdl-speedbar-contract-level ()
15057 "Contract current level in current directory/project."
15059 (when (or (save-excursion
15060 (beginning-of-line) (looking-at "^[0-9]:\\s-*[[{<]-"))
15061 (and (save-excursion
15062 (beginning-of-line) (looking-at "^\\([0-9]+\\):"))
15063 (re-search-backward
15064 (format "^[0-%d]:\\s-*[[{<]-"
15065 (max (1- (string-to-number (match-string 1))) 0)) nil t
)))
15066 (goto-char (match-end 0))
15067 (speedbar-do-function-pointer)
15068 (speedbar-center-buffer-smartly)))
15070 (defun vhdl-speedbar-contract-all ()
15071 "Contract all expanded design units in current directory/project."
15073 (if (and vhdl-speedbar-show-projects
15074 (save-excursion (beginning-of-line) (looking-at "^0:")))
15075 (progn (setq vhdl-speedbar-shown-project-list nil
)
15076 (vhdl-speedbar-refresh))
15077 (let ((key (vhdl-speedbar-line-key)))
15078 (vhdl-adelete 'vhdl-speedbar-shown-unit-alist key
)
15079 (vhdl-speedbar-refresh (and vhdl-speedbar-show-projects key
))
15080 (when (memq 'display vhdl-speedbar-save-cache
)
15081 (add-to-list 'vhdl-updated-project-list key
)))))
15083 (defun vhdl-speedbar-expand-all ()
15084 "Expand all design units in current directory/project."
15086 (let* ((key (vhdl-speedbar-line-key))
15087 (ent-alist (vhdl-aget vhdl-entity-alist key
))
15088 (conf-alist (vhdl-aget vhdl-config-alist key
))
15089 (pack-alist (vhdl-aget vhdl-package-alist key
))
15090 arch-alist unit-alist subunit-alist
)
15091 (add-to-list 'vhdl-speedbar-shown-project-list key
)
15093 (setq arch-alist
(nth 4 (car ent-alist
)))
15094 (setq subunit-alist nil
)
15096 (push (caar arch-alist
) subunit-alist
)
15097 (setq arch-alist
(cdr arch-alist
)))
15098 (push (list (caar ent-alist
) subunit-alist
) unit-alist
)
15099 (setq ent-alist
(cdr ent-alist
)))
15101 (push (list (caar conf-alist
)) unit-alist
)
15102 (setq conf-alist
(cdr conf-alist
)))
15104 (push (list (caar pack-alist
)) unit-alist
)
15105 (setq pack-alist
(cdr pack-alist
)))
15106 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
)
15107 (vhdl-speedbar-refresh)
15108 (when (memq 'display vhdl-speedbar-save-cache
)
15109 (add-to-list 'vhdl-updated-project-list key
))))
15111 (declare-function speedbar-change-expand-button-char
"speedbar" (char))
15112 (declare-function speedbar-delete-subblock
"speedbar" (indent))
15114 (defun vhdl-speedbar-expand-project (text token indent
)
15115 "Expand/contract the project under the cursor."
15117 ((string-match "+" text
) ; expand project
15118 (speedbar-change-expand-button-char ?-
)
15119 (unless (member token vhdl-speedbar-shown-project-list
)
15120 (setq vhdl-speedbar-shown-project-list
15121 (cons token vhdl-speedbar-shown-project-list
)))
15122 (speedbar-with-writable
15124 (end-of-line) (forward-char 1)
15125 (vhdl-speedbar-insert-project-hierarchy token
(1+ indent
)
15126 speedbar-power-click
))))
15127 ((string-match "-" text
) ; contract project
15128 (speedbar-change-expand-button-char ?
+)
15129 (setq vhdl-speedbar-shown-project-list
15130 (delete token vhdl-speedbar-shown-project-list
))
15131 (speedbar-delete-subblock indent
))
15132 (t (error "Nothing to display")))
15133 (when (equal (selected-frame) speedbar-frame
)
15134 (speedbar-center-buffer-smartly)))
15136 (defun vhdl-speedbar-expand-entity (text token indent
)
15137 "Expand/contract the entity under the cursor."
15139 ((string-match "+" text
) ; expand entity
15140 (let* ((key (vhdl-speedbar-line-key indent
))
15141 (ent-alist (vhdl-aget vhdl-entity-alist key
))
15142 (ent-entry (vhdl-aget ent-alist token
))
15143 (arch-alist (nth 3 ent-entry
))
15144 (inst-alist (vhdl-get-instantiations token indent
))
15145 (subpack-alist (nth 5 ent-entry
))
15146 (multiple-arch (> (length arch-alist
) 1))
15147 arch-entry inst-entry
)
15148 (if (not (or arch-alist inst-alist subpack-alist
))
15149 (speedbar-change-expand-button-char ??
)
15150 (speedbar-change-expand-button-char ?-
)
15151 ;; add entity to `vhdl-speedbar-shown-unit-alist'
15152 (let* ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15153 (vhdl-aput 'unit-alist token nil
)
15154 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
))
15155 (speedbar-with-writable
15157 (end-of-line) (forward-char 1)
15158 ;; insert architectures
15160 (vhdl-speedbar-make-title-line "Architectures:" (1+ indent
)))
15162 (setq arch-entry
(car arch-alist
))
15163 (speedbar-make-tag-line
15164 'curly ?
+ 'vhdl-speedbar-expand-architecture
15165 (cons token
(nth 0 arch-entry
))
15166 (nth 1 arch-entry
) 'vhdl-speedbar-find-file
15167 (cons (nth 2 arch-entry
) (nth 3 arch-entry
))
15168 'vhdl-speedbar-architecture-face
(1+ indent
))
15169 (when (and multiple-arch
15170 (equal (nth 0 arch-entry
) (nth 4 ent-entry
)))
15171 (end-of-line 0) (insert " (mra)") (forward-char 1))
15172 (setq arch-alist
(cdr arch-alist
)))
15173 ;; insert instantiations
15175 (vhdl-speedbar-make-title-line "Instantiated as:" (1+ indent
)))
15177 (setq inst-entry
(car inst-alist
))
15178 (vhdl-speedbar-make-inst-line
15179 (nth 0 inst-entry
) (nth 1 inst-entry
) (nth 2 inst-entry
)
15180 (nth 3 inst-entry
) (nth 4 inst-entry
) (nth 5 inst-entry
)
15181 nil nil nil
(1+ indent
) 0 " in ")
15182 (setq inst-alist
(cdr inst-alist
)))
15183 ;; insert required packages
15184 (vhdl-speedbar-insert-subpackages
15185 subpack-alist
(1+ indent
) indent
)))
15186 (when (memq 'display vhdl-speedbar-save-cache
)
15187 (add-to-list 'vhdl-updated-project-list key
))
15188 (vhdl-speedbar-update-current-unit t t
))))
15189 ((string-match "-" text
) ; contract entity
15190 (speedbar-change-expand-button-char ?
+)
15191 ;; remove entity from `vhdl-speedbar-shown-unit-alist'
15192 (let* ((key (vhdl-speedbar-line-key indent
))
15193 (unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15194 (vhdl-adelete 'unit-alist token
)
15196 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
)
15197 (vhdl-adelete 'vhdl-speedbar-shown-unit-alist key
))
15198 (speedbar-delete-subblock indent
)
15199 (when (memq 'display vhdl-speedbar-save-cache
)
15200 (add-to-list 'vhdl-updated-project-list key
))))
15201 (t (error "Nothing to display")))
15202 (when (equal (selected-frame) speedbar-frame
)
15203 (speedbar-center-buffer-smartly)))
15205 (defun vhdl-speedbar-expand-architecture (text token indent
)
15206 "Expand/contract the architecture under the cursor."
15208 ((string-match "+" text
) ; expand architecture
15209 (let* ((key (vhdl-speedbar-line-key (1- indent
)))
15210 (ent-alist (vhdl-aget vhdl-entity-alist key
))
15211 (conf-alist (vhdl-aget vhdl-config-alist key
))
15212 (hier-alist (vhdl-get-hierarchy
15213 ent-alist conf-alist
(car token
) (cdr token
) nil nil
15215 (ent-entry (vhdl-aget ent-alist
(car token
)))
15216 (arch-entry (vhdl-aget (nth 3 ent-entry
) (cdr token
)))
15217 (subpack-alist (nth 4 arch-entry
))
15219 (if (not (or hier-alist subpack-alist
))
15220 (speedbar-change-expand-button-char ??
)
15221 (speedbar-change-expand-button-char ?-
)
15222 ;; add architecture to `vhdl-speedbar-shown-unit-alist'
15223 (let* ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
))
15224 (arch-alist (nth 0 (vhdl-aget unit-alist
(car token
)))))
15225 (vhdl-aput 'unit-alist
(car token
)
15226 (list (cons (cdr token
) arch-alist
)))
15227 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
))
15228 (speedbar-with-writable
15230 (end-of-line) (forward-char 1)
15231 ;; insert instance hierarchy
15233 (vhdl-speedbar-make-title-line "Subcomponent hierarchy:"
15236 (setq entry
(car hier-alist
))
15237 (when (or (= vhdl-speedbar-hierarchy-depth
0)
15238 (< (nth 9 entry
) vhdl-speedbar-hierarchy-depth
))
15239 (vhdl-speedbar-make-inst-line
15240 (nth 0 entry
) (nth 1 entry
) (nth 2 entry
) (nth 3 entry
)
15241 (nth 4 entry
) (nth 5 entry
) (nth 6 entry
) (nth 7 entry
)
15242 (nth 8 entry
) (1+ indent
) (1+ (nth 9 entry
)) ": "))
15243 (setq hier-alist
(cdr hier-alist
)))
15244 ;; insert required packages
15245 (vhdl-speedbar-insert-subpackages
15246 subpack-alist
(1+ indent
) (1- indent
))))
15247 (when (memq 'display vhdl-speedbar-save-cache
)
15248 (add-to-list 'vhdl-updated-project-list key
))
15249 (vhdl-speedbar-update-current-unit t t
))))
15250 ((string-match "-" text
) ; contract architecture
15251 (speedbar-change-expand-button-char ?
+)
15252 ;; remove architecture from `vhdl-speedbar-shown-unit-alist'
15253 (let* ((key (vhdl-speedbar-line-key (1- indent
)))
15254 (unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
))
15255 (arch-alist (nth 0 (vhdl-aget unit-alist
(car token
)))))
15256 (vhdl-aput 'unit-alist
(car token
) (list (delete (cdr token
) arch-alist
)))
15257 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
)
15258 (speedbar-delete-subblock indent
)
15259 (when (memq 'display vhdl-speedbar-save-cache
)
15260 (add-to-list 'vhdl-updated-project-list key
))))
15261 (t (error "Nothing to display")))
15262 (when (equal (selected-frame) speedbar-frame
)
15263 (speedbar-center-buffer-smartly)))
15265 (defun vhdl-speedbar-expand-config (text token indent
)
15266 "Expand/contract the configuration under the cursor."
15268 ((string-match "+" text
) ; expand configuration
15269 (let* ((key (vhdl-speedbar-line-key indent
))
15270 (conf-alist (vhdl-aget vhdl-config-alist key
))
15271 (conf-entry (vhdl-aget conf-alist token
))
15272 (ent-alist (vhdl-aget vhdl-entity-alist key
))
15273 (hier-alist (vhdl-get-hierarchy
15274 ent-alist conf-alist
(nth 3 conf-entry
)
15275 (nth 4 conf-entry
) token
(nth 5 conf-entry
)
15277 (subpack-alist (nth 6 conf-entry
))
15279 (if (not (or hier-alist subpack-alist
))
15280 (speedbar-change-expand-button-char ??
)
15281 (speedbar-change-expand-button-char ?-
)
15282 ;; add configuration to `vhdl-speedbar-shown-unit-alist'
15283 (let* ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15284 (vhdl-aput 'unit-alist token nil
)
15285 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
))
15286 (speedbar-with-writable
15288 (end-of-line) (forward-char 1)
15289 ;; insert instance hierarchy
15291 (vhdl-speedbar-make-title-line "Design hierarchy:" (1+ indent
)))
15293 (setq entry
(car hier-alist
))
15294 (when (or (= vhdl-speedbar-hierarchy-depth
0)
15295 (<= (nth 9 entry
) vhdl-speedbar-hierarchy-depth
))
15296 (vhdl-speedbar-make-inst-line
15297 (nth 0 entry
) (nth 1 entry
) (nth 2 entry
) (nth 3 entry
)
15298 (nth 4 entry
) (nth 5 entry
) (nth 6 entry
) (nth 7 entry
)
15299 (nth 8 entry
) (1+ indent
) (nth 9 entry
) ": "))
15300 (setq hier-alist
(cdr hier-alist
)))
15301 ;; insert required packages
15302 (vhdl-speedbar-insert-subpackages
15303 subpack-alist
(1+ indent
) indent
)))
15304 (when (memq 'display vhdl-speedbar-save-cache
)
15305 (add-to-list 'vhdl-updated-project-list key
))
15306 (vhdl-speedbar-update-current-unit t t
))))
15307 ((string-match "-" text
) ; contract configuration
15308 (speedbar-change-expand-button-char ?
+)
15309 ;; remove configuration from `vhdl-speedbar-shown-unit-alist'
15310 (let* ((key (vhdl-speedbar-line-key indent
))
15311 (unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15312 (vhdl-adelete 'unit-alist token
)
15314 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
)
15315 (vhdl-adelete 'vhdl-speedbar-shown-unit-alist key
))
15316 (speedbar-delete-subblock indent
)
15317 (when (memq 'display vhdl-speedbar-save-cache
)
15318 (add-to-list 'vhdl-updated-project-list key
))))
15319 (t (error "Nothing to display")))
15320 (when (equal (selected-frame) speedbar-frame
)
15321 (speedbar-center-buffer-smartly)))
15323 (defun vhdl-speedbar-expand-package (text token indent
)
15324 "Expand/contract the package under the cursor."
15326 ((string-match "+" text
) ; expand package
15327 (let* ((key (vhdl-speedbar-line-key indent
))
15328 (pack-alist (vhdl-aget vhdl-package-alist key
))
15329 (pack-entry (vhdl-aget pack-alist token
))
15330 (comp-alist (nth 3 pack-entry
))
15331 (func-alist (nth 4 pack-entry
))
15332 (func-body-alist (nth 8 pack-entry
))
15333 (subpack-alist (append (nth 5 pack-entry
) (nth 9 pack-entry
)))
15334 comp-entry func-entry func-body-entry
)
15335 (if (not (or comp-alist func-alist subpack-alist
))
15336 (speedbar-change-expand-button-char ??
)
15337 (speedbar-change-expand-button-char ?-
)
15338 ;; add package to `vhdl-speedbar-shown-unit-alist'
15339 (let* ((unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15340 (vhdl-aput 'unit-alist token nil
)
15341 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
))
15342 (speedbar-with-writable
15344 (end-of-line) (forward-char 1)
15345 ;; insert components
15347 (vhdl-speedbar-make-title-line "Components:" (1+ indent
)))
15349 (setq comp-entry
(car comp-alist
))
15350 (speedbar-make-tag-line
15352 (cons token
(nth 0 comp-entry
))
15353 (nth 1 comp-entry
) 'vhdl-speedbar-find-file
15354 (cons (nth 2 comp-entry
) (nth 3 comp-entry
))
15355 'vhdl-speedbar-entity-face
(1+ indent
))
15356 (setq comp-alist
(cdr comp-alist
)))
15357 ;; insert subprograms
15359 (vhdl-speedbar-make-title-line "Subprograms:" (1+ indent
)))
15361 (setq func-entry
(car func-alist
)
15362 func-body-entry
(vhdl-aget func-body-alist
15364 (when (nth 2 func-entry
)
15365 (vhdl-speedbar-make-subprogram-line
15367 (cons (nth 2 func-entry
) (nth 3 func-entry
))
15368 (cons (nth 1 func-body-entry
) (nth 2 func-body-entry
))
15370 (setq func-alist
(cdr func-alist
)))
15371 ;; insert required packages
15372 (vhdl-speedbar-insert-subpackages
15373 subpack-alist
(1+ indent
) indent
)))
15374 (when (memq 'display vhdl-speedbar-save-cache
)
15375 (add-to-list 'vhdl-updated-project-list key
))
15376 (vhdl-speedbar-update-current-unit t t
))))
15377 ((string-match "-" text
) ; contract package
15378 (speedbar-change-expand-button-char ?
+)
15379 ;; remove package from `vhdl-speedbar-shown-unit-alist'
15380 (let* ((key (vhdl-speedbar-line-key indent
))
15381 (unit-alist (vhdl-aget vhdl-speedbar-shown-unit-alist key
)))
15382 (vhdl-adelete 'unit-alist token
)
15384 (vhdl-aput 'vhdl-speedbar-shown-unit-alist key unit-alist
)
15385 (vhdl-adelete 'vhdl-speedbar-shown-unit-alist key
))
15386 (speedbar-delete-subblock indent
)
15387 (when (memq 'display vhdl-speedbar-save-cache
)
15388 (add-to-list 'vhdl-updated-project-list key
))))
15389 (t (error "Nothing to display")))
15390 (when (equal (selected-frame) speedbar-frame
)
15391 (speedbar-center-buffer-smartly)))
15393 (defun vhdl-speedbar-insert-subpackages (subpack-alist indent dir-indent
)
15394 "Insert required packages."
15395 (let* ((pack-alist (vhdl-aget vhdl-package-alist
15396 (vhdl-speedbar-line-key dir-indent
)))
15397 pack-key lib-name pack-entry
)
15398 (when subpack-alist
15399 (vhdl-speedbar-make-title-line "Packages Used:" indent
))
15400 (while subpack-alist
15401 (setq pack-key
(cdar subpack-alist
)
15402 lib-name
(caar subpack-alist
))
15403 (setq pack-entry
(vhdl-aget pack-alist pack-key
))
15404 (vhdl-speedbar-make-subpack-line
15405 (or (nth 0 pack-entry
) pack-key
) lib-name
15406 (cons (nth 1 pack-entry
) (nth 2 pack-entry
))
15407 (cons (nth 6 pack-entry
) (nth 7 pack-entry
)) indent
)
15408 (setq subpack-alist
(cdr subpack-alist
)))))
15410 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15411 ;; Display help functions
15413 (defvar vhdl-speedbar-update-current-unit t
15414 "Non-nil means to run `vhdl-speedbar-update-current-unit'.")
15416 (defun vhdl-speedbar-update-current-project ()
15417 "Highlight project that is currently active."
15418 (when (and vhdl-speedbar-show-projects
15419 (not (equal vhdl-speedbar-last-selected-project vhdl-project
))
15420 (and (boundp 'speedbar-frame
)
15421 (frame-live-p speedbar-frame
)))
15422 (let ((last-frame (selected-frame))
15423 (project-alist vhdl-project-alist
)
15425 (select-frame speedbar-frame
)
15426 (speedbar-with-writable
15428 (while project-alist
15429 (goto-char (point-min))
15430 (when (re-search-forward
15431 (concat "<.> \\(" (caar project-alist
) "\\)$") nil t
)
15432 (put-text-property (match-beginning 1) (match-end 1) 'face
15433 (if (equal (caar project-alist
) vhdl-project
)
15434 'speedbar-selected-face
15435 'speedbar-directory-face
))
15436 (when (equal (caar project-alist
) vhdl-project
)
15437 (setq pos
(1- (match-beginning 1)))))
15438 (setq project-alist
(cdr project-alist
))))
15439 (when pos
(goto-char pos
)))
15440 (select-frame last-frame
)
15441 (setq vhdl-speedbar-last-selected-project vhdl-project
)))
15444 (declare-function speedbar-position-cursor-on-line
"speedbar" ())
15446 (defun vhdl-speedbar-update-current-unit (&optional no-position always
)
15447 "Highlight all design units that are contained in the current file.
15448 NO-POSITION non-nil means do not re-position cursor."
15449 (let ((last-frame (selected-frame))
15450 (project-list vhdl-speedbar-shown-project-list
)
15451 file-alist pos file-name
)
15452 ;; get current file name
15453 (if (fboundp 'speedbar-select-attached-frame
)
15454 (speedbar-select-attached-frame)
15455 (select-frame speedbar-attached-frame
))
15456 (setq file-name
(abbreviate-file-name (or (buffer-file-name) "")))
15457 (when (and vhdl-speedbar-update-current-unit
15458 (or always
(not (equal file-name speedbar-last-selected-file
))))
15459 (if vhdl-speedbar-show-projects
15460 (while project-list
15461 (setq file-alist
(append file-alist
15462 (vhdl-aget vhdl-file-alist
15463 (car project-list
))))
15464 (setq project-list
(cdr project-list
)))
15466 (vhdl-aget vhdl-file-alist
15467 (abbreviate-file-name default-directory
))))
15468 (select-frame speedbar-frame
)
15469 (set-buffer speedbar-buffer
)
15470 (speedbar-with-writable
15471 (vhdl-prepare-search-1
15473 ;; unhighlight last units
15474 (let* ((file-entry (vhdl-aget file-alist
15475 speedbar-last-selected-file
)))
15476 (vhdl-speedbar-update-units
15477 "\\[.] " (nth 0 file-entry
)
15478 speedbar-last-selected-file
'vhdl-speedbar-entity-face
)
15479 (vhdl-speedbar-update-units
15480 "{.} " (nth 1 file-entry
)
15481 speedbar-last-selected-file
'vhdl-speedbar-architecture-face
)
15482 (vhdl-speedbar-update-units
15483 "\\[.] " (nth 3 file-entry
)
15484 speedbar-last-selected-file
'vhdl-speedbar-configuration-face
)
15485 (vhdl-speedbar-update-units
15486 "[]>] " (nth 4 file-entry
)
15487 speedbar-last-selected-file
'vhdl-speedbar-package-face
)
15488 (vhdl-speedbar-update-units
15489 "\\[.].+(" '("body")
15490 speedbar-last-selected-file
'vhdl-speedbar-package-face
)
15491 (vhdl-speedbar-update-units
15492 "> " (nth 6 file-entry
)
15493 speedbar-last-selected-file
'vhdl-speedbar-instantiation-face
))
15494 ;; highlight current units
15495 (let* ((file-entry (vhdl-aget file-alist file-name
)))
15497 pos
(vhdl-speedbar-update-units
15498 "\\[.] " (nth 0 file-entry
)
15499 file-name
'vhdl-speedbar-entity-selected-face pos
)
15500 pos
(vhdl-speedbar-update-units
15501 "{.} " (nth 1 file-entry
)
15502 file-name
'vhdl-speedbar-architecture-selected-face pos
)
15503 pos
(vhdl-speedbar-update-units
15504 "\\[.] " (nth 3 file-entry
)
15505 file-name
'vhdl-speedbar-configuration-selected-face pos
)
15506 pos
(vhdl-speedbar-update-units
15507 "[]>] " (nth 4 file-entry
)
15508 file-name
'vhdl-speedbar-package-selected-face pos
)
15509 pos
(vhdl-speedbar-update-units
15510 "\\[.].+(" '("body")
15511 file-name
'vhdl-speedbar-package-selected-face pos
)
15512 pos
(vhdl-speedbar-update-units
15513 "> " (nth 6 file-entry
)
15514 file-name
'vhdl-speedbar-instantiation-selected-face pos
))))))
15515 ;; move speedbar so the first highlighted unit is visible
15516 (when (and pos
(not no-position
))
15518 (speedbar-center-buffer-smartly)
15519 (speedbar-position-cursor-on-line))
15520 (setq speedbar-last-selected-file file-name
))
15521 (select-frame last-frame
)
15524 (defun vhdl-speedbar-update-units (text unit-list file-name face
15526 "Help function to highlight design units."
15528 (goto-char (point-min))
15529 (while (re-search-forward
15530 (concat text
"\\(" (car unit-list
) "\\)\\>") nil t
)
15531 (when (equal file-name
(car (get-text-property
15532 (match-beginning 1) 'speedbar-token
)))
15533 (setq pos
(or pos
(point-marker)))
15534 (put-text-property (match-beginning 1) (match-end 1) 'face face
)))
15535 (setq unit-list
(cdr unit-list
)))
15538 (declare-function speedbar-make-button
"speedbar"
15539 (start end face mouse function
&optional token
))
15541 (defun vhdl-speedbar-make-inst-line (inst-name inst-file-marker
15542 ent-name ent-file-marker
15543 arch-name arch-file-marker
15544 conf-name conf-file-marker
15545 lib-name depth offset delimiter
)
15546 "Insert instantiation entry."
15547 (let ((start (point))
15549 (insert (int-to-string depth
) ":")
15550 (put-text-property start
(point) 'invisible t
)
15551 (setq visible-start
(point))
15552 (insert-char ?
(* depth speedbar-indentation-width
))
15553 (while (> offset
0)
15555 (insert-char (if (= offset
1) ?- ?
) (1- speedbar-indentation-width
))
15556 (setq offset
(1- offset
)))
15557 (put-text-property visible-start
(point) 'invisible nil
)
15558 (setq start
(point))
15560 (speedbar-make-button start
(point) nil nil nil
)
15561 (setq visible-start
(point))
15563 (setq start
(point))
15564 (if (not inst-name
)
15567 (speedbar-make-button
15568 start
(point) 'vhdl-speedbar-instantiation-face
'speedbar-highlight-face
15569 'vhdl-speedbar-find-file inst-file-marker
))
15572 (setq start
(point))
15574 (speedbar-make-button
15575 start
(point) 'vhdl-speedbar-entity-face
'speedbar-highlight-face
15576 'vhdl-speedbar-find-file ent-file-marker
)
15579 (setq start
(point))
15581 (speedbar-make-button
15582 start
(point) 'vhdl-speedbar-architecture-face
'speedbar-highlight-face
15583 'vhdl-speedbar-find-file arch-file-marker
)
15587 (setq start
(point))
15589 (speedbar-make-button
15590 start
(point) 'vhdl-speedbar-configuration-face
'speedbar-highlight-face
15591 'vhdl-speedbar-find-file conf-file-marker
)
15593 (when (and lib-name
(not (equal lib-name
(downcase (vhdl-work-library)))))
15594 (setq start
(point))
15595 (insert " (" lib-name
")")
15596 (put-text-property (+ 2 start
) (1- (point)) 'face
15597 'vhdl-speedbar-library-face
))
15598 (insert-char ?
\n 1)
15599 (put-text-property visible-start
(point) 'invisible nil
)))
15601 (defun vhdl-speedbar-make-pack-line (pack-key pack-name pack-file-marker
15602 body-file-marker depth
)
15603 "Insert package entry."
15604 (let ((start (point))
15606 (insert (int-to-string depth
) ":")
15607 (put-text-property start
(point) 'invisible t
)
15608 (setq visible-start
(point))
15609 (insert-char ?
(* depth speedbar-indentation-width
))
15610 (put-text-property visible-start
(point) 'invisible nil
)
15611 (setq start
(point))
15613 (speedbar-make-button
15614 start
(point) 'speedbar-button-face
'speedbar-highlight-face
15615 'vhdl-speedbar-expand-package pack-key
)
15616 (setq visible-start
(point))
15617 (insert-char ?
1 nil
)
15618 (setq start
(point))
15620 (speedbar-make-button
15621 start
(point) 'vhdl-speedbar-package-face
'speedbar-highlight-face
15622 'vhdl-speedbar-find-file pack-file-marker
)
15623 (unless (car pack-file-marker
)
15625 (when (car body-file-marker
)
15627 (setq start
(point))
15629 (speedbar-make-button
15630 start
(point) 'vhdl-speedbar-package-face
'speedbar-highlight-face
15631 'vhdl-speedbar-find-file body-file-marker
)
15633 (insert-char ?
\n 1)
15634 (put-text-property visible-start
(point) 'invisible nil
)))
15636 (defun vhdl-speedbar-make-subpack-line (pack-name lib-name pack-file-marker
15637 pack-body-file-marker depth
)
15638 "Insert used package entry."
15639 (let ((start (point))
15641 (insert (int-to-string depth
) ":")
15642 (put-text-property start
(point) 'invisible t
)
15643 (setq visible-start
(point))
15644 (insert-char ?
(* depth speedbar-indentation-width
))
15645 (put-text-property visible-start
(point) 'invisible nil
)
15646 (setq start
(point))
15648 (speedbar-make-button start
(point) nil nil nil
)
15649 (setq visible-start
(point))
15651 (setq start
(point))
15653 (speedbar-make-button
15654 start
(point) 'vhdl-speedbar-package-face
'speedbar-highlight-face
15655 'vhdl-speedbar-find-file pack-file-marker
)
15656 (when (car pack-body-file-marker
)
15658 (setq start
(point))
15660 (speedbar-make-button
15661 start
(point) 'vhdl-speedbar-package-face
'speedbar-highlight-face
15662 'vhdl-speedbar-find-file pack-body-file-marker
)
15664 (setq start
(point))
15665 (insert " (" lib-name
")")
15666 (put-text-property (+ 2 start
) (1- (point)) 'face
15667 'vhdl-speedbar-library-face
)
15668 (insert-char ?
\n 1)
15669 (put-text-property visible-start
(point) 'invisible nil
)))
15671 (defun vhdl-speedbar-make-subprogram-line (func-name func-file-marker
15672 func-body-file-marker
15674 "Insert subprogram entry."
15675 (let ((start (point))
15677 (insert (int-to-string depth
) ":")
15678 (put-text-property start
(point) 'invisible t
)
15679 (setq visible-start
(point))
15680 (insert-char ?
(* depth speedbar-indentation-width
))
15681 (put-text-property visible-start
(point) 'invisible nil
)
15682 (setq start
(point))
15684 (speedbar-make-button start
(point) nil nil nil
)
15685 (setq visible-start
(point))
15687 (setq start
(point))
15689 (speedbar-make-button
15690 start
(point) 'vhdl-speedbar-subprogram-face
'speedbar-highlight-face
15691 'vhdl-speedbar-find-file func-file-marker
)
15692 (when (car func-body-file-marker
)
15694 (setq start
(point))
15696 (speedbar-make-button
15697 start
(point) 'vhdl-speedbar-subprogram-face
'speedbar-highlight-face
15698 'vhdl-speedbar-find-file func-body-file-marker
)
15700 (insert-char ?
\n 1)
15701 (put-text-property visible-start
(point) 'invisible nil
)))
15703 (defun vhdl-speedbar-make-title-line (text &optional depth
)
15704 "Insert design unit title entry."
15705 (let ((start (point))
15708 (insert (int-to-string depth
) ":")
15709 (put-text-property start
(point) 'invisible t
))
15710 (setq visible-start
(point))
15711 (insert-char ?
(* (or depth
0) speedbar-indentation-width
))
15712 (setq start
(point))
15714 (speedbar-make-button start
(point) nil nil nil nil
)
15715 (insert-char ?
\n 1)
15716 (put-text-property visible-start
(point) 'invisible nil
)))
15718 (defun vhdl-speedbar-insert-dirs (files level
)
15719 "Insert subdirectories."
15720 (let ((dirs (car files
)))
15722 (speedbar-make-tag-line 'angle ?
+ 'vhdl-speedbar-dired
(car dirs
)
15723 (car dirs
) 'speedbar-dir-follow nil
15724 'speedbar-directory-face level
)
15725 (setq dirs
(cdr dirs
)))))
15727 (declare-function speedbar-reset-scanners
"speedbar" ())
15729 (defun vhdl-speedbar-dired (text token indent
)
15730 "Speedbar click handler for directory expand button in hierarchy mode."
15731 (cond ((string-match "+" text
) ; we have to expand this dir
15732 (setq speedbar-shown-directories
15733 (cons (expand-file-name
15734 (concat (speedbar-line-directory indent
) token
"/"))
15735 speedbar-shown-directories
))
15736 (speedbar-change-expand-button-char ?-
)
15737 (speedbar-reset-scanners)
15738 (speedbar-with-writable
15740 (end-of-line) (forward-char 1)
15741 (vhdl-speedbar-insert-dirs
15742 (speedbar-file-lists
15743 (concat (speedbar-line-directory indent
) token
"/"))
15745 (speedbar-reset-scanners)
15746 (vhdl-speedbar-insert-dir-hierarchy
15747 (abbreviate-file-name
15748 (concat (speedbar-line-directory indent
) token
"/"))
15749 (1+ indent
) speedbar-power-click
)))
15750 (vhdl-speedbar-update-current-unit t t
))
15751 ((string-match "-" text
) ; we have to contract this node
15752 (speedbar-reset-scanners)
15753 (let ((oldl speedbar-shown-directories
)
15755 (td (expand-file-name
15756 (concat (speedbar-line-directory indent
) token
))))
15758 (if (not (string-match (concat "^" (regexp-quote td
)) (car oldl
)))
15759 (push (car oldl
) newl
))
15760 (setq oldl
(cdr oldl
)))
15761 (setq speedbar-shown-directories
(nreverse newl
)))
15762 (speedbar-change-expand-button-char ?
+)
15763 (speedbar-delete-subblock indent
))
15764 (t (error "Nothing to display")))
15765 (when (equal (selected-frame) speedbar-frame
)
15766 (speedbar-center-buffer-smartly)))
15768 (declare-function speedbar-files-item-info
"speedbar" ())
15770 (defun vhdl-speedbar-item-info ()
15771 "Derive and display information about this line item."
15773 (beginning-of-line)
15774 ;; skip invisible number info
15775 (when (looking-at "^[0-9]+:") (goto-char (match-end 0)))
15777 ;; project/directory entry
15778 ((looking-at "\\s-*<[-+?]>\\s-+\\([^\n]+\\)$")
15779 (if vhdl-speedbar-show-projects
15780 (message "Project \"%s\"" (match-string-no-properties 1))
15781 (speedbar-files-item-info)))
15782 ;; design unit entry
15783 ((looking-at "\\(\\s-*\\([[{][-+?][]}]\\|[| -]*>\\) \\)\"?\\w")
15784 (goto-char (match-end 1))
15785 (let ((face (get-text-property (point) 'face
)))
15787 "%s \"%s\" in \"%s\""
15788 ;; design unit kind
15789 (cond ((or (eq face
'vhdl-speedbar-entity-face
)
15790 (eq face
'vhdl-speedbar-entity-selected-face
))
15791 (if (equal (match-string 2) ">") "Component" "Entity"))
15792 ((or (eq face
'vhdl-speedbar-architecture-face
)
15793 (eq face
'vhdl-speedbar-architecture-selected-face
))
15795 ((or (eq face
'vhdl-speedbar-configuration-face
)
15796 (eq face
'vhdl-speedbar-configuration-selected-face
))
15798 ((or (eq face
'vhdl-speedbar-package-face
)
15799 (eq face
'vhdl-speedbar-package-selected-face
))
15801 ((or (eq face
'vhdl-speedbar-instantiation-face
)
15802 (eq face
'vhdl-speedbar-instantiation-selected-face
))
15804 ((eq face
'vhdl-speedbar-subprogram-face
)
15807 ;; design unit name
15808 (buffer-substring-no-properties
15809 (progn (looking-at "\"?\\(\\(\\w\\|_\\)+\\)\"?") (match-beginning 1))
15812 (file-relative-name
15813 (or (car (get-text-property (point) 'speedbar-token
))
15815 (vhdl-default-directory)))))
15816 (t (message "")))))
15818 (declare-function speedbar-line-text
"speedbar" (&optional p
))
15820 (defun vhdl-speedbar-line-text ()
15821 "Calls `speedbar-line-text' and removes text properties."
15822 (let ((string (speedbar-line-text)))
15823 (set-text-properties 0 (length string
) nil string
)
15826 (defun vhdl-speedbar-higher-text ()
15827 "Get speedbar-line-text of higher level."
15828 (let (depth string
)
15830 (beginning-of-line)
15831 (looking-at "^\\([0-9]+\\):")
15832 (setq depth
(string-to-number (match-string 1)))
15833 (when (re-search-backward (format "^%d: *[[<{][-+?][]>}] \\([^ \n]+\\)" (1- depth
)) nil t
)
15834 (setq string
(match-string 1))
15835 (set-text-properties 0 (length string
) nil string
)
15838 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15841 (defun vhdl-speedbar-line-key (&optional indent
)
15842 "Get currently displayed directory of project name."
15843 (if vhdl-speedbar-show-projects
15844 (vhdl-speedbar-line-project)
15845 (abbreviate-file-name
15846 (file-name-as-directory (speedbar-line-directory indent
)))))
15848 (defun vhdl-speedbar-line-project (&optional indent
)
15849 "Get currently displayed project name."
15850 (and vhdl-speedbar-show-projects
15853 (re-search-backward "^[0-9]+:\\s-*<[-+?]>\\s-+\\([^\n]+\\)$" nil t
)
15854 (match-string-no-properties 1))))
15856 (defun vhdl-add-modified-file ()
15857 "Add file to `vhdl-modified-file-list'."
15858 (when vhdl-file-alist
15859 (add-to-list 'vhdl-modified-file-list
(buffer-file-name)))
15862 (defun vhdl-resolve-paths (path-list)
15863 "Resolve path wildcards in PATH-LIST."
15864 (let (path-list-1 path-list-2 path-beg path-end dir
)
15865 ;; eliminate non-existent directories
15867 (setq dir
(car path-list
))
15868 (string-match "\\(-r \\)?\\(\\([^?*]*[/\\]\\)*\\)" dir
)
15869 (if (file-directory-p (match-string 2 dir
))
15870 (push dir path-list-1
)
15871 (vhdl-warning-when-idle "No such directory: \"%s\"" (match-string 2 dir
)))
15872 (setq path-list
(cdr path-list
)))
15873 ;; resolve path wildcards
15875 (setq dir
(car path-list-1
))
15876 (if (string-match "\\(-r \\)?\\(\\([^?*]*[/\\]\\)*\\)\\([^/\\]*[?*][^/\\]*\\)\\([/\\].*\\)" dir
)
15878 (setq path-beg
(match-string 1 dir
)
15879 path-end
(match-string 5 dir
))
15884 (lambda (var) (concat path-beg var path-end
)))
15885 (let ((all-list (vhdl-directory-files
15886 (match-string 2 dir
) t
15887 (concat "\\<" (wildcard-to-regexp
15888 (match-string 4 dir
)))))
15891 (when (file-directory-p (car all-list
))
15892 (push (car all-list
) dir-list
))
15893 (setq all-list
(cdr all-list
)))
15895 (cdr path-list-1
))))
15896 (string-match "\\(-r \\)?\\(.*\\)[/\\].*" dir
)
15897 (when (file-directory-p (match-string 2 dir
))
15898 (push dir path-list-2
))
15899 (setq path-list-1
(cdr path-list-1
))))
15900 (nreverse path-list-2
)))
15902 (defun vhdl-speedbar-goto-this-unit (directory unit
)
15903 "If UNIT is displayed in DIRECTORY, goto this line and return t, else nil."
15904 (let ((dest (point)))
15905 (if (and (if vhdl-speedbar-show-projects
15906 (progn (goto-char (point-min)) t
)
15907 (speedbar-goto-this-file directory
))
15908 (re-search-forward (concat "[]}] " unit
"\\>") nil t
))
15909 (progn (speedbar-position-cursor-on-line)
15914 (declare-function speedbar-find-file-in-frame
"speedbar" (file))
15915 (declare-function speedbar-set-timer
"speedbar" (timeout))
15916 ;; speedbar loads dframe at runtime.
15917 (declare-function dframe-maybee-jump-to-attached-frame
"dframe" ())
15919 (defun vhdl-speedbar-find-file (text token indent
)
15920 "When user clicks on TEXT, load file with name and position in TOKEN.
15921 Jump to the design unit if `vhdl-speedbar-jump-to-unit' is t or if the file
15922 is already shown in a buffer."
15923 (if (not (car token
))
15924 (error "ERROR: File cannot be found")
15925 (let ((buffer (get-file-buffer (car token
))))
15926 (speedbar-find-file-in-frame (car token
))
15927 (when (or vhdl-speedbar-jump-to-unit buffer
)
15928 (goto-char (point-min))
15929 (forward-line (1- (cdr token
)))
15931 (vhdl-speedbar-update-current-unit t t
)
15932 (speedbar-set-timer dframe-update-speed
)
15933 (dframe-maybee-jump-to-attached-frame))))
15935 (defun vhdl-speedbar-port-copy ()
15936 "Copy the port of the entity/component or subprogram under the cursor."
15938 (let ((is-entity (vhdl-speedbar-check-unit 'entity
)))
15939 (if (not (or is-entity
(vhdl-speedbar-check-unit 'subprogram
)))
15940 (error "ERROR: No entity/component or subprogram under cursor")
15941 (beginning-of-line)
15942 (if (looking-at "\\([0-9]\\)+:\\s-*\\(\\[[-+?]]\\|>\\) \\(\\(\\w\\|\\s_\\)+\\)")
15943 (condition-case info
15944 (let ((token (get-text-property
15945 (match-beginning 3) 'speedbar-token
)))
15946 (vhdl-visit-file (car token
) t
15947 (progn (goto-char (point-min))
15948 (forward-line (1- (cdr token
)))
15952 (vhdl-subprog-copy)))))
15953 (error (error "ERROR: %s not scanned successfully\n (%s)"
15954 (if is-entity
"Port" "Interface") (cadr info
))))
15955 (error "ERROR: No entity/component or subprogram on current line")))))
15957 (defun vhdl-speedbar-place-component ()
15958 "Place the entity/component under the cursor as component."
15960 (if (not (vhdl-speedbar-check-unit 'entity
))
15961 (error "ERROR: No entity/component under cursor")
15962 (vhdl-speedbar-port-copy)
15963 (if (fboundp 'speedbar-select-attached-frame
)
15964 (speedbar-select-attached-frame)
15965 (select-frame speedbar-attached-frame
))
15966 (vhdl-compose-place-component)
15967 (select-frame speedbar-frame
)))
15969 (defun vhdl-speedbar-configuration ()
15970 "Generate configuration for the architecture under the cursor."
15972 (if (not (vhdl-speedbar-check-unit 'architecture
))
15973 (error "ERROR: No architecture under cursor")
15974 (let ((arch-name (vhdl-speedbar-line-text))
15975 (ent-name (vhdl-speedbar-higher-text)))
15976 (if (fboundp 'speedbar-select-attached-frame
)
15977 (speedbar-select-attached-frame)
15978 (select-frame speedbar-attached-frame
))
15979 (vhdl-compose-configuration ent-name arch-name
))))
15981 (defun vhdl-speedbar-select-mra ()
15982 "Select the architecture under the cursor as MRA."
15984 (if (not (vhdl-speedbar-check-unit 'architecture
))
15985 (error "ERROR: No architecture under cursor")
15986 (let* ((arch-key (downcase (vhdl-speedbar-line-text)))
15987 (ent-key (downcase (vhdl-speedbar-higher-text)))
15988 (ent-alist (vhdl-aget
15990 (or (vhdl-project-p)
15991 (abbreviate-file-name default-directory
))))
15992 (ent-entry (vhdl-aget ent-alist ent-key
)))
15993 (setcar (cddr (cddr ent-entry
)) arch-key
) ; (nth 4 ent-entry)
15994 (speedbar-refresh))))
15996 (declare-function speedbar-line-file
"speedbar" (&optional p
))
15998 (defun vhdl-speedbar-make-design ()
15999 "Make (compile) design unit or directory/project under the cursor."
16001 (if (not (save-excursion (beginning-of-line)
16002 (looking-at "[0-9]+: *\\(\\(\\[\\)\\|<\\)")))
16003 (error "ERROR: No primary design unit or directory/project under cursor")
16004 (let ((is-unit (match-string 2))
16005 (unit-name (vhdl-speedbar-line-text))
16006 (vhdl-project (vhdl-speedbar-line-project))
16007 (directory (file-name-as-directory
16008 (or (speedbar-line-file) (speedbar-line-directory)))))
16009 (if (fboundp 'speedbar-select-attached-frame
)
16010 (speedbar-select-attached-frame)
16011 (select-frame speedbar-attached-frame
))
16012 (let ((default-directory directory
))
16013 (vhdl-make (and is-unit unit-name
))))))
16015 (defun vhdl-speedbar-generate-makefile ()
16016 "Generate Makefile for directory/project under the cursor."
16018 (let ((vhdl-project (vhdl-speedbar-line-project))
16019 (default-directory (file-name-as-directory
16020 (or (speedbar-line-file) (speedbar-line-directory)))))
16021 (vhdl-generate-makefile)))
16023 (defun vhdl-speedbar-check-unit (design-unit)
16024 "Check whether design unit under cursor corresponds to DESIGN-UNIT (or its
16025 expansion function)."
16027 (speedbar-position-cursor-on-line)
16028 (cond ((eq design-unit
'entity
)
16029 (memq (get-text-property (match-end 0) 'face
)
16030 '(vhdl-speedbar-entity-face
16031 vhdl-speedbar-entity-selected-face
)))
16032 ((eq design-unit
'architecture
)
16033 (memq (get-text-property (match-end 0) 'face
)
16034 '(vhdl-speedbar-architecture-face
16035 vhdl-speedbar-architecture-selected-face
)))
16036 ((eq design-unit
'subprogram
)
16037 (eq (get-text-property (match-end 0) 'face
)
16038 'vhdl-speedbar-subprogram-face
))
16041 (defun vhdl-speedbar-set-depth (depth)
16042 "Set hierarchy display depth to DEPTH and refresh speedbar."
16043 (setq vhdl-speedbar-hierarchy-depth depth
)
16044 (speedbar-refresh))
16046 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16049 (defface vhdl-speedbar-entity-face
16050 '((((class color
) (background light
)) (:foreground
"ForestGreen"))
16051 (((class color
) (background dark
)) (:foreground
"PaleGreen")))
16052 "Face used for displaying entity names."
16053 :group
'speedbar-faces
)
16055 (defface vhdl-speedbar-architecture-face
16056 '((((min-colors 88) (class color
) (background light
)) (:foreground
"Blue1"))
16057 (((class color
) (background light
)) (:foreground
"Blue"))
16059 (((class color
) (background dark
)) (:foreground
"LightSkyBlue")))
16060 "Face used for displaying architecture names."
16061 :group
'speedbar-faces
)
16063 (defface vhdl-speedbar-configuration-face
16064 '((((class color
) (background light
)) (:foreground
"DarkGoldenrod"))
16065 (((class color
) (background dark
)) (:foreground
"Salmon")))
16066 "Face used for displaying configuration names."
16067 :group
'speedbar-faces
)
16069 (defface vhdl-speedbar-package-face
16070 '((((class color
) (background light
)) (:foreground
"Grey50"))
16071 (((class color
) (background dark
)) (:foreground
"Grey80")))
16072 "Face used for displaying package names."
16073 :group
'speedbar-faces
)
16075 (defface vhdl-speedbar-library-face
16076 '((((class color
) (background light
)) (:foreground
"Purple"))
16077 (((class color
) (background dark
)) (:foreground
"Orchid1")))
16078 "Face used for displaying library names."
16079 :group
'speedbar-faces
)
16081 (defface vhdl-speedbar-instantiation-face
16082 '((((class color
) (background light
)) (:foreground
"Brown"))
16083 (((min-colors 88) (class color
) (background dark
)) (:foreground
"Yellow1"))
16084 (((class color
) (background dark
)) (:foreground
"Yellow")))
16085 "Face used for displaying instantiation names."
16086 :group
'speedbar-faces
)
16088 (defface vhdl-speedbar-subprogram-face
16089 '((((class color
) (background light
)) (:foreground
"Orchid4"))
16090 (((class color
) (background dark
)) (:foreground
"BurlyWood2")))
16091 "Face used for displaying subprogram names."
16092 :group
'speedbar-faces
)
16094 (defface vhdl-speedbar-entity-selected-face
16095 '((((class color
) (background light
)) (:foreground
"ForestGreen" :underline t
))
16096 (((class color
) (background dark
)) (:foreground
"PaleGreen" :underline t
)))
16097 "Face used for displaying entity names."
16098 :group
'speedbar-faces
)
16100 (defface vhdl-speedbar-architecture-selected-face
16101 '((((min-colors 88) (class color
) (background light
)) (:foreground
16102 "Blue1" :underline t
))
16103 (((class color
) (background light
)) (:foreground
"Blue" :underline t
))
16104 (((class color
) (background dark
)) (:foreground
"LightSkyBlue" :underline t
)))
16105 "Face used for displaying architecture names."
16106 :group
'speedbar-faces
)
16108 (defface vhdl-speedbar-configuration-selected-face
16109 '((((class color
) (background light
)) (:foreground
"DarkGoldenrod" :underline t
))
16110 (((class color
) (background dark
)) (:foreground
"Salmon" :underline t
)))
16111 "Face used for displaying configuration names."
16112 :group
'speedbar-faces
)
16114 (defface vhdl-speedbar-package-selected-face
16115 '((((class color
) (background light
)) (:foreground
"Grey50" :underline t
))
16116 (((class color
) (background dark
)) (:foreground
"Grey80" :underline t
)))
16117 "Face used for displaying package names."
16118 :group
'speedbar-faces
)
16120 (defface vhdl-speedbar-instantiation-selected-face
16121 '((((class color
) (background light
)) (:foreground
"Brown" :underline t
))
16122 (((class color
) (background dark
)) (:foreground
"Yellow" :underline t
)))
16123 "Face used for displaying instantiation names."
16124 :group
'speedbar-faces
)
16126 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16130 (when (fboundp 'speedbar
)
16131 (let ((current-frame (selected-frame)))
16133 (when (and vhdl-speedbar-auto-open
16134 (not (and (boundp 'speedbar-frame
)
16135 (frame-live-p speedbar-frame
))))
16136 (speedbar-frame-mode 1))
16137 (error (vhdl-warning-when-idle "ERROR: An error occurred while opening speedbar")))
16138 (select-frame current-frame
)))
16140 ;; initialize speedbar
16141 (if (not (boundp 'speedbar-frame
))
16142 (add-hook 'speedbar-load-hook
'vhdl-speedbar-initialize
)
16143 (vhdl-speedbar-initialize)
16144 (when speedbar-frame
(vhdl-speedbar-refresh)))
16147 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16148 ;;; Structural composition
16149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16151 (defun vhdl-get-components-package-name ()
16152 "Return the name of the components package."
16153 (let ((project (vhdl-project-p)))
16155 (vhdl-replace-string (car vhdl-components-package-name
)
16156 (subst-char-in-string ? ?_ project
))
16157 (cdr vhdl-components-package-name
))))
16159 (defun vhdl-compose-new-component ()
16160 "Create entity and architecture for new component."
16162 (let* ((case-fold-search t
)
16163 (ent-name (read-from-minibuffer "entity name: "
16164 nil vhdl-minibuffer-local-map
))
16166 (if (equal (cdr vhdl-compose-architecture-name
) "")
16167 (read-from-minibuffer "architecture name: "
16168 nil vhdl-minibuffer-local-map
)
16169 (vhdl-replace-string vhdl-compose-architecture-name ent-name
)))
16170 ent-file-name arch-file-name ent-buffer arch-buffer project end-pos
)
16171 (message "Creating component \"%s(%s)\"..." ent-name arch-name
)
16172 ;; open entity file
16173 (unless (eq vhdl-compose-create-files
'none
)
16174 (setq ent-file-name
16175 (concat (vhdl-replace-string vhdl-entity-file-name ent-name t
)
16176 "." (file-name-extension (buffer-file-name))))
16177 (when (and (file-exists-p ent-file-name
)
16178 (not (y-or-n-p (concat "File \"" ent-file-name
16179 "\" exists; overwrite? "))))
16180 (error "ERROR: Creating component...aborted"))
16181 (find-file ent-file-name
)
16183 (set-buffer-modified-p nil
))
16185 (if vhdl-compose-include-header
16186 (progn (vhdl-template-header)
16187 (setq end-pos
(point))
16188 (goto-char (point-max)))
16189 (vhdl-comment-display-line) (insert "\n\n"))
16190 ;; insert library clause
16191 (vhdl-template-package-std-logic-1164)
16192 (when vhdl-use-components-package
16194 (vhdl-template-standard-package (vhdl-work-library)
16195 (vhdl-get-components-package-name)))
16196 (insert "\n\n") (vhdl-comment-display-line) (insert "\n\n")
16197 ;; insert entity declaration
16198 (vhdl-insert-keyword "ENTITY ") (insert ent-name
)
16199 (vhdl-insert-keyword " IS\n")
16200 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
16201 (indent-to vhdl-basic-offset
) (vhdl-insert-keyword "GENERIC (\n")
16202 (indent-to (* 2 vhdl-basic-offset
)) (insert ");\n")
16203 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
16204 (indent-to vhdl-basic-offset
) (vhdl-insert-keyword "PORT (\n")
16205 (indent-to (* 2 vhdl-basic-offset
)) (insert ");\n")
16206 (when (memq vhdl-insert-empty-lines
'(unit all
)) (insert "\n"))
16207 (vhdl-insert-keyword "END ")
16208 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "ENTITY "))
16209 (insert ent-name
";\n\n")
16210 (vhdl-comment-display-line) (insert "\n")
16211 ;; open architecture file
16212 (if (not (eq vhdl-compose-create-files
'separate
))
16214 (goto-char (or end-pos
(point-min)))
16215 (setq ent-buffer
(current-buffer))
16216 (setq arch-file-name
16217 (concat (vhdl-replace-string vhdl-architecture-file-name
16218 (concat ent-name
" " arch-name
) t
)
16219 "." (file-name-extension (buffer-file-name))))
16220 (when (and (file-exists-p arch-file-name
)
16221 (not (y-or-n-p (concat "File \"" arch-file-name
16222 "\" exists; overwrite? "))))
16223 (error "ERROR: Creating component...aborted"))
16224 (find-file arch-file-name
)
16226 (set-buffer-modified-p nil
)
16228 (if vhdl-compose-include-header
16229 (progn (vhdl-template-header)
16230 (goto-char (point-max)))
16231 (vhdl-comment-display-line) (insert "\n\n")))
16232 ;; insert architecture body
16233 (vhdl-insert-keyword "ARCHITECTURE ") (insert arch-name
)
16234 (vhdl-insert-keyword " OF ") (insert ent-name
)
16235 (vhdl-insert-keyword " IS\n\n")
16236 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n")
16237 (indent-to vhdl-basic-offset
) (insert "-- Internal signal declarations\n")
16238 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n\n")
16239 (unless (or vhdl-use-components-package
(vhdl-use-direct-instantiation))
16240 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n")
16241 (indent-to vhdl-basic-offset
) (insert "-- Component declarations\n")
16242 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n\n"))
16243 (vhdl-insert-keyword "BEGIN")
16244 (when vhdl-self-insert-comments
16246 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "ARCHITECTURE "))
16247 (insert arch-name
))
16249 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n")
16250 (indent-to vhdl-basic-offset
) (insert "-- Component instantiations\n")
16251 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n\n")
16252 (vhdl-insert-keyword "END ")
16253 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "ARCHITECTURE "))
16254 (insert arch-name
";\n\n")
16255 ;; insert footer and save
16256 (if (and vhdl-compose-include-header
(not (equal vhdl-file-footer
"")))
16257 (vhdl-template-footer)
16258 (vhdl-comment-display-line) (insert "\n"))
16259 (goto-char (or end-pos
(point-min)))
16260 (setq arch-buffer
(current-buffer))
16261 (when ent-buffer
(set-buffer ent-buffer
) (save-buffer))
16262 (set-buffer arch-buffer
) (save-buffer)
16264 (concat (format "Creating component \"%s(%s)\"...done" ent-name arch-name
)
16266 (format "\n File created: \"%s\"" ent-file-name
))
16267 (and arch-file-name
16268 (format "\n File created: \"%s\"" arch-file-name
))))))
16270 (defun vhdl-compose-place-component ()
16271 "Place new component by pasting current port as component declaration and
16272 component instantiation."
16274 (if (not vhdl-port-list
)
16275 (error "ERROR: No port has been read")
16277 (vhdl-prepare-search-2
16278 (unless (or (re-search-backward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
16279 (re-search-forward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
))
16280 (error "ERROR: No architecture found"))
16281 (let* ((ent-name (match-string 1))
16283 (concat (vhdl-replace-string vhdl-entity-file-name ent-name t
)
16284 "." (file-name-extension (buffer-file-name))))
16285 (orig-buffer (current-buffer)))
16286 (message "Placing component \"%s\"..." (nth 0 vhdl-port-list
))
16287 ;; place component declaration
16288 (unless (or vhdl-use-components-package
16289 (vhdl-use-direct-instantiation)
16292 (concat "^\\s-*component\\s-+"
16293 (car vhdl-port-list
) "\\>") nil t
)))
16294 (re-search-forward "^begin\\>" nil
)
16295 (beginning-of-line)
16296 (skip-chars-backward " \t\n\r\f")
16297 (insert "\n\n") (indent-to vhdl-basic-offset
)
16298 (vhdl-port-paste-component t
))
16299 ;; place component instantiation
16300 (re-search-forward "^end\\>" nil
)
16301 (beginning-of-line)
16302 (skip-chars-backward " \t\n\r\f")
16303 (insert "\n\n") (indent-to vhdl-basic-offset
)
16304 (vhdl-port-paste-instance nil t t
)
16305 ;; place use clause for used packages
16306 (when (nth 3 vhdl-port-list
)
16307 ;; open entity file
16308 (when (file-exists-p ent-file-name
)
16309 (find-file ent-file-name
))
16310 (goto-char (point-min))
16311 (unless (re-search-forward (concat "^entity[ \t\n\r\f]+" ent-name
"[ \t\n\r\f]+is\\>") nil t
)
16312 (error "ERROR: Entity not found: \"%s\"" ent-name
))
16313 (goto-char (match-beginning 0))
16314 (if (and (save-excursion
16315 (re-search-backward "^\\(library\\|use\\)\\|end\\>" nil t
))
16317 (progn (goto-char (match-end 0))
16318 (beginning-of-line 2))
16321 (vhdl-port-paste-context-clause)
16322 (switch-to-buffer orig-buffer
))
16323 (message "Placing component \"%s\"...done" (nth 0 vhdl-port-list
)))))))
16325 (defun vhdl-compose-wire-components ()
16326 "Connect components."
16329 (vhdl-prepare-search-2
16330 (unless (or (re-search-backward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
)
16331 (re-search-forward "^architecture[ \t\n\r\f]+\\w+[ \t\n\r\f]+of[ \t\n\r\f]+\\(\\w+\\)[ \t\n\r\f]+is\\>" nil t
))
16332 (error "ERROR: No architecture found"))
16333 (let* ((ent-name (match-string 1))
16335 (concat (vhdl-replace-string vhdl-entity-file-name ent-name t
)
16336 "." (file-name-extension (buffer-file-name))))
16337 (arch-decl-pos (point-marker))
16338 (arch-stat-pos (re-search-forward "^begin\\>" nil
))
16339 (arch-end-pos (re-search-forward "^end\\>" nil
))
16340 (pack-name (vhdl-get-components-package-name))
16342 (concat (vhdl-replace-string vhdl-package-file-name pack-name t
)
16343 "." (file-name-extension (buffer-file-name))))
16344 inst-name comp-name comp-ent-name comp-ent-file-name has-generic
16345 port-alist generic-alist inst-alist
16346 signal-name signal-entry signal-alist local-list written-list
16347 single-in-list multi-in-list single-out-list multi-out-list
16348 constant-name constant-entry constant-alist single-list multi-list
16349 port-beg-pos port-in-pos port-out-pos port-inst-pos port-end-pos
16350 generic-beg-pos generic-pos generic-inst-pos generic-end-pos
16351 signal-beg-pos signal-pos
16352 constant-temp-pos port-temp-pos signal-temp-pos
)
16353 (message "Wiring components...")
16354 ;; process all instances
16355 (goto-char arch-stat-pos
)
16356 (while (re-search-forward
16357 (concat "^[ \t]*\\(\\w+\\)[ \t\n\r\f]*:[ \t\n\r\f]*\\("
16358 "\\(component[ \t\n\r\f]+\\)?\\(\\w+\\)"
16359 "[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n\r\f]+map\\|"
16360 "\\(\\(entity\\)\\|configuration\\)[ \t\n\r\f]+\\(\\(\\w+\\)\\.\\)?\\(\\w+\\)\\([ \t\n\r\f]*(\\(\\w+\\))\\)?"
16361 "[ \t\n\r\f]+\\(--[^\n]*\n[ \t\n\r\f]*\\)*\\(\\(generic\\)\\|port\\)[ \t\n\r\f]+map\\)[ \t\n\r\f]*(") arch-end-pos t
)
16362 (setq inst-name
(match-string-no-properties 1)
16363 comp-name
(match-string-no-properties 4)
16364 comp-ent-name
(match-string-no-properties 12)
16365 has-generic
(or (match-string 7) (match-string 17)))
16368 ;; ... from component declaration
16370 (when vhdl-use-components-package pack-file-name
) t
16372 (goto-char (point-min))
16373 (unless (re-search-forward (concat "^\\s-*component[ \t\n\r\f]+" comp-name
"\\>") nil t
)
16374 (error "ERROR: Component declaration not found: \"%s\"" comp-name
))
16376 ;; ... from entity declaration (direct instantiation)
16377 (setq comp-ent-file-name
16378 (concat (vhdl-replace-string vhdl-entity-file-name comp-ent-name t
)
16379 "." (file-name-extension (buffer-file-name))))
16381 comp-ent-file-name t
16383 (goto-char (point-min))
16384 (unless (re-search-forward (concat "^\\s-*entity[ \t\n\r\f]+" comp-ent-name
"\\>") nil t
)
16385 (error "ERROR: Entity declaration not found: \"%s\"" comp-ent-name
))
16386 (vhdl-port-copy))))
16387 (vhdl-port-flatten t
)
16388 (setq generic-alist
(nth 1 vhdl-port-list
)
16389 port-alist
(nth 2 vhdl-port-list
)
16390 vhdl-port-list nil
)
16391 (setq constant-alist nil
16394 ;; process all constants in generic map
16395 (vhdl-forward-syntactic-ws)
16396 (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n\r\f]*=>[ \t\n\r\f]*\\)?\\(\\w+\\),?" t
)
16397 (setq constant-name
(match-string-no-properties 3))
16398 (setq constant-entry
16399 (cons constant-name
16400 (if (match-string 1)
16401 (or (vhdl-aget generic-alist
(match-string 2))
16402 (error "ERROR: Formal generic \"%s\" mismatch for instance \"%s\"" (match-string 2) inst-name
))
16403 (cdar generic-alist
))))
16404 (push constant-entry constant-alist
)
16405 (setq constant-name
(downcase constant-name
))
16406 (if (or (member constant-name single-list
)
16407 (member constant-name multi-list
))
16408 (progn (setq single-list
(delete constant-name single-list
))
16409 (add-to-list 'multi-list constant-name
))
16410 (add-to-list 'single-list constant-name
))
16411 (unless (match-string 1)
16412 (setq generic-alist
(cdr generic-alist
)))
16413 (vhdl-forward-syntactic-ws))
16414 (vhdl-re-search-forward "\\<port\\s-+map[ \t\n\r\f]*(" nil t
))
16415 ;; process all signals in port map
16416 (vhdl-forward-syntactic-ws)
16417 (while (vhdl-parse-string "\\(\\(\\w+\\)[ \t\n\r\f]*=>[ \t\n\r\f]*\\)?\\(\\w+\\),?" t
)
16418 (setq signal-name
(match-string-no-properties 3))
16421 (if (match-string 1)
16422 (or (vhdl-aget port-alist
(match-string 2))
16423 (error "ERROR: Formal port \"%s\" mismatch for instance \"%s\"" (match-string 2) inst-name
))
16424 (cdar port-alist
))))
16425 (push signal-entry signal-alist
)
16426 (setq signal-name
(downcase signal-name
))
16427 (if (equal (upcase (nth 2 signal-entry
)) "IN")
16430 ((member signal-name local-list
)
16432 ((or (member signal-name single-out-list
)
16433 (member signal-name multi-out-list
))
16434 (setq single-out-list
(delete signal-name single-out-list
))
16435 (setq multi-out-list
(delete signal-name multi-out-list
))
16436 (add-to-list 'local-list signal-name
))
16437 ((member signal-name single-in-list
)
16438 (setq single-in-list
(delete signal-name single-in-list
))
16439 (add-to-list 'multi-in-list signal-name
))
16440 ((not (member signal-name multi-in-list
))
16441 (add-to-list 'single-in-list signal-name
)))
16444 ((member signal-name local-list
)
16446 ((or (member signal-name single-in-list
)
16447 (member signal-name multi-in-list
))
16448 (setq single-in-list
(delete signal-name single-in-list
))
16449 (setq multi-in-list
(delete signal-name multi-in-list
))
16450 (add-to-list 'local-list signal-name
))
16451 ((member signal-name single-out-list
)
16452 (setq single-out-list
(delete signal-name single-out-list
))
16453 (add-to-list 'multi-out-list signal-name
))
16454 ((not (member signal-name multi-out-list
))
16455 (add-to-list 'single-out-list signal-name
))))
16456 (unless (match-string 1)
16457 (setq port-alist
(cdr port-alist
)))
16458 (vhdl-forward-syntactic-ws))
16459 (push (list inst-name
(nreverse constant-alist
)
16460 (nreverse signal-alist
)) inst-alist
))
16461 ;; prepare signal insertion
16462 (vhdl-goto-marker arch-decl-pos
)
16464 (re-search-forward "^\\s-*-- Internal signal declarations[ \t\n\r\f]*-*\n" arch-stat-pos t
)
16465 (setq signal-pos
(point-marker))
16466 (while (progn (vhdl-forward-syntactic-ws)
16467 (looking-at "signal\\>"))
16468 (beginning-of-line 2)
16469 (delete-region signal-pos
(point)))
16470 (setq signal-beg-pos signal-pos
)
16471 ;; open entity file
16472 (when (file-exists-p ent-file-name
)
16473 (find-file ent-file-name
))
16474 (goto-char (point-min))
16475 (unless (re-search-forward (concat "^entity[ \t\n\r\f]+" ent-name
"[ \t\n\r\f]+is\\>") nil t
)
16476 (error "ERROR: Entity not found: \"%s\"" ent-name
))
16477 ;; prepare generic clause insertion
16478 (unless (and (re-search-forward "\\(^\\s-*generic[ \t\n\r\f]*(\\)\\|^end\\>" nil t
)
16480 (goto-char (match-beginning 0))
16481 (indent-to vhdl-basic-offset
)
16482 (insert "generic ();\n\n")
16485 (setq generic-pos
(point-marker))
16486 (forward-sexp) (end-of-line)
16487 (delete-region generic-pos
(point)) (delete-char 1)
16491 (indent-to (* 2 vhdl-basic-offset
))
16492 (insert "-- global generics\n"))
16493 (setq generic-beg-pos
(point-marker) generic-pos
(point-marker)
16494 generic-inst-pos
(point-marker) generic-end-pos
(point-marker))
16495 ;; prepare port clause insertion
16496 (unless (and (re-search-forward "\\(^\\s-*port[ \t\n\r\f]*(\\)\\|^end\\>" nil t
)
16498 (goto-char (match-beginning 0))
16499 (indent-to vhdl-basic-offset
)
16500 (insert "port ();\n\n")
16503 (setq port-in-pos
(point-marker))
16504 (forward-sexp) (end-of-line)
16505 (delete-region port-in-pos
(point)) (delete-char 1)
16507 (when (or multi-in-list multi-out-list
)
16509 (indent-to (* 2 vhdl-basic-offset
))
16510 (insert "-- global ports\n"))
16511 (setq port-beg-pos
(point-marker) port-in-pos
(point-marker)
16512 port-out-pos
(point-marker) port-inst-pos
(point-marker)
16513 port-end-pos
(point-marker))
16514 ;; insert generics, ports and signals
16515 (setq inst-alist
(nreverse inst-alist
))
16517 (setq inst-name
(nth 0 (car inst-alist
))
16518 constant-alist
(nth 1 (car inst-alist
))
16519 signal-alist
(nth 2 (car inst-alist
))
16520 constant-temp-pos generic-inst-pos
16521 port-temp-pos port-inst-pos
16522 signal-temp-pos signal-pos
)
16524 (while constant-alist
16525 (setq constant-name
(downcase (caar constant-alist
))
16526 constant-entry
(car constant-alist
))
16527 (unless (string-match "^[0-9]+" constant-name
)
16528 (cond ((member constant-name written-list
)
16530 ((member constant-name multi-list
)
16531 (vhdl-goto-marker generic-pos
)
16532 (setq generic-end-pos
16535 (vhdl-compose-insert-generic constant-entry
)))
16536 (setq generic-pos
(point-marker))
16537 (add-to-list 'written-list constant-name
))
16540 (vhdl-max-marker generic-inst-pos generic-pos
))
16541 (setq generic-end-pos
16542 (vhdl-compose-insert-generic constant-entry
))
16543 (setq generic-inst-pos
(point-marker))
16544 (add-to-list 'written-list constant-name
))))
16545 (setq constant-alist
(cdr constant-alist
)))
16546 (when (/= constant-temp-pos generic-inst-pos
)
16547 (vhdl-goto-marker (vhdl-max-marker constant-temp-pos generic-pos
))
16548 (insert "\n") (indent-to (* 2 vhdl-basic-offset
))
16549 (insert "-- generics for \"" inst-name
"\"\n")
16550 (vhdl-goto-marker generic-inst-pos
))
16551 ;; ports and signals
16552 (while signal-alist
16553 (setq signal-name
(downcase (caar signal-alist
))
16554 signal-entry
(car signal-alist
))
16555 (cond ((member signal-name written-list
)
16557 ((member signal-name multi-in-list
)
16558 (vhdl-goto-marker port-in-pos
)
16561 port-end-pos
(vhdl-compose-insert-port signal-entry
)))
16562 (setq port-in-pos
(point-marker))
16563 (add-to-list 'written-list signal-name
))
16564 ((member signal-name multi-out-list
)
16565 (vhdl-goto-marker (vhdl-max-marker port-out-pos port-in-pos
))
16568 port-end-pos
(vhdl-compose-insert-port signal-entry
)))
16569 (setq port-out-pos
(point-marker))
16570 (add-to-list 'written-list signal-name
))
16571 ((or (member signal-name single-in-list
)
16572 (member signal-name single-out-list
))
16576 (vhdl-max-marker port-out-pos port-in-pos
)))
16577 (setq port-end-pos
(vhdl-compose-insert-port signal-entry
))
16578 (setq port-inst-pos
(point-marker))
16579 (add-to-list 'written-list signal-name
))
16580 ((equal (upcase (nth 2 signal-entry
)) "OUT")
16581 (vhdl-goto-marker signal-pos
)
16582 (vhdl-compose-insert-signal signal-entry
)
16583 (setq signal-pos
(point-marker))
16584 (add-to-list 'written-list signal-name
)))
16585 (setq signal-alist
(cdr signal-alist
)))
16586 (when (/= port-temp-pos port-inst-pos
)
16588 (vhdl-max-marker port-temp-pos
16589 (vhdl-max-marker port-in-pos port-out-pos
)))
16590 (insert "\n") (indent-to (* 2 vhdl-basic-offset
))
16591 (insert "-- ports to \"" inst-name
"\"\n")
16592 (vhdl-goto-marker port-inst-pos
))
16593 (when (/= signal-temp-pos signal-pos
)
16594 (vhdl-goto-marker signal-temp-pos
)
16595 (insert "\n") (indent-to vhdl-basic-offset
)
16596 (insert "-- outputs of \"" inst-name
"\"\n")
16597 (vhdl-goto-marker signal-pos
))
16598 (setq inst-alist
(cdr inst-alist
)))
16599 ;; finalize generic/port clause
16600 (vhdl-goto-marker generic-end-pos
) (backward-char)
16601 (when (= generic-beg-pos generic-end-pos
)
16602 (insert "\n") (indent-to (* 2 vhdl-basic-offset
))
16603 (insert ";") (backward-char))
16605 (vhdl-goto-marker port-end-pos
) (backward-char)
16606 (when (= port-beg-pos port-end-pos
)
16607 (insert "\n") (indent-to (* 2 vhdl-basic-offset
))
16608 (insert ";") (backward-char))
16610 ;; align everything
16611 (when vhdl-auto-align
16612 (vhdl-goto-marker generic-beg-pos
)
16613 (vhdl-align-region-groups generic-beg-pos generic-end-pos
1)
16614 (vhdl-align-region-groups port-beg-pos port-end-pos
1)
16615 (vhdl-goto-marker signal-beg-pos
)
16616 (vhdl-align-region-groups signal-beg-pos signal-pos
))
16617 (switch-to-buffer (marker-buffer signal-beg-pos
))
16618 (message "Wiring components...done")))))
16620 (defun vhdl-compose-insert-generic (entry)
16621 "Insert ENTRY as generic declaration."
16623 (indent-to (* 2 vhdl-basic-offset
))
16624 (insert (nth 0 entry
) " : " (nth 1 entry
))
16625 (when (nth 2 entry
)
16626 (insert " := " (nth 2 entry
)))
16628 (setq pos
(point-marker))
16629 (when (and vhdl-include-port-comments
(nth 3 entry
))
16630 (vhdl-comment-insert-inline (nth 3 entry
) t
))
16634 (defun vhdl-compose-insert-port (entry)
16635 "Insert ENTRY as port declaration."
16637 (indent-to (* 2 vhdl-basic-offset
))
16638 (insert (nth 0 entry
) " : " (nth 2 entry
) " " (nth 3 entry
) ";")
16639 (setq pos
(point-marker))
16640 (when (and vhdl-include-port-comments
(nth 4 entry
))
16641 (vhdl-comment-insert-inline (nth 4 entry
) t
))
16645 (defun vhdl-compose-insert-signal (entry)
16646 "Insert ENTRY as signal declaration."
16647 (indent-to vhdl-basic-offset
)
16648 (insert "signal " (nth 0 entry
) " : " (nth 3 entry
) ";")
16649 (when (and vhdl-include-port-comments
(nth 4 entry
))
16650 (vhdl-comment-insert-inline (nth 4 entry
) t
))
16653 (defun vhdl-compose-components-package ()
16654 "Generate a package containing component declarations for all entities in the
16655 current project/directory."
16657 (vhdl-require-hierarchy-info)
16658 (let* ((project (vhdl-project-p))
16659 (pack-name (vhdl-get-components-package-name))
16661 (concat (vhdl-replace-string vhdl-package-file-name pack-name t
)
16662 "." (file-name-extension (buffer-file-name))))
16663 (ent-alist (vhdl-aget vhdl-entity-alist
16665 (abbreviate-file-name default-directory
))))
16666 (lazy-lock-minimum-size 0)
16667 clause-pos component-pos
)
16668 (message "Generating components package \"%s\"..." pack-name
)
16669 ;; open package file
16670 (when (and (file-exists-p pack-file-name
)
16671 (not (y-or-n-p (concat "File \"" pack-file-name
16672 "\" exists; overwrite? "))))
16673 (error "ERROR: Generating components package...aborted"))
16674 (find-file pack-file-name
)
16677 (if vhdl-compose-include-header
16678 (progn (vhdl-template-header
16679 (concat "Components package (generated by Emacs VHDL Mode "
16681 (goto-char (point-max)))
16682 (vhdl-comment-display-line) (insert "\n\n"))
16683 ;; insert std_logic_1164 package
16684 (vhdl-template-package-std-logic-1164)
16685 (insert "\n") (setq clause-pos
(point-marker))
16686 (insert "\n") (vhdl-comment-display-line) (insert "\n\n")
16687 ;; insert package declaration
16688 (vhdl-insert-keyword "PACKAGE ") (insert pack-name
)
16689 (vhdl-insert-keyword " IS\n\n")
16690 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n")
16691 (indent-to vhdl-basic-offset
) (insert "-- Component declarations\n")
16692 (indent-to vhdl-basic-offset
) (vhdl-comment-display-line) (insert "\n\n")
16693 (indent-to vhdl-basic-offset
)
16694 (setq component-pos
(point-marker))
16695 (insert "\n\n") (vhdl-insert-keyword "END ")
16696 (unless (vhdl-standard-p '87) (vhdl-insert-keyword "PACKAGE "))
16697 (insert pack-name
";\n\n")
16699 (if (and vhdl-compose-include-header
(not (equal vhdl-file-footer
"")))
16700 (vhdl-template-footer)
16701 (vhdl-comment-display-line) (insert "\n"))
16702 ;; insert component declarations
16704 (vhdl-visit-file (nth 2 (car ent-alist
)) nil
16705 (progn (goto-char (point-min))
16706 (forward-line (1- (nth 3 (car ent-alist
))))
16709 (goto-char component-pos
)
16710 (vhdl-port-paste-component t
)
16711 (when (cdr ent-alist
) (insert "\n\n") (indent-to vhdl-basic-offset
))
16712 (setq component-pos
(point-marker))
16713 (goto-char clause-pos
)
16714 (vhdl-port-paste-context-clause pack-name
)
16715 (setq clause-pos
(point-marker))
16716 (setq ent-alist
(cdr ent-alist
)))
16717 (goto-char (point-min))
16719 (message "Generating components package \"%s\"...done\n File created: \"%s\""
16720 pack-name pack-file-name
)))
16722 (defun vhdl-compose-configuration-architecture (ent-name arch-name ent-alist
16723 conf-alist inst-alist
16724 &optional insert-conf
)
16725 "Generate block configuration for architecture."
16726 (let ((margin (current-indentation))
16727 (beg (point-at-bol))
16728 ent-entry inst-entry inst-path inst-prev-path cons-key tmp-alist
)
16729 ;; insert block configuration (for architecture)
16730 (vhdl-insert-keyword "FOR ") (insert arch-name
"\n")
16731 (setq margin
(+ margin vhdl-basic-offset
))
16732 ;; process all instances
16734 (setq inst-entry
(car inst-alist
))
16736 (when (nth 4 inst-entry
)
16737 (setq insert-conf t
)
16738 (setq inst-path
(nth 9 inst-entry
))
16739 ;; skip common path with previous instance
16740 (while (and inst-path
(equal (car inst-path
) (car inst-prev-path
)))
16741 (setq inst-path
(cdr inst-path
)
16742 inst-prev-path
(cdr inst-prev-path
)))
16743 ;; insert block configuration end (for previous block/generate)
16744 (while inst-prev-path
16745 (setq margin
(- margin vhdl-basic-offset
))
16747 (vhdl-insert-keyword "END FOR;\n")
16748 (setq inst-prev-path
(cdr inst-prev-path
)))
16749 ;; insert block configuration beginning (for current block/generate)
16752 (setq margin
(+ margin vhdl-basic-offset
))
16753 (vhdl-insert-keyword "FOR ")
16754 (insert (car inst-path
) "\n")
16756 (setq inst-path
(cdr inst-path
)))
16757 ;; insert component configuration beginning
16758 (vhdl-insert-keyword "FOR ")
16759 (insert (nth 1 inst-entry
) " : " (nth 4 inst-entry
) "\n")
16760 ;; find subconfiguration
16761 (setq conf-key
(nth 7 inst-entry
))
16762 (setq tmp-alist conf-alist
)
16763 ;; use first configuration found for instance's entity
16764 (while (and tmp-alist
(null conf-key
))
16765 (when (equal (nth 5 inst-entry
) (nth 4 (car tmp-alist
)))
16766 (setq conf-key
(nth 0 (car tmp-alist
))))
16767 (setq tmp-alist
(cdr tmp-alist
)))
16768 (setq conf-entry
(vhdl-aget conf-alist conf-key
))
16769 ;; insert binding indication ...
16770 ;; ... with subconfiguration (if exists)
16771 (if (and vhdl-compose-configuration-use-subconfiguration conf-entry
)
16773 (indent-to (+ margin vhdl-basic-offset
))
16774 (vhdl-insert-keyword "USE CONFIGURATION ")
16775 (insert (vhdl-work-library) "." (nth 0 conf-entry
))
16777 ;; ... with entity (if exists)
16778 (setq ent-entry
(vhdl-aget ent-alist
(nth 5 inst-entry
)))
16780 (indent-to (+ margin vhdl-basic-offset
))
16781 (vhdl-insert-keyword "USE ENTITY ")
16782 (insert (vhdl-work-library) "." (nth 0 ent-entry
))
16783 ;; insert architecture name (if architecture exists)
16784 (when (nth 3 ent-entry
)
16786 ;; choose architecture name a) from configuration,
16787 ;; b) from mra, or c) from first architecture
16788 (or (nth 0 (vhdl-aget (nth 3 ent-entry
)
16789 (or (nth 6 inst-entry
)
16790 (nth 4 ent-entry
))))
16791 (nth 1 (car (nth 3 ent-entry
)))))
16792 (insert "(" arch-name
")"))
16794 ;; insert block configuration (for architecture of subcomponent)
16795 (when (and vhdl-compose-configuration-hierarchical
16797 (indent-to (+ margin vhdl-basic-offset
))
16798 (vhdl-compose-configuration-architecture
16799 (nth 0 ent-entry
) arch-name ent-alist conf-alist
16800 (nth 3 (vhdl-aget (nth 3 ent-entry
) (downcase arch-name
)))))))
16801 ;; insert component configuration end
16803 (vhdl-insert-keyword "END FOR;\n")
16804 (setq inst-prev-path
(nth 9 inst-entry
)))
16805 (setq inst-alist
(cdr inst-alist
)))
16806 ;; insert block configuration end (for block/generate)
16807 (while inst-prev-path
16808 (setq margin
(- margin vhdl-basic-offset
))
16810 (vhdl-insert-keyword "END FOR;\n")
16811 (setq inst-prev-path
(cdr inst-prev-path
)))
16812 (indent-to (- margin vhdl-basic-offset
))
16813 ;; insert block configuration end or remove beginning (for architecture)
16815 (vhdl-insert-keyword "END FOR;\n")
16816 (delete-region beg
(point)))))
16818 (defun vhdl-compose-configuration (&optional ent-name arch-name
)
16819 "Generate configuration declaration."
16821 (vhdl-require-hierarchy-info)
16822 (let ((ent-alist (vhdl-aget vhdl-entity-alist
16823 (or (vhdl-project-p)
16824 (abbreviate-file-name default-directory
))))
16825 (conf-alist (vhdl-aget vhdl-config-alist
16826 (or (vhdl-project-p)
16827 (abbreviate-file-name default-directory
))))
16828 (from-speedbar ent-name
)
16829 inst-alist conf-name conf-file-name pos
)
16830 (vhdl-prepare-search-2
16831 ;; get entity and architecture name
16834 (unless (and (re-search-backward "^\\(architecture\\s-+\\(\\w+\\)\\s-+of\\s-+\\(\\w+\\)\\|end\\)\\>" nil t
)
16835 (not (equal "END" (upcase (match-string 1))))
16836 (setq ent-name
(match-string-no-properties 3))
16837 (setq arch-name
(match-string-no-properties 2)))
16838 (error "ERROR: Not within an architecture"))))
16839 (setq conf-name
(vhdl-replace-string
16840 vhdl-compose-configuration-name
16841 (concat ent-name
" " arch-name
)))
16843 (nth 3 (vhdl-aget (nth 3 (vhdl-aget ent-alist
(downcase ent-name
)))
16844 (downcase arch-name
)))))
16845 (message "Generating configuration \"%s\"..." conf-name
)
16846 (if vhdl-compose-configuration-create-file
16847 ;; open configuration file
16849 (setq conf-file-name
16850 (concat (vhdl-replace-string vhdl-configuration-file-name
16852 "." (file-name-extension (buffer-file-name))))
16853 (when (and (file-exists-p conf-file-name
)
16854 (not (y-or-n-p (concat "File \"" conf-file-name
16855 "\" exists; overwrite? "))))
16856 (error "ERROR: Creating configuration...aborted"))
16857 (find-file conf-file-name
)
16859 (set-buffer-modified-p nil
)
16861 (if vhdl-compose-include-header
16862 (progn (vhdl-template-header
16863 (concat "Configuration declaration for design \""
16864 ent-name
"(" arch-name
")\""))
16865 (goto-char (point-max)))
16866 (vhdl-comment-display-line) (insert "\n\n")))
16867 ;; goto end of architecture
16868 (unless from-speedbar
16869 (re-search-forward "^end\\>" nil
)
16870 (end-of-line) (insert "\n\n")
16871 (vhdl-comment-display-line) (insert "\n\n")))
16872 ;; insert library clause
16874 (vhdl-template-standard-package (vhdl-work-library) nil
)
16875 (when (/= pos
(point))
16877 ;; insert configuration
16878 (vhdl-insert-keyword "CONFIGURATION ") (insert conf-name
)
16879 (vhdl-insert-keyword " OF ") (insert ent-name
)
16880 (vhdl-insert-keyword " IS\n")
16881 (indent-to vhdl-basic-offset
)
16882 ;; insert block configuration (for architecture)
16883 (vhdl-compose-configuration-architecture
16884 ent-name arch-name ent-alist conf-alist inst-alist t
)
16885 (vhdl-insert-keyword "END ") (insert conf-name
";")
16886 (when conf-file-name
16887 ;; insert footer and save
16889 (if (and vhdl-compose-include-header
(not (equal vhdl-file-footer
"")))
16890 (vhdl-template-footer)
16891 (vhdl-comment-display-line) (insert "\n"))
16894 (concat (format "Generating configuration \"%s\"...done" conf-name
)
16895 (and conf-file-name
16896 (format "\n File created: \"%s\"" conf-file-name
))))))
16899 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16900 ;;; Compilation / Makefile generation
16901 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16902 ;; (using `compile.el')
16904 (defvar vhdl-compile-post-command
""
16905 "String appended to compile command after file name.")
16907 (defun vhdl-makefile-name ()
16908 "Return the Makefile name of the current project or the current compiler if
16909 no project is defined."
16910 (let ((project-alist (vhdl-aget vhdl-project-alist vhdl-project
))
16911 (compiler-alist (vhdl-aget vhdl-compiler-alist vhdl-compiler
)))
16912 (vhdl-replace-string
16913 (cons "\\(.*\\)\n\\(.*\\)"
16914 (or (nth 8 project-alist
) (nth 8 compiler-alist
)))
16915 (concat (nth 9 compiler-alist
) "\n" (nth 6 project-alist
)))))
16917 (defun vhdl-compile-directory ()
16918 "Return the directory where compilation/make should be run."
16919 (let* ((project (vhdl-aget vhdl-project-alist
(vhdl-project-p t
)))
16920 (compiler (vhdl-aget vhdl-compiler-alist vhdl-compiler
))
16921 (directory (vhdl-resolve-env-variable
16923 (vhdl-replace-string
16924 (cons "\\(.*\\)" (nth 5 project
)) (nth 9 compiler
))
16925 (nth 6 compiler
)))))
16926 (file-name-as-directory
16927 (if (file-name-absolute-p directory
)
16929 (expand-file-name directory
(vhdl-default-directory))))))
16931 (defun vhdl-uniquify (in-list)
16932 "Remove duplicate elements from IN-LIST."
16935 (add-to-list 'out-list
(car in-list
))
16936 (setq in-list
(cdr in-list
)))
16939 (defun vhdl-set-compiler (name)
16940 "Set current compiler to NAME."
16942 (list (let ((completion-ignore-case t
))
16943 (completing-read "Compiler name: " vhdl-compiler-alist nil t
))))
16944 (if (assoc name vhdl-compiler-alist
)
16945 (progn (setq vhdl-compiler name
)
16946 (message "Current compiler: \"%s\"" vhdl-compiler
))
16947 (vhdl-warning (format "Unknown compiler: \"%s\"" name
))))
16949 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16952 (defun vhdl-compile-init ()
16953 "Initialize for compilation."
16954 (when (and (not vhdl-emacs-22
)
16955 (or (null compilation-error-regexp-alist
)
16956 (not (assoc (car (nth 11 (car vhdl-compiler-alist
)))
16957 compilation-error-regexp-alist
))))
16958 ;; `compilation-error-regexp-alist'
16959 (let ((commands-alist vhdl-compiler-alist
)
16960 regexp-alist sublist
)
16961 (while commands-alist
16962 (setq sublist
(nth 11 (car commands-alist
)))
16963 (unless (or (equal "" (car sublist
))
16964 (assoc (car sublist
) regexp-alist
))
16965 (push (list (nth 0 sublist
)
16966 (if (and (featurep 'xemacs
) (not (nth 1 sublist
)))
16969 (nth 2 sublist
) (nth 3 sublist
))
16971 (setq commands-alist
(cdr commands-alist
)))
16972 (setq compilation-error-regexp-alist
16973 (append compilation-error-regexp-alist
(nreverse regexp-alist
))))
16974 ;; `compilation-file-regexp-alist'
16975 (let ((commands-alist vhdl-compiler-alist
)
16976 regexp-alist sublist
)
16977 ;; matches vhdl-mode file name output
16978 (setq regexp-alist
'(("^Compiling \"\\(.+\\)\"" 1)))
16979 (while commands-alist
16980 (setq sublist
(nth 12 (car commands-alist
)))
16981 (unless (or (equal "" (car sublist
))
16982 (assoc (car sublist
) regexp-alist
))
16983 (push sublist regexp-alist
))
16984 (setq commands-alist
(cdr commands-alist
)))
16985 (setq compilation-file-regexp-alist
16986 (append compilation-file-regexp-alist
(nreverse regexp-alist
))))))
16988 (defvar vhdl-compile-file-name nil
16989 "Name of file to be compiled.")
16991 (defun vhdl-compile-print-file-name ()
16992 "Function called within `compile' to print out file name for compilers that
16993 do not print any file names."
16994 (insert "Compiling \"" vhdl-compile-file-name
"\"\n"))
16996 (defun vhdl-get-compile-options (project compiler file-name
16997 &optional file-options-only
)
16998 "Get compiler options. Returning nil means do not compile this file."
16999 (let* ((compiler-options (nth 1 compiler
))
17000 (project-entry (vhdl-aget (nth 4 project
) vhdl-compiler
))
17001 (project-options (nth 0 project-entry
))
17002 (exception-list (and file-name
(nth 2 project-entry
)))
17003 (work-library (vhdl-work-library))
17004 (case-fold-search nil
)
17006 (while (and exception-list
17007 (not (string-match (caar exception-list
) file-name
)))
17008 (setq exception-list
(cdr exception-list
)))
17009 (if (and exception-list
(not (cdar exception-list
)))
17011 (if (and file-options-only
(not exception-list
))
17013 (setq file-options
(cdar exception-list
))
17014 ;; insert library name in compiler-specific options
17015 (setq compiler-options
17016 (vhdl-replace-string (cons "\\(.*\\)" compiler-options
)
17018 ;; insert compiler-specific options in project-specific options
17019 (when project-options
17020 (setq project-options
17021 (vhdl-replace-string
17022 (cons "\\(.*\\)\n\\(.*\\)" project-options
)
17023 (concat work-library
"\n" compiler-options
))))
17024 ;; insert project-specific options in file-specific options
17027 (vhdl-replace-string
17028 (cons "\\(.*\\)\n\\(.*\\)\n\\(.*\\)" file-options
)
17029 (concat work-library
"\n" compiler-options
"\n"
17030 project-options
))))
17032 (or file-options project-options compiler-options
)))))
17034 (defun vhdl-get-make-options (project compiler
)
17035 "Get make options."
17036 (let* ((compiler-options (nth 3 compiler
))
17037 (project-entry (vhdl-aget (nth 4 project
) vhdl-compiler
))
17038 (project-options (nth 1 project-entry
))
17039 (makefile-name (vhdl-makefile-name)))
17040 ;; insert Makefile name in compiler-specific options
17041 (setq compiler-options
17042 (vhdl-replace-string (cons "\\(.*\\)" (nth 3 compiler
))
17044 ;; insert compiler-specific options in project-specific options
17045 (when project-options
17046 (setq project-options
17047 (vhdl-replace-string
17048 (cons "\\(.*\\)\n\\(.*\\)" project-options
)
17049 (concat makefile-name
"\n" compiler-options
))))
17051 (or project-options compiler-options
)))
17053 (defun vhdl-compile ()
17054 "Compile current buffer using the VHDL compiler specified in
17057 (vhdl-compile-init)
17058 (let* ((project (vhdl-aget vhdl-project-alist vhdl-project
))
17059 (compiler (or (vhdl-aget vhdl-compiler-alist vhdl-compiler
)
17060 (error "ERROR: No such compiler: \"%s\"" vhdl-compiler
)))
17061 (command (nth 0 compiler
))
17062 (default-directory (vhdl-compile-directory))
17063 (file-name (if vhdl-compile-absolute-path
17065 (file-relative-name (buffer-file-name))))
17066 (options (vhdl-get-compile-options project compiler file-name
))
17067 compilation-process-setup-function
)
17068 (unless (file-directory-p default-directory
)
17069 (error "ERROR: Compile directory does not exist: \"%s\"" default-directory
))
17070 ;; put file name into quotes if it contains spaces
17071 (when (string-match " " file-name
)
17072 (setq file-name
(concat "\"" file-name
"\"")))
17073 ;; print out file name if compiler does not
17074 (setq vhdl-compile-file-name
(if vhdl-compile-absolute-path
17076 (file-relative-name (buffer-file-name))))
17077 (when (and (= 0 (nth 1 (nth 10 compiler
)))
17078 (= 0 (nth 1 (nth 11 compiler
))))
17079 (setq compilation-process-setup-function
'vhdl-compile-print-file-name
))
17083 (compile (concat command
" " options
" " file-name
17084 (unless (equal vhdl-compile-post-command
"")
17085 (concat " " vhdl-compile-post-command
)))))
17086 (vhdl-warning "Your project settings tell me not to compile this file"))))
17088 (defvar vhdl-make-target
"all"
17089 "Default target for `vhdl-make' command.")
17091 (defun vhdl-make (&optional target
)
17092 "Call make command for compilation of all updated source files (requires
17093 `Makefile'). Optional argument TARGET allows you to compile the design
17094 specified by a target."
17096 (setq vhdl-make-target
17097 (or target
(read-from-minibuffer "Target: " vhdl-make-target
17098 vhdl-minibuffer-local-map
)))
17099 (vhdl-compile-init)
17100 (let* ((project (vhdl-aget vhdl-project-alist vhdl-project
))
17101 (compiler (or (vhdl-aget vhdl-compiler-alist vhdl-compiler
)
17102 (error "ERROR: No such compiler: \"%s\"" vhdl-compiler
)))
17103 (command (nth 2 compiler
))
17104 (options (vhdl-get-make-options project compiler
))
17105 (default-directory (vhdl-compile-directory)))
17106 (unless (file-directory-p default-directory
)
17107 (error "ERROR: Compile directory does not exist: \"%s\"" default-directory
))
17109 (compile (concat (if (equal command
"") "make" command
)
17110 " " options
" " vhdl-make-target
))))
17113 (defvar vhdl-error-regexp-emacs-alist
17114 ;; Get regexps from `vhdl-compiler-alist'
17115 (let ((compiler-alist vhdl-compiler-alist
)
17116 (error-regexp-alist '((vhdl-directory "^ *Compiling \"\\(.+\\)\"" 1))))
17117 (while compiler-alist
17118 ;; only add regexps for currently selected compiler
17119 (when (or (not vhdl-compile-use-local-error-regexp
)
17120 (equal vhdl-compiler
(nth 0 (car compiler-alist
))))
17121 ;; add error message regexps
17122 (setq error-regexp-alist
17123 (cons (append (list (make-symbol (concat "vhdl-" (subst-char-in-string ? ?-
(downcase (nth 0 (car compiler-alist
)))))))
17124 (nth 11 (car compiler-alist
)))
17125 error-regexp-alist
))
17126 ;; add filename regexps
17127 (when (/= 0 (nth 1 (nth 12 (car compiler-alist
))))
17128 (setq error-regexp-alist
17129 (cons (append (list (make-symbol (concat "vhdl-" (subst-char-in-string ? ?-
(downcase (nth 0 (car compiler-alist
)))) "-file")))
17130 (nth 12 (car compiler-alist
)))
17131 error-regexp-alist
))))
17132 (setq compiler-alist
(cdr compiler-alist
)))
17133 error-regexp-alist
)
17134 "List of regexps for VHDL compilers. For Emacs 22+.")
17136 ;; Add error regexps using compilation-mode-hook.
17137 (defun vhdl-error-regexp-add-emacs ()
17138 "Set up Emacs compile for VHDL."
17140 (when (and (boundp 'compilation-error-regexp-alist-alist
)
17141 (not (assoc 'vhdl-modelsim compilation-error-regexp-alist-alist
)))
17142 ;; remove all other compilers
17143 (when vhdl-compile-use-local-error-regexp
17144 (setq compilation-error-regexp-alist nil
))
17145 ;; add VHDL compilers
17148 (push (car item
) compilation-error-regexp-alist
)
17149 (push item compilation-error-regexp-alist-alist
))
17150 vhdl-error-regexp-emacs-alist
)))
17152 (when vhdl-emacs-22
17153 (add-hook 'compilation-mode-hook
'vhdl-error-regexp-add-emacs
))
17155 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17156 ;; Makefile generation
17158 (defun vhdl-generate-makefile ()
17159 "Generate `Makefile'."
17161 (let* ((compiler (or (vhdl-aget vhdl-compiler-alist vhdl-compiler
)
17162 (error "ERROR: No such compiler: \"%s\"" vhdl-compiler
)))
17163 (command (nth 4 compiler
)))
17164 ;; generate makefile
17166 (let ((default-directory (vhdl-compile-directory)))
17167 (compile (vhdl-replace-string
17168 (cons "\\(.*\\) \\(.*\\)" command
)
17169 (concat (vhdl-makefile-name) " " (vhdl-work-library)))))
17170 (vhdl-generate-makefile-1))))
17172 (defun vhdl-get-packages (lib-alist work-library
)
17173 "Get packages from LIB-ALIST that belong to WORK-LIBRARY."
17176 (when (equal (downcase (caar lib-alist
)) (downcase work-library
))
17177 (push (cdar lib-alist
) pack-list
))
17178 (setq lib-alist
(cdr lib-alist
)))
17181 (defun vhdl-generate-makefile-1 ()
17182 "Generate Makefile for current project or directory."
17183 ;; scan hierarchy if required
17184 (if (vhdl-project-p)
17185 (unless (or (assoc vhdl-project vhdl-file-alist
)
17186 (vhdl-load-cache vhdl-project
))
17187 (vhdl-scan-project-contents vhdl-project
))
17188 (let ((directory (abbreviate-file-name default-directory
)))
17189 (unless (or (assoc directory vhdl-file-alist
)
17190 (vhdl-load-cache directory
))
17191 (vhdl-scan-directory-contents directory
))))
17192 (let* ((directory (abbreviate-file-name (vhdl-default-directory)))
17193 (project (vhdl-project-p))
17194 (ent-alist (vhdl-aget vhdl-entity-alist
(or project directory
)))
17195 (conf-alist (vhdl-aget vhdl-config-alist
(or project directory
)))
17196 (pack-alist (vhdl-aget vhdl-package-alist
(or project directory
)))
17197 (regexp-list (or (nth 12 (vhdl-aget vhdl-compiler-alist vhdl-compiler
))
17198 '("\\1.vhd" "\\2_\\1.vhd" "\\1.vhd"
17199 "\\1.vhd" "\\1_body.vhd" identity
)))
17201 (if (nth 12 (vhdl-aget vhdl-compiler-alist vhdl-compiler
)) t nil
))
17202 (ent-regexp (cons "\\(.*\\) \\(.*\\) \\(.*\\)" (nth 0 regexp-list
)))
17203 (arch-regexp (cons "\\(.*\\) \\(.*\\) \\(.*\\)" (nth 1 regexp-list
)))
17204 (conf-regexp (cons "\\(.*\\) \\(.*\\) \\(.*\\)" (nth 2 regexp-list
)))
17205 (pack-regexp (cons "\\(.*\\) \\(.*\\) \\(.*\\)" (nth 3 regexp-list
)))
17206 (pack-body-regexp (cons "\\(.*\\) \\(.*\\) \\(.*\\)" (nth 4 regexp-list
)))
17207 (adjust-case (nth 5 regexp-list
))
17208 (work-library (downcase (vhdl-work-library)))
17209 (compile-directory (expand-file-name (vhdl-compile-directory)
17210 default-directory
))
17211 (makefile-name (vhdl-makefile-name))
17212 rule-alist arch-alist inst-alist
17213 target-list depend-list unit-list prim-list second-list subcomp-list
17214 lib-alist lib-body-alist pack-list all-pack-list
17215 ent-key ent-file-name arch-key arch-file-name ent-arch-key
17216 conf-key conf-file-name pack-key pack-file-name
17217 ent-entry arch-entry conf-entry pack-entry inst-entry
17218 pack-body-key pack-body-file-name inst-ent-key inst-conf-key
17219 tmp-key tmp-list rule
)
17220 ;; check prerequisites
17221 (unless (file-exists-p compile-directory
)
17222 (make-directory compile-directory t
))
17223 (unless mapping-exist
17225 (format "No unit-to-file name mapping found for compiler \"%s\".\n Directory of dummy files is created instead (to be used as dependencies).\n Please contact the VHDL Mode maintainer for full support of \"%s\""
17226 vhdl-compiler vhdl-compiler
) t
))
17227 (message "Generating makefile \"%s\"..." makefile-name
)
17228 ;; rules for all entities
17229 (setq tmp-list ent-alist
)
17231 (setq ent-entry
(car ent-alist
)
17232 ent-key
(nth 0 ent-entry
))
17233 (when (nth 2 ent-entry
)
17234 (setq ent-file-name
(if vhdl-compile-absolute-path
17236 (file-relative-name (nth 2 ent-entry
)
17237 compile-directory
))
17238 arch-alist
(nth 4 ent-entry
)
17239 lib-alist
(nth 6 ent-entry
)
17240 rule
(vhdl-aget rule-alist ent-file-name
)
17241 target-list
(nth 0 rule
)
17242 depend-list
(nth 1 rule
)
17245 (setq tmp-key
(vhdl-replace-string
17247 (funcall adjust-case
17248 (concat ent-key
" " work-library
))))
17249 (push (cons ent-key tmp-key
) unit-list
)
17250 ;; rule target for this entity
17251 (push ent-key target-list
)
17252 ;; rule dependencies for all used packages
17253 (setq pack-list
(vhdl-get-packages lib-alist work-library
))
17254 (setq depend-list
(append depend-list pack-list
))
17255 (setq all-pack-list pack-list
)
17257 (vhdl-aput 'rule-alist ent-file-name
(list target-list depend-list
))
17258 ;; rules for all corresponding architectures
17260 (setq arch-entry
(car arch-alist
)
17261 arch-key
(nth 0 arch-entry
)
17262 ent-arch-key
(concat ent-key
"-" arch-key
)
17263 arch-file-name
(if vhdl-compile-absolute-path
17265 (file-relative-name (nth 2 arch-entry
)
17266 compile-directory
))
17267 inst-alist
(nth 4 arch-entry
)
17268 lib-alist
(nth 5 arch-entry
)
17269 rule
(vhdl-aget rule-alist arch-file-name
)
17270 target-list
(nth 0 rule
)
17271 depend-list
(nth 1 rule
))
17272 (setq tmp-key
(vhdl-replace-string
17274 (funcall adjust-case
17275 (concat arch-key
" " ent-key
" "
17278 (cons (cons ent-arch-key tmp-key
) unit-list
))
17279 (push ent-arch-key second-list
)
17280 ;; rule target for this architecture
17281 (push ent-arch-key target-list
)
17282 ;; rule dependency for corresponding entity
17283 (push ent-key depend-list
)
17284 ;; rule dependencies for contained component instantiations
17286 (setq inst-entry
(car inst-alist
))
17287 (when (or (null (nth 8 inst-entry
))
17288 (equal (downcase (nth 8 inst-entry
)) work-library
))
17289 (setq inst-ent-key
(or (nth 7 inst-entry
)
17290 (nth 5 inst-entry
)))
17291 (setq depend-list
(cons inst-ent-key depend-list
)
17292 subcomp-list
(cons inst-ent-key subcomp-list
)))
17293 (setq inst-alist
(cdr inst-alist
)))
17294 ;; rule dependencies for all used packages
17295 (setq pack-list
(vhdl-get-packages lib-alist work-library
))
17296 (setq depend-list
(append depend-list pack-list
))
17297 (setq all-pack-list
(append all-pack-list pack-list
))
17299 (vhdl-aput 'rule-alist arch-file-name
(list target-list depend-list
))
17300 (setq arch-alist
(cdr arch-alist
)))
17301 (push (list ent-key second-list
(append subcomp-list all-pack-list
))
17303 (setq ent-alist
(cdr ent-alist
)))
17304 (setq ent-alist tmp-list
)
17305 ;; rules for all configurations
17306 (setq tmp-list conf-alist
)
17308 (setq conf-entry
(car conf-alist
)
17309 conf-key
(nth 0 conf-entry
)
17310 conf-file-name
(if vhdl-compile-absolute-path
17312 (file-relative-name (nth 2 conf-entry
)
17313 compile-directory
))
17314 ent-key
(nth 4 conf-entry
)
17315 arch-key
(nth 5 conf-entry
)
17316 inst-alist
(nth 6 conf-entry
)
17317 lib-alist
(nth 7 conf-entry
)
17318 rule
(vhdl-aget rule-alist conf-file-name
)
17319 target-list
(nth 0 rule
)
17320 depend-list
(nth 1 rule
)
17321 subcomp-list
(list ent-key
))
17322 (setq tmp-key
(vhdl-replace-string
17324 (funcall adjust-case
17325 (concat conf-key
" " work-library
))))
17326 (push (cons conf-key tmp-key
) unit-list
)
17327 ;; rule target for this configuration
17328 (push conf-key target-list
)
17329 ;; rule dependency for corresponding entity and architecture
17331 (cons ent-key
(cons (concat ent-key
"-" arch-key
) depend-list
)))
17332 ;; rule dependencies for used packages
17333 (setq pack-list
(vhdl-get-packages lib-alist work-library
))
17334 (setq depend-list
(append depend-list pack-list
))
17335 ;; rule dependencies for contained component configurations
17337 (setq inst-entry
(car inst-alist
))
17338 (setq inst-ent-key
(nth 2 inst-entry
)
17339 inst-conf-key
(nth 4 inst-entry
))
17340 (when (equal (downcase (nth 5 inst-entry
)) work-library
)
17342 (setq depend-list
(cons inst-ent-key depend-list
)
17343 subcomp-list
(cons inst-ent-key subcomp-list
)))
17344 (when inst-conf-key
17345 (setq depend-list
(cons inst-conf-key depend-list
)
17346 subcomp-list
(cons inst-conf-key subcomp-list
))))
17347 (setq inst-alist
(cdr inst-alist
)))
17349 (vhdl-aput 'rule-alist conf-file-name
(list target-list depend-list
))
17350 (push (list conf-key nil
(append subcomp-list pack-list
)) prim-list
)
17351 (setq conf-alist
(cdr conf-alist
)))
17352 (setq conf-alist tmp-list
)
17353 ;; rules for all packages
17354 (setq tmp-list pack-alist
)
17356 (setq pack-entry
(car pack-alist
)
17357 pack-key
(nth 0 pack-entry
)
17359 (when (nth 2 pack-entry
)
17360 (setq pack-file-name
(if vhdl-compile-absolute-path
17362 (file-relative-name (nth 2 pack-entry
)
17363 compile-directory
))
17364 lib-alist
(nth 6 pack-entry
) lib-body-alist
(nth 10 pack-entry
)
17365 rule
(vhdl-aget rule-alist pack-file-name
)
17366 target-list
(nth 0 rule
) depend-list
(nth 1 rule
))
17367 (setq tmp-key
(vhdl-replace-string
17369 (funcall adjust-case
17370 (concat pack-key
" " work-library
))))
17371 (push (cons pack-key tmp-key
) unit-list
)
17372 ;; rule target for this package
17373 (push pack-key target-list
)
17374 ;; rule dependencies for all used packages
17375 (setq pack-list
(vhdl-get-packages lib-alist work-library
))
17376 (setq depend-list
(append depend-list pack-list
))
17377 (setq all-pack-list pack-list
)
17379 (vhdl-aput 'rule-alist pack-file-name
(list target-list depend-list
))
17380 ;; rules for this package's body
17381 (when (nth 7 pack-entry
)
17382 (setq pack-body-key
(concat pack-key
"-body")
17383 pack-body-file-name
(if vhdl-compile-absolute-path
17385 (file-relative-name (nth 7 pack-entry
)
17386 compile-directory
))
17387 rule
(vhdl-aget rule-alist pack-body-file-name
)
17388 target-list
(nth 0 rule
)
17389 depend-list
(nth 1 rule
))
17390 (setq tmp-key
(vhdl-replace-string
17392 (funcall adjust-case
17393 (concat pack-key
" " work-library
))))
17395 (cons (cons pack-body-key tmp-key
) unit-list
))
17396 ;; rule target for this package's body
17397 (push pack-body-key target-list
)
17398 ;; rule dependency for corresponding package declaration
17399 (push pack-key depend-list
)
17400 ;; rule dependencies for all used packages
17401 (setq pack-list
(vhdl-get-packages lib-body-alist work-library
))
17402 (setq depend-list
(append depend-list pack-list
))
17403 (setq all-pack-list
(append all-pack-list pack-list
))
17405 (vhdl-aput 'rule-alist pack-body-file-name
17406 (list target-list depend-list
)))
17408 (cons (list pack-key
(when pack-body-key
(list pack-body-key
))
17411 (setq pack-alist
(cdr pack-alist
)))
17412 (setq pack-alist tmp-list
)
17413 ;; generate Makefile
17414 (let* ((project (vhdl-aget vhdl-project-alist project
))
17415 (compiler (vhdl-aget vhdl-compiler-alist vhdl-compiler
))
17416 (compiler-id (nth 9 compiler
))
17418 (vhdl-resolve-env-variable
17419 (vhdl-replace-string
17420 (cons "\\(.*\\)" (or (nth 7 project
) (nth 7 compiler
)))
17422 (makefile-path-name (expand-file-name
17423 makefile-name compile-directory
))
17424 (orig-buffer (current-buffer))
17425 cell second-list subcomp-list options unit-key unit-name
)
17427 (setq unit-list
(vhdl-sort-alist unit-list
))
17428 (setq prim-list
(vhdl-sort-alist prim-list
))
17429 (setq tmp-list rule-alist
)
17430 (while tmp-list
; pre-sort rule targets
17431 (setq cell
(cdar tmp-list
))
17432 (setcar cell
(sort (car cell
) 'string
<))
17433 (setq tmp-list
(cdr tmp-list
)))
17434 (setq rule-alist
; sort by first rule target
17436 (function (lambda (a b
)
17437 (string< (car (cadr a
)) (car (cadr b
)))))))
17438 ;; open and clear Makefile
17439 (set-buffer (find-file-noselect makefile-path-name t t
))
17441 (insert "# -*- Makefile -*-\n"
17442 "### " (file-name-nondirectory makefile-name
)
17443 " - VHDL Makefile generated by Emacs VHDL Mode " vhdl-version
17446 (insert "\n# Project : " (nth 0 project
))
17447 (insert "\n# Directory : \"" directory
"\""))
17448 (insert "\n# Platform : " vhdl-compiler
17449 "\n# Generated : " (format-time-string "%Y-%m-%d %T ")
17450 (user-login-name) "\n")
17451 ;; insert compile and option variable settings
17452 (insert "\n\n# Define compilation command and options\n"
17453 "\nCOMPILE = " (nth 0 compiler
)
17454 "\nOPTIONS = " (vhdl-get-compile-options project compiler nil
)
17455 (if (equal vhdl-compile-post-command
"") ""
17456 (concat "\nPOST-COMPILE = " vhdl-compile-post-command
))
17458 ;; insert library paths
17459 (setq library-directory
17460 (directory-file-name
17461 (if (file-name-absolute-p library-directory
)
17463 (file-relative-name
17464 (expand-file-name library-directory directory
)
17465 compile-directory
))))
17466 (insert "\n\n# Define library paths\n"
17467 "\nLIBRARY-" work-library
" = " library-directory
"\n")
17468 (unless mapping-exist
17469 (insert "LIBRARY-" work-library
"-make = " "$(LIBRARY-" work-library
17471 ;; insert variable definitions for all library unit files
17472 (insert "\n\n# Define library unit files\n")
17473 (setq tmp-list unit-list
)
17475 (insert "\nUNIT-" work-library
"-" (caar unit-list
)
17476 " = \\\n\t$(LIBRARY-" work-library
17477 (if mapping-exist
"" "-make") ")/" (cdar unit-list
))
17478 (setq unit-list
(cdr unit-list
)))
17479 ;; insert variable definition for list of all library unit files
17480 (insert "\n\n\n# Define list of all library unit files\n"
17482 (setq unit-list tmp-list
)
17484 (insert " \\\n\t" "$(UNIT-" work-library
"-" (caar unit-list
) ")")
17485 (setq unit-list
(cdr unit-list
)))
17487 (setq unit-list tmp-list
)
17488 ;; insert `make all' rule
17489 (insert "\n\n\n# Rule for compiling entire design\n"
17490 "\n" (nth 0 vhdl-makefile-default-targets
) " :"
17491 " \\\n\t\t" (nth 2 vhdl-makefile-default-targets
)
17492 " \\\n\t\t$(ALL_UNITS)\n")
17493 ;; insert `make clean' rule
17494 (insert "\n\n# Rule for cleaning entire design\n"
17495 "\n" (nth 1 vhdl-makefile-default-targets
) " : "
17496 "\n\t-rm -f $(ALL_UNITS)\n")
17497 ;; insert `make library' rule
17498 (insert "\n\n# Rule for creating library directory\n"
17499 "\n" (nth 2 vhdl-makefile-default-targets
) " :"
17500 " \\\n\t\t$(LIBRARY-" work-library
")"
17501 (if mapping-exist
""
17502 (concat " \\\n\t\t$(LIBRARY-" work-library
"-make)\n"))
17504 "\n$(LIBRARY-" work-library
") :"
17506 (vhdl-replace-string
17507 (cons "\\(.*\\)\n\\(.*\\)" (nth 5 compiler
))
17508 (concat "$(LIBRARY-" work-library
")\n" (vhdl-work-library)))
17510 (unless mapping-exist
17511 (insert "\n$(LIBRARY-" work-library
"-make) :"
17513 "mkdir -p $(LIBRARY-" work-library
"-make)\n"))
17514 ;; insert '.PHONY' declaration
17515 (insert "\n\n.PHONY : "
17516 (nth 0 vhdl-makefile-default-targets
) " "
17517 (nth 1 vhdl-makefile-default-targets
) " "
17518 (nth 2 vhdl-makefile-default-targets
) "\n")
17519 ;; insert rule for each library unit
17520 (insert "\n\n# Rules for compiling single library units and their subhierarchy\n")
17522 (setq second-list
(sort (nth 1 (car prim-list
)) 'string
<))
17524 (sort (vhdl-uniquify (nth 2 (car prim-list
))) 'string
<))
17525 (setq unit-key
(caar prim-list
)
17526 unit-name
(or (nth 0 (vhdl-aget ent-alist unit-key
))
17527 (nth 0 (vhdl-aget conf-alist unit-key
))
17528 (nth 0 (vhdl-aget pack-alist unit-key
))))
17529 (insert "\n" unit-key
)
17530 (unless (equal unit-key unit-name
)
17531 (insert " \\\n" unit-name
))
17533 " \\\n\t\t" (nth 2 vhdl-makefile-default-targets
))
17534 (while subcomp-list
17535 (when (and (assoc (car subcomp-list
) unit-list
)
17536 (not (equal unit-key
(car subcomp-list
))))
17537 (insert " \\\n\t\t" (car subcomp-list
)))
17538 (setq subcomp-list
(cdr subcomp-list
)))
17539 (insert " \\\n\t\t$(UNIT-" work-library
"-" unit-key
")")
17541 (insert " \\\n\t\t$(UNIT-" work-library
"-" (car second-list
) ")")
17542 (setq second-list
(cdr second-list
)))
17544 (setq prim-list
(cdr prim-list
)))
17545 ;; insert rule for each library unit file
17546 (insert "\n\n# Rules for compiling single library unit files\n")
17548 (setq rule
(car rule-alist
))
17549 ;; get compiler options for this file
17551 (vhdl-get-compile-options project compiler
(nth 0 rule
) t
))
17552 ;; insert rule if file is supposed to be compiled
17553 (setq target-list
(nth 1 rule
)
17554 depend-list
(sort (vhdl-uniquify (nth 2 rule
)) 'string
<))
17556 (setq tmp-list target-list
)
17558 (insert "\n$(UNIT-" work-library
"-" (car target-list
) ")"
17559 (if (cdr target-list
) " \\" " :"))
17560 (setq target-list
(cdr target-list
)))
17561 (setq target-list tmp-list
)
17562 ;; insert file name as first dependency
17563 (insert " \\\n\t\t" (nth 0 rule
))
17564 ;; insert dependencies (except if also target or unit does not exist)
17566 (when (and (not (member (car depend-list
) target-list
))
17567 (assoc (car depend-list
) unit-list
))
17568 (insert " \\\n\t\t"
17569 "$(UNIT-" work-library
"-" (car depend-list
) ")"))
17570 (setq depend-list
(cdr depend-list
)))
17571 ;; insert compile command
17573 (insert "\n\t$(COMPILE) "
17574 (if (eq options
'default
) "$(OPTIONS)" options
) " "
17576 (if (equal vhdl-compile-post-command
"") ""
17577 " $(POST-COMPILE)") "\n")
17579 (unless (and options mapping-exist
)
17580 (setq tmp-list target-list
)
17582 (insert "\t@touch $(UNIT-" work-library
"-" (car target-list
) ")\n")
17583 (setq target-list
(cdr target-list
)))
17584 (setq target-list tmp-list
))
17585 (setq rule-alist
(cdr rule-alist
)))
17587 (insert "\n\n### " makefile-name
" ends here\n")
17588 ;; run Makefile generation hook
17589 (run-hooks 'vhdl-makefile-generation-hook
)
17590 (message "Generating makefile \"%s\"...done" makefile-name
)
17591 ;; save and close file
17592 (if (file-writable-p makefile-path-name
)
17593 (progn (save-buffer)
17594 (kill-buffer (current-buffer))
17595 (set-buffer orig-buffer
)
17596 (when (fboundp 'add-to-history
)
17597 (add-to-history 'file-name-history makefile-path-name
)))
17598 (vhdl-warning-when-idle
17599 (format "File not writable: \"%s\""
17600 (abbreviate-file-name makefile-path-name
)))
17601 (switch-to-buffer (current-buffer))))))
17604 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17606 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17607 ;; (using `reporter.el')
17609 (defconst vhdl-mode-help-address
17610 "Reto Zimmermann <reto@gnu.org>"
17611 "Address for VHDL Mode bug reports.")
17613 (defun vhdl-submit-bug-report ()
17614 "Submit via mail a bug report on VHDL Mode."
17616 ;; load in reporter
17618 (y-or-n-p "Do you want to submit a report on VHDL Mode? ")
17619 (let ((reporter-prompt-for-summary-p t
))
17620 (reporter-submit-bug-report
17621 vhdl-mode-help-address
17622 (concat "VHDL Mode " vhdl-version
)
17624 ;; report all important user options
17625 'vhdl-offsets-alist
17626 'vhdl-comment-only-line-offset
17628 'vhdl-electric-mode
17630 'vhdl-indent-tabs-mode
17631 'vhdl-project-alist
17633 'vhdl-project-file-name
17634 'vhdl-project-auto-load
17636 'vhdl-compiler-alist
17638 'vhdl-compile-use-local-error-regexp
17639 'vhdl-makefile-default-targets
17640 'vhdl-makefile-generation-hook
17641 'vhdl-default-library
17644 'vhdl-upper-case-keywords
17645 'vhdl-upper-case-types
17646 'vhdl-upper-case-attributes
17647 'vhdl-upper-case-enum-values
17648 'vhdl-upper-case-constants
17649 'vhdl-use-direct-instantiation
17650 'vhdl-array-index-record-field-in-sensitivity-list
17651 'vhdl-compose-configuration-name
17652 'vhdl-entity-file-name
17653 'vhdl-architecture-file-name
17654 'vhdl-configuration-file-name
17655 'vhdl-package-file-name
17656 'vhdl-file-name-case
17657 'vhdl-electric-keywords
17658 'vhdl-optional-labels
17659 'vhdl-insert-empty-lines
17660 'vhdl-argument-list-indent
17661 'vhdl-association-list-with-formals
17662 'vhdl-conditions-in-parenthesis
17663 'vhdl-sensitivity-list-all
17669 'vhdl-copyright-string
17670 'vhdl-platform-spec
17672 'vhdl-modify-date-prefix-string
17673 'vhdl-modify-date-on-saving
17675 'vhdl-reset-active-high
17676 'vhdl-clock-rising-edge
17677 'vhdl-clock-edge-condition
17681 'vhdl-include-port-comments
17682 'vhdl-include-direction-comments
17683 'vhdl-include-type-comments
17684 'vhdl-include-group-comments
17685 'vhdl-actual-generic-name
17686 'vhdl-actual-port-name
17687 'vhdl-instance-name
17688 'vhdl-testbench-entity-name
17689 'vhdl-testbench-architecture-name
17690 'vhdl-testbench-configuration-name
17691 'vhdl-testbench-dut-name
17692 'vhdl-testbench-include-header
17693 'vhdl-testbench-declarations
17694 'vhdl-testbench-statements
17695 'vhdl-testbench-initialize-signals
17696 'vhdl-testbench-include-library
17697 'vhdl-testbench-include-configuration
17698 'vhdl-testbench-create-files
17699 'vhdl-testbench-entity-file-name
17700 'vhdl-testbench-architecture-file-name
17701 'vhdl-compose-create-files
17702 'vhdl-compose-configuration-create-file
17703 'vhdl-compose-configuration-hierarchical
17704 'vhdl-compose-configuration-use-subconfiguration
17705 'vhdl-compose-include-header
17706 'vhdl-compose-architecture-name
17707 'vhdl-components-package-name
17708 'vhdl-use-components-package
17709 'vhdl-self-insert-comments
17710 'vhdl-prompt-for-comments
17711 'vhdl-inline-comment-column
17712 'vhdl-end-comment-column
17715 'vhdl-align-group-separate
17716 'vhdl-align-same-indent
17717 'vhdl-highlight-keywords
17718 'vhdl-highlight-names
17719 'vhdl-highlight-special-words
17720 'vhdl-highlight-forbidden-words
17721 'vhdl-highlight-verilog-keywords
17722 'vhdl-highlight-translate-off
17723 'vhdl-highlight-case-sensitive
17724 'vhdl-special-syntax-alist
17725 'vhdl-forbidden-words
17726 'vhdl-forbidden-syntax
17727 'vhdl-directive-keywords
17728 'vhdl-speedbar-auto-open
17729 'vhdl-speedbar-display-mode
17730 'vhdl-speedbar-scan-limit
17731 'vhdl-speedbar-jump-to-unit
17732 'vhdl-speedbar-update-on-saving
17733 'vhdl-speedbar-save-cache
17734 'vhdl-speedbar-cache-file-name
17736 'vhdl-source-file-menu
17737 'vhdl-hideshow-menu
17738 'vhdl-hide-all-init
17739 'vhdl-print-two-column
17740 'vhdl-print-customize-faces
17741 'vhdl-intelligent-tab
17742 'vhdl-indent-syntax-based
17743 'vhdl-indent-comment-like-next-code-line
17744 'vhdl-word-completion-case-sensitive
17745 'vhdl-word-completion-in-minibuffer
17746 'vhdl-underscore-is-part-of-word
17751 (if vhdl-special-indent-hook
17752 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
17753 "vhdl-special-indent-hook is set to '"
17754 (format "%s" vhdl-special-indent-hook
)
17755 ".\nPerhaps this is your problem?\n"
17756 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n")
17762 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17764 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17766 (defconst vhdl-doc-release-notes nil
17768 Release Notes for VHDL Mode 3.37
17769 ================================
17771 - Added support for VHDL'08:
17772 - New keywords, types, functions, attributes, operators, packages
17773 - Context declaration
17776 - `all' keyword in sensitivity list
17779 Release Notes for VHDL Mode 3.34
17780 ================================
17782 - Added support for GNU Emacs 22/23/24:
17783 - Compilation error parsing fixed for new `compile.el' package.
17785 - Port translation: Derive actual generic name from formal generic name.
17787 - New user options:
17788 `vhdl-actual-generic-name': Specify how actual generic names are obtained.
17791 Release Notes for VHDL Mode 3.33
17792 ================================
17797 CONFIGURATION DECLARATION GENERATION:
17798 - Automatic generation of a configuration declaration for a design.
17799 (See documentation (`C-c C-h') in section on STRUCTURAL COMPOSITION.)
17805 For Emacs compliance the following key bindings have been changed:
17807 - `C-c c' -> `C-c C-c' `vhdl-comment-uncomment-region'
17808 - `C-c f' -> `C-c C-i C-f' `vhdl-fontify-buffer'
17809 - `C-c s' -> `C-c C-i C-s' `vhdl-statistics-buffer'
17810 - `C-c C-c ...' -> `C-c C-m ...' `vhdl-compose-...'
17816 `vhdl-configuration-file-name': (new)
17817 Specify how the configuration file name is obtained.
17818 `vhdl-compose-configuration-name': (new)
17819 Specify how the configuration name is obtained.
17820 `vhdl-compose-configuration-create-file': (new)
17821 Specify whether a new file should be created for a configuration.
17822 `vhdl-compose-configuration-hierarchical': (new)
17823 Specify whether hierarchical configurations should be created.
17824 `vhdl-compose-configuration-use-subconfiguration': (new)
17825 Specify whether subconfigurations should be used inside configurations.
17826 `vhdl-makefile-default-targets': (new)
17827 Customize names of Makefile default targets.
17828 `vhdl-indent-comment-like-next-code-line': (new)
17829 Specify whether comment lines are indented like following code line.
17830 `vhdl-array-index-record-field-in-sensitivity-list': (new)
17831 Specify whether to include array indices / record fields in sensitivity list.
17835 (defconst vhdl-doc-keywords nil
17837 Reserved words in VHDL
17838 ----------------------
17840 VHDL'08 (IEEE Std 1076-2008):
17841 `vhdl-08-keywords' : keywords
17842 `vhdl-08-types' : standardized types
17843 `vhdl-08-attributes' : standardized attributes
17844 `vhdl-08-functions' : standardized functions
17845 `vhdl-08-packages' : standardized packages and libraries
17847 VHDL'93/02 (IEEE Std 1076-1993/2002):
17848 `vhdl-02-keywords' : keywords
17849 `vhdl-02-types' : standardized types
17850 `vhdl-02-attributes' : standardized attributes
17851 `vhdl-02-enum-values' : standardized enumeration values
17852 `vhdl-02-functions' : standardized functions
17853 `vhdl-02-packages' : standardized packages and libraries
17855 VHDL-AMS (IEEE Std 1076.1 / 1076.1.1):
17856 `vhdl-ams-keywords' : keywords
17857 `vhdl-ams-types' : standardized types
17858 `vhdl-ams-attributes' : standardized attributes
17859 `vhdl-ams-enum-values' : standardized enumeration values
17860 `vhdl-ams-constants' : standardized constants
17861 `vhdl-ams-functions' : standardized functions
17863 Math Packages (IEEE Std 1076.2):
17864 `vhdl-math-types' : standardized types
17865 `vhdl-math-constants' : standardized constants
17866 `vhdl-math-functions' : standardized functions
17867 `vhdl-math-packages' : standardized packages
17870 `vhdl-verilog-keywords' : Verilog reserved words
17872 NOTE: click `mouse-2' on variable names above (not in XEmacs).")
17875 (defconst vhdl-doc-coding-style nil
17877 For VHDL coding style and naming convention guidelines, see the following
17881 \"VHDL Coding Styles and Methodologies\".
17882 Kluwer Academic Publishers, 1999.
17883 http://members.aol.com/vhdlcohen/vhdl/
17885 [2] Michael Keating and Pierre Bricaud.
17886 \"Reuse Methodology Manual, Second Edition\".
17887 Kluwer Academic Publishers, 1999.
17888 http://www.openmore.com/openmore/rmm2.html
17890 [3] European Space Agency.
17891 \"VHDL Modelling Guidelines\".
17892 ftp://ftp.estec.esa.nl/pub/vhdl/doc/ModelGuide.{pdf,ps}
17894 Use user options `vhdl-highlight-special-words' and `vhdl-special-syntax-alist'
17895 to visually support naming conventions.")
17898 (defun vhdl-version ()
17899 "Echo the current version of VHDL Mode in the minibuffer."
17901 (message "VHDL Mode %s (%s)" vhdl-version vhdl-time-stamp
)
17902 (vhdl-keep-region-active))
17904 (defun vhdl-doc-variable (variable)
17905 "Display VARIABLE's documentation in *Help* buffer."
17907 (unless (featurep 'xemacs
)
17908 (help-setup-xref (list #'vhdl-doc-variable variable
)
17909 (called-interactively-p 'interactive
)))
17910 (with-output-to-temp-buffer
17911 (if (fboundp 'help-buffer
) (help-buffer) "*Help*")
17912 (princ (documentation-property variable
'variable-documentation
))
17913 (with-current-buffer standard-output
17915 (help-print-return-message)))
17917 (defun vhdl-doc-mode ()
17918 "Display VHDL Mode documentation in *Help* buffer."
17920 (unless (featurep 'xemacs
)
17921 (help-setup-xref (list #'vhdl-doc-mode
)
17922 (called-interactively-p 'interactive
)))
17923 (with-output-to-temp-buffer
17924 (if (fboundp 'help-buffer
) (help-buffer) "*Help*")
17927 (princ (documentation 'vhdl-mode
))
17928 (with-current-buffer standard-output
17930 (help-print-return-message)))
17933 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17935 (provide 'vhdl-mode
)
17937 ;;; vhdl-mode.el ends here