Click here if you've got it installed, but got no colors...
Click here if you'd like to alter the way search operates in the Verilog mode
Click here if you want to see some frequently asked questions and answers.
Click here if you want to see how to install it on Windows.
This install guide has been translated to the Serbo-Croatian language by Jovana Milutinovich from WebHostingGeeks.com.
OK, you want to use the Verilog emacs mode, but have never used emacs, or always had some one else do the messy set up details. Here is a step by step recipe for installing the verilog-mode:
To uncompress the file, on a Linux or Unix machine use gunzip which you should have, if not you can get it from the Free Software Foundation. Run:
On a Windows machine, the tool called winzip can be used to uncompress the file; find one by searching the net.
Note: you can remove the old lisp you may have from using a previous version of verilog-mode; the below is all you need. The old stuff tried to complete the installation of font-lock mode, pick rational colors, and figure out what color your background screen was. Emacs is a fair bit better at this now.
An easy way to determine the right place is to type C-h v load-path RET to emacs; this will give you a list of the paths that are searched to find lisp files. Here, typing at FSF emacs, I get:
Coloring your code is really cool, impresses your friends, and actually does help one code quicker, and helps one understand others code. The only problem is that each version of emacs has different ways of specifying what color should be used, and hence it is a bear.
For a while, I distributed code folks could put in their .emacs that would attempt to figure out what version of emacs (FSF or XEmacs) was installed, and which sub version of the two major packages was in use. Further, it attempted to determine if the user had a dark, or a light background, and then would install my notion of what might be nice colors.
The world is changing too fast; and both XEmacs and FSF emacs now have easy to modify, and quite reasonable defaults. Therefore I removed my distributed code, and have added this section to support folks still using older emacsen. Find your version below, and see what hints I have for getting colors to work.
First: install verilog-mode as per the above instructions.
What is a word? By default the Verilog mode treats as a word sequences of characters that are legal as a variable name. As such, a sequence like ALPHA_CHANNEL_FILTER is considered one word by the verilog mode. If you have the point on the first A, and type C-s C-w, emacs will select the whole word as the search item and take you to the next occurance.
However, for some folks, or certain designs, it is more useful that the mode treats the _ as a word boundry, so the sequence ALPHA_CHANNEL_FILTER would be treated as three different words that are adjacent. As a result, typing C-s C-w with the cursor on the A would select the sequence ALPHA as the search target, and you could type another C-s to find the next ALPHA sequence in the buffer, or type C-w to extend the search sequence to become ALPHA_CHANNEL (and then perhaps type C-s to find other ALPHA_CHANNELS, or type C-w to get the original behavior, with the entier variable name in the search target.
To get this other behavior, add
(add-hook 'verilog-mode-hook '(lambda () (modify-syntax-entry ?_ "." verilog-mode-syntax-table)))
to your emacs startup file (typically called .emacs
You can control the degree to which the Verilog mode highlights your code.
Using XEmacs, do the following:
Look at the menu bar at the top of your XEmacs screen.
This saves this decision for later invocations of XEmacs.
Note that in the highlighting, the choices are Least, More, Even More and Most. The expensive highlighting is only turned on in the 'Most' level; hence you could speed things up even more by selecting 'More' or 'Least'; however the only really expensive selection is the 'Most', as it highlights stings that appear on multiple lines.
Add the following code to your .emacs file: (or init.el file for XEmacs 21 users!)
Start an new emacs/xemacs
Type M-x customize-variable RET
respond to Variable: with font-lock-maximum-decoration RET
select from 'Value Menu' in the buffer the item 'mode specific'
Select from Mode, the item 'name'
Fill in the name 'verilog-mode'
Select in Decoration, item 'level'
Fill in the level '2'
Select INS to insert another item
In this item's Mode, select 'all'
In this item's Decoration, select the level of decoration you would like. 'maximum' gives you all sorts of colors; typical levels range from 0 to 3.
Go the to the top of the buffer and select [Set for Current Session] and [Save for Future Session]
Q 1: I share my verilog to someone using codewrite. When they edit the code it looks unindented. Is the problems tabs, can I control whether the tools inserts tabs???
A 1: This is a general problem sharing files between folks. It also occurs between folks using the same editor, as many editors allow one to set the tab width. The general solution is for you to add a write file hook that expands tabs to spaces.
Add the following to your .emacs file: (or init.el file for XEmacs 21 users!)
Some explanation: This arranges so that any file in verilog mode (the "add-hook 'verilog-mode-hook" part) gets added to it's 'local-write-file-hooks' a call to the function 'untabify' with arguments that are the first and last character in the buffer.
Q 2: If I use Helvetica as my font, the auto indent doesn't work.
A 2: The indent scheme used by the verilog mode is based on counting spaces, and hence only works if you are using constant width fonts. Helvetica is not constant width, while Courier, or Fixed and the like are constant width. Sorry.
Q 3: How do I indent a region of code; typing
TAB on every line is getting old...
Is there any way to
indent a whole module/function/if clause etc. like
c-indent-exp [M-C-q] in C-mode ?
A 3: Use C-M-\ to indent a region (selected by setting the point at one end, and having the cursor at the other end, as usual). Perhaps a future version of the emacs mode will include functions that mimic some of C's extra bindings.
Q 4: I am an active user of your emacs for verilog. I must congratulate you for your innovative work. At work I have unix work station. So no problem. But at home I wish work with emacs for verilog on a Windows PC. Can you please suggest some way I can do it?
A 4:
On Windows 7, right click on the file in your Downloads
directory and select Extract All...
In this directory you should find a file named README.W32. Open this file with your current editor and search for "Setting up Emacs" and follow its instructions for setting up so you can launch emacs from the Start menu.
Note that Emacs ships with a version of the Verilog-mode already installed (often slightly out of date; the one included with emacs-24.2 is version 724, released 11/27/2011).
If you are using Windows 7, then you are done! You can verify that everything worked by running emacs, and typing:
C-x C-f foo.v RET
C-h v verilog-mode-version RET
As of today, you should get a buffer telling you:
verilog-mode-version is a variable defined in `verilog-mode.el'. Its value is "813"
If you are using Windows-XP, then you may need to proceed as follows:
On XP right click my computer, and select Properties. | |
Then select Advanced, and from that tab select Environment Variables. | |
Then select New from the User Variables for your name. | |
Create a variable named HOME, and assign to it the value of your $EMACS, or in our case C:\Program Files\emacs-24.2 |
What is happening? The first two steps install an emacs on your machine. Probably any emacs will do; I know the above works for the ftp://ftp.gnu.org/gnu/emacs/windows version of emacs that I use.
The third step adds a directory where you can install third party lisp routines (like verilog-mode). It is a really good idea to add your own customization lisp files for emacs into such a directory, rather than just copying them to one of the standard places, is so that later if you install a new version of emacs, you don't overwrite goodies that you have collected over the years.
In the fourth step you actually install the verilog-mode file in this site lisp directory.
In the fifth step you arrange it so upon startup, emacs will know where everything is.
In the sixth step you tell emacs that you want verilog files to come up in verilog mode.
The optional seventh step builds a quick launch icon that you can click on to launch the emacs. You can place this on your desktop, or in the quick launch bar, or in your My Documents so that emacs is easy to launch.
A final note: GIVE BACK to the community Please send me any corrections to these suggestions, and feedback on parts that were not perfectly clear to you, so that I can update this suggestion to be even more helpful to you and to others
Q 5: I can't seem to insert tabs (fixed number of whitespaces) anywhere in the file -- for ex. between port list line and comment next to signal:
A 5: In general, in emacs you can escape the special meaning of any key by first typing C-q, which is documented as follows. (Type C-h k C-q to see the documentation yourself)
For this particular case (lining up comments) another key stroke is even more useful (and also works in most any emacs mode): M-; Escape ; is documented as follows:
A 6: Certainly. You need to tell viper that it is ok with you for files in verilog to come up in verilog-mode and viper.
To do that, type
Then scroll down and find the item Vi State Mode List Left-Click on the triangle to open this up.
Scroll down through the blizzard of listed modes to the bottom. You should see:
Middle-click on the bare INS; you should get:
Then left-click on nil, and replace the string 'nil' with verilog-mode
You should get:Now middle-click on [State] and a pop up menu appears; select Set for Current Session and then also middle click again and select Save for Future Sessions.
Now if you are running viper, when you load a verilog file, it will start in viper mode.
or perhaps a similar message:
So, it looks like it's seeing my verilog-mode.el but not executing properly. Any help will be greatly appreciated!
A 7: You need skeleton.el, part of the base package for the first, or overlay.el, part of the fsf-compatibility package for the second, which are both XEmacs lisp packages, which you somehow have not installed, or have not updated.
Go to Tools -> Packages ->Add download site and pick a site (xemacs.org works for me)
Then select Tools -> Packages -> List & Install
Go to the bottom, and click on the line that says xemacs-base. to get the skeleton.el file. You will see something like:
For the overlay package, click on the line that says fsf-compat. to get the overlay.el file. In this case you will see something like:
When you click on it, the * changes to a +
Then type x, which will install the package.
Then restart XEmacs and things should then work just fine.
Take heart; The learning curve is steep; but the view from the top is wonderful!