svlint 0.6.1

SystemVerilog linter
Documentation

svlint

SystemVerilog linter

Actions Status codecov

Crates.io svlint

svlint

Installation

Download binary

Download from release page, and extract to the directory in PATH.

snapcraft

You can install from snapcraft

sudo snap install svlint

Cargo

You can install by cargo.

cargo install svlint

Usage

Configuration

First of all, you must put a configuration file .svlint.toml to specify enabled rules. Configuration file is searched to the upper directory until /. So you can put configuration file (.svlint.toml) on the repository root alongside .gitignore. Alternatively, for project-wide rules you can set the environment variable SVLINT_CONFIG to something like /cad/projectFoo/teamBar.svlint.toml.

The example of configuration file is below:

[option]
exclude_paths = ["ip/.*"]
prefix_label = ""

[rules]
non_ansi_module = true
keyword_forbidden_wire_reg = true

The complete example can be generated by svlint --example

[option] section

  • exclude_paths is a list of regular expressions. If a file path is matched with the list, the file is skipped to check.
  • prefix_(inout|input|output) are strings which port identifiers must begin with. Only used when the corresponding rule is enabled. Defaults to "b_", "i_", and "o_" respectively.
  • prefix_label is a string which generate labels must begin with. Applicable to if/else, for, and case generate constructs when the corresponding generate_*_with_label rule is enabled. Defaults to "l_". To check only that a label exists, set this to "".
  • prefix_instance is a string which instances must begin with. Defaults to "u_".
  • prefix_(interface|module|package) are strings which definitions must begin with. An alternative naming convention for interface, module, and package names is uppercase/lowercase first letter. This is similar to Haskell where types begin with uppercase and variables begin with lowercase. These alternative rules are called (lower|upper)camelcase_(interface|module|package).
  • re_(forbidden|required)_* are regular expressions for detailed naming conventions, used only when the corresponding rules are enabled. The defaults for re_required_* are either uppercase, lowercase, or mixed-case starting with lowercase, i.e. just vaguely sensible. The defaults for re_forbidden_* are to forbid all strings, except those starting with "X", i.e. not at all sensible (configuration required).

[rules] section

By default, all rules are disabled. To enable a rule, assign true to its name, e.g. case_default = true.

Configuration update

If svlint is updated, .svlint.toml can be updated to the latest version with svlint --update.

Rules

All rules are documented here. You are welcome to suggest a new rule through Issues or Pull Requests. Some example rulesets, are available here.

If you need to turn off specific rules for a section, then you can use special comments:

/* svlint off keyword_forbidden_always */
always @* foo = bar;                      // <-- This line is special.
/* svlint on keyword_forbidden_always */

Plugin rules

svlint supports plugin rules, an example of which is available here.

Filelist

svlint supports filelist like major EDA tools. The following features are supported.

  • Substitute environment variables
  • Specify include directories by +incdir
  • Define Verilog define by +define
  • Include other filelists by -f

An example is below:

xxx.sv
${XXX_DIR}/yyy.sv
$(XXX_DIR)/zzz.sv
+incdir+$PWD/header/src
+define+SYNTHESIS
-f other.f

Command Line Interface

svlint 0.6.0

USAGE:
    svlint [OPTIONS] [--] [FILES]...

ARGS:
    <FILES>...    Source file

OPTIONS:
    -1                           Print results by single line
    -c, --config <CONFIG>        TOML configuration file [default: .svlint.toml]
    -d, --define <DEFINES>       Define
        --dump-filelist          Print data from filelists
        --dump-syntaxtree        Print syntax trees
    -E                           Print preprocessor output instead of performing checks
        --example                Print TOML configuration example
    -f, --filelist <FILELIST>    File list
        --github-actions         Print message for GitHub Actions
    -h, --help                   Print help information
    -i, --include <INCLUDES>     Include directory path
        --ignore-include         Ignore any include
    -p, --plugin <PLUGINS>       Plugin file
    -s, --silent                 Suppress messages
        --update                 Update configuration
    -v, --verbose                Print verbose messages
    -V, --version                Print version information