diff --git a/bin/verilator b/bin/verilator index 12e52611c..534c1a9d6 100755 --- a/bin/verilator +++ b/bin/verilator @@ -964,9 +964,11 @@ If the design is not to be completely Verilated see also the --bbox-sys and --bbox-unsup options. =item --MMD +=item --no-MMD -Enable creation of .d dependency files, used for make dependency detection, -similar to gcc -MMD option. On by default, use --no-MMD to disable. +Enable/disable creation of .d dependency files, used for make dependency +detection, similar to gcc -MMD option. By default this option is enabled +for --cc or --sp modes. =item --MP @@ -1017,9 +1019,11 @@ with extra loads and stores to handle the (imaginary) aliasing. Using only 'vlTOPp->' references allows these old compilers to produce tight code. =item --no-skip-identical +=item --skip-identical -Rarely needed. Disables skipping execution of Verilator if all source -files are identical, and all output files exist with newer dates. +Rarely needed. Disables or enables skipping execution of Verilator if all +source files are identical, and all output files exist with newer dates. +By default this option is enabled for --cc or --sp modes only. =item +notimingchecks diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 59e1ae399..b3c28eb60 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -528,11 +528,12 @@ string V3Options::getenvVERILATOR_ROOT() { void V3Options::notify() { // Notify that all arguments have been passed and final modification can be made. if (!outFormatOk() - && !preprocOnly() + && !cdc() + && !dpiHdrOnly() && !lintOnly() - && !xmlOnly() - && !cdc()) { - v3fatal("verilator: Need --cc, --sc, --cdc, --lint-only, --xml_only or --E option"); + && !preprocOnly() + && !xmlOnly()) { + v3fatal("verilator: Need --cc, --sc, --cdc, --dpi-hdr-only, --lint-only, --xml-only or --E option"); } // Make sure at least one make system is enabled @@ -559,6 +560,22 @@ void V3Options::notify() { +V3Error::warnMore()+"... Suggest remove --vpi."); } } + + // Default some options if not turned on or off + if (v3Global.opt.skipIdentical().isDefault()) { + v3Global.opt.m_skipIdentical.setTrueOrFalse( + !v3Global.opt.cdc() + && !v3Global.opt.dpiHdrOnly() + && !v3Global.opt.lintOnly() + && !v3Global.opt.preprocOnly()); + } + if (v3Global.opt.makeDepend().isDefault()) { + v3Global.opt.m_makeDepend.setTrueOrFalse( + !v3Global.opt.cdc() + && !v3Global.opt.dpiHdrOnly() + && !v3Global.opt.lintOnly() + && !v3Global.opt.preprocOnly()); + } } //###################################################################### @@ -638,6 +655,15 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) { else if (0==strncmp(sw, "-no-", 4) && (0==strcmp(sw+4, arg+1))) { flag = false; return true; } return false; } +bool V3Options::onoffb(const char* sw, const char* arg, VOptionBool& bflag) { + bool flag; + if (onoff(sw, arg, flag/*ref*/)) { + bflag.setTrueOrFalse(flag); + return true; + } else { + return false; + } +} bool V3Options::suffixed(const string& sw, const char* arg) { if (strlen(arg) > sw.length()) return false; @@ -696,12 +722,13 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char else if (argv[i][0]=='-') { const char *sw = argv[i]; bool flag = true; + VOptionBool bflag; // Allow gnu -- switches if (sw[0]=='-' && sw[1]=='-') ++sw; if (0) {} // Single switches else if (!strcmp(sw, "-E")) { m_preprocOnly = true; } - else if ( onoff (sw, "-MMD", flag/*ref*/)) { m_makeDepend = flag; } + else if ( onoffb(sw, "-MMD", bflag/*ref*/)) { m_makeDepend = bflag; } else if ( onoff (sw, "-MP", flag/*ref*/)) { m_makePhony = flag; } else if (!strcmp(sw, "-P")) { m_preprocNoLine = true; } else if ( onoff (sw, "-assert", flag/*ref*/)) { m_assert = flag; } @@ -748,13 +775,13 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char else if ( onoff (sw, "-protect-ids", flag/*ref*/)) { m_protectIds = flag; } else if ( onoff (sw, "-public", flag/*ref*/)) { m_public = flag; } else if ( onoff (sw, "-public-flat-rw", flag/*ref*/) ) { m_publicFlatRW = flag; v3Global.dpi(true); } - else if (!strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); } + else if (!strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); } else if ( onoff (sw, "-relative-cfuncs", flag/*ref*/)) { m_relativeCFuncs = flag; } else if ( onoff (sw, "-relative-includes", flag/*ref*/)) { m_relativeIncludes = flag; } else if ( onoff (sw, "-report-unoptflat", flag/*ref*/)) { m_reportUnoptflat = flag; } else if ( onoff (sw, "-savable", flag/*ref*/)) { m_savable = flag; } else if (!strcmp(sw, "-sc")) { m_outFormatOk = true; m_systemC = true; } - else if ( onoff (sw, "-skip-identical", flag/*ref*/)) { m_skipIdentical = flag; } + else if ( onoffb(sw, "-skip-identical", bflag/*ref*/)) { m_skipIdentical = bflag; } else if ( onoff (sw, "-stats", flag/*ref*/)) { m_stats = flag; } else if ( onoff (sw, "-stats-vars", flag/*ref*/)) { m_statsVars = flag; m_stats |= flag; } else if (!strcmp(sw, "-sv")) { m_defaultLanguage = V3LangCode::L1800_2005; } @@ -1420,7 +1447,6 @@ V3Options::V3Options() { m_inhibitSim = false; m_lintOnly = false; m_gmake = false; - m_makeDepend = true; m_makePhony = false; m_orderClockDly = true; m_outFormatOk = false; @@ -1440,7 +1466,6 @@ V3Options::V3Options() { m_relativeIncludes = false; m_reportUnoptflat = false; m_savable = false; - m_skipIdentical = true; m_stats = false; m_statsVars = false; m_systemC = false; diff --git a/src/V3Options.h b/src/V3Options.h index 465f164c4..61f428837 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -37,6 +37,39 @@ class FileLine; //###################################################################### +class VOptionBool { + // Class to track options that are either not specified (and default + // true/false), versus user setting the option to true or false +public: + enum en { + OPT_DEFAULT_FALSE = 0, + OPT_DEFAULT_TRUE, + OPT_TRUE, + OPT_FALSE, + _ENUM_END + }; + enum en m_e; + inline VOptionBool() : m_e(OPT_DEFAULT_FALSE) {} + // cppcheck-suppress noExplicitConstructor + inline VOptionBool(en _e) : m_e(_e) {} + explicit inline VOptionBool(int _e) : m_e(static_cast(_e)) {} + operator en() const { return m_e; } + bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; } + bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; } + bool isFalse() const { return m_e == OPT_FALSE || m_e == OPT_DEFAULT_FALSE; } + void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; } + const char* ascii() const { + static const char* const names[] = { + "DEFAULT_FALSE", "DEFAULT_TRUE", "TRUE", "FALSE"}; + return names[m_e]; } + }; + inline bool operator==(VOptionBool lhs, VOptionBool rhs) { return (lhs.m_e == rhs.m_e); } + inline bool operator==(VOptionBool lhs, VOptionBool::en rhs) { return (lhs.m_e == rhs); } + inline bool operator==(VOptionBool::en lhs, VOptionBool rhs) { return (lhs == rhs.m_e); } + inline std::ostream& operator<<(std::ostream& os, const VOptionBool& rhs) { return os< 1); } diff --git a/src/Verilator.cpp b/src/Verilator.cpp index 99efc6830..c01728dd7 100644 --- a/src/Verilator.cpp +++ b/src/Verilator.cpp @@ -607,10 +607,7 @@ int main(int argc, char** argv, char** env) { // Can we skip doing everything if times are ok? V3File::addSrcDepend(v3Global.opt.bin()); - if (v3Global.opt.skipIdentical() - && !v3Global.opt.preprocOnly() - && !v3Global.opt.lintOnly() - && !v3Global.opt.cdc() + if (v3Global.opt.skipIdentical().isTrue() && V3File::checkTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix() +"__verFiles.dat", argString)) { UINFO(1,"--skip-identical: No change to any source files, exiting\n"); @@ -648,13 +645,10 @@ int main(int argc, char** argv, char** env) { V3Global::dumpCheckGlobalTree("final", 990, v3Global.opt.dumpTreeLevel(__FILE__) >= 3); V3Error::abortIfWarnings(); - if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc() - && !v3Global.opt.dpiHdrOnly() && v3Global.opt.makeDepend()) { + if (v3Global.opt.makeDepend().isTrue()) { V3File::writeDepend(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__ver.d"); } - if (!v3Global.opt.lintOnly() && !v3Global.opt.cdc() - && !v3Global.opt.dpiHdrOnly() - && (v3Global.opt.skipIdentical() || v3Global.opt.makeDepend())) { + if (v3Global.opt.skipIdentical().isTrue() || v3Global.opt.makeDepend().isTrue()) { V3File::writeTimes(v3Global.opt.makeDir()+"/"+v3Global.opt.prefix() +"__verFiles.dat", argString); } diff --git a/test_regress/t/t_dpi_import_hdr_only.pl b/test_regress/t/t_dpi_import_hdr_only.pl index cce0dcf8b..a884ce466 100755 --- a/test_regress/t/t_dpi_import_hdr_only.pl +++ b/test_regress/t/t_dpi_import_hdr_only.pl @@ -17,14 +17,15 @@ top_filename("t/t_dpi_import.v"); my $tmp_dir = File::Temp->newdir(); compile( - verilator_flags2 => ["-Wall -Wno-DECLFILENAME -Mdir " . $tmp_dir . " --dpi-hdr-only"], + # Override default flags also + verilator_flags => ["-Wall -Wno-DECLFILENAME -Mdir " . $tmp_dir . " --dpi-hdr-only"], verilator_make_gmake => 0, ); my @files = glob($tmp_dir . "/*"); error("Did not produce DPI header") if scalar(@files) == 0; -error("Too many files created") if scalar(@files) > 1; +error("Too many files created:".join(', ', @files)) if scalar(@files) > 1; my $tmp_header = $files[0]; print("============".$tmp_header."\n");