Skip to main content

vsg-rs

A fast Rust-native VHDL formatter and style checker with the command line, rules and configuration of VSG.

vsg-rs is an independent Rust implementation of a VHDL formatter and style checker that aims for compatibility with the rules and configuration of the VHDL Style Guide (VSG). It is not affiliated with, endorsed by, or maintained by the VHDL Style Guide project or its maintainers.

vsg-rs was inspired by the VHDL Style Guide (VSG) project by Jeremiah Leary and contributors. vsg-rs contains no VSG code; VSG is used only as a behavioural reference.

Status: beta. vsg-rs is tested against more than 11,000 real-world files. 192 VSG rules are implemented as rules with fixes (structure, identifier case and consistency, naming, comments, length_001). The other 779 rules are layout rules covered by the formatter: whitespace, indentation (including indent.tokens), blank lines, alignment, keyword case and line structure. Expect layout changes before 1.0.

Why

  • Drop-in for VSG. Same arguments, same configuration files, same report formats and exit codes. Existing scripts and CI jobs keep working.
  • One phase. All violations are reported at once, and --fix fixes everything in one run: no repeated --fix runs, no rule-order dependencies.
  • A real formatter. Source is parsed once into a lossless syntax tree and printed in one canonical layout, like rustfmt or Black. Running --fix twice changes nothing.
  • Long lines are folded, not just reported. Calls, maps, aggregates, expressions, conditions, declarations and signatures fold at structural boundaries (line folding).
  • Safe to run on save. Formatted output is re-parsed and must contain exactly the same tokens and comments; fixed output must parse. Files with syntax errors are never changed. Fixes that VSG does not apply by default, or that could break code, need --unsafe_fixes.
  • Fast. A typical file takes a few milliseconds; real-world VHDL is checked at about 3.4 MB/s on one core, and files are processed in parallel worker processes (performance).

Installation

pip install vsg-rs            # Linux, Windows and macOS wheels, Python 3.10+ (or: uv tool install vsg-rs)
cargo install --path .        # from source (Rust 1.95 or newer)

Standalone binaries for Linux (static, x86_64 and aarch64), Windows (x64 and arm64) and macOS (arm64 and x86_64) are attached to each GitHub release, with a SHA256SUMS file.

Usage

vsg-rs takes VSG's arguments:

vsg-rs -f src/fifo.vhd src/fifo_pkg.vhd      # report violations
vsg-rs src/*.vhd                             # file names can also be given without -f
vsg-rs -f src/*.vhd --fix                    # fix and format the files in place
vsg-rs -f src/*.vhd --fix -b                 # ... keeping a .bak copy of each changed file
vsg-rs -f src/*.vhd -c vsg.yaml              # with a VSG configuration file
vsg-rs -f src/*.vhd -of summary -js report.json -j junit.xml --quality_report gl.json
vsg-rs --stdin < src/fifo.vhd                # read from stdin
vsg-rs -rc entity_015                        # the configuration of one rule
vsg-rs -oc effective.json                    # the whole effective configuration
vsg-rs --style indent_only -f src/*.vhd --fix  # only re-indent
vsg-rs --recursive src                       # every .vhd/.vhdl file below src

As in VSG, files can also be listed in the configuration (file_list), and directories are not searched unless --recursive is given. The exit code is 0 when no error-severity violations were found and 1 otherwise.

What is reported

  • Rule violations, with VSG's rule ids and solution texts, in VSG's console layout (-of vsg, the default), as -of syntastic lines or as an -of summary.
  • Layout violations: every place where --fix would change the layout (indentation, spacing, line breaks, blank lines, trailing whitespace, keyword case, comment columns), under the VSG rule that reports it. vsg-rs decides the whole layout at once; the rule for each kind of change was learned by comparing with VSG on real code. Changes without a known VSG rule are reported as format.

When several files are checked together, uses of names declared in another file's package, or of another file's entity ports and generics, are checked for consistent capitalization too.

Fixes

--fix applies the fixes VSG applies by default and then formats the file. Rules that VSG does not fix by default (for example adding a missing port mode, port_023, or removing a signal's default value, signal_007) are left alone unless their configuration sets fixable: true or --unsafe_fixes is given. --fix_only FILE limits fixing to the listed rules and lines, as in VSG.

Additions to VSG's command line

Option Meaning
--unsafe_fixes with --fix, also apply fixes VSG does not apply by default; they may change behaviour or remove information, so review the result
--diff with --fix, print a unified diff instead of changing files
--stdin_filename PATH name of the --stdin input, used to find the configuration and in reports
--range START:END with --stdin --fix, change only these lines (1-based)
--sarif FILE write a SARIF 2.1.0 report (GitHub code scanning)
--list_rules list every VSG rule and how vsg-rs handles it
--recursive check the .vhd / .vhdl files in directories given as inputs, and in their subdirectories

With --stdin --fix, the fixed source is written to stdout and the report to stderr (VSG 3.35 cannot fix stdin). -fp and -ap are accepted and have no effect, --force_fix has no effect (files with syntax errors are never changed), and local rules (-lr, VSG's Python rule plugins) are run by an installed VSG (see below). See compatibility for the details.

Configuration

Configuration files use VSG's format (YAML or JSON) and are passed with -c; later files override earlier ones. Without -c, vsg-rs uses the nearest vsg-rs.yaml / .vsg-rs.yaml (or .json) next to the first input or in a parent directory, which VSG itself ignores.

rule:
  global:
    indent_style: spaces
    indent_size: 2
  group:
    case::name:
      case: lower
  length_001:
    length: 100
  process_016:
    disable: true
  port_023:
    fixable: true          # also add missing port modes with --fix
indent:
  tokens:
    case_statement_alternative:
      when_keyword: {after: current, token: current}
file_rules:
  legacy/**/*.vhd:
    rule:
      length_001:
        disable: true

Local rules (-lr DIR or local_rules: DIR) are VSG Python plugins, so vsg-rs runs them with an installed VSG (vsg on the path, or the command in VSG_RS_VSG, for example uvx --from vsg==3.35.0 vsg) with all built-in rules disabled, and merges their findings; with --fix, their fixes are applied first.

Blank-line, alignment, keyword-case and indentation rules configure the formatter (formatting). Formatting can be switched off for a region with -- vsg-rs: fmt off / -- vsg-rs: fmt on; VSG's -- vsg_off [rule ...] / -- vsg_on comments suppress rules (and, without rule names, formatting).

Editor integration

Configure your editor to pipe the buffer through vsg-rs --stdin --fix --stdin_filename <path> (add --range START:END to format selected lines). With exit code 0 the buffer is replaced with stdout; otherwise stdout is empty, stderr explains why, and the buffer should be left unchanged. See editor integration for VS Code, Neovim, Helix and Emacs.

GitHub Action

vsg-rs is also a GitHub Action. Add a workflow such as .github/workflows/vhdl-style.yml:

name: VHDL style
on:
  push:
    branches: [main]
  pull_request:

jobs:
  vsg:
    runs-on: ubuntu-latest
    permissions:
      contents: write          # only to resolve suggestions that no longer apply (else: read)
      pull-requests: write     # suggestions and the summary comment
    steps:
      - uses: actions/checkout@v5
      - uses: ru551n/vsg-rs@v0.9.6
        with:
          args: -c vsg.yaml --recursive src   # any vsg-rs arguments

The action downloads the vsg-rs release of its own tag (checked against SHA256SUMS) and runs vsg-rs with args. On a pull request:

  • Suggested changes: what --fix would change on the pull request's lines is posted as suggestions in one review, applied with one click. Suggestions that no longer apply are resolved on the next run.
  • One summary comment: findings per rule and the command that fixes them, updated in place on every push.
  • Annotations on the lines the pull request adds or changes.
  • Code scanning (optional, sarif-upload: true with security-events: write): rule violations also become tracked alerts under Security → Code scanning, and GitHub's code scanning bot comments on the ones a pull request introduces.
  • Result: the step fails when vsg-rs reports error-severity violations (fail-on-violations: false only reports them).

Other inputs: version (a release tag or latest), working-directory, annotations (changed, true or false), layout (suggestions, or alerts for one code scanning alert per block to reformat), pr-comment, and token. Outputs: exit-code, sarif-file and version. Linux, Windows and macOS runners are supported. To fix the reported violations locally, run the same arguments with --fix. See GitHub Action for details, and ru551n/vhdl-ai-test#9 for an example pull request.

Python

The wheels install the vsg-rs executable. python -m vsg_rs ... runs it too, and vsg_rs.find_vsg_rs_bin() returns its path.

Documentation

Development

cargo fmt --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test
cargo run --release --example corpus -- --width 80 path/to/vhdl   # stability and overflow report
FIX=1 cargo run --release --example corpus -- path/to/vhdl         # the same for --fix (FIX=unsafe: --unsafe_fixes; CONFIG=file)
cargo run --release --example bench                                # timing on generated inputs
python scripts/compare_vsg.py FILE...                              # findings per rule, vsg-rs vs VSG 3.35
python scripts/learn_layout_rules.py FILE...                       # relearn src/layout_rules.json
python scripts/gen_spacing_rules.py VSG_CHECKOUT/docs              # regenerate src/spacing_rules.json
UPDATE_EXPECT=1 cargo test --test golden                           # re-bless golden files (review the diff)

The library (vsg_rs) can also be used directly: Parsed::new, format_parsed, fix_with, rules::check_with and the range variants format_range / fix_range.

License

vsg-rs is licensed under either of Apache License, Version 2.0 or MIT license, at your option. Third-party dependencies are listed in THIRD_PARTY_LICENSES.md. The VHDL parser, vhdl_syntax from the rust_hdl project, is MPL-2.0 and is used as an unmodified dependency.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in vsg-rs, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vsg_rs-0.9.6.tar.gz (269.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vsg_rs-0.9.6-py3-none-win_arm64.whl (1.8 MB view details)

Uploaded Python 3Windows ARM64

vsg_rs-0.9.6-py3-none-win_amd64.whl (2.0 MB view details)

Uploaded Python 3Windows x86-64

vsg_rs-0.9.6-py3-none-musllinux_1_2_x86_64.whl (2.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

vsg_rs-0.9.6-py3-none-musllinux_1_2_aarch64.whl (1.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

vsg_rs-0.9.6-py3-none-manylinux_2_28_x86_64.whl (2.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

vsg_rs-0.9.6-py3-none-manylinux_2_28_aarch64.whl (1.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

vsg_rs-0.9.6-py3-none-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

vsg_rs-0.9.6-py3-none-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file vsg_rs-0.9.6.tar.gz.

File metadata

  • Download URL: vsg_rs-0.9.6.tar.gz
  • Upload date:
  • Size: 269.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.9.6.tar.gz
Algorithm Hash digest
SHA256 614409e193e3407e4015251e0a0b371feb52c43c6a7f286454b551facf4d7f9c
MD5 8ab7c2e3d63f1f77fdc0135b882813f6
BLAKE2b-256 187412ca2ed776aacffe10e648a6432c155555a6a112fee95d216a9d54b6abdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6.tar.gz:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-win_arm64.whl.

File metadata

  • Download URL: vsg_rs-0.9.6-py3-none-win_arm64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.9.6-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 d2119b6d5591735a99125a80b3d4d32830ff5758c9ebab862a720510739057ed
MD5 e907f8d0baad7824c5c3c8eb5ae4feaa
BLAKE2b-256 05512e52f173f318334a0722261a3428fd6849781a36c1fd1a1086c88551de7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-win_arm64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-win_amd64.whl.

File metadata

  • Download URL: vsg_rs-0.9.6-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for vsg_rs-0.9.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9695cccc6ffe23399f7ba1c76f44c9ea43b454d287d6c34b9a2c547399acd19d
MD5 f1ae062c2722ebd2a1dfeb58ce21b42f
BLAKE2b-256 11c9be8c44937dd5a537a62a637ede633674aae4f0f494e72f3b3c1caed1bf7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-win_amd64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1f407d52e3e7cba84a53288e52a85f345a3145374f33a95a90b939753c0c1ee4
MD5 e000c234fd31b78f2ec92fbe25a4260f
BLAKE2b-256 d1e02bce8223b057859447e2984aaeace31c790448f574187545cf90643cc27d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-musllinux_1_2_x86_64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5d6d0bc1562193396f758f163e62f43d6f3f412d137017d8f303fbe26e04396d
MD5 b93d68b962ffe998007fa73884f93bdb
BLAKE2b-256 c4f45993322342cdf3cee9ed34358a885098b954d1fe92cbce70b65fd3372688

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-musllinux_1_2_aarch64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d5d78a76448b8be612701c366d47bb80e1b9611fa76dc5817793858adfd3a770
MD5 721915d1aa563a1824b411c21406050d
BLAKE2b-256 592caa6a6647d27674cecace00de41e6b39092ea5d7fc7a247cc33c4f6383a5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 19561208983f83a42d196c1e61d5fb7418192b1e6062770ec493c40e64b0775d
MD5 4e13c6bf91ed96f15538be280c28c578
BLAKE2b-256 584d543c72dc77047a7571c672762736afa05fda3dd852241f68d8cbe2b9ff59

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cc4335b7bca1b82f6a410170bd3a9529dc7d8bb847c1498206ef31aca85c2c68
MD5 f986ee220f3ade8d395a44582414ccb9
BLAKE2b-256 197d4936f7d1d329632ec86d9cd080599bf4dd7f26c3177f728db6b1a6db9ad6

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vsg_rs-0.9.6-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for vsg_rs-0.9.6-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d77e0ae41c06cd5a79c43a4d75918feb57e1fc4639c6f657cf3613cd0e9fae67
MD5 14e6365e9ef7a990e9932fe97af79417
BLAKE2b-256 808498366b9d7151d5843a32482ca9bb257f5f9f972fd3abc36c1f6cd9042277

See more details on using hashes here.

Provenance

The following attestation bundles were made for vsg_rs-0.9.6-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on ru551n/vsg-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.9.6 This release

9 files

0.9.5

9 files

0.9.4

9 files

0.9.3

9 files

0.9.2

9 files

0.9.1

9 files

0.9.0

9 files

0.8.0

9 files

0.7.0

9 files

0.6.0

7 files

0.5.0

7 files

0.4.0

7 files

0.3.0

7 files

0.2.0

7 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page