Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

Fromco is a command line tool for analysing SystemVerilog Hardware Description Language (HDL). Basically, it performs parsing and name resolution of given source files and emits diagnostics. Additionaly, some extra checks like sizecheck, style, or other checks might be enabled by user.

In that point, it is easier to setup fromco on existing project and show it’s power on real code. Let’s focus on setup.

Project setup

There are two main sections. In case you are not interested in IDE setup, click here.

Language Server Setup

fromco language server runs via --lsp flag. It allows any compatible editor to interact with tool via LSP protocol. It enriches text editor with IDE functionality like gotos (go to definition, reference, etc), hovers, code actions and so on.

Create a configuration file .fromco.cfg at project root directory. With such content:

{
    "top_module"     	  : "top",
    "file_list"      	  : "filelist.f",
    "exclude_globs"  	  : ["glob1", "glob2", "..."]
}

It might be obtained by fromco --lsp-init command. For example, in root of your HDL project:

fromco-exe --lsp-init | tee .fromco.cfg

Then, ajust fields like top_module and file_list according to you project. The most important part is filelist; it gives necessary context such as file order and files to analyze. Some files/directiries might be excluded via exclude_globs setting. For example, it might be netlists, some vendor libraries, tech cells, which usually are not interesting for front-end HDL design.

If you have dependencies e.g. UVM, just create a separate filelist for UVM and add it to root file list.

For example uvm_1_2.f:

+incdir+/path_to_uvm/UVM/1.2/
/path_to_uvm/UVM/1.2/uvm_pkg.sv

If your filelist has dependency from environment variable, you can add it to IDE env variables or you can define it via in .fromco_env file. They will be visible only for LSP and substituted into described filelists. So, fromco-lsp is just a simple wrapper:

#!/bin/bash
FROMCO_ROOT="$(pwd)"
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
if [ -f "$FROMCO_ROOT/.fromco_env" ]; then
	export $(grep -v '^#' "$FROMCO_ROOT/.fromco_env" | xargs)
fi
"$SCRIPT_DIR/fromco-exe" --lsp

It is also possible to use fromco-lsp without filelist. In that case, preprocessor dependencies will not be resolved across files.

Files, opened and not included in filelist are processed by fromco in preprocessor context after last file in filelist. And they do not share preprocessor context between each other.

IDE setup

In that point project config is ready. This is a time to connect fromco to your editor. The default distribution contains pre-defined configs for number of a common text editors. Feel free to modify and reuse it.

Visual Studio Code

The default distribution contains an extension for vscode (see fromco*.vsix). It provides key LSP protocol functionality (see LSP features), additional functionality (e.g. goto drivers, preprocessor highlights), Schematic Viewer, and support for Vaporview waveform viewer.

Extension can be installed via Extensions -> Install from VSIX. It requires a proper path to fromco-lsp executable, which can be provided via vscode settings.

Once it installed and fromco-lsp path is properly set, fromco-lsp will start analyzing files listed in file_list. Once it ready, you will see hovers on variables, semantic hightlight, and diagnostics.

In case you want to explore more VSCode functionality, please follow that section.

Nvim

It contains a predefined config for lazyVim (see folder fromco.nvim), which allows to use some specific functionality, e.g. additional commands for waveform manipulation, preprocessor’s fadings, additional key bindings.

Config file fromco.lua can be installed manually or copied with install.sh. It contains some settings for a fromco.nvim.

There are only required to specify: dir and cmd.

return {
  -- Provide a path to fromco.nvim
  dir = "/path-to/fromco.nvim",
  dependencies = { "neovim/nvim-lspconfig" },
  ft = { "verilog", "systemverilog" },
  opts = {
    -- Provide a path to fromco-lsp if it is not copied to PATH locations
    cmd = { "fromco-lsp" },
    lsp_log_level = "OFF",
    -- Change here for faster feedback
    defer_ms = 200,
  },
}

In case you want to explore more NVim functionality, please follow that section.

Sublime Text

There is no Sublime Text extension for fromco yet. But core IDE functionaliy is supported via LSP protocol.

Install LSP package, go to Package Settings -> LSP -> Server Configurations, and add the entry below:

{
  "fromco-lsp" : {
    "enabled"  : true,
    "command"  : ["/home/user/.local/bin/fromco-lsp"], // Full path to fromco-lsp execulable
    "selector" : "source.systemverilog | source.verilog",
    "semantic_highlighting" : true
   }
}

In case you have older Sublime Text version, and have no Server Configurations option in LSP settings: Go to Package Settings -> LSP -> Settings and paste this configuration:

{
  "clients": {
    "fromco-lsp": {
      "enabled": true,
      "command": ["/home/user/.local/bin/fromco-lsp"], // Full path to fromco-lsp execulable
      "selector": "source.systemverilog, source.verilog"
    }
  }
}

In that point LSP activates on verilog or systemverilog language. You still require to install some package which adds systemverilog/verilog syntax. Just install any you prefer.

Other editors

Any editor which supports LSP out of the box, also able to run fromco in similar manner as Sublime Text.

There is a feature list, which is currently supported by editors.