mirror of
https://github.com/verilator/verilator.git
synced 2026-10-03 16:44:11 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02530172e7 | ||
|
|
447d803800 | ||
|
|
6b04901c4d | ||
|
|
7fb29621c3 | ||
|
|
b032fce962 | ||
|
|
ce879122bb | ||
|
|
2fa16708b7 | ||
|
|
54bc8608e3 | ||
|
|
706a7802cc | ||
|
|
9dc01cf540 | ||
|
|
8943ad5966 | ||
|
|
deb7a1c9c0 | ||
|
|
96a5445d44 | ||
|
|
d693065afb | ||
|
|
bdeee35669 | ||
|
|
62b3deb90d | ||
|
|
9df9ff59e0 | ||
|
|
23a3271c06 | ||
|
|
f4a5aa2e94 | ||
|
|
bdd54eed1c | ||
|
|
c6a20a72f2 | ||
|
|
d7a54b3632 | ||
|
|
be6a3d0f10 | ||
|
|
e9125a3a22 | ||
|
|
c27a60658f | ||
|
|
8f2bc6e028 | ||
|
|
a6b78cbbee | ||
|
|
182a7076fd | ||
|
|
17a9b22dce | ||
|
|
f190d12802 | ||
|
|
b12dd526f9 | ||
|
|
473d555dc1 | ||
|
|
fa9208ccdd | ||
|
|
4aa088eb2f | ||
|
|
8f8147d646 | ||
|
|
e637dd2390 | ||
|
|
c90960fc88 | ||
|
|
da86a1c9f2 | ||
|
|
0adb789238 | ||
|
|
15082a178b | ||
|
|
4a0db26c36 | ||
|
|
ad3ea636d5 | ||
|
|
6a238b0514 |
@@ -3,6 +3,62 @@ Revision history for Verilator
|
||||
The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
|
||||
* Verilator 3.904 2017-05-30
|
||||
|
||||
*** Fix non-cutable ordering loops on clock arrays, bug1009. [Todd Strader]
|
||||
|
||||
*** Support ports of array of reals, bug1154. [J Briquet]
|
||||
|
||||
*** Support arrayed parameter overrides, bug1153. [John Stevenson]
|
||||
|
||||
*** Support $value$plusargs with variables, bug1165. [Wesley Terpstra]
|
||||
|
||||
**** Support modport access to un-modport objects, bug1161. [Todd Strader]
|
||||
|
||||
**** Add stack trace when can't optimize function, bug1158. [Todd Strader]
|
||||
|
||||
**** Add warning on mis-sized literal, bug1156. [Todd Strader]
|
||||
|
||||
**** Fix interface functions returning wrong parameters, bug996. [Todd Strader]
|
||||
|
||||
**** Fix non-arrayed cells with interface arrays, bug1153. [John Stevenson]
|
||||
|
||||
**** Fix --assert with complex case statements, bug1164. [Enzo Chi]
|
||||
|
||||
|
||||
* Verilator 3.902 2017-04-02
|
||||
|
||||
** Add -FI option to force includes,msg2146. [Amir Gonnen]
|
||||
|
||||
** Add --relative-includes. [Rob Stoddard]
|
||||
|
||||
*** Add error on duplicate pattern assignments, bug1145. [Johan Bjork]
|
||||
|
||||
**** Fix error on improperly widthed default function, bug984. [Todd Strader]
|
||||
|
||||
**** Fix 2009 localparam syntax, msg2139. [Galen Seitz]
|
||||
|
||||
**** Fix ugly interface-to-non-interface errors, bug1112. [Johan Bjork]
|
||||
|
||||
**** Fix LDFLAGS and CFLAGS not preserving order, bug1130. [Olof Kindgren]
|
||||
|
||||
**** Fix internal error on initializing parameter array, bug1131. [Jie Xu]
|
||||
|
||||
**** Fix internal error on interface arrays, bug1135. [John Stevenson]
|
||||
|
||||
**** Fix calling sformatf to display, and elab $displays, bug1139. [Johan Bjork]
|
||||
|
||||
**** Fix realpath compile issue on MSVC++, bug1141. [Miodrag Milanovic]
|
||||
|
||||
**** Fix missing error on interface size mismatch, bug1143. [Johan Bjork]
|
||||
|
||||
**** Fix error on parameters with dotted references, bug1146. [Johan Bjork]
|
||||
|
||||
**** Fix wreal not handling continuous assign, bug1150. [J Briquet]
|
||||
|
||||
**** Fix nested structure parameter selects, bug1150. [J Briquet]
|
||||
|
||||
|
||||
* Verilator 3.900 2017-01-15
|
||||
|
||||
** Internal code changes for improved compatibility and performance.
|
||||
|
||||
@@ -132,6 +132,8 @@ DISTFILES_INC = $(INFOS) .gitignore Artistic COPYING COPYING.LESSER \
|
||||
test_verilated/vgen*.pl \
|
||||
test_regress/t/t*/*.sv* \
|
||||
test_regress/t/t*/*.v* \
|
||||
test_regress/t/t*/*/*.sv* \
|
||||
test_regress/t/t*/*/*.v* \
|
||||
test_regress/t/*.cpp \
|
||||
test_regress/t/*.h \
|
||||
test_regress/t/*.dat \
|
||||
|
||||
+82
-30
@@ -280,6 +280,7 @@ descriptions in the next sections for more information.
|
||||
--exe Link to create executable
|
||||
-F <file> Parse options from a file, relatively
|
||||
-f <file> Parse options from a file
|
||||
-FI <file> Force include of a file
|
||||
-G<name>=<value> Overwrite toplevel parameter
|
||||
--gdb Run Verilator under GDB interactively
|
||||
--gdbbt Run Verilator under GDB for backtrace
|
||||
@@ -323,6 +324,7 @@ descriptions in the next sections for more information.
|
||||
--private Debugging; see docs
|
||||
--public Debugging; see docs
|
||||
-pvalue+<name>=<value> Overwrite toplevel parameter
|
||||
--relative-includes Resolve includes relative to current file
|
||||
--report-unoptflat Extra diagnostics for UNOPTFLAT
|
||||
--savable Enable model save-restore
|
||||
--sc Create SystemC output
|
||||
@@ -493,6 +495,10 @@ If the signal is the input to top-module, the directly the signal name. If you
|
||||
find it difficult to find the exact name, try to use C</*verilator clocker*/> in
|
||||
RTL file to mark the signal directly.
|
||||
|
||||
If clock signals are assigned to vectors and then later used individually,
|
||||
Verilator will attempt to decompose the vector and connect the single-bit
|
||||
clock signals directly. This should be transparent to the user.
|
||||
|
||||
=item --compiler I<compiler-name>
|
||||
|
||||
Enables tunings and workarounds for the specified C++ compiler.
|
||||
@@ -704,6 +710,14 @@ The file may contain // comments which are ignored to the end of the line.
|
||||
Any $VAR, $(VAR), or ${VAR} will be replaced with the specified environment
|
||||
variable.
|
||||
|
||||
=item -FI <file>
|
||||
|
||||
Force include of the specified C++ header file. All generated C++ files
|
||||
will insert a #include of the specified file before any other includes. The
|
||||
specified file might be used to contain define prototypes of custom
|
||||
VL_VPRINTF functions, and may need to include verilatedos.h as this file is
|
||||
included before any other standard includes.
|
||||
|
||||
=item -GI<name>=I<value>
|
||||
|
||||
Overwrites the given parameter of the toplevel module. The value is limited
|
||||
@@ -1014,6 +1028,12 @@ inlining. This will also turn off inlining as if all modules had a
|
||||
Overwrites the given parameter(s) of the toplevel module. See -G for a
|
||||
detailed description.
|
||||
|
||||
=item --relative-includes
|
||||
|
||||
When a file references an include file, resolve the filename relative to
|
||||
the path of the referencing file, instead of relative to the current
|
||||
directory.
|
||||
|
||||
=item --report-unoptflat
|
||||
|
||||
Extra diagnostics for UNOPTFLAT warnings. This includes for each loop, the
|
||||
@@ -1897,54 +1917,71 @@ documented below.
|
||||
Verilator has an important difference from an event based simulator; signal
|
||||
values that are changed by the VPI will not immediately propagate their
|
||||
values, instead the top level header file's eval() method must be called.
|
||||
Normally this would be part of the normal evaluation (IE the next clock
|
||||
Normally this would be part of the normal evaluation (i.e. the next clock
|
||||
edge), not as part of the value change. This makes the performance of VPI
|
||||
routines extremely fast compared to event based simulators, but can confuse
|
||||
some test-benches that expect immediate propagation.
|
||||
|
||||
Note the VPI by it's specified implementation will always be much slower
|
||||
Note the VPI by its specified implementation will always be much slower
|
||||
than accessing the Verilator values by direct reference
|
||||
(structure->module->signame), as the VPI accessors perform lookup in
|
||||
functions at runtime requiring at best hundreds of instructions, while the
|
||||
direct references are evaluated by the compiler and result in only a couple
|
||||
of instructions.
|
||||
|
||||
For signal callbacks to work the main loop of the program must call
|
||||
VerilatedVpi::callValueCbs().
|
||||
|
||||
=head2 VPI Example
|
||||
|
||||
In the below example, we have readme marked read-only, and writeme which if
|
||||
written from outside the model will have the same semantics as if it
|
||||
changed on the specified clock edge.
|
||||
|
||||
module t;
|
||||
reg readme /*verilator public_flat_rd*/;
|
||||
reg writeme /*verilator public_flat_rw @(posedge clk) */;
|
||||
endmodule
|
||||
cat <<EOF >our.v
|
||||
module our (input clk);
|
||||
reg readme /*verilator public_flat_rd*/;
|
||||
reg writeme /*verilator public_flat_rw @(posedge clk) */;
|
||||
initial $finish;
|
||||
endmodule
|
||||
EOF
|
||||
|
||||
There are many online tutorials and books on the VPI, but an example that
|
||||
accesses the above would be:
|
||||
accesses the above signal "readme" would be:
|
||||
|
||||
void read_and_check() {
|
||||
vpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)"t.readme", NULL);
|
||||
if (!vh1) { error... }
|
||||
const char* name = vpi_get_str(vpiName, vh1);
|
||||
printf("Module name: %s\n"); // Prints "readme"
|
||||
cat <<EOF >sim_main.cpp
|
||||
#include "Vour.h"
|
||||
#include "verilated.h"
|
||||
#include "verilated_vpi.h" // Required to get definitions
|
||||
|
||||
s_vpi_value v;
|
||||
v.format = vpiIntVal;
|
||||
vpi_get_value(vh1, &v);
|
||||
printf("Value of v: %d\n", v.value.integer); // Prints "readme"
|
||||
}
|
||||
vluint64_t main_time = 0; // See comments in first example
|
||||
double sc_time_stamp () { return main_time; }
|
||||
|
||||
For signal callbacks to work the main loop of the program must call
|
||||
VerilatedVpi::callValueCbs().
|
||||
void read_and_check() {
|
||||
vpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)"TOP.our.readme", NULL);
|
||||
if (!vh1) { vl_fatal(__FILE__, __LINE__, "sim_main", "No handle found"); }
|
||||
const char* name = vpi_get_str(vpiName, vh1);
|
||||
printf("Module name: %s\n", name); // Prints "readme"
|
||||
|
||||
#include "verilated_vpi.h" // Required to get definitions
|
||||
...
|
||||
while (time passes) {
|
||||
...
|
||||
topp->eval();
|
||||
VerilatedVpi::callValueCbs();
|
||||
}
|
||||
s_vpi_value v;
|
||||
v.format = vpiIntVal;
|
||||
vpi_get_value(vh1, &v);
|
||||
printf("Value of v: %d\n", v.value.integer); // Prints "readme"
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **env) {
|
||||
Verilated::commandArgs(argc, argv);
|
||||
Vour* top = new Vour;
|
||||
Verilated::internalsDump(); // See scopes to help debug
|
||||
while (!Verilated::gotFinish()) {
|
||||
top->eval();
|
||||
VerilatedVpi::callValueCbs(); // For signal callbacks
|
||||
read_and_check();
|
||||
}
|
||||
delete top;
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
=head1 CROSS COMPILATION
|
||||
@@ -2385,6 +2422,14 @@ reduce the size of the final executable when a task is used a very large
|
||||
number of times. For this flag to work, the task and tasks below it must
|
||||
be pure; they cannot reference any variables outside the task itself.
|
||||
|
||||
=item /*verilator public*/ (parameter)
|
||||
|
||||
Used after a parameter declaration to indicate the emitted C code should
|
||||
have the parameter values visible. Due to C++ language restrictions, this
|
||||
may only be used on 64-bit or narrower integral enumerations.
|
||||
|
||||
parameter [2:0] PARAM /*verilator public*/ = 2'b0;
|
||||
|
||||
=item /*verilator public*/ (typedef enum)
|
||||
|
||||
Used after an enum typedef declaration to indicate the emitted C code
|
||||
@@ -2518,6 +2563,14 @@ always @* to reduce missing activity items. Avoid putting $displays in
|
||||
combo blocks, as they may print multiple times when not desired, even on
|
||||
compliant simulators as event ordering is not specified.
|
||||
|
||||
=head2 Signal Naming
|
||||
|
||||
To avoid conflicts with C symbol naming, any character in a signal name
|
||||
that is not alphanumeric nor a single underscore will be replaced by __0hh
|
||||
where hh is the hex code of the character. To avoid conflicts with
|
||||
Verilator's internal symbols, any double underscore are replaced with
|
||||
___05F (5F is the hex code of an underscore.)
|
||||
|
||||
=head2 Bind
|
||||
|
||||
Verilator only supports "bind" to a target module name, not an instance
|
||||
@@ -2922,13 +2975,12 @@ Simply use a different register for the flop:
|
||||
always @* foo[0] = foo_flopped[0];
|
||||
always @* foo[1] = ...
|
||||
|
||||
This is good coding practice anyways.
|
||||
|
||||
It is also possible to disable this error when one of the assignments is
|
||||
inside a public task.
|
||||
|
||||
Ignoring this warning may make Verilator simulations differ from other
|
||||
simulators.
|
||||
This is not illegal in SystemVerilog, but a violation of good coding
|
||||
practice. Verilator reports this as an error, because ignoring this warning
|
||||
may make Verilator simulations differ from other simulators.
|
||||
|
||||
=item BLKSEQ
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
#AC_INIT([Verilator],[#.### YYYY-MM-DD])
|
||||
#AC_INIT([Verilator],[#.### devel])
|
||||
AC_INIT([Verilator],[3.900 2017-01-15])
|
||||
AC_INIT([Verilator],[3.904 2017-05-30])
|
||||
# When releasing, also update header of Changes file
|
||||
|
||||
AC_CONFIG_HEADER(src/config_build.h)
|
||||
|
||||
+62
-20
@@ -302,8 +302,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||
bool inPct = false;
|
||||
bool widthSet = false;
|
||||
int width = 0;
|
||||
const char* pos = formatp;
|
||||
for (; *pos; ++pos) {
|
||||
for (const char* pos = formatp; *pos; ++pos) {
|
||||
if (!inPct && pos[0]=='%') {
|
||||
pctp = pos;
|
||||
inPct = true;
|
||||
@@ -1077,22 +1076,36 @@ IData VL_TESTPLUSARGS_I(const char* formatp) {
|
||||
else return 1;
|
||||
}
|
||||
|
||||
IData VL_VALUEPLUSARGS_IN(int, const char* prefixp, char, string& ldr) {
|
||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||
const char* dp = match.c_str() + 1 /*leading + */ + strlen(prefixp);
|
||||
if (match == "") return 0;
|
||||
ldr = string(dp);
|
||||
return 1;
|
||||
}
|
||||
IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rwp) {
|
||||
string prefix;
|
||||
bool inPct = false;
|
||||
bool done = false;
|
||||
char fmt = ' ';
|
||||
for (const char* posp = ld.c_str(); !done && *posp; ++posp) {
|
||||
if (!inPct && posp[0]=='%') {
|
||||
inPct = true;
|
||||
} else if (!inPct) { // Normal text
|
||||
prefix += *posp;
|
||||
} else { // Format character
|
||||
switch (tolower(*posp)) {
|
||||
case '%':
|
||||
prefix += *posp;
|
||||
inPct = false;
|
||||
break;
|
||||
default:
|
||||
fmt = *posp;
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rwp) {
|
||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||
const char* dp = match.c_str() + 1 /*leading + */ + strlen(prefixp);
|
||||
const string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
||||
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
||||
if (match == "") return 0;
|
||||
|
||||
VL_ZERO_RESET_W(rbits, rwp);
|
||||
switch (tolower(fmt)) {
|
||||
case '%':
|
||||
break;
|
||||
case 'd':
|
||||
vlsint64_t ld;
|
||||
sscanf(dp,"%30" VL_PRI64 "d",&ld);
|
||||
@@ -1108,18 +1121,47 @@ IData VL_VALUEPLUSARGS_IW(int rbits, const char* prefixp, char fmt, WDataOutP rw
|
||||
case 'x':
|
||||
_vl_vsss_based(rwp,rbits, 4, dp, 0, (int)strlen(dp));
|
||||
break;
|
||||
case 's':
|
||||
for (int i=0, lsb=0, pos=((int)strlen(dp))-1; i<rbits && pos>=0; pos--) {
|
||||
_vl_vsss_setbit(rwp,rbits,lsb, 8, dp[pos]); lsb+=8;
|
||||
case 's': // string/no conversion
|
||||
for (int i=0, lsb=0, posp=((int)strlen(dp))-1; i<rbits && posp>=0; posp--) {
|
||||
_vl_vsss_setbit(rwp,rbits,lsb, 8, dp[posp]); lsb+=8;
|
||||
}
|
||||
break;
|
||||
default: // Compile time should have found all errors before this
|
||||
vl_fatal (__FILE__, __LINE__, "", "$value$plusargs format error");
|
||||
break;
|
||||
case 'e': //FALLTHRU - Unsupported
|
||||
case 'f': //FALLTHRU - Unsupported
|
||||
case 'g': //FALLTHRU - Unsupported
|
||||
default: // Other simulators simply return 0 in these cases and don't error out
|
||||
return 0;
|
||||
}
|
||||
_VL_CLEAN_INPLACE_W(rbits,rwp);
|
||||
return 1;
|
||||
}
|
||||
IData VL_VALUEPLUSARGS_INN(int, const string& ld, string& rdr) {
|
||||
string prefix;
|
||||
bool inPct = false;
|
||||
bool done = false;
|
||||
for (const char* posp = ld.c_str(); !done && *posp; ++posp) {
|
||||
if (!inPct && posp[0]=='%') {
|
||||
inPct = true;
|
||||
} else if (!inPct) { // Normal text
|
||||
prefix += *posp;
|
||||
} else { // Format character
|
||||
switch (tolower(*posp)) {
|
||||
case '%':
|
||||
prefix += *posp;
|
||||
inPct = false;
|
||||
break;
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const string& match = VerilatedImp::argPlusMatch(prefix.c_str());
|
||||
const char* dp = match.c_str() + 1 /*leading + */ + prefix.length();
|
||||
if (match == "") return 0;
|
||||
rdr = string(dp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* vl_mc_scan_plusargs(const char* prefixp) {
|
||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||
|
||||
@@ -1077,7 +1077,9 @@ static inline QData VL_MULS_QQQ(int,int lbits,int, QData lhs,QData rhs) {
|
||||
|
||||
static inline WDataOutP VL_MULS_WWW(int,int lbits,int, WDataOutP owp,WDataInP lwp,WDataInP rwp){
|
||||
int words = VL_WORDS_I(lbits);
|
||||
// cppcheck-suppress variableScope
|
||||
IData lwstore[VL_MULS_MAX_WORDS]; // Fixed size, as MSVC++ doesn't allow [words] here
|
||||
// cppcheck-suppress variableScope
|
||||
IData rwstore[VL_MULS_MAX_WORDS];
|
||||
WDataInP lwusp = lwp;
|
||||
WDataInP rwusp = rwp;
|
||||
|
||||
@@ -66,6 +66,19 @@ extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb, int fnwo
|
||||
extern IData VL_SSCANF_INX(int lbits, const string& ld, const char* formatp, ...);
|
||||
extern void VL_SFORMAT_X(int obits_ignored, string &output, const char* formatp, ...);
|
||||
extern string VL_SFORMATF_NX(const char* formatp, ...);
|
||||
extern IData VL_VALUEPLUSARGS_IN(int rbits, const char* prefixp, char fmt, string& ldr);
|
||||
extern IData VL_VALUEPLUSARGS_INW(int rbits, const string& ld, WDataOutP rdp);
|
||||
inline IData VL_VALUEPLUSARGS_INI(int rbits, const string& ld, IData& rdr) {
|
||||
IData rwp[1];
|
||||
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
||||
if (got) rdr = rwp[0];
|
||||
return got;
|
||||
}
|
||||
inline IData VL_VALUEPLUSARGS_INQ(int rbits, const string& ld, QData& rdr) {
|
||||
IData rwp[2];
|
||||
IData got = VL_VALUEPLUSARGS_INW(rbits,ld,rwp);
|
||||
if (got) rdr = VL_SET_QW(rwp);
|
||||
return got;
|
||||
}
|
||||
extern IData VL_VALUEPLUSARGS_INN(int, const string& ld, string& rdr);
|
||||
|
||||
#endif // Guard
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ private:
|
||||
// Move the active's contents to the other active
|
||||
UINFO(4," merge active "<<sensesp<<" into "<<wantp<<endl);
|
||||
if (nodep->sensesStorep()) {
|
||||
if (sensesp != nodep->sensesStorep()) nodep->v3fatalSrc("sensesStore should have been deleted earlier if different\n");
|
||||
if (sensesp != nodep->sensesStorep()) nodep->v3fatalSrc("sensesStore should have been deleted earlier if different");
|
||||
sensesp->unlinkFrBack();
|
||||
// There may be other references to same sense tree,
|
||||
// we'll be removing all references when we get to them,
|
||||
|
||||
+4
-14
@@ -246,20 +246,10 @@ private:
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
|
||||
for (AstNode* icondp = itemp->condsp(); icondp!=NULL; icondp=icondp->nextp()) {
|
||||
AstNode* onep;
|
||||
AstConst* iconstp = icondp->castConst();
|
||||
if (iconstp && iconstp->num().isFourState()
|
||||
&& (nodep->casex() || nodep->casez() || nodep->caseInside())) {
|
||||
V3Number nummask (itemp->fileline(), iconstp->width());
|
||||
nummask.opBitsNonX(iconstp->num());
|
||||
V3Number numval (itemp->fileline(), iconstp->width());
|
||||
numval.opBitsOne(iconstp->num());
|
||||
AstNode* and1p = new AstAnd(itemp->fileline(), nodep->exprp()->cloneTree(false),
|
||||
new AstConst(itemp->fileline(), nummask));
|
||||
AstNode* and2p = new AstAnd(itemp->fileline(),
|
||||
new AstConst(itemp->fileline(), numval),
|
||||
new AstConst(itemp->fileline(), nummask));
|
||||
onep = AstEq::newTyped(itemp->fileline(), and1p, and2p);
|
||||
|
||||
if (nodep->casex() || nodep->casez() || nodep->caseInside()) {
|
||||
onep = AstEqWild::newTyped(itemp->fileline(),
|
||||
nodep->exprp()->cloneTree(false),
|
||||
icondp->cloneTree(false));
|
||||
} else {
|
||||
onep = AstEq::newTyped(icondp->fileline(),
|
||||
nodep->exprp()->cloneTree(false),
|
||||
|
||||
+16
-3
@@ -427,6 +427,7 @@ public:
|
||||
SUPPLY0,
|
||||
SUPPLY1,
|
||||
WIRE,
|
||||
WREAL,
|
||||
IMPLICITWIRE,
|
||||
TRIWIRE,
|
||||
TRI0,
|
||||
@@ -448,13 +449,13 @@ public:
|
||||
static const char* names[] = {
|
||||
"?","GPARAM","LPARAM","GENVAR",
|
||||
"VAR","INPUT","OUTPUT","INOUT",
|
||||
"SUPPLY0","SUPPLY1","WIRE","IMPLICITWIRE",
|
||||
"SUPPLY0","SUPPLY1","WIRE","WREAL","IMPLICITWIRE",
|
||||
"TRIWIRE","TRI0","TRI1",
|
||||
"PORT",
|
||||
"BLOCKTEMP","MODULETEMP","STMTTEMP","XTEMP",
|
||||
"IFACEREF"};
|
||||
return names[m_e]; }
|
||||
bool isSignal() const { return (m_e==WIRE || m_e==IMPLICITWIRE
|
||||
bool isSignal() const { return (m_e==WIRE || m_e==WREAL || m_e==IMPLICITWIRE
|
||||
|| m_e==TRIWIRE
|
||||
|| m_e==TRI0 || m_e==TRI1
|
||||
|| m_e==SUPPLY0 || m_e==SUPPLY1
|
||||
@@ -1674,6 +1675,7 @@ public:
|
||||
virtual bool maybePointedTo() const { return true; }
|
||||
virtual AstNodeDType* virtRefDTypep() const { return NULL; } // Iff has a non-null refDTypep(), as generic node function
|
||||
virtual void virtRefDTypep(AstNodeDType* nodep) { } // Iff has refDTypep(), set as generic node function
|
||||
virtual bool similarDType(AstNodeDType* samep) const = 0; // Assignable equivalence. Call skipRefp() on this and samep before calling
|
||||
//
|
||||
// Changing the width may confuse the data type resolution, so must clear TypeTable cache after use.
|
||||
void widthForce(int width, int sized) { m_width=width; m_widthMin=sized; }
|
||||
@@ -1723,6 +1725,9 @@ public:
|
||||
virtual int widthAlignBytes() const; // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this)
|
||||
virtual int widthTotalBytes() const; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,...
|
||||
// op1 = members
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
return this==samep; // We don't compare members, require exact equivalence
|
||||
}
|
||||
AstMemberDType* membersp() const { return op1p()->castMemberDType(); } // op1 = AstMember list
|
||||
void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
|
||||
bool packed() const { return m_packed; }
|
||||
@@ -1753,7 +1758,7 @@ public:
|
||||
virtual void dump(ostream& str);
|
||||
virtual void dumpSmall(ostream& str);
|
||||
virtual const char* broken() const { BROKEN_RTN(!((m_refDTypep && !childDTypep() && m_refDTypep->brokeExists())
|
||||
|| (!m_refDTypep && childDTypep()))); return NULL; }
|
||||
|| (!m_refDTypep && childDTypep()))); return NULL; }
|
||||
virtual void cloneRelink() { if (m_refDTypep && m_refDTypep->clonep()) {
|
||||
m_refDTypep = m_refDTypep->clonep();
|
||||
}}
|
||||
@@ -1762,6 +1767,14 @@ public:
|
||||
return (msb()==sp->msb()
|
||||
&& subDTypep()==sp->subDTypep()
|
||||
&& rangenp()->sameTree(sp->rangenp())); } // HashedDT doesn't recurse, so need to check children
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
AstNodeArrayDType* sp = samep->castNodeArrayDType();
|
||||
return (sp
|
||||
&& type() == samep->type()
|
||||
&& msb() == sp->msb()
|
||||
&& rangenp()->sameTree(sp->rangenp())
|
||||
&& subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp()));
|
||||
}
|
||||
virtual V3Hash sameHash() const { return V3Hash(V3Hash(m_refDTypep),V3Hash(msb()),V3Hash(lsb())); }
|
||||
AstNodeDType* getChildDTypep() const { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||
|
||||
@@ -140,6 +140,13 @@ AstNodeBiop* AstLte::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) {
|
||||
}
|
||||
}
|
||||
|
||||
AstNodeBiop* AstEqWild::newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp) {
|
||||
if (lhsp->isDouble() && rhsp->isDouble()) {
|
||||
return new AstEqD(fl, lhsp, rhsp);
|
||||
} else {
|
||||
return new AstEqWild(fl, lhsp, rhsp);
|
||||
}
|
||||
}
|
||||
|
||||
bool AstVar::isSigPublic() const {
|
||||
return (m_sigPublic || (v3Global.opt.allPublic() && !isTemp() && !isGenVar()));
|
||||
@@ -195,6 +202,8 @@ string AstVar::verilogKwd() const {
|
||||
return "tri";
|
||||
} else if (varType()==AstVarType::WIRE) {
|
||||
return "wire";
|
||||
} else if (varType()==AstVarType::WREAL) {
|
||||
return "wreal";
|
||||
} else {
|
||||
return dtypep()->name();
|
||||
}
|
||||
|
||||
+29
-16
@@ -180,6 +180,10 @@ public:
|
||||
virtual AstNodeDType* skipRefp() const { return subDTypep()->skipRefp(); }
|
||||
virtual AstNodeDType* skipRefToConstp() const { return subDTypep()->skipRefToConstp(); }
|
||||
virtual AstNodeDType* skipRefToEnump() const { return subDTypep()->skipRefToEnump(); }
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
AstParamTypeDType* sp = samep->castParamTypeDType();
|
||||
return (sp && this->subDTypep()->skipRefp()->similarDType(sp->subDTypep()->skipRefp()));
|
||||
}
|
||||
virtual int widthAlignBytes() const { return dtypep()->widthAlignBytes(); }
|
||||
virtual int widthTotalBytes() const { return dtypep()->widthTotalBytes(); }
|
||||
// METHODS
|
||||
@@ -250,7 +254,9 @@ public:
|
||||
m_uniqueNum = uniqueNumInc();
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(DefImplicitDType)
|
||||
virtual bool same(AstNode* samep) const { return m_uniqueNum==samep->castDefImplicitDType()->m_uniqueNum; }
|
||||
virtual bool same(AstNode* samep) const { return m_uniqueNum==samep->castDefImplicitDType()->m_uniqueNum; }
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
return type()==samep->type() && same(samep); }
|
||||
virtual V3Hash sameHash() const { return V3Hash(m_uniqueNum); }
|
||||
AstNodeDType* getChildDTypep() const { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||
@@ -392,6 +398,8 @@ public:
|
||||
virtual V3Hash sameHash() const { return V3Hash(V3Hash(m.m_keyword), V3Hash(m.m_nrange.hi())); }
|
||||
virtual bool same(AstNode* samep) const { // width/widthMin/numeric compared elsewhere
|
||||
return samep->castBasicDType()->m == m; }
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
return type()==samep->type() && same(samep); }
|
||||
virtual string name() const { return m.m_keyword.ascii(); }
|
||||
virtual const char* broken() const { BROKEN_RTN(dtypep()!=this); return NULL; }
|
||||
AstRange* rangep() const { return op1p()->castRange(); } // op1 = Range of variable
|
||||
@@ -456,6 +464,8 @@ public:
|
||||
}}
|
||||
virtual bool same(AstNode* samep) const {
|
||||
return (m_refDTypep==samep->castConstDType()->m_refDTypep); }
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
return skipRefp()->similarDType(samep->skipRefp()); }
|
||||
virtual V3Hash sameHash() const { return V3Hash(m_refDTypep); } // node's type() included elsewhere
|
||||
AstNodeDType* getChildDTypep() const { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||
@@ -499,6 +509,7 @@ public:
|
||||
virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; }
|
||||
virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; }
|
||||
virtual AstNodeDType* skipRefToEnump() const { return (AstNodeDType*)this; }
|
||||
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
|
||||
virtual int widthAlignBytes() const { return 1; }
|
||||
virtual int widthTotalBytes() const { return 1; }
|
||||
string cellName() const { return m_cellName; }
|
||||
@@ -540,6 +551,8 @@ public:
|
||||
return (m_refDTypep==samep->castRefDType()->m_refDTypep
|
||||
&& m_name==samep->castRefDType()->m_name
|
||||
&& m_packagep==samep->castRefDType()->m_packagep); }
|
||||
virtual bool similarDType(AstNodeDType* samep) const {
|
||||
return skipRefp()->similarDType(samep->skipRefp()); }
|
||||
virtual V3Hash sameHash() const { return V3Hash(V3Hash(m_refDTypep),V3Hash(m_packagep)); }
|
||||
virtual void dump(ostream& str=cout);
|
||||
virtual string name() const { return m_name; }
|
||||
@@ -623,6 +636,7 @@ public:
|
||||
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
|
||||
virtual AstNodeDType* virtRefDTypep() const { return m_refDTypep; }
|
||||
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
|
||||
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
|
||||
//
|
||||
virtual AstBasicDType* basicp() const { return subDTypep()->basicp(); } // (Slow) recurse down to find basic data type (Note don't need virtual - AstVar isn't a NodeDType)
|
||||
AstNodeDType* dtypeSkipRefp() const { return subDTypep()->skipRefp(); } // op1 = Range of variable (Note don't need virtual - AstVar isn't a NodeDType)
|
||||
@@ -704,6 +718,7 @@ public:
|
||||
m_refDTypep = m_refDTypep->clonep();
|
||||
}}
|
||||
virtual bool same(AstNode* samep) const { return m_uniqueNum==samep->castEnumDType()->m_uniqueNum; }
|
||||
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
|
||||
virtual V3Hash sameHash() const { return V3Hash(m_uniqueNum); }
|
||||
AstNodeDType* getChildDTypep() const { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Data type
|
||||
@@ -733,6 +748,7 @@ public:
|
||||
ASTNODE_NODE_FUNCS(ParseTypeDType)
|
||||
AstNodeDType* dtypep() const { return NULL; }
|
||||
// METHODS
|
||||
virtual bool similarDType(AstNodeDType* samep) const { return this==samep; }
|
||||
virtual AstBasicDType* basicp() const { return NULL; }
|
||||
virtual AstNodeDType* skipRefp() const { return NULL; }
|
||||
virtual AstNodeDType* skipRefToConstp() const { return (AstNodeDType*)this; }
|
||||
@@ -2642,28 +2658,24 @@ public:
|
||||
class AstValuePlusArgs : public AstNodeMath {
|
||||
// Parents: expr
|
||||
// Child: variable to set. If NULL then this is a $test$plusargs instead of $value$plusargs
|
||||
private:
|
||||
string m_text;
|
||||
public:
|
||||
AstValuePlusArgs(FileLine* fileline, const string& text, AstNode* exprsp)
|
||||
: AstNodeMath (fileline), m_text(text) {
|
||||
setOp1p(exprsp);
|
||||
AstValuePlusArgs(FileLine* fileline, AstNode* searchp, AstNode* outp)
|
||||
: AstNodeMath (fileline) {
|
||||
setOp1p(searchp); setOp2p(outp);
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(ValuePlusArgs)
|
||||
virtual string name() const { return m_text; }
|
||||
virtual string verilogKwd() const { return "$value$plusargs"; }
|
||||
virtual string emitVerilog() { return verilogKwd(); }
|
||||
virtual string emitC() { return "VL_VALUEPLUSARGS_%nq(%lw, %P, NULL)"; }
|
||||
virtual string emitVerilog() { return "%f$value$plusargs(%l, %k%r)"; }
|
||||
virtual string emitC() { V3ERROR_NA; return ""; }
|
||||
virtual bool isGateOptimizable() const { return false; }
|
||||
virtual bool isPredictOptimizable() const { return false; }
|
||||
virtual bool cleanOut() { return true; }
|
||||
virtual V3Hash sameHash() const { return V3Hash(text()); }
|
||||
virtual bool same(AstNode* samep) const {
|
||||
return text()==samep->castValuePlusArgs()->text(); }
|
||||
AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output
|
||||
void exprsp(AstNode* nodep) { setOp1p(nodep); } // op1 = Expressions to output
|
||||
string text() const { return m_text; } // * = Text to display
|
||||
void text(const string& text) { m_text=text; }
|
||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||
virtual bool same(AstNode* samep) const { return true; }
|
||||
AstNode* searchp() const { return op1p(); } // op1 = Search expression
|
||||
void searchp(AstNode* nodep) { setOp1p(nodep); }
|
||||
AstNode* outp() const { return op2p(); } // op2 = Expressions to output
|
||||
void outp(AstNode* nodep) { setOp2p(nodep); }
|
||||
};
|
||||
|
||||
class AstTestPlusArgs : public AstNodeMath {
|
||||
@@ -4657,6 +4669,7 @@ public:
|
||||
dtypeSetLogicBool(); }
|
||||
ASTNODE_NODE_FUNCS(EqWild)
|
||||
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { return new AstEqWild(this->fileline(), lhsp, rhsp); }
|
||||
static AstNodeBiop* newTyped(FileLine* fl, AstNode* lhsp, AstNode* rhsp); // Return AstEqWild/AstEqD
|
||||
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opWildEq(lhs,rhs); }
|
||||
virtual string emitVerilog() { return "%k(%l %f==? %r)"; }
|
||||
virtual string emitC() { return "VL_EQ_%lq(%lW, %P, %li, %ri)"; }
|
||||
|
||||
+5
-5
@@ -62,7 +62,7 @@ public:
|
||||
if (debug()>=9) cout<<"-nodeDel: "<<(void*)(nodep)<<endl;
|
||||
NodeMap::iterator iter = s_nodes.find(nodep);
|
||||
if (iter==s_nodes.end() || !(iter->second & FLAG_ALLOCATED)) {
|
||||
((AstNode*)(nodep))->v3fatalSrc("Deleting AstNode object that was never tracked or already deleted\n");
|
||||
((AstNode*)(nodep))->v3fatalSrc("Deleting AstNode object that was never tracked or already deleted");
|
||||
}
|
||||
if (iter!=s_nodes.end()) s_nodes.erase(iter);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
if (debug()>=9) cout<<"-nodeNew: "<<(void*)(nodep)<<endl;
|
||||
NodeMap::iterator iter = s_nodes.find(nodep);
|
||||
if (iter!=s_nodes.end() || (iter->second & FLAG_ALLOCATED)) {
|
||||
((AstNode*)(nodep))->v3fatalSrc("Newing AstNode object that is already allocated\n");
|
||||
((AstNode*)(nodep))->v3fatalSrc("Newing AstNode object that is already allocated");
|
||||
}
|
||||
if (iter == s_nodes.end()) {
|
||||
int flags = FLAG_ALLOCATED; // This int needed to appease GCC 4.1.2
|
||||
@@ -94,16 +94,16 @@ public:
|
||||
NodeMap::iterator iter = s_nodes.find(nodep);
|
||||
if (iter == s_nodes.end()) {
|
||||
#ifdef VL_LEAK_CHECKS
|
||||
nodep->v3fatalSrc("AstNode is in tree, but not allocated\n");
|
||||
nodep->v3fatalSrc("AstNode is in tree, but not allocated");
|
||||
#endif
|
||||
} else {
|
||||
if (!(iter->second & FLAG_ALLOCATED)) {
|
||||
#ifdef VL_LEAK_CHECKS
|
||||
nodep->v3fatalSrc("AstNode is in tree, but not allocated\n");
|
||||
nodep->v3fatalSrc("AstNode is in tree, but not allocated");
|
||||
#endif
|
||||
}
|
||||
if (iter->second & FLAG_IN_TREE) {
|
||||
nodep->v3fatalSrc("AstNode is already in tree at another location\n");
|
||||
nodep->v3fatalSrc("AstNode is already in tree at another location");
|
||||
}
|
||||
}
|
||||
int or_flags = FLAG_IN_TREE | (linkable?FLAG_LINKABLE:0);
|
||||
|
||||
+7
-2
@@ -75,7 +75,8 @@ public:
|
||||
m_numStmts += 1;
|
||||
}
|
||||
|
||||
V3CCtorsVisitor(AstNodeModule* nodep, string basename, string argsp="", string callargsp="") {
|
||||
V3CCtorsVisitor(AstNodeModule* nodep, string basename, string argsp="", string callargsp="",
|
||||
const string& stmt="") {
|
||||
m_basename = basename;
|
||||
m_argsp = argsp;
|
||||
m_callargsp = callargsp;
|
||||
@@ -87,6 +88,9 @@ public:
|
||||
m_tlFuncp->isStatic(false);
|
||||
m_tlFuncp->slow(true);
|
||||
m_tlFuncp->argTypes(m_argsp);
|
||||
if (stmt != "") {
|
||||
m_tlFuncp->addStmtsp(new AstCStmt(nodep->fileline(), stmt));
|
||||
}
|
||||
m_funcp = m_tlFuncp;
|
||||
m_modp->addStmtp(m_tlFuncp);
|
||||
}
|
||||
@@ -100,7 +104,8 @@ void V3CCtors::cctorsAll() {
|
||||
// Process each module in turn
|
||||
V3CCtorsVisitor var_reset (modp, "_ctor_var_reset");
|
||||
V3CCtorsVisitor configure_coverage (modp, "_configure_coverage",
|
||||
EmitCBaseVisitor::symClassVar()+ ", bool first", "vlSymsp, first");
|
||||
EmitCBaseVisitor::symClassVar()+ ", bool first", "vlSymsp, first",
|
||||
"if (0 && vlSymsp && first) {} // Prevent unused\n");
|
||||
|
||||
for (AstNode* np = modp->stmtsp(); np; np = np->nextp()) {
|
||||
AstVar* varp = np->castVar();
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ private:
|
||||
for (AstNode* icondp = itemp->condsp(); icondp!=NULL; icondp=icondp->nextp()) {
|
||||
//if (debug()>=9) icondp->dumpTree(cout," caseitem: ");
|
||||
AstConst* iconstp = icondp->castConst();
|
||||
if (!iconstp) nodep->v3fatalSrc("above 'can't parse' should have caught this\n");
|
||||
if (!iconstp) nodep->v3fatalSrc("above 'can't parse' should have caught this");
|
||||
if (neverItem(nodep, iconstp)) {
|
||||
// X in casez can't ever be executed
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -629,9 +629,9 @@ private:
|
||||
}
|
||||
virtual void visit(AstNodeVarRef* nodep) {
|
||||
if (m_scopep) {
|
||||
if (!m_logicVertexp) nodep->v3fatalSrc("Var ref not under a logic block\n");
|
||||
if (!m_logicVertexp) nodep->v3fatalSrc("Var ref not under a logic block");
|
||||
AstVarScope* varscp = nodep->varScopep();
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp\n");
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp");
|
||||
CdcVarVertex* varvertexp = makeVarVertex(varscp);
|
||||
UINFO(5," VARREF to "<<varscp<<endl);
|
||||
// We use weight of one for normal edges,
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ private:
|
||||
AstNode::user1ClearTree();
|
||||
// Create the change detection function
|
||||
AstScope* scopep = nodep->scopep();
|
||||
if (!scopep) nodep->v3fatalSrc("No scope found on top level, perhaps you have no statements?\n");
|
||||
if (!scopep) nodep->v3fatalSrc("No scope found on top level, perhaps you have no statements?");
|
||||
m_statep->m_scopetopp = scopep;
|
||||
|
||||
// Create a wrapper change detection function that calls each change detection function
|
||||
|
||||
+1
-1
@@ -559,7 +559,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
if (!vVxp->inBeginp()) {
|
||||
// At this point, any variable not linked is an error
|
||||
// (It should have at least landed under the Head node)
|
||||
vVxp->nodep()->v3fatalSrc("Variable became stranded in clk gate detection\n");
|
||||
vVxp->nodep()->v3fatalSrc("Variable became stranded in clk gate detection");
|
||||
}
|
||||
if (!lastVxp || vVxp->sortCmp(lastVxp)) {
|
||||
// Different sources for this new node
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ private:
|
||||
UINFO(4," TOPSCOPE "<<nodep<<endl);
|
||||
m_topScopep=nodep;
|
||||
m_scopep = nodep->scopep();
|
||||
if (!m_scopep) nodep->v3fatalSrc("No scope found on top level, perhaps you have no statements?\n");
|
||||
if (!m_scopep) nodep->v3fatalSrc("No scope found on top level, perhaps you have no statements?");
|
||||
//VV***** We reset all user1p()
|
||||
AstNode::user1ClearTree();
|
||||
// Make top functions
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ private:
|
||||
V3Hash hashval = it->first;
|
||||
AstNode* node1p = it->second;
|
||||
if (!node1p->castCFunc()) continue;
|
||||
if (hashval.isIllegal()) node1p->v3fatalSrc("Illegal (unhashed) nodes\n");
|
||||
if (hashval.isIllegal()) node1p->v3fatalSrc("Illegal (unhashed) nodes");
|
||||
for (V3Hashed::iterator eqit = it; eqit != m_hashed.end(); ++eqit) {
|
||||
AstNode* node2p = eqit->second;
|
||||
if (!(eqit->first == hashval)) break;
|
||||
|
||||
+9
-1
@@ -555,7 +555,7 @@ private:
|
||||
// Replace oldp node with a constant set to specified value
|
||||
UASSERT (oldp, "Null old\n");
|
||||
if (oldp->castConst() && !oldp->castConst()->num().isFourState()) {
|
||||
oldp->v3fatalSrc("Already constant??\n");
|
||||
oldp->v3fatalSrc("Already constant??");
|
||||
}
|
||||
AstNode* newp = new AstConst(oldp->fileline(), num);
|
||||
newp->dtypeFrom(oldp);
|
||||
@@ -1491,6 +1491,14 @@ private:
|
||||
did=true;
|
||||
}
|
||||
}
|
||||
else if (m_params && valuep->castInitArray() && nodep->backp()->castPin()) {
|
||||
// Allow parameters to pass arrays
|
||||
// Earlier recursion of InitArray made sure each array value is constant
|
||||
// This exception is fairly fragile, i.e. doesn't support arrays of arrays or other stuff
|
||||
AstNode* newp = valuep->cloneTree(false);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
did = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!did && m_required) {
|
||||
|
||||
+4
-4
@@ -207,8 +207,8 @@ private:
|
||||
dimvalp.push_front(valp);
|
||||
}
|
||||
AstVarRef* varrefp = dimselp->castVarRef();
|
||||
if (!varrefp) nodep->v3fatalSrc("No var underneath arraysels\n");
|
||||
if (!varrefp->varScopep()) varrefp->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp\n");
|
||||
if (!varrefp) nodep->v3fatalSrc("No var underneath arraysels");
|
||||
if (!varrefp->varScopep()) varrefp->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp");
|
||||
varrefp->unlinkFrBack();
|
||||
AstVar* oldvarp = varrefp->varp();
|
||||
int modVecNum = oldvarp->user4(); oldvarp->user4(modVecNum+1);
|
||||
@@ -393,7 +393,7 @@ private:
|
||||
if (!m_activep) nodep->v3fatalSrc("<= not under sensitivity block");
|
||||
if (!m_activep->hasClocked()) nodep->v3error("Internal: Blocking <= assignment in non-clocked block, should have converted in V3Active");
|
||||
AstVarScope* oldvscp = nodep->varScopep();
|
||||
if (!oldvscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp\n");
|
||||
if (!oldvscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp");
|
||||
AstVarScope* dlyvscp = oldvscp->user1p()->castVarScope();
|
||||
if (dlyvscp) { // Multiple use of delayed variable
|
||||
AstActive* oldactivep = dlyvscp->user2p()->castActive();
|
||||
@@ -433,7 +433,7 @@ private:
|
||||
}
|
||||
|
||||
virtual void visit(AstNodeFor* nodep) {
|
||||
nodep->v3fatalSrc("For statements should have been converted to while statements in V3Begin\n");
|
||||
nodep->v3fatalSrc("For statements should have been converted to while statements in V3Begin");
|
||||
}
|
||||
virtual void visit(AstWhile* nodep) {
|
||||
bool oldloop = m_inLoop;
|
||||
|
||||
+25
-47
@@ -217,7 +217,7 @@ public:
|
||||
}
|
||||
virtual void visit(AstNodeCase* nodep) {
|
||||
// In V3Case...
|
||||
nodep->v3fatalSrc("Case statements should have been reduced out\n");
|
||||
nodep->v3fatalSrc("Case statements should have been reduced out");
|
||||
}
|
||||
virtual void visit(AstComment* nodep) {
|
||||
putsDecoration((string)"// "+nodep->name()+" at "+nodep->fileline()->ascii()+"\n");
|
||||
@@ -277,54 +277,15 @@ public:
|
||||
displayNode(nodep, NULL, nodep->text(), nodep->exprsp(), true);
|
||||
}
|
||||
virtual void visit(AstValuePlusArgs* nodep) {
|
||||
string prefix;
|
||||
char format = '?';
|
||||
bool pct=false;
|
||||
int got=0;
|
||||
string txt = nodep->text();
|
||||
for (string::const_iterator it=txt.begin(); it!=txt.end(); ++it) {
|
||||
char ch = *it;
|
||||
if (pct) {
|
||||
pct = false;
|
||||
switch (tolower(ch)) {
|
||||
case '%':
|
||||
prefix += ch;
|
||||
break;
|
||||
case 'd': // FALLTHRU
|
||||
case 'o': // FALLTHRU
|
||||
case 'h': // FALLTHRU
|
||||
case 'x': // FALLTHRU
|
||||
case 'b': // FALLTHRU
|
||||
case 'v': // FALLTHRU
|
||||
case 's':
|
||||
got++; format = tolower(ch);
|
||||
break;
|
||||
case 'e': // FALLTHRU
|
||||
case 'f': // FALLTHRU
|
||||
case 'g':
|
||||
got++; format = tolower(ch);
|
||||
nodep->v3error("Unsupported $value$plusargs format qualifier: '"<<ch<<"'"<<endl);
|
||||
break;
|
||||
default:
|
||||
got++;
|
||||
nodep->v3error("Illegal $value$plusargs format qualifier: '"<<ch<<"'"<<endl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ch == '%') pct = true;
|
||||
else prefix += ch;
|
||||
}
|
||||
if (got!=1) nodep->v3error("Missing or extra $value$plusargs format qualifier: '"<<nodep->text()<<"'"<<endl);
|
||||
puts("VL_VALUEPLUSARGS_I");
|
||||
emitIQW(nodep->exprsp());
|
||||
puts("VL_VALUEPLUSARGS_IN");
|
||||
emitIQW(nodep->outp());
|
||||
puts("(");
|
||||
puts(cvtToStr(nodep->exprsp()->widthMin())); // Note argument width, not node width (which is always 32)
|
||||
putbs(",");
|
||||
putsQuoted(prefix);
|
||||
putbs(",");
|
||||
puts("'"); puts(cvtToStr(format)); puts("'");
|
||||
puts(cvtToStr(nodep->outp()->widthMin()));
|
||||
puts(",");
|
||||
nodep->exprsp()->iterateAndNext(*this);
|
||||
emitCvtPackStr(nodep->searchp());
|
||||
puts(",");
|
||||
putbs("");
|
||||
nodep->outp()->iterateAndNext(*this);
|
||||
puts(")");
|
||||
}
|
||||
virtual void visit(AstTestPlusArgs* nodep) {
|
||||
@@ -618,6 +579,23 @@ public:
|
||||
puts(nodep->hiername());
|
||||
puts(nodep->varp()->name());
|
||||
}
|
||||
void emitCvtPackStr(AstNode* nodep) {
|
||||
if (AstConst* constp = nodep->castConst()) {
|
||||
putbs("string(");
|
||||
putsQuoted(constp->num().toString());
|
||||
puts(")");
|
||||
} else {
|
||||
putbs("VL_CVT_PACK_STR_N");
|
||||
emitIQW(nodep);
|
||||
puts("(");
|
||||
if (nodep->isWide()) {
|
||||
puts(cvtToStr(nodep->widthWords())); // Note argument width, not node width (which is always 32)
|
||||
puts(",");
|
||||
}
|
||||
nodep->iterateAndNext(*this);
|
||||
puts(")");
|
||||
}
|
||||
}
|
||||
void emitConstant(AstConst* nodep, AstVarRef* assigntop, const string& assignString) {
|
||||
// Put out constant set to the specified variable, or given variable in a string
|
||||
if (nodep->num().isFourState()) {
|
||||
|
||||
+1
-6
@@ -270,12 +270,7 @@ void EmitCSyms::emitSymHdr() {
|
||||
puts("#define _"+symClassName()+"_H_\n");
|
||||
puts("\n");
|
||||
|
||||
if (optSystemPerl()) puts("#include \"systemperl.h\"\n");
|
||||
else if (optSystemC()) puts("#include \"systemc.h\"\n");
|
||||
|
||||
if (optSystemPerl() || optSystemC()) {
|
||||
puts("#include \"verilated_sc.h\"\n");
|
||||
}
|
||||
ofp()->putsIntTopInclude();
|
||||
if (v3Global.needHeavy()) {
|
||||
puts("#include \"verilated_heavy.h\"\n");
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -168,16 +168,16 @@ public:
|
||||
|
||||
of.puts("# User CFLAGS (from -CFLAGS on Verilator command line)\n");
|
||||
of.puts("VM_USER_CFLAGS = \\\n");
|
||||
const V3StringSet& cFlags = v3Global.opt.cFlags();
|
||||
for (V3StringSet::const_iterator it = cFlags.begin(); it != cFlags.end(); ++it) {
|
||||
const V3StringList& cFlags = v3Global.opt.cFlags();
|
||||
for (V3StringList::const_iterator it = cFlags.begin(); it != cFlags.end(); ++it) {
|
||||
of.puts("\t"+*it+" \\\n");
|
||||
}
|
||||
of.puts("\n");
|
||||
|
||||
of.puts("# User LDLIBS (from -LDFLAGS on Verilator command line)\n");
|
||||
of.puts("VM_USER_LDLIBS = \\\n");
|
||||
const V3StringSet& ldLibs = v3Global.opt.ldLibs();
|
||||
for (V3StringSet::const_iterator it = ldLibs.begin(); it != ldLibs.end(); ++it) {
|
||||
const V3StringList& ldLibs = v3Global.opt.ldLibs();
|
||||
for (V3StringList::const_iterator it = ldLibs.begin(); it != ldLibs.end(); ++it) {
|
||||
of.puts("\t"+*it+" \\\n");
|
||||
}
|
||||
of.puts("\n");
|
||||
|
||||
@@ -238,10 +238,6 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
|
||||
virtual void visit(AstSFormatF* nodep) {
|
||||
visitNodeDisplay(nodep, NULL, nodep->text(), nodep->exprsp());
|
||||
}
|
||||
virtual void visit(AstValuePlusArgs* nodep) {
|
||||
visitNodeDisplay(nodep, NULL, nodep->text(), nodep->exprsp());
|
||||
}
|
||||
|
||||
virtual void visit(AstFOpen* nodep) {
|
||||
putfs(nodep,nodep->verilogKwd());
|
||||
putbs(" (");
|
||||
|
||||
+6
-1
@@ -269,7 +269,12 @@ inline void v3errorEnd(ostringstream& sstr) { V3Error::v3errorEnd(sstr); }
|
||||
#define UINFO(level,stmsg) {if(VL_UNLIKELY(debug()>=(level))) { cout<<"- "<<V3Error::lineStr(__FILE__,__LINE__)<<stmsg; }}
|
||||
#define UINFONL(level,stmsg) {if(VL_UNLIKELY(debug()>=(level))) { cout<<stmsg; } }
|
||||
|
||||
#define UDEBUGONLY(stmts) {stmts}
|
||||
#ifdef VL_DEBUG
|
||||
# define UDEBUGONLY(stmts) {stmts}
|
||||
#else
|
||||
# define UDEBUGONLY(stmts) {if (0) {stmts}}
|
||||
#endif
|
||||
|
||||
#define UASSERT(condition,stmsg) { if (VL_UNLIKELY(!(condition))) { v3fatalSrc(stmsg); }}
|
||||
// For use in V3Ast static functions only
|
||||
#define UASSERT_STATIC(condition,stmsg) { if (VL_UNLIKELY(!(condition))) { cerr<<"Internal Error: "<<__FILE__<<":"<<dec<<__LINE__<<":"<<(stmsg)<<endl; abort(); } }
|
||||
|
||||
@@ -841,3 +841,10 @@ V3OutFile::~V3OutFile() {
|
||||
if (m_fp) fclose(m_fp);
|
||||
m_fp = NULL;
|
||||
}
|
||||
|
||||
void V3OutFile::putsForceIncs() {
|
||||
const V3StringList& forceIncs = v3Global.opt.forceIncs();
|
||||
for (V3StringList::const_iterator it = forceIncs.begin(); it != forceIncs.end(); ++it) {
|
||||
puts("#include \""+*it+"\"\n");
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -173,6 +173,7 @@ class V3OutFile : public V3OutFormatter {
|
||||
public:
|
||||
V3OutFile(const string& filename, V3OutFormatter::Language lang);
|
||||
virtual ~V3OutFile();
|
||||
void putsForceIncs();
|
||||
private:
|
||||
// CALLBACKS
|
||||
virtual void putcOutput(char chr) { fputc(chr, m_fp); }
|
||||
@@ -193,7 +194,9 @@ public:
|
||||
this->printf("%-19s\t%s;\n", classStar.c_str(), cellname.c_str());
|
||||
}
|
||||
virtual void putsHeader() { puts("// Verilated -*- C++ -*-\n"); }
|
||||
virtual void putsIntTopInclude() { }
|
||||
virtual void putsIntTopInclude() {
|
||||
putsForceIncs();
|
||||
}
|
||||
// Print out public/privates
|
||||
void resetPrivate() { m_private = 0; }
|
||||
void putsPrivate(bool setPrivate) {
|
||||
@@ -213,6 +216,7 @@ public:
|
||||
virtual ~V3OutScFile() {}
|
||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||
virtual void putsIntTopInclude() {
|
||||
putsForceIncs();
|
||||
puts("#include \"systemc.h\"\n");
|
||||
puts("#include \"verilated_sc.h\"\n");
|
||||
}
|
||||
@@ -224,6 +228,7 @@ public:
|
||||
virtual ~V3OutSpFile() {}
|
||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||
virtual void putsIntTopInclude() {
|
||||
putsForceIncs();
|
||||
puts("#include \"systemperl.h\"\n");
|
||||
puts("#include \"verilated_sc.h\"\n");
|
||||
}
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ void FileLine::operator delete(void* objp, size_t size) {
|
||||
if (it != fileLineLeakChecks.end()) {
|
||||
fileLineLeakChecks.erase(it);
|
||||
} else {
|
||||
flp->v3fatalSrc("Deleting FileLine object that was never tracked\n");
|
||||
flp->v3fatalSrc("Deleting FileLine object that was never tracked");
|
||||
}
|
||||
::operator delete(objp);
|
||||
}
|
||||
|
||||
+216
-4
@@ -113,6 +113,20 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
// Returns only the result from the LAST vertex iterated over
|
||||
// Note: This behaves differently than iterateInEdges() in that it will traverse
|
||||
// all edges that exist when it is initially called, whereas
|
||||
// iterateInEdges() will stop traversing edges if one is deleted
|
||||
VNUser iterateCurrentOutEdges(GateGraphBaseVisitor& v, VNUser vu=VNUser(0)) {
|
||||
VNUser ret = VNUser(0);
|
||||
V3GraphEdge* next_edgep = NULL;
|
||||
for (V3GraphEdge* edgep = outBeginp(); edgep; edgep = next_edgep) {
|
||||
// Need to find the next edge before visiting in case the edge is deleted
|
||||
next_edgep = edgep->outNextp();
|
||||
ret = dynamic_cast<GateEitherVertex*>(edgep->top())->accept(v, vu);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
class GateVarVertex : public GateEitherVertex {
|
||||
@@ -291,6 +305,7 @@ private:
|
||||
// {statement}Node::user1p -> GateLogicVertex* for this statement
|
||||
// AstVarScope::user2 -> bool: Signal used in SenItem in *this* always statement
|
||||
// AstVar::user2 -> bool: Warned about SYNCASYNCNET
|
||||
// AstVarNodeRef::user2 -> bool: ConcatOffset visited
|
||||
AstUser1InUse m_inuser1;
|
||||
AstUser2InUse m_inuser2;
|
||||
|
||||
@@ -358,6 +373,7 @@ private:
|
||||
void replaceAssigns();
|
||||
void dedupe();
|
||||
void mergeAssigns();
|
||||
void decomposeClkVectors();
|
||||
|
||||
// VISITORS
|
||||
virtual void visit(AstNetlist* nodep) {
|
||||
@@ -365,6 +381,8 @@ private:
|
||||
//if (debug()>6) m_graph.dump();
|
||||
if (debug()>6) m_graph.dumpDotFilePrefixed("gate_pre");
|
||||
warnSignals(); // Before loss of sync/async pointers
|
||||
// Decompose clock vectors -- need to do this before removing redundant edges
|
||||
decomposeClkVectors();
|
||||
m_graph.removeRedundantEdgesSum(&V3GraphEdge::followAlwaysTrue);
|
||||
m_graph.dumpDotFilePrefixed("gate_simp");
|
||||
// Find gate interconnect and optimize
|
||||
@@ -409,9 +427,9 @@ private:
|
||||
}
|
||||
virtual void visit(AstNodeVarRef* nodep) {
|
||||
if (m_scopep) {
|
||||
if (!m_logicVertexp) nodep->v3fatalSrc("Var ref not under a logic block\n");
|
||||
if (!m_logicVertexp) nodep->v3fatalSrc("Var ref not under a logic block");
|
||||
AstVarScope* varscp = nodep->varScopep();
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp\n");
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp");
|
||||
GateVarVertex* vvertexp = makeVarVertex(varscp);
|
||||
UINFO(5," VARREF to "<<varscp<<endl);
|
||||
if (m_inSenItem) vvertexp->setIsClock();
|
||||
@@ -484,7 +502,7 @@ private:
|
||||
}
|
||||
virtual void visit(AstConcat* nodep) {
|
||||
if (nodep->backp()->castNodeAssign() && nodep->backp()->castNodeAssign()->lhsp()==nodep) {
|
||||
nodep->v3fatalSrc("Concat on LHS of assignment; V3Const should have deleted it\n");
|
||||
nodep->v3fatalSrc("Concat on LHS of assignment; V3Const should have deleted it");
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
@@ -704,7 +722,7 @@ void GateVisitor::replaceAssigns() {
|
||||
if (!vscp->valuep()->castNodeMath()
|
||||
|| vscp->valuep()->nextp()) {
|
||||
vscp->dumpTree(cerr, "vscStrange: ");
|
||||
vscp->v3fatalSrc("Value of varscope not mathematical\n");
|
||||
vscp->v3fatalSrc("Value of varscope not mathematical");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1238,6 +1256,200 @@ void GateVisitor::mergeAssigns() {
|
||||
m_statAssignMerged += merger.numMergedAssigns();
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// Find a var's offset in a concatenation
|
||||
|
||||
class GateConcatVisitor : public GateBaseVisitor {
|
||||
private:
|
||||
// STATE
|
||||
AstVarScope* m_vscp; // Varscope we're trying to find
|
||||
int m_offset; // Current offset of varscope
|
||||
int m_found_offset; // Found offset of varscope
|
||||
bool m_found; // Offset found
|
||||
|
||||
// VISITORS
|
||||
virtual void visit(AstNodeVarRef* nodep) {
|
||||
UINFO(9,"CLK DECOMP Concat search var (off = "<<m_offset<<") - "<<nodep<<endl);
|
||||
if (nodep->varScopep() == m_vscp && !nodep->user2() && !m_found) {
|
||||
// A concatenation may use the same var multiple times
|
||||
// But the graph will initially have an edge per instance
|
||||
nodep->user2(true);
|
||||
m_found_offset = m_offset;
|
||||
m_found = true;
|
||||
UINFO(9,"CLK DECOMP Concat found var (off = "<<m_offset<<") - "<<nodep<<endl);
|
||||
}
|
||||
m_offset += nodep->dtypep()->width();
|
||||
}
|
||||
virtual void visit(AstConcat* nodep) {
|
||||
UINFO(9,"CLK DECOMP Concat search (off = "<<m_offset<<") - "<<nodep<<endl);
|
||||
nodep->rhsp()->iterate(*this);
|
||||
nodep->lhsp()->iterate(*this);
|
||||
}
|
||||
//--------------------
|
||||
// Default
|
||||
virtual void visit(AstNode* nodep) {
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
GateConcatVisitor() {
|
||||
m_vscp = NULL;
|
||||
m_offset = 0;
|
||||
m_found_offset = 0;
|
||||
m_found = false;
|
||||
}
|
||||
virtual ~GateConcatVisitor() {}
|
||||
// PUBLIC METHODS
|
||||
bool concatOffset(AstConcat* concatp, AstVarScope* vscp, int& offsetr) {
|
||||
m_vscp = vscp;
|
||||
m_offset = 0;
|
||||
m_found = false;
|
||||
// Iterate
|
||||
concatp->accept(*this);
|
||||
UINFO(9,"CLK DECOMP Concat Offset (found = "<<m_found<<") ("<<m_found_offset<<") - "<<concatp<<" : "<<vscp<<endl);
|
||||
offsetr = m_found_offset;
|
||||
return m_found;
|
||||
}
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
// Recurse through the graph, looking for clock vectors to bypass
|
||||
|
||||
class GateClkDecompState {
|
||||
public:
|
||||
int m_offset;
|
||||
AstVarScope* m_last_vsp;
|
||||
GateClkDecompState(int offset, AstVarScope* vsp) {
|
||||
m_offset = offset;
|
||||
m_last_vsp = vsp;
|
||||
}
|
||||
virtual ~GateClkDecompState() {}
|
||||
};
|
||||
|
||||
class GateClkDecompGraphVisitor : public GateGraphBaseVisitor {
|
||||
private:
|
||||
// NODE STATE
|
||||
// AstVarScope::user2p -> bool: already visited
|
||||
V3Graph* m_graphp;
|
||||
int m_seen_clk_vectors;
|
||||
AstVarScope* m_clk_vsp;
|
||||
GateVarVertex* m_clk_vvertexp;
|
||||
GateConcatVisitor m_concat_visitor;
|
||||
int m_total_seen_clk_vectors;
|
||||
int m_total_decomposed_clk_vectors;
|
||||
|
||||
virtual VNUser visit(GateVarVertex* vvertexp, VNUser vu) {
|
||||
// Check that we haven't been here before
|
||||
AstVarScope* vsp = vvertexp->varScp();
|
||||
if (vsp->user2SetOnce()) return VNUser(0);
|
||||
UINFO(9,"CLK DECOMP Var - "<<vvertexp<<" : "<<vsp<<endl);
|
||||
if (vsp->varp()->width() > 1) {
|
||||
m_seen_clk_vectors++;
|
||||
m_total_seen_clk_vectors++;
|
||||
}
|
||||
GateClkDecompState* currState = (GateClkDecompState*) vu.c();
|
||||
GateClkDecompState nextState(currState->m_offset, vsp);
|
||||
vvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState));
|
||||
if (vsp->varp()->width() > 1) {
|
||||
m_seen_clk_vectors--;
|
||||
}
|
||||
vsp->user2(false);
|
||||
return VNUser(0);
|
||||
}
|
||||
|
||||
virtual VNUser visit(GateLogicVertex* lvertexp, VNUser vu) {
|
||||
GateClkDecompState* currState = (GateClkDecompState*) vu.c();
|
||||
int clk_offset = currState->m_offset;
|
||||
if (AstAssignW* assignp = lvertexp->nodep()->castAssignW()) {
|
||||
UINFO(9,"CLK DECOMP Logic (off = "<<clk_offset<<") - "<<lvertexp<<" : "<<m_clk_vsp<<endl);
|
||||
if (AstSel* rselp = assignp->rhsp()->castSel()) {
|
||||
if (rselp->lsbp()->castConst() && rselp->widthp()->castConst()) {
|
||||
if (clk_offset < rselp->lsbConst() || clk_offset > rselp->msbConst()) {
|
||||
UINFO(9,"CLK DECOMP Sel [ "<<rselp->msbConst()<<" : "<<rselp->lsbConst()<<" ] dropped clock ("<<clk_offset<<")"<<endl);
|
||||
return VNUser(0);
|
||||
}
|
||||
clk_offset -= rselp->lsbConst();
|
||||
} else {
|
||||
return VNUser(0);
|
||||
}
|
||||
} else if (AstConcat* catp = assignp->rhsp()->castConcat()) {
|
||||
UINFO(9,"CLK DECOMP Concat searching - "<<assignp->lhsp()<<endl);
|
||||
int concat_offset;
|
||||
if (!m_concat_visitor.concatOffset(catp, currState->m_last_vsp, concat_offset)) {
|
||||
return VNUser(0);
|
||||
}
|
||||
clk_offset += concat_offset;
|
||||
}
|
||||
if (AstSel* lselp = assignp->lhsp()->castSel()) {
|
||||
if (lselp->lsbp()->castConst() && lselp->widthp()->castConst()) {
|
||||
clk_offset += lselp->lsbConst();
|
||||
} else {
|
||||
return VNUser(0);
|
||||
}
|
||||
} else if (AstVarRef* vrp = assignp->lhsp()->castVarRef()) {
|
||||
if (vrp->dtypep()->width() == 1 && m_seen_clk_vectors) {
|
||||
if (clk_offset != 0) {
|
||||
UINFO(9,"Should only make it here with clk_offset = 0"<<endl);
|
||||
return VNUser(0);
|
||||
}
|
||||
UINFO(9,"CLK DECOMP Connecting - "<<assignp->lhsp()<<" <-> "<<m_clk_vsp<<endl);
|
||||
AstNode* rhsp = assignp->rhsp();
|
||||
rhsp->replaceWith(new AstVarRef(rhsp->fileline(), m_clk_vsp, false));
|
||||
for (V3GraphEdge* edgep = lvertexp->inBeginp(); edgep; ) {
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
}
|
||||
new V3GraphEdge(m_graphp, m_clk_vvertexp, lvertexp, 1);
|
||||
m_total_decomposed_clk_vectors++;
|
||||
}
|
||||
}
|
||||
GateClkDecompState nextState(clk_offset, currState->m_last_vsp);
|
||||
return lvertexp->iterateCurrentOutEdges(*this, VNUser(&nextState));
|
||||
}
|
||||
return VNUser(0);
|
||||
}
|
||||
|
||||
public:
|
||||
GateClkDecompGraphVisitor(V3Graph* graphp) {
|
||||
m_graphp = graphp;
|
||||
m_seen_clk_vectors = 0;
|
||||
m_clk_vsp = NULL;
|
||||
m_clk_vvertexp = NULL;
|
||||
m_total_seen_clk_vectors = 0;
|
||||
m_total_decomposed_clk_vectors = 0;
|
||||
}
|
||||
virtual ~GateClkDecompGraphVisitor() {
|
||||
V3Stats::addStat("Optimizations, Clocker seen vectors", m_total_seen_clk_vectors);
|
||||
V3Stats::addStat("Optimizations, Clocker decomposed vectors", m_total_decomposed_clk_vectors);
|
||||
}
|
||||
void clkDecomp(GateVarVertex* vvertexp) {
|
||||
UINFO(9,"CLK DECOMP Starting Var - "<<vvertexp<<endl);
|
||||
m_seen_clk_vectors = 0;
|
||||
m_clk_vsp = vvertexp->varScp();
|
||||
m_clk_vvertexp = vvertexp;
|
||||
GateClkDecompState nextState(0, m_clk_vsp);
|
||||
vvertexp->accept(*this, VNUser(&nextState));
|
||||
}
|
||||
};
|
||||
|
||||
void GateVisitor::decomposeClkVectors() {
|
||||
UINFO(9,"Starting clock decomposition"<<endl);
|
||||
AstNode::user2ClearTree();
|
||||
GateClkDecompGraphVisitor decomposer(&m_graph);
|
||||
for (V3GraphVertex* itp = m_graph.verticesBeginp(); itp; itp=itp->verticesNextp()) {
|
||||
if (GateVarVertex* vertp = dynamic_cast<GateVarVertex*>(itp)) {
|
||||
AstVarScope* vsp = vertp->varScp();
|
||||
if (vsp->varp()->attrClocker() == AstVarAttrClocker::CLOCKER_YES) {
|
||||
if (vsp->varp()->width() > 1) {
|
||||
UINFO(9,"Clocker > 1 bit, not decomposing: "<<vsp<<endl);
|
||||
} else {
|
||||
UINFO(9,"CLK DECOMP - "<<vertp<<" : "<<vsp<<endl);
|
||||
decomposer.clkDecomp(vertp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//######################################################################
|
||||
// Convert VARSCOPE(ASSIGN(default, VARREF)) to just VARSCOPE(default)
|
||||
|
||||
+1
-1
@@ -529,7 +529,7 @@ double V3Graph::orderDFSIterate(V3GraphVertex* vertexp) {
|
||||
// Compute fanouts of each node
|
||||
// If forward edge, don't double count that fanout
|
||||
if (vertexp->user() == 2) return vertexp->fanout(); // Already processed it
|
||||
if (vertexp->user() == 1) v3fatalSrc("Loop found, backward edges should be dead\n");
|
||||
if (vertexp->user() == 1) v3fatalSrc("Loop found, backward edges should be dead");
|
||||
vertexp->user(1);
|
||||
double fanout = 0;
|
||||
for (V3GraphEdge* edgep = vertexp->outBeginp(); edgep; edgep = edgep->outNextp()) {
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ DfaVertex* DfaGraph::findStart() {
|
||||
startp = vvertexp;
|
||||
}
|
||||
} else {
|
||||
v3fatalSrc("Non DfaVertex in DfaGraph\n");
|
||||
v3fatalSrc("Non DfaVertex in DfaGraph");
|
||||
}
|
||||
}
|
||||
if (!startp) v3fatalSrc("No start point in NFA graph");
|
||||
@@ -520,7 +520,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!acceptp) v3fatalSrc("No accepting vertex in DFA\n");
|
||||
if (!acceptp) v3fatalSrc("No accepting vertex in DFA");
|
||||
|
||||
// Remap edges
|
||||
for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=vertexp->verticesNextp()) {
|
||||
|
||||
+4
-3
@@ -277,7 +277,7 @@ private:
|
||||
AstVarRef* exprvarrefp = nodep->user2p()->castVarRef();
|
||||
UINFO(8,"connectto: "<<nodep->user2p()<<endl);
|
||||
if (!exprconstp && !exprvarrefp) {
|
||||
nodep->v3fatalSrc("Unknown interconnect type; pinReconnectSimple should have cleared up\n");
|
||||
nodep->v3fatalSrc("Unknown interconnect type; pinReconnectSimple should have cleared up");
|
||||
}
|
||||
if (exprconstp) {
|
||||
m_modp->addStmtp(new AstAssignW(nodep->fileline(),
|
||||
@@ -362,7 +362,7 @@ private:
|
||||
nodep->varp( exprvarrefp->varp() );
|
||||
}
|
||||
else {
|
||||
nodep->v3fatalSrc("Null connection?\n");
|
||||
nodep->v3fatalSrc("Null connection?");
|
||||
}
|
||||
}
|
||||
nodep->name(nodep->varp()->name());
|
||||
@@ -510,10 +510,11 @@ private:
|
||||
// delete it in later optimizations.
|
||||
AstVar* pinOldVarp = pinp->modVarp();
|
||||
AstVar* pinNewVarp = pinOldVarp->clonep();
|
||||
if (!pinNewVarp) pinOldVarp->v3fatalSrc("Cloning failed");
|
||||
|
||||
AstNode* connectRefp = pinp->exprp();
|
||||
if (!connectRefp->castConst() && !connectRefp->castVarRef()) {
|
||||
pinp->v3fatalSrc("Unknown interconnect type; pinReconnectSimple should have cleared up\n");
|
||||
pinp->v3fatalSrc("Unknown interconnect type; pinReconnectSimple should have cleared up");
|
||||
}
|
||||
if (pinNewVarp->isOutOnly() && connectRefp->castConst()) {
|
||||
pinp->v3error("Output port is connected to a constant pin, electrical short");
|
||||
|
||||
+136
-46
@@ -90,7 +90,7 @@ private:
|
||||
// Make a ASSIGNW (expr, pin)
|
||||
AstNode* exprp = nodep->exprp()->cloneTree(false);
|
||||
if (exprp->width() != nodep->modVarp()->width())
|
||||
nodep->v3fatalSrc("Width mismatch, should have been handled in pinReconnectSimple\n");
|
||||
nodep->v3fatalSrc("Width mismatch, should have been handled in pinReconnectSimple");
|
||||
if (nodep->modVarp()->isInout()) {
|
||||
nodep->v3fatalSrc("Unsupported: Verilator is a 2-state simulator");
|
||||
} else if (nodep->modVarp()->isOutput()) {
|
||||
@@ -143,7 +143,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
explicit InstVisitor(AstNode* nodep) {
|
||||
explicit InstVisitor(AstNetlist* nodep) {
|
||||
m_modp=NULL;
|
||||
m_cellp=NULL;
|
||||
//
|
||||
@@ -154,6 +154,65 @@ public:
|
||||
|
||||
//######################################################################
|
||||
|
||||
class InstDeModVarVisitor : public AstNVisitor {
|
||||
// Expand all module variables, and save names for later reference
|
||||
private:
|
||||
// STATE
|
||||
typedef map<string,AstVar*> VarNameMap;
|
||||
VarNameMap m_modVarNameMap; // Per module, name of cloned variables
|
||||
|
||||
static int debug() {
|
||||
static int level = -1;
|
||||
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
|
||||
return level;
|
||||
}
|
||||
|
||||
// VISITORS
|
||||
virtual void visit(AstVar* nodep) {
|
||||
if (nodep->dtypep()->castIfaceRefDType()) {
|
||||
UINFO(8," dm-1-VAR "<<nodep<<endl);
|
||||
insert(nodep);
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
// Save some time
|
||||
virtual void visit(AstNodeMath*) {}
|
||||
// Default: Just iterate
|
||||
virtual void visit(AstNode* nodep) {
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
public:
|
||||
// METHODS
|
||||
void insert(AstVar* nodep) {
|
||||
UINFO(8," dmINSERT "<<nodep<<endl);
|
||||
m_modVarNameMap.insert(make_pair(nodep->name(), nodep));
|
||||
}
|
||||
AstVar* find(const string& name) {
|
||||
VarNameMap::iterator it = m_modVarNameMap.find(name);
|
||||
if (it != m_modVarNameMap.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
void dump() {
|
||||
for (VarNameMap::iterator it=m_modVarNameMap.begin(); it!=m_modVarNameMap.end(); ++it) {
|
||||
cout<<"-namemap: "<<it->first<<" -> "<<it->second<<endl;
|
||||
}
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
explicit InstDeModVarVisitor() {}
|
||||
void accept(AstNodeModule* nodep) {
|
||||
UINFO(8," dmMODULE "<<nodep<<endl);
|
||||
m_modVarNameMap.clear();
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~InstDeModVarVisitor() {}
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
||||
class InstDeVisitor : public AstNVisitor {
|
||||
// Find all cells with arrays, and convert to non-arrayed
|
||||
private:
|
||||
@@ -161,6 +220,9 @@ private:
|
||||
AstRange* m_cellRangep; // Range for arrayed instantiations, NULL for normal instantiations
|
||||
int m_instNum; // Current instantiation number
|
||||
int m_instLsb; // Current instantiation number
|
||||
InstDeModVarVisitor m_deModVars; // State of variables for current cell module
|
||||
|
||||
typedef map<string,AstVar*> VarNameMap;
|
||||
|
||||
static int debug() {
|
||||
static int level = -1;
|
||||
@@ -169,10 +231,46 @@ private:
|
||||
}
|
||||
|
||||
// VISITORS
|
||||
virtual void visit(AstVar* nodep) {
|
||||
if (nodep->dtypep()->castUnpackArrayDType()
|
||||
&& nodep->dtypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType()) {
|
||||
UINFO(8," dv-vec-VAR "<<nodep<<endl);
|
||||
AstUnpackArrayDType* arrdtype = nodep->dtypep()->castUnpackArrayDType();
|
||||
AstNode* prevp = NULL;
|
||||
for (int i = arrdtype->lsb(); i <= arrdtype->msb(); ++i) {
|
||||
string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
UINFO(8,"VAR name insert "<<varNewName<<" "<<nodep<<endl);
|
||||
if (!m_deModVars.find(varNewName)) {
|
||||
AstIfaceRefDType* ifaceRefp = arrdtype->subDTypep()->castIfaceRefDType()->cloneTree(false);
|
||||
arrdtype->addNextHere(ifaceRefp);
|
||||
ifaceRefp->cellp(NULL);
|
||||
|
||||
AstVar* varNewp = nodep->cloneTree(false);
|
||||
varNewp->name(varNewName);
|
||||
varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->dtypep(ifaceRefp);
|
||||
m_deModVars.insert(varNewp);
|
||||
if (!prevp) {
|
||||
prevp = varNewp;
|
||||
} else {
|
||||
prevp->addNextHere(varNewp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prevp) nodep->addNextHere(prevp);
|
||||
if (prevp && debug()==9) { prevp->dumpTree(cout, "newintf: "); cout << endl; }
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
|
||||
virtual void visit(AstCell* nodep) {
|
||||
UINFO(4," CELL "<<nodep<<endl);
|
||||
// Find submodule vars
|
||||
if (!nodep->modp()) nodep->v3fatalSrc("Unlinked");
|
||||
m_deModVars.accept(nodep->modp());
|
||||
//
|
||||
if (nodep->rangep()) {
|
||||
m_cellRangep = nodep->rangep();
|
||||
UINFO(4," CELL "<<nodep<<endl);
|
||||
|
||||
AstVar* ifaceVarp = nodep->nextp()->castVar();
|
||||
bool isIface = ifaceVarp
|
||||
@@ -191,9 +289,10 @@ private:
|
||||
// The spec says we add [x], but that won't work in C...
|
||||
newp->name(newp->name()+"__BRA__"+cvtToStr(m_instNum)+"__KET__");
|
||||
newp->origName(newp->origName()+"__BRA__"+cvtToStr(m_instNum)+"__KET__");
|
||||
UINFO(8," CELL loop "<<newp<<endl);
|
||||
|
||||
// If this AstCell is actually an interface instantiation, let's ensure we also clone
|
||||
// the IfaceRef.
|
||||
// If this AstCell is actually an interface instantiation, also clone the IfaceRef
|
||||
// within the same parent module as the cell
|
||||
if (isIface) {
|
||||
AstUnpackArrayDType* arrdtype = ifaceVarp->dtypep()->castUnpackArrayDType();
|
||||
AstIfaceRefDType* origIfaceRefp = arrdtype->subDTypep()->castIfaceRefDType();
|
||||
@@ -221,36 +320,11 @@ private:
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
} else {
|
||||
m_cellRangep = NULL;
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void visit(AstVar* nodep) {
|
||||
bool isIface = nodep->dtypep()->castUnpackArrayDType()
|
||||
&& nodep->dtypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
if (isIface) {
|
||||
AstUnpackArrayDType* arrdtype = nodep->dtypep()->castUnpackArrayDType();
|
||||
AstNode* prev = NULL;
|
||||
for (int i = arrdtype->lsb(); i <= arrdtype->msb(); ++i) {
|
||||
AstVar* varNewp = nodep->cloneTree(false);
|
||||
AstIfaceRefDType* ifaceRefp = arrdtype->subDTypep()->castIfaceRefDType()->cloneTree(false);
|
||||
arrdtype->addNextHere(ifaceRefp);
|
||||
ifaceRefp->cellp(NULL);
|
||||
varNewp->name(varNewp->name() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->dtypep(ifaceRefp);
|
||||
if (!prev) {
|
||||
prev = varNewp;
|
||||
} else {
|
||||
prev->addNextHere(varNewp);
|
||||
}
|
||||
}
|
||||
nodep->addNextHere(prev);
|
||||
if (debug()==9) { prev->dumpTree(cout, "newintf: "); cout << endl; }
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
|
||||
virtual void visit(AstPin* nodep) {
|
||||
// Any non-direct pins need reconnection with a part-select
|
||||
if (!nodep->exprp()) return; // No-connect
|
||||
@@ -303,7 +377,7 @@ private:
|
||||
}
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
AstVarRef* varrefp = arrselp->lhsp()->castVarRef();
|
||||
AstVarXRef* newp = new AstVarXRef(nodep->fileline(),varrefp->name () + "__BRA__" + index + "__KET__", "", true);
|
||||
AstVarXRef* newp = new AstVarXRef(nodep->fileline(), varrefp->name()+"__BRA__"+index+"__KET__", "", true);
|
||||
newp->dtypep(nodep->modVarp()->dtypep());
|
||||
newp->packagep(varrefp->packagep());
|
||||
arrselp->addNextHere(newp);
|
||||
@@ -319,24 +393,39 @@ private:
|
||||
// Clone the var referenced by the pin, and clone each var referenced by the varref
|
||||
// Clone pin varp:
|
||||
for (int i = pinArrp->lsb(); i <= pinArrp->msb(); ++i) {
|
||||
AstVar* varNewp = pinVarp->cloneTree(false);
|
||||
AstIfaceRefDType* ifaceRefp = pinArrp->subDTypep()->castIfaceRefDType();
|
||||
ifaceRefp->cellp(NULL);
|
||||
varNewp->name(varNewp->name() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->dtypep(ifaceRefp);
|
||||
if (!prevp) {
|
||||
prevp = varNewp;
|
||||
string varNewName = pinVarp->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
AstVar* varNewp = NULL;
|
||||
|
||||
// Only clone the var once for all usages of a given child module
|
||||
if (!pinVarp->backp()) {
|
||||
varNewp = m_deModVars.find(varNewName);
|
||||
} else {
|
||||
prevp->addNextHere(varNewp);
|
||||
AstIfaceRefDType* ifaceRefp = pinArrp->subDTypep()->castIfaceRefDType();
|
||||
ifaceRefp->cellp(NULL);
|
||||
varNewp = pinVarp->cloneTree(false);
|
||||
varNewp->name(varNewName);
|
||||
varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
varNewp->dtypep(ifaceRefp);
|
||||
m_deModVars.insert(varNewp);
|
||||
if (!prevp) {
|
||||
prevp = varNewp;
|
||||
} else {
|
||||
prevp->addNextHere(varNewp);
|
||||
}
|
||||
}
|
||||
if (!varNewp) {
|
||||
if (debug()>=9) m_deModVars.dump();
|
||||
nodep->v3fatalSrc("Module dearray failed for "<<AstNode::prettyName(varNewName));
|
||||
}
|
||||
|
||||
// But clone the pin for each module instance
|
||||
// Now also clone the pin itself and update its varref
|
||||
AstPin* newp = nodep->cloneTree(false);
|
||||
newp->modVarp(varNewp);
|
||||
newp->name(newp->name() + "__BRA__" + cvtToStr(i) + "__KET__");
|
||||
// And replace exprp with a new varxref
|
||||
AstVarRef* varrefp = newp->exprp()->castVarRef();
|
||||
string newname = varrefp->name () + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
string newname = varrefp->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
AstVarXRef* newVarXRefp = new AstVarXRef (nodep->fileline(), newname, "", true);
|
||||
newVarXRefp->varp(newp->modVarp());
|
||||
newVarXRefp->dtypep(newp->modVarp()->dtypep());
|
||||
@@ -348,11 +437,12 @@ private:
|
||||
prevPinp->addNextHere(newp);
|
||||
}
|
||||
}
|
||||
pinVarp->replaceWith(prevp);
|
||||
if (prevp) {
|
||||
pinVarp->replaceWith(prevp);
|
||||
pushDeletep(pinVarp);
|
||||
} // else pinVarp already unlinked when another instance did this step
|
||||
nodep->replaceWith(prevPinp);
|
||||
pushDeletep(pinVarp);
|
||||
pushDeletep(nodep);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +455,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
explicit InstDeVisitor(AstNode* nodep) {
|
||||
explicit InstDeVisitor(AstNetlist* nodep) {
|
||||
m_cellRangep=NULL;
|
||||
m_instNum=0;
|
||||
m_instLsb=0;
|
||||
|
||||
+34
-25
@@ -445,6 +445,10 @@ public:
|
||||
<<") <- se"<<srcp<<" "<<srcp->nodep()<<endl);
|
||||
// srcp should be an interface reference pointing to the interface we want to import
|
||||
lhsp->importFromIface(symsp(), srcp);
|
||||
// Allow access to objects not permissible to be listed in a modport
|
||||
if (srcp->nodep()->castModport()) {
|
||||
lhsp->importFromIface(symsp(), srcp->parentp(), true);
|
||||
}
|
||||
}
|
||||
//m_scopeAliasMap[samn].clear(); // Done with it, but put into debug file
|
||||
}
|
||||
@@ -839,7 +843,7 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
virtual void visit(AstNodeFTask* nodep) {
|
||||
// NodeTask: Remember its name for later resolution
|
||||
UINFO(5," "<<nodep<<endl);
|
||||
if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Function/Task not under module??\n");
|
||||
if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Function/Task not under module?");
|
||||
// Remember the existing symbol table scope
|
||||
VSymEnt* oldCurSymp = m_curSymp;
|
||||
{
|
||||
@@ -873,7 +877,7 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
}
|
||||
virtual void visit(AstVar* nodep) {
|
||||
// Var: Remember its name for later resolution
|
||||
if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Var not under module??\n");
|
||||
if (!m_curSymp || !m_modSymp) nodep->v3fatalSrc("Var not under module?");
|
||||
nodep->iterateChildren(*this);
|
||||
if (!m_statep->forScopeCreation()) {
|
||||
// Find under either a task or the module's vars
|
||||
@@ -957,12 +961,12 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
}
|
||||
virtual void visit(AstTypedef* nodep) {
|
||||
// Remember its name for later resolution
|
||||
if (!m_curSymp) nodep->v3fatalSrc("Typedef not under module??\n");
|
||||
if (!m_curSymp) nodep->v3fatalSrc("Typedef not under module?");
|
||||
nodep->iterateChildren(*this);
|
||||
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
|
||||
}
|
||||
virtual void visit(AstParamTypeDType* nodep) {
|
||||
if (!m_curSymp) nodep->v3fatalSrc("Parameter type not under module??\n");
|
||||
if (!m_curSymp) nodep->v3fatalSrc("Parameter type not under module?");
|
||||
nodep->iterateChildren(*this);
|
||||
m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
|
||||
}
|
||||
@@ -1593,7 +1597,7 @@ private:
|
||||
checkNoDot(nodep);
|
||||
nodep->iterateChildren(*this);
|
||||
if (!nodep->modVarp()) {
|
||||
if (!m_pinSymp) nodep->v3fatalSrc("Pin not under cell?\n");
|
||||
if (!m_pinSymp) nodep->v3fatalSrc("Pin not under cell?");
|
||||
VSymEnt* foundp = m_pinSymp->findIdFlat(nodep->name());
|
||||
const char* whatp = nodep->param() ? "parameter pin" : "pin";
|
||||
if (!foundp) {
|
||||
@@ -1759,26 +1763,29 @@ private:
|
||||
// Upper AstDot visitor will handle it from here
|
||||
}
|
||||
else if (foundp->nodep()->castCell()
|
||||
&& allowVar && m_cellp
|
||||
&& foundp->nodep()->castCell()->modp()->castIface()) {
|
||||
// Interfaces can be referenced like a variable for interconnect
|
||||
&& allowVar && m_cellp) {
|
||||
AstCell* cellp = foundp->nodep()->castCell();
|
||||
VSymEnt* cellEntp = m_statep->getNodeSym(cellp); if (!cellEntp) nodep->v3fatalSrc("No interface sym entry");
|
||||
VSymEnt* parentEntp = cellEntp->parentp(); // Container of the var; probably a module or generate begin
|
||||
string findName = nodep->name()+"__Viftop";
|
||||
VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName);
|
||||
AstVar* ifaceRefVarp = ifaceSymp ? ifaceSymp->nodep()->castVar() : NULL;
|
||||
if (!ifaceRefVarp) nodep->v3fatalSrc("Can't find interface var ref: "<<findName);
|
||||
//
|
||||
ok = true;
|
||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
||||
m_ds.m_dotText += nodep->name();
|
||||
m_ds.m_dotSymp = foundp;
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
UINFO(9," cell -> iface varref "<<foundp->nodep()<<endl);
|
||||
AstNode* newp = new AstVarRef(ifaceRefVarp->fileline(), ifaceRefVarp, false);
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
if (cellp->modp()->castIface()) {
|
||||
// Interfaces can be referenced like a variable for interconnect
|
||||
VSymEnt* cellEntp = m_statep->getNodeSym(cellp); if (!cellEntp) nodep->v3fatalSrc("No interface sym entry");
|
||||
VSymEnt* parentEntp = cellEntp->parentp(); // Container of the var; probably a module or generate begin
|
||||
string findName = nodep->name()+"__Viftop";
|
||||
VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName);
|
||||
AstVar* ifaceRefVarp = ifaceSymp ? ifaceSymp->nodep()->castVar() : NULL;
|
||||
if (!ifaceRefVarp) nodep->v3fatalSrc("Can't find interface var ref: "<<findName);
|
||||
//
|
||||
ok = true;
|
||||
if (m_ds.m_dotText!="") m_ds.m_dotText += ".";
|
||||
m_ds.m_dotText += nodep->name();
|
||||
m_ds.m_dotSymp = foundp;
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
UINFO(9," cell -> iface varref "<<foundp->nodep()<<endl);
|
||||
AstNode* newp = new AstVarRef(ifaceRefVarp->fileline(), ifaceRefVarp, false);
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
} else if (cellp->modp()->castNotFoundModule()) {
|
||||
cellp->v3error("Cannot find file containing interface: " << AstNode::prettyName(cellp->modp()->name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AstVar* varp = foundp->nodep()->castVar()) {
|
||||
AstIfaceRefDType* ifacerefp = LinkDotState::ifaceRefFromArray(varp->subDTypep());
|
||||
@@ -1858,7 +1865,9 @@ private:
|
||||
}
|
||||
//
|
||||
if (!ok) {
|
||||
bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText=="");
|
||||
// Cells/interfaces can't be implicit
|
||||
bool isCell = foundp ? foundp->nodep()->castCell() != NULL : false;
|
||||
bool checkImplicit = (!m_ds.m_dotp && m_ds.m_dotText=="" && !isCell);
|
||||
bool err = !(checkImplicit && m_statep->implicitOk(m_modp, nodep->name()));
|
||||
if (err) {
|
||||
if (foundp) {
|
||||
|
||||
@@ -174,8 +174,10 @@ private:
|
||||
virtual void visit(AstValuePlusArgs* nodep) {
|
||||
bool last_setRefLvalue = m_setRefLvalue;
|
||||
{
|
||||
m_setRefLvalue = false;
|
||||
nodep->searchp()->iterateAndNext(*this);
|
||||
m_setRefLvalue = true;
|
||||
nodep->exprsp()->iterateAndNext(*this);
|
||||
nodep->outp()->iterateAndNext(*this);
|
||||
}
|
||||
m_setRefLvalue = last_setRefLvalue;
|
||||
}
|
||||
|
||||
@@ -236,12 +236,12 @@ private:
|
||||
|
||||
virtual void visit(AstPragma* nodep) {
|
||||
if (nodep->pragType() == AstPragmaType::PUBLIC_MODULE) {
|
||||
if (!m_modp) nodep->v3fatalSrc("PUBLIC_MODULE not under a module\n");
|
||||
if (!m_modp) nodep->v3fatalSrc("PUBLIC_MODULE not under a module");
|
||||
m_modp->modPublic(true);
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->pragType() == AstPragmaType::PUBLIC_TASK) {
|
||||
if (!m_ftaskp) nodep->v3fatalSrc("PUBLIC_TASK not under a task\n");
|
||||
if (!m_ftaskp) nodep->v3fatalSrc("PUBLIC_TASK not under a task");
|
||||
m_ftaskp->taskPublic(true);
|
||||
m_modp->modPublic(true); // Need to get to the task...
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
|
||||
+12
-6
@@ -48,7 +48,7 @@ V3Number::V3Number(VerilogStringLiteral, FileLine* fileline, const string& str)
|
||||
}
|
||||
}
|
||||
}
|
||||
opCleanThis();
|
||||
opCleanThis(true);
|
||||
}
|
||||
|
||||
V3Number::V3Number (FileLine* fileline, const char* sourcep) {
|
||||
@@ -254,7 +254,7 @@ V3Number::V3Number (FileLine* fileline, const char* sourcep) {
|
||||
setBit(obit, bitIs(obit-1));
|
||||
obit++;
|
||||
}
|
||||
opCleanThis();
|
||||
opCleanThis(true);
|
||||
|
||||
//printf("Dump \"%s\" CP \"%s\" B '%c' %d W %d\n", sourcep, value_startp, base, width(), m_value[0]);
|
||||
}
|
||||
@@ -1587,10 +1587,16 @@ V3Number& V3Number::opClean (const V3Number& lhs, uint32_t bits) {
|
||||
return opSel(lhs, bits-1, 0);
|
||||
}
|
||||
|
||||
void V3Number::opCleanThis() {
|
||||
// Clean in place number
|
||||
m_value[words()-1] &= hiWordMask();
|
||||
m_valueX[words()-1] &= hiWordMask();
|
||||
void V3Number::opCleanThis(bool warnOnTruncation) {
|
||||
// Clean MSB of number
|
||||
uint32_t newValueMsb = m_value[words()-1] & hiWordMask();
|
||||
uint32_t newValueXMsb = m_valueX[words()-1] & hiWordMask();
|
||||
if (warnOnTruncation && (newValueMsb != m_value[words()-1] || newValueXMsb != m_valueX[words()-1])) {
|
||||
// Displaying in decimal avoids hiWordMask truncation
|
||||
m_fileline->v3warn(WIDTH,"Value too large for "<<width()<<" bit number: "<<displayed(m_fileline, "%d"));
|
||||
}
|
||||
m_value[words()-1] = newValueMsb;
|
||||
m_valueX[words()-1] = newValueXMsb;
|
||||
}
|
||||
|
||||
V3Number& V3Number::opSel (const V3Number& lhs, const V3Number& msb, const V3Number& lsb) {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class V3Number {
|
||||
// METHODS
|
||||
V3Number& setSingleBits(char value);
|
||||
V3Number& setString(const string& str) { m_isString=true; m_stringVal=str; return *this; }
|
||||
void opCleanThis();
|
||||
void opCleanThis(bool warnOnTruncation = false);
|
||||
public:
|
||||
FileLine* fileline() const { return m_fileline; }
|
||||
void fileline(FileLine* fl) { m_fileline=fl; }
|
||||
|
||||
@@ -84,7 +84,7 @@ void test(string lhss, string op, string rhss, string exps) {
|
||||
V3Number ok (new FileLine("ck",__LINE__), 1);
|
||||
ok.opCaseEq(expnum,gotnum);
|
||||
if (ok.toUInt()!=1) {
|
||||
v3fatalSrc("%Error:Test FAILED\n");
|
||||
v3fatalSrc("%Error:Test FAILED");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-11
@@ -183,14 +183,10 @@ void V3Options::addCppFile(const string& filename) {
|
||||
}
|
||||
}
|
||||
void V3Options::addCFlags(const string& filename) {
|
||||
if (m_cFlags.find(filename) == m_cFlags.end()) {
|
||||
m_cFlags.insert(filename);
|
||||
}
|
||||
m_cFlags.push_back(filename);
|
||||
}
|
||||
void V3Options::addLdLibs(const string& filename) {
|
||||
if (m_ldLibs.find(filename) == m_ldLibs.end()) {
|
||||
m_ldLibs.insert(filename);
|
||||
}
|
||||
m_ldLibs.push_back(filename);
|
||||
}
|
||||
void V3Options::addFuture(const string& flag) {
|
||||
if (m_futures.find(flag) == m_futures.end()) {
|
||||
@@ -229,6 +225,10 @@ void V3Options::addVFile(const string& filename) {
|
||||
// in a specific order and multiple of them.
|
||||
m_vFiles.push_back(filename);
|
||||
}
|
||||
void V3Options::addForceInc(const string& filename) {
|
||||
m_forceIncs.push_back(filename);
|
||||
}
|
||||
|
||||
void V3Options::addArg(const string& arg) {
|
||||
m_impp->m_allArgs.push_back(arg);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ string V3Options::filePathCheckOneDir(const string& modname, const string& dirna
|
||||
return "";
|
||||
}
|
||||
|
||||
string V3Options::filePath (FileLine* fl, const string& modname,
|
||||
string V3Options::filePath (FileLine* fl, const string& modname, const string& lastpath,
|
||||
const string& errmsg) { // Error prefix or "" to suppress error
|
||||
// Find a filename to read the specified module name,
|
||||
// using the incdir and libext's.
|
||||
@@ -351,6 +351,11 @@ string V3Options::filePath (FileLine* fl, const string& modname,
|
||||
if (exists!="") return exists;
|
||||
}
|
||||
|
||||
if (m_relativeIncludes) {
|
||||
string exists = filePathCheckOneDir(modname, lastpath);
|
||||
if (exists!="") return V3Os::filenameRealPath(exists);
|
||||
}
|
||||
|
||||
// Warn and return not found
|
||||
if (errmsg != "") {
|
||||
fl->v3error(errmsg+modname);
|
||||
@@ -555,7 +560,7 @@ string V3Options::version() {
|
||||
|
||||
void V3Options::throwSigsegv() {
|
||||
// cppcheck-suppress nullPointer
|
||||
char* zp=NULL; *zp=0;
|
||||
char* zp=NULL; *zp=0; // Intentional core dump, ignore warnings here
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
@@ -602,7 +607,7 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) {
|
||||
// if sw=="-no-arg", then return true (found it), and flag=false
|
||||
// if sw=="-noarg", then return true (found it), and flag=false
|
||||
// else return false
|
||||
if (arg[0]!='-') v3fatalSrc("OnOff switches must have leading dash.\n");
|
||||
if (arg[0]!='-') v3fatalSrc("OnOff switches must have leading dash");
|
||||
if (0==strcmp(sw,arg)) { flag=true; return true; }
|
||||
else if (0==strncmp(sw,"-no",3) && (0==strcmp(sw+3,arg+1))) { flag=false; return true; }
|
||||
else if (0==strncmp(sw,"-no-",4) && (0==strcmp(sw+4,arg+1))) { flag=false; return true; }
|
||||
@@ -706,6 +711,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
else if ( onoff (sw, "-public", flag/*ref*/) ) { m_public = flag; }
|
||||
else if ( !strncmp(sw, "-pvalue+", strlen("-pvalue+"))) { addParameter(string(sw+strlen("-pvalue+")), false); }
|
||||
else if ( onoff (sw, "-report-unoptflat", flag/*ref*/) ) { m_reportUnoptflat = flag; }
|
||||
else if ( onoff (sw, "-relative-includes", flag/*ref*/) ) { m_relativeIncludes = flag; }
|
||||
else if ( onoff (sw, "-savable", flag/*ref*/) ) { m_savable = flag; }
|
||||
else if ( !strcmp (sw, "-sc") ) { m_outFormatOk = true; m_systemC = true; m_systemPerl = false; }
|
||||
else if ( onoff (sw, "-skip-identical", flag/*ref*/) ) { m_skipIdentical = flag; }
|
||||
@@ -795,11 +801,15 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
shift;
|
||||
V3Error::errorLimit(atoi(argv[i]));
|
||||
}
|
||||
else if ( !strcmp (sw, "-FI") && (i+1)<argc ) {
|
||||
shift;
|
||||
addForceInc(parseFileArg(optdir, string (argv[i])));
|
||||
}
|
||||
else if ( !strncmp (sw, "-G", strlen("-G"))) {
|
||||
addParameter (string (sw+strlen("-G")), false);
|
||||
addParameter(string (sw+strlen("-G")), false);
|
||||
}
|
||||
else if ( !strncmp (sw, "-I", 2)) {
|
||||
addIncDirUser (parseFileArg(optdir, string (sw+strlen("-I"))));
|
||||
addIncDirUser(parseFileArg(optdir, string (sw+strlen("-I"))));
|
||||
}
|
||||
else if ( !strcmp (sw, "-if-depth") && (i+1)<argc ) {
|
||||
shift;
|
||||
@@ -1218,6 +1228,7 @@ V3Options::V3Options() {
|
||||
m_preprocNoLine = false;
|
||||
m_public = false;
|
||||
m_reportUnoptflat = false;
|
||||
m_relativeIncludes = false;
|
||||
m_savable = false;
|
||||
m_skipIdentical = true;
|
||||
m_stats = false;
|
||||
|
||||
+10
-6
@@ -48,14 +48,15 @@ class V3Options {
|
||||
// MEMBERS (general options)
|
||||
V3OptionsImp* m_impp; // Slow hidden options
|
||||
|
||||
V3StringSet m_cppFiles; // argument: C++ files to link against
|
||||
V3StringSet m_cFlags; // argument: user CFLAGS
|
||||
V3StringSet m_ldLibs; // argument: user LDFLAGS
|
||||
V3StringSet m_cppFiles; // argument: C++ files to link against
|
||||
V3StringList m_cFlags; // argument: user CFLAGS
|
||||
V3StringList m_ldLibs; // argument: user LDFLAGS
|
||||
V3StringSet m_futures; // argument: -Wfuture- list
|
||||
V3StringSet m_libraryFiles; // argument: Verilog -v files
|
||||
V3StringSet m_clockers; // argument: Verilog -clk signals
|
||||
V3StringSet m_noClockers; // argument: Verilog -noclk signals
|
||||
V3StringList m_vFiles; // argument: Verilog files to read
|
||||
V3StringList m_forceIncs; // argument: -FI
|
||||
DebugSrcMap m_debugSrcs; // argument: --debugi-<srcfile>=<level>
|
||||
DebugSrcMap m_dumpTrees; // argument: --dump-treei-<srcfile>=<level>
|
||||
map<string,string> m_parameters; // Parameters
|
||||
@@ -88,6 +89,7 @@ class V3Options {
|
||||
bool m_profileCFuncs;// main switch: --profile-cfuncs
|
||||
bool m_public; // main switch: --public
|
||||
bool m_reportUnoptflat; // main switch: --report-unoptflat
|
||||
bool m_relativeIncludes; // main switch: --relative-includes
|
||||
bool m_savable; // main switch: --savable
|
||||
bool m_systemC; // main switch: --sc: System C instead of simple C++
|
||||
bool m_skipIdentical;// main switch: --skip-identical
|
||||
@@ -199,6 +201,7 @@ class V3Options {
|
||||
void addClocker(const string& signame);
|
||||
void addNoClocker(const string& signame);
|
||||
void addVFile(const string& filename);
|
||||
void addForceInc(const string& filename);
|
||||
|
||||
// ACCESSORS (options)
|
||||
bool preprocOnly() const { return m_preprocOnly; }
|
||||
@@ -278,10 +281,11 @@ class V3Options {
|
||||
string xAssign() const { return m_xAssign; }
|
||||
|
||||
const V3StringSet& cppFiles() const { return m_cppFiles; }
|
||||
const V3StringSet& cFlags() const { return m_cFlags; }
|
||||
const V3StringSet& ldLibs() const { return m_ldLibs; }
|
||||
const V3StringList& cFlags() const { return m_cFlags; }
|
||||
const V3StringList& ldLibs() const { return m_ldLibs; }
|
||||
const V3StringSet& libraryFiles() const { return m_libraryFiles; }
|
||||
const V3StringList& vFiles() const { return m_vFiles; }
|
||||
const V3StringList& forceIncs() const { return m_forceIncs; }
|
||||
const V3LangCode& defaultLanguage() const { return m_defaultLanguage; }
|
||||
|
||||
bool hasParameter(string name);
|
||||
@@ -341,7 +345,7 @@ class V3Options {
|
||||
|
||||
// METHODS (file utilities using these options)
|
||||
string fileExists (const string& filename);
|
||||
string filePath (FileLine* fl, const string& modname, const string& errmsg);
|
||||
string filePath(FileLine* fl, const string& modname, const string& lastpath, const string& errmsg);
|
||||
void filePathLookedMsg(FileLine* fl, const string& modname);
|
||||
V3LangCode fileLanguage(const string &filename);
|
||||
static bool fileStatDir (const string& filename);
|
||||
|
||||
+5
-5
@@ -194,7 +194,7 @@ public:
|
||||
// METHODS
|
||||
OrderVarVertex* newVarUserVertex(V3Graph* graphp, AstScope* scopep,
|
||||
AstVarScope* varscp, WhichVertex type, bool* createdp=NULL) {
|
||||
if (type>=WV_MAX) varscp->v3fatalSrc("Bad Case\n");
|
||||
if (type>=WV_MAX) varscp->v3fatalSrc("Bad case");
|
||||
OrderVarVertex* vertexp = m_vertexp[type];
|
||||
if (!vertexp) {
|
||||
UINFO(6,"New vertex "<<varscp<<endl);
|
||||
@@ -205,7 +205,7 @@ public:
|
||||
case WV_PORD: vertexp = new OrderVarPordVertex (graphp, scopep, varscp); break;
|
||||
case WV_POST: vertexp = new OrderVarPostVertex (graphp, scopep, varscp); break;
|
||||
case WV_SETL: vertexp = new OrderVarSettleVertex(graphp, scopep, varscp); break;
|
||||
default: varscp->v3fatalSrc("Bad Case\n");
|
||||
default: varscp->v3fatalSrc("Bad case");
|
||||
}
|
||||
m_vertexp[type] = vertexp;
|
||||
} else {
|
||||
@@ -806,15 +806,15 @@ private:
|
||||
virtual void visit(AstNodeVarRef* nodep) {
|
||||
if (m_scopep) {
|
||||
AstVarScope* varscp = nodep->varScopep();
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp\n");
|
||||
if (!varscp) nodep->v3fatalSrc("Var didn't get varscoped in V3Scope.cpp");
|
||||
if (m_inSenTree) {
|
||||
// Add CLOCK dependency... This is a root of the tree we'll trace
|
||||
if (nodep->lvalue()) nodep->v3fatalSrc("How can a sensitivity be setting a var?\n");
|
||||
if (nodep->lvalue()) nodep->v3fatalSrc("How can a sensitivity be setting a var?");
|
||||
OrderVarVertex* varVxp = newVarUserVertex(varscp, WV_STD);
|
||||
varVxp->isClock(true);
|
||||
new OrderEdge(&m_graph, varVxp, m_activeSenVxp, WEIGHT_MEDIUM);
|
||||
} else {
|
||||
if (!m_logicVxp) nodep->v3fatalSrc("Var ref not under a logic block\n");
|
||||
if (!m_logicVxp) nodep->v3fatalSrc("Var ref not under a logic block");
|
||||
// What new directions is this used
|
||||
// We don't want to add extra edges if the logic block has many usages of same var
|
||||
bool gen = false;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <cerrno>
|
||||
#include <fcntl.h>
|
||||
#include <iomanip>
|
||||
@@ -141,6 +143,23 @@ string V3Os::filenameSubstitute (const string& filename) {
|
||||
|
||||
}
|
||||
|
||||
string V3Os::filenameRealPath(const string& filename) {
|
||||
// Get rid of all the ../ behavior in the middle of the paths.
|
||||
// If there is a ../ that goes down from the 'root' of this path it is preserved.
|
||||
char retpath[PATH_MAX];
|
||||
if (
|
||||
#if defined( _MSC_VER ) || defined( __MINGW32__ )
|
||||
::_fullpath(retpath,filename.c_str(),PATH_MAX)
|
||||
#else
|
||||
realpath(filename.c_str(), retpath)
|
||||
#endif
|
||||
) {
|
||||
return string(retpath);
|
||||
} else {
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
bool V3Os::filenameIsRel(const string& filename) {
|
||||
return (filename.length()>0 && filename[0] != '/');
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
static string filenameNonDirExt (const string& filename) { return filenameNonExt(filenameNonDir(filename)); } ///< Return basename of filename
|
||||
static string filenameDir (const string& filename); ///< Return directory part of filename
|
||||
static string filenameSubstitute (const string& filename); ///< Return filename with env vars removed
|
||||
static string filenameRealPath(const string& fn); ///< Return realpath of filename
|
||||
static bool filenameIsRel (const string& filename); ///< True if relative
|
||||
|
||||
// METHODS (directory utilities)
|
||||
|
||||
+63
-5
@@ -204,7 +204,7 @@ private:
|
||||
pinp->modPTypep(cloneiter->second->castParamTypeDType());
|
||||
}
|
||||
else {
|
||||
pinp->v3fatalSrc("Not linked?\n");
|
||||
pinp->v3fatalSrc("Not linked?");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,59 @@ private:
|
||||
virtual void visit(AstVarRef* nodep) {
|
||||
if (nodep->varp()) nodep->varp()->iterate(*this);
|
||||
}
|
||||
bool ifaceParamReplace(AstVarXRef* nodep, AstNode* candp) {
|
||||
for (; candp; candp = candp->nextp()) {
|
||||
if (nodep->name() == candp->name()) {
|
||||
if (AstVar* varp = candp->castVar()) {
|
||||
UINFO(9,"Found interface parameter: "<<varp<<endl);
|
||||
nodep->varp(varp);
|
||||
return true;
|
||||
} else if (AstPin* pinp = candp->castPin()) {
|
||||
UINFO(9,"Found interface parameter: "<<pinp<<endl);
|
||||
if (!pinp->exprp()) pinp->v3fatalSrc("Interface parameter pin missing expression");
|
||||
nodep->replaceWith(pinp->exprp()->cloneTree(false)); VL_DANGLING(nodep);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
virtual void visit(AstVarXRef* nodep) {
|
||||
// Check to see if the scope is just an interface because interfaces are special
|
||||
string dotted = nodep->dotted();
|
||||
if (!dotted.empty() && nodep->varp() && nodep->varp()->isParam()) {
|
||||
AstNode* backp = nodep;
|
||||
while ((backp = backp->backp())) {
|
||||
if (backp->castNodeModule()) {
|
||||
UINFO(9,"Hit module boundary, done looking for interface"<<endl);
|
||||
break;
|
||||
}
|
||||
if (backp->castVar()
|
||||
&& backp->castVar()->isIfaceRef()
|
||||
&& backp->castVar()->childDTypep()
|
||||
&& backp->castVar()->childDTypep()->castIfaceRefDType()) {
|
||||
AstIfaceRefDType* ifacerefp = backp->castVar()->childDTypep()->castIfaceRefDType();
|
||||
// Interfaces passed in on the port map have ifaces
|
||||
if (AstIface* ifacep = ifacerefp->ifacep()) {
|
||||
if (dotted == backp->name()) {
|
||||
UINFO(9,"Iface matching scope: "<<ifacep<<endl);
|
||||
if (ifaceParamReplace(nodep, ifacep->stmtsp())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Interfaces declared in this module have cells
|
||||
else if (AstCell* cellp = ifacerefp->cellp()) {
|
||||
if (dotted == cellp->name()) {
|
||||
UINFO(9,"Iface matching scope: "<<cellp<<endl);
|
||||
if (ifaceParamReplace(nodep, cellp->paramsp())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nodep->varp(NULL); // Needs relink, as may remove pointed-to var
|
||||
}
|
||||
|
||||
@@ -493,6 +545,12 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
if (AstVar* modvarp = pinp->modVarp()) {
|
||||
if (!modvarp->isGParam()) {
|
||||
pinp->v3error("Attempted parameter setting of non-parameter: Param "<<pinp->prettyName()<<" of "<<nodep->prettyName());
|
||||
} else if (pinp->exprp()->castInitArray()
|
||||
&& modvarp->subDTypep()->castUnpackArrayDType()) {
|
||||
// Array assigned to array
|
||||
AstNode* exprp = pinp->exprp();
|
||||
longname += "_" + paramSmallName(nodep->modp(),modvarp)+paramValueNumber(exprp);
|
||||
any_overrides = true;
|
||||
} else {
|
||||
AstConst* exprp = pinp->exprp()->castConst();
|
||||
AstConst* origp = modvarp->valuep()->castConst();
|
||||
@@ -541,7 +599,7 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
AstVar* modvarp = pinp->modVarp();
|
||||
if (modvarp->isIfaceRef()) {
|
||||
AstIfaceRefDType* portIrefp = modvarp->subDTypep()->castIfaceRefDType();
|
||||
if (!portIrefp) {
|
||||
if (!portIrefp && modvarp->subDTypep()->castUnpackArrayDType()) {
|
||||
portIrefp = modvarp->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
}
|
||||
|
||||
@@ -574,7 +632,7 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
UINFO(9," portIfaceRef "<<portIrefp<<endl);
|
||||
|
||||
if (!portIrefp) {
|
||||
pinp->v3error("Interface port '"<<modvarp->prettyName()<<"' is not an interface" << modvarp);
|
||||
pinp->v3error("Interface port '"<<modvarp->prettyName()<<"' is not an interface " << modvarp);
|
||||
} else if (!pinIrefp) {
|
||||
pinp->v3error("Interface port '"<<modvarp->prettyName()<<"' is not connected to interface/modport pin expression");
|
||||
} else {
|
||||
@@ -651,11 +709,11 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp=pinp->nextp()->castPin()) {
|
||||
if (pinp->exprp()) {
|
||||
if (AstVar* modvarp = pinp->modVarp()) {
|
||||
AstConst* constp = pinp->exprp()->castConst();
|
||||
AstNode* newp = pinp->exprp(); // Const or InitArray
|
||||
// Remove any existing parameter
|
||||
if (modvarp->valuep()) modvarp->valuep()->unlinkFrBack()->deleteTree();
|
||||
// Set this parameter to value requested by cell
|
||||
modvarp->valuep(constp->cloneTree(false));
|
||||
modvarp->valuep(newp->cloneTree(false));
|
||||
}
|
||||
else if (AstParamTypeDType* modptp = pinp->modPTypep()) {
|
||||
AstNodeDType* dtypep = pinp->exprp()->castNodeDType();
|
||||
|
||||
+5
-4
@@ -33,6 +33,7 @@
|
||||
#include "V3PreProc.h"
|
||||
#include "V3File.h"
|
||||
#include "V3Parse.h"
|
||||
#include "V3Os.h"
|
||||
|
||||
//######################################################################
|
||||
|
||||
@@ -102,7 +103,7 @@ protected:
|
||||
|
||||
// Preprocess
|
||||
s_filterp = filterp;
|
||||
bool ok = preprocOpen(fl, s_filterp, modname, errmsg);
|
||||
bool ok = preprocOpen(fl, s_filterp, modname, "", errmsg);
|
||||
if (!ok) return false;
|
||||
|
||||
while (!s_preprocp->isEof()) {
|
||||
@@ -116,10 +117,10 @@ protected:
|
||||
if (modname[0]=='/' || modname[0]=='\\') {
|
||||
fl->v3warn(INCABSPATH,"Suggest `include with absolute path be made relative, and use +include: "<<modname);
|
||||
}
|
||||
preprocOpen(fl, s_filterp, modname, "Cannot find include file: ");
|
||||
preprocOpen(fl, s_filterp, modname, V3Os::filenameDir(fl->filename()), "Cannot find include file: ");
|
||||
}
|
||||
|
||||
bool preprocOpen (FileLine* fl, V3InFilter* filterp, const string& modname,
|
||||
bool preprocOpen (FileLine* fl, V3InFilter* filterp, const string& modname, const string& lastpath,
|
||||
const string& errmsg) { // Error message or "" to suppress
|
||||
// Returns true if successful
|
||||
// Allow user to put `defined names on the command line instead of filenames,
|
||||
@@ -127,7 +128,7 @@ protected:
|
||||
string ppmodname = s_preprocp->removeDefines (modname);
|
||||
|
||||
// Open include or master file
|
||||
string filename = v3Global.opt.filePath (fl, ppmodname, errmsg);
|
||||
string filename = v3Global.opt.filePath (fl, ppmodname, lastpath, errmsg);
|
||||
if (filename=="") return false; // Not found
|
||||
|
||||
UINFO(2," Reading "<<filename<<endl);
|
||||
|
||||
+153
-50
@@ -44,12 +44,25 @@
|
||||
#include "V3Task.h"
|
||||
|
||||
#include <deque>
|
||||
#include <sstream>
|
||||
|
||||
//============================================================================
|
||||
|
||||
//######################################################################
|
||||
// Simulate class functions
|
||||
|
||||
class SimulateStackNode {
|
||||
public:
|
||||
// MEMBERS
|
||||
AstFuncRef* m_funcp;
|
||||
V3TaskConnects* m_tconnects;
|
||||
// CONSTRUCTORS
|
||||
SimulateStackNode(AstFuncRef* funcp, V3TaskConnects* tconnects):
|
||||
m_funcp(funcp),
|
||||
m_tconnects(tconnects) {}
|
||||
~SimulateStackNode() {}
|
||||
};
|
||||
|
||||
class SimulateVisitor : public AstNVisitor {
|
||||
// Simulate a node tree, returning value of variables
|
||||
// Two major operating modes:
|
||||
@@ -90,6 +103,12 @@ private:
|
||||
// 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
|
||||
deque<SimulateStackNode*> m_callStack; ///< Call stack for verbose error messages
|
||||
|
||||
// Cleanup
|
||||
// V3Numbers that represents strings are a bit special and the API for V3Number does not allow changing them.
|
||||
deque<V3Number*> m_stringNumbersp; // List of allocated string numbers
|
||||
|
||||
|
||||
// Note level 8&9 include debugging each simulation value
|
||||
static int debug() {
|
||||
@@ -98,6 +117,54 @@ private:
|
||||
return level;
|
||||
}
|
||||
|
||||
// Potentially very slow, intended for debugging
|
||||
string prettyNumber(V3Number* nump, AstNodeDType* dtypep) {
|
||||
if (AstRefDType* refdtypep = dtypep->castRefDType()) {
|
||||
dtypep = refdtypep->skipRefp();
|
||||
}
|
||||
if (AstStructDType* stp = dtypep->castStructDType()) {
|
||||
if (stp->packed()) {
|
||||
ostringstream out;
|
||||
out<<"'{";
|
||||
for (AstMemberDType* itemp = stp->membersp(); itemp; itemp=itemp->nextp()->castMemberDType()) {
|
||||
int width = itemp->width();
|
||||
int lsb = itemp->lsb();
|
||||
int msb = lsb + width - 1;
|
||||
V3Number fieldNum = V3Number(nump->fileline(), width);
|
||||
fieldNum.opSel(*nump, msb, lsb);
|
||||
out<<itemp->name()<<": ";
|
||||
if (AstNodeDType * childTypep = itemp->subDTypep()) {
|
||||
out<<prettyNumber(&fieldNum, childTypep);
|
||||
} else {
|
||||
out<<fieldNum;
|
||||
}
|
||||
if (itemp->nextp()) out<<", ";
|
||||
}
|
||||
out<<"}";
|
||||
return out.str();
|
||||
}
|
||||
} else if (AstPackArrayDType * arrayp = dtypep->castPackArrayDType()) {
|
||||
if (AstNodeDType * childTypep = arrayp->subDTypep()) {
|
||||
ostringstream out;
|
||||
out<<"[";
|
||||
int arrayElements = arrayp->elementsConst();
|
||||
for (int element = 0; element < arrayElements; ++element) {
|
||||
int width = childTypep->width();
|
||||
int lsb = width * element;
|
||||
int msb = lsb + width - 1;
|
||||
V3Number fieldNum = V3Number(nump->fileline(), width);
|
||||
fieldNum.opSel(*nump, msb, lsb);
|
||||
int arrayElem = arrayp->lsb() + element;
|
||||
out<<arrayElem<<" = "<<prettyNumber(&fieldNum, childTypep);
|
||||
if (element < arrayElements - 1) out<<", ";
|
||||
}
|
||||
out<<"]";
|
||||
return out.str();
|
||||
}
|
||||
}
|
||||
return nump->ascii();
|
||||
}
|
||||
|
||||
// Checking METHODS
|
||||
public:
|
||||
/// Call other-this function on all new *non-constant* var references
|
||||
@@ -114,6 +181,19 @@ public:
|
||||
cout<<endl;
|
||||
}
|
||||
m_whyNotOptimizable = why;
|
||||
ostringstream stack;
|
||||
for (deque<SimulateStackNode*>::iterator it=m_callStack.begin(); it !=m_callStack.end(); ++it) {
|
||||
AstFuncRef* funcp = (*it)->m_funcp;
|
||||
stack<<"\nCalled from:\n"<<funcp->fileline()<<" "<<funcp->prettyName()<<"() with parameters:";
|
||||
V3TaskConnects* tconnects = (*it)->m_tconnects;
|
||||
for (V3TaskConnects::iterator conIt = tconnects->begin(); conIt != tconnects->end(); ++conIt) {
|
||||
AstVar* portp = conIt->first;
|
||||
AstNode* pinp = conIt->second->exprp();
|
||||
AstNodeDType* dtypep = pinp->dtypep();
|
||||
stack<<"\n "<<portp->prettyName()<<" = "<<prettyNumber(fetchNumber(pinp), dtypep);
|
||||
}
|
||||
}
|
||||
m_whyNotOptimizable += stack.str();
|
||||
}
|
||||
}
|
||||
inline bool optimizable() const { return m_whyNotNodep==NULL; }
|
||||
@@ -463,52 +543,53 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
bool handleAssignSel(AstNodeAssign* nodep, AstSel* selp, AstVarRef** outVarrefp, int depth) {
|
||||
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
||||
AstVarRef* varrefp = NULL;
|
||||
V3Number lsb = V3Number(nodep->fileline());
|
||||
nodep->rhsp()->iterateAndNext(*this); // Value to assign
|
||||
handleAssignSelRecurse(nodep, selp, varrefp/*ref*/, lsb/*ref*/, 0);
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
if (!varrefp) nodep->v3fatalSrc("Indicated optimizable, but no variable found on RHS of select");
|
||||
AstNode* vscp = varOrScope(varrefp);
|
||||
V3Number outnum = V3Number(nodep->fileline());
|
||||
if (V3Number* vscpnump = fetchOutNumberNull(vscp)) {
|
||||
outnum = *vscpnump;
|
||||
} else if (V3Number* vscpnump = fetchNumberNull(vscp)) {
|
||||
outnum = *vscpnump;
|
||||
} else { // Assignment to unassigned variable, all bits are X or 0
|
||||
outnum = V3Number(nodep->fileline(), varrefp->varp()->widthMin());
|
||||
if (varrefp->varp()->basicp() && varrefp->varp()->basicp()->isZeroInit()) {
|
||||
outnum.setAllBits0();
|
||||
} else {
|
||||
outnum.setAllBitsX();
|
||||
}
|
||||
}
|
||||
outnum.opSelInto(*fetchNumber(nodep->rhsp()),
|
||||
lsb,
|
||||
selp->widthConst());
|
||||
assignOutNumber(nodep, vscp, &outnum);
|
||||
}
|
||||
}
|
||||
void handleAssignSelRecurse (AstNodeAssign* nodep, AstSel* selp,
|
||||
AstVarRef*& outVarrefpRef, V3Number& lsbRef,
|
||||
int depth) {
|
||||
// Recurse down to find final variable being set (outVarrefp), with value to write on nodep->rhsp()
|
||||
checkNodeInfo(selp);
|
||||
AstVarRef* varrefp = selp->fromp()->castVarRef();
|
||||
if (!varrefp) {
|
||||
selp = selp->lhsp()->castSel();
|
||||
if (selp) {
|
||||
if (!handleAssignSel(nodep, selp, &varrefp, depth+1)) {
|
||||
clearOptimizable(nodep, "Select LHS isn't simple variable");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_checkOnly) {
|
||||
nodep->iterateChildren(*this);
|
||||
} else {
|
||||
selp->lsbp()->iterateAndNext(*this);
|
||||
nodep->rhsp()->iterateAndNext(*this);
|
||||
|
||||
selp->lsbp()->iterateAndNext(*this); // Bit index
|
||||
if (AstVarRef* varrefp = selp->fromp()->castVarRef()) {
|
||||
outVarrefpRef = varrefp;
|
||||
lsbRef = *fetchNumber(selp->lsbp());
|
||||
return; // And presumably still optimizable()
|
||||
} else if (AstSel* subselp = selp->lhsp()->castSel()) {
|
||||
V3Number sublsb = V3Number(nodep->fileline());
|
||||
handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb/*ref*/, depth+1);
|
||||
if (optimizable()) {
|
||||
if (varrefp) {
|
||||
AstNode* vscp = varOrScope(varrefp);
|
||||
V3Number outnum = V3Number(nodep->fileline());
|
||||
if (V3Number* vscpnump = fetchOutNumberNull(vscp)) {
|
||||
outnum = *vscpnump;
|
||||
} else if (V3Number* vscpnump = fetchNumberNull(vscp)) {
|
||||
outnum = *vscpnump;
|
||||
} else { // Assignment to unassigned variable, all bits are X or 0
|
||||
outnum = V3Number(nodep->fileline(), varrefp->varp()->widthMin());
|
||||
if (varrefp->varp()->basicp() && varrefp->varp()->basicp()->isZeroInit()) {
|
||||
outnum.setAllBits0();
|
||||
} else {
|
||||
outnum.setAllBitsX();
|
||||
}
|
||||
}
|
||||
if (depth == 0) {
|
||||
outnum.opSelInto(*fetchNumber(nodep->rhsp()),
|
||||
*fetchNumber(selp->lsbp()),
|
||||
selp->widthConst());
|
||||
assignOutNumber(nodep, vscp, &outnum);
|
||||
}
|
||||
}
|
||||
lsbRef = sublsb;
|
||||
lsbRef.opAdd(sublsb, *fetchNumber(selp->lsbp()));
|
||||
}
|
||||
} else {
|
||||
clearOptimizable(nodep, "Select LHS isn't simple variable");
|
||||
}
|
||||
if (outVarrefp) *outVarrefp = varrefp;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void visit(AstNodeAssign* nodep) {
|
||||
@@ -525,7 +606,7 @@ private:
|
||||
|
||||
if (AstSel* selp = nodep->lhsp()->castSel()) {
|
||||
if (!m_params) { clearOptimizable(nodep, "LHS has select"); return; }
|
||||
handleAssignSel(nodep, selp, NULL, 0);
|
||||
handleAssignSel(nodep, selp);
|
||||
}
|
||||
else if (!nodep->lhsp()->castVarRef()) {
|
||||
clearOptimizable(nodep, "LHS isn't simple variable");
|
||||
@@ -712,8 +793,11 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
SimulateStackNode stackNode(nodep, &tconnects);
|
||||
m_callStack.push_front(&stackNode);
|
||||
// Evaluate the function
|
||||
funcp->accept(*this);
|
||||
m_callStack.pop_front();
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
// Grab return value from output variable (if it's a function)
|
||||
if (!funcp->fvarp()) nodep->v3fatalSrc("Function reference points at non-function");
|
||||
@@ -726,6 +810,12 @@ private:
|
||||
if (!m_params) { badNodeType(nodep); return; }
|
||||
}
|
||||
|
||||
virtual void visit(AstScopeName *nodep) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
if (!m_params) { badNodeType(nodep); return; }
|
||||
// Ignore
|
||||
}
|
||||
|
||||
virtual void visit(AstSFormatF *nodep) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
if (!optimizable()) return; // Accelerate
|
||||
@@ -743,11 +833,11 @@ private:
|
||||
} else if (!inPct) { // Normal text
|
||||
result += *pos;
|
||||
} else { // Format character
|
||||
AstNode* argp = nextArgp;
|
||||
inPct = false;
|
||||
nextArgp = nextArgp->nextp();
|
||||
|
||||
if (V3Number::displayedFmtLegal(tolower(pos[0]))) {
|
||||
AstNode* argp = nextArgp;
|
||||
nextArgp = nextArgp->nextp();
|
||||
V3Number* nump = fetchNumberNull(argp);
|
||||
if (!nump) {
|
||||
clearOptimizable(nodep, "Argument for $display like statement is not constant");
|
||||
@@ -760,6 +850,10 @@ private:
|
||||
case '%':
|
||||
result += "%";
|
||||
break;
|
||||
case 'm':
|
||||
// This happens prior to AstScope so we don't know the scope name. Leave the %m in place.
|
||||
result += "%m";
|
||||
break;
|
||||
default:
|
||||
clearOptimizable(nodep, "Unknown $display-like format code.");
|
||||
break;
|
||||
@@ -767,7 +861,11 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
nodep->text(result);
|
||||
|
||||
V3Number* resultNump = new V3Number(V3Number::String(), nodep->fileline(), result);
|
||||
setNumber(nodep, resultNump);
|
||||
m_stringNumbersp.push_back(resultNump);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,19 +874,20 @@ private:
|
||||
if (!optimizable()) return; // Accelerate
|
||||
nodep->iterateChildren(*this);
|
||||
if (m_params) {
|
||||
V3Number* textp = fetchNumber(nodep->fmtp());
|
||||
switch (nodep->displayType()) {
|
||||
case AstDisplayType::DT_DISPLAY: // FALLTHRU
|
||||
case AstDisplayType::DT_INFO:
|
||||
v3warn(USERINFO, nodep->fmtp()->text());
|
||||
v3warn(USERINFO, textp->toString());
|
||||
break;
|
||||
case AstDisplayType::DT_ERROR:
|
||||
v3warn(USERERROR, nodep->fmtp()->text());
|
||||
v3warn(USERERROR, textp->toString());
|
||||
break;
|
||||
case AstDisplayType::DT_WARNING:
|
||||
v3warn(USERWARN, nodep->fmtp()->text());
|
||||
v3warn(USERWARN, textp->toString());
|
||||
break;
|
||||
case AstDisplayType::DT_FATAL:
|
||||
v3warn(USERFATAL, nodep->fmtp()->text());
|
||||
v3warn(USERFATAL, textp->toString());
|
||||
break;
|
||||
case AstDisplayType::DT_WRITE: // FALLTHRU
|
||||
default:
|
||||
@@ -863,6 +962,10 @@ public:
|
||||
for (deque<V3Number*>::iterator it = m_numAllps.begin(); it != m_numAllps.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
for (deque<V3Number*>::iterator it = m_stringNumbersp.begin(); it != m_stringNumbersp.end(); ++it) {
|
||||
delete (*it);
|
||||
}
|
||||
m_stringNumbersp.clear();
|
||||
m_numFreeps.clear();
|
||||
m_numAllps.clear();
|
||||
}
|
||||
|
||||
+4
-4
@@ -272,12 +272,12 @@ private:
|
||||
//UINFO(9," push "<<nodep<<endl);
|
||||
SplitLogicVertex* vertexp = new SplitLogicVertex(&m_graph, nodep);
|
||||
m_stmtStackps.push_back(vertexp);
|
||||
if (nodep->user3p()) nodep->v3fatalSrc("user3p should not be used; cleared in processBlock\n");
|
||||
if (nodep->user3p()) nodep->v3fatalSrc("user3p should not be used; cleared in processBlock");
|
||||
nodep->user3p(vertexp);
|
||||
}
|
||||
void scoreboardPopStmt() {
|
||||
//UINFO(9," pop"<<endl);
|
||||
if (m_stmtStackps.empty()) v3fatalSrc("Stack underflow\n");
|
||||
if (m_stmtStackps.empty()) v3fatalSrc("Stack underflow");
|
||||
m_stmtStackps.pop_back();
|
||||
}
|
||||
|
||||
@@ -346,8 +346,8 @@ private:
|
||||
SplitLogicVertex* vvertexp = (SplitLogicVertex*)nextp->user3p();
|
||||
vvertexp->splitColor(vvertexp->color());
|
||||
uint32_t color = vvertexp->splitColor();
|
||||
if (color >= numVertexes) nextp->v3fatalSrc("More colors than vertexes!\n");
|
||||
if (!color) nextp->v3fatalSrc("No node color assigned\n");
|
||||
if (color >= numVertexes) nextp->v3fatalSrc("More colors than vertexes");
|
||||
if (!color) nextp->v3fatalSrc("No node color assigned");
|
||||
if (lastOfColor[color]) {
|
||||
new SplitStrictEdge(&m_graph, lastOfColor[color], vvertexp);
|
||||
}
|
||||
|
||||
+8
-5
@@ -183,16 +183,19 @@ public:
|
||||
}
|
||||
return any;
|
||||
}
|
||||
void importFromIface(VSymGraph* graphp, const VSymEnt* srcp) {
|
||||
void importFromIface(VSymGraph* graphp, const VSymEnt* srcp, bool onlyUnmodportable = false) {
|
||||
// Import interface tokens from source symbol table into this symbol table, recursively
|
||||
UINFO(9, " importIf se"<<(void*)this<<" from se"<<(void*)srcp<<endl);
|
||||
for (IdNameMap::const_iterator it=srcp->m_idNameMap.begin(); it!=srcp->m_idNameMap.end(); ++it) {
|
||||
const string& name = it->first;
|
||||
VSymEnt* subSrcp = it->second;
|
||||
VSymEnt* subSymp = new VSymEnt(graphp, subSrcp);
|
||||
reinsert(name, subSymp);
|
||||
// And recurse to create children
|
||||
subSymp->importFromIface(graphp, subSrcp);
|
||||
AstVar* varp = subSrcp->nodep()->castVar();
|
||||
if (!onlyUnmodportable || (varp && varp->varType() == AstVarType::GPARAM)) {
|
||||
VSymEnt* subSymp = new VSymEnt(graphp, subSrcp);
|
||||
reinsert(name, subSymp);
|
||||
// And recurse to create children
|
||||
subSymp->importFromIface(graphp, subSrcp);
|
||||
}
|
||||
}
|
||||
}
|
||||
void cellErrorScopes(AstNode* lookp, string prettyName="") {
|
||||
|
||||
+2
-2
@@ -263,7 +263,7 @@ private:
|
||||
if (nodep->varp()->user2p()) { // It's being converted to a alias.
|
||||
UINFO(9, " relinkVar "<<(void*)nodep->varp()->user2p()<<" "<<nodep<<endl);
|
||||
AstVarScope* newvscp = nodep->varp()->user2p()->castVarScope();
|
||||
if (!newvscp) nodep->v3fatalSrc("Null?\n");
|
||||
if (!newvscp) nodep->v3fatalSrc("not linked");
|
||||
nodep->varScopep(newvscp);
|
||||
nodep->varp(nodep->varScopep()->varp());
|
||||
nodep->name(nodep->varp()->name());
|
||||
@@ -1147,7 +1147,7 @@ private:
|
||||
m_insStmtp = NULL; // Next thing should be new statement
|
||||
}
|
||||
virtual void visit(AstNodeFor* nodep) {
|
||||
nodep->v3fatalSrc("For statements should have been converted to while statements in V3Begin.cpp\n");
|
||||
nodep->v3fatalSrc("For statements should have been converted to while statements in V3Begin.cpp");
|
||||
}
|
||||
virtual void visit(AstNodeStmt* nodep) {
|
||||
m_insMode = IM_BEFORE;
|
||||
|
||||
+1
-1
@@ -387,7 +387,7 @@ private:
|
||||
} else if (basefromp->castConst()) {
|
||||
// If it's a PARAMETER[bit], then basefromp may be a constant instead of a varrefp
|
||||
} else {
|
||||
nodep->v3fatalSrc("No VarRef or Const under ArraySel\n");
|
||||
nodep->v3fatalSrc("No VarRef or Const under ArraySel");
|
||||
}
|
||||
// Find range of dtype we are selecting from
|
||||
int declElements = -1;
|
||||
|
||||
+51
-16
@@ -1184,7 +1184,14 @@ private:
|
||||
}
|
||||
virtual void visit(AstNodeVarRef* nodep) {
|
||||
if (nodep->didWidth()) return;
|
||||
if (!nodep->varp()) nodep->v3fatalSrc("Unlinked varref");
|
||||
if (!nodep->varp()) {
|
||||
if (m_paramsOnly && nodep->castVarXRef()) {
|
||||
checkConstantOrReplace(nodep, "Parameter-resolved constants must not use dotted references: "+nodep->prettyName()); VL_DANGLING(nodep);
|
||||
return;
|
||||
} else {
|
||||
nodep->v3fatalSrc("Unlinked varref");
|
||||
}
|
||||
}
|
||||
if (!nodep->varp()->didWidth()) {
|
||||
// Var hasn't been widthed, so make it so.
|
||||
userIterate(nodep->varp(), NULL);
|
||||
@@ -1283,7 +1290,7 @@ private:
|
||||
AstNodeDType* vdtypep = m_vup->dtypep();
|
||||
if (!vdtypep) nodep->v3fatalSrc("InitArray type not assigned by AstPattern/Var visitor");
|
||||
nodep->dtypep(vdtypep);
|
||||
if (AstNodeArrayDType* arrayp = vdtypep->castNodeArrayDType()) {
|
||||
if (AstNodeArrayDType* arrayp = vdtypep->skipRefp()->castNodeArrayDType()) {
|
||||
userIterateChildren(nodep, WidthVP(arrayp->subDTypep(),BOTH).p());
|
||||
} else {
|
||||
nodep->v3fatalSrc("InitArray on non-array");
|
||||
@@ -1613,7 +1620,10 @@ private:
|
||||
} else if (!memp && patp) { patp->v3error("Assignment pattern contains too many elements");
|
||||
memp=NULL; patp=NULL; break;
|
||||
} else {
|
||||
patmap.insert(make_pair(memp, patp));
|
||||
pair<PatMap::iterator, bool> ret = patmap.insert(make_pair(memp, patp));
|
||||
if (!ret.second) {
|
||||
patp->v3error("Assignment pattern contains duplicate entry: " << patp->keyp()->castText()->text());
|
||||
}
|
||||
}
|
||||
// Next
|
||||
if (memp) memp = memp->nextp()->castMemberDType();
|
||||
@@ -2084,8 +2094,9 @@ private:
|
||||
}
|
||||
virtual void visit(AstValuePlusArgs* nodep) {
|
||||
if (m_vup->prelim()) {
|
||||
userIterateAndNext(nodep->exprsp(), WidthVP(SELF,BOTH).p());
|
||||
nodep->dtypeSetSigned32(); // Spec says integer return
|
||||
userIterateAndNext(nodep->searchp(), WidthVP(SELF,BOTH).p());
|
||||
userIterateAndNext(nodep->outp(), WidthVP(SELF,BOTH).p());
|
||||
nodep->dtypeChgWidthSigned(32,1,AstNumeric::SIGNED); // Spec says integer return
|
||||
}
|
||||
}
|
||||
virtual void visit(AstUCStmt* nodep) {
|
||||
@@ -2126,7 +2137,8 @@ private:
|
||||
AstNodeDType* subDTypep = pinDTypep;
|
||||
int pinwidth = pinDTypep->width();
|
||||
int conwidth = conDTypep->width();
|
||||
if (conDTypep == pinDTypep) { // If match, we're golden
|
||||
if (conDTypep == pinDTypep // If match, we're golden
|
||||
|| similarDTypeRecurse(conDTypep, pinDTypep)) {
|
||||
userIterateAndNext(nodep->exprp(), WidthVP(subDTypep,FINAL).p());
|
||||
}
|
||||
else if (m_cellRangep) {
|
||||
@@ -2157,15 +2169,35 @@ private:
|
||||
// otherwise would need some mess to force both sides to proper size
|
||||
}
|
||||
}
|
||||
// TODO Simple dtype checking, should be a more general check
|
||||
bool hiArray = nodep->exprp()->dtypep()->skipRefp()->castUnpackArrayDType();
|
||||
bool loArray = nodep->modVarp()->dtypep()->skipRefp()->castUnpackArrayDType();
|
||||
if (loArray != hiArray && pinwidth != conwidth) {
|
||||
// Check if an interface is connected to a non-interface and vice versa
|
||||
AstNodeDType* modDTypep = nodep->modVarp()->dtypep();
|
||||
AstNodeDType* exprDTypep = nodep->exprp()->dtypep();
|
||||
if ((modDTypep->castIfaceRefDType() && !exprDTypep->castIfaceRefDType()) ||
|
||||
(exprDTypep->castIfaceRefDType() && !modDTypep->castIfaceRefDType())) {
|
||||
nodep->v3error("Illegal "<<nodep->prettyOperatorName()<<","
|
||||
<<" mismatch between port which is"<<(hiArray?"":" not")<<" an array,"
|
||||
<<" and expression which is"<<(loArray?"":" not")<<" an array.");
|
||||
UINFO(1," Related lo: "<<nodep->exprp()->dtypep()->skipRefp()<<endl);
|
||||
UINFO(1," Related hi: "<<nodep->modVarp()->dtypep()->skipRefp()<<endl);
|
||||
<<" mismatch between port which is"<<(modDTypep->castIfaceRefDType()?"":" not")<<" an interface,"
|
||||
<<" and expression which is"<<(exprDTypep->castIfaceRefDType()?"":" not")<<" an interface.");
|
||||
}
|
||||
|
||||
// TODO Simple dtype checking, should be a more general check
|
||||
AstNodeArrayDType* exprArrayp = exprDTypep->skipRefp()->castUnpackArrayDType();
|
||||
AstNodeArrayDType* modArrayp = modDTypep->skipRefp()->castUnpackArrayDType();
|
||||
if (exprArrayp && modArrayp && exprArrayp->subDTypep()->skipRefp()->castIfaceRefDType()
|
||||
&& exprArrayp->declRange().elements() != modArrayp->declRange().elements()) {
|
||||
int exprSize = exprArrayp->declRange().elements();
|
||||
int modSize = modArrayp->declRange().elements();
|
||||
nodep->v3error("Illegal "<<nodep->prettyOperatorName()<<","
|
||||
<<" mismatch between port which is an interface array of size "<<modSize<<","
|
||||
<<" and expression which is an interface array of size "<<exprSize<<".");
|
||||
UINFO(1," Related lo: "<<modDTypep->skipRefp()<<endl);
|
||||
UINFO(1," Related hi: "<<exprDTypep->skipRefp()<<endl);
|
||||
} else if ((exprArrayp && !modArrayp && pinwidth != conwidth)
|
||||
|| (!exprArrayp && modArrayp && pinwidth != conwidth)) {
|
||||
nodep->v3error("Illegal "<<nodep->prettyOperatorName()<<","
|
||||
<<" mismatch between port which is"<<(modArrayp?"":" not")<<" an array,"
|
||||
<<" and expression which is"<<(exprArrayp?"":" not")<<" an array.");
|
||||
UINFO(1," Related lo: "<<modDTypep->skipRefp()<<endl);
|
||||
UINFO(1," Related hi: "<<exprDTypep->skipRefp()<<endl);
|
||||
}
|
||||
iterateCheckAssign(nodep,"pin connection",nodep->exprp(),FINAL,subDTypep);
|
||||
}
|
||||
@@ -2786,11 +2818,11 @@ private:
|
||||
if (extendRule == EXTEND_OFF) return;
|
||||
AstConst* constp = nodep->castConst();
|
||||
int expWidth = expDTypep->width();
|
||||
if (constp && !nodep->isSigned()) {
|
||||
if (constp && !constp->num().isNegative()) {
|
||||
// Save later constant propagation work, just right-size it.
|
||||
V3Number num (nodep->fileline(), expWidth);
|
||||
num.opAssign(constp->num());
|
||||
num.isSigned(expDTypep->isSigned());
|
||||
num.isSigned(false);
|
||||
AstNode* newp = new AstConst(nodep->fileline(), num);
|
||||
constp->replaceWith(newp);
|
||||
pushDeletep(constp); VL_DANGLING(constp); VL_DANGLING(nodep);
|
||||
@@ -2879,6 +2911,9 @@ private:
|
||||
return false; // No change
|
||||
}
|
||||
|
||||
bool similarDTypeRecurse(AstNodeDType* node1p, AstNodeDType* node2p) {
|
||||
return node1p->skipRefp()->similarDType(node2p->skipRefp());
|
||||
}
|
||||
void iterateCheckFileDesc (AstNode* nodep, AstNode* underp, Stage stage) {
|
||||
if (stage != BOTH) nodep->v3fatalSrc("Bad call");
|
||||
// underp may change as a result of replacement
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ bool VlcOptions::onoff(const char* sw, const char* arg, bool& flag) {
|
||||
// if sw=="-no-arg", then return true (found it), and flag=false
|
||||
// if sw=="-noarg", then return true (found it), and flag=false
|
||||
// else return false
|
||||
if (arg[0]!='-') v3fatalSrc("OnOff switches must have leading dash.\n");
|
||||
if (arg[0]!='-') v3fatalSrc("OnOff switches must have leading dash.");
|
||||
if (0==strcmp(sw,arg)) { flag=true; return true; }
|
||||
else if (0==strncmp(sw,"-no",3) && (0==strcmp(sw+3,arg+1))) { flag=false; return true; }
|
||||
else if (0==strncmp(sw,"-no-",4) && (0==strcmp(sw+4,arg+1))) { flag=false; return true; }
|
||||
|
||||
+1
-1
@@ -873,7 +873,7 @@ vnum {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
|
||||
/* Attributes */
|
||||
/* Note simulators vary in support for "(* /_*something*_/ foo*)" where _ doesn't exist */
|
||||
<V95,V01,V05,VA5,S05,S09,S12,SAX>{
|
||||
"(*"({ws}|{crnl})*({id}|{escid}) { yymore(); yy_push_state(ATTRMODE); } // Doesn't match (*), but (* attr_spec
|
||||
"(*"({ws}|{crnl})*({id}|{escid}) { yymore(); yy_push_state(ATTRMODE); } /* Doesn't match (*), but (* attr_spec */
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
+16
-8
@@ -934,13 +934,13 @@ portDirNetE: // IEEE: part of port, optional net type and/or direction
|
||||
// // Per spec, if direction given default the nettype.
|
||||
// // The higher level rule may override this VARDTYPE with one later in the parse.
|
||||
| port_direction { VARDECL(PORT); VARDTYPE(NULL/*default_nettype*/); }
|
||||
| port_direction { VARDECL(PORT); } net_type { VARDTYPE(NULL/*default_nettype*/); } // net_type calls VARNET
|
||||
| net_type { } // net_type calls VARNET
|
||||
| port_direction { VARDECL(PORT); } net_type { VARDTYPE(NULL/*default_nettype*/); } // net_type calls VARDECL
|
||||
| net_type { } // net_type calls VARDECL
|
||||
;
|
||||
|
||||
port_declNetE: // IEEE: part of port_declaration, optional net type
|
||||
/* empty */ { }
|
||||
| net_type { } // net_type calls VARNET
|
||||
| net_type { } // net_type calls VARDECL
|
||||
;
|
||||
|
||||
portSig<nodep>:
|
||||
@@ -1155,10 +1155,14 @@ parameter_declarationFront: // IEEE: parameter_declaration w/o assignment
|
||||
|
||||
parameter_port_declarationFrontE: // IEEE: parameter_port_declaration w/o assignment
|
||||
// // IEEE: parameter_declaration (minus assignment)
|
||||
// // IEEE: local_parameter_declaration (minus assignment)
|
||||
// // Front must execute first so VARDTYPE is ready before list of vars
|
||||
varGParamReset implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset data_type { /*VARRESET-in-varGParam*/ VARDTYPE($2); }
|
||||
| varGParamReset yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| varLParamReset implicit_typeE { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset data_type { /*VARRESET-in-varLParam*/ VARDTYPE($2); }
|
||||
| varLParamReset yTYPE { /*VARRESET-in-varLParam*/ VARDTYPE(new AstParseTypeDType($2)); }
|
||||
| implicit_typeE { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
|
||||
| data_type { /*VARRESET-in-varGParam*/ VARDTYPE($1); }
|
||||
| yTYPE { /*VARRESET-in-varGParam*/ VARDTYPE(new AstParseTypeDType($1)); }
|
||||
@@ -1205,6 +1209,8 @@ net_type: // ==IEEE: net_type
|
||||
//UNSUP yWAND { VARDECL(WAND); }
|
||||
| yWIRE { VARDECL(WIRE); }
|
||||
//UNSUP yWOR { VARDECL(WOR); }
|
||||
// // VAMS - somewhat hackish
|
||||
| yWREAL { VARDECL(WREAL); }
|
||||
;
|
||||
|
||||
varGParamReset:
|
||||
@@ -1287,8 +1293,6 @@ non_integer_type<bdtypep>: // ==IEEE: non_integer_type
|
||||
yREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
|
||||
| yREALTIME { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); }
|
||||
//UNSUP ySHORTREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::FLOAT); }
|
||||
// // VAMS - somewhat hackish
|
||||
| yWREAL { $$ = new AstBasicDType($1,AstBasicDTypeKwd::DOUBLE); VARDECL(WIRE); }
|
||||
;
|
||||
|
||||
signingE<signstate>: // IEEE: signing - plus empty
|
||||
@@ -2070,7 +2074,7 @@ instnameParen<cellp>:
|
||||
|
||||
instRangeE<rangep>:
|
||||
/* empty */ { $$ = NULL; }
|
||||
| '[' constExpr ']' { $$ = new AstRange($1,new AstConst($1,0),$2); }
|
||||
| '[' constExpr ']' { $$ = new AstRange($1, new AstConst($1, 0), new AstSub($1, $2, new AstConst($1, 1))); }
|
||||
| '[' constExpr ':' constExpr ']' { $$ = new AstRange($1,$2,$4); }
|
||||
;
|
||||
|
||||
@@ -2706,12 +2710,12 @@ system_f_call<nodep>: // IEEE: system_tf_call (as func)
|
||||
| yD_SQRT '(' expr ')' { $$ = new AstSqrtD($1,$3); }
|
||||
| yD_SSCANF '(' expr ',' str commaVRDListE ')' { $$ = new AstSScanF($1,*$5,$3,$6); }
|
||||
| yD_STIME parenE { $$ = new AstSel($1,new AstTime($1),0,32); }
|
||||
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemF($1,$3); }
|
||||
| yD_SYSTEM '(' expr ')' { $$ = new AstSystemF($1,$3); }
|
||||
| yD_TESTPLUSARGS '(' str ')' { $$ = new AstTestPlusArgs($1,*$3); }
|
||||
| yD_TIME parenE { $$ = new AstTime($1); }
|
||||
| yD_UNPACKED_DIMENSIONS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::DIM_UNPK_DIMENSIONS,$3); }
|
||||
| yD_UNSIGNED '(' expr ')' { $$ = new AstUnsigned($1,$3); }
|
||||
| yD_VALUEPLUSARGS '(' str ',' expr ')' { $$ = new AstValuePlusArgs($1,*$3,$5); }
|
||||
| yD_VALUEPLUSARGS '(' expr ',' expr ')' { $$ = new AstValuePlusArgs($1,$3,$5); }
|
||||
;
|
||||
|
||||
exprOrDataType<nodep>: // expr | data_type: combined to prevent conflicts
|
||||
@@ -3799,6 +3803,10 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, string name, AstRange
|
||||
return NULL;
|
||||
}
|
||||
AstVarType type = GRAMMARP->m_varIO;
|
||||
if (GRAMMARP->m_varDecl == AstVarType::WREAL) {
|
||||
// dtypep might not be null, might be implicit LOGIC before we knew better
|
||||
dtypep = new AstBasicDType(fileline,AstBasicDTypeKwd::DOUBLE);
|
||||
}
|
||||
if (!dtypep) { // Created implicitly
|
||||
dtypep = new AstBasicDType(fileline, LOGIC_IMPLICIT);
|
||||
} else { // May make new variables with same type, so clone
|
||||
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
verilator_flags2 => ['--assert'],
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,33 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2016 by Wilson Snyder
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Outputs
|
||||
dout,
|
||||
// Inputs
|
||||
clk, sel, a, c
|
||||
);
|
||||
|
||||
input clk;
|
||||
input bit [3:0] sel;
|
||||
input bit [3:0] a;
|
||||
input bit c;
|
||||
output bit dout;
|
||||
|
||||
localparam logic DC = 1'b?;
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
unique casez(sel)
|
||||
4'b0000: dout <= a[0];
|
||||
4'b001?: dout <= a[1];
|
||||
{1'b0, 1'b1, 1'b?, 1'b?}: dout <= a[2];
|
||||
{1'b1, 1'b?, 1'b?, DC}: dout <= a[3];
|
||||
default: dout <= '0;
|
||||
endcase
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,97 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
module some_module (
|
||||
input wrclk
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
|
||||
always @(posedge wrclk) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (wrclk)
|
||||
some_other_state <= 0;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [3:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
`ifdef BROKEN
|
||||
.wrclk (i_clks[3])
|
||||
`else
|
||||
.wrclk (i_clk1)
|
||||
`endif
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [3:0] the_clks;
|
||||
logic data_q;
|
||||
|
||||
assign the_clks = {i_clk1, i_clk2, i_clk1, i_clk0};
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks (the_clks),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk1),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,106 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
module some_module (
|
||||
input wrclk
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
|
||||
always @(posedge wrclk) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (wrclk)
|
||||
some_other_state <= 0;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [3:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
`ifdef BROKEN
|
||||
.wrclk (i_clks[3])
|
||||
`else
|
||||
.wrclk (i_clk1)
|
||||
`endif
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [3:0] the_clks;
|
||||
logic data_q;
|
||||
|
||||
assign the_clks[3] = i_clk1;
|
||||
assign the_clks[2] = i_clk2;
|
||||
assign the_clks[1] = i_clk1;
|
||||
assign the_clks[0] = i_clk0;
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks (the_clks),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
/*AUTOARG*/
|
||||
// Inputs
|
||||
clk /*verilator clocker*/,
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
always @(posedge clk) begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,101 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
/* verilator lint_off LITENDIAN */
|
||||
module some_module (
|
||||
input wrclk
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
|
||||
always @(posedge wrclk) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (wrclk)
|
||||
some_other_state <= 0;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [-12:-9] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
`ifdef BROKEN
|
||||
.wrclk (i_clks[-12])
|
||||
`else
|
||||
.wrclk (i_clk1)
|
||||
`endif
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [-12:-9] the_clks;
|
||||
logic data_q;
|
||||
|
||||
assign the_clks[-12] = i_clk1;
|
||||
assign the_clks[-11] = i_clk2;
|
||||
assign the_clks[-10] = i_clk1;
|
||||
assign the_clks[-9] = i_clk0;
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks (the_clks),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk1),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,105 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
module some_module (
|
||||
input wrclk
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
|
||||
always @(posedge wrclk) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (wrclk)
|
||||
some_other_state <= 0;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [3:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
generate
|
||||
genvar i;
|
||||
for (i = 0; i < 2; i = i + 1) begin: a_generate_block
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
`ifdef BROKEN
|
||||
.wrclk (i_clks[3])
|
||||
`else
|
||||
.wrclk (i_clk1)
|
||||
`endif
|
||||
);
|
||||
end
|
||||
endgenerate
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [3:0] the_clks;
|
||||
logic data_q;
|
||||
|
||||
assign the_clks[3] = i_clk1;
|
||||
assign the_clks[2] = i_clk2;
|
||||
assign the_clks[1] = i_clk1;
|
||||
assign the_clks[0] = i_clk0;
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks (the_clks),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk1),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,104 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
module some_module (
|
||||
input [3:0] i_clks
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
|
||||
always @(posedge i_clks[3]) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (i_clks[3])
|
||||
some_other_state <= 0;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [3:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
.i_clks (i_clks)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [3:0] the_clks;
|
||||
logic data_q;
|
||||
|
||||
assign the_clks[3] = i_clk1;
|
||||
assign the_clks[2] = i_clk2;
|
||||
assign the_clks[1] = i_clk1;
|
||||
assign the_clks[0] = i_clk0;
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks (the_clks),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
/*AUTOARG*/
|
||||
// Inputs
|
||||
clk /*verilator clocker*/,
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
// initial begin
|
||||
// $write("*-* All Finished *-*\n");
|
||||
// $finish;
|
||||
// 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-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.
|
||||
|
||||
compile (
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,113 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty.
|
||||
//
|
||||
|
||||
module some_module (
|
||||
input [3:0] i_clks
|
||||
);
|
||||
|
||||
logic [ 1 : 0 ] some_state;
|
||||
logic [1:0] some_other_state;
|
||||
logic the_clk;
|
||||
|
||||
assign the_clk = i_clks[3];
|
||||
|
||||
always @(posedge the_clk) begin
|
||||
case (some_state)
|
||||
2'b11:
|
||||
if (some_other_state == 0)
|
||||
some_state <= 2'b00;
|
||||
default:
|
||||
$display ("This is a display statement");
|
||||
endcase
|
||||
|
||||
if (the_clk)
|
||||
some_other_state <= 0;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
`define BROKEN
|
||||
|
||||
module t1(
|
||||
input [3:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1
|
||||
);
|
||||
|
||||
some_module
|
||||
some_module
|
||||
(
|
||||
.i_clks (i_clks)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module ident(
|
||||
input i_ident,
|
||||
output o_ident
|
||||
);
|
||||
assign o_ident = i_ident;
|
||||
endmodule
|
||||
|
||||
module t2(
|
||||
input [2:0] i_clks,
|
||||
input i_clk0,
|
||||
input i_clk1,
|
||||
input i_clk2,
|
||||
input i_data
|
||||
);
|
||||
logic [3:0] the_clks;
|
||||
logic data_q;
|
||||
logic ident_clk1;
|
||||
|
||||
always @(posedge i_clk0) begin
|
||||
data_q <= i_data;
|
||||
end
|
||||
|
||||
ident
|
||||
ident
|
||||
(
|
||||
.i_ident (i_clk1),
|
||||
.o_ident (ident_clk1)
|
||||
);
|
||||
|
||||
t1 t1
|
||||
(
|
||||
.i_clks ({ident_clk1, i_clk2, ident_clk1, i_clk0}),
|
||||
.i_clk0 (i_clk0),
|
||||
.i_clk1 (i_clk1)
|
||||
);
|
||||
endmodule
|
||||
|
||||
module t(
|
||||
/*AUTOARG*/
|
||||
// Inputs
|
||||
clk /*verilator clocker*/ /*verilator public_flat*/,
|
||||
input clk0 /*verilator clocker*/,
|
||||
input clk1 /*verilator clocker*/,
|
||||
input clk2 /*verilator clocker*/,
|
||||
input data_in
|
||||
);
|
||||
|
||||
input clk;
|
||||
|
||||
logic [2:0] clks;
|
||||
|
||||
assign clks = {1'b0, clk1, clk0};
|
||||
|
||||
t2
|
||||
t2
|
||||
(
|
||||
.i_clks (clks),
|
||||
.i_clk0 (clk0),
|
||||
.i_clk1 (clk),
|
||||
.i_clk2 (clk2),
|
||||
.i_data (data_in)
|
||||
);
|
||||
|
||||
endmodule
|
||||
@@ -0,0 +1,39 @@
|
||||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
//
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
|
||||
#include <verilated.h>
|
||||
#include "Vt_flag_fi.h"
|
||||
|
||||
//======================================================================
|
||||
|
||||
unsigned int main_time = 0;
|
||||
|
||||
double sc_time_stamp () {
|
||||
return main_time;
|
||||
}
|
||||
|
||||
VM_PREFIX* topp = NULL;
|
||||
bool gotit = false;
|
||||
|
||||
void myfunction() {
|
||||
gotit = true;
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
topp = new VM_PREFIX;
|
||||
|
||||
Verilated::debug(0);
|
||||
|
||||
topp->eval();
|
||||
if (!gotit) {
|
||||
vl_fatal (__FILE__, __LINE__, "dut", "Never got call to myfunction");
|
||||
}
|
||||
|
||||
topp->final();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/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.
|
||||
|
||||
$Self->{vlt} or $Self->skip("Verilator only test");
|
||||
|
||||
compile (
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
v_flags2 => ["-FI $Self->{t_dir}/t_flag_fi_h.h",
|
||||
"--exe $Self->{t_dir}/$Self->{name}.cpp"],
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,14 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// Copyright 2017 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.
|
||||
|
||||
module t ();
|
||||
initial begin
|
||||
$c("myfunction();");
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
@@ -0,0 +1,16 @@
|
||||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
//*************************************************************************
|
||||
//
|
||||
// Copyright 2010-2017 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.
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
extern void myfunction();
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/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.
|
||||
|
||||
$Self->{vlt} or $Self->skip("Verilator only test");
|
||||
|
||||
compile (
|
||||
v_flags2 => ["--relative-includes",
|
||||
"--lint-only $Self->{t_dir}/t_flag_relinc_dir/chip/t_flag_relinc_sub.v"],
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
verilator_make_gcc => 0,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,10 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// Copyright 2017 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.
|
||||
|
||||
module t;
|
||||
t_flag_relinc_sub sub ();
|
||||
endmodule
|
||||
@@ -0,0 +1,15 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// Copyright 2017 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.
|
||||
|
||||
`include "../include/t_flag_relinc.vh"
|
||||
|
||||
module t_flag_relinc_sub ();
|
||||
initial begin
|
||||
`all_finished;
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
@@ -0,0 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// Copyright 2017 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.
|
||||
|
||||
`define all_finished $write("*-* All Finished *-*\n")
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2017 by Todd Strader. 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{%Warning-USERFATAL: f_add = 15
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const2_bad.v:10: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_add2'
|
||||
%Error: t/t_func_const2_bad.v:21: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const2_bad.v:26: f_add() with parameters:
|
||||
a = 32'h7
|
||||
b = 32'h8
|
||||
Called from:
|
||||
t/t_func_const2_bad.v:10: f_add2() with parameters:
|
||||
a = ?32?sh7
|
||||
b = ?32?sh8
|
||||
c = ?32?sh9
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,28 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Todd Strader.
|
||||
|
||||
module t;
|
||||
|
||||
localparam P6 = f_add(5, 1);
|
||||
localparam P14 = f_add2(2, 3, f_add(4, 5));
|
||||
localparam P24 = f_add2(7, 8, 9);
|
||||
|
||||
initial begin
|
||||
// Should never get here
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_add(input [31:0] a, input [31:0] b);
|
||||
f_add = a+b;
|
||||
if (f_add == 15)
|
||||
$fatal(2, "f_add = 15");
|
||||
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
|
||||
endmodule
|
||||
@@ -11,17 +11,39 @@ 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.*},
|
||||
q{%Error: t/t_func_const_bad.v:11: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_output'
|
||||
%Error: t/t_func_const_bad.v:12: ... Location of non-constant VAR 'o': Language violation: Outputs not allowed in constant functions
|
||||
%Error: t/t_func_const_bad.v:20: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_dotted'
|
||||
%Error: t/t_func_const_bad.v:22: ... Location of non-constant VARXREF 'EIGHT': Language violation: Dotted hierarchical references not allowed in constant functions
|
||||
Called from:
|
||||
t/t_func_const_bad.v:20: f_bad_dotted() with parameters:
|
||||
a = ?32?sh2
|
||||
%Error: t/t_func_const_bad.v:27: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_nonparam'
|
||||
%Error: t/t_func_const_bad.v:29: ... Location of non-constant VARREF 'modvar': Language violation: reference to non-function-local variable
|
||||
Called from:
|
||||
t/t_func_const_bad.v:27: f_bad_nonparam() with parameters:
|
||||
a = ?32?sh3
|
||||
%Error: t/t_func_const_bad.v:35: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_infinite'
|
||||
%Error: t/t_func_const_bad.v:37: ... Location of non-constant WHILE: Loop unrolling took too long; probably this is an infinite loop, or set --unroll-count above 1024
|
||||
Called from:
|
||||
t/t_func_const_bad.v:35: f_bad_infinite() with parameters:
|
||||
a = ?32?sh3
|
||||
%Error: t/t_func_const_bad.v:43: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_stop'
|
||||
%Error: t/t_func_const_bad.v:45: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_bad.v:43: f_bad_stop() with parameters:
|
||||
a = ?32?sh3
|
||||
-Info: Printing in loop: 0
|
||||
-Info: Printing in loop: 1
|
||||
-Info: Printing in loop: 2
|
||||
%Warning-USERFATAL: Fatal Error
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const_bad.v:49: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_bad_fatal'
|
||||
%Error: t/t_func_const_bad.v:54: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_bad.v:49: f_bad_fatal() with parameters:
|
||||
a = ?32?sh3
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
|
||||
@@ -45,4 +45,12 @@ module t;
|
||||
$stop;
|
||||
endfunction
|
||||
|
||||
// Verify $fatal works with sformatf as argument
|
||||
localparam BFATAL = f_bad_fatal(3);
|
||||
function integer f_bad_fatal(input [31:0] a);
|
||||
for (integer i=0;i<3;i++) begin
|
||||
$display("Printing in loop: %s", $sformatf("%d", i));
|
||||
end
|
||||
$fatal(2, "%s", $sformatf("Fatal Error"));
|
||||
endfunction
|
||||
endmodule
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2017 by Todd Strader. 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{%Warning-USERFATAL: f_add = 15
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const_packed_array_bad.v:11: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_add2'
|
||||
%Error: t/t_func_const_packed_array_bad.v:22: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_packed_array_bad.v:30: f_add() with parameters:
|
||||
params = [0 = 32'h7, 1 = 32'h8]
|
||||
Called from:
|
||||
t/t_func_const_packed_array_bad.v:11: f_add2() with parameters:
|
||||
a = ?32?sh7
|
||||
b = ?32?sh8
|
||||
c = ?32?sh9
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,32 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Todd Strader.
|
||||
|
||||
module t;
|
||||
|
||||
localparam [ 1 : 0 ] [ 31 : 0 ] P = {32'd5, 32'd1};
|
||||
localparam P6 = f_add(P);
|
||||
localparam P14 = f_add2(2, 3, f_add(P));
|
||||
localparam P24 = f_add2(7, 8, 9);
|
||||
|
||||
initial begin
|
||||
// Should never get here
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_add(input [ 1 : 0 ] [ 31 : 0 ] params);
|
||||
f_add = params[0]+params[1];
|
||||
if (f_add == 15)
|
||||
$fatal(2, "f_add = 15");
|
||||
endfunction
|
||||
|
||||
// Speced ok: function called from function
|
||||
function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c);
|
||||
logic [ 1 : 0 ] [ 31 : 0 ] params;
|
||||
params[0] = a;
|
||||
params[1] = b;
|
||||
f_add2 = f_add(params)+c;
|
||||
endfunction
|
||||
endmodule
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2017 by Todd Strader. 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{%Warning-USERFATAL: f_add = 15
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const_packed_struct_bad.v:13: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_add2'
|
||||
%Error: t/t_func_const_packed_struct_bad.v:24: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_packed_struct_bad.v:32: f_add() with parameters:
|
||||
params = [0 = '{a: 32'h7, b: 32'h22b}, 1 = '{a: 32'h3039, b: 32'h8}]
|
||||
Called from:
|
||||
t/t_func_const_packed_struct_bad.v:13: f_add2() with parameters:
|
||||
a = ?32?sh7
|
||||
b = ?32?sh8
|
||||
c = ?32?sh9
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,34 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Todd Strader.
|
||||
|
||||
module t;
|
||||
|
||||
typedef struct packed {
|
||||
logic [ 31 : 0 ] a;
|
||||
logic [ 31 : 0 ] b;
|
||||
} params_t;
|
||||
|
||||
localparam P24 = f_add2(7, 8, 9);
|
||||
|
||||
initial begin
|
||||
// Should never get here
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_add(input params_t [ 1 : 0 ] params);
|
||||
f_add = params[0].a+params[1].b;
|
||||
if (f_add == 15)
|
||||
$fatal(2, "f_add = 15");
|
||||
endfunction
|
||||
|
||||
// Speced ok: function called from function
|
||||
function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c);
|
||||
params_t [ 1 : 0 ] params;
|
||||
params[0] = '{a:a, b:555};
|
||||
params[1] = '{a:12345, b:b};
|
||||
f_add2 = f_add(params)+c;
|
||||
endfunction
|
||||
endmodule
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2017 by Todd Strader. 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{%Warning-USERFATAL: f_add = 15
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const_packed_struct_bad2.v:19: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_add2'
|
||||
%Error: t/t_func_const_packed_struct_bad2.v:30: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_packed_struct_bad2.v:42: f_add() with parameters:
|
||||
params = [0 = '{a: 32'h7, foo: 6'hb, sub_params: '{b: 32'h37, bar: 8'h6f}}, 1 = '{a: 32'h3039, foo: 6'hc, sub_params: '{b: 32'h8, bar: 8'h70}}]
|
||||
Called from:
|
||||
t/t_func_const_packed_struct_bad2.v:19: f_add2() with parameters:
|
||||
a = ?32?sh7
|
||||
b = ?32?sh8
|
||||
c = ?32?sh9
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,44 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Todd Strader.
|
||||
|
||||
module t;
|
||||
|
||||
typedef struct packed {
|
||||
logic [ 31 : 0 ] b;
|
||||
logic [ 7 : 0 ] bar;
|
||||
} sub_params_t;
|
||||
|
||||
typedef struct packed {
|
||||
logic [ 31 : 0 ] a;
|
||||
logic [ 5 : 0 ] foo;
|
||||
sub_params_t sub_params;
|
||||
} params_t;
|
||||
|
||||
localparam P24 = f_add2(7, 8, 9);
|
||||
|
||||
initial begin
|
||||
// Should never get here
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_add(input params_t [ 1 : 0 ] params);
|
||||
f_add = params[0].a+params[1].sub_params.b;
|
||||
if (f_add == 15)
|
||||
$fatal(2, "f_add = 15");
|
||||
endfunction
|
||||
|
||||
// Speced ok: function called from function
|
||||
function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c);
|
||||
params_t [ 1 : 0 ] params;
|
||||
sub_params_t sp0;
|
||||
sub_params_t sp1;
|
||||
sp0 = '{b:55, bar:111};
|
||||
params[0] = '{a:a, foo:11, sub_params:sp0};
|
||||
sp1 = '{b:b, bar:112};
|
||||
params[1] = '{a:12345, foo:12, sub_params:sp1};
|
||||
f_add2 = f_add(params)+c;
|
||||
endfunction
|
||||
endmodule
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2017 by Todd Strader. 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{%Warning-USERFATAL: f_add = 15
|
||||
%Warning-USERFATAL: Use "/* verilator lint_off USERFATAL */" and lint_on around source to disable this message.
|
||||
%Error: t/t_func_const_struct_bad.v:16: Expecting expression to be constant, but can't determine constant for FUNCREF 'f_add2'
|
||||
%Error: t/t_func_const_struct_bad.v:27: ... Location of non-constant STOP: $stop executed during function constification; maybe indicates assertion firing
|
||||
Called from:
|
||||
t/t_func_const_struct_bad.v:37: f_add() with parameters:
|
||||
params = '{a: 32'h7, b: 32'h8}
|
||||
Called from:
|
||||
t/t_func_const_struct_bad.v:16: f_add2() with parameters:
|
||||
a = ?32?sh7
|
||||
b = ?32?sh8
|
||||
c = ?32?sh9
|
||||
},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,39 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Todd Strader.
|
||||
|
||||
module t;
|
||||
|
||||
typedef struct packed {
|
||||
logic [ 31 : 0 ] a;
|
||||
logic [ 31 : 0 ] b;
|
||||
} params_t;
|
||||
|
||||
localparam params_t P = '{a:5, b:1};
|
||||
localparam P6 = f_add(P);
|
||||
localparam P14 = f_add2(2, 3, f_add(P));
|
||||
localparam P24 = f_add2(7, 8, 9);
|
||||
|
||||
initial begin
|
||||
// Should never get here
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
function integer f_add(input params_t params);
|
||||
f_add = params.a+params.b;
|
||||
if (f_add == 15)
|
||||
$fatal(2, "f_add = 15");
|
||||
endfunction
|
||||
|
||||
// Speced ok: function called from function
|
||||
function integer f_add2(input [31:0] a, input [31:0] b, input [31:0] c);
|
||||
params_t params;
|
||||
params = '{
|
||||
a: a,
|
||||
b: b
|
||||
};
|
||||
f_add2 = f_add(params)+c;
|
||||
endfunction
|
||||
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 (
|
||||
verilator_flags2 => ["-Wno-WIDTH"],
|
||||
);
|
||||
|
||||
execute (
|
||||
check_finished=>1,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,28 @@
|
||||
// DESCRIPTION: Verilator: Test for warning (not error) on improperly width'ed
|
||||
// default function argument
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2015 by Todd Strader.
|
||||
|
||||
function logic foo
|
||||
(
|
||||
// Intentionally provide a non-width'ed default value
|
||||
// This should warn, not error out
|
||||
input logic x = 0
|
||||
);
|
||||
return x;
|
||||
endfunction
|
||||
|
||||
module t (/*AUTOARG*/);
|
||||
logic foo_val;
|
||||
|
||||
initial begin
|
||||
foo_val = foo();
|
||||
if (foo_val != 1'b0) $stop;
|
||||
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/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 (
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,26 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// The code here is used to trigger Verilator internal error
|
||||
// "InitArray on non-array"
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Jie Xu.
|
||||
|
||||
typedef logic [7:0] mask_t [7:0];
|
||||
|
||||
// parameter logic [7:0] IMP_MASK[7:0] = '{8'hE1, 8'h03, 8'h07, 8'h3F, 8'h33, 8'hC3, 8'hC3, 8'h37};
|
||||
|
||||
parameter mask_t IMP_MASK = '{8'hE1, 8'h03, 8'h07, 8'h3F, 8'h33, 8'hC3, 8'hC3, 8'h37};
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
input clk;
|
||||
|
||||
mask_t a;
|
||||
//logic [7:0] a[7:0];
|
||||
|
||||
assign a = IMP_MASK;
|
||||
|
||||
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,85 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by John Stevenson.
|
||||
|
||||
typedef logic [63:0] uid_t;
|
||||
typedef logic [31:0] value_t;
|
||||
|
||||
interface the_intf #(parameter M = 5);
|
||||
logic valid;
|
||||
uid_t uid;
|
||||
value_t [M-1:0] values;
|
||||
|
||||
modport i(
|
||||
output valid,
|
||||
output uid,
|
||||
output values
|
||||
);
|
||||
modport t(
|
||||
input valid,
|
||||
input uid,
|
||||
input values
|
||||
);
|
||||
endinterface
|
||||
|
||||
module Contemplator #(
|
||||
parameter IMPL = 0,
|
||||
parameter M = 5,
|
||||
parameter N = 1 )
|
||||
(
|
||||
input logic clk,
|
||||
the_intf.i out [N-1:0]
|
||||
);
|
||||
|
||||
the_intf #(.M(M)) inp[N-1:0] ();
|
||||
|
||||
DeepThought #(
|
||||
.N ( N ))
|
||||
ultimateAnswerer(
|
||||
.src ( inp ),
|
||||
.dst ( out ));
|
||||
endmodule
|
||||
|
||||
module DeepThought #(
|
||||
parameter N = 1 )
|
||||
(
|
||||
the_intf.t src[N-1:0],
|
||||
the_intf.i dst[N-1:0]
|
||||
);
|
||||
endmodule
|
||||
|
||||
|
||||
module t (/*AUTOARG*/
|
||||
// Inputs
|
||||
clk
|
||||
);
|
||||
input clk;
|
||||
|
||||
localparam M = 5;
|
||||
localparam N = 1;
|
||||
|
||||
the_intf #(.M(M)) out0 [N-1:0] ();
|
||||
the_intf #(.M(M)) out1 [N-1:0] ();
|
||||
|
||||
Contemplator #(
|
||||
.IMPL ( 0 ),
|
||||
.M ( M ),
|
||||
.N ( N ))
|
||||
contemplatorOfTheZerothKind(
|
||||
.clk ( clk ),
|
||||
.out ( out0 ));
|
||||
|
||||
Contemplator #(
|
||||
.IMPL ( 1 ),
|
||||
.M ( M ),
|
||||
.N ( N ))
|
||||
contemplatorOfTheFirstKind(
|
||||
.clk ( clk ),
|
||||
.out ( out1 ));
|
||||
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 (
|
||||
verilator_flags2 => ["--lint-only"],
|
||||
fails=>0,
|
||||
verilator_make_gcc => 0,
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
@@ -0,0 +1,120 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by John Stevenson.
|
||||
|
||||
package pkg;
|
||||
typedef logic [31:0] unique_id_t;
|
||||
typedef struct packed {
|
||||
unique_id_t foo;
|
||||
} inner_thing_t;
|
||||
typedef struct packed {
|
||||
inner_thing_t bar;
|
||||
inner_thing_t baz;
|
||||
} outer_thing_t;
|
||||
|
||||
endpackage
|
||||
|
||||
import pkg::*;
|
||||
|
||||
interface the_intf
|
||||
#(parameter M=5);
|
||||
outer_thing_t [M-1:0] things;
|
||||
logic valid;
|
||||
modport i (
|
||||
output things,
|
||||
output valid);
|
||||
modport t (
|
||||
input things,
|
||||
input valid);
|
||||
endinterface
|
||||
|
||||
module ThingMuxOH
|
||||
#(
|
||||
parameter NTHINGS = 1,
|
||||
parameter M = 5 )
|
||||
(
|
||||
input logic [NTHINGS-1:0] select_oh,
|
||||
the_intf.t things_in [NTHINGS-1:0],
|
||||
the_intf.i thing_out
|
||||
);
|
||||
endmodule
|
||||
|
||||
module Thinker
|
||||
#(
|
||||
parameter M = 5,
|
||||
parameter N = 2)
|
||||
(
|
||||
input logic clk,
|
||||
input logic reset,
|
||||
input unique_id_t uids[0:N-1],
|
||||
the_intf.t thing_inp,
|
||||
the_intf.i thing_out
|
||||
);
|
||||
|
||||
the_intf #(.M(M)) curr_things [N-1:0] ();
|
||||
the_intf #(.M(M)) prev_things [N-1:0] ();
|
||||
the_intf #(.M(M)) curr_thing ();
|
||||
the_intf #(.M(M)) prev_thing ();
|
||||
|
||||
logic [N-1:0] select_oh;
|
||||
|
||||
// 1st mux:
|
||||
ThingMuxOH #(
|
||||
.NTHINGS ( N ),
|
||||
.M ( M ))
|
||||
curr_thing_mux(
|
||||
.select_oh( select_oh ),
|
||||
.things_in( curr_things ),
|
||||
.thing_out( curr_thing ));
|
||||
|
||||
// 2nd mux, comment this out and no problem:
|
||||
ThingMuxOH #(
|
||||
.NTHINGS ( N ),
|
||||
.M ( M ))
|
||||
prev_thing_mux(
|
||||
.select_oh( select_oh ),
|
||||
.things_in( prev_things ),
|
||||
.thing_out( prev_thing ));
|
||||
|
||||
endmodule
|
||||
|
||||
module t
|
||||
(
|
||||
input logic clk,
|
||||
input logic reset
|
||||
);
|
||||
|
||||
localparam M = 5;
|
||||
localparam N = 2;
|
||||
|
||||
unique_id_t uids[0:N-1];
|
||||
|
||||
the_intf #(.M(M)) thing_inp();
|
||||
the_intf #(.M(M)) thing_out();
|
||||
|
||||
Thinker #(
|
||||
.M ( M ),
|
||||
.N ( N ))
|
||||
thinker(
|
||||
.clk ( clk ),
|
||||
.reset ( reset ),
|
||||
.uids ( uids ),
|
||||
.thing_inp( thing_inp ),
|
||||
.thing_out( thing_out ));
|
||||
|
||||
// Previously there was a problem in V3Inst if non-default parameters was used
|
||||
localparam K = 2;
|
||||
the_intf #(.M(K)) thing_inp2();
|
||||
the_intf #(.M(K)) thing_out2();
|
||||
|
||||
Thinker #(
|
||||
.M ( K ),
|
||||
.N ( N ))
|
||||
thinker2(
|
||||
.clk ( clk ),
|
||||
.reset ( reset ),
|
||||
.uids ( uids ),
|
||||
.thing_inp( thing_inp2 ),
|
||||
.thing_out( thing_out2 ));
|
||||
endmodule
|
||||
+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 (
|
||||
fails=>1,
|
||||
expect=>
|
||||
q{%Error: t/t_interface_param_another_bad.v:\d+: Parameter-resolved constants must not use dotted references: dummy
|
||||
%Error: Exiting due to.*},
|
||||
);
|
||||
|
||||
ok(1);
|
||||
1;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user