Compiler checks (slang)
The plugin’s own checks run while you type, but they look at one file and its names; they do not compile the design.
Some mistakes only show up when the whole design is compiled together: a time scale set in one file and not in the
others, a port connected with the wrong width through a parameter, a top module that does not exist. Simulators report
them at the start of a run, which is late. slang is an open-source SystemVerilog compiler. When it is installed,
the plugin compiles your design with it each time you save a file and shows its errors and warnings in the editor,
marked slang:, next to the plugin’s own. The status bar at the bottom of the IDE says how the last compile went.
slang is optional: without it, everything else in the plugin works as before.
Install slang
Section titled “Install slang”Open Settings (⌘, on macOS / Ctrl+Alt+S on Windows/Linux), go to Languages & Frameworks | SystemVerilog | slang and click Download slang and slang-server (slang-server is used by the Design hierarchy window; this page needs only slang). The plugin downloads the versions it is tested with (slang 12.0.0, slang-server 0.3.0) from the SystemVerilog Studio download mirror or the official GitHub releases, checks each file against the checksum built into the plugin, and puts the programs in the IDE’s own folders. The first time a project with a compile file opens without slang, a notification slang is not installed offers the same download. When the download has finished, choose Code | slang | Run slang (or save a file) to compile; you do not need to reopen the project. If the download fails (no network, a proxy), download slang 12.0 yourself from its GitHub releases and set slang to its path.
slang (github.com/MikePopoloski/slang) and slang-server (github.com/hudson-trading/slang-server) are open-source projects under the MIT licence (with parts under the Boost Software License); the plugin downloads their official releases unchanged, and their licence files are in the archives.
Already have slang 12.0 or newer? Leave the download and set slang to its path on the same page; an empty path
means the downloaded copy, then the one on your PATH. There is no official slang build for Linux on ARM and for Intel
Macs: there, build slang yourself and set its path.
Try it
Section titled “Try it”The steps use the sample project: unzip it, open the folder with File | Open…, and wait until the progress bar at the bottom right of the IDE (indexing) has finished. slang must be installed (see above). Nothing in the sample project is edited; step 3 changes a setting, and says how to change it back.
-
See what slang reports. Look at the status bar at the bottom of the IDE window, on the right: it shows
slang: compiling…for a moment, thenslang: 2 errors. If it showsslangalone orslang: unavailableright after you installed slang, choose Code | slang | Run slang. slang compiled the files of the compile filesim.f. Hover the mouse over the text to see which slang version compiled the design and how long it took. -
Read it in the editor. Open
rtl/counter.sv. On the first line,module counter #(parameter int MAX = 10) (, the namecounteris underlined in red. Hover the mouse over it:slang: design element does not have a time scale defined but others in the design do [MissingTimeScale]rtl/top.svstarts with`timescale 1ns/1ps, butrtl/counter_pkg.svandrtl/counter.sv, compiled before it, have no time scale: a`timescaleapplies to the files compiled after it. Simulators such as VCS refuse such a design too. In your own code you would put a`timescalein each file (or in a header every file includes); step 3 shows the command-line way instead. The name in brackets is slang’s code for the problem;rtl/counter_pkg.svhas the same error oncounter_pkg. -
Give slang an option. In Settings | Languages & Frameworks | SystemVerilog | slang, under This project, type
--timescale 1ns/1psin Extra flags and click OK. This gives every file without its own time scale one, as a simulator option would. slang compiles again: the status bar shows only the slang version, such asslang 12.0.0, which means no problems, and the underline inrtl/counter.svis gone. Now clear Extra flags and click OK again: the status bar showsslang: 2 errorsagain (step 4 expects them). -
Run it in a terminal. Choose Code | slang | Copy slang Command Line. The clipboard now holds the command the plugin runs, written for a macOS or Linux shell:
cdto the project folder, then the full path of the slang program,--single-unit --libraries-inherit-macros(all files as one unit, the One compilation unit setting), the include directories, the three files ofsim.f, and anything in Extra flags. Paste it into a terminal to see slang’s own report, with the same two errors. (On Windows, which is untested, use Git Bash.)
If the status bar says something else, see If it doesn’t work.
How it works
Section titled “How it works”When slang runs. When the project opens, when you click OK or Apply in the slang settings, and about a
second after you save a .sv, .svh, .v, .vh or .f
file of the project (or any file the last compile read, such as a library file outside the project). Code | slang |
Run slang compiles now, even if nothing changed. A compile runs in the background; while it runs the status bar
says slang: compiling…. When nothing slang read has changed since the last compile, the last result is reused.
What slang compiles. The compile file chosen in Settings | Languages & Frameworks | SystemVerilog (the
project’s only .f file by default), as the plugin reads it: its files, +incdir+, +define+, -y and -v
libraries, the top module (-top) and time scale options, plus the defines in the Extra defines field of that page. Options only another
simulator knows are left out. A library or include directory that does not exist is left out too (simulators skip
it; slang would stop). All files are compiled as one unit, so a macro defined in one file is seen in the files after
it, as most simulators do it.
What you see. slang’s errors are underlined in red and its warnings in yellow, in the files it compiled. The
message starts with slang: and ends with slang’s code in brackets; a warning’s tooltip links to slang’s description
of it. A file with unsaved changes shows no slang problems until it is saved (the IDE also saves when you switch to
another application; ⌘S / Ctrl+S saves at once): slang read the file on disk, so its line
numbers may no longer match. Neither does a file saved after the compile started, until slang compiles again.
When one of the plugin’s own checks reports the same kind of problem (an undeclared name, an unconnected input), slang’s report of it is not shown twice: the plugin’s own stays, with its quick fixes. If that check is switched off, or the file uses names the plugin cannot find (a package that is not in the project), slang’s report is shown.
| The status bar says | Meaning |
|---|---|
slang 12.0.0 |
The last compile found no problems |
slang: 2 errors, 1 warning |
The last compile found these; they are underlined in the files |
slang: compiling… |
slang is compiling now |
slang |
slang has not compiled this project yet; choose Code | slang | Run slang |
slang: not compiled |
slang could not compile the design (the project has no compile file, or slang stopped); hover for why |
slang: unavailable |
slang is not installed, or switched off; hover for why |
An error about the design as a whole, such as a top module that does not exist, is not drawn in a file: a notification slang did not compile the design says it once. A project without a compile file gets no notification: slang stays silent until a compile file is chosen, then it runs by itself.
Settings
Section titled “Settings”Settings | Languages & Frameworks | SystemVerilog | slang:
| Setting | Default | What it does |
|---|---|---|
| Use slang (this machine) | on | Off: slang is not used in any project |
| slang, slang-server (this machine) | empty | The programs’ paths; empty: the downloaded copy, then PATH |
| Compile this project with slang | on | Off: slang does not compile this project |
| Extra flags | empty | Options added to every compile, as on a command line (--compat vcs, -Wno-width-trunc, --timescale 1ns/1ps) |
| One compilation unit | on | Off: each file is compiled on its own (macros of one file are not seen in the next) |
| Timeout (seconds) | 120 | A compile that takes longer is stopped |
If it doesn’t work
Section titled “If it doesn’t work”| You see | Likely cause | What to do |
|---|---|---|
| No slang text in the status bar | The status-bar item is hidden, or the project has no compile file yet | Right-click the status bar and turn on slang; choose a compile file in Settings | Languages & Frameworks | SystemVerilog |
| No Code | slang menu | The plugin is disabled | See Installation |
| Nothing changed after installing slang | slang has not run since it was installed | Code | slang | Run slang |
slang: unavailable |
slang is not installed, or Use slang is off | Hover the text for the reason; install slang |
slang: not compiled |
The project has no compile file, or slang stopped on the compile file (an option it does not know) | Hover the text; choose a compile file in Settings | Languages & Frameworks | SystemVerilog, or fix Extra flags |
| A file shows no slang problems | It has unsaved changes, or it is not in the compile file | Save it (⌘S / Ctrl+S); add it to the .f file |
The same problem appears once, without slang: |
The plugin’s own check reports it, and slang’s copy is not shown | That is expected; see How it works |
See also Known limitations: slang. Windows is untested.
Related
Section titled “Related”- Design hierarchy: the elaborated design, from slang-server.
- Coding agents:
sv_checkadds slang’s results for agents. - Running simulations: the compile file slang reads is the one simulators use.