Project

General

Profile

[logo] 
 
Home
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

use verilator as a linter per single file

Added by Kris Jeon over 3 years ago

Hi,

I hope to use verilator as a linter for single file. So, I want verilator to ignore `include "xxxx" files and undefined modules in that single file and continue linting. But verilator always searches include files and modules and generates error messages and stops linting like the following:

>> verilator_bin --lint-only abc.v

%Error: abc.v:9: Cannot find file containing module: mod_test
%Error: abc.v:9: This may be because there's no search path specified with -I<dir>.
%Error: abc.v:9: Looked in:
%Error: abc.v:9:       mod_test
%Error: abc.v:9:       mod_test.v
%Error: abc.v:9:       mod_test.sv
%Error: abc.v:9:       obj_dir/mod_test
%Error: abc.v:9:       obj_dir/mod_test.v
%Error: abc.v:9:       obj_dir/mod_test.sv
%Error: Exiting due to 9 error(s)

Is there any way to solve it ?

Thank you.


Replies (6)

RE: use verilator as a linter per single file - Added by Wilson Snyder over 3 years ago

Unfortunately Verilog as a language can't in the general case be parsed without include files. It also can't be linted without elaboration, which requires the whole design. So this isn't and won't be supported in Verilator. Sorry.

If you're trying to avoid this because you're writing something like a wrapper module and don't want to lint what is below, you may want to make a "null module", which has the same I/O as your below module but none of the guts. verilog-mode makes this easy.

RE: use verilator as a linter per single file - Added by Kris Jeon over 3 years ago

I'm making Sublime Text's linter plugin by using SublimeLinter framework. It enables to visualize lint message on editor in real time!. I think Verilator is good to use like that (fast/light...). In order to solve mentioned above, I forked https://github.com/wind0136/verilator and changed some codes (https://github.com/poucotm/verilator). You can also check linter page here, https://github.com/poucotm/SublimeLinter-contrib-verilator

Not many people use Sublime Text as HDL editor. But I think it will be grown. I hope verilator to support systemverilog's verification codes as well as synthesizable codes.

Thank you for your job.

RE: use verilator as a linter per single file - Added by Wilson Snyder over 3 years ago

Thanks for the notice about this, sounds great. It looks like you're making progress, so perhaps you prefer to work on a branch for a bit until it's stable, then when ready we can talk about getting it into a form that can be merged back?

RE: use verilator as a linter per single file - Added by Kris Jeon over 3 years ago

Thank you for your mention.

I have more question. I've changed codes to ignore modules in another files like this :
...
nodep->v3warn(IGNMOD, "Cannot find file containing module: "<<nodep->modName());
// v3Global.opt.filePathLookedMsg(nodep->fileline(), nodep->modName());
...
But there's side effect. UNUSED warnings are displayed for the signals connected NOTFOUNDMODULE's pin.

What is the good way to mark or not to display UNUSED warnings for that kind of signals ? Is it possible to add the property to AstVar whether it connected or not ?

RE: use verilator as a linter per single file - Added by Wilson Snyder over 3 years ago

That's going to be complicated because the lack of a submodule means the normal attachment of pins to variables won't occur; also I suspect this will pull a long thread of possible errors that will need to be fixed. Anyhow probably in V3LinkDot when a NotFoundModule is found, you could iterate through the child nodes in a new Visitor class, looking for a AstParseRef, then for that ParseRef look at the symbol tree. If a symbol is found and it corresponds to a variable, call that variable's fileline()->warnOff(UNUSED,true). Then if later it would have normally printed an error message it will instead suppress it just as if that variable had a //verilator lint_off UNUSED. Probably similar is needed for UNDRIVEN.

RE: use verilator as a linter per single file - Added by Kris Jeon over 3 years ago

Thank you for your advice.

I added the method onto V3LinkParse.cpp to check whether it is connected NOTFOUNDMODULE or not.

    virtual void visit(AstParseRef* nodep) {
        if (v3Global.opt.lintOnly()) {
            AstNode* pin;
            bool ispin = false;
            if (nodep->backp()->type() == AstType::atPin) {
                ispin = true;
                pin = nodep->backp();
            }
            else if (nodep->backp()->type() == AstType::atSelBit)
            if (nodep->backp()->backp()->type() == AstType::atPin) {
                ispin = true;
                pin = nodep->backp()->backp();
            }
            if (ispin) {
                AstNode* niterp;
                niterp = pin;
                while(niterp) {
                    if (niterp->type() == AstType::atCell && ((AstCell*) niterp)->modp()->type() == AstType::atNotFoundModule) {
                        FileLine::m_ignunused.insert(nodep->name());
                        niterp = NULL;
                    }
                    else if (niterp->type() == AstType::atModule) niterp = NULL;
                    else niterp = niterp->backp();
                }
            }
        }
    // Default: Just iterate
    cleanFileline(nodep);
    nodep->iterateChildren(*this);
    }

New warning (to be ignorable) added In V3Undriven.cpp

        bool pass = false;
        if (v3Global.opt.lintOnly() && FileLine::m_ignunused.find(nodep->name()) != FileLine::m_ignunused.end()) {
            nodep->v3warn(IGNUNUSED, "Signal is unused. it is connected to NOTFOUNDMODULE: "<<nodep->prettyName());
            pass = true;
        }

It is too hard to me to write more good codes...

    (1-6/6)