Function: vhdl-compose-configuration
vhdl-compose-configuration is an interactive and byte-compiled
function defined in vhdl-mode.el.gz.
Signature
(vhdl-compose-configuration &optional ENT-NAME ARCH-NAME)
Documentation
Generate configuration declaration.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-compose-configuration (&optional ent-name arch-name)
"Generate configuration declaration."
(interactive)
(vhdl-require-hierarchy-info)
(let ((ent-alist (vhdl-aget vhdl-entity-alist
(or (vhdl-project-p)
(abbreviate-file-name default-directory))))
(conf-alist (vhdl-aget vhdl-config-alist
(or (vhdl-project-p)
(abbreviate-file-name default-directory))))
(from-speedbar ent-name)
inst-alist conf-name conf-file-name pos)
(vhdl-prepare-search-2
;; get entity and architecture name
(unless ent-name
(save-excursion
(unless (and (re-search-backward "^\\(architecture\\s-+\\(\\w+\\)\\s-+of\\s-+\\(\\w+\\)\\|end\\)\\>" nil t)
(not (equal "END" (upcase (match-string 1))))
(setq ent-name (match-string-no-properties 3))
(setq arch-name (match-string-no-properties 2)))
(error "ERROR: Not within an architecture"))))
(setq conf-name (vhdl-replace-string
vhdl-compose-configuration-name
(concat ent-name " " arch-name)))
(setq inst-alist
(nth 3 (vhdl-aget (nth 3 (vhdl-aget ent-alist (downcase ent-name)))
(downcase arch-name)))))
(message "Generating configuration \"%s\"..." conf-name)
(if vhdl-compose-configuration-create-file
;; open configuration file
(progn
(setq conf-file-name
(concat (vhdl-replace-string vhdl-configuration-file-name
conf-name t)
"." (file-name-extension (buffer-file-name))))
(when (and (file-exists-p conf-file-name)
(not (y-or-n-p (concat "File \"" conf-file-name
"\" exists; overwrite? "))))
(error "ERROR: Creating configuration...aborted"))
(find-file conf-file-name)
(erase-buffer)
(set-buffer-modified-p nil)
;; insert header
(if vhdl-compose-include-header
(progn (vhdl-template-header
(concat "Configuration declaration for design \""
ent-name "(" arch-name ")\""))
(goto-char (point-max)))
(vhdl-comment-display-line) (insert "\n\n")))
;; goto end of architecture
(unless from-speedbar
(re-search-forward "^end\\>" nil)
(end-of-line) (insert "\n\n")
(vhdl-comment-display-line) (insert "\n\n")))
;; insert library clause
(setq pos (point))
(vhdl-template-standard-package (vhdl-work-library) nil)
(when (/= pos (point))
(insert "\n\n"))
;; insert configuration
(vhdl-insert-keyword "CONFIGURATION ") (insert conf-name)
(vhdl-insert-keyword " OF ") (insert ent-name)
(vhdl-insert-keyword " IS\n")
(indent-to vhdl-basic-offset)
;; insert block configuration (for architecture)
(vhdl-compose-configuration-architecture
ent-name arch-name ent-alist conf-alist inst-alist t)
(vhdl-insert-keyword "END ") (insert conf-name ";")
(when conf-file-name
;; insert footer and save
(insert "\n\n")
(if (and vhdl-compose-include-header (not (equal vhdl-file-footer "")))
(vhdl-template-footer)
(vhdl-comment-display-line) (insert "\n"))
(save-buffer))
(message "%s"
(concat (format "Generating configuration \"%s\"...done" conf-name)
(and conf-file-name
(format "\n File created: \"%s\"" conf-file-name))))))