Compare commits

...
30 Commits
Author SHA1 Message Date
Wilson Snyder ce531c5a67 Release configure.ac file in kit
git-svn-id: file://localhost/svn/verilator/trunk/verilator@851 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-20 01:11:25 +00:00
Wilson Snyder 52e36fb434 Reduce depth of priority encoded case statements.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@848 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-19 16:26:49 +00:00
Wilson Snyder 100d5b386c Version bump
git-svn-id: file://localhost/svn/verilator/trunk/verilator@847 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-19 14:13:34 +00:00
Wilson Snyder 699563c9bd Add support.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@846 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-19 14:09:57 +00:00
Wilson Snyder a599fbea18 Have tests pick up standard .mk so PERL is set based on configure
git-svn-id: file://localhost/svn/verilator/trunk/verilator@845 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 20:33:10 +00:00
Wilson Snyder c5f0ed9c99 Fix makefile typo, and remove unneeded PWD variable
git-svn-id: file://localhost/svn/verilator/trunk/verilator@844 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 20:05:02 +00:00
Wilson Snyder 2ce30e78a1 Move some test_v tests into test_regress area
git-svn-id: file://localhost/svn/verilator/trunk/verilator@843 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 19:49:36 +00:00
Wilson Snyder 3b554f4c5b Rename config.h to config_build.h, and add cross compile notes.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@842 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 19:20:45 +00:00
Wilson Snyder cf40fd356f Fix split list ordering causing circular refs
git-svn-id: file://localhost/svn/verilator/trunk/verilator@841 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 18:20:13 +00:00
Wilson Snyder 8848469bf9 Fix dotted references into generate fors
git-svn-id: file://localhost/svn/verilator/trunk/verilator@840 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-18 18:14:53 +00:00
Wilson Snyder 4100417f83 Show known scopes when dotted errors show up
git-svn-id: file://localhost/svn/verilator/trunk/verilator@839 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-15 22:28:18 +00:00
Wilson Snyder bd6d743f9c Move configure.in to configure.ac
git-svn-id: file://localhost/svn/verilator/trunk/verilator@838 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-15 21:18:41 +00:00
Wilson Snyder 857ac24ba7 Fix dotted ref signals under generate cells
git-svn-id: file://localhost/svn/verilator/trunk/verilator@837 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-12 18:25:33 +00:00
Wilson Snyder 5672b99203 Add t_extend_class example
git-svn-id: file://localhost/svn/verilator/trunk/verilator@836 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-10 22:48:26 +00:00
Wilson Snyder 3d8de3194c Fix SuSE10.0 compile warnings
git-svn-id: file://localhost/svn/verilator/trunk/verilator@833 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-05 15:24:38 +00:00
Wilson Snyder 8b91a9f898 Version bump
git-svn-id: file://localhost/svn/verilator/trunk/verilator@832 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-12-05 15:12:19 +00:00
Wilson Snyder 038ee69a96 Add M32 make variable
git-svn-id: file://localhost/svn/verilator/trunk/verilator@831 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-11-02 19:13:07 +00:00
Wilson Snyder 8986d1f16f Avoid some duplicate sensitivity ifs.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@830 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-26 01:20:49 +00:00
Wilson Snyder 86c8e7b3e6 Add --output-split-cfuncs for accelerating GCC.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@829 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-26 01:08:44 +00:00
Wilson Snyder 9026118a7c Fix (blah) with width violation
git-svn-id: file://localhost/svn/verilator/trunk/verilator@828 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-25 21:41:32 +00:00
Wilson Snyder 58fc922737 Test fix
git-svn-id: file://localhost/svn/verilator/trunk/verilator@825 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-18 13:56:54 +00:00
Wilson Snyder 3b5c791332 Test fix
git-svn-id: file://localhost/svn/verilator/trunk/verilator@824 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-18 13:54:36 +00:00
Wilson Snyder 6e16bc1b7b Version bump
git-svn-id: file://localhost/svn/verilator/trunk/verilator@823 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-18 13:50:44 +00:00
Wilson Snyder 1aba0f6379 Show error code on non-generic errors; add TASKNSVAR
git-svn-id: file://localhost/svn/verilator/trunk/verilator@822 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-18 13:45:50 +00:00
Wilson Snyder 11cfa3c072 Suppress unused warnings using attribute
git-svn-id: file://localhost/svn/verilator/trunk/verilator@821 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-18 12:59:30 +00:00
Wilson Snyder 59141b1678 Fix --skip-identical
git-svn-id: file://localhost/svn/verilator/trunk/verilator@820 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-12 14:01:06 +00:00
Wilson Snyder 2083c071ce Version bump
git-svn-id: file://localhost/svn/verilator/trunk/verilator@817 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-11 15:42:32 +00:00
Wilson Snyder 3ad5872d30 Add verilator no_inline_task
git-svn-id: file://localhost/svn/verilator/trunk/verilator@816 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-11 15:41:42 +00:00
Wilson Snyder ea6bb21cdc Fix V3Subst mis-optimizing concats in t_case_write
git-svn-id: file://localhost/svn/verilator/trunk/verilator@815 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-11 15:34:50 +00:00
Wilson Snyder 3d4fe0364a No functional change; have V3Subst use a sub-structure.
git-svn-id: file://localhost/svn/verilator/trunk/verilator@814 77ca24e4-aefa-0310-84f0-b9a241c72d87
2006-10-11 14:13:37 +00:00
233 changed files with 7747 additions and 2019 deletions
+36 -6
View File
@@ -3,17 +3,47 @@ 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.62**
* Verilator 3.630 12/19/2006
**** Fix link error when using --exe with --trace. [Eugene Weber]
** Support $readmemb and $readmemh. [Eugene Weber, Arthur Kahlich]
**** Public functions now allow > 64 bit arguments.
*** Fixed configure and compiling under Solaris. [Bob Farrell]
**** Don't core dump on errors when not under --debug. [Allan Cochrane]
*** When dotted signal lookup fails, help the user by showing known scopes.
*** Reduce depth of priority encoded case statements. [Eugene Weber]
**** Fix dotted references inside generated cells. [David Hewson]
**** Fix missed split optimization points underneath other re-split blocks.
* Verilator 3.623 12/05/2006
*** Add --output-split-cfuncs for accelerating GCC compile. [Eugene Weber]
**** Fix $signed mis-extending when input has a WIDTH violation. [Eugene Weber]
**** Add M32 make variable to support -m32 compiles. [Eugene Weber]
* Verilator 3.622 10/17/2006 Stable
**** Fix --skip-identical without --debug, broken in 3.621. [Andy Meier]
* Verilator 3.621 10/11/2006 Beta
** Add /*verilator no_inline_task*/ to prevent over-expansion. [Eugene Weber]
*** Public functions now allow > 64 bit arguments.
**** Remove .vpp intermediate files when not under --debug.
* Verilator 3.620 10/04/2006
**** Fix link error when using --exe with --trace. [Eugene Weber]
**** Fix mis-optimization of wide concats with constants.
**** Fix core dump on printing error when not under --debug. [Allan Cochrane]
* Verilator 3.620 10/04/2006 Stable
*** Support simple inout task ports. [Eugene Weber]
@@ -436,7 +466,7 @@ indicates the contributor was also the author of the fix; Thanks!
**** Added NC Verilog as alternative to VCS for reference tests.
**** Support implicit wire declarations on input-only signals.
(Dangerous, as leads to wires without drivers, but allowed by spec.)
(Dangerous, as leads to wires without drivers, but allowed by spec.)
**** Fixed compile warnings on Suse 9.1
+8 -9
View File
@@ -78,7 +78,6 @@ datadir = @datadir@
infodir = @infodir@
# Directory in which to install package specific files
# Note this gets coded into v3c/config.h also
pkgdatadir = @pkgdatadir@
#### End of system configuration section. ####
@@ -95,7 +94,7 @@ DISTDEP = info Makefile
# Files to distribute.
DISTBIN = $(wildcard bin/verilator-*)
DISTFILES_INC = $(INFOS) .cvsignore COPYING *.in \
DISTFILES_INC = $(INFOS) .cvsignore COPYING *.in *.ac \
Changes README TODO \
bin/* \
install-sh configure mkinstalldirs *.texi \
@@ -265,16 +264,16 @@ uninstall:
-cd $(mandir)/man1 && rm -f $(VL_INST_MAN_FILES)
-cd $(bindir) && rm -f $(VL_INST_BIN_FILES)
# autoheader might not change config.h.in, so touch a stamp file.
# autoheader might not change config_build.h.in, so touch a stamp file.
IN_WILD := ${srcdir}/*.in ${srcdir}/*/*.in ${srcdir}/*/*/*.in \
*.in */*.in */*.in
${srcdir}/config.h.in: stamp-h.in
${srcdir}/stamp-h.in: configure.in $(wildcard $(IN_WILD))
${srcdir}/config_build.h.in: stamp-h.in
${srcdir}/stamp-h.in: configure.ac $(wildcard $(IN_WILD))
cd ${srcdir} && autoheader
echo timestamp > ${srcdir}/stamp-h.in
config.h: stamp-h
stamp-h: config.h.in config.status
config_build.h: stamp-h
stamp-h: config_build.h.in config.status
./config.status
Makefile: Makefile.in config.status
./config.status
@@ -282,7 +281,7 @@ src/Makefile: src/Makefile.in config.status
./config.status
config.status: configure
./config.status --recheck
configure: configure.in
configure: configure.ac
autoconf
maintainer-clean::
@@ -317,7 +316,7 @@ TAGS: $(TAGFILES)
######################################################################
# Distributions
DISTCONFIG = src/config.h.in
DISTCONFIG = src/config_build.h.in
DISTTITLE := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e 's/v/V/' -e q $(DISTCONFIG))
DISTNAME := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e q $(DISTCONFIG))
+144 -29
View File
@@ -377,9 +377,18 @@ C++ file exceeds the specified number of operations, a new file will be
created. In addition, any slow routines will be placed into __Slow files.
This accelerates compilation by as optimization can be disabled on the slow
routines, and the remaining files can be compiled on parallel machines.
Using --output-split should have only a trivial impact on performance.
With GCC 3.3 on a 2GHz Opteron, --output-split 20000 will result in
splitting into approximately one-minute-compile chunks.
=item --output-split-cfuncs I<statements>
Enables splitting functions in the output .cpp/.sp files into multiple
functions. When a generated function exceeds the specified number of
operations, a new function will be created. With --output-split, this will
enable GCC to compile faster, at a small loss in performance that increases
with smaller statement values.
=item --pins64
Specifies SystemC outputs of 33-64 bits wide should use uint64_t instead of
@@ -407,7 +416,7 @@ compatibility.
=item --psl
Enable PSL parsing. Without this switch, psl meta-comments are ignored.
Enable PSL parsing. Without this switch, PSL meta-comments are ignored.
See the --assert flag to enable all assertions, and --coverage-user to
enable functional coverage.
@@ -609,7 +618,7 @@ Then we convert the SystemPerl output to SystemC.
$SYSTEMPERL/sp_preproc --preproc *.sp
(You can also skip the above sp_preproc by getting pure SystemC from
verilator by replacing the verilator --sp flag in the previous step with
Verilator by replacing the verilator --sp flag in the previous step with
-sc.)
We then can compile it
@@ -846,6 +855,34 @@ Lower modules are not pure SystemC code. This is a feature, as using the
SystemC pin interconnect scheme everywhere would reduce performance by an
order of magnitude.
=head1 CROSS COMPILATION
Verilator supports cross-compling Verilated code. This is generally used
to run Verilator on a Linux system and produce C++ code that is then compiled
on Windows.
Cross compilation involves up to three different OSes. The build system is
where you configured and compiled Verilator, the host system where you run
Verilator, and the target system where you compile the Verilated code and
run the simulation.
Currently, Verilator requires the build and host system type to be the
same, though the target system type may be different. To support this,
./configure and make Verilator on the build system. Then, run Verilator on
the host system. Finally, the output of Verilator may be compiled on the
different target system.
To support this, none of the files that Verilator produces will reference
any configure generated build-system specific files, such as config.h
(which is renamed in Verilator to config_build.h to reduce confusion.) The
disadvantage of this approach is that include/verilatedos.h must
self-detect the requirements of the target system, rather then using
configure.
The target system may also require edits to the Makefiles, the simple
Makefiles produced by Verilator presume the target system is the same type
as the build system.
=head1 VERILOG 2001 SUPPORT
Verilator supports the more common Verilog 2001 language features. This
@@ -938,7 +975,7 @@ call C++ functions from your Verilog code.
String arguments will be put directly into the output C++ code. Expression
arguments will have the code to evaluate the expression inserted. Thus to
call a C++ function, $c("func(",a,")") will result in 'func(a)' in the
output C++ code. For input arguments, rather then hardcoding variable
output C++ code. For input arguments, rather then hard-coding variable
names in the string $c("func(a)"), instead pass the variable as an
expression $c("func(",a,")"). This will allow the call to work inside
Verilog functions where the variable is flattened out, and also enable
@@ -959,16 +996,6 @@ Verilog standard, %x prints a number with the natural width, %0x prints a
number with minimum width, however %5x prints 5 digits per the C standard
(it's unspecified in Verilog).
=item $fopen, $fclose, $fdisplay, $fwrite
File descriptors passed to the file PLI calls must be file descriptors, not
MCDs, which includes the mode parameter to $fopen being mandatory.
Verilator will convert the integer used to hold the file descriptor into a
internal FILE*. To prevent core dumps due to mis-use, and because integers
are 32 bits while FILE*s may be 64 bits, the descriptor must be stored in a
reg [63:0] rather then an integer. The define `verilator_file_descriptor in
verilated.v can be used to hide this difference.
=item `coverage_block_off
Specifies the entire begin/end block should be ignored for coverage analysis.
@@ -1056,6 +1083,14 @@ Disable the specified warning message for any warnings following the comment.
Re-enable the specified warning message for any warnings following the comment.
=item /*verilator no_inline_task*/
Used in a function or task variable definition section to specify the
function or task should not be inlined into where it is used. This may
reduce the size of the final executable when a task is used a very large
number of times. For this flag to work, the task and tasks below it must
be pure; they cannot reference any variables outside the task itself.
=item /*verilator sc_clock*/
Used after a input declaration to indicate the signal should be declared in
@@ -1271,7 +1306,28 @@ appropriate width.
$display and friends must have a constant format string as the first
argument (as with C's printf), you cannot simply list variables standalone.
=head1 ERRORS
=item $displayb, $displayh, $displayo, $writeb, $writeh, $writeo, etc
The sized display functions are rarely used and so not supported. Replace
them with a $write with the appropriate format specifier.
=item $fopen, $fclose, $fdisplay, $fwrite
File descriptors passed to the file PLI calls must be file descriptors, not
MCDs, which includes the mode parameter to $fopen being mandatory.
Verilator will convert the integer used to hold the file descriptor into a
internal FILE*. To prevent core dumps due to mis-use, and because integers
are 32 bits while FILE*s may be 64 bits, the descriptor must be stored in a
reg [63:0] rather then an integer. The define `verilator_file_descriptor in
verilated.v can be used to hide this difference.
=item $readmemb, $readmemh
Read memory commands should work properly. Note Verilator and the Verilog
specification does not include support for readmem to multi-dimensional
arrays.
=head1 ERRORS AND WARNINGS
Warnings may be disabled in two ways. First, when the warning is
printed it will include a warning code. Simply surround the offending
@@ -1281,13 +1337,13 @@ line with a warn_off/warn_on pair:
if (`DEF_THAT_IS_EQ_ZERO <= 3) $stop;
// verilator lint_on UNSIGNED
They may also be globally disabled by invoking Verilator with the
C<-Wno-I<warning>> switch. This should be avoided, as it removes
all checking across the designs, and prevents other users from
compiling your code without knowing the magic set of disables needed
to successfully compile your design.
Warnings may also be globally disabled by invoking Verilator with the
C<-Wno-I<warning>> switch. This should be avoided, as it removes all
checking across the designs, and prevents other users from compiling your
code without knowing the magic set of disables needed to successfully
compile your design.
Warnings:
List of all warnings:
=over 4
@@ -1344,12 +1400,41 @@ signal before it is implicitly declared by a cell, and can lead to dangling
nets. A better option is the /*AUTOWIRE*/ feature of Verilog-Mode for
Emacs, available from L<http://www.veripool.com/>
=item IMPURE
Warns that a task or function that has been marked with /*verilator
no_inline_task*/ references variables that are not local to the task.
Verilator cannot schedule these variables correctly.
=item MULTIDRIVEN
Warns that the specified signal comes from multiple always blocks. This is
often unsupported by synthesis tools, and is considered bad style. It will
also cause longer runtimes due to reduced optimizations.
=item TASKNSVAR
Error when a call to a task or function has a output from that task tied to
a non-simple signal. Instead connect the task output to a temporary signal
of the appropriate width, and use that signal to set the appropriate
expression as the next statement. For example:
task foo; output sig; ... endtask
always @* begin
foo(bus_we_select_from[2]); // Will get TASKNSVAR error
end
Change this to:
reg foo_temp_out;
always @* begin
foo(foo_temp_out);
bus_we_select_from[2] = foo_temp_out;
end
Verilator doesn't do this conversion for you, as some more complicated
cases would result in simulator mismatches.
=item UNDRIVEN
Warns that the specified signal is never sourced.
@@ -1375,11 +1460,11 @@ may be only one particular usage of a multiply instantiated block. The
construct should be cleaned up to improve runtime; two times better
performance may be possible by fixing these warnings.
Unlike UNOPT this occurs after netlist flattening, and indicates a more
basic problem, as the less obvious case described under UNOPT does not
apply.
Unlike the UNOPT warning, this occurs after netlist flattening, and
indicates a more basic problem, as the less obvious case described under
UNOPT does not apply.
Often this is caused by logic that isn't truly circular as viewed by
Often UNOPTFLAT is caused by logic that isn't truly circular as viewed by
synthesis which analyzes interconnection per-bit, but is circular to
simulation which analyzes per-bus:
@@ -1387,12 +1472,31 @@ simulation which analyzes per-bus:
This statement needs to be evaluated multiple times, as a change in
"shift_in" requires "x" to be computed 3 times before it becomes stable.
This is because a change in "x" requires "x" itself to change value, which
causes the warning.
For significantly better performance, split this into 2 separate signals:
wire [2:1] x_21 = x[1:0];
wire [0:0] x_0 = shift_in;
wire [2:0] xout = {x[1:0],shift_in};
This warning may also be due to clock enables. To fix these, use the
and change all receiving logic to instead receive "xout". Alternatively,
change it to
wire [2:0] x = {xin[1:0],shift_in};
and change all driving logic to instead drive "xin".
With this change this assignment needs to be evaluated only once. These
sort of changes may also speed up your traditional event driven simulator,
as it will result in fewer events per cycle.
The most complicated UNOPTFLAT path we've seen was due to low bits of a bus
being generated from an always statement that consumed high bits of the
same bus processed by another series of always blocks. The fix is the
same; split it into two separate signals generated from each block.
The UNOPTFLAT warning may also be due to clock enables, identified from the
reported path going through a clock gating cell. To fix these, use the
clock_enable meta comment described above.
=item UNSIGNED
@@ -1450,8 +1554,8 @@ that is not yet supported in Verilator. See the Limitations chapter.
=item Verilated model didn't converge
Verilator sometimes has to evaluate combinatorial logic multiple times,
usually around code where a UNOPT warning was issued, but disabled. For
example:
usually around code where a UNOPTFLAT warning was issued, but disabled.
For example:
always @ (a) b=~a;
always @ (b) a=b
@@ -1546,6 +1650,11 @@ controlled by --assert are disabled.
In C++ (non SystemC) code you need to define this function so that the
simulator knows the current time. See the "CONNECTING TO C++" examples.
=item Why do I get "undefined reference to `VL_RAND_RESET_I' or `Verilated::...'"?
You need to link your compiled Verilated code against the verilated.cpp
file found in the include directory of the Verilator kit.
=item Is the PLI supported?
No.
@@ -1556,6 +1665,12 @@ complex, since Verilator emits standard C++ code, you can simply write your
own C++ routines that can access and modify signal values without needing
any PLI interface code, and call it with $c("{any_c++_statement}").
=item How do I make a Verilog module that contain a C++ object?
You need to add the object to the structure that Verilator creates, then
use $c to call a method inside your object. The
test_regress/t/t_extend_class files show an example of how to do this.
=item How do I get faster build times?
Between GCC 3.0 to 3.3, each compiled progressively slower, thus if you can
+2 -2
View File
@@ -6,7 +6,7 @@ dnl General Public License or the Perl Artistic License.
AC_REVISION($Revision$)dnl
AC_INIT(src/Verilator.cpp)
AC_CONFIG_HEADER(src/config.h)
AC_CONFIG_HEADER(src/config_build.h)
dnl Special Substitutions
@@ -24,7 +24,7 @@ dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h unistd.h sys/file.h sys/time.h sys/un.h math.h stdint.h mingw/stdint.h)
AC_CHECK_HEADERS(fcntl.h unistd.h inttypes.h sys/file.h sys/time.h sys/un.h math.h stdint.h mingw/stdint.h)
dnl Checks for typedefs, structures
AC_CHECK_TYPE(size_t,unsigned int)
+108
View File
@@ -24,6 +24,7 @@
#include "verilated.h"
#include <string.h>
#include <ctype.h>
#define VL_VALUE_STRING_MAX_WIDTH 1024 ///< Max static char array for VL_VALUE_STRING
@@ -238,6 +239,113 @@ QData VL_FOPEN_WI(int fnwords, WDataInP filenamep, IData mode) {
return VL_CVT_FP_Q(fopen(filenamez,modez));
}
void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int,
QData ofilename, void* memp, IData start, IData end) {
IData fnw[2]; VL_SET_WQ(fnw, ofilename);
return VL_READMEM_W(hex,2,width,depth,array_lsb, fnw,memp,start,end);
}
void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
WDataInP ofilenamep, void* memp, IData start, IData end) {
char ofilenamez[VL_TO_STRING_MAX_WORDS*VL_WORDSIZE+1];
_VL_VINT_TO_STRING(fnwords*VL_WORDSIZE, ofilenamez, ofilenamep);
FILE* fp = fopen(ofilenamez, "r");
if (!fp) {
// We don't report the Verilog source filename as it slow to have to pass it down
vl_fatal (ofilenamez, 0, "", "$readmem file not found");
return;
}
// Prep for reading
IData addr = start;
int linenum = 0;
bool innum = false;
bool ignore_to_eol = false;
bool ignore_to_cmt = false;
bool needinc = false;
bool reading_addr = false;
int lastc = ' ';
// Read the data
// We process a character at a time, as then we don't need to deal
// with changing buffer sizes dynamically, etc.
while (1) {
int c = fgetc(fp);
if (c==EOF) break;
//printf("%d: Got '%c' Addr%x IN%d IgE%d IgC%d ninc%d\n", linenum, c, addr, innum, ignore_to_eol, ignore_to_cmt, needinc);
if (c=='\n') { linenum++; ignore_to_eol=false; if (innum) reading_addr=false; innum=false; }
else if (c=='\t' || c==' ' || c=='\r' || c=='\f') { if (innum) reading_addr=false; innum=false; }
// Skip // comments and detect /* comments
else if (ignore_to_cmt && lastc=='*' && c=='/') {
ignore_to_cmt = false; if (innum) reading_addr=false; innum=false;
} else if (!ignore_to_eol && !ignore_to_cmt) {
if (lastc=='/' && c=='*') { ignore_to_cmt = true; }
else if (lastc=='/' && c=='/') { ignore_to_eol = true; }
else if (c=='/') {} // Part of /* or //
else if (c=='_') {}
else if (c=='@') { reading_addr = true; innum=false; needinc=false; }
// Check for hex or binary digits as file format requests
else if (isxdigit(c)) {
c = tolower(c);
int value = (c >= 'a' ? (c-'a'+10) : (c-'0'));
if (!innum) { // Prep for next number
if (needinc) { addr++; needinc=false; }
}
if (reading_addr) {
// Decode @ addresses
if (!innum) addr=0;
addr = (addr<<4) + value;
} else {
needinc = true;
//printf(" Value width=%d @%x = %c\n", width, addr, c);
if (addr >= (IData)(depth+array_lsb) || addr < (IData)(array_lsb)) {
vl_fatal (ofilenamez, linenum, "", "$readmem file address beyond bounds of array");
} else {
int entry = addr - array_lsb;
QData shift = hex ? VL_ULL(4) : VL_ULL(1);
// Shift value in
if (width<=8) {
CData* datap = &((CData*)(memp))[entry];
if (!innum) { *datap = 0; }
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
} else if (width<=16) {
SData* datap = &((SData*)(memp))[entry];
if (!innum) { *datap = 0; }
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
} else if (width<=VL_WORDSIZE) {
IData* datap = &((IData*)(memp))[entry];
if (!innum) { *datap = 0; }
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
} else if (width<=VL_QUADSIZE) {
QData* datap = &((QData*)(memp))[entry];
if (!innum) { *datap = 0; }
*datap = ((*datap << (QData)(shift)) + (QData)(value)) & VL_MASK_Q(width);
} else {
WDataOutP datap = &((WDataOutP)(memp))[ entry*VL_WORDS_I(width) ];
if (!innum) { VL_ZERO_RESET_W(width, datap); }
_VL_SHIFTL_INPLACE_W(width, datap, shift);
datap[0] |= value;
}
if (value>=(1<<shift)) {
vl_fatal (ofilenamez, linenum, "", "$readmemb (binary) file contains hex characters");
}
}
}
innum = true;
}
else {
vl_fatal (ofilenamez, linenum, "", "$readmem file syntax error");
}
}
lastc = c;
}
if (needinc) { addr++; needinc=false; }
// Final checks
fclose(fp);
if (end != (IData)(~ VL_ULL(0)) && addr != (end+1)) {
vl_fatal (ofilenamez, linenum, "", "$readmem file ended before specified ending-address");
}
}
//===========================================================================
// Verilated:: Methods
+62 -3
View File
@@ -194,9 +194,17 @@ inline const char* VL_VALUE_FORMATTED_I(int obits, char fmt, bool drop0, IData l
}
/// File I/O
extern QData VL_FOPEN_WI(int fnwords, WDataInP filename, IData mode);
extern QData VL_FOPEN_QI(QData filename, IData mode);
inline QData VL_FOPEN_II(IData filename, IData mode) { return VL_FOPEN_QI(filename,mode); }
extern QData VL_FOPEN_WI(int fnwords, WDataInP ofilename, IData mode);
extern QData VL_FOPEN_QI(QData ofilename, IData mode);
inline QData VL_FOPEN_II(IData ofilename, IData mode) { return VL_FOPEN_QI(ofilename,mode); }
extern void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
WDataInP ofilename, void* memp, IData start, IData end);
extern void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int fnwords,
QData ofilename, void* memp, IData start, IData end);
inline void VL_READMEM_I(bool hex, int width, int depth, int array_lsb, int fnwords,
IData ofilename, void* memp, IData start, IData end) {
VL_READMEM_Q(hex, width,depth,array_lsb,fnwords, ofilename,memp,start,end); }
//=========================================================================
// Base macros
@@ -226,6 +234,13 @@ static inline QData VL_CVT_FP_Q(FILE* fp) { union { FILE* fp; QData q; } u; u.q
static inline IData VL_EXTENDSIGN_I(int lbits, IData lhs) { return (-((lhs)&(1UL<<(lbits-1)))); }
static inline QData VL_EXTENDSIGN_Q(int lbits, QData lhs) { return (-((lhs)&(VL_ULL(1)<<(lbits-1)))); }
// Debugging prints
static inline void _VL_DEBUG_PRINT_W(int lbits, WDataInP iwp) {
printf(" Data: w%d: ", lbits);
for (int i=VL_WORDS_I(lbits)-1; i>=0; i--) { printf("%08x ",iwp[i]); }
printf("\n");
}
//=========================================================================
// Pli macros
@@ -1035,6 +1050,18 @@ static inline WDataOutP VL_CONCAT_WWW(int obits,int lbits,int rbits,WDataOutP ow
//===================================================================
// Shifts
// Static shift, used by internal functions
// The output is the same as the input - it overlaps!
static inline void _VL_SHIFTL_INPLACE_W(int obits,WDataOutP iowp,IData rd/*1 or 4*/) {
int words = VL_WORDS_I(obits);
IData linsmask = VL_MASK_I(rd);
for (int i=words-1; i>=1; i--) {
iowp[i] = ((iowp[i]<<rd) & ~linsmask) | ((iowp[i-1] >> (32-rd)) & linsmask);
}
iowp[0] = ((iowp[0]<<rd) & ~linsmask);
iowp[VL_WORDS_I(obits)-1] &= VL_MASK_I(obits);
}
// EMIT_RULE: VL_SHIFTL: oclean=lclean; rclean==clean;
// Important: Unlike most other funcs, the shift might well be a computed
// expression. Thus consider this when optimizing. (And perhaps have 2 funcs?)
@@ -1328,6 +1355,38 @@ static inline WDataOutP VL_CONST_W_16X(int obits, WDataOutP o,
o[0]=d0; o[1]=d1; o[2]=d2; o[3]=d3; o[4]=d4; o[5]=d5; o[6]=d6; o[7]=d7;
o[8]=d8; o[9]=d9; o[10]=d10; o[11]=d11; o[12]=d12; o[13]=d13; o[14]=d14; o[15]=d15;
_END(obits,16); }
static inline WDataOutP VL_CONST_W_17X(int obits, WDataOutP o,
I d16,
I d15,I d14,I d13,I d12,I d11,I d10,I d9,I d8,
I d7,I d6,I d5,I d4,I d3,I d2,I d1,I d0) {
o[0]=d0; o[1]=d1; o[2]=d2; o[3]=d3; o[4]=d4; o[5]=d5; o[6]=d6; o[7]=d7;
o[8]=d8; o[9]=d9; o[10]=d10; o[11]=d11; o[12]=d12; o[13]=d13; o[14]=d14; o[15]=d15;
o[16]=d16;
_END(obits,17); }
static inline WDataOutP VL_CONST_W_18X(int obits, WDataOutP o,
I d17,I d16,
I d15,I d14,I d13,I d12,I d11,I d10,I d9,I d8,
I d7,I d6,I d5,I d4,I d3,I d2,I d1,I d0) {
o[0]=d0; o[1]=d1; o[2]=d2; o[3]=d3; o[4]=d4; o[5]=d5; o[6]=d6; o[7]=d7;
o[8]=d8; o[9]=d9; o[10]=d10; o[11]=d11; o[12]=d12; o[13]=d13; o[14]=d14; o[15]=d15;
o[16]=d16; o[17]=d17;
_END(obits,18); }
static inline WDataOutP VL_CONST_W_19X(int obits, WDataOutP o,
I d18,I d17,I d16,
I d15,I d14,I d13,I d12,I d11,I d10,I d9,I d8,
I d7,I d6,I d5,I d4,I d3,I d2,I d1,I d0) {
o[0]=d0; o[1]=d1; o[2]=d2; o[3]=d3; o[4]=d4; o[5]=d5; o[6]=d6; o[7]=d7;
o[8]=d8; o[9]=d9; o[10]=d10; o[11]=d11; o[12]=d12; o[13]=d13; o[14]=d14; o[15]=d15;
o[16]=d16; o[17]=d17; o[18]=d18;
_END(obits,19); }
static inline WDataOutP VL_CONST_W_20X(int obits, WDataOutP o,
I d19,I d18,I d17,I d16,
I d15,I d14,I d13,I d12,I d11,I d10,I d9,I d8,
I d7,I d6,I d5,I d4,I d3,I d2,I d1,I d0) {
o[0]=d0; o[1]=d1; o[2]=d2; o[3]=d3; o[4]=d4; o[5]=d5; o[6]=d6; o[7]=d7;
o[8]=d8; o[9]=d9; o[10]=d10; o[11]=d11; o[12]=d12; o[13]=d13; o[14]=d14; o[15]=d15;
o[16]=d16; o[17]=d17; o[18]=d18; o[19]=d19;
_END(obits,20); }
static inline WDataOutP VL_CONST_W_24X(int obits, WDataOutP o,
I d23,I d22,I d21,I d20,I d19,I d18,I d17,I d16,
I d15,I d14,I d13,I d12,I d11,I d10,I d9,I d8,
+3
View File
@@ -48,6 +48,9 @@ VPATH += $(VERILATOR_ROOT)/include
#OPT = -ggdb -DPRINTINITSTR
CPPFLAGS += $(OPT)
CPPFLAGS += $(M32)
LDFLAGS += $(M32)
# See the benchmarking section of bin/verilator.
# Support class optimizations. This includes the tracing and symbol table.
# SystemC takes minutes to optimize, thus it is off by default.
+5 -3
View File
@@ -15,9 +15,11 @@
/// \file
/// \brief Verilator: Common include for OS portability (verilated & verilator)
///
/// This header is used by both verilated code, and the verilator
/// program itself Code needed by only one goes into verilated.h or
/// config.h.in respectively.
/// This header is used by both the Verilator source code (run on the
/// build and host system), and the Verilated output (run on the target
/// system). Code needed by only the host system goes into
/// config_build.h.in, code needed by Verilated code only goes into
/// verilated.h, and code needed by both goes here (verilatedos.h).
///
/// Code available from: http://www.veripool.com/verilator
///
+1 -1
View File
@@ -1,5 +1,5 @@
*.old
config.h
config_build.h
Makefile
Makefile_obj
.objcache*
+1 -1
View File
@@ -87,4 +87,4 @@ clean mostlyclean distclean maintainer-clean::
-rm -f .objcache*
distclean maintainer-clean::
-rm -f Makefile Makefile_obj
-rm -f Makefile Makefile_obj config_build.h
+3 -4
View File
@@ -28,6 +28,8 @@ CC = @CC@
CXX = @CXX@
LINK = @CXX@
LDFLAGS += @LDFLAGS@
#### End of system configuration section. ####
VPATH += . $(srcdir)
@@ -36,14 +38,12 @@ TGT = ../../verilator_bin
#################
ifeq ($(VL_DEBUG),)
# Optimize
LDFLAGS =
COPT = -O
else
# Debug
LDFLAGS =
COPT = -ggdb -DVL_DEBUG
# Debug & Profile:
#LDFLAGS = -pg -g
#LDFLAGS += -pg -g
#COPT = -ggdb -pg -g
endif
#################
@@ -89,7 +89,6 @@ clean mostlyclean distclean maintainer-clean::
-rm -f obj_* .objcache*
distclean maintainer-clean:: clean
rm -f Makefile config.h
maintainer-clean::
+2 -1
View File
@@ -31,7 +31,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3ACTIVE_H_
#define _V3ACTIVE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -28,7 +28,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3ACTIVETOP_H_
#define _V3ACTIVETOP_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3ASSERT_H_
#define _V3ASSERT_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -22,7 +22,8 @@
// Attach clocks to each assertion
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3ASSERTPRE_H_
#define _V3ASSERTPRE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+6
View File
@@ -98,6 +98,12 @@ string AstNode::prettyName(const string& namein) {
while ((pos=pretty.find("__DOT__")) != string::npos) {
pretty.replace(pos, 7, ".");
}
while ((pos=pretty.find("__BRA__")) != string::npos) {
pretty.replace(pos, 7, "[");
}
while ((pos=pretty.find("__KET__")) != string::npos) {
pretty.replace(pos, 7, "]");
}
while ((pos=pretty.find("__PVT__")) != string::npos) {
pretty.replace(pos, 7, "");
}
+3 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3AST_H_
#define _V3AST_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Number.h"
#include <vector>
@@ -57,6 +58,7 @@ public:
COVERAGE_BLOCK_OFF,
INLINE_MODULE,
NO_INLINE_MODULE,
NO_INLINE_TASK,
PUBLIC_MODULE,
PUBLIC_TASK
};
+5 -1
View File
@@ -19,6 +19,8 @@
//
//*************************************************************************
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <fstream>
@@ -349,7 +351,8 @@ void AstVar::dump(ostream& str) {
if (isSigPublic()) str<<" [P]";
if (attrClockEn()) str<<" [aCLKEN]";
if (attrFileDescr()) str<<" [aFD]";
if (isFuncLocal() || isFuncReturn()) str<<" [FUNC]";
if (isFuncReturn()) str<<" [FUNCRTN]";
else if (isFuncLocal()) str<<" [FUNC]";
str<<" "<<varType();
}
void AstSenTree::dump(ostream& str) {
@@ -375,6 +378,7 @@ void AstNodeFTaskRef::dump(ostream& str) {
}
void AstNodeFTask::dump(ostream& str) {
this->AstNode::dump(str);
if (taskPublic()) str<<" [PUBLIC]";
}
void AstCoverDecl::dump(ostream& str) {
this->AstNode::dump(str);
+29
View File
@@ -1167,6 +1167,7 @@ public:
virtual int instrCount() const { return widthInstrs()+instrCountBranch(); }
AstNode* condsp() const { return op1p()->castNode(); } // op1= list of possible matching expressions
AstNode* bodysp() const { return op2p()->castNode(); } // op2= what to do
void condsp(AstNode* nodep) { setOp1p(nodep); }
void addBodysp(AstNode* newp) { addOp2p(newp); }
bool isDefault() const { return condsp()==NULL; }
bool ignoreOverlap() const { return m_ignoreOverlap; }
@@ -1251,6 +1252,34 @@ struct AstFOpen : public AstNodeStmt {
AstNode* modep() const { return op3p(); }
};
struct AstReadMem : public AstNodeStmt {
private:
bool m_isHex; // readmemh, not readmemb
public:
AstReadMem(FileLine* fileline, bool hex,
AstNode* filenamep, AstNode* memp, AstNode* lsbp, AstNode* msbp)
: AstNodeStmt (fileline), m_isHex(hex) {
setOp1p(filenamep); setOp2p(memp); setNOp3p(lsbp); setNOp4p(msbp);
}
virtual ~AstReadMem() {}
virtual AstType type() const { return AstType::READMEM;}
virtual AstNode* clone() { return new AstReadMem(*this); }
virtual void accept(AstNVisitor& v, AstNUser* vup=NULL) { v.visit(this,vup); }
virtual string verilogKwd() const { return (isHex()?"$readmemh":"$readmemb"); };
virtual bool isGateOptimizable() const { return false; }
virtual bool isPredictOptimizable() const { return false; }
virtual bool isSplittable() const { return false; }
virtual bool isOutputter() const { return true; }
virtual bool isUnlikely() const { return true; }
virtual V3Hash sameHash() const { return V3Hash(); }
virtual bool same(AstNode* samep) const { return isHex()==samep->castReadMem()->isHex(); }
bool isHex() const { return m_isHex; }
AstNode* filenamep() const { return op1p()->castNode(); }
AstNode* memp() const { return op2p()->castNode(); }
AstNode* lsbp() const { return op3p()->castNode(); }
AstNode* msbp() const { return op4p()->castNode(); }
};
struct AstGenFor : public AstNodeFor {
AstGenFor(FileLine* fileline, AstNode* initsp, AstNode* condp,
AstNode* incsp, AstNode* bodysp)
+2 -1
View File
@@ -27,7 +27,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3BEGIN_H_
#define _V3BEGIN_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -25,7 +25,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3BRANCH_H_
#define _V3BRANCH_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -26,7 +26,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3BROKEN_H_
#define _V3BROKEN_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+65 -26
View File
@@ -38,7 +38,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -51,6 +52,7 @@
#define CASE_OVERLAP_WIDTH 12 // Maximum width we can check for overlaps in
#define CASE_BARF 999999 // Magic width when non-constant
#define CASE_ENCODER_GROUP_DEPTH 8 // Levels of priority to be ORed together in top IF tree
//######################################################################
@@ -274,21 +276,15 @@ private:
// IF((EQ (AND MASK cexpr) (AND MASK icond1)
// ,istmts2, istmts3
AstNode* cexprp = nodep->exprp()->unlinkFrBack();
AstNode* ifrootp = NULL;
AstNode* ifnextp = NULL;
// We'll do this in two stages. First stage, convert the conditions to
// the appropriate IF AND terms.
if (debug()>=9) nodep->dumpTree(cout," _comp_IN: ");
bool hadDefault = false;
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
AstNode* istmtsp = itemp->bodysp(); // Maybe null -- no action.
if (istmtsp) istmtsp->unlinkFrBackWithNext();
if (!itemp->condsp()) {
// Default clause. We reordered in link, so default is always last
if (ifnextp) {
if (istmtsp) ifnextp->castIf()->addElsesp(istmtsp);
} else { // Just a empty case default: endcase
ifnextp = istmtsp;
}
if (!ifrootp) ifrootp = istmtsp;
ifnextp = istmtsp;
itemp = NULL; break;
// Default clause. Just make true, we'll optimize it away later
itemp->condsp(new AstConst(itemp->fileline(), V3Number(itemp->fileline(), 1,1)));
hadDefault = true;
} else {
// Expressioned clause
AstNode* icondNextp = NULL;
@@ -323,24 +319,67 @@ private:
ifexprp = new AstLogOr(itemp->fileline(), ifexprp, condp);
}
}
// Make the new IF and attach in the tree
if (ifexprp) {
AstIf* newp = new AstIf(itemp->fileline(), ifexprp, istmtsp, NULL);
if (ifnextp) {
ifnextp->castIf()->addElsesp(newp);
}
if (!ifrootp) ifrootp = newp;
ifnextp = newp;
}
// Replace expression in tree
itemp->condsp(ifexprp);
}
}
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.
nodep->addItemsp(new AstCaseItem(nodep->fileline(),
new AstConst(nodep->fileline(), V3Number(nodep->fileline(),1,1)),
NULL));
}
if (debug()>=9) nodep->dumpTree(cout," _comp_COND: ");
// Now build the IF statement tree
// The tree can be quite huge. Pull ever group of 8 out, and make a OR tree.
// This reduces the depth for the bottom elements, at the cost of some of the top elements.
// If we ever have profiling data, we should pull out the most common item from here and
// instead make it the first IF branch.
int depth = 0;
AstNode* grouprootp = NULL;
AstIf* groupnextp = NULL;
AstIf* itemnextp = NULL;
for (AstCaseItem* itemp = nodep->itemsp(); itemp; itemp=itemp->nextp()->castCaseItem()) {
AstNode* istmtsp = itemp->bodysp(); // Maybe null -- no action.
if (istmtsp) istmtsp->unlinkFrBackWithNext();
// Expressioned clause
AstNode* ifexprp = itemp->condsp()->unlinkFrBack();
{ // Prepare for next group
if (++depth > CASE_ENCODER_GROUP_DEPTH) depth = 1;
if (depth == 1) { // First group or starting new group
itemnextp = NULL;
AstIf* newp = new AstIf(itemp->fileline(), ifexprp->cloneTree(true), NULL, NULL);
if (groupnextp) groupnextp->addElsesp(newp);
else grouprootp = newp;
groupnextp = newp;
} else { // Continue group, modify if condition to OR in this new condition
AstNode* condp = groupnextp->condp()->unlinkFrBack();
groupnextp->condp(new AstOr(ifexprp->fileline(),
condp,
ifexprp->cloneTree(true)));
}
}
{ // Make the new lower IF and attach in the tree
AstNode* itemexprp = ifexprp; ifexprp=NULL;
if (depth == (CASE_ENCODER_GROUP_DEPTH)) { // End of group - can skip the condition
itemexprp->deleteTree(); itemexprp=NULL;
itemexprp = new AstConst(itemp->fileline(), V3Number(itemp->fileline(),1,1));
}
AstIf* newp = new AstIf(itemp->fileline(), itemexprp, istmtsp, NULL);
if (itemnextp) itemnextp->addElsesp(newp);
else groupnextp->addIfsp(newp); // First in a new group
itemnextp = newp;
}
}
if (debug()>=9) nodep->dumpTree(cout," _comp_TREE: ");
// Handle any assertions
replaceCaseParallel(nodep, false);
// Replace the CASE... with IF...
if (ifrootp) nodep->replaceWith(ifrootp);
if (debug()>=9) grouprootp->dumpTree(cout," _new: ");
if (grouprootp) nodep->replaceWith(grouprootp);
else nodep->unlinkFrBack();
if (debug()>=9) ifrootp->dumpTree(cout," _new: ");
nodep->deleteTree(); nodep=NULL;
}
void replaceCaseParallel(AstCase* nodep, bool noOverlapsAllCovered) {
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CASE_H_
#define _V3CASE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -42,7 +42,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CAST_H_
#define _V3CAST_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -31,7 +31,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CHANGED_H_
#define _V3CHANGED_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+6 -1
View File
@@ -28,7 +28,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -239,6 +240,10 @@ private:
nodep->iterateChildren(*this);
insureCleanAndNext (nodep->bodysp());
}
virtual void visit(AstCCall* nodep, AstNUser*) {
nodep->iterateChildren(*this);
insureCleanAndNext (nodep->argsp());
}
//--------------------
// Default: Just iterate
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CLEAN_H_
#define _V3CLEAN_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+3 -3
View File
@@ -32,7 +32,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -364,8 +365,7 @@ private:
// Move statements to if
m_lastIfp->addIfsp(stmtsp);
} else if (nodep->hasSettle()) {
// Settlement
clearLastSen();
// Don't need to: clearLastSen();, as we're adding it to different cfunc
// Move statements to function
addToSettleLoop(stmtsp);
} else {
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CLOCK_H_
#define _V3CLOCK_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -35,7 +35,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3COMBINE_H_
#define _V3COMBINE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -25,7 +25,8 @@
// If operands are constant, replace this node with constant.
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3CONST_H_
#define _V3CONST_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -29,7 +29,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3COVERAGE_H_
#define _V3COVERAGE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -24,7 +24,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3DEAD_H_
#define _V3DEAD_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -52,7 +52,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3DELAYED_H_
#define _V3DELAYED_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -28,7 +28,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3DEPTH_H_
#define _V3DEPTH_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -27,7 +27,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3DESCOPE_H_
#define _V3DESCOPE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+49 -17
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -96,22 +97,20 @@ public:
string cFuncArgs(AstCFunc* nodep) {
// Return argument list for given C function
string args = nodep->argTypes();
if (args=="") {
// Might be a user function with argument list.
for (AstNode* stmtp = nodep->argsp(); stmtp; stmtp=stmtp->nextp()) {
if (AstVar* portp = stmtp->castVar()) {
if (portp->isIO() && !portp->isFuncReturn()) {
if (args != "") args+= ", ";
if (portp->isWide()) {
if (portp->isInOnly()) args += "const ";
args += portp->cType();
args += " (& "+portp->name();
args += ")["+cvtToStr(portp->widthWords())+"]";
} else {
args += portp->cType();
if (portp->isOutput()) args += "&";
args += " "+portp->name();
}
// Might be a user function with argument list.
for (AstNode* stmtp = nodep->argsp(); stmtp; stmtp=stmtp->nextp()) {
if (AstVar* portp = stmtp->castVar()) {
if (portp->isIO() && !portp->isFuncReturn()) {
if (args != "") args+= ", ";
if (portp->isWide()) {
if (portp->isInOnly()) args += "const ";
args += portp->cType();
args += " (& "+portp->name();
args += ")["+cvtToStr(portp->widthWords())+"]";
} else {
args += portp->cType();
if (portp->isOutput()) args += "&";
args += " "+portp->name();
}
}
}
@@ -250,6 +249,39 @@ public:
nodep->modep()->iterateAndNext(*this);
puts(");\n");
}
virtual void visit(AstReadMem* nodep, AstNUser*) {
puts("VL_READMEM_");
emitIQW(nodep->filenamep());
puts(" ("); // We take a void* rather then emitIQW(nodep->memp());
puts(nodep->isHex()?"true":"false");
putbs(",");
puts(cvtToStr(nodep->memp()->widthMin())); // Need real storage width
putbs(",");
uint32_t array_lsb = 0;
{
AstVarRef* varrefp = nodep->memp()->castVarRef();
if (!varrefp || !varrefp->varp()->arrayp(0)) { nodep->v3error("Readmem loading non-arrayed variable"); }
else {
puts(cvtToStr(varrefp->varp()->arrayElements()));
array_lsb = varrefp->varp()->arrayp(0)->lsbConst();
}
}
putbs(", ");
puts(cvtToStr(array_lsb));
putbs(",");
puts(cvtToStr(nodep->filenamep()->widthWords()));
if (nodep->filenamep()->widthWords() > VL_TO_STRING_MAX_WORDS) {
nodep->v3error("String of "<<nodep->filenamep()->width()<<" bits exceeds hardcoded limit VL_TO_STRING_MAX_WORDS in verilatedos.h\n");
}
putbs(", ");
nodep->filenamep()->iterateAndNext(*this);
putbs(", ");
nodep->memp()->iterateAndNext(*this);
putbs(","); if (nodep->lsbp()) { nodep->lsbp()->iterateAndNext(*this); }
else puts(cvtToStr(array_lsb));
putbs(","); if (nodep->msbp()) { nodep->msbp()->iterateAndNext(*this); } else puts("~0");
puts(");\n");
}
virtual void visit(AstFClose* nodep, AstNUser*) {
puts("if (");
nodep->filep()->iterateAndNext(*this);
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3EMITC_H_
#define _V3EMITC_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+3 -2
View File
@@ -22,7 +22,8 @@
#ifndef _V3EMITCBASE_H_
#define _V3EMITCBASE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -109,7 +110,7 @@ public:
bool optSystemPerl() { return v3Global.opt.systemPerl(); }
static string symClassName() { return v3Global.opt.prefix()+"__Syms"; }
static string symClassVar() { return symClassName()+"* __restrict vlSymsp"; }
static string symTopAssign() { return v3Global.opt.prefix()+"* __restrict vlTOPp = vlSymsp->TOPp;"; }
static string symTopAssign() { return v3Global.opt.prefix()+"* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp;"; }
static string modClassName(AstModule* modp) { // Return name of current module being processed
if (modp->isTop()) {
return v3Global.opt.prefix();
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3EMITMK_H_
#define _V3EMITMK_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+12 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -192,6 +193,16 @@ public:
if (nodep->filep()) nodep->filep()->iterateChildren(*this);
puts(");\n");
}
virtual void visit(AstReadMem* nodep, AstNUser*) {
putbs(nodep->verilogKwd());
putbs(" (");
if (nodep->filenamep()) nodep->filenamep()->iterateChildren(*this);
putbs(",");
if (nodep->memp()) nodep->memp()->iterateChildren(*this);
if (nodep->lsbp()) { putbs(","); nodep->lsbp()->iterateChildren(*this); }
if (nodep->msbp()) { putbs(","); nodep->msbp()->iterateChildren(*this); }
puts(");\n");
}
virtual void visit(AstNodeFor* nodep, AstNUser*) {
puts("for (");
m_suppressSemi = true;
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3EMITV_H_
#define _V3EMITV_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+5 -5
View File
@@ -92,7 +92,7 @@ void FileLine::lineDirective(const char* textp) {
bool FileLine::warnOff(const string& msg, bool flag) {
V3ErrorCode code (msg.c_str());
if (code == V3ErrorCode::ERROR) {
if (code < V3ErrorCode::FIRST_WARN) {
return false;
} else {
warnOff(code, flag);
@@ -168,9 +168,8 @@ void FileLine::v3errorEnd(ostringstream& str) {
void V3Error::init() {
for (int i=0; i<V3ErrorCode::MAX; i++) {
s_describedEachWarn[i] = false;
s_pretendError[i] = false;
s_pretendError[i] = V3ErrorCode(i).pretendError();
}
pretendError(V3ErrorCode::BLKANDNBLK, true);
if (string(V3ErrorCode(V3ErrorCode::MAX).ascii()) != " MAX") {
v3fatalSrc("Enum table in V3ErrorCode::ascii() is munged");
@@ -204,8 +203,9 @@ void V3Error::abortIfErrors() {
string V3Error::msgPrefix(V3ErrorCode code) {
if (code==V3ErrorCode::SUPPRESS) return "-arning-suppressed: ";
else if (code==V3ErrorCode::FATAL) return "%Error: ";
else if (code==V3ErrorCode::ERROR
|| s_pretendError[code]) return "%Error: ";
else if (code==V3ErrorCode::ERROR) return "%Error: ";
else if (code<V3ErrorCode::FIRST_WARN
|| s_pretendError[code]) return "%Error-"+(string)code.ascii()+": ";
else return "%Warning-"+(string)code.ascii()+": ";
}
+12 -3
View File
@@ -21,7 +21,8 @@
#ifndef _V3ERROR_H_
#define _V3ERROR_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <string>
#include <iostream>
#include <sstream>
@@ -34,9 +35,12 @@ public:
enum en {
SUPPRESS, // Warning suppressed by user
FATAL, // Kill the program
ERROR, // Error out, can't suppress
ERROR, // General error out, can't suppress
// Error codes:
TASKNSVAR, // Error: Task I/O not simple
// Warning codes:
FIRST_WARN, // Just a code so the program knows where to start warnings
//
BLKANDNBLK, // Blocked and non-blocking assignments to same variable
CASEINCOMPLETE, // Case statement has missing values
CASEOVERLAP, // Case statements overlap
@@ -45,6 +49,7 @@ public:
COMBDLY, // Combinatorial delayed assignment
GENCLK, // Generated Clock
IMPLICIT, // Implicit wire
IMPURE, // Impure function not being inlined
MULTIDRIVEN, // Driven from multiple blocks
UNDRIVEN, // No drivers
UNOPT, // Unoptimizable block
@@ -66,10 +71,11 @@ public:
const char* names[] = {
// Leading spaces indicate it can't be disabled.
" SUPPRESS", " FATAL", " ERROR",
"TASKNSVAR",
" FIRST_WARN",
"BLKANDNBLK",
"CASEINCOMPLETE", "CASEOVERLAP", "CASEX", "CMPCONST",
"COMBDLY", "GENCLK", "IMPLICIT",
"COMBDLY", "GENCLK", "IMPLICIT", "IMPURE",
"MULTIDRIVEN",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
"VARHIDDEN", "WIDTH",
@@ -79,6 +85,9 @@ public:
};
// Warnings that warn about nasty side effects
bool dangerous() const { return ( m_e==COMBDLY );};
// Warnings we'll present to the user as errors
// Later -Werror- options may make more of these.
bool pretendError() const { return ( m_e==BLKANDNBLK || m_e==IMPURE); };
};
inline bool operator== (V3ErrorCode lhs, V3ErrorCode rhs) { return (lhs.m_e == rhs.m_e); }
inline bool operator== (V3ErrorCode lhs, V3ErrorCode::en rhs) { return (lhs.m_e == rhs); }
+5 -1
View File
@@ -30,7 +30,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -660,6 +661,9 @@ private:
// Lhs or Rhs may be word, long, or quad.
// newAstWordSelClone nicely abstracts the difference.
int rhsshift = rhsp->rhsp()->widthMin();
// Sometimes doing the words backwards is preferrable.
// When we have x={x,foo} backwards is better, when x={foo,x} forward is better
// However V3Subst tends to rip this up, so not worth optimizing now.
for (int w=0; w<rhsp->widthWords(); w++) {
addWordAssign(nodep, w,
new AstOr (rhsp->fileline(),
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3EXPAND_H_
#define _V3EXPAND_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdarg.h>
#include <sys/stat.h>
#include <unistd.h>
+5 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3FILE_H_
#define _V3FILE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include <stdio.h>
#include <stack>
@@ -42,6 +43,9 @@ public:
}
static ofstream* new_ofstream(const string& filename, bool append=false) {
addTgtDepend(filename);
return new_ofstream_nodepend (filename, append);
}
static ofstream* new_ofstream_nodepend(const string& filename, bool append=false) {
if (append) {
return new ofstream(filename.c_str(), ios::app);
} else {
+2 -1
View File
@@ -26,7 +26,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3GATE_H_
#define _V3GATE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -24,7 +24,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3GENCLK_H_
#define _V3GENCLK_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -22,7 +22,8 @@
#ifndef _V3GLOBAL_H_
#define _V3GLOBAL_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <string>
#include "V3Error.h"
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3GRAPH_H_
#define _V3GRAPH_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3List.h"
#include <vector>
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3GRAPHALG_H_
#define _V3GRAPHALG_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Global.h"
#include "V3Graph.h"
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3GRAPHDFA_H_
#define _V3GRAPHDFA_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <vector>
#include "V3Global.h"
+2 -1
View File
@@ -19,7 +19,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -26,7 +26,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3HASHED_H_
#define _V3HASHED_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -29,7 +29,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3INLINE_H_
#define _V3INLINE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+3 -2
View File
@@ -26,7 +26,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -200,7 +201,7 @@ private:
}
// Save some time
virtual void visit(AstNodeStmt*, AstNUser*) {}
virtual void visit(AstNodeMath*, AstNUser*) {}
//--------------------
// Default: Just iterate
virtual void visit(AstNode* nodep, AstNUser*) {
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3INST_H_
#define _V3INST_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LANGUAGEWORDS_H_
#define _V3LANGUAGEWORDS_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <map>
//============================================================================
+5 -2
View File
@@ -28,7 +28,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -374,7 +375,9 @@ private:
//UINFO(4," CCALL "<<nodep<<endl);
nodep->iterateChildren(*this);
// Enter the function and trace it
nodep->funcp()->accept(*this);
if (!nodep->funcp()->entryPoint()) { // else is non-inline or public function we optimize separately
nodep->funcp()->accept(*this);
}
}
virtual void visit(AstUCFunc* nodep, AstNUser*) {
m_sideEffect = true; // If appears on assign RHS, don't ever delete the assignment
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LIFE_H_
#define _V3LIFE_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -29,7 +29,8 @@
//
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LIFEPOST_H_
#define _V3LIFEPOST_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -26,7 +26,8 @@
// Link to var they reference
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LINK_H_
#define _V3LINK_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -25,7 +25,8 @@
// Link to module that instantiates it
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LINKCELLS_H_
#define _V3LINKCELLS_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+89 -15
View File
@@ -29,7 +29,8 @@
// Find appropriate named cell and link to var they reference
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
@@ -81,6 +82,26 @@ public:
}
return NULL;
}
void errorScopes(AstNode* nodep) {
if (!this) { // Silence if we messed it up and aren't debugging
if (debug()) nodep->v3fatalSrc("Void pointer; perhaps used null vxp instead of okVxp?");
return;
}
{
string scopes;
for (NameVtxMap::iterator it = m_nameToVtxMap.begin(); it!=m_nameToVtxMap.end(); ++it) {
if (scopes != "") scopes += ", ";
scopes += AstNode::prettyName(it->second->cellName());
}
cerr<<V3Error::msgPrefix()<<" Known scopes under '"<<cellName()<<"': "
<<scopes<<endl;
}
if (debug()) {
for (NameVtxMap::iterator it = m_nameToVtxMap.begin(); it!=m_nameToVtxMap.end(); ++it) {
UINFO(1,"\t\t KnownScope: "<<it->second->name()<<endl);
}
}
}
};
class LinkDotCellVertex : public LinkDotBaseVertex {
@@ -125,6 +146,27 @@ public:
virtual string dotColor() const { return "yellow"; }
};
class LinkDotBeginVertex : public LinkDotBaseVertex {
// A fake point in the hierarchy, corresponding to a begin block
// After we remove begins these will go away
// Note we use the symbol table of the parent, as we want to find variables there
// However, cells walk the graph, so cells will appear under the begin itself
AstBegin* m_nodep; // Relevant node
LinkDotCellVertex* m_symVxp; // Above cell so we can find real symbol table
// // (Could walk graph to find it, but that's much slower.)
public:
LinkDotBeginVertex(V3Graph* graphp, AstBegin* nodep, LinkDotCellVertex* symVxp)
: LinkDotBaseVertex(graphp, nodep->name()+"__DOT__")
, m_nodep(nodep), m_symVxp(symVxp) {}
virtual ~LinkDotBeginVertex() {}
// Search up through tree to find the real symbol table.
virtual V3SymTable& syms() { return m_symVxp->syms(); }
virtual string modName() const { return m_nodep->name(); }
virtual string cellName() const { return m_nodep->name(); }
virtual string name() const { return (string)("BEG C:")+cellName(); }
virtual string dotColor() const { return "blue"; }
};
//######################################################################
// LinkDot state, as a visitor of each AstNode
@@ -194,6 +236,14 @@ public:
}
return vxp;
}
LinkDotBeginVertex* insertBegin(LinkDotBaseVertex* abovep, LinkDotCellVertex* cellVxp,
AstBegin* nodep) {
UINFO(9," INSERTbeg "<<nodep<<endl);
LinkDotBeginVertex* vxp = new LinkDotBeginVertex(&m_graph, nodep, cellVxp);
new V3GraphEdge(&m_graph, abovep, vxp, 1, false);
abovep->insertSubcellName(nodep->name(), vxp);
return vxp;
}
void insertSym(LinkDotCellVertex* abovep, const string& name, AstNode* nodep) {
UINFO(9," INSERTsym "<<name<<" "<<nodep<<endl);
abovep->syms().insert(name, nodep);
@@ -225,12 +275,14 @@ private:
return NULL;
}
public:
LinkDotBaseVertex* findDotted(LinkDotBaseVertex* cellVxp, const string& dotname, string& baddot) {
LinkDotBaseVertex* findDotted(LinkDotBaseVertex* cellVxp, const string& dotname,
string& baddot, LinkDotBaseVertex*& okVxp) {
// Given a dotted hiearchy name, return where in scope it is
// Note when dotname=="" we just fall through and return cellVxp
UINFO(8," dottedFind "<<dotname<<endl);
bool firstId = true;
string leftname = dotname;
okVxp = cellVxp; // So can list bad scopes
while (leftname != "") { // foreach dotted part of xref name
string::size_type pos;
string ident;
@@ -242,6 +294,7 @@ public:
leftname = "";
}
baddot = ident; // So user can see where they botched it
okVxp = cellVxp;
string altIdent = "";
if (m_forPrearray) {
// Cell foo__[array] before we've expanded arrays is just foo.
@@ -353,29 +406,36 @@ private:
}
virtual void visit(AstCell* nodep, AstNUser*) {
UINFO(5," CELL under "<<m_scope<<" is "<<nodep<<endl);
// Process XREFs inside pins
nodep->iterateChildren(*this);
// Recurse in, preserving state
string oldscope = m_scope;
AstBegin* oldbeginp = m_beginp;
LinkDotCellVertex* oldVxp = m_cellVxp;
LinkDotBaseVertex* oldInlineVxp = m_inlineVxp;
// Where do we add it?
LinkDotBaseVertex* aboveVxp = m_cellVxp;
LinkDotBaseVertex* aboveVxp = m_inlineVxp;
string origname = nodep->prettyName();
string::size_type pos;
if ((pos = origname.rfind(".")) != string::npos) {
// Flattened, find what CellInline it should live under
string scope = origname.substr(0,pos);
string baddot;
aboveVxp = m_statep->findDotted(aboveVxp, scope, baddot);
LinkDotBaseVertex* okVxp;
aboveVxp = m_statep->findDotted(aboveVxp, scope, baddot, okVxp);
if (!aboveVxp) nodep->v3fatalSrc("Can't find cell insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
}
{
m_scope = m_scope+"."+nodep->name();
m_cellVxp = m_statep->insertCell(aboveVxp, m_cellVxp, nodep, m_scope);
m_inlineVxp = m_cellVxp;
m_beginp = NULL;
if (nodep->modp()) nodep->modp()->accept(*this);
}
m_scope = oldscope;
m_beginp = oldbeginp;
m_cellVxp = oldVxp;
m_inlineVxp = m_cellVxp;
m_inlineVxp = oldInlineVxp;
}
virtual void visit(AstCellInline* nodep, AstNUser*) {
UINFO(5," CELLINLINE under "<<m_scope<<" is "<<nodep<<endl);
@@ -387,7 +447,8 @@ private:
string dotted = dottedname.substr(0, pos);
string ident = dottedname.substr(pos+strlen("__DOT__"));
string baddot;
aboveVxp = m_statep->findDotted(aboveVxp, dotted, baddot);
LinkDotBaseVertex* okVxp;
aboveVxp = m_statep->findDotted(aboveVxp, dotted, baddot, okVxp);
if (!aboveVxp) nodep->v3fatalSrc("Can't find cellinline insertion point at '"<<baddot<<"' in: "<<nodep->prettyName());
m_statep->insertInline(aboveVxp, m_cellVxp, nodep, ident);
} else { // No __DOT__, just directly underneath
@@ -396,10 +457,16 @@ private:
}
virtual void visit(AstBegin* nodep, AstNUser*) {
UINFO(5," "<<nodep<<endl);
// We don't pickup variables, but do need to find cells
AstBegin* oldbegin = m_beginp;
m_beginp = nodep;
nodep->iterateChildren(*this);
LinkDotBaseVertex* oldVxp = m_inlineVxp;
{
m_beginp = nodep;
// Ignore begin names
m_inlineVxp = m_statep->insertBegin(m_inlineVxp, m_cellVxp, nodep);
// We don't pickup variables, but do need to find cells
nodep->iterateChildren(*this);
}
m_inlineVxp = oldVxp;
m_beginp = oldbegin;
}
virtual void visit(AstVar* nodep, AstNUser*) {
@@ -407,6 +474,8 @@ private:
&& !m_beginp // For now, we don't support xrefs into begin blocks
&& !nodep->isFuncLocal()) {
m_statep->insertSym(m_cellVxp, nodep->name(), nodep);
} else {
UINFO(9," Not allowing dot refs to: "<<nodep<<endl);
}
}
virtual void visit(AstNodeFTask* nodep, AstNUser*) {
@@ -418,7 +487,7 @@ private:
}
// For speed, don't recurse things that can't have cells
virtual void visit(AstNodeStmt*, AstNUser*) {}
// Note we allow AstNodeStmt's as generates may be under them
virtual void visit(AstNodeMath*, AstNUser*) {}
virtual void visit(AstNode* nodep, AstNUser*) {
// Default: Just iterate
@@ -479,9 +548,9 @@ private:
nodep->iterateChildren(*this);
}
// For speed, don't recurse things that can't have scope
// Note we allow AstNodeStmt's as generates may be under them
virtual void visit(AstCell*, AstNUser*) {}
virtual void visit(AstVar*, AstNUser*) {}
virtual void visit(AstNodeStmt*, AstNUser*) {}
virtual void visit(AstNodeMath*, AstNUser*) {}
virtual void visit(AstNode* nodep, AstNUser*) {
// Default: Just iterate
@@ -544,13 +613,14 @@ private:
nodep->varp(NULL); // Module that is not in hiearchy. We'll be dead code eliminating it later.
} else {
string baddot;
LinkDotBaseVertex* okVxp;
LinkDotBaseVertex* dotVxp = m_cellVxp; // Start search at current scope
if (nodep->inlinedDots()!="") { // Correct for current scope
string inl = AstNode::prettyName(nodep->inlinedDots());
dotVxp = m_statep->findDotted(dotVxp, inl, baddot);
dotVxp = m_statep->findDotted(dotVxp, inl, baddot, okVxp);
if (!dotVxp) nodep->v3fatalSrc("Couldn't resolve inlined scope '"<<baddot<<"' in: "<<nodep->inlinedDots());
}
dotVxp = m_statep->findDotted(dotVxp, nodep->dotted(), baddot); // Maybe NULL
dotVxp = m_statep->findDotted(dotVxp, nodep->dotted(), baddot, okVxp); // Maybe NULL
if (!m_statep->forScopeCreation()) {
AstVar* varp = (m_statep->findSym(dotVxp, nodep->name(), baddot)
->castVar()); // maybe NULL
@@ -558,6 +628,7 @@ private:
UINFO(7," Resolved "<<nodep<<endl); // Also prints varp
if (!nodep->varp()) {
nodep->v3error("Can't find definition of '"<<baddot<<"' in dotted signal: "<<nodep->dotted()+"."+nodep->prettyName());
okVxp->errorScopes(nodep);
}
} else {
string baddot;
@@ -565,6 +636,7 @@ private:
->castVarScope()); // maybe NULL
if (!vscp) {
nodep->v3error("Can't find varpin scope of '"<<baddot<<"' in dotted signal: "<<nodep->dotted()+"."+nodep->prettyName());
okVxp->errorScopes(nodep);
} else {
while (vscp->user2p()) { // If V3Inline aliased it, pick up the new signal
UINFO(7," Resolved pre-alias "<<vscp<<endl); // Also prints taskp
@@ -588,14 +660,15 @@ private:
nodep->taskp(NULL); // Module that is not in hiearchy. We'll be dead code eliminating it later.
} else {
string baddot;
LinkDotBaseVertex* okVxp;
LinkDotBaseVertex* dotVxp = m_cellVxp; // Start search at current scope
if (nodep->inlinedDots()!="") { // Correct for current scope
string inl = AstNode::prettyName(nodep->inlinedDots());
UINFO(8,"\t\tInlined "<<inl<<endl);
dotVxp = m_statep->findDotted(dotVxp, inl, baddot);
dotVxp = m_statep->findDotted(dotVxp, inl, baddot, okVxp);
if (!dotVxp) nodep->v3fatalSrc("Couldn't resolve inlined scope '"<<baddot<<"' in: "<<nodep->inlinedDots());
}
dotVxp = m_statep->findDotted(dotVxp, nodep->dotted(), baddot); // Maybe NULL
dotVxp = m_statep->findDotted(dotVxp, nodep->dotted(), baddot, okVxp); // Maybe NULL
AstNodeFTask* taskp = (m_statep->findSym(dotVxp, nodep->name(), baddot)
->castNodeFTask()); // maybe NULL
@@ -603,6 +676,7 @@ private:
UINFO(7," Resolved "<<nodep<<endl); // Also prints taskp
if (!nodep->taskp()) {
nodep->v3error("Can't find definition of '"<<baddot<<"' in dotted task/function: "<<nodep->dotted()+"."+nodep->prettyName());
okVxp->errorScopes(nodep);
}
}
nodep->iterateChildren(*this);
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LINKDOT_H_
#define _V3LINKDOT_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -24,7 +24,8 @@
// Create new MODULE TOP with connections to below signals
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+2 -1
View File
@@ -21,7 +21,8 @@
#ifndef _V3LINKLEVEL_H_
#define _V3LINKLEVEL_H_ 1
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
+2 -1
View File
@@ -28,7 +28,8 @@
// Convert normal var to FILE* type
//*************************************************************************
#include "config.h"
#include "config_build.h"
#include "verilatedos.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>

Some files were not shown because too many files have changed in this diff Show More