Closed goekce closed 1 month ago
As far as I understand, currently nvim-lint
passes only the opened file to Verilator, so it has no clue about your imports or top module. As a workaround a have a verilator.f
config file with following contents:
-Wall
--timing
--trace-fst
--trace-structs
--x-assign unique
--x-initial unique
-Irtl
-Irtl/include
rtl/board_top.sv
This config is in project's root directory, my modules is in rtl
directory and packages in rtl/include
. I also specify top. It doesn't have --lint-only
option, because I use it not only for linting, but for simulation is well.
After writing your config, the only thing that is left to do is to pass it as an argument:
local verilator = require('lint').linters.verilator
verilator.args = {
'--lint-only',
'-F',
vim.fs.find("verilator.f", {
upward = true,
stop = "/home",
type = "file"
})[1]
}
Here I specify --lint-only
option and look for a file in current or parent directories until /home. I have a basic verilator.f
in my home with -Wall
and --timing
for small files without their own config. [1]
is needed, because vim.fs.find()
returns a list and we need the first element
This is a good workaround @max-kudinov, thanks.
Taking all the .sv or .v files in current directory could be better, however Verilator does not order the files during compilation — so even this could lead to some problems for linting.
I believe currently there is nothing that nvim-lint
can do better without parsing the source files, so I'll close this issue.
Test case:
test_pkg.sv:
test.sv:
The linter outputs:
Taking all files in the folder using
verilator --lint-only *.sv
does not output any error.Is this a problem of
verilator
ornvim-lint
configuration?