Content


Abstract

This Lisp package for emacs provides a VHDL editing mode for emacs. This mode includes features like automatic syntax coloring, automatic indentation, word completion, and interactive generation of VHDL code. In addition, all of the powerful emacs editing commands can be used. Syntax coloring and automatic indentation allow your code to be clear and readable with a minimum of effort. Word completion allows you to type only the first part of a keyword or signal name (or any other text, actually) and hit the Tab character. Then, vhdl-mode will scan through the current buffer for words that start with that string, and repeated use of Tab will cycle through all of the matches. Also, it will scan through any other open buffers you have open to look through completions. No more typing in long signal names like bfctl_data_in_a. The automatic code generation feature is also extremely useful. For example, type process and hit space. You will be prompted to enter the label for the process, the sensitivity list, and a small comment description of the process. All will be generated using correct VHDL syntax, freeing you from having to remember it! The final feature included is called stuttering. Basically, by typing certain characters twice, you can generate hard to type sequences. For instance, typing ",," will expand into " <= ".


Installing vhdl-mode

In order to get vhdl-mode installed, copy this file to your home directory. Then, enter the following command:
tar xvf vhdl-mode-3.10.tar
from your home directory. That's it!


Configuring Emacs for vhdl-mode

Add the following lines to your .emacs file (if it exists). If it doesn't exist, just copy these lines into a file named .emacs in your home directory.

;; automatically go into auto-fill-mode whenever text-mode is entered
(setq text-mode-hook '(auto-fill-mode))

;; always have line-number-mode and column-number-mode on by default
(setq-default line-number-mode t)
(setq-default column-number-mode t)

(global-set-key "\C-xg" 'goto-line)
(global-set-key "\C-l" 'recenter)
(global-set-key "\C-xl" 'count-lines-page)
(global-set-key "\C-xp" 'replace-string)
(global-set-key "\C-h" 'backward-delete-char-untabify)
(global-set-key "\C-cr" 'revert-buffer)

;; Configure vhdl-mode
;; ========================

;; make sure that the directory specifed here is the one in which you
;; have the vhdl-mode.el and vhdl-mode.elc files
(setq load-path (cons (expand-file-name "~/vhdl-mode-3.10") load-path))
(autoload 'vhdl-mode "vhdl-mode" "VHDL Editing Mode" t)

;; this will put you into vhdl-mode whenever you open a *.vhd or *.vhdl file
(setq auto-mode-alist (append '(("\\.vhdl?$" . vhdl-mode)) auto-mode-alist))
(setq auto-mode-alist (append '(("\\.vhd?$" . vhdl-mode)) auto-mode-alist))

(setq indent-tabs-mode nil)

;; set basic number of spaces per tab and basic offset.  most other offsets will
;; be a multiple of this number
(setq vhdl-basic-offset 4)

;; fix indenting so that code looks like this:
;;
;;   port (
;;     input in : std_logic;
;;   );
;;
;; instead of like this:
;;
;;   port (
;;     input in : std_logic;
;;     );
;;
(defun vhdl-mode-indent-fix ()
  (vhdl-set-offset 'arglist-close '0)
  )
(add-hook 'vhdl-mode-hook 'vhdl-mode-indent-fix)

;;(setq vhdl-keywords-colorize nil)
;;(custom-set-variables
;; '(vhdl-intelligent-tab nil))
;;(custom-set-faces)
;; ========================

Now, you can open up emacs and edit your files in VHDL mode. For descriptions of some of the workings of vhdl-mode, look in the file vhdl-mode.el (which is quite heavily commented to explain what everything does) and in the file vhdl-mode.info (which is actually from the 3.21 version, but most still applies to the 3.10 version that you have just installed). In there, you can find descriptions of the indentataion and how to customize it, and how to use the automatic code generation feature (quite intuitive...just start coding and you'll run into it) and what the stuttering key-combinations are.


Using vhdl-mode and Maxplus2 in Harmony

I do most of my editing in emacs using vhdl-mode. When it comes time to compile, I go to Maxplus2 and open the file and run through the usual stuff to compile. When fixing minor errors so that the code compiles, I usually just use the Maxplus2 editor. In order to update the buffer in emacs with these changes when I go back to emacs, use the command C-c r or M-x revert-buffer to revert the buffer to what is saved on disk (which will actually be newer. Emacs will prompt you to make sure you really want to do this, so respond yes. Then, to get Maxplus2 to recognize the changes you've made in emacs, merely reopen the file in Maxplus2, and it'll refresh the contents. Sometimes, it may also detect that the file has changed and prompt you to update it automatically. All in all, it is very seamless.


Other Benefits

The main benefit of using vhdl-mode with emacs is the powerful VHDL-specific editing capabilities that vhdl-mode has. However, using emacs as your text editor also makes it easier for you to use version control as per Paul Somogyi's Application Note. More detail on doing this is provided there.


Other Resources

The emacs tutorial can be accessed by typing C-x t in emacs, where C-x represents Control-x. This will teach you the basics of navigating, editing, and working with files in emacs.

The latest version of emacs can be obtained from http://www.gnu.org and the latest version of xemacs can be obtained from http://www.xemacs.org. Ports of these programs have been made to other operating systems, including Windows, and more information should be available from those sites. The latest version of vhdl-mode can be obtained from http://www.geocities.com/SiliconValley/Peaks/8287/. The latest version, 3.21, also includes information on how to configure vhdl-mode on a Windows machine running one of the emacs or xemacs ports.


Feedback

Please feel free to submit comments, questions, and feedback in general on this topic to the address shown at the bottom of the page. I will answer your questions and update this document to improve its overall clarity and utility.


Maintainer: Javan Gargus, <javan@cs.ualberta.ca>
Last Update: 11:34 on Thursday, Oct 29, 1998