Add --future0 and --future1 options.

This commit is contained in:
Wilson Snyder 2022-08-20 14:01:13 -04:00
parent 4d81eb021d
commit 90dc04cf93
5 changed files with 47 additions and 1 deletions

View File

@ -13,6 +13,7 @@ Verilator 4.225 devel
**Minor:**
* Add --future0 and --future1 options.
* Fix incorrect bit op tree optimization (#3470). [algrobman]
* Fix empty string arguments to display (#3484). [Grulfen]
* Fix table misoptimizing away display (#3488). [Stefan Post]

View File

@ -491,6 +491,30 @@ Summary:
are typically used only when recommended by a maintainer to help debug
or work around an issue.
.. option:: -future0 <option>
Rarely needed. Suppress an unknown Verilator option for an option that
takes no additional arguments. This is used to allow scripts written
with pragmas for a later version of Verilator to run under a older
version. e.g. :code:`-future0 option --option` would on older versions
that do not understand :code:`--option` or :code:`+option` suppress what
would otherwise be an invalid option error, and on newer versions that
implement :code:`--option`, :code:`-future0 option --option` would have
the :code:`-future0 option` ignored and the :code:`--option` would
function appropriately.
.. option:: -future1 <option>
Rarely needed. Suppress an unknown Verilator option for an option that
takes an additional argument. This is used to allow scripts written
with pragmas for a later version of Verilator to run under a older
version. e.g. :code:`-future1 option --option arg` would on older
versions that do not understand :code:`--option arg` or :code:`+option
arg` suppress what would otherwise be an invalid option error, and on
newer versions that implement :code:`--option arg`, :code:`-future1
option --option arg` would have the :code:`-future1 option` ignored and
the :code:`--option arg` would function appropriately.
.. option:: -G<name>=<value>
Overwrites the given parameter of the toplevel module. The value is

View File

@ -359,9 +359,17 @@ void V3Options::addCFlags(const string& filename) { m_cFlags.push_back(filename)
void V3Options::addLdLibs(const string& filename) { m_ldLibs.push_back(filename); }
void V3Options::addMakeFlags(const string& filename) { m_makeFlags.push_back(filename); }
void V3Options::addFuture(const string& flag) { m_futures.insert(flag); }
void V3Options::addFuture0(const string& flag) { m_future0s.insert(flag); }
void V3Options::addFuture1(const string& flag) { m_future1s.insert(flag); }
bool V3Options::isFuture(const string& flag) const {
return m_futures.find(flag) != m_futures.end();
}
bool V3Options::isFuture0(const string& flag) const {
return m_future0s.find(flag) != m_future0s.end();
}
bool V3Options::isFuture1(const string& flag) const {
return m_future1s.find(flag) != m_future1s.end();
}
bool V3Options::isLibraryFile(const string& filename) const {
return m_libraryFiles.find(filename) != m_libraryFiles.end();
}
@ -1083,6 +1091,8 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
parseOptsFile(fl, parseFileArg(optdir, valp), false);
});
DECL_OPTION("-flatten", OnOff, &m_flatten);
DECL_OPTION("-future0", CbVal, [this, fl, &optdir](const char* valp) { addFuture0(valp); });
DECL_OPTION("-future1", CbVal, [this, fl, &optdir](const char* valp) { addFuture1(valp); });
DECL_OPTION("-facyc-simp", FOnOff, &m_fAcycSimp);
DECL_OPTION("-fassemble", FOnOff, &m_fAssemble);
@ -1512,8 +1522,13 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
++i;
}
} else if (argv[i][0] == '-' || argv[i][0] == '+') {
const char* argvNoDashp = (argv[i][1] == '-') ? (argv[i] + 2) : (argv[i] + 1);
if (const int consumed = parser.parse(i, argc, argv)) {
i += consumed;
} else if (isFuture0(argvNoDashp)) {
++i;
} else if (isFuture1(argvNoDashp)) {
i += 2;
} else {
fl->v3fatal("Invalid option: " << argv[i] << parser.getSuggestion(argv[i]));
++i; // LCOV_EXCL_LINE

View File

@ -199,6 +199,8 @@ private:
V3StringList m_ldLibs; // argument: user LDFLAGS
V3StringList m_makeFlags; // argument: user MAKEFLAGS
V3StringSet m_futures; // argument: -Wfuture- list
V3StringSet m_future0s; // argument: -future list
V3StringSet m_future1s; // argument: -future1 list
V3StringSet m_libraryFiles; // argument: Verilog -v files
V3StringSet m_clockers; // argument: Verilog -clk signals
V3StringSet m_noClockers; // argument: Verilog -noclk signals
@ -371,6 +373,8 @@ private:
void addArg(const string& arg);
void addDefine(const string& defline, bool allowPlus);
void addFuture(const string& flag);
void addFuture0(const string& flag);
void addFuture1(const string& flag);
void addIncDirUser(const string& incdir); // User requested
void addIncDirFallback(const string& incdir); // Low priority if not found otherwise
void addParameter(const string& paramline, bool allowPlus);
@ -572,6 +576,8 @@ public:
void checkParameters();
bool isFuture(const string& flag) const;
bool isFuture0(const string& flag) const;
bool isFuture1(const string& flag) const;
bool isLibraryFile(const string& filename) const;
bool isClocker(const string& signame) const;
bool isNoClocker(const string& signame) const;

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
scenarios(vlt => 1);
lint(
verilator_flags2 => [qw(--lint-only -Wfuture-FUTURE1 -Wfuture-FUTURE2)],
verilator_flags2 => [qw(--lint-only --future0 thefuture --future1 thefuturei --thefuture -thefuture +thefuture --thefuturei 1 -Wfuture-FUTURE1 -Wfuture-FUTURE2)],
);
ok(1);