Home

Awesome

MELPA MELPA Stable Build Status Build Status Build Status

vhdl-ext.el - VHDL Extensions for Emacs

This package provides useful extensions on top of vhdl-mode and vhdl-ts-mode.

Requirements

Tree-sitter is optional but recommended and only required if using vhdl-ts-mode for some of the features above.

For more info, see the wiki.

Installation

MELPA

vhdl-ext is available on MELPA.

straight.el

To install it via straight with use-package:

(straight-use-package 'use-package)
(use-package vhdl-ext)

Basic config

The most basic configuration just requires choosing which features you want to load, setup the minor-mode and add it as a hook for vhdl-mode. By default all features are enabled:

;; Can also be set through `M-x RET customize-group RET vhdl-ext':
;; Comment out/remove the ones you do not need
(setq vhdl-ext-feature-list
      '(font-lock
        xref
        capf
        hierarchy
        eglot
        lsp
        lsp-bridge
        lspce
        flycheck
        beautify
        navigation
        template
        compilation
        imenu
        which-func
        hideshow
        time-stamp
        ports))
(require 'vhdl-ext)
(vhdl-ext-mode-setup)
(add-hook 'vhdl-mode-hook #'vhdl-ext-mode)

If installed and loaded via use-package:

(use-package vhdl-ext
  :hook ((vhdl-mode . vhdl-ext-mode))
  :init
  ;; Can also be set through `M-x RET customize-group RET vhdl-ext':
  ;; Comment out/remove the ones you do not need
  (setq vhdl-ext-feature-list
        '(font-lock
          xref
          capf
          hierarchy
          eglot
          lsp
          lsp-bridge
          lspce
          flycheck
          beautify
          navigation
          template
          compilation
          imenu
          which-func
          hideshow
          time-stamp
          ports))
  :config
  (vhdl-ext-mode-setup))

Keybindings

Enabling of vhdl-ext-mode minor-mode creates the following keybindings:

Features

Tree-sitter

Some of the features that vhdl-ext provides are based either on builtin vhdl-mode Emacs lisp parsing or on tree-sitter vhdl-ts-mode:

For information about installation of vhdl-ts-mode check its repo.

Project management

The package provides the variable vhdl-ext-project-alist to select which files belong to a specific project:

(setq vhdl-ext-project-alist
      `(("axi_if_converter" ; Project name
         :root "/home/gonz/Repos/larumbe/axi_if_converter" ; supports remote dirs via Tramp
         :files ("src/my_block.vhd"
                 "src/*.vhd") ; Multiple files can be specified through the glob pattern
         :dirs ("src/tb"
                "-r src/rtl" ; -r to add directories recursively
                "src/syn/*_block"
                "src/**/netlists") ; add all dirs that begin with "src" and end with "netlists"
         :ignore-dirs ("src/ignored_ip")
         :ignore-files ("src/some_ip/ignored_sim_netlist.vhd")
         ;; The ones below are used for GHDL-related features
         :worklib "xil_defaultlib"                     ; Defaults to `work' if not set
         :workdir "library/xil_defaultlib"             ; Output compilation directory for worklib
         :lib-search-path ("/opt/ghdl_Xilinx_lib/")))) ; Extra directories to look for compiled libraries

The different properties for each project entry determine which files will be used for some features of the package, such as completion, xref navigation, hierarchy extraction and compilation.

Syntax highlighting

<img src="https://user-images.githubusercontent.com/51021955/215353070-8a21f758-407d-4455-bdac-bf92310c59e4.gif" width=80%>

For configuration information, see the wiki.

Find definitions and references

vhdl-ext provides a builtin xref backend to navigate definitions and references of current project in vhdl-ext-project-alist.

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/7fde4bc6-0c84-4da0-8e37-6a0e0dac36f6" width=80%>

For configuration information, see the wiki.

Auto-completion

Complete with tags from current VHDL project.

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/4c908a17-df9e-4fb3-8263-e5e302700ac9" width=80%>

For configuration information, see the wiki.

Hierarchy extraction

Hierarchy extraction of entity at current buffer.

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/79018dc4-833a-4ce6-9f2b-3195ba75481d" width=80%>

For configuration information, see the wiki.

Language Server Protocol

Auto-configure various VHDL language servers for lsp-bridge, lsp-mode, eglot and lspce:

For configuration instructions, see the wiki.

Linting

Support via flycheck for the following linters:

For configuration and usage instructions, see the wiki

Beautify blocks and instances

Beautify block and instances at point:

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/cffb0c9d-3a39-4e58-b422-fb275db124a8" width=80%>

Interactive functions:

Batch-mode functions:

Navigation

<img src="https://user-images.githubusercontent.com/51021955/215353135-446b678b-e3be-42f3-8009-5d5bd7c5e5bd.gif" width=80%>

For detailed info see the wiki.

Templates

Snippet selection via hydra.

<img src="https://user-images.githubusercontent.com/51021955/215353124-7e374754-cd91-4924-9b4b-3c6a29cad921.gif" width=80%>

Compilation

Provides functions to perform compilations with syntax highlighting and jump to error:

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/845980ab-c54b-4e89-b53f-056140be87a7" width=80%>

See more info in the wiki.

Imenu

Support detection of instances.

<img src="https://user-images.githubusercontent.com/51021955/215353082-9a187daf-7f76-4c9b-8563-7beba6e1aa6a.gif" width=80%>

Which-func

Enhanced which-func support: show current block/instance at point in the mode-line

Code folding

Improve code folding via hideshow: add support for if/else/elsif blocks.

Time-stamp

Automatic update of header timestamp after file saving.

For configuration see wiki

Port connections

Toggle connections of ports under instance at point:

<img src="https://github.com/gmlarumbe/vhdl-ext/assets/51021955/14536463-a6c4-410f-a890-081f7deb668e" width=70%>

Contributing

Contributions are welcome! Just stick to common Elisp conventions and run the ERT suite after testing your changes and before submitting a new PR.

For new functionality add new ERT tests if possible.

Consider sponsoring to help maintaining the project and for the development of new features. Thank you!

Setup

To run the whole ERT test suite change directory to the vhdl-ext root and make sure test-hdl Git submodule has been loaded:

git submodule update --init

Targets

Then run the default target:

$ make

To run a subset of tests (e.g. navigation):

$ make TESTS=navigation

To regenerate all the expected outputs for the tests:

$ make gen

To regenerate the expected outputs for a group of tests (e.g. navigation):

$ make gen TESTS=navigation

Other packages