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

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:

LinterProgramChecks
verilatorverilatorThe elaborated design: widths, unused and undriven signals, latches
veribleverible-verilog-lintStyle, one file at a time, without preprocessing or elaborating
slangslangThe elaborated design against the SystemVerilog standard, and warnings
ascentlintascentlintThe 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
StepIn this flowProduces
filelistAsks FuseSoC for the lint target of the design’s core, for the job’s linterA copy of every source, and a description of the files
flattenMakes the linter’s arguments from the target’s files and optionsfilelist.f, and verible.flags for Verible
lintRuns the linter. The lint resultThe 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.

KeyFileUsed byEffect
coredesign.hjsonfilelistThe FuseSoC core to lint
topdesign.hjsonlintThe top module. If unset, the top is the toplevel of the core’s target
tool.linterlint.hjsonallThe 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
targetlint.hjsonfilelistThe core’s target that describes a lint build. Default lint
mappingsdesign.hjsonfilelistFuseSoC --mapping for each: the core to use where a virtual core has several providers
scopedesign.hjsonalltop makes the design a top, which other designs are linted in the context of
mappingslint.hjsonfilelistMore mappings, for lint only, after the top’s and the design’s
timeoutlint.hjsonlintWall-clock limit for each lint step, such as 30m. No limit if unset
tagsdesign.hjson, lint.hjsonSelectionLabels 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.hjsonThat stepWhat the step holds while it runs: threads, memory and disk, for every tool or for one. See Resource pools
tools.verilator.commandlint.hjsonlintThe Verilator to lint with, if it is not verilator
tools.verilator.lint.argslint.hjsonlintExtra Verilator arguments, after the target’s options
tools.verible.lint.argslint.hjsonlintExtra verible-verilog-lint arguments, after the flag file
tools.slang.lint.argslint.hjsonlintExtra slang arguments, after the target’s options
tools.ascentlint.lint.argslint.hjsonlintExtra 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):

DesignJobsFuseSoC mappings
A toplint/earlgrey@verilatorThe top’s, then its lint.hjson’s
A top’s ownlint/earlgrey/pwrmgr@verilatorThe top’s, the design’s, its lint.hjson’s
Shared, used by two topslint/earlgrey/uart@verilator and lint/darjeeling/uart@verilatorEach top’s, the design’s, its lint.hjson’s
Shared, used by no toplint/spare@verilatorThe 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"
LinterFuseSoC --toolWaiversOptions of the target
verilatorverilatorFiles of type vltverilator_options
veribleveriblelintFiles of type veribleLintWaiverruleset, rules, verible_lint_args, and one file of type veribleLintRules
slangslangNone. Use slang_options or pragmasslang_options
ascentlintascentlintFiles of type waiver, Tcl the run script sourcesascentlint_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 default target. lowrisc:lint:common gives AscentLint -wait_license and -stop_on_error this 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 -Wextra or other -W options, slang reports its default ones.
  • slang needs --single-unit for 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 as ascentlint-config.tcl in OpenTitan’s lowrisc: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 as lowrisc:prim:flop gets 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).

  1. Did the lint step run, with the code you expect? In result.json, check revision, and each step’s cached. 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
    
  2. Were the right cores linted? See filelist: filelist/stderr.log lists 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 in filelist/work/src/ are always there.

  3. Were the right options and waivers used? See flatten: read flatten/filelist.f, and flatten/verible.flags for Verible, and flatten/ascentlint.tcl and flatten/ascentlint.flags for AscentLint.

  4. Do the counts match the log? See lint.

  5. 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 DESIGN runs every linter bound for the design. --tool keeps the jobs of one.
  • Options are not checked against the steps a linter has. tools.verilator.build is 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.hjson and a lint.hjson.

The roadmap covers what is planned for each.