;;; 93AUG16 ; ;CONTENTS: ; copyright ; mail and support info ; history ; general philosophy ; quick start instructions ; future enhancements ; gnuvhdl-elisp-code: ; abbrev table ; mode setup ; vhdl functions ; idioms ; comment functions ; hook table ; ;############################################################################# ; GNU EMACS GENERAL PUBLIC LICENSE ; (Clarified 11 Feb 1988) ; ; Copyright (C) 1985, 1987, 1988 Richard M. Stallman ; Everyone is permitted to copy and distribute verbatim copies ; of this license, but changing it is not allowed. You can also ; use this wording to make the terms for other programs. ; ; The license agreements of most software companies keep you at the ;mercy of those companies. By contrast, our general public license is ;intended to give everyone the right to share GNU Emacs. To make ;sure that you get the rights we want you to have, we need to make ;restrictions that forbid anyone to deny you these rights or to ask you ;to surrender the rights. Hence this license agreement. ; ; Specifically, we want to make sure that you have the right to give ;away copies of Emacs, that you receive source code or else can get it ;if you want it, that you can change Emacs or use pieces of it in new ;free programs, and that you know you can do these things. ; ; To make sure that everyone has such rights, we have to forbid you to ;deprive anyone else of these rights. For example, if you distribute ;copies of Emacs, you must give the recipients all the rights that you ;have. You must make sure that they, too, receive or can get the ;source code. And you must tell them their rights. ; ; Also, for our own protection, we must make certain that everyone ;finds out that there is no warranty for GNU Emacs. If Emacs is ;modified by someone else and passed on, we want its recipients to know ;that what they have is not what we distributed, so that any problems ;introduced by others will not reflect on our reputation. ; ; Therefore we (Richard Stallman and the Free Software Fundation, ;Inc.) make the following terms which say what you must do to be ;allowed to distribute or change GNU Emacs. ; ; COPYING POLICIES ; ; 1. You may copy and distribute verbatim copies of GNU Emacs source code ;as you receive it, in any medium, provided that you conspicuously and ;appropriately publish on each copy a valid copyright notice "Copyright ;(C) 1988 Free Software Foundation, Inc." (or with whatever year is ;appropriate); keep intact the notices on all files that refer to this ;License Agreement and to the absence of any warranty; and give any ;other recipients of the GNU Emacs program a copy of this License ;Agreement along with the program. You may charge a distribution fee ;for the physical act of transferring a copy. ; ; 2. You may modify your copy or copies of GNU Emacs source code or ;any portion of it, and copy and distribute such modifications under ;the terms of Paragraph 1 above, provided that you also do the following: ; ; a) cause the modified files to carry prominent notices stating ; that you changed the files and the date of any change; and ; ; b) cause the whole of any work that you distribute or publish, ; that in whole or in part contains or is a derivative of GNU Emacs ; or any part thereof, to be licensed at no charge to all third ; parties on terms identical to those contained in this License ; Agreement (except that you may choose to grant more extensive ; warranty protection to some or all third parties, at your option). ; ; c) if the modified program serves as a text editor, cause it when ; started running in the simplest and usual way, to print an ; announcement including a valid copyright notice "Copyright (C) ; 1988 Free Software Foundation, Inc." (or with the year that is ; appropriate), saying that there is no warranty (or else, saying ; that you provide a warranty) and that users may redistribute the ; program under these conditions, and telling the user how to view a ; copy of this License Agreement. ; ; d) You may charge a distribution fee for the physical act of ; transferring a copy, and you may at your option offer warranty ; protection in exchange for a fee. ; ;Mere aggregation of another unrelated program with this program (or its ;derivative) on a volume of a storage or distribution medium does not bring ;the other program under the scope of these terms. ; ; 3. You may copy and distribute GNU Emacs (or a portion or derivative of it, ;under Paragraph 2) in object code or executable form under the terms of ;Paragraphs 1 and 2 above provided that you also do one of the following: ; ; a) accompany it with the complete corresponding machine-readable ; source code, which must be distributed under the terms of ; Paragraphs 1 and 2 above; or, ; ; b) accompany it with a written offer, valid for at least three ; years, to give any third party free (except for a nominal ; shipping charge) a complete machine-readable copy of the ; corresponding source code, to be distributed under the terms of ; Paragraphs 1 and 2 above; or, ; ; c) accompany it with the information you received as to where the ; corresponding source code may be obtained. (This alternative is ; allowed only for noncommercial distribution and only if you ; received the program in object code or executable form alone.) ; ;For an executable file, complete source code means all the source code for ;all modules it contains; but, as a special exception, it need not include ;source code for modules which are standard libraries that accompany the ;operating system on which the executable file runs. ; ; 4. You may not copy, sublicense, distribute or transfer GNU Emacs ;except as expressly provided under this License Agreement. Any attempt ;otherwise to copy, sublicense, distribute or transfer GNU Emacs is void and ;your rights to use GNU Emacs under this License agreement shall be ;automatically terminated. However, parties who have received computer ;software programs from you with this License Agreement will not have ;their licenses terminated so long as such parties remain in full compliance. ; ; 5. If you wish to incorporate parts of GNU Emacs into other free programs ;whose distribution conditions are different, write to the Free Software ;Foundation. We have not yet worked out a simple rule that can be stated ;here, but we will often permit this. We will be guided by the two goals of ;preserving the free status of all derivatives of our free software and of ;promoting the sharing and reuse of software. ; ;Your comments and suggestions about our licensing policies and our ;software are welcome! Please contact the Free Software Foundation, Inc., ;675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296. ; ; NO WARRANTY ; ; BECAUSE GNU EMACS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY ;NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT ;WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, ;RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU EMACS "AS IS" ;WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, ;BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ;FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY ;AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE GNU EMACS ;PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY ;SERVICING, REPAIR OR CORRECTION. ; ; IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE ;FOUNDATION, INC., RICHARD M. STALLMAN, AND/OR ANY OTHER PARTY WHO MAY ;MODIFY AND REDISTRIBUTE GNU EMACS AS PERMITTED ABOVE, BE LIABLE TO YOU ;FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER ;SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR ;INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA ;BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A ;FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY ;FREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN ;ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY ;OTHER PARTY. ; ;############################################################################# ; ; PLEASE SEND COMMENTS, MODIFICATIONS, AND ENHANCEMENTS TO: ; vhdl-mode@src.honeywell.com ; As appropriate, these will be incorporated and periodically posted to ; comp.lang.vhdl. If someone wants to make available an archive site ; for "raw" change suggestions, I will forward any mail to that location ; ; Note that this is a "hack" and is work in progress. ; Please also note (of course) that this work is done on personal time. ; ;############################################################################# ; GENERAL PHILOSOPHY ;############################################################################# ; ; We used the old ^C mode from the old VHDL/Ada/Pascal mode for ; about 35 milliseconds before discovering that our particular form of brain ; damage actually made it harder to remember the keystroke than the real VHDL. ; So, thus was born: ; ; SYNTAX-DIRECTED-GNU-VHDL-MODE (no catchy acronyms) (TM) ; ; Main features of VHDL mode include: ; automatic keyword capitalization ; powerful commenting ; clean VHDL templates ; clean, easy to read, automatic indentation ; ; A major goal of our VHDL mode was to help the designer create screen readable ; code without having to resort to fancy editors and paper-pretty-printers ; that tend to kill trees. So the capitalization rules, indentation, and ; commenting are all there to help improve code readability. Face it - most ; folks, especially new code writers, write ugly code. This mode is supposed ; to be able to at least standardize some habits and lessen the chore of ; writing readable code. ; ; As an aside, other rules we have imposed on our code writers include case ; rules for signal, variables, and other VHDL names. This allows the reviewer ; to instantly know what type of object is being used, without having to ; search for declarations. Here is a summary: ; ; CASE CHARACTERS Abbreviations* ; ; SIGNALS mix A-Z a-z 0-9 Yes ; VARIABLES lower a-z 0-9 '_' No ; CONSTANTS upper A-Z 0-9 '_' Yes ; GENERICS upper A-Z 0-9 '_' Yes ; ENUM TYPES upper A-Z 0-9 No ; PROCESSES mix A-Z a-z 0-9 No ; KEYWORDS upper A-Z N/A ; ENTITY mix A-Z a-z 0-9 Yes ; ARCHITECTURE mix A-Z a-z 0-9 Yes ; CONFIGURATION mix A-Z a-z 0-9 Yes ; TYPE FIELDS lower a-z 0-9 '_' No ; FUNCTIONS lower a-z 0-9 '_' No ; PROCEDURES lower a-z 0-9 '_' No ; ; ; VHDL mode uses 5 main techniques for aiding your VHDL task: ; ; (1) DYNAMIC HOOKED ABBREVS (SPC) ; In short, VHDL-MODE will examine what you are typing, and attempt to predict ; what you want to do, before you actually have to type it. It usually works ; by typing the first word of some VHDL construct (say, "FOR" for a FOR LOOP). ; As soon as you hit the space following the FOR, Emacs will call a function, ; and ask you all the questions you need to fill in the loop. Emacs will ; build the loops structure for you, mainting nice clean indentation. Your ; point will be left in a position from which it is natural to continue. ; ; (2) STUTTERING (double strike) ; VHDL mode also uses stuttering quite a bit. Stuttering is when you double ; strike a key. For instance, instead of hunting for the colon ":", you can ; double strike the semi colon ";". Or instead of the cumbersome "<=" signal ; assignment, simply hit the period "." twice. Play around with stuttering, ; as there are quite a few bindings. Comments are a form of stuttering ; ; (3) DABBREV (TAB Key) ; VVDL mode also uses dabbrevs. This is a cool toy that allows you to use ; complex signal names (for instance) without having to type them out every ; time. To use this mode (for any word), simply type the word once somewhere ; in the file. Thereafter, further down in the file, if you need to repeat ; the word, start typing it. Then hit the TAB key. TAB will cycle through ; the words in the file prior to the one on which you are currently typing, ; until you have a match. Then simply continue typing on your way. ; ; If you are not typing a word, TAB will indent the line on which you are ; currently typing. ; ; (4) ^C ; The Control C binding remain for compatibility. Sometimes. Bleah. ; ; (5) COMMENTS (--, ---, --CR) ; Comments must be easy to use in order for your VHDL coders to comment. So, ; we added some stuff to make life easy. The best bet is to start typing in ; comments, and get a feel for it. But, in short: ; ; "--" will put a single comment in the current column, or if it is following ; a line of code, it will left adjust to column 40. This is for short ; comments. ; ; "---" will create a comment block with nice long bars on the top and bottom ; Note that these maintain indentation. ; ; "--" will comment out code. Continued pressing of will continue ; the commenting out of the code. ; ; Note that VHDL.EL is written primarily for writing behavioral VHDL. ; We contend that structural VHDL should be captured with schematics, as ; pictures are worth many several pages of ugly code. With that in mind, ; you'll notice there is very little support for port declarations, connection, ; etc. If you want to write them, I will be happy to add them to the mode. ; ;############################################################################# ; INSTRUCTIONS for a quick start ;############################################################################# ; ; In the true vein of this sort of things, it is all self documenting. You ; don't need explicit instructions. But, as a start, we'll give you this :) ; ; (1) ; Add the following to your .emacs (profile.el) file. Modify file ending ; as appropriate. Don't forget to remove the leading semicolon comment! ;; ;; Auto Load Functions (save memory by loading these only when called) ;; VHDL stuff ;(autoload 'vhdl-mode "vhdl" "vhdl-mode with hooked abbrevs" t) ;(setq auto-mode-alist (cons (cons "\\.vhdl$" 'vhdl-mode) auto-mode-alist)) ;(setq auto-mode-alist (cons (cons "\\.vhd$" 'vhdl-mode) auto-mode-alist)) ;(setq auto-mode-alist (cons (cons "\\.vdl$" 'vhdl-mode) auto-mode-alist)) ; ; (2) ; restart emacs, M-x eval-current-buffer, or M-x load-file ~/.emacs. ; Then visit a VHDL file and start typing VHDL code. The mode will do ; the rest of the work for you. Note the wild and wooly things involving ; the TAB key, and stuttering other keys. Note that VHDL.el creates an ; abbrev table. ; ; (3) ; Email changes and enhancements to vhdl-mode@src.honeywell.com ; These will be summarized and posted regularily in comp.lang.vhdl ; ; (4) ; More extensive documentation would be nice. Wanna write some for us? ; ;############################################################################# ; ADDING FUNCTIONS ;############################################################################# ; ; write function. If it is a VHDL construct, put it in VHLD-FUNCTIONS ; (roughly alphabetical order). ; ; create hook for it (hook table at end of file) ; ; create abbrev ; ; email modification to vhdl-mode@src.honeywell.com ; ;############################################################################# ; CREDITS ;############################################################################# ; In previous lives, looking much different and not hooked or abbrev'd ; and of a different VHDL (and elisp) coding style, this package had the ; following comments: ; ; The following was created by changing the 'ada.el' Ada-mode ; code which was a part of the gnu-emacs 18.50 distribution into ; a 'vhdl.el' vhdl-mode to support some level of electric editing ; and semi-automatic creation of VHDL code fragments ; with the GNU-EMACS text editor. ; -- Steve Grout, MCC CAD Program, March 31, 1988. ; Ada editing support package in GNUlisp. v1.0 ; Author: Vincent Broman May 1987. ; (borrows heavily from Mick Jordan's Modula-2 package for GNU, ; as modified by Peter Robinson, Michael Schmidt, and Tom Perrine.) ; ;############################################################################# ; Future enhancements ;############################################################################# ; ; recursive dabbrev ; Dump the whole beast and port to Leif ; Add defaults to vhdl-field ; complete compilation mode ; tie to gdb (debugger) ; ; add recursive edit to vhdl-field, i.e. if you type a line-feed as ; the answer to a field query, you are put into a recursive edit and ; line-feed pops you up a recurse level if typed when not being field ; queried. I don't know if line-feed is the right key to use for this. ; Recursive editing is for experts. A novice can get confused. So, ; this functionality also should have a voltage control. ; ; (as)salt-to-taste variables to accommodate alternate programming styles. ; ;> (autoload 'vantage-compile "compile-vantage" "compiler" t nil) ;Any cautions needed to keep this compile stuff from breaking on other systems? ; ;> (defun vhdl-print () ; ;Describe pretty printing in header ;This may break on some systems. ; ;Need to describe the two hooks. ; ;############################################################################# ; REVISION INFO ;############################################################################# ; 92JUN17: removed "current line" reference in vhdl-process ; enhanced TAB overloading to tab-to-tab-stop while in middle of ; line, and justify only if no non-whitespace to left. ; new vhdlgrind ; appropriately aligned entity END ; 93JAN14 procedure body cleanup ; 93AUG16 fixed tab-to-tab-stop problems seen in Lucid and GNUEmacs19 ; added port, lib, generic, and others (thanks Gnanasekaran Swaminathan) ;############################################################################# (provide 'vhdl-mode) (autoload 'vantage-compile "compile-vantage" "compiler" t nil) ;genericize this (autoload 'vantage-compile-all "compile-vantage" "compiler" t nil) ;genericize this ; This goes into your .abbrev_defs file, but if it isn't there, this takes ; care of adding it automatically. ;(and (not (boundp 'vhdl-mode-abbrev-table)) ; (file-exists-p abbrev-file-name) ; (read-abbrev-file nil t)) ;if no table and abbrev file exists, read it (and (or (not (boundp 'vhdl-mode-abbrev-table)) (not vhdl-mode-abbrev-table)) ;if no table or it is nil, define it. (define-abbrev-table 'vhdl-mode-abbrev-table '( ("--" "" vhdl-display-comment-hook 0) ("and" "" vhdl-and-hook 0) ("arch" "" vhdl-architecture-hook 0) ("architecture" "" vhdl-architecture-hook 0) ("array" "" vhdl-array-hook 0) ("typea" "" vhdl-type-array-hook 0) ("assert" "" vhdl-assert-hook 0) ("attribute" "" vhdl-attribute-hook 0) ("block" "" vhdl-block-hook 0) ("case" "" vhdl-case-hook 0) ("comp" "" vhdl-component-hook 0) ("compi" "" vhdl-component-instance-hook 0) ("component" "" vhdl-component-hook 0) ("componenti" "" vhdl-component-instance-hook 0) ("config" "" vhdl-configuration-spec-hook 0) ("configd" "" vhdl-configuration-declaration-hook 0) ("configuration" "" vhdl-configuration-spec-hook 0) ("configurationd" "" vhdl-configuration-declaration-hook 0) ("cons" "" vhdl-constant-hook 0) ("constant" "" vhdl-constant-hook 0) ("else" "" vhdl-else-hook 0) ("elseif" "" vhdl-elsif-hook 0) ("elsif" "" vhdl-elsif-hook 0) ("entity" "" vhdl-entity-hook 0) ("exit" "" vhdl-exit-hook 0) ("for" "" vhdl-for-loop-hook 0) ("func" "" vhdl-function-spec-hook 0) ("funcb" "" vhdl-function-body-hook 0) ("functionb" "" vhdl-function-body-hook 0) ("function" "" vhdl-function-spec-hook 0) ("generic" "" vhdl-generic-hook 0) ("genm" "" vhdl-generic-map-hook 0) ("gen" "" vhdl-generate-hook 0) ("generate" "" vhdl-generate-hook 0) ("header" "" vhdl-header-hook 0) ("if" "" vhdl-if-hook 0) ("lib" "" vhdl-library-hook 0) ("library" "" vhdl-library-hook 0) ("loop" "" vhdl-loop-hook 0) ("nand" "" vhdl-nand-hook 0) ("nor" "" vhdl-nor-hook 0) ("not" "" vhdl-not-hook 0) ("or" "" vhdl-or-hook 0) ("others" "" vhdl-others-hook 0) ("pack" "" vhdl-package-spec-hook 0) ("package" "" vhdl-package-spec-hook 0) ("packageb" "" vhdl-package-body-hook 0) ("packb" "" vhdl-package-body-hook 0) ("por" "" vhdl-port-hook 0) ("portm" "" vhdl-port-map-hook 0) ("procedure" "" vhdl-procedure-spec-hook 0) ("procedureb" "" vhdl-procedure-body-hook 0) ("process" "" vhdl-process-hook 0) ("record" "" vhdl-record-hook 0) ("ret" "" vhdl-return-hook 0) ("return" "" vhdl-return-hook 0) ("select" "" vhdl-selected-signal-assignment-hook 0) ("selw" "" vhdl-selected-when-hook 0) ("sig" "" vhdl-signal-hook 0) ("signal" "" vhdl-signal-hook 0) ("sub" "" vhdl-subtype-hook 0) ("subtype" "" vhdl-subtype-hook 0) ("type" "" vhdl-type-hook 0) ("typerecord" "" vhdl-type-record-hook 0) ("typer" "" vhdl-type-record-hook 0) ("use" "" vhdl-use-hook 0) ("var" "" vhdl-variable-hook 0) ("variable" "" vhdl-variable-hook 0) ("wait" "" vhdl-wait-hook 0) ("when" "" vhdl-when-hook 0) ("while" "" vhdl-while-loop-hook 0) ("with" "" vhdl-selected-signal-assignment-hook 0) ("xnor" "" vhdl-xnor-hook 0) ("xor" "" vhdl-xor-hook 0) ; ("?" "" vhdl-conditional-signal-assignment-hook 0) ; ("?" "" vhdl-conditional-waveform-hook 0) ))) (defvar vhdl-mode-syntax-table nil "Syntax table in use in vhdl-mode buffers.") (setq vhdl-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?\n ">" vhdl-mode-syntax-table) (modify-syntax-entry ?_ "_" vhdl-mode-syntax-table) (modify-syntax-entry ?\# "_" vhdl-mode-syntax-table) (modify-syntax-entry ?\( "()" vhdl-mode-syntax-table) (modify-syntax-entry ?\) ")(" vhdl-mode-syntax-table) (modify-syntax-entry ?$ "." vhdl-mode-syntax-table) (modify-syntax-entry ?* "." vhdl-mode-syntax-table) (modify-syntax-entry ?/ "." vhdl-mode-syntax-table) (modify-syntax-entry ?+ "." vhdl-mode-syntax-table) (modify-syntax-entry ?- ". 12" vhdl-mode-syntax-table) (modify-syntax-entry ?= "." vhdl-mode-syntax-table) (modify-syntax-entry ?\& "." vhdl-mode-syntax-table) (modify-syntax-entry ?\| "." vhdl-mode-syntax-table) (modify-syntax-entry ?< "." vhdl-mode-syntax-table) (modify-syntax-entry ?> "." vhdl-mode-syntax-table) (modify-syntax-entry ?\[ "(]" vhdl-mode-syntax-table) (modify-syntax-entry ?\] ")[" vhdl-mode-syntax-table) (modify-syntax-entry ?\{ "(}" vhdl-mode-syntax-table) (modify-syntax-entry ?\} "){" vhdl-mode-syntax-table) (modify-syntax-entry ?. "." vhdl-mode-syntax-table) (modify-syntax-entry ?\\ "." vhdl-mode-syntax-table) (modify-syntax-entry ?: "." vhdl-mode-syntax-table) (modify-syntax-entry ?\; "." vhdl-mode-syntax-table) (modify-syntax-entry ?\' "." vhdl-mode-syntax-table) (modify-syntax-entry ?\" "\"" vhdl-mode-syntax-table) (defvar vhdl-mode-map nil "Keymap used in vhdl mode. Inherited from Ada, needs rationalizing So far, few of the vhdl keyword functions calls have been found to be useful in conjunction with the hooked abbrevs. However, they remain for backward compatibility.") (let (c (map (make-sparse-keymap))) (define-key map "\C-cC" 'vantage-compile) ;needs genericization (define-key map "\C-cA" 'vantage-compile-all) ;needs genericization (define-key map "\C-c'" 'vantage-next-error) ;needs genericization (define-key map "\C-?" 'backward-delete-char-untabify) (define-key map "\C-ca" 'vhdl-architecture) (define-key map "\C-c\C-a" 'vhdl-array) (define-key map "\C-c<" 'vhdl-backward-to-same-indent) (define-key map "\C-cB" 'vhdl-bind) (define-key map "\C-cc" 'vhdl-case) (define-key map "\C-c\C-C" 'vhdl-display-comment) (define-key map "\C-cE" 'vhdl-else) (define-key map "\C-cI" 'vhdl-elsif) (define-key map "\C-ce" 'vhdl-entity) (define-key map "\C-cx" 'vhdl-exit) (define-key map "\C-c\C-e" 'vhdl-find-listing) (define-key map "\C-cf" 'vhdl-for-loop) (define-key map "\C-c>" 'vhdl-forward-to-same-indent) (define-key map "\C-c\C-f" 'vhdl-function-spec) (define-key map "\C-ch" 'vhdl-header) (define-key map "\C-ci" 'vhdl-indent-region) (define-key map "\C-cd" 'vhdl-dedent-region) (define-key map "\C-c-" 'vhdl-inline-comment) (define-key map "\C-cl" 'vhdl-loop) (define-key map "\C-j" 'vhdl-next-block) (define-key map "\C-ck" 'vhdl-package-body) (define-key map "\C-c\C-k" 'vhdl-package-spec) (define-key map "\C-c(" 'vhdl-paired-parens) (define-key map "\C-cp" 'vhdl-procedure-body) (define-key map "\C-c\C-p" 'vhdl-procedure-spec) (define-key map "\C-c\C-r" 'vhdl-record) (define-key map "\C-cW" 'vhdl-selected-signal-assignment) (define-key map "\C-cO" 'vhdl-set-options) (define-key map "\C-cP" 'vhdl-print) (define-key map "\C-c\C-s" 'vhdl-subtype) (define-key map "\C-i" 'vhdl-tab) (define-key map "\C-ct" 'vhdl-tabsize) (define-key map "\C-c\C-t" 'vhdl-type) (define-key map "\C-c\C-i" 'vhdl-untab) (define-key map "\C-c\C-u" 'vhdl-use) (define-key map "\C-c\C-w" 'vhdl-when) (define-key map "\C-cr" 'vhdl-comment-region) (define-key map "\C-cw" 'vhdl-while-loop) (define-key map "\C-cu" 'vhdl-uncomment-region) (define-key map "\r" 'vhdl-return) (define-key map " " 'vhdl-outer-space) (define-key map "-" 'vhdl-stutter-dash) (define-key map "'" 'vhdl-stutter-quote) (define-key map ";" 'vhdl-stutter-semicolon) (define-key map "[" 'vhdl-stutter-open-bracket) (define-key map "]" 'vhdl-stutter-close-bracket) (define-key map "." 'vhdl-stutter-period) (define-key map "," 'vhdl-stutter-comma) (let ((c 97)) (while (< c 123) ; for little a-z (define-key map (char-to-string c) 'vhdl-stutter-caps) (setq c (1+ c)) )) (setq vhdl-mode-map map) ) (defvar vhdl-indent-start nil "*List of keywords which cause an indentation.") (setq vhdl-indent-start '("ARCHITECTURE" "architecture" "ASSERT" "assert" "BEGIN" "begin" "BLOCK" "block" "BODY" "body" "CASE" "case" "COMPONENT" "component" "CONFIGURATION" "configuration" "ELSE" "else" "ELSIF" "elsif" "ENTITY" "entity" "FOR" "for" "FUNCTION" "function" "GENERATE" "generate" "GENERIC" "generic" "IF" "if" "LIBRARY" "library" "LOOP" "loop" "PACKAGE" "package" "PORT" "port" "PROCEDURE" "procedure" "PROCESS" "process" "RECORD" "record" "REPORT" "report" "SELECT" "select" "THEN" "then" "UNTIL" "until" "WHEN" "when" "WHILE" "while" "WITH" "with" ) ) (defvar vhdl-indent 2 "Value is the number of columns to indent in vhdl-Mode") (defvar vhdl-when-indent 2 "*value is the number of columns to indent from case") ;############################################################################# ; Defuns ;############################################################################# (defun vhdl-mode () "This is a mode intended to support program development in vhdl. Most control constructs and declarations of vhdl can be inserted in the buffer by typing the first word of the construct you wish to enter, followed by a space. Other support includes commenting, dabbrevs (hit TAB to expand previously typed words), and stuttering (double strike the first letter of a word and it will capitalize, double strike comma and get a signal assignment, etc.). You can also get VHDL constructs by typing Control-C followed by a character mnemonic for the construct or via hooked abbrev of the keyword. (see vhdl-mode-abbrev-table)\\{vhdl-mode-map}" (interactive) (kill-all-local-variables) (use-local-map vhdl-mode-map) (setq major-mode 'vhdl-mode) (setq mode-name "VHDL") (setq local-abbrev-table vhdl-mode-abbrev-table) (abbrev-mode 1) (set-syntax-table vhdl-mode-syntax-table) (setq indent-tabs-mode nil) ; always use spaces instead of tabs (make-local-variable 'paragraph-start) (setq paragraph-start (concat "^$\\|" page-delimiter)) (make-local-variable 'paragraph-separate) (setq paragraph-separate paragraph-start) (make-local-variable 'indent-line-function) (setq indent-line-function 'vhdl-indent-line) (make-local-variable 'require-final-newline) (setq require-final-newline t) (make-local-variable 'comment-start) (setq comment-start "--") (make-local-variable 'comment-end) (setq comment-end "") (setq comment-column 41) (make-local-variable 'comment-start-skip) (setq comment-start-skip "--+ *") (make-local-variable 'end-comment-column) (setq end-comment-column 79) (make-local-variable 'comment-indent-hook) (setq comment-indent-hook 'vhdl-comment-indent) (run-hooks 'vhdl-mode-hook) (abbrev-mode 0) ) (defun vhdl-print () "Pretty print the current buffer." (interactive) (save-buffer) (message "Printing") (sit-for 0) (setq print-source-file (buffer-name)) (shell-command (concat "vhdlgrind " print-source-file)) (message "") (sit-for 0) ; flush misleading shell message (kill-buffer "*Shell Command Output*") ) (defun vhdl-fix-keyword-case () "Ensure key words are in upper case." (interactive) (mapcar (function (lambda (x) (let ((case-fold-search t) (case-replace nil)) (goto-char 0) (while (word-search-forward x nil 1) (or (vhdl-in-comment) (vhdl-in-quote) (upcase-word -1) ) ) ))) (list "abs" "access" "after" "alias" "all" "and" "architecture" "array" "assert" "attribute" "begin" "block" "body" "buffer" "bus" "case" "component" "configuration" "constant" "disconnect" "downto" "else" "elsif" "end" "entity" "error" "exit" "failure" "file" "for" "function" "generate" "generic" "guarded" "if" "in" "inout" "is" "label" "library" "linkage" "loop" "map" "mod" "nand" "new" "next" "nor" "not" "note" "null" "of" "on" "open" "or" "others" "out" "package" "port" "procedure" "process" "range" "record" "register" "rem" "report" "return" "select" "severity" "signal" "subtype" "then" "to" "transport" "type" "units" "until" "use" "variable" "wait" "warning" "when" "while" "with" "xor") ) ) (defun vhdl-remove-blank-line () "removes a blank line in vhdl" (interactive) (beginning-of-line nil) (kill-line) (end-of-line 2) ) (defun vhdl-tabsize (s) "changes spacing used for indentation. Reads spacing from minibuffer." (interactive "new indentation spacing: ") (setq vhdl-indent s) ) (defun vhdl-indent-line () "Indent this line 'correctly' for vhdl." (interactive) (let ( markit (opoint (point)) (pats vhdl-indent-start) ) (save-excursion (forward-line -1) (while (and (looking-at "[ \t]*--\\|[ \t]*$") (> (forward-line -1) -1))) ;skip blank and comment lines (back-to-indentation) (re-search-forward "^[ \t]*[a-z]+[ \t]*:[ \t]*" (save-excursion (end-of-line) (point)) t) (while (and pats (setq markit (not (looking-at (car pats))))) (setq pats (cdr pats))) ;does line's first word cause indentation? (setq markit (if markit (current-column) ;indentation column (+ (current-column) vhdl-indent))) (goto-char opoint) ;where we were (back-to-indentation) ;beginning of line we started on (if (> (current-column) markit) (delete-horizontal-space)) (indent-to markit) ) (if (< (current-column) markit) (skip-chars-forward " \t")) ) ) (defun vhdl-indent-region (start end &optional times) "indent region (vhdl-indent) spaces. Accepts number of times to indent" (interactive "r\np") (indent-code-rigidly start end (* times vhdl-indent) ) ) (defun vhdl-dedent-region (start end &optional times) "dedent region (vhdl-indent) spaces. Accepts number of times to dedent" (interactive "r\np") (indent-code-rigidly start end (* -1 times vhdl-indent)) ) (defun vhdl-tab (&optional pre-arg) " If preceeding character is part of a word then dabbrev-expand, else if right of non whitespace on line then tab-to-tab-stop, else if last command was a tab or return then dedent one step, else indent 'correctly'" (interactive "*P") (cond ((= (char-syntax (preceding-char)) ?w) (let ((case-fold-search t)) (dabbrev-expand pre-arg))) ((> (current-column) (current-indentation)) (tab-to-tab-stop)) ((and (or (eq last-command 'vhdl-tab) (eq last-command 'vhdl-return)) (/= 0 (current-indentation))) (backward-delete-char-untabify vhdl-indent nil)) ((vhdl-indent-line)) ) (setq this-command 'vhdl-tab) ) (defun vhdl-untab () "Delete backwards to previous tab stop." (interactive) (backward-delete-char-untabify vhdl-indent nil) ) (defun vhdl-return () "newline-and-indent or indent-new-comment-line if in comment and preceding character is a space." (interactive) (if (and (= (preceding-char) ? ) (vhdl-in-comment)) (indent-new-comment-line) (newline-and-indent) ) ) (defun vhdl-go-to-this-indent (step indent-level) "Move point repeatedly by lines till the current line has given indent-level or less, or the start/end of the buffer is hit. Ignore blank lines, statement labels, block/loop names." (while (and (zerop (forward-line step)) (or (looking-at "^[ ]*$") (looking-at "^[ ]*--") (looking-at "^<<[A-Za-z0-9_]+>>") (looking-at "^[A-Za-z0-9_]+:") (> (current-indentation) indent-level))) nil) ) (defun vhdl-backward-to-same-indent () "Move point backwards to nearest line with same indentation or less. If not found, point is left at top of buffer." (interactive) (vhdl-go-to-this-indent -1 (current-indentation)) (back-to-indentation) ) (defun vhdl-forward-to-same-indent () "Move point forwards to nearest line with same indentation or less. If not found, point is left at start of last line in buffer." (interactive) (vhdl-go-to-this-indent 1 (current-indentation)) (back-to-indentation) ) (defun vhdl-in-comment () "Check if point is to right of beginning comment delimiter." (interactive) (let ((opoint (point))) (save-excursion ; finds an unquoted comment (beginning-of-line) (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*--" opoint t) ) ) ) (defun vhdl-in-quote () "Check if point is in a quoted string." (interactive) (let ((not-string t) (opoint (point))) (save-excursion ; preceeeded by odd number of quotes? (beginning-of-line) (re-search-forward "^\\([^\"]*\"[^\"]*\"\\)*[^\"]*\"" opoint t) ) ) ) (defun vhdl-outer-space (count) "Self-insert space(s), do indent-new-comment-line if in comment and past end-comment-column." (interactive "p") (expand-abbrev) (cond ((< (current-column) end-comment-column) (self-insert-command count)) ((vhdl-in-comment) (while (> (current-column) end-comment-column) (forward-word -1)) (while (> (preceding-char) ? ) (forward-word -1)) (delete-horizontal-space) (indent-new-comment-line) (end-of-line nil) (insert-char ? count)) ) ) (defun vhdl-field (prompt &optional following-string) "PROMPT for string and insert it in buffer with optional FOLLOWING-STRING." (let ((opoint (point))) (insert "[" prompt "]") (let ((string (read-string (concat "[" prompt "]: ")))) (delete-region opoint (point)) (insert string (or following-string "")) string ) ) ) (defun vhdl-get-choice-list () "read from user a choice list." (let ( (cpoint (point)) (margin (current-column)) (choice nil) ) (while (not (string-equal (vhdl-field "choice") "")) (setq cpoint (point)) (insert " |\n") (indent-to margin) (setq choice t) ) (if choice (progn (delete-region cpoint (point)) t); return t nil; return nil ) ) ) (defun vhdl-get-name-list(&optional name &optional no-parenthesis) "read from user a name list. Do not add parenthesis if there is an optional ARG whose value is t. Else add parenthesis. Arguments ending with ';' or ',' are presumed single and stacked." (let ( (cpoint (point)) margin args) (if (not no-parenthesis) (insert " (")) (setq margin (current-column)) (if (string-equal (setq args (vhdl-field name)) "") (progn (delete-region cpoint (point)) nil); return nil (progn (while (string-match "[,;]$" args) (newline) (indent-to margin) (setq args (vhdl-field name)) ) (if (not no-parenthesis) (insert ")")) t); return t if there is an arg ) ) ) (defun vhdl-get-field (field-type &optional mode) "insert a {list of names: mode typename := initialize} structure" (interactive) (if (not (vhdl-get-name-list field-type t)) nil (progn (insert ":") (indent-to 32 1) (if mode (progn (vhdl-field "mode") (indent-to 40 1)) ) (vhdl-field "type-name") (let ( (cpoint (point)) ) (insert " := ") (if (string-equal (vhdl-field "initialize") "") (delete-region cpoint (point)))) t) ) ) (defun vhdl-next-block (count) "Exit this block of code and advance to the next." (interactive "p") (if (> (recursion-depth) 0) (exit-recursive-edit) (re-search-forward "^\\([ ]*end .*\\|[ \t]+\\)$" nil 1 count) (if (> (preceding-char) ? ) (forward-char 1)) ) ) (defun vhdl-begin-end (&optional name) "Insert a begin ... end pair with optional NAME after the end. Point is left between them." (if (and name (listp name)) (progn (insert-char ?\n 1) (indent-to (cdr name)) (setq name (car name)) ) (newline-and-indent) ) (let ((return (point)) (margin (current-column))) (newline) (indent-to margin) (insert "BEGIN" (and name (concat " -- " name)) " \n") (indent-to (+ margin vhdl-indent)) (newline) (indent-to margin) (insert "END" (and name (concat " " name)) ";") (goto-char return) ) ) (defun vhdl-get-arg-list () "Read from user a procedure or function argument list. Add parens unless arguments absent, and insert into buffer. Individual arguments are arranged vertically if entered one-at-a-time. Arguments ending with ';' or ',' are presumed single and stacked." (insert " (") (let (args (margin (current-column))) (if (string-equal (setq args (vhdl-field "arguments")) "") (backward-delete-char 2) (progn (while (string-match "[,;]$" args) (newline) (indent-to margin) (setq args (vhdl-field "next argument")) ) (insert 41) ;close-paren ) ) ) ) (defun vhdl-get-subprogram-name () "Return (without moving point or mark) a pair whose CAR is the name of the function or procedure whose spec immediately precedes point, and whose CDR is the column where the procedure/function/process keyword was found." (save-excursion (let ((vhdl-proc-indent 0) (case-fold-search t)) (if (re-search-backward "\\\\|\\\\|\\" nil t) (if (vhdl-in-comment) (vhdl-get-subprogram-name) (setq vhdl-proc-indent (current-column)) (forward-word 2) (let ((p2 (point))) (forward-word -1) (cons (buffer-substring (point) p2) vhdl-proc-indent))) (cons "NAME?" vhdl-proc-indent))) ) ) (defun vhdl-next-block (count) "Exit this block of code and advance to the next." (interactive "p") (if (> (recursion-depth) 0) (exit-recursive-edit) (re-search-forward "^\\([ ]*end .*\\|[ \t]+\\)$" nil 1 count) (if (> (preceding-char) ? ) (forward-char 1)) ) ) (defun vhdl-stutter-caps (count) "Double first letters of a word replaced by a single capital of the letter." (interactive "p") (if (and (= (preceding-char) last-input-char) ; doubled (or (= (point) 2) ; beginning of buffer (/= (char-syntax (char-after (- (point) 2))) ?w) ;not mid-word (< (char-after (- (point) 2)) ?A)));alfa-numeric (progn (delete-char -1) (insert-char (- last-input-char 32) count)) (self-insert-command count) ) ) (defun vhdl-stutter-close-bracket () " ']' --> ')', ')]' --> ']'" (interactive) (if (= (preceding-char) 41) ; close-paren (progn (delete-char -1) (insert-char 93 1)) ; close-bracket (insert-char 41 1) ; close-paren ) (blink-matching-open) ) (defun vhdl-stutter-semicolon () "';;' --> ' : ', ': ;' --> ' := '" (interactive) (cond ((= (preceding-char) last-input-char) (progn (delete-char -1) (insert " : "))) ((and (eq last-command 'vhdl-stutter-colon) (= (preceding-char) ? )) (progn (delete-char -1) (insert "= "))) (t (insert-char 59 1)) ; semi-colon ) (setq this-command 'vhdl-stutter-colon) ) (defun vhdl-stutter-open-bracket () " '[' --> '(', '([' --> '['" (interactive) (if (= (preceding-char) 40) ; open-paren (progn (delete-char -1) (insert-char 91 1)) ; open-bracket (insert-char 40 1) ; open-paren ) ) (defun vhdl-stutter-quote () "'' --> """ (interactive) (if (= (preceding-char) last-input-char) (progn (delete-backward-char 1) (insert-char 34 1)) ; double-quote (insert-char 39 1) ; single-quote ) ) (defun vhdl-stutter-comma () " ',,' --> '<='" (interactive) (cond ((= (preceding-char) last-input-char) (progn (delete-char -1) (insert " <= "))) (t (insert-char 44 1)) ; comma ) ) (defun vhdl-stutter-period () " '..' --> '=>'" (interactive) (cond ((= (preceding-char) last-input-char) (progn (delete-char -1) (insert " => "))) (t (insert-char 46 1)) ; period ) ) (defun vhdl-paired-parens () "Insert a pair of round parentheses, placing point between them." (interactive) (insert "()") (backward-char) ) (defun vhdl-stutter-dash (count) "-- starts a comment, --- starts a display comment" (interactive "p") (cond ((and abbrev-start-location (= abbrev-start-location (point))) (setq abbrev-start-location nil) (goto-char last-abbrev-location) (beginning-of-line nil) (vhdl-display-comment)) ((/= (preceding-char) ?-) ; standard dash (minus) (self-insert-command count)) (t (delete-char -1) ; delete the previous dash (message "Enter - for display comment, CR for commenting-out code,\ else 1st char of inline comment") (let ((next-input (read-char))) (if (= next-input ?-) ; triple dash (vhdl-display-comment) (setq unread-command-char next-input) ;pushback the char (vhdl-inline-comment) ) ) ) ) ) ;############################################################################# ; VHDL CONSTRUCTS ;############################################################################# (defun vhdl-architecture () "Insert architecture, prompting for name and related entity" (interactive) (let* ((margin (current-column)) (name)) (insert "ARCHITECTURE ") (setq name (vhdl-field "architecture name" " OF ")) (vhdl-field "entity name" " IS") (vhdl-begin-end (cons (or name "") margin)) (indent-to (+ margin vhdl-indent)) ) ) (defun vhdl-array () "Insert array type definition, prompting for component type, leaving the user to type in the index subtypes." (interactive) (insert "ARRAY (") (vhdl-field "range[s]" ") OF ") (vhdl-field "component type") (insert-char 59 1) ; semi-colon ) (defun vhdl-type-array () "insert array type definition, prompting details." (interactive) (insert "TYPE ") (vhdl-field "array type name" " IS ") (vhdl-array) ) (defun vhdl-assert () "inserts a assert skeleton" (interactive) (let ( (margin (current-column)) ) (insert "assert ") (vhdl-field "false evaluating boolean-expression" "\n") (indent-to (+ margin vhdl-indent)) (insert "report ") (vhdl-field "string-expression" "\n") (indent-to (+ margin vhdl-indent)) (insert "severity ") (vhdl-field "note, warning, error, failure" ";\n") (indent-to margin) ) ) (defun vhdl-attribute () "Inserts a attribute-declaration skeleton" (interactive) (insert "ATTRIBUTE ") (vhdl-field "attribute name" " : ") (vhdl-field "type-mark" ";") ) (defun vhdl-block () "insert a block and indent for the 1st declaration." (interactive) (let ((name (vhdl-field "block name" ": block"))) ;; handle guard expression, generic and port stuff here (insert ?() (vhdl-field "guard expression") (insert ?)) (vhdl-begin-end (concat "BLOCK " name)) ; end let (indent-to (+ (current-column) vhdl-indent) ) ) ) (defun vhdl-case () "Build skeleton case statement, prompting for the selector expression. starts up the first when clause, too." (interactive) (let ((margin (current-column)) (name)) (insert "CASE ") (setq name (vhdl-field "selector expression" " IS\n\n")) (indent-to margin) (insert "END CASE;") ; add a comment at the end so we know which case is closed (vhdl-inline-comment) (insert name) (forward-line -1) (indent-to (+ margin vhdl-indent)) (vhdl-when) ) ) (defun vhdl-component () "Inserts a component skeleton" (interactive) (let ((margin (current-column))) (insert "COMPONENT ") (vhdl-field "component-name" "\n") (vhdl-indent-line) (insert "-- generic ();") (newline-and-indent) (insert "PORT (") (vhdl-field " : " ");\n") (indent-to margin)) (insert "END COMPONENT;") ) (defun vhdl-component-instance () "inserts a component-instance skeleton" (interactive) (let ((margin (current-column))) (vhdl-field "instance name" " : ") (vhdl-field "component-type") (let ( (opoint (point)) ) (newline) (indent-to (+ margin vhdl-indent)) (if (not (vhdl-generic-map)) (delete-region opoint (point)) ) ) (insert ";\n") (indent-to margin) ) ) (defun vhdl-configuration-spec () "Inserts a configuration-spec skeleton" (interactive) (insert "FOR ") (vhdl-field "list of components" ": ") (vhdl-field "component type" "\n") (vhdl-indent-line) (let ( (margin (current-column)) ) (insert "USE ENTITY ") (vhdl-field "lib.entity(arch)") (let ( (opoint (point)) ) (insert "\n") (indent-to margin) (if (not (vhdl-generic-map)) (delete-region opoint (point)) ) ) (insert ";\n") (indent-to (- margin vhdl-indent)) ) ) (defun vhdl-configuration-declaration () "Inserts a configuration-declaration skeleton" (interactive) (let ((margin (current-column)) (dummy (insert "CONFIGURATION ")) (name (vhdl-field "name" " OF "))) (vhdl-field "item to be configured" " IS\n\n") (indent-to margin) (insert "END " name ";")) (end-of-line 0) (vhdl-indent-line) ) (defun vhdl-constant () "Start insertion of CONSTANT declaration, prompting for the constant name." (interactive) (insert "CONSTANT ") (let (abbrev-mode) (tab-to-tab-stop)) (vhdl-field "constant name") (let (abbrev-mode) (tab-to-tab-stop)) (let (abbrev-mode) (tab-to-tab-stop)) (insert " : ") (vhdl-field "constant type " " := ") (vhdl-field "value " ";") ) (defun vhdl-else () "Add an else clause inside an if-then-end-if clause." (interactive) (vhdl-untab) (insert "ELSE\n") (vhdl-indent-line) ) (defun vhdl-elsif () "Add elsif clause to IF statement, prompting for the boolean-expression." (interactive) (vhdl-untab) (insert "ELSIF (") (vhdl-field "condition" ") THEN\n") (vhdl-indent-line) ) (defun vhdl-entity () "Insert entity, prompting for name" (interactive) (let* ((margin (current-column)) (name)) (insert "ENTITY ") (setq name (vhdl-field "entity name" " IS\n\n")) (indent-to margin) (insert "END " name ";")) (forward-line -1) (vhdl-indent-line) ) (defun vhdl-exit () "Insert an exit statement, prompting for loop name and condition." (interactive) (insert "EXIT ") (if (string-equal (vhdl-field "name of loop to exit" " ") "") (delete-char -1)) (let ((opoint (point)) (exit (vhdl-field "exit condition" ";"))) (cond ((string-equal exit "") (delete-char -1)) ((string-match "^ *[Ww][Hh][Ee][Nn] +" exit) ()) (t (goto-char opoint) (insert "WHEN ") (end-of-line nil)) ) ) ) (defun vhdl-for-loop () "Build a skeleton for-loop statement, prompting for the loop parameters." (interactive) (let* ((margin (current-column)) (name (vhdl-field "loop name")) (named (not (string-equal name ""))) (index)) (if named (insert " : ")) (insert "FOR ") (setq index (vhdl-field "loop variable" " IN ")) (vhdl-field "range" " LOOP\n\n") (indent-to margin) (insert "END LOOP" (if named (concat " " name ";")?;)) (if (not named) (progn (vhdl-inline-comment) (insert index))) (forward-line -1) (vhdl-indent-line) ) ) (defun vhdl-function-spec () "Insert a function specification. Prompts for name and arguments." (interactive) (let* ((margin (current-column))) (insert "FUNCTION ") (vhdl-field "function name") (vhdl-get-arg-list) (insert " RETURN ") (vhdl-field "result typemark" ";\n") (indent-to margin)) ) (defun vhdl-function-body () "Insert frame for function body." (interactive) (let ( (margin (current-column)) (func-name) ) (insert "FUNCTION ") (vhdl-field "function name") (vhdl-get-arg-list) (insert " RETURN ") (vhdl-field "result typemark") (insert " IS") (vhdl-begin-end (vhdl-get-subprogram-name)) (indent-to (+ margin vhdl-indent))) ) (defun vhdl-generate () "Inserts a generate skeleton - ****** set up if or for scheme" (interactive) (let ((margin (current-column)) (label (vhdl-field "label" ": "))) (vhdl-field "generate-scheme (FOR | IF)" " GENERATE\n\n") (indent-to margin) (insert "END GENERATE " label ";")) (end-of-line 0) (vhdl-indent-line) ) (defun vhdl-get-generic-arg-list () "get {generics : type-name;} list" (interactive) (insert " (") (let ( (margin (current-column)) cpoint args) (if (not (setq args (vhdl-get-field "generic-name"))) (progn (backward-delete-char 2) nil) (while args (progn (setq cpoint (point)) (insert ";\n") (indent-to margin) (setq args (vhdl-get-field "generic-name"))) ) (delete-region cpoint (point)) (insert ")") t) ) ) (defun vhdl-generic () "inserts a generic skeleton." (interactive) (let ((margin (current-column)) (opoint (point)) args) (insert "generic") (setq args (vhdl-get-generic-arg-list)) (if (not args) (delete-region opoint (point)) (progn (insert ";\n") (indent-to margin)) ) (vhdl-port) ) ) (defun vhdl-generic-map () "inserts a generic map skeleton." (interactive) (let ((opoint (point)) (margin (current-column)) args) (insert "generic map") (setq args (vhdl-get-arg-list)) (if (not args) (delete-region opoint (point)) (progn (insert "\n") (indent-to margin)) ) (vhdl-port-map)) ) (defun vhdl-header () "Insert a comment block containing the module title, author, etc." (interactive) (let ((start (point))) (insert " ------------------------------------------------------------------------------- -- copyright 1993 -- All Rights Reserved -- -- File name : " (buffer-name) " -- Title : [] -- Module : [] -- -- Purpose : [] -- -- Roadmap : ------------------------------------------------------------------------------- -- Modification History : -- Date \t\tAuthor \tRevision \tComments -- " (current-time-string) "\t" (user-full-name) "\tRev A \t\tCreation ------------------------------------------------------------------------------- ") (goto-char start) (search-forward "[]") (replace-match (read-string "Title: ") t t) (search-forward "[]") (replace-match (read-string "Module: ") t t) (search-forward "[]") (replace-match (read-string "Purpose: ")) ;(let (tail (processes (- (preceding-char) 48))) ; (search-forward "[]") (replace-match (read-string "Process Name: ") t t) ; (search-forward "[Description]") ; (message "Enter description followed by linefeed.") (sit-for 0) ; (delete-char -13) ; (setq tail (save-excursion (forward-line 1) (copy-marker (point)))) ; (recursive-edit) ; (while (> (setq processes (1- processes)) 0) ; (goto-char tail) ; (open-line 1) ; (insert "-- " (read-string "Process Name: ") ":\n") ; (insert "-- ") ; (message "Enter description followed by linefeed.") (sit-for 0) ; (recursive-edit) ; ) ;) ;(search-forward "[]") (delete-char -2) ;more stuff here to go back and edit [] fields ) ) (defun vhdl-if () "Insert skeleton if statement, prompting for a boolean-expression." (interactive) (let ((margin (current-column))) (insert "IF (") (vhdl-field "condition" ") THEN\n\n") (indent-to margin) (insert "END IF;") (forward-line -1) (vhdl-indent-line) ) ) (defun vhdl-library () "insert a library statement." (interactive) (let ( (margin (current-column)) (cpoint (point)) (use t) libname args) (insert "LIBRARY ") (if (string-equal (setq libname (vhdl-field "library-name" ";\n")) "") (progn (delete-region cpoint (point)) nil); return nil (progn (while use (setq cpoint (point)) (indent-to (+ margin vhdl-indent)) (insert "use " libname ".") (if (string-equal (setq args (vhdl-field "package-name" ".all;\n")) "") (progn (setq use nil) (delete-region cpoint (point)) (indent-to margin)) ) ) t ); return t ) ) ) (defun vhdl-loop () "insert a skeleton loop statement. exit statement added by hand." (interactive) (let* ((margin (current-column)) (name (vhdl-field "loop name")) (named (not (string-equal name "")))) (if named (insert " : ")) (insert "LOOP \n\n") (indent-to margin) (insert "END LOOP" (if named (concat " " name ";") ?;)) (forward-line -1) (vhdl-indent-line) ) ) (defun vhdl-others () " Simply capitalize OTHERS." (interactive) (insert "OTHERS ") ) (defun vhdl-package-spec () "Insert a skeleton package specification." (interactive) (let ((margin (current-column)) (dummy (insert "PACKAGE ")) (name (vhdl-field "package name" " IS\n\n"))) (indent-to margin) (insert "END " name ";") (forward-line -1) ) ) (defun vhdl-package-body () "Insert a skeleton package body -- includes a begin statement." (interactive) (let ((margin (current-column)) (dummy (insert "PACKAGE BODY ")) (name (vhdl-field "package name" " IS\n\n"))) (indent-to margin) (insert "END " name ";") (forward-line -1) (vhdl-indent-line) ) ) (defun vhdl-get-port-arg-list () "get {port-name : mode typename := intialization} list" (interactive) (insert " (") (let ( (cpoint (point)) (margin (current-column)) args) (if (not (setq args (vhdl-get-field "port-name" t))) (progn (backward-delete-char 2) nil) (while args (progn (setq cpoint (point)) (insert ";\n") (indent-to margin) (setq args (vhdl-get-field "port-name" t))) ) (delete-region cpoint (point)) (insert ")") t ) ) ) (defun vhdl-port () "insert a skeleton port." (interactive) (let ((margin (current-column)) (opoint (point))) (insert "port") (if (not (vhdl-get-port-arg-list)) (progn (delete-region opoint (point)) nil) (progn (insert ";\n") (indent-to margin) t) ) ) ) (defun vhdl-port-map () "insert a skeleton port." (interactive) (let ( (opoint (point)) ) (insert "port map") (if (not (vhdl-get-arg-list)) (progn (delete-region opoint (point)) nil) t ; return t if port map stays otherwise return nil ) ) ) (defun vhdl-procedure-spec () "Insert a procedure specification, prompting for its name and arguments." (interactive) (let ((margin (current-column))) (insert "PROCEDURE ") (vhdl-field "procedure name") (vhdl-get-arg-list) (insert ";\n") (indent-to margin)) ) (defun vhdl-procedure-body () "Inserts a procedure skeleton" (interactive) (let* ((margin (current-column)) (line (save-excursion (beginning-of-line) (1+ (count-lines 1 (point))))) (name (vhdl-field "procedure name"))) (beginning-of-line) (indent-to margin) (insert "PROCEDURE ") (end-of-line) (vhdl-get-arg-list) (insert " IS\n") (vhdl-begin-end (cons (concat "PROCEDURE " (or name "") ) margin)) (save-excursion (forward-line (- line (save-excursion (beginning-of-line) (1+ (count-lines 1 (point)))))) (open-line 1) (indent-to margin) (vhdl-display-comment) (insert (concat "Procedure: " name " ")) (vhdl-return) (insert "Purpose: ") (vhdl-return) (insert "Inputs: ") (vhdl-return) (insert "Outputs: ") ) (indent-to (+ margin vhdl-indent)) ) ) (defun vhdl-process () "Inserts a process skeleton" (interactive) (let* ((margin (current-column)) (line (save-excursion (beginning-of-line) (1+ (count-lines 1 (point))))) (name (vhdl-field "process name")) (named (not (string-equal name "")))) (if named (progn (insert " : ") (setq name (concat " " name)))) (insert "PROCESS") (vhdl-get-arg-list) (vhdl-begin-end (cons (concat "PROCESS" (or name "") ) margin)) (save-excursion (forward-line (- line (save-excursion (beginning-of-line) (1+ (count-lines 1 (point)))))) (open-line 1) (indent-to margin) (vhdl-display-comment) (insert "Process: ") (if named (insert (concat name " "))) (vhdl-return) (insert "Purpose: ") (vhdl-return) (insert "Inputs: ") (vhdl-return) (insert "Outputs: ") ) (indent-to (+ margin vhdl-indent)) ) ) (defun vhdl-record () "Insert a skeleton record type declaration." (interactive) (let ((margin (current-column))) (insert "RECORD\n") (newline) (indent-to margin) (insert "END RECORD;") (end-of-line 0) (vhdl-indent-line)) ) (defun vhdl-record-field () "insert a record field" (interactive) (if (string-equal (vhdl-field "field-name") "") nil (progn (insert ":") (indent-to 32 1) (vhdl-field "type-name") t) ) ) (defun vhdl-type-record () "insert a skeleton record type declaration." (interactive) (let ((margin (current-column))) (insert "type ") (vhdl-field "record-type-name" " is record\n") (indent-to (+ margin vhdl-indent)) (while (vhdl-record-field) (insert ";\n") (indent-to (+ margin vhdl-indent)) ) (vhdl-untab) (insert "end record;\n\n") (indent-to margin) ) ) (defun vhdl-return-value () "Insert a VHDL return statement, prompting for return value." (interactive) (let ((margin (current-column))) (insert "RETURN (") (vhdl-field "return expression" ");\n") (indent-to margin)) ) (defun vhdl-selected-signal-assignment () "Inserts a selected signal assignment. Does first vhdl-selected-when" (interactive) (insert "WITH ") (vhdl-field "selector expression" " SELECT\n") (vhdl-indent-line) (vhdl-field "target signal" " <= ") (vhdl-field "options (guarded | transport)" "\n") (vhdl-indent-line) (vhdl-selected-when) (newline-and-indent) (insert-char 59 1) ;semi-colon (end-of-line 0) ) (defun vhdl-selected-when () "Inserts a when section into a selected signal assignment." (interactive) (vhdl-field "waveform1" " WHEN ") (vhdl-field "choices1 " ",") (newline-and-indent) ) (defun vhdl-signal () "Start insertion of a signal declaration, prompting for the signal name." (interactive) (insert "SIGNAL ") (let (abbrev-mode) (tab-to-tab-stop)) (vhdl-field "signal name") (let (abbrev-mode) (tab-to-tab-stop)) (let (abbrev-mode) (tab-to-tab-stop)) (insert " : ") (vhdl-field "signal type [ := initialization ]" ";") ) (defun vhdl-subtype () "Start insertion of a subtype declaration, prompting for the subtype name." (interactive) (insert "SUBTYPE ") (vhdl-field "subtype name:" " IS ") (vhdl-field "insert subtype indication, and resolution function" ";") ) (defun vhdl-type () "Start insertion of a type declaration, prompting for the type name." (interactive) (insert "TYPE ") (vhdl-field "type name") (insert " IS ") (vhdl-field "type definition" ";") (backward-char 1) ) (defun vhdl-use () "inserts a use clause, prompting for the list of packages used." (interactive) (let ( (margin (current-column)) ) (insert "USE ") (vhdl-field "list of packages to use" ";\n") (indent-to margin) ) ) (defun vhdl-variable () "Start insertion of a variable declaration, prompting for variable name." (interactive) (insert "VARIABLE ") (let (abbrev-mode) (tab-to-tab-stop)) (vhdl-field "variable name") (let (abbrev-mode) (tab-to-tab-stop)) (insert " : ") (vhdl-field "variable type [ := initialization ]" ";") ) (defun vhdl-wait () "inserts a wait skeleton" (interactive) (let ( (margin (current-column)) cpoint) (insert "WAIT") (setq cpoint (point)) (insert " ON ") (if (vhdl-get-name-list "sensitivity-list" t) (setq cpoint (point)) (delete-region cpoint (point)) ) (insert " UNTIL ") (if (string-equal (vhdl-field "Boolean-expression") "") (delete-region cpoint (point)) (setq cpoint (point)) ) (insert " FOR ") (if (string-equal (vhdl-field "time-expression") "") (delete-region cpoint (point)) ) (insert ";\n") (indent-to margin) ) ) (defun vhdl-when () " Simply capitalize WHEN. Support for WHEN within CASE and SELECT and EXIT has been removed due to complexity (and limited value)" (interactive) (insert "WHEN ") ; ; "Start a case statement alternative with a when clause." ; (interactive) ; (if (save-excursion ; (forward-line -1) ; (while (looking-at "^[ \t]*$") (forward-line -1)) ; (not (looking-at "^[ \t]*CASE "))) ; (backward-delete-char-untabify vhdl-indent nil) ; ) ; (insert "WHEN ") ; (vhdl-field "'|'-delimited choice list" " =>") ; (newline-and-indent) ) (defun vhdl-while-loop () (interactive) (let* ((margin (current-column)) (name (vhdl-field "loop name")) (named (not (string-equal name "")))) (if named (insert " : ")) (insert "WHILE ") (vhdl-field "entry condition" " LOOP\n\n") (indent-to margin) (insert "END LOOP" (if named (concat " " name ";") ?;)) (forward-line -1) (vhdl-indent-line) ) ) (defun vhdl-conditional-signal-assignment () "Inserts a conditional-signal-assignment skeleton" (interactive) (vhdl-field "target" " <= ") (vhdl-field "options (guarded | transport)" "\n") (vhdl-indent-line) (vhdl-conditional-waveform) (insert 59 1) ;semi-colon (backward-char) ) (defun vhdl-conditional-waveform () "Inserts a conditional-signal-assignment waveform." (interactive) (vhdl-field "+ when boolean-expr [else]") (newline-and-indent) ) ;############################################################################# ; LOGIC FUNCTIONS ;############################################################################# (defun vhdl-and () " Simply capitalize AND." (interactive) (insert "AND ") ) (defun vhdl-or () " Simply capitalize OR." (interactive) (insert "OR ") ) (defun vhdl-nand () " Simply capitalize NAND." (interactive) (insert "NAND ") ) (defun vhdl-nor () " Simply capitalize NOR." (interactive) (insert "NOR ") ) (defun vhdl-xor () " Simply capitalize XOR." (interactive) (insert "XOR ") ) (defun vhdl-xnor () " Simply capitalize XNOR." (interactive) (insert "XNOR ") ) (defun vhdl-not () " Simply capitalize NOT." (interactive) (insert "NOT ") ) ;############################################################################# ; IDIOMS ;############################################################################# (defun vhdl-clocked-wait () "Inserts a VHDL rising edge clocked WAIT statement" (interactive) (insert "WAIT UNTIL ") (let* ((clock (vhdl-field "Clock Name"))) (insert "'EVENT AND ") (insert clock) (insert " = '1';") (vhdl-return) ) ) (defun vhdl-clock-async-reset () "Inserts a VHDL rising edge clock and asynchronous reset" (interactive) (let* ( (margin (current-column))) (vhdl-inline-comment) (insert "Asynchronous (active low) reset") (vhdl-return) (insert "IF ( ") (vhdl-field "Active Low Reset Line") (insert " = LOGIC0 ) THEN\n\n") (indent-to margin) (vhdl-inline-comment) (insert "This guards the whole process for a rising clock edge. ") (vhdl-return) (insert "That causes all the signals set in here to be registers.\n") (indent-to margin) (insert "ELSIF ( ") (let* ((clock (vhdl-field "Clock Name"))) (insert "'EVENT AND ") (insert clock) (insert " = LOGIC1 ) THEN\n") (indent-to margin) (insert "END IF;") (vhdl-inline-comment)(insert clock)) (forward-line -1) (end-of-line nil) (vhdl-return) ) ) ;############################################################################# ; COMMENT FUNCTIONS ;############################################################################# (defun vhdl-comment-indent () (let* ((opoint (point)) (col (progn (forward-line -1) (if (re-search-forward "--" opoint t) (- (current-column) 2) ;Existing comment at bol stays there. (goto-char opoint) (skip-chars-backward " \t") (max comment-column ;Else indent to comment column (1+ (current-column))) ;except leave at least one space. ) ) ) ) (goto-char opoint) col ) ) (defun vhdl-inline-comment () "Start a comment at the end of the line. If on line with code, indent at least comment-column. If starting after end-comment-column, start a new line." (interactive) (if (> (current-column) end-comment-column) (newline-and-indent)) (if (looking-at "[ \t]*$") ;end of line (let ((margin (current-column))) (delete-horizontal-space) (if (bolp) (progn (indent-to margin) (insert "-- ")) (indent-to comment-column) (insert "-- ") )) ; else code following current point implies commenting out code (if (= unread-command-char -1) (message "Enter CR if commenting out a line of code.")) (let (next-input code) (while (= (setq next-input (read-char)) 13) ; CR (insert "--"); or have a space after it? (forward-char -2) (next-line 1) (message "Enter CR if commenting out a line of code.") (setq code t) ) (if (not code) (progn (indent-to comment-column) (insert "-- ") ;hardwire to 2 spaces or use vhdl-indent? )) (setq unread-command-char next-input) ;pushback the char ) ) ) (defun vhdl-display-comment () "Inserts 3 comment lines at the current indent, making a display comment." (interactive) (cond ((and (bolp) (not (eolp))) (insert-char ?\n 1) (forward-char -1)) ((save-excursion (beginning-of-line nil) (not (looking-at "[ \t]*$"))) (progn (end-of-line) (newline-and-indent))) ) (let* ((col (current-column)) (len (- end-comment-column col))) (insert-char ?- len) (insert-char ?\n 2) (insert-char ? col) (insert-char ?- len) (end-of-line 0) (insert-char ? col) ) (insert "-- ") ;hardwire to 2 spaces or use vhdl-indent? ) (defun vhdl-comment-region (start end) "Comment out the region of vhdl code by inserting -- the first 2 columns of each line." ; see function indent.rigidly in indent.el (interactive "r") (save-excursion (goto-char end) (setq end (point-marker)) (goto-char start) (or (bolp) (forward-line 1)) (while (< (point) end) (let ( (indent (current-indentation)) ) (delete-region (point) (progn (skip-chars-forward " \t") (point))) (or (eolp) (progn (insert "--") (indent-to (+ indent 2)) ) )) (forward-line 1)) (move-marker end nil) ) ) (defun vhdl-uncomment-region (start end) "Uncomment the region of vhdl code by removing -- from the begining of each line." (interactive "r") (save-excursion (goto-char end) (setq end (point-marker)) (goto-char start) (or (bolp) (forward-line 1)) (while (< (point) end) (let ( (bolpoint (point)) indent ) (skip-chars-forward " ---\t") (setq indent (current-column)) (delete-region bolpoint (point)) (or (eolp) (progn (indent-to (max 0 (- indent 2)) )) )) (forward-line 1)) (move-marker end nil) ) ) ;############################################################################# ; HOOKED ABBREV FUNCTIONS ;############################################################################# (defun vhdl-hooked-abbrev (fun) "Do FUNCTION, if syntax says abbrev is a keyword, invoked by hooked abbrev, but not if inside a comment or quote)" (if (or (vhdl-in-comment) (vhdl-in-quote) (save-excursion (forward-word -1) (looking-at "END"))) (progn (undo-start) ;unexpand-abbrev has capitalization problem on null (undo-more 1) (forward-word 1)) (let ((invoke-char last-command-char)) (funcall fun) (if (= invoke-char ?-) (setq abbrev-start-location (point))) (if (or (eq (key-binding "\^?") 'backward-delete-char-untabify) (eq (key-binding "\^?") 'backward-delete-char)) (setq unread-command-char ?\^?) ; push back a delete char (if (= (preceding-char) invoke-char) (delete-char -1))) ) ; ^ UGLY, but that's what you get when you want it both ways ) ) (defun vhdl-architecture-hook () "hooked version of vhdl-architecture." (vhdl-hooked-abbrev 'vhdl-architecture)) (defun vhdl-array-hook () "hooked version of vhdl-array." (vhdl-hooked-abbrev 'vhdl-array)) (defun vhdl-type-array-hook () "hooked version of vhdl-type-array." (vhdl-hooked-abbrev 'vhdl-type-array)) (defun vhdl-assert-hook () "hooked version of vhdl-assert." (vhdl-hooked-abbrev 'vhdl-assert)) (defun vhdl-attribute-hook () "hooked version of vhdl-attribute." (vhdl-hooked-abbrev 'vhdl-attribute)) (defun vhdl-block-hook () "hooked version of vhdl-block." (vhdl-hooked-abbrev 'vhdl-block)) (defun vhdl-case-hook () "hooked version of vhdl-case." (vhdl-hooked-abbrev 'vhdl-case)) (defun vhdl-comment-region-hook () "hooked version of vhdl-comment-region." (vhdl-hooked-abbrev 'vhdl-comment-region)) (defun vhdl-uncomment-region-hook () "hooked version of vhdl-uncomment-region." (vhdl-hooked-abbrev 'vhdl-uncomment-region)) (defun vhdl-component-hook () "hooked version of vhdl-component." (vhdl-hooked-abbrev 'vhdl-component)) (defun vhdl-component-instance-hook () "hooked version of vhdl-component-instance." (vhdl-hooked-abbrev 'vhdl-component-instance)) (defun vhdl-configuration-declaration-hook () "hooked version of vhdl-configuration-declaration." (vhdl-hooked-abbrev 'vhdl-configuration-declaration)) (defun vhdl-configuration-spec-hook () "hooked version of vhdl-configuration-spec." (vhdl-hooked-abbrev 'vhdl-configuration-spec)) (defun vhdl-constant-hook () "hooked version of vhdl-constant." (vhdl-hooked-abbrev 'vhdl-constant)) (defun vhdl-display-comment-hook () "hooked version of vhdl-display-comment." (vhdl-hooked-abbrev 'vhdl-display-comment)) (defun vhdl-else-hook () "hooked version of vhdl-else." (vhdl-hooked-abbrev 'vhdl-else)) (defun vhdl-elsif-hook () "hooked version of vhdl-elsif." (vhdl-hooked-abbrev 'vhdl-elsif)) (defun vhdl-entity-hook () "hooked version of vhdl-entity." (vhdl-hooked-abbrev 'vhdl-entity)) (defun vhdl-exit-hook () "hooked version of vhdl-exit." (vhdl-hooked-abbrev 'vhdl-exit)) (defun vhdl-for-loop-hook () "hooked version of vhdl-for-loop." (vhdl-hooked-abbrev 'vhdl-for-loop)) (defun vhdl-function-body-hook () "hooked version of vhdl-function-body." (vhdl-hooked-abbrev 'vhdl-function-body)) (defun vhdl-function-spec-hook () "hooked version of vhdl-function-spec." (vhdl-hooked-abbrev 'vhdl-function-spec)) (defun vhdl-generate-hook () "hooked version of vhdl-generate." (vhdl-hooked-abbrev 'vhdl-generate)) (defun vhdl-generic-hook () "hoooked version of vhdl-generic." (vhdl-hooked-abbrev 'vhdl-generic)) (defun vhdl-generic-map-hook () "hooked version of vhdl-generic-map." (vhdl-hooked-abbrev 'vhdl-generic-map)) (defun vhdl-header-hook () "hooked version of vhdl-header." (vhdl-hooked-abbrev 'vhdl-header)) (defun vhdl-if-hook () "hooked version of vhdl-if." (vhdl-hooked-abbrev 'vhdl-if)) (defun vhdl-library-hook () "hooked version of vhdl-library." (vhdl-hooked-abbrev 'vhdl-library)) (defun vhdl-loop-hook () "hooked version of vhdl-loop." (vhdl-hooked-abbrev 'vhdl-loop)) (defun vhdl-others-hook () "hooked version of vhdl-others." (vhdl-hooked-abbrev 'vhdl-others)) (defun vhdl-package-body-hook () "hooked version of vhdl-package-body." (vhdl-hooked-abbrev 'vhdl-package-body)) (defun vhdl-package-spec-hook () "hooked version of vhdl-package-spec." (vhdl-hooked-abbrev 'vhdl-package-spec)) (defun vhdl-port-hook () "hooked version of vhdl-port." (vhdl-hooked-abbrev 'vhdl-port)) (defun vhdl-port-map-hook () "hooked version of vhdl-port-map." (vhdl-hooked-abbrev 'vhdl-port-map)) (defun vhdl-procedure-body-hook () "hooked version of vhdl-procedure-body." (vhdl-hooked-abbrev 'vhdl-procedure-body)) (defun vhdl-procedure-spec-hook () "hooked version of vhdl-procedure-spec." (vhdl-hooked-abbrev 'vhdl-procedure-spec)) (defun vhdl-process-hook () "hooked version of vhdl-process." (vhdl-hooked-abbrev 'vhdl-process)) (defun vhdl-record-hook () "hooked version of vhdl-record." (vhdl-hooked-abbrev 'vhdl-record)) (defun vhdl-return-hook () "hooked version of vhdl-return-value." (vhdl-hooked-abbrev 'vhdl-return-value)) (defun vhdl-selected-signal-assignment-hook () "hooked version of vhdl-selected-signal-assignment." (vhdl-hooked-abbrev 'vhdl-selected-signal-assignment)) (defun vhdl-selected-when-hook () "hooked version of vhdl-selected-when." (vhdl-hooked-abbrev 'vhdl-selected-when)) (defun vhdl-signal-hook () "hooked version of vhdl-signal." (vhdl-hooked-abbrev 'vhdl-signal)) (defun vhdl-subtype-hook () "hooked version of vhdl-subtype." (vhdl-hooked-abbrev 'vhdl-subtype)) (defun vhdl-type-hook () "hooked version of vhdl-type." (vhdl-hooked-abbrev 'vhdl-type)) (defun vhdl-type-record-hook () "hooked version of vhdl-type-record." (vhdl-hooked-abbrev 'vhdl-type-record)) (defun vhdl-use-hook () "hooked version of vhdl-use." (vhdl-hooked-abbrev 'vhdl-use)) (defun vhdl-variable-hook () "hooked version of vhdl-variable." (vhdl-hooked-abbrev 'vhdl-variable)) (defun vhdl-wait-hook () "hooked version of vhdl-wait." (vhdl-hooked-abbrev 'vhdl-wait)) (defun vhdl-when-hook () "hooked version of vhdl-when." (vhdl-hooked-abbrev 'vhdl-when)) (defun vhdl-while-loop-hook () "hooked version of vhdl-while-loop." (vhdl-hooked-abbrev 'vhdl-while-loop)) (defun vhdl-and-hook () "hooked version of vhdl-and." (vhdl-hooked-abbrev 'vhdl-and)) (defun vhdl-or-hook () "hooked version of vhdl-or." (vhdl-hooked-abbrev 'vhdl-or)) (defun vhdl-nand-hook () "hooked version of vhdl-nand." (vhdl-hooked-abbrev 'vhdl-nand)) (defun vhdl-nor-hook () "hooked version of vhdl-nor." (vhdl-hooked-abbrev 'vhdl-nor)) (defun vhdl-xor-hook () "hooked version of vhdl-xor." (vhdl-hooked-abbrev 'vhdl-xor)) (defun vhdl-xnor-hook () "hooked version of vhdl-xnor." (vhdl-hooked-abbrev 'vhdl-xnor)) (defun vhdl-not-hook () "hooked version of vhdl-not." (vhdl-hooked-abbrev 'vhdl-not)) (run-hooks 'vhdl-load-hook) ;############################################################################# ; END OF VHDL.EL ;############################################################################# ;############################################################################# ; Included VHDLGRIND FILE ;############################################################################# ; ;#!/bin/csh -f ;# vgrind a vhdl file, Usage: vhdlgrind [vgrind args] [filename] ;# This is a polyglot file, read by both csh and vgrind. ;# The environment variable TROFF should be set to your favorite *roff, ;# e.g. "/usr/ucb/ptroff" for postscript. Add " -F font" if you want a font ;# other than Courier. Set environment variable PRINTER to your local printer. ; ;if (! $?TROFF) then # if TROFF isn't set, assume local/ptroff with Courier ; setenv TROFF "/usr/local/ptroff -F Courier" ;else if ("$TROFF" =~ /usr/local/ptroff) then # if ptroff & no font, use Courier ; setenv TROFF "/usr/local/ptroff -F Courier" ;endif ;set n=$0; if ($0 !~ /*) set n=$cwd/$0 # absolute path to this file ;if ($#argv == 0) then # echo above header for naive users ; head -5 $n; exit ;endif ;@ num = $#argv - 1 ;(if ($argv[$#argv] =~ */*) cd $argv[$#argv]:h;\ ; /usr/ucb/vgrind -s7 -lvhdl -d $n $argv[$num] $argv[$#argv]:t &) ;exit ;# end of what csh reads, beginning of what vgrind reads ; ;vhdl|vhd:\ ; :pb=(^\d?(entity|architecture|configuration|procedure|function)\d\p\d|\(|;|\:):\ ; :bb=\d(begin|block|body|case|component|configuration\ ; |entity|for|if|loop|package|process|while|with)\d:\ ; :be=\dend:\ ; :cb=--:ce=$:\ ; :oc:\ ; :kw=abs access after alias all and architecture array assert attribute\ ; begin block body buffer bus\ ; case component configuration constant\ ; disconnect downto\ ; else elsif end entity exit\ ; file for function\ ; generate generic guarded\ ; if in inout is\ ; label library linkage loop\ ; map mod\ ; nand new next nor not null\ ; of on open or others out\ ; package port procedure process\ ; range record register rem report return reverse_range\ ; select severity signal subtype\ ; then to transport type\ ; units until use\ ; variable\ ; wait when while with\ ; xor: