mirror of
https://github.com/verilator/verilator.git
synced 2026-10-05 17:43:31 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa9dac29e8 | ||
|
|
afc432042f | ||
|
|
21cb29baf0 | ||
|
|
e8b5001cfe | ||
|
|
849c1e46a2 | ||
|
|
ebad6cde36 | ||
|
|
f920b3945e | ||
|
|
178028a70a | ||
|
|
5e54d3e41a | ||
|
|
f0af8726e3 | ||
|
|
57f2fe77ea | ||
|
|
d56ca25089 | ||
|
|
d39ce17dea | ||
|
|
373a68ec8b | ||
|
|
5613758ee3 | ||
|
|
2102f86909 | ||
|
|
d5ea785de7 | ||
|
|
9edd28d2ed | ||
|
|
7698af5178 | ||
|
|
52ae451f5c | ||
|
|
9254443cd4 | ||
|
|
4e4bc7b90f | ||
|
|
c7e0f2e196 | ||
|
|
acabaab6ac | ||
|
|
b0a249f338 | ||
|
|
0cb5d5cc5a | ||
|
|
9208c87f91 | ||
|
|
0081ce4a75 | ||
|
|
7850f49963 | ||
|
|
c72ee41142 | ||
|
|
bf5dee955d | ||
|
|
3df23a148a | ||
|
|
0a1b55c296 | ||
|
|
14b8efe4bb | ||
|
|
64162efebd | ||
|
|
faf5e1de51 | ||
|
|
0d7b1a7dc7 | ||
|
|
fa63bc6b78 | ||
|
|
379bfd062f | ||
|
|
49108c23f0 | ||
|
|
4475060268 | ||
|
|
4f269e336d | ||
|
|
4464b13163 | ||
|
|
215d5f68b0 | ||
|
|
281f4e04ee | ||
|
|
17a3f9691d | ||
|
|
4fde6ee7af | ||
|
|
040b1b06d5 | ||
|
|
b16ea8b719 | ||
|
|
cc22847bc3 | ||
|
|
3702e17b2e | ||
|
|
7abc220fb3 | ||
|
|
4fc9a906f6 | ||
|
|
5de83c9805 | ||
|
|
f71d904a9b | ||
|
|
318ded4198 | ||
|
|
f1874b211f | ||
|
|
c60ffd7fd9 | ||
|
|
dc57282168 | ||
|
|
3c336e179f | ||
|
|
6bda57da5d | ||
|
|
9a16001e51 | ||
|
|
34870e899f | ||
|
|
d0653f72e2 | ||
|
|
64748b7b1d | ||
|
|
7163c8d048 | ||
|
|
d0ec991bb2 | ||
|
|
d458af4454 | ||
|
|
9e9e7c33ae | ||
|
|
ce7de5ed30 | ||
|
|
776d8edf52 |
@@ -3,6 +3,84 @@ Revision history for Verilator
|
||||
The contributors that suggested a given feature are shown in []. [by ...]
|
||||
indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
* Verilator 3.880 2015-12-19
|
||||
|
||||
*** Support display %u, %v, %p, %z, bug989. [Johan Bjork]
|
||||
|
||||
**** Fix real parameters causing bad module names, bug992. [Johan Bjork]
|
||||
|
||||
**** Fix size-changing cast on packed struct, bug993. [Johan Bjork]
|
||||
|
||||
**** Fix function calls on arrayed interface, bug994. [Johan Bjork]
|
||||
|
||||
**** Fix arrayed interfaces, bug879, bug1001. [Todd Strader]
|
||||
|
||||
**** Fix constant function assigned to packed structs, bug997. [Johan Bjork]
|
||||
|
||||
**** Fix interface inside generate, bug998. [Johan Bjork]
|
||||
|
||||
**** Fix $signed casts under generates, bug999. [Clifford Wolf]
|
||||
|
||||
**** Fix genvar constant propagation, bug1003. [Johan Bjork]
|
||||
|
||||
**** Fix parameter constant propagation from package, bug1004. [Johan Bjork]
|
||||
|
||||
**** Fix array slicing of non-const indexes, bug1006. [Johan Bjork]
|
||||
|
||||
**** Fix dotted generated array error, bug1005. [Jeff Bush, Johan Bjork]
|
||||
|
||||
**** Fix error instead of warning on large concat, msg1768. [Paul Rolfe]
|
||||
|
||||
**** Fix $bitstoreal constant propagation, bug1012. [Jonathan Kimmitt]
|
||||
|
||||
**** Fix model restore crash, bug1013. [Jason McMullan]
|
||||
|
||||
**** Fix arrayed instances to unpacked of same size, bug1015. [Varun Koyyalagunta]
|
||||
|
||||
**** Fix slices of unpacked arrays with non-zero LSBs.
|
||||
|
||||
**** Fix ternary operation with unpacked array, bug1017. [Varun Koyyalagunta].
|
||||
|
||||
|
||||
* Verilator 3.878 2015-11-01
|
||||
|
||||
** Add --vpi flag, and fix VPI linkage, bug969. [Arthur Kahlich]
|
||||
|
||||
** Support genvar indexes into arrayed cells, bug517. [Todd Strader]
|
||||
|
||||
** Support $sformatf, bug977. [Johan Bjork]
|
||||
|
||||
*** Support elaboration assertions, bug973. [Johan Bjork]
|
||||
|
||||
*** Support $display with non-format arguments, bug467. [Jamey Hicks]
|
||||
|
||||
**** Add VerilatedScopeNameMap for introspection, bug966. [Todd Strader]
|
||||
|
||||
**** Ignore %l in $display, bug983. [Todd Strader]
|
||||
|
||||
**** Fix very long module names, bug937. [Todd Strader]
|
||||
|
||||
**** Fix internal error on dotted refs into generates, bug958. [Jie Xu]
|
||||
|
||||
**** Fix structure parameter constant propagation, bug968. [Todd Strader]
|
||||
|
||||
**** Fix enum constant propagation, bug970. [Todd Strader]
|
||||
|
||||
**** Fix mis-optimizing public DPI functions, bug963. [Wei Song]
|
||||
|
||||
**** Fix package:scope.scope variable references.
|
||||
|
||||
**** Fix $fwrite to constant stderr/stdout, bug961. [Wei Song]
|
||||
|
||||
**** Fix struct.enum.name method calls, bug855. [Jonathon Donaldson]
|
||||
|
||||
**** Fix dot indexing into arrayed inferfaces, bug978. [Johan Bjork]
|
||||
|
||||
**** Fix crash in commandArgsPlusMatch, bug987. [Jamie Iles]
|
||||
|
||||
**** Fix error message on missing interface, bug985. [Todd Strader]
|
||||
|
||||
|
||||
* Verilator 3.876 2015-08-12
|
||||
|
||||
*** Add tracing_on, etc to vlt files, bug932. [Frederic Requin]
|
||||
|
||||
@@ -100,6 +100,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
#### End of system configuration section. ####
|
||||
######################################################################
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
SUBDIRS = src test_verilated test_c test_sc test_regress
|
||||
|
||||
+2
-1
@@ -117,9 +117,10 @@ and add it to path using Modules/modulecmd:
|
||||
After installing you'll want a module file like the following:
|
||||
|
||||
set install_root /CAD_DISK/verilator/{version-number-used-above}
|
||||
setenv VERILATOR_ROOT $install_root
|
||||
unsetenv VERILATOR_ROOT
|
||||
prepend-path PATH $install_root/bin
|
||||
prepend-path MANPATH $install_root/man
|
||||
prepend-path PKG_CONFIG_PATH $install_root/share/pkgconfig
|
||||
|
||||
=item 3.
|
||||
|
||||
|
||||
+53
-24
@@ -331,6 +331,7 @@ descriptions in the next sections for more information.
|
||||
-v <filename> Verilog library
|
||||
+verilog1995ext+<ext> Synonym for +1364-1995ext+<ext>
|
||||
+verilog2001ext+<ext> Synonym for +1364-2001ext+<ext>
|
||||
--vpi Enable VPI compiles
|
||||
-Werror-<message> Convert warning to error
|
||||
-Wfuture-<message> Disable unknown message warnings
|
||||
-Wno-<message> Disable warning
|
||||
@@ -471,7 +472,7 @@ Verilator will mark the signal as clocker and propagate the clocker attribute
|
||||
automatically to other signals derived from that. In this way, Verilator will
|
||||
try to avoid taking the clocker signal into checking list.
|
||||
|
||||
Note signal-name is specified by the RTL hiearchy path. For example, v.foo.bar.
|
||||
Note signal-name is specified by the RTL hierarchy path. For example, v.foo.bar.
|
||||
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.
|
||||
@@ -1103,6 +1104,10 @@ Note -v is fairly standard across Verilog tools.
|
||||
|
||||
Synonyms for C<+1364-1995ext+>I<ext> and C<+1364-2001ext+>I<ext> respectively
|
||||
|
||||
=item --vpi
|
||||
|
||||
Enable use of VPI and linking against the verilated_vpi.cpp files.
|
||||
|
||||
=item -Wall
|
||||
|
||||
Enable all warnings, including code style warnings that are normally
|
||||
@@ -1802,6 +1807,8 @@ Verilator supports a very limited subset of the VPI. This subset allows
|
||||
inspection, examination, value change callbacks, and depositing of values
|
||||
to public signals only.
|
||||
|
||||
VPI is enabled with the verilator --vpi switch.
|
||||
|
||||
To access signals via the VPI, Verilator must be told exactly which signals
|
||||
are to be accessed. This is done using the Verilator public pragmas
|
||||
documented below.
|
||||
@@ -1835,17 +1842,28 @@ changed on the specified clock edge.
|
||||
There are many online tutorials and books on the VPI, but an example that
|
||||
accesses the above 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"
|
||||
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"
|
||||
|
||||
s_vpi_value v;
|
||||
v.format = vpiIntVal;
|
||||
vpi_get_value(vh1, &v);
|
||||
printf("Value of v: %d\n", v.value.integer); // Prints "readme"
|
||||
}
|
||||
|
||||
s_vpi_value v;
|
||||
v.format = vpiIntVal;
|
||||
vpi_get_value(vh1, &v);
|
||||
printf("Value of v: %d\n", v.value.integer); // Prints "readme"
|
||||
}
|
||||
For signal callbacks to work the main loop of the program must call
|
||||
VerilatedVpi::callValueCbs().
|
||||
|
||||
#include "verilated_vpi.h" // Required to get definitions
|
||||
...
|
||||
while (time passes) {
|
||||
...
|
||||
topp->eval();
|
||||
VerilatedVpi::callValueCbs();
|
||||
}
|
||||
|
||||
|
||||
=head1 CROSS COMPILATION
|
||||
@@ -2085,45 +2103,52 @@ per the C standard (it's unspecified in Verilog).
|
||||
|
||||
=item `coverage_block_off
|
||||
|
||||
Specifies the entire begin/end block should be ignored for coverage analysis.
|
||||
Specifies the entire begin/end block should be ignored for coverage
|
||||
analysis. Must be inside a basic block, e.g. within a begin/end pair.
|
||||
Same as /* verilator coverage_block_off */.
|
||||
|
||||
=item `systemc_header
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into the output .h file's header. Despite the name of this
|
||||
macro, this also works in pure C++ code.
|
||||
place it verbatim into the output .h file's header. Must be placed as a
|
||||
module item, e.g. directly inside a module/endmodule pair. Despite the name
|
||||
of this macro, this also works in pure C++ code.
|
||||
|
||||
=item `systemc_ctor
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into the C++ class constructor. Despite the name of this
|
||||
macro, this also works in pure C++ code.
|
||||
place it verbatim into the C++ class constructor. Must be placed as a
|
||||
module item, e.g. directly inside a module/endmodule pair. Despite the name
|
||||
of this macro, this also works in pure C++ code.
|
||||
|
||||
=item `systemc_dtor
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into the C++ class destructor. Despite the name of this
|
||||
macro, this also works in pure C++ code.
|
||||
place it verbatim into the C++ class destructor. Must be placed as a
|
||||
module item, e.g. directly inside a module/endmodule pair. Despite the name
|
||||
of this macro, this also works in pure C++ code.
|
||||
|
||||
=item `systemc_interface
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into the C++ class interface. Despite the name of this
|
||||
macro, this also works in pure C++ code.
|
||||
place it verbatim into the C++ class interface. Must be placed as a module
|
||||
item, e.g. directly inside a module/endmodule pair. Despite the name of
|
||||
this macro, this also works in pure C++ code.
|
||||
|
||||
=item `systemc_imp_header
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into the header of all files for this C++ class
|
||||
implementation. Despite the name of this macro, this also works in pure
|
||||
C++ code.
|
||||
implementation. Must be placed as a module item, e.g. directly inside a
|
||||
module/endmodule pair. Despite the name of this macro, this also works in
|
||||
pure C++ code.
|
||||
|
||||
=item `systemc_implementation
|
||||
|
||||
Take remaining text up to the next `verilog or `systemc_... mode switch and
|
||||
place it verbatim into a single file of the C++ class implementation.
|
||||
Despite the name of this macro, this also works in pure C++ code.
|
||||
place it verbatim into a single file of the C++ class implementation. Must
|
||||
be placed as a module item, e.g. directly inside a module/endmodule
|
||||
pair. Despite the name of this macro, this also works in pure C++ code.
|
||||
|
||||
If you will be reading or writing any Verilog variables in the C++
|
||||
functions, the Verilog signals must be declared with /*verilator public*/.
|
||||
@@ -3315,6 +3340,10 @@ with "unused" in the name, or put the appropriate lint_off around the wire.
|
||||
Having unused signals in one place makes it easy to find what is unused,
|
||||
and reduces the number of lint_off pragmas, reducing bugs.
|
||||
|
||||
=item USERINFO, USERWARN, USERERROR, USERFATAL
|
||||
|
||||
A SystemVerilog elaboration-time assertion print was executed.
|
||||
|
||||
=item VARHIDDEN
|
||||
|
||||
Warns that a task, function, or begin/end block is declaring a variable by
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
#AC_INIT([Verilator],[#.### YYYY-MM-DD])
|
||||
#AC_INIT([Verilator],[#.### devel])
|
||||
AC_INIT([Verilator],[3.876 2015-08-12])
|
||||
AC_INIT([Verilator],[3.880 2015-12-19])
|
||||
# When releasing, also update header of Changes file
|
||||
|
||||
AC_CONFIG_HEADER(src/config_build.h)
|
||||
|
||||
+36
-4
@@ -374,7 +374,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||
} else {
|
||||
lwp = va_arg(ap,WDataInP);
|
||||
ld = lwp[0];
|
||||
if (fmt == 'u' || fmt == 'd') fmt = 'x'; // Not supported, but show something
|
||||
if (fmt == 'd' || fmt == '#') fmt = 'x'; // Not supported, but show something
|
||||
}
|
||||
int lsb=lbits-1;
|
||||
if (widthSet && width==0) while (lsb && !VL_BITISSET_W(lwp,lsb)) lsb--;
|
||||
@@ -404,7 +404,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||
output += tmp;
|
||||
break;
|
||||
}
|
||||
case 'u': { // Unsigned decimal
|
||||
case '#': { // Unsigned decimal
|
||||
int digits=sprintf(tmp,"%" VL_PRI64 "u",ld);
|
||||
int needmore = width-digits;
|
||||
if (needmore>0) {
|
||||
@@ -438,6 +438,7 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||
output += ((lwp[VL_BITWORD_I(lsb)]>>VL_BITBIT_I(lsb)) & 1) + '0';
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 'o':
|
||||
for (; lsb>=0; lsb--) {
|
||||
lsb = (lsb / 3) * 3; // Next digit
|
||||
@@ -450,6 +451,28 @@ void _vl_vsformat(string& output, const char* formatp, va_list ap) {
|
||||
+ ((VL_BITISSETLIMIT_W(lwp, lbits, lsb+2)) ? 4 : 0));
|
||||
}
|
||||
break;
|
||||
case 'u': // Packed 2-state
|
||||
output.reserve(output.size() + 4*VL_WORDS_I(lbits));
|
||||
for (int i=0; i<VL_WORDS_I(lbits); i++) {
|
||||
output += (char)((lwp[i] >> 0) & 0xff);
|
||||
output += (char)((lwp[i] >> 8) & 0xff);
|
||||
output += (char)((lwp[i] >> 16) & 0xff);
|
||||
output += (char)((lwp[i] >> 24) & 0xff);
|
||||
}
|
||||
case 'z': // Packed 4-state
|
||||
output.reserve(output.size() + 8*VL_WORDS_I(lbits));
|
||||
for (int i=0; i<VL_WORDS_I(lbits); i++) {
|
||||
output += (char)((lwp[i] >> 0) & 0xff);
|
||||
output += (char)((lwp[i] >> 8) & 0xff);
|
||||
output += (char)((lwp[i] >> 16) & 0xff);
|
||||
output += (char)((lwp[i] >> 24) & 0xff);
|
||||
output += "\0\0\0\0"; // No tristate
|
||||
}
|
||||
case 'v': // Strength; assume always strong
|
||||
for (lsb=lbits-1; lsb>=0; lsb--) {
|
||||
if ((lwp[VL_BITWORD_I(lsb)]>>VL_BITBIT_I(lsb)) & 1) output += "St1 ";
|
||||
else output += "St0 ";
|
||||
}
|
||||
case 'x':
|
||||
for (; lsb>=0; lsb--) {
|
||||
lsb = (lsb / 4) * 4; // Next digit
|
||||
@@ -633,7 +656,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf
|
||||
break;
|
||||
}
|
||||
case 't': // FALLTHRU // Time
|
||||
case 'u': { // Unsigned decimal
|
||||
case '#': { // Unsigned decimal
|
||||
_vl_vsss_skipspace(fp,floc,fromp,fstr);
|
||||
_vl_vsss_read(fp,floc,fromp,fstr, tmp, "0123456789+-xXzZ?_");
|
||||
if (!tmp[0]) goto done;
|
||||
@@ -1151,7 +1174,12 @@ void Verilated::commandArgs(int argc, const char** argv) {
|
||||
}
|
||||
|
||||
const char* Verilated::commandArgsPlusMatch(const char* prefixp) {
|
||||
return VerilatedImp::argPlusMatch(prefixp).c_str();
|
||||
const string& match = VerilatedImp::argPlusMatch(prefixp);
|
||||
static VL_THREAD char outstr[VL_VALUE_STRING_MAX_WIDTH];
|
||||
if (match == "") return "";
|
||||
strncpy(outstr, match.c_str(), VL_VALUE_STRING_MAX_WIDTH);
|
||||
outstr[VL_VALUE_STRING_MAX_WIDTH-1] = '\0';
|
||||
return outstr;
|
||||
}
|
||||
|
||||
void Verilated::internalsDump() {
|
||||
@@ -1170,6 +1198,10 @@ int Verilated::exportFuncNum(const char* namep) {
|
||||
return VerilatedImp::exportFind(namep);
|
||||
}
|
||||
|
||||
const VerilatedScopeNameMap* Verilated::scopeNameMap() {
|
||||
return VerilatedImp::scopeNameMap();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// VerilatedModule:: Methods
|
||||
|
||||
|
||||
+6
-2
@@ -38,6 +38,7 @@
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
// <iostream> avoided to reduce compile time
|
||||
// <map> avoided and instead in verilated_heavy.h to reduce compile time
|
||||
// <string> avoided and instead in verilated_heavy.h to reduce compile time
|
||||
using namespace std;
|
||||
|
||||
@@ -68,6 +69,7 @@ typedef void (*VerilatedVoidCb)(void);
|
||||
|
||||
class SpTraceVcd;
|
||||
class SpTraceVcdCFile;
|
||||
class VerilatedScopeNameMap;
|
||||
class VerilatedVar;
|
||||
class VerilatedVarNameMap;
|
||||
class VerilatedVcd;
|
||||
@@ -102,9 +104,9 @@ class VerilatedModule {
|
||||
private:
|
||||
const char* m_namep; ///< Module name
|
||||
VerilatedModule(); ///< N/A, always use named constructor below
|
||||
VerilatedModule(const VerilatedModule& ); ///< N/A, no copying modules
|
||||
VerilatedModule(const VerilatedModule& ); ///< N/A, no copy constructor
|
||||
public:
|
||||
VerilatedModule(const char* namep); ///< Create module with given hierarchy name
|
||||
explicit VerilatedModule(const char* namep); ///< Create module with given hierarchy name
|
||||
~VerilatedModule();
|
||||
const char* name() const { return m_namep; } ///< Return name of module
|
||||
};
|
||||
@@ -287,6 +289,7 @@ public:
|
||||
static void commandArgs(int argc, const char** argv);
|
||||
static void commandArgs(int argc, char** argv) { commandArgs(argc,(const char**)argv); }
|
||||
static CommandArgValues* getCommandArgs() {return &s_args;}
|
||||
/// Match plusargs with a given prefix. Returns static char* valid only for a single call
|
||||
static const char* commandArgsPlusMatch(const char* prefixp);
|
||||
|
||||
/// Produce name & version for (at least) VPI
|
||||
@@ -308,6 +311,7 @@ public:
|
||||
static const char* catName(const char* n1, const char* n2); // Returns new'ed data
|
||||
// Internal: Find scope
|
||||
static const VerilatedScope* scopeFind(const char* namep);
|
||||
static const VerilatedScopeNameMap* scopeNameMap();
|
||||
// Internal: Get and set DPI context
|
||||
static const VerilatedScope* dpiScope() { return t_dpiScopep; }
|
||||
static void dpiScope(const VerilatedScope* scopep) { t_dpiScopep=scopep; }
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
virtual vluint64_t count() const { return *m_countp; }
|
||||
virtual void zero() const { *m_countp = 0; }
|
||||
// CONSTRUCTORS
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VerilatedCoverItemSpec(T* countp) : m_countp(countp) { zero(); }
|
||||
virtual ~VerilatedCoverItemSpec() {}
|
||||
};
|
||||
@@ -261,8 +262,8 @@ public:
|
||||
assert(m_insertp);
|
||||
// First two key/vals are filename
|
||||
ckeyps[0]="filename"; valps[0]=m_insertFilenamep;
|
||||
VlCovCvtToCStr linestrp (m_insertLineno);
|
||||
ckeyps[1]="lineno"; valps[1]=linestrp;
|
||||
string linestr = vlCovCvtToStr(m_insertLineno);
|
||||
ckeyps[1]="lineno"; valps[1]=linestr.c_str();
|
||||
// Default page if not specified
|
||||
const char* fnstartp = m_insertFilenamep;
|
||||
while (const char* foundp = strchr(fnstartp,'/')) fnstartp=foundp+1;
|
||||
@@ -440,8 +441,10 @@ void VerilatedCov::_insertp (A(0),A(1),A(2),A(3),A(4),A(5),A(6),A(7),A(8),A(9),
|
||||
// Backward compatibility for Verilator
|
||||
void VerilatedCov::_insertp (A(0), A(1), K(2),int val2, K(3),int val3,
|
||||
K(4),const string& val4, A(5),A(6)) {
|
||||
string val2str = vlCovCvtToStr(val2);
|
||||
string val3str = vlCovCvtToStr(val3);
|
||||
_insertp(C(0),C(1),
|
||||
key2,VlCovCvtToCStr(val2), key3,VlCovCvtToCStr(val3), key4, val4.c_str(),
|
||||
key2,val2str.c_str(), key3,val3str.c_str(), key4, val4.c_str(),
|
||||
C(5),C(6),N(7),N(8),N(9),
|
||||
N(10),N(11),N(12),N(13),N(14),N(15),N(16),N(17),N(18),N(19),
|
||||
N(20),N(21),N(22),N(23),N(24),N(25),N(26),N(27),N(28),N(29));
|
||||
|
||||
@@ -78,19 +78,6 @@ template< class T> std::string vlCovCvtToStr (const T& t) {
|
||||
ostringstream os; os<<t; return os.str();
|
||||
}
|
||||
|
||||
/// Usage: something(VlCovCvtToCStr(i))
|
||||
/// Note the pointer will only be valid for as long as the object remains
|
||||
/// in scope!
|
||||
struct VlCovCvtToCStr {
|
||||
string m_str;
|
||||
// Casters
|
||||
template< class T> VlCovCvtToCStr (const T& t) {
|
||||
ostringstream os; os<<t; m_str=os.str();
|
||||
}
|
||||
~VlCovCvtToCStr() {}
|
||||
operator const char* () const { return m_str.c_str(); };
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// VerilatedCov
|
||||
/// Verilator coverage global class
|
||||
|
||||
@@ -49,7 +49,6 @@ class VerilatedImp {
|
||||
// TYPES
|
||||
typedef vector<string> ArgVec;
|
||||
typedef map<pair<const void*,void*>,void*> UserMap;
|
||||
typedef map<const char*, const VerilatedScope*, VerilatedCStrCmp> ScopeNameMap;
|
||||
typedef map<const char*, int, VerilatedCStrCmp> ExportNameMap;
|
||||
|
||||
// MEMBERS
|
||||
@@ -60,7 +59,7 @@ class VerilatedImp {
|
||||
ArgVec m_argVec; ///< Argument list (NOT save-restored, may want different results)
|
||||
bool m_argVecLoaded; ///< Ever loaded argument list
|
||||
UserMap m_userMap; ///< Map of <(scope,userkey), userData>
|
||||
ScopeNameMap m_nameMap; ///< Map of <scope_name, scope pointer>
|
||||
VerilatedScopeNameMap m_nameMap; ///< Map of <scope_name, scope pointer>
|
||||
// Slow - somewhat static:
|
||||
ExportNameMap m_exportMap; ///< Map of <export_func_proto, func number>
|
||||
int m_exportNext; ///< Next export funcnum
|
||||
@@ -154,30 +153,33 @@ public: // But only for verilated*.cpp
|
||||
// METHODS - scope name
|
||||
static void scopeInsert(const VerilatedScope* scopep) {
|
||||
// Slow ok - called once/scope at construction
|
||||
ScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
||||
VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
||||
if (it == s_s.m_nameMap.end()) {
|
||||
s_s.m_nameMap.insert(it, make_pair(scopep->name(),scopep));
|
||||
}
|
||||
}
|
||||
static inline const VerilatedScope* scopeFind(const char* namep) {
|
||||
ScopeNameMap::iterator it=s_s.m_nameMap.find(namep);
|
||||
VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(namep);
|
||||
if (VL_LIKELY(it != s_s.m_nameMap.end())) return it->second;
|
||||
else return NULL;
|
||||
}
|
||||
static void scopeErase(const VerilatedScope* scopep) {
|
||||
// Slow ok - called once/scope at destruction
|
||||
userEraseScope(scopep);
|
||||
ScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
||||
VerilatedScopeNameMap::iterator it=s_s.m_nameMap.find(scopep->name());
|
||||
if (it != s_s.m_nameMap.end()) s_s.m_nameMap.erase(it);
|
||||
}
|
||||
static void scopesDump() {
|
||||
VL_PRINTF(" scopesDump:\n");
|
||||
for (ScopeNameMap::iterator it=s_s.m_nameMap.begin(); it!=s_s.m_nameMap.end(); ++it) {
|
||||
for (VerilatedScopeNameMap::iterator it=s_s.m_nameMap.begin(); it!=s_s.m_nameMap.end(); ++it) {
|
||||
const VerilatedScope* scopep = it->second;
|
||||
scopep->scopeDump();
|
||||
}
|
||||
VL_PRINTF("\n");
|
||||
}
|
||||
static const VerilatedScopeNameMap* scopeNameMap() {
|
||||
return &s_s.m_nameMap;
|
||||
}
|
||||
|
||||
public: // But only for verilated*.cpp
|
||||
// METHODS - export names
|
||||
|
||||
@@ -201,7 +201,7 @@ void VerilatedRestore::fill() {
|
||||
if (VL_UNLIKELY(!isOpen())) return;
|
||||
// Move remaining characters down to start of buffer. (No memcpy, overlaps allowed)
|
||||
vluint8_t* rp = m_bufp;
|
||||
for (vluint8_t* sp=m_cp; rp < m_endp;) *rp++ = *sp++; // Overlaps
|
||||
for (vluint8_t* sp=m_cp; sp < m_endp;) *rp++ = *sp++; // Overlaps
|
||||
m_endp = m_bufp + (m_endp - m_cp);
|
||||
m_cp = m_bufp; // Reset buffer
|
||||
// Read into buffer starting at m_endp
|
||||
|
||||
@@ -48,6 +48,8 @@ protected:
|
||||
m_bufp = new vluint8_t [bufferSize()];
|
||||
m_cp = m_bufp;
|
||||
}
|
||||
private:
|
||||
VerilatedSerialBase(const VerilatedSerialBase& ); ///< N/A, no copy constructor
|
||||
public:
|
||||
// CREATORS
|
||||
virtual ~VerilatedSerialBase() {
|
||||
@@ -223,7 +225,7 @@ inline VerilatedSerialize& operator<<(VerilatedSerialize& os, string& rhs) {
|
||||
return os.write(rhs.data(), len);
|
||||
}
|
||||
inline VerilatedDeserialize& operator>>(VerilatedDeserialize& os, string& rhs) {
|
||||
vluint32_t len;
|
||||
vluint32_t len=0;
|
||||
os>>len;
|
||||
rhs.resize(len);
|
||||
return os.read((void*)rhs.data(), len);
|
||||
|
||||
+14
-10
@@ -32,16 +32,6 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
//======================================================================
|
||||
// Types
|
||||
|
||||
struct VerilatedCStrCmp {
|
||||
/// Ordering maps keyed by const char*'s
|
||||
bool operator() (const char *a, const char *b) const {
|
||||
return std::strcmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
/// Verilator range
|
||||
|
||||
@@ -93,6 +83,20 @@ public:
|
||||
//======================================================================
|
||||
/// Types
|
||||
|
||||
struct VerilatedCStrCmp {
|
||||
/// Ordering maps keyed by const char*'s
|
||||
bool operator() (const char *a, const char *b) const {
|
||||
return std::strcmp(a, b) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
class VerilatedScopeNameMap
|
||||
: public map<const char*, const VerilatedScope*, VerilatedCStrCmp> {
|
||||
public:
|
||||
VerilatedScopeNameMap() {}
|
||||
~VerilatedScopeNameMap() {}
|
||||
};
|
||||
|
||||
class VerilatedVarNameMap : public map<const char*, VerilatedVar, VerilatedCStrCmp> {
|
||||
public:
|
||||
VerilatedVarNameMap() {}
|
||||
|
||||
@@ -144,13 +144,15 @@ private:
|
||||
return out + ((char)((code)%94+33));
|
||||
}
|
||||
|
||||
VerilatedVcd(const VerilatedVcd& ); ///< N/A, no copy constructor
|
||||
|
||||
protected:
|
||||
// METHODS
|
||||
void evcd(bool flag) { m_evcd = flag; }
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
VerilatedVcd(VerilatedVcdFile* filep=NULL);
|
||||
explicit VerilatedVcd(VerilatedVcdFile* filep=NULL);
|
||||
~VerilatedVcd();
|
||||
|
||||
// ACCESSORS
|
||||
@@ -399,7 +401,7 @@ class VerilatedVcdC {
|
||||
VerilatedVcd m_sptrace; ///< Trace file being created
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
VerilatedVcdC(VerilatedVcdFile* filep=NULL) : m_sptrace(filep) {}
|
||||
explicit VerilatedVcdC(VerilatedVcdFile* filep=NULL) : m_sptrace(filep) {}
|
||||
~VerilatedVcdC() {}
|
||||
// ACCESSORS
|
||||
/// Is file open?
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
//--------------------------------------------------
|
||||
#if (SYSTEMC_VERSION>=20050714)
|
||||
// SystemC 2.1.v1
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment (const std::string &) {}
|
||||
void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const char **) {}
|
||||
|
||||
@@ -74,6 +75,7 @@ void VerilatedVcdSc::trace (const unsigned int &, const std::string &, const cha
|
||||
//--------------------------------------------------
|
||||
#elif (SYSTEMC_VERSION>20011000)
|
||||
// SystemC 2.0.1
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment (const sc_string &) {}
|
||||
void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {}
|
||||
|
||||
@@ -116,6 +118,7 @@ void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char
|
||||
//--------------------------------------------------
|
||||
#else
|
||||
// SystemC 1.2.1beta
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VerilatedVcdSc::write_comment (const sc_string &) {}
|
||||
void VerilatedVcdSc::trace (const unsigned int &, const sc_string &, const char **) {}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+17
-993
File diff suppressed because it is too large
Load Diff
@@ -95,6 +95,12 @@
|
||||
// This is not necessarily the same as #UL, depending on what the IData typedef is.
|
||||
#define VL_UL(c) ((IData)(c##UL)) ///< Add appropriate suffix to 32-bit constant
|
||||
|
||||
#ifdef VL_CPPCHECK
|
||||
# define VL_DANGLING(v)
|
||||
#else
|
||||
# define VL_DANGLING(v) do { (v) = NULL; } while(0) ///< After e.g. delete, set variable to NULL to indicate must not use later
|
||||
#endif
|
||||
|
||||
//=========================================================================
|
||||
// C++-2011
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ obj_opt:
|
||||
obj_dbg:
|
||||
mkdir $@
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
.PHONY: ../verilator_bin ../verilator_bin_dbg ../verilator_coverage_bin_dbg
|
||||
|
||||
opt: ../verilator_bin
|
||||
|
||||
@@ -327,6 +327,8 @@ V3PreLex_pregen.yy.cpp: V3PreLex.l $(HEADERS)
|
||||
V3PreLex.yy.cpp: V3PreLex_pregen.yy.cpp $(FLEXFIX)
|
||||
$(PERL) $(FLEXFIX) V3PreLex <$< >$@
|
||||
|
||||
.SUFFIXES:
|
||||
|
||||
######################################################################
|
||||
######################################################################
|
||||
|
||||
|
||||
+9
-9
@@ -83,7 +83,7 @@ private:
|
||||
}
|
||||
virtual void visit(AstSenTree* nodep, AstNUser*) {
|
||||
// Simplify sensitivity list
|
||||
V3Const::constifyExpensiveEdit(nodep); nodep=NULL;
|
||||
V3Const::constifyExpensiveEdit(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
// Empty visitors, speed things up
|
||||
virtual void visit(AstNodeStmt* nodep, AstNUser*) { }
|
||||
@@ -184,7 +184,7 @@ private:
|
||||
nodep->lhsp()->unlinkFrBack(),
|
||||
nodep->rhsp()->unlinkFrBack());
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstAssign* nodep, AstNUser*) {
|
||||
@@ -288,7 +288,7 @@ private:
|
||||
// Relink to CFUNC for the final
|
||||
UINFO(4," FINAL "<<nodep<<endl);
|
||||
if (!nodep->bodysp()) { // Empty, Kill it.
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
ActiveDlyVisitor dlyvisitor (nodep, ActiveDlyVisitor::CT_INITIAL);
|
||||
@@ -304,7 +304,7 @@ private:
|
||||
nodep->unlinkFrBack();
|
||||
m_scopeFinalp->addStmtsp(new AstComment(nodep->fileline(), nodep->typeName()));
|
||||
m_scopeFinalp->addStmtsp(nodep->bodysp()->unlinkFrBackWithNext());
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
// METHODS
|
||||
@@ -316,7 +316,7 @@ private:
|
||||
&& oldsensesp->sensesp()->castSenItem()->isNever()) {
|
||||
// Never executing. Kill it.
|
||||
if (oldsensesp->sensesp()->nextp()) nodep->v3fatalSrc("Never senitem should be alone, else the never should be eliminated.");
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ private:
|
||||
|
||||
// Delete sensitivity list
|
||||
if (oldsensesp) {
|
||||
oldsensesp->unlinkFrBackWithNext()->deleteTree(); oldsensesp=NULL;
|
||||
oldsensesp->unlinkFrBackWithNext()->deleteTree(); VL_DANGLING(oldsensesp);
|
||||
}
|
||||
|
||||
// Move node to new active
|
||||
@@ -377,7 +377,7 @@ private:
|
||||
|
||||
if (!nodep->bodysp()) {
|
||||
// Empty always. Kill it.
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
visitAlways(nodep, nodep->sensesp(), nodep->keyword());
|
||||
@@ -402,7 +402,7 @@ private:
|
||||
m_itemCombo = true;
|
||||
// Delete the sensitivity
|
||||
// We'll add it as a generic COMBO SenItem in a moment.
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
} else if (nodep->varrefp()) {
|
||||
// V3LinkResolve should have cleaned most of these up
|
||||
if (!nodep->varrefp()->width1()) nodep->v3error("Unsupported: Non-single bit wide signal pos/negedge sensitivity: "
|
||||
@@ -421,7 +421,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ActiveVisitor(AstNetlist* nodep) {
|
||||
explicit ActiveVisitor(AstNetlist* nodep) {
|
||||
m_scopeFinalp = NULL;
|
||||
m_itemCombo = false;
|
||||
m_itemSequent = false;
|
||||
|
||||
+2
-2
@@ -87,7 +87,7 @@ private:
|
||||
&& sensesp->sensesp()->castSenItem()->isNever()) {
|
||||
// Never executing. Kill it.
|
||||
if (sensesp->sensesp()->nextp()) nodep->v3fatalSrc("Never senitem should be alone, else the never should be eliminated.");
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
// Copy combo tree to settlement tree with duplicated statements
|
||||
@@ -147,7 +147,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ActiveTopVisitor(AstNetlist* nodep) {
|
||||
explicit ActiveTopVisitor(AstNetlist* nodep) {
|
||||
m_topscopep = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
+5
-5
@@ -138,7 +138,7 @@ private:
|
||||
nodep->replaceWith(newp);
|
||||
}
|
||||
// Bye
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void newVAssertion(AstVAssert* nodep, AstNode* propp) {
|
||||
@@ -160,7 +160,7 @@ private:
|
||||
// Install it
|
||||
nodep->replaceWith(newp);
|
||||
// Bye
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
virtual void visit(AstIf* nodep, AstNUser*) {
|
||||
@@ -285,12 +285,12 @@ private:
|
||||
nodep->iterateChildren(*this);
|
||||
if (m_beginp && nodep->name() == "") nodep->name(m_beginp->name());
|
||||
newPslAssertion(nodep, nodep->propp(), nodep->sentreep(),
|
||||
nodep->stmtsp(), nodep->name()); nodep=NULL;
|
||||
nodep->stmtsp(), nodep->name()); VL_DANGLING(nodep);
|
||||
++m_statAsCover;
|
||||
}
|
||||
virtual void visit(AstVAssert* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
newVAssertion(nodep, nodep->propp()); nodep=NULL;
|
||||
newVAssertion(nodep, nodep->propp()); VL_DANGLING(nodep);
|
||||
++m_statAsSV;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
AssertVisitor(AstNetlist* nodep) {
|
||||
explicit AssertVisitor(AstNetlist* nodep) {
|
||||
m_beginp = NULL;
|
||||
m_modp = NULL;
|
||||
// Process
|
||||
|
||||
+3
-3
@@ -83,7 +83,7 @@ private:
|
||||
} else {
|
||||
nodep->unlinkFrBack();
|
||||
}
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
virtual void visit(AstPslCover* nodep, AstNUser*) {
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
// Unlink and just keep a pointer to it, convert to sentree as needed
|
||||
m_senip = nodep->sensesp();
|
||||
nodep->replaceWith(blockp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstNodeModule* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
@@ -122,7 +122,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
AssertPreVisitor(AstNetlist* nodep) {
|
||||
explicit AssertPreVisitor(AstNetlist* nodep) {
|
||||
m_seniDefaultp = NULL;
|
||||
clearAssertInfo();
|
||||
// Process
|
||||
|
||||
+21
-7
@@ -28,6 +28,7 @@
|
||||
#include "V3File.h"
|
||||
#include "V3Global.h"
|
||||
#include "V3Broken.h"
|
||||
#include "V3String.h"
|
||||
|
||||
//======================================================================
|
||||
// Statics
|
||||
@@ -93,10 +94,9 @@ void AstNode::init() {
|
||||
|
||||
string AstNode::encodeName(const string& namein) {
|
||||
// Encode signal name raw from parser, then not called again on same signal
|
||||
const char* start = namein.c_str();
|
||||
string out;
|
||||
for (const char* pos = start; *pos; pos++) {
|
||||
if ((pos==start) ? isalpha(pos[0]) // digits can't lead identifiers
|
||||
for (string::const_iterator pos = namein.begin(); pos!=namein.end(); ++pos) {
|
||||
if ((pos==namein.begin()) ? isalpha(pos[0]) // digits can't lead identifiers
|
||||
: isalnum(pos[0])) {
|
||||
out += pos[0];
|
||||
} else if (pos[0]=='_') {
|
||||
@@ -115,6 +115,10 @@ string AstNode::encodeName(const string& namein) {
|
||||
out += hex;
|
||||
}
|
||||
}
|
||||
// Shorten names
|
||||
// TODO long term use VName in place of "string name"
|
||||
VName vname(out);
|
||||
out = vname.hashedName();
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -823,10 +827,10 @@ AstNode* AstNode::acceptSubtreeReturnEdits(AstNVisitor& v, AstNUser* vup) {
|
||||
// Calling on standalone tree; insert a shim node so we can keep track, then delete it on completion
|
||||
AstBegin* tempp = new AstBegin(nodep->fileline(),"[EditWrapper]",nodep);
|
||||
{
|
||||
tempp->stmtsp()->accept(v, vup); nodep=NULL; // nodep to null as may be replaced
|
||||
tempp->stmtsp()->accept(v, vup); VL_DANGLING(nodep); // nodep to null as may be replaced
|
||||
}
|
||||
nodep = tempp->stmtsp()->unlinkFrBackWithNext();
|
||||
tempp->deleteTree(); tempp=NULL;
|
||||
tempp->deleteTree(); VL_DANGLING(tempp);
|
||||
} else {
|
||||
// Use back to determine who's pointing at us (IE assume new node grafts into same place as old one)
|
||||
AstNode** nextnodepp = NULL;
|
||||
@@ -837,7 +841,7 @@ AstNode* AstNode::acceptSubtreeReturnEdits(AstNVisitor& v, AstNUser* vup) {
|
||||
else if (this->m_backp->m_nextp == this) nextnodepp = &(this->m_backp->m_nextp);
|
||||
if (!nextnodepp) this->v3fatalSrc("Node's back doesn't point to forward to node itself");
|
||||
{
|
||||
nodep->accept(v, vup); nodep=NULL; // nodep to null as may be replaced
|
||||
nodep->accept(v, vup); VL_DANGLING(nodep); // nodep to null as may be replaced
|
||||
}
|
||||
nodep = *nextnodepp; // Grab new node from point where old was connected
|
||||
}
|
||||
@@ -863,6 +867,16 @@ void AstNode::cloneRelinkTree() {
|
||||
//======================================================================
|
||||
// Comparison
|
||||
|
||||
bool AstNode::gateTreeIter() {
|
||||
// Return true if the two trees are identical
|
||||
if (this==NULL) return true;
|
||||
if (!isGateOptimizable()) return false;
|
||||
return (this->op1p()->gateTreeIter()
|
||||
&& this->op2p()->gateTreeIter()
|
||||
&& this->op3p()->gateTreeIter()
|
||||
&& this->op4p()->gateTreeIter());
|
||||
}
|
||||
|
||||
bool AstNode::sameTreeIter(AstNode* node2p, bool ignNext, bool gateOnly) {
|
||||
// Return true if the two trees are identical
|
||||
if (this==NULL && node2p==NULL) return true;
|
||||
@@ -1016,7 +1030,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump) {
|
||||
if (doDump) {
|
||||
{ // Write log & close
|
||||
UINFO(2,"Dumping "<<filename<<endl);
|
||||
const auto_ptr<ofstream> logsp (V3File::new_ofstream(filename, append));
|
||||
const VL_UNIQUE_PTR<ofstream> logsp (V3File::new_ofstream(filename, append));
|
||||
if (logsp->fail()) v3fatalSrc("Can't write "<<filename);
|
||||
*logsp<<"Verilator Tree Dump (format 0x3900) from <e"<<dec<<editCountLast()<<">";
|
||||
*logsp<<" to <e"<<dec<<editCountGbl()<<">"<<endl;
|
||||
|
||||
+33
-9
@@ -53,6 +53,7 @@ public:
|
||||
enum en m_e;
|
||||
// cppcheck-suppress uninitVar // responsiblity of each subclass
|
||||
inline AstType () {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstType (en _e) : m_e(_e) {}
|
||||
explicit inline AstType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -87,7 +88,9 @@ public:
|
||||
return names[m_e];
|
||||
};
|
||||
inline AstNumeric () : m_e(UNSIGNED) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstNumeric (en _e) : m_e(_e) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstNumeric (VSignedState signst) {
|
||||
if (signst==signedst_UNSIGNED) m_e=UNSIGNED;
|
||||
else if (signst==signedst_SIGNED) m_e=SIGNED;
|
||||
@@ -121,6 +124,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline AstPragmaType () : m_e(ILLEGAL) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstPragmaType (en _e) : m_e(_e) {}
|
||||
explicit inline AstPragmaType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -144,6 +148,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline AstCFuncType () : m_e(FT_NORMAL) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstCFuncType (en _e) : m_e(_e) {}
|
||||
explicit inline AstCFuncType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -212,6 +217,7 @@ public:
|
||||
return names[m_e];
|
||||
};
|
||||
inline AstEdgeType () : m_e(ET_ILLEGAL) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstEdgeType (en _e) : m_e(_e) {}
|
||||
explicit inline AstEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -279,6 +285,7 @@ public:
|
||||
return names[m_e];
|
||||
};
|
||||
inline AstAttrType () : m_e(ILLEGAL) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstAttrType (en _e) : m_e(_e) {}
|
||||
explicit inline AstAttrType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -338,6 +345,7 @@ public:
|
||||
UASSERT(0==strcmp(AstBasicDTypeKwd(_ENUM_MAX).dpiType()," MAX"),"Enum array mismatch");
|
||||
}
|
||||
inline AstBasicDTypeKwd () : m_e(UNKNOWN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstBasicDTypeKwd (en _e) : m_e(_e) {}
|
||||
explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -432,6 +440,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline AstVarType () : m_e(UNKNOWN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstVarType (en _e) : m_e(_e) {}
|
||||
explicit inline AstVarType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -469,6 +478,7 @@ public:
|
||||
enum en m_e;
|
||||
// CONSTRUCTOR - note defaults to *UNKNOWN*
|
||||
inline AstBranchPred () : m_e(BP_UNKNOWN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstBranchPred (en _e) : m_e(_e) {}
|
||||
explicit inline AstBranchPred (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -500,6 +510,7 @@ public:
|
||||
enum en m_e;
|
||||
// CONSTRUCTOR - note defaults to *UNKNOWN*
|
||||
inline AstVarAttrClocker () : m_e(CLOCKER_UNKNOWN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstVarAttrClocker (en _e) : m_e(_e) {}
|
||||
explicit inline AstVarAttrClocker (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -530,6 +541,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline VAlwaysKwd () : m_e(ALWAYS) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline VAlwaysKwd (en _e) : m_e(_e) {}
|
||||
explicit inline VAlwaysKwd (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -554,6 +566,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline VCaseType () : m_e(CT_CASE) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline VCaseType (en _e) : m_e(_e) {}
|
||||
explicit inline VCaseType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -576,6 +589,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline AstDisplayType () : m_e(DT_DISPLAY) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstDisplayType (en _e) : m_e(_e) {}
|
||||
explicit inline AstDisplayType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -600,6 +614,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline AstParseRefExp() : m_e(PX_NONE) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline AstParseRefExp (en _e) : m_e(_e) {}
|
||||
explicit inline AstParseRefExp (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -897,16 +912,19 @@ public:
|
||||
// CREATORS
|
||||
class Illegal {}; // for creator type-overload selection
|
||||
class FullValue {}; // for creator type-overload selection
|
||||
V3Hash(Illegal) { m_both=0; }
|
||||
explicit V3Hash(Illegal) { m_both=0; }
|
||||
// Saving and restoring inside a userp
|
||||
V3Hash(AstNUser* up) { m_both=up->castInt(); }
|
||||
explicit V3Hash(AstNUser* up) { m_both=up->castInt(); }
|
||||
V3Hash operator+= (const V3Hash& rh) {
|
||||
setBoth(depth()+rh.depth(), (hshval()*31+rh.hshval()));
|
||||
return *this; };
|
||||
// Creating from raw data (sameHash functions)
|
||||
V3Hash() { setBoth(1,0); }
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
V3Hash(uint32_t val) { setBoth(1,val); }
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
V3Hash(const void* vp) { setBoth(1,cvtToHash(vp)); }
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
V3Hash(const string& name);
|
||||
V3Hash(V3Hash h1, V3Hash h2) {
|
||||
setBoth(1,h1.hshval()*31+h2.hshval()); }
|
||||
@@ -974,12 +992,15 @@ class AstNode {
|
||||
|
||||
void init(); // initialize value of AstNode
|
||||
void iterateListBackwards(AstNVisitor& v, AstNUser* vup=NULL);
|
||||
private:
|
||||
AstNode* cloneTreeIter();
|
||||
AstNode* cloneTreeIterList();
|
||||
void checkTreeIter(AstNode* backp);
|
||||
void checkTreeIterList(AstNode* backp);
|
||||
bool gateTreeIter();
|
||||
bool sameTreeIter(AstNode* node2p, bool ignNext, bool gateOnly);
|
||||
void deleteTreeIter();
|
||||
public:
|
||||
void deleteNode();
|
||||
static void relinkOneLink(AstNode*& pointpr, AstNode* newp);
|
||||
// cppcheck-suppress functionConst
|
||||
@@ -988,7 +1009,7 @@ class AstNode {
|
||||
protected:
|
||||
// CONSTUCTORS
|
||||
AstNode() {init(); }
|
||||
AstNode(FileLine* fileline) {init(); m_fileline = fileline; }
|
||||
explicit AstNode(FileLine* fileline) {init(); m_fileline = fileline; }
|
||||
virtual AstNode* clone() = 0; // Generally, cloneTree is what you want instead
|
||||
virtual void cloneRelink() {}
|
||||
void cloneRelinkTree();
|
||||
@@ -1207,6 +1228,7 @@ public:
|
||||
|
||||
// METHODS - Iterate on a tree
|
||||
AstNode* cloneTree(bool cloneNextLink);
|
||||
bool gateTree() { return gateTreeIter(); } // Is tree gateOptimizable?
|
||||
bool sameTree(AstNode* node2p); // Does tree of this == node2p?
|
||||
bool sameGateTree(AstNode* node2p); // Does tree of this == node2p?, not allowing non-isGateOptimizable
|
||||
void deleteTree(); // Always deletes the next link
|
||||
@@ -1270,7 +1292,7 @@ inline void AstNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); }
|
||||
class AstNodeMath : public AstNode {
|
||||
// Math -- anything that's part of an expression tree
|
||||
public:
|
||||
AstNodeMath(FileLine* fl)
|
||||
explicit AstNodeMath(FileLine* fl)
|
||||
: AstNode(fl) {}
|
||||
ASTNODE_BASE_FUNCS(NodeMath)
|
||||
// METHODS
|
||||
@@ -1287,7 +1309,7 @@ public:
|
||||
class AstNodeTermop : public AstNodeMath {
|
||||
// Terminal operator -- a operator with no "inputs"
|
||||
public:
|
||||
AstNodeTermop(FileLine* fl)
|
||||
explicit AstNodeTermop(FileLine* fl)
|
||||
: AstNodeMath(fl) {}
|
||||
ASTNODE_BASE_FUNCS(NodeTermop)
|
||||
// Know no children, and hot function, so skip iterator for speed
|
||||
@@ -1431,7 +1453,7 @@ public:
|
||||
class AstNodeStmt : public AstNode {
|
||||
// Statement -- anything that's directly under a function
|
||||
public:
|
||||
AstNodeStmt(FileLine* fl)
|
||||
explicit AstNodeStmt(FileLine* fl)
|
||||
: AstNode(fl) {}
|
||||
ASTNODE_BASE_FUNCS(NodeStmt)
|
||||
// METHODS
|
||||
@@ -1521,7 +1543,7 @@ public:
|
||||
class AstNodeSenItem : public AstNode {
|
||||
// An AstSenItem or AstSenGate
|
||||
public:
|
||||
AstNodeSenItem(FileLine* fl) : AstNode(fl) {}
|
||||
explicit AstNodeSenItem(FileLine* fl) : AstNode(fl) {}
|
||||
ASTNODE_BASE_FUNCS(NodeSenItem)
|
||||
virtual bool isClocked() const = 0;
|
||||
virtual bool isCombo() const = 0;
|
||||
@@ -1608,7 +1630,7 @@ private:
|
||||
static int s_uniqueNum; // Unique number assigned to each dtype during creation for IEEE matching
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
AstNodeDType(FileLine* fl) : AstNode(fl) {
|
||||
explicit AstNodeDType(FileLine* fl) : AstNode(fl) {
|
||||
m_width=0; m_widthMin=0; m_generic=false;
|
||||
}
|
||||
ASTNODE_BASE_FUNCS(NodeDType)
|
||||
@@ -1697,7 +1719,7 @@ private:
|
||||
AstNodeDType* m_refDTypep; // Elements of this type (after widthing)
|
||||
AstNode* rangenp() const { return op2p(); } // op2 = Array(s) of variable
|
||||
public:
|
||||
AstNodeArrayDType(FileLine* fl) : AstNodeDType(fl) {
|
||||
explicit AstNodeArrayDType(FileLine* fl) : AstNodeDType(fl) {
|
||||
m_refDTypep = NULL;
|
||||
}
|
||||
ASTNODE_BASE_FUNCS(NodeArrayDType)
|
||||
@@ -1790,6 +1812,7 @@ public:
|
||||
virtual void dump(ostream& str=cout);
|
||||
virtual string name() const { return m_name; } // * = Var name
|
||||
virtual bool maybePointedTo() const { return true; }
|
||||
virtual bool isGateOptimizable() const { return !((m_dpiExport || m_dpiImport) && !m_pure); }
|
||||
// {AstFunc only} op1 = Range output variable
|
||||
virtual void name(const string& name) { m_name = name; }
|
||||
string cname() const { return m_cname; }
|
||||
@@ -1848,6 +1871,7 @@ public:
|
||||
}}
|
||||
virtual void dump(ostream& str=cout);
|
||||
virtual string name() const { return m_name; } // * = Var name
|
||||
virtual bool isGateOptimizable() const { return m_taskp && m_taskp->isGateOptimizable(); }
|
||||
string dotted() const { return m_dotted; } // * = Scope name or ""
|
||||
string prettyDotted() const { return prettyName(dotted()); }
|
||||
string inlinedDots() const { return m_inlinedDots; }
|
||||
|
||||
+62
-9
@@ -1311,6 +1311,7 @@ public:
|
||||
ASTNODE_NODE_FUNCS(VarXRef, VARXREF)
|
||||
virtual void dump(ostream& str);
|
||||
string dotted() const { return m_dotted; }
|
||||
void dotted(const string& dotted) { m_dotted = dotted; }
|
||||
string prettyDotted() const { return prettyName(dotted()); }
|
||||
string inlinedDots() const { return m_inlinedDots; }
|
||||
void inlinedDots(const string& flag) { m_inlinedDots = flag; }
|
||||
@@ -1570,6 +1571,56 @@ public:
|
||||
virtual void name(const string& name) { m_name = name; }
|
||||
};
|
||||
|
||||
class AstCellRef : public AstNode {
|
||||
// As-of-yet unlinkable reference into a cell
|
||||
private:
|
||||
string m_name; // Cell name
|
||||
public:
|
||||
AstCellRef(FileLine* fl,
|
||||
string name, AstNode* cellp, AstNode* exprp)
|
||||
: AstNode(fl)
|
||||
, m_name(name) {
|
||||
addNOp1p(cellp); addNOp2p(exprp); }
|
||||
ASTNODE_NODE_FUNCS(CellRef, CELLREF)
|
||||
// ACCESSORS
|
||||
virtual string name() const { return m_name; } // * = Array name
|
||||
AstNode* cellp() const { return op1p(); } // op1 = Cell
|
||||
AstNode* exprp() const { return op2p(); } // op2 = Expression
|
||||
};
|
||||
|
||||
class AstCellArrayRef : public AstNode {
|
||||
// As-of-yet unlinkable reference into an array of cells
|
||||
private:
|
||||
string m_name; // Array name
|
||||
public:
|
||||
AstCellArrayRef(FileLine* fl,
|
||||
string name, AstNode* selectExprp)
|
||||
: AstNode(fl)
|
||||
, m_name(name) {
|
||||
addNOp1p(selectExprp); }
|
||||
ASTNODE_NODE_FUNCS(CellArrayRef, CELLARRAYREF)
|
||||
// ACCESSORS
|
||||
virtual string name() const { return m_name; } // * = Array name
|
||||
AstNode* selp() const { return op1p(); } // op1 = Select expression
|
||||
};
|
||||
|
||||
class AstUnlinkedRef : public AstNode {
|
||||
// As-of-yet unlinkable Ref
|
||||
private:
|
||||
string m_name; // Var name
|
||||
public:
|
||||
AstUnlinkedRef(FileLine* fl,
|
||||
AstNode* refp, string name, AstNode* crp)
|
||||
: AstNode(fl)
|
||||
, m_name(name) {
|
||||
addNOp1p(refp); addNOp2p(crp); }
|
||||
ASTNODE_NODE_FUNCS(UnlinkedRef, UNLINKEDREF)
|
||||
// ACCESSORS
|
||||
virtual string name() const { return m_name; } // * = Var name
|
||||
AstNode* refp() const { return op1p(); } // op1 = VarXRef or AstNodeFTaskRef
|
||||
AstNode* cellrefp() const { return op2p(); } // op2 = CellArrayRef or CellRef
|
||||
};
|
||||
|
||||
class AstBind : public AstNode {
|
||||
// Parents: MODULE
|
||||
// Children: CELL
|
||||
@@ -2208,11 +2259,13 @@ class AstSFormatF : public AstNode {
|
||||
public:
|
||||
AstSFormatF(FileLine* fl, const string& text, bool hidden, AstNode* exprsp)
|
||||
: AstNode(fl), m_text(text), m_hidden(hidden) {
|
||||
dtypeSetString();
|
||||
addNOp1p(exprsp); addNOp2p(NULL); }
|
||||
ASTNODE_NODE_FUNCS(SFormatF, SFORMATF)
|
||||
virtual string name() const { return m_text; }
|
||||
virtual int instrCount() const { return instrCountPli(); }
|
||||
virtual V3Hash sameHash() const { return V3Hash(text()); }
|
||||
virtual bool hasDType() const { return true; }
|
||||
virtual bool same(AstNode* samep) const { return text()==samep->castSFormatF()->text(); }
|
||||
virtual string verilogKwd() const { return "$sformatf"; }
|
||||
void exprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output
|
||||
@@ -2602,7 +2655,7 @@ public:
|
||||
|
||||
class AstBreak : public AstNodeStmt {
|
||||
public:
|
||||
AstBreak(FileLine* fileline)
|
||||
explicit AstBreak(FileLine* fileline)
|
||||
: AstNodeStmt (fileline) {}
|
||||
ASTNODE_NODE_FUNCS(Break, BREAK)
|
||||
virtual string verilogKwd() const { return "break"; };
|
||||
@@ -2612,7 +2665,7 @@ public:
|
||||
|
||||
class AstContinue : public AstNodeStmt {
|
||||
public:
|
||||
AstContinue(FileLine* fileline)
|
||||
explicit AstContinue(FileLine* fileline)
|
||||
: AstNodeStmt (fileline) {}
|
||||
ASTNODE_NODE_FUNCS(Continue, CONTINUE)
|
||||
virtual string verilogKwd() const { return "continue"; };
|
||||
@@ -2905,7 +2958,7 @@ public:
|
||||
|
||||
class AstStop : public AstNodeStmt {
|
||||
public:
|
||||
AstStop(FileLine* fl)
|
||||
explicit AstStop(FileLine* fl)
|
||||
: AstNodeStmt(fl) {}
|
||||
ASTNODE_NODE_FUNCS(Stop, STOP)
|
||||
virtual bool isGateOptimizable() const { return false; }
|
||||
@@ -2921,7 +2974,7 @@ public:
|
||||
|
||||
class AstFinish : public AstNodeStmt {
|
||||
public:
|
||||
AstFinish(FileLine* fl)
|
||||
explicit AstFinish(FileLine* fl)
|
||||
: AstNodeStmt(fl) {}
|
||||
ASTNODE_NODE_FUNCS(Finish, FINISH)
|
||||
virtual bool isGateOptimizable() const { return false; }
|
||||
@@ -3070,7 +3123,7 @@ private:
|
||||
string scopeNameFormatter(AstText* textp) const;
|
||||
string scopePrettyNameFormatter(AstText* textp) const;
|
||||
public:
|
||||
AstScopeName(FileLine* fl) : AstNodeMath(fl), m_dpiExport(false) {
|
||||
explicit AstScopeName(FileLine* fl) : AstNodeMath(fl), m_dpiExport(false) {
|
||||
dtypeSetUInt64(); }
|
||||
ASTNODE_NODE_FUNCS(ScopeName, SCOPENAME)
|
||||
virtual V3Hash sameHash() const { return V3Hash(); }
|
||||
@@ -3120,7 +3173,7 @@ private:
|
||||
public:
|
||||
AstRand(FileLine* fl, AstNodeDType* dtp, bool reset) : AstNodeTermop(fl) {
|
||||
dtypep(dtp); m_reset=reset; }
|
||||
AstRand(FileLine* fl) : AstNodeTermop(fl), m_reset(false) { }
|
||||
explicit AstRand(FileLine* fl) : AstNodeTermop(fl), m_reset(false) { }
|
||||
ASTNODE_NODE_FUNCS(Rand, RAND)
|
||||
virtual string emitVerilog() { return "%f$random"; }
|
||||
virtual string emitC() {
|
||||
@@ -3137,7 +3190,7 @@ public:
|
||||
|
||||
class AstTime : public AstNodeTermop {
|
||||
public:
|
||||
AstTime(FileLine* fl) : AstNodeTermop(fl) {
|
||||
explicit AstTime(FileLine* fl) : AstNodeTermop(fl) {
|
||||
dtypeSetUInt64(); }
|
||||
ASTNODE_NODE_FUNCS(Time, TIME)
|
||||
virtual string emitVerilog() { return "%f$time"; }
|
||||
@@ -3152,7 +3205,7 @@ public:
|
||||
|
||||
class AstTimeD : public AstNodeTermop {
|
||||
public:
|
||||
AstTimeD(FileLine* fl) : AstNodeTermop(fl) {
|
||||
explicit AstTimeD(FileLine* fl) : AstNodeTermop(fl) {
|
||||
dtypeSetDouble(); }
|
||||
ASTNODE_NODE_FUNCS(TimeD, TIMED)
|
||||
virtual string emitVerilog() { return "%f$realtime"; }
|
||||
@@ -5080,7 +5133,7 @@ class AstTypeTable : public AstNode {
|
||||
typedef map<VBasicTypeKey,AstBasicDType*> DetailedMap;
|
||||
DetailedMap m_detailedMap;
|
||||
public:
|
||||
AstTypeTable(FileLine* fl) : AstNode(fl) {
|
||||
explicit AstTypeTable(FileLine* fl) : AstNode(fl) {
|
||||
for (int i=0; i<AstBasicDTypeKwd::_ENUM_MAX; ++i) m_basicps[i] = NULL;
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(TypeTable, TYPETABLE)
|
||||
|
||||
+28
-3
@@ -56,7 +56,7 @@ public:
|
||||
m_anyFuncInBegin = false;
|
||||
}
|
||||
~BeginState() {}
|
||||
void userMarkChanged(AstNodeFTask* nodep) {
|
||||
void userMarkChanged(AstNode* nodep) {
|
||||
nodep->user1(true);
|
||||
m_anyFuncInBegin = true;
|
||||
}
|
||||
@@ -160,12 +160,13 @@ private:
|
||||
} else {
|
||||
nodep->unlinkFrBack();
|
||||
}
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstVar* nodep, AstNUser*) {
|
||||
if (m_unnamedScope != "") {
|
||||
// Rename it
|
||||
nodep->name(m_unnamedScope+"__DOT__"+nodep->name());
|
||||
m_statep->userMarkChanged(nodep);
|
||||
// Move to module
|
||||
nodep->unlinkFrBack();
|
||||
if (m_ftaskp) m_ftaskp->addStmtsp(nodep); // Begins under funcs just move into the func
|
||||
@@ -175,6 +176,7 @@ private:
|
||||
virtual void visit(AstCell* nodep, AstNUser*) {
|
||||
UINFO(8," CELL "<<nodep<<endl);
|
||||
if (m_namedScope != "") {
|
||||
m_statep->userMarkChanged(nodep);
|
||||
// Rename it
|
||||
nodep->name(m_namedScope+"__DOT__"+nodep->name());
|
||||
UINFO(8," rename to "<<nodep->name()<<endl);
|
||||
@@ -182,6 +184,14 @@ private:
|
||||
nodep->unlinkFrBack();
|
||||
m_modp->addStmtp(nodep);
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
virtual void visit(AstVarXRef* nodep, AstNUser*) {
|
||||
UINFO(9, " VARXREF "<<nodep<<endl);
|
||||
if (m_namedScope != "" && nodep->inlinedDots() == "") {
|
||||
nodep->inlinedDots(m_namedScope);
|
||||
UINFO(9, " rescope to "<<nodep<<endl);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstScopeName* nodep, AstNUser*) {
|
||||
// If there's a %m in the display text, we add a special node that will contain the name()
|
||||
@@ -215,7 +225,7 @@ private:
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
m_ifDepth = prevIfDepth;
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
@@ -249,6 +259,21 @@ private:
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||
if (nodep->varp()->user1()) { // It was converted
|
||||
UINFO(9, " relinVarRef "<<nodep<<endl);
|
||||
nodep->name(nodep->varp()->name());
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
virtual void visit(AstIfaceRefDType* nodep, AstNUser*) {
|
||||
// May have changed cell names
|
||||
// TypeTable is always after all modules, so names are stable
|
||||
UINFO(8," IFACEREFDTYPE "<<nodep<<endl);
|
||||
if (nodep->cellp()) nodep->cellName(nodep->cellp()->name());
|
||||
UINFO(8," rename to "<<nodep<<endl);
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
//--------------------
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
BranchVisitor(AstNetlist* nodep) {
|
||||
explicit BranchVisitor(AstNetlist* nodep) {
|
||||
reset();
|
||||
nodep->iterateChildren(*this);
|
||||
calc_tasks();
|
||||
|
||||
+12
-5
@@ -186,14 +186,18 @@ private:
|
||||
// NODE STATE
|
||||
// Nothing! // This may be called deep inside other routines
|
||||
// // so userp and friends may not be used
|
||||
// VISITORS
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
// METHODS
|
||||
void processAndIterate(AstNode* nodep) {
|
||||
BrokenTable::addInTree(nodep, nodep->maybePointedTo());
|
||||
nodep->iterateChildrenConst(*this);
|
||||
}
|
||||
// VISITORS
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
processAndIterate(nodep);
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
BrokenMarkVisitor(AstNetlist* nodep) {
|
||||
explicit BrokenMarkVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~BrokenMarkVisitor() {}
|
||||
@@ -210,7 +214,7 @@ private:
|
||||
nodep->v3fatalSrc("Width != WidthMin");
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
void processAndIterate(AstNode* nodep) {
|
||||
BrokenTable::setUnder(nodep,true);
|
||||
if (const char* whyp=nodep->broken()) {
|
||||
nodep->v3fatalSrc("Broken link in node (or something without maybePointedTo): "<<whyp);
|
||||
@@ -232,9 +236,12 @@ private:
|
||||
nodep->iterateChildrenConst(*this);
|
||||
BrokenTable::setUnder(nodep,false);
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
processAndIterate(nodep);
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
BrokenCheckVisitor(AstNetlist* nodep) {
|
||||
explicit BrokenCheckVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~BrokenCheckVisitor() {}
|
||||
|
||||
+13
-15
@@ -112,7 +112,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CaseLintVisitor(AstNodeCase* nodep) {
|
||||
explicit CaseLintVisitor(AstNodeCase* nodep) {
|
||||
m_caseExprp = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ private:
|
||||
if (m_valueItem[a] != m_valueItem[b]) { same=false; break; }
|
||||
}
|
||||
if (same) {
|
||||
tree1p->deleteTree(); tree1p=NULL;
|
||||
tree1p->deleteTree(); VL_DANGLING(tree1p);
|
||||
return tree0p;
|
||||
}
|
||||
|
||||
@@ -295,8 +295,8 @@ private:
|
||||
|
||||
if (ifrootp) nodep->replaceWith(ifrootp);
|
||||
else nodep->unlinkFrBack();
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
cexprp->deleteTree(); cexprp=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
cexprp->deleteTree(); VL_DANGLING(cexprp);
|
||||
if (debug()>=9) ifrootp->dumpTree(cout," _simp: ");
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ private:
|
||||
AstConst* iconstp = icondp->castConst();
|
||||
if (iconstp && neverItem(nodep, iconstp)) {
|
||||
// X in casez can't ever be executed
|
||||
icondp->deleteTree(); icondp=NULL; iconstp=NULL;
|
||||
icondp->deleteTree(); VL_DANGLING(icondp); VL_DANGLING(iconstp);
|
||||
// For simplicity, make expression that is not equal, and let later
|
||||
// optimizations remove it
|
||||
condp = new AstConst(itemp->fileline(), AstConst::LogicFalse());
|
||||
@@ -351,7 +351,7 @@ private:
|
||||
AstNode* and2p = new AstAnd(itemp->fileline(),
|
||||
new AstConst(itemp->fileline(), numval),
|
||||
new AstConst(itemp->fileline(), nummask));
|
||||
icondp->deleteTree(); icondp=NULL; iconstp=NULL;
|
||||
icondp->deleteTree(); VL_DANGLING(icondp); VL_DANGLING(iconstp);
|
||||
condp = AstEq::newTyped(itemp->fileline(), and1p, and2p);
|
||||
} else {
|
||||
// Not a caseX mask, we can simply build CASEEQ(cexpr icond)
|
||||
@@ -369,7 +369,7 @@ private:
|
||||
itemp->condsp(ifexprp);
|
||||
}
|
||||
}
|
||||
cexprp->deleteTree(); cexprp=NULL;
|
||||
cexprp->deleteTree(); VL_DANGLING(cexprp);
|
||||
if (!hadDefault) {
|
||||
// If there was no default, add a empty one, this greatly simplifies below code
|
||||
// and constant propagation will just eliminate it for us later.
|
||||
@@ -408,10 +408,9 @@ private:
|
||||
}
|
||||
}
|
||||
{ // Make the new lower IF and attach in the tree
|
||||
AstNode* itemexprp = ifexprp; ifexprp=NULL;
|
||||
AstNode* itemexprp = ifexprp; VL_DANGLING(ifexprp);
|
||||
if (depth == (CASE_ENCODER_GROUP_DEPTH)) { // End of group - can skip the condition
|
||||
itemexprp->deleteTree(); itemexprp=NULL;
|
||||
// cppcheck-suppress redundantAssignment
|
||||
itemexprp->deleteTree(); VL_DANGLING(itemexprp);
|
||||
itemexprp = new AstConst(itemp->fileline(), AstConst::LogicTrue());
|
||||
}
|
||||
AstIf* newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, NULL);
|
||||
@@ -427,7 +426,7 @@ private:
|
||||
if (debug()>=9) grouprootp->dumpTree(cout," _new: ");
|
||||
if (grouprootp) nodep->replaceWith(grouprootp);
|
||||
else nodep->unlinkFrBack();
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void replaceCaseParallel(AstCase* nodep, bool noOverlapsAllCovered) {
|
||||
@@ -460,11 +459,10 @@ private:
|
||||
// It's a simple priority encoder or complete statement
|
||||
// we can make a tree of statements to avoid extra comparisons
|
||||
++m_statCaseFast;
|
||||
replaceCaseFast(nodep); nodep=NULL;
|
||||
replaceCaseFast(nodep); VL_DANGLING(nodep);
|
||||
} else {
|
||||
++m_statCaseSlow;
|
||||
// cppcheck-supporess uselessAssignmentPtrArg
|
||||
replaceCaseComplicated(nodep); nodep=NULL;
|
||||
replaceCaseComplicated(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
//--------------------
|
||||
@@ -475,7 +473,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CaseVisitor(AstNetlist* nodep) {
|
||||
explicit CaseVisitor(AstNetlist* nodep) {
|
||||
m_caseNoOverlapsAllCovered = false;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
+1
-1
@@ -176,7 +176,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CastVisitor(AstNetlist* nodep) {
|
||||
explicit CastVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~CastVisitor() {}
|
||||
|
||||
+3
-3
@@ -184,7 +184,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CdcWidthVisitor(AstNode* nodep) {
|
||||
explicit CdcWidthVisitor(AstNode* nodep) {
|
||||
m_maxLineno = 0;
|
||||
m_maxFilenameLen = 0;
|
||||
nodep->accept(*this);
|
||||
@@ -496,7 +496,7 @@ private:
|
||||
}
|
||||
|
||||
string filename = v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"__cdc_edges.txt";
|
||||
const auto_ptr<ofstream> ofp (V3File::new_ofstream(filename));
|
||||
const VL_UNIQUE_PTR<ofstream> ofp (V3File::new_ofstream(filename));
|
||||
if (ofp->fail()) v3fatalSrc("Can't write "<<filename);
|
||||
*ofp<<"Edge Report for "<<v3Global.opt.prefix()<<endl;
|
||||
|
||||
@@ -726,7 +726,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CdcVisitor(AstNode* nodep) {
|
||||
explicit CdcVisitor(AstNode* nodep) {
|
||||
m_logicVertexp = NULL;
|
||||
m_scopep = NULL;
|
||||
m_modp = NULL;
|
||||
|
||||
+1
-1
@@ -280,7 +280,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CleanVisitor(AstNetlist* nodep) {
|
||||
explicit CleanVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~CleanVisitor() {}
|
||||
|
||||
+11
-11
@@ -66,7 +66,7 @@ class GaterVarVertex;
|
||||
class GaterVertex : public V3GraphVertex {
|
||||
static uint32_t s_rankNum;
|
||||
public:
|
||||
GaterVertex(V3Graph* graphp)
|
||||
explicit GaterVertex(V3Graph* graphp)
|
||||
: V3GraphVertex(graphp) {
|
||||
s_rankNum++; rank(s_rankNum);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ uint32_t GaterVertex::s_rankNum = 0;
|
||||
|
||||
class GaterHeadVertex : public GaterVertex {
|
||||
public:
|
||||
GaterHeadVertex(V3Graph* graphp)
|
||||
explicit GaterHeadVertex(V3Graph* graphp)
|
||||
: GaterVertex(graphp) {}
|
||||
virtual ~GaterHeadVertex() {}
|
||||
virtual int typeNum() const { return __LINE__; } // C++ typeof() equivelent
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
|
||||
class GaterPliVertex : public GaterVertex {
|
||||
public:
|
||||
GaterPliVertex(V3Graph* graphp)
|
||||
explicit GaterPliVertex(V3Graph* graphp)
|
||||
: GaterVertex(graphp) {}
|
||||
virtual ~GaterPliVertex() {}
|
||||
virtual int typeNum() const { return __LINE__; } // C++ typeof() equivelent
|
||||
@@ -217,7 +217,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
GaterCondVisitor(AstNode* nodep) {
|
||||
explicit GaterCondVisitor(AstNode* nodep) {
|
||||
m_isSimple = true;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ class GaterBodyVisitor : public GaterBaseVisitor {
|
||||
}
|
||||
|
||||
if ((childstate & STATE_DELETE) && !(childstate & STATE_KEEP)) {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
// Pass upwards we did delete
|
||||
m_state |= STATE_DELETE;
|
||||
} else {
|
||||
@@ -427,7 +427,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
for (V3GraphEdge* nextp,* edgep = m_pliVertexp->outBeginp(); edgep; edgep = nextp) {
|
||||
nextp = edgep->outNextp(); // We may edit the list
|
||||
if (GaterVarVertex* vVxp = dynamic_cast<GaterVarVertex*>(edgep->top())) {
|
||||
vVxp->unlinkDelete(&m_graph); vVxp=NULL; edgep=NULL;
|
||||
vVxp->unlinkDelete(&m_graph); VL_DANGLING(vVxp); VL_DANGLING(edgep);
|
||||
} else {
|
||||
m_graph.dump();
|
||||
v3fatalSrc("PLI vertex points to non-signal");
|
||||
@@ -463,7 +463,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
V3GraphVertex* toVxp = edgep->top();
|
||||
//UINFO(9," to "<<toVxp->user()<<" "<<toVxp<<endl);
|
||||
if ((toVxp->user() & VU_IF) && (toVxp->user() & VU_ELSE)) {
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
if (!(toVxp->user() & VU_MADE)) { // Make an edge only once
|
||||
toVxp->user(toVxp->user() | VU_MADE);
|
||||
GaterEdge* inedgep = static_cast<GaterEdge*>(vertexp->inBeginp());
|
||||
@@ -487,7 +487,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
if (toVxp->user() && toVxp->user() < depth) {
|
||||
// A recursion "above" us marked it,
|
||||
// Remove this edge, it's redundant with the upper edge
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
} else {
|
||||
GaterEdge* cedgep = static_cast<GaterEdge*>(edgep);
|
||||
if (cedgep->ifelseBoth()) {
|
||||
@@ -515,7 +515,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
if (GaterIfVertex* toVxp = dynamic_cast<GaterIfVertex*>(edgep->top())) {
|
||||
if (!toVxp->outBeginp()) {
|
||||
if (!nextp || nextp->top() != edgep->top()) { // Else next would disappear; we'll do it next loop
|
||||
toVxp->unlinkDelete(&m_graph); toVxp=NULL; edgep=NULL;
|
||||
toVxp->unlinkDelete(&m_graph); VL_DANGLING(toVxp); VL_DANGLING(edgep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +529,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
nextp = edgep->outNextp(); // We may edit the list
|
||||
if (GaterVarVertex* toVxp = dynamic_cast<GaterVarVertex*>(edgep->top())) {
|
||||
if (!nextp || nextp->top() != edgep->top()) { // Else next would disappear; we'll do it next loop
|
||||
toVxp->unlinkDelete(&m_graph); toVxp=NULL; edgep=NULL;
|
||||
toVxp->unlinkDelete(&m_graph); VL_DANGLING(toVxp); VL_DANGLING(edgep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -878,7 +878,7 @@ class GaterVisitor : public GaterBaseVisitor {
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
GaterVisitor(AstNode* nodep) {
|
||||
explicit GaterVisitor(AstNode* nodep) {
|
||||
// AstAlways visitor does the real work, so most zeroing needs to be in clear()
|
||||
clear();
|
||||
nodep->accept(*this);
|
||||
|
||||
+7
-7
@@ -268,7 +268,7 @@ private:
|
||||
stmtsp->unlinkFrBackWithNext();
|
||||
cmtp->addNextHere(stmtsp);
|
||||
}
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstAlwaysPost* nodep, AstNUser*) {
|
||||
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName());
|
||||
@@ -277,7 +277,7 @@ private:
|
||||
stmtsp->unlinkFrBackWithNext();
|
||||
cmtp->addNextHere(stmtsp);
|
||||
}
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstCoverToggle* nodep, AstNUser*) {
|
||||
//nodep->dumpTree(cout,"ct:");
|
||||
@@ -297,7 +297,7 @@ private:
|
||||
newp->addIfsp(new AstAssign(nodep->fileline(),
|
||||
changep->cloneTree(false),
|
||||
origp->cloneTree(false)));
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstInitial* nodep, AstNUser*) {
|
||||
AstNode* cmtp = new AstComment(nodep->fileline(), nodep->typeName());
|
||||
@@ -306,7 +306,7 @@ private:
|
||||
stmtsp->unlinkFrBackWithNext();
|
||||
cmtp->addNextHere(stmtsp);
|
||||
}
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstCFunc* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
@@ -342,7 +342,7 @@ private:
|
||||
// Not at the top or empty block...
|
||||
// Only empty blocks should be leftover on the non-top. Killem.
|
||||
if (nodep->stmtsp()) nodep->v3fatalSrc("Non-empty lower active");
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
} else {
|
||||
UINFO(4," ACTIVE "<<nodep<<endl);
|
||||
AstNode* stmtsp = nodep->stmtsp()->unlinkFrBackWithNext();
|
||||
@@ -374,7 +374,7 @@ private:
|
||||
// Move statements to function
|
||||
addToEvalLoop(stmtsp);
|
||||
}
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep = NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ClockVisitor(AstNetlist* nodep) {
|
||||
explicit ClockVisitor(AstNetlist* nodep) {
|
||||
m_modp=NULL; m_activep=NULL;
|
||||
m_evalFuncp = NULL;
|
||||
m_topScopep=NULL;
|
||||
|
||||
+8
-8
@@ -111,7 +111,7 @@ public:
|
||||
callp->unlinkFrBack();
|
||||
}
|
||||
callp->user3(true); // Dead now
|
||||
pushDeletep(callp); callp=NULL;
|
||||
pushDeletep(callp); VL_DANGLING(callp);
|
||||
m_callMmap.erase(eqit); // Fix the table
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
CombMarkVisitor(AstNode* nodep) {
|
||||
explicit CombMarkVisitor(AstNode* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~CombMarkVisitor() {}
|
||||
@@ -230,7 +230,7 @@ private:
|
||||
CombMarkVisitor visitor(oldfuncp);
|
||||
m_call.replaceFunc(oldfuncp, NULL);
|
||||
oldfuncp->unlinkFrBack();
|
||||
pushDeletep(oldfuncp); oldfuncp=NULL;
|
||||
pushDeletep(oldfuncp); VL_DANGLING(oldfuncp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ private:
|
||||
CombMarkVisitor visitor(oldfuncp);
|
||||
m_call.replaceFunc(oldfuncp, newfuncp);
|
||||
oldfuncp->unlinkFrBack();
|
||||
pushDeletep(oldfuncp); oldfuncp=NULL;
|
||||
pushDeletep(oldfuncp); VL_DANGLING(oldfuncp);
|
||||
}
|
||||
void replaceOnlyCallFunc(AstCCall* nodep) {
|
||||
if (AstCFunc* oldfuncp = nodep->backp()->castCFunc()) {
|
||||
@@ -274,7 +274,7 @@ private:
|
||||
UINFO(9," Function only has call "<<oldfuncp<<endl);
|
||||
m_call.deleteCall(nodep);
|
||||
CombMarkVisitor visitor(oldfuncp);
|
||||
replaceFuncWFunc(oldfuncp, nodep->funcp()); nodep=NULL;
|
||||
replaceFuncWFunc(oldfuncp, nodep->funcp()); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,8 +384,8 @@ private:
|
||||
m_call.addCall(call2p);
|
||||
// If either new statement makes a func with only a single call, replace
|
||||
// the above callers to call it directly
|
||||
replaceOnlyCallFunc(call1p); call1p=NULL;
|
||||
replaceOnlyCallFunc(call2p); call2p=NULL;
|
||||
replaceOnlyCallFunc(call1p); VL_DANGLING(call1p);
|
||||
replaceOnlyCallFunc(call2p); VL_DANGLING(call2p);
|
||||
}
|
||||
|
||||
// VISITORS
|
||||
@@ -457,7 +457,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CombineVisitor(AstNetlist* nodep) {
|
||||
explicit CombineVisitor(AstNetlist* nodep) {
|
||||
m_modp=NULL;
|
||||
m_funcp = NULL;
|
||||
m_state = STATE_IDLE;
|
||||
|
||||
+92
-90
@@ -33,6 +33,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "V3Global.h"
|
||||
#include "V3String.h"
|
||||
#include "V3Const.h"
|
||||
#include "V3Ast.h"
|
||||
#include "V3Width.h"
|
||||
@@ -54,7 +55,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ConstVarMarkVisitor(AstNode* nodep) {
|
||||
explicit ConstVarMarkVisitor(AstNode* nodep) {
|
||||
AstNode::user4ClearTree(); // Check marked InUse before we're called
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -76,7 +77,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ConstVarFindVisitor(AstNode* nodep) {
|
||||
explicit ConstVarFindVisitor(AstNode* nodep) {
|
||||
m_found = false;
|
||||
nodep->iterateAndNext(*this, NULL);
|
||||
}
|
||||
@@ -214,7 +215,7 @@ private:
|
||||
if (!operandsSame(ap, bp)) return false;
|
||||
// Do it
|
||||
cp->unlinkFrBack();
|
||||
andp->unlinkFrBack()->deleteTree(); andp=NULL; notp=NULL;
|
||||
andp->unlinkFrBack()->deleteTree(); VL_DANGLING(andp); VL_DANGLING(notp);
|
||||
// Replace whichever branch is now dangling
|
||||
if (nodep->rhsp()) nodep->lhsp(cp);
|
||||
else nodep->rhsp(cp);
|
||||
@@ -319,7 +320,7 @@ private:
|
||||
&& nodep->lsbConst()==0
|
||||
&& (int)nodep->widthConst()==extendp->lhsp()->width()
|
||||
)) return false;
|
||||
replaceWChild(nodep, extendp->lhsp()); nodep=NULL;
|
||||
replaceWChild(nodep, extendp->lhsp()); VL_DANGLING(nodep);
|
||||
return true;
|
||||
}
|
||||
bool operandSelBiLower(AstSel* nodep) {
|
||||
@@ -338,7 +339,7 @@ private:
|
||||
bip->lhsp(new AstSel(nodep->fileline(), bilhsp, 0, nodep->widthConst()));
|
||||
bip->rhsp(new AstSel(nodep->fileline(), birhsp, 0, nodep->widthConst()));
|
||||
if (debug()>=9) bip->dumpTree(cout,"SEL(BI)-ou:");
|
||||
replaceWChild(nodep, bip); nodep=NULL;
|
||||
replaceWChild(nodep, bip); VL_DANGLING(nodep);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -364,7 +365,7 @@ private:
|
||||
V3Number num (constp->fileline(), subsize);
|
||||
num.opAssign(constp->num());
|
||||
nodep->lhsp(new AstConst(constp->fileline(), num));
|
||||
constp->deleteTree(); constp=NULL;
|
||||
constp->deleteTree(); VL_DANGLING(constp);
|
||||
if (debug()>=9) nodep->dumpTree(cout,"BI(EXTEND)-ou:");
|
||||
return true;
|
||||
}
|
||||
@@ -450,6 +451,9 @@ private:
|
||||
if (!ifvarp || !elsevarp) return false;
|
||||
if (ifvarp->isWide()) return false; // Would need temporaries, so not worth it
|
||||
if (!ifvarp->sameGateTree(elsevarp)) return false;
|
||||
UINFO(1,"HERE "<<nodep<<endl);
|
||||
if (!ifp->rhsp()->gateTree()) return false;
|
||||
if (!elsep->rhsp()->gateTree()) return false;
|
||||
return true;
|
||||
}
|
||||
bool operandIfIf(AstNodeIf* nodep) {
|
||||
@@ -559,58 +563,58 @@ private:
|
||||
if (debug()>5) oldp->dumpTree(cout," const_old: ");
|
||||
if (debug()>5) newp->dumpTree(cout," _new: ");
|
||||
oldp->replaceWith(newp);
|
||||
oldp->deleteTree(); oldp=NULL;
|
||||
oldp->deleteTree(); VL_DANGLING(oldp);
|
||||
}
|
||||
void replaceNum (AstNode* nodep, uint32_t val) {
|
||||
V3Number num (nodep->fileline(), nodep->width(), val);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceNumSigned(AstNodeBiop* nodep, uint32_t val) {
|
||||
// We allow both sides to be constant, as one may have come from parameter propagation, etc.
|
||||
if (m_warn && !(nodep->lhsp()->castConst() && nodep->rhsp()->castConst())) {
|
||||
nodep->v3warn(UNSIGNED,"Comparison is constant due to unsigned arithmetic");
|
||||
}
|
||||
replaceNum(nodep, val); nodep=NULL;
|
||||
replaceNum(nodep, val); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceNumLimited(AstNodeBiop* nodep, uint32_t val) {
|
||||
// Avoids gcc warning about same
|
||||
if (m_warn) nodep->v3warn(CMPCONST,"Comparison is constant due to limited range");
|
||||
replaceNum(nodep, val); nodep=NULL;
|
||||
replaceNum(nodep, val); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceZero(AstNode* nodep) {
|
||||
replaceNum(nodep, 0); nodep=NULL;
|
||||
replaceNum(nodep, 0); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceZeroChkPure(AstNode* nodep, AstNode* checkp) {
|
||||
// For example, "0 * n" -> 0 if n has no side effects
|
||||
// Else strength reduce it to 0 & n.
|
||||
// If ever change the operation note AstAnd rule specially ignores this created pattern
|
||||
if (isTPure(checkp)) {
|
||||
replaceNum(nodep, 0); nodep=NULL;
|
||||
replaceNum(nodep, 0); VL_DANGLING(nodep);
|
||||
} else {
|
||||
AstNode* newp = new AstAnd(nodep->fileline(),
|
||||
new AstConst(nodep->fileline(), 0),
|
||||
checkp->unlinkFrBack());
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
void replaceAllOnes (AstNode* nodep) {
|
||||
V3Number ones (nodep->fileline(), nodep->width(), 0);
|
||||
ones.setMask(nodep->width());
|
||||
replaceNum(nodep, ones); nodep=NULL;
|
||||
replaceNum(nodep, ones); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceConst(AstNodeUniop* nodep) {
|
||||
V3Number num (nodep->fileline(), nodep->width());
|
||||
nodep->numberOperate(num, nodep->lhsp()->castConst()->num());
|
||||
UINFO(4,"UNICONST -> "<<num<<endl);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceConst(AstNodeBiop* nodep) {
|
||||
V3Number num (nodep->fileline(), nodep->width());
|
||||
nodep->numberOperate(num, nodep->lhsp()->castConst()->num(), nodep->rhsp()->castConst()->num());
|
||||
UINFO(4,"BICONST -> "<<num<<endl);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceConst(AstNodeTriop* nodep) {
|
||||
V3Number num (nodep->fileline(), nodep->width());
|
||||
@@ -618,7 +622,7 @@ private:
|
||||
nodep->rhsp()->castConst()->num(),
|
||||
nodep->thsp()->castConst()->num());
|
||||
UINFO(4,"TRICONST -> "<<num<<endl);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void replaceConstString (AstNode* oldp, const string& num) {
|
||||
@@ -628,7 +632,7 @@ private:
|
||||
if (debug()>5) oldp->dumpTree(cout," const_old: ");
|
||||
if (debug()>5) newp->dumpTree(cout," _new: ");
|
||||
oldp->replaceWith(newp);
|
||||
oldp->deleteTree(); oldp=NULL;
|
||||
oldp->deleteTree(); VL_DANGLING(oldp);
|
||||
}
|
||||
//----------------------------------------
|
||||
// Replacement functions.
|
||||
@@ -641,7 +645,7 @@ private:
|
||||
// This may adversly affect the operation of the node being replaced.
|
||||
childp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(childp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
//! Replace a ternary node with its RHS after iterating
|
||||
@@ -775,9 +779,9 @@ private:
|
||||
UINFO(5, "merged two adjacent sel "<<lselp <<" and "<<rselp<< " to one "<<newselp<<endl);
|
||||
|
||||
nodep->replaceWith(newselp);
|
||||
lselp->deleteTree(); lselp = NULL;
|
||||
rselp->deleteTree(); rselp = NULL;
|
||||
nodep->deleteTree(); nodep = NULL;
|
||||
lselp->deleteTree(); VL_DANGLING(lselp);
|
||||
rselp->deleteTree(); VL_DANGLING(rselp);
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceConcatMerge(AstConcat* nodep) {
|
||||
AstNodeBiop* lp = nodep->lhsp()->castNodeBiop();
|
||||
@@ -794,8 +798,8 @@ private:
|
||||
lp->rhsp()->replaceWith(newrp);
|
||||
lp->dtypeChgWidthSigned(newlp->width(), newlp->width(), AstNumeric::fromBool(true));
|
||||
UINFO(5, "merged "<< nodep <<endl);
|
||||
rp->unlinkFrBack()->deleteTree(); rp = NULL;
|
||||
nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); nodep = NULL;
|
||||
rp->unlinkFrBack()->deleteTree(); VL_DANGLING(rp);
|
||||
nodep->replaceWith(lp->unlinkFrBack()); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
lp->lhsp()->accept(*this);
|
||||
lp->rhsp()->accept(*this);
|
||||
} else nodep->v3fatalSrc("tried to merge two Concat which are not adjacent");
|
||||
@@ -808,7 +812,7 @@ private:
|
||||
? (new AstExtendS(nodep->fileline(), arg0p))->castNode()
|
||||
: (new AstExtend (nodep->fileline(), arg0p))->castNode());
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replacePowShift (AstNodeBiop* nodep) { // Pow or PowS
|
||||
UINFO(5,"POW(2,b)->SHIFTL(1,b) "<<nodep<<endl);
|
||||
@@ -818,7 +822,7 @@ private:
|
||||
rhsp);
|
||||
newp->dtypeFrom(nodep);
|
||||
newp->lhsp()->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceMulShift (AstMul* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5,"MUL(2^n,b)->SHIFTL(b,n) "<<nodep<<endl);
|
||||
@@ -827,7 +831,7 @@ private:
|
||||
AstShiftL* newp = new AstShiftL(nodep->fileline(),
|
||||
opp, new AstConst(nodep->fileline(), amount));
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceDivShift (AstDiv* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5,"DIV(b,2^n)->SHIFTR(b,n) "<<nodep<<endl);
|
||||
@@ -836,7 +840,7 @@ private:
|
||||
AstShiftR* newp = new AstShiftR(nodep->fileline(),
|
||||
opp, new AstConst(nodep->fileline(), amount));
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceShiftOp (AstNodeBiop* nodep) {
|
||||
UINFO(5,"SHIFT(AND(a,b),CONST)->AND(SHIFT(a,CONST),SHIFT(b,CONST)) "<<nodep<<endl);
|
||||
@@ -867,8 +871,8 @@ private:
|
||||
int shift1 = shift1p->castConst()->toUInt();
|
||||
int shift2 = shift2p->castConst()->toUInt();
|
||||
int newshift = shift1+shift2;
|
||||
shift1p->deleteTree(); shift1p=NULL;
|
||||
shift2p->deleteTree(); shift2p=NULL;
|
||||
shift1p->deleteTree(); VL_DANGLING(shift1p);
|
||||
shift2p->deleteTree(); VL_DANGLING(shift2p);
|
||||
nodep->lhsp(ap);
|
||||
nodep->rhsp(new AstConst(nodep->fileline(), newshift));
|
||||
nodep->accept(*this); // Further reduce, either node may have more reductions.
|
||||
@@ -877,8 +881,8 @@ private:
|
||||
int shift1 = shift1p->castConst()->toUInt(); if (lhsp->castShiftR()) shift1=-shift1;
|
||||
int shift2 = shift2p->castConst()->toUInt(); if (nodep->castShiftR()) shift2=-shift2;
|
||||
int newshift = shift1+shift2;
|
||||
shift1p->deleteTree(); shift1p=NULL;
|
||||
shift2p->deleteTree(); shift2p=NULL;
|
||||
shift1p->deleteTree(); VL_DANGLING(shift1p);
|
||||
shift2p->deleteTree(); VL_DANGLING(shift2p);
|
||||
AstNode* newp;
|
||||
V3Number mask1 (nodep->fileline(), nodep->width());
|
||||
V3Number ones (nodep->fileline(), nodep->width());
|
||||
@@ -906,11 +910,11 @@ private:
|
||||
newp,
|
||||
new AstConst (nodep->fileline(), mask));
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
//newp->dumpTree(cout, " repShiftShift_new: ");
|
||||
newp->accept(*this); // Further reduce, either node may have more reductions.
|
||||
}
|
||||
lhsp->deleteTree(); lhsp=NULL;
|
||||
lhsp->deleteTree(); VL_DANGLING(lhsp);
|
||||
}
|
||||
|
||||
bool replaceAssignMultiSel(AstNodeAssign* nodep) {
|
||||
@@ -983,7 +987,7 @@ private:
|
||||
nodep->v3error("Wire inputs its own output, creating circular logic (wire x=x)");
|
||||
return false; // Don't delete the assign, or V3Gate will freak out
|
||||
} else {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1079,8 +1083,8 @@ private:
|
||||
if (debug()>=9 && newp) newp->dumpTreeAndNext(cout," _new: ");
|
||||
nodep->addNextHere(newp);
|
||||
// Cleanup
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
conp->deleteTree(); conp=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
conp->deleteTree(); VL_DANGLING(conp);
|
||||
// Further reduce, either node may have more reductions.
|
||||
return true;
|
||||
}
|
||||
@@ -1093,8 +1097,8 @@ private:
|
||||
AstNode* streamp = nodep->rhsp()->castStreamR()->unlinkFrBack();
|
||||
nodep->rhsp(srcp);
|
||||
// Cleanup
|
||||
sizep->deleteTree(); sizep=NULL;
|
||||
streamp->deleteTree(); streamp=NULL;
|
||||
sizep->deleteTree(); VL_DANGLING(sizep);
|
||||
streamp->deleteTree(); VL_DANGLING(streamp);
|
||||
// Further reduce, any of the nodes may have more reductions.
|
||||
return true;
|
||||
}
|
||||
@@ -1137,8 +1141,8 @@ private:
|
||||
nodep->lhsp(dstp);
|
||||
nodep->rhsp(srcp);
|
||||
// Cleanup
|
||||
sizep->deleteTree(); sizep=NULL;
|
||||
streamp->deleteTree(); streamp=NULL;
|
||||
sizep->deleteTree(); VL_DANGLING(sizep);
|
||||
streamp->deleteTree(); VL_DANGLING(streamp);
|
||||
// Further reduce, any of the nodes may have more reductions.
|
||||
return true;
|
||||
}
|
||||
@@ -1171,7 +1175,7 @@ private:
|
||||
fromp);
|
||||
newp->dtypeSetLogicSized(nodep->width(), nodep->width(), AstNumeric::UNSIGNED); // widthMin no longer applicable if different C-expanded width
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
if (debug()>=9) newp->dumpTree(cout," _new: ");
|
||||
}
|
||||
|
||||
@@ -1185,13 +1189,13 @@ private:
|
||||
<<nodep->prettyTypeName()<<endl
|
||||
<<errorp->warnMore()<<"... Location of non-constant "
|
||||
<<errorp->prettyTypeName()<<": "<<simvis.whyNotMessage());
|
||||
replaceZero(nodep); nodep=NULL;
|
||||
replaceZero(nodep); VL_DANGLING(nodep);
|
||||
} else {
|
||||
// Fetch the result
|
||||
V3Number* outnump = simvis.fetchNumberNull(nodep);
|
||||
if (!outnump) nodep->v3fatalSrc("No number returned from simulation");
|
||||
// Replace it
|
||||
replaceNum(nodep,*outnump); nodep=NULL;
|
||||
replaceNum(nodep,*outnump); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1271,7 +1275,7 @@ private:
|
||||
// If bp was a concat, then we have this exact same form again!
|
||||
// Recurse rather then calling node->iterate to prevent 2^n recursion!
|
||||
if (operandConcatMove(abConcp)) moveConcat(abConcp);
|
||||
bcConcp->deleteTree(); bcConcp=NULL;
|
||||
bcConcp->deleteTree(); VL_DANGLING(bcConcp);
|
||||
} else {
|
||||
AstConcat* abConcp = nodep->lhsp()->castConcat(); abConcp->unlinkFrBack();
|
||||
AstNode* ap = abConcp->lhsp()->unlinkFrBack();
|
||||
@@ -1282,7 +1286,7 @@ private:
|
||||
nodep->lhsp(ap);
|
||||
nodep->rhsp(bcConcp);
|
||||
if (operandConcatMove(bcConcp)) moveConcat(bcConcp);
|
||||
abConcp->deleteTree(); abConcp=NULL;
|
||||
abConcp->deleteTree(); VL_DANGLING(abConcp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1313,8 +1317,8 @@ private:
|
||||
if (lsb1p->castConst() && lsb2p->castConst()) {
|
||||
newlsbp = new AstConst(lsb1p->fileline(),
|
||||
lsb1p->castConst()->toUInt() + lsb2p->castConst()->toUInt());
|
||||
lsb1p->deleteTree(); lsb1p=NULL;
|
||||
lsb2p->deleteTree(); lsb2p=NULL;
|
||||
lsb1p->deleteTree(); VL_DANGLING(lsb1p);
|
||||
lsb2p->deleteTree(); VL_DANGLING(lsb2p);
|
||||
} else {
|
||||
// Width is important, we need the width of the fromp's
|
||||
// expression, not the potentially smaller lsb1p's width
|
||||
@@ -1328,7 +1332,7 @@ private:
|
||||
newlsbp,
|
||||
widthp);
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void replaceSelConcat(AstSel* nodep) {
|
||||
@@ -1368,7 +1372,7 @@ private:
|
||||
conRhsp->width()-nodep->lsbConst()));
|
||||
nodep->replaceWith(newp);
|
||||
}
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void replaceSelReplicate(AstSel* nodep) {
|
||||
@@ -1382,7 +1386,7 @@ private:
|
||||
new AstConst(lsbp->fileline(), lsbp->toUInt() % fromp->width()),
|
||||
widthp);
|
||||
newp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void replaceSelIntoBiop(AstSel* nodep) {
|
||||
@@ -1400,7 +1404,7 @@ private:
|
||||
fromp->rhsp(new AstSel(nodep->fileline(),
|
||||
birhsp, lsbp, widthp));
|
||||
fromp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(fromp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(fromp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void replaceSelIntoUniop(AstSel* nodep) {
|
||||
// SEL(NOT(a),1,bit) => NOT(SEL(a,bit))
|
||||
@@ -1414,7 +1418,7 @@ private:
|
||||
fromp->lhsp(new AstSel(nodep->fileline(),
|
||||
bilhsp, lsbp, widthp));
|
||||
fromp->dtypeFrom(nodep);
|
||||
nodep->replaceWith(fromp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(fromp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
virtual void visit(AstAttrOf* nodep, AstNUser*) {
|
||||
@@ -1443,7 +1447,7 @@ private:
|
||||
}
|
||||
m_selp = NULL;
|
||||
}
|
||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||
virtual void visit(AstNodeVarRef* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
if (!nodep->varp()) nodep->v3fatalSrc("Not linked");
|
||||
bool did=false;
|
||||
@@ -1463,7 +1467,7 @@ private:
|
||||
if (operandConst(valuep)) {
|
||||
const V3Number& num = valuep->castConst()->num();
|
||||
//UINFO(2,"constVisit "<<(void*)valuep<<" "<<num<<endl);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
did=true;
|
||||
}
|
||||
else if (m_selp && valuep->castInitArray()) {
|
||||
@@ -1473,7 +1477,7 @@ private:
|
||||
if (itemp->castConst()) {
|
||||
const V3Number& num = itemp->castConst()->num();
|
||||
//UINFO(2,"constVisit "<<(void*)valuep<<" "<<num<<endl);
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
did=true;
|
||||
}
|
||||
}
|
||||
@@ -1492,7 +1496,7 @@ private:
|
||||
nodep->itemp()->valuep()->iterateAndNext(*this);
|
||||
if (AstConst* valuep = nodep->itemp()->valuep()->castConst()) {
|
||||
const V3Number& num = valuep->num();
|
||||
replaceNum(nodep, num); nodep=NULL;
|
||||
replaceNum(nodep, num); VL_DANGLING(nodep);
|
||||
did=true;
|
||||
}
|
||||
}
|
||||
@@ -1519,13 +1523,13 @@ private:
|
||||
if (nodep->isClocked()) { // A constant can never get a pos/negexge
|
||||
if (onlySenItemInSenTree(nodep)) {
|
||||
nodep->replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Never()));
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
} else {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
} else { // Otherwise it may compute a result that needs to settle out
|
||||
nodep->replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Combo()));
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
} else if (m_doNConst && nodep->sensp()->castNot()) {
|
||||
// V3Gate may propagate NOTs into clocks... Just deal with it
|
||||
@@ -1541,7 +1545,7 @@ private:
|
||||
AstNodeVarRef* senvarp = lastSensp->unlinkFrBack()->castNodeVarRef();
|
||||
if (!senvarp) sensp->v3fatalSrc("Non-varref sensitivity variable");
|
||||
sensp->replaceWith(senvarp);
|
||||
sensp->deleteTree(); sensp=NULL;
|
||||
sensp->deleteTree(); VL_DANGLING(sensp);
|
||||
} else if (!m_doNConst // Deal with later when doNConst missing
|
||||
&& (nodep->sensp()->castEnumItemRef()
|
||||
|| nodep->sensp()->castConst())) {
|
||||
@@ -1556,15 +1560,15 @@ private:
|
||||
UINFO(4,"SENGATE(...,0)->NEVER"<<endl);
|
||||
if (onlySenItemInSenTree(nodep)) {
|
||||
nodep->replaceWith(new AstSenItem(nodep->fileline(), AstSenItem::Never()));
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
} else {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
} else {
|
||||
UINFO(4,"SENGATE(SENITEM,0)->ALWAYS SENITEM"<<endl);
|
||||
AstNode* senitemp = nodep->sensesp()->unlinkFrBack();
|
||||
nodep->replaceWith(senitemp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1630,7 +1634,7 @@ private:
|
||||
// Found, push this item up to the top
|
||||
itemp->unlinkFrBack();
|
||||
nodep->addSensesp(itemp);
|
||||
gatep->unlinkFrBack()->deleteTree(); gatep=NULL; senp=NULL;
|
||||
gatep->unlinkFrBack()->deleteTree(); VL_DANGLING(gatep); VL_DANGLING(senp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1686,7 +1690,7 @@ private:
|
||||
&& ritemp->edgeType()==AstEdgeType::ET_NEGEDGE)
|
||||
litemp->edgeType(AstEdgeType::ET_BOTHEDGE);
|
||||
// Remove redundant node
|
||||
ritemp->unlinkFrBack()->deleteTree(); ritemp=NULL; cmpp=NULL;
|
||||
ritemp->unlinkFrBack()->deleteTree(); VL_DANGLING(ritemp); VL_DANGLING(cmpp);
|
||||
// Try to collapse again
|
||||
nextp=litemp;
|
||||
}
|
||||
@@ -1729,7 +1733,7 @@ private:
|
||||
new AstAssign(nodep->fileline(),
|
||||
varrefp, exprp));
|
||||
m_modp->addStmtp(newinitp);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
// Set the initial value right in the variable so we can constant propagate
|
||||
AstNode* initvaluep = exprp->cloneTree(false);
|
||||
varrefp->varp()->valuep(initvaluep);
|
||||
@@ -1754,12 +1758,12 @@ private:
|
||||
} else {
|
||||
nodep->unlinkFrBack();
|
||||
}
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (!afterComment(nodep->ifsp()) && !afterComment(nodep->elsesp())) {
|
||||
// Empty block, remove it
|
||||
// Note if we support more C++ then there might be side effects in the condition itself
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (!afterComment(nodep->ifsp())) {
|
||||
UINFO(4,"IF({x}) NULL {...} => IF(NOT{x}}: "<<nodep<<endl);
|
||||
@@ -1781,7 +1785,7 @@ private:
|
||||
AstIf* ifp = new AstIf(nodep->fileline(), condp, elsesp, ifsp);
|
||||
ifp->branchPred(nodep->branchPred().invert());
|
||||
nodep->replaceWith(ifp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (ifSameAssign(nodep)) {
|
||||
UINFO(4,"IF({a}) ASSIGN({b},{c}) else ASSIGN({b},{d}) => ASSIGN({b}, {a}?{c}:{d})"<<endl);
|
||||
@@ -1794,7 +1798,7 @@ private:
|
||||
ifp->rhsp(new AstCond(truep->fileline(),
|
||||
condp, truep, falsep));
|
||||
nodep->replaceWith(ifp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (0 // Disabled, as vpm assertions are faster without due to short-circuiting
|
||||
&& operandIfIf(nodep)) {
|
||||
@@ -1806,7 +1810,7 @@ private:
|
||||
nodep->condp(new AstLogAnd(lowerIfp->fileline(),
|
||||
condp, lowerCondp));
|
||||
lowerIfp->replaceWith(lowerIfsp);
|
||||
lowerIfp->deleteTree(); lowerIfp=NULL;
|
||||
lowerIfp->deleteTree(); VL_DANGLING(lowerIfp);
|
||||
}
|
||||
else if (operandBoolShift(nodep->condp())) {
|
||||
replaceBoolShift(nodep->condp());
|
||||
@@ -1825,7 +1829,7 @@ private:
|
||||
}
|
||||
if (m_doNConst && anyconst) {
|
||||
//UINFO(9," Display in "<<nodep->text()<<endl);
|
||||
string dispout = "";
|
||||
string newFormat = "";
|
||||
string fmt = "";
|
||||
bool inPct = false;
|
||||
AstNode* argp = nodep->exprsp();
|
||||
@@ -1843,38 +1847,36 @@ private:
|
||||
switch (tolower(ch)) {
|
||||
case '%': break; // %% - just output a %
|
||||
case 'm': break; // %m - auto insert "name"
|
||||
case 'l': break; // %l - auto insert "library"
|
||||
default: // Most operators, just move to next argument
|
||||
if (argp) {
|
||||
AstNode* nextp=argp->nextp();
|
||||
if (argp && argp->castConst()) { // Convert it
|
||||
string out = argp->castConst()->num().displayed(fmt);
|
||||
string out = argp->castConst()->num().displayed(nodep->fileline(), fmt);
|
||||
UINFO(9," DispConst: "<<fmt<<" -> "<<out<<" for "<<argp<<endl);
|
||||
{ // fmt = out w/ replace % with %% as it must be literal.
|
||||
fmt = "";
|
||||
for (string::iterator pos = out.begin(); pos != out.end(); ++pos) {
|
||||
if (*pos == '%') fmt += '%';
|
||||
fmt += *pos;
|
||||
}
|
||||
}
|
||||
// fmt = out w/ replace % with %% as it must be literal.
|
||||
fmt = VString::quotePercent(out);
|
||||
argp->unlinkFrBack()->deleteTree();
|
||||
}
|
||||
argp=nextp;
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
dispout += fmt;
|
||||
newFormat += fmt;
|
||||
} else {
|
||||
dispout += ch;
|
||||
newFormat += ch;
|
||||
}
|
||||
}
|
||||
nodep->text(dispout);
|
||||
//UINFO(9," Display out "<<nodep->text()<<endl);
|
||||
if (newFormat != nodep->text()) {
|
||||
nodep->text(newFormat);
|
||||
UINFO(9," Display out "<<nodep<<endl);
|
||||
}
|
||||
}
|
||||
if (!nodep->exprsp()
|
||||
&& nodep->name().find("%") == string::npos
|
||||
&& !nodep->hidden()) {
|
||||
// Just a simple constant string - the formatting is pointless
|
||||
replaceConstString(nodep, nodep->name()); nodep=NULL;
|
||||
replaceConstString(nodep, nodep->name()); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1895,7 +1897,7 @@ private:
|
||||
UINFO(4,"WHILE(0) => nop "<<nodep<<endl);
|
||||
if (nodep->precondsp()) nodep->replaceWith(nodep->precondsp());
|
||||
else nodep->unlinkFrBack();
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (operandBoolShift(nodep->condp())) {
|
||||
replaceBoolShift(nodep->condp());
|
||||
@@ -1915,7 +1917,7 @@ private:
|
||||
virtual void visit(AstSysIgnore* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
if (m_doNConst) {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1945,7 +1947,7 @@ private:
|
||||
if (nodep->stmtsp()) underp = nodep->stmtsp()->unlinkFrBackWithNext();
|
||||
if (underp) nodep->replaceWith(underp);
|
||||
else nodep->unlinkFrBack();
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2289,7 +2291,7 @@ public:
|
||||
};
|
||||
|
||||
// CONSTUCTORS
|
||||
ConstVisitor(ProcMode pmode) {
|
||||
explicit ConstVisitor(ProcMode pmode) {
|
||||
m_params = false;
|
||||
m_required = false;
|
||||
m_doExpensive = false;
|
||||
|
||||
+3
-3
@@ -87,7 +87,7 @@ private:
|
||||
if (!nodep->isToggleCoverable())
|
||||
return "Not relevant signal type";
|
||||
if (!v3Global.opt.coverageUnderscore()) {
|
||||
if (prettyName.c_str()[0] == '_')
|
||||
if (prettyName[0] == '_')
|
||||
return "Leading underscore";
|
||||
if (prettyName.find("._") != string::npos)
|
||||
return "Inlined leading underscore";
|
||||
@@ -343,7 +343,7 @@ private:
|
||||
// Skip all NEXT nodes under this block, and skip this if/case branch
|
||||
UINFO(4," OFF: "<<nodep<<endl);
|
||||
m_checkBlock = false;
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
} else {
|
||||
if (m_checkBlock) nodep->iterateChildren(*this);
|
||||
}
|
||||
@@ -378,7 +378,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CoverageVisitor(AstNetlist* rootp) {
|
||||
explicit CoverageVisitor(AstNetlist* rootp) {
|
||||
// Operate on all modules
|
||||
m_checkBlock = true;
|
||||
m_beginHier = "";
|
||||
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
UINFO(8," new "<<removep->incp()->declp()<<endl);
|
||||
// Mark the found node as a duplicate of the first node
|
||||
// (Not vice-versa as we have the iterator for the found node)
|
||||
removep->unlinkFrBack(); pushDeletep(removep); removep=NULL;
|
||||
removep->unlinkFrBack(); pushDeletep(removep); VL_DANGLING(removep);
|
||||
// Remove node from comparison so don't hit it again
|
||||
hashed.erase(dupit);
|
||||
++m_statToggleJoins;
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
CoverageJoinVisitor(AstNetlist* nodep) {
|
||||
explicit CoverageJoinVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~CoverageJoinVisitor() {
|
||||
|
||||
+4
-4
@@ -58,7 +58,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
DeadModVisitor(AstNodeModule* nodep) {
|
||||
explicit DeadModVisitor(AstNodeModule* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~DeadModVisitor() {}
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
// And its children may now be killable too; correct counts
|
||||
// Recurse, as cells may not be directly under the module but in a generate
|
||||
DeadModVisitor visitor(modp);
|
||||
modp->unlinkFrBack()->deleteTree(); modp=NULL;
|
||||
modp->unlinkFrBack()->deleteTree(); VL_DANGLING(modp);
|
||||
retry = true;
|
||||
}
|
||||
}
|
||||
@@ -252,9 +252,9 @@ private:
|
||||
for (AssignMap::iterator it = eqrange.first; it != eqrange.second; ++it) {
|
||||
AstNodeAssign* assp = it->second;
|
||||
UINFO(4," Dead assign "<<assp<<endl);
|
||||
assp->unlinkFrBack()->deleteTree(); assp=NULL;
|
||||
assp->unlinkFrBack()->deleteTree(); VL_DANGLING(assp);
|
||||
}
|
||||
vscp->unlinkFrBack()->deleteTree(); vscp=NULL;
|
||||
vscp->unlinkFrBack()->deleteTree(); VL_DANGLING(vscp);
|
||||
}
|
||||
}
|
||||
for (vector<AstNode*>::iterator it = m_varEtcsp.begin(); it!=m_varEtcsp.end(); ++it) {
|
||||
|
||||
+4
-4
@@ -374,9 +374,9 @@ private:
|
||||
if (newlhsp) {
|
||||
nodep->lhsp(newlhsp);
|
||||
} else {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
lhsp->deleteTree(); lhsp=NULL;
|
||||
lhsp->deleteTree(); VL_DANGLING(lhsp);
|
||||
}
|
||||
else {
|
||||
nodep->iterateChildren(*this);
|
||||
@@ -420,7 +420,7 @@ private:
|
||||
}
|
||||
AstVarRef* newrefp = new AstVarRef(nodep->fileline(), dlyvscp, true);
|
||||
newrefp->user2(true); // No reason to do it again
|
||||
nodep->replaceWith(newrefp); nodep->deleteTree(); nodep=NULL;
|
||||
nodep->replaceWith(newrefp); nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (!m_inDly && nodep->lvalue()) {
|
||||
//UINFO(9,"NBA "<<nodep<<endl);
|
||||
@@ -450,7 +450,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
DelayedVisitor(AstNetlist* nodep) {
|
||||
explicit DelayedVisitor(AstNetlist* nodep) {
|
||||
m_inDly = false;
|
||||
m_activep=NULL;
|
||||
m_cfuncp=NULL;
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
DepthVisitor(AstNetlist* nodep) {
|
||||
explicit DepthVisitor(AstNetlist* nodep) {
|
||||
m_modp=NULL;
|
||||
m_funcp=NULL;
|
||||
m_stmtp=NULL;
|
||||
|
||||
@@ -125,7 +125,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
DepthBlockVisitor(AstNetlist* nodep) {
|
||||
explicit DepthBlockVisitor(AstNetlist* nodep) {
|
||||
m_modp=NULL;
|
||||
m_depth=0;
|
||||
//
|
||||
|
||||
+1
-1
@@ -247,7 +247,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
DescopeVisitor(AstNetlist* nodep) {
|
||||
explicit DescopeVisitor(AstNetlist* nodep) {
|
||||
m_modp = NULL;
|
||||
m_scopep = NULL;
|
||||
m_needThis = false;
|
||||
|
||||
+16
-14
@@ -295,6 +295,7 @@ public:
|
||||
case 'h': // FALLTHRU
|
||||
case 'x': // FALLTHRU
|
||||
case 'b': // FALLTHRU
|
||||
case 'v': // FALLTHRU
|
||||
case 's':
|
||||
got++; format = tolower(ch);
|
||||
break;
|
||||
@@ -656,7 +657,7 @@ public:
|
||||
}
|
||||
} else if (nodep->isQuad()) {
|
||||
vluint64_t num = nodep->toUQuad();
|
||||
if (num<10) ofp()->printf("VL_ULL(%" VL_PRI64 "d)", num);
|
||||
if (num<10) ofp()->printf("VL_ULL(%" VL_PRI64 "u)", num);
|
||||
else ofp()->printf("VL_ULL(0x%" VL_PRI64 "x)", num);
|
||||
} else {
|
||||
uint32_t num = nodep->toUInt();
|
||||
@@ -1273,17 +1274,18 @@ void EmitCStmts::displayArg(AstNode* dispp, AstNode** elistp, bool isScan,
|
||||
dispp->v3error("Exceeded limit of "+cvtToStr(VL_VALUE_STRING_MAX_WIDTH)+" bits for any $display-like arguments");
|
||||
}
|
||||
if (argp && argp->isWide()
|
||||
&& (fmtLetter=='d'||fmtLetter=='u')) {
|
||||
&& (fmtLetter=='d'||fmtLetter=='#')) {
|
||||
argp->v3error("Unsupported: "<<dispp->verilogKwd()<<" of dec format of > 64 bit results (use hex format instead)");
|
||||
}
|
||||
if (argp && argp->widthMin()>8 && fmtLetter=='c') {
|
||||
// Technically legal, but surely not what the user intended.
|
||||
argp->v3error(dispp->verilogKwd()<<" of char format of > 8 bit result");
|
||||
argp->v3warn(WIDTH,dispp->verilogKwd()<<"of %c format of > 8 bit value");
|
||||
|
||||
}
|
||||
|
||||
//string pfmt = "%"+displayFormat(argp, vfmt, fmtLetter)+fmtLetter;
|
||||
string pfmt;
|
||||
if ((fmtLetter=='u' || fmtLetter=='d' || fmtLetter=='t')
|
||||
if ((fmtLetter=='#' || fmtLetter=='d' || fmtLetter=='t')
|
||||
&& !isScan
|
||||
&& vfmt == "") { // Size decimal output. Spec says leading spaces, not zeros
|
||||
double mantissabits = argp->widthMin() - ((fmtLetter=='d')?1:0);
|
||||
@@ -1341,14 +1343,15 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep,
|
||||
case 'b': displayArg(nodep,&elistp,isScan, vfmt,'b'); break;
|
||||
case 'c': displayArg(nodep,&elistp,isScan, vfmt,'c'); break;
|
||||
case 't': displayArg(nodep,&elistp,isScan, vfmt,'t'); break;
|
||||
case 'd': displayArg(nodep,&elistp,isScan, vfmt,'u'); break; // Unsigned decimal
|
||||
case 'd': displayArg(nodep,&elistp,isScan, vfmt,'#'); break; // Unsigned decimal
|
||||
case 'o': displayArg(nodep,&elistp,isScan, vfmt,'o'); break;
|
||||
case 'h':
|
||||
case 'h': //FALLTHRU
|
||||
case 'x': displayArg(nodep,&elistp,isScan, vfmt,'x'); break;
|
||||
case 's': displayArg(nodep,&elistp,isScan, vfmt,'s'); break;
|
||||
case 'e': displayArg(nodep,&elistp,isScan, vfmt,'e'); break;
|
||||
case 'f': displayArg(nodep,&elistp,isScan, vfmt,'f'); break;
|
||||
case 'g': displayArg(nodep,&elistp,isScan, vfmt,'g'); break;
|
||||
case 'v': displayArg(nodep,&elistp,isScan, vfmt,'v'); break;
|
||||
case 'm': {
|
||||
if (!scopenamep) nodep->v3fatalSrc("Display with %m but no AstScopeName");
|
||||
string suffix = scopenamep->scopePrettySymName();
|
||||
@@ -1358,12 +1361,11 @@ void EmitCStmts::displayNode(AstNode* nodep, AstScopeName* scopenamep,
|
||||
emitDispState.pushFormat(suffix);
|
||||
break;
|
||||
}
|
||||
case 'u':
|
||||
case 'z':
|
||||
case 'l':
|
||||
case 'v':
|
||||
nodep->v3error("Unsupported: $display-like format code: %"<<pos[0]);
|
||||
case 'l': {
|
||||
// Better than not compiling
|
||||
emitDispState.pushFormat("----");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
nodep->v3error("Unknown $display-like format code: %"<<pos[0]);
|
||||
break;
|
||||
@@ -1560,7 +1562,7 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) {
|
||||
puts("void "+modClassName(modp)+"::"+funcname+"("+classname+"& os) {\n");
|
||||
// Place a computed checksum to insure proper structure save/restore formatting
|
||||
// OK if this hash includes some things we won't dump, since just looking for loading the wrong model
|
||||
VHashFnv hash;
|
||||
VHashSha1 hash;
|
||||
for (AstNode* nodep=modp->stmtsp(); nodep; nodep = nodep->nextp()) {
|
||||
if (AstVar* varp = nodep->castVar()) {
|
||||
hash.insert(varp->name());
|
||||
@@ -1785,7 +1787,7 @@ void EmitCStmts::emitVarList(AstNode* firstp, EisWhich which, const string& pref
|
||||
}
|
||||
}
|
||||
}
|
||||
ofp()->putAlign(isstatic, 4, 0, prefixIfImp.c_str());
|
||||
ofp()->putAlign(isstatic, 4, 0, prefixIfImp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2434,7 +2436,7 @@ class EmitCTrace : EmitCStmts {
|
||||
}
|
||||
|
||||
public:
|
||||
EmitCTrace(bool slow) {
|
||||
explicit EmitCTrace(bool slow) {
|
||||
m_funcp = NULL;
|
||||
m_slow = slow;
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
EmitCBaseCounterVisitor(AstNode* nodep) {
|
||||
explicit EmitCBaseCounterVisitor(AstNode* nodep) {
|
||||
m_count = 0;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class EmitCInlines : EmitCBaseVisitor {
|
||||
//---------------------------------------
|
||||
// ACCESSORS
|
||||
public:
|
||||
EmitCInlines(AstNetlist* nodep) {
|
||||
explicit EmitCInlines(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
if (v3Global.needHInlines()) {
|
||||
emitInt();
|
||||
|
||||
+1
-1
@@ -244,7 +244,7 @@ class EmitCSyms : EmitCBaseVisitor {
|
||||
//---------------------------------------
|
||||
// ACCESSORS
|
||||
public:
|
||||
EmitCSyms(AstNetlist* nodep) {
|
||||
explicit EmitCSyms(AstNetlist* nodep) {
|
||||
m_funcp = NULL;
|
||||
m_modp = NULL;
|
||||
m_coverBins = 0;
|
||||
|
||||
+4
-1
@@ -81,6 +81,9 @@ public:
|
||||
if (v3Global.dpi()) {
|
||||
putMakeClassEntry(of, "verilated_dpi.cpp");
|
||||
}
|
||||
if (v3Global.opt.vpi()) {
|
||||
putMakeClassEntry(of, "verilated_vpi.cpp");
|
||||
}
|
||||
if (v3Global.opt.savable()) {
|
||||
putMakeClassEntry(of, "verilated_save.cpp");
|
||||
}
|
||||
@@ -231,7 +234,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
EmitMkVisitor(AstNetlist*) {
|
||||
explicit EmitMkVisitor(AstNetlist*) {
|
||||
emitClassMake();
|
||||
emitOverallMake();
|
||||
}
|
||||
|
||||
+1
-1
@@ -589,7 +589,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
|
||||
}
|
||||
|
||||
public:
|
||||
EmitVBaseVisitor(AstSenTree* domainp=NULL) { // Domain for printing one a ALWAYS under a ACTIVE
|
||||
explicit EmitVBaseVisitor(AstSenTree* domainp=NULL) { // Domain for printing one a ALWAYS under a ACTIVE
|
||||
m_suppressSemi = false;
|
||||
m_sensesp = domainp;
|
||||
}
|
||||
|
||||
+7
-1
@@ -96,6 +96,10 @@ public:
|
||||
UNPACKED, // Unsupported unpacked
|
||||
UNSIGNED, // Comparison is constant due to unsigned arithmetic
|
||||
UNUSED, // No receivers
|
||||
USERERROR, // Elaboration time $error
|
||||
USERFATAL, // Elaboration time $fatal
|
||||
USERINFO, // Elaboration time $info
|
||||
USERWARN, // Elaboration time $warning
|
||||
VARHIDDEN, // Hiding variable
|
||||
WIDTH, // Width mismatch
|
||||
WIDTHCONCAT, // Unsized numbers/parameters in concatenations
|
||||
@@ -104,8 +108,9 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline V3ErrorCode () : m_e(EC_MIN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline V3ErrorCode (en _e) : m_e(_e) {}
|
||||
V3ErrorCode (const char* msgp); // Matching code or ERROR
|
||||
explicit V3ErrorCode (const char* msgp); // Matching code or ERROR
|
||||
explicit inline V3ErrorCode (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
const char* ascii() const {
|
||||
@@ -131,6 +136,7 @@ public:
|
||||
"REALCVT", "REDEFMACRO",
|
||||
"SELRANGE", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
|
||||
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNPACKED", "UNSIGNED", "UNUSED",
|
||||
"USERERROR", "USERFATAL", "USERINFO", "USERWARN",
|
||||
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
|
||||
" MAX"
|
||||
};
|
||||
|
||||
+17
-17
@@ -86,7 +86,7 @@ private:
|
||||
void replaceWithDelete (AstNode* nodep, AstNode* newp) {
|
||||
newp->user1(1); // Already processed, don't need to re-iterate
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
AstNode* newWordAssign (AstNodeAssign* placep, int word, AstNode* lhsp, AstNode* rhsp) {
|
||||
AstAssign* newp = new AstAssign (placep->fileline(),
|
||||
@@ -332,7 +332,7 @@ private:
|
||||
lhsp->dtypeFrom(nodep); // Just mark it, else nop
|
||||
}
|
||||
}
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
bool expandWide (AstNodeAssign* nodep, AstExtend* rhsp) {
|
||||
@@ -438,7 +438,7 @@ private:
|
||||
if (midp) newp = new AstOr (nodep->fileline(), midp, newp);
|
||||
if (hip) newp = new AstOr (nodep->fileline(), hip, newp);
|
||||
newp->dtypeFrom(nodep);
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
else { // Long/Quad from Long/Quad
|
||||
UINFO(8," SEL->SHIFT "<<nodep<<endl);
|
||||
@@ -454,7 +454,7 @@ private:
|
||||
newp = new AstCCast (newp->fileline(), newp, nodep);
|
||||
}
|
||||
newp->dtypeFrom(nodep);
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,8 +541,8 @@ private:
|
||||
rhsp, lsb)));
|
||||
}
|
||||
}
|
||||
rhsp->deleteTree(); rhsp=NULL;
|
||||
destp->deleteTree(); destp=NULL;
|
||||
rhsp->deleteTree(); VL_DANGLING(rhsp);
|
||||
destp->deleteTree(); VL_DANGLING(destp);
|
||||
} else {
|
||||
UINFO(8," ASSIGNSEL(const,narrow) "<<nodep<<endl);
|
||||
if (destp->isQuad() && !rhsp->isQuad()) rhsp = new AstCCast(nodep->fileline(), rhsp, nodep);
|
||||
@@ -667,7 +667,7 @@ private:
|
||||
nodep->width()),
|
||||
rhsp);
|
||||
newp->dtypeFrom(nodep); // Unsigned
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
bool expandWide (AstNodeAssign* nodep, AstConcat* rhsp) {
|
||||
@@ -720,7 +720,7 @@ private:
|
||||
lhsp->deleteTree(); // Never used
|
||||
}
|
||||
newp->dtypeFrom(nodep); // Unsigned
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
bool expandWide (AstNodeAssign* nodep, AstReplicate* rhsp) {
|
||||
@@ -761,7 +761,7 @@ private:
|
||||
newAstWordSelClone (nodep->rhsp(), w));
|
||||
newp = (newp==NULL) ? eqp : (new AstOr (nodep->fileline(), newp, eqp));
|
||||
}
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
void visitEqNeq(AstNodeBiop* nodep) {
|
||||
@@ -784,7 +784,7 @@ private:
|
||||
newp = new AstEq (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), 0), newp);
|
||||
}
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstEq* nodep, AstNUser*) { visitEqNeq (nodep); }
|
||||
@@ -803,7 +803,7 @@ private:
|
||||
}
|
||||
newp = new AstNeq (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), 0), newp);
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
} else {
|
||||
UINFO(8," REDOR->EQ "<<nodep<<endl);
|
||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||
@@ -811,7 +811,7 @@ private:
|
||||
AstNode* newp = new AstNeq (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), zero),
|
||||
lhsp);
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstRedAnd* nodep, AstNUser*) {
|
||||
@@ -833,14 +833,14 @@ private:
|
||||
}
|
||||
newp = new AstEq (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), ~0), newp);
|
||||
replaceWithDelete(nodep, newp); nodep=NULL;
|
||||
replaceWithDelete(nodep, newp); VL_DANGLING(nodep);
|
||||
} else {
|
||||
UINFO(8," REDAND->EQ "<<nodep<<endl);
|
||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||
AstNode* newp = new AstEq (nodep->fileline(),
|
||||
new AstConst (nodep->fileline(), wordMask(lhsp)),
|
||||
lhsp);
|
||||
replaceWithDelete(nodep,newp); nodep=NULL;
|
||||
replaceWithDelete(nodep,newp); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstRedXor* nodep, AstNUser*) {
|
||||
@@ -856,7 +856,7 @@ private:
|
||||
}
|
||||
newp = new AstRedXor (nodep->fileline(), newp);
|
||||
UINFO(8," Wordize REDXORnew "<<newp<<endl);
|
||||
replaceWithDelete(nodep, newp); nodep=NULL;
|
||||
replaceWithDelete(nodep, newp); VL_DANGLING(nodep);
|
||||
}
|
||||
// We don't reduce non-wide XORs, as its more efficient to use a temp register,
|
||||
// which the inlined function does nicely.
|
||||
@@ -907,7 +907,7 @@ private:
|
||||
}
|
||||
// Cleanup common code
|
||||
if (did) {
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
m_stmtp = NULL;
|
||||
}
|
||||
@@ -921,7 +921,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ExpandVisitor(AstNetlist* nodep) {
|
||||
explicit ExpandVisitor(AstNetlist* nodep) {
|
||||
m_stmtp=NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
+15
-13
@@ -185,7 +185,7 @@ inline void V3FileDependImp::writeTimes(const string& filename, const string& cm
|
||||
}
|
||||
|
||||
inline bool V3FileDependImp::checkTimes(const string& filename, const string& cmdlineIn) {
|
||||
const auto_ptr<ifstream> ifp (V3File::new_ifstream_nodepend(filename));
|
||||
const VL_UNIQUE_PTR<ifstream> ifp (V3File::new_ifstream_nodepend(filename));
|
||||
if (ifp->fail()) {
|
||||
UINFO(2," --check-times failed: no input "<<filename<<endl);
|
||||
return false;
|
||||
@@ -363,6 +363,7 @@ private:
|
||||
}
|
||||
return out;
|
||||
}
|
||||
// cppcheck-suppress unusedFunction unusedPrivateFunction
|
||||
string readFilterLine() {
|
||||
// Slow, but we don't need it much
|
||||
UINFO(9,"readFilterLine\n");
|
||||
@@ -380,6 +381,7 @@ private:
|
||||
UINFO(6,"filter-line-in: "<<line);
|
||||
return line;
|
||||
}
|
||||
// cppcheck-suppress unusedFunction unusedPrivateFunction
|
||||
void writeFilter(const string& out) {
|
||||
if (debug()>=6) { UINFO(6,"filter-out: "<<out); if (out[out.length()-1]!='\n') cout<<endl; }
|
||||
if (!m_pid) { v3error("--pipe-filter: write to closed file\n"); m_readEof = true; stop(); }
|
||||
@@ -521,7 +523,7 @@ protected:
|
||||
return out;
|
||||
}
|
||||
// CONSTRUCTORS
|
||||
V3InFilterImp(const string& command) {
|
||||
explicit V3InFilterImp(const string& command) {
|
||||
m_readEof = false;
|
||||
m_pid = 0;
|
||||
m_pidExited = false;
|
||||
@@ -549,7 +551,7 @@ bool V3InFilter::readWholefile(const string& filename, V3InFilter::StrList& outl
|
||||
// V3OutFormatter: A class for printing to a file, with automatic indentation of C++ code.
|
||||
|
||||
V3OutFormatter::V3OutFormatter(const string& filename, V3OutFormatter::Language lang)
|
||||
: m_filename(filename), m_lang(lang)
|
||||
: m_filename(filename), m_lang(lang), m_blockIndent(4)
|
||||
, m_lineno(1), m_column(0)
|
||||
, m_nobreak(false), m_prependIndent(true), m_indentLevel(0)
|
||||
, m_declSAlign(0), m_declNSAlign(0), m_declPadNum(0) {
|
||||
@@ -617,7 +619,7 @@ int V3OutFormatter::endLevels (const char *strg) {
|
||||
// label/public/private: Deindent by 2 spaces
|
||||
const char* mp=cp;
|
||||
for (; isalnum(*mp); mp++) ;
|
||||
if (mp[0]==':' && mp[1]!=':') return (levels-INDBLK/2);
|
||||
if (mp[0]==':' && mp[1]!=':') return (levels-m_blockIndent/2);
|
||||
}
|
||||
|
||||
// We want "} else {" to be one level to the left of normal
|
||||
@@ -625,16 +627,16 @@ int V3OutFormatter::endLevels (const char *strg) {
|
||||
switch (*cp) {
|
||||
case '}':
|
||||
case ')':
|
||||
levels-=INDBLK;
|
||||
levels-=m_blockIndent;
|
||||
break;
|
||||
case '<':
|
||||
if (m_lang==LA_XML) {
|
||||
if (cp[1] == '/') levels-=INDBLK;
|
||||
if (cp[1] == '/') levels-=m_blockIndent;
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
if (m_lang==LA_VERILOG && tokenEnd(cp)) {
|
||||
levels-=INDBLK;
|
||||
levels-=m_blockIndent;
|
||||
}
|
||||
break;
|
||||
case '\t':
|
||||
@@ -748,19 +750,19 @@ void V3OutFormatter::putBreak () {
|
||||
}
|
||||
}
|
||||
|
||||
void V3OutFormatter::putsQuoted(const char* strg) {
|
||||
void V3OutFormatter::putsQuoted(const string& strg) {
|
||||
// Quote \ and " for use inside C programs
|
||||
// Don't use to quote a filename for #include - #include doesn't \ escape.
|
||||
putcNoTracking('"');
|
||||
string quoted = V3Number::quoteNameControls(strg);
|
||||
for (const char* cp=quoted.c_str(); *cp; cp++) {
|
||||
putcNoTracking (*cp);
|
||||
for (string::const_iterator cp=quoted.begin(); cp!=quoted.end(); ++cp) {
|
||||
putcNoTracking (*cp);
|
||||
}
|
||||
putcNoTracking('"');
|
||||
}
|
||||
void V3OutFormatter::putsNoTracking (const char *strg) {
|
||||
void V3OutFormatter::putsNoTracking (const string& strg) {
|
||||
// Don't track {}'s, probably because it's a $display format string
|
||||
for (const char* cp=strg; *cp; cp++) {
|
||||
for (string::const_iterator cp=strg.begin(); cp!=strg.end(); ++cp) {
|
||||
putcNoTracking (*cp);
|
||||
}
|
||||
}
|
||||
@@ -789,7 +791,7 @@ void V3OutFormatter::putcNoTracking (char chr) {
|
||||
putcOutput (chr);
|
||||
}
|
||||
|
||||
void V3OutFormatter::putAlign (bool/*AlignClass*/ isStatic, int align, int size, const char* prefix) {
|
||||
void V3OutFormatter::putAlign (bool/*AlignClass*/ isStatic, int align, int size, const string& prefix) {
|
||||
if (size==0) size=align;
|
||||
int alignSize = size; if (alignSize>8) alignSize=8;
|
||||
int& alignr = isStatic ? m_declSAlign : m_declNSAlign;
|
||||
|
||||
+20
-17
@@ -77,6 +77,7 @@ class V3InFilterImp;
|
||||
|
||||
class V3InFilter {
|
||||
V3InFilterImp* m_impp;
|
||||
V3InFilter(const V3InFilter&); ///< N/A, no copy constructor
|
||||
public:
|
||||
// TYPES
|
||||
typedef list<string> StrList;
|
||||
@@ -86,7 +87,7 @@ public:
|
||||
bool readWholefile(const string& filename, StrList& outl);
|
||||
|
||||
// CONSTRUCTORS
|
||||
V3InFilter(const string& command);
|
||||
explicit V3InFilter(const string& command);
|
||||
~V3InFilter();
|
||||
};
|
||||
|
||||
@@ -96,7 +97,6 @@ public:
|
||||
class V3OutFormatter {
|
||||
// TYPES
|
||||
enum MiscConsts {
|
||||
INDBLK = 4, // Indentation per block level
|
||||
WIDTH = 50, // Width after which to break at ,'s
|
||||
MAXSPACE = 80}; // After this indent, stop indenting more
|
||||
public:
|
||||
@@ -114,6 +114,7 @@ private:
|
||||
// MEMBERS
|
||||
string m_filename;
|
||||
Language m_lang; // Indenting Verilog code
|
||||
int m_blockIndent; // Characters per block indent
|
||||
int m_lineno;
|
||||
int m_column;
|
||||
int m_nobreak; // Basic operator or begin paren, don't break next
|
||||
@@ -132,29 +133,29 @@ public:
|
||||
V3OutFormatter(const string& filename, Language lang);
|
||||
virtual ~V3OutFormatter() {}
|
||||
// ACCESSORS
|
||||
int column() const { return m_column; }
|
||||
int column() const { return m_column; }
|
||||
int blockIndent() const { return m_blockIndent; }
|
||||
void blockIndent(int flag) { m_blockIndent=flag; }
|
||||
// METHODS
|
||||
void printf(const char* fmt...) VL_ATTR_PRINTF(2);
|
||||
void puts(const char* strg);
|
||||
void puts(const string& strg) { puts(strg.c_str()); }
|
||||
void putsNoTracking(const char* strg);
|
||||
void putsNoTracking(const string& strg) { putsNoTracking(strg.c_str()); }
|
||||
void putsQuoted(const char* strg);
|
||||
void putsQuoted(const string& strg) { putsQuoted(strg.c_str()); }
|
||||
void putsNoTracking(const string& strg);
|
||||
void putsQuoted(const string& strg);
|
||||
void putBreak(); // Print linebreak if line is too wide
|
||||
void putBreakExpr(); // Print linebreak in expression if line is too wide
|
||||
void putAlign(bool isstatic/*AlignClass*/, int align, int size=0/*=align*/, const char* prefix=""); // Declare a variable, with natural alignment
|
||||
void putAlign(bool isstatic/*AlignClass*/, int align, int size=0/*=align*/, const string& prefix=""); // Declare a variable, with natural alignment
|
||||
void putbs(const char* strg) { putBreakExpr(); puts(strg); }
|
||||
void putbs(const string& strg) { putBreakExpr(); puts(strg); }
|
||||
bool exceededWidth() const { return m_column > WIDTH; }
|
||||
bool tokenStart(const char* cp, const char* cmp);
|
||||
bool tokenEnd(const char* cp);
|
||||
void indentInc() { m_indentLevel += INDBLK; }
|
||||
void indentInc() { m_indentLevel += m_blockIndent; }
|
||||
void indentDec() {
|
||||
m_indentLevel -= INDBLK;
|
||||
m_indentLevel -= m_blockIndent;
|
||||
UASSERT(m_indentLevel>=0, ": "<<m_filename<<": Underflow of indentation\n");
|
||||
}
|
||||
void blockInc() { m_parenVec.push(m_indentLevel + INDBLK); }
|
||||
void blockInc() { m_parenVec.push(m_indentLevel + m_blockIndent); }
|
||||
void blockDec() { if (!m_parenVec.empty()) m_parenVec.pop(); }
|
||||
// STATIC METHODS
|
||||
static const string indentSpaces(int levels);
|
||||
@@ -183,7 +184,7 @@ private:
|
||||
class V3OutCFile : public V3OutFile {
|
||||
int m_private;
|
||||
public:
|
||||
V3OutCFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_C) {
|
||||
explicit V3OutCFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_C) {
|
||||
resetPrivate();
|
||||
}
|
||||
virtual ~V3OutCFile() {}
|
||||
@@ -208,7 +209,7 @@ public:
|
||||
|
||||
class V3OutScFile : public V3OutCFile {
|
||||
public:
|
||||
V3OutScFile(const string& filename) : V3OutCFile(filename) {}
|
||||
explicit V3OutScFile(const string& filename) : V3OutCFile(filename) {}
|
||||
virtual ~V3OutScFile() {}
|
||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||
virtual void putsIntTopInclude() {
|
||||
@@ -219,7 +220,7 @@ public:
|
||||
|
||||
class V3OutSpFile : public V3OutCFile {
|
||||
public:
|
||||
V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
|
||||
explicit V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
|
||||
virtual ~V3OutSpFile() {}
|
||||
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
|
||||
virtual void putsIntTopInclude() {
|
||||
@@ -230,21 +231,23 @@ public:
|
||||
|
||||
class V3OutVFile : public V3OutFile {
|
||||
public:
|
||||
V3OutVFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_VERILOG) {}
|
||||
explicit V3OutVFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_VERILOG) {}
|
||||
virtual ~V3OutVFile() {}
|
||||
virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); }
|
||||
};
|
||||
|
||||
class V3OutXmlFile : public V3OutFile {
|
||||
public:
|
||||
V3OutXmlFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_XML) {}
|
||||
explicit V3OutXmlFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_XML) {
|
||||
blockIndent(2);
|
||||
}
|
||||
virtual ~V3OutXmlFile() {}
|
||||
virtual void putsHeader() { puts("<?xml version=\"1.0\" ?>\n"); }
|
||||
};
|
||||
|
||||
class V3OutMkFile : public V3OutFile {
|
||||
public:
|
||||
V3OutMkFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_MK) {}
|
||||
explicit V3OutMkFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_MK) {}
|
||||
virtual ~V3OutMkFile() {}
|
||||
virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); }
|
||||
// No automatic indentation yet.
|
||||
|
||||
+2
-2
@@ -102,9 +102,9 @@ public:
|
||||
FileLine (const string& filename, int lineno) {
|
||||
m_lineno=lineno; m_filenameno = singleton().nameToNumber(filename);
|
||||
m_warnOn=defaultFileLine().m_warnOn; }
|
||||
FileLine (FileLine* fromp) {
|
||||
explicit FileLine (FileLine* fromp) {
|
||||
m_lineno=fromp->m_lineno; m_filenameno = fromp->m_filenameno; m_warnOn=fromp->m_warnOn; }
|
||||
FileLine (EmptySecret);
|
||||
explicit FileLine (EmptySecret);
|
||||
~FileLine() { }
|
||||
FileLine* create(const string& filename, int lineno) { return new FileLine(filename,lineno); }
|
||||
FileLine* create(int lineno) { return create(filename(), lineno); }
|
||||
|
||||
+18
-18
@@ -496,7 +496,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
GateVisitor(AstNode* nodep) {
|
||||
explicit GateVisitor(AstNode* nodep) {
|
||||
AstNode::user1ClearTree();
|
||||
m_logicVertexp = NULL;
|
||||
m_scopep = NULL;
|
||||
@@ -617,7 +617,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
|
||||
varvertexp->propagateAttrClocksFrom(vvertexp);
|
||||
}
|
||||
// Remove the edge
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
++m_statRefs;
|
||||
edgep = vvertexp->outBeginp();
|
||||
}
|
||||
@@ -625,7 +625,7 @@ void GateVisitor::optimizeSignals(bool allowMultiIn) {
|
||||
if (removedAllUsages) {
|
||||
// Remove input links
|
||||
while (V3GraphEdge* edgep = vvertexp->inBeginp()) {
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
}
|
||||
// Clone tree so we remember it for tracing, and keep the pointer
|
||||
// to the "ALWAYS" part of the tree as part of this statement
|
||||
@@ -678,25 +678,25 @@ void GateVisitor::replaceAssigns() {
|
||||
if (vscp->valuep() && !vscp->valuep()->castNodeMath()) {
|
||||
//if (debug()>9) vscp->dumpTree(cout, "-vscPre: ");
|
||||
while (AstNode* delp=vscp->valuep()->castComment()) {
|
||||
delp->unlinkFrBack()->deleteTree(); delp=NULL;
|
||||
delp->unlinkFrBack()->deleteTree(); VL_DANGLING(delp);
|
||||
}
|
||||
if (AstInitial* delp=vscp->valuep()->castInitial()) {
|
||||
AstNode* bodyp=delp->bodysp();
|
||||
bodyp->unlinkFrBackWithNext();
|
||||
delp->replaceWith(bodyp);
|
||||
delp->deleteTree(); delp=NULL;
|
||||
delp->deleteTree(); VL_DANGLING(delp);
|
||||
}
|
||||
if (AstAlways* delp=vscp->valuep()->castAlways()) {
|
||||
AstNode* bodyp=delp->bodysp();
|
||||
bodyp->unlinkFrBackWithNext();
|
||||
delp->replaceWith(bodyp);
|
||||
delp->deleteTree(); delp=NULL;
|
||||
delp->deleteTree(); VL_DANGLING(delp);
|
||||
}
|
||||
if (AstNodeAssign* delp=vscp->valuep()->castNodeAssign()) {
|
||||
AstNode* rhsp=delp->rhsp();
|
||||
rhsp->unlinkFrBack();
|
||||
delp->replaceWith(rhsp);
|
||||
delp->deleteTree(); delp=NULL;
|
||||
delp->deleteTree(); VL_DANGLING(delp);
|
||||
}
|
||||
//if (debug()>9) {vscp->dumpTree(cout, "-vscDone: "); cout<<endl;}
|
||||
if (!vscp->valuep()->castNodeMath()
|
||||
@@ -749,7 +749,7 @@ void GateVisitor::consumedMove() {
|
||||
// Eventually: Move the statement to a new active block with "tracing-on" sensitivity
|
||||
UINFO(8," Remove unconsumed "<<nodep<<endl);
|
||||
nodep->unlinkFrBack();
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -817,7 +817,7 @@ private:
|
||||
// Make the substp an rvalue like nodep. This facilitate the hashing in dedupe.
|
||||
if (AstNodeVarRef* varrefp = substp->castNodeVarRef()) varrefp->lvalue(false);
|
||||
nodep->replaceWith(substp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
@@ -1039,7 +1039,7 @@ private:
|
||||
|
||||
// Remove inputs links
|
||||
while (V3GraphEdge* inedgep = vvertexp->inBeginp()) {
|
||||
inedgep->unlinkDelete(); inedgep=NULL;
|
||||
inedgep->unlinkDelete(); VL_DANGLING(inedgep);
|
||||
}
|
||||
// replaceAssigns() does the deleteTree on lvertexNodep in a later step
|
||||
AstNode* lvertexNodep = lvertexp->nodep();
|
||||
@@ -1161,14 +1161,14 @@ private:
|
||||
if (AstSel* newselp = merge(preselp, curselp)) {
|
||||
UINFO(5, "assemble to new sel: "<<newselp<<endl);
|
||||
// replace preSel with newSel
|
||||
preselp->replaceWith(newselp); preselp->deleteTree(); preselp = NULL;
|
||||
preselp->replaceWith(newselp); preselp->deleteTree(); VL_DANGLING(preselp);
|
||||
// create new rhs for pre assignment
|
||||
AstNode* newrhsp = new AstConcat(m_assignp->rhsp()->fileline(), m_assignp->rhsp()->cloneTree(false), assignp->rhsp()->cloneTree(false));
|
||||
AstNode* oldrhsp = m_assignp->rhsp();
|
||||
oldrhsp->replaceWith(newrhsp); oldrhsp->deleteTree(); oldrhsp = NULL;
|
||||
oldrhsp->replaceWith(newrhsp); oldrhsp->deleteTree(); VL_DANGLING(oldrhsp);
|
||||
m_assignp->dtypeChgWidthSigned(m_assignp->width()+assignp->width(), m_assignp->width()+assignp->width(), AstNumeric::fromBool(true));
|
||||
// don't need to delete, will be handled
|
||||
//assignp->unlinkFrBack(); assignp->deleteTree(); assignp = NULL;
|
||||
//assignp->unlinkFrBack(); assignp->deleteTree(); VL_DANGLING(assignp);
|
||||
|
||||
// update the graph
|
||||
{
|
||||
@@ -1179,11 +1179,11 @@ private:
|
||||
ledgep = ledgep->inNextp();
|
||||
GateEitherVertex* fromvp = dynamic_cast<GateEitherVertex*>(oedgep->fromp());
|
||||
new V3GraphEdge(m_graphp, fromvp, m_logicvp, 1);
|
||||
oedgep->unlinkDelete(); oedgep = NULL;
|
||||
oedgep->unlinkDelete(); VL_DANGLING(oedgep);
|
||||
}
|
||||
}
|
||||
// delete all outedges to lvertexp, only one
|
||||
oldedgep->unlinkDelete(); oldedgep = NULL;
|
||||
oldedgep->unlinkDelete(); VL_DANGLING(oldedgep);
|
||||
}
|
||||
++m_numMergedAssigns;
|
||||
} else {
|
||||
@@ -1202,7 +1202,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
GateMergeAssignsGraphVisitor(V3Graph* graphp) {
|
||||
explicit GateMergeAssignsGraphVisitor(V3Graph* graphp) {
|
||||
m_assignp = NULL;
|
||||
m_activep = NULL;
|
||||
m_logicvp = NULL;
|
||||
@@ -1241,7 +1241,7 @@ private:
|
||||
AstNode* valuep = assp->rhsp();
|
||||
valuep->unlinkFrBack();
|
||||
assp->replaceWith(valuep);
|
||||
assp->deleteTree(); assp=NULL;
|
||||
assp->deleteTree(); VL_DANGLING(assp);
|
||||
}
|
||||
}
|
||||
// Speedups
|
||||
@@ -1253,7 +1253,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
GateDeassignVisitor(AstNode* nodep) {
|
||||
explicit GateDeassignVisitor(AstNode* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~GateDeassignVisitor() {}
|
||||
|
||||
+2
-2
@@ -109,7 +109,7 @@ private:
|
||||
AstVarScope* newvscp = genInpClk(vscp);
|
||||
AstVarRef* newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->lvalue());
|
||||
nodep->replaceWith(newrefp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
GenClkReadVisitor(AstNetlist* nodep) {
|
||||
explicit GenClkReadVisitor(AstNetlist* nodep) {
|
||||
m_activep = NULL;
|
||||
m_assignp = NULL;
|
||||
m_topModp = NULL;
|
||||
|
||||
+1
-1
@@ -46,6 +46,7 @@ public:
|
||||
};
|
||||
enum en m_e;
|
||||
inline VWidthMinUsage () : m_e(LINT_WIDTH) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline VWidthMinUsage (en _e) : m_e(_e) {}
|
||||
explicit inline VWidthMinUsage (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
@@ -63,7 +64,6 @@ class V3Global {
|
||||
VWidthMinUsage m_widthMinUsage; // What AstNode::widthMin() is used for
|
||||
|
||||
int m_debugFileNumber; // Number to append to debug files created
|
||||
int m_assertWidthsMatch; // Tree should have width()==widthMin()
|
||||
bool m_assertDTypesResolved; // Tree should have dtypep()'s
|
||||
bool m_constRemoveXs; // Const needs to strip any Xs
|
||||
bool m_needHInlines; // Need __Inlines file
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ void V3Graph::dumpDotFilePrefixedAlways(const string& nameComment, bool colorAsS
|
||||
void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) {
|
||||
// This generates a file used by graphviz, http://www.graphviz.org
|
||||
// "hardcoded" parameters:
|
||||
const auto_ptr<ofstream> logp (V3File::new_ofstream(filename));
|
||||
const VL_UNIQUE_PTR<ofstream> logp (V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatalSrc("Can't write "<<filename);
|
||||
|
||||
// Header
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ protected:
|
||||
// CONSTRUCTORS
|
||||
V3GraphVertex(V3Graph* graphp, const V3GraphVertex& old);
|
||||
public:
|
||||
V3GraphVertex(V3Graph* graphp);
|
||||
explicit V3GraphVertex(V3Graph* graphp);
|
||||
//! Clone copy constructor. Doesn't copy edges or user/userp.
|
||||
virtual V3GraphVertex* clone(V3Graph* graphp) const {
|
||||
return new V3GraphVertex(graphp, *this); }
|
||||
|
||||
+15
-13
@@ -269,7 +269,7 @@ void GraphAcyc::deleteMarked () {
|
||||
nextp = vertexp->verticesNextp();
|
||||
GraphAcycVertex* avertexp = (GraphAcycVertex*)vertexp;
|
||||
if (avertexp->isDelete()) {
|
||||
avertexp->unlinkDelete(&m_breakGraph); avertexp=NULL;
|
||||
avertexp->unlinkDelete(&m_breakGraph); VL_DANGLING(avertexp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,13 +285,13 @@ void GraphAcyc::simplifyNone (GraphAcycVertex* avertexp) {
|
||||
while (V3GraphEdge* edgep = avertexp->outBeginp()) {
|
||||
V3GraphVertex* otherVertexp = edgep->top();
|
||||
//UINFO(9," out "<<otherVertexp<<endl);
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
workPush(otherVertexp);
|
||||
}
|
||||
while (V3GraphEdge* edgep = avertexp->inBeginp()) {
|
||||
V3GraphVertex* otherVertexp = edgep->fromp();
|
||||
//UINFO(9," in "<<otherVertexp<<endl);
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
workPush(otherVertexp);
|
||||
}
|
||||
}
|
||||
@@ -319,10 +319,11 @@ void GraphAcyc::simplifyOne (GraphAcycVertex* avertexp) {
|
||||
&& (!outEdgep->cutable()
|
||||
|| inEdgep->weight()<outEdgep->weight() ))
|
||||
? inEdgep : outEdgep);
|
||||
// cppcheck-suppress leakReturnValNotUsed
|
||||
edgeFromEdge(templateEdgep, inVertexp, outVertexp);
|
||||
// Remove old edge
|
||||
inEdgep->unlinkDelete(); inEdgep = NULL;
|
||||
outEdgep->unlinkDelete(); outEdgep = NULL; templateEdgep=NULL;
|
||||
inEdgep->unlinkDelete(); VL_DANGLING(inEdgep);
|
||||
outEdgep->unlinkDelete(); VL_DANGLING(outEdgep); VL_DANGLING(templateEdgep);
|
||||
workPush(inVertexp);
|
||||
workPush(outVertexp);
|
||||
}
|
||||
@@ -353,12 +354,13 @@ void GraphAcyc::simplifyOut (GraphAcycVertex* avertexp) {
|
||||
return;
|
||||
}
|
||||
// Make a new edge connecting the two vertices directly
|
||||
// cppcheck-suppress leakReturnValNotUsed
|
||||
edgeFromEdge(inEdgep, inVertexp, outVertexp);
|
||||
// Remove old edge
|
||||
inEdgep->unlinkDelete(); inEdgep = NULL;
|
||||
inEdgep->unlinkDelete(); VL_DANGLING(inEdgep);
|
||||
workPush(inVertexp);
|
||||
}
|
||||
outEdgep->unlinkDelete(); outEdgep = NULL;
|
||||
outEdgep->unlinkDelete(); VL_DANGLING(outEdgep);
|
||||
workPush(outVertexp);
|
||||
}
|
||||
}
|
||||
@@ -381,18 +383,18 @@ void GraphAcyc::simplifyDup (GraphAcycVertex* avertexp) {
|
||||
// !cutable duplicates prev !cutable: we can ignore it, redundant
|
||||
// cutable duplicates prev !cutable: know it's not a relevant loop, ignore it
|
||||
UINFO(8," DelDupEdge "<<avertexp<<" -> "<<edgep->top()<<endl);
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
} else if (!edgep->cutable()) {
|
||||
// !cutable duplicates prev cutable: delete the earlier cutable
|
||||
UINFO(8," DelDupPrev "<<avertexp<<" -> "<<prevEdgep->top()<<endl);
|
||||
prevEdgep->unlinkDelete(); prevEdgep = NULL;
|
||||
prevEdgep->unlinkDelete(); VL_DANGLING(prevEdgep);
|
||||
outVertexp->userp(edgep);
|
||||
} else {
|
||||
// cutable duplicates prev cutable: combine weights
|
||||
UINFO(8," DelDupComb "<<avertexp<<" -> "<<edgep->top()<<endl);
|
||||
prevEdgep->weight (prevEdgep->weight() + edgep->weight());
|
||||
addOrigEdgep (prevEdgep, edgep);
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
}
|
||||
workPush(outVertexp);
|
||||
workPush(avertexp);
|
||||
@@ -410,7 +412,7 @@ void GraphAcyc::cutBasic (GraphAcycVertex* avertexp) {
|
||||
nextp = edgep->outNextp();
|
||||
if (edgep->cutable() && edgep->top()==avertexp) {
|
||||
cutOrigEdge (edgep, " Cut Basic");
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
workPush(avertexp);
|
||||
}
|
||||
}
|
||||
@@ -431,7 +433,7 @@ void GraphAcyc::cutBackward (GraphAcycVertex* avertexp) {
|
||||
nextp = edgep->outNextp();
|
||||
if (edgep->cutable() && edgep->top()->user()) {
|
||||
cutOrigEdge (edgep, " Cut A->B->A");
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
workPush(avertexp);
|
||||
}
|
||||
}
|
||||
@@ -495,7 +497,7 @@ void GraphAcyc::placeTryEdge(V3GraphEdge* edgep) {
|
||||
// Adding this edge would cause a loop, kill it
|
||||
edgep->cutable(true); // So graph still looks pretty
|
||||
cutOrigEdge (edgep, " Cut loop");
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
// Backout the ranks we calculated
|
||||
while (GraphAcycVertex* vertexp = workBeginp()) {
|
||||
workPop();
|
||||
|
||||
+2
-2
@@ -109,10 +109,10 @@ private:
|
||||
}
|
||||
if (saveOld) {
|
||||
if (m_sumWeights) prevEdgep->weight(prevEdgep->weight() + edgep->weight());
|
||||
edgep->unlinkDelete(); edgep = NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
} else {
|
||||
if (m_sumWeights) edgep->weight(prevEdgep->weight() + edgep->weight());
|
||||
prevEdgep->unlinkDelete(); prevEdgep = NULL;
|
||||
prevEdgep->unlinkDelete(); VL_DANGLING(prevEdgep);
|
||||
outVertexp->userp(edgep);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -331,7 +331,7 @@ private:
|
||||
for (V3GraphVertex* nextp,*vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=nextp) {
|
||||
nextp = vertexp->verticesNextp();
|
||||
if (nfaState(vertexp)) {
|
||||
vertexp->unlinkDelete(m_graphp); vertexp=NULL;
|
||||
vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ private:
|
||||
if (vvertexp->accepting()) {
|
||||
for (V3GraphEdge* nextp,*edgep = vertexp->outBeginp(); edgep; edgep=nextp) {
|
||||
nextp = edgep->outNextp();
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ private:
|
||||
for (V3GraphVertex* nextp,*vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=nextp) {
|
||||
nextp = vertexp->verticesNextp();
|
||||
if (!vertexp->user()) {
|
||||
vertexp->unlinkDelete(m_graphp); vertexp=NULL;
|
||||
vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ private:
|
||||
}
|
||||
}
|
||||
// Transitions to this state removed by the unlink function
|
||||
vertexp->unlinkDelete(m_graphp); vertexp=NULL;
|
||||
vertexp->unlinkDelete(m_graphp); VL_DANGLING(vertexp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ private:
|
||||
DfaVertex* tovertexp = static_cast<DfaVertex*>(edgep->top());
|
||||
if (tovertexp->accepting()) {
|
||||
new DfaEdge(graphp(), vvertexp, m_tempNewerReject, vedgep);
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
}
|
||||
|
||||
// NOT of all values goes to accept
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
HashedVisitor(AstNode* nodep) {
|
||||
explicit HashedVisitor(AstNode* nodep) {
|
||||
nodeHashIterate(nodep);
|
||||
//UINFO(9," stmthash "<<hex<<V3Hashed::nodeHash(nodep)<<" "<<nodep<<endl);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ void V3Hashed::dumpFilePrefixed(const string& nameComment, bool tree) {
|
||||
}
|
||||
|
||||
void V3Hashed::dumpFile(const string& filename, bool tree) {
|
||||
const auto_ptr<ofstream> logp (V3File::new_ofstream(filename));
|
||||
const VL_UNIQUE_PTR<ofstream> logp (V3File::new_ofstream(filename));
|
||||
if (logp->fail()) v3fatalSrc("Can't write "<<filename);
|
||||
|
||||
map<int,int> dist;
|
||||
|
||||
+9
-9
@@ -135,14 +135,14 @@ private:
|
||||
} else {
|
||||
m_modp->user1(1);
|
||||
}
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL; // Remove so don't propagate to upper cell...
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell...
|
||||
} else if (nodep->pragType() == AstPragmaType::NO_INLINE_MODULE) {
|
||||
if (!m_modp) {
|
||||
nodep->v3error("Inline pragma not under a module");
|
||||
} else {
|
||||
cantInline("Pragma NO_INLINE_MODULE",false);
|
||||
}
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL; // Remove so don't propagate to upper cell...
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep); // Remove so don't propagate to upper cell...
|
||||
} else {
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
InlineMarkVisitor(AstNode* nodep) {
|
||||
explicit InlineMarkVisitor(AstNode* nodep) {
|
||||
m_modp = NULL;
|
||||
m_stmtCnt = 0;
|
||||
nodep->accept(*this);
|
||||
@@ -227,7 +227,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one
|
||||
explicit InlineCollectVisitor(AstNodeModule* nodep) { // passed OLD module, not new one
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~InlineCollectVisitor() {}
|
||||
@@ -347,7 +347,7 @@ private:
|
||||
AstVarRef* exprvarrefp = nodep->varp()->user2p()->castNode()->castVarRef();
|
||||
if (exprconstp) {
|
||||
nodep->replaceWith(exprconstp->cloneTree(true));
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
else if (exprvarrefp) {
|
||||
@@ -521,9 +521,9 @@ private:
|
||||
if (stmtsp) stmtsp->unlinkFrBackWithNext();
|
||||
if (stmtsp) m_modp->addStmtp(stmtsp);
|
||||
// Remove the cell
|
||||
newmodp->deleteTree(); newmodp=NULL; // Clear any leftover ports, etc
|
||||
newmodp->deleteTree(); VL_DANGLING(newmodp); // Clear any leftover ports, etc
|
||||
nodep->unlinkFrBack();
|
||||
pushDeletep(nodep); nodep = NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
if (debug()>=9) { m_modp->dumpTree(cout,"donemod:"); }
|
||||
}
|
||||
}
|
||||
@@ -537,7 +537,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
InlineVisitor(AstNode* nodep) {
|
||||
explicit InlineVisitor(AstNode* nodep) {
|
||||
m_modp = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -560,7 +560,7 @@ void V3Inline::inlineAll(AstNetlist* nodep) {
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp=nextmodp) {
|
||||
nextmodp = modp->nextp()->castNodeModule();
|
||||
if (modp->user1()) { // Was inlined
|
||||
modp->unlinkFrBack()->deleteTree(); modp=NULL;
|
||||
modp->unlinkFrBack()->deleteTree(); VL_DANGLING(modp);
|
||||
}
|
||||
}
|
||||
V3Global::dumpCheckGlobalTree("inline.tree", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
|
||||
|
||||
+149
-8
@@ -36,6 +36,7 @@
|
||||
#include "V3Inst.h"
|
||||
#include "V3Ast.h"
|
||||
#include "V3Changed.h"
|
||||
#include "V3Const.h"
|
||||
|
||||
//######################################################################
|
||||
// Inst state, as a visitor of each AstNode
|
||||
@@ -105,12 +106,15 @@ private:
|
||||
exprp);
|
||||
m_modp->addStmtp(assp);
|
||||
if (debug()>=9) assp->dumpTree(cout," _new: ");
|
||||
} else if (nodep->modVarp()->isIfaceRef()) {
|
||||
} else if (nodep->modVarp()->isIfaceRef()
|
||||
|| (nodep->modVarp()->subDTypep()->castUnpackArrayDType()
|
||||
&& nodep->modVarp()->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType())) {
|
||||
// Create an AstAssignVarScope for Vars to Cells so we can link with their scope later
|
||||
AstNode* lhsp = new AstVarXRef (exprp->fileline(), nodep->modVarp(), m_cellp->name(), false);
|
||||
AstVarRef* refp = exprp->castVarRef();
|
||||
if (!refp) exprp->v3fatalSrc("Interfaces: Pin is not connected to a VarRef");
|
||||
AstAssignVarScope* assp = new AstAssignVarScope(exprp->fileline(), lhsp, refp);
|
||||
AstVarXRef* xrefp = exprp->castVarXRef();
|
||||
if (!refp && !xrefp) exprp->v3fatalSrc("Interfaces: Pin is not connected to a VarRef or VarXRef");
|
||||
AstAssignVarScope* assp = new AstAssignVarScope(exprp->fileline(), lhsp, exprp);
|
||||
m_modp->addStmtp(assp);
|
||||
} else {
|
||||
nodep->v3error("Assigned pin is neither input nor output");
|
||||
@@ -118,7 +122,7 @@ private:
|
||||
}
|
||||
|
||||
// We're done with the pin
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
virtual void visit(AstUdpTable* nodep, AstNUser*) {
|
||||
@@ -139,7 +143,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
InstVisitor(AstNode* nodep) {
|
||||
explicit InstVisitor(AstNode* nodep) {
|
||||
m_modp=NULL;
|
||||
m_cellp=NULL;
|
||||
//
|
||||
@@ -169,6 +173,12 @@ private:
|
||||
if (nodep->rangep()) {
|
||||
m_cellRangep = nodep->rangep();
|
||||
UINFO(4," CELL "<<nodep<<endl);
|
||||
|
||||
AstVar* ifaceVarp = nodep->nextp()->castVar();
|
||||
bool isIface = ifaceVarp
|
||||
&& ifaceVarp->dtypep()->castUnpackArrayDType()
|
||||
&& ifaceVarp->dtypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
|
||||
// Make all of the required clones
|
||||
m_instLsb = m_cellRangep->lsbConst();
|
||||
for (m_instNum = m_instLsb; m_instNum<=m_cellRangep->msbConst(); m_instNum++) {
|
||||
@@ -181,6 +191,24 @@ 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__");
|
||||
|
||||
// If this AstCell is actually an interface instantiation, let's ensure we also clone
|
||||
// the IfaceRef.
|
||||
if (isIface) {
|
||||
AstUnpackArrayDType* arrdtype = ifaceVarp->dtypep()->castUnpackArrayDType();
|
||||
AstIfaceRefDType* origIfaceRefp = arrdtype->subDTypep()->castIfaceRefDType();
|
||||
origIfaceRefp->cellp(NULL);
|
||||
AstVar* varNewp = ifaceVarp->cloneTree(false);
|
||||
AstIfaceRefDType* ifaceRefp = arrdtype->subDTypep()->castIfaceRefDType()->cloneTree(false);
|
||||
arrdtype->addNextHere(ifaceRefp);
|
||||
ifaceRefp->cellp(newp);
|
||||
ifaceRefp->cellName(newp->name());
|
||||
varNewp->name(varNewp->name() + "__BRA__" + cvtToStr(m_instNum) + "__KET__");
|
||||
varNewp->origName(varNewp->origName() + "__BRA__" + cvtToStr(m_instNum) + "__KET__");
|
||||
varNewp->dtypep(ifaceRefp);
|
||||
newp->addNextHere(varNewp);
|
||||
if (debug()==9) { varNewp->dumpTree(cout, "newintf: "); cout << endl; }
|
||||
}
|
||||
// Fixup pins
|
||||
newp->pinsp()->iterateAndNext(*this);
|
||||
if (debug()==9) { newp->dumpTree(cout,"newcell: "); cout<<endl; }
|
||||
@@ -188,9 +216,40 @@ private:
|
||||
|
||||
// Done. Delete original
|
||||
m_cellRangep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
if (isIface) {
|
||||
ifaceVarp->unlinkFrBack(); pushDeletep(ifaceVarp); VL_DANGLING(ifaceVarp);
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
|
||||
virtual void visit(AstVar* nodep, AstNUser*) {
|
||||
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, AstNUser*) {
|
||||
// Any non-direct pins need reconnection with a part-select
|
||||
if (!nodep->exprp()) return; // No-connect
|
||||
@@ -198,7 +257,20 @@ private:
|
||||
UINFO(4," PIN "<<nodep<<endl);
|
||||
int pinwidth = nodep->modVarp()->width();
|
||||
int expwidth = nodep->exprp()->width();
|
||||
if (expwidth == pinwidth) {
|
||||
pair<uint32_t,uint32_t> pinDim = nodep->modVarp()->dtypep()->dimensions(false);
|
||||
pair<uint32_t,uint32_t> expDim = nodep->exprp()->dtypep()->dimensions(false);
|
||||
UINFO(4," PINVAR "<<nodep->modVarp()<<endl);
|
||||
UINFO(4," EXP "<<nodep->exprp()<<endl);
|
||||
UINFO(4," pinwidth ew="<<expwidth<<" pw="<<pinwidth
|
||||
<<" ed="<<expDim.first<<","<<expDim.second
|
||||
<<" pd="<<pinDim.first<<","<<pinDim.second<<endl);
|
||||
if (expDim.first == pinDim.first && expDim.second == pinDim.second+1) {
|
||||
// Connection to array, where array dimensions match the instant dimension
|
||||
AstNode* exprp = nodep->exprp()->unlinkFrBack();
|
||||
exprp = new AstArraySel (exprp->fileline(), exprp,
|
||||
(m_instNum-m_instLsb));
|
||||
nodep->exprp(exprp);
|
||||
} else if (expwidth == pinwidth) {
|
||||
// NOP: Arrayed instants: widths match so connect to each instance
|
||||
} else if (expwidth == pinwidth*m_cellRangep->elementsConst()) {
|
||||
// Arrayed instants: one bit for each of the instants (each assign is 1 pinwidth wide)
|
||||
@@ -217,6 +289,69 @@ private:
|
||||
} else {
|
||||
nodep->v3fatalSrc("Width mismatch; V3Width should have errored out.");
|
||||
}
|
||||
} else if (AstArraySel* arrselp = nodep->exprp()->castArraySel()) {
|
||||
if (AstUnpackArrayDType* arrp = arrselp->lhsp()->dtypep()->castUnpackArrayDType()) {
|
||||
if (!arrp->subDTypep()->castIfaceRefDType())
|
||||
return;
|
||||
|
||||
V3Const::constifyParamsEdit(arrselp->rhsp());
|
||||
AstConst* constp = arrselp->rhsp()->castConst();
|
||||
if (!constp) {
|
||||
nodep->v3error("Unsupported: Non-constant index when passing interface to module");
|
||||
return;
|
||||
}
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
AstVarRef* varrefp = arrselp->lhsp()->castVarRef();
|
||||
AstVarXRef* newp = new AstVarXRef(nodep->fileline(),varrefp->name () + "__BRA__" + index + "__KET__", "", true);
|
||||
newp->dtypep(nodep->modVarp()->dtypep());
|
||||
newp->packagep(varrefp->packagep());
|
||||
arrselp->addNextHere(newp);
|
||||
arrselp->unlinkFrBack()->deleteTree();
|
||||
}
|
||||
} else {
|
||||
AstVar* pinVarp = nodep->modVarp();
|
||||
AstUnpackArrayDType* pinArrp = pinVarp->dtypep()->castUnpackArrayDType();
|
||||
if (!pinArrp || !pinArrp->subDTypep()->castIfaceRefDType())
|
||||
return;
|
||||
AstNode* prevp = NULL;
|
||||
AstNode* prevPinp = NULL;
|
||||
// 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;
|
||||
} else {
|
||||
prevp->addNextHere(varNewp);
|
||||
}
|
||||
// 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__";
|
||||
AstVarXRef* newVarXRefp = new AstVarXRef (nodep->fileline(), newname, "", true);
|
||||
newVarXRefp->varp(newp->modVarp());
|
||||
newVarXRefp->dtypep(newp->modVarp()->dtypep());
|
||||
newp->exprp()->unlinkFrBack()->deleteTree();
|
||||
newp->exprp(newVarXRefp);
|
||||
if (!prevPinp) {
|
||||
prevPinp = newp;
|
||||
} else {
|
||||
prevPinp->addNextHere(newp);
|
||||
}
|
||||
}
|
||||
pinVarp->replaceWith(prevp);
|
||||
nodep->replaceWith(prevPinp);
|
||||
pushDeletep(pinVarp);
|
||||
pushDeletep(nodep);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +364,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
InstDeVisitor(AstNode* nodep) {
|
||||
explicit InstDeVisitor(AstNode* nodep) {
|
||||
m_cellRangep=NULL;
|
||||
m_instNum=0;
|
||||
m_instLsb=0;
|
||||
@@ -272,8 +407,10 @@ public:
|
||||
// Else create a intermediate wire to perform the interconnect
|
||||
// Return the new assignment, if one was made
|
||||
// Note this module calles cloneTree() via new AstVar
|
||||
|
||||
AstVar* pinVarp = pinp->modVarp();
|
||||
AstVarRef* connectRefp = pinp->exprp()->castVarRef();
|
||||
AstVarXRef* connectXRefp = pinp->exprp()->castVarXRef();
|
||||
AstBasicDType* pinBasicp = pinVarp->dtypep()->basicp(); // Maybe NULL
|
||||
AstBasicDType* connBasicp = NULL;
|
||||
AstAssignW* assignp = NULL;
|
||||
@@ -288,6 +425,10 @@ public:
|
||||
&& connectRefp
|
||||
&& connectRefp->varp()->isIfaceRef()) {
|
||||
// Done. Interface
|
||||
} else if (!alwaysCvt
|
||||
&& connectXRefp
|
||||
&& connectXRefp->varp()
|
||||
&& connectXRefp->varp()->isIfaceRef()) {
|
||||
} else if (!alwaysCvt
|
||||
&& connBasicp
|
||||
&& pinBasicp
|
||||
|
||||
+2
-1
@@ -64,8 +64,9 @@ public:
|
||||
//
|
||||
enum en m_e;
|
||||
inline V3LangCode () : m_e(L_ERROR) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline V3LangCode (en _e) : m_e(_e) {}
|
||||
V3LangCode (const char* textp);
|
||||
explicit V3LangCode (const char* textp);
|
||||
explicit inline V3LangCode (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
};
|
||||
|
||||
+9
-9
@@ -93,10 +93,10 @@ public:
|
||||
LifeVarEntry(SIMPLEASSIGN, AstNodeAssign* assp) {
|
||||
init(true); simpleAssign(assp);
|
||||
}
|
||||
LifeVarEntry(COMPLEXASSIGN) {
|
||||
explicit LifeVarEntry(COMPLEXASSIGN) {
|
||||
init(false); complexAssign();
|
||||
}
|
||||
LifeVarEntry(CONSUMED) {
|
||||
explicit LifeVarEntry(CONSUMED) {
|
||||
init(false); consumed();
|
||||
}
|
||||
~LifeVarEntry() {}
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
// above our current iteration point.
|
||||
if (debug()>4) oldassp->dumpTree(cout, " REMOVE/SAMEBLK ");
|
||||
entp->complexAssign();
|
||||
m_statep->pushUnlinkDeletep(oldassp); oldassp=NULL;
|
||||
m_statep->pushUnlinkDeletep(oldassp); VL_DANGLING(oldassp);
|
||||
++m_statep->m_statAssnDel;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
// We'll later constant propagate
|
||||
UINFO(4," replaceconst: "<<varrefp<<endl);
|
||||
varrefp->replaceWith(constp->cloneTree(false));
|
||||
varrefp->deleteTree(); varrefp=NULL;
|
||||
varrefp->deleteTree(); VL_DANGLING(varrefp);
|
||||
++m_statep->m_statAssnCon;
|
||||
return; // **DONE, no longer a var reference**
|
||||
}
|
||||
@@ -313,7 +313,7 @@ private:
|
||||
if (nodep->lvalue()) {
|
||||
m_lifep->complexAssign(vscp);
|
||||
} else {
|
||||
m_lifep->varUsageReplace(vscp, nodep); nodep=NULL;
|
||||
m_lifep->varUsageReplace(vscp, nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodeAssign* nodep, AstNUser*) {
|
||||
@@ -455,14 +455,14 @@ public:
|
||||
m_sideEffect = false;
|
||||
m_noopt = false;
|
||||
{
|
||||
// Cpp check bug, it is deleted
|
||||
// cppcheck-suppress leak
|
||||
m_lifep = new LifeBlock (NULL, m_statep);
|
||||
nodep->accept(*this);
|
||||
delete m_lifep; m_lifep=NULL;
|
||||
if (m_lifep) { delete m_lifep; m_lifep=NULL; }
|
||||
}
|
||||
}
|
||||
virtual ~LifeVisitor() {}
|
||||
virtual ~LifeVisitor() {
|
||||
if (m_lifep) { delete m_lifep; m_lifep=NULL; }
|
||||
}
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
||||
+4
-4
@@ -68,7 +68,7 @@ private:
|
||||
UINFO(9, " Replace "<<nodep<<" to "<<newvscp<<endl);
|
||||
AstVarRef* newrefp = new AstVarRef(nodep->fileline(), newvscp, nodep->lvalue());
|
||||
nodep->replaceWith(newrefp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodeModule* nodep, AstNUser*) {
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
LifePostElimVisitor(AstTopScope* nodep) {
|
||||
explicit LifePostElimVisitor(AstTopScope* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~LifePostElimVisitor() {}
|
||||
@@ -155,7 +155,7 @@ private:
|
||||
UINFO(4," DELETE "<<nodep<<endl);
|
||||
// Mark so LifePostElimVisitor will get it
|
||||
rhsp->varScopep()->user4p(lhsp->varScopep());
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
++m_statAssnDel;
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
LifePostDlyVisitor(AstNetlist* nodep) {
|
||||
explicit LifePostDlyVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~LifePostDlyVisitor() {
|
||||
|
||||
+17
-7
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
class LibraryVertex : public V3GraphVertex {
|
||||
public:
|
||||
LibraryVertex(V3Graph* graphp)
|
||||
explicit LibraryVertex(V3Graph* graphp)
|
||||
: V3GraphVertex(graphp) {}
|
||||
virtual ~LibraryVertex() {}
|
||||
virtual string name() const { return "*LIBRARY*"; }
|
||||
@@ -292,7 +292,7 @@ private:
|
||||
if (pinStar) pinp->v3error("Duplicate .* in a cell");
|
||||
pinStar = true;
|
||||
// Done with this fake pin
|
||||
pinp->unlinkFrBack()->deleteTree(); pinp=NULL;
|
||||
pinp->unlinkFrBack()->deleteTree(); VL_DANGLING(pinp);
|
||||
}
|
||||
}
|
||||
// Convert unnamed pins to pin number based assignments
|
||||
@@ -348,11 +348,21 @@ private:
|
||||
// This is quite similar to how classes work; when unpacked classes are better supported
|
||||
// may remap interfaces to be more like a class.
|
||||
if (!nodep->hasIfaceVar()) {
|
||||
string varName = nodep->name()+"__Viftop"; // V3LinkDot looks for this naming
|
||||
AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(), nodep->modp()->name());
|
||||
idtypep->cellp(nodep); // Only set when real parent cell known
|
||||
string varName = nodep->name() + "__Viftop"; // V3LinkDot looks for this naming
|
||||
AstIfaceRefDType* idtypep = new AstIfaceRefDType(nodep->fileline(), nodep->name(),
|
||||
nodep->modp()->name());
|
||||
idtypep->ifacep(NULL); // cellp overrides
|
||||
AstVar* varp = new AstVar(nodep->fileline(), AstVarType::IFACEREF, varName, VFlagChildDType(), idtypep);
|
||||
// In the case of arrayed interfaces, we replace cellp when de-arraying in V3Inst
|
||||
idtypep->cellp(nodep); // Only set when real parent cell known.
|
||||
AstVar* varp;
|
||||
if (nodep->rangep()) {
|
||||
AstNodeArrayDType* arrp = new AstUnpackArrayDType(nodep->fileline(),VFlagChildDType(), idtypep, nodep->rangep()->cloneTree(true));
|
||||
varp = new AstVar(nodep->fileline(), AstVarType::IFACEREF, varName,
|
||||
VFlagChildDType(), arrp);
|
||||
} else {
|
||||
varp = new AstVar(nodep->fileline(), AstVarType::IFACEREF, varName,
|
||||
VFlagChildDType(), idtypep);
|
||||
}
|
||||
varp->isIfaceParent(true);
|
||||
nodep->addNextHere(varp);
|
||||
nodep->hasIfaceVar(true);
|
||||
@@ -384,7 +394,7 @@ private:
|
||||
<<foundp->warnMore()<<"... Location of original declaration");
|
||||
}
|
||||
nodep->unlinkFrBack();
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
} else if (!foundp) {
|
||||
m_mods.rootp()->insert(nodep->name(), new VSymEnt(&m_mods, nodep));
|
||||
}
|
||||
|
||||
+147
-49
@@ -365,14 +365,31 @@ public:
|
||||
void insertIfaceVarSym(VSymEnt* symp) { // Where sym is for a VAR of dtype IFACEREFDTYPE
|
||||
m_ifaceVarSyms.push_back(symp);
|
||||
}
|
||||
// Iface for a raw or arrayed iface
|
||||
static AstIfaceRefDType* ifaceRefFromArray(AstNodeDType* nodep) {
|
||||
AstIfaceRefDType* ifacerefp = nodep->castIfaceRefDType();
|
||||
if (!ifacerefp) {
|
||||
if (AstUnpackArrayDType* arrp = nodep->castUnpackArrayDType()) {
|
||||
ifacerefp = arrp->subDTypep()->castIfaceRefDType();
|
||||
}
|
||||
}
|
||||
return ifacerefp;
|
||||
}
|
||||
void computeIfaceVarSyms() {
|
||||
for (IfaceVarSyms::iterator it = m_ifaceVarSyms.begin(); it != m_ifaceVarSyms.end(); ++it) {
|
||||
VSymEnt* varSymp = *it;
|
||||
AstVar* varp = varSymp->nodep()->castVar();
|
||||
UINFO(9, " insAllIface se"<<(void*)varSymp<<" "<<varp<<endl);
|
||||
AstIfaceRefDType* ifacerefp = varp->subDTypep()->castIfaceRefDType();
|
||||
AstIfaceRefDType* ifacerefp = ifaceRefFromArray(varp->subDTypep());
|
||||
if (!ifacerefp) varp->v3fatalSrc("Non-ifacerefs on list!");
|
||||
if (!ifacerefp->ifaceViaCellp()) ifacerefp->v3fatalSrc("Unlinked interface");
|
||||
if (!ifacerefp->ifaceViaCellp()) {
|
||||
if (!ifacerefp->cellp()) { // Probably a NotFoundModule, or a normal module if made mistake
|
||||
ifacerefp->v3error("Cannot find file containing interface: "<<AstNode::prettyName(ifacerefp->ifaceName()));
|
||||
continue;
|
||||
} else {
|
||||
ifacerefp->v3fatalSrc("Unlinked interface");
|
||||
}
|
||||
}
|
||||
VSymEnt* ifaceSymp = getNodeSym(ifacerefp->ifaceViaCellp());
|
||||
VSymEnt* ifOrPortSymp = ifaceSymp;
|
||||
// Link Modport names to the Modport Node under the Interface
|
||||
@@ -401,6 +418,10 @@ public:
|
||||
// Track and later insert scope aliases; an interface referenced by a child cell connecting to that interface
|
||||
// Typically lhsp=VAR w/dtype IFACEREF, rhsp=IFACE cell
|
||||
UINFO(9," insertScopeAlias se"<<(void*)lhsp<<" se"<<(void*)rhsp<<endl);
|
||||
if (rhsp->nodep()->castCell()
|
||||
&& !rhsp->nodep()->castCell()->modp()->castIface()) {
|
||||
rhsp->nodep()->v3fatalSrc("Got a non-IFACE alias RHS");
|
||||
}
|
||||
m_scopeAliasMap[samn].insert(make_pair(lhsp, rhsp));
|
||||
}
|
||||
void computeScopeAliases() {
|
||||
@@ -508,6 +529,17 @@ public:
|
||||
return lookupSymp;
|
||||
}
|
||||
|
||||
static string removeLastInlineScope(const string& name) {
|
||||
string out = name;
|
||||
string dot = "__DOT__";
|
||||
size_t dotPos = out.rfind(dot, out.size() - dot.length() - 2);
|
||||
if (dotPos == string::npos) {
|
||||
return "";
|
||||
} else {
|
||||
return out.erase(dotPos + dot.length(), string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
VSymEnt* findSymPrefixed(VSymEnt* lookupSymp, const string& dotname, string& baddot) {
|
||||
// Find symbol in given point in hierarchy, allowing prefix (post-Inline)
|
||||
// For simplicity lookupSymp may be passed NULL result from findDotted
|
||||
@@ -518,7 +550,15 @@ public:
|
||||
<<((lookupSymp->symPrefix()=="") ? "" : lookupSymp->symPrefix()+dotname)
|
||||
<<" at se"<<lookupSymp
|
||||
<<endl);
|
||||
VSymEnt* foundp = lookupSymp->findIdFallback(lookupSymp->symPrefix() + dotname); // Might be NULL
|
||||
string prefix = lookupSymp->symPrefix();
|
||||
VSymEnt* foundp = NULL;
|
||||
while (!foundp) {
|
||||
foundp = lookupSymp->findIdFallback(prefix + dotname); // Might be NULL
|
||||
if (prefix == "") {
|
||||
break;
|
||||
}
|
||||
prefix = removeLastInlineScope(prefix);
|
||||
}
|
||||
if (!foundp) baddot = dotname;
|
||||
return foundp;
|
||||
}
|
||||
@@ -814,7 +854,7 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
newdtypep->unlinkFrBack();
|
||||
findvarp->childDTypep(newdtypep);
|
||||
}
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
} else {
|
||||
nodep->v3error("Duplicate declaration of signal: "<<nodep->prettyName()<<endl
|
||||
<<findvarp->warnMore()<<"... Location of original declaration");
|
||||
@@ -835,10 +875,12 @@ class LinkDotFindVisitor : public AstNVisitor {
|
||||
VSymEnt* insp = m_statep->insertSym(m_curSymp, nodep->name(), nodep, m_packagep);
|
||||
if (m_statep->forPrimary() && nodep->isGParam()) {
|
||||
m_paramNum++;
|
||||
VSymEnt* symp = m_statep->insertSym(m_curSymp, "__paramNumber"+cvtToStr(m_paramNum), nodep, m_packagep);
|
||||
VSymEnt* symp = m_statep->insertSym(m_curSymp, "__paramNumber" + cvtToStr(m_paramNum),
|
||||
nodep, m_packagep);
|
||||
symp->exported(false);
|
||||
}
|
||||
if (nodep->subDTypep()->castIfaceRefDType()) {
|
||||
AstIfaceRefDType* ifacerefp = LinkDotState::ifaceRefFromArray(nodep->subDTypep());
|
||||
if (ifacerefp) {
|
||||
// Can't resolve until interfaces and modport names are known; see notes at top
|
||||
m_statep->insertIfaceVarSym(insp);
|
||||
}
|
||||
@@ -1005,7 +1047,7 @@ private:
|
||||
nodep->name(),
|
||||
exprp);
|
||||
cellp->addParamsp(pinp);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstPort* nodep, AstNUser*) {
|
||||
@@ -1025,7 +1067,7 @@ private:
|
||||
symp->exported(false);
|
||||
}
|
||||
// Ports not needed any more
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstAssignW* nodep, AstNUser*) {
|
||||
// Deal with implicit definitions
|
||||
@@ -1050,7 +1092,7 @@ private:
|
||||
// Unsupported gates need implicit creation
|
||||
pinImplicitExprRecurse(nodep);
|
||||
// We're done with implicit gates
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
// Default: Just iterate
|
||||
@@ -1104,7 +1146,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
|
||||
&& nodep->varp()->isIfaceParent()) {
|
||||
UINFO(9,"Iface parent ref var "<<nodep->varp()->name()<<" "<<nodep<<endl);
|
||||
// Find the interface cell the var references
|
||||
AstIfaceRefDType* dtypep = nodep->varp()->dtypep()->castIfaceRefDType();
|
||||
AstIfaceRefDType* dtypep = LinkDotState::ifaceRefFromArray(nodep->varp()->dtypep());
|
||||
if (!dtypep) nodep->v3fatalSrc("Non AstIfaceRefDType on isIfaceRef() var");
|
||||
UINFO(9,"Iface parent dtype "<<dtypep<<endl);
|
||||
string ifcellname = dtypep->cellName();
|
||||
@@ -1145,10 +1187,20 @@ class LinkDotScopeVisitor : public AstNVisitor {
|
||||
VSymEnt* rhsSymp;
|
||||
{
|
||||
AstVarRef* refp = nodep->rhsp()->castVarRef();
|
||||
if (!refp) nodep->v3fatalSrc("Unsupported: Non VarRef attached to interface pin");
|
||||
string scopename = refp->name();
|
||||
string baddot; VSymEnt* okSymp;
|
||||
VSymEnt* symp = m_statep->findDotted(m_modSymp, scopename, baddot, okSymp);
|
||||
AstVarXRef* xrefp = nodep->rhsp()->castVarXRef();
|
||||
if (!refp && !xrefp) nodep->v3fatalSrc("Unsupported: Non Var(X)Ref attached to interface pin");
|
||||
string inl = (xrefp && xrefp->inlinedDots().size()) ? (xrefp->inlinedDots() + "__DOT__") : "";
|
||||
VSymEnt* symp = NULL;
|
||||
string scopename;
|
||||
while (!symp) {
|
||||
scopename = refp ? refp->name() : (inl.size() ? (inl + xrefp->name()) : xrefp->name());
|
||||
string baddot; VSymEnt* okSymp;
|
||||
symp = m_statep->findDotted(m_modSymp, scopename, baddot, okSymp);
|
||||
if (inl == "")
|
||||
break;
|
||||
inl = LinkDotState::removeLastInlineScope(inl);
|
||||
}
|
||||
if (!symp) UINFO(9,"No symbol for interface alias rhs ("<<string(refp?"VARREF ":"VARXREF ")<<scopename<<")"<<endl);
|
||||
if (!symp) nodep->v3fatalSrc("No symbol for interface alias rhs");
|
||||
UINFO(5, " Found a linked scope RHS: "<<scopename<<" se"<<(void*)symp<<" "<<symp->nodep()<<endl);
|
||||
rhsSymp = symp;
|
||||
@@ -1168,7 +1220,7 @@ class LinkDotScopeVisitor : public AstNVisitor {
|
||||
// or maybe an alias of an alias
|
||||
m_statep->insertScopeAlias(LinkDotState::SAMN_IFTOP, lhsSymp, rhsSymp);
|
||||
// We have stored the link, we don't need these any more
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
// For speed, don't recurse things that can't have scope
|
||||
// Note we allow AstNodeStmt's as generates may be under them
|
||||
@@ -1235,7 +1287,7 @@ class LinkDotIfaceVisitor : public AstNVisitor {
|
||||
if (m_statep->forScopeCreation()) {
|
||||
// Done with AstModportFTaskRef.
|
||||
// Delete to prevent problems if we dead-delete pointed to ftask
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstModportVarRef* nodep, AstNUser*) {
|
||||
@@ -1258,7 +1310,7 @@ class LinkDotIfaceVisitor : public AstNVisitor {
|
||||
if (m_statep->forScopeCreation()) {
|
||||
// Done with AstModportVarRef.
|
||||
// Delete to prevent problems if we dead-delete pointed to variable
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
@@ -1322,12 +1374,15 @@ private:
|
||||
DotPosition m_dotPos; // Scope part of dotted resolution
|
||||
VSymEnt* m_dotSymp; // SymEnt for dotted AstParse lookup
|
||||
AstDot* m_dotp; // Current dot
|
||||
bool m_unresolved; // Unresolved, needs help from V3Param
|
||||
AstNode* m_unlinkedScope;// Unresolved scope, needs corresponding VarXRef
|
||||
bool m_dotErr; // Error found in dotted resolution, ignore upwards
|
||||
string m_dotText; // String of dotted names found in below parseref
|
||||
DotStates() { init(NULL); }
|
||||
~DotStates() {}
|
||||
void init(VSymEnt* curSymp) {
|
||||
m_dotPos = DP_NONE; m_dotSymp = curSymp; m_dotp = NULL; m_dotErr = false; m_dotText = "";
|
||||
m_unresolved = false; m_unlinkedScope = NULL;
|
||||
}
|
||||
string ascii() const {
|
||||
static const char* names[] = { "NONE","PACKAGE","SCOPE","FINAL","MEMBER" };
|
||||
@@ -1335,6 +1390,7 @@ private:
|
||||
sstr<<"ds="<<names[m_dotPos];
|
||||
sstr<<" dse"<<(void*)m_dotSymp;
|
||||
sstr<<" txt="<<m_dotText;
|
||||
sstr<<" unr="<<m_unresolved;
|
||||
return sstr.str();
|
||||
}
|
||||
} m_ds; // State to preserve across recursions
|
||||
@@ -1416,7 +1472,7 @@ private:
|
||||
virtual void visit(AstCellInline* nodep, AstNUser*) {
|
||||
checkNoDot(nodep);
|
||||
if (m_statep->forScopeCreation()) {
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstCell* nodep, AstNUser*) {
|
||||
@@ -1460,7 +1516,7 @@ private:
|
||||
if (!refp) {
|
||||
if (nodep->name() == "__paramNumber1" && m_cellp->modp()->castPrimitive()) {
|
||||
// Primitive parameter is really a delay we can just ignore
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
}
|
||||
nodep->v3error(ucfirst(whatp)<<" not found: "<<nodep->prettyName());
|
||||
@@ -1487,7 +1543,7 @@ private:
|
||||
if (nodep->user3SetOnce()) return;
|
||||
UINFO(8," "<<nodep<<endl);
|
||||
DotStates lastStates = m_ds;
|
||||
bool start = !m_ds.m_dotp; // Save, as m_dotp will be changed
|
||||
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
{
|
||||
if (start) { // Starting dot sequence
|
||||
if (debug()>=9) nodep->dumpTree("-dot-in: ");
|
||||
@@ -1498,13 +1554,16 @@ private:
|
||||
|
||||
// m_ds.m_dotText communicates the cell prefix between stages
|
||||
if (nodep->lhsp()->castPackageRef()) {
|
||||
if (!start) { nodep->lhsp()->v3error("Package reference may not be embedded in dotted reference"); m_ds.m_dotErr=true; }
|
||||
//if (!start) { nodep->lhsp()->v3error("Package reference may not be embedded in dotted reference"); m_ds.m_dotErr=true; }
|
||||
m_ds.m_dotPos = DP_PACKAGE;
|
||||
} else {
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
nodep->lhsp()->iterateAndNext(*this);
|
||||
//if (debug()>=9) nodep->dumpTree("-dot-lho: ");
|
||||
}
|
||||
if (m_ds.m_unresolved && (nodep->lhsp()->castCellRef() || nodep->lhsp()->castCellArrayRef())) {
|
||||
m_ds.m_unlinkedScope = nodep->lhsp();
|
||||
}
|
||||
if (!m_ds.m_dotErr) { // Once something wrong, give up
|
||||
if (start && m_ds.m_dotPos==DP_SCOPE) m_ds.m_dotPos = DP_FINAL; // Top 'final' dot RHS is final RHS, else it's a DOT(DOT(x,*here*),real-rhs) which we consider a RHS
|
||||
nodep->rhsp()->iterateAndNext(*this);
|
||||
@@ -1520,11 +1579,15 @@ private:
|
||||
}
|
||||
if (debug()>=9) newp->dumpTree("-dot-out: ");
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
} else { // Dot midpoint
|
||||
AstNode* newp = nodep->rhsp()->unlinkFrBack();
|
||||
if (m_ds.m_unresolved) {
|
||||
AstCellRef* crp = new AstCellRef(nodep->fileline(), nodep->name(), nodep->lhsp()->unlinkFrBack(), newp);
|
||||
newp = crp;
|
||||
}
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
if (start) {
|
||||
@@ -1541,7 +1604,7 @@ private:
|
||||
if (!m_ds.m_dotSymp) nodep->v3fatalSrc("NULL lookup symbol table");
|
||||
if (!m_statep->forPrimary()) nodep->v3fatalSrc("ParseRefs should no longer exist");
|
||||
DotStates lastStates = m_ds;
|
||||
bool start = !m_ds.m_dotp;
|
||||
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
|
||||
if (start) {
|
||||
m_ds.init(m_curSymp);
|
||||
// Note m_ds.m_dot remains NULL; this is a reference not under a dot
|
||||
@@ -1551,7 +1614,7 @@ private:
|
||||
AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack();
|
||||
AstNode* newp = new AstMemberSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name());
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
else {
|
||||
//
|
||||
@@ -1624,11 +1687,12 @@ private:
|
||||
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); nodep = NULL;
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
else if (AstVar* varp = foundp->nodep()->castVar()) {
|
||||
if (AstIfaceRefDType* ifacerefp = varp->subDTypep()->castIfaceRefDType()) {
|
||||
AstIfaceRefDType* ifacerefp = LinkDotState::ifaceRefFromArray(varp->subDTypep());
|
||||
if (ifacerefp) {
|
||||
if (!ifacerefp->ifaceViaCellp()) ifacerefp->v3fatalSrc("Unlinked interface");
|
||||
// Really this is a scope reference into an interface
|
||||
UINFO(9,"varref-ifaceref "<<m_ds.m_dotText<<" "<<nodep<<endl);
|
||||
@@ -1638,21 +1702,30 @@ private:
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
ok = true;
|
||||
AstNode* newp = new AstVarRef(nodep->fileline(), varp, false);
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL;
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (allowVar) {
|
||||
AstNodeVarRef* newp;
|
||||
AstNode* newp;
|
||||
if (m_ds.m_dotText != "") {
|
||||
newp = new AstVarXRef(nodep->fileline(), nodep->name(), m_ds.m_dotText, false); // lvalue'ness computed later
|
||||
newp->varp(varp);
|
||||
AstVarXRef* refp = new AstVarXRef(nodep->fileline(), nodep->name(),
|
||||
m_ds.m_dotText, false); // lvalue'ness computed later
|
||||
refp->varp(varp);
|
||||
m_ds.m_dotText = "";
|
||||
if (m_ds.m_unresolved && m_ds.m_unlinkedScope) {
|
||||
newp = new AstUnlinkedRef(nodep->fileline(), refp->castVarXRef(),
|
||||
refp->name(), m_ds.m_unlinkedScope->unlinkFrBack());
|
||||
m_ds.m_unlinkedScope = NULL;
|
||||
m_ds.m_unresolved = false;
|
||||
} else {
|
||||
newp = refp;
|
||||
}
|
||||
} else {
|
||||
newp = new AstVarRef(nodep->fileline(), nodep->name(), false); // lvalue'ness computed later
|
||||
newp->varp(varp);
|
||||
newp->packagep(foundp->packagep());
|
||||
UINFO(9," new "<<newp<<endl);
|
||||
AstVarRef* refp = new AstVarRef(nodep->fileline(), varp, false); // lvalue'ness computed later
|
||||
refp->packagep(foundp->packagep());
|
||||
newp = refp;
|
||||
}
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL;
|
||||
UINFO(9," new "<<newp<<endl);
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
m_ds.m_dotPos = DP_MEMBER;
|
||||
ok = true;
|
||||
}
|
||||
@@ -1682,13 +1755,13 @@ private:
|
||||
ok = true;
|
||||
AstVar* varp = makeIfaceModportVar(nodep->fileline(), cellp, ifacep, modportp);
|
||||
AstVarRef* refp = new AstVarRef(varp->fileline(), varp, false);
|
||||
nodep->replaceWith(refp); pushDeletep(nodep); nodep = NULL;
|
||||
nodep->replaceWith(refp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
else if (AstEnumItem* valuep = foundp->nodep()->castEnumItem()) {
|
||||
if (allowVar) {
|
||||
AstNode* newp = new AstEnumItemRef(nodep->fileline(), valuep, foundp->packagep());
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); nodep = NULL;
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
ok = true;
|
||||
m_ds.m_dotText = "";
|
||||
}
|
||||
@@ -1717,7 +1790,7 @@ private:
|
||||
// Create if implicit, and also if error (so only complain once)
|
||||
AstVarRef* newp = new AstVarRef(nodep->fileline(), nodep->name(), false);
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep = NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
createImplicitVar (m_curSymp, newp, m_modp, m_modSymp, err);
|
||||
}
|
||||
}
|
||||
@@ -1795,7 +1868,7 @@ private:
|
||||
UINFO(7," Resolved "<<nodep<<endl); // Also prints taskp
|
||||
AstVarRef* newvscp = new AstVarRef(nodep->fileline(), vscp, nodep->lvalue());
|
||||
nodep->replaceWith(newvscp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
UINFO(9," new "<<newvscp<<endl); // Also prints taskp
|
||||
}
|
||||
}
|
||||
@@ -1831,14 +1904,24 @@ private:
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
m_ds.m_dotp = NULL;
|
||||
} else if (m_ds.m_dotp && m_ds.m_dotPos == DP_FINAL) {
|
||||
nodep->dotted(m_ds.m_dotText); // Maybe ""
|
||||
if (m_ds.m_unresolved && m_ds.m_unlinkedScope) {
|
||||
AstNodeFTaskRef *newftaskp = nodep->cloneTree(false);
|
||||
newftaskp->dotted(m_ds.m_dotText);
|
||||
AstNode* newp = new AstUnlinkedRef(nodep->fileline(), newftaskp, nodep->name(), m_ds.m_unlinkedScope->unlinkFrBack());
|
||||
m_ds.m_unlinkedScope = NULL;
|
||||
m_ds.m_unresolved = false;
|
||||
nodep->replaceWith(newp);
|
||||
return;
|
||||
} else {
|
||||
nodep->dotted(m_ds.m_dotText); // Maybe ""
|
||||
}
|
||||
} else if (m_ds.m_dotp && m_ds.m_dotPos == DP_MEMBER) {
|
||||
// Found a Var, everything following is method call. {scope}.{var}.HERE {method} ( ARGS )
|
||||
AstNode* varEtcp = m_ds.m_dotp->lhsp()->unlinkFrBack();
|
||||
AstNode* argsp = NULL; if (nodep->pinsp()) argsp = nodep->pinsp()->unlinkFrBackWithNext();
|
||||
AstNode* newp = new AstMethodSel(nodep->fileline(), varEtcp, VFlagChildDType(), nodep->name(), argsp);
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
return;
|
||||
} else {
|
||||
checkNoDot(nodep);
|
||||
@@ -1906,12 +1989,9 @@ private:
|
||||
if (nodep->user3SetOnce()) return;
|
||||
nodep->lhsp()->iterateAndNext(*this);
|
||||
if (m_ds.m_dotPos == DP_SCOPE) { // Already under dot, so this is {modulepart} DOT {modulepart}
|
||||
if (AstConst* constp = nodep->rhsp()->castConst()) {
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
m_ds.m_dotText += "__BRA__"+index+"__KET__";
|
||||
} else {
|
||||
nodep->v3error("Unsupported: Non-constant inside []'s in the cell part of a dotted reference");
|
||||
}
|
||||
UINFO(9," deferring until after a V3Param pass: "<<nodep<<endl);
|
||||
m_ds.m_dotText += "__BRA__??__KET__";
|
||||
m_ds.m_unresolved = true;
|
||||
// And pass up m_ds.m_dotText
|
||||
}
|
||||
// Pass dot state down to fromp()
|
||||
@@ -1923,6 +2003,11 @@ private:
|
||||
nodep->attrp()->iterateAndNext(*this);
|
||||
}
|
||||
m_ds = lastStates;
|
||||
if (m_ds.m_unresolved && m_ds.m_dotPos == DP_SCOPE) {
|
||||
AstNode* exprp = nodep->bitp()->unlinkFrBack();
|
||||
AstCellArrayRef* newp = new AstCellArrayRef(nodep->fileline(), nodep->fromp()->name(), exprp);
|
||||
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodePreSel* nodep, AstNUser*) {
|
||||
// Excludes simple AstSelBit, see above
|
||||
@@ -2016,8 +2101,21 @@ private:
|
||||
virtual void visit(AstPackageImport* nodep, AstNUser*) {
|
||||
// No longer needed
|
||||
checkNoDot(nodep);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstCellRef* nodep, AstNUser*) {
|
||||
UINFO(5," AstCellRef: "<<nodep<<" "<<m_ds.ascii()<<endl);
|
||||
nodep->iterateChildren(*this);
|
||||
}
|
||||
virtual void visit(AstCellArrayRef* nodep, AstNUser*) {
|
||||
UINFO(5," AstCellArrayRef: "<<nodep<<" "<<m_ds.ascii()<<endl);
|
||||
// Expression already iterated
|
||||
}
|
||||
virtual void visit(AstUnlinkedRef* nodep, AstNUser*) {
|
||||
UINFO(5," AstCellArrayRef: "<<nodep<<" "<<m_ds.ascii()<<endl);
|
||||
// No need to iterate, if we have a UnlinkedVarXRef, we're already done
|
||||
}
|
||||
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
// Default: Just iterate
|
||||
checkNoDot(nodep);
|
||||
|
||||
+6
-6
@@ -159,7 +159,7 @@ private:
|
||||
initsp = initsp->addNext(newp);
|
||||
newp = initsp;
|
||||
nodep->replaceWith(newp);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstWhile* nodep, AstNUser*) {
|
||||
// Don't need to track AstRepeat/AstFor as they have already been converted
|
||||
@@ -192,7 +192,7 @@ private:
|
||||
AstJumpLabel* labelp = findAddLabel(m_ftaskp, false);
|
||||
nodep->addPrev(new AstJumpGo(nodep->fileline(), labelp));
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstBreak* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
@@ -202,7 +202,7 @@ private:
|
||||
AstJumpLabel* labelp = findAddLabel(m_loopp, false);
|
||||
nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp));
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstContinue* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
@@ -213,7 +213,7 @@ private:
|
||||
AstJumpLabel* labelp = findAddLabel(m_loopp, true);
|
||||
nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp));
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstDisable* nodep, AstNUser*) {
|
||||
UINFO(8," DISABLE "<<nodep<<endl);
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
AstJumpLabel* labelp = findAddLabel(beginp, false);
|
||||
nodep->addNextHere(new AstJumpGo(nodep->fileline(), labelp));
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
//if (debug()>=9) { UINFO(0,"\n"); beginp->dumpTree(cout," labelo: "); }
|
||||
}
|
||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||
@@ -246,7 +246,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
LinkJumpVisitor(AstNetlist* nodep) {
|
||||
explicit LinkJumpVisitor(AstNetlist* nodep) {
|
||||
m_modp = NULL;
|
||||
m_ftaskp = NULL;
|
||||
m_loopp = NULL;
|
||||
|
||||
@@ -211,6 +211,14 @@ private:
|
||||
}
|
||||
m_setRefLvalue = last_setRefLvalue;
|
||||
}
|
||||
virtual void visit(AstCellArrayRef* nodep, AstNUser*) {
|
||||
bool last_setRefLvalue = m_setRefLvalue;
|
||||
{ // selp is not an lvalue
|
||||
m_setRefLvalue = false;
|
||||
nodep->selp()->iterateAndNext(*this);
|
||||
}
|
||||
m_setRefLvalue = last_setRefLvalue;
|
||||
}
|
||||
virtual void visit(AstNodePreSel* nodep, AstNUser*) {
|
||||
bool last_setRefLvalue = m_setRefLvalue;
|
||||
{ // Only set lvalues on the from
|
||||
|
||||
+15
-15
@@ -190,62 +190,62 @@ private:
|
||||
AstTypedef* typep = nodep->backp()->castTypedef();
|
||||
if (!typep) nodep->v3fatalSrc("Attribute not attached to typedef");
|
||||
typep->attrPublic(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_CLOCK) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrScClocked(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_CLOCK_ENABLE) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrClockEn(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_PUBLIC) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->sigUserRWPublic(true); m_varp->sigModPublic(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->sigUserRWPublic(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT_RD) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->sigUserRdPublic(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_PUBLIC_FLAT_RW) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->sigUserRWPublic(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_ISOLATE_ASSIGNMENTS) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrIsolateAssign(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_SFORMAT) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrSFormat(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_SC_BV) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrScBv(true);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_CLOCKER) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrClocker(AstVarAttrClocker::CLOCKER_YES);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->attrType() == AstAttrType::VAR_NO_CLOCKER) {
|
||||
if (!m_varp) nodep->v3fatalSrc("Attribute not attached to variable");
|
||||
m_varp->attrClocker(AstVarAttrClocker::CLOCKER_NO);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ private:
|
||||
if (backp->castTypedef()) { // A typedef doesn't need us to make yet another level of typedefing
|
||||
// For typedefs just remove the AstRefDType level of abstraction
|
||||
nodep->replaceWith(dtypep);
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
return;
|
||||
} else {
|
||||
defp = new AstTypedef(nodep->fileline(), nodep->name(), NULL, VFlagChildDType(), dtypep);
|
||||
@@ -297,7 +297,7 @@ private:
|
||||
}
|
||||
}
|
||||
nodep->replaceWith(new AstRefDType(nodep->fileline(), defp->name()));
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
virtual void visit(AstTypedefFwd* nodep, AstNUser*) {
|
||||
@@ -349,7 +349,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
LinkParseVisitor(AstNetlist* rootp) {
|
||||
explicit LinkParseVisitor(AstNetlist* rootp) {
|
||||
m_varp = NULL;
|
||||
m_modp = NULL;
|
||||
m_ftaskp = NULL;
|
||||
|
||||
+83
-45
@@ -38,6 +38,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "V3Global.h"
|
||||
#include "V3String.h"
|
||||
#include "V3LinkResolve.h"
|
||||
#include "V3Ast.h"
|
||||
|
||||
@@ -82,7 +83,7 @@ private:
|
||||
nodep->iterateChildren(*this);
|
||||
// Initial assignments under function/tasks can just be simple assignments without the initial
|
||||
if (m_ftaskp) {
|
||||
nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); nodep=NULL;
|
||||
nodep->replaceWith(nodep->bodysp()->unlinkFrBackWithNext()); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
virtual void visit(AstVAssert* nodep, AstNUser*) {
|
||||
@@ -167,18 +168,18 @@ private:
|
||||
did=0;
|
||||
if (AstNodeSel* selp = nodep->sensp()->castNodeSel()) {
|
||||
AstNode* fromp = selp->fromp()->unlinkFrBack();
|
||||
selp->replaceWith(fromp); selp->deleteTree(); selp=NULL;
|
||||
selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp);
|
||||
did=1;
|
||||
}
|
||||
// NodeSel doesn't include AstSel....
|
||||
if (AstSel* selp = nodep->sensp()->castSel()) {
|
||||
AstNode* fromp = selp->fromp()->unlinkFrBack();
|
||||
selp->replaceWith(fromp); selp->deleteTree(); selp=NULL;
|
||||
selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp);
|
||||
did=1;
|
||||
}
|
||||
if (AstNodePreSel* selp = nodep->sensp()->castNodePreSel()) {
|
||||
AstNode* fromp = selp->lhsp()->unlinkFrBack();
|
||||
selp->replaceWith(fromp); selp->deleteTree(); selp=NULL;
|
||||
selp->replaceWith(fromp); selp->deleteTree(); VL_DANGLING(selp);
|
||||
did=1;
|
||||
}
|
||||
}
|
||||
@@ -204,6 +205,9 @@ private:
|
||||
if (AstNodeVarRef* varrefp = basefromp->castNodeVarRef()) { // Maybe varxref - so need to clone
|
||||
nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE,
|
||||
varrefp->cloneTree(false)));
|
||||
} else if (AstUnlinkedRef* uvxrp = basefromp->castUnlinkedRef()) { // Maybe unlinked - so need to clone
|
||||
nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::VAR_BASE,
|
||||
uvxrp->cloneTree(false)));
|
||||
} else if (AstMemberSel* fromp = basefromp->castMemberSel()) {
|
||||
nodep->attrp(new AstAttrOf(nodep->fileline(), AstAttrType::MEMBER_BASE,
|
||||
fromp->cloneTree(false)));
|
||||
@@ -233,17 +237,17 @@ private:
|
||||
if (nodep->pragType() == AstPragmaType::PUBLIC_MODULE) {
|
||||
if (!m_modp) nodep->v3fatalSrc("PUBLIC_MODULE not under a module\n");
|
||||
m_modp->modPublic(true);
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
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");
|
||||
m_ftaskp->taskPublic(true);
|
||||
m_modp->modPublic(true); // Need to get to the task...
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
else if (nodep->pragType() == AstPragmaType::COVERAGE_BLOCK_OFF) {
|
||||
if (!v3Global.opt.coverageLine()) { // No need for block statements; may optimize better without
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -251,24 +255,30 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void expectFormat(AstNode* nodep, const string& format, AstNode* argp, bool isScan) {
|
||||
// Check display arguments
|
||||
string expectFormat(AstNode* nodep, const string& format, AstNode* argp, bool isScan) {
|
||||
// Check display arguments, return new format string
|
||||
string newFormat;
|
||||
bool inPct = false;
|
||||
string fmt = "";
|
||||
for (string::const_iterator it = format.begin(); it != format.end(); ++it) {
|
||||
char ch = tolower(*it);
|
||||
char ch = *it;
|
||||
if (!inPct && ch=='%') {
|
||||
inPct = true;
|
||||
fmt = ch;
|
||||
} else if (inPct && (isdigit(ch) || ch=='.')) {
|
||||
fmt += ch;
|
||||
} else if (inPct) {
|
||||
inPct = false;
|
||||
fmt += ch;
|
||||
switch (tolower(ch)) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '.':
|
||||
inPct = true;
|
||||
case '%': // %% - just output a %
|
||||
break;
|
||||
case '%': break; // %% - just output a %
|
||||
case 'm': // %m - auto insert "name"
|
||||
if (isScan) nodep->v3error("Unsupported: %m in $fscanf");
|
||||
if (isScan) { nodep->v3error("Unsupported: %m in $fscanf"); fmt = ""; }
|
||||
break;
|
||||
case 'l': // %l - auto insert "library"
|
||||
if (isScan) { nodep->v3error("Unsupported: %l in $fscanf"); fmt = ""; }
|
||||
if (m_modp) fmt = VString::quotePercent(m_modp->prettyName());
|
||||
break;
|
||||
default: // Most operators, just move to next argument
|
||||
if (!V3Number::displayedFmtLegal(ch)) {
|
||||
@@ -282,11 +292,61 @@ private:
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
newFormat += fmt;
|
||||
} else {
|
||||
newFormat += ch;
|
||||
}
|
||||
}
|
||||
if (argp) {
|
||||
argp->v3error("Extra arguments for $display-like format");
|
||||
|
||||
if (argp && !isScan) {
|
||||
int skipCount = 0; // number of args consume by any additional format strings
|
||||
while (argp) {
|
||||
if (skipCount) {
|
||||
argp = argp->nextp();
|
||||
skipCount--;
|
||||
continue;
|
||||
}
|
||||
AstConst *constp = argp->castConst();
|
||||
bool isFromString = (constp) ? constp->num().isFromString() : false;
|
||||
if (isFromString) {
|
||||
int numchars = argp->dtypep()->width()/8;
|
||||
string str(numchars, ' ');
|
||||
// now scan for % operators
|
||||
bool inpercent = false;
|
||||
for (int i = 0; i < numchars; i++) {
|
||||
int ii = numchars - i - 1;
|
||||
char c = constp->num().dataByte(ii);
|
||||
str[i] = c;
|
||||
if (!inpercent && c == '%') {
|
||||
inpercent = true;
|
||||
} else if (inpercent) {
|
||||
inpercent = 0;
|
||||
switch (c) {
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
case '.':
|
||||
inpercent = true;
|
||||
break;
|
||||
case '%':
|
||||
break;
|
||||
default:
|
||||
if (V3Number::displayedFmtLegal(c)) {
|
||||
skipCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newFormat.append(str);
|
||||
AstNode *nextp = argp->nextp();
|
||||
argp->unlinkFrBack(); pushDeletep(argp); VL_DANGLING(argp);
|
||||
argp = nextp;
|
||||
} else {
|
||||
newFormat.append("%h");
|
||||
argp = argp->nextp();
|
||||
}
|
||||
}
|
||||
}
|
||||
return newFormat;
|
||||
}
|
||||
|
||||
void expectDescriptor(AstNode* nodep, AstNodeVarRef* filep) {
|
||||
@@ -306,23 +366,8 @@ private:
|
||||
nodep->iterateChildren(*this);
|
||||
expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
}
|
||||
virtual void visit(AstFFlush* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
if (nodep->filep()) {
|
||||
expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
}
|
||||
}
|
||||
virtual void visit(AstFGetC* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
}
|
||||
virtual void visit(AstFGetS* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
}
|
||||
virtual void visit(AstFScanF* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
expectFormat(nodep, nodep->text(), nodep->exprsp(), true);
|
||||
}
|
||||
virtual void visit(AstSScanF* nodep, AstNUser*) {
|
||||
@@ -331,7 +376,8 @@ private:
|
||||
}
|
||||
virtual void visit(AstSFormatF* nodep, AstNUser*) {
|
||||
nodep->iterateChildren(*this);
|
||||
expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
nodep->text(newFormat);
|
||||
if ((nodep->backp()->castDisplay() && nodep->backp()->castDisplay()->displayType().needScopeTracking())
|
||||
|| nodep->formatScopeTracking()) {
|
||||
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
||||
@@ -339,14 +385,6 @@ private:
|
||||
}
|
||||
virtual void visit(AstDisplay* nodep, AstNUser* vup) {
|
||||
nodep->iterateChildren(*this);
|
||||
if (nodep->filep()) expectDescriptor(nodep, nodep->filep()->castNodeVarRef());
|
||||
if (!m_assertp
|
||||
&& (nodep->displayType() == AstDisplayType::DT_INFO
|
||||
|| nodep->displayType() == AstDisplayType::DT_WARNING
|
||||
|| nodep->displayType() == AstDisplayType::DT_ERROR
|
||||
|| nodep->displayType() == AstDisplayType::DT_FATAL)) {
|
||||
nodep->v3error(nodep->verilogKwd()+" only allowed under an assertion.");
|
||||
}
|
||||
}
|
||||
|
||||
virtual void visit(AstUdpTable* nodep, AstNUser*) {
|
||||
@@ -372,7 +410,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); nodep=NULL;
|
||||
nodep->unlinkFrBack(); pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +437,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
LinkResolveVisitor(AstNetlist* rootp) {
|
||||
explicit LinkResolveVisitor(AstNetlist* rootp) {
|
||||
m_ftaskp = NULL;
|
||||
m_modp = NULL;
|
||||
m_assertp = NULL;
|
||||
@@ -451,7 +489,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
LinkBotupVisitor(AstNetlist* rootp) {
|
||||
explicit LinkBotupVisitor(AstNetlist* rootp) {
|
||||
m_modp = NULL;
|
||||
//
|
||||
rootp->accept(*this);
|
||||
|
||||
+2
-2
@@ -93,7 +93,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
LocalizeDehierVisitor(AstNetlist* nodep) {
|
||||
explicit LocalizeDehierVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~LocalizeDehierVisitor() {}
|
||||
@@ -233,7 +233,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
LocalizeVisitor(AstNetlist* nodep) {
|
||||
explicit LocalizeVisitor(AstNetlist* nodep) {
|
||||
m_cfuncp = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
NameVisitor(AstNetlist* nodep) {
|
||||
explicit NameVisitor(AstNetlist* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~NameVisitor() {}
|
||||
|
||||
+60
-17
@@ -396,12 +396,12 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
|
||||
|
||||
if (binary) {
|
||||
out<<"b";
|
||||
out<<displayed("%0b");
|
||||
out<<displayed(m_fileline, "%0b");
|
||||
}
|
||||
else {
|
||||
if (prefixed) out<<"h";
|
||||
// Always deal with 4 bits at once. Note no 4-state, it's above.
|
||||
out<<displayed("%0h");
|
||||
out<<displayed(m_fileline, "%0h");
|
||||
}
|
||||
return out.str();
|
||||
}
|
||||
@@ -409,9 +409,8 @@ string V3Number::ascii(bool prefixed, bool cleanVerilog) const {
|
||||
string V3Number::quoteNameControls(const string& namein) {
|
||||
// Encode control chars into C style escapes
|
||||
// Reverse is V3Parse::deQuote
|
||||
const char* start = namein.c_str();
|
||||
string out;
|
||||
for (const char* pos = start; *pos; pos++) {
|
||||
for (string::const_iterator pos=namein.begin(); pos!=namein.end(); ++pos) {
|
||||
if (pos[0]=='\\' || pos[0]=='"') {
|
||||
out += string("\\")+pos[0];
|
||||
} else if (pos[0]=='\n') {
|
||||
@@ -424,7 +423,8 @@ string V3Number::quoteNameControls(const string& namein) {
|
||||
out += pos[0];
|
||||
} else {
|
||||
// This will also cover \a etc
|
||||
char octal[10]; sprintf(octal,"\\%03o",pos[0]);
|
||||
// Can't use %03o as messes up when signed
|
||||
char octal[10]; sprintf(octal,"\\%o%o%o",(pos[0]>>6)&3, (pos[0]>>3)&7, pos[0]&7);
|
||||
out += octal;
|
||||
}
|
||||
}
|
||||
@@ -442,16 +442,20 @@ bool V3Number::displayedFmtLegal(char format) {
|
||||
case 'g': return true;
|
||||
case 'h': return true;
|
||||
case 'o': return true;
|
||||
case 'p': return true; // Pattern
|
||||
case 's': return true;
|
||||
case 't': return true;
|
||||
case 'u': return true; // Packed 2-state
|
||||
case 'v': return true; // Strength
|
||||
case 'x': return true;
|
||||
case 'z': return true; // Packed 4-state
|
||||
case '@': return true; // Packed string
|
||||
case '~': return true; // Signed decimal
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
string V3Number::displayed(const string& vformat) const {
|
||||
string V3Number::displayed(FileLine*fl, const string& vformat) const {
|
||||
string::const_iterator pos = vformat.begin();
|
||||
UASSERT(pos != vformat.end() && pos[0]=='%', "$display-like function with non format argument "<<*this);
|
||||
++pos;
|
||||
@@ -496,14 +500,12 @@ string V3Number::displayed(const string& vformat) const {
|
||||
return str;
|
||||
}
|
||||
case 'c': {
|
||||
if (this->width()>8) m_fileline->v3error("$display-like format of char of > 8 bit value");
|
||||
int v = bitsValue(0, 8);
|
||||
str += (char)(v);
|
||||
if (this->width()>8) fl->v3warn(WIDTH,"$display-like format of %c format of > 8 bit value");
|
||||
unsigned int v = bitsValue(0, 8);
|
||||
char strc[2]; strc[0] = v&0xff; strc[1] = '\0';
|
||||
str = strc;
|
||||
return str;
|
||||
}
|
||||
case '@': { // Packed string
|
||||
return toString();
|
||||
}
|
||||
case 's': {
|
||||
// Spec says always drop leading zeros, this isn't quite right, we space pad.
|
||||
int bit=this->width()-1;
|
||||
@@ -532,7 +534,7 @@ string V3Number::displayed(const string& vformat) const {
|
||||
fmtsize = cvtToStr(int(dchars));
|
||||
}
|
||||
if (width() > 64) {
|
||||
m_fileline->v3error("Unsupported: $display-like format of decimal of > 64 bit results (use hex format instead)");
|
||||
fl->v3error("Unsupported: $display-like format of decimal of > 64 bit results (use hex format instead)");
|
||||
return "ERR";
|
||||
}
|
||||
if (issigned) {
|
||||
@@ -555,8 +557,45 @@ string V3Number::displayed(const string& vformat) const {
|
||||
sprintf(tmp, vformat.c_str(), toDouble());
|
||||
return tmp;
|
||||
}
|
||||
// 'l' // Library - converted to text by V3LinkResolve
|
||||
// 'p' // Packed - converted to another code by V3Width
|
||||
case 'u': { // Packed 2-state
|
||||
for (int i=0; i<words(); i++) {
|
||||
str += (char)((m_value[i] >> 0) & 0xff);
|
||||
str += (char)((m_value[i] >> 8) & 0xff);
|
||||
str += (char)((m_value[i] >> 16) & 0xff);
|
||||
str += (char)((m_value[i] >> 24) & 0xff);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
case 'z': { // Packed 4-state
|
||||
for (int i=0; i<words(); i++) {
|
||||
str += (char)((m_value[i] >> 0) & 0xff);
|
||||
str += (char)((m_value[i] >> 8) & 0xff);
|
||||
str += (char)((m_value[i] >> 16) & 0xff);
|
||||
str += (char)((m_value[i] >> 24) & 0xff);
|
||||
str += (char)((m_valueX[i] >> 0) & 0xff);
|
||||
str += (char)((m_valueX[i] >> 8) & 0xff);
|
||||
str += (char)((m_valueX[i] >> 16) & 0xff);
|
||||
str += (char)((m_valueX[i] >> 24) & 0xff);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
case 'v': { // Strength
|
||||
int bit = width()-1;
|
||||
for (; bit>=0; bit--) {
|
||||
if (bitIs0(bit)) str+="St0 "; // Yes, always a space even for bit 0
|
||||
else if (bitIs1(bit)) str+="St1 ";
|
||||
else if (bitIsZ(bit)) str+="StZ ";
|
||||
else str+="StX";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
case '@': { // Packed string
|
||||
return toString();
|
||||
}
|
||||
default:
|
||||
m_fileline->v3fatalSrc("Unknown $display-like format code for number: %"<<pos[0]);
|
||||
fl->v3fatalSrc("Unknown $display-like format code for number: %"<<pos[0]);
|
||||
return "ERR";
|
||||
}
|
||||
}
|
||||
@@ -939,7 +978,7 @@ V3Number& V3Number::opRepl (const V3Number& lhs, const V3Number& rhs) { // rhs i
|
||||
V3Number& V3Number::opRepl (const V3Number& lhs, uint32_t rhsval) { // rhs is # of times to replicate
|
||||
// i op repl, L(i)*value(rhs) bit return
|
||||
setZero();
|
||||
if (rhsval>8192) m_fileline->v3fatal("More than a 8k bit replication is probably wrong: "<<rhsval);
|
||||
if (rhsval>8192) m_fileline->v3warn(WIDTHCONCAT,"More than a 8k bit replication is probably wrong: "<<rhsval);
|
||||
int obit = 0;
|
||||
for (unsigned times=0; times<rhsval; times++) {
|
||||
for(int bit=0; bit<lhs.width(); bit++) {
|
||||
@@ -1627,14 +1666,18 @@ V3Number& V3Number::opRealToBits (const V3Number& lhs) {
|
||||
if (lhs.width()!=64 || this->width()!=64) {
|
||||
m_fileline->v3fatalSrc("Real operation on wrong sized number");
|
||||
}
|
||||
return opAssign(lhs);
|
||||
opAssign(lhs);
|
||||
m_double = false;
|
||||
return *this;
|
||||
}
|
||||
V3Number& V3Number::opBitsToRealD (const V3Number& lhs) {
|
||||
// Conveniently our internal format is identical so we can copy bits...
|
||||
if (lhs.width()!=64 || this->width()!=64) {
|
||||
m_fileline->v3fatalSrc("Real operation on wrong sized number");
|
||||
}
|
||||
return opAssign(lhs);
|
||||
opAssign(lhs);
|
||||
m_double = true;
|
||||
return *this;
|
||||
}
|
||||
V3Number& V3Number::opNegateD (const V3Number& lhs) {
|
||||
return setDouble(- lhs.toDouble());
|
||||
|
||||
+16
-6
@@ -56,10 +56,19 @@ public:
|
||||
V3Number& setDouble(double value);
|
||||
void setBit (int bit, char value) { // Note must be pre-zeroed!
|
||||
if (bit>=m_width) return;
|
||||
if (value=='0'||value==0) m_value [bit/32] &= ~(1UL<<(bit&31));
|
||||
else {
|
||||
if (value=='1'||value=='x'||value==1||value==3) m_value [bit/32] |= (1UL<<(bit&31));
|
||||
if (value=='z'||value=='x'||value==2||value==3) m_valueX[bit/32] |= (1UL<<(bit&31));
|
||||
uint32_t mask = (1UL<<(bit&31));
|
||||
if (value=='0' || value==0) {
|
||||
m_value [bit/32] &= ~mask;
|
||||
m_valueX[bit/32] &= ~mask;
|
||||
} else if (value=='1'|| value==1) {
|
||||
m_value [bit/32] |= mask;
|
||||
m_valueX[bit/32] &= ~mask;
|
||||
} else if (value=='z'|| value==2) {
|
||||
m_value [bit/32] &= ~mask;
|
||||
m_valueX[bit/32] |= mask;
|
||||
} else { // X
|
||||
m_value [bit/32] |= mask;
|
||||
m_valueX[bit/32] |= mask;
|
||||
}
|
||||
}
|
||||
private:
|
||||
@@ -120,7 +129,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
V3Number(FileLine* fileline) { init(fileline, 1); }
|
||||
explicit V3Number(FileLine* fileline) { init(fileline, 1); }
|
||||
V3Number(FileLine* fileline, int width) { init(fileline, width); } // 0=unsized
|
||||
V3Number(FileLine* fileline, int width, uint32_t value) { init(fileline, width); m_value[0]=value; opCleanThis(); }
|
||||
V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number.
|
||||
@@ -162,7 +171,7 @@ public:
|
||||
// ACCESSORS
|
||||
string ascii(bool prefixed=true, bool cleanVerilog=false) const;
|
||||
static string quoteNameControls(const string& namein); // Add backslash quotes to strings
|
||||
string displayed(const string& format) const;
|
||||
string displayed(FileLine* fl, const string& format) const;
|
||||
static bool displayedFmtLegal(char format); // Is this a valid format letter?
|
||||
int width() const { return m_width; }
|
||||
int widthMin() const; // Minimum width that can represent this number (~== log2(num)+1)
|
||||
@@ -196,6 +205,7 @@ public:
|
||||
double toDouble() const;
|
||||
uint32_t toHash() const;
|
||||
uint32_t dataWord(int word) const;
|
||||
uint8_t dataByte(int byte) const { return (dataWord(byte/4) >> (8*(byte&3))) & 0xff; }
|
||||
uint32_t countOnes() const;
|
||||
uint32_t mostSetBitP1() const; // Highest bit set plus one, IE for 16 return 5, for 0 return 0.
|
||||
|
||||
|
||||
+22
-13
@@ -563,9 +563,9 @@ bool V3Options::onoff(const char* sw, const char* arg, bool& flag) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool V3Options::suffixed(const char* sw, const char* arg) {
|
||||
if (strlen(arg) > strlen(sw)) return false;
|
||||
return (0==strcmp(sw+strlen(sw)-strlen(arg), arg));
|
||||
bool V3Options::suffixed(const string& sw, const char* arg) {
|
||||
if (strlen(arg) > sw.length()) return false;
|
||||
return (0==strcmp(sw.c_str()+sw.length()-strlen(arg), arg));
|
||||
}
|
||||
|
||||
void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char** argv) {
|
||||
@@ -672,6 +672,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
else if ( onoff (sw, "-trace-structs", flag/*ref*/) ) { m_traceStructs = flag; }
|
||||
else if ( onoff (sw, "-trace-underscore", flag/*ref*/) ) { m_traceUnderscore = flag; }
|
||||
else if ( onoff (sw, "-underline-zero", flag/*ref*/) ) { m_underlineZero = flag; } // Undocumented, old Verilator-2
|
||||
else if ( onoff (sw, "-vpi", flag/*ref*/) ) { m_vpi = flag; }
|
||||
else if ( onoff (sw, "-x-initial-edge", flag/*ref*/) ) { m_xInitialEdge = flag; }
|
||||
else if ( onoff (sw, "-xml-only", flag/*ref*/) ) { m_xmlOnly = flag; } // Undocumented, still experimental
|
||||
// Optimization
|
||||
@@ -711,6 +712,10 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
shift;
|
||||
addCFlags(argv[i]);
|
||||
}
|
||||
else if ( !strcmp (sw, "-comp-limits-syms") && (i+1)<argc ) { // Undocumented
|
||||
shift;
|
||||
VName::maxLength(atoi(argv[i]));
|
||||
}
|
||||
else if ( !strcmp (sw, "-converge-limit") && (i+1)<argc ) {
|
||||
shift;
|
||||
m_convergeLimit = atoi(argv[i]);
|
||||
@@ -957,16 +962,16 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
|
||||
else {
|
||||
// Filename
|
||||
string filename = parseFileArg(optdir,argv[i]);
|
||||
if (suffixed(filename.c_str(), ".cpp")
|
||||
|| suffixed(filename.c_str(), ".cxx")
|
||||
|| suffixed(filename.c_str(), ".cc")
|
||||
|| suffixed(filename.c_str(), ".c")
|
||||
|| suffixed(filename.c_str(), ".sp")) {
|
||||
if (suffixed(filename, ".cpp")
|
||||
|| suffixed(filename, ".cxx")
|
||||
|| suffixed(filename, ".cc")
|
||||
|| suffixed(filename, ".c")
|
||||
|| suffixed(filename, ".sp")) {
|
||||
V3Options::addCppFile(filename);
|
||||
}
|
||||
else if (suffixed(filename.c_str(), ".a")
|
||||
|| suffixed(filename.c_str(), ".o")
|
||||
|| suffixed(filename.c_str(), ".so")) {
|
||||
else if (suffixed(filename, ".a")
|
||||
|| suffixed(filename, ".o")
|
||||
|| suffixed(filename, ".so")) {
|
||||
V3Options::addLdLibs(filename);
|
||||
}
|
||||
else {
|
||||
@@ -984,7 +989,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
||||
// Read the specified -f filename and process as arguments
|
||||
UINFO(1,"Reading Options File "<<filename<<endl);
|
||||
|
||||
const auto_ptr<ifstream> ifp (V3File::new_ifstream(filename));
|
||||
const VL_UNIQUE_PTR<ifstream> ifp (V3File::new_ifstream(filename));
|
||||
if (ifp->fail()) {
|
||||
fl->v3error("Cannot open -f command file: "+filename);
|
||||
return;
|
||||
@@ -997,6 +1002,7 @@ void V3Options::parseOptsFile(FileLine* fl, const string& filename, bool rel) {
|
||||
getline(*ifp, line);
|
||||
// Strip simple comments
|
||||
string oline;
|
||||
// cppcheck-suppress StlMissingComparison
|
||||
for (string::const_iterator pos = line.begin(); pos != line.end(); ++pos) {
|
||||
if (inCmt) {
|
||||
if (*pos=='*' && *(pos+1)=='/') {
|
||||
@@ -1150,6 +1156,7 @@ V3Options::V3Options() {
|
||||
m_preprocOnly = false;
|
||||
m_preprocNoLine = false;
|
||||
m_public = false;
|
||||
m_reportUnoptflat = false;
|
||||
m_savable = false;
|
||||
m_skipIdentical = true;
|
||||
m_stats = false;
|
||||
@@ -1162,7 +1169,7 @@ V3Options::V3Options() {
|
||||
m_traceStructs = false;
|
||||
m_traceUnderscore = false;
|
||||
m_underlineZero = false;
|
||||
m_reportUnoptflat = false;
|
||||
m_vpi = false;
|
||||
m_xInitialEdge = false;
|
||||
m_xmlOnly = false;
|
||||
|
||||
@@ -1190,6 +1197,8 @@ V3Options::V3Options() {
|
||||
|
||||
m_defaultLanguage = V3LangCode::mostRecent();
|
||||
|
||||
VName::maxLength(128); // Linux filename limits 256; leave half for prefix
|
||||
|
||||
optimize(true);
|
||||
// Default +libext+
|
||||
addLibExtV(""); // So include "filename.v" will find the same file
|
||||
|
||||
+6
-2
@@ -85,6 +85,7 @@ class V3Options {
|
||||
bool m_pinsUint8; // main switch: --pins-uint8
|
||||
bool m_profileCFuncs;// main switch: --profile-cfuncs
|
||||
bool m_public; // main switch: --public
|
||||
bool m_reportUnoptflat; // main switch: --report-unoptflat
|
||||
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
|
||||
@@ -97,7 +98,7 @@ class V3Options {
|
||||
bool m_traceStructs; // main switch: --trace-structs
|
||||
bool m_traceUnderscore;// main switch: --trace-underscore
|
||||
bool m_underlineZero;// main switch: --underline-zero; undocumented old Verilator 2
|
||||
bool m_reportUnoptflat; // main switch: --report-unoptflat
|
||||
bool m_vpi; // main switch: --vpi
|
||||
bool m_xInitialEdge; // main switch: --x-initial-edge
|
||||
bool m_xmlOnly; // main switch: --xml-netlist
|
||||
|
||||
@@ -167,13 +168,15 @@ class V3Options {
|
||||
void showVersion(bool verbose);
|
||||
void coverage(bool flag) { m_coverageLine = m_coverageToggle = m_coverageUser = flag; }
|
||||
bool onoff(const char* sw, const char* arg, bool& flag);
|
||||
bool suffixed(const char* sw, const char* arg);
|
||||
bool suffixed(const string& sw, const char* arg);
|
||||
string parseFileArg(const string& optdir, const string& relfilename);
|
||||
bool parseLangExt(const char* swp, const char* langswp, const V3LangCode& lc);
|
||||
string filePathCheckOneDir(const string& modname, const string& dirname);
|
||||
|
||||
static string getenvSYSTEMPERLGuts();
|
||||
|
||||
V3Options(const V3Options&); ///< N/A, no copy constructor
|
||||
|
||||
public:
|
||||
// CREATORS
|
||||
V3Options();
|
||||
@@ -239,6 +242,7 @@ class V3Options {
|
||||
bool ignc() const { return m_ignc; }
|
||||
bool inhibitSim() const { return m_inhibitSim; }
|
||||
bool reportUnoptflat() const { return m_reportUnoptflat; }
|
||||
bool vpi() const { return m_vpi; }
|
||||
bool xInitialEdge() const { return m_xInitialEdge; }
|
||||
bool xmlOnly() const { return m_xmlOnly; }
|
||||
|
||||
|
||||
+6
-6
@@ -363,7 +363,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
OrderClkMarkVisitor(AstNode* nodep) {
|
||||
explicit OrderClkMarkVisitor(AstNode* nodep) {
|
||||
m_hasClk = false;
|
||||
m_inClocked = false;
|
||||
m_inAss = false;
|
||||
@@ -410,7 +410,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
OrderClkAssVisitor(AstNode* nodep) {
|
||||
explicit OrderClkAssVisitor(AstNode* nodep) {
|
||||
m_clkAss = false;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -1265,7 +1265,7 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
|
||||
domainp->dumpTree(cout);
|
||||
cout<<endl;
|
||||
}
|
||||
newtreep->deleteTree(); newtreep=NULL;
|
||||
newtreep->deleteTree(); VL_DANGLING(newtreep);
|
||||
}
|
||||
}
|
||||
} // next input edgep
|
||||
@@ -1476,7 +1476,7 @@ void OrderVisitor::processMoveDoneOne(OrderMoveVertex* vertexp) {
|
||||
UINFO(9," Clear to "<<(toVertexp->inEmpty()?"[EMP] ":" ")
|
||||
<<toVertexp<<endl);
|
||||
// Delete this edge
|
||||
edgep->unlinkDelete(); edgep=NULL;
|
||||
edgep->unlinkDelete(); VL_DANGLING(edgep);
|
||||
if (toVertexp->inEmpty()) {
|
||||
// If destination node now has all inputs resolved; recurse to move that vertex
|
||||
// This is thus depth first (before width) which keeps the resulting executable's d-cache happy.
|
||||
@@ -1530,7 +1530,7 @@ void OrderVisitor::processMoveOne(OrderMoveVertex* vertexp, OrderMoveDomScope* d
|
||||
nodep->unlinkFrBack();
|
||||
if (domainp == m_deleteDomainp) {
|
||||
UINFO(4," Ordering deleting pre-settled "<<nodep<<endl);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
} else {
|
||||
m_pomNewFuncp->addStmtsp(nodep);
|
||||
if (v3Global.opt.outputSplitCFuncs()) {
|
||||
@@ -1646,7 +1646,7 @@ void OrderVisitor::process() {
|
||||
m_graph.dumpDotFilePrefixed("orderg_done");
|
||||
if (0 && debug()) {
|
||||
string dfilename = v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+"_INT_order.tree";
|
||||
const auto_ptr<ofstream> logp (V3File::new_ofstream(dfilename));
|
||||
const VL_UNIQUE_PTR<ofstream> logp (V3File::new_ofstream(dfilename));
|
||||
if (logp->fail()) v3fatalSrc("Can't write "<<dfilename);
|
||||
m_graph.dump(*logp);
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ struct OrderVEdgeType {
|
||||
}
|
||||
enum en m_e;
|
||||
inline OrderVEdgeType () : m_e(VERTEX_UNKNOWN) {}
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
inline OrderVEdgeType (en _e) : m_e(_e) {}
|
||||
explicit inline OrderVEdgeType (int _e) : m_e(static_cast<en>(_e)) {}
|
||||
operator en () const { return m_e; }
|
||||
|
||||
+96
-20
@@ -88,7 +88,7 @@ private:
|
||||
struct ModInfo {
|
||||
AstNodeModule* m_modp; // Module with specified name
|
||||
VarCloneMap m_cloneMap; // Map of old-varp -> new cloned varp
|
||||
ModInfo(AstNodeModule* modp) { m_modp=modp; }
|
||||
explicit ModInfo(AstNodeModule* modp) { m_modp=modp; }
|
||||
};
|
||||
typedef map<string,ModInfo> ModNameMap;
|
||||
ModNameMap m_modNameMap; // Hash of created module flavors by name
|
||||
@@ -108,6 +108,8 @@ private:
|
||||
typedef deque<AstCell*> CellList;
|
||||
CellList m_cellps; // Cells left to process (in this module)
|
||||
|
||||
string m_unlinkedTxt; // Text for AstUnlinkedRef
|
||||
|
||||
// METHODS
|
||||
static int debug() {
|
||||
static int level = -1;
|
||||
@@ -137,7 +139,7 @@ private:
|
||||
char ch = varp->user4()&255;
|
||||
string st = cvtToStr(ch);
|
||||
while (index) {
|
||||
st += cvtToStr(char((index%26)+'A'));
|
||||
st += cvtToStr(char((index%25)+'A'));
|
||||
index /= 26;
|
||||
}
|
||||
return st;
|
||||
@@ -146,7 +148,7 @@ private:
|
||||
// Given a compilcated object create a number to use for param module assignment
|
||||
// Ideally would be relatively stable if design changes (not use pointer value),
|
||||
// and must return same value given same input node
|
||||
// Return must presently be numberic so doesn't collide with 'small' alphanumeric parameter names
|
||||
// Return must presently be numeric so doesn't collide with 'small' alphanumeric parameter names
|
||||
ValueMap::iterator it = m_valueMap.find(nodep);
|
||||
if (it != m_valueMap.end()) {
|
||||
return cvtToStr(it->second);
|
||||
@@ -160,7 +162,8 @@ private:
|
||||
else { m_nextValueMap.insert(make_pair(bucket, offset + 1)); }
|
||||
int num = bucket + offset * BUCKETS;
|
||||
m_valueMap.insert(make_pair(nodep, num));
|
||||
return cvtToStr(num);
|
||||
// 'z' just to make sure we don't collide with a normal non-hashed number
|
||||
return (string)"z"+cvtToStr(num);
|
||||
}
|
||||
}
|
||||
void relinkPins(VarCloneMap* clonemapp, AstPin* startpinp) {
|
||||
@@ -248,6 +251,47 @@ private:
|
||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||
if (nodep->varp()) nodep->varp()->iterate(*this);
|
||||
}
|
||||
virtual void visit(AstVarXRef* nodep, AstNUser*) {
|
||||
nodep->varp(NULL); // Needs relink, as may remove pointed-to var
|
||||
}
|
||||
|
||||
virtual void visit(AstUnlinkedRef* nodep, AstNUser*) {
|
||||
AstVarXRef* varxrefp = nodep->op1p()->castVarXRef();
|
||||
AstNodeFTaskRef* taskrefp = nodep->op1p()->castNodeFTaskRef();
|
||||
if (varxrefp) {
|
||||
m_unlinkedTxt = varxrefp->dotted();
|
||||
} else if (taskrefp) {
|
||||
m_unlinkedTxt = taskrefp->dotted();
|
||||
} else {
|
||||
nodep->v3fatalSrc("Unexpected AstUnlinkedRef node");
|
||||
return;
|
||||
}
|
||||
nodep->cellrefp()->iterate(*this);
|
||||
|
||||
if (varxrefp) {
|
||||
varxrefp->dotted(m_unlinkedTxt);
|
||||
} else {
|
||||
taskrefp->dotted(m_unlinkedTxt);
|
||||
}
|
||||
nodep->replaceWith(nodep->op1p()->unlinkFrBack());
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstCellArrayRef* nodep, AstNUser*) {
|
||||
V3Const::constifyParamsEdit(nodep->selp());
|
||||
if (AstConst* constp = nodep->selp()->castConst()) {
|
||||
string index = AstNode::encodeNumber(constp->toSInt());
|
||||
string replacestr = nodep->name() + "__BRA__??__KET__";
|
||||
size_t pos = m_unlinkedTxt.find(replacestr);
|
||||
if (pos == string::npos) {
|
||||
nodep->v3error("Could not find array index in unlinked text: '" << m_unlinkedTxt << "' for node: " << nodep);
|
||||
return;
|
||||
}
|
||||
m_unlinkedTxt.replace(pos, replacestr.length(), nodep->name() + "__BRA__"+index+"__KET__");
|
||||
} else {
|
||||
nodep->v3error("Could not expand constant selection inside dotted reference: "<<nodep->selp()->prettyName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate Statements
|
||||
virtual void visit(AstGenerate* nodep, AstNUser*) {
|
||||
@@ -262,7 +306,7 @@ private:
|
||||
} else {
|
||||
nodep->unlinkFrBack();
|
||||
}
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstGenIf* nodep, AstNUser*) {
|
||||
UINFO(9," GENIF "<<nodep<<endl);
|
||||
@@ -283,7 +327,7 @@ private:
|
||||
} else {
|
||||
nodep->unlinkFrBack();
|
||||
}
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
// Normal edit rules will now recurse the replacement
|
||||
} else {
|
||||
nodep->condp()->v3error("Generate If condition must evaluate to constant");
|
||||
@@ -310,7 +354,7 @@ private:
|
||||
string beginName = nodep->name();
|
||||
// Leave the original Begin, as need a container for the (possible) GENVAR
|
||||
// Note V3Unroll will replace some AstVarRef's to the loop variable with constants
|
||||
V3Unroll::unrollGen(forp, beginName); forp=NULL;
|
||||
V3Unroll::unrollGen(forp, beginName); VL_DANGLING(forp);
|
||||
// Blocks were constructed under the special begin, move them up
|
||||
// Note forp is null, so grab statements again
|
||||
if (AstNode* stmtsp = nodep->genforp()) {
|
||||
@@ -339,8 +383,7 @@ private:
|
||||
for (AstNode* ep = itemp->condsp(); ep; ) {
|
||||
AstNode* nextp = ep->nextp(); //May edit list
|
||||
ep->iterateAndNext(*this);
|
||||
V3Const::constifyParamsEdit(ep); ep=NULL; // ep may change
|
||||
// cppcheck-suppress redundantAssignment
|
||||
V3Const::constifyParamsEdit(ep); VL_DANGLING(ep); // ep may change
|
||||
ep = nextp;
|
||||
}
|
||||
}
|
||||
@@ -372,7 +415,7 @@ private:
|
||||
nodep->replaceWith(keepp);
|
||||
}
|
||||
else nodep->unlinkFrBack();
|
||||
nodep->deleteTree(); nodep=NULL;
|
||||
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
// Default: Just iterate
|
||||
@@ -382,7 +425,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ParamVisitor(AstNetlist* nodep) {
|
||||
explicit ParamVisitor(AstNetlist* nodep) {
|
||||
m_longId = 0;
|
||||
//
|
||||
nodep->accept(*this);
|
||||
@@ -431,9 +474,13 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
// Setting parameter to its default value. Just ignore it.
|
||||
// This prevents making additional modules, and makes coverage more
|
||||
// obvious as it won't show up under a unique module page name.
|
||||
} else {
|
||||
} else if (!constp->num().isDouble() && !constp->num().isString()
|
||||
&& !constp->num().isFourState() && !constp->num().isNegative()) {
|
||||
longname += "_" + paramSmallName(nodep->modp(),pinp->modVarp())+constp->num().ascii(false);
|
||||
any_overrides = true;
|
||||
} else {
|
||||
longname += "_" + paramSmallName(nodep->modp(),pinp->modVarp())+paramValueNumber(constp);
|
||||
any_overrides = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,16 +489,44 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
AstVar* modvarp = pinp->modVarp();
|
||||
if (modvarp->isIfaceRef()) {
|
||||
AstIfaceRefDType* portIrefp = modvarp->subDTypep()->castIfaceRefDType();
|
||||
//UINFO(9," portIfaceRef "<<portIrefp<<endl);
|
||||
if (!pinp->exprp()
|
||||
|| !pinp->exprp()->castVarRef()
|
||||
|| !pinp->exprp()->castVarRef()->varp()
|
||||
|| !pinp->exprp()->castVarRef()->varp()->subDTypep()
|
||||
|| !pinp->exprp()->castVarRef()->varp()->subDTypep()->castIfaceRefDType()) {
|
||||
if (!portIrefp) {
|
||||
portIrefp = modvarp->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
}
|
||||
|
||||
AstIfaceRefDType* pinIrefp = NULL;
|
||||
AstNode* exprp = pinp->exprp();
|
||||
if (exprp
|
||||
&& exprp->castVarRef()
|
||||
&& exprp->castVarRef()->varp()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()->castIfaceRefDType())
|
||||
pinIrefp = exprp->castVarRef()->varp()->subDTypep()->castIfaceRefDType();
|
||||
else if (exprp
|
||||
&& exprp->op1p()
|
||||
&& exprp->op1p()->castVarRef()
|
||||
&& exprp->op1p()->castVarRef()->varp()
|
||||
&& exprp->op1p()->castVarRef()->varp()->subDTypep()
|
||||
&& exprp->op1p()->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()
|
||||
&& exprp->op1p()->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()
|
||||
&& exprp->op1p()->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType())
|
||||
pinIrefp = exprp->op1p()->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
else if (exprp
|
||||
&& exprp->castVarRef()
|
||||
&& exprp->castVarRef()->varp()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()
|
||||
&& exprp->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType())
|
||||
pinIrefp = exprp->castVarRef()->varp()->subDTypep()->castUnpackArrayDType()->subDTypep()->castIfaceRefDType();
|
||||
|
||||
UINFO(9," portIfaceRef "<<portIrefp<<endl);
|
||||
|
||||
if (!portIrefp) {
|
||||
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 {
|
||||
AstIfaceRefDType* pinIrefp = pinp->exprp()->castVarRef()->varp()->subDTypep()->castIfaceRefDType();
|
||||
//UINFO(9," pinIfaceRef "<<pinIrefp<<endl);
|
||||
UINFO(9," pinIfaceRef "<<pinIrefp<<endl);
|
||||
if (portIrefp->ifaceViaCellp() != pinIrefp->ifaceViaCellp()) {
|
||||
UINFO(9," IfaceRefDType needs reconnect "<<pinIrefp<<endl);
|
||||
longname += "_" + paramSmallName(nodep->modp(),pinp->modVarp())+paramValueNumber(pinIrefp);
|
||||
@@ -467,6 +542,7 @@ void ParamVisitor::visitCell(AstCell* nodep) {
|
||||
} else {
|
||||
// If the name is very long, we don't want to overwhelm the filename limit
|
||||
// We don't do this always, as it aids debugability to have intuitive naming.
|
||||
// TODO can use new V3Name hash replacement instead of this
|
||||
string newname = longname;
|
||||
if (longname.length()>30) {
|
||||
LongMap::iterator iter = m_longMap.find(longname);
|
||||
|
||||
@@ -36,6 +36,7 @@ class V3Parse {
|
||||
private:
|
||||
V3ParseImp* m_impp;
|
||||
|
||||
V3Parse(const V3Parse&); ///< N/A, no copy constructor
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
// We must allow reading multiple files into one parser
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
|
||||
}
|
||||
if (ofp) {
|
||||
ofp->close();
|
||||
delete ofp; ofp = NULL;
|
||||
delete ofp; VL_DANGLING(ofp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public:
|
||||
}
|
||||
public:
|
||||
// CREATORS
|
||||
V3ParseSym(AstNetlist* rootp)
|
||||
explicit V3ParseSym(AstNetlist* rootp)
|
||||
: m_syms(rootp) {
|
||||
s_anonNum = 0; // Number of next anonymous object
|
||||
pushScope(findNewTable(rootp));
|
||||
|
||||
+1
-1
@@ -1074,7 +1074,7 @@ int V3PreProcImp::getStateToken() {
|
||||
out = defineSubst(refp);
|
||||
//NOP: out = m_preprocp->defSubstitute(out);
|
||||
}
|
||||
m_defRefs.pop(); refp=NULL;
|
||||
m_defRefs.pop(); VL_DANGLING(refp);
|
||||
if (m_defRefs.empty()) {
|
||||
statePop();
|
||||
if (!m_off) unputDefrefString(out);
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
PremitAssignVisitor(AstNodeAssign* nodep) {
|
||||
explicit PremitAssignVisitor(AstNodeAssign* nodep) {
|
||||
UINFO(4," PremitAssignVisitor on "<<nodep<<endl);
|
||||
m_noopt = false;
|
||||
nodep->accept(*this);
|
||||
@@ -383,7 +383,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
PremitVisitor(AstNetlist* nodep) {
|
||||
explicit PremitVisitor(AstNetlist* nodep) {
|
||||
m_modp = NULL;
|
||||
m_funcp = NULL;
|
||||
m_stmtp = NULL;
|
||||
|
||||
+3
-3
@@ -294,7 +294,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ScopeVisitor(AstNetlist* nodep) {
|
||||
explicit ScopeVisitor(AstNetlist* nodep) {
|
||||
m_aboveCellp = NULL;
|
||||
m_aboveScopep = NULL;
|
||||
m_modp = NULL;
|
||||
@@ -334,7 +334,7 @@ private:
|
||||
nodep->iterateChildren(*this);
|
||||
} else {
|
||||
// A block that was just moved under a scope, Kill it.
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
ScopeCleanupVisitor(AstNetlist* nodep) {
|
||||
explicit ScopeCleanupVisitor(AstNetlist* nodep) {
|
||||
m_scopep = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
|
||||
+143
-40
@@ -255,13 +255,15 @@ private:
|
||||
virtual void visit(AstVarRef* nodep, AstNUser*) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
if (!optimizable()) return; // Accelerate
|
||||
nodep->varp()->iterateChildren(*this);
|
||||
AstNode* vscp = varOrScope(nodep);
|
||||
|
||||
// We can't have non-delayed assignments with same value on LHS and RHS
|
||||
// as we don't figure out variable ordering.
|
||||
// Delayed is OK though, as we'll decode the next state separately.
|
||||
if (!nodep->varp()->dtypeSkipRefp()->castBasicDType()
|
||||
&& !nodep->varp()->dtypeSkipRefp()->castPackArrayDType())
|
||||
&& !nodep->varp()->dtypeSkipRefp()->castPackArrayDType()
|
||||
&& !nodep->varp()->dtypeSkipRefp()->castStructDType())
|
||||
clearOptimizable(nodep,"Array references/not basic");
|
||||
if (nodep->lvalue()) {
|
||||
if (m_inDlyAssign) {
|
||||
@@ -281,10 +283,10 @@ private:
|
||||
if (!m_params && (vscp->user1() & VU_LV)) clearOptimizable(nodep,"Var write & read");
|
||||
vscp->user1( vscp->user1() | VU_RV);
|
||||
bool isConst = nodep->varp()->isParam();
|
||||
AstConst* constp = (isConst ? nodep->varp()->valuep()->castConst() : NULL);
|
||||
if (isConst && constp) { // Propagate PARAM constants for constant function analysis
|
||||
V3Number* nump = isConst ? fetchNumberNull(nodep->varp()->valuep()) : NULL;
|
||||
if (isConst && nump) { // Propagate PARAM constants for constant function analysis
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
newNumber(vscp)->opAssign(constp->num());
|
||||
newNumber(vscp)->opAssign(*nump);
|
||||
}
|
||||
} else {
|
||||
if (m_checkOnly) varRefCb (nodep);
|
||||
@@ -344,6 +346,19 @@ private:
|
||||
setNumber(nodep, &(nodep->num()));
|
||||
}
|
||||
}
|
||||
virtual void visit(AstEnumItemRef* nodep, AstNUser*) {
|
||||
checkNodeInfo(nodep);
|
||||
if (!nodep->itemp()) nodep->v3fatalSrc("Not linked");
|
||||
if (!m_checkOnly && optimizable()) {
|
||||
AstNode* valuep = nodep->itemp()->valuep();
|
||||
if (valuep) {
|
||||
valuep->iterateAndNext(*this);
|
||||
newNumber(nodep)->opAssign(*fetchNumber(valuep));
|
||||
} else {
|
||||
clearOptimizable(nodep, "No value found for enum item");
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void visit(AstNodeUniop* nodep, AstNUser*) {
|
||||
if (!optimizable()) return; // Accelerate
|
||||
checkNodeInfo(nodep);
|
||||
@@ -437,6 +452,56 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool handleAssignSel(AstNodeAssign* nodep, AstSel* selp, AstVarRef** outVarrefp, int depth) {
|
||||
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);
|
||||
|
||||
if (optimizable()) {
|
||||
AstNode* vscp;
|
||||
if (varrefp) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (outVarrefp) *outVarrefp = varrefp;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void visit(AstNodeAssign* nodep, AstNUser*) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
if (!optimizable()) return; // Accelerate
|
||||
@@ -448,41 +513,10 @@ private:
|
||||
if (m_anyAssignDly) clearOptimizable(nodep, "Mix of dly/non-dly assigns");
|
||||
m_anyAssignComb = true;
|
||||
}
|
||||
|
||||
if (AstSel* selp = nodep->lhsp()->castSel()) {
|
||||
if (!m_params) { clearOptimizable(nodep, "LHS has select"); return; }
|
||||
checkNodeInfo(selp);
|
||||
AstVarRef* varrefp = selp->fromp()->castVarRef();
|
||||
if (!varrefp) {
|
||||
clearOptimizable(nodep, "Select LHS isn't simple variable");
|
||||
return;
|
||||
}
|
||||
if (m_checkOnly) {
|
||||
nodep->iterateChildren(*this);
|
||||
} else {
|
||||
selp->lsbp()->iterateAndNext(*this);
|
||||
nodep->rhsp()->iterateAndNext(*this);
|
||||
if (optimizable()) {
|
||||
AstNode* vscp = varOrScope(varrefp);
|
||||
if (optimizable()) {
|
||||
V3Number outnum (nodep->fileline(), varrefp->varp()->widthMin());
|
||||
if (V3Number* outnump = fetchOutNumberNull(vscp)) {
|
||||
outnum = *outnump;
|
||||
} else if (V3Number* outnump = fetchNumberNull(vscp)) {
|
||||
outnum = *outnump;
|
||||
} else { // Assignment to unassigned variable, all bits are X or 0
|
||||
if (varrefp->varp()->basicp() && varrefp->varp()->basicp()->isZeroInit()) {
|
||||
outnum.setAllBits0();
|
||||
} else {
|
||||
outnum.setAllBitsX();
|
||||
}
|
||||
}
|
||||
outnum.opSelInto(*fetchNumber(nodep->rhsp()),
|
||||
*fetchNumber(selp->lsbp()),
|
||||
selp->widthConst());
|
||||
assignOutNumber(nodep, vscp, &outnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
handleAssignSel(nodep, selp, NULL, 0);
|
||||
}
|
||||
else if (!nodep->lhsp()->castVarRef()) {
|
||||
clearOptimizable(nodep, "LHS isn't simple variable");
|
||||
@@ -566,6 +600,7 @@ private:
|
||||
}
|
||||
}
|
||||
virtual void visit(AstStop* nodep, AstNUser*) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
if (m_params) { // This message seems better than an obscure $stop
|
||||
// The spec says $stop is just ignored, it seems evil to ignore assertions
|
||||
clearOptimizable(nodep,"$stop executed during function constification; maybe indicates assertion firing");
|
||||
@@ -639,8 +674,7 @@ private:
|
||||
UINFO(5," FUNCREF "<<nodep<<endl);
|
||||
if (!m_params) { badNodeType(nodep); return; }
|
||||
AstNodeFTask* funcp = nodep->taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked");
|
||||
// cppcheck-suppress redundantAssignment
|
||||
if (m_params) { V3Width::widthParamsEdit(funcp); } funcp=NULL; // Make sure we've sized the function
|
||||
if (m_params) { V3Width::widthParamsEdit(funcp); } VL_DANGLING(funcp); // Make sure we've sized the function
|
||||
funcp = nodep->taskp()->castNodeFTask(); if (!funcp) nodep->v3fatalSrc("Not linked");
|
||||
// Apply function call values to function
|
||||
V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp());
|
||||
@@ -682,9 +716,78 @@ private:
|
||||
if (!m_params) { badNodeType(nodep); return; }
|
||||
}
|
||||
|
||||
virtual void visit(AstSFormatF *nodep, AstNUser *) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
nodep->iterateChildren(*this);
|
||||
if (m_params) {
|
||||
AstNode* nextArgp = nodep->exprsp();
|
||||
|
||||
string result = "";
|
||||
string format = nodep->text();
|
||||
string::const_iterator pos = format.begin();
|
||||
bool inPct = false;
|
||||
for (; pos != format.end(); ++pos) {
|
||||
if (!inPct && pos[0] == '%') {
|
||||
inPct = true;
|
||||
} else if (!inPct) { // Normal text
|
||||
result += *pos;
|
||||
} else { // Format character
|
||||
AstNode* argp = nextArgp;
|
||||
inPct = false;
|
||||
nextArgp = nextArgp->nextp();
|
||||
|
||||
if (V3Number::displayedFmtLegal(tolower(pos[0]))) {
|
||||
V3Number* nump = fetchNumberNull(argp);
|
||||
if (!nump) {
|
||||
clearOptimizable(nodep, "Argument for $display like statement is not constant");
|
||||
break;
|
||||
}
|
||||
string format = string("%") + pos[0];
|
||||
result += nump->displayed(nodep->fileline(), format);
|
||||
} else {
|
||||
switch (tolower(pos[0])) {
|
||||
case '%':
|
||||
result += "%";
|
||||
break;
|
||||
default:
|
||||
clearOptimizable(nodep, "Unknown $display-like format code.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nodep->text(result);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void visit(AstDisplay *nodep, AstNUser *) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
nodep->iterateChildren(*this);
|
||||
if (m_params) {
|
||||
switch (nodep->displayType()) {
|
||||
case AstDisplayType::DT_DISPLAY: // FALLTHRU
|
||||
case AstDisplayType::DT_INFO:
|
||||
v3warn(USERINFO, nodep->fmtp()->text());
|
||||
break;
|
||||
case AstDisplayType::DT_ERROR:
|
||||
v3warn(USERERROR, nodep->fmtp()->text());
|
||||
break;
|
||||
case AstDisplayType::DT_WARNING:
|
||||
v3warn(USERWARN, nodep->fmtp()->text());
|
||||
break;
|
||||
case AstDisplayType::DT_FATAL:
|
||||
v3warn(USERFATAL, nodep->fmtp()->text());
|
||||
break;
|
||||
case AstDisplayType::DT_WRITE: // FALLTHRU
|
||||
default:
|
||||
clearOptimizable(nodep, "Unexpected display type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// default
|
||||
// These types are definately not reducable
|
||||
// AstCoverInc, AstDisplay, AstArraySel, AstStop, AstFinish,
|
||||
// AstCoverInc, AstArraySel, AstFinish,
|
||||
// AstRand, AstTime, AstUCFunc, AstCCall, AstCStmt, AstUCStmt
|
||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||
if (jumpingOver(nodep)) return;
|
||||
|
||||
+15
-19
@@ -99,7 +99,9 @@ class SliceCloneVisitor : public AstNVisitor {
|
||||
// Reassign the bitp()
|
||||
if (nodep->length() > 1) {
|
||||
if (AstConst* bitp = nodep->bitp()->castConst()) {
|
||||
unsigned idx = nodep->start() + m_selBits[m_vecIdx][m_depth];
|
||||
AstUnpackArrayDType* adtypep = nodep->fromp()->dtypep()->skipRefp()->castUnpackArrayDType();
|
||||
if (!adtypep) nodep->v3fatalSrc("slice select tried to expand an array without an ArrayDType");
|
||||
unsigned idx = nodep->start() + m_selBits[m_vecIdx][m_depth] - adtypep->lsb();
|
||||
AstNode* constp = new AstConst(bitp->fileline(), V3Number(bitp->fileline(), bitp->castConst()->num().width(), idx));
|
||||
bitp->replaceWith(constp);
|
||||
} else {
|
||||
@@ -124,7 +126,7 @@ class SliceCloneVisitor : public AstNVisitor {
|
||||
clonep->iterateChildren(*this);
|
||||
nodep->addNextHere(clonep);
|
||||
}
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep = NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
|
||||
// Not all Uniop nodes should be cloned down to a single bit
|
||||
@@ -164,7 +166,7 @@ class SliceCloneVisitor : public AstNVisitor {
|
||||
}
|
||||
}
|
||||
nodep->addNextHere(lhsp);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep = NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
virtual void visit(AstRedOr* nodep, AstNUser*) {
|
||||
cloneUniop(nodep);
|
||||
@@ -185,7 +187,7 @@ class SliceCloneVisitor : public AstNVisitor {
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
SliceCloneVisitor(AstNode* nodep) {
|
||||
explicit SliceCloneVisitor(AstNode* nodep) {
|
||||
nodep->accept(*this);
|
||||
}
|
||||
virtual ~SliceCloneVisitor() {}
|
||||
@@ -272,7 +274,9 @@ class SliceVisitor : public AstNVisitor {
|
||||
int x = msb; msb = lsb; lsb = x;
|
||||
}
|
||||
UINFO(9," ArraySel-child: "<<topp<<endl);
|
||||
AstArraySel* newp = new AstArraySel(nodep->fileline(), topp, new AstConst(nodep->fileline(),lsb));
|
||||
AstArraySel* newp = new AstArraySel(nodep->fileline(), topp,
|
||||
// "lsb-lsb": Arrays are zero-based so index 0 is always lsb
|
||||
new AstConst(nodep->fileline(), lsb-lsb));
|
||||
if (!newp->dtypep()) {
|
||||
newp->v3fatalSrc("ArraySel dtyping failed when resolving slice"); // see ArraySel constructor
|
||||
}
|
||||
@@ -295,7 +299,7 @@ class SliceVisitor : public AstNVisitor {
|
||||
AstVarRef* clonep = nodep->cloneTree(false);
|
||||
clonep->user1p(nodep);
|
||||
AstNode* newp = insertImplicit(clonep, 1, dimensions);
|
||||
nodep->replaceWith(newp); nodep = NULL;
|
||||
nodep->replaceWith(newp); VL_DANGLING(nodep);
|
||||
newp->accept(*this);
|
||||
}
|
||||
}
|
||||
@@ -361,6 +365,8 @@ class SliceVisitor : public AstNVisitor {
|
||||
// The conditional must be a single bit so only look at the expressions
|
||||
nodep->expr1p()->accept(*this);
|
||||
nodep->expr2p()->accept(*this);
|
||||
// Downstream data type may have changed; propagate up
|
||||
nodep->dtypeFrom(nodep->expr1p());
|
||||
}
|
||||
|
||||
// Return the first AstVarRef under the node
|
||||
@@ -422,7 +428,7 @@ class SliceVisitor : public AstNVisitor {
|
||||
}
|
||||
//if (debug()>=9) newp->dumpTreeAndNext(cout, "-InitArrayOut: ");
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
return; // WIll iterate in a moment
|
||||
}
|
||||
// Hasn't been searched for implicit slices yet
|
||||
@@ -446,16 +452,6 @@ class SliceVisitor : public AstNVisitor {
|
||||
if ((int)(dim - varDim.second) < 0) {
|
||||
// Unpacked dimensions are referenced first, make sure we have them all
|
||||
nodep->v3error("Unary operator used across unpacked dimensions");
|
||||
} else if ((int)(dim - (varDim.second)) < 0) {
|
||||
// Implicit packed dimensions are allowed, make them explicit
|
||||
uint32_t newDim = (varDim.second) - dim;
|
||||
AstNode* clonep = nodep->lhsp()->cloneTree(false);
|
||||
clonep->user1p(refp);
|
||||
AstNode* newp = insertImplicit(clonep, dim+1, newDim);
|
||||
nodep->lhsp()->replaceWith(newp); refp = NULL;
|
||||
int clones = countClones(nodep->lhsp()->castArraySel());
|
||||
nodep->user2(clones);
|
||||
SliceCloneVisitor scv(nodep);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,7 +483,7 @@ class SliceVisitor : public AstNVisitor {
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
SliceVisitor(AstNetlist* rootp) {
|
||||
explicit SliceVisitor(AstNetlist* rootp) {
|
||||
m_assignp = NULL;
|
||||
m_lhsVarRefp = NULL;
|
||||
rootp->accept(*this);
|
||||
@@ -501,5 +497,5 @@ public:
|
||||
void V3Slice::sliceAll(AstNetlist* rootp) {
|
||||
UINFO(2,__FUNCTION__<<": "<<endl);
|
||||
SliceVisitor visitor(rootp);
|
||||
V3Global::dumpCheckGlobalTree("slices.tree", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
|
||||
V3Global::dumpCheckGlobalTree("slice.tree", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@
|
||||
|
||||
class SplitPliVertex : public V3GraphVertex {
|
||||
public:
|
||||
SplitPliVertex(V3Graph* graphp)
|
||||
explicit SplitPliVertex(V3Graph* graphp)
|
||||
: V3GraphVertex(graphp) {}
|
||||
virtual ~SplitPliVertex() {}
|
||||
virtual string name() const { return "*PLI*"; }
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
SplitAsFindVisitor(AstAlways* nodep) {
|
||||
explicit SplitAsFindVisitor(AstAlways* nodep) {
|
||||
m_splitVscp = NULL;
|
||||
nodep->accept(*this);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
SplitAsVisitor(AstNetlist* nodep) {
|
||||
explicit SplitAsVisitor(AstNetlist* nodep) {
|
||||
m_splitVscp = NULL;
|
||||
AstNode::user1ClearTree(); // user1p() used on entire tree
|
||||
nodep->accept(*this);
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public:
|
||||
~V3Double0() {}
|
||||
|
||||
// Implicit conversion operators:
|
||||
inline V3Double0 (const vluint64_t v) : m_d(v) { }
|
||||
inline explicit V3Double0 (const vluint64_t v) : m_d(v) { }
|
||||
inline operator double () const { return m_d; }
|
||||
|
||||
// Explicit operators:
|
||||
|
||||
@@ -177,7 +177,7 @@ public:
|
||||
}
|
||||
|
||||
// CONSTRUCTORS
|
||||
StatsReport(ofstream* aofp)
|
||||
explicit StatsReport(ofstream* aofp)
|
||||
: os(*aofp) {
|
||||
header();
|
||||
sumit();
|
||||
@@ -214,5 +214,5 @@ void V3Stats::statsReport() {
|
||||
StatsReport reporter (ofp);
|
||||
|
||||
// Cleanup
|
||||
ofp->close(); delete ofp; ofp = NULL;
|
||||
ofp->close(); delete ofp; VL_DANGLING(ofp);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,13 @@
|
||||
#include "config_build.h"
|
||||
#include "verilatedos.h"
|
||||
|
||||
#include "V3Global.h"
|
||||
#include "V3String.h"
|
||||
#include "V3Error.h"
|
||||
|
||||
|
||||
size_t VName::s_minLength = 32;
|
||||
size_t VName::s_maxLength = 0; // Disabled
|
||||
|
||||
//######################################################################
|
||||
// Wildcard
|
||||
@@ -70,3 +76,244 @@ string VString::downcase(const string& str) {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string VString::quotePercent(const string& str) {
|
||||
string out;
|
||||
for (string::const_iterator pos = str.begin(); pos != str.end(); ++pos) {
|
||||
if (*pos == '%') out += '%';
|
||||
out += *pos;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// VHashSha1
|
||||
|
||||
static inline uint32_t sha1Rotl32(uint32_t lhs, uint32_t rhs) VL_ATTR_ALWINLINE;
|
||||
static inline uint32_t sha1Rotl32(uint32_t lhs, uint32_t rhs) {
|
||||
return ((lhs << rhs) | (lhs >> (32 - rhs)));
|
||||
}
|
||||
|
||||
static inline void sha1Block(uint32_t* h, uint32_t* w) VL_ATTR_ALWINLINE;
|
||||
static inline void sha1Block(uint32_t* h, uint32_t* w) {
|
||||
#define SHA1ITER(func, roundConst) do { \
|
||||
uint32_t t = sha1Rotl32(a, 5) + (func) + e + (roundConst) + w[round]; \
|
||||
e = d; d = c; c = sha1Rotl32(b, 30); b = a; a = t; \
|
||||
} while (0)
|
||||
|
||||
uint32_t a = h[0];
|
||||
uint32_t b = h[1];
|
||||
uint32_t c = h[2];
|
||||
uint32_t d = h[3];
|
||||
uint32_t e = h[4];
|
||||
int round = 0;
|
||||
|
||||
for (; round < 16; ++round) {
|
||||
SHA1ITER((b & c) | (~b & d), 0x5a827999);
|
||||
}
|
||||
for (; round < 20; ++round) {
|
||||
w[round] = sha1Rotl32((w[round - 3] ^ w[round - 8] ^ w[round - 14] ^ w[round - 16]), 1);
|
||||
SHA1ITER((b & c) | (~b & d), 0x5a827999);
|
||||
}
|
||||
for (; round < 40; ++round) {
|
||||
w[round] = sha1Rotl32((w[round - 3] ^ w[round - 8] ^ w[round - 14] ^ w[round - 16]), 1);
|
||||
SHA1ITER(b ^ c ^ d, 0x6ed9eba1);
|
||||
}
|
||||
for (; round < 60; ++round) {
|
||||
w[round] = sha1Rotl32((w[round - 3] ^ w[round - 8] ^ w[round - 14] ^ w[round - 16]), 1);
|
||||
SHA1ITER((b & c) | (b & d) | (c & d), 0x8f1bbcdc);
|
||||
}
|
||||
for (; round < 80; ++round) {
|
||||
w[round] = sha1Rotl32((w[round - 3] ^ w[round - 8] ^ w[round - 14] ^ w[round - 16]), 1);
|
||||
SHA1ITER(b ^ c ^ d, 0xca62c1d6);
|
||||
}
|
||||
|
||||
h[0] += a;
|
||||
h[1] += b;
|
||||
h[2] += c;
|
||||
h[3] += d;
|
||||
h[4] += e;
|
||||
#undef SHA1ITER
|
||||
}
|
||||
|
||||
void VHashSha1::insert(const void* datap, size_t length) {
|
||||
UASSERT(!m_final, "Called VHashSha1::insert after finalized the hash value");
|
||||
m_totLength += length;
|
||||
|
||||
string tempData;
|
||||
int chunkLen;
|
||||
const uint8_t* chunkp;
|
||||
if (m_remainder=="") {
|
||||
chunkLen = length;
|
||||
chunkp = (const uint8_t*)datap;
|
||||
} else {
|
||||
// If there are large inserts it would be more efficient to avoid this copy
|
||||
// by copying bytes in the loop below from either m_remainder or the data
|
||||
// as appropriate.
|
||||
tempData = m_remainder + string((const char*)datap,length);
|
||||
chunkLen = tempData.length();
|
||||
chunkp = (const uint8_t*)tempData.data();
|
||||
}
|
||||
|
||||
// See wikipedia SHA-1 algorithm summary
|
||||
uint32_t w[80]; // Round buffer, [0..15] are input data, rest used by rounds
|
||||
int posBegin = 0; // Position in buffer for start of this block
|
||||
int posEnd = 0; // Position in buffer for end of this block
|
||||
|
||||
// Process complete 64-byte blocks
|
||||
while (posBegin <= chunkLen - 64) {
|
||||
posEnd = posBegin + 64;
|
||||
// 64 byte round input data, being careful to swap on big, keep on little
|
||||
for (int roundByte = 0; posBegin < posEnd; posBegin += 4) {
|
||||
w[roundByte++] = ((uint32_t) chunkp[posBegin + 3]
|
||||
| (((uint32_t) chunkp[posBegin + 2]) << 8)
|
||||
| (((uint32_t) chunkp[posBegin + 1]) << 16)
|
||||
| (((uint32_t) chunkp[posBegin]) << 24));
|
||||
}
|
||||
sha1Block(m_inthash, w);
|
||||
}
|
||||
|
||||
m_remainder = string((const char*)(chunkp+posBegin), chunkLen-posEnd);
|
||||
}
|
||||
|
||||
void VHashSha1::finalize() {
|
||||
if (!m_final) {
|
||||
// Make sure no 64 byte blocks left
|
||||
insert("");
|
||||
m_final = true;
|
||||
|
||||
// Process final possibly non-complete 64-byte block
|
||||
uint32_t w[80]; // Round buffer, [0..15] are input data, rest used by rounds
|
||||
for (int i=0; i<16; ++i) w[i] = 0;
|
||||
size_t blockPos = 0;
|
||||
for (; blockPos < m_remainder.length(); ++blockPos) {
|
||||
w[blockPos >> 2] |= ((uint32_t) m_remainder[blockPos]) << ((3 - (blockPos & 3)) << 3);
|
||||
}
|
||||
w[blockPos >> 2] |= 0x80 << ((3 - (blockPos & 3)) << 3);
|
||||
if (m_remainder.length() >= 56) {
|
||||
sha1Block(m_inthash, w);
|
||||
for (int i=0; i<16; ++i) w[i] = 0;
|
||||
}
|
||||
w[15] = m_totLength << 3;
|
||||
sha1Block(m_inthash, w);
|
||||
|
||||
m_remainder.clear();
|
||||
}
|
||||
}
|
||||
|
||||
string VHashSha1::digestBinary() {
|
||||
finalize();
|
||||
string out; out.reserve(20);
|
||||
for (size_t i=0; i<20; ++i) {
|
||||
out[i] = (m_inthash[i >> 2] >> (((3 - i) & 0x3) << 3)) & 0xff;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
uint64_t VHashSha1::digestUInt64() {
|
||||
const string& binhash = digestBinary();
|
||||
uint64_t out = 0;
|
||||
for (size_t byte=0; byte<sizeof(uint64_t); ++byte) {
|
||||
out = (out<<8) | binhash[byte];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string VHashSha1::digestHex() {
|
||||
static const char digits[16+1] = "0123456789abcdef";
|
||||
const string& binhash = digestBinary();
|
||||
string out; out.reserve(40);
|
||||
for (size_t byte=0; byte<20; ++byte) {
|
||||
out += digits[ (binhash[byte]>>4) & 0xf ];
|
||||
out += digits[ (binhash[byte]>>0) & 0xf ];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
string VHashSha1::digestSymbol() {
|
||||
// Make a symbol name from hash. Similar to base64, however base 64
|
||||
// has + and / for last two digits, but need C symbol, and we also
|
||||
// avoid conflicts with use of _, so use "AB" at the end.
|
||||
// Thus this function is non-reversable.
|
||||
static const char digits[64+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789AB";
|
||||
const string& binhash = digestBinary();
|
||||
string out; out.reserve(28);
|
||||
int pos = 0;
|
||||
for (; pos < (160/8) - 2; pos += 3) {
|
||||
out += digits[((binhash[pos] >> 2) & 0x3f)];
|
||||
out += digits[((binhash[pos] & 0x3) << 4)
|
||||
| ((int) (binhash[pos + 1] & 0xf0) >> 4)];
|
||||
out += digits[((binhash[pos + 1] & 0xf) << 2)
|
||||
| ((int) (binhash[pos + 2] & 0xc0) >> 6)];
|
||||
out += digits[((binhash[pos + 2] & 0x3f))];
|
||||
}
|
||||
if (0) { // Not needed for 160 bit hash
|
||||
out += digits[((binhash[pos] >> 2) & 0x3f)];
|
||||
out += digits[((binhash[pos] & 0x3) << 4)];
|
||||
}
|
||||
else {
|
||||
out += digits[((binhash[pos] >> 2) & 0x3f)];
|
||||
out += digits[((binhash[pos] & 0x3) << 4)
|
||||
| ((int) (binhash[pos + 1] & 0xf0) >> 4)];
|
||||
out += digits[((binhash[pos + 1] & 0xf) << 2)];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void VHashSha1::selfTestOne(const string& data, const string& data2,
|
||||
const string& exp, const string& exp64) {
|
||||
VHashSha1 digest (data);
|
||||
if (data2!="") digest.insert(data2);
|
||||
if (digest.digestHex() != exp) {
|
||||
cerr << "%Error: When hashing '"<<data+data2<<"'"<<endl;
|
||||
cerr << "%Error: got="<<digest.digestHex()<<endl;
|
||||
cerr << "%Error: exp="<<exp<<endl;
|
||||
}
|
||||
if (digest.digestSymbol() != exp64) {
|
||||
cerr << "%Error: When hashing '"<<data+data2<<"'"<<endl;
|
||||
cerr << "%Error: got="<<digest.digestSymbol()<<endl;
|
||||
cerr << "%Error: exp="<<exp64<<endl;
|
||||
}
|
||||
}
|
||||
|
||||
void VHashSha1::selfTest() {
|
||||
selfTestOne("", "",
|
||||
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
||||
"2jmj7l5rSw0yVbBvlWAYkKBYBwk");
|
||||
selfTestOne("a", "",
|
||||
"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8",
|
||||
"hvfkNBqlpBzhXR3cuerq6jd2Z7g");
|
||||
selfTestOne("The quick brown fox jumps over the lazy dog", "",
|
||||
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
|
||||
"L9ThxnotKPzthJ7hu3bnORuT6xI");
|
||||
selfTestOne("The quick brown fox jumps over the lazy"," dog",
|
||||
"2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
|
||||
"L9ThxnotKPzthJ7hu3bnORuT6xI");
|
||||
selfTestOne("Test using larger than block-size key and larger than one block-size data", "",
|
||||
"9026e8faed6ef4ec5ae3ff049020d7f0af7abbbf",
|
||||
"kCboAu1u9Oxa4B8EkCDX8K96u78");
|
||||
selfTestOne("Test using", " larger than block-size key and larger than one block-size data",
|
||||
"9026e8faed6ef4ec5ae3ff049020d7f0af7abbbf",
|
||||
"kCboAu1u9Oxa4B8EkCDX8K96u78");
|
||||
}
|
||||
|
||||
//######################################################################
|
||||
// VName
|
||||
|
||||
string VName::hashedName() {
|
||||
if (m_name=="") return "";
|
||||
if (m_hashed!="") return m_hashed; // Memoized
|
||||
if (s_maxLength==0 || m_name.length() < s_maxLength) {
|
||||
m_hashed = m_name;
|
||||
return m_hashed;
|
||||
} else {
|
||||
VHashSha1 hash(m_name);
|
||||
string suffix = "__Vhsh"+hash.digestSymbol();
|
||||
if (s_minLength < s_maxLength) {
|
||||
m_hashed = m_name.substr(0,s_minLength) + suffix;
|
||||
} else {
|
||||
m_hashed = suffix;
|
||||
}
|
||||
return m_hashed;
|
||||
}
|
||||
}
|
||||
|
||||
+60
-41
@@ -24,6 +24,7 @@
|
||||
#include "config_build.h"
|
||||
#include "verilatedos.h"
|
||||
#include <string>
|
||||
#include "V3Error.h"
|
||||
|
||||
//######################################################################
|
||||
// VString - String manipulation
|
||||
@@ -34,56 +35,74 @@ public:
|
||||
// METHODS (generic string utilities)
|
||||
static bool wildmatch(const char* s, const char* p);
|
||||
static string downcase(const string& str);
|
||||
static string quotePercent(const string& str);
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
// Compute FNV1a (Fowler/Noll/Vo) hashes
|
||||
// See http://www.isthe.com/chongo/tech/comp/fnv/index.html
|
||||
// Algorithmic basis for these functions was in the public domain, by chongo <Landon Curt Noll>
|
||||
// VHashSha1 - Compute Sha1 hashes
|
||||
|
||||
class VHashFnv {
|
||||
enum { FNV1_64_INIT = 0xcbf29ce484222325ULL }; // Initial value
|
||||
vluint64_t m_hash;
|
||||
class VHashSha1 {
|
||||
// As blocks must be processed in 64 byte chunks, this does not at present
|
||||
// support calling input() on multiple non-64B chunks and getting the correct
|
||||
// hash. To do that first combine the string before calling here.
|
||||
// Or improve to store 0-63 bytes of data between calls to input().
|
||||
|
||||
inline void hashC(uint8_t c) {
|
||||
m_hash ^= c;
|
||||
// Below is faster than m_hash *= 0x100000001b3ULL;
|
||||
m_hash += ((m_hash << 1) + (m_hash << 4) + (m_hash << 5)
|
||||
+ (m_hash << 7) + (m_hash << 8) + (m_hash << 40));
|
||||
}
|
||||
// MEMBERS
|
||||
uint32_t m_inthash[5]; // Intermediate hash, in host order
|
||||
string m_remainder; // Unhashed data
|
||||
bool m_final; // Finalized
|
||||
size_t m_totLength; // Total all-chunk length as needed by output digest
|
||||
public:
|
||||
VHashFnv() : m_hash(FNV1_64_INIT) {}
|
||||
~VHashFnv() {}
|
||||
// CONSTRUCTORS
|
||||
VHashSha1() { init(); }
|
||||
explicit VHashSha1(const string& data) { init(); insert(data); }
|
||||
~VHashSha1() {}
|
||||
|
||||
vluint64_t digestUInt64() const { return m_hash; }
|
||||
// METHODS
|
||||
string digestBinary(); // Return digest as 20 character binary
|
||||
string digestHex(); // Return digest formatted as a hex string
|
||||
string digestSymbol(); // Return digest formatted as C symbol/base64ish
|
||||
uint64_t digestUInt64(); // Return 64-bits of digest
|
||||
static void selfTest(); // Test this class
|
||||
|
||||
VHashFnv& insert(const void* bufp, size_t len) { // Memory
|
||||
const uint8_t* bp = (const uint8_t*)bufp;
|
||||
const uint8_t* be = bp + len;
|
||||
while (bp < be) hashC((vluint64_t)*bp++);
|
||||
return *this;
|
||||
// Inerting hash data
|
||||
void insert(const void* datap, size_t length); // Process data into the digest
|
||||
void insert(const string& data) { insert(data.data(), data.length()); } // Process data into the digest
|
||||
void insert(uint64_t value) { insert(cvtToStr(value)); }
|
||||
|
||||
private:
|
||||
void init() {
|
||||
m_inthash[0] = 0x67452301; m_inthash[1] = 0xefcdab89; m_inthash[2] = 0x98badcfe;
|
||||
m_inthash[3] = 0x10325476; m_inthash[4] = 0xc3d2e1f0;
|
||||
m_final = false;
|
||||
m_totLength = 0;
|
||||
}
|
||||
VHashFnv& insert(const char* strp) { // String
|
||||
const uint8_t* sp = (const uint8_t*)strp;
|
||||
while (*sp) hashC((vluint64_t)*sp++);
|
||||
return *this;
|
||||
}
|
||||
VHashFnv& insert(const string& str) { return insert(str.data(), str.length()); }
|
||||
VHashFnv& insert(vluint64_t n) {
|
||||
hashC(n>>0); hashC(n>>8); hashC(n>>16); hashC(n>>24);
|
||||
hashC(n>>32); hashC(n>>40); hashC(n>>48); hashC(n>>56);
|
||||
return *this;
|
||||
}
|
||||
VHashFnv& insert(uint32_t n) {
|
||||
hashC(n>>0); hashC(n>>8); hashC(n>>16); hashC(n>>24);
|
||||
return *this;
|
||||
}
|
||||
VHashFnv& insert(uint16_t n) {
|
||||
hashC(n>>0); hashC(n>>8);
|
||||
return *this;
|
||||
}
|
||||
VHashFnv& insert(uint8_t n) { hashC(n); return *this; }
|
||||
VHashFnv& insert(int n) { hashC((vluint64_t)n); return *this; }
|
||||
static void selfTestOne(const string& data, const string& data2,
|
||||
const string& exp, const string& exp64);
|
||||
void finalize(); // Process remaining data
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
// VName - string which contains a possibly hashed string
|
||||
// TODO use this wherever there is currently a "string m_name"
|
||||
|
||||
class VName {
|
||||
string m_name;
|
||||
string m_hashed;
|
||||
|
||||
static size_t s_maxLength; // Length at which to start hashing
|
||||
static size_t s_minLength; // Length to preserve if over maxLength
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
explicit VName (const string& name) : m_name(name) {}
|
||||
~VName() {}
|
||||
// METHODS
|
||||
void name(const string& name) { m_name = name; m_hashed = ""; }
|
||||
string name() const { return m_name; }
|
||||
string hashedName();
|
||||
// CONFIG STATIC METHORS
|
||||
static void maxLength(size_t flag) { s_maxLength=flag; } // Length at which to start hashing, 0=disable
|
||||
static size_t maxLength() { return s_maxLength; }
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
||||
+6
-6
@@ -86,7 +86,7 @@ class SubstVarEntry {
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
SubstVarEntry (AstVar* varp) { // Construction for when a var is used
|
||||
explicit SubstVarEntry (AstVar* varp) { // Construction for when a var is used
|
||||
m_varp = varp;
|
||||
m_whole.m_use = false;
|
||||
m_wordAssign = false;
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
}
|
||||
void deleteAssign (AstNodeAssign* nodep) {
|
||||
UINFO(5, "Delete "<<nodep<<endl);
|
||||
nodep->unlinkFrBack()->deleteTree(); nodep=NULL;
|
||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
||||
}
|
||||
void deleteUnusedAssign() {
|
||||
// If there are unused assignments in this var, kill them
|
||||
@@ -310,7 +310,7 @@ private:
|
||||
}
|
||||
if (debug()>5) newp->dumpTree(cout," w_new: ");
|
||||
nodep->replaceWith(newp);
|
||||
pushDeletep(nodep); nodep=NULL;
|
||||
pushDeletep(nodep); VL_DANGLING(nodep);
|
||||
++m_statSubsts;
|
||||
}
|
||||
virtual void visit(AstWordSel* nodep, AstNUser*) {
|
||||
@@ -329,7 +329,7 @@ private:
|
||||
// Check that the RHS hasn't changed value since we recorded it.
|
||||
SubstUseVisitor visitor (substp, entryp->getWordStep(word));
|
||||
if (visitor.ok()) {
|
||||
replaceSubstEtc(nodep, substp); nodep=NULL;
|
||||
replaceSubstEtc(nodep, substp); VL_DANGLING(nodep);
|
||||
} else {
|
||||
entryp->consumeWord(word);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ private:
|
||||
SubstUseVisitor visitor (substp, entryp->getWholeStep());
|
||||
if (visitor.ok()) {
|
||||
UINFO(8," USEwhole "<<nodep<<endl);
|
||||
replaceSubstEtc(nodep, substp); nodep=NULL;
|
||||
replaceSubstEtc(nodep, substp); VL_DANGLING(nodep);
|
||||
} else {
|
||||
UINFO(8," USEwholeButChg "<<nodep<<endl);
|
||||
entryp->consumeWhole();
|
||||
@@ -379,7 +379,7 @@ private:
|
||||
}
|
||||
public:
|
||||
// CONSTUCTORS
|
||||
SubstVisitor(AstNode* nodep) {
|
||||
explicit SubstVisitor(AstNode* nodep) {
|
||||
AstNode::user1ClearTree(); // user1p() used on entire tree
|
||||
AstNode::user2ClearTree(); // user2p() used on entire tree
|
||||
m_ops = 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user