Function: vhdl-port-paste-initializations
vhdl-port-paste-initializations is an interactive and byte-compiled
function defined in vhdl-mode.el.gz.
Signature
(vhdl-port-paste-initializations &optional NO-INDENT)
Documentation
Paste ports as signal initializations.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-port-paste-initializations (&optional no-indent)
"Paste ports as signal initializations."
(interactive)
(if (not vhdl-port-list)
(error "ERROR: No port read")
(let ((orig-vhdl-port-list vhdl-port-list))
(message "Pasting port as initializations...")
;; flatten local copy of port list (must be flat for signal initial.)
(vhdl-port-flatten)
(unless no-indent (indent-according-to-mode))
(let ((margin (current-indentation))
start port name
(port-list (nth 2 vhdl-port-list)))
(when port-list
(setq start (point))
(while port-list
(setq port (car port-list))
;; paste actual port signal (inputs only)
(when (equal "IN" (upcase (nth 2 port)))
(setq name (car (nth 0 port)))
(insert (vhdl-replace-string vhdl-actual-port-name name))
;; paste initialization
(insert " <= "
(cond ((string-match "integer" (nth 3 port)) "0")
((string-match "natural" (nth 3 port)) "0")
((string-match "positive" (nth 3 port)) "0")
((string-match "real" (nth 3 port)) "0.0")
((string-match "(.+)" (nth 3 port)) "(others => '0')")
(t "'0'"))
";"))
(setq port-list (cdr port-list))
(when (and port-list
(equal "IN" (upcase (nth 2 (car port-list)))))
(insert "\n") (indent-to margin)))
;; align signal list
(when vhdl-auto-align (vhdl-align-region-groups start (point) 1))))
(message "Pasting port as initializations...done")
(setq vhdl-port-list orig-vhdl-port-list))))