Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@codingame/svlangserver

imc-trading8MIT0.3.5TypeScript support: included

A language server for systemverilog

sv, systemverilog, verilog, language, server

readme

SVLangserver

A language server for systemverilog that has been tested to work with coc.nvim, VSCode, Sublime Text 3 and emacs

Features

  • Auto completion (no need for ctags or other such mechanisms)
  • Go to symbol in document
  • Go to symbol in workspace folder (indexed modules/interfaces/packages)
  • Go to definition (works for module/interface/package names and for ports too!)
  • Hover over help
  • Signature help
  • Fast indexing
  • Verilator linting on the fly
  • Code snippets for many common blocks
  • Code formatting with verible-verilog-format
  • Elaborate syntax highlighting (for VSCode)

Versions

The code has been tested to work with below tool versions

  • vim 8.2
    • coc.nvim 0.0.80-2cece2600a
  • VSCode 1.52.0
  • Sublime Text 3.2.2
  • emacs 26.1
    • lsp-mode 20210513.1723
  • Verilator 4.008
  • Verible v0.0-1114-ged89c1b

Installation

  • For coc.nvim
    • npm install -g @imc-trading/svlangserver
    • Update .vim/coc-settings.json
  • For VSCode
    • Install the extension from the marketplace.
    • Update the settings
  • For Sublime Text 3
    • Install the systemverilog package in sublime text
    • npm install -g @imc-trading/svlangserver
    • Update the LSP settings (Preferences -> Package Settings -> LSP -> settings) and the sublime-project files
  • For emacs
    • Install lsp-mode
    • npm install -g @imc-trading/svlangserver
    • Update .emacs/init.el

To get the snippets, git clone this repo and copy the snippets directory wherever applicable

For installing from source (not applicable for VSCode)

  • git clone https://github.com/imc-trading/svlangserver.git
  • cd svlangserver && npm install
    • Update the settings with the correct command (e.g. /git/repo/path/svlangserver/bin/main.js)

NOTE: This has been tested with npm version 6.14.11 and node version 14.15.5

Settings

  • systemverilog.includeIndexing: Array, Globs defining files to be indexed
  • systemverilog.libraryIndexing: Array, Globs defining library files to be added to linting. It's useful when module name is not equal to filename.
  • systemverilog.excludeIndexing: Array, Exclude files from indexing based on glob
  • systemverilog.linter: String, Select linter
    • Default: false
  • systemverilog.launchConfiguration: String, Command to run for launching linting
    • Default: verilator --sv --lint-only --Wall
    • If not in path, replace verilator with the appropriate command
  • systemverilog.lintOnUnsaved: Boolean, Lint even unsaved files
    • Default: true
  • systemverilog.defines: Array, Defines for the project. Used by the language server as well as linting
    • Default: empty
  • systemverilog.formatCommand: String, verible-verilog-format command for code formatting
    • Default: verible-verilog-format
    • If not in path, replace verible-verilog-format with the appropriate command
  • systemverilog.disableCompletionProvider: Boolean, Disable auto completion provided by the language server
    • Default: false
  • systemverilog.disableHoverProvider: Boolean, Disable hover over help provided by the language server
    • Default: false
  • systemverilog.disableSignatureHelpProvider: Boolean, Disable signature help provided by the language server
    • Default: false
  • systemverilog.disableLinting: Boolean, Disable linting
    • Default: false
  • Example coc.nvim settings file
      {
          "languageserver": {
              "svlangserver": {
                  "command": "svlangserver",
                  "filetypes": ["systemverilog"],
                  "settings": {
                      "systemverilog.includeIndexing": ["**/*.{sv,svh}"],
                      "systemverilog.excludeIndexing": ["test/**/*.sv*"],
                      "systemverilog.defines" : [],
                      "systemverilog.launchConfiguration": "/tools/verilator -sv -Wall --lint-only",
                      "systemverilog.formatCommand": "/tools/verible-verilog-format"
                  }
              }
          }
      }
    For project specific settings this file should be at <WORKSPACE PATH>/.vim/coc-settings.json
  • Example vscode settings file
      {
          "systemverilog.includeIndexing": ["**/*.{sv,svh}"],
          "systemverilog.excludeIndexing": ["test/**/*.sv*"],
          "systemverilog.defines" : [],
          "systemverilog.launchConfiguration": "/tools/verilator -sv -Wall --lint-only",
          "systemverilog.formatCommand": "/tools/verible-verilog-format"
      }
    For project specific settings this file should be at <WORKSPACE PATH>/.vscode/settings.json
  • Example Sublime Text 3 settings files
    • The global LSP settings file: LSP.sublime-settings
      {
          "clients": {
              "svlangserver": {
                  "enabled": true,
                  "command": ["svlangserver"],
                  "languageId": "systemverilog",
                  "scopes": ["source.systemverilog"],
                  "syntaxes": ["Packages/SystemVerilog/SystemVerilog.sublime-syntax"],
                  "settings": {
                      "systemverilog.disableHoverProvider": true,
                      "systemverilog.launchConfiguration": "/tools/verilator -sv --lint-only -Wall",
                      "systemverilog.formatCommand" : "/tools/verible-verilog-format"
                  }
              }
          }
      }
    • The project specific settings go in <PROJECT>.sublime-project
      {
          "folders":
          [
              {
                  "path": "."
              }
          ],
          "settings": {
              "LSP": {
                  "svlangserver": {
                      "settings": {
                          "systemverilog.includeIndexing": [ "**/*.{sv,svh}", ],
                          "systemverilog.excludeIndexing": ["test/**/*.sv*"],
                          "systemverilog.defines": [],
                      }
                  }
              }
          }
      }
  • Example settings for emacs

    • Below content goes in .emacs or init.el

      (require 'lsp-verilog)
      
      (custom-set-variables
        '(lsp-clients-svlangserver-launchConfiguration "/tools/verilator -sv --lint-only -Wall")
        '(lsp-clients-svlangserver-formatCommand "/tools/verible-verilog-format"))
      
      (add-hook 'verilog-mode-hook #'lsp-deferred)
    • The project specific settings go in .dir-locals.el
      ((verilog-mode (lsp-clients-svlangserver-workspace-additional-dirs . ("/some/lib/path"))
                     (lsp-clients-svlangserver-includeIndexing . ("src/**/*.{sv,svh}"))
                     (lsp-clients-svlangserver-excludeIndexing . ("src/test/**/*.{sv,svh}"))))

Commands

  • systemverilog.build_index: Instructs language server to rerun indexing

Troubleshooting

  • Editor is not able to find language server binary.
    • Make sure the binary is in the system path as exposed to the editor. If the binary is installed in custom directory, expose that path to your editor
  • Not getting any diagnostics
    • Make sure the launchConfiguration setting has been properly set to use verilator from the correct installation path
  • Diagnostics show Cannot find file containing module 'modulename'_
    • Make sure all submodules can be found by includeIndexing
    • If the issue still remains, it may due to different naming of module and file, or a file containing multiple modules. Make sure these files can be found by libraryIndexing.
  • Check settings used by the language server
    • for coc.nvim: Use the command :CocCommand workspace.showOutput and then select svlangserver
    • for vscode: Check the SVLangServer output channel
    • for sublime: Open the command palette in the tools menu and select LSP: Toggle Log Panel
    • for emacs: Check the *lsp-log* buffer

Known Issues

  • Language server doesn't understand most verification specific concepts (e.g. classes).

Future

Rewrite parser to make it much more robust

Acknowledgements

Although most of the code is written from scratch, this VSCode-SystemVerilog extension was what I started with and developed on.

Release Notes

See the changelog for more details

0.3.5

  • Improvements to auto-completion and jump to definition
  • Bug fixes

0.3.4

  • Bug fixes

0.3.3

  • Updated instructions to use published packages

0.3.1

  • Add support for Sublime LSP and Emacs

0.3.0

  • Initial release

changelog

Changelog

All notable changes to this repository are documented below.

[0.3.5] - 2021.10.24

  • Extended keyword and snippets completion
  • Jump to definition improvements
    • Fix jump to definition for packages
    • Support jump to definition for includes
  • Added systemverilog.libraryIndexing property
  • Bug fixes
    • for issue #8
    • for issue #10
    • Typo fix in verilator.ts that caused some editors to hang on exit

[0.3.4] - 2021.05.31

  • Bug fix for issue #1
  • Refectored code to prevent server crashing because of errors
  • Fix verilator linting for systemverilog packages

[0.3.3] - 2021.05.13

  • Updates for publishing to npm
  • Updates for publishing to vscode marketplace
  • Update installation instructions to use published packages

[0.3.1] - 2021.04.25

  • Support for Sublime Text 3
  • Support for Emacs
  • Configurable enabling/disabling of language server features viz. Completion, Hover, SignatureHelp
  • Misc bug fixes

[0.3.0] - 2021.04.22

  • Initial release