Function: vhdl-get-hierarchy

vhdl-get-hierarchy is a byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-get-hierarchy ENT-ALIST-ARG CONF-ALIST-ARG ENT-KEY ARCH-KEY CONF-KEY-ARG CONF-INST-ALIST LEVEL INDENT &optional INCLUDE-TOP ENT-HIER)

Documentation

Get instantiation hierarchy beginning in architecture ARCH-KEY of entity ENT-KEY.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
;; structure (parenthesized expression means list of such entries)
;; (inst-key inst-file-marker comp-ent-key comp-ent-file-marker
;;  comp-arch-key comp-arch-file-marker comp-conf-key comp-conf-file-marker
;;  comp-lib-name level)
(defun vhdl-get-hierarchy ( ent-alist-arg conf-alist-arg ent-key arch-key
			    conf-key-arg conf-inst-alist level indent
			    &optional include-top ent-hier)
  "Get instantiation hierarchy beginning in architecture ARCH-KEY of
entity ENT-KEY."
  (let* ((ent-alist ent-alist-arg)
	 (conf-alist conf-alist-arg)
	 (conf-key conf-key-arg)
	 (ent-entry (vhdl-aget ent-alist ent-key))
	 (arch-entry (if arch-key (vhdl-aget (nth 3 ent-entry) arch-key)
		       (cdar (last (nth 3 ent-entry)))))
	 (inst-alist (nth 3 arch-entry))
	 inst-entry inst-ent-entry inst-arch-entry inst-conf-entry comp-entry
	 hier-list subcomp-list tmp-list inst-key inst-comp-name
	 inst-ent-key inst-arch-key inst-conf-key inst-lib-key)
    (when (= level 0) (message "Extract design hierarchy..."))
    (when include-top
      (setq level (1+ level)))
    (when (member ent-key ent-hier)
      (error "ERROR:  Instantiation loop detected, component instantiates itself: \"%s\"" ent-key))
    ;; process all instances
    (while inst-alist
      (setq inst-entry (car inst-alist)
	    inst-key (nth 0 inst-entry)
	    inst-comp-name (nth 4 inst-entry)
	    inst-conf-key (nth 7 inst-entry))
      ;; search entry in configuration's instantiations list
      (setq tmp-list conf-inst-alist)
      (while (and tmp-list
		  (not (and (member (nth 0 (car tmp-list))
				    (list "all" inst-key))
			    (equal (nth 1 (car tmp-list))
				   (downcase (or inst-comp-name ""))))))
	(setq tmp-list (cdr tmp-list)))
      (setq inst-conf-key (or (nth 4 (car tmp-list)) inst-conf-key))
      (setq inst-conf-entry (vhdl-aget conf-alist inst-conf-key))
      (when (and inst-conf-key (not inst-conf-entry))
	(vhdl-warning-when-idle "Configuration not found: \"%s\"" inst-conf-key))
      ;; determine entity
      (setq inst-ent-key
	    (or (nth 2 (car tmp-list))	; from configuration
		(nth 3 inst-conf-entry) ; from subconfiguration
		(nth 3 (vhdl-aget conf-alist (nth 7 inst-entry)))
					; from configuration spec.
		(nth 5 inst-entry)))	; from direct instantiation
      (setq inst-ent-entry (vhdl-aget ent-alist inst-ent-key))
      ;; determine architecture
      (setq inst-arch-key
	    (or (nth 3 (car tmp-list))		; from configuration
		(nth 4 inst-conf-entry)		; from subconfiguration
		(nth 6 inst-entry)		; from direct instantiation
		(nth 4 (vhdl-aget conf-alist (nth 7 inst-entry)))
						; from configuration spec.
		(nth 4 inst-ent-entry)		; MRA
		(caar (nth 3 inst-ent-entry))))	; first alphabetically
      (setq inst-arch-entry (vhdl-aget (nth 3 inst-ent-entry) inst-arch-key))
      ;; set library
      (setq inst-lib-key
	    (or (nth 5 (car tmp-list))		; from configuration
		(nth 8 inst-entry)))		; from direct instantiation
      ;; gather information for this instance
      (setq comp-entry
	    (list (nth 1 inst-entry)
		  (cons (nth 2 inst-entry) (nth 3 inst-entry))
		  (or (nth 0 inst-ent-entry) (nth 4 inst-entry))
		  (cons (nth 1 inst-ent-entry) (nth 2 inst-ent-entry))
		  (or (nth 0 inst-arch-entry) inst-arch-key)
		  (cons (nth 1 inst-arch-entry) (nth 2 inst-arch-entry))
		  (or (nth 0 inst-conf-entry) inst-conf-key)
		  (cons (nth 1 inst-conf-entry) (nth 2 inst-conf-entry))
		  inst-lib-key level))
      ;; get subcomponent hierarchy
      (setq subcomp-list (vhdl-get-hierarchy
			  ent-alist conf-alist
			  inst-ent-key inst-arch-key inst-conf-key
			  (nth 5 inst-conf-entry)
			  (1+ level) indent nil (cons ent-key ent-hier)))
      ;; add to list
      (setq hier-list (append hier-list (list comp-entry) subcomp-list))
      (setq inst-alist (cdr inst-alist)))
    (when include-top
      (setq hier-list
	    (cons (list nil nil (nth 0 ent-entry)
			(cons (nth 1 ent-entry) (nth 2 ent-entry))
			(nth 0 arch-entry)
			(cons (nth 1 arch-entry) (nth 2 arch-entry))
			nil nil
			nil (1- level))
		  hier-list)))
    (when (or (= level 0) (and include-top (= level 1))) (message ""))
    hier-list))