1 // -*- mode: C++; c-file-style: "cc-mode" -*-
2 //*************************************************************************
3 // DESCRIPTION: Verilator: Command line options
4 //
5 // Code available from: https://verilator.org
6 //
7 //*************************************************************************
8 //
9 // Copyright 2003-2021 by Wilson Snyder. This program is free software; you
10 // can redistribute it and/or modify it under the terms of either the GNU
11 // Lesser General Public License Version 3 or the Perl Artistic License
12 // Version 2.0.
13 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
14 //
15 //*************************************************************************
16 
17 #ifndef VERILATOR_V3OPTIONS_H_
18 #define VERILATOR_V3OPTIONS_H_
19 
20 #include "config_build.h"
21 #include "verilatedos.h"
22 
23 #include "V3Global.h"
24 #include "V3LangCode.h"
25 
26 #include <map>
27 #include <set>
28 #include <string>
29 #include <vector>
30 
31 class V3OptionsImp;
32 class FileLine;
33 
34 //######################################################################
35 
36 class VOptionBool final {
37     // Class to track options that are either not specified (and default
38     // true/false), versus user setting the option to true or false
39 public:
40     enum en : uint8_t { OPT_DEFAULT_FALSE = 0, OPT_DEFAULT_TRUE, OPT_TRUE, OPT_FALSE };
41     enum en m_e;
VOptionBool()42     inline VOptionBool()
43         : m_e{OPT_DEFAULT_FALSE} {}
44     // cppcheck-suppress noExplicitConstructor
VOptionBool(en _e)45     inline VOptionBool(en _e)
46         : m_e{_e} {}
VOptionBool(int _e)47     explicit inline VOptionBool(int _e)
48         : m_e(static_cast<en>(_e)) {}  // Need () or GCC 4.8 false warning
en()49     operator en() const { return m_e; }
isDefault()50     bool isDefault() const { return m_e == OPT_DEFAULT_FALSE || m_e == OPT_DEFAULT_TRUE; }
isTrue()51     bool isTrue() const { return m_e == OPT_TRUE || m_e == OPT_DEFAULT_TRUE; }
isSetTrue()52     bool isSetTrue() const { return m_e == OPT_TRUE; }
isSetFalse()53     bool isSetFalse() const { return m_e == OPT_FALSE; }
setTrueOrFalse(bool flag)54     void setTrueOrFalse(bool flag) { m_e = flag ? OPT_TRUE : OPT_FALSE; }
55 };
56 inline bool operator==(const VOptionBool& lhs, const VOptionBool& rhs) {
57     return lhs.m_e == rhs.m_e;
58 }
59 inline bool operator==(const VOptionBool& lhs, VOptionBool::en rhs) { return lhs.m_e == rhs; }
60 inline bool operator==(VOptionBool::en lhs, const VOptionBool& rhs) { return lhs == rhs.m_e; }
61 
62 //######################################################################
63 
64 class VTimescale final {
65 public:
66     enum en : uint8_t {
67         // clang-format off
68         TS_100S = 0, TS_10S = 1, TS_1S = 2,
69         TS_100MS = 3, TS_10MS = 4, TS_1MS = 5,
70         TS_100US = 6, TS_10US = 7, TS_1US = 8,
71         TS_100NS = 9, TS_10NS = 10, TS_1NS = 11,
72         TS_100PS = 12, TS_10PS = 13, TS_1PS = 14,
73         TS_100FS = 15, TS_10FS = 16, TS_1FS = 17,
74         // clang-format on
75         NONE = 18,
76         _ENUM_END
77     };
78     enum : uint8_t { TS_DEFAULT = TS_1PS };
79     enum en m_e;
80     // CONSTRUCTOR
VTimescale()81     inline VTimescale()
82         : m_e{NONE} {}
83     // cppcheck-suppress noExplicitConstructor
VTimescale(en _e)84     inline VTimescale(en _e)
85         : m_e{_e} {}
VTimescale(int _e)86     explicit inline VTimescale(int _e)
87         : m_e(static_cast<en>(_e)) {}  // Need () or GCC 4.8 false warning
88     // Construct from string
89     VTimescale(const string& value, bool& badr);
VTimescale(double value,bool & badr)90     VTimescale(double value, bool& badr) {
91         badr = false;
92         for (int i = TS_100S; i < _ENUM_END; ++i) {
93             m_e = static_cast<en>(i);
94             if (multiplier() == value) break;
95         }
96         if (multiplier() != value) {
97             m_e = NONE;
98             badr = true;
99         }
100     }
isNone()101     bool isNone() const { return m_e == NONE; }
102     // Parse a "unit/precision" string into two VTimescales, with error checking
103     static void parseSlashed(FileLine* fl, const char* textp, VTimescale& unitr, VTimescale& precr,
104                              bool allowEmpty = false);
ascii()105     const char* ascii() const {
106         static const char* const names[]
107             = {"100s", "10s", "1s",    "100ms", "10ms", "1ms",   "100us", "10us", "1us", "100ns",
108                "10ns", "1ns", "100ps", "10ps",  "1ps",  "100fs", "10fs",  "1fs",  "NONE"};
109         return names[m_e];
110     }
powerOfTen()111     int powerOfTen() const { return 2 - static_cast<int>(m_e); }
multiplier()112     double multiplier() const {
113         static const double values[]
114             = {100,  10,   1,     1e-1,  1e-2,  1e-3,  1e-4,  1e-5,  1e-6, 1e-7,
115                1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 0};
116         return values[m_e];
117     }
118 };
119 inline bool operator==(const VTimescale& lhs, const VTimescale& rhs) { return lhs.m_e == rhs.m_e; }
120 inline bool operator==(const VTimescale& lhs, VTimescale::en rhs) { return lhs.m_e == rhs; }
121 inline bool operator==(VTimescale::en lhs, const VTimescale& rhs) { return lhs == rhs.m_e; }
122 // Comparisons are based on time, not enum values, so seconds > milliseconds
123 inline bool operator<(const VTimescale& lhs, const VTimescale& rhs) { return lhs.m_e > rhs.m_e; }
124 inline std::ostream& operator<<(std::ostream& os, const VTimescale& rhs) {
125     return os << rhs.ascii();
126 }
127 
128 //######################################################################
129 
130 class TraceFormat final {
131 public:
132     enum en : uint8_t { VCD = 0, FST } m_e;
133     // cppcheck-suppress noExplicitConstructor
134     inline TraceFormat(en _e = VCD)
135         : m_e{_e} {}
TraceFormat(int _e)136     explicit inline TraceFormat(int _e)
137         : m_e(static_cast<en>(_e)) {}  // Need () or GCC 4.8 false warning
en()138     operator en() const { return m_e; }
fst()139     bool fst() const { return m_e == FST; }
classBase()140     string classBase() const {
141         static const char* const names[] = {"VerilatedVcd", "VerilatedFst"};
142         return names[m_e];
143     }
sourceName()144     string sourceName() const {
145         static const char* const names[] = {"verilated_vcd", "verilated_fst"};
146         return names[m_e];
147     }
148 };
149 inline bool operator==(const TraceFormat& lhs, const TraceFormat& rhs) {
150     return lhs.m_e == rhs.m_e;
151 }
152 inline bool operator==(const TraceFormat& lhs, TraceFormat::en rhs) { return lhs.m_e == rhs; }
153 inline bool operator==(TraceFormat::en lhs, const TraceFormat& rhs) { return lhs == rhs.m_e; }
154 
155 using V3StringList = std::vector<std::string>;
156 using V3StringSet = std::set<std::string>;
157 
158 //######################################################################
159 
160 // Information given by --hierarchical-block option
161 class V3HierarchicalBlockOption final {
162 public:
163     // key:parameter name, value:value (as string)
164     using ParamStrMap = std::map<const std::string, std::string>;
165 
166 private:
167     string m_origName;  // module name
168     // module name after uniquified
169     // same as m_origName for non-parameterized module
170     string m_mangledName;
171     // overriding parameter values specified by -G option
172     ParamStrMap m_parameters;
173 
174 public:
175     explicit V3HierarchicalBlockOption(const string& optstring);
origName()176     const string& origName() const { return m_origName; }
mangledName()177     const string& mangledName() const { return m_mangledName; }
params()178     const ParamStrMap params() const { return m_parameters; }
179 };
180 
181 using V3HierBlockOptSet = std::map<const std::string, V3HierarchicalBlockOption>;
182 
183 //######################################################################
184 // V3Options - Command line options
185 
186 class V3Options final {
187 public:
188 private:
189     // TYPES
190     using DebugSrcMap = std::map<const std::string, int>;
191 
192     // MEMBERS (general options)
193     V3OptionsImp* m_impp;  // Slow hidden options
194 
195     // clang-format off
196     V3StringSet m_cppFiles;     // argument: C++ files to link against
197     V3StringList m_cFlags;      // argument: user CFLAGS
198     V3StringList m_ldLibs;      // argument: user LDFLAGS
199     V3StringList m_makeFlags;   // argument: user MAKEFLAGS
200     V3StringSet m_futures;      // argument: -Wfuture- list
201     V3StringSet m_libraryFiles; // argument: Verilog -v files
202     V3StringSet m_clockers;     // argument: Verilog -clk signals
203     V3StringSet m_noClockers;   // argument: Verilog -noclk signals
204     V3StringList m_vFiles;      // argument: Verilog files to read
205     V3StringList m_forceIncs;   // argument: -FI
206     DebugSrcMap m_debugSrcs;    // argument: --debugi-<srcfile>=<level>
207     DebugSrcMap m_dumpTrees;    // argument: --dump-treei-<srcfile>=<level>
208     std::map<const string, string> m_parameters;  // Parameters
209     std::map<const string, V3HierarchicalBlockOption> m_hierBlocks;  // main switch: --hierarchical-block
210 
211     bool m_preprocOnly = false;     // main switch: -E
212     bool m_makePhony = false;       // main switch: -MP
213     bool m_preprocNoLine = false;   // main switch: -P
214     bool m_assert = false;          // main switch: --assert
215     bool m_autoflush = false;       // main switch: --autoflush
216     bool m_bboxSys = false;         // main switch: --bbox-sys
217     bool m_bboxUnsup = false;       // main switch: --bbox-unsup
218     bool m_build = false;           // main switch: --build
219     bool m_cdc = false;             // main switch: --cdc
220     bool m_cmake = false;           // main switch: --make cmake
221     bool m_context = true;          // main switch: --Wcontext
222     bool m_coverageLine = false;    // main switch: --coverage-block
223     bool m_coverageToggle = false;  // main switch: --coverage-toggle
224     bool m_coverageUnderscore = false;  // main switch: --coverage-underscore
225     bool m_coverageUser = false;    // main switch: --coverage-func
226     bool m_debugCheck = false;      // main switch: --debug-check
227     bool m_debugCollision = false;  // main switch: --debug-collision
228     bool m_debugEmitV = false;      // main switch: --debug-emitv
229     bool m_debugExitParse = false;  // main switch: --debug-exit-parse
230     bool m_debugExitUvm = false;    // main switch: --debug-exit-uvm
231     bool m_debugLeak = true;        // main switch: --debug-leak
232     bool m_debugNondeterminism = false;  // main switch: --debug-nondeterminism
233     bool m_debugPartition = false;  // main switch: --debug-partition
234     bool m_debugProtect = false;    // main switch: --debug-protect
235     bool m_debugSelfTest = false;   // main switch: --debug-self-test
236     bool m_decoration = true;       // main switch: --decoration
237     bool m_dpiHdrOnly = false;      // main switch: --dpi-hdr-only
238     bool m_dumpDefines = false;     // main switch: --dump-defines
239     bool m_dumpTreeAddrids = false; // main switch: --dump-tree-addrids
240     bool m_exe = false;             // main switch: --exe
241     bool m_flatten = false;         // main switch: --flatten
242     bool m_hierarchical = false;    // main switch: --hierarchical
243     bool m_hierChild = false;       // main switch: --hierarchical-child
244     bool m_ignc = false;            // main switch: --ignc
245     bool m_lintOnly = false;        // main switch: --lint-only
246     bool m_gmake = false;           // main switch: --make gmake
247     bool m_main = false;            // main swithc: --main
248     bool m_mergeConstPool = true;   // main switch: --merge-const-pool
249     bool m_orderClockDly = true;    // main switch: --order-clock-delay
250     bool m_outFormatOk = false;     // main switch: --cc, --sc or --sp was specified
251     bool m_pedantic = false;        // main switch: --Wpedantic
252     bool m_pinsScUint = false;      // main switch: --pins-sc-uint
253     bool m_pinsScBigUint = false;   // main switch: --pins-sc-biguint
254     bool m_pinsUint8 = false;       // main switch: --pins-uint8
255     bool m_ppComments = false;      // main switch: --pp-comments
256     bool m_profC = false;           // main switch: --prof-c
257     bool m_profCFuncs = false;      // main switch: --prof-cfuncs
258     bool m_profThreads = false;     // main switch: --prof-threads
259     bool m_protectIds = false;      // main switch: --protect-ids
260     bool m_public = false;          // main switch: --public
261     bool m_publicFlatRW = false;    // main switch: --public-flat-rw
262     bool m_quietExit = false;       // main switch: --quiet-exit
263     bool m_relativeIncludes = false; // main switch: --relative-includes
264     bool m_reportUnoptflat = false; // main switch: --report-unoptflat
265     bool m_savable = false;         // main switch: --savable
266     bool m_structsPacked = true;    // main switch: --structs-packed
267     bool m_systemC = false;         // main switch: --sc: System C instead of simple C++
268     bool m_stats = false;           // main switch: --stats
269     bool m_statsVars = false;       // main switch: --stats-vars
270     bool m_threadsCoarsen = true;   // main switch: --threads-coarsen
271     bool m_threadsDpiPure = true;   // main switch: --threads-dpi all/pure
272     bool m_threadsDpiUnpure = false;  // main switch: --threads-dpi all
273     bool m_trace = false;           // main switch: --trace
274     bool m_traceCoverage = false;   // main switch: --trace-coverage
275     bool m_traceParams = true;      // main switch: --trace-params
276     bool m_traceStructs = false;    // main switch: --trace-structs
277     bool m_traceUnderscore = false; // main switch: --trace-underscore
278     bool m_underlineZero = false;   // main switch: --underline-zero; undocumented old Verilator 2
279     bool m_verilate = true;         // main swith: --verilate
280     bool m_vpi = false;             // main switch: --vpi
281     bool m_xInitialEdge = false;    // main switch: --x-initial-edge
282     bool m_xmlOnly = false;         // main switch: --xml-only
283 
284     int         m_buildJobs = 1;    // main switch: -j
285     int         m_convergeLimit = 100;  // main switch: --converge-limit
286     int         m_coverageMaxWidth = 256; // main switch: --coverage-max-width
287     int         m_dumpTree = 0;     // main switch: --dump-tree
288     int         m_expandLimit = 64;  // main switch: --expand-limit
289     int         m_gateStmts = 100;    // main switch: --gate-stmts
290     int         m_ifDepth = 0;      // main switch: --if-depth
291     int         m_inlineMult = 2000;   // main switch: --inline-mult
292     int         m_instrCountDpi = 200;   // main switch: --instr-count-dpi
293     VOptionBool m_makeDepend;  // main switch: -MMD
294     int         m_maxNumWidth = 65536;  // main switch: --max-num-width
295     int         m_moduleRecursion = 100;  // main switch: --module-recursion-depth
296     int         m_outputSplit = 20000;  // main switch: --output-split
297     int         m_outputSplitCFuncs = -1;  // main switch: --output-split-cfuncs
298     int         m_outputSplitCTrace = -1;  // main switch: --output-split-ctrace
299     int         m_pinsBv = 65;       // main switch: --pins-bv
300     int         m_reloopLimit = 40; // main switch: --reloop-limit
301     VOptionBool m_skipIdentical;  // main switch: --skip-identical
302     int         m_threads = 0;      // main switch: --threads (0 == --no-threads)
303     int         m_threadsMaxMTasks = 0;  // main switch: --threads-max-mtasks
304     VTimescale  m_timeDefaultPrec;  // main switch: --timescale
305     VTimescale  m_timeDefaultUnit;  // main switch: --timescale
306     VTimescale  m_timeOverridePrec;  // main switch: --timescale-override
307     VTimescale  m_timeOverrideUnit;  // main switch: --timescale-override
308     int         m_traceDepth = 0;   // main switch: --trace-depth
309     TraceFormat m_traceFormat;  // main switch: --trace or --trace-fst
310     int         m_traceMaxArray = 32;  // main switch: --trace-max-array
311     int         m_traceMaxWidth = 256; // main switch: --trace-max-width
312     int         m_traceThreads = 0; // main switch: --trace-threads
313     int         m_unrollCount = 64;  // main switch: --unroll-count
314     int         m_unrollStmts = 30000;  // main switch: --unroll-stmts
315 
316     int         m_compLimitBlocks = 0;  // compiler selection; number of nested blocks
317     int         m_compLimitMembers = 64;  // compiler selection; number of members in struct before make anon array
318     int         m_compLimitParens = 0;  // compiler selection; number of nested parens
319 
320     string      m_bin;          // main switch: --bin {binary}
321     string      m_exeName;      // main switch: -o {name}
322     string      m_flags;        // main switch: -f {name}
323     string      m_l2Name;       // main switch: --l2name; "" for top-module's name
324     string      m_libCreate;    // main switch: --lib-create {lib_name}
325     string      m_makeDir;      // main switch: -Mdir
326     string      m_modPrefix;    // main switch: --mod-prefix
327     string      m_pipeFilter;   // main switch: --pipe-filter
328     string      m_prefix;       // main switch: --prefix
329     string      m_protectKey;   // main switch: --protect-key
330     string      m_topModule;    // main switch: --top-module
331     string      m_unusedRegexp; // main switch: --unused-regexp
332     string      m_waiverOutput;  // main switch: --waiver-output {filename}
333     string      m_xAssign;      // main switch: --x-assign
334     string      m_xInitial;     // main switch: --x-initial
335     string      m_xmlOutput;    // main switch: --xml-output
336 
337     // Language is now held in FileLine, on a per-node basis. However we still
338     // have a concept of the default language at a global level.
339     V3LangCode  m_defaultLanguage;      // main switch: --language
340 
341     // MEMBERS (optimizations)
342     //                          // main switch: -Op: --public
343     bool        m_oAcycSimp;    // main switch: -Oy: acyclic pre-optimizations
344     bool        m_oAssemble;    // main switch: -Om: assign assemble
345     bool        m_oCase;        // main switch: -Oe: case tree conversion
346     bool        m_oCombine;     // main switch: -Ob: common icode packing
347     bool        m_oConst;       // main switch: -Oc: constant folding
348     bool        m_oConstBitOpTree;  // main switch: -Oo: constant bit op tree
349     bool        m_oDedupe;      // main switch: -Od: logic deduplication
350     bool        m_oExpand;      // main switch: -Ox: expansion of C macros
351     bool        m_oGate;        // main switch: -Og: gate wire elimination
352     bool        m_oInline;      // main switch: -Oi: module inlining
353     bool        m_oLife;        // main switch: -Ol: variable lifetime
354     bool        m_oLifePost;    // main switch: -Ot: delayed assignment elimination
355     bool        m_oLocalize;    // main switch: -Oz: convert temps to local variables
356     bool        m_oMergeCond;   // main switch: -Ob: merge conditionals
357     bool        m_oReloop;      // main switch: -Ov: reform loops
358     bool        m_oReorder;     // main switch: -Or: reorder assignments in blocks
359     bool        m_oSplit;       // main switch: -Os: always assignment splitting
360     bool        m_oSubst;       // main switch: -Ou: substitute expression temp values
361     bool        m_oSubstConst;  // main switch: -Ok: final constant substitution
362     bool        m_oTable;       // main switch: -Oa: lookup table creation
363     // clang-format on
364 
365     bool m_available = false;  // Set to true at the end of option parsing
366 
367 private:
368     // METHODS
369     void addArg(const string& arg);
370     void addDefine(const string& defline, bool allowPlus);
371     void addFuture(const string& flag);
372     void addIncDirUser(const string& incdir);  // User requested
373     void addIncDirFallback(const string& incdir);  // Low priority if not found otherwise
374     void addParameter(const string& paramline, bool allowPlus);
375     void addLangExt(const string& langext, const V3LangCode& lc);
376     void addLibExtV(const string& libext);
377     void optimize(int level);
378     void showVersion(bool verbose);
coverage(bool flag)379     void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; }
380     static bool suffixed(const string& sw, const char* arg);
381     static string parseFileArg(const string& optdir, const string& relfilename);
382     string filePathCheckOneDir(const string& modname, const string& dirname);
383     static int stripOptionsForChildRun(const string& opt, bool forTop);
384 
385     // CONSTRUCTORS
386     VL_UNCOPYABLE(V3Options);
387 
388 public:
389     V3Options();
390     ~V3Options();
391     void setDebugMode(int level);
392     void setDebugSrcLevel(const string& srcfile, int level);
393     int debugSrcLevel(const string& srcfile_path, int default_level = V3Error::debugDefault());
394     void setDumpTreeLevel(const string& srcfile, int level);
395     int dumpTreeLevel(const string& srcfile_path);
396 
397     // METHODS
398     void addCppFile(const string& filename);
399     void addCFlags(const string& filename);
400     void addLdLibs(const string& filename);
401     void addMakeFlags(const string& filename);
402     void addLibraryFile(const string& filename);
403     void addClocker(const string& signame);
404     void addNoClocker(const string& signame);
405     void addVFile(const string& filename);
406     void addForceInc(const string& filename);
407     void notify();
available()408     bool available() const { return m_available; }
409 
410     // ACCESSORS (options)
preprocOnly()411     bool preprocOnly() const { return m_preprocOnly; }
makePhony()412     bool makePhony() const { return m_makePhony; }
preprocNoLine()413     bool preprocNoLine() const { return m_preprocNoLine; }
underlineZero()414     bool underlineZero() const { return m_underlineZero; }
bin()415     string bin() const { return m_bin; }
flags()416     string flags() const { return m_flags; }
systemC()417     bool systemC() const { return m_systemC; }
savable()418     bool savable() const { return m_savable; }
stats()419     bool stats() const { return m_stats; }
statsVars()420     bool statsVars() const { return m_statsVars; }
structsPacked()421     bool structsPacked() const { return m_structsPacked; }
assertOn()422     bool assertOn() const { return m_assert; }  // assertOn as __FILE__ may be defined
autoflush()423     bool autoflush() const { return m_autoflush; }
bboxSys()424     bool bboxSys() const { return m_bboxSys; }
bboxUnsup()425     bool bboxUnsup() const { return m_bboxUnsup; }
build()426     bool build() const { return m_build; }
cdc()427     bool cdc() const { return m_cdc; }
cmake()428     bool cmake() const { return m_cmake; }
context()429     bool context() const { return m_context; }
coverage()430     bool coverage() const { return m_coverageLine || m_coverageToggle || m_coverageUser; }
coverageLine()431     bool coverageLine() const { return m_coverageLine; }
coverageToggle()432     bool coverageToggle() const { return m_coverageToggle; }
coverageUnderscore()433     bool coverageUnderscore() const { return m_coverageUnderscore; }
coverageUser()434     bool coverageUser() const { return m_coverageUser; }
debugCheck()435     bool debugCheck() const { return m_debugCheck; }
debugCollision()436     bool debugCollision() const { return m_debugCollision; }
debugEmitV()437     bool debugEmitV() const { return m_debugEmitV; }
debugExitParse()438     bool debugExitParse() const { return m_debugExitParse; }
debugExitUvm()439     bool debugExitUvm() const { return m_debugExitUvm; }
debugLeak()440     bool debugLeak() const { return m_debugLeak; }
debugNondeterminism()441     bool debugNondeterminism() const { return m_debugNondeterminism; }
debugPartition()442     bool debugPartition() const { return m_debugPartition; }
debugProtect()443     bool debugProtect() const { return m_debugProtect; }
debugSelfTest()444     bool debugSelfTest() const { return m_debugSelfTest; }
decoration()445     bool decoration() const { return m_decoration; }
dpiHdrOnly()446     bool dpiHdrOnly() const { return m_dpiHdrOnly; }
dumpDefines()447     bool dumpDefines() const { return m_dumpDefines; }
exe()448     bool exe() const { return m_exe; }
flatten()449     bool flatten() const { return m_flatten; }
gmake()450     bool gmake() const { return m_gmake; }
threadsDpiPure()451     bool threadsDpiPure() const { return m_threadsDpiPure; }
threadsDpiUnpure()452     bool threadsDpiUnpure() const { return m_threadsDpiUnpure; }
threadsCoarsen()453     bool threadsCoarsen() const { return m_threadsCoarsen; }
trace()454     bool trace() const { return m_trace; }
traceCoverage()455     bool traceCoverage() const { return m_traceCoverage; }
traceParams()456     bool traceParams() const { return m_traceParams; }
traceStructs()457     bool traceStructs() const { return m_traceStructs; }
traceUnderscore()458     bool traceUnderscore() const { return m_traceUnderscore; }
main()459     bool main() const { return m_main; }
mergeConstPool()460     bool mergeConstPool() const { return m_mergeConstPool; }
orderClockDly()461     bool orderClockDly() const { return m_orderClockDly; }
outFormatOk()462     bool outFormatOk() const { return m_outFormatOk; }
keepTempFiles()463     bool keepTempFiles() const { return (V3Error::debugDefault() != 0); }
pedantic()464     bool pedantic() const { return m_pedantic; }
pinsScUint()465     bool pinsScUint() const { return m_pinsScUint; }
pinsScBigUint()466     bool pinsScBigUint() const { return m_pinsScBigUint; }
pinsUint8()467     bool pinsUint8() const { return m_pinsUint8; }
ppComments()468     bool ppComments() const { return m_ppComments; }
profC()469     bool profC() const { return m_profC; }
profCFuncs()470     bool profCFuncs() const { return m_profCFuncs; }
profThreads()471     bool profThreads() const { return m_profThreads; }
protectIds()472     bool protectIds() const { return m_protectIds; }
allPublic()473     bool allPublic() const { return m_public; }
publicFlatRW()474     bool publicFlatRW() const { return m_publicFlatRW; }
lintOnly()475     bool lintOnly() const { return m_lintOnly; }
ignc()476     bool ignc() const { return m_ignc; }
quietExit()477     bool quietExit() const { return m_quietExit; }
reportUnoptflat()478     bool reportUnoptflat() const { return m_reportUnoptflat; }
verilate()479     bool verilate() const { return m_verilate; }
vpi()480     bool vpi() const { return m_vpi; }
xInitialEdge()481     bool xInitialEdge() const { return m_xInitialEdge; }
xmlOnly()482     bool xmlOnly() const { return m_xmlOnly; }
483 
buildJobs()484     int buildJobs() const { return m_buildJobs; }
convergeLimit()485     int convergeLimit() const { return m_convergeLimit; }
coverageMaxWidth()486     int coverageMaxWidth() const { return m_coverageMaxWidth; }
dumpTree()487     int dumpTree() const { return m_dumpTree; }
dumpTreeAddrids()488     bool dumpTreeAddrids() const { return m_dumpTreeAddrids; }
expandLimit()489     int expandLimit() const { return m_expandLimit; }
gateStmts()490     int gateStmts() const { return m_gateStmts; }
ifDepth()491     int ifDepth() const { return m_ifDepth; }
inlineMult()492     int inlineMult() const { return m_inlineMult; }
instrCountDpi()493     int instrCountDpi() const { return m_instrCountDpi; }
makeDepend()494     VOptionBool makeDepend() const { return m_makeDepend; }
maxNumWidth()495     int maxNumWidth() const { return m_maxNumWidth; }
moduleRecursionDepth()496     int moduleRecursionDepth() const { return m_moduleRecursion; }
outputSplit()497     int outputSplit() const { return m_outputSplit; }
outputSplitCFuncs()498     int outputSplitCFuncs() const { return m_outputSplitCFuncs; }
outputSplitCTrace()499     int outputSplitCTrace() const { return m_outputSplitCTrace; }
pinsBv()500     int pinsBv() const { return m_pinsBv; }
reloopLimit()501     int reloopLimit() const { return m_reloopLimit; }
skipIdentical()502     VOptionBool skipIdentical() const { return m_skipIdentical; }
threads()503     int threads() const { return m_threads; }
threadsMaxMTasks()504     int threadsMaxMTasks() const { return m_threadsMaxMTasks; }
mtasks()505     bool mtasks() const { return (m_threads > 1); }
timeDefaultPrec()506     VTimescale timeDefaultPrec() const { return m_timeDefaultPrec; }
timeDefaultUnit()507     VTimescale timeDefaultUnit() const { return m_timeDefaultUnit; }
timeOverridePrec()508     VTimescale timeOverridePrec() const { return m_timeOverridePrec; }
timeOverrideUnit()509     VTimescale timeOverrideUnit() const { return m_timeOverrideUnit; }
510     VTimescale timeComputePrec(const VTimescale& flag) const;
511     VTimescale timeComputeUnit(const VTimescale& flag) const;
traceDepth()512     int traceDepth() const { return m_traceDepth; }
traceFormat()513     TraceFormat traceFormat() const { return m_traceFormat; }
traceMaxArray()514     int traceMaxArray() const { return m_traceMaxArray; }
traceMaxWidth()515     int traceMaxWidth() const { return m_traceMaxWidth; }
traceThreads()516     int traceThreads() const { return m_traceThreads; }
trueTraceThreads()517     bool trueTraceThreads() const {
518         return traceThreads() == 0 ? 0 : traceThreads() - traceFormat().fst();
519     }
unrollCount()520     int unrollCount() const { return m_unrollCount; }
unrollStmts()521     int unrollStmts() const { return m_unrollStmts; }
522 
compLimitBlocks()523     int compLimitBlocks() const { return m_compLimitBlocks; }
compLimitMembers()524     int compLimitMembers() const { return m_compLimitMembers; }
compLimitParens()525     int compLimitParens() const { return m_compLimitParens; }
526 
exeName()527     string exeName() const { return m_exeName != "" ? m_exeName : prefix(); }
l2Name()528     string l2Name() const { return m_l2Name; }
libCreate()529     string libCreate() const { return m_libCreate; }
libCreateName(bool shared)530     string libCreateName(bool shared) {
531         string libName = "lib" + libCreate();
532         if (shared) {
533             libName += ".so";
534         } else {
535             libName += ".a";
536         }
537         return libName;
538     }
makeDir()539     string makeDir() const { return m_makeDir; }
modPrefix()540     string modPrefix() const { return m_modPrefix; }
pipeFilter()541     string pipeFilter() const { return m_pipeFilter; }
prefix()542     string prefix() const { return m_prefix; }
543     // Not just called protectKey() to avoid bugs of not using protectKeyDefaulted()
protectKeyProvided()544     bool protectKeyProvided() const { return !m_protectKey.empty(); }
545     string protectKeyDefaulted();  // Set default key if not set by user
topModule()546     string topModule() const { return m_topModule; }
unusedRegexp()547     string unusedRegexp() const { return m_unusedRegexp; }
waiverOutput()548     string waiverOutput() const { return m_waiverOutput; }
isWaiverOutput()549     bool isWaiverOutput() const { return !m_waiverOutput.empty(); }
xAssign()550     string xAssign() const { return m_xAssign; }
xInitial()551     string xInitial() const { return m_xInitial; }
xmlOutput()552     string xmlOutput() const { return m_xmlOutput; }
553 
cppFiles()554     const V3StringSet& cppFiles() const { return m_cppFiles; }
cFlags()555     const V3StringList& cFlags() const { return m_cFlags; }
ldLibs()556     const V3StringList& ldLibs() const { return m_ldLibs; }
makeFlags()557     const V3StringList& makeFlags() const { return m_makeFlags; }
libraryFiles()558     const V3StringSet& libraryFiles() const { return m_libraryFiles; }
vFiles()559     const V3StringList& vFiles() const { return m_vFiles; }
forceIncs()560     const V3StringList& forceIncs() const { return m_forceIncs; }
561 
562     bool hasParameter(const string& name);
563     string parameter(const string& name);
564     void checkParameters();
565 
566     bool isFuture(const string& flag) const;
567     bool isLibraryFile(const string& filename) const;
568     bool isClocker(const string& signame) const;
569     bool isNoClocker(const string& signame) const;
570 
571     // ACCESSORS (optimization options)
oAcycSimp()572     bool oAcycSimp() const { return m_oAcycSimp; }
oAssemble()573     bool oAssemble() const { return m_oAssemble; }
oCase()574     bool oCase() const { return m_oCase; }
oCombine()575     bool oCombine() const { return m_oCombine; }
oConst()576     bool oConst() const { return m_oConst; }
oConstBitOpTree()577     bool oConstBitOpTree() const { return m_oConstBitOpTree; }
oDedupe()578     bool oDedupe() const { return m_oDedupe; }
oExpand()579     bool oExpand() const { return m_oExpand; }
oGate()580     bool oGate() const { return m_oGate; }
oInline()581     bool oInline() const { return m_oInline; }
oLife()582     bool oLife() const { return m_oLife; }
oLifePost()583     bool oLifePost() const { return m_oLifePost; }
oLocalize()584     bool oLocalize() const { return m_oLocalize; }
oMergeCond()585     bool oMergeCond() const { return m_oMergeCond; }
oReloop()586     bool oReloop() const { return m_oReloop; }
oReorder()587     bool oReorder() const { return m_oReorder; }
oSplit()588     bool oSplit() const { return m_oSplit; }
oSubst()589     bool oSubst() const { return m_oSubst; }
oSubstConst()590     bool oSubstConst() const { return m_oSubstConst; }
oTable()591     bool oTable() const { return m_oTable; }
592 
traceClassBase()593     string traceClassBase() const { return m_traceFormat.classBase(); }
traceClassLang()594     string traceClassLang() const { return m_traceFormat.classBase() + (systemC() ? "Sc" : "C"); }
traceSourceBase()595     string traceSourceBase() const { return m_traceFormat.sourceName(); }
traceSourceLang()596     string traceSourceLang() const {
597         return m_traceFormat.sourceName() + (systemC() ? "_sc" : "_c");
598     }
599 
hierarchical()600     bool hierarchical() const { return m_hierarchical; }
hierChild()601     bool hierChild() const { return m_hierChild; }
hierTop()602     bool hierTop() const { return !m_hierChild && !m_hierBlocks.empty(); }
hierBlocks()603     const V3HierBlockOptSet& hierBlocks() const { return m_hierBlocks; }
604     // Directory to save .tree, .dot, .dat, .vpp for hierarchical block top
605     // Returns makeDir() unless top module of hierarchical verilation.
hierTopDataDir()606     string hierTopDataDir() const {
607         return hierTop() ? (makeDir() + '/' + prefix() + "__hier.dir") : makeDir();
608     }
609 
610     // METHODS (from main)
611     static string version();
612     static string argString(int argc, char** argv);  ///< Return list of arguments as simple string
613     string allArgsString() const;  ///< Return all passed arguments as simple string
614     // Return options for child hierarchical blocks when forTop==false, otherwise returns args for
615     // the top module.
616     string allArgsStringForHierBlock(bool forTop) const;
bin(const string & flag)617     void bin(const string& flag) { m_bin = flag; }
618     void parseOpts(FileLine* fl, int argc, char** argv);
619     void parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv);
620     void parseOptsFile(FileLine* fl, const string& filename, bool rel);
621 
622     // METHODS (environment)
623     // Most of these may be built into the executable with --enable-defenv,
624     // see the README.  If adding new variables, also see src/Makefile_obj.in
625     // Also add to V3Options::showVersion()
626     static string getenvBuiltins(const string& var);
627     static string getenvMAKE();
628     static string getenvPERL();
629     static string getenvSYSTEMC();
630     static string getenvSYSTEMC_ARCH();
631     static string getenvSYSTEMC_INCLUDE();
632     static string getenvSYSTEMC_LIBDIR();
633     static string getenvVERILATOR_ROOT();
634     static bool systemCSystemWide();
635     static bool systemCFound();  // SystemC installed, or environment points to it
636 
637     // METHODS (file utilities using these options)
638     string fileExists(const string& filename);
639     string filePath(FileLine* fl, const string& modname, const string& lastpath,
640                     const string& errmsg);
641     void filePathLookedMsg(FileLine* fl, const string& modname);
642     V3LangCode fileLanguage(const string& filename);
643     static bool fileStatNormal(const string& filename);
644     static void fileNfsFlush(const string& filename);
645 
646     // METHODS (other OS)
647     static void throwSigsegv();
648 };
649 
650 //######################################################################
651 
652 #endif  // guard
653