diff options
| author | Dan Nicolaescu | 2008-03-25 15:45:49 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-03-25 15:45:49 +0000 |
| commit | e2076c2c17dd412fa238d5743ff2294884ba061b (patch) | |
| tree | 2acf03c91840eb83ab67d1a5fbf1ee29f294ccc4 | |
| parent | 98db7a382a424fb0644ab96baf7982f1ef8342bf (diff) | |
| download | emacs-e2076c2c17dd412fa238d5743ff2294884ba061b.tar.gz emacs-e2076c2c17dd412fa238d5743ff2294884ba061b.zip | |
(verilog-auto-output)
(verilog-auto-input, verilog-auto-inout, verilog-auto)
(verilog-delete-auto): Add optional regular expression to
AUTOINPUT/AUTOOUTPUT/AUTOINOUT.
(verilog-signals-matching-regexp): New internal function for
signal matching.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/progmodes/verilog-mode.el | 97 |
2 files changed, 89 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 49747f9bfb9..96471a279b4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2008-03-25 Wilson Snyder <wsnyder@wsnyder.org> | ||
| 2 | |||
| 3 | * progmodes/verilog-mode.el (verilog-auto-output) | ||
| 4 | (verilog-auto-input, verilog-auto-inout, verilog-auto) | ||
| 5 | (verilog-delete-auto): Add optional regular expression to | ||
| 6 | AUTOINPUT/AUTOOUTPUT/AUTOINOUT. | ||
| 7 | (verilog-signals-matching-regexp): New internal function for | ||
| 8 | signal matching. | ||
| 9 | |||
| 1 | 2008-03-25 Johan Bockg$(Q)[(Brd <bojohan@gnu.org> | 10 | 2008-03-25 Johan Bockg$(Q)[(Brd <bojohan@gnu.org> |
| 2 | 11 | ||
| 3 | * info.el (Info-isearch-search): Always return point. | 12 | * info.el (Info-isearch-search): Always return point. |
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 71b870b27ed..d156637f261 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el | |||
| @@ -7333,6 +7333,17 @@ and invalidating the cache." | |||
| 7333 | (setq enumlist (cdr enumlist)))) | 7333 | (setq enumlist (cdr enumlist)))) |
| 7334 | (nreverse out-list))) | 7334 | (nreverse out-list))) |
| 7335 | 7335 | ||
| 7336 | (defun verilog-signals-matching-regexp (in-list regexp) | ||
| 7337 | "Return all signals in IN-LIST matching the given REGEXP, if non-nil." | ||
| 7338 | (if (not regexp) | ||
| 7339 | in-list | ||
| 7340 | (let (out-list) | ||
| 7341 | (while in-list | ||
| 7342 | (if (string-match regexp (verilog-sig-name (car in-list))) | ||
| 7343 | (setq out-list (cons (car in-list) out-list))) | ||
| 7344 | (setq in-list (cdr in-list))) | ||
| 7345 | (nreverse out-list)))) | ||
| 7346 | |||
| 7336 | (defun verilog-signals-not-matching-regexp (in-list regexp) | 7347 | (defun verilog-signals-not-matching-regexp (in-list regexp) |
| 7337 | "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." | 7348 | "Return all signals in IN-LIST not matching the given REGEXP, if non-nil." |
| 7338 | (if (not regexp) | 7349 | (if (not regexp) |
| @@ -7643,15 +7654,28 @@ called before and after this function, respectively." | |||
| 7643 | ;; Allow user to customize | 7654 | ;; Allow user to customize |
| 7644 | (run-hooks 'verilog-before-delete-auto-hook) | 7655 | (run-hooks 'verilog-before-delete-auto-hook) |
| 7645 | 7656 | ||
| 7646 | ;; Remove those that have multi-line insertions | 7657 | ;; Remove those that have multi-line insertions, possibly with parameters |
| 7647 | (verilog-auto-re-search-do "/\\*AUTO\\(OUTPUTEVERY\\|CONCATCOMMENT\\|WIRE\\|REG\\|DEFINEVALUE\\|REGINPUT\\|INPUT\\|OUTPUT\\|INOUT\\|RESET\\|TIEOFF\\|UNUSED\\)\\*/" | 7658 | (verilog-auto-re-search-do |
| 7648 | 'verilog-delete-autos-lined) | 7659 | (concat "/\\*" |
| 7649 | ;; Remove those that have multi-line insertions with parameters | 7660 | (eval-when-compile |
| 7650 | (verilog-auto-re-search-do "/\\*AUTO\\(INOUTMODULE\\|ASCIIENUM\\)([^)]*)\\*/" | 7661 | (verilog-regexp-words |
| 7651 | 'verilog-delete-autos-lined) | 7662 | `("AUTOASCIIENUM" "AUTOCONCATCOMMENT" "AUTODEFINEVALUE" |
| 7663 | "AUTOINOUT" "AUTOINOUTMODULE" "AUTOINPUT" "AUTOOUTPUT" | ||
| 7664 | "AUTOOUTPUTEVERY" | ||
| 7665 | "AUTOREG" "AUTOREGINPUT" "AUTORESET" "AUTOTIEOFF" | ||
| 7666 | "AUTOUNUSED" "AUTOWIRE"))) | ||
| 7667 | "\\(\\|([^)]*)\\|(\"[^\"]*\")\\)" ; Optional parens or quoted parameter | ||
| 7668 | "\\*/") | ||
| 7669 | 'verilog-delete-autos-lined) | ||
| 7652 | ;; Remove those that are in parenthesis | 7670 | ;; Remove those that are in parenthesis |
| 7653 | (verilog-auto-re-search-do "/\\*\\(AS\\|AUTO\\(ARG\\|CONCATWIDTH\\|INST\\|INSTPARAM\\|SENSE\\)\\)\\*/" | 7671 | (verilog-auto-re-search-do |
| 7654 | 'verilog-delete-to-paren) | 7672 | (concat "/\\*" |
| 7673 | (eval-when-compile | ||
| 7674 | (verilog-regexp-words | ||
| 7675 | `("AS" "AUTOARG" "AUTOCONCATWIDTH" "AUTOINST" "AUTOINSTPARAM" | ||
| 7676 | "AUTOSENSE"))) | ||
| 7677 | "\\*/") | ||
| 7678 | 'verilog-delete-to-paren) | ||
| 7655 | ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments | 7679 | ;; Do .* instantiations, but avoid removing any user pins by looking for our magic comments |
| 7656 | (verilog-auto-re-search-do "\\.\\*" | 7680 | (verilog-auto-re-search-do "\\.\\*" |
| 7657 | 'verilog-delete-auto-star-all) | 7681 | 'verilog-delete-auto-star-all) |
| @@ -8636,7 +8660,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 8636 | (goto-char pnt) | 8660 | (goto-char pnt) |
| 8637 | (verilog-pretty-expr "//")))))) | 8661 | (verilog-pretty-expr "//")))))) |
| 8638 | 8662 | ||
| 8639 | (defun verilog-auto-output () | 8663 | (defun verilog-auto-output (&optional with-params) |
| 8640 | "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. | 8664 | "Expand AUTOOUTPUT statements, as part of \\[verilog-auto]. |
| 8641 | Make output statements for any output signal from an /*AUTOINST*/ that | 8665 | Make output statements for any output signal from an /*AUTOINST*/ that |
| 8642 | isn't a input to another AUTOINST. This is useful for modules which | 8666 | isn't a input to another AUTOINST. This is useful for modules which |
| @@ -8676,10 +8700,18 @@ Typing \\[verilog-auto] will make this into: | |||
| 8676 | .ov (ov[31:0]), | 8700 | .ov (ov[31:0]), |
| 8677 | // Inputs | 8701 | // Inputs |
| 8678 | .i (i)); | 8702 | .i (i)); |
| 8679 | endmodule" | 8703 | endmodule |
| 8704 | |||
| 8705 | You may also provide an optional regular expression, in which case only | ||
| 8706 | signals matching the regular expression will be included. For example the | ||
| 8707 | same expansion will result from only extracting outputs starting with ov: | ||
| 8708 | |||
| 8709 | /*AUTOOUTPUT(\"^ov\")*/" | ||
| 8680 | (save-excursion | 8710 | (save-excursion |
| 8681 | ;; Point must be at insertion point. | 8711 | ;; Point must be at insertion point. |
| 8682 | (let* ((indent-pt (current-indentation)) | 8712 | (let* ((indent-pt (current-indentation)) |
| 8713 | (regexp (and with-params | ||
| 8714 | (nth 0 (verilog-read-auto-params 1)))) | ||
| 8683 | (v2k (verilog-in-paren)) | 8715 | (v2k (verilog-in-paren)) |
| 8684 | (modi (verilog-modi-current)) | 8716 | (modi (verilog-modi-current)) |
| 8685 | (sig-list (verilog-signals-not-in | 8717 | (sig-list (verilog-signals-not-in |
| @@ -8688,6 +8720,9 @@ Typing \\[verilog-auto] will make this into: | |||
| 8688 | (verilog-modi-get-inouts modi) | 8720 | (verilog-modi-get-inouts modi) |
| 8689 | (verilog-modi-get-sub-inputs modi) | 8721 | (verilog-modi-get-sub-inputs modi) |
| 8690 | (verilog-modi-get-sub-inouts modi))))) | 8722 | (verilog-modi-get-sub-inouts modi))))) |
| 8723 | (when regexp | ||
| 8724 | (setq sig-list (verilog-signals-matching-regexp | ||
| 8725 | sig-list regexp))) | ||
| 8691 | (setq sig-list (verilog-signals-not-matching-regexp | 8726 | (setq sig-list (verilog-signals-not-matching-regexp |
| 8692 | sig-list verilog-auto-output-ignore-regexp)) | 8727 | sig-list verilog-auto-output-ignore-regexp)) |
| 8693 | (forward-line 1) | 8728 | (forward-line 1) |
| @@ -8749,7 +8784,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 8749 | (verilog-insert-indent "// End of automatics\n")) | 8784 | (verilog-insert-indent "// End of automatics\n")) |
| 8750 | (when v2k (verilog-repair-close-comma))))) | 8785 | (when v2k (verilog-repair-close-comma))))) |
| 8751 | 8786 | ||
| 8752 | (defun verilog-auto-input () | 8787 | (defun verilog-auto-input (&optional with-params) |
| 8753 | "Expand AUTOINPUT statements, as part of \\[verilog-auto]. | 8788 | "Expand AUTOINPUT statements, as part of \\[verilog-auto]. |
| 8754 | Make input statements for any input signal into an /*AUTOINST*/ that | 8789 | Make input statements for any input signal into an /*AUTOINST*/ that |
| 8755 | isn't declared elsewhere inside the module. This is useful for modules which | 8790 | isn't declared elsewhere inside the module. This is useful for modules which |
| @@ -8789,9 +8824,17 @@ Typing \\[verilog-auto] will make this into: | |||
| 8789 | .ov (ov[31:0]), | 8824 | .ov (ov[31:0]), |
| 8790 | // Inputs | 8825 | // Inputs |
| 8791 | .i (i)); | 8826 | .i (i)); |
| 8792 | endmodule" | 8827 | endmodule |
| 8828 | |||
| 8829 | You may also provide an optional regular expression, in which case only | ||
| 8830 | signals matching the regular expression will be included. For example the | ||
| 8831 | same expansion will result from only extracting inputs starting with i: | ||
| 8832 | |||
| 8833 | /*AUTOINPUT(\"^i\")*/" | ||
| 8793 | (save-excursion | 8834 | (save-excursion |
| 8794 | (let* ((indent-pt (current-indentation)) | 8835 | (let* ((indent-pt (current-indentation)) |
| 8836 | (regexp (and with-params | ||
| 8837 | (nth 0 (verilog-read-auto-params 1)))) | ||
| 8795 | (v2k (verilog-in-paren)) | 8838 | (v2k (verilog-in-paren)) |
| 8796 | (modi (verilog-modi-current)) | 8839 | (modi (verilog-modi-current)) |
| 8797 | (sig-list (verilog-signals-not-in | 8840 | (sig-list (verilog-signals-not-in |
| @@ -8804,6 +8847,9 @@ Typing \\[verilog-auto] will make this into: | |||
| 8804 | (verilog-modi-get-gparams modi) | 8847 | (verilog-modi-get-gparams modi) |
| 8805 | (verilog-modi-get-sub-outputs modi) | 8848 | (verilog-modi-get-sub-outputs modi) |
| 8806 | (verilog-modi-get-sub-inouts modi))))) | 8849 | (verilog-modi-get-sub-inouts modi))))) |
| 8850 | (when regexp | ||
| 8851 | (setq sig-list (verilog-signals-matching-regexp | ||
| 8852 | sig-list regexp))) | ||
| 8807 | (setq sig-list (verilog-signals-not-matching-regexp | 8853 | (setq sig-list (verilog-signals-not-matching-regexp |
| 8808 | sig-list verilog-auto-input-ignore-regexp)) | 8854 | sig-list verilog-auto-input-ignore-regexp)) |
| 8809 | (forward-line 1) | 8855 | (forward-line 1) |
| @@ -8815,7 +8861,7 @@ Typing \\[verilog-auto] will make this into: | |||
| 8815 | (verilog-insert-indent "// End of automatics\n")) | 8861 | (verilog-insert-indent "// End of automatics\n")) |
| 8816 | (when v2k (verilog-repair-close-comma))))) | 8862 | (when v2k (verilog-repair-close-comma))))) |
| 8817 | 8863 | ||
| 8818 | (defun verilog-auto-inout () | 8864 | (defun verilog-auto-inout (&optional with-params) |
| 8819 | "Expand AUTOINOUT statements, as part of \\[verilog-auto]. | 8865 | "Expand AUTOINOUT statements, as part of \\[verilog-auto]. |
| 8820 | Make inout statements for any inout signal in an /*AUTOINST*/ that | 8866 | Make inout statements for any inout signal in an /*AUTOINST*/ that |
| 8821 | isn't declared elsewhere inside the module. | 8867 | isn't declared elsewhere inside the module. |
| @@ -8854,10 +8900,18 @@ Typing \\[verilog-auto] will make this into: | |||
| 8854 | .ov (ov[31:0]), | 8900 | .ov (ov[31:0]), |
| 8855 | // Inputs | 8901 | // Inputs |
| 8856 | .i (i)); | 8902 | .i (i)); |
| 8857 | endmodule" | 8903 | endmodule |
| 8904 | |||
| 8905 | You may also provide an optional regular expression, in which case only | ||
| 8906 | signals matching the regular expression will be included. For example the | ||
| 8907 | same expansion will result from only extracting inouts starting with i: | ||
| 8908 | |||
| 8909 | /*AUTOINOUT(\"^i\")*/" | ||
| 8858 | (save-excursion | 8910 | (save-excursion |
| 8859 | ;; Point must be at insertion point. | 8911 | ;; Point must be at insertion point. |
| 8860 | (let* ((indent-pt (current-indentation)) | 8912 | (let* ((indent-pt (current-indentation)) |
| 8913 | (regexp (and with-params | ||
| 8914 | (nth 0 (verilog-read-auto-params 1)))) | ||
| 8861 | (v2k (verilog-in-paren)) | 8915 | (v2k (verilog-in-paren)) |
| 8862 | (modi (verilog-modi-current)) | 8916 | (modi (verilog-modi-current)) |
| 8863 | (sig-list (verilog-signals-not-in | 8917 | (sig-list (verilog-signals-not-in |
| @@ -8867,6 +8921,9 @@ Typing \\[verilog-auto] will make this into: | |||
| 8867 | (verilog-modi-get-inputs modi) | 8921 | (verilog-modi-get-inputs modi) |
| 8868 | (verilog-modi-get-sub-inputs modi) | 8922 | (verilog-modi-get-sub-inputs modi) |
| 8869 | (verilog-modi-get-sub-outputs modi))))) | 8923 | (verilog-modi-get-sub-outputs modi))))) |
| 8924 | (when regexp | ||
| 8925 | (setq sig-list (verilog-signals-matching-regexp | ||
| 8926 | sig-list regexp))) | ||
| 8870 | (setq sig-list (verilog-signals-not-matching-regexp | 8927 | (setq sig-list (verilog-signals-not-matching-regexp |
| 8871 | sig-list verilog-auto-inout-ignore-regexp)) | 8928 | sig-list verilog-auto-inout-ignore-regexp)) |
| 8872 | (forward-line 1) | 8929 | (forward-line 1) |
| @@ -9556,9 +9613,15 @@ Wilson Snyder (wsnyder@wsnyder.org), and/or see http://www.veripool.com." | |||
| 9556 | ;; first in/outs from other files | 9613 | ;; first in/outs from other files |
| 9557 | (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) | 9614 | (verilog-auto-re-search-do "/\\*AUTOINOUTMODULE([^)]*)\\*/" 'verilog-auto-inout-module) |
| 9558 | ;; next in/outs which need previous sucked inputs first | 9615 | ;; next in/outs which need previous sucked inputs first |
| 9559 | (verilog-auto-search-do "/*AUTOOUTPUT*/" 'verilog-auto-output) | 9616 | (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\((\"[^\"]*\")\\)\\*/" |
| 9560 | (verilog-auto-search-do "/*AUTOINPUT*/" 'verilog-auto-input) | 9617 | '(lambda () (verilog-auto-output t))) |
| 9561 | (verilog-auto-search-do "/*AUTOINOUT*/" 'verilog-auto-inout) | 9618 | (verilog-auto-re-search-do "/\\*AUTOOUTPUT\\*/" 'verilog-auto-output) |
| 9619 | (verilog-auto-re-search-do "/\\*AUTOINPUT\\((\"[^\"]*\")\\)\\*/" | ||
| 9620 | '(lambda () (verilog-auto-input t))) | ||
| 9621 | (verilog-auto-re-search-do "/\\*AUTOINPUT\\*/" 'verilog-auto-input) | ||
| 9622 | (verilog-auto-re-search-do "/\\*AUTOINOUT\\((\"[^\"]*\")\\)\\*/" | ||
| 9623 | '(lambda () (verilog-auto-inout t))) | ||
| 9624 | (verilog-auto-re-search-do "/\\*AUTOINOUT\\*/" 'verilog-auto-inout) | ||
| 9562 | ;; Then tie off those in/outs | 9625 | ;; Then tie off those in/outs |
| 9563 | (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff) | 9626 | (verilog-auto-search-do "/*AUTOTIEOFF*/" 'verilog-auto-tieoff) |
| 9564 | ;; Wires/regs must be after inputs/outputs | 9627 | ;; Wires/regs must be after inputs/outputs |