Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: A small function that displays the location of the cursor within a sub-module instance #645

Closed
veripoolbot opened this issue May 19, 2013 · 0 comments
Labels

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Yuval Sapir
Original Redmine Message: 1114 from https://www.veripool.org


See below a small function that when invoked, if the cursor is inside a sub-module instance, it displays the following information in the minibuffer:

  • submodule name
  • instance name
  • the position of the cursor – whether it is under the “Outputs/Inputs/Inouts/Interfaces/Interfacedâ€� comment, if such a comment exists in the instance.

I find this function useful when searching for a signal, and the search result is inside a sub-module instance, and the module and instance name are outside the display (above the first displayed line). I've assigned this function it to the Pause/Break key, so I can easily invoke it in a single keystroke.

As you can see below, the implementation of this function was made possible by some of the excellent Verilog-mode functions.

(defun verilog-display-module-and-inst-name ()
  (interactive) 
  (condition-case error 
     (progn
      (save-excursion
        (beginning-of-line)
        (setq submodule_name (verilog-read-inst-module))  ;; get the name of the submodule
        (setq instance_name (verilog-read-inst-name)))    ;; get the name of the instance

      (save-excursion
        (beginning-of-line)
        (verilog-read-inst-backward-name)
        (setq inst_start_point (match-beginning 0)))  ;; get the start point of the instance

      (save-excursion                                 ;; now get the I/O group that the signal in the cursor position belongs to
        (end-of-line)
        (setq cursor_position "")
        (re-search-backward "\\/\\/\\s-*\\(Outputs\\|Inputs\\|Inouts\\|Interfaces\\|Interfaced\\)")
        (if (looking-at "\\/\\/\\s-*Outputs")
            (setq io_type_comment " \"// Outputs\" "))
        (if (looking-at "\\/\\/\\s-*Inputs")
            (setq io_type_comment " \"// Inputs\" "))
        (if (looking-at "\\/\\/\\s-*Inouts")
            (setq io_type_comment " \"// Inouts\" "))
        (if (looking-at "\\/\\/\\s-*Interfaces")
            (setq io_type_comment " \"// Interfaces\" "))
        (if (looking-at "\\/\\/\\s-*Interfaced")
            (setq io_type_comment " \"// Interfaced\" "))

        (if (< (match-beginning 0) inst_start_point)            ;; Check location of the comment, validate it only if inside instance.
            (setq cursor_position "")                           ;;    Cursor location details are not displayed if there is no valid comment inside the instance
            (setq cursor_position (concat "  (cursor position is below the" io_type_comment "comment)")))

        (message (concat submodule_name " " instance_name cursor_position))))  ;; print to minibuffer
     (error
      (message "")))
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant