aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog31
-rw-r--r--lisp/progmodes/verilog-mode.el410
2 files changed, 270 insertions, 171 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index abe6b1e8c8a..5f50546468b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,34 @@
12010-04-07 Michael McNamara <mac@mail.brushroad.com>
2
3 * verilog-mode.el (verilog-forward-sexp, verilog-calc-1): Support
4 "disable fork" and "fork wait" multi word keywords, suggested by
5 Steve Pearlmutter.
6 (verilog-pretty-declarations): Support lineup of declarations in
7 port lists.
8 (verilog-skip-backward-comments, verilog-skip-forward-comment-p):
9 fix bug for /* / comments
10 (verilog-backward-syntactic-ws, verilog-forward-syntactic-ws):
11 Speed up and simplfy as this is never called with a bound.
12 (verilog-pretty-declarations): Enhance to line up declarations
13 inside a parameter list, suggested by Alan Morgan.
14 (verilog-pretty-expr): Tune assignment regular expression match
15 string for corner cases; also use markers instead of character
16 number as indent changes the later.
17
182010-04-07 Wilson Snyder <wsnyder@wsnyder.org>
19
20 * verilog-mode.el (verilog-type-keywords): Fix pulldown as missing
21 keyword.
22 (verilog-read-sub-decls-line): Fix comments in AUTO_TEMPLATE
23 causing truncation of AUTOWIRE signals. Reported by Bruce
24 Tennant.
25 (verilog-auto-inst, verilog-auto-inst-port): Add vl_mbits for
26 AUTO_TEMPLATEs needing multiple array bits. Suggested by Bruce
27 Tennant.
28 (verilog-keywords):
29 (verilog-1800-2005-keywords, verilog-1800-2009-keywords): Add IEEE
30 1800-2009 keywords, including "global.".
31
12010-04-06 John Wiegley <jwiegley@gmail.com> 322010-04-06 John Wiegley <jwiegley@gmail.com>
2 33
3 * ido.el (ido-add-virtual-buffers-to-list): Fix duplicated names 34 * ido.el (ido-add-virtual-buffers-to-list): Fix duplicated names
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index e391216796b..05ce36c56d2 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -79,7 +79,7 @@
79;; .emacs, or in your site's site-load.el 79;; .emacs, or in your site's site-load.el
80 80
81; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t ) 81; (autoload 'verilog-mode "verilog-mode" "Verilog mode" t )
82; (add-to-list 'auto-mode-alist '("\\.[ds]?v\\'" . verilog-mode)) 82; (add-to-list 'auto-mode-alist '("\\.[ds]?vh?\\'" . verilog-mode))
83 83
84;; If you want to customize Verilog mode to fit your needs better, 84;; If you want to customize Verilog mode to fit your needs better,
85;; you may add these lines (the values of the variables presented 85;; you may add these lines (the values of the variables presented
@@ -118,9 +118,9 @@
118;;; Code: 118;;; Code:
119 119
120;; This variable will always hold the version number of the mode 120;; This variable will always hold the version number of the mode
121(defconst verilog-mode-version "556" 121(defconst verilog-mode-version "565"
122 "Version of this Verilog mode.") 122 "Version of this Verilog mode.")
123(defconst verilog-mode-release-date "2009-12-10-GNU" 123(defconst verilog-mode-release-date "2010-03-01-GNU"
124 "Release date of this Verilog mode.") 124 "Release date of this Verilog mode.")
125(defconst verilog-mode-release-emacs t 125(defconst verilog-mode-release-emacs t
126 "If non-nil, this version of Verilog mode was released with Emacs itself.") 126 "If non-nil, this version of Verilog mode was released with Emacs itself.")
@@ -2116,7 +2116,8 @@ find the errors."
2116 `( 2116 `(
2117 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass" 2117 "endmodule" "endprimitive" "endinterface" "endpackage" "endprogram" "endclass"
2118 )))) 2118 ))))
2119(defconst verilog-disable-fork-re "disable\\s-+fork") 2119(defconst verilog-disable-fork-re "disable\\s-+fork\\>")
2120(defconst verilog-fork-wait-re "fork\\s-+wait\\>")
2120(defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?") 2121(defconst verilog-extended-case-re "\\(unique\\s-+\\|priority\\s-+\\)?case[xz]?")
2121(defconst verilog-extended-complete-re 2122(defconst verilog-extended-complete-re
2122 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)" 2123 (concat "\\(\\<extern\\s-+\\|\\<virtual\\s-+\\|\\<protected\\s-+\\)*\\(\\<function\\>\\|\\<task\\>\\)"
@@ -2198,6 +2199,11 @@ find the errors."
2198 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void" 2199 "unique" "unsigned" "use" "uwire" "var" "vectored" "virtual" "void"
2199 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard" 2200 "wait" "wait_order" "wand" "weak0" "weak1" "while" "wildcard"
2200 "wire" "with" "within" "wor" "xnor" "xor" 2201 "wire" "with" "within" "wor" "xnor" "xor"
2202 ;; 1800-2009
2203 "accept_on" "checker" "endchecker" "eventually" "global" "implies"
2204 "let" "nexttime" "reject_on" "restrict" "s_always" "s_eventually"
2205 "s_nexttime" "s_until" "s_until_with" "strong" "sync_accept_on"
2206 "sync_reject_on" "unique0" "until" "until_with" "untyped" "weak"
2201 ) 2207 )
2202 "List of Verilog keywords.") 2208 "List of Verilog keywords.")
2203 2209
@@ -2314,7 +2320,7 @@ See also `verilog-font-lock-extra-types'.")
2314 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam" 2320 "and" "bit" "buf" "bufif0" "bufif1" "cmos" "defparam"
2315 "event" "genvar" "inout" "input" "integer" "localparam" 2321 "event" "genvar" "inout" "input" "integer" "localparam"
2316 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or" 2322 "logic" "mailbox" "nand" "nmos" "not" "notif0" "notif1" "or"
2317 "output" "parameter" "pmos" "pull0" "pull1" "pullup" 2323 "output" "parameter" "pmos" "pull0" "pull1" "pulldown" "pullup"
2318 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" 2324 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran"
2319 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply" 2325 "rtranif0" "rtranif1" "semaphore" "signed" "struct" "supply"
2320 "supply0" "supply1" "time" "tran" "tranif0" "tranif1" 2326 "supply0" "supply1" "time" "tran" "tranif0" "tranif1"
@@ -2328,7 +2334,7 @@ See also `verilog-font-lock-extra-types'.")
2328 '("surefire" "synopsys" "rtl_synthesis" "verilint" "leda" "0in") nil 2334 '("surefire" "synopsys" "rtl_synthesis" "verilint" "leda" "0in") nil
2329 ))) 2335 )))
2330 2336
2331 (verilog-p1800-keywords 2337 (verilog-1800-2005-keywords
2332 (eval-when-compile 2338 (eval-when-compile
2333 (verilog-regexp-opt 2339 (verilog-regexp-opt
2334 '("alias" "assert" "assume" "automatic" "before" "bind" 2340 '("alias" "assert" "assume" "automatic" "before" "bind"
@@ -2352,6 +2358,15 @@ See also `verilog-font-lock-extra-types'.")
2352 "wait_order" "weak0" "weak1" "wildcard" "with" "within" 2358 "wait_order" "weak0" "weak1" "wildcard" "with" "within"
2353 ) nil ))) 2359 ) nil )))
2354 2360
2361 (verilog-1800-2009-keywords
2362 (eval-when-compile
2363 (verilog-regexp-opt
2364 '("accept_on" "checker" "endchecker" "eventually" "global"
2365 "implies" "let" "nexttime" "reject_on" "restrict" "s_always"
2366 "s_eventually" "s_nexttime" "s_until" "s_until_with" "strong"
2367 "sync_accept_on" "sync_reject_on" "unique0" "until"
2368 "until_with" "untyped" "weak" ) nil )))
2369
2355 (verilog-ams-keywords 2370 (verilog-ams-keywords
2356 (eval-when-compile 2371 (eval-when-compile
2357 (verilog-regexp-opt 2372 (verilog-regexp-opt
@@ -2403,11 +2418,17 @@ See also `verilog-font-lock-extra-types'.")
2403 'font-lock-type-face)) 2418 'font-lock-type-face))
2404 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>") 2419 (cons (concat "\\<\\(" verilog-type-font-keywords "\\)\\>")
2405 'font-lock-type-face) 2420 'font-lock-type-face)
2406 ;; Fontify IEEE-P1800 keywords appropriately 2421 ;; Fontify IEEE-1800-2005 keywords appropriately
2407 (if verilog-highlight-p1800-keywords 2422 (if verilog-highlight-p1800-keywords
2408 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") 2423 (cons (concat "\\<\\(" verilog-1800-2005-keywords "\\)\\>")
2409 'verilog-font-lock-p1800-face) 2424 'verilog-font-lock-p1800-face)
2410 (cons (concat "\\<\\(" verilog-p1800-keywords "\\)\\>") 2425 (cons (concat "\\<\\(" verilog-1800-2005-keywords "\\)\\>")
2426 'font-lock-type-face))
2427 ;; Fontify IEEE-1800-2009 keywords appropriately
2428 (if verilog-highlight-p1800-keywords
2429 (cons (concat "\\<\\(" verilog-1800-2009-keywords "\\)\\>")
2430 'verilog-font-lock-p1800-face)
2431 (cons (concat "\\<\\(" verilog-1800-2009-keywords "\\)\\>")
2411 'font-lock-type-face)) 2432 'font-lock-type-face))
2412 ;; Fontify Verilog-AMS keywords 2433 ;; Fontify Verilog-AMS keywords
2413 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>") 2434 (cons (concat "\\<\\(" verilog-ams-keywords "\\)\\>")
@@ -2580,20 +2601,28 @@ Use filename, if current buffer being edited shorten to just buffer name."
2580 (setq md 3) ;; ender is third item in regexp 2601 (setq md 3) ;; ender is third item in regexp
2581 ) 2602 )
2582 ((match-end 4) 2603 ((match-end 4)
2583 ;; might be "disable fork" 2604 ;; might be "disable fork" or "fork wait"
2584 (if (or 2605 (let
2585 (looking-at verilog-disable-fork-re) 2606 (here)
2586 (and (looking-at "fork") 2607 (if (looking-at verilog-fork-wait-re)
2587 (progn 2608 (progn ;; it is a fork wait; ignore it
2588 (forward-word -1) 2609 (goto-char (match-end 0))
2589 (looking-at verilog-disable-fork-re)))) 2610 (setq reg nil))
2590 (progn 2611 (if (or
2591 (goto-char (match-end 0)) 2612 (looking-at verilog-disable-fork-re)
2592 (forward-word 1) 2613 (and (looking-at "fork")
2593 (setq reg nil)) 2614 (progn
2594 (progn 2615 (setq here (point)) ;; sometimes a fork is just a fork
2595 ;; Search forward for matching join 2616 (forward-word -1)
2596 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" )))) 2617 (looking-at verilog-disable-fork-re))))
2618 (progn ;; it is a disable fork; ignore it
2619 (goto-char (match-end 0))
2620 (forward-word 1)
2621 (setq reg nil))
2622 (progn ;; it is a nice simple fork
2623 (goto-char here) ;; return from looking for "disable fork"
2624 ;; Search forward for matching join
2625 (setq reg "\\(\\<fork\\>\\)\\|\\(\\<join\\(_any\\|_none\\)?\\>\\)" ))))))
2597 ((match-end 6) 2626 ((match-end 6)
2598 ;; Search forward for matching endclass 2627 ;; Search forward for matching endclass
2599 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" )) 2628 (setq reg "\\(\\<class\\>\\)\\|\\(\\<endclass\\>\\)" ))
@@ -2644,12 +2673,27 @@ Use filename, if current buffer being edited shorten to just buffer name."
2644 (let ((depth 1)) 2673 (let ((depth 1))
2645 (while (verilog-re-search-forward reg nil 'move) 2674 (while (verilog-re-search-forward reg nil 'move)
2646 (cond 2675 (cond
2647 ((match-end md) ; the closer in reg, so we are climbing out 2676 ((match-end md) ; a closer in regular expression, so we are climbing out
2648 (setq depth (1- depth)) 2677 (setq depth (1- depth))
2649 (if (= 0 depth) ; we are out! 2678 (if (= 0 depth) ; we are out!
2650 (throw 'skip 1))) 2679 (throw 'skip 1)))
2651 ((match-end 1) ; the opener in reg, so we are deeper now 2680 ((match-end 1) ; an opener in the r-e, so we are in deeper now
2652 (setq depth (1+ depth)))))) 2681 (setq here (point)) ; remember where we started
2682 (goto-char (match-beginning 1))
2683 (cond
2684 ((looking-at verilog-fork-wait-re)
2685 (goto-char (match-end 0))) ; false alarm
2686 ((if (or
2687 (looking-at verilog-disable-fork-re)
2688 (and (looking-at "fork")
2689 (progn
2690 (forward-word -1)
2691 (looking-at verilog-disable-fork-re))))
2692 (progn ;; it is a disable fork; another false alarm
2693 (goto-char (match-end 0)))
2694 (progn ;; it is a simple fork (or has nothing to do with fork)
2695 (goto-char here)
2696 (setq depth (1+ depth))))))))))
2653 (if (verilog-re-search-forward reg nil 'move) 2697 (if (verilog-re-search-forward reg nil 'move)
2654 (throw 'skip 1)))))) 2698 (throw 'skip 1))))))
2655 2699
@@ -4532,8 +4576,9 @@ Return a list of two elements: (INDENT-TYPE INDENT-LEVEL)."
4532 ((match-end 4) ; *sigh* could be "disable fork" 4576 ((match-end 4) ; *sigh* could be "disable fork"
4533 (let ((here (point))) 4577 (let ((here (point)))
4534 (verilog-beg-of-statement) 4578 (verilog-beg-of-statement)
4535 (if (looking-at verilog-disable-fork-re) 4579 (if (or (looking-at verilog-disable-fork-re)
4536 t ; is disable fork, this is a normal statement 4580 (looking-at verilog-fork-wait-re))
4581 t ; this is a normal statement
4537 (progn ; or is fork, starts a new block 4582 (progn ; or is fork, starts a new block
4538 (goto-char here) 4583 (goto-char here)
4539 (throw 'nesting 'block))))) 4584 (throw 'nesting 'block)))))
@@ -4882,31 +4927,13 @@ Set point to where line starts."
4882 (goto-char back) 4927 (goto-char back)
4883 t)))))))) 4928 t))))))))
4884 4929
4885(defun verilog-backward-syntactic-ws (&optional bound) 4930(defun verilog-backward-syntactic-ws ()
4886 "Backward skip over syntactic whitespace for Emacs 19. 4931 (verilog-skip-backward-comments)
4887Optional BOUND limits search." 4932 (forward-comment (- (buffer-size))))
4888 (save-restriction
4889 (let* ((bound (or bound (point-min))) (here bound) )
4890 (if (< bound (point))
4891 (progn
4892 (narrow-to-region bound (point))
4893 (while (/= here (point))
4894 (setq here (point))
4895 (verilog-skip-backward-comments))))))
4896 t)
4897 4933
4898(defun verilog-forward-syntactic-ws (&optional bound) 4934(defun verilog-forward-syntactic-ws ()
4899 "Forward skip over syntactic whitespace for Emacs 19. 4935 (verilog-skip-forward-comment-p)
4900Optional BOUND limits search." 4936 (forward-comment (buffer-size)))
4901 (save-restriction
4902 (let* ((bound (or bound (point-max)))
4903 (here bound))
4904 (if (> bound (point))
4905 (progn
4906 (narrow-to-region (point) bound)
4907 (while (/= here (point))
4908 (setq here (point))
4909 (forward-comment (buffer-size))))))))
4910 4937
4911(defun verilog-backward-ws&directives (&optional bound) 4938(defun verilog-backward-ws&directives (&optional bound)
4912 "Backward skip over syntactic whitespace and compiler directives for Emacs 19. 4939 "Backward skip over syntactic whitespace and compiler directives for Emacs 19.
@@ -5119,14 +5146,11 @@ Optional BOUND limits search."
5119 (search-backward "/*") 5146 (search-backward "/*")
5120 (skip-chars-backward " \t\n\f") 5147 (skip-chars-backward " \t\n\f")
5121 t) 5148 t)
5122 ((and (not (bobp)) 5149 ((if (and (not (bobp))
5123 (= (char-before) ?\/) 5150 (= (char-before) ?\/)
5124 (= (char-before (1- (point))) ?\*)) 5151 (= (char-before (1- (point))) ?\*))
5125 (goto-char (- (point) 2)) 5152 (goto-char (- (point) 2))
5126 t) 5153 (/= (skip-chars-backward " \t\n\f") 0)))))))))
5127 (t
5128 (skip-chars-backward " \t\n\f")
5129 nil)))))))
5130 5154
5131(defun verilog-skip-forward-comment-p () 5155(defun verilog-skip-forward-comment-p ()
5132 "If in comment, move to end and return true." 5156 "If in comment, move to end and return true."
@@ -5134,16 +5158,18 @@ Optional BOUND limits search."
5134 (progn 5158 (progn
5135 (setq state (save-excursion (verilog-syntax-ppss))) 5159 (setq state (save-excursion (verilog-syntax-ppss)))
5136 (cond 5160 (cond
5137 ((nth 3 state) 5161 ((nth 3 state) ;Inside string
5138 t) 5162 t)
5139 ((nth 7 state) ;Inside // comment 5163 ((nth 7 state) ;Inside // comment
5140 (end-of-line) 5164 (end-of-line)
5141 (forward-char 1) 5165 (forward-char 1)
5142 t) 5166 t)
5143 ((nth 4 state) ;Inside any comment 5167 ((nth 4 state) ;Inside any comment
5168 (search-forward "*/")
5169 (skip-chars-forward " \t\n\f")
5144 t) 5170 t)
5145 (t 5171 (t
5146 nil))))) 5172 (skip-chars-forward " \t\n\f"))))))
5147 5173
5148(defun verilog-indent-line-relative () 5174(defun verilog-indent-line-relative ()
5149 "Cheap version of indent line. 5175 "Cheap version of indent line.
@@ -5376,108 +5402,143 @@ ARG is ignored, for `comment-indent-function' compatibility."
5376 "Line up declarations around point. 5402 "Line up declarations around point.
5377Be verbose about progress unless optional QUIET set." 5403Be verbose about progress unless optional QUIET set."
5378 (interactive) 5404 (interactive)
5379 (save-excursion 5405 (let* ((m1 (make-marker))
5380 (if (progn 5406 (e (point))
5381 (verilog-beg-of-statement-1) 5407 el
5382 (and (not (verilog-in-directive-p)) ;; could have `define input foo 5408 r
5383 (not (verilog-parenthesis-depth)) ;; could be in a #(param block ) 5409 (here (point))
5410 ind
5411 start
5412 startpos
5413 end
5414 endpos
5415 base-ind
5416 )
5417 (save-excursion
5418 (if (progn
5419; (verilog-beg-of-statement-1)
5420 (beginning-of-line)
5421 (verilog-forward-syntactic-ws)
5422 (and (not (verilog-in-directive-p)) ;; could have `define input foo
5384 (looking-at verilog-declaration-re))) 5423 (looking-at verilog-declaration-re)))
5385 (let* ((m1 (make-marker)) 5424 (progn
5386 (e (point)) 5425 (if (verilog-parenthesis-depth)
5387 (r) 5426 ;; in an argument list or parameter block
5388 (here (point)) 5427 (setq el (backward-up-list -1)
5389 ;; Start of declaration range 5428 start (progn
5390 (start 5429 (goto-char e)
5391 (progn 5430 (backward-up-list 1)
5392 (verilog-beg-of-statement-1) 5431 (forward-line) ;; ignore ( input foo,
5393 (while (and (looking-at verilog-declaration-re) 5432 (verilog-re-search-forward verilog-declaration-re el 'move)
5394 (not (bobp))) 5433 (goto-char (match-beginning 0))
5395 (skip-chars-backward " \t") 5434 (skip-chars-backward " \t")
5396 (setq e (point)) 5435 (point))
5397 (beginning-of-line) 5436 startpos (set-marker (make-marker) start)
5398 (verilog-backward-syntactic-ws) 5437 end (progn
5399 (backward-char) 5438 (goto-char start)
5400 (verilog-beg-of-statement-1)) 5439 (backward-up-list -1)
5401 e)) 5440 (forward-char -1)
5402 ;; End of declaration range 5441 (verilog-backward-syntactic-ws)
5403 (end 5442 (point))
5404 (progn 5443 endpos (set-marker (make-marker) end)
5405 (goto-char here) 5444 base-ind (progn
5406 (verilog-end-of-statement) 5445 (goto-char start)
5407 (setq e (point)) ;Might be on last line 5446 (verilog-do-indent (verilog-calculate-indent))
5408 (verilog-forward-syntactic-ws) 5447 (verilog-forward-ws&directives)
5409 (while (looking-at verilog-declaration-re) 5448 (current-column))
5410 ;;(beginning-of-line) 5449 )
5411 (verilog-end-of-statement) 5450 ;; in a declaration block (not in argument list)
5412 (setq e (point)) 5451 (setq
5413 (verilog-forward-syntactic-ws)) 5452 start (progn
5414 e)) 5453 (verilog-beg-of-statement-1)
5415 (edpos (set-marker (make-marker) end)) 5454 (while (and (looking-at verilog-declaration-re)
5416 (ind) 5455 (not (bobp)))
5417 (base-ind 5456 (skip-chars-backward " \t")
5418 (progn 5457 (setq e (point))
5419 (goto-char start) 5458 (beginning-of-line)
5420 (verilog-do-indent (verilog-calculate-indent)) 5459 (verilog-backward-syntactic-ws)
5421 (verilog-forward-ws&directives) 5460 (backward-char)
5422 (current-column)))) 5461 (verilog-beg-of-statement-1))
5423 (goto-char start) 5462 e)
5424 (if (and (not quiet) 5463 startpos (set-marker (make-marker) start)
5425 (> (- end start) 100)) 5464 end (progn
5426 (message "Lining up declarations..(please stand by)")) 5465 (goto-char here)
5427 ;; Get the beginning of line indent first 5466 (verilog-end-of-statement)
5428 (while (progn (setq e (marker-position edpos)) 5467 (setq e (point)) ;Might be on last line
5429 (< (point) e)) 5468 (verilog-forward-syntactic-ws)
5430 (cond 5469 (while (looking-at verilog-declaration-re)
5431 ( (save-excursion (skip-chars-backward " \t") 5470 ;;(beginning-of-line)
5432 (bolp)) 5471 (verilog-end-of-statement)
5433 (verilog-forward-ws&directives) 5472 (setq e (point))
5434 (indent-line-to base-ind) 5473 (verilog-forward-syntactic-ws))
5435 (verilog-forward-ws&directives) 5474 e)
5436 (verilog-re-search-forward "[ \t\n\f]" e 'move)) 5475 endpos (set-marker (make-marker) end)
5437 (t 5476 base-ind (progn
5438 (just-one-space) 5477 (goto-char start)
5439 (verilog-re-search-forward "[ \t\n\f]" e 'move))) 5478 (verilog-do-indent (verilog-calculate-indent))
5440 ;;(forward-line) 5479 (verilog-forward-ws&directives)
5441 ) 5480 (current-column))))
5442 ;; Now find biggest prefix 5481 ;; OK, start and end are set
5443 (setq ind (verilog-get-lineup-indent start edpos)) 5482 (goto-char (marker-position startpos))
5444 ;; Now indent each line. 5483 (if (and (not quiet)
5445 (goto-char start) 5484 (> (- end start) 100))
5446 (while (progn (setq e (marker-position edpos)) 5485 (message "Lining up declarations..(please stand by)"))
5447 (setq r (- e (point))) 5486 ;; Get the beginning of line indent first
5448 (> r 0)) 5487 (while (progn (setq e (marker-position endpos))
5449 (setq e (point)) 5488 (< (point) e))
5450 (unless quiet (message "%d" r)) 5489 (cond
5451 (verilog-indent-line) 5490 ((save-excursion (skip-chars-backward " \t")
5452 (cond 5491 (bolp))
5453 ((or (and verilog-indent-declaration-macros 5492 (verilog-forward-ws&directives)
5454 (looking-at verilog-declaration-re-2-macro)) 5493 (indent-line-to base-ind)
5455 (looking-at verilog-declaration-re-2-no-macro)) 5494 (verilog-forward-ws&directives)
5456 (let ((p (match-end 0))) 5495 (if (< (point) e)
5457 (set-marker m1 p) 5496 (verilog-re-search-forward "[ \t\n\f]" e 'move)))
5458 (if (verilog-re-search-forward "[[#`]" p 'move) 5497 (t
5459 (progn 5498 (just-one-space)
5460 (forward-char -1) 5499 (verilog-re-search-forward "[ \t\n\f]" e 'move)))
5461 (just-one-space) 5500 ;;(forward-line)
5462 (goto-char (marker-position m1)) 5501 )
5463 (just-one-space) 5502 ;; Now find biggest prefix
5464 (indent-to ind)) 5503 (setq ind (verilog-get-lineup-indent (marker-position startpos) endpos))
5465 (progn 5504 ;; Now indent each line.
5466 (just-one-space) 5505 (goto-char (marker-position startpos))
5467 (indent-to ind))))) 5506 (while (progn (setq e (marker-position endpos))
5468 ((verilog-continued-line-1 start) 5507 (setq r (- e (point)))
5469 (goto-char e) 5508 (> r 0))
5470 (indent-line-to ind)) 5509 (setq e (point))
5471 ((verilog-in-struct-p) 5510 (unless quiet (message "%d" r))
5472 ;; could have a declaration of a user defined item 5511 (verilog-indent-line)
5473 (goto-char e) 5512 (verilog-forward-ws&directives)
5474 (verilog-end-of-statement)) 5513 (cond
5475 (t ; Must be comment or white space 5514 ((or (and verilog-indent-declaration-macros
5476 (goto-char e) 5515 (looking-at verilog-declaration-re-2-macro))
5477 (verilog-forward-ws&directives) 5516 (looking-at verilog-declaration-re-2-no-macro))
5478 (forward-line -1))) 5517 (let ((p (match-end 0)))
5479 (forward-line 1)) 5518 (set-marker m1 p)
5480 (unless quiet (message "")))))) 5519 (if (verilog-re-search-forward "[[#`]" p 'move)
5520 (progn
5521 (forward-char -1)
5522 (just-one-space)
5523 (goto-char (marker-position m1))
5524 (just-one-space)
5525 (indent-to ind))
5526 (progn
5527 (just-one-space)
5528 (indent-to ind)))))
5529 ((verilog-continued-line-1 (marker-position startpos))
5530 (goto-char e)
5531 (indent-line-to ind))
5532 ((verilog-in-struct-p)
5533 ;; could have a declaration of a user defined item
5534 (goto-char e)
5535 (verilog-end-of-statement))
5536 (t ; Must be comment or white space
5537 (goto-char e)
5538 (verilog-forward-ws&directives)
5539 (forward-line -1)))
5540 (forward-line 1))
5541 (unless quiet (message "")))))))
5481 5542
5482(defun verilog-pretty-expr (&optional quiet myre) 5543(defun verilog-pretty-expr (&optional quiet myre)
5483 "Line up expressions around point, optionally QUIET with regexp MYRE." 5544 "Line up expressions around point, optionally QUIET with regexp MYRE."
@@ -5486,7 +5547,8 @@ Be verbose about progress unless optional QUIET set."
5486 (if (or (eq myre nil) 5547 (if (or (eq myre nil)
5487 (string-equal myre "")) 5548 (string-equal myre ""))
5488 (setq myre "\\(<\\|:\\)?=")) 5549 (setq myre "\\(<\\|:\\)?="))
5489 (setq myre (concat "\\(^[^;#:<=>]*\\)\\(" myre "\\)")) 5550 ;; want to match the first <= | := | =
5551 (setq myre (concat "\\(^.*?\\)\\(" myre "\\)"))
5490 (let ((rexp(concat "^\\s-*" verilog-complete-reg))) 5552 (let ((rexp(concat "^\\s-*" verilog-complete-reg)))
5491 (beginning-of-line) 5553 (beginning-of-line)
5492 (if (and (not (looking-at rexp )) 5554 (if (and (not (looking-at rexp ))
@@ -5529,7 +5591,7 @@ Be verbose about progress unless optional QUIET set."
5529 (beginning-of-line) 5591 (beginning-of-line)
5530 ) 5592 )
5531 e)) 5593 e))
5532 (edpos (set-marker (make-marker) end)) 5594 (endpos (set-marker (make-marker) end))
5533 (ind) 5595 (ind)
5534 ) 5596 )
5535 (goto-char start) 5597 (goto-char start)
@@ -5539,7 +5601,7 @@ Be verbose about progress unless optional QUIET set."
5539 (message "Lining up expressions..(please stand by)")) 5601 (message "Lining up expressions..(please stand by)"))
5540 5602
5541 ;; Set indent to minimum throughout region 5603 ;; Set indent to minimum throughout region
5542 (while (< (point) (marker-position edpos)) 5604 (while (< (point) (marker-position endpos))
5543 (beginning-of-line) 5605 (beginning-of-line)
5544 (verilog-just-one-space myre) 5606 (verilog-just-one-space myre)
5545 (end-of-line) 5607 (end-of-line)
@@ -5547,11 +5609,11 @@ Be verbose about progress unless optional QUIET set."
5547 ) 5609 )
5548 5610
5549 ;; Now find biggest prefix 5611 ;; Now find biggest prefix
5550 (setq ind (verilog-get-lineup-indent-2 myre start edpos)) 5612 (setq ind (verilog-get-lineup-indent-2 myre start endpos))
5551 5613
5552 ;; Now indent each line. 5614 ;; Now indent each line.
5553 (goto-char start) 5615 (goto-char start)
5554 (while (progn (setq e (marker-position edpos)) 5616 (while (progn (setq e (marker-position endpos))
5555 (setq r (- e (point))) 5617 (setq r (- e (point)))
5556 (> r 0)) 5618 (> r 0))
5557 (setq e (point)) 5619 (setq e (point))
@@ -5679,7 +5741,8 @@ Region is defined by B and EDPOS."
5679 ;; No lineup-string found 5741 ;; No lineup-string found
5680 (goto-char b) 5742 (goto-char b)
5681 (end-of-line) 5743 (end-of-line)
5682 (skip-chars-backward " \t") 5744 (verilog-backward-syntactic-ws)
5745 ;;(skip-chars-backward " \t")
5683 (1+ (current-column)))))) 5746 (1+ (current-column))))))
5684 5747
5685(defun verilog-get-lineup-indent-2 (myre b edpos) 5748(defun verilog-get-lineup-indent-2 (myre b edpos)
@@ -5747,7 +5810,7 @@ it displays a list of all possible completions.")
5747 '( 5810 '(
5748 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input" 5811 "and" "buf" "bufif0" "bufif1" "cmos" "defparam" "inout" "input"
5749 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0" 5812 "integer" "localparam" "logic" "mailbox" "nand" "nmos" "nor" "not" "notif0"
5750 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pullup" 5813 "notif1" "or" "output" "parameter" "pmos" "pull0" "pull1" "pulldown" "pullup"
5751 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0" 5814 "rcmos" "real" "realtime" "reg" "rnmos" "rpmos" "rtran" "rtranif0"
5752 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1" 5815 "rtranif1" "semaphore" "time" "tran" "tranif0" "tranif1" "tri" "tri0" "tri1"
5753 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor" 5816 "triand" "trior" "trireg" "wand" "wire" "wor" "xnor" "xor"
@@ -6974,7 +7037,7 @@ Return the list of signals found, using submodi to look up each port."
6974 (verilog-read-sub-decls-expr 7037 (verilog-read-sub-decls-expr
6975 submoddecls comment port 7038 submoddecls comment port
6976 (buffer-substring 7039 (buffer-substring
6977 (point) (1- (progn (backward-char 1) ; start at ( 7040 (point) (1- (progn (search-backward "(") ; start at (
6978 (forward-sexp 1) (point)))))))) ; expr 7041 (forward-sexp 1) (point)))))))) ; expr
6979 ;; 7042 ;;
6980 (forward-line 1))))) 7043 (forward-line 1)))))
@@ -8747,6 +8810,8 @@ Avoid declaring ports manually, as it makes code harder to maintain."
8747(defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning 8810(defvar vl-name nil "See `verilog-auto-inst'.") ; Prevent compile warning
8748(defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning 8811(defvar vl-width nil "See `verilog-auto-inst'.") ; Prevent compile warning
8749(defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning 8812(defvar vl-dir nil "See `verilog-auto-inst'.") ; Prevent compile warning
8813(defvar vl-bits nil "See `verilog-auto-inst'.") ; Prevent compile warning
8814(defvar vl-mbits nil "See `verilog-auto-inst'.") ; Prevent compile warning
8750 8815
8751(defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star par-values) 8816(defun verilog-auto-inst-port (port-st indent-pt tpl-list tpl-num for-star par-values)
8752 "Print out a instantiation connection for this PORT-ST. 8817 "Print out a instantiation connection for this PORT-ST.
@@ -8762,6 +8827,8 @@ If PAR-VALUES replace final strings with these parameter values."
8762 (vl-name (verilog-sig-name port-st)) 8827 (vl-name (verilog-sig-name port-st))
8763 (vl-width (verilog-sig-width port-st)) 8828 (vl-width (verilog-sig-width port-st))
8764 (vl-modport (verilog-sig-modport port-st)) 8829 (vl-modport (verilog-sig-modport port-st))
8830 (vl-mbits (if (verilog-sig-multidim port-st)
8831 (verilog-sig-multidim-string port-st) ""))
8765 (vl-bits (if (or verilog-auto-inst-vector 8832 (vl-bits (if (or verilog-auto-inst-vector
8766 (not (assoc port vector-skip-list)) 8833 (not (assoc port vector-skip-list))
8767 (not (equal (verilog-sig-bits port-st) 8834 (not (equal (verilog-sig-bits port-st)
@@ -9110,6 +9177,7 @@ Lisp Templates:
9110 9177
9111 vl-name Name portion of the input/output port. 9178 vl-name Name portion of the input/output port.
9112 vl-bits Bus bits portion of the input/output port ('[2:0]'). 9179 vl-bits Bus bits portion of the input/output port ('[2:0]').
9180 vl-mbits Multidimensional array bits for port ('[2:0][3:0]').
9113 vl-width Width of the input/output port ('3' for [2:0]). 9181 vl-width Width of the input/output port ('3' for [2:0]).
9114 May be a (...) expression if bits isn't a constant. 9182 May be a (...) expression if bits isn't a constant.
9115 vl-dir Direction of the pin input/output/inout/interface. 9183 vl-dir Direction of the pin input/output/inout/interface.