Vlog Mode for Emacs

Brief Overview of Features

Enabling Vlog-mode

If you use Bill Mann's standard .emacs file, and you have the latest copy, then Vlog-mode will be enabled automatically. Otherwise, you should add this code to your .emacs file to enable Vlog-mode.

Features in Detail

Tabs

The Tab key operates differently in Vlog mode than in Verilog mode.

Auto-Inserting Code

Typing many common keywords will cause a template to execute that will assist in your code writing. The user will be prompted for variable names at certain times. All these templates can be individually modified in your personal .emacs file, or globally disabled. I give examples of both under Customization.

Useful key bindings and functions

C-c C-b  Insert begin/end pair with blank line in between
C-c C-a  Insert always block.  It prompts for sensitivity list
C-c C-f  (vlog-find-file) If point rests on a verilog module name, 
         that module_name.v will be opened from the current directory.
C-c i    (vlog-if-else-begin) Insert an if-else block
C-c m    (vlog-insert-module-instance) Insert module instantiation.
           Prompts for filename of module.
C-c e    (vlog-enable-reg) Insert a inferred flip-flop with enable
C-c r    (vlog-std-reg) Insert an inferred flip-flop
C-c ]    (end-of-vlog-module)
C-c [    (beginning-of-vlog-module)
,,       (stutter-comma) Typing two commas replaces the commas with " <= "

Quickly declaring wires and registers

I've made a couple of short cuts for declaring regs and wires, while you're coding. These functions take the name of the reg/wire that your cursor is on top of, asks for the bus width of the signal, and puts a reg or wire declaration at the top of your code. You don't see this happen; your view of the code is unchanged. It makes it easy to declare these as your are writing or adding code.

The regs/wires declarations are all positioned underneath a text string declared in the variable vlog-local-regs-wires-str. The default value is the string "//### local regs/wires".

C-c g    (vlog-declare-reg) Declares a reg for the signal that the
          cursor is on.
C-c w	 (vlog-declare-wire) Declares a wire for the signal that the
          cursor is on.

Functions for Structural Level Connectivity

Restrictions on I/O declarations: The above three functions operate best when only 1 signal name used per input, output or inout declaration.

Modifying Automatic Instance Names

The default module instance name used in vlog-insert-module-instance is umodule_name . After instantiation, the cursor is left next to the instance name, for manual modification, if necessary. I have also added some controls to the automatic instance name generation.

To set any of these variables, use the following example. Note that true is 't in emacs-lisp and false is nil.
(add-hook 'vlog-mode-hook (function (lambda () (setq vlog-shorten-instance-name 't))))

Customization

Examples of things to add to your .emacs file to customize Vlog-mode:

Known Bugs (and workarounds)