Skip to content

Linting

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

Requirements

Any of the following linters:

After installing, make sure that it is available on the $PATH. E.g for verilator:

$ which verilator
/usr/bin/verilator

Configuration

The simplest way to configure different linters is through M-x customize-group RET verilog-ext-flycheck.

You can add extra directories and files to search for additional modules/classes through some of these variables. For example, to add the UVM sources for slang:

(setq verilog-ext-flycheck-slang-include-path `(,(file-name-concat (getenv "UVM_HOME") "src")))
(setq verilog-ext-flycheck-slang-file-list `(,(file-name-concat (getenv "UVM_HOME") "src/uvm_pkg.sv")))

Some linters will also look for modules/classes in the list of current open Verilog files and directories if set. To enable this functionality:

(setq verilog-ext-flycheck-use-open-buffers t)

Other linters, such as verible, will only parse current file without trying to find instance module definitions in other files. verible offers the option of configuring rules through customization of variable verilog-ext-flycheck-verible-rules, according to its syntax. For example, the following snippet disables the lint checks for rule line-length and enables checks for parameter-type-name-style:

(setq verilog-ext-flycheck-verible-rules '("-line-length"
                                           "+parameter-type-name-style"))

Sometimes there might be some compilation order issues or missing arguments for some specific cases. This can be overcome by adding a commands.f command file in the project root for linters that support it.

And being the content of commands.f, e.g:

-y ~/my-verilog-project/some-not-found-dir
~/my-verilog-project/src/my_pkg.sv
+define+SYNTHESIS+0

Usage

  • verilog-ext-flycheck-mode is bound by default to C-c C-f.
  • If run with prefix-arg C-u C-c C-f it allows selection of current active linter. This is particularly useful if switching between RTL and Verification code
    • Verilator is quite effective for RTL code but does not support SystemVerilog verification constructs
    • Verible can be very useful for one-file linting for Verification files, but might be less efective than Verilator for RTL
Clone this wiki locally