Lint
Lint runs linters over a design’s RTL, as described in the design’s FuseSoC core file: its lint target of the design’s core names the sources, the waiver files, the top module and each linter’s options, and the linter checks them. Any message it reports fails the design.
There are four linters. A design’s lint config names the ones to run, or leaves it to the project file, and each runs in a job of its own:
| Linter | Program | Checks |
|---|---|---|
verilator | verilator | The elaborated design: widths, unused and undriven signals, latches |
verible | verible-verilog-lint | Style, one file at a time, without preprocessing or elaborating |
slang | slang | The elaborated design against the SystemVerilog standard, and warnings |
ascentlint | ascentlint | The elaborated design against the rules of a policy, such as lowRISC’s. Commercial, from Real Intent |
This page covers the steps the flow runs, its config, and how to check a run. Each step has its own page under Steps. Read Running flows first for how any step runs and what outcomes mean.
doris plan lint top_chip_system # each job's steps as a tree, cached or will run
doris plan -v lint top_chip_system # the steps and exact commands of each job
doris run lint # every design with a lint config, with each of its linters
doris run lint top_chip_system # one design
doris run lint top_chip_system --until flatten
doris report lint # write the report pages again
The steps
Every job has the same three steps:
flowchart LR
filelist --> flatten --> lint
filelist --> lint
| Step | In this flow | Produces |
|---|---|---|
filelist | Asks FuseSoC for the lint target of the design’s core, for the job’s linter | A copy of every source, and a description of the files |
flatten | Makes the linter’s arguments from the target’s files and options | filelist.f, and verible.flags for Verible |
lint | Runs the linter. The lint result | The linter’s logs, and the messages parsed from them |
There is one job per design, context and linter. A design on its own is lint/<design>@<linter>, in scratch/doris/lint/<design>@<linter>/. A design in a top’s context is lint/<top>/<design>@<linter>, in scratch/doris/lint/<top>.<design>@<linter>/: see Contexts. Every step is cached. The jobs of one design share nothing: FuseSoC is asked once per linter, because a core can keep filesets for one tool.
The job passes when every step passes. For the lint result, see what passed means for the lint step: in short, the linter read every source and reported no error and no warning.
What the config files control
The flow lints the core of the design’s design.hjson. A design with no core can’t have a lint config. The flow reads lint.hjson (schema dv/lint/1) next to or below the design file.
| Key | File | Used by | Effect |
|---|---|---|---|
core | design.hjson | filelist | The FuseSoC core to lint |
top | design.hjson | lint | The top module. If unset, the top is the toplevel of the core’s target |
tool.linter | lint.hjson | all | The linters: verilator, verible, slang, ascentlint. A name, or a list of names with a job each. If unset, the project file’s tool.lint.linter |
target | lint.hjson | filelist | The core’s target that describes a lint build. Default lint |
mappings | design.hjson | filelist | FuseSoC --mapping for each: the core to use where a virtual core has several providers |
scope | design.hjson | all | top makes the design a top, which other designs are linted in the context of |
mappings | lint.hjson | filelist | More mappings, for lint only, after the top’s and the design’s |
timeout | lint.hjson | lint | Wall-clock limit for each lint step, such as 30m. No limit if unset |
tags | design.hjson, lint.hjson | Selection | Labels that -i tag=GLOB and -x tag=GLOB select on (see Filters). The design file’s are every job’s, and the lint config’s are added for its lint jobs. They are not part of any cache key |
resources.<step>, resources.<step>@<tool> | lint.hjson | That step | What the step holds while it runs: threads, memory and disk, for every tool or for one. See Resource pools |
tools.verilator.command | lint.hjson | lint | The Verilator to lint with, if it is not verilator |
tools.verilator.lint.args | lint.hjson | lint | Extra Verilator arguments, after the target’s options |
tools.verible.lint.args | lint.hjson | lint | Extra verible-verilog-lint arguments, after the flag file |
tools.slang.lint.args | lint.hjson | lint | Extra slang arguments, after the target’s options |
tools.ascentlint.lint.args | lint.hjson | lint | Extra AscentLint arguments, before the target’s options |
A config for a design whose core has a lint target:
{
schema: dv/lint/1
tool: {
linter: [
verilator
verible
slang
]
}
}
Lint has one role, linter, and tool.linter binds the linters to it. A name by itself binds one:
tool: {
linter: verilator
}
A project whose designs all use the same linters can name them once, as tool.lint.linter in the project file. A lint config then needs only its schema, and one that sets tool.linter has its own list in place of the project’s. A design with no linter from either file is an error when config loads.
A tools.<name> table gives a linter options the core’s target does not, under the linter’s name and then the step’s. It is read only by that linter’s job:
tools: {
slang: {
lint: {
args: [
-Wextra
]
}
}
}
A table for a tool that is not a linter, such as tools.xcelium, is an error. tools.verilator is also where a TestRIG config keeps the simulator’s options, so it accepts build and run tables here too. Lint has no such steps, and ignores them.
Contexts
A design is linted once for each context it has (see Tops and contexts):
| Design | Jobs | FuseSoC mappings |
|---|---|---|
| A top | lint/earlgrey@verilator | The top’s, then its lint.hjson’s |
| A top’s own | lint/earlgrey/pwrmgr@verilator | The top’s, the design’s, its lint.hjson’s |
| Shared, used by two tops | lint/earlgrey/uart@verilator and lint/darjeeling/uart@verilator | Each top’s, the design’s, its lint.hjson’s |
| Shared, used by no top | lint/spare@verilator | The design’s, then its lint.hjson’s |
A block is linted in a top’s context as well as by the top’s own lint job because the two see different things. The top’s job elaborates the block with the parameters the top gives it. The block’s job elaborates it by itself, with its default parameters and the top’s packages.
doris run lint uart # uart in every top that uses it
doris run lint earlgrey/uart # uart in Earl Grey's context only
doris run lint --top earlgrey # Earl Grey, its own designs, and the shared designs it uses
doris run lint pwrmgr # an error if two tops have one: give earlgrey/pwrmgr
The same work is not done twice. Each context is a job of its own, with its own FuseSoC step, because the mappings are part of that step’s command. If two tops resolve a design to the same sources and options, the flatten and lint steps have the same cache key, and the second job takes them from the cache. If they differ, the design really is a different build in each top, and both are linted.
What the core file controls
Everything else comes from the core file, so the same description serves doris and FuseSoC run directly. Arguments a config adds with tools.<linter>.lint.args come after the core file’s on the command line. FuseSoC is asked for the target once per linter, with --tool set, so a fileset can be kept for one linter with a tool_<name> ? condition:
filesets:
files_verilator_waiver:
files:
- lint/top_chip_system.vlt
file_type: vlt
files_veriblelint_waiver:
files:
- lint/top_chip_system.vbl
file_type: veribleLintWaiver
files_ascentlint_waiver:
files:
- lint/top_chip_system.waiver
file_type: waiver
targets:
lint:
filesets:
- tool_verilator ? (files_verilator_waiver)
- tool_veriblelint ? (files_veriblelint_waiver)
- tool_ascentlint ? (files_ascentlint_waiver)
- files_rtl
toplevel: top_chip_system
default_tool: verilator
parameters:
- SYNTHESIS=true
tools:
verilator:
mode: lint-only
verilator_options:
- "-Wall"
veriblelint:
ruleset: default
rules:
- "-line-length"
slang:
slang_options:
- "--single-unit"
- "-Wextra"
| Linter | FuseSoC --tool | Waivers | Options of the target |
|---|---|---|---|
verilator | verilator | Files of type vlt | verilator_options |
verible | veriblelint | Files of type veribleLintWaiver | ruleset, rules, verible_lint_args, and one file of type veribleLintRules |
slang | slang | None. Use slang_options or pragmas | slang_options |
ascentlint | ascentlint | Files of type waiver, Tcl the run script sources | ascentlint_options, and files of type tclSource, such as one that loads the policy |
- Waivers and rules files are files of the target’s filesets, the design’s own and those of every core it depends on. doris has no waiver list of its own. A shared core, such as
lowrisc:lint:common, can bring a style rules file and common Verible waivers to every core that depends on it. - Options come from every core. FuseSoC adds to the options of the design’s own target those of each core it depends on, from that core’s
defaulttarget.lowrisc:lint:commongives AscentLint-wait_licenseand-stop_on_errorthis way, so a design that depends on it needs no AscentLint options of its own. - Which checks run is decided by those options. Without
-Wall, Verilator reports only its default warnings. Without-Wextraor other-Woptions, slang reports its default ones. - slang needs
--single-unitfor most FuseSoC cores. By default slang compiles each file by itself, so a macro defined in one file is unknown in the next. FuseSoC orders the files for one compilation unit, which is what Verilator and the simulators assume. - AscentLint checks only what its policy names. The run script loads none: a file of type
tclSource, such asascentlint-config.tclin OpenTitan’slowrisc:lint:common, sources the policy and sets its limits. Without one, AscentLint checks its default rules. - A mapping names a whole core, version included, such as
lowrisc:prim_generic:all:0.1. Without one, a virtual core such aslowrisc:prim:flopgets whichever provider FuseSoC finds, which may be an FPGA library.
How these become the linter’s command line is on the flatten page.
The result
result.json has messages: each one’s severity (error or warning), rule (such as WIDTHEXPAND, line-length or width-trunc, absent for a message that belongs to no rule), file, line, column and text. errors and warnings count them. tool.linter names the linter, and versions has its version and FuseSoC’s. context names the top a shared design was linted in the context of, and is absent for a design linted on its own. linted is false if the lint step did not complete, and the counts then say nothing.
A message’s file is relative to the job’s directory, such as filelist/work/src/<core>/rtl/<file>.sv. That is the copy FuseSoC made, which is the file the linter read. The path after src/<core>/ is the file’s path below the directory of its core file. AscentLint’s report names a file by its name only, so doris names the copied source with that name. If two sources have the name, or none does, file is the name as the report gave it.
Checking a run by hand
Work through these in a job’s directory after a run. The linter’s logs are outputs of the lint step, so they are there after any run. Every other log is deleted when its step passes (see Working directories).
-
Did the lint step run, with the code you expect? In
result.json, checkrevision, and each step’scached. A cached lint step’s log is from an earlier run with the same sources and options.jq -r '.revision, (.steps[] | "\(.name)\t\(.outcome)\t\(.seconds)s\tcached=\(.cached)")' result.json -
Were the right cores linted? See filelist:
filelist/stderr.loglists them. That log is not an output of the step, so it is only there after a run with--debug:doris run lint DESIGN --debug. The copied sources infilelist/work/src/are always there. -
Were the right options and waivers used? See flatten: read
flatten/filelist.f, andflatten/verible.flagsfor Verible, andflatten/ascentlint.tclandflatten/ascentlint.flagsfor AscentLint. -
Do the counts match the log? See lint.
-
Does FuseSoC’s own flow agree? It should report the same messages:
fusesoc --cores-root hw run --target=lint --tool=verilator --work-root /tmp/lint <core> fusesoc --cores-root hw run --target=lint --tool=veriblelint --work-root /tmp/lint <core> fusesoc --cores-root hw run --target=lint --tool=slang --work-root /tmp/lint <core> fusesoc --cores-root hw run --target=lint --tool=ascentlint --work-root /tmp/lint <core>
A check that the flow can fail at all is worth doing once: add an unused signal to the design and confirm the Verilator job reports failed with an UNUSEDSIGNAL warning. Don’t name it unused: Verilator leaves out signals whose name contains that.
Limits
doris run lint DESIGNruns every linter bound for the design.--toolkeeps the jobs of one.- Options are not checked against the steps a linter has.
tools.verilator.buildis accepted in a lint config and ignored. See Tool capabilities in the roadmap. - Which tops use a design is read from the core files, not asked of FuseSoC, so a design reached only through a virtual core with several providers is linted on its own. See Tops and contexts.
- Each context is its own job and result. Two tops that resolve a design to the same sources share the cached lint step, but the design still has a job and a report row for each.
- Waived messages are not in the result. The linter applies the waivers, so doris never sees a waived message.
- Each design needs its own config files: a
design.hjsonand alint.hjson.
The roadmap covers what is planned for each.