mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a0babb47d | ||
|
|
b085b34a69 | ||
|
|
abc738b6f1 | ||
|
|
d37cc5a160 | ||
|
|
1a0de753e9 | ||
|
|
b798f4fe71 | ||
|
|
0c0a588b55 | ||
|
|
faa5ef193b | ||
|
|
4c7b5005a6 | ||
|
|
9cf61cef9d | ||
|
|
28c61b548b | ||
|
|
0b24e62d43 | ||
|
|
b19dd49fc9 | ||
|
|
91b1e66933 | ||
|
|
eea2712eac | ||
|
|
b19a4b6956 | ||
|
|
a01c995a53 | ||
|
|
59b491e3a8 | ||
|
|
c44febe85e | ||
|
|
15b3c9797b | ||
|
|
584cfa4d4a | ||
|
|
b92f57eacb | ||
|
|
aeeaaa53d4 | ||
|
|
a532fce0e4 | ||
|
|
510fe8e634 | ||
|
|
556d90a1b4 | ||
|
|
4dde1ede0e | ||
|
|
1c833f8a9a | ||
|
|
6a36bd8514 | ||
|
|
12cb819adc |
@@ -3,6 +3,36 @@ Revision history for Verilator
|
|||||||
The contributors that suggested a given feature are shown in []. [by ...]
|
The contributors that suggested a given feature are shown in []. [by ...]
|
||||||
indicates the contributor was also the author of the fix; Thanks!
|
indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
|
* Verilator 3.714 2009/09/18
|
||||||
|
|
||||||
|
** Add --bbox-sys option to blackbox $system calls.
|
||||||
|
|
||||||
|
** Support generate for var++, var--, ++var, --var.
|
||||||
|
|
||||||
|
*** Improved warning when "do" used as identifier.
|
||||||
|
|
||||||
|
**** Don't require SYSTEMPERL_INCLUDE if SYSTEMPERL/src exists. [Gary Thomas]
|
||||||
|
|
||||||
|
**** Fix deep defines causing flex scanner overflows. [Brad Dobbie]
|
||||||
|
|
||||||
|
**** Fix preprocessing commas in deep parameterized macros. [Brad Dobbie]
|
||||||
|
|
||||||
|
**** Fix tracing escaped dotted identifiers, bug107.
|
||||||
|
|
||||||
|
**** Fix $display with uppercase %M.
|
||||||
|
|
||||||
|
**** Fix --error-limit option being ignored.
|
||||||
|
|
||||||
|
* Verilator 3.713 2009/08/04
|
||||||
|
|
||||||
|
** Support constant function calls for parameters. [many!]
|
||||||
|
|
||||||
|
*** Support SystemVerilog "logic", bug101. [by Alex Duller]
|
||||||
|
|
||||||
|
*** Name SYMRSVDWORD error, and allow disabling it, bug103. [Gary Thomas]
|
||||||
|
|
||||||
|
**** Fix escaped preprocessor identifiers, bug106. [Nimrod Gileadi]
|
||||||
|
|
||||||
* Verilator 3.712 2009/07/14
|
* Verilator 3.712 2009/07/14
|
||||||
|
|
||||||
** Patching SystemC is no longer required to trace sc_bvs.
|
** Patching SystemC is no longer required to trace sc_bvs.
|
||||||
|
|||||||
+82
-11
@@ -179,6 +179,7 @@ descriptions in the next sections for more information.
|
|||||||
|
|
||||||
--assert Enable all assertions
|
--assert Enable all assertions
|
||||||
--autoflush Flush streams after all $displays
|
--autoflush Flush streams after all $displays
|
||||||
|
--bbox-sys Blackbox unknown $system calls
|
||||||
--bin <filename> Override Verilator binary
|
--bin <filename> Override Verilator binary
|
||||||
--cc Create C++ output
|
--cc Create C++ output
|
||||||
--compiler <compiler-name> Tune for specified C++ compiler
|
--compiler <compiler-name> Tune for specified C++ compiler
|
||||||
@@ -193,7 +194,7 @@ descriptions in the next sections for more information.
|
|||||||
--debugi-<srcfile> <level> Enable debugging a source file at a level
|
--debugi-<srcfile> <level> Enable debugging a source file at a level
|
||||||
--dump-tree Enable dumping .tree files
|
--dump-tree Enable dumping .tree files
|
||||||
-E Preprocess, but do not compile
|
-E Preprocess, but do not compile
|
||||||
--error-limit <value> Abort after this number of errors
|
--error-limit <value> Abort after this number of errors
|
||||||
--exe Link to create executable
|
--exe Link to create executable
|
||||||
-f <file> Parse options from a file
|
-f <file> Parse options from a file
|
||||||
--help Display this help.
|
--help Display this help.
|
||||||
@@ -228,11 +229,14 @@ descriptions in the next sections for more information.
|
|||||||
--trace-depth <levels> Depth of tracing
|
--trace-depth <levels> Depth of tracing
|
||||||
-U<var> Undefine preprocessor define
|
-U<var> Undefine preprocessor define
|
||||||
--underline-zero Zero signals with leading _'s
|
--underline-zero Zero signals with leading _'s
|
||||||
-V Verbose version and config
|
--unroll-count <loops> Tune maximum loop iterations
|
||||||
|
--unroll-stmts <stmts> Tune maximum loop body size
|
||||||
|
-V Verbose version and config
|
||||||
-v <filename> Verilog library
|
-v <filename> Verilog library
|
||||||
-Werror-<message> Convert warning to error
|
-Werror-<message> Convert warning to error
|
||||||
-Wfuture-<message> Disable unknown message warnings
|
-Wfuture-<message> Disable unknown message warnings
|
||||||
-Wno-<message> Disable warning
|
-Wno-<message> Disable warning
|
||||||
|
-Wno-lint Disable all lint warnings
|
||||||
-x-assign <mode> Initially assign Xs to this value
|
-x-assign <mode> Initially assign Xs to this value
|
||||||
-y <dir> Directory to search for modules
|
-y <dir> Directory to search for modules
|
||||||
|
|
||||||
@@ -269,6 +273,14 @@ After every $display or $fdisplay, flush the output stream. This insures
|
|||||||
that messages will appear immediately but may reduce performance. Defaults
|
that messages will appear immediately but may reduce performance. Defaults
|
||||||
off, which will buffer output as provided by the normal C stdio calls.
|
off, which will buffer output as provided by the normal C stdio calls.
|
||||||
|
|
||||||
|
=item --bbox-sys
|
||||||
|
|
||||||
|
Black box any unknown $system task or function calls. System tasks will be
|
||||||
|
simply NOPed, and system functions will be replaced by unsized zero.
|
||||||
|
Arguments to such functions will be parsed, but not otherwise checked.
|
||||||
|
This prevents errors when linting in the presence of company specific PLI
|
||||||
|
calls.
|
||||||
|
|
||||||
=item --bin I<filename>
|
=item --bin I<filename>
|
||||||
|
|
||||||
Rarely needed. Override the default filename for Verilator itself. When a
|
Rarely needed. Override the default filename for Verilator itself. When a
|
||||||
@@ -441,6 +453,9 @@ appropriate `begin_keywords.
|
|||||||
|
|
||||||
Check the files for lint violations only, do not create any other output.
|
Check the files for lint violations only, do not create any other output.
|
||||||
|
|
||||||
|
If the design is not to be completely Verilated see also the --bbox-sys
|
||||||
|
option.
|
||||||
|
|
||||||
=item --MMD
|
=item --MMD
|
||||||
|
|
||||||
Enable creation of .d dependency files, used for make dependency detection,
|
Enable creation of .d dependency files, used for make dependency detection,
|
||||||
@@ -610,6 +625,16 @@ zero, as was done in Verilator 2. Default is for all signals including
|
|||||||
those with underlines being randomized. This option may be depreciated in
|
those with underlines being randomized. This option may be depreciated in
|
||||||
future versions.
|
future versions.
|
||||||
|
|
||||||
|
=item --unroll-count I<loops>
|
||||||
|
|
||||||
|
Rarely needed. Specifies the maximum number of loop iterations that may be
|
||||||
|
unrolled. See also BLKLOOPINIT warning.
|
||||||
|
|
||||||
|
=item --unroll-stmts I<statements>
|
||||||
|
|
||||||
|
Rarely needed. Specifies the maximum number of statements in a loop for
|
||||||
|
that loop to be unrolled. See also BLKLOOPINIT warning.
|
||||||
|
|
||||||
=item -Werror-I<message>
|
=item -Werror-I<message>
|
||||||
|
|
||||||
Convert the specified warning message into a error message. This is
|
Convert the specified warning message into a error message. This is
|
||||||
@@ -1144,8 +1169,8 @@ including function call-like preprocessor defines.
|
|||||||
|
|
||||||
Verilator supports ==? and !=? operators, $bits, $countones, $error,
|
Verilator supports ==? and !=? operators, $bits, $countones, $error,
|
||||||
$fatal, $info, $isunknown, $onehot, $onehot0, $warning, always_comb,
|
$fatal, $info, $isunknown, $onehot, $onehot0, $warning, always_comb,
|
||||||
always_ff, always_latch, do-while, final, priority case/if, and unique
|
always_ff, always_latch, do-while, final, logic, priority case/if, and
|
||||||
case/if.
|
unique case/if.
|
||||||
|
|
||||||
It also supports .name and .* interconnection.
|
It also supports .name and .* interconnection.
|
||||||
|
|
||||||
@@ -1816,7 +1841,8 @@ it's a bit slower than a non-delayed assignment.) Here's an example
|
|||||||
|
|
||||||
This message is only seen on large or complicated loops because Verilator
|
This message is only seen on large or complicated loops because Verilator
|
||||||
generally unrolls small loops. You may want to try increasing
|
generally unrolls small loops. You may want to try increasing
|
||||||
--unroll-count which will raise the small loop bar to avoid this error.
|
--unroll-count (and occasionally --unroll-stmts) which will raise the small
|
||||||
|
loop bar to avoid this error.
|
||||||
|
|
||||||
=item CASEINCOMPLETE
|
=item CASEINCOMPLETE
|
||||||
|
|
||||||
@@ -1965,6 +1991,13 @@ example:
|
|||||||
Ignoring this warning may make Verilator simulations differ from other
|
Ignoring this warning may make Verilator simulations differ from other
|
||||||
simulators.
|
simulators.
|
||||||
|
|
||||||
|
=item SYMRSVDWORD
|
||||||
|
|
||||||
|
Error that a symbol matches a C++ reserved word and using this as a symbol
|
||||||
|
name would result in odd C compiler errors. You may disable this error
|
||||||
|
message as you would disable warnings, but the symbol will be renamed by
|
||||||
|
Verilator to avoid the conflict.
|
||||||
|
|
||||||
=item TASKNSVAR
|
=item TASKNSVAR
|
||||||
|
|
||||||
Error when a call to a task or function has a output from that task tied to
|
Error when a call to a task or function has a output from that task tied to
|
||||||
@@ -2241,26 +2274,64 @@ untarred directory.
|
|||||||
In your top level C code, call Verilated::traceEverOn(true). Then create a
|
In your top level C code, call Verilated::traceEverOn(true). Then create a
|
||||||
SpTraceVcdC object, and in your main loop call "trace_object->dump(time)"
|
SpTraceVcdC object, and in your main loop call "trace_object->dump(time)"
|
||||||
every time step, and finally call "trace_object->close()". For an example,
|
every time step, and finally call "trace_object->close()". For an example,
|
||||||
see the call to SpTraceVcdC in the test_c/sim_main.cpp file of the
|
see below and the test_c/sim_main.cpp file of the distribution.
|
||||||
distribution.
|
|
||||||
|
|
||||||
You also need to compile SpTraceVcdC.cpp and add it to your link. This is
|
You also need to compile SpTraceVcdC.cpp and add it to your link. This is
|
||||||
done for you if using the Verilator --exe flag.
|
done for you if using the Verilator --exe flag.
|
||||||
|
|
||||||
|
Note you can also call ->trace on multiple Verilated objects with the same
|
||||||
|
trace file if you want all data to land in the same output file.
|
||||||
|
|
||||||
|
#include "SpTraceVcdC.cpp"
|
||||||
|
...
|
||||||
|
int main(int argc, char **argv, char **env) {
|
||||||
|
...
|
||||||
|
Verilated::traceEverOn(true);
|
||||||
|
SpTraceVcdCFile* tfp = new SpTraceVcdCFile;
|
||||||
|
topp->trace (tfp, 99);
|
||||||
|
tfp->open ("obj_dir/t_trace_ena_cc/simx.vcd");
|
||||||
|
...
|
||||||
|
while (sc_time_stamp() < sim_time && !Verilated::gotFinish()) {
|
||||||
|
main_time += #;
|
||||||
|
tfp->dump (main_time);
|
||||||
|
}
|
||||||
|
tfp->close();
|
||||||
|
}
|
||||||
|
|
||||||
=item How do I generate waveforms (traces) in SystemC/SystemPerl?
|
=item How do I generate waveforms (traces) in SystemC/SystemPerl?
|
||||||
|
|
||||||
Add the --trace switch to Verilator, and make sure the SystemPerl package
|
Add the --trace switch to Verilator, and make sure the SystemPerl package
|
||||||
is installed.
|
is installed.
|
||||||
|
|
||||||
In your top level C sc_main code, call Verilated::traceEverOn(true). Then
|
In your top level C sc_main code, include SpTraceVcd.h. Then call
|
||||||
create a SpTraceFile object as you would create a normal SystemC trace
|
Verilated::traceEverOn(true). Then create a SpTraceFile object as you
|
||||||
file. For an example, see the call to SpTraceFile in the
|
would create a normal SystemC trace file. For an example, see the call to
|
||||||
test_sp/sc_main.cpp file of the distribution.
|
SpTraceFile in the test_sp/sc_main.cpp file of the distribution, and below.
|
||||||
|
|
||||||
Alternatively you may use the C++ trace mechanism described in the previous
|
Alternatively you may use the C++ trace mechanism described in the previous
|
||||||
question, however the timescale and timeprecision will not inherited from
|
question, however the timescale and timeprecision will not inherited from
|
||||||
your SystemC settings.
|
your SystemC settings.
|
||||||
|
|
||||||
|
You'll then need to compile in Sp.cpp, which includes SpTraceVcd.cpp among
|
||||||
|
other things.
|
||||||
|
|
||||||
|
Note you can also call ->trace on multiple Verilated objects with the same
|
||||||
|
trace file if you want all data to land in the same output file.
|
||||||
|
|
||||||
|
#include "SpTraceVcd.cpp"
|
||||||
|
...
|
||||||
|
int main(int argc, char **argv, char **env) {
|
||||||
|
...
|
||||||
|
Verilated::traceEverOn(true);
|
||||||
|
SpTraceFile* tfp = new SpTraceFile;
|
||||||
|
topp->trace (tfp, 99);
|
||||||
|
tfp->open ("obj_dir/t_trace_ena_cc/simx.vcd");
|
||||||
|
...
|
||||||
|
sc_start(1);
|
||||||
|
...
|
||||||
|
tfp->close();
|
||||||
|
}
|
||||||
|
|
||||||
=item How do I view waveforms (traces)?
|
=item How do I view waveforms (traces)?
|
||||||
|
|
||||||
Verilator makes standard VCD (Value Change Dump) files. They are viewable
|
Verilator makes standard VCD (Value Change Dump) files. They are viewable
|
||||||
|
|||||||
+3
-1
@@ -65,7 +65,9 @@ private:
|
|||||||
AstNode* timesp = nodep->exprsp(); if (timesp) timesp->unlinkFrBack();
|
AstNode* timesp = nodep->exprsp(); if (timesp) timesp->unlinkFrBack();
|
||||||
timesp = timesp->addNext(new AstTime(nodep->fileline()));
|
timesp = timesp->addNext(new AstTime(nodep->fileline()));
|
||||||
nodep->exprsp(timesp);
|
nodep->exprsp(timesp);
|
||||||
if (!nodep->scopeNamep() && nodep->name().find("%m") != string::npos) {
|
if (!nodep->scopeNamep()
|
||||||
|
&& (nodep->name().find("%m") != string::npos
|
||||||
|
|| nodep->name().find("%M") != string::npos)) {
|
||||||
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-51
@@ -41,10 +41,10 @@ public:
|
|||||||
// enum en {...};
|
// enum en {...};
|
||||||
// const char* ascii() const {...};
|
// const char* ascii() const {...};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstType () {};
|
inline AstType () {}
|
||||||
inline AstType (en _e) : m_e(_e) {};
|
inline AstType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstType lhs, AstType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstType lhs, AstType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstType lhs, AstType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstType lhs, AstType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -64,10 +64,10 @@ public:
|
|||||||
PUBLIC_TASK
|
PUBLIC_TASK
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstPragmaType () {};
|
inline AstPragmaType () {}
|
||||||
inline AstPragmaType (en _e) : m_e(_e) {};
|
inline AstPragmaType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstPragmaType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstPragmaType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstPragmaType lhs, AstPragmaType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstPragmaType lhs, AstPragmaType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstPragmaType lhs, AstPragmaType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstPragmaType lhs, AstPragmaType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -87,10 +87,10 @@ public:
|
|||||||
TRACE_CHANGE_SUB
|
TRACE_CHANGE_SUB
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstCFuncType () {};
|
inline AstCFuncType () {}
|
||||||
inline AstCFuncType (en _e) : m_e(_e) {};
|
inline AstCFuncType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstCFuncType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstCFuncType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
// METHODS
|
// METHODS
|
||||||
bool isTrace() const { return (m_e==TRACE_INIT || m_e==TRACE_INIT_SUB
|
bool isTrace() const { return (m_e==TRACE_INIT || m_e==TRACE_INIT_SUB
|
||||||
|| m_e==TRACE_FULL || m_e==TRACE_FULL_SUB
|
|| m_e==TRACE_FULL || m_e==TRACE_FULL_SUB
|
||||||
@@ -155,10 +155,10 @@ public:
|
|||||||
};
|
};
|
||||||
return names[m_e];
|
return names[m_e];
|
||||||
};
|
};
|
||||||
inline AstEdgeType () {};
|
inline AstEdgeType () {}
|
||||||
inline AstEdgeType (en _e) : m_e(_e) {};
|
inline AstEdgeType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstEdgeType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstEdgeType lhs, AstEdgeType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstEdgeType lhs, AstEdgeType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstEdgeType lhs, AstEdgeType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstEdgeType lhs, AstEdgeType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -188,10 +188,10 @@ public:
|
|||||||
};
|
};
|
||||||
return names[m_e];
|
return names[m_e];
|
||||||
};
|
};
|
||||||
inline AstAttrType () {};
|
inline AstAttrType () {}
|
||||||
inline AstAttrType (en _e) : m_e(_e) {};
|
inline AstAttrType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstAttrType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstAttrType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstAttrType lhs, AstAttrType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstAttrType lhs, AstAttrType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstAttrType lhs, AstAttrType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstAttrType lhs, AstAttrType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -223,17 +223,17 @@ public:
|
|||||||
XTEMP
|
XTEMP
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstVarType () {};
|
inline AstVarType () {}
|
||||||
inline AstVarType (en _e) : m_e(_e) {};
|
inline AstVarType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstVarType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstVarType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
const char* ascii() const {
|
const char* ascii() const {
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
"?","GPARAM","LPARAM","GENVAR",
|
"?","GPARAM","LPARAM","GENVAR",
|
||||||
"INTEGER","INPUT","OUTPUT","INOUT",
|
"INTEGER","INPUT","OUTPUT","INOUT",
|
||||||
"SUPPLY0","SUPPLY1","WIRE","IMPLICIT","REG","TRIWIRE","PORT",
|
"SUPPLY0","SUPPLY1","WIRE","IMPLICIT","REG","TRIWIRE","PORT",
|
||||||
"BLOCKTEMP","MODULETEMP","STMTTEMP","XTEMP"};
|
"BLOCKTEMP","MODULETEMP","STMTTEMP","XTEMP"};
|
||||||
return names[m_e];};
|
return names[m_e]; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstVarType lhs, AstVarType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstVarType lhs, AstVarType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstVarType lhs, AstVarType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstVarType lhs, AstVarType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -252,10 +252,10 @@ public:
|
|||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
// CONSTRUCTOR - note defaults to *UNKNOWN*
|
// CONSTRUCTOR - note defaults to *UNKNOWN*
|
||||||
inline AstBranchPred () : m_e(UNKNOWN) {};
|
inline AstBranchPred () : m_e(UNKNOWN) {}
|
||||||
inline AstBranchPred (en _e) : m_e(_e) {};
|
inline AstBranchPred (en _e) : m_e(_e) {}
|
||||||
explicit inline AstBranchPred (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstBranchPred (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
AstBranchPred invert() const {
|
AstBranchPred invert() const {
|
||||||
if (m_e==UNLIKELY) return LIKELY;
|
if (m_e==UNLIKELY) return LIKELY;
|
||||||
else if (m_e==LIKELY) return UNLIKELY;
|
else if (m_e==LIKELY) return UNLIKELY;
|
||||||
@@ -264,7 +264,7 @@ public:
|
|||||||
const char* ascii() const {
|
const char* ascii() const {
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
"","VL_LIKELY","VL_UNLIKELY"};
|
"","VL_LIKELY","VL_UNLIKELY"};
|
||||||
return names[m_e];};
|
return names[m_e]; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstBranchPred lhs, AstBranchPred rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstBranchPred lhs, AstBranchPred rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstBranchPred lhs, AstBranchPred::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstBranchPred lhs, AstBranchPred::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -281,10 +281,10 @@ public:
|
|||||||
CASEZ
|
CASEZ
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstCaseType () {};
|
inline AstCaseType () {}
|
||||||
inline AstCaseType (en _e) : m_e(_e) {};
|
inline AstCaseType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstCaseType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstCaseType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstCaseType lhs, AstCaseType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstCaseType lhs, AstCaseType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstCaseType lhs, AstCaseType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstCaseType lhs, AstCaseType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -303,16 +303,16 @@ public:
|
|||||||
FATAL
|
FATAL
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstDisplayType () {};
|
inline AstDisplayType () {}
|
||||||
inline AstDisplayType (en _e) : m_e(_e) {};
|
inline AstDisplayType (en _e) : m_e(_e) {}
|
||||||
explicit inline AstDisplayType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstDisplayType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
bool addNewline() const { return m_e!=WRITE; }
|
bool addNewline() const { return m_e!=WRITE; }
|
||||||
bool needScopeTracking() const { return m_e!=DISPLAY && m_e!=WRITE; }
|
bool needScopeTracking() const { return m_e!=DISPLAY && m_e!=WRITE; }
|
||||||
const char* ascii() const {
|
const char* ascii() const {
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
"display","write","info","error","warning","fatal"};
|
"display","write","info","error","warning","fatal"};
|
||||||
return names[m_e];};
|
return names[m_e]; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstDisplayType lhs, AstDisplayType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstDisplayType lhs, AstDisplayType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstDisplayType lhs, AstDisplayType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstDisplayType lhs, AstDisplayType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -331,14 +331,14 @@ public:
|
|||||||
_ENUM_END
|
_ENUM_END
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline AstParseRefExp() : m_e(NONE) {};
|
inline AstParseRefExp() : m_e(NONE) {}
|
||||||
inline AstParseRefExp (en _e) : m_e(_e) {};
|
inline AstParseRefExp (en _e) : m_e(_e) {}
|
||||||
explicit inline AstParseRefExp (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline AstParseRefExp (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
const char* ascii() const {
|
const char* ascii() const {
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
"","VAR_MEM","VAR_ANY","TASK","FUNC"};
|
"","VAR_MEM","VAR_ANY","TASK","FUNC"};
|
||||||
return names[m_e];};
|
return names[m_e]; }
|
||||||
};
|
};
|
||||||
inline bool operator== (AstParseRefExp lhs, AstParseRefExp rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (AstParseRefExp lhs, AstParseRefExp rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (AstParseRefExp lhs, AstParseRefExp::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (AstParseRefExp lhs, AstParseRefExp::en rhs) { return (lhs.m_e == rhs); }
|
||||||
@@ -520,9 +520,9 @@ public:
|
|||||||
uint32_t depth() const { return (m_both >> 24) & 255; }
|
uint32_t depth() const { return (m_both >> 24) & 255; }
|
||||||
uint32_t hshval() const { return m_both & M24; }
|
uint32_t hshval() const { return m_both & M24; }
|
||||||
// OPERATORS
|
// OPERATORS
|
||||||
inline bool operator== (const V3Hash& rh) const { return m_both==rh.m_both; };
|
inline bool operator== (const V3Hash& rh) const { return m_both==rh.m_both; }
|
||||||
inline bool operator!= (const V3Hash& rh) const { return m_both!=rh.m_both; };
|
inline bool operator!= (const V3Hash& rh) const { return m_both!=rh.m_both; }
|
||||||
inline bool operator< (const V3Hash& rh) const { return m_both<rh.m_both; };
|
inline bool operator< (const V3Hash& rh) const { return m_both<rh.m_both; }
|
||||||
// CREATORS
|
// CREATORS
|
||||||
class Illegal {}; // for creator type-overload selection
|
class Illegal {}; // for creator type-overload selection
|
||||||
class FullValue {}; // for creator type-overload selection
|
class FullValue {}; // for creator type-overload selection
|
||||||
@@ -669,6 +669,7 @@ public:
|
|||||||
|
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
virtual string name() const { return ""; }
|
virtual string name() const { return ""; }
|
||||||
|
virtual void name(const string& name) { this->v3fatalSrc("name() called on object without name() method"); }
|
||||||
virtual string verilogKwd() const { return ""; }
|
virtual string verilogKwd() const { return ""; }
|
||||||
string shortName() const; // Name with __PVT__ removed for concatenating scopes
|
string shortName() const; // Name with __PVT__ removed for concatenating scopes
|
||||||
static string dedotName(const string& namein); // Name with dots removed
|
static string dedotName(const string& namein); // Name with dots removed
|
||||||
@@ -980,7 +981,6 @@ struct AstNodeFor : public AstNodeStmt {
|
|||||||
AstNode* incsp() const { return op3p()->castNode(); } // op3= increment statements
|
AstNode* incsp() const { return op3p()->castNode(); } // op3= increment statements
|
||||||
AstNode* bodysp() const { return op4p()->castNode(); } // op4= body of loop
|
AstNode* bodysp() const { return op4p()->castNode(); } // op4= body of loop
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
|
||||||
virtual int instrCount() const { return instrCountBranch(); }
|
virtual int instrCount() const { return instrCountBranch(); }
|
||||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||||
virtual bool same(AstNode* samep) const { return true; }
|
virtual bool same(AstNode* samep) const { return true; }
|
||||||
@@ -1059,7 +1059,7 @@ public:
|
|||||||
virtual int instrCount() const { return widthInstrs(); }
|
virtual int instrCount() const { return widthInstrs(); }
|
||||||
virtual void cloneRelink();
|
virtual void cloneRelink();
|
||||||
virtual string name() const { return m_name; } // * = Var name
|
virtual string name() const { return m_name; } // * = Var name
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
bool lvalue() const { return m_lvalue; }
|
bool lvalue() const { return m_lvalue; }
|
||||||
void lvalue(bool lval) { m_lvalue=lval; } // Avoid using this; Set in constructor
|
void lvalue(bool lval) { m_lvalue=lval; } // Avoid using this; Set in constructor
|
||||||
AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable
|
AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable
|
||||||
@@ -1136,7 +1136,7 @@ public:
|
|||||||
virtual bool maybePointedTo() const { return true; }
|
virtual bool maybePointedTo() const { return true; }
|
||||||
// {AstFunc only} op1 = Range output variable
|
// {AstFunc only} op1 = Range output variable
|
||||||
// op3 = Statements/Ports/Vars
|
// op3 = Statements/Ports/Vars
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
AstNode* stmtsp() const { return op3p()->castNode(); } // op1 = List of statements
|
AstNode* stmtsp() const { return op3p()->castNode(); } // op1 = List of statements
|
||||||
void addStmtsp(AstNode* nodep) { addOp3p(nodep); }
|
void addStmtsp(AstNode* nodep) { addOp3p(nodep); }
|
||||||
void taskPublic(bool flag) { m_taskPublic=flag; }
|
void taskPublic(bool flag) { m_taskPublic=flag; }
|
||||||
@@ -1169,7 +1169,7 @@ public:
|
|||||||
void inlinedDots(const string& flag) { m_inlinedDots = flag; }
|
void inlinedDots(const string& flag) { m_inlinedDots = flag; }
|
||||||
AstNodeFTask* taskp() const { return m_taskp; } // [After Link] Pointer to variable
|
AstNodeFTask* taskp() const { return m_taskp; } // [After Link] Pointer to variable
|
||||||
void taskp(AstNodeFTask* taskp) { m_taskp=taskp; }
|
void taskp(AstNodeFTask* taskp) { m_taskp=taskp; }
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
void dotted(const string& name) { m_dotted = name; }
|
void dotted(const string& name) { m_dotted = name; }
|
||||||
// op1 = namep
|
// op1 = namep
|
||||||
AstNode* namep() const { return op1p(); }
|
AstNode* namep() const { return op1p(); }
|
||||||
|
|||||||
+17
-26
@@ -251,13 +251,6 @@ private:
|
|||||||
m_trace=false;
|
m_trace=false;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
AstVar(FileLine* fl, AstVarType type, const string& name)
|
|
||||||
:AstNode(fl)
|
|
||||||
, m_name(name) {
|
|
||||||
init();
|
|
||||||
combineType(type);
|
|
||||||
width(msb()-lsb()+1,0);
|
|
||||||
}
|
|
||||||
AstVar(FileLine* fl, AstVarType type, const string& name, AstRange* rangep, AstRange* arrayp=NULL)
|
AstVar(FileLine* fl, AstVarType type, const string& name, AstRange* rangep, AstRange* arrayp=NULL)
|
||||||
:AstNode(fl)
|
:AstNode(fl)
|
||||||
, m_name(name) {
|
, m_name(name) {
|
||||||
@@ -277,7 +270,7 @@ public:
|
|||||||
if (examplep->arraysp()) {
|
if (examplep->arraysp()) {
|
||||||
setOp2p(examplep->arraysp()->cloneTree(true));
|
setOp2p(examplep->arraysp()->cloneTree(true));
|
||||||
}
|
}
|
||||||
width(msb()-lsb()+1,0);
|
width(examplep->width(), examplep->widthMin());
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(Var, VAR)
|
ASTNODE_NODE_FUNCS(Var, VAR)
|
||||||
virtual void dump(ostream& str);
|
virtual void dump(ostream& str);
|
||||||
@@ -315,7 +308,7 @@ public:
|
|||||||
void funcReturn(bool flag) { m_funcReturn = flag; }
|
void funcReturn(bool flag) { m_funcReturn = flag; }
|
||||||
void trace(bool flag) { m_trace=flag; }
|
void trace(bool flag) { m_trace=flag; }
|
||||||
// METHODS
|
// METHODS
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
bool isInput() const { return m_input; }
|
bool isInput() const { return m_input; }
|
||||||
bool isOutput() const { return m_output; }
|
bool isOutput() const { return m_output; }
|
||||||
bool isInOnly() const { return m_input && !m_output; }
|
bool isInOnly() const { return m_input && !m_output; }
|
||||||
@@ -432,7 +425,7 @@ public:
|
|||||||
virtual bool broken() const;
|
virtual bool broken() const;
|
||||||
virtual bool maybePointedTo() const { return true; }
|
virtual bool maybePointedTo() const { return true; }
|
||||||
virtual string name() const { return m_name; } // * = Scope name
|
virtual string name() const { return m_name; } // * = Scope name
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
string nameDotless() const;
|
string nameDotless() const;
|
||||||
string nameVlSym() const { return (((string)"vlSymsp->") + nameDotless()); }
|
string nameVlSym() const { return (((string)"vlSymsp->") + nameDotless()); }
|
||||||
AstModule* modp() const { return m_modp; }
|
AstModule* modp() const { return m_modp; }
|
||||||
@@ -572,7 +565,7 @@ public:
|
|||||||
virtual void dump(ostream& str);
|
virtual void dump(ostream& str);
|
||||||
virtual bool broken() const { return (m_modVarp && !m_modVarp->brokeExists()); }
|
virtual bool broken() const { return (m_modVarp && !m_modVarp->brokeExists()); }
|
||||||
virtual string name() const { return m_name; } // * = Pin name, ""=go by number
|
virtual string name() const { return m_name; } // * = Pin name, ""=go by number
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
bool dotStar() const { return name() == ".*"; } // Special fake name for .* connections until linked
|
bool dotStar() const { return name() == ".*"; } // Special fake name for .* connections until linked
|
||||||
int pinNum() const { return m_pinNum; }
|
int pinNum() const { return m_pinNum; }
|
||||||
void exprp(AstNode* nodep) { addOp1p(nodep); }
|
void exprp(AstNode* nodep) { addOp1p(nodep); }
|
||||||
@@ -612,7 +605,7 @@ public:
|
|||||||
void addStmtp(AstNode* nodep) { addOp2p(nodep); }
|
void addStmtp(AstNode* nodep) { addOp2p(nodep); }
|
||||||
void addActivep(AstNode* nodep) { addOp3p(nodep); }
|
void addActivep(AstNode* nodep) { addOp3p(nodep); }
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
string origName() const { return m_origName; }
|
string origName() const { return m_origName; }
|
||||||
bool inLibrary() const { return m_inLibrary; }
|
bool inLibrary() const { return m_inLibrary; }
|
||||||
void inLibrary(bool flag) { m_inLibrary = flag; }
|
void inLibrary(bool flag) { m_inLibrary = flag; }
|
||||||
@@ -649,7 +642,7 @@ public:
|
|||||||
virtual bool maybePointedTo() const { return true; }
|
virtual bool maybePointedTo() const { return true; }
|
||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
virtual string name() const { return m_name; } // * = Cell name
|
virtual string name() const { return m_name; } // * = Cell name
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
string origName() const { return m_origName; } // * = Original name
|
string origName() const { return m_origName; } // * = Original name
|
||||||
void origName(const string& name) { m_origName = name; }
|
void origName(const string& name) { m_origName = name; }
|
||||||
string modName() const { return m_modName; } // * = Instance name
|
string modName() const { return m_modName; } // * = Instance name
|
||||||
@@ -679,7 +672,7 @@ public:
|
|||||||
// ACCESSORS
|
// ACCESSORS
|
||||||
virtual string name() const { return m_name; } // * = Cell name
|
virtual string name() const { return m_name; } // * = Cell name
|
||||||
string origModName() const { return m_origModName; } // * = modp()->origName() before inlining
|
string origModName() const { return m_origModName; } // * = modp()->origName() before inlining
|
||||||
void name(const string& name) { m_name = name; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AstPort : public AstNode {
|
struct AstPort : public AstNode {
|
||||||
@@ -714,7 +707,7 @@ public:
|
|||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(Begin, BEGIN)
|
ASTNODE_NODE_FUNCS(Begin, BEGIN)
|
||||||
virtual string name() const { return m_name; } // * = Block name
|
virtual string name() const { return m_name; } // * = Block name
|
||||||
void name(const string& flag) { m_name=flag; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
// op1 = Statements
|
// op1 = Statements
|
||||||
AstNode* stmtsp() const { return op1p()->castNode(); } // op1 = List of statements
|
AstNode* stmtsp() const { return op1p()->castNode(); } // op1 = List of statements
|
||||||
void addStmtp(AstNode* nodep) { addOp1p(nodep); }
|
void addStmtp(AstNode* nodep) { addOp1p(nodep); }
|
||||||
@@ -942,7 +935,7 @@ struct AstAssign : public AstNodeAssign {
|
|||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(Assign, ASSIGN)
|
ASTNODE_NODE_FUNCS(Assign, ASSIGN)
|
||||||
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstAssign(this->fileline(), lhsp, rhsp); }
|
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstAssign(this->fileline(), lhsp, rhsp); }
|
||||||
virtual string verilogKwd() const { return "="; };
|
virtual string verilogKwd() const { return "="; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AstAssignAlias : public AstNodeAssign {
|
struct AstAssignAlias : public AstNodeAssign {
|
||||||
@@ -961,7 +954,7 @@ struct AstAssignDly : public AstNodeAssign {
|
|||||||
ASTNODE_NODE_FUNCS(AssignDly, ASSIGNDLY)
|
ASTNODE_NODE_FUNCS(AssignDly, ASSIGNDLY)
|
||||||
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstAssignDly(this->fileline(), lhsp, rhsp); }
|
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstAssignDly(this->fileline(), lhsp, rhsp); }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual string verilogKwd() const { return "<="; };
|
virtual string verilogKwd() const { return "<="; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AstAssignW : public AstNodeAssign {
|
struct AstAssignW : public AstNodeAssign {
|
||||||
@@ -1249,7 +1242,7 @@ struct AstFClose : public AstNodeStmt {
|
|||||||
setNOp2p(filep);
|
setNOp2p(filep);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(FClose, FCLOSE)
|
ASTNODE_NODE_FUNCS(FClose, FCLOSE)
|
||||||
virtual string verilogKwd() const { return "$fclose"; };
|
virtual string verilogKwd() const { return "$fclose"; }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
virtual bool isPredictOptimizable() const { return false; }
|
||||||
virtual bool isSplittable() const { return false; }
|
virtual bool isSplittable() const { return false; }
|
||||||
@@ -1269,7 +1262,7 @@ struct AstFOpen : public AstNodeStmt {
|
|||||||
setOp3p(modep);
|
setOp3p(modep);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(FOpen, FOPEN)
|
ASTNODE_NODE_FUNCS(FOpen, FOPEN)
|
||||||
virtual string verilogKwd() const { return "$fclose"; };
|
virtual string verilogKwd() const { return "$fclose"; }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
virtual bool isPredictOptimizable() const { return false; }
|
||||||
virtual bool isSplittable() const { return false; }
|
virtual bool isSplittable() const { return false; }
|
||||||
@@ -1290,7 +1283,7 @@ struct AstFFlush : public AstNodeStmt {
|
|||||||
setNOp2p(filep);
|
setNOp2p(filep);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(FFlush, FFLUSH)
|
ASTNODE_NODE_FUNCS(FFlush, FFLUSH)
|
||||||
virtual string verilogKwd() const { return "$fflush"; };
|
virtual string verilogKwd() const { return "$fflush"; }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
virtual bool isPredictOptimizable() const { return false; }
|
||||||
virtual bool isSplittable() const { return false; }
|
virtual bool isSplittable() const { return false; }
|
||||||
@@ -1378,7 +1371,7 @@ public:
|
|||||||
setOp1p(filenamep); setOp2p(memp); setNOp3p(lsbp); setNOp4p(msbp);
|
setOp1p(filenamep); setOp2p(memp); setNOp3p(lsbp); setNOp4p(msbp);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(ReadMem, READMEM)
|
ASTNODE_NODE_FUNCS(ReadMem, READMEM)
|
||||||
virtual string verilogKwd() const { return (isHex()?"$readmemh":"$readmemb"); };
|
virtual string verilogKwd() const { return (isHex()?"$readmemh":"$readmemb"); }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
virtual bool isPredictOptimizable() const { return false; }
|
||||||
virtual bool isSplittable() const { return false; }
|
virtual bool isSplittable() const { return false; }
|
||||||
@@ -1417,8 +1410,7 @@ struct AstRepeat : public AstNodeStmt {
|
|||||||
ASTNODE_NODE_FUNCS(Repeat, REPEAT)
|
ASTNODE_NODE_FUNCS(Repeat, REPEAT)
|
||||||
AstNode* countp() const { return op2p()->castNode(); } // op2= condition to continue
|
AstNode* countp() const { return op2p()->castNode(); } // op2= condition to continue
|
||||||
AstNode* bodysp() const { return op3p()->castNode(); } // op3= body of loop
|
AstNode* bodysp() const { return op3p()->castNode(); } // op3= body of loop
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; } // Not releavant - converted to FOR
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
|
||||||
virtual int instrCount() const { return instrCountBranch(); }
|
virtual int instrCount() const { return instrCountBranch(); }
|
||||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||||
virtual bool same(AstNode* samep) const { return true; }
|
virtual bool same(AstNode* samep) const { return true; }
|
||||||
@@ -1436,7 +1428,6 @@ struct AstWhile : public AstNodeStmt {
|
|||||||
void addPrecondsp(AstNode* newp) { addOp1p(newp); }
|
void addPrecondsp(AstNode* newp) { addOp1p(newp); }
|
||||||
void addBodysp(AstNode* newp) { addOp3p(newp); }
|
void addBodysp(AstNode* newp) { addOp3p(newp); }
|
||||||
virtual bool isGateOptimizable() const { return false; }
|
virtual bool isGateOptimizable() const { return false; }
|
||||||
virtual bool isPredictOptimizable() const { return false; }
|
|
||||||
virtual int instrCount() const { return instrCountBranch(); }
|
virtual int instrCount() const { return instrCountBranch(); }
|
||||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||||
virtual bool same(AstNode* samep) const { return true; }
|
virtual bool same(AstNode* samep) const { return true; }
|
||||||
@@ -2636,7 +2627,7 @@ public:
|
|||||||
virtual string name() const { return m_name; } // * = Var name
|
virtual string name() const { return m_name; } // * = Var name
|
||||||
virtual V3Hash sameHash() const { return V3Hash(name()); }
|
virtual V3Hash sameHash() const { return V3Hash(name()); }
|
||||||
virtual bool same(AstNode* samep) const { return samep->name() == name(); }
|
virtual bool same(AstNode* samep) const { return samep->name() == name(); }
|
||||||
void name(const string& flag) { m_name = flag; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
AstNode* propp() const { return op1p(); } // op1 = property
|
AstNode* propp() const { return op1p(); } // op1 = property
|
||||||
AstSenTree* sentreep() const { return op2p()->castSenTree(); } // op2 = clock domain
|
AstSenTree* sentreep() const { return op2p()->castSenTree(); } // op2 = clock domain
|
||||||
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
||||||
@@ -2818,7 +2809,7 @@ public:
|
|||||||
&& (rtnTypeVoid()==samep->castCFunc()->rtnTypeVoid())
|
&& (rtnTypeVoid()==samep->castCFunc()->rtnTypeVoid())
|
||||||
&& (argTypes()==samep->castCFunc()->argTypes())); }
|
&& (argTypes()==samep->castCFunc()->argTypes())); }
|
||||||
//
|
//
|
||||||
void name(const string& flag) { m_name = flag; }
|
virtual void name(const string& name) { m_name = name; }
|
||||||
AstScope* scopep() const { return m_scopep; }
|
AstScope* scopep() const { return m_scopep; }
|
||||||
void scopep(AstScope* nodep) { m_scopep = nodep; }
|
void scopep(AstScope* nodep) { m_scopep = nodep; }
|
||||||
string rtnTypeVoid() const { return ((m_rtnType=="") ? "void" : m_rtnType); }
|
string rtnTypeVoid() const { return ((m_rtnType=="") ? "void" : m_rtnType); }
|
||||||
|
|||||||
+1
-1
@@ -86,7 +86,7 @@ private:
|
|||||||
if (varp->width()!=1) varp->v3error("Unsupported: Clock edge on non-single bit signal: "<<varp->prettyName());
|
if (varp->width()!=1) varp->v3error("Unsupported: Clock edge on non-single bit signal: "<<varp->prettyName());
|
||||||
string newvarname = ((string)"__Vclklast__"+vscp->scopep()->nameDotless()+"__"+varp->shortName());
|
string newvarname = ((string)"__Vclklast__"+vscp->scopep()->nameDotless()+"__"+varp->shortName());
|
||||||
AstVar* newvarp
|
AstVar* newvarp
|
||||||
= new AstVar (vscp->fileline(), AstVarType::MODULETEMP, newvarname); // No range; 1 bit.
|
= new AstVar (vscp->fileline(), AstVarType::MODULETEMP, newvarname, NULL, NULL); // No range; 1 bit.
|
||||||
newvarp->width(1,1);
|
newvarp->width(1,1);
|
||||||
m_modp->addStmtp(newvarp);
|
m_modp->addStmtp(newvarp);
|
||||||
AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp);
|
AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp);
|
||||||
|
|||||||
+58
-15
@@ -39,6 +39,7 @@
|
|||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
#include "V3Width.h"
|
#include "V3Width.h"
|
||||||
#include "V3Signed.h"
|
#include "V3Signed.h"
|
||||||
|
#include "V3Simulate.h"
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// Utilities
|
// Utilities
|
||||||
@@ -312,15 +313,24 @@ private:
|
|||||||
if (m_warn
|
if (m_warn
|
||||||
&& nodep->lsbp()->castConst()
|
&& nodep->lsbp()->castConst()
|
||||||
&& nodep->widthp()->castConst()
|
&& nodep->widthp()->castConst()
|
||||||
&& (!varp->rangep() || varp->msb()) // else it's non-resolvable parameterized
|
&& (!varp->rangep() || varp->msb())) { // else it's non-resolvable parameterized
|
||||||
&& ( ( (nodep->msbConst() > varp->msbMaxSelect())
|
if (nodep->lsbp()->castConst()->num().isFourState()
|
||||||
|| (nodep->lsbConst() > varp->msbMaxSelect())))) {
|
|| nodep->widthp()->castConst()->num().isFourState()) {
|
||||||
// See also warning in V3Width
|
nodep->v3error("Selection index is constantly unknown or tristated: "
|
||||||
nodep->v3error("Selection index out of range: "
|
"lsb="<<nodep->lsbp()->name()<<" width="<<nodep->widthp()->name());
|
||||||
<<nodep->msbConst()<<":"<<nodep->lsbConst()
|
// Replacing nodep will make a mess above, so we replace the offender
|
||||||
<<" outside "<<varp->msbMaxSelect()<<":0"
|
replaceZero(nodep->lsbp());
|
||||||
<<(varp->lsb()>=0 ? ""
|
}
|
||||||
:" (adjusted +"+cvtToStr(-varp->lsb())+" to account for negative lsb)"));
|
else if ((nodep->msbConst() > varp->msbMaxSelect())
|
||||||
|
|| (nodep->lsbConst() > varp->msbMaxSelect())) {
|
||||||
|
// See also warning in V3Width
|
||||||
|
nodep->v3error("Selection index out of range: "
|
||||||
|
<<nodep->msbConst()<<":"<<nodep->lsbConst()
|
||||||
|
<<" outside "<<varp->msbMaxSelect()<<":0"
|
||||||
|
<<(varp->lsb()>=0 ? ""
|
||||||
|
:" (adjusted +"+cvtToStr(-varp->lsb())+" to account for negative lsb)"));
|
||||||
|
// Don't replace with zero, we'll do it later
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false; // Not a transform, so NOP
|
return false; // Not a transform, so NOP
|
||||||
@@ -366,7 +376,9 @@ private:
|
|||||||
void replaceNum (AstNode* oldp, const V3Number& num) {
|
void replaceNum (AstNode* oldp, const V3Number& num) {
|
||||||
// Replace oldp node with a constant set to specified value
|
// Replace oldp node with a constant set to specified value
|
||||||
UASSERT (oldp, "Null old\n");
|
UASSERT (oldp, "Null old\n");
|
||||||
if (oldp->castConst()) oldp->v3fatalSrc("Already constant??\n");
|
if (oldp->castConst() && !oldp->castConst()->num().isFourState()) {
|
||||||
|
oldp->v3fatalSrc("Already constant??\n");
|
||||||
|
}
|
||||||
AstNode* newp = new AstConst(oldp->fileline(), num);
|
AstNode* newp = new AstConst(oldp->fileline(), num);
|
||||||
newp->widthSignedFrom(oldp);
|
newp->widthSignedFrom(oldp);
|
||||||
if (debug()>5) oldp->dumpTree(cout," const_old: ");
|
if (debug()>5) oldp->dumpTree(cout," const_old: ");
|
||||||
@@ -827,6 +839,26 @@ private:
|
|||||||
if (debug()>=9) newp->dumpTree(cout," _new: ");
|
if (debug()>=9) newp->dumpTree(cout," _new: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void replaceWithSimulation(AstNode* nodep) {
|
||||||
|
SimulateVisitor simvis;
|
||||||
|
// Run it - may be unoptimizable due to large for loop, etc
|
||||||
|
simvis.mainParamEmulate(nodep);
|
||||||
|
if (!simvis.optimizable()) {
|
||||||
|
AstNode* errorp = simvis.whyNotNodep(); if (!errorp) errorp = nodep;
|
||||||
|
nodep->v3error("Expecting expression to be constant, but can't determine constant for "
|
||||||
|
<<nodep->prettyTypeName()<<endl
|
||||||
|
<<V3Error::msgPrefix()<<errorp->fileline()<<"... Location of non-constant "
|
||||||
|
<<errorp->prettyTypeName()<<": "<<simvis.whyNotMessage());
|
||||||
|
replaceZero(nodep); nodep=NULL;
|
||||||
|
} else {
|
||||||
|
// Fetch the result
|
||||||
|
V3Number* outnump = simvis.fetchNumberNull(nodep);
|
||||||
|
if (!outnump) nodep->v3fatalSrc("No number returned from simulation");
|
||||||
|
// Replace it
|
||||||
|
replaceNum(nodep,*outnump); nodep=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
// VISITORS
|
// VISITORS
|
||||||
@@ -1420,6 +1452,13 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstFuncRef* nodep, AstNUser*) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
if (m_params) { // Only parameters force us to do constant function call propagation
|
||||||
|
replaceWithSimulation(nodep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void visit(AstWhile* nodep, AstNUser*) {
|
virtual void visit(AstWhile* nodep, AstNUser*) {
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
if (nodep->condp()->isZero()) {
|
if (nodep->condp()->isZero()) {
|
||||||
@@ -1708,12 +1747,16 @@ public:
|
|||||||
|
|
||||||
void V3Const::constifyParam(AstNode* nodep) {
|
void V3Const::constifyParam(AstNode* nodep) {
|
||||||
//if (debug()>0) nodep->dumpTree(cout," forceConPRE : ");
|
//if (debug()>0) nodep->dumpTree(cout," forceConPRE : ");
|
||||||
if (!nodep->width()) {
|
V3Width::widthSignedIfNotAlready(nodep); // Make sure we've sized everything first
|
||||||
V3Width::widthParams(nodep);
|
|
||||||
V3Signed::signedParams(nodep);
|
|
||||||
}
|
|
||||||
ConstVisitor visitor (true,false,false,false);
|
ConstVisitor visitor (true,false,false,false);
|
||||||
visitor.main(nodep);
|
if (AstVar* varp=nodep->castVar()) {
|
||||||
|
// If a var wants to be constified, it's really a param, and
|
||||||
|
// we want the value to be constant. We aren't passed just the
|
||||||
|
// init value because we need widthing above to handle the var's type.
|
||||||
|
if (varp->initp()) visitor.main(varp->initp());
|
||||||
|
} else {
|
||||||
|
visitor.main(nodep);
|
||||||
|
}
|
||||||
// Because we do edits, nodep links may get trashed and core dump this.
|
// Because we do edits, nodep links may get trashed and core dump this.
|
||||||
//if (debug()>0) nodep->dumpTree(cout," forceConDONE: ");
|
//if (debug()>0) nodep->dumpTree(cout," forceConDONE: ");
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-3
@@ -1796,10 +1796,13 @@ class EmitCTrace : EmitCStmts {
|
|||||||
puts("if (!Verilated::calcUnusedSigs()) vl_fatal(__FILE__,__LINE__,__FILE__,\"Turning on wave traces requires Verilated::traceEverOn(true) call before time 0.\");\n");
|
puts("if (!Verilated::calcUnusedSigs()) vl_fatal(__FILE__,__LINE__,__FILE__,\"Turning on wave traces requires Verilated::traceEverOn(true) call before time 0.\");\n");
|
||||||
|
|
||||||
//Future; need to wait to estabilish backwards compatibility
|
//Future; need to wait to estabilish backwards compatibility
|
||||||
//puts("#if defined(SPTRACEVCDC_VERSION) && SPTRACEVCDC_VERSION >= 1320\n");
|
puts("#if defined(SPTRACEVCDC_VERSION) && SPTRACEVCDC_VERSION >= 1330\n");
|
||||||
//puts("vcdp->scopeEscape(' ');\n");
|
puts("vcdp->scopeEscape(' ');\n");
|
||||||
puts("t->traceInitThis (vlSymsp, vcdp, code);\n");
|
puts("t->traceInitThis (vlSymsp, vcdp, code);\n");
|
||||||
//puts("vcdp->scopeEscape('.');\n"); // Restore so SystemPerl traced files won't break
|
puts("vcdp->scopeEscape('.');\n"); // Restore so SystemPerl traced files won't break
|
||||||
|
puts("#else\n");
|
||||||
|
puts("t->traceInitThis (vlSymsp, vcdp, code);\n");
|
||||||
|
puts("#endif\n");
|
||||||
puts("}\n");
|
puts("}\n");
|
||||||
|
|
||||||
puts("void "+topClassName()+"::traceFull(SpTraceVcd* vcdp, void* userthis, uint32_t code) {\n");
|
puts("void "+topClassName()+"::traceFull(SpTraceVcd* vcdp, void* userthis, uint32_t code) {\n");
|
||||||
|
|||||||
+6
-6
@@ -43,7 +43,7 @@ public:
|
|||||||
V3OutCFile(const string& filename) : V3OutFile(filename) {
|
V3OutCFile(const string& filename) : V3OutFile(filename) {
|
||||||
resetPrivate();
|
resetPrivate();
|
||||||
}
|
}
|
||||||
virtual ~V3OutCFile() {};
|
virtual ~V3OutCFile() {}
|
||||||
virtual void putsCellDecl(const string& classname, const string& cellname) {
|
virtual void putsCellDecl(const string& classname, const string& cellname) {
|
||||||
this->printf("%-19s\t%s;\n",
|
this->printf("%-19s\t%s;\n",
|
||||||
(classname + "*").c_str(),cellname.c_str());
|
(classname + "*").c_str(),cellname.c_str());
|
||||||
@@ -66,7 +66,7 @@ public:
|
|||||||
class V3OutScFile : public V3OutCFile {
|
class V3OutScFile : public V3OutCFile {
|
||||||
public:
|
public:
|
||||||
V3OutScFile(const string& filename) : V3OutCFile(filename) {}
|
V3OutScFile(const string& filename) : V3OutCFile(filename) {}
|
||||||
virtual ~V3OutScFile() {};
|
virtual ~V3OutScFile() {}
|
||||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||||
virtual void putsIntTopInclude() {
|
virtual void putsIntTopInclude() {
|
||||||
puts("#include \"systemc.h\"\n");
|
puts("#include \"systemc.h\"\n");
|
||||||
@@ -77,7 +77,7 @@ public:
|
|||||||
class V3OutSpFile : public V3OutCFile {
|
class V3OutSpFile : public V3OutCFile {
|
||||||
public:
|
public:
|
||||||
V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
|
V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
|
||||||
virtual ~V3OutSpFile() {};
|
virtual ~V3OutSpFile() {}
|
||||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||||
virtual void putsIntTopInclude() {
|
virtual void putsIntTopInclude() {
|
||||||
puts("#include \"systemperl.h\"\n");
|
puts("#include \"systemperl.h\"\n");
|
||||||
@@ -88,14 +88,14 @@ public:
|
|||||||
class V3OutVFile : public V3OutFile {
|
class V3OutVFile : public V3OutFile {
|
||||||
public:
|
public:
|
||||||
V3OutVFile(const string& filename) : V3OutFile(filename) {}
|
V3OutVFile(const string& filename) : V3OutFile(filename) {}
|
||||||
virtual ~V3OutVFile() {};
|
virtual ~V3OutVFile() {}
|
||||||
virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); }
|
virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class V3OutMkFile : public V3OutFile {
|
class V3OutMkFile : public V3OutFile {
|
||||||
public:
|
public:
|
||||||
V3OutMkFile(const string& filename) : V3OutFile(filename) {}
|
V3OutMkFile(const string& filename) : V3OutFile(filename) {}
|
||||||
virtual ~V3OutMkFile() {};
|
virtual ~V3OutMkFile() {}
|
||||||
virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); }
|
virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); }
|
||||||
// No automatic indentation yet.
|
// No automatic indentation yet.
|
||||||
void puts(const char* strg) { putsNoTracking(strg); }
|
void puts(const char* strg) { putsNoTracking(strg); }
|
||||||
@@ -110,7 +110,7 @@ public:
|
|||||||
// STATE
|
// STATE
|
||||||
V3OutCFile* m_ofp;
|
V3OutCFile* m_ofp;
|
||||||
// METHODS
|
// METHODS
|
||||||
V3OutCFile* ofp() const { return m_ofp; };
|
V3OutCFile* ofp() const { return m_ofp; }
|
||||||
void puts(const string& str) { ofp()->puts(str); }
|
void puts(const string& str) { ofp()->puts(str); }
|
||||||
void putbs(const string& str) { ofp()->putbs(str); }
|
void putbs(const string& str) { ofp()->putbs(str); }
|
||||||
void putsQuoted(const string& str) { ofp()->putsQuoted(str); }
|
void putsQuoted(const string& str) { ofp()->putsQuoted(str); }
|
||||||
|
|||||||
+3
-1
@@ -65,7 +65,9 @@ class EmitCSyms : EmitCBaseVisitor {
|
|||||||
if (nodep->name() != "") {
|
if (nodep->name() != "") {
|
||||||
string rsvd = m_words.isKeyword(nodep->name());
|
string rsvd = m_words.isKeyword(nodep->name());
|
||||||
if (rsvd != "") {
|
if (rsvd != "") {
|
||||||
nodep->v3error("Unsupported: "+rsvd+": "<<nodep->name());
|
// Generally V3Name should find all of these and throw SYMRSVDWORD.
|
||||||
|
// We'll still check here because the compiler errors resulting if we miss this warning are SO nasty
|
||||||
|
nodep->v3error("Symbol matching "+rsvd+" reserved word reached emitter, should have hit SYMRSVDWORD: '"<<nodep->name()<<"'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -461,7 +461,7 @@ class EmitVFileVisitor : public EmitVBaseVisitor {
|
|||||||
// MEMBERS
|
// MEMBERS
|
||||||
V3OutFile* m_ofp;
|
V3OutFile* m_ofp;
|
||||||
// METHODS
|
// METHODS
|
||||||
V3OutFile* ofp() const { return m_ofp; };
|
V3OutFile* ofp() const { return m_ofp; }
|
||||||
void puts(const string& str) { ofp()->puts(str); }
|
void puts(const string& str) { ofp()->puts(str); }
|
||||||
void putbs(const string& str) { ofp()->putbs(str); }
|
void putbs(const string& str) { ofp()->putbs(str); }
|
||||||
void putsNoTracking(const string& str) { ofp()->putsNoTracking(str); }
|
void putsNoTracking(const string& str) { ofp()->putsNoTracking(str); }
|
||||||
|
|||||||
+2
-2
@@ -46,7 +46,7 @@ bool V3Error::s_describedWarnings = false;
|
|||||||
bool V3Error::s_pretendError[V3ErrorCode::MAX];
|
bool V3Error::s_pretendError[V3ErrorCode::MAX];
|
||||||
|
|
||||||
struct v3errorIniter {
|
struct v3errorIniter {
|
||||||
v3errorIniter() { V3Error::init(); };
|
v3errorIniter() { V3Error::init(); }
|
||||||
};
|
};
|
||||||
v3errorIniter v3errorInit;
|
v3errorIniter v3errorInit;
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ void V3Error::v3errorEnd (ostringstream& sstr) {
|
|||||||
// If first warning is not the user's fault (internal/unsupported) then give the website
|
// If first warning is not the user's fault (internal/unsupported) then give the website
|
||||||
// Not later warnings, as a internal may be caused by an earlier problem
|
// Not later warnings, as a internal may be caused by an earlier problem
|
||||||
if (s_tellManual == 0) {
|
if (s_tellManual == 0) {
|
||||||
if (s_errorCode==V3ErrorCode::FATALSRC
|
if (s_errorCode.mentionManual()
|
||||||
|| sstr.str().find("Unsupported") != string::npos) {
|
|| sstr.str().find("Unsupported") != string::npos) {
|
||||||
s_tellManual = 1;
|
s_tellManual = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+14
-10
@@ -59,6 +59,7 @@ public:
|
|||||||
CMPCONST, // Comparison is constant due to limited range
|
CMPCONST, // Comparison is constant due to limited range
|
||||||
COMBDLY, // Combinatorial delayed assignment
|
COMBDLY, // Combinatorial delayed assignment
|
||||||
STMTDLY, // Delayed statement
|
STMTDLY, // Delayed statement
|
||||||
|
SYMRSVDWORD, // Symbol is Reserved Word
|
||||||
GENCLK, // Generated Clock
|
GENCLK, // Generated Clock
|
||||||
IMPERFECTSCH, // Imperfect schedule (disabled by default)
|
IMPERFECTSCH, // Imperfect schedule (disabled by default)
|
||||||
IMPLICIT, // Implicit wire
|
IMPLICIT, // Implicit wire
|
||||||
@@ -77,11 +78,11 @@ public:
|
|||||||
// ***Add new elements below also***
|
// ***Add new elements below also***
|
||||||
};
|
};
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline V3ErrorCode () {};
|
inline V3ErrorCode () {}
|
||||||
inline V3ErrorCode (en _e) : m_e(_e) {};
|
inline V3ErrorCode (en _e) : m_e(_e) {}
|
||||||
V3ErrorCode (const char* msgp); // Matching code or ERROR
|
V3ErrorCode (const char* msgp); // Matching code or ERROR
|
||||||
explicit inline V3ErrorCode (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline V3ErrorCode (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
const char* ascii() const {
|
const char* ascii() const {
|
||||||
const char* names[] = {
|
const char* names[] = {
|
||||||
// Leading spaces indicate it can't be disabled.
|
// Leading spaces indicate it can't be disabled.
|
||||||
@@ -94,21 +95,24 @@ public:
|
|||||||
" FIRST_WARN",
|
" FIRST_WARN",
|
||||||
"BLKANDNBLK",
|
"BLKANDNBLK",
|
||||||
"CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CMPCONST",
|
"CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CMPCONST",
|
||||||
"COMBDLY", "STMTDLY", "GENCLK", "IMPERFECTSCH", "IMPLICIT", "IMPURE",
|
"COMBDLY", "STMTDLY", "SYMRSVDWORD", "GENCLK", "IMPERFECTSCH", "IMPLICIT", "IMPURE",
|
||||||
"MULTIDRIVEN", "REDEFMACRO",
|
"MULTIDRIVEN", "REDEFMACRO",
|
||||||
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
|
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
|
||||||
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
|
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
|
||||||
" MAX"
|
" MAX"
|
||||||
};
|
};
|
||||||
return names[m_e];
|
return names[m_e];
|
||||||
};
|
}
|
||||||
// Warnings that default to off
|
// Warnings that default to off
|
||||||
bool defaultsOff() const { return ( m_e==IMPERFECTSCH );};
|
bool defaultsOff() const { return ( m_e==IMPERFECTSCH ); }
|
||||||
// Warnings that warn about nasty side effects
|
// Warnings that warn about nasty side effects
|
||||||
bool dangerous() const { return ( m_e==COMBDLY );};
|
bool dangerous() const { return ( m_e==COMBDLY ); }
|
||||||
// Warnings we'll present to the user as errors
|
// Warnings we'll present to the user as errors
|
||||||
// Later -Werror- options may make more of these.
|
// Later -Werror- options may make more of these.
|
||||||
bool pretendError() const { return ( m_e==BLKANDNBLK || m_e==IMPURE); };
|
bool pretendError() const { return ( m_e==BLKANDNBLK || m_e==IMPURE || m_e==SYMRSVDWORD); }
|
||||||
|
// Warnings to mention manual
|
||||||
|
bool mentionManual() const { return ( m_e==FATALSRC || pretendError() ); }
|
||||||
|
|
||||||
// Warnings that are lint only
|
// Warnings that are lint only
|
||||||
bool lintError() const { return ( m_e==CASEINCOMPLETE || m_e==CASEOVERLAP
|
bool lintError() const { return ( m_e==CASEINCOMPLETE || m_e==CASEOVERLAP
|
||||||
|| m_e==CASEWITHX || m_e==CASEX
|
|| m_e==CASEWITHX || m_e==CASEX
|
||||||
@@ -116,7 +120,7 @@ public:
|
|||||||
|| m_e==IMPLICIT
|
|| m_e==IMPLICIT
|
||||||
|| m_e==UNDRIVEN || m_e==UNSIGNED
|
|| m_e==UNDRIVEN || m_e==UNSIGNED
|
||||||
|| m_e==UNUSED || m_e==VARHIDDEN
|
|| m_e==UNUSED || m_e==VARHIDDEN
|
||||||
|| m_e==WIDTH); };
|
|| m_e==WIDTH); }
|
||||||
};
|
};
|
||||||
inline bool operator== (V3ErrorCode lhs, V3ErrorCode rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (V3ErrorCode lhs, V3ErrorCode rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (V3ErrorCode lhs, V3ErrorCode::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (V3ErrorCode lhs, V3ErrorCode::en rhs) { return (lhs.m_e == rhs); }
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ class V3FileDependImp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool operator<(const DependFile& rhs) const { return filename()<rhs.filename(); };
|
bool operator<(const DependFile& rhs) const { return filename()<rhs.filename(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
|
|||||||
+1
-1
@@ -123,7 +123,7 @@ public:
|
|||||||
bool exceededWidth() const { return m_column > WIDTH; }
|
bool exceededWidth() const { return m_column > WIDTH; }
|
||||||
bool tokenStart(const char* cp, const char* cmp);
|
bool tokenStart(const char* cp, const char* cmp);
|
||||||
bool tokenEnd(const char* cp);
|
bool tokenEnd(const char* cp);
|
||||||
void indentInc() { m_indentLevel += INDBLK; };
|
void indentInc() { m_indentLevel += INDBLK; }
|
||||||
void indentDec() {
|
void indentDec() {
|
||||||
m_indentLevel -= INDBLK;
|
m_indentLevel -= INDBLK;
|
||||||
UASSERT(m_indentLevel>=0, ": "<<m_filename<<": Underflow of indentation\n");
|
UASSERT(m_indentLevel>=0, ": "<<m_filename<<": Underflow of indentation\n");
|
||||||
|
|||||||
+1
-1
@@ -156,7 +156,7 @@ private:
|
|||||||
if (!forrefp->varp()) {
|
if (!forrefp->varp()) {
|
||||||
if (!noWarn) forrefp->v3warn(IMPLICIT,"Signal definition not found, creating implicitly: "<<forrefp->prettyName());
|
if (!noWarn) forrefp->v3warn(IMPLICIT,"Signal definition not found, creating implicitly: "<<forrefp->prettyName());
|
||||||
AstVar* newp = new AstVar (forrefp->fileline(), AstVarType::WIRE,
|
AstVar* newp = new AstVar (forrefp->fileline(), AstVarType::WIRE,
|
||||||
forrefp->name());
|
forrefp->name(), NULL, NULL); // width 1
|
||||||
newp->trace(m_modp->modTrace());
|
newp->trace(m_modp->modTrace());
|
||||||
m_modp->addStmtp(newp);
|
m_modp->addStmtp(newp);
|
||||||
// Link it to signal list
|
// Link it to signal list
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ private:
|
|||||||
inPct = true;
|
inPct = true;
|
||||||
} else if (inPct) {
|
} else if (inPct) {
|
||||||
inPct = false;
|
inPct = false;
|
||||||
switch (ch) {
|
switch (tolower(ch)) {
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9':
|
case '5': case '6': case '7': case '8': case '9':
|
||||||
inPct = true;
|
inPct = true;
|
||||||
@@ -441,7 +441,8 @@ private:
|
|||||||
nodep->v3error(nodep->verilogKwd()+" only allowed under a assertion.");
|
nodep->v3error(nodep->verilogKwd()+" only allowed under a assertion.");
|
||||||
}
|
}
|
||||||
if (nodep->displayType().needScopeTracking()
|
if (nodep->displayType().needScopeTracking()
|
||||||
|| nodep->name().find("%m") != string::npos) {
|
|| nodep->name().find("%m") != string::npos
|
||||||
|
|| nodep->name().find("%M") != string::npos) {
|
||||||
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ protected:
|
|||||||
};
|
};
|
||||||
uint32_t m_flags;
|
uint32_t m_flags;
|
||||||
VarFlags(AstNode* nodep) { m_flags = nodep->user2(); }
|
VarFlags(AstNode* nodep) { m_flags = nodep->user2(); }
|
||||||
void setNodeFlags(AstNode* nodep) { nodep->user2(m_flags); };
|
void setNodeFlags(AstNode* nodep) { nodep->user2(m_flags); }
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+27
-22
@@ -34,6 +34,7 @@
|
|||||||
#include "V3Global.h"
|
#include "V3Global.h"
|
||||||
#include "V3Name.h"
|
#include "V3Name.h"
|
||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
|
#include "V3LanguageWords.h"
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// Name state, as a visitor of each AstNode
|
// Name state, as a visitor of each AstNode
|
||||||
@@ -45,14 +46,11 @@ private:
|
|||||||
// AstCell::user1() -> bool. Set true if already processed
|
// AstCell::user1() -> bool. Set true if already processed
|
||||||
// AstScope::user1() -> bool. Set true if already processed
|
// AstScope::user1() -> bool. Set true if already processed
|
||||||
// AstVar::user1() -> bool. Set true if already processed
|
// AstVar::user1() -> bool. Set true if already processed
|
||||||
//
|
|
||||||
// AstCell::user2() -> bool. Set true if was privitized
|
|
||||||
// AstVar::user2() -> bool. Set true if was privitized
|
|
||||||
AstUser1InUse m_inuser1;
|
AstUser1InUse m_inuser1;
|
||||||
AstUser2InUse m_inuser2;
|
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
AstModule* m_modp;
|
AstModule* m_modp;
|
||||||
|
V3LanguageWords m_words; // Reserved word detector
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
static int debug() {
|
static int debug() {
|
||||||
@@ -61,6 +59,23 @@ private:
|
|||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rename(AstNode* nodep, bool addPvt) {
|
||||||
|
if (!nodep->user1()) { // Not already done
|
||||||
|
if (addPvt) {
|
||||||
|
string newname = (string)"__PVT__"+nodep->name();
|
||||||
|
nodep->name(newname);
|
||||||
|
} else {
|
||||||
|
string rsvd = m_words.isKeyword(nodep->name());
|
||||||
|
if (rsvd != "") {
|
||||||
|
nodep->v3warn(SYMRSVDWORD,"Symbol matches "+rsvd+": '"<<nodep->name()<<"'");
|
||||||
|
string newname = (string)"__SYM__"+nodep->name();
|
||||||
|
nodep->name(newname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodep->user1(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// VISITORS
|
// VISITORS
|
||||||
virtual void visit(AstModule* nodep, AstNUser*) {
|
virtual void visit(AstModule* nodep, AstNUser*) {
|
||||||
m_modp = nodep;
|
m_modp = nodep;
|
||||||
@@ -70,16 +85,13 @@ private:
|
|||||||
// Add __PVT__ to names of local signals
|
// Add __PVT__ to names of local signals
|
||||||
virtual void visit(AstVar* nodep, AstNUser*) {
|
virtual void visit(AstVar* nodep, AstNUser*) {
|
||||||
// Don't iterate... Don't need temps for RANGES under the Var.
|
// Don't iterate... Don't need temps for RANGES under the Var.
|
||||||
if (!nodep->user1()
|
rename(nodep, (!m_modp->isTop()
|
||||||
&& !m_modp->isTop()
|
&& !nodep->isSigPublic()
|
||||||
&& !nodep->isSigPublic()
|
&& !nodep->isTemp())); // Don't bother to rename internal signals
|
||||||
&& !nodep->isTemp()) { // Don't bother to rename internal signals
|
}
|
||||||
// Change the name to something private...
|
virtual void visit(AstCFunc* nodep, AstNUser*) {
|
||||||
string newname = (string)"__PVT__"+nodep->name();
|
nodep->iterateChildren(*this);
|
||||||
nodep->name(newname);
|
rename(nodep, false);
|
||||||
nodep->user1(1);
|
|
||||||
nodep->user2(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||||
if (nodep->varp()) {
|
if (nodep->varp()) {
|
||||||
@@ -88,14 +100,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstCell* nodep, AstNUser*) {
|
virtual void visit(AstCell* nodep, AstNUser*) {
|
||||||
if (!nodep->user1()
|
rename(nodep, !nodep->modp()->modPublic());
|
||||||
&& !nodep->modp()->modPublic()) {
|
|
||||||
// Change the name to something private...
|
|
||||||
string newname = (string)"__PVT__"+nodep->name();
|
|
||||||
nodep->name(newname);
|
|
||||||
nodep->user1(1);
|
|
||||||
nodep->user2(1);
|
|
||||||
}
|
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
}
|
}
|
||||||
virtual void visit(AstScope* nodep, AstNUser*) {
|
virtual void visit(AstScope* nodep, AstNUser*) {
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ public:
|
|||||||
class VerilogString {}; // for creator type-overload selection
|
class VerilogString {}; // for creator type-overload selection
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
V3Number(FileLine* fileline) { init(fileline, 1); }
|
V3Number(FileLine* fileline) { init(fileline, 1); }
|
||||||
V3Number(FileLine* fileline, int width) { init(fileline, width); }; // 0=unsized
|
V3Number(FileLine* fileline, int width) { init(fileline, width); } // 0=unsized
|
||||||
V3Number(FileLine* fileline, int width, uint32_t value) { init(fileline, width); m_value[0]=value; }
|
V3Number(FileLine* fileline, int width, uint32_t value) { init(fileline, width); m_value[0]=value; }
|
||||||
V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number.
|
V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number.
|
||||||
V3Number(VerilogString, FileLine* fileline, const string& vvalue);
|
V3Number(VerilogString, FileLine* fileline, const string& vvalue);
|
||||||
|
|||||||
+15
-14
@@ -374,27 +374,27 @@ string V3Options::getenvSYSTEMPERLGuts() {
|
|||||||
|
|
||||||
string V3Options::getenvSYSTEMPERL_INCLUDE() {
|
string V3Options::getenvSYSTEMPERL_INCLUDE() {
|
||||||
string var = getenvStr("SYSTEMPERL_INCLUDE","");
|
string var = getenvStr("SYSTEMPERL_INCLUDE","");
|
||||||
if (var == "" && string(DEFENV_SYSTEMPERL_INCLUDE) != "") {
|
if (var == "") {
|
||||||
// Note if SYSTEMPERL is DEFENVed, then SYSTEMPERL_INCLUDE is also DEFENVed
|
string sp_src = V3Options::getenvSYSTEMPERLGuts()+"/src";
|
||||||
// So we don't need to sweat testing SYSTEMPERL also
|
if (V3Options::fileStatNormal(sp_src+"/systemperl.h")) {
|
||||||
var = DEFENV_SYSTEMPERL_INCLUDE;
|
var = sp_src;
|
||||||
setenvStr("SYSTEMPERL_INCLUDE", var, "Hardcoded at build time");
|
setenvStr ("SYSTEMPERL_INCLUDE", var, "From $SYSTEMPERL/src");
|
||||||
|
} else if (string(DEFENV_SYSTEMPERL_INCLUDE) != "") {
|
||||||
|
// Note if SYSTEMPERL is DEFENVed, then SYSTEMPERL_INCLUDE is also DEFENVed
|
||||||
|
// So we don't need to sweat testing DEFENV_SYSTEMPERL also
|
||||||
|
var = DEFENV_SYSTEMPERL_INCLUDE;
|
||||||
|
setenvStr("SYSTEMPERL_INCLUDE", var, "Hardcoded at build time");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Only correct or check it if we really need the value
|
// Only correct or check it if we really need the value
|
||||||
if (v3Global.opt.usingSystemPerlLibs()) {
|
if (v3Global.opt.usingSystemPerlLibs()) {
|
||||||
if (var == "") {
|
|
||||||
string sp = V3Options::getenvSYSTEMPERLGuts();
|
|
||||||
var = sp+"/src";
|
|
||||||
setenvStr ("SYSTEMPERL_INCLUDE", var, "From $SYSTEMPERL/src");
|
|
||||||
}
|
|
||||||
// We warn about $SYSTEMPERL instead of _INCLUDE since that's more likely
|
// We warn about $SYSTEMPERL instead of _INCLUDE since that's more likely
|
||||||
// what users will want to set.
|
// what users will want to set.
|
||||||
if (var == "") {
|
if (var == "") {
|
||||||
v3fatal("Need $SYSTEMPERL in environment for --sp or --trace\n"
|
v3fatal("Need $SYSTEMPERL and $SYSTEMPERL_INCLUDE in environment for --sp or --trace\n"
|
||||||
"Probably System-Perl isn't installed, see http://www.veripool.org/systemperl\n");
|
"Probably System-Perl isn't installed, see http://www.veripool.org/systemperl\n");
|
||||||
}
|
}
|
||||||
if (var != ""
|
else if (var != "" && !V3Options::fileStatNormal(var+"/systemperl.h")) {
|
||||||
&& !V3Options::fileStatNormal(var+"/systemperl.h")) {
|
|
||||||
v3fatal("Neither $SYSTEMPERL nor $SYSTEMPERL_INCLUDE environment vars to point to System-Perl kit: "<<var<<endl);
|
v3fatal("Neither $SYSTEMPERL nor $SYSTEMPERL_INCLUDE environment vars to point to System-Perl kit: "<<var<<endl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +577,7 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-error-limit") ) {
|
else if ( !strcmp (sw, "-error-limit") ) {
|
||||||
shift;
|
shift;
|
||||||
m_inlineMult = atoi(argv[i]);
|
m_errorLimit = atoi(argv[i]);
|
||||||
}
|
}
|
||||||
else if ( !strcmp (sw, "-inline-mult") ) {
|
else if ( !strcmp (sw, "-inline-mult") ) {
|
||||||
shift;
|
shift;
|
||||||
@@ -638,6 +638,7 @@ void V3Options::parseOptsList(FileLine* fl, int argc, char** argv) {
|
|||||||
else if ( onoff (sw, "-MP", flag/*ref*/) ) { m_makePhony = flag; }
|
else if ( onoff (sw, "-MP", flag/*ref*/) ) { m_makePhony = flag; }
|
||||||
else if ( onoff (sw, "-assert", flag/*ref*/) ) { m_assert = flag; m_psl = flag; }
|
else if ( onoff (sw, "-assert", flag/*ref*/) ) { m_assert = flag; m_psl = flag; }
|
||||||
else if ( onoff (sw, "-autoflush", flag/*ref*/) ) { m_autoflush = flag; }
|
else if ( onoff (sw, "-autoflush", flag/*ref*/) ) { m_autoflush = flag; }
|
||||||
|
else if ( onoff (sw, "-bbox-sys", flag/*ref*/) ) { m_bboxSys = flag; }
|
||||||
else if ( !strcmp (sw, "-cc") ) { m_outFormatOk = true; m_systemC = false; m_systemPerl = false; }
|
else if ( !strcmp (sw, "-cc") ) { m_outFormatOk = true; m_systemC = false; m_systemPerl = false; }
|
||||||
else if ( onoff (sw, "-coverage", flag/*ref*/) ) { coverage(flag); }
|
else if ( onoff (sw, "-coverage", flag/*ref*/) ) { coverage(flag); }
|
||||||
else if ( onoff (sw, "-coverage-line", flag/*ref*/) ){ m_coverageLine = flag; }
|
else if ( onoff (sw, "-coverage-line", flag/*ref*/) ){ m_coverageLine = flag; }
|
||||||
|
|||||||
+6
-4
@@ -60,11 +60,11 @@ public:
|
|||||||
bool legal() const { return m_e != ERROR; }
|
bool legal() const { return m_e != ERROR; }
|
||||||
//
|
//
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline V3LangCode () : m_e(ERROR) {};
|
inline V3LangCode () : m_e(ERROR) {}
|
||||||
inline V3LangCode (en _e) : m_e(_e) {};
|
inline V3LangCode (en _e) : m_e(_e) {}
|
||||||
V3LangCode (const char* textp); // Return matching code or ERROR
|
V3LangCode (const char* textp); // Return matching code or ERROR
|
||||||
explicit inline V3LangCode (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline V3LangCode (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
@@ -94,6 +94,7 @@ class V3Options {
|
|||||||
bool m_makePhony; // main switch: -MP
|
bool m_makePhony; // main switch: -MP
|
||||||
bool m_assert; // main switch: --assert
|
bool m_assert; // main switch: --assert
|
||||||
bool m_autoflush; // main switch: --autoflush
|
bool m_autoflush; // main switch: --autoflush
|
||||||
|
bool m_bboxSys; // main switch: --bbox-sys
|
||||||
bool m_coverageLine; // main switch: --coverage-block
|
bool m_coverageLine; // main switch: --coverage-block
|
||||||
bool m_coverageToggle;// main switch: --coverage-toggle
|
bool m_coverageToggle;// main switch: --coverage-toggle
|
||||||
bool m_coverageUser; // main switch: --coverage-func
|
bool m_coverageUser; // main switch: --coverage-func
|
||||||
@@ -204,6 +205,7 @@ class V3Options {
|
|||||||
bool stats() const { return m_stats; }
|
bool stats() const { return m_stats; }
|
||||||
bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined
|
bool assertOn() const { return m_assert; } // assertOn as __FILE__ may be defined
|
||||||
bool autoflush() const { return m_autoflush; }
|
bool autoflush() const { return m_autoflush; }
|
||||||
|
bool bboxSys() const { return m_bboxSys; }
|
||||||
bool coverage() const { return m_coverageLine || m_coverageToggle || m_coverageUser; }
|
bool coverage() const { return m_coverageLine || m_coverageToggle || m_coverageUser; }
|
||||||
bool coverageLine() const { return m_coverageLine; }
|
bool coverageLine() const { return m_coverageLine; }
|
||||||
bool coverageToggle() const { return m_coverageToggle; }
|
bool coverageToggle() const { return m_coverageToggle; }
|
||||||
|
|||||||
+5
-5
@@ -103,12 +103,12 @@ struct OrderVEdgeType {
|
|||||||
|
|
||||||
};
|
};
|
||||||
return names[m_e];
|
return names[m_e];
|
||||||
};
|
}
|
||||||
enum en m_e;
|
enum en m_e;
|
||||||
inline OrderVEdgeType () {};
|
inline OrderVEdgeType () {}
|
||||||
inline OrderVEdgeType (en _e) : m_e(_e) {};
|
inline OrderVEdgeType (en _e) : m_e(_e) {}
|
||||||
explicit inline OrderVEdgeType (int _e) : m_e(static_cast<en>(_e)) {};
|
explicit inline OrderVEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||||
operator en () const { return m_e; };
|
operator en () const { return m_e; }
|
||||||
};
|
};
|
||||||
inline bool operator== (OrderVEdgeType lhs, OrderVEdgeType rhs) { return (lhs.m_e == rhs.m_e); }
|
inline bool operator== (OrderVEdgeType lhs, OrderVEdgeType rhs) { return (lhs.m_e == rhs.m_e); }
|
||||||
inline bool operator== (OrderVEdgeType lhs, OrderVEdgeType::en rhs) { return (lhs.m_e == rhs); }
|
inline bool operator== (OrderVEdgeType lhs, OrderVEdgeType::en rhs) { return (lhs.m_e == rhs); }
|
||||||
|
|||||||
@@ -127,6 +127,14 @@ private:
|
|||||||
}
|
}
|
||||||
virtual void visit(AstCell* nodep, AstNUser*);
|
virtual void visit(AstCell* nodep, AstNUser*);
|
||||||
|
|
||||||
|
// Make sure all parameters are constantified
|
||||||
|
virtual void visit(AstVar* nodep, AstNUser*) {
|
||||||
|
if (nodep->isParam()) {
|
||||||
|
if (!nodep->hasSimpleInit()) { nodep->v3fatalSrc("Parameter without initial value"); }
|
||||||
|
V3Const::constifyParam(nodep); // The variable, not just the var->init()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generate Statements
|
// Generate Statements
|
||||||
virtual void visit(AstGenerate* nodep, AstNUser*) {
|
virtual void visit(AstGenerate* nodep, AstNUser*) {
|
||||||
if (debug()>=9) nodep->dumpTree(cout,"-genin: ");
|
if (debug()>=9) nodep->dumpTree(cout,"-genin: ");
|
||||||
|
|||||||
+12
-4
@@ -26,6 +26,8 @@
|
|||||||
#ifndef _VPREPROCLEX_H_ // Guard
|
#ifndef _VPREPROCLEX_H_ // Guard
|
||||||
#define _VPREPROCLEX_H_ 1
|
#define _VPREPROCLEX_H_ 1
|
||||||
|
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
#include "V3Error.h"
|
#include "V3Error.h"
|
||||||
|
|
||||||
// Token codes
|
// Token codes
|
||||||
@@ -105,7 +107,7 @@ class V3PreLex {
|
|||||||
|
|
||||||
// Parse state
|
// Parse state
|
||||||
FILE* m_fp; // File state is for
|
FILE* m_fp; // File state is for
|
||||||
YY_BUFFER_STATE m_yyState; // flex input state
|
stack<YY_BUFFER_STATE> m_bufferStack; // Stack of inserted text above current point
|
||||||
|
|
||||||
// State to lexer
|
// State to lexer
|
||||||
static V3PreLex* s_currentLexp; // Current lexing point
|
static V3PreLex* s_currentLexp; // Current lexing point
|
||||||
@@ -121,14 +123,18 @@ class V3PreLex {
|
|||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
V3PreLex(FILE* fp) {
|
V3PreLex(FILE* fp) {
|
||||||
m_fp = fp;
|
m_fp = fp;
|
||||||
m_yyState = yy_create_buffer (fp, YY_BUF_SIZE);
|
|
||||||
m_keepComments = 0;
|
m_keepComments = 0;
|
||||||
m_pedantic = false;
|
m_pedantic = false;
|
||||||
m_parenLevel = 0;
|
m_parenLevel = 0;
|
||||||
m_pslParenLevel = 0;
|
m_pslParenLevel = 0;
|
||||||
m_pslMoreNeeded = false;
|
m_pslMoreNeeded = false;
|
||||||
|
m_bufferStack.push(yy_create_buffer (fp, YY_BUF_SIZE));
|
||||||
|
yy_switch_to_buffer(m_bufferStack.top());
|
||||||
|
}
|
||||||
|
~V3PreLex() {
|
||||||
|
fclose(m_fp);
|
||||||
|
while (!m_bufferStack.empty()) { yy_delete_buffer(m_bufferStack.top()); m_bufferStack.pop(); }
|
||||||
}
|
}
|
||||||
~V3PreLex() { fclose(m_fp); yy_delete_buffer(m_yyState); }
|
|
||||||
|
|
||||||
// Called by V3PreLex.l from lexer
|
// Called by V3PreLex.l from lexer
|
||||||
void appendDefValue(const char* text, int len);
|
void appendDefValue(const char* text, int len);
|
||||||
@@ -139,9 +145,11 @@ class V3PreLex {
|
|||||||
void pushStateDefForm();
|
void pushStateDefForm();
|
||||||
void pushStateDefValue();
|
void pushStateDefValue();
|
||||||
void pushStateIncFilename();
|
void pushStateIncFilename();
|
||||||
void unputString(const char* textp);
|
void scanBytes(const string& strg);
|
||||||
/// Called by VPreproc.cpp to get data from lexer
|
/// Called by VPreproc.cpp to get data from lexer
|
||||||
|
YY_BUFFER_STATE currentBuffer();
|
||||||
int currentStartState();
|
int currentStartState();
|
||||||
|
void dumpStack();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Guard
|
#endif // Guard
|
||||||
|
|||||||
+28
-11
@@ -1,4 +1,3 @@
|
|||||||
/* -*- C++ -*- */
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* DESCRIPTION: Verilator: Flex verilog preprocessor
|
* DESCRIPTION: Verilator: Flex verilog preprocessor
|
||||||
*
|
*
|
||||||
@@ -69,7 +68,7 @@ wsn [ \t\f]
|
|||||||
crnl [\r]*[\n]
|
crnl [\r]*[\n]
|
||||||
quote [\"]
|
quote [\"]
|
||||||
backslash [\\]
|
backslash [\\]
|
||||||
symb [a-zA-Z_][a-zA-Z0-9_$]*
|
symb ([a-zA-Z_][a-zA-Z0-9_$]*|\\[^ \t\f\r\n]+)
|
||||||
drop [\032]
|
drop [\032]
|
||||||
psl [p]sl
|
psl [p]sl
|
||||||
|
|
||||||
@@ -131,6 +130,7 @@ psl [p]sl
|
|||||||
/* Note '(' must IMMEDIATELY follow definition name */
|
/* Note '(' must IMMEDIATELY follow definition name */
|
||||||
<DEFFPAR>[(] { appendDefValue("(",1); BEGIN(DEFFORM); }
|
<DEFFPAR>[(] { appendDefValue("(",1); BEGIN(DEFFORM); }
|
||||||
<DEFFPAR>{crnl} { yy_pop_state(); unput('\n'); yyleng=0; return VP_DEFFORM; } /* DEFVAL will later grab the return */
|
<DEFFPAR>{crnl} { yy_pop_state(); unput('\n'); yyleng=0; return VP_DEFFORM; } /* DEFVAL will later grab the return */
|
||||||
|
<DEFFPAR><<EOF>> { yy_pop_state(); return VP_DEFFORM; } /* empty formals */
|
||||||
<DEFFPAR>. { yy_pop_state(); unput(yytext[yyleng-1]); yyleng=0; return VP_DEFFORM; } /* empty formals */
|
<DEFFPAR>. { yy_pop_state(); unput(yytext[yyleng-1]); yyleng=0; return VP_DEFFORM; } /* empty formals */
|
||||||
|
|
||||||
/* Reading definition formals */
|
/* Reading definition formals */
|
||||||
@@ -204,7 +204,6 @@ psl [p]sl
|
|||||||
<PSLONEM>[{(] { pslParenLevelInc(); return (VP_TEXT); }
|
<PSLONEM>[{(] { pslParenLevelInc(); return (VP_TEXT); }
|
||||||
<PSLONEM>[})] { pslParenLevelDec(); return (VP_TEXT); }
|
<PSLONEM>[})] { pslParenLevelDec(); return (VP_TEXT); }
|
||||||
<PSLONEM>[;] { if (!pslParenLevel()) {BEGIN PSLONEE; pslMoreNeeded(false);} return (VP_TEXT); }
|
<PSLONEM>[;] { if (!pslParenLevel()) {BEGIN PSLONEE; pslMoreNeeded(false);} return (VP_TEXT); }
|
||||||
<PSLONEM><<EOF>> { yyerrorf("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); }
|
|
||||||
<PSLONEM>{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); }
|
<PSLONEM>{crnl} { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); }
|
||||||
|
|
||||||
/* Completed psl oneline comments */
|
/* Completed psl oneline comments */
|
||||||
@@ -224,16 +223,17 @@ psl [p]sl
|
|||||||
<CMTMODE>. { yymore(); }
|
<CMTMODE>. { yymore(); }
|
||||||
|
|
||||||
/* Psl C-style comments. */
|
/* Psl C-style comments. */
|
||||||
|
/* EOFs are normal because / * `foo(..) * / hits a unputString EOF */
|
||||||
<PSLMUL1>.|{crnl} { yyless(0); BEGIN PSLMULM; return(VP_PSL); }
|
<PSLMUL1>.|{crnl} { yyless(0); BEGIN PSLMULM; return(VP_PSL); }
|
||||||
<PSLMULM>"*/" { yy_pop_state(); return(VP_COMMENT); }
|
<PSLMULM>"*/" { yy_pop_state(); return(VP_COMMENT); }
|
||||||
<PSLMULM>"//"[^\n\r]* { return (VP_COMMENT); } /* Comments inside block comments get literal inclusion (later removal) */
|
<PSLMULM>"//"[^\n\r]* { return (VP_COMMENT); } /* Comments inside block comments get literal inclusion (later removal) */
|
||||||
<PSLMULM><<EOF>> { yyerrorf("EOF in '/* ... */' psl comment\n"); yyleng=0; yyterminate(); }
|
|
||||||
|
|
||||||
/* Define calls */
|
/* Define calls */
|
||||||
<INITIAL,PSLMULM,PSLONEM>"`"{symb} { return (VP_DEFREF); }
|
<INITIAL,PSLMULM,PSLONEM>"`"{symb} { return (VP_DEFREF); }
|
||||||
|
|
||||||
/* Generics */
|
/* Generics */
|
||||||
<INITIAL,PSLMULM>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); }
|
<INITIAL,PSLMULM>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); }
|
||||||
|
<INITIAL,PSLMULM,PSLONEM><<EOF>> { yyterminate(); } /* A "normal" EOF */
|
||||||
<INITIAL,PSLMULM,PSLONEM>{symb} { return (VP_SYMBOL); }
|
<INITIAL,PSLMULM,PSLONEM>{symb} { return (VP_SYMBOL); }
|
||||||
<INITIAL,PSLMULM,PSLONEM>{wsn}+ { return (VP_WHITE); }
|
<INITIAL,PSLMULM,PSLONEM>{wsn}+ { return (VP_WHITE); }
|
||||||
<INITIAL,PSLMULM,PSLONEM>{drop} { }
|
<INITIAL,PSLMULM,PSLONEM>{drop} { }
|
||||||
@@ -268,13 +268,9 @@ void V3PreLex::pushStateIncFilename() {
|
|||||||
yymore();
|
yymore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3PreLex::unputString(const char* textp) {
|
void V3PreLex::scanBytes(const string& strg) {
|
||||||
// Add characters to input stream in back-to-front order
|
yy_scan_bytes(strg.c_str(), strg.length());
|
||||||
const char* cp;
|
m_bufferStack.push(currentBuffer()); // yy_scan_bytes makes new buffer
|
||||||
for (cp = textp; *cp; cp++);
|
|
||||||
for (cp--; cp >= textp; cp--) {
|
|
||||||
unput(*cp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3PreLex::appendDefValue(const char* textp, int len) {
|
void V3PreLex::appendDefValue(const char* textp, int len) {
|
||||||
@@ -282,6 +278,10 @@ void V3PreLex::appendDefValue(const char* textp, int len) {
|
|||||||
m_defValue.append(textp,len);
|
m_defValue.append(textp,len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YY_BUFFER_STATE V3PreLex::currentBuffer() {
|
||||||
|
return YY_CURRENT_BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
int V3PreLex::currentStartState() {
|
int V3PreLex::currentStartState() {
|
||||||
return YY_START;
|
return YY_START;
|
||||||
}
|
}
|
||||||
@@ -291,3 +291,20 @@ void V3PreLex::lineDirective(const char* textp) {
|
|||||||
// Make sure we have a dependency on whatever file was specified
|
// Make sure we have a dependency on whatever file was specified
|
||||||
V3File::addSrcDepend(m_curFilelinep->filename());
|
V3File::addSrcDepend(m_curFilelinep->filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V3PreLex::dumpStack() {
|
||||||
|
// For debug use
|
||||||
|
stack<YY_BUFFER_STATE> tmpstack = m_bufferStack;
|
||||||
|
printf(" bufferStack[%p]:",this);
|
||||||
|
while (!tmpstack.empty()) {
|
||||||
|
printf(" %p",tmpstack.top());
|
||||||
|
tmpstack.pop();
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*###################################################################
|
||||||
|
* Local Variables:
|
||||||
|
* mode: C++
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
|
|||||||
+41
-13
@@ -160,6 +160,7 @@ private:
|
|||||||
|
|
||||||
bool commentTokenMatch(string& cmdr, const char* strg);
|
bool commentTokenMatch(string& cmdr, const char* strg);
|
||||||
string trimWhitespace(const string& strg);
|
string trimWhitespace(const string& strg);
|
||||||
|
void unputString(const string& strg);
|
||||||
|
|
||||||
void parsingOn() {
|
void parsingOn() {
|
||||||
m_off--;
|
m_off--;
|
||||||
@@ -386,6 +387,18 @@ const char* V3PreProcImp::tokenName(int tok) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V3PreProcImp::unputString(const string& strg) {
|
||||||
|
// We used to just m_lexp->unputString(strg.c_str());
|
||||||
|
// However this can lead to "flex scanner push-back overflow"
|
||||||
|
// so instead we scan from a temporary buffer, then on EOF return.
|
||||||
|
// This is also faster than the old scheme, amazingly.
|
||||||
|
if (m_lexp->m_bufferStack.empty() || m_lexp->m_bufferStack.top()!=m_lexp->currentBuffer()) {
|
||||||
|
fileline()->v3fatalSrc("bufferStack missing current buffer; will return incorrectly");
|
||||||
|
// Hard to debug lost text as won't know till much later
|
||||||
|
}
|
||||||
|
m_lexp->scanBytes(strg);
|
||||||
|
}
|
||||||
|
|
||||||
string V3PreProcImp::trimWhitespace(const string& strg) {
|
string V3PreProcImp::trimWhitespace(const string& strg) {
|
||||||
string out = strg;
|
string out = strg;
|
||||||
while (out.length()>0 && isspace(out[0])) {
|
while (out.length()>0 && isspace(out[0])) {
|
||||||
@@ -535,7 +548,6 @@ void V3PreProcImp::openFile(FileLine* fl, const string& filename) {
|
|||||||
addLineComment(1); // Enter
|
addLineComment(1); // Enter
|
||||||
|
|
||||||
yy_flex_debug = (debug()>4)?1:0;
|
yy_flex_debug = (debug()>4)?1:0;
|
||||||
yy_switch_to_buffer(m_lexp->m_yyState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3PreProcImp::insertUnreadbackAtBol(const string& text) {
|
void V3PreProcImp::insertUnreadbackAtBol(const string& text) {
|
||||||
@@ -560,16 +572,27 @@ void V3PreProcImp::addLineComment(int enter_exit_level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void V3PreProcImp::eof() {
|
void V3PreProcImp::eof() {
|
||||||
// Remove current lexer
|
// Perhaps we're completing unputString
|
||||||
UINFO(4,fileline()<<"EOF!\n");
|
if (m_lexp->m_bufferStack.size()>1) {
|
||||||
addLineComment(2); // Exit
|
UINFO(4,fileline()<<"EOS\n");
|
||||||
delete m_lexp; m_lexp=NULL;
|
// Switch to file or next unputString, but not a eof so don't delete lexer
|
||||||
// Perhaps there's a parent file including us?
|
yy_delete_buffer(m_lexp->currentBuffer());
|
||||||
if (!m_includeStack.empty()) {
|
m_lexp->m_bufferStack.pop(); // Must work as size>1
|
||||||
// Back to parent.
|
yy_switch_to_buffer(m_lexp->m_bufferStack.top());
|
||||||
m_lexp = m_includeStack.top(); m_includeStack.pop();
|
} else {
|
||||||
addLineComment(0);
|
// Remove current lexer
|
||||||
yy_switch_to_buffer(m_lexp->m_yyState);
|
UINFO(4,fileline()<<"EOF!\n");
|
||||||
|
addLineComment(2); // Exit
|
||||||
|
// Destructor will call yy_delete_buffer
|
||||||
|
delete m_lexp; m_lexp=NULL;
|
||||||
|
// Perhaps there's a parent file including us?
|
||||||
|
if (!m_includeStack.empty()) {
|
||||||
|
// Back to parent.
|
||||||
|
m_lexp = m_includeStack.top(); m_includeStack.pop();
|
||||||
|
addLineComment(0);
|
||||||
|
if (m_lexp->m_bufferStack.empty()) fileline()->v3fatalSrc("No include buffer to return to");
|
||||||
|
yy_switch_to_buffer(m_lexp->m_bufferStack.top()); // newest buffer in older lexer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,6 +817,7 @@ int V3PreProcImp::getToken() {
|
|||||||
if (m_defRefs.empty()) v3fatalSrc("Shouldn't be in DEFARG w/o active defref");
|
if (m_defRefs.empty()) v3fatalSrc("Shouldn't be in DEFARG w/o active defref");
|
||||||
V3DefineRef* refp = &(m_defRefs.top());
|
V3DefineRef* refp = &(m_defRefs.top());
|
||||||
refp->nextarg(refp->nextarg()+m_lexp->m_defValue); m_lexp->m_defValue="";
|
refp->nextarg(refp->nextarg()+m_lexp->m_defValue); m_lexp->m_defValue="";
|
||||||
|
UINFO(4,"defarg++ "<<refp->nextarg()<<endl);
|
||||||
if (tok==VP_DEFARG && yyleng==1 && yytext[0]==',') {
|
if (tok==VP_DEFARG && yyleng==1 && yytext[0]==',') {
|
||||||
refp->args().push_back(refp->nextarg());
|
refp->args().push_back(refp->nextarg());
|
||||||
m_state = ps_DEFARG;
|
m_state = ps_DEFARG;
|
||||||
@@ -806,13 +830,17 @@ int V3PreProcImp::getToken() {
|
|||||||
// Substitute in and prepare for next action
|
// Substitute in and prepare for next action
|
||||||
// Similar code in non-parenthesized define (Search for END_OF_DEFARG)
|
// Similar code in non-parenthesized define (Search for END_OF_DEFARG)
|
||||||
m_defRefs.pop();
|
m_defRefs.pop();
|
||||||
m_lexp->unputString(out.c_str());
|
|
||||||
if (m_defRefs.empty()) {
|
if (m_defRefs.empty()) {
|
||||||
|
unputString(out.c_str());
|
||||||
m_state = ps_TOP;
|
m_state = ps_TOP;
|
||||||
m_lexp->m_parenLevel = 0;
|
m_lexp->m_parenLevel = 0;
|
||||||
}
|
}
|
||||||
else { // Finished a defref inside a upper defref
|
else { // Finished a defref inside a upper defref
|
||||||
|
// Can't subst now, or
|
||||||
|
// `define a(ign) x,y
|
||||||
|
// foo(`a(ign),`b) would break because a contains comma
|
||||||
refp = &(m_defRefs.top()); // We popped, so new top
|
refp = &(m_defRefs.top()); // We popped, so new top
|
||||||
|
refp->nextarg(refp->nextarg()+m_lexp->m_defValue+out); m_lexp->m_defValue="";
|
||||||
m_lexp->m_parenLevel = refp->parenLevel();
|
m_lexp->m_parenLevel = refp->parenLevel();
|
||||||
m_state = ps_DEFARG;
|
m_state = ps_DEFARG;
|
||||||
}
|
}
|
||||||
@@ -936,7 +964,7 @@ int V3PreProcImp::getToken() {
|
|||||||
// Similar code in parenthesized define (Search for END_OF_DEFARG)
|
// Similar code in parenthesized define (Search for END_OF_DEFARG)
|
||||||
if (m_defRefs.empty()) {
|
if (m_defRefs.empty()) {
|
||||||
// Just output the substitution
|
// Just output the substitution
|
||||||
m_lexp->unputString(out.c_str());
|
unputString(out.c_str());
|
||||||
} else {
|
} else {
|
||||||
// Inside another define. Can't subst now, or
|
// Inside another define. Can't subst now, or
|
||||||
// `define a x,y
|
// `define a x,y
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ protected:
|
|||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
static V3PreProc* createPreProc(FileLine* fileline);
|
static V3PreProc* createPreProc(FileLine* fileline);
|
||||||
virtual ~V3PreProc() {};
|
virtual ~V3PreProc() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Guard
|
#endif // Guard
|
||||||
|
|||||||
+1
-1
@@ -103,7 +103,7 @@ public: // But for internal use only
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return next token, for bison, since bison isn't class based, use a global THIS
|
// Return next token, for bison, since bison isn't class based, use a global THIS
|
||||||
static int yylex() { return s_readp->yylexThis(); };
|
static int yylex() { return s_readp->yylexThis(); }
|
||||||
static FileLine* fileline() { return s_readp->m_fileline; }
|
static FileLine* fileline() { return s_readp->m_fileline; }
|
||||||
static AstNetlist* rootp() { return s_readp->m_rootp; }
|
static AstNetlist* rootp() { return s_readp->m_rootp; }
|
||||||
static FileLine* copyOrSameFileLine() { return s_readp->fileline()->copyOrSameFileLine(); }
|
static FileLine* copyOrSameFileLine() { return s_readp->fileline()->copyOrSameFileLine(); }
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ private:
|
|||||||
if (!inPct && ch=='%') {
|
if (!inPct && ch=='%') {
|
||||||
inPct = true;
|
inPct = true;
|
||||||
} else if (inPct && isdigit(ch)) {
|
} else if (inPct && isdigit(ch)) {
|
||||||
} else if (inPct) {
|
} else if (tolower(inPct)) {
|
||||||
inPct = false;
|
inPct = false;
|
||||||
switch (tolower(ch)) {
|
switch (tolower(ch)) {
|
||||||
case '%': break; // %% - just output a %
|
case '%': break; // %% - just output a %
|
||||||
|
|||||||
@@ -0,0 +1,599 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
//*************************************************************************
|
||||||
|
// DESCRIPTION: Verilator: Simulate code to determine output values/variables
|
||||||
|
//
|
||||||
|
// Code available from: http://www.veripool.org/verilator
|
||||||
|
//
|
||||||
|
// AUTHORS: Wilson Snyder with Paul Wasson, Duane Gabli
|
||||||
|
//
|
||||||
|
//*************************************************************************
|
||||||
|
//
|
||||||
|
// Copyright 2003-2009 by Wilson Snyder. This program is free software; you can
|
||||||
|
// redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
// Version 2.0.
|
||||||
|
//
|
||||||
|
// Verilator is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
//*************************************************************************
|
||||||
|
//
|
||||||
|
// void example_usage() {
|
||||||
|
// SimulateVisitor simvis (false, false);
|
||||||
|
// simvis.clear();
|
||||||
|
// // Set all inputs to the constant
|
||||||
|
// for (deque<AstVarScope*>::iterator it = m_inVarps.begin(); it!=m_inVarps.end(); ++it) {
|
||||||
|
// simvis.newNumber(invscp, #);
|
||||||
|
// }
|
||||||
|
// // Simulate
|
||||||
|
// simvis.main(nodep);
|
||||||
|
// // Read outputs
|
||||||
|
// for (deque<AstVarScope*>::iterator it = m_outVarps.begin(); it!=m_outVarps.end(); ++it) {
|
||||||
|
// V3Number* outnump = simvis.fetchOutNumberNull(outvscp);
|
||||||
|
//
|
||||||
|
//*************************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _V3SIMULATE_H_
|
||||||
|
#define _V3SIMULATE_H_ 1
|
||||||
|
#include "config_build.h"
|
||||||
|
#include "verilatedos.h"
|
||||||
|
#include "V3Error.h"
|
||||||
|
#include "V3Ast.h"
|
||||||
|
#include "V3Width.h"
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
//######################################################################
|
||||||
|
// Simulate class functions
|
||||||
|
|
||||||
|
class SimulateVisitor : public AstNVisitor {
|
||||||
|
// Simulate a node tree, returning value of variables
|
||||||
|
// Two major operating modes:
|
||||||
|
// Test the tree to see if it is conformant
|
||||||
|
// Given a set of input values, find the output values
|
||||||
|
// Both are done in this same visitor to reduce risk; if a visitor
|
||||||
|
// is missing, we will simply not apply the optimization, rather then bomb.
|
||||||
|
|
||||||
|
private:
|
||||||
|
// NODE STATE
|
||||||
|
// Cleared on each always/assignw
|
||||||
|
AstUser1InUse m_inuser1;
|
||||||
|
AstUser2InUse m_inuser2;
|
||||||
|
AstUser3InUse m_inuser3;
|
||||||
|
|
||||||
|
// Checking:
|
||||||
|
// AstVarScope::user1() -> VarUsage. Set true to indicate tracking as lvalue/rvalue
|
||||||
|
// Simulating:
|
||||||
|
// AstVarScope::user3() -> V3Number*. Input value of variable or node (and output for non-delayed assignments)
|
||||||
|
// AstVarScope::user2() -> V3Number*. Output value of variable (delayed assignments)
|
||||||
|
|
||||||
|
enum VarUsage { VU_NONE=0, VU_LV=1, VU_RV=2, VU_LVDLY=4 };
|
||||||
|
|
||||||
|
// STATE
|
||||||
|
// Major mode
|
||||||
|
bool m_checkOnly; ///< Checking only (no simulation) mode
|
||||||
|
bool m_scoped; ///< Running with AstVarScopes instead of AstVars
|
||||||
|
bool m_params; ///< Doing parameter propagation
|
||||||
|
// Checking:
|
||||||
|
string m_whyNotOptimizable; ///< String explaining why not optimizable or NULL to optimize
|
||||||
|
AstNode* m_whyNotNodep; ///< First node not optimizable
|
||||||
|
bool m_anyAssignDly; ///< True if found a delayed assignment
|
||||||
|
bool m_anyAssignComb; ///< True if found a non-delayed assignment
|
||||||
|
bool m_inDlyAssign; ///< Under delayed assignment
|
||||||
|
int m_instrCount; ///< Number of nodes
|
||||||
|
int m_dataCount; ///< Bytes of data
|
||||||
|
// Simulating:
|
||||||
|
deque<V3Number*> m_numFreeps; ///< List of all numbers free and not in use
|
||||||
|
deque<V3Number*> m_numAllps; ///< List of all numbers free and in use
|
||||||
|
|
||||||
|
// Note level 8&9 include debugging each simulation value
|
||||||
|
static int debug() {
|
||||||
|
static int level = -1;
|
||||||
|
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checking METHODS
|
||||||
|
public:
|
||||||
|
/// Call other-this function on all new var references
|
||||||
|
virtual void varRefCb(AstVarRef* nodep) {}
|
||||||
|
|
||||||
|
void clearOptimizable(AstNode* nodep/*null ok*/, const string& why) {
|
||||||
|
// Something bad found. optimizable() will return false,
|
||||||
|
// and fetchNumber should not be called or it may assert.
|
||||||
|
if (!m_whyNotNodep) {
|
||||||
|
m_whyNotNodep = nodep;
|
||||||
|
if (debug()>=5) {
|
||||||
|
UINFO(0,"Clear optimizable: "<<why);
|
||||||
|
if (nodep) cout<<": "<<nodep;
|
||||||
|
cout<<endl;
|
||||||
|
}
|
||||||
|
m_whyNotOptimizable = why;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inline bool optimizable() const { return m_whyNotNodep==NULL; }
|
||||||
|
string whyNotMessage() const { return m_whyNotOptimizable; }
|
||||||
|
AstNode* whyNotNodep() const { return m_whyNotNodep; }
|
||||||
|
|
||||||
|
bool isAssignDly() const { return m_anyAssignDly; }
|
||||||
|
int instrCount() const { return m_instrCount; }
|
||||||
|
int dataCount() const { return m_dataCount; }
|
||||||
|
|
||||||
|
// Simulation METHODS
|
||||||
|
private:
|
||||||
|
V3Number* allocNumber(AstNode* nodep, uint32_t value) {
|
||||||
|
// Save time - kept a list of allocated but unused V3Numbers
|
||||||
|
// It would be more efficient to do this by size, but the extra accounting
|
||||||
|
// slows things down more than we gain.
|
||||||
|
V3Number* nump;
|
||||||
|
if (!m_numFreeps.empty()) {
|
||||||
|
//UINFO(7,"Num Reuse "<<nodep->width()<<endl);
|
||||||
|
nump = m_numFreeps.back(); m_numFreeps.pop_back();
|
||||||
|
nump->width(nodep->width());
|
||||||
|
nump->fileline(nodep->fileline());
|
||||||
|
nump->setLong(value); // We do support more than 32 bit numbers, just valuep=0 in that case
|
||||||
|
} else {
|
||||||
|
//UINFO(7,"Num New "<<nodep->width()<<endl);
|
||||||
|
nump = new V3Number (nodep->fileline(), nodep->width(), value);
|
||||||
|
m_numAllps.push_back(nump);
|
||||||
|
}
|
||||||
|
return nump;
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
V3Number* newNumber(AstNode* nodep, uint32_t value=0) {
|
||||||
|
// Set a constant value for this node
|
||||||
|
if (!nodep->user3p()) {
|
||||||
|
V3Number* nump = allocNumber(nodep, value);
|
||||||
|
setNumber(nodep, nump);
|
||||||
|
return nump;
|
||||||
|
} else {
|
||||||
|
return (fetchNumber(nodep));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
V3Number* newOutNumber(AstNode* nodep, uint32_t value=0) {
|
||||||
|
// Set a constant value for this node
|
||||||
|
if (!nodep->user2p()) {
|
||||||
|
V3Number* nump = allocNumber(nodep, value);
|
||||||
|
setOutNumber(nodep, nump);
|
||||||
|
return nump;
|
||||||
|
} else {
|
||||||
|
return (fetchOutNumber(nodep));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
V3Number* fetchNumberNull(AstNode* nodep) {
|
||||||
|
return ((V3Number*)nodep->user3p());
|
||||||
|
}
|
||||||
|
V3Number* fetchOutNumberNull(AstNode* nodep) {
|
||||||
|
return ((V3Number*)nodep->user2p());
|
||||||
|
}
|
||||||
|
V3Number* fetchNumber(AstNode* nodep) {
|
||||||
|
V3Number* nump = fetchNumberNull(nodep);
|
||||||
|
if (!nump) nodep->v3fatalSrc("No value found for node.");
|
||||||
|
//UINFO(9," fetch num "<<*nump<<" on "<<nodep<<endl);
|
||||||
|
return nump;
|
||||||
|
}
|
||||||
|
V3Number* fetchOutNumber(AstNode* nodep) {
|
||||||
|
V3Number* nump = fetchOutNumberNull(nodep);
|
||||||
|
if (!nump) nodep->v3fatalSrc("No value found for node.");
|
||||||
|
return nump;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
inline void setNumber(AstNode* nodep, const V3Number* nump) {
|
||||||
|
UINFO(9," set num "<<*nump<<" on "<<nodep<<endl);
|
||||||
|
nodep->user3p((AstNUser*)nump);
|
||||||
|
}
|
||||||
|
inline void setOutNumber(AstNode* nodep, const V3Number* nump) {
|
||||||
|
UINFO(9," set num "<<*nump<<" on "<<nodep<<endl);
|
||||||
|
nodep->user2p((AstNUser*)nump);
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkNodeInfo(AstNode* nodep) {
|
||||||
|
if (m_checkOnly) {
|
||||||
|
m_instrCount += nodep->instrCount();
|
||||||
|
m_dataCount += nodep->width();
|
||||||
|
}
|
||||||
|
if (!nodep->isPredictOptimizable()) {
|
||||||
|
//UINFO(9," !predictopt "<<nodep<<endl);
|
||||||
|
clearOptimizable(nodep,"Isn't predictable");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void badNodeType(AstNode* nodep) {
|
||||||
|
// Call for default node types, or other node types we don't know how to handle
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (optimizable()) {
|
||||||
|
// Hmm, what is this then?
|
||||||
|
// In production code, we'll just not optimize. It should be fixed though.
|
||||||
|
clearOptimizable(nodep, "Unknown node type, perhaps missing visitor in SimulateVisitor");
|
||||||
|
#ifdef VL_DEBUG
|
||||||
|
UINFO(0,"Unknown node type in SimulateVisitor: "<<nodep->prettyTypeName()<<endl);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AstNode* varOrScope(AstVarRef* nodep) {
|
||||||
|
AstNode* vscp;
|
||||||
|
if (m_scoped) vscp = nodep->varScopep();
|
||||||
|
else vscp = nodep->varp();
|
||||||
|
if (!vscp) nodep->v3fatalSrc("Not linked");
|
||||||
|
return vscp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int unrollCount() {
|
||||||
|
return m_params ? v3Global.opt.unrollCount()*16
|
||||||
|
: v3Global.opt.unrollCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// VISITORS
|
||||||
|
virtual void visit(AstAlways* nodep, AstNUser*) {
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
}
|
||||||
|
virtual void visit(AstSenTree* nodep, AstNUser*) {
|
||||||
|
// Sensitivities aren't inputs per se; we'll keep our tree under the same sens.
|
||||||
|
}
|
||||||
|
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
AstNode* vscp = varOrScope(nodep);
|
||||||
|
|
||||||
|
// We can't have non-delayed assignments with same value on LHS and RHS
|
||||||
|
// as we don't figure out variable ordering.
|
||||||
|
// Delayed is OK though, as we'll decode the next state separately.
|
||||||
|
if (nodep->varp()->arraysp()) clearOptimizable(nodep,"Array references");
|
||||||
|
if (nodep->lvalue()) {
|
||||||
|
if (m_inDlyAssign) {
|
||||||
|
if (!(vscp->user1() & VU_LVDLY)) {
|
||||||
|
vscp->user1( vscp->user1() | VU_LVDLY);
|
||||||
|
if (m_checkOnly) varRefCb (nodep);
|
||||||
|
}
|
||||||
|
} else { // nondly asn
|
||||||
|
if (!(vscp->user1() & VU_LV)) {
|
||||||
|
if (!m_params && (vscp->user1() & VU_RV)) clearOptimizable(nodep,"Var read & write");
|
||||||
|
vscp->user1( vscp->user1() | VU_LV);
|
||||||
|
if (m_checkOnly) varRefCb (nodep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(vscp->user1() & VU_RV)) {
|
||||||
|
if (!m_params && (vscp->user1() & VU_LV)) clearOptimizable(nodep,"Var write & read");
|
||||||
|
vscp->user1( vscp->user1() | VU_RV);
|
||||||
|
if (m_checkOnly) varRefCb (nodep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!m_checkOnly && optimizable()) { // simulating
|
||||||
|
if (nodep->lvalue()) {
|
||||||
|
nodep->v3fatalSrc("LHS varref should be handled in AstAssign visitor.");
|
||||||
|
} else {
|
||||||
|
// Return simulation value - copy by reference instead of value for speed
|
||||||
|
V3Number* nump = fetchNumberNull(vscp);
|
||||||
|
if (!nump) {
|
||||||
|
if (m_params) {
|
||||||
|
clearOptimizable(nodep,"Language violation: reference to non-function-local variable");
|
||||||
|
} else {
|
||||||
|
nodep->v3fatalSrc("Variable value should have been set before any visitor called.");
|
||||||
|
}
|
||||||
|
nump = allocNumber(nodep, 0); // Any value; just so recover from error
|
||||||
|
}
|
||||||
|
setNumber(nodep, nump);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstVarXRef* nodep, AstNUser*) {
|
||||||
|
if (m_scoped) { badNodeType(nodep); return; }
|
||||||
|
else { clearOptimizable(nodep,"Language violation: Dotted hierarchical references not allowed in constant functions"); }
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeFTask* nodep, AstNUser*) {
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeIf* nodep, AstNUser*) {
|
||||||
|
UINFO(5," IF "<<nodep<<endl);
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
} else {
|
||||||
|
nodep->condp()->iterateAndNext(*this);
|
||||||
|
if (optimizable()) {
|
||||||
|
if (fetchNumber(nodep->condp())->isNeqZero()) {
|
||||||
|
nodep->ifsp()->iterateAndNext(*this);
|
||||||
|
} else {
|
||||||
|
nodep->elsesp()->iterateAndNext(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstConst* nodep, AstNUser*) {
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
setNumber(nodep, &(nodep->num()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeUniop* nodep, AstNUser*) {
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeBiop* nodep, AstNUser*) {
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()), *fetchNumber(nodep->rhsp()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeTriop* nodep, AstNUser*) {
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
nodep->numberOperate(*newNumber(nodep),
|
||||||
|
*fetchNumber(nodep->lhsp()),
|
||||||
|
*fetchNumber(nodep->rhsp()),
|
||||||
|
*fetchNumber(nodep->thsp()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeCond* nodep, AstNUser*) {
|
||||||
|
// We could use above visit(AstNodeTriop), but it's slower even O(n^2) to evaluate
|
||||||
|
// both sides when we really only need to evaluate one side.
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
} else {
|
||||||
|
nodep->condp()->accept(*this);
|
||||||
|
if (optimizable()) {
|
||||||
|
if (fetchNumber(nodep->condp())->isNeqZero()) {
|
||||||
|
nodep->expr1p()->accept(*this);
|
||||||
|
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr1p()));
|
||||||
|
} else {
|
||||||
|
nodep->expr2p()->accept(*this);
|
||||||
|
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr2p()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeAssign* nodep, AstNUser*) {
|
||||||
|
if (!optimizable()) return; // Accelerate
|
||||||
|
if (nodep->castAssignDly()) {
|
||||||
|
if (m_anyAssignComb) clearOptimizable(nodep, "Mix of dly/non dly assigns");
|
||||||
|
m_anyAssignDly = true;
|
||||||
|
m_inDlyAssign = true;
|
||||||
|
} else {
|
||||||
|
if (m_anyAssignDly) clearOptimizable(nodep, "Mix of dly/non dly assigns");
|
||||||
|
m_anyAssignComb = true;
|
||||||
|
}
|
||||||
|
if (!nodep->lhsp()->castVarRef()) {
|
||||||
|
clearOptimizable(nodep, "LHS isn't simple variable");
|
||||||
|
}
|
||||||
|
else if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
}
|
||||||
|
else if (optimizable()) {
|
||||||
|
nodep->rhsp()->iterateAndNext(*this);
|
||||||
|
if (optimizable()) {
|
||||||
|
AstNode* vscp = varOrScope(nodep->lhsp()->castVarRef());
|
||||||
|
// Copy by value, not reference, as we don't want a=a+1 to get right results
|
||||||
|
if (nodep->castAssignDly()) {
|
||||||
|
// Don't do setNumber, as value isn't yet visible to following statements
|
||||||
|
newOutNumber(vscp)->opAssign(*fetchNumber(nodep->rhsp()));
|
||||||
|
} else {
|
||||||
|
newNumber(vscp)->opAssign(*fetchNumber(nodep->rhsp()));
|
||||||
|
newOutNumber(vscp)->opAssign(*fetchNumber(nodep->rhsp()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_inDlyAssign = false;
|
||||||
|
}
|
||||||
|
virtual void visit(AstBegin* nodep, AstNUser*) {
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
}
|
||||||
|
virtual void visit(AstNodeCase* nodep, AstNUser*) {
|
||||||
|
UINFO(5," CASE "<<nodep<<endl);
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
} else if (optimizable()) {
|
||||||
|
nodep->exprp()->iterateAndNext(*this);
|
||||||
|
bool hit = false;
|
||||||
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
|
||||||
|
if (!itemp->isDefault()) {
|
||||||
|
for (AstNode* ep = itemp->condsp(); ep; ep=ep->nextp()) {
|
||||||
|
if (hit) break;
|
||||||
|
ep->iterateAndNext(*this);
|
||||||
|
if (optimizable()) {
|
||||||
|
V3Number match (nodep->fileline(), 1);
|
||||||
|
match.opEq(*fetchNumber(nodep->exprp()), *fetchNumber(ep));
|
||||||
|
if (match.isNeqZero()) {
|
||||||
|
itemp->bodysp()->iterateAndNext(*this);
|
||||||
|
hit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Else default match
|
||||||
|
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
|
||||||
|
if (hit) break;
|
||||||
|
if (!hit && itemp->isDefault()) {
|
||||||
|
itemp->bodysp()->iterateAndNext(*this);
|
||||||
|
hit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstCaseItem* nodep, AstNUser*) {
|
||||||
|
// Real handling is in AstNodeCase
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstComment*, AstNUser*) {}
|
||||||
|
|
||||||
|
virtual void visit(AstStop* nodep, AstNUser*) {
|
||||||
|
if (m_params) { // This message seems better than an obscure $stop
|
||||||
|
// The spec says $stop is just ignored, it seems evil to ignore assertions
|
||||||
|
clearOptimizable(nodep,"$stop executed during function constification; maybe indicates assertion firing");
|
||||||
|
}
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstNodeFor* nodep, AstNUser*) {
|
||||||
|
// Doing lots of Whiles is slow, so only for parameters
|
||||||
|
UINFO(5," FOR "<<nodep<<endl);
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
} else if (optimizable()) {
|
||||||
|
int loops = 0;
|
||||||
|
nodep->initsp()->iterateAndNext(*this);
|
||||||
|
while (1) {
|
||||||
|
UINFO(5," FOR-ITER "<<nodep<<endl);
|
||||||
|
nodep->condp()->iterateAndNext(*this);
|
||||||
|
if (!optimizable()) break;
|
||||||
|
if (!fetchNumber(nodep->condp())->isNeqZero()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nodep->bodysp()->iterateAndNext(*this);
|
||||||
|
nodep->incsp()->iterateAndNext(*this);
|
||||||
|
if (loops++ > unrollCount()*16) {
|
||||||
|
clearOptimizable(nodep, "Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above "+cvtToStr(unrollCount()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstWhile* nodep, AstNUser*) {
|
||||||
|
// Doing lots of Whiles is slow, so only for parameters
|
||||||
|
UINFO(5," WHILE "<<nodep<<endl);
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
checkNodeInfo(nodep);
|
||||||
|
if (m_checkOnly) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
} else if (optimizable()) {
|
||||||
|
int loops = 0;
|
||||||
|
while (1) {
|
||||||
|
UINFO(5," WHILE-ITER "<<nodep<<endl);
|
||||||
|
nodep->precondsp()->iterateAndNext(*this);
|
||||||
|
nodep->condp()->iterateAndNext(*this);
|
||||||
|
if (!optimizable()) break;
|
||||||
|
if (!fetchNumber(nodep->condp())->isNeqZero()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nodep->bodysp()->iterateAndNext(*this);
|
||||||
|
if (loops++ > unrollCount()*16) {
|
||||||
|
clearOptimizable(nodep, "Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above "+cvtToStr(unrollCount()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstFuncRef* nodep, AstNUser*) {
|
||||||
|
UINFO(5," FUNCREF "<<nodep<<endl);
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
AstFunc* funcp = nodep->taskp()->castFunc(); if (!funcp) nodep->v3fatalSrc("Not linked");
|
||||||
|
V3Width::widthSignedIfNotAlready(funcp); // Make sure we've sized the function
|
||||||
|
// Apply function call values to function
|
||||||
|
// Note we'd need a stack if we allowed recursive functions!
|
||||||
|
AstNode* pinp = nodep->pinsp(); AstNode* nextpinp = NULL;
|
||||||
|
for (AstNode* stmtp = funcp->stmtsp(); stmtp; pinp=nextpinp, stmtp=stmtp->nextp()) {
|
||||||
|
if (AstVar* portp = stmtp->castVar()) {
|
||||||
|
if (portp->isIO()) {
|
||||||
|
if (pinp==NULL) {
|
||||||
|
nodep->v3error("Too few arguments in function call");
|
||||||
|
} else {
|
||||||
|
nextpinp = pinp->nextp();
|
||||||
|
if (portp->isOutput()) {
|
||||||
|
clearOptimizable(portp,"Language violation: Outputs not allowed in constant functions");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Evaluate pin value
|
||||||
|
pinp->accept(*this);
|
||||||
|
// Apply value to the function
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
newNumber(stmtp)->opAssign(*fetchNumber(pinp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Evaluate the function
|
||||||
|
funcp->accept(*this);
|
||||||
|
if (!m_checkOnly && optimizable()) {
|
||||||
|
// Grab return value from output variable
|
||||||
|
newNumber(nodep)->opAssign(*fetchNumber(funcp->fvarp()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void visit(AstVar* nodep, AstNUser*) {
|
||||||
|
if (!m_params) { badNodeType(nodep); return; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// default
|
||||||
|
// These types are definately not reducable
|
||||||
|
// AstCoverInc, AstNodePli, AstArraySel, AstStop, AstFinish,
|
||||||
|
// AstRand, AstTime, AstUCFunc, AstCCall, AstCStmt, AstUCStmt
|
||||||
|
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||||
|
badNodeType(nodep);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
// CONSTRUCTORS
|
||||||
|
SimulateVisitor() {
|
||||||
|
setMode(false,false,false);
|
||||||
|
clear(); // We reuse this structure in the main loop, so put initializers inside clear()
|
||||||
|
}
|
||||||
|
void setMode(bool scoped, bool checkOnly, bool params) {
|
||||||
|
m_checkOnly = checkOnly;
|
||||||
|
m_scoped = scoped;
|
||||||
|
m_params = params;
|
||||||
|
}
|
||||||
|
void clear() {
|
||||||
|
m_whyNotOptimizable = "";
|
||||||
|
m_whyNotNodep = NULL;
|
||||||
|
m_anyAssignComb = false;
|
||||||
|
m_anyAssignDly = false;
|
||||||
|
m_inDlyAssign = false;
|
||||||
|
m_instrCount = 0;
|
||||||
|
m_dataCount = 0;
|
||||||
|
|
||||||
|
AstNode::user1ClearTree(); // user1p() used on entire tree
|
||||||
|
AstNode::user2ClearTree(); // user2p() used on entire tree
|
||||||
|
AstNode::user3ClearTree(); // user3p() used on entire tree
|
||||||
|
|
||||||
|
// Move all allocated numbers to the free pool
|
||||||
|
m_numFreeps = m_numAllps;
|
||||||
|
}
|
||||||
|
void mainTableCheck (AstNode* nodep) {
|
||||||
|
setMode(true/*scoped*/,true/*checking*/, false/*params*/);
|
||||||
|
nodep->accept(*this);
|
||||||
|
}
|
||||||
|
void mainTableEmulate (AstNode* nodep) {
|
||||||
|
setMode(true/*scoped*/,false/*checking*/, false/*params*/);
|
||||||
|
nodep->accept(*this);
|
||||||
|
}
|
||||||
|
void mainParamEmulate (AstNode* nodep) {
|
||||||
|
setMode(false/*scoped*/,false/*checking*/, true/*params*/);
|
||||||
|
nodep->accept(*this);
|
||||||
|
}
|
||||||
|
virtual ~SimulateVisitor() {
|
||||||
|
for (deque<V3Number*>::iterator it = m_numAllps.begin(); it != m_numAllps.end(); ++it) {
|
||||||
|
delete (*it);
|
||||||
|
}
|
||||||
|
m_numFreeps.clear();
|
||||||
|
m_numAllps.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // Guard
|
||||||
+8
-8
@@ -34,19 +34,19 @@ class V3Double0 {
|
|||||||
double m_d; ///< Count of occurrences/ value
|
double m_d; ///< Count of occurrences/ value
|
||||||
public:
|
public:
|
||||||
// METHODS
|
// METHODS
|
||||||
V3Double0() : m_d(0) {};
|
V3Double0() : m_d(0) {}
|
||||||
~V3Double0() {}
|
~V3Double0() {}
|
||||||
|
|
||||||
// Implicit conversion operators:
|
// Implicit conversion operators:
|
||||||
inline V3Double0 (const vluint64_t v) : m_d(v) { };
|
inline V3Double0 (const vluint64_t v) : m_d(v) { }
|
||||||
inline operator double () const { return m_d; };
|
inline operator double () const { return m_d; }
|
||||||
|
|
||||||
// Explicit operators:
|
// Explicit operators:
|
||||||
inline V3Double0& operator++() { ++m_d; return *this; }; // prefix
|
inline V3Double0& operator++() { ++m_d; return *this; } // prefix
|
||||||
inline V3Double0 operator++(int) { V3Double0 old=*this; m_d++; return old; }; // postfix
|
inline V3Double0 operator++(int) { V3Double0 old=*this; m_d++; return old; } // postfix
|
||||||
inline V3Double0& operator= (const double v) { m_d = v; return *this; };
|
inline V3Double0& operator= (const double v) { m_d = v; return *this; }
|
||||||
inline V3Double0& operator+=(const double v) { m_d += v; return *this; };
|
inline V3Double0& operator+=(const double v) { m_d += v; return *this; }
|
||||||
inline V3Double0& operator-=(const double v) { m_d -= v; return *this; };
|
inline V3Double0& operator-=(const double v) { m_d -= v; return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|||||||
+26
-352
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include "V3Global.h"
|
#include "V3Global.h"
|
||||||
#include "V3Table.h"
|
#include "V3Table.h"
|
||||||
|
#include "V3Simulate.h"
|
||||||
#include "V3Stats.h"
|
#include "V3Stats.h"
|
||||||
#include "V3Ast.h"
|
#include "V3Ast.h"
|
||||||
|
|
||||||
@@ -48,365 +49,31 @@ static const double TABLE_TOTAL_BYTES = 64*1024*1024; // 64MB is close to max me
|
|||||||
static const double TABLE_SPACE_TIME_MULT = 8; // Worth 8 bytes of data to replace a instruction
|
static const double TABLE_SPACE_TIME_MULT = 8; // Worth 8 bytes of data to replace a instruction
|
||||||
static const int TABLE_MIN_NODE_COUNT = 32; // If < 32 instructions, not worth the effort
|
static const int TABLE_MIN_NODE_COUNT = 32; // If < 32 instructions, not worth the effort
|
||||||
|
|
||||||
|
//######################################################################
|
||||||
|
|
||||||
class TableVisitor;
|
class TableVisitor;
|
||||||
|
|
||||||
//######################################################################
|
class TableSimulateVisitor : public SimulateVisitor {
|
||||||
|
// MEMBERS
|
||||||
class TableBaseVisitor : public AstNVisitor {
|
|
||||||
public:
|
|
||||||
// Note level 8&9 include debugging each simulation value
|
|
||||||
static int debug() {
|
|
||||||
static int level = -1;
|
|
||||||
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//######################################################################
|
|
||||||
|
|
||||||
class TableSimulateVisitor : public TableBaseVisitor {
|
|
||||||
// Simulate a node tree, returning value of variables
|
|
||||||
// Two major operating modes:
|
|
||||||
// Test the tree to see if it is conformant
|
|
||||||
// Given a set of input values, find the output values
|
|
||||||
// Both are done in this same visitor to reduce risk; if a visitor
|
|
||||||
// is missing, we will simply not apply the optimization, rather then bomb.
|
|
||||||
|
|
||||||
private:
|
|
||||||
// NODE STATE
|
|
||||||
// Cleared on each always/assignw
|
|
||||||
// Checking:
|
|
||||||
// AstVarScope::user1() -> VarUsage. Set true to indicate tracking as lvalue/rvalue
|
|
||||||
// Simulating:
|
|
||||||
// AstVarScope::user3() -> V3Number*. Input value of variable or node (and output for non-delayed assignments)
|
|
||||||
// AstVarScope::user4() -> V3Number*. Output value of variable (delayed assignments)
|
|
||||||
|
|
||||||
enum VarUsage { VU_NONE=0, VU_LV=1, VU_RV=2, VU_LVDLY=4 };
|
|
||||||
|
|
||||||
// STATE
|
|
||||||
bool m_checking; ///< Checking vs. simulation mode
|
|
||||||
// Checking:
|
|
||||||
TableVisitor* m_cbthis; ///< Class for callback
|
TableVisitor* m_cbthis; ///< Class for callback
|
||||||
const char* m_whyNotOptimizable; ///< String explaining why not optimizable or NULL to optimize
|
|
||||||
bool m_anyAssignDly; ///< True if found a delayed assignment
|
|
||||||
bool m_anyAssignComb; ///< True if found a non-delayed assignment
|
|
||||||
bool m_inDlyAssign; ///< Under delayed assignment
|
|
||||||
int m_instrCount; ///< Number of nodes
|
|
||||||
int m_dataCount; ///< Bytes of data
|
|
||||||
// Simulating:
|
|
||||||
deque<V3Number*> m_numFreeps; ///< List of all numbers free and not in use
|
|
||||||
deque<V3Number*> m_numAllps; ///< List of all numbers free and in use
|
|
||||||
|
|
||||||
// Checking METHODS
|
|
||||||
public:
|
|
||||||
void varRefCb(AstVarRef* nodep); ///< Call other-this function on all new var references
|
|
||||||
|
|
||||||
void clearOptimizable(AstNode* nodep/*null ok*/, const char* why) {
|
|
||||||
if (!m_whyNotOptimizable) {
|
|
||||||
if (debug()>=5) {
|
|
||||||
UINFO(0,"Clear optimizable: "<<why);
|
|
||||||
if (nodep) cout<<": "<<nodep;
|
|
||||||
cout<<endl;
|
|
||||||
}
|
|
||||||
m_whyNotOptimizable = why;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool optimizable() const { return m_whyNotOptimizable==NULL; }
|
|
||||||
bool isAssignDly() const { return m_anyAssignDly; }
|
|
||||||
int instrCount() const { return m_instrCount; }
|
|
||||||
int dataCount() const { return m_dataCount; }
|
|
||||||
|
|
||||||
// Simulation METHODS
|
|
||||||
private:
|
|
||||||
V3Number* allocNumber(AstNode* nodep, uint32_t value) {
|
|
||||||
// Save time - kept a list of allocated but unused V3Numbers
|
|
||||||
// It would be more efficient to do this by size, but the extra accounting
|
|
||||||
// slows things down more than we gain.
|
|
||||||
V3Number* nump;
|
|
||||||
if (!m_numFreeps.empty()) {
|
|
||||||
//UINFO(7,"Num Reuse "<<nodep->width()<<endl);
|
|
||||||
nump = m_numFreeps.back(); m_numFreeps.pop_back();
|
|
||||||
nump->width(nodep->width());
|
|
||||||
nump->fileline(nodep->fileline());
|
|
||||||
nump->setLong(value); // We do support more than 32 bit numbers, just valuep=0 in that case
|
|
||||||
} else {
|
|
||||||
//UINFO(7,"Num New "<<nodep->width()<<endl);
|
|
||||||
nump = new V3Number (nodep->fileline(), nodep->width(), value);
|
|
||||||
m_numAllps.push_back(nump);
|
|
||||||
}
|
|
||||||
return nump;
|
|
||||||
}
|
|
||||||
public:
|
|
||||||
V3Number* newNumber(AstNode* nodep, uint32_t value=0) {
|
|
||||||
// Set a constant value for this node
|
|
||||||
if (!nodep->user3p()) {
|
|
||||||
V3Number* nump = allocNumber(nodep, value);
|
|
||||||
setNumber(nodep, nump);
|
|
||||||
}
|
|
||||||
return (fetchNumber(nodep));
|
|
||||||
}
|
|
||||||
V3Number* newOutNumber(AstNode* nodep, uint32_t value=0) {
|
|
||||||
// Set a constant value for this node
|
|
||||||
if (!nodep->user4p()) {
|
|
||||||
V3Number* nump = allocNumber(nodep, value);
|
|
||||||
setOutNumber(nodep, nump);
|
|
||||||
}
|
|
||||||
return (fetchOutNumber(nodep));
|
|
||||||
}
|
|
||||||
V3Number* fetchNumberNull(AstNode* nodep) {
|
|
||||||
return ((V3Number*)nodep->user3p());
|
|
||||||
}
|
|
||||||
V3Number* fetchOutNumberNull(AstNode* nodep) {
|
|
||||||
return ((V3Number*)nodep->user4p());
|
|
||||||
}
|
|
||||||
V3Number* fetchNumber(AstNode* nodep) {
|
|
||||||
V3Number* nump = fetchNumberNull(nodep);
|
|
||||||
if (!nump) nodep->v3fatalSrc("No value found for node.");
|
|
||||||
return nump;
|
|
||||||
}
|
|
||||||
V3Number* fetchOutNumber(AstNode* nodep) {
|
|
||||||
V3Number* nump = fetchOutNumberNull(nodep);
|
|
||||||
if (!nump) nodep->v3fatalSrc("No value found for node.");
|
|
||||||
return nump;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
void setNumber(AstNode* nodep, const V3Number* nump) {
|
|
||||||
UINFO(9," set num "<<*nump<<" on "<<nodep<<endl);
|
|
||||||
nodep->user3p((AstNUser*)nump);
|
|
||||||
}
|
|
||||||
void setOutNumber(AstNode* nodep, const V3Number* nump) {
|
|
||||||
UINFO(9," set num "<<*nump<<" on "<<nodep<<endl);
|
|
||||||
nodep->user4p((AstNUser*)nump);
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkNodeInfo(AstNode* nodep) {
|
|
||||||
m_instrCount += nodep->instrCount();
|
|
||||||
m_dataCount += nodep->width();
|
|
||||||
if (!nodep->isPredictOptimizable()) {
|
|
||||||
//UINFO(9," !predictopt "<<nodep<<endl);
|
|
||||||
clearOptimizable(nodep,"!predictOptimzable");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// VISITORS
|
|
||||||
virtual void visit(AstAlways* nodep, AstNUser*) {
|
|
||||||
if (m_checking) checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
}
|
|
||||||
virtual void visit(AstSenTree* nodep, AstNUser*) {
|
|
||||||
// Sensitivities aren't inputs per se; we'll keep our tree under the same sens.
|
|
||||||
}
|
|
||||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
|
||||||
AstVarScope* vscp = nodep->varScopep();
|
|
||||||
if (!vscp) nodep->v3fatalSrc("Not linked");
|
|
||||||
if (m_checking) {
|
|
||||||
if (m_checking && !optimizable()) return; // Accelerate
|
|
||||||
// We can't have non-delayed assignments with same value on LHS and RHS
|
|
||||||
// as we don't figure out variable ordering.
|
|
||||||
// Delayed is OK though, as we'll decode the next state separately.
|
|
||||||
if (nodep->varp()->arraysp()) clearOptimizable(nodep,"Array references");
|
|
||||||
if (nodep->lvalue()) {
|
|
||||||
if (m_inDlyAssign) {
|
|
||||||
if (!(vscp->user1() & VU_LVDLY)) {
|
|
||||||
vscp->user1( vscp->user1() | VU_LVDLY);
|
|
||||||
varRefCb (nodep);
|
|
||||||
}
|
|
||||||
} else { // nondly asn
|
|
||||||
if (!(vscp->user1() & VU_LV)) {
|
|
||||||
if (vscp->user1() & VU_RV) clearOptimizable(nodep,"Var read & write");
|
|
||||||
vscp->user1( vscp->user1() | VU_LV);
|
|
||||||
varRefCb (nodep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!(vscp->user1() & VU_RV)) {
|
|
||||||
if (vscp->user1() & VU_LV) clearOptimizable(nodep,"Var write & read");
|
|
||||||
vscp->user1( vscp->user1() | VU_RV);
|
|
||||||
varRefCb (nodep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { // simulating
|
|
||||||
if (nodep->lvalue()) {
|
|
||||||
nodep->v3fatalSrc("LHS varref should be handled in AstAssign visitor.");
|
|
||||||
} else {
|
|
||||||
// Return simulation value
|
|
||||||
V3Number* nump = fetchNumberNull(vscp);
|
|
||||||
if (!nump) nodep->v3fatalSrc("Variable value should have been set before any visitor called.");
|
|
||||||
setNumber(nodep, nump);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeIf* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
} else {
|
|
||||||
nodep->condp()->iterateAndNext(*this);
|
|
||||||
if (fetchNumber(nodep->condp())->isNeqZero()) {
|
|
||||||
nodep->ifsp()->iterateAndNext(*this);
|
|
||||||
} else {
|
|
||||||
nodep->elsesp()->iterateAndNext(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstConst* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
} else {
|
|
||||||
setNumber(nodep, &(nodep->num()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeUniop* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
if (!optimizable()) return; // Accelerate
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
} else {
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeBiop* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
if (!optimizable()) return; // Accelerate
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
} else {
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
nodep->numberOperate(*newNumber(nodep), *fetchNumber(nodep->lhsp()), *fetchNumber(nodep->rhsp()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeTriop* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
if (!optimizable()) return; // Accelerate
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
} else {
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
nodep->numberOperate(*newNumber(nodep),
|
|
||||||
*fetchNumber(nodep->lhsp()),
|
|
||||||
*fetchNumber(nodep->rhsp()),
|
|
||||||
*fetchNumber(nodep->thsp()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeCond* nodep, AstNUser*) {
|
|
||||||
// We could use above visit(AstNodeTriop), but it's slower even O(n^2) to evaluate
|
|
||||||
// both sides when we really only need to evaluate one side.
|
|
||||||
if (m_checking) {
|
|
||||||
if (!optimizable()) return; // Accelerate
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
} else {
|
|
||||||
nodep->condp()->accept(*this);
|
|
||||||
if (fetchNumber(nodep->condp())->isNeqZero()) {
|
|
||||||
nodep->expr1p()->accept(*this);
|
|
||||||
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr1p()));
|
|
||||||
} else {
|
|
||||||
nodep->expr2p()->accept(*this);
|
|
||||||
newNumber(nodep)->opAssign(*fetchNumber(nodep->expr2p()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
virtual void visit(AstNodeAssign* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
if (!optimizable()) return; // Accelerate
|
|
||||||
if (nodep->castAssignDly()) {
|
|
||||||
if (m_anyAssignComb) clearOptimizable(nodep, "Mix of dly/non dly assigns");
|
|
||||||
m_anyAssignDly = true;
|
|
||||||
m_inDlyAssign = true;
|
|
||||||
} else {
|
|
||||||
if (m_anyAssignDly) clearOptimizable(nodep, "Mix of dly/non dly assigns");
|
|
||||||
m_anyAssignComb = true;
|
|
||||||
}
|
|
||||||
nodep->iterateChildren(*this);
|
|
||||||
}
|
|
||||||
if (!nodep->lhsp()->castVarRef()) {
|
|
||||||
clearOptimizable(nodep, "LHS isn't simple variable");
|
|
||||||
}
|
|
||||||
else if (!m_checking) {
|
|
||||||
nodep->rhsp()->iterateAndNext(*this);
|
|
||||||
AstVarScope* vscp = nodep->lhsp()->castVarRef()->varScopep();
|
|
||||||
if (nodep->castAssignDly()) {
|
|
||||||
// Don't do setNumber, as value isn't yet visible to following statements
|
|
||||||
setOutNumber(vscp, fetchNumber(nodep->rhsp()));
|
|
||||||
} else {
|
|
||||||
setNumber(vscp, fetchNumber(nodep->rhsp()));
|
|
||||||
setOutNumber(vscp, fetchNumber(nodep->rhsp()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_inDlyAssign = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void visit(AstComment*, AstNUser*) {}
|
|
||||||
// default
|
|
||||||
// These types are definately not reducable
|
|
||||||
// AstCoverInc, AstNodePli, AstArraySel, AstStop, AstFinish,
|
|
||||||
// AstRand, AstTime, AstUCFunc, AstCCall, AstCStmt, AstUCStmt
|
|
||||||
// In theory, we could follow the loop, but might be slow
|
|
||||||
// AstFor, AstWhile
|
|
||||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
|
||||||
if (m_checking) {
|
|
||||||
checkNodeInfo(nodep);
|
|
||||||
if (optimizable()) {
|
|
||||||
// Hmm, what is this then?
|
|
||||||
// In production code, we'll just not optimize. It should be fixed though.
|
|
||||||
clearOptimizable(nodep, "Unknown node type, perhaps missing visitor in TableSimulateVisitor");
|
|
||||||
#ifdef VL_DEBUG
|
|
||||||
UINFO(0,"Unknown node type in TableSimulateVisitor: "<<nodep->prettyTypeName()<<endl);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} else { // simulating
|
|
||||||
nodep->v3fatalSrc("Optimizable should have been cleared in check step, and never reach simulation.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void varRefCb(AstVarRef* nodep); ///< Call other-this function on all new var references
|
||||||
|
|
||||||
// CONSTRUCTORS
|
// CONSTRUCTORS
|
||||||
TableSimulateVisitor(TableVisitor* cbthis, bool checking) {
|
TableSimulateVisitor(TableVisitor* cbthis) {
|
||||||
m_cbthis = cbthis;
|
m_cbthis = cbthis;
|
||||||
m_checking = checking;
|
|
||||||
clear(); // We reuse this structure in the main loop, so put initializers inside clear()
|
|
||||||
}
|
|
||||||
void clear() {
|
|
||||||
m_whyNotOptimizable = NULL;
|
|
||||||
m_anyAssignComb = false;
|
|
||||||
m_anyAssignDly = false;
|
|
||||||
m_inDlyAssign = false;
|
|
||||||
m_instrCount = 0;
|
|
||||||
m_dataCount = 0;
|
|
||||||
|
|
||||||
AstNode::user1ClearTree(); // user1p() used on entire tree
|
|
||||||
AstNode::user3ClearTree(); // user3p() used on entire tree
|
|
||||||
AstNode::user4ClearTree(); // user4p() used on entire tree
|
|
||||||
|
|
||||||
// Move all allocated numbers to the free pool
|
|
||||||
m_numFreeps = m_numAllps;
|
|
||||||
}
|
|
||||||
void main (AstNode* nodep) {
|
|
||||||
nodep->accept(*this);
|
|
||||||
}
|
|
||||||
virtual ~TableSimulateVisitor() {
|
|
||||||
for (deque<V3Number*>::iterator it = m_numAllps.begin(); it != m_numAllps.end(); ++it) {
|
|
||||||
delete (*it);
|
|
||||||
}
|
|
||||||
m_numFreeps.clear();
|
|
||||||
m_numAllps.clear();
|
|
||||||
}
|
}
|
||||||
|
virtual ~TableSimulateVisitor() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//######################################################################
|
//######################################################################
|
||||||
// Table class functions
|
// Table class functions
|
||||||
|
|
||||||
class TableVisitor : public TableBaseVisitor {
|
class TableVisitor : public AstNVisitor {
|
||||||
private:
|
private:
|
||||||
// NODE STATE
|
// NODE STATE
|
||||||
// Cleared on each always/assignw
|
// Cleared on each always/assignw
|
||||||
AstUser1InUse m_inuser1;
|
|
||||||
AstUser2InUse m_inuser2;
|
|
||||||
AstUser3InUse m_inuser3;
|
|
||||||
AstUser4InUse m_inuser4;
|
|
||||||
|
|
||||||
// STATE
|
// STATE
|
||||||
double m_totalBytes; // Total bytes in tables created
|
double m_totalBytes; // Total bytes in tables created
|
||||||
@@ -432,6 +99,12 @@ private:
|
|||||||
deque<AstVarScope*> m_tableVarps; // Table being created
|
deque<AstVarScope*> m_tableVarps; // Table being created
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
|
static int debug() {
|
||||||
|
static int level = -1;
|
||||||
|
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
bool treeTest(AstAlways* nodep) {
|
bool treeTest(AstAlways* nodep) {
|
||||||
// Process alw/assign tree
|
// Process alw/assign tree
|
||||||
m_inWidth = 0;
|
m_inWidth = 0;
|
||||||
@@ -441,8 +114,8 @@ private:
|
|||||||
m_outNotSet.clear();
|
m_outNotSet.clear();
|
||||||
|
|
||||||
// Collect stats
|
// Collect stats
|
||||||
TableSimulateVisitor chkvis (this, true);
|
TableSimulateVisitor chkvis (this);
|
||||||
chkvis.main(nodep);
|
chkvis.mainTableCheck(nodep);
|
||||||
m_assignDly = chkvis.isAssignDly();
|
m_assignDly = chkvis.isAssignDly();
|
||||||
// Also sets m_inWidth
|
// Also sets m_inWidth
|
||||||
// Also sets m_outWidth
|
// Also sets m_outWidth
|
||||||
@@ -458,19 +131,19 @@ private:
|
|||||||
double bytesPerInst = 4;
|
double bytesPerInst = 4;
|
||||||
double time = (chkvis.instrCount()*bytesPerInst + chkvis.dataCount()) + 1; // +1 so won't div by zero
|
double time = (chkvis.instrCount()*bytesPerInst + chkvis.dataCount()) + 1; // +1 so won't div by zero
|
||||||
if (chkvis.instrCount() < TABLE_MIN_NODE_COUNT) {
|
if (chkvis.instrCount() < TABLE_MIN_NODE_COUNT) {
|
||||||
chkvis.clearOptimizable(nodep,"Too few nodes involved");
|
chkvis.clearOptimizable(nodep,"Table has too few nodes involved");
|
||||||
}
|
}
|
||||||
if (space > TABLE_MAX_BYTES) {
|
if (space > TABLE_MAX_BYTES) {
|
||||||
chkvis.clearOptimizable(nodep,"Too much space");
|
chkvis.clearOptimizable(nodep,"Table takes too much space");
|
||||||
}
|
}
|
||||||
if (space > time * TABLE_SPACE_TIME_MULT) {
|
if (space > time * TABLE_SPACE_TIME_MULT) {
|
||||||
chkvis.clearOptimizable(nodep,"Bad tradeoff");
|
chkvis.clearOptimizable(nodep,"Table has bad tradeoff");
|
||||||
}
|
}
|
||||||
if (m_totalBytes > TABLE_TOTAL_BYTES) {
|
if (m_totalBytes > TABLE_TOTAL_BYTES) {
|
||||||
chkvis.clearOptimizable(nodep,"Out of memory");
|
chkvis.clearOptimizable(nodep,"Table out of memory");
|
||||||
}
|
}
|
||||||
if (!m_outWidth || !m_inWidth) {
|
if (!m_outWidth || !m_inWidth) {
|
||||||
chkvis.clearOptimizable(nodep,"No I/O");
|
chkvis.clearOptimizable(nodep,"Table has no outputs");
|
||||||
}
|
}
|
||||||
UINFO(4, " Test: Opt="<<(chkvis.optimizable()?"OK":"NO")
|
UINFO(4, " Test: Opt="<<(chkvis.optimizable()?"OK":"NO")
|
||||||
<<", Instrs="<<chkvis.instrCount()<<" Data="<<chkvis.dataCount()
|
<<", Instrs="<<chkvis.instrCount()<<" Data="<<chkvis.dataCount()
|
||||||
@@ -599,7 +272,7 @@ private:
|
|||||||
m_outNotSet.push_back(false);
|
m_outNotSet.push_back(false);
|
||||||
}
|
}
|
||||||
uint32_t inValueNextInitArray=0;
|
uint32_t inValueNextInitArray=0;
|
||||||
TableSimulateVisitor simvis (this, false);
|
TableSimulateVisitor simvis (this);
|
||||||
for (uint32_t inValue=0; inValue <= VL_MASK_I(m_inWidth); inValue++) {
|
for (uint32_t inValue=0; inValue <= VL_MASK_I(m_inWidth); inValue++) {
|
||||||
// Make a new simulation structure so we can set new input values
|
// Make a new simulation structure so we can set new input values
|
||||||
UINFO(8," Simulating "<<hex<<inValue<<endl);
|
UINFO(8," Simulating "<<hex<<inValue<<endl);
|
||||||
@@ -621,7 +294,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulate
|
// Simulate
|
||||||
simvis.main(nodep);
|
simvis.mainTableEmulate(nodep);
|
||||||
|
if (!simvis.optimizable()) simvis.whyNotNodep()->v3fatalSrc("Optimizable cleared, even though earlier test run said not: "<<simvis.whyNotMessage());
|
||||||
|
|
||||||
// If a output changed, add it to table
|
// If a output changed, add it to table
|
||||||
int outnum = 0;
|
int outnum = 0;
|
||||||
|
|||||||
@@ -650,6 +650,7 @@ private:
|
|||||||
if (nodep->modVarp()->user1p()) {
|
if (nodep->modVarp()->user1p()) {
|
||||||
// create the input pin
|
// create the input pin
|
||||||
AstVarRef* refp = nodep->exprp()->castVarRef();
|
AstVarRef* refp = nodep->exprp()->castVarRef();
|
||||||
|
if (!refp) nodep->v3fatal("Unsupported: Tristate pin not connected to simple net");
|
||||||
AstVar* inp;
|
AstVar* inp;
|
||||||
if (refp->varp()->user1p()) { // this is a tristate
|
if (refp->varp()->user1p()) { // this is a tristate
|
||||||
inp = (AstVar*) refp->varp()->user1p();
|
inp = (AstVar*) refp->varp()->user1p();
|
||||||
|
|||||||
+17
-4
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include "V3Global.h"
|
#include "V3Global.h"
|
||||||
#include "V3Width.h"
|
#include "V3Width.h"
|
||||||
|
#include "V3Signed.h"
|
||||||
#include "V3Number.h"
|
#include "V3Number.h"
|
||||||
#include "V3Const.h"
|
#include "V3Const.h"
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@
|
|||||||
int m_minWidth; // Minimum width, for (2+2), it's 2 bits, for 32'2+32'2 it's 32 bits
|
int m_minWidth; // Minimum width, for (2+2), it's 2 bits, for 32'2+32'2 it's 32 bits
|
||||||
Stage m_stage; // If true, report errors
|
Stage m_stage; // If true, report errors
|
||||||
public:
|
public:
|
||||||
WidthVP(int width, int minWidth, Stage stage) : m_width(width), m_minWidth(minWidth), m_stage(stage) {};
|
WidthVP(int width, int minWidth, Stage stage) : m_width(width), m_minWidth(minWidth), m_stage(stage) {}
|
||||||
int width() const { return m_width; }
|
int width() const { return m_width; }
|
||||||
int widthMin() const { return m_minWidth?m_minWidth:m_width; }
|
int widthMin() const { return m_minWidth?m_minWidth:m_width; }
|
||||||
bool prelim() const { return m_stage&1; }
|
bool prelim() const { return m_stage&1; }
|
||||||
@@ -442,6 +443,8 @@ private:
|
|||||||
virtual void visit(AstVar* nodep, AstNUser* vup) {
|
virtual void visit(AstVar* nodep, AstNUser* vup) {
|
||||||
//if (debug()) nodep->dumpTree(cout," InitPre: ");
|
//if (debug()) nodep->dumpTree(cout," InitPre: ");
|
||||||
// Must have deterministic constant width
|
// Must have deterministic constant width
|
||||||
|
// We can't skip this step when width()!=0, as creating a AstVar
|
||||||
|
// with non-constant range gets size 1, not size 0.
|
||||||
int width=1; int mwidth=1;
|
int width=1; int mwidth=1;
|
||||||
nodep->arraysp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
nodep->arraysp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||||
if (nodep->rangep()) {
|
if (nodep->rangep()) {
|
||||||
@@ -457,8 +460,11 @@ private:
|
|||||||
}
|
}
|
||||||
if (nodep->initp()) {
|
if (nodep->initp()) {
|
||||||
nodep->initp()->iterateAndNext(*this,WidthVP(width,0,BOTH).p());
|
nodep->initp()->iterateAndNext(*this,WidthVP(width,0,BOTH).p());
|
||||||
if (nodep->isParam() && !nodep->rangep()) {
|
if (nodep->isParam()) {
|
||||||
if (nodep->initp()->widthSized()) {
|
if (nodep->rangep()) {
|
||||||
|
// Parameters need to preserve widthMin from the value, not get a constant size
|
||||||
|
mwidth = nodep->initp()->widthMin();
|
||||||
|
} else if (nodep->initp()->widthSized()) {
|
||||||
width = mwidth = nodep->initp()->width();
|
width = mwidth = nodep->initp()->width();
|
||||||
} else {
|
} else {
|
||||||
if (nodep->initp()->width()>32) nodep->initp()->v3warn(WIDTH,"Assigning >32 bit to unranged parameter (defaults to 32 bits)\n");
|
if (nodep->initp()->width()>32) nodep->initp()->v3warn(WIDTH,"Assigning >32 bit to unranged parameter (defaults to 32 bits)\n");
|
||||||
@@ -847,7 +853,7 @@ public:
|
|||||||
m_taskDepth = 0;
|
m_taskDepth = 0;
|
||||||
m_cellRangep = NULL;
|
m_cellRangep = NULL;
|
||||||
m_casep = NULL;
|
m_casep = NULL;
|
||||||
nodep->accept(*this);
|
nodep->accept(*this, WidthVP(ANYSIZE,0,BOTH).p());
|
||||||
}
|
}
|
||||||
virtual ~WidthVisitor() {}
|
virtual ~WidthVisitor() {}
|
||||||
};
|
};
|
||||||
@@ -1192,6 +1198,13 @@ void V3Width::widthParams(AstNode* nodep) {
|
|||||||
WidthVisitor visitor (nodep, true);
|
WidthVisitor visitor (nodep, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void V3Width::widthSignedIfNotAlready(AstNode* nodep) {
|
||||||
|
if (!nodep->width()) {
|
||||||
|
V3Width::widthParams(nodep);
|
||||||
|
V3Signed::signedParams(nodep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void V3Width::widthCommit(AstNode* nodep) {
|
void V3Width::widthCommit(AstNode* nodep) {
|
||||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||||
WidthCommitVisitor visitor (nodep);
|
WidthCommitVisitor visitor (nodep);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public:
|
|||||||
static void width(AstNetlist* nodep);
|
static void width(AstNetlist* nodep);
|
||||||
// Smaller step... Only do a single node for parameter propagation
|
// Smaller step... Only do a single node for parameter propagation
|
||||||
static void widthParams(AstNode* nodep);
|
static void widthParams(AstNode* nodep);
|
||||||
|
static void widthSignedIfNotAlready(AstNode* nodep);
|
||||||
// Final step... Mark all widths as equal
|
// Final step... Mark all widths as equal
|
||||||
static void widthCommit(AstNode* nodep);
|
static void widthCommit(AstNode* nodep);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
//**********************************************************************
|
//**********************************************************************
|
||||||
//**** Version and host name
|
//**** Version and host name
|
||||||
|
|
||||||
#define DTVERSION "Verilator 3.712 2009/07/14"
|
#define DTVERSION "Verilator 3.714 2009/09/18"
|
||||||
|
|
||||||
//**********************************************************************
|
//**********************************************************************
|
||||||
//**** Functions
|
//**** Functions
|
||||||
|
|||||||
+18
-14
@@ -44,6 +44,10 @@ extern void yyerrorf(const char* format, ...);
|
|||||||
|
|
||||||
#define FL { yylval.fileline = CRELINE(); }
|
#define FL { yylval.fileline = CRELINE(); }
|
||||||
|
|
||||||
|
#define RETURN_BBOX_SYS_OR_MSG(msg,yytext) { \
|
||||||
|
if (v3Global.opt.bboxSys()) return yD_aIGNORE; \
|
||||||
|
else yyerrorf(msg,yytext); }
|
||||||
|
|
||||||
void V3Read::ppline (const char* textp) {
|
void V3Read::ppline (const char* textp) {
|
||||||
// Handle `line directive
|
// Handle `line directive
|
||||||
fileline()->lineDirective(textp);
|
fileline()->lineDirective(textp);
|
||||||
@@ -239,18 +243,18 @@ escid \\[^ \t\f\r\n]+
|
|||||||
"xnor" { FL; return yXNOR; }
|
"xnor" { FL; return yXNOR; }
|
||||||
"xor" { FL; return yXOR; }
|
"xor" { FL; return yXOR; }
|
||||||
/* Special errors */
|
/* Special errors */
|
||||||
"$displayb" { yyerrorf("Unsupported: Use $display with %%b format instead: %s",yytext); }
|
"$displayb" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $display with %%b format instead: %s",yytext); }
|
||||||
"$displayh" { yyerrorf("Unsupported: Use $display with %%x format instead: %s",yytext); }
|
"$displayh" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $display with %%x format instead: %s",yytext); }
|
||||||
"$displayo" { yyerrorf("Unsupported: Use $display with %%o format instead: %s",yytext); }
|
"$displayo" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $display with %%o format instead: %s",yytext); }
|
||||||
"$fdisplayb" { yyerrorf("Unsupported: Use $fdisplay with %%b format instead: %s",yytext); }
|
"$fdisplayb" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fdisplay with %%b format instead: %s",yytext); }
|
||||||
"$fdisplayh" { yyerrorf("Unsupported: Use $fdisplay with %%x format instead: %s",yytext); }
|
"$fdisplayh" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fdisplay with %%x format instead: %s",yytext); }
|
||||||
"$fdisplayo" { yyerrorf("Unsupported: Use $fdisplay with %%o format instead: %s",yytext); }
|
"$fdisplayo" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fdisplay with %%o format instead: %s",yytext); }
|
||||||
"$fwriteb" { yyerrorf("Unsupported: Use $fwrite with %%b format instead: %s",yytext); }
|
"$fwriteb" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fwrite with %%b format instead: %s",yytext); }
|
||||||
"$fwriteh" { yyerrorf("Unsupported: Use $fwrite with %%x format instead: %s",yytext); }
|
"$fwriteh" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fwrite with %%x format instead: %s",yytext); }
|
||||||
"$fwriteo" { yyerrorf("Unsupported: Use $fwrite with %%o format instead: %s",yytext); }
|
"$fwriteo" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $fwrite with %%o format instead: %s",yytext); }
|
||||||
"$writeb" { yyerrorf("Unsupported: Use $write with %%b format instead: %s",yytext); }
|
"$writeb" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $write with %%b format instead: %s",yytext); }
|
||||||
"$writeh" { yyerrorf("Unsupported: Use $write with %%x format instead: %s",yytext); }
|
"$writeh" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $write with %%x format instead: %s",yytext); }
|
||||||
"$writeo" { yyerrorf("Unsupported: Use $write with %%o format instead: %s",yytext); }
|
"$writeo" { RETURN_BBOX_SYS_OR_MSG("Unsupported: Use $write with %%o format instead: %s",yytext); }
|
||||||
/* Generic unsupported warnings */
|
/* Generic unsupported warnings */
|
||||||
"cmos" { yyerrorf("Unsupported: Verilog 1995 reserved word not implemented: %s",yytext); }
|
"cmos" { yyerrorf("Unsupported: Verilog 1995 reserved word not implemented: %s",yytext); }
|
||||||
"deassign" { yyerrorf("Unsupported: Verilog 1995 reserved word not implemented: %s",yytext); }
|
"deassign" { yyerrorf("Unsupported: Verilog 1995 reserved word not implemented: %s",yytext); }
|
||||||
@@ -358,6 +362,7 @@ escid \\[^ \t\f\r\n]+
|
|||||||
"endproperty" { FL; return yENDPROPERTY; }
|
"endproperty" { FL; return yENDPROPERTY; }
|
||||||
"final" { FL; return yFINAL; }
|
"final" { FL; return yFINAL; }
|
||||||
"iff" { FL; return yIFF; }
|
"iff" { FL; return yIFF; }
|
||||||
|
"logic" { FL; return yLOGIC; }
|
||||||
"priority" { FL; return yPRIORITY; }
|
"priority" { FL; return yPRIORITY; }
|
||||||
"static" { FL; return ySTATIC; }
|
"static" { FL; return ySTATIC; }
|
||||||
"timeprecision" { FL; return yTIMEPRECISION; }
|
"timeprecision" { FL; return yTIMEPRECISION; }
|
||||||
@@ -407,7 +412,6 @@ escid \\[^ \t\f\r\n]+
|
|||||||
"join_any" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"join_any" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
"join_none" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"join_none" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
"local" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"local" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
"logic" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
|
||||||
"longint" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"longint" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
"matches" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"matches" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
"modport" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
"modport" { yyerrorf("Unsupported: SystemVerilog 2005 reserved word not implemented: %s",yytext); }
|
||||||
@@ -461,7 +465,7 @@ escid \\[^ \t\f\r\n]+
|
|||||||
|
|
||||||
/* Default PLI rule */
|
/* Default PLI rule */
|
||||||
<V95,V01,V05,S05,PSL>{
|
<V95,V01,V05,S05,PSL>{
|
||||||
"$"[a-zA-Z_$][a-zA-Z0-9_$]* { yyerrorf("Unsupported or unknown PLI call: %s",yytext); }
|
"$"[a-zA-Z_$][a-zA-Z0-9_$]* { FL; RETURN_BBOX_SYS_OR_MSG("Unsupported or unknown PLI call: %s",yytext); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
+43
-19
@@ -113,6 +113,12 @@ static AstNode* newVarInit(FileLine* fileline, AstNode* varp, AstNode* initp) {
|
|||||||
|
|
||||||
#define INSTPREP(modname,paramsp) { V3Parse::s_impliedDecl = true; V3Parse::s_instModule = modname; V3Parse::s_instParamp = paramsp; }
|
#define INSTPREP(modname,paramsp) { V3Parse::s_impliedDecl = true; V3Parse::s_instModule = modname; V3Parse::s_instParamp = paramsp; }
|
||||||
|
|
||||||
|
static void ERRSVKWD(FileLine* fileline, const string& tokname) {
|
||||||
|
static int toldonce = 0;
|
||||||
|
fileline->v3error((string)"Unexpected \""+tokname+"\": \""+tokname+"\" is a SystemVerilog keyword misused as an identifier.");
|
||||||
|
if (!toldonce++) fileline->v3error("Modify the Verilog-2001 code to avoid SV keywords, or use `begin_keywords or --language.");
|
||||||
|
}
|
||||||
|
|
||||||
//======================================================================
|
//======================================================================
|
||||||
|
|
||||||
class AstSenTree;
|
class AstSenTree;
|
||||||
@@ -246,6 +252,7 @@ class AstSenTree;
|
|||||||
%token<fileline> yGENVAR "genvar"
|
%token<fileline> yGENVAR "genvar"
|
||||||
%token<fileline> yIF "if"
|
%token<fileline> yIF "if"
|
||||||
%token<fileline> yIFF "iff"
|
%token<fileline> yIFF "iff"
|
||||||
|
%token<fileline> yLOGIC "logic"
|
||||||
%token<fileline> yINITIAL "initial"
|
%token<fileline> yINITIAL "initial"
|
||||||
%token<fileline> yINOUT "inout"
|
%token<fileline> yINOUT "inout"
|
||||||
%token<fileline> yINPUT "input"
|
%token<fileline> yINPUT "input"
|
||||||
@@ -320,6 +327,7 @@ class AstSenTree;
|
|||||||
%token<fileline> yD_UNSIGNED "$unsigned"
|
%token<fileline> yD_UNSIGNED "$unsigned"
|
||||||
%token<fileline> yD_WARNING "$warning"
|
%token<fileline> yD_WARNING "$warning"
|
||||||
%token<fileline> yD_WRITE "$write"
|
%token<fileline> yD_WRITE "$write"
|
||||||
|
%token<fileline> yD_aIGNORE "${ignored-bbox-sys}"
|
||||||
|
|
||||||
%token<fileline> yPSL "psl"
|
%token<fileline> yPSL "psl"
|
||||||
%token<fileline> yPSL_ASSERT "PSL assert"
|
%token<fileline> yPSL_ASSERT "PSL assert"
|
||||||
@@ -656,6 +664,7 @@ port_declNetE: // IEEE: part of port_declaration, optional net type
|
|||||||
|
|
||||||
portSig<portp>:
|
portSig<portp>:
|
||||||
id/*port*/ { $$ = new AstPort(CRELINE(),PINNUMINC(),*$1); }
|
id/*port*/ { $$ = new AstPort(CRELINE(),PINNUMINC(),*$1); }
|
||||||
|
| idSVKwd { $$ = new AstPort(CRELINE(),PINNUMINC(),*$1); }
|
||||||
;
|
;
|
||||||
|
|
||||||
//**********************************************************************
|
//**********************************************************************
|
||||||
@@ -823,6 +832,7 @@ data_type<rangep>: // ==IEEE: data_type
|
|||||||
data_typeNoRef<rangep>: // ==IEEE: data_type, excluding class_type etc references
|
data_typeNoRef<rangep>: // ==IEEE: data_type, excluding class_type etc references
|
||||||
yINTEGER { VARDECL(INTEGER); $$ = new AstRange($1,31,0); $$->isSigned(true); }
|
yINTEGER { VARDECL(INTEGER); $$ = new AstRange($1,31,0); $$->isSigned(true); }
|
||||||
| yREG signingE rangeListE { VARDECL(REG); $$ = $3; }
|
| yREG signingE rangeListE { VARDECL(REG); $$ = $3; }
|
||||||
|
| yLOGIC signingE rangeListE { VARDECL(REG); $$ = $3; }
|
||||||
//UNSUP: above instead of integer_type
|
//UNSUP: above instead of integer_type
|
||||||
//
|
//
|
||||||
//UNSUP integer_type signingE regArRangeE { UNSUP }
|
//UNSUP integer_type signingE regArRangeE { UNSUP }
|
||||||
@@ -852,6 +862,7 @@ variable_decl_assignment<varp>: // ==IEEE: variable_decl_assignment
|
|||||||
| id variable_dimensionListE sigAttrListE '=' variable_declExpr
|
| id variable_dimensionListE sigAttrListE '=' variable_declExpr
|
||||||
{ $$ = VARDONEA(*$1,$2,$3);
|
{ $$ = VARDONEA(*$1,$2,$3);
|
||||||
$$->addNext(new AstInitial($4,new AstAssign($4, new AstVarRef($4, *$1, true), $5))); }
|
$$->addNext(new AstInitial($4,new AstAssign($4, new AstVarRef($4, *$1, true), $5))); }
|
||||||
|
| idSVKwd { $$ = NULL; }
|
||||||
//
|
//
|
||||||
// // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
|
// // IEEE: "dynamic_array_variable_identifier '[' ']' [ '=' dynamic_array_new ]"
|
||||||
// // Matches above with variable_dimensionE = "[]"
|
// // Matches above with variable_dimensionE = "[]"
|
||||||
@@ -1094,24 +1105,23 @@ genvar_initialization<nodep>: // ==IEEE: genvar_initalization
|
|||||||
;
|
;
|
||||||
|
|
||||||
genvar_iteration<nodep>: // ==IEEE: genvar_iteration
|
genvar_iteration<nodep>: // ==IEEE: genvar_iteration
|
||||||
varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
|
varRefBase '=' expr { $$ = new AstAssign($2,$1,$3); }
|
||||||
//UNSUP id '=' expr { UNSUP }
|
| varRefBase yP_PLUSEQ expr { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_PLUSEQ expr { UNSUP }
|
| varRefBase yP_MINUSEQ expr { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_MINUSEQ expr { UNSUP }
|
| varRefBase yP_TIMESEQ expr { $$ = new AstAssign($2,$1,new AstMul ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_TIMESEQ expr { UNSUP }
|
| varRefBase yP_DIVEQ expr { $$ = new AstAssign($2,$1,new AstDiv ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_DIVEQ expr { UNSUP }
|
| varRefBase yP_MODEQ expr { $$ = new AstAssign($2,$1,new AstModDiv ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_MODEQ expr { UNSUP }
|
| varRefBase yP_ANDEQ expr { $$ = new AstAssign($2,$1,new AstAnd ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_ANDEQ expr { UNSUP }
|
| varRefBase yP_OREQ expr { $$ = new AstAssign($2,$1,new AstOr ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_OREQ expr { UNSUP }
|
| varRefBase yP_XOREQ expr { $$ = new AstAssign($2,$1,new AstXor ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_XOREQ expr { UNSUP }
|
| varRefBase yP_SLEFTEQ expr { $$ = new AstAssign($2,$1,new AstShiftL ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_SLEFTEQ expr { UNSUP }
|
| varRefBase yP_SRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftR ($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_SRIGHTEQ expr { UNSUP }
|
| varRefBase yP_SSRIGHTEQ expr { $$ = new AstAssign($2,$1,new AstShiftRS($2,$1->cloneTree(true),$3)); }
|
||||||
//UNSUP id yP_SSRIGHTEQ expr { UNSUP }
|
|
||||||
// // inc_or_dec_operator
|
// // inc_or_dec_operator
|
||||||
//UNSUP yP_PLUSPLUS id { UNSUP }
|
| yP_PLUSPLUS varRefBase { $$ = new AstAssign($1,$2,new AstAdd ($1,$2->cloneTree(true),new AstConst($1,V3Number($1,"'b1")))); }
|
||||||
//UNSUP yP_MINUSMINUS id { UNSUP }
|
| yP_MINUSMINUS varRefBase { $$ = new AstAssign($1,$2,new AstSub ($1,$2->cloneTree(true),new AstConst($1,V3Number($1,"'b1")))); }
|
||||||
//UNSUP id yP_PLUSPLUS { UNSUP }
|
| varRefBase yP_PLUSPLUS { $$ = new AstAssign($2,$1,new AstAdd ($2,$1->cloneTree(true),new AstConst($2,V3Number($2,"'b1")))); }
|
||||||
//UNSUP id yP_MINUSMINUS { UNSUP }
|
| varRefBase yP_MINUSMINUS { $$ = new AstAssign($2,$1,new AstSub ($2,$1->cloneTree(true),new AstConst($2,V3Number($2,"'b1")))); }
|
||||||
;
|
;
|
||||||
|
|
||||||
case_generate_itemListE<nodep>: // IEEE: [{ case_generate_itemList }]
|
case_generate_itemListE<nodep>: // IEEE: [{ case_generate_itemList }]
|
||||||
@@ -1187,6 +1197,7 @@ netSig<varp>: // IEEE: net_decl_assignment - one element from list_of_port_id
|
|||||||
|
|
||||||
netId<strp>:
|
netId<strp>:
|
||||||
id/*new-net*/ { $$ = $1; }
|
id/*new-net*/ { $$ = $1; }
|
||||||
|
| idSVKwd { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
sigId<varp>:
|
sigId<varp>:
|
||||||
@@ -1313,6 +1324,7 @@ cellpinItList<pinp>: // IEEE: list_of_port_connections + list_of_parameter_assi
|
|||||||
cellpinItemE<pinp>: // IEEE: named_port_connection + named_parameter_assignment + empty
|
cellpinItemE<pinp>: // IEEE: named_port_connection + named_parameter_assignment + empty
|
||||||
/* empty: ',,' is legal */ { $$ = NULL; PINNUMINC(); }
|
/* empty: ',,' is legal */ { $$ = NULL; PINNUMINC(); }
|
||||||
| yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",NULL); }
|
| yP_DOTSTAR { $$ = new AstPin($1,PINNUMINC(),".*",NULL); }
|
||||||
|
| '.' idSVKwd { $$ = NULL; PINNUMINC(); }
|
||||||
| '.' idAny { $$ = new AstPin($1,PINNUMINC(),*$2,new AstVarRef($1,*$2,false)); $$->svImplicit(true);}
|
| '.' idAny { $$ = new AstPin($1,PINNUMINC(),*$2,new AstVarRef($1,*$2,false)); $$->svImplicit(true);}
|
||||||
| '.' idAny '(' ')' { $$ = NULL; PINNUMINC(); }
|
| '.' idAny '(' ')' { $$ = NULL; PINNUMINC(); }
|
||||||
| '.' idAny '(' expr ')' { $$ = new AstPin($1,PINNUMINC(),*$2,$4); }
|
| '.' idAny '(' expr ')' { $$ = new AstPin($1,PINNUMINC(),*$2,$4); }
|
||||||
@@ -1651,7 +1663,10 @@ function_subroutine_callNoMethod<nodep>: // IEEE: function_subroutine_call (as f
|
|||||||
|
|
||||||
system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
||||||
//
|
//
|
||||||
yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCStmt($1,$3)); }
|
yD_aIGNORE '(' ')' { $$ = NULL; }
|
||||||
|
| yD_aIGNORE '(' exprList ')' { $$ = NULL; }
|
||||||
|
//
|
||||||
|
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCStmt($1,$3)); }
|
||||||
| yD_FCLOSE '(' idClassSel ')' { $$ = new AstFClose($1, $3); }
|
| yD_FCLOSE '(' idClassSel ')' { $$ = new AstFClose($1, $3); }
|
||||||
| yD_FFLUSH { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
| yD_FFLUSH { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
||||||
| yD_FFLUSH '(' ')' { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
| yD_FFLUSH '(' ')' { $1->v3error("Unsupported: $fflush of all handles does not map to C++.\n"); }
|
||||||
@@ -1685,7 +1700,10 @@ system_t_call<nodep>: // IEEE: system_tf_call (as task)
|
|||||||
;
|
;
|
||||||
|
|
||||||
system_f_call<nodep>: // IEEE: system_tf_call (as func)
|
system_f_call<nodep>: // IEEE: system_tf_call (as func)
|
||||||
yD_BITS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::BITS,$3); }
|
yD_aIGNORE '(' ')' { $$ = new AstConst($1,V3Number($1,"'b0")); } // Unsized 0
|
||||||
|
| yD_aIGNORE '(' exprList ')' { $$ = new AstConst($1,V3Number($1,"'b0")); } // Unsized 0
|
||||||
|
//
|
||||||
|
| yD_BITS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::BITS,$3); }
|
||||||
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCFunc($1,$3)); }
|
| yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCFunc($1,$3)); }
|
||||||
| yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); }
|
| yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); }
|
||||||
| yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); }
|
| yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); }
|
||||||
@@ -2284,6 +2302,12 @@ idAny<strp>: // Any kind of identifier
|
|||||||
yaID__ETC { $$ = $1; }
|
yaID__ETC { $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
idSVKwd<strp>: // Warn about non-forward compatible Verilog 2001 code
|
||||||
|
// // yBIT, yBYTE won't work here as causes conflicts
|
||||||
|
yDO { static string s = "do" ; $$ = &s; ERRSVKWD($1,*$$); }
|
||||||
|
| yFINAL { static string s = "final"; $$ = &s; ERRSVKWD($1,*$$); }
|
||||||
|
;
|
||||||
|
|
||||||
variable_lvalue<nodep>: // IEEE: variable_lvalue or net_lvalue
|
variable_lvalue<nodep>: // IEEE: variable_lvalue or net_lvalue
|
||||||
// // Note many variable_lvalue's must use exprOkLvalue when arbitrary expressions may also exist
|
// // Note many variable_lvalue's must use exprOkLvalue when arbitrary expressions may also exist
|
||||||
idClassSel { $$ = $1; }
|
idClassSel { $$ = $1; }
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ simx*
|
|||||||
ncverilog.*
|
ncverilog.*
|
||||||
INCA_libs
|
INCA_libs
|
||||||
logs
|
logs
|
||||||
|
.vcsmx_rebuild
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ include $(VERILATOR_ROOT)/include/verilated.mk
|
|||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
ifneq ($(VCS_HOME),)
|
ifneq ($(VCS_HOME),)
|
||||||
PRODUCTS += --vcs
|
#Default to off, even with vcs; not all tests are insured to be working
|
||||||
|
#PRODUCTS += --vcs
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(NC_ROOT),)
|
ifneq ($(NC_ROOT),)
|
||||||
PRODUCTS += --nc
|
#Default to off, even with vcs; not all tests are insured to be working
|
||||||
|
#PRODUCTS += --nc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PRODUCTS += --v3
|
PRODUCTS += --v3
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ sub new {
|
|||||||
sim_time => 1000,
|
sim_time => 1000,
|
||||||
benchmark => $opt_benchmark,
|
benchmark => $opt_benchmark,
|
||||||
# All compilers
|
# All compilers
|
||||||
v_flags => [split(/\s+/,(" -f input.vc --debug-check"
|
v_flags => [split(/\s+/,(" -f input.vc "
|
||||||
.($opt_verbose ? " +define+TEST_VERBOSE=1":"")
|
.($opt_verbose ? " +define+TEST_VERBOSE=1":"")
|
||||||
.($opt_benchmark ? " +define+TEST_BENCHMARK=$opt_benchmark":"")
|
.($opt_benchmark ? " +define+TEST_BENCHMARK=$opt_benchmark":"")
|
||||||
.($opt_trace ? " +define+WAVES=1":"")
|
.($opt_trace ? " +define+WAVES=1":"")
|
||||||
@@ -245,7 +245,7 @@ sub new {
|
|||||||
v_other_filenames => [], # After the filename so we can spec multiple files
|
v_other_filenames => [], # After the filename so we can spec multiple files
|
||||||
# VCS
|
# VCS
|
||||||
vcs => 0,
|
vcs => 0,
|
||||||
vcs_flags => [split(/\s+/,"+cli -I +define+vcs+1 -q +v2k")],
|
vcs_flags => [split(/\s+/,"+cli -I +define+vcs+1 -q -sverilog")],
|
||||||
vcs_flags2 => [], # Overridden in some sim files
|
vcs_flags2 => [], # Overridden in some sim files
|
||||||
# NC
|
# NC
|
||||||
nc => 0,
|
nc => 0,
|
||||||
@@ -255,7 +255,8 @@ sub new {
|
|||||||
# Verilator
|
# Verilator
|
||||||
'v3' => 0,
|
'v3' => 0,
|
||||||
verilator_flags => ["-cc",
|
verilator_flags => ["-cc",
|
||||||
"-Mdir $self->{obj_dir}"],
|
"-Mdir $self->{obj_dir}",
|
||||||
|
"--debug-check"],
|
||||||
verilator_flags2 => [],
|
verilator_flags2 => [],
|
||||||
verilator_make_gcc => 1,
|
verilator_make_gcc => 1,
|
||||||
verilated_debug => $Opt_Verilated_Debug,
|
verilated_debug => $Opt_Verilated_Debug,
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ module Test (/*AUTOARG*/
|
|||||||
// merge the output values into the result vector.
|
// merge the output values into the result vector.
|
||||||
|
|
||||||
input clk;
|
input clk;
|
||||||
input [31:0] in;
|
input [31:0] in;
|
||||||
output reg [31:0] out;
|
output reg [31:0] out;
|
||||||
|
|
||||||
always @(posedge clk) begin
|
always @(posedge clk) begin
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ module sub;
|
|||||||
begin
|
begin
|
||||||
$write("[%0t] In %m\n", $time);
|
$write("[%0t] In %m\n", $time);
|
||||||
begin : subblock
|
begin : subblock
|
||||||
$write("[%0t] In %m\n", $time);
|
$write("[%0t] In %M\n", $time); // Uppercase %M test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
endtask
|
endtask
|
||||||
|
|||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2008 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
v_flags2 => ["--bbox-sys"],
|
||||||
|
) if $Self->{v3};
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
) if $Self->{v3};
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2008 by Wilson Snyder.
|
||||||
|
|
||||||
|
module a;
|
||||||
|
reg a;
|
||||||
|
initial begin
|
||||||
|
$unknown_sys_task_call_to_be_bbox("blah");
|
||||||
|
a = $unknown_sys_func_call(23);
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
@@ -8,6 +8,9 @@ module t;
|
|||||||
`ifndef GOT_DEF2
|
`ifndef GOT_DEF2
|
||||||
$write("%%Error: NO GOT_DEF2\n"); $stop;
|
$write("%%Error: NO GOT_DEF2\n"); $stop;
|
||||||
`endif
|
`endif
|
||||||
|
`ifndef GOT_DEF3
|
||||||
|
$write("%%Error: NO GOT_DEF3\n"); $stop;
|
||||||
|
`endif
|
||||||
`ifdef NON_DEF
|
`ifdef NON_DEF
|
||||||
$write("%%Error: NON_DEF\n"); $stop;
|
$write("%%Error: NON_DEF\n"); $stop;
|
||||||
`endif
|
`endif
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
// Test that environment substitutions work
|
// Test that environment substitutions work
|
||||||
-f $VERILATOR_ROOT/test_regress/t/t_flag_f__2.vc
|
-f $VERILATOR_ROOT/test_regress/t/t_flag_f__2.vc
|
||||||
|
// Env var with .v file
|
||||||
|
$VERILATOR_ROOT/test_regress/t/t_flag_f__3.v
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
`define GOT_DEF3 1
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -3,15 +3,12 @@
|
|||||||
// This file ONLY is placed into the Public Domain, for any use,
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
// without warranty, 2003 by Wilson Snyder.
|
// without warranty, 2003 by Wilson Snyder.
|
||||||
|
|
||||||
module t_loop (/*AUTOARG*/
|
module t (/*AUTOARG*/
|
||||||
// Outputs
|
|
||||||
passed,
|
|
||||||
// Inputs
|
// Inputs
|
||||||
clk
|
clk
|
||||||
);
|
);
|
||||||
|
|
||||||
input clk;
|
input clk;
|
||||||
output passed; reg passed; initial passed = 0;
|
|
||||||
reg [7:0] cyc; initial cyc=0;
|
reg [7:0] cyc; initial cyc=0;
|
||||||
|
|
||||||
reg [31:0] loops;
|
reg [31:0] loops;
|
||||||
@@ -53,8 +50,8 @@ module t_loop (/*AUTOARG*/
|
|||||||
end
|
end
|
||||||
if (loops !== 100000) $stop;
|
if (loops !== 100000) $stop;
|
||||||
//
|
//
|
||||||
$write("[%0t] t_loop: Passed\n",$time);
|
$write("*-* All Finished *-*\n");
|
||||||
passed <= 1'b1;
|
$finish;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t;
|
||||||
|
|
||||||
|
localparam P4 = f_add(P3,1);
|
||||||
|
localparam P8 = f_add2(P3,P3,f_add(1,1));
|
||||||
|
localparam P5 = f_while(7);
|
||||||
|
localparam P16 = f_for(P4);
|
||||||
|
localparam P18 = f_case(P4);
|
||||||
|
localparam P3 = 3;
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
`ifdef TEST_VERBOSE
|
||||||
|
$display("P5=%0d P8=%0d P16=%0d P18=%0d",P5,P8,P16,P18);
|
||||||
|
`endif
|
||||||
|
if (P3 !== 3) $stop;
|
||||||
|
if (P4 !== 4) $stop;
|
||||||
|
if (P5 !== 5) $stop;
|
||||||
|
if (P8 !== 8) $stop;
|
||||||
|
if (P16 !== 16) $stop;
|
||||||
|
if (P18 !== 18) $stop;
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
|
||||||
|
function integer f_add(input [31:0] a, input [31:0] b);
|
||||||
|
f_add = a+b;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced ok: function called from function
|
||||||
|
function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c);
|
||||||
|
f_add2 = f_add(a,b)+c;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced ok: local variables
|
||||||
|
function integer f_for(input [31:0] a);
|
||||||
|
integer i;
|
||||||
|
integer times;
|
||||||
|
begin
|
||||||
|
times = 1;
|
||||||
|
for (i=0; i<a; i=i+1) times = times*2;
|
||||||
|
f_for = times;
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function integer f_while(input [31:0] a);
|
||||||
|
integer i;
|
||||||
|
begin
|
||||||
|
i=0;
|
||||||
|
begin : named
|
||||||
|
f_while = 1;
|
||||||
|
end : named
|
||||||
|
while (i<=a) begin
|
||||||
|
if (i[0]) f_while = f_while + 1;
|
||||||
|
i = i + 1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced ok: local variables
|
||||||
|
function integer f_case(input [31:0] a);
|
||||||
|
case(a)
|
||||||
|
32'd1: f_case = 1;
|
||||||
|
32'd0, 32'd4: f_case = 18;
|
||||||
|
32'd1234: begin $display("never get here"); $stop; end
|
||||||
|
default: f_case = 99;
|
||||||
|
endcase
|
||||||
|
endfunction
|
||||||
|
endmodule
|
||||||
Executable
+28
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
v_flags2 => ["--lint-only"],
|
||||||
|
fails=>1,
|
||||||
|
expect=>
|
||||||
|
q{%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_output'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant VAR 'o': Language violation: Outputs not allowed in constant functions
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_dotted'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant VARXREF 'EIGHT': Language violation: Dotted hierarchical references not allowed in constant functions
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_nonparam'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant VARREF 'modvar': Language violation: reference to non-function-local variable
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_infinite'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant WHILE: Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above 1024
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_stop'
|
||||||
|
%Error: t/t_func_const_bad.v:\d+: ... Location of non-constant STOP: .stop executed during function constification; maybe indicates assertion firing
|
||||||
|
%Error: Exiting due to.*},
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t;
|
||||||
|
|
||||||
|
// Speced ignored: system calls. I think this is nasty, so we error instead.
|
||||||
|
|
||||||
|
// Speced Illegal: inout/output/ref not allowed
|
||||||
|
localparam B1 = f_bad_output(1,2);
|
||||||
|
function integer f_bad_output(input [31:0] a, output [31:0] o);
|
||||||
|
f_bad_output = 0;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced Illegal: void
|
||||||
|
|
||||||
|
// Speced Illegal: dotted
|
||||||
|
localparam EIGHT = 8;
|
||||||
|
localparam B2 = f_bad_dotted(2);
|
||||||
|
function integer f_bad_dotted(input [31:0] a);
|
||||||
|
f_bad_dotted = t.EIGHT;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced Illegal: ref to non-local var
|
||||||
|
integer modvar;
|
||||||
|
localparam B3 = f_bad_nonparam(3);
|
||||||
|
function integer f_bad_nonparam(input [31:0] a);
|
||||||
|
f_bad_nonparam = modvar;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Speced Illegal: needs constant function itself
|
||||||
|
|
||||||
|
// Our own - infinite loop
|
||||||
|
localparam B4 = f_bad_infinite(3);
|
||||||
|
function integer f_bad_infinite(input [31:0] a);
|
||||||
|
while (1) begin
|
||||||
|
f_bad_infinite = 0;
|
||||||
|
end
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
// Our own - stop
|
||||||
|
localparam BSTOP = f_bad_stop(3);
|
||||||
|
function integer f_bad_stop(input [31:0] a);
|
||||||
|
$stop;
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
endmodule
|
||||||
@@ -18,19 +18,21 @@ module t (/*AUTOARG*/
|
|||||||
|
|
||||||
/*AUTOWIRE*/
|
/*AUTOWIRE*/
|
||||||
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
||||||
wire [2:0] pos; // From test of Test.v
|
wire [2:0] pos1; // From test of Test.v
|
||||||
|
wire [2:0] pos2; // From test of Test.v
|
||||||
// End of automatics
|
// End of automatics
|
||||||
|
|
||||||
Test test (
|
Test test (
|
||||||
// Outputs
|
// Outputs
|
||||||
.pos (pos[2:0]),
|
.pos1 (pos1[2:0]),
|
||||||
|
.pos2 (pos2[2:0]),
|
||||||
/*AUTOINST*/
|
/*AUTOINST*/
|
||||||
// Inputs
|
// Inputs
|
||||||
.clk (clk),
|
.clk (clk),
|
||||||
.rst_n (rst_n));
|
.rst_n (rst_n));
|
||||||
|
|
||||||
// Aggregate outputs into a single result vector
|
// Aggregate outputs into a single result vector
|
||||||
wire [63:0] result = {61'h0, pos};
|
wire [63:0] result = {61'h0, pos1};
|
||||||
|
|
||||||
// What checksum will we end up with
|
// What checksum will we end up with
|
||||||
`define EXPECTED_SUM 64'h039ea4d039c2e70b
|
`define EXPECTED_SUM 64'h039ea4d039c2e70b
|
||||||
@@ -54,6 +56,7 @@ module t (/*AUTOARG*/
|
|||||||
rst_n <= ~1'b1;
|
rst_n <= ~1'b1;
|
||||||
end
|
end
|
||||||
else if (cyc<90) begin
|
else if (cyc<90) begin
|
||||||
|
if (pos1 !== pos2) $stop;
|
||||||
end
|
end
|
||||||
else if (cyc==99) begin
|
else if (cyc==99) begin
|
||||||
$write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum);
|
$write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum);
|
||||||
@@ -69,11 +72,12 @@ endmodule
|
|||||||
module Test
|
module Test
|
||||||
#(parameter SAMPLE_WIDTH = 5 )
|
#(parameter SAMPLE_WIDTH = 5 )
|
||||||
(
|
(
|
||||||
`ifdef verilator // UNSUPPORTED
|
`ifdef verilator // Some simulators don't support clog2
|
||||||
output reg [$clog2(SAMPLE_WIDTH)-1:0] pos,
|
output reg [$clog2(SAMPLE_WIDTH)-1:0] pos1,
|
||||||
`else
|
`else
|
||||||
output reg [log2(SAMPLE_WIDTH-1)-1:0] pos,
|
output reg [log2(SAMPLE_WIDTH-1)-1:0] pos1,
|
||||||
`endif
|
`endif
|
||||||
|
output reg [log2(SAMPLE_WIDTH-1)-1:0] pos2,
|
||||||
// System
|
// System
|
||||||
input clk,
|
input clk,
|
||||||
input rst_n
|
input rst_n
|
||||||
@@ -88,9 +92,11 @@ module Test
|
|||||||
|
|
||||||
always @ (posedge clk or negedge rst_n)
|
always @ (posedge clk or negedge rst_n)
|
||||||
if (!rst_n) begin
|
if (!rst_n) begin
|
||||||
pos <= 0;
|
pos1 <= 0;
|
||||||
|
pos2 <= 0;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
pos <= pos + 1;
|
pos1 <= pos1 + 1;
|
||||||
|
pos2 <= pos2 + 1;
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/
|
||||||
|
// Inputs
|
||||||
|
clk
|
||||||
|
);
|
||||||
|
input clk;
|
||||||
|
integer cyc=0;
|
||||||
|
|
||||||
|
genvar g;
|
||||||
|
|
||||||
|
reg [31:0] gen_pre_PLUSPLUS = 32'h0;
|
||||||
|
reg [31:0] gen_pre_MINUSMINUS = 32'h0;
|
||||||
|
reg [31:0] gen_post_PLUSPLUS = 32'h0;
|
||||||
|
reg [31:0] gen_post_MINUSMINUS = 32'h0;
|
||||||
|
reg [31:0] gen_PLUSEQ = 32'h0;
|
||||||
|
reg [31:0] gen_MINUSEQ = 32'h0;
|
||||||
|
reg [31:0] gen_TIMESEQ = 32'h0;
|
||||||
|
reg [31:0] gen_DIVEQ = 32'h0;
|
||||||
|
reg [31:0] gen_MODEQ = 32'h0;
|
||||||
|
reg [31:0] gen_ANDEQ = 32'h0;
|
||||||
|
reg [31:0] gen_OREQ = 32'h0;
|
||||||
|
reg [31:0] gen_XOREQ = 32'h0;
|
||||||
|
reg [31:0] gen_SLEFTEQ = 32'h0;
|
||||||
|
reg [31:0] gen_SRIGHTEQ = 32'h0;
|
||||||
|
reg [31:0] gen_SSRIGHTEQ = 32'h0;
|
||||||
|
|
||||||
|
generate
|
||||||
|
for (g=8; g<=16; ++g) always @(posedge clk) gen_pre_PLUSPLUS[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; --g) always @(posedge clk) gen_pre_MINUSMINUS[g] = 1'b1;
|
||||||
|
for (g=8; g<=16; g++) always @(posedge clk) gen_post_PLUSPLUS[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; g--) always @(posedge clk) gen_post_MINUSMINUS[g] = 1'b1;
|
||||||
|
for (g=8; g<=16; g+=2) always @(posedge clk) gen_PLUSEQ[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; g-=2) always @(posedge clk) gen_MINUSEQ[g] = 1'b1;
|
||||||
|
`ifndef verilator //UNSUPPORTED
|
||||||
|
for (g=8; g<=16; g*=2) always @(posedge clk) gen_TIMESEQ[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; g/=2) always @(posedge clk) gen_DIVEQ[g] = 1'b1;
|
||||||
|
for (g=15; g>8; g%=8) always @(posedge clk) gen_MODEQ[g] = 1'b1;
|
||||||
|
for (g=7; g>4; g&=4) always @(posedge clk) gen_ANDEQ[g] = 1'b1;
|
||||||
|
for (g=1; g<=1; g|=2) always @(posedge clk) gen_OREQ[g] = 1'b1;
|
||||||
|
for (g=7; g==7; g^=2) always @(posedge clk) gen_XOREQ[g] = 1'b1;
|
||||||
|
for (g=8; g<=16; g<<=2) always @(posedge clk) gen_SLEFTEQ[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; g>>=2) always @(posedge clk) gen_SRIGHTEQ[g] = 1'b1;
|
||||||
|
for (g=16; g>=8; g>>>=2) always @(posedge clk) gen_SSRIGHTEQ[g] = 1'b1;
|
||||||
|
`endif
|
||||||
|
endgenerate
|
||||||
|
|
||||||
|
always @ (posedge clk) begin
|
||||||
|
cyc <= cyc + 1;
|
||||||
|
if (cyc == 3) begin
|
||||||
|
`ifdef TEST_VERBOSE
|
||||||
|
$write("gen_pre_PLUSPLUS %b\n", gen_pre_PLUSPLUS);
|
||||||
|
$write("gen_pre_MINUSMINUS %b\n", gen_pre_MINUSMINUS);
|
||||||
|
$write("gen_post_PLUSPLUS %b\n", gen_post_PLUSPLUS);
|
||||||
|
$write("gen_post_MINUSMINUS %b\n", gen_post_MINUSMINUS);
|
||||||
|
$write("gen_PLUSEQ %b\n", gen_PLUSEQ);
|
||||||
|
$write("gen_MINUSEQ %b\n", gen_MINUSEQ);
|
||||||
|
$write("gen_TIMESEQ %b\n", gen_TIMESEQ);
|
||||||
|
$write("gen_DIVEQ %b\n", gen_DIVEQ);
|
||||||
|
$write("gen_MODEQ %b\n", gen_MODEQ);
|
||||||
|
$write("gen_ANDEQ %b\n", gen_ANDEQ);
|
||||||
|
$write("gen_OREQ %b\n", gen_OREQ);
|
||||||
|
$write("gen_XOREQ %b\n", gen_XOREQ);
|
||||||
|
$write("gen_SLEFTEQ %b\n", gen_SLEFTEQ);
|
||||||
|
$write("gen_SRIGHTEQ %b\n", gen_SRIGHTEQ);
|
||||||
|
$write("gen_SSRIGHTEQ %b\n", gen_SSRIGHTEQ);
|
||||||
|
`endif
|
||||||
|
if (gen_pre_PLUSPLUS !== 32'b00000000000000011111111100000000) $stop;
|
||||||
|
if (gen_pre_MINUSMINUS !== 32'b00000000000000011111111100000000) $stop;
|
||||||
|
if (gen_post_PLUSPLUS !== 32'b00000000000000011111111100000000) $stop;
|
||||||
|
if (gen_post_MINUSMINUS!== 32'b00000000000000011111111100000000) $stop;
|
||||||
|
if (gen_PLUSEQ !== 32'b00000000000000010101010100000000) $stop;
|
||||||
|
if (gen_MINUSEQ !== 32'b00000000000000010101010100000000) $stop;
|
||||||
|
`ifndef verilator //UNSUPPORTED
|
||||||
|
if (gen_TIMESEQ !== 32'b00000000000000010000000100000000) $stop;
|
||||||
|
if (gen_DIVEQ !== 32'b00000000000000010000000100000000) $stop;
|
||||||
|
if (gen_MODEQ !== 32'b00000000000000001000000000000000) $stop;
|
||||||
|
if (gen_ANDEQ !== 32'b00000000000000000000000010000000) $stop;
|
||||||
|
if (gen_OREQ !== 32'b00000000000000000000000000000010) $stop;
|
||||||
|
if (gen_XOREQ !== 32'b00000000000000000000000010000000) $stop;
|
||||||
|
if (gen_SLEFTEQ !== 32'b00000000000000000000000100000000) $stop;
|
||||||
|
if (gen_SRIGHTEQ !== 32'b00000000000000010000000000000000) $stop;
|
||||||
|
if (gen_SSRIGHTEQ !== 32'b00000000000000010000000000000000) $stop;
|
||||||
|
`endif
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
@@ -36,8 +36,10 @@ module t (/*AUTOARG*/
|
|||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module m1;
|
module m1;
|
||||||
|
localparam PAR1MINUS1 = PAR1DUP-2-1;
|
||||||
|
localparam PAR1DUP = PAR1+2; // Check we propagate parameters properly
|
||||||
parameter PAR1 = 0;
|
parameter PAR1 = 0;
|
||||||
m2 #(PAR1-1) m2 ();
|
m2 #(PAR1MINUS1) m2 ();
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module m2;
|
module m2;
|
||||||
|
|||||||
@@ -191,4 +191,10 @@ Line_Preproc_Check 131
|
|||||||
(x,y )
|
(x,y )
|
||||||
Line_Preproc_Check 144
|
Line_Preproc_Check 144
|
||||||
|
|
||||||
`line 146 "t/t_preproc.v" 2
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
x,y)--bee submacro has comma paren
|
||||||
|
`line 152 "t/t_preproc.v" 2
|
||||||
|
|||||||
@@ -143,3 +143,9 @@ Line_Preproc_Check `__LINE__
|
|||||||
)
|
)
|
||||||
Line_Preproc_Check `__LINE__
|
Line_Preproc_Check `__LINE__
|
||||||
|
|
||||||
|
//======================================================================
|
||||||
|
// misparsed comma in submacro
|
||||||
|
`define sb bee
|
||||||
|
`define sa(l) x,y)
|
||||||
|
`define sfoo(q,r) q--r
|
||||||
|
`sfoo(`sa(el),`sb) submacro has comma paren
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ module t (/*AUTOARG*/);
|
|||||||
|
|
||||||
reg signed [2:0] negcnt;
|
reg signed [2:0] negcnt;
|
||||||
integer times;
|
integer times;
|
||||||
integer repeats;
|
|
||||||
initial begin
|
initial begin
|
||||||
times = 0;
|
times = 0;
|
||||||
repeat (1) begin
|
repeat (1) begin
|
||||||
@@ -23,7 +22,6 @@ module t (/*AUTOARG*/);
|
|||||||
end
|
end
|
||||||
if (times != 10) $stop;
|
if (times != 10) $stop;
|
||||||
//
|
//
|
||||||
repeats = 0;
|
|
||||||
forever begin
|
forever begin
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
|
|||||||
# Version 2.0.
|
# Version 2.0.
|
||||||
|
|
||||||
compile (
|
compile (
|
||||||
|
v_flags2 => ["--lint-only"],
|
||||||
fails=>$Self->{v3},
|
fails=>$Self->{v3},
|
||||||
expect=>
|
expect=>
|
||||||
'%Error: t/t_var_bad_rsvd.v:\d+: Unsupported: C\+\+ common word: bool
|
q{%Error: t/t_select_bad_tri.v:\d+: Selection index is constantly unknown or tristated: lsb=7'bxxxxxxx width=\?32\?sh47
|
||||||
%Error: t/t_var_bad_rsvd.v:\d+: Unsupported: C\+\+ reserved word: switch
|
%Error: Exiting due to.*},
|
||||||
%Error: Exiting due to.*',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(1);
|
ok(1);
|
||||||
1;
|
1;
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2008 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/);
|
||||||
|
|
||||||
|
reg [72:1] in;
|
||||||
|
initial begin
|
||||||
|
if (in[( (1'h0 / 1'b0) )+:71] != 71'h0) $stop;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
v_flags2 => ["--lint-only"],
|
||||||
|
fails=>$Self->{v3},
|
||||||
|
expect=>
|
||||||
|
'%Error: t/t_var_bad_sv.v:\d+: Unexpected "do": "do" is a SystemVerilog keyword misused as an identifier.
|
||||||
|
%Error: t/t_var_bad_sv.v:\d+: Modify the Verilog-2001 code to avoid SV keywords, or use `begin_keywords or --language.
|
||||||
|
%Error: t/t_var_bad_sv.v:\d+: Unexpected "do": "do" is a SystemVerilog keyword misused as an identifier.
|
||||||
|
.*
|
||||||
|
%Error: Exiting due to.*',
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t;
|
||||||
|
reg do;
|
||||||
|
mod mod (.do(bar));
|
||||||
|
endmodule
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/
|
||||||
|
// Inputs
|
||||||
|
clk
|
||||||
|
);
|
||||||
|
input clk;
|
||||||
|
|
||||||
|
|
||||||
|
integer cyc=0;
|
||||||
|
// Test that we can actually use the logic keyword without an error popping up
|
||||||
|
//reg [63:0] crc;
|
||||||
|
logic [63:0] crc;
|
||||||
|
reg [63:0] sum;
|
||||||
|
|
||||||
|
|
||||||
|
// Take CRC data and apply to testblock inputs
|
||||||
|
wire [31:0] in = crc[31:0];
|
||||||
|
|
||||||
|
/*AUTOWIRE*/
|
||||||
|
// Beginning of automatic wires (for undeclared instantiated-module outputs)
|
||||||
|
wire [31:0] out; // From test of Test.v
|
||||||
|
// End of automatics
|
||||||
|
|
||||||
|
Test test (/*AUTOINST*/
|
||||||
|
// Outputs
|
||||||
|
.out (out[31:0]),
|
||||||
|
// Inputs
|
||||||
|
.clk (clk),
|
||||||
|
.in (in[31:0]));
|
||||||
|
|
||||||
|
// Aggregate outputs into a single result vector
|
||||||
|
wire [63:0] result = {32'h0, out};
|
||||||
|
|
||||||
|
// Test loop
|
||||||
|
always @ (posedge clk) begin
|
||||||
|
`ifdef TEST_VERBOSE
|
||||||
|
$write("[%0t] cyc==%0d crc=%x result=%x\n",$time, cyc, crc, result);
|
||||||
|
`endif
|
||||||
|
cyc <= cyc + 1;
|
||||||
|
crc <= {crc[62:0], crc[63]^crc[2]^crc[0]};
|
||||||
|
sum <= result ^ {sum[62:0],sum[63]^sum[2]^sum[0]};
|
||||||
|
if (cyc==0) begin
|
||||||
|
// Setup
|
||||||
|
crc <= 64'h5aef0c8d_d70a4497;
|
||||||
|
sum <= 64'h0;
|
||||||
|
end
|
||||||
|
else if (cyc<10) begin
|
||||||
|
sum <= 64'h0;
|
||||||
|
end
|
||||||
|
else if (cyc<90) begin
|
||||||
|
end
|
||||||
|
else if (cyc==99) begin
|
||||||
|
$write("[%0t] cyc==%0d crc=%x sum=%x\n",$time, cyc, crc, sum);
|
||||||
|
if (crc !== 64'hc77bb9b3784ea091) $stop;
|
||||||
|
// What checksum will we end up with (above print should match)
|
||||||
|
`define EXPECTED_SUM 64'h4afe43fb79d7b71e
|
||||||
|
if (sum !== `EXPECTED_SUM) $stop;
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module Test (/*AUTOARG*/
|
||||||
|
// Outputs
|
||||||
|
out,
|
||||||
|
// Inputs
|
||||||
|
clk, in
|
||||||
|
);
|
||||||
|
|
||||||
|
input clk;
|
||||||
|
input [31:0] in;
|
||||||
|
output reg [31:0] out;
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
out <= in;
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
);
|
||||||
|
|
||||||
|
execute (
|
||||||
|
check_finished=>1,
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// DESCRIPTION: Verilator: Verilog Test module
|
||||||
|
//
|
||||||
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
|
// without warranty, 2005 by Wilson Snyder.
|
||||||
|
|
||||||
|
// verilator lint_off SYMRSVDWORD
|
||||||
|
|
||||||
|
module t (/*AUTOARG*/
|
||||||
|
// Inputs
|
||||||
|
bool
|
||||||
|
);
|
||||||
|
|
||||||
|
input bool; // BAD
|
||||||
|
|
||||||
|
reg vector; // OK, as not public
|
||||||
|
reg switch /*verilator public*/; // Bad
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
$write("*-* All Finished *-*\n");
|
||||||
|
$finish;
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2003 by Wilson Snyder. This program is free software; you can
|
||||||
|
# redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
|
||||||
|
compile (
|
||||||
|
fails=>$Self->{v3},
|
||||||
|
expect=>
|
||||||
|
q{%Error-SYMRSVDWORD: t/t_var_rsvd_bad.v:\d+: Symbol matches C\+\+ common word: 'bool'
|
||||||
|
%Error-SYMRSVDWORD: t/t_var_rsvd_bad.v:\d+: Symbol matches C\+\+ reserved word: 'switch'
|
||||||
|
%Error: Exiting due to.*},
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
+1
-5
@@ -80,11 +80,7 @@ module t (/*AUTOARG*/
|
|||||||
// Inputs
|
// Inputs
|
||||||
.clk (clk),
|
.clk (clk),
|
||||||
.fastclk (fastclk));
|
.fastclk (fastclk));
|
||||||
t_loop tloop
|
assign passedv[15] = 1'b1;
|
||||||
(.passed (passedv[15]),
|
|
||||||
/*AUTOINST*/
|
|
||||||
// Inputs
|
|
||||||
.clk (clk));
|
|
||||||
assign passedv[16] = 1'b1;
|
assign passedv[16] = 1'b1;
|
||||||
assign passedv[17] = 1'b1;
|
assign passedv[17] = 1'b1;
|
||||||
assign passedv[18] = 1'b1;
|
assign passedv[18] = 1'b1;
|
||||||
|
|||||||
Reference in New Issue
Block a user