Skip to content

Navigation

Gonzalo Larumbe edited this page Dec 19, 2023 · 14 revisions

Context aware dwim navigation (do what I mean)

Depending on the type of file being edited, the following dwim functions perform different actions.

  • C-M-a verilog-ext-nav-beg-of-defun-dwim
  • C-M-e verilog-ext-nav-end-of-defun-dwim
  • C-M-d verilog-ext-nav-down-dwim
  • C-M-u verilog-ext-nav-up-dwim
  • C-M-p verilog-ext-nav-prev-dwim
  • C-M-n verilog-ext-nav-next-dwim

If current file has a module definition it will be detected as an RTL environment. Otherwise, it will be considered a Verification class-based environment.

  • verilog-ext-nav-beg-of-defun-dwim and verilog-ext-nav-end-of-defun-dwim
    • RTL
      • Navigate through 'blocks' (module, interface, program, package, class, function, task, initial, always, generate, property, sequence and `define)
    • Verification
      • Navigate through classes and methods
  • verilog-ext-nav-down-dwim and verilog-ext-nav-up-dwim
    • RTL
      • Navigate through instances
    • Verification:
      • Navigate through classes and methods
  • verilog-ext-nav-prev-dwim and verilog-ext-nav-next-dwim
    • RTL and Verification:
      • Navigate parenthesized and begin-end expressions or move through paragraphs forward/backward

Navigate instances inside a module

The following functions are defined for instance navigation:

  • verilog-ext-find-module-instance-fwd
  • verilog-ext-find-module-instance-bwd

However, these are not bound to any key since they are called by verilog-ext-nav-down-dwim (C-M-d) and verilog-ext-nav-up-dwim (C-M-u) respectively, when current file has a module declaration (e.g. RTL code in most cases).

Jump to definition/references of module at point

If point is inside a module instantiation, it is possible to navigate to its definition or references:

  • C-c M-. verilog-ext-jump-to-module-at-point-def
  • C-c M-? verilog-ext-jump-to-module-at-point-ref

This functionality requires setting up a backend for xref and add it to xref-backend-functions. This can be done in three ways:

  • Configuring builtin xref backend (see link)
  • Configuring LSP (see link)
  • Configuring global and ggtags-mode
    • Requires installation of global, ctags (for definitions) and python/pygments (for references).
      # For Ubuntu/Debian systems
      sudo apt-get install global universal-ctags python3-pygments
    • Find complete installation and configuration information here

Jump to parent module

Running verilog-ext-jump-to-parent-module (C-M-.) will run ag or ripgrep, depending on the value of verilog-ext-jump-to-parent-module-engine, and will try to find instantiations of current file module definition on current project.

To install ag:

  • For Ubuntu/Debian:
sudo apt-get install silversearcher-ag

For ripgrep you need to install a version that supports PCRE2:

  • For Ubuntu/Debian the one available via apt-get on default PPAs might not have PCRE2 enabled. Therefore the command below is recommended:
$ curl -LO https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep_13.0.0_amd64.deb
$ sudo dpkg -i ripgrep_13.0.0_amd64.deb