Verilog Mode for Emacs/Epoch 
Author Message
 Verilog Mode for Emacs/Epoch

Does anyone out there have one of these? I'm getting tired of manually
indenting lines.

Also, is there an FAQ for this group? If so, where can I find it (it's
not in news.answers on ftp.uu.net).

thanks in advance,

nick



Sat, 27 May 1995 01:02:12 GMT  
 Verilog Mode for Emacs/Epoch

Quote:
>Does anyone out there have one of these? I'm getting tired of manually
>indenting lines.

There are others, but here is mine.

********************************************************************
*   Jim Dahlberg                 Computing Devices International   *

********************************************************************
-------------------- cut here -------------------------
;; ver editing support package in GNUlisp.  v1.0

;; (borrows heavily from ada.el package)

;; Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 1, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

;; (setq auto-mode-alist (cons (cons "\\.ver$" 'ver-mode) auto-mode-alist))
;; changed ver auto mode recognition string JAD 07/14/92
(setq auto-mode-alist (cons (cons "\\.v$" 'ver-mode) auto-mode-alist))

(defvar ver-mode-syntax-table nil
  "Syntax table in use in ver-mode buffers.")

(let ((table (make-syntax-table)))
  (modify-syntax-entry ?_ "_" table)
  (modify-syntax-entry ?\# "_" table)
  (modify-syntax-entry ?\( "()" table)
  (modify-syntax-entry ?\) ")(" table)
  (modify-syntax-entry ?$ "." table)
  (modify-syntax-entry ?* "." table)
  (modify-syntax-entry ?/ "." table)
  (modify-syntax-entry ?+ "." table)
  (modify-syntax-entry ?- "." table)
  (modify-syntax-entry ?= "." table)
  (modify-syntax-entry ?\& "." table)
  (modify-syntax-entry ?\| "." table)
  (modify-syntax-entry ?< "." table)
  (modify-syntax-entry ?> "." table)
  (modify-syntax-entry ?\[ "." table)
  (modify-syntax-entry ?\] "." table)
  (modify-syntax-entry ?\{ "." table)
  (modify-syntax-entry ?\} "." table)
  (modify-syntax-entry ?. "." table)
  (modify-syntax-entry ?\\ "." table)
  (modify-syntax-entry ?: "." table)
  (modify-syntax-entry ?\; "." table)
  (modify-syntax-entry ?\' "." table)
  (modify-syntax-entry ?\" "\"" table)
  (setq ver-mode-syntax-table table))

(defvar ver-mode-map nil
  "Keymap used in ver mode.")

(let ((map (make-sparse-keymap)))
  (define-key map "\C-m" 'ver-newline)
  (define-key map "\C-?" 'backward-delete-char-untabify)
  (define-key map "\C-i" 'ver-tab)
  (define-key map "\C-c\C-i" 'ver-untab)
  (define-key map "\C-c<" 'ver-backward-to-same-indent)
  (define-key map "\C-c>" 'ver-forward-to-same-indent)
  (define-key map "\C-ch" 'ver-header)
  (define-key map "\C-c(" 'ver-paired-parens)
  (define-key map "\C-c/" 'ver-inline-comment)
  (define-key map "\C-cm" 'ver-declare-module)
  (define-key map "\C-cc" 'ver-case)
  (define-key map "\C-c\C-f" 'ver-function-spec)
  (define-key map "\C-ci" 'ver-if)
  (define-key map "\C-cI" 'ver-elsif)
  (define-key map "\C-ce" 'ver-else)
  (define-key map "\C-c\C-t" 'ver-template)
  (define-key map "\C-ct" 'ver-tabsize)
  (define-key map "\C-c\C-/" 'ver-display-comment)
  (setq ver-mode-map map))

(defvar ver-indent 4 "*Value is the number of columns to indent in ver-Mode.")

(defun ver-mode ()
"This is a mode intended to support program development in verilog.
Most control constructs and declarations of ver can be inserted in the buffer
by typing Control-C followed by a character mnemonic for the construct.

C-c h   header          C-c /   inline comment
C-c m   module declare  C-c c   case statement
C-c C-f function        C-c i   if statement
C-c I   else if         C-c e   else
C-c C-t template (Lamps)C-c C-/ insert comment header
C-c t   ver tabsize     C-c (   insert a pair of parens

C-c < and C-c > move backward and forward respectively to the next line
having the same (or lesser) level of indentation.

Variable ver-indent controls the number of spaces for indent/undent.

\\{ver-mode-map}
"
  (interactive)
  (kill-all-local-variables)
  (use-local-map ver-mode-map)
  (setq major-mode 'ver-mode)
  (setq mode-name "ver")
  (make-local-variable 'comment-column)
  (setq comment-column 39)
  (make-local-variable 'end-comment-column)
  (setq end-comment-column 78)
  (set-syntax-table ver-mode-syntax-table)
  (make-local-variable 'paragraph-start)
  (setq paragraph-start (concat "^$\\|" page-delimiter))
  (make-local-variable 'paragraph-separate)
  (setq paragraph-separate paragraph-start)
  (make-local-variable 'paragraph-ignore-fill-prefix)
  (setq paragraph-ignore-fill-prefix t)
;  (make-local-variable 'indent-line-function)
;  (setq indent-line-function 'c-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 "*/")
;;  (make-local-variable 'comment-column)
;;  (setq comment-column 41)
  (make-local-variable 'comment-start-skip)
  (setq comment-start-skip "//+ *")
  (make-local-variable 'comment-indent-hook)
  (setq comment-indent-hook 'c-comment-indent)
  (make-local-variable 'parse-sexp-ignore-comments)
  (setq parse-sexp-ignore-comments t)
  (run-hooks 'ver-mode-hook))

(defun ver-tabsize (s)
  "changes spacing used for indentation. Reads spacing from minibuffer."
  (interactive "nnew indentation spacing: ")
  (setq ver-indent s))

(defun ver-newline ()
  "Start new line and indent to current tab stop."
  (interactive)
  (let ((ver-cc (current-indentation)))
    (newline)
    (indent-to ver-cc)))

(defun ver-tab ()
  "Indent to next tab stop."
  (interactive)
;;  (indent-to (* (1+ (/ (current-indentation) ver-indent)) ver-indent)))
  (indent-to (* (1+ (/ (current-column) ver-indent)) ver-indent)))

(defun ver-untab ()
  "Delete backwards to previous tab stop."
  (interactive)
  (backward-delete-char-untabify ver-indent nil))

(defun ver-go-to-this-indent (step indent-level)
  "Move point repeatedly by <step> 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 ver-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)
  (ver-go-to-this-indent -1 (current-indentation))
  (back-to-indentation))

(defun ver-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)
  (ver-go-to-this-indent 1 (current-indentation))
  (back-to-indentation))

(defun ver-case ()
  "Build skeleton case statment, prompting for the selector expression.
starts up the first when clause, too."
  (interactive)
  (insert "case (")
  (insert (read-string "selector expression: ") " )")
  (ver-newline)
  (insert "condition1 :")
  (ver-newline)
  (insert "condition2 :")
  (ver-newline)
  (insert "endcase")
  (ver-newline))

(defun ver-declare-module ()
  "Insert a module statement."
  (interactive)
  (let ((ver-module-name (read-string "[module name]: ")))
    (insert "module ")
    (insert ver-module-name "(")
    (ver-newline)
    (insert "//MODULE INPUTS")
    (ver-newline)
    (ver-newline)
    (insert "//MODULE OUTPUTS")
    (ver-newline)
    (ver-newline)
    (insert "//MODULE BIDIRECTS")
    (ver-newline)
    (ver-newline)
    (insert ");")
    (ver-newline)))

(defun ver-else ()
  "Add an else clause inside an if-else if clause."
  (interactive)
  (ver-untab)
  (insert "else")
  (ver-newline)
  (ver-tab))

(defun ver-header ()
  "Insert a comment block containing the module title, author, etc."
  (interactive)
  (insert "//\n//  Title: \t")
  (insert (read-string "File name :") )
  (insert "\n//  Created:\t" (current-time-string))
  (insert "\n//  Author: \t" (user-full-name))

(defun ver-if ()
  "Insert skeleton if statment, prompting for a boolean-expression."
  (interactive)
  (insert "if (")
  (insert (read-string "condition: ") " )")
  (ver-newline)
  (ver-tab))

(defun ver-elsif ()
  "Add an elsif clause to an if statement, prompting for the boolean-expression."
  (interactive)
  (ver-untab)
  (insert "else if (")
  (insert (read-string "condition: ") " )")
  (ver-newline)
  (ver-tab))

(defun ver-function-spec ()
  "Insert a function specification.  Prompts for name and arguments."
  (interactive)
  (let ((ver-function-size (read-string "[function size (width)]: ")))
  (let ((ver-function-name (read-string "[function name]: ")))
  (insert "function [")
  (insert ver-function-size "] ")
  (insert ver-function-name ";")
  (ver-newline)
  (insert " input ?;")
  (insert " input ?;")
  (ver-newline)
  (insert "endfunction //" ver-function-name)
  (ver-newline))))

(defun ver-template ()
  "Insert template for the entire verilog file."
  (interactive)
  (let ((ver-module-name (read-string "[module name]: ")))

    (insert "//**********************************************************************")
    (ver-newline)
    (insert "//")
    (ver-newline)
    (insert "// I.   Module Name: " ver-module-name)
    (ver-newline)
    (insert "//      File Name:   " ver-module-name ".v")
...

read more »



Sat, 27 May 1995 07:56:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Emacs Verilog mode & 2001

2. emacs verilog mode?

3. Extension to Emacs Verilog-Mode ?

4. Emacs verilog mode

5. verilog-mode for emacs, `define and /*autosense*/

6. emacs & verilog-mode

7. Emacs verilog mode

8. Emacs verilog mode ands Silos?

9. parathesis matching in emacs-verilog mode

10. Emacs Verilog-mode problems

11. Verilog mode for (x)emacs???

12. Emacs verilog mode problem

 

 
Powered by phpBB® Forum Software