[ # ] Emacs Keyword Syntax Highlighting for Verilog, Specman Elite
/* Posted April 28th, 2008 at 4:04pm *//* Filed under Programming, Reference */
If you’re an avid Unix user you’ve probably used Emacs at one point or another. Ever wonder how sometimes when you open up a file (like .cpp) the editor is able to highlight and color all the right keywords pertaining to the programming language the file is coded in? The secret is in the .emacs file located in your home directory. I’ve worked with both Verilog and Specman Elite files before, and found the correct code to add in the .emacs file to enable the beautiful keyword syntax highlighting/coloring that makes the code much more readable.
For Verilog, place this verilog-mode.el file in the “~/elisp” directory. If it does not exist, create it. Then copy and paste this in at the end of your .emacs file (because that’s the safest place to put your own customizations:
;;;;;; for verilog syntax highlighting ;;;;;;;
(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))
(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the directory ~/bin for elisp files
(prepend-path "~/elisp")
;; Load verilog mode only when needed
(autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
;; Any files that end in .v should be in verilog mode
(setq auto-mode-alist (cons '("\\.v\\'" . verilog-mode) auto-mode-alist))
;; Any files in verilog mode should have their keywords colorized
(add-hook 'verilog-mode-hook '(lambda () (font-lock-mode 1)))
For Specman Elite highlighting, place this specman-mode.el file in the “~/elisp” directory and then copy and paste this code into your .emacs file:
;;;;;; for specman e syntax highlighting ;;;;;;;
(defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))
(defun append-path ( my-path )
(setq load-path (append load-path (list (expand-file-name my-path)))))
;; Look first in the directory ~/elisp for elisp files
(prepend-path "~/elisp")
;; Load specman mode only when needed
(autoload 'specman-mode "specman-mode" "Specman mode" t )
;; Any files that end in .e, .e3, et cetera should be in specman mode
(setq auto-mode-alist
(append (list
(cons "\\.e\\'" 'specman-mode)
(cons "\\.e3\\'" 'specman-mode)
(cons "\\.load\\'" 'specman-mode)
(cons "\\.ecom\\'" 'specman-mode)
(cons "\\.etst\\'" 'specman-mode)) auto-mode-alist))
;; Any files in specman mode should have their keywords colorized
(add-hook 'specman-mode-hook '(lambda () (font-lock-mode 1)))













Leave a Reply
(* required)