diff --git a/bin/verilator b/bin/verilator index 7ca399a73..6140a856a 100755 --- a/bin/verilator +++ b/bin/verilator @@ -2414,7 +2414,9 @@ simulators. Warns that a module or other declaration's name doesn't match the filename with path and extension stripped that it is declared in. The filename a modules/interfaces/programs is declared in should match the name of the -module etc. so that -y directory searching will work. +module etc. so that -y directory searching will work. This warning is +printed for only the first mismatching module in any given file, and -v +library files are ignored. Disabled by default as this is a code style warning, it will simulate correctly. diff --git a/src/V3Link.cpp b/src/V3Link.cpp index 126db7647..0f422d020 100644 --- a/src/V3Link.cpp +++ b/src/V3Link.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -79,6 +80,7 @@ private: bool m_inGenerate; // Inside a generate AstNodeModule* m_valueModp; // If set, move AstVar->valuep() initial values to this module vector m_delSymps; // Symbol tables to delete + set m_declfnWarned; // Files we issued DECLFILENAME on static int debug() { static int level = -1; @@ -228,9 +230,14 @@ private: // Module: Create sim table for entire module and iterate UINFO(2,"Link Module: "<fileline()->filebasenameNoExt() != nodep->prettyName()) { - nodep->v3warn(DECLFILENAME, "Filename '"<fileline()->filebasenameNoExt() - <<"' does not match "<typeName()<<" name: "<prettyName()); + if (nodep->fileline()->filebasenameNoExt() != nodep->prettyName() + && !v3Global.opt.isLibraryFile(nodep->fileline()->filename())) { + // We only complain once per file, otherwise library-like files have a huge mess of warnings + if (m_declfnWarned.find(nodep->fileline()->filename()) == m_declfnWarned.end()) { + m_declfnWarned.insert(nodep->fileline()->filename()); + nodep->v3warn(DECLFILENAME, "Filename '"<fileline()->filebasenameNoExt() + <<"' does not match "<typeName()<<" name: "<prettyName()); + } } } AstCell* upperCellp = m_cellp; diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 1f521ab67..bc7da0391 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -115,6 +115,9 @@ void V3Options::addFuture(const string& flag) { bool V3Options::isFuture(const string& flag) const { return m_futures.find(flag) != m_futures.end(); } +bool V3Options::isLibraryFile(const string& filename) const { + return m_libraryFiles.find(filename) != m_libraryFiles.end(); +} void V3Options::addLibraryFile(const string& filename) { if (m_libraryFiles.find(filename) == m_libraryFiles.end()) { diff --git a/src/V3Options.h b/src/V3Options.h index 353fc1801..df48ae9a9 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -276,6 +276,7 @@ class V3Options { const V3LangCode& language() const { return m_language; } bool isFuture(const string& flag) const; + bool isLibraryFile(const string& filename) const; // ACCESSORS (optimization options) bool oAcycSimp() const { return m_oAcycSimp; }