Function: vhdl-compose-configuration-architecture

vhdl-compose-configuration-architecture is a byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-compose-configuration-architecture ENT-NAME ARCH-NAME ENT-ALIST-ARG CONF-ALIST-ARG INST-ALIST &optional INSERT-CONF)

Documentation

Generate block configuration for architecture.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-compose-configuration-architecture ( _ent-name arch-name
						 ent-alist-arg conf-alist-arg
						 inst-alist
						 &optional insert-conf)
  "Generate block configuration for architecture."
  (let ((ent-alist ent-alist-arg)
	(conf-alist conf-alist-arg)
	(margin (current-indentation))
	(beg (point-at-bol))
	ent-entry inst-entry inst-path inst-prev-path tmp-alist) ;; cons-key
    ;; insert block configuration (for architecture)
    (vhdl-insert-keyword "FOR ") (insert arch-name "\n")
    (setq margin (+ margin vhdl-basic-offset))
    ;; process all instances
    (while inst-alist
      (setq inst-entry (car inst-alist))
      ;; is component?
      (when (nth 4 inst-entry)
	(setq insert-conf t)
	(setq inst-path (nth 9 inst-entry))
	;; skip common path with previous instance
	(while (and inst-path (equal (car inst-path) (car inst-prev-path)))
	  (setq inst-path (cdr inst-path)
		inst-prev-path (cdr inst-prev-path)))
	;; insert block configuration end (for previous block/generate)
	(while inst-prev-path
	  (setq margin (- margin vhdl-basic-offset))
	  (indent-to margin)
	  (vhdl-insert-keyword "END FOR;\n")
	  (setq inst-prev-path (cdr inst-prev-path)))
	;; insert block configuration beginning (for current block/generate)
	(indent-to margin)
	(while inst-path
	  (setq margin (+ margin vhdl-basic-offset))
	  (vhdl-insert-keyword "FOR ")
	  (insert (car inst-path) "\n")
	  (indent-to margin)
	  (setq inst-path (cdr inst-path)))
	;; insert component configuration beginning
	(vhdl-insert-keyword "FOR ")
	(insert (nth 1 inst-entry) " : " (nth 4 inst-entry) "\n")
	;; find subconfiguration
	(setq conf-key (nth 7 inst-entry))
	(setq tmp-alist conf-alist)
	;; use first configuration found for instance's entity
	(while (and tmp-alist (null conf-key))
	  (when (equal (nth 5 inst-entry) (nth 4 (car tmp-alist)))
	    (setq conf-key (nth 0 (car tmp-alist))))
	  (setq tmp-alist (cdr tmp-alist)))
	(setq conf-entry (vhdl-aget conf-alist conf-key))
	;; insert binding indication ...
	;; ... with subconfiguration (if exists)
	(if (and vhdl-compose-configuration-use-subconfiguration conf-entry)
	    (progn
	      (indent-to (+ margin vhdl-basic-offset))
	      (vhdl-insert-keyword "USE CONFIGURATION ")
	      (insert (vhdl-work-library) "." (nth 0 conf-entry))
	      (insert ";\n"))
	  ;; ... with entity (if exists)
	  (setq ent-entry (vhdl-aget ent-alist (nth 5 inst-entry)))
	  (when ent-entry
	    (indent-to (+ margin vhdl-basic-offset))
	    (vhdl-insert-keyword "USE ENTITY ")
	    (insert (vhdl-work-library) "." (nth 0 ent-entry))
	    ;; insert architecture name (if architecture exists)
	    (when (nth 3 ent-entry)
	      (setq arch-name
		    ;; choose architecture name a) from configuration,
		    ;; b) from mra, or c) from first architecture
		    (or (nth 0 (vhdl-aget (nth 3 ent-entry)
					  (or (nth 6 inst-entry)
					      (nth 4 ent-entry))))
			(nth 1 (car (nth 3 ent-entry)))))
	      (insert "(" arch-name ")"))
	    (insert ";\n")
	    ;; insert block configuration (for architecture of subcomponent)
	    (when (and vhdl-compose-configuration-hierarchical
		       (nth 3 ent-entry))
	      (indent-to (+ margin vhdl-basic-offset))
	      (vhdl-compose-configuration-architecture
	       (nth 0 ent-entry) arch-name ent-alist conf-alist
	       (nth 3 (vhdl-aget (nth 3 ent-entry) (downcase arch-name)))))))
	;; insert component configuration end
	(indent-to margin)
	(vhdl-insert-keyword "END FOR;\n")
	(setq inst-prev-path (nth 9 inst-entry)))
      (setq inst-alist (cdr inst-alist)))
    ;; insert block configuration end (for block/generate)
    (while inst-prev-path
      (setq margin (- margin vhdl-basic-offset))
      (indent-to margin)
      (vhdl-insert-keyword "END FOR;\n")
      (setq inst-prev-path (cdr inst-prev-path)))
    (indent-to (- margin vhdl-basic-offset))
    ;; insert block configuration end or remove beginning (for architecture)
    (if insert-conf
	(vhdl-insert-keyword "END FOR;\n")
      (delete-region beg (point)))))