Function: vhdl-update-sensitivity-list

vhdl-update-sensitivity-list is a byte-compiled function defined in vhdl-mode.el.gz.

Signature

(vhdl-update-sensitivity-list)

Documentation

Update sensitivity list.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/vhdl-mode.el.gz
(defun vhdl-update-sensitivity-list ()
  "Update sensitivity list."
    (let ((proc-beg (point))
	  (proc-end (re-search-forward "^\\s-*end\\s-+process\\>" nil t))
	  (proc-mid (vhdl-re-search-backward
		     "\\(\\(\\<begin\\>\\)\\|^\\s-*process\\>\\)" nil t))
	  seq-region-list)
      (cond
       ;; error if 'begin' keyword missing
       ((not (match-string 2))
	(error "ERROR:  No 'begin' keyword found"))
       ;; search for wait statement (no sensitivity list allowed)
       ((progn (goto-char proc-mid)
	       (vhdl-re-search-forward "\\<wait\\>" proc-end t))
	(error "ERROR:  Process with wait statement, sensitivity list not generated"))
       ;; combinational process (update sensitivity list)
       (t
	(let
	    ;; scan for visible signals
	    ((visible-list (vhdl-get-visible-signals))
	     name field read-list sens-list signal-list tmp-list
	     sens-beg sens-end beg end margin)
	  ;; scan for signals in old sensitivity list
	  (goto-char proc-beg)
	  (vhdl-re-search-forward "\\<process\\>" proc-mid t)
	  (if (not (looking-at "[ \t\n\r\f]*("))
	      (setq sens-beg (point))
	    (setq sens-beg (vhdl-re-search-forward "\\([ \t\n\r\f]*\\)([ \t\n\r\f]*" nil t))
	    (goto-char (match-end 1))
	    (forward-sexp)
	    (setq sens-end (1- (point)))
	    (goto-char sens-beg)
	    (while (and (vhdl-re-search-forward "\\(\\w+\\)" sens-end t)
			(setq sens-list
			      (cons (downcase (match-string 0)) sens-list))
			(vhdl-re-search-forward "\\s-*,\\s-*" sens-end t))))
	  (setq signal-list (append visible-list sens-list))
	  ;; search for sequential parts
	  (goto-char proc-mid)
	  (while (setq beg (re-search-forward "^\\s-*\\(els\\)?if\\>" proc-end t))
	    (setq end (vhdl-re-search-forward "\\<then\\>" proc-end t))
	    (when (vhdl-re-search-backward "\\('event\\|\\<\\(falling\\|rising\\)_edge\\)\\>" beg t)
	      (goto-char end)
	      (backward-word-strictly 1)
	      (vhdl-forward-sexp)
	      (push (cons end (point)) seq-region-list)
	      (beginning-of-line)))
	  ;; scan for signals read in process
	  (dolist (scan-fun vhdl--signal-regions-functions)
	    (goto-char proc-mid)
	    (while (setq end (funcall scan-fun proc-end))
	      (unless (or (vhdl-in-literal)
			  (and seq-region-list
			       (let ((tmp-list seq-region-list))
				 (while (and tmp-list
					     (< (point) (caar tmp-list)))
				   (setq tmp-list (cdr tmp-list)))
				 (and tmp-list (< (point) (cdar tmp-list))))))
		(while (vhdl-re-search-forward "[^'\".]\\<\\([a-zA-Z]\\w*\\)\\(\\(\\.\\w+\\|[ \t\n\r\f]*([^)]*)\\)*\\)[ \t\n\r\f]*\\('\\(\\w+\\)\\|\\(=>\\)\\)?" end t)
		  (setq name (match-string 1))
		  ;; get array index range
		  (when vhdl-array-index-record-field-in-sensitivity-list
		    (setq field (match-string 2))
		    ;; not use if it includes a variable name
		    (save-match-data
		      (setq tmp-list visible-list)
		      (while (and field tmp-list)
			(when (string-match
			       (concat "\\<" (car tmp-list) "\\>") field)
			  (setq field nil))
			(setq tmp-list (cdr tmp-list)))))
		  (when (and (not (match-string 6)) ; not when formal parameter
			     (not (and (match-string 5) ; not event attribute
				       (not (member (downcase (match-string 5))
						    '("event" "last_event" "transaction")))))
			     (member (downcase name) signal-list))
		    ;; not add if name or name+field already exists
		    (unless
			(or (member-ignore-case name read-list)
			    (member-ignore-case (concat name field) read-list))
		      (push (concat name field) read-list))
		    (setq tmp-list read-list)
		    ;; remove existing name+field if name is added
		    (save-match-data
		      (while tmp-list
			(when (string-match (concat "^" name field "[(.]")
					    (car tmp-list))
			  (setq read-list (delete (car tmp-list) read-list)))
			(setq tmp-list (cdr tmp-list)))))
		  (goto-char (match-end 1))))))
	  ;; update sensitivity list
	  (goto-char sens-beg)
	  (if sens-end
	      (delete-region sens-beg sens-end)
	    (when read-list
	      (insert " ()") (backward-char)))
	  (setq read-list (sort read-list #'string<))
	  (when read-list
	    (setq margin (current-column))
	    (insert (car read-list))
	    (setq read-list (cdr read-list))
	    (while read-list
	      (insert ",")
	      (if (<= (+ (current-column) (length (car read-list)) 2)
		      end-comment-column)
		  (insert " ")
		(insert "\n") (indent-to margin))
	      (insert (car read-list))
	      (setq read-list (cdr read-list)))))))))