Compare commits

...
101 Commits
Author SHA1 Message Date
Wilson Snyder 0029d068c7 Version bump 2012-04-15 16:21:31 -04:00
Wilson Snyder de388b3dc8 Part of last commit 2012-04-15 16:14:18 -04:00
Wilson Snyder fb904d53cd Add doxygen comments, bug482 2012-04-15 15:44:32 -04:00
Wilson Snyder 600cc02de3 Commentary 2012-04-15 15:08:13 -04:00
Wilson Snyder 946d0cd219 Add readme.pdf and internal.pdf 2012-04-15 14:51:04 -04:00
Wilson Snyder 4d0b964e36 Internals: Merge from dtype. Create subDTypep. No functional change intended. 2012-04-14 12:43:03 -04:00
Wilson Snyder 2b12ab4d5a Internals: Merge from dtype. Add hasDType; still unused. No functional change. 2012-04-14 11:03:38 -04:00
Wilson Snyder 8114957e6d Internals: Merge from dtype. Rename isSigned to dtypeChgSigned. No functional change. 2012-04-14 10:45:24 -04:00
Wilson Snyder 50edef4ab2 Add Emacs indentation line. No functional change 2012-04-12 21:08:20 -04:00
Wilson Snyder e5a991988f Tests added 2012-04-12 20:13:35 -04:00
Wilson Snyder e85eb6d0f4 Tests: Add t_enum_type_methods, bug473 2012-04-12 18:21:08 -04:00
Wilson Snyder 6949f35f22 Tests: Add t_array_query, t_sv_conditional, bug473 2012-04-12 18:15:39 -04:00
Wilson Snyder e0391b93c4 Commentary 2012-04-12 06:48:02 -04:00
Wilson Snyder 4a5e775a2b Fix change detections on arrays. 2012-04-09 20:17:51 -04:00
Wilson Snyder 323f019350 Tests: Add t_interface, bug481. Merge from JERAS/test_sv. 2012-04-08 18:13:56 -04:00
Wilson Snyder 98053c2d4c Tests: Add t_param_type, bug480. Merge from JERAS/test_sv. 2012-04-08 17:59:46 -04:00
Wilson Snyder aab338760c Increase VL_VALUE_STRING_MAX_WIDTH, bug479 2012-04-05 21:46:55 -04:00
Wilson Snyder ab9a2b1728 Internal: Prevent possible buffer overrun 2012-04-05 21:46:03 -04:00
Wilson Snyder 6a38d3bcf3 Add SELRANGE as warning instead of error, bug477. 2012-04-04 21:55:20 -04:00
Wilson Snyder 76f3cbdf4c Merge branch 'master' of ssh://git-verilator-wsnyder/git/verilator 2012-04-02 22:05:40 -04:00
Wilson Snyder d45d58b6bf Fix real constant parameter functions, bug475. 2012-04-02 21:58:40 -04:00
Wilson Snyder f32a422330 Tests: New test 2012-04-02 19:38:42 -04:00
Wilson Snyder 74d4be28dd Commentary 2012-04-02 07:17:37 -04:00
Wilson Snyder b4a31bd292 Internals: Merge AstCCast minwidth set. No functional change intended 2012-04-01 21:17:58 -04:00
Wilson Snyder cc1adf9b38 Internals: merge V3Hashed cleanups. No functional change intended 2012-04-01 21:04:28 -04:00
Wilson Snyder 1601b3b6b0 Internals: Merge VFlagChildDtype calls. No functional change intended. 2012-03-31 11:22:19 -04:00
Wilson Snyder 61cbdd1a19 Internals: Merge VFlag rename. No functional change. 2012-03-31 11:10:34 -04:00
Wilson Snyder a3ee6131a3 Internals: Merge using dtypeSetLogicSized. No functional change intended 2012-03-31 10:53:53 -04:00
Wilson Snyder 6dfddaa453 Internals: Rename dtypeChg to dtypeSet. No functional change 2012-03-31 10:19:27 -04:00
Wilson Snyder de696b7092 Debug: Print dtype big endian correctly 2012-03-30 21:50:37 -04:00
Wilson Snyder 9165233657 Fix OpenSolaris compile error. 2012-03-30 07:26:00 -04:00
Wilson Snyder aa3a417e97 Tests: Add t_dpi_accessors 2012-03-27 20:06:59 -04:00
Wilson Snyder 996f48fcf0 Fix processing unused parametrized modules, bug470. 2012-03-24 15:54:06 -04:00
Wilson Snyder 81d83f629f Tests: default_nettype is ok 2012-03-24 15:15:32 -04:00
Wilson Snyder 5e3b0bf348 tests: Add unsupported as target type; additional tests 2012-03-24 11:10:17 -04:00
Wilson Snyder 4a31463299 Fix genvar and begin under generate, bug461. 2012-03-23 08:49:47 -04:00
Wilson Snyder 8a5471e175 Tests: skip test for bug462 2012-03-22 22:35:24 -04:00
Wilson Snyder 605fd9f8e1 Tests: Skip test for bug461 2012-03-22 22:15:35 -04:00
Wilson Snyder 2bda43875d Support += and -= in standard for loops, bug463. 2012-03-22 21:02:38 -04:00
Wilson Snyder 11edc9e7a7 Debug: Add --dump-treei option 2012-03-20 22:45:35 -04:00
Wilson Snyder 3b9b823511 tests: Fix missing manifest from earlier test commit 2012-03-20 22:45:00 -04:00
Wilson Snyder da0ecf59c6 Tests: Rename t_mem_packed_assign_bad since fails 2012-03-20 20:55:16 -04:00
Wilson Snyder e5b1fdf668 Tests: Added additional SystemVerilog tests.
Squashed commit of the following:

commit c1eeda7d472fc14a0ffd5c1712ae7f7c614073a1
Author: Iztok Jeras <[email protected]>
Date:   Tue Mar 20 16:39:44 2012 +0100

- fixed assignment operator in t_array_packed_write_read.v from = to <=
- added tests for enumerations (existing tests do not use methods like
next(), num(), ...)
- added t_sv_bus_mux_demux test, with packed arrays, structures and unions
2012-03-20 19:28:35 -04:00
Wilson Snyder 204fb82975 Add very experimental --xml option 2012-03-20 16:13:10 -04:00
Wilson Snyder 37839e2709 Cleanup trailing whitespace. No functional change 2012-03-20 16:01:53 -04:00
Wilson Snyder dbaedb5995 Internals: Add XML output internals, unused. No functional change. 2012-03-20 15:57:29 -04:00
Wilson Snyder 0a832e90bd Internals: Rename left/right to match IEEE. No functional change. 2012-03-19 21:32:05 -04:00
Wilson Snyder b4e908d04d Fix warning on gcc 4.6.1 2012-03-16 18:06:32 -04:00
Wilson Snyder 4619d29b78 Commentary; bug457 2012-03-15 18:44:08 -04:00
Wilson Snyder c63b697636 Fix signed array warning, bug456. 2012-03-12 20:29:00 -04:00
Wilson Snyder 06d29d6fda Commentary 2012-03-10 10:56:48 -05:00
Wilson Snyder c0f7bc4b5e Tests: Parameter bug case 2012-03-09 19:35:37 -05:00
Wilson Snyder 7139c9ae59 Fix and document --gdb option, bug454. 2012-03-09 18:37:38 -05:00
Wilson Snyder 0ae00fc921 Commentary; bug452. 2012-03-08 18:36:51 -05:00
Wilson Snyder fe456cb83d Devel version 2012-03-07 23:02:24 -05:00
Wilson Snyder a8432ed4a4 Version bump 2012-03-07 22:50:13 -05:00
Wilson Snyder 04f910b747 Fix V3Tristate t_tri_select crash 2012-03-07 22:42:47 -05:00
Wilson Snyder 1c3de70155 Internals: Debug merge. No functional change 2012-03-07 21:48:02 -05:00
Wilson Snyder b73642f8a8 Report ENDLABEL on mismatching end labels, bug450. 2012-03-07 20:14:18 -05:00
Wilson Snyder 479b497528 Tests: Add new tests from Iztok Jeras, bug446, bug450. 2012-03-07 20:00:09 -05:00
Wilson Snyder 31b55d3844 Tests: Fix running different simulators simultaneously 2012-03-06 20:58:23 -05:00
Wilson Snyder dbf4e08d09 Tests 2012-03-06 20:12:47 -05:00
Wilson Snyder 274359e6ee Tests: Bit extraction from non-logic types 2012-03-04 17:17:57 -05:00
Wilson Snyder 8687dcbce1 Internals: Add isRanged, more debug. No functional change. 2012-03-04 16:18:41 -05:00
Wilson Snyder 03dfbdb7b1 Fix inheriting signed type across untyped parameters. 2012-03-03 21:03:34 -05:00
Wilson Snyder 3c8519f245 Fix inheriting real type across untyped parameters. 2012-03-03 16:29:06 -05:00
Wilson Snyder 4d2cc3ebdd Tests: New param value test 2012-03-03 15:44:56 -05:00
Wilson Snyder 6e2758ae26 Internals: Minor refactorings from dtype branch. No functional change. 2012-03-03 12:10:29 -05:00
Wilson Snyder 4637e06ad2 Fix backward widths in function output warning 2012-03-03 12:09:01 -05:00
Wilson Snyder 764399256c Internals: Rename gdb dump utilities, add fileline dump 2012-03-03 11:29:09 -05:00
Wilson Snyder f4ca4edc64 Debug: Add default .gdbinit file 2012-03-02 20:59:47 -05:00
Wilson Snyder 872a1216a7 Internals: Fix enum widthTotalBytes. 2012-03-02 06:58:19 -05:00
Wilson Snyder 8c75674591 Internals: V3Dead: Avoid iterating over vars we can't remove. 2012-02-29 23:05:11 -05:00
Wilson Snyder e6244ca204 Internals: Move dimension accessors from AstVar to AstNodeDType. 2012-02-28 21:33:17 -05:00
Wilson Snyder f540362e36 Fix expansion of back-slashed escaped macros, bug441. 2012-02-25 21:31:36 -05:00
Wilson Snyder 2be6699a6a Internals: Make covergroup parsing closer to normal types 2012-02-23 22:09:51 -05:00
Wilson Snyder 09c10492ab Fix hang on recursive substitution `defines, bug443. 2012-02-23 21:54:37 -05:00
Wilson Snyder c8e4b1fc84 Fix functions inside generate for block. 2012-02-21 22:23:06 -05:00
Wilson Snyder 0de7cece5b Fix hang when functions inside begin block. 2012-02-21 21:25:11 -05:00
Wilson Snyder a3413a6749 Merge branch 'master' of ssh://git-verilator-wsnyder/git/verilator 2012-02-21 08:03:07 -05:00
Wilson Snyder b104ab9491 Internals: AstRefDType points to type _below_ AstTyperef. No functional change 2012-02-21 07:27:17 -05:00
Wilson Snyder 269c5dce60 Internals: Use dtypeChgLogicBool(). No functional change. 2012-02-20 20:51:24 -05:00
Wilson Snyder a39c81c63f Internals: Remove width() on AstCaseItem. No functional change. 2012-02-20 16:48:52 -05:00
Wilson Snyder d699247269 Internals: In AstBasicDType avoid use of Range for constants. No functional change. 2012-02-20 11:48:31 -05:00
Wilson Snyder 7caafb4014 Internals: Use dtype functions; changes to integer to match spec 2012-02-20 09:55:20 -05:00
Wilson Snyder f1546abf09 Fix error when using UDPs without --bbox-unsup 2012-02-20 09:02:59 -05:00
Wilson Snyder 3083562f6f tests: Avoid massive make parallelism. 2012-02-17 21:40:52 -05:00
Wilson Snyder da2ee70462 Makefile: Print build done in right parallel spot 2012-02-16 20:39:13 -05:00
Wilson Snyder 7e9dda3c5e Fix false command not found warning in Makefiles. 2012-02-16 07:17:08 -05:00
Wilson Snyder 0b96f88875 Fix bisonpre documentation 2012-02-12 20:53:43 -05:00
Wilson Snyder f13ffe2098 Internals: Merge from VHDL branch. Minor stuff, no functional change. 2012-02-11 20:40:58 -05:00
Wilson Snyder bca5d26583 Backout ca927fe5; snps isn't supported in DC. 2012-02-10 22:36:19 -05:00
Wilson Snyder 660bc757f1 Tests: Remove debug 2012-02-04 20:00:36 -05:00
Wilson Snyder ca927fe587 Support snps directives 2012-02-02 10:26:45 -05:00
Wilson Snyder 9df8966f4a Support arrayed SystemC I/O pins. 2012-02-01 20:20:43 -05:00
Wilson Snyder 3429f41489 Typo 2012-01-29 18:26:39 -05:00
Wilson Snyder 0c7c4924ee Fix core dump with over 100 deep UNOPTFLAT, bug432. 2012-01-26 20:20:23 -05:00
Wilson Snyder 8f40d6617e For generated variables, opt towards 2-state so zero init 2012-01-26 08:29:55 -05:00
Wilson Snyder af9e85bda1 Fix memory delayed assignments from multiple clock domains. 2012-01-26 08:10:50 -05:00
Wilson Snyder 717f45d117 Devel version 2012-01-25 19:23:58 -05:00
Wilson Snyder 35c53865fb Check c style array 2012-01-25 19:23:41 -05:00
347 changed files with 10374 additions and 1336 deletions
+2 -1
View File
@@ -9,6 +9,7 @@
.*.swp
*.tmp
*.tex
*.pdf
/Makefile
README
autom4te.cache
@@ -16,8 +17,8 @@ config.cache
config.status
configure
dddrun*
doxygen-doc
gdbrun*
internals.txt
verilator.pdf
verilator.txt
verilator_bin*
+48 -2
View File
@@ -4,6 +4,52 @@ The contributors that suggested a given feature are shown in []. [by ...]
indicates the contributor was also the author of the fix; Thanks!
* Verilator 3.833 2012/04/15
*** Support += and -= in standard for loops, bug463. [Alex Solomatnikov]
*** Fix processing unused parametrized modules, bug469, bug470. [Alex Solomatnikov]
**** Add SELRANGE as warning instead of error, bug477. [Alex Solomatnikov]
**** Add readme.pdf and internal.pdf and doxygen, bug483. [by Jeremy Bennett]
**** Fix change detections on arrays, bug364. [John Stevenson, Alex Solomatnikov]
**** Fix signed array warning, bug456. [Alex Solomatnikov]
**** Fix genvar and begin under generate, bug461. [Alex Solomatnikov]
**** Fix real constant parameter functions, bug475. [Alex Solomatnikov]
**** Fix and document --gdb option, bug454. [Jeremy Bennett]
**** Fix OpenSolaris compile error. [Sanjay Singh]
* Verilator 3.832 2012/03/07
*** Fix memory delayed assignments from multiple clock domains. [Andrew Ling]
*** Support arrayed SystemC I/O pins. [Christophe Joly]
*** Report MULTIDRIVEN on memories set in multiple clock domains.
*** Report ENDLABEL on mismatching end labels, bug450. [Iztok Jeras]
**** Fix expansion of back-slashed escaped macros, bug441. [Alberto Del Rio]
**** Fix inheriting real and signed type across untyped parameters.
**** Fix core dump with over 100 deep UNOPTFLAT, bug432. [Joe Eiler]
**** Fix false command not found warning in makefiles. [Ruben Diez]
**** Fix hang when functions inside begin block. [David Welch]
**** Fix hang on recursive substitution `defines, bug443. [Alex Solomatnikov]
* Verilator 3.831 2012/01/20
** Support SystemC 2.3.0 prerelease. This requires setting the new
@@ -33,7 +79,7 @@ indicates the contributor was also the author of the fix; Thanks!
**** Support $system. [Ruben Diez]
**** Support $sscanf with %g. [Holger Wächtler]
**** Support $sscanf with %g. [Holger Waechtler]
**** Indicate 'exiting due to errors' if errors, not warnings. [Ruben Diez]
@@ -41,7 +87,7 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix reporting not found modules if generate-off, bug403. [Jeremy Bennett]
**** Fix $display with %d following %g. [Holger Wächtler]
**** Fix $display with %d following %g. [Holger Waechtler]
* Verilator 3.824 2011/10/25
+2
View File
@@ -1,5 +1,6 @@
^CVS/
/CVS/
\.gdbinit$
\.git/
\.svn/
\.(bak|old)/
@@ -34,3 +35,4 @@ nodist/
/simv.daidir/
/vc_hdrs.h$
/csrc/
doxygen-doc/.*
+38 -12
View File
@@ -54,11 +54,13 @@ srcdir = @srcdir@
VPATH = @srcdir@
HOST = @HOST@
DOXYGEN = doxygen
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
MAKEINFO = makeinfo
POD2TEXT = pod2text
POD2LATEXFIX = $(srcdir)/src/pod2latexfix
PERL = @PERL@
# Destination prefix for RPMs
@@ -100,7 +102,8 @@ SHELL = /bin/sh
SUBDIRS = src test_verilated test_c test_sc test_sp test_regress test_vcs
INFOS = README internals.txt verilator.txt verilator.html verilator.1 verilator.pdf
INFOS = README README.html README.pdf internals.txt internals.html \
internals.pdf verilator.txt verilator.html verilator.1 verilator.pdf
# Files that can be generated, but should be up to date for a distribution.
DISTDEP = info Makefile
@@ -110,6 +113,7 @@ DISTFILES_INC = $(INFOS) .gitignore Artistic COPYING COPYING.LESSER \
Changes TODO \
MANIFEST.SKIP \
bin/* \
doxygen-mainpage doxygen.config veripool-logo.png \
install-sh configure mkinstalldirs *.pod \
include/*.[chv]* \
include/*.in \
@@ -121,7 +125,8 @@ DISTFILES_INC = $(INFOS) .gitignore Artistic COPYING COPYING.LESSER \
test_*/.*ignore test_*/Makefile* test_*/*.cpp \
test_*/*.pl test_*/*.v test_*/*.vc test_*/*.vh \
test_verilated/vgen*.pl \
test_regress/t/tsub/*.v* \
test_regress/t/t*/*.sv* \
test_regress/t/t*/*.v* \
test_regress/t/*.cpp \
test_regress/t/*.h \
test_regress/t/*.dat \
@@ -164,7 +169,7 @@ verilator_exe verilator_bin verilator_bin_dbg:
(cd src && $(MAKE) $(OBJCACHE_JOBS) )
.PHONY:msg_test
msg_test:
msg_test: all_nomsg
@echo "Build complete!"
@echo
@echo "Type 'make test' to test."
@@ -215,15 +220,7 @@ verilator.html: ${srcdir}/bin/verilator
# PDF needs DIST variables; but having configure.ac as dependency isn't detected
verilator.pdf: ${srcdir}/bin/verilator Makefile
pod2latex --full --out verilator.tex ${srcdir}/bin/verilator
cat < verilator.tex \
| sed 's/\\begin{document}/\\usepackage[left=1.7in,right=1.7in,top=1.3in,bottom=1.3in]{geometry}\n\\begin{document}/' \
| sed 's/\\begin{document}/\\usepackage[pdftex,bookmarks=true,bookmarksnumbered=true,hypertexnames=false,breaklinks=true,linkbordercolor={0 0 1}]{hyperref}\n\\begin{document}/' \
| sed 's/\\begin{document}/\\usepackage{fancyhdr} \\pagestyle{fancy}\n\\begin{document}/' \
| sed 's/\\begin{document}/\\setlength{\\parindent}{0pt} \\setlength{\\parskip}{\\baselineskip}\n\\begin{document}/' \
| sed 's/\\begin{document}/\\title{$(DISTTITLE)} \\date{${DISTDATE}} \\author{Wilson Snyder\\\\ http:\/\/www.veripool.org}\n\\begin{document}/' \
| sed 's/\\begin{document}/\\lhead[$(DISTTITLE)]{$(DISTTITLE)}\n\\begin{document}/' \
| sed 's/\\tableofcontents/\\begin{titlepage} \\maketitle \\end{titlepage}\n\\tableofcontents/' \
> verilator2.tex
$(PERL) $(POD2LATEXFIX) "$(DISTTITLE)" "${DISTDATE}" < verilator.tex > verilator2.tex
mv verilator2.tex verilator.tex
pdflatex verilator.tex
pdflatex verilator.tex
@@ -233,10 +230,34 @@ README: readme.pod
-rm -f $@
$(POD2TEXT) --loose $< > $@
README.html: readme.pod
pod2html $< >$@
# PDF needs DIST variables; but having configure.ac as dependency isn't detected
README.pdf: readme.pod Makefile
pod2latex --full --out README.tex readme.pod
$(PERL) $(POD2LATEXFIX) "$(DISTTITLE) README File" "${DISTDATE}" < README.tex > README2.tex
mv README2.tex README.tex
pdflatex README.tex
pdflatex README.tex
-rm -f README.toc README.aux README.idx README.out
internals.txt: internals.pod
-rm -f $@
$(POD2TEXT) --loose $< > $@
internals.html: internals.pod
pod2html $< >$@
# PDF needs DIST variables; but having configure.ac as dependency isn't detected
internals.pdf: internals.pod Makefile
pod2latex --full --out internals.tex internals.pod
$(PERL) $(POD2LATEXFIX) "$(DISTTITLE) Internals Manual" "${DISTDATE}" < internals.tex > internals2.tex
mv internals2.tex internals.tex
pdflatex internals.tex
pdflatex internals.tex
-rm -f internals.toc internals.aux internals.idx internals.out
# See uninstall also - don't put wildcards in this variable, it might uninstall other stuff
VL_INST_BIN_FILES = verilator verilator_bin verilator_bin_dbg \
verilator_includer verilator_profcfunc
@@ -442,6 +463,11 @@ TAGFILES=${srcdir}/*/*.cpp ${srcdir}/*/*.h ${srcdir}/*/[a-z]*.in \
TAGS: $(TAGFILES)
etags $(TAGFILES)
.PHONY: doxygen
doxygen:
$(DOXYGEN) doxygen.config
######################################################################
# Test targets
+141 -58
View File
@@ -69,7 +69,7 @@ if (! GetOptions (
"debug:s" => \&debug,
# "version!" => \&version, # Also passthru'ed
# Switches
"gdb=s" => \$opt_gdb, # Undocumented debugging
"gdb!" => \$opt_gdb,
"gdbbt!" => \$opt_gdbbt,
# Additional parameters
"<>" => sub {}, # Ignored
@@ -82,17 +82,24 @@ if ($opt_gdbbt && !gdb_works()) {
warn "-Info: --gdbbt ignored: gdb doesn't seem to be working\n" if $Debug;
$opt_gdbbt = 0;
}
if ($opt_gdbbt && !$opt_gdb && $Debug) {
if ($opt_gdb) {
# Generic GDB interactive
run (("gdb"||$ENV{VERILATOR_GDB})
." ".verilator_bin()
." -ex 'run ".join(' ',@Opt_Verilator_Sw)."'"
." -ex 'set width 0'"
." -ex 'bt'");
} elsif ($opt_gdbbt && $Debug) {
# Run under GDB to get gdbbt
run ("gdb ".verilator_bin()
run ("gdb"
." ".verilator_bin()
." --batch --quiet --return-child-result"
." -ex 'run ".join(' ',@Opt_Verilator_Sw)."'"
." -ex 'set width 0'"
." -ex 'bt'");
} else {
# Normal, non gdb
run (($opt_gdb?"$opt_gdb ":"")
.verilator_bin()
run (verilator_bin()
." ".join(' ',@Opt_Verilator_Sw));
}
@@ -247,7 +254,7 @@ descriptions in the next sections for more information.
--coverage-line Enable line coverage
--coverage-toggle Enable toggle coverage
--coverage-user Enable PSL/SVL user coverage
--coverage-underscore Enable covarge of _signals
--coverage-underscore Enable coverage of _signals
-D<var>[=<value>] Set preprocessor define
--debug Enable debugging
--debug-check Enable debugging assertions
@@ -255,11 +262,13 @@ descriptions in the next sections for more information.
--debugi-<srcfile> <level> Enable debugging a source file at a level
+define+<var>+<value> Set preprocessor define
--dump-tree Enable dumping .tree files
--dump-treei <level> Enable dumping .tree files at a level
-E Preprocess, but do not compile
--error-limit <value> Abort after this number of errors
--exe Link to create executable
-F <file> Parse options from a file, relatively
-f <file> Parse options from a file
--gdb Run Verilator under GDB interactively
--gdbbt Run Verilator under GDB for backtrace
--help Display this help
-I<dir> Directory to search for includes
@@ -521,9 +530,16 @@ standard across Verilog tools while -D is an alias for GCC compatibility.
=item --dump-tree
Rarely needed. Enable writing .tree debug files. This is enabled with
--debug, so "--debug --no-dump-tree" may be useful if the dump files are
large and not desired.
Rarely needed. Enable writing .tree debug files with dumping level 3,
which dumps the standard critical stages. --dump-tree is enabled
automatically with --debug, so "--debug --no-dump-tree" may be useful if
the dump files are large and not desired.
=item --dump-treei
Rarely needed. Enable writing .tree debug files with a specific dumping
level, 0 disbles dumps and is equivelent to "--no-dump-tree". Level 9
enables dumping of every stage.
=item -E
@@ -558,11 +574,17 @@ The file may contain // comments which are ignored to the end of the line.
Any $VAR, $(VAR), or ${VAR} will be replaced with the specified environment
variable.
=item --gdb
Run Verilator underneath an interactive GDB (or VERILATOR_GDB environment
variable value) session. See also --gdbbt.
=item --gdbbt
If --debug is specified, run Verilator underneath a GDB process and print
a backtrace on exit. Without --debug or if GDB doesn't seem to work, this
flag is ignored.
If --debug is specified, run Verilator underneath a GDB process and print a
backtrace on exit, then exit GDB immediately. Without --debug or if GDB
doesn't seem to work, this flag is ignored. Intended for easy creation of
backtraces by users; otherwise see the --gdb flag.
=item --help
@@ -905,9 +927,9 @@ Disable the specified warning message.
Disable all lint related warning messages, and all style warnings. This is
equivalent to "-Wno-CASEINCOMPLETE -Wno-CASEOVERLAP -Wno-CASEX
-Wno-CASEWITHX -Wno-CMPCONST -Wno-IMPLICIT -Wno-LITENDIAN -Wno-SYNCASYNCNET
-Wno-UNDRIVEN -Wno-UNSIGNED -Wno-UNUSED -Wno-WIDTH" plus the list shown for
Wno-style.
-Wno-CASEWITHX -Wno-CMPCONST -Wno-ENDLABEL -Wno-IMPLICIT -Wno-LITENDIAN
-Wno-SYNCASYNCNET -Wno-UNDRIVEN -Wno-UNSIGNED -Wno-UNUSED -Wno-WIDTH" plus
the list shown for Wno-style.
It is strongly recommended you cleanup your code rather than using this
option, it is only intended to be use when running test-cases of code
@@ -937,8 +959,8 @@ Enables the specified warning message.
Enable all lint related warning messages (note by default they are already
enabled), but do not affect style messages. This is equivalent to
"-Wwarn-CASEINCOMPLETE -Wwarn-CASEOVERLAP -Wwarn-CASEX -Wwarn-CASEWITHX
-Wwarn-CMPCONST -Wwarn-IMPLICIT -Wwarn-LITENDIAN -Wwarn-REALCVT
-Wwarn-UNSIGNED -Wwarn-WIDTH".
-Wwarn-CMPCONST -Wwarn-ENDLABEL -Wwarn-IMPLICIT -Wwarn-LITENDIAN
-Wwarn-REALCVT -Wwarn-UNSIGNED -Wwarn-WIDTH".
=item -Wwarn-style
@@ -1270,7 +1292,7 @@ SYSTEMC/include.
If set, specifies the directory containing the libsystemc.a library. If not
specified, it will come from a default optionally specified at configure
time (before Verilator was compiled), or compted from
time (before Verilator was compiled), or computed from
SYSTEMC/lib-SYSTEMC_ARCH.
=item SYSTEMPERL
@@ -1299,6 +1321,11 @@ baseline regression tests.
If set, specifies an alternative name of the Verilator binary. May be used
for debugging and selecting between multiple operating system builds.
=item VERILATOR_GDB
If set, the command to run when using the --gdb option, such as "ddd". If
not specified, it will use "gdb".
=item VERILATOR_ROOT
Specifies the directory containing the distribution kit. This is used to
@@ -1451,6 +1478,26 @@ DPI compatible but is easier to read and better supports multiple designs.
Vour::publicSetBool(value);
// or top->publicSetBool(value);
Note that if the DPI task or function accesses any register or net within the
RTL, it will require a scope to be set. This can be done using the standard
functions within svdpi.h, after the module is instantiated, but before the
task(s) and/or function(s) are called.
For example, if the top level module is instantiated with the name "dut" and
the name references within tasks are all hierarchical (dotted) names with
respect to that top level module, then the scope could be set with
#include "svdpi.h"
...
svSetScope (svGetScopeFromName ("dut"));
(Remember that Verilator adds a "V" to the top of the module hierarchy.)
Scope can also be set from within a DPI imported C function that has been
called from Verilog by querying the scope of that function. See the
sections on DPI Context Functions and DPI Header Isolation below and the
comments within the svdpi.h header for more information.
=head2 DPI Display Functions
Verilator allows writing $display like functions using this syntax:
@@ -1747,9 +1794,9 @@ assertion clocks.
=head2 Synthesis Directive Assertion Support
With the --assert switch, Verilator reads any "//synopsys full_case" or "//
synopsys parallel_case" directives. The same applies to any "// ambit
synthesis", "//cadence" or "//pragma" directives of the same form.
With the --assert switch, Verilator reads any "//synopsys full_case" or
"//synopsys parallel_case" directives. The same applies to any
"//ambit synthesis", "//cadence" or "//pragma" directives of the same form.
When these synthesis directives are discovered, Verilator will either
formally prove the directive to be true, or failing that, will insert the
@@ -1895,9 +1942,17 @@ The Verilog code returns to the last language mode specified with
Used after a signal declaration to indicate the signal is used to gate a
clock, and the user takes responsibility for insuring there are no races
related to it. (Typically by adding a latch, and running static timing
analysis.) This will cause the clock gate to be ignored in the scheduling
algorithm, improving performance. It's also a good idea to enable the
related to it. (Typically by adding a latch, and running static timing
analysis.) For example:
reg enable_r /*verilator clock_enable*/;
wire gated_clk = clk & enable_r;
always_ff @ (posedge clk)
enable_r <= enable_early;
The clock_enable attribute will cause the clock gate to be ignored in the
scheduling algorithm, sometimes required for correct clock behavior, and
always improving performance. It's also a good idea to enable the
IMPERFECTSCH warning, to insure all clock enables are properly recognized.
=item /*verilator coverage_block_off*/
@@ -2214,10 +2269,12 @@ different.)
=head2 Generated Clocks
Verilator attempts to deal with generated clocks correctly, however new
cases may turn up bugs in the scheduling algorithm. The safest option is
to have all clocks as primary inputs to the model, or wires directly
attached to primary inputs.
Verilator attempts to deal with generated and enabled clocks correctly,
however some cases cause problems in the scheduling algorithm which is
optimized for performance. The safest option is to have all clocks as
primary inputs to the model, or wires directly attached to primary inputs.
For proper behavior clock enables may also need the /*verilator
clock_enable*/ attribute.
=head2 Ranges must be big-bit-endian
@@ -2585,6 +2642,14 @@ designs should now be using the #(...) format to specify parameters.
Disabled by default as this is a code style warning; it will simulate
correctly.
=item ENDLABEL
Warns that a label attached to a "end"-something statement does not match
the label attached to the block start.
Ignoring this warning will only suppress the lint check, it will simulate
correctly.
=item GENCLK
Warns that the specified signal is generated, but is also being used as a
@@ -2706,6 +2771,23 @@ is not possible, add a undef to indicate the code is overriding the value:
`undef MACRO
`define MACRO otherdef
=item SELRANGE
Warns that a selection index will go out of bounds:
wire vec[6:0];
initial out = vec[7]; // There is no 7
Verilator will assume zero for this value, instead of X. Note that in some
cases this warning may be false, when a condition upstream or downstream of
the access means the access out of bounds will never execute or be used.
wire vec[6:0];
initial begin
seven = 7;
...
if (seven != 7) out = vec[seven]; // Never will use vec[7]
=item STMTDLY
Warns that you have a statement with a delayed time in front of it, for
@@ -3362,43 +3444,44 @@ faster than many popular commercial simulators.
Many people have provided ideas and other assistance with Verilator.
The major corporate sponsors of Verilator, by providing significant
contributions of time or funds include include Compaq Corporation, Digital
Equipment Corporation, Intel Corporation, Mindspeed Technologies Inc.,
MicroTune Inc., picoChip Designs Ltd., Sun Microsystems, Nauticus Networks,
and SiCortex Inc.
contributions of time or funds include include Cavium Networks, Compaq
Corporation, Digital Equipment Corporation, Embecosm Ltd., Intel
Corporation, Mindspeed Technologies Inc., MicroTune Inc., picoChip Designs
Ltd., Sun Microsystems, Nauticus Networks, and SiCortex Inc.
The people who have contributed major functionality are Byron Bradley, Lane
Brooks, Duane Galbi, Paul Wasson, and Wilson Snyder. Major testers include
Jeff Dutton, Ralf Karge, David Hewson, Wim Michiels, and Gene Weber.
The people who have contributed major functionality are Byron Bradley,
Jeremy Bennett, Lane Brooks, Duane Galbi, Paul Wasson, and Wilson Snyder.
Major testers include Jeff Dutton, Ralf Karge, David Hewson, Wim Michiels,
Alex Solomatnikov, Sebastien Van Cauwenberghe and Gene Weber.
Some of the people who have provided ideas and feedback for Verilator
include: David Addison, Hans Van Antwerpen, Vasu Arasanipalai, Jens Arm, J
Baxter, Jeremy Bennett, David Black, Gregg Bouchard, Christopher Boumenot,
Nick Bowler, Byron Bradley, Bryan Brady, Lane Brooks, John Brownlee,
Lawrence Butcher, Chris Candler, Lauren Carlson, Donal Casey, Terry Chen,
Robert A. Clark, Allan Cochrane, Gunter Dannoritzer, Ashutosh Das, Bernard
Deadman, John Deroo, John Dickol, Danny Ding, Ivan Djordjevic, Alex Duller,
Jeff Dutton, Chandan Egbert, Joe Eiler, Ahmed El-Mahmoudy, Robert Farrell,
Eugen Fekete, Andrea Foletto, Bob Fredieu, Shankar Giri, Sam Gladstone,
Amir Gonnen, Chitlesh Goorah, Neil Hamilton, Thomas Hawkins, David Hewson,
Jae Hossell, Ben Jackson, Iztok Jeras, Mike Kagen, Guy-Armand Kamendje,
Vasu Kandadi, Patricio Kaplan, Ralf Karge, Dan Katz, Sol Katzman, Jonathan
Kimmitt, Gernot Koch, Soon Koh, Steve Kolecki, Steve Lang, Stephane
Laurent, Christian Leber, Charlie Lind, Paul Liu, Dan Lussier, Fred Ma,
include: David Addison, Vasu Arasanipalai, Jens Arm, J Baxter, Jeremy
Bennett, David Black, Gregg Bouchard, Christopher Boumenot, Nick Bowler,
Byron Bradley, Bryan Brady, Lane Brooks, John Brownlee, Lawrence Butcher,
Chris Candler, Lauren Carlson, Donal Casey, Terry Chen, Robert A. Clark,
Allan Cochrane, Gunter Dannoritzer, Ashutosh Das, Bernard Deadman, Mike
Denio, John Deroo, John Dickol, Ruben Diez, Danny Ding, Ivan Djordjevic,
Alex Duller, Jeff Dutton, Chandan Egbert, Joe Eiler, Ahmed El-Mahmoudy,
Robert Farrell, Eugen Fekete, Andrea Foletto, Bob Fredieu, Shankar Giri,
Sam Gladstone, Amir Gonnen, Chitlesh Goorah, Neil Hamilton, Thomas Hawkins,
David Hewson, Jae Hossell, Ben Jackson, Iztok Jeras, Christophe Joly, Mike
Kagen, Guy-Armand Kamendje, Vasu Kandadi, Patricio Kaplan, Ralf Karge, Dan
Katz, Sol Katzman, Jonathan Kimmitt, Gernot Koch, Soon Koh, Steve Kolecki,
David Kravitz, Steve Lang, Stephane Laurent, Walter Lavino, Christian
Leber, John Li, Charlie Lind, Andrew Ling, Paul Liu, Dan Lussier, Fred Ma,
Duraid Madina, Mark Marshall, Jason McMullan, Wim Michiels, Dennis
Muhlestein, John Murphy, Richard Myers, Dimitris Nalbantis, Paul Nitza,
Pete Nixon, Lisa Noack, Mark Nodine, Andreas Olofsson, Brad Parker, Dominic
Plunkett, Niranjan Prabhu, Usha Priyadharshini, Oleg Rodionov, John
Sanguinetti, Salman Sheikh, Mike Shinkarovsky, Rafael Shirakawa, Jeffrey
Short, Rodney Sinclair, Brian Small, Alex Solomatnikov, Art Stamness, John
Stroebel, Emerson Suguimoto, Gene Sullivan, Renga Sundararajan, Stefan
Thiede, Gary Thomas, Steve Tong, Holger Waechtler, Stefan Wallentowitz,
Shawn Wang, Greg Waters, Eugene Weber, David Welch, Leon Wildman, Gerald
Williams, Trevor Williams, Jeff Winston, Joshua Wise, Johan Wouters, and
Ding Xiaoliang.
Thanks all.
Plunkett, Niranjan Prabhu, Usha Priyadharshini, Alberto Del Rio, Oleg
Rodionov, John Sanguinetti, Salman Sheikh, Mike Shinkarovsky, Rafael
Shirakawa, Jeffrey Short, Rodney Sinclair, Brian Small, Alex Solomatnikov,
Art Stamness, John Stroebel, Emerson Suguimoto, Gene Sullivan, Renga
Sundararajan, Stefan Thiede, Gary Thomas, Steve Tong, Hans Van Antwerpen,
Holger Waechtler, Stefan Wallentowitz, Shawn Wang, Greg Waters, Thomas
Watts, Eugene Weber, David Welch, Leon Wildman, Gerald Williams, Trevor
Williams, Jeff Winston, Joshua Wise, Johan Wouters, and Ding Xiaoliang.
Thanks to them, and all those we've missed including above.
=head1 DISTRIBUTION
+1 -1
View File
@@ -193,5 +193,5 @@ C<verilator>
######################################################################
### Local Variables:
### compile-command: "$V4/bin/verilator_difftree $V4/test_c/obj_dir/V*_03_*.tree $V4N/test_c/obj_dir/V*_03_*.tree"
### compile-command: "$V4/bin/verilator_difftree {$V4D,$V4}/test_regress/obj_dir/t_EXAMPLE/V*_03_*.tree"
### End:
+1 -1
View File
@@ -4,7 +4,7 @@
# redistribute it and/or modify it under the terms of either the GNU Lesser
# General Public License Version 3 or the Perl Artistic License Version 2.0.
AC_INIT([Verilator],[3.831 2012-01-20])
AC_INIT([Verilator],[3.833 2012-04-15])
AC_CONFIG_HEADER(src/config_build.h)
AC_CONFIG_FILES(Makefile src/Makefile src/Makefile_obj include/verilated.mk)
+6
View File
@@ -0,0 +1,6 @@
/*! \mainpage Verilator Doxygen Documentation
*
* \section intro_sec Introduction
*
* This is a full doxygen analysis of the Verilator source tree.
*/
+1772
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
@@ -27,7 +27,7 @@
#include "verilated_imp.h"
#include <cctype>
#define VL_VALUE_STRING_MAX_WIDTH 1024 ///< Max static char array for VL_VALUE_STRING
#define VL_VALUE_STRING_MAX_WIDTH 8192 ///< Max static char array for VL_VALUE_STRING
//===========================================================================
// Global variables
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
-1
View File
@@ -1,4 +1,3 @@
// -*- C++ -*-
//*************************************************************************
//
// Code available from: http://www.veripool.org/verilator
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2010-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- SystemC -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- SystemC -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- SystemC -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- SystemC -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//=============================================================================
//
// THIS MODULE IS PUBLICLY LICENSED
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2009-2012 by Wilson Snyder. This program is free software; you can
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
+242 -35
View File
@@ -52,7 +52,11 @@ preprocessing, then lexical analysis with Flex and parsing with Bison.
This produces an abstract syntax tree (AST) representation of the design,
which is what is visible in the .tree files described below.
Cells are then linked, which will read and parse additional files as above.
Verilator then makes a series of passes over the AST, progressively refining
and optimizing it.
Cells in the AST first linked, which will read and parse additional files as
above.
Functions, variable and other references are linked to their definitions.
@@ -87,6 +91,39 @@ hints, and performs additional constant propagation.
Verilator finally writes the C++ modules.
=head2 Key Classes Used in the Verilator Flow
The AST is represented at the top level by the class C<AstNode>. This abstract
class has derived classes for the individual components (e.g. C<AstGenerate>
for a generate block) or groups of components (e.g. C<AstNodeFTask> for
functions and tasks, which in turn has C<AstFunc> and C<AstTask> as derived
classes).
Each C<AstNode> has pointers to up to four children, accessed by the
C<op1p> through C<op4p> methods. These methods are then abstracted in a
specific Ast* node class to a more specific name. For example with the
C<AstIf> node (for C<if> statements), C<ifsp> calls C<op1p> to give the
pointer to the AST for the "then" block, while C<elsesp> calls C<op2p> to
give the pointer to the AST for the "else" block, or NULL if there is not
one.
C<AstNode> has the concept of a next and previous AST - for example the
next and previous statements in a block. Pointers to the AST for these
statements (if they exist) can be obtained using the C<back> and C<next>
methods.
It is useful to remember that the derived class C<AstNetlist> is at the top
of the tree, so checking for this class is the standard way to see if you
are at the top of the tree.
By convention, each function/method uses the variable C<nodep> as a pointer
to the C<AstNode> currently being processed.
The passes are implemented by AST visitor classes (see L</Visitor
Functions>). These are implemented by subclasses of the abstract class,
C<AstNVisitor>. Each pass creates an instance of the visitor class, which
in turn implements a method to perform the pass.
=head2 Verilated Flow
The evaluation loop outputted by Verilator is designed to allow a single
@@ -120,57 +157,182 @@ changed; if clear, checking those signals for changes may be skipped.
To match the indentation of Verilator C++ sources, use 4 spaces per level,
and leave tabs at 8 columns, so every other indent level is a tab stop.
In Emacs, use in your ~/.emacs
All files should contain the magic header to insure standard indentation:
(add-hook 'c-mode-common-hook '(lambda ()
(c-set-style "cc-mode"))))
// -*- mode: C++; c-file-style: "cc-mode" -*-
This sets indentation to the cc-mode defaults. (Verilator predates a
CC-mode change of several years ago which overrides the defaults with GNU
style indentation; the c-set-style undoes that.)
=head2 The C<astgen> script
Some of the code implementing passes is extremely repetitive, and must be
implemented for each sub-class of C<AstNode>. However, while repetitive,
there is more variability than can be handled in C++ macros.
In Verilator this is implemented by using a Perl script, C<astgen> to
pre-process the C++ code. For example in C<V3Const.cpp> this is used to
implement the C<visit()> functions for each binary operation using the
TREEOP macro.
The original C++ source code is transformed into C++ code in the C<obj_opt>
and C<obj_dbg> sub-directories (the former for the optimized version of
verilator, the latter for the debug version). So for example C<V3Const.cpp>
into C<V3Const__gen.cpp>.
=head2 Visitor Functions
There's three ways data is passed between visitor functions.
The verilator uses the I<Visitor> design pattern to implement its
refinement and optimization passes. This allows separation of the pass
algorithm from the AST on which it operates. Wikipedia provides an
introduction to the concept at
L<http://en.wikipedia.org/wiki/Visitor_pattern>.
1. A visitor-class member variable. This is generally for passing "parent"
information down to children. m_modp is a common example. It's set to
NULL in the constructor, where that node (AstModule visitor) sets it, then
the children are iterated, then it's cleared. Children under an AstModule
will see it set, while nodes elsewhere will see it clear. If there can be
nested items (for example an AstFor under an AstFor) the variable needs to
be save-set-restored in the AstFor visitor, otherwise exiting the lower for
will loose the upper for's setting.
As noted above, all visitors are derived classes of C<AstNvisitor>. All
derived classes of C<AstNode> implement the C<accept> method, which takes
as argument a reference to an instance or a C<AstNVisitor> derived class
and applies the visit method of the C<AstNVisitor> to the invoking AstNode
instance (i.e. C<this>).
One possible difficulty is that a call to C<accept> may perform an edit
which destroys the node it receives as argument. The
C<acceptSubtreeReturnEdits> method of C<AstNode> is provided to apply
C<accept> and return the resulting node, even if the original node is
destroyed (if it is not destroyed it will just return the original node).
The behavior of the visitor classes is achieved by overloading the C<visit>
function for the different C<AstNode> derived classes. If a specific
implementation is not found, the system will look in turn for overloaded
implementations up the inheritance hierarchy. For example calling C<accept>
on C<AstIf> will look in turn for:
void visit (AstIf* nodep, AstNUser* vup)
void visit (AstNodeIf* nodep, AstNUser* vup)
void visit (AstNodeStmt* nodep, AstNUser* vup)
void visit (AstNode* nodep, AstNUser* vup)
There are three ways data is passed between visitor functions.
=over 4
=item 1.
A visitor-class member variable. This is generally for passing "parent"
information down to children. C<m_modp> is a common example. It's set to
NULL in the constructor, where that node (C<AstModule> visitor) sets it,
then the children are iterated, then it's cleared. Children under an
C<AstModule> will see it set, while nodes elsewhere will see it clear. If
there can be nested items (for example an C<AstFor> under an C<AstFor>) the
variable needs to be save-set-restored in the C<AstFor> visitor, otherwise
exiting the lower for will lose the upper for's setting.
=item 2.
User attributes. Each C<AstNode> (B<Note.> The AST node, not the visitor)
has five user attributes, which may be accessed as an integer using the
C<user1()> through C<user5()> methods, or as a pointer (of type
C<AstNuser>) using the C<user1p()> through C<user5p()> methods (a common
technique lifted from graph traversal packages).
2. User() attributes. Each node has 5 ->user() number or ->userp() pointer
utility values (a common technique lifted from graph traversal packages).
A visitor first clears the one it wants to use by calling
AstNode::user#ClearTree(), then it can mark any node's user() with whatever
data it wants. Readers just call nodep->user(), but may need to cast
appropriately, so you'll often see nodep->userp()->castSOMETYPE(). At the
top of each visitor are comments describing how the user() stuff applies to
that visitor class. For example:
C<AstNode::user#ClearTree()>, then it can mark any node's user() with whatever
data it wants. Readers just call C<< nodep->user() >>, but may need to cast
appropriately, so you'll often see C<< nodep->userp()->castSOMETYPE() >>. At
the top of each visitor are comments describing how the C<user()> stuff
applies to that visitor class. For example:
// NODE STATE
// Cleared entire netlist
// AstModule::user1p() // bool. True to inline this module
This says that at the AstNetlist user1ClearTree() is called. Each
AstModule's is user1() is used to indicate if we're going to inline it.
This says that at the C<AstNetlist> C<user1ClearTree()> is called. Each
C<AstModule>'s C<user1()> is used to indicate if we're going to inline it.
These comments are important to make sure a user#() on a given AstNode type
is never being used for two different purposes.
These comments are important to make sure a C<user#()> on a given C<AstNode>
type is never being used for two different purposes.
Note that calling user#ClearTree is fast, it doesn't walk the tree, so it's
ok to call fairly often. For example, it's commonly called on every
Note that calling C<user#ClearTree> is fast, it doesn't walk the tree, so
it's ok to call fairly often. For example, it's commonly called on every
module.
3. Parameters can be passed between the visitors in close to the "normal"
function caller to callee way. This is the second "vup" parameter that is
ignored on most of the visitor functions. V3Width does this, but it proved
more messy than the above and is deprecated. (V3Width was nearly the first
module written. Someday this scheme may be removed, as it slows the
program down to have to pass vup everywhere.)
=item 3.
Parameters can be passed between the visitors in close to the "normal"
function caller to callee way. This is the second C<vup> parameter of type
C<AstNuser> that is ignored on most of the visitor functions. V3Width does
this, but it proved more messy than the above and is deprecated. (V3Width
was nearly the first module written. Someday this scheme may be removed,
as it slows the program down to have to pass vup everywhere.)
=back
=head2 Iterators
C<AstNode> provides a set of iterators to facilitate walking over the
tree. Each takes two arguments, a visitor, C<v>, of type C<AstNVisitor> and
an optional pointer user data, C<vup>, of type C<AstNuser*>. The second is
one of the ways to pass parameters to visitors described in L</Visitor
Functions>, but its use is no deprecated and should be used for new visitor
classes.
=over 4
=item C<iterate()>
This just applies the C<accept> method of the C<AstNode> to the visitor
function.
=item C<iterateAndNextIgnoreEdit>
Applies the C<accept> method of each C<AstNode> in a list (i.e. connected
by C<nextp> and C<backp> pointers).
=item C<iterateAndNext>
Applies the C<accept> method of each C<AstNode> in a list. If a node is
edited by the call to C<accept>, apply C<accept> again, until the node does
not change.
=item C<iterateListBackwards>
Applies the C<accept> method of each C<AstNode> in a list, starting with
the last one.
=item C<iterateChildren>
Apply the C<iterateAndNext> method on each child C<op1p> through C<op4p> in
turn.
=item C<iterateChildrenBackwards>
Apply the C<iterateListBackwards> method on each child C<op1p> through
C<op4p> in turn.
=back
=head2 Identifying derived classes
A common requirement is to identify the specific C<AstNode> class we are
dealing with. For example a visitor might not implement separate C<visit>
methods for C<AstIf> and C<AstGenIf>, but just a single method for the base
class:
void visit (AstNodeIf* nodep, AstNUser* vup)
However that method might want to specify additional code if it is called
for C<AstGenIf>. Verilator does this by providing a C<castSOMETYPE()>
method for each possible node type, using C++ C<dynamic_cast>. This either
returns a pointer to the object cast to that type (if it is of class
C<SOMETYPE>, or a derived class of C<SOMETYPE>) or else NULL. So our
C<visit> method could use:
if (nodep->castAstGenIf()) {
<code specific to AstGenIf>
}
A common test is for C<AstNetlist>, which is the node at the root of the
AST.
=head1 TESTING
@@ -214,7 +376,8 @@ algorithmic stage. An example:
=over 4
"1:2:" indicates the hierarchy the VAR is op2p under the MODULE.
"1:2:" indicates the hierarchy of the C<VAR> is the C<op2p> pointer under
the C<MODULE>, which in turn is the C<op1p> pointer under the C<NETLIST>
"VAR" is the AstNodeType.
@@ -239,14 +402,58 @@ variable is an output.
=head2 Debugging with GDB
The test_regress/driver.pl script accepts --debug --gdb to start Verilator
under gdb. You can also use --debug --gdbbt to just backtrace and then
exit gdb.
under gdb and break when an error is hit or the program is about to exit.
You can also use --debug --gdbbt to just backtrace and then exit gdb. To
debug the Verilated executable, use --gdbsim.
If you wish to start verilator under GDB (or another debugger), then you
can use --debug and look at the underlying invocation of verilator_dgb. For
example
t/t_alw_dly.pl --debug
shows it invokes the command:
../verilator_bin_dbg --prefix Vt_alw_dly --x-assign unique --debug
-cc -Mdir obj_dir/t_alw_dly --debug-check -f input.vc t/t_alw_dly.v
Start GDB, then C<start> with the remaining arguments.
gdb ../verilator_bin_dbg
...
(gdb) start --prefix Vt_alw_dly --x-assign unique --debug -cc -Mdir
obj_dir/t_alw_dly --debug-check -f input.vc t/t_alw_dly.v
> obj_dir/t_alw_dly/vlt_compile.log
...
Temporary breakpoint 1, main (argc=13, argv=0xbfffefa4, env=0xbfffefdc)
at ../Verilator.cpp:615
615 ios::sync_with_stdio();
(gdb)
You can then continue execution with breakpoints as required.
To break at a specific edit number which changed a node (presumably to find
what made a <e####> line in the tree dumps):
watch AstNode::s_editCntGbl==####
To print a node:
call nodep->dumpGdb() # aliased to "pn" in src/.gdbinit
call nodep->dumpTreeGdb() # aliased to "pnt" in src/.gdbinit
When GDB halts, it is useful to understand that the backtrace will commonly
show the iterator functions between each invocation of C<visit> in the
backtrace. You will typically see a frame sequence something like
...
visit()
iterateChildren()
iterateAndNext()
accept()
visit()
...
=head1 DISTRIBUTION
The latest version is available from L<http://www.veripool.org/>.
+23 -1
View File
@@ -13,6 +13,7 @@ use vars qw ($Debug);
# main
our $Opt_Stage = 0;
our $Opt_Jobs = calc_jobs();
autoflush STDOUT 1;
autoflush STDERR 1;
@@ -21,11 +22,13 @@ if (! GetOptions (
"debug" => sub { $Debug = 1; },
"<>" => sub { die "%Error: Unknown parameter: $_[0]\n"; },
"stage=i" => \$Opt_Stage,
"j=i" => \$Opt_Jobs,
)) {
die "%Error: Bad usage, try 'install_test --help'\n";
}
test();
exit(0);
#######################################################################
@@ -47,7 +50,7 @@ sub test {
run("/bin/rm -rf $blddir");
run("/bin/mkdir -p $blddir");
run("cd $blddir && $srcdir/configure --prefix $prefix");
run("cd $blddir && make -j");
run("cd $blddir && make -j $Opt_Jobs");
}
# Install it under the prefix
@@ -121,6 +124,16 @@ sub cleanenv {
#######################################################################
sub calc_jobs {
my $ok = eval "
use Unix::Processors;
return Unix::Processors->new->max_online;
";
$ok && !$@ or return 1;
print "driver.pl: Found $ok cores, using -j ",$ok+1,"\n" if $Debug;
return $ok + 1;
}
sub run {
# Run a system command, check errors
my $command = shift;
@@ -157,6 +170,15 @@ required.
Displays this message and program version and exits.
=item -j I<jobs>
Specify make -j flag. Defaults to number of cores + 1 if Perl's
Unix::Processors is installed, else 1.
=item -stage I<stage>
Runs a specific test stage (see the script).
=back
=head1 DISTRIBUTION
+20
View File
@@ -0,0 +1,20 @@
# DESCRIPTION: Verilator: GDB startup file with useful defines
#
# Copyright 2012-2012 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
define pn
call $arg0->dumpGdb()
end
document pn
Verilator: Print single AstNode NODEP
end
define pnt
call $arg0->dumpTreeGdb()
end
document pnt
Verilator: Print AstNode NODEP's tree
end
+2 -1
View File
@@ -27,7 +27,7 @@ config_srcdir = @srcdir@
ifeq ($(config_srcdir),.)
srcdir = ..
else # Run an experiment
ifeq ($(shell -e $(config_srcdir)/../Makefile_obj.in),)
ifeq ($(wildcard $(config_srcdir)/../Makefile_obj.in),)
srcdir = $(config_srcdir)
else
srcdir = $(config_srcdir)/..
@@ -182,6 +182,7 @@ RAW_OBJS = \
V3EmitCSyms.o \
V3EmitMk.o \
V3EmitV.o \
V3EmitXml.o \
V3Error.o \
V3Expand.o \
V3File.o \
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity active domains
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity block domains
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity active domains
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity block domains
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Collect and print statistics
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Assertion expansion
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Collect and print statistics
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Assertion pre-expansion
//
+21 -2
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Ast node structures
//
@@ -245,7 +246,7 @@ inline void AstNode::debugTreeChange(const char* prefix, int lineno, bool next)
// Called on all major tree changers.
// Only for use for those really nasty bugs relating to internals
// Note this may be null.
//if (debug()) cout<<"-treeChange: V3Ast.cpp:"<<lineno<<" Tree Change for "<<prefix<<": "<<(void*)this<<endl;
//if (debug()) cout<<"-treeChange: V3Ast.cpp:"<<lineno<<" Tree Change for "<<prefix<<": "<<(void*)this<<" <e"<<AstNode::s_editCntGbl<<">"<<endl;
//if (debug()) {
// cout<<"-treeChange: V3Ast.cpp:"<<lineno<<" Tree Change for "<<prefix<<endl;
// v3Global.rootp()->dumpTree(cout,"-treeChange: ");
@@ -719,6 +720,7 @@ void AstNode::deleteTree() {
if (!this) return;
UASSERT(m_backp==NULL,"Delete called on node with backlink still set\n");
this->debugTreeChange("-delTree: ", __LINE__, true);
this->editCountInc();
// MUST be depth first!
deleteTreeIter();
}
@@ -947,6 +949,22 @@ void AstNode::checkTree() {
}
}
void AstNode::dumpGdb() { // For GDB only
if (!this) { cout<<"This=NULL"<<endl; return; }
dumpGdbHeader();
cout<<" "; dump(cout); cout<<endl;
}
void AstNode::dumpTreeGdb() { // For GDB only
if (!this) { cout<<"This=NULL"<<endl; return; }
dumpGdbHeader();
dumpTree(cout);
}
void AstNode::dumpGdbHeader() const { // For GDB only
if (!this) { cout<<"This=NULL"<<endl; return; }
dumpPtrs(cout);
cout<<" Fileline = "<<fileline()<<endl;
}
void AstNode::dumpPtrs(ostream& os) const {
os<<"This="<<typeName()<<" "<<(void*)this;
os<<" back="<<(void*)backp();
@@ -997,7 +1015,8 @@ void AstNode::dumpTreeFile(const string& filename, bool append) {
if (logsp->fail()) v3fatalSrc("Can't write "<<filename);
*logsp<<"Tree Dump from <e"<<dec<<editCountLast()<<">";
*logsp<<" to <e"<<dec<<editCountGbl()<<">"<<endl;
if (editCountGbl()==editCountLast()) {
if (editCountGbl()==editCountLast()
&& !(v3Global.opt.dumpTree()>=9)) {
*logsp<<endl;
*logsp<<"No changes since last dump!\n";
} else {
+67 -24
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Ast node structure
//
@@ -29,13 +29,16 @@
#include "V3Global.h"
#include <vector>
#include <cmath>
#include <map>
#include "V3Ast__gen_classes.h" // From ./astgen
// Things like:
// class V3AstNode;
// Hint class so we can choose constructors
class AstLogicPacked {};
class VFlagLogicPacked {};
class VFlagBitPacked {};
class VFlagChildDType {}; // Used by parser.y to select constructor that sets childDType
//######################################################################
@@ -251,7 +254,9 @@ public:
// Internal types for mid-steps
SCOPEPTR, CHARPTR,
// Internal types, eliminated after parsing
LOGIC_IMPLICIT
LOGIC_IMPLICIT,
// Leave last
_ENUM_MAX
};
enum en m_e;
const char* ascii() const {
@@ -261,7 +266,8 @@ public:
"real", "shortint", "shortreal", "time",
"string",
"VerilatedScope*", "char*",
"LOGIC_IMPLICIT"
"LOGIC_IMPLICIT",
" MAX"
};
return names[m_e];
};
@@ -272,28 +278,35 @@ public:
"double", "short int", "float", "long long",
"const char*",
"dpiScope", "const char*",
""
"",
" MAX"
};
return names[m_e];
};
static void test() {
UASSERT(0==strcmp(AstBasicDTypeKwd(_ENUM_MAX).ascii()," MAX"),"Enum array mismatch");
UASSERT(0==strcmp(AstBasicDTypeKwd(_ENUM_MAX).dpiType()," MAX"),"Enum array mismatch");
}
inline AstBasicDTypeKwd () : m_e(UNKNOWN) {}
inline AstBasicDTypeKwd (en _e) : m_e(_e) {}
explicit inline AstBasicDTypeKwd (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; }
int width() const {
switch (m_e) {
case BIT: return 1;
case BIT: return 1; // scalar, can't bit extract unless ranged
case BYTE: return 8;
case CHANDLE: return 64;
case INT: return 32;
case INTEGER: return 32;
case LOGIC: return 1;
case LOGIC: return 1; // scalar, can't bit extract unless ranged
case LONGINT: return 64;
case DOUBLE: return 64;
case FLOAT: return 32;
case DOUBLE: return 64; // opaque
case FLOAT: return 32; // opaque
case SHORTINT: return 16;
case TIME: return 64;
case STRING: return 64; // Just the pointer, for today
case STRING: return 64; // opaque // Just the pointer, for today
case SCOPEPTR: return 0; // opaque
case CHARPTR: return 0; // opaque
default: return 0;
}
}
@@ -310,7 +323,7 @@ public:
bool isSloppy() const { // Don't be as anal about width warnings
return !(m_e==LOGIC || m_e==BIT);
}
bool isBitLogic() const { // Don't be as anal about width warnings
bool isBitLogic() const { // Bit/logic vector types; can form a packed array
return (m_e==LOGIC || m_e==BIT);
}
bool isDpiUnsupported() const {
@@ -331,7 +344,7 @@ public:
enum AstSignedState {
// This can't be in the fancy class as the lexer union will get upset
signedst_NOP=0, signedst_SIGNED=1, signedst_UNSIGNED=2
signedst_NOSIGNED=0, signedst_UNSIGNED=1, signedst_SIGNED=2
};
//######################################################################
@@ -688,11 +701,14 @@ public:
// Creating from raw data (sameHash functions)
V3Hash() { setBoth(1,0); }
V3Hash(uint32_t val) { setBoth(1,val); }
V3Hash(void* vp) { setBoth(1,cvtToHash(vp)); }
V3Hash(const void* vp) { setBoth(1,cvtToHash(vp)); }
V3Hash(const string& name);
V3Hash(V3Hash lh, V3Hash rh) {
setBoth(1,lh.hshval()*31+rh.hshval());
}
V3Hash(V3Hash h1, V3Hash h2) {
setBoth(1,h1.hshval()*31+h2.hshval()); }
V3Hash(V3Hash h1, V3Hash h2, V3Hash h3) {
setBoth(1,(h1.hshval()*31+h2.hshval())*31+h3.hshval()); }
V3Hash(V3Hash h1, V3Hash h2, V3Hash h3, V3Hash h4) {
setBoth(1,((h1.hshval()*31+h2.hshval())*31+h3.hshval())*31+h4.hshval()); }
};
ostream& operator<<(ostream& os, V3Hash rhs);
@@ -860,16 +876,16 @@ public:
void numericFrom(AstNode* fromp) { numeric(fromp->numeric()); }
void numeric(AstNumeric flag) { m_numeric = (int)flag; if (flag.isDouble()) width(64,64); }
AstNumeric numeric() const { return AstNumeric(m_numeric); }
bool isDouble() const { return numeric().isDouble(); }
bool isSigned() const { return numeric().isSigned(); }
void isSigned(bool flag) { numeric(flag ? AstNumeric::SIGNED : AstNumeric::UNSIGNED); }
bool isUnsigned() const { return numeric().isUnsigned(); }
void didWidth(bool flag) { m_didWidth=flag; }
bool didWidth() const { return m_didWidth; }
bool didWidthAndSet() { if (didWidth()) return true; didWidth(true); return false;}
void doingWidth(bool flag) { m_doingWidth=flag; }
bool doingWidth() const { return m_doingWidth; }
bool isQuad() const { return (width()>VL_WORDSIZE && width()<=VL_QUADSIZE); }
bool isWide() const { return (width()>VL_QUADSIZE); }
bool isDouble() const;
bool isSigned() const;
AstNUser* user1p() const {
// Slows things down measurably, so disabled by default
@@ -933,12 +949,20 @@ public:
bool isAllOnesV(); // Verilog width rules apply
// METHODS - data type changes especially for initial creation
void dtypeChgBool() { numeric(AstNumeric::UNSIGNED); width(1,1); }
void dtypeChgDouble() { numeric(AstNumeric::DOUBLE); }
void dtypeChgSigned(bool flag) { numeric(flag ? AstNumeric::SIGNED : AstNumeric::UNSIGNED); }
void dtypeSetBitSized(int widthf, int widthMinf, AstNumeric numericf) { numeric(numericf); width(widthf,widthMinf); }
void dtypeSetLogicSized(int widthf, int widthMinf, AstNumeric numericf) { numeric(numericf); width(widthf,widthMinf); }
void dtypeSetLogicBool() { numeric(AstNumeric::UNSIGNED); width(1,1); }
void dtypeSetDouble() { numeric(AstNumeric::DOUBLE); }
void dtypeSetSigned32() { numeric(AstNumeric::SIGNED); width(VL_WORDSIZE,VL_WORDSIZE); }
void dtypeSetUInt32() { numeric(AstNumeric::UNSIGNED); width(VL_WORDSIZE,VL_WORDSIZE); }
void dtypeSetUInt64() { numeric(AstNumeric::UNSIGNED); width(VL_QUADSIZE,VL_QUADSIZE); }
// METHODS - dump and error
void v3errorEnd(ostringstream& str) const;
virtual void dump(ostream& str=cout);
void dumpGdb(); // For GDB only
void dumpGdbHeader() const;
// METHODS - Tree modifications
AstNode* addNext(AstNode* newp); // Returns this, adds to end of list
@@ -963,6 +987,7 @@ public:
void checkTree(); // User Interface version
void dumpPtrs(ostream& str=cout) const;
void dumpTree(ostream& str=cout, const string& indent=" ", int maxDepth=0);
void dumpTreeGdb(); // For GDB only
void dumpTreeAndNext(ostream& str=cout, const string& indent=" ", int maxDepth=0);
void dumpTreeFile(const string& filename, bool append=false);
@@ -977,6 +1002,7 @@ public:
virtual int instrCount() const { return 0; }
virtual V3Hash sameHash() const { return V3Hash(V3Hash::Illegal()); } // Not a node that supports it
virtual bool same(AstNode* otherp) const { return true; }
virtual bool hasDType() const { return false; } // Iff has a data type; dtype() must be non null
virtual bool maybePointedTo() const { return false; } // Another AstNode* may have a pointer into this node, other then normal front/back/etc.
virtual bool broken() const { return false; }
@@ -1013,6 +1039,7 @@ struct AstNodeMath : public AstNode {
: AstNode(fl) {}
ASTNODE_BASE_FUNCS(NodeMath)
// METHODS
virtual bool hasDType() const { return true; }
virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV
virtual string emitC() = 0;
virtual string emitSimpleOperator() { return ""; }
@@ -1162,8 +1189,8 @@ struct AstNodeStmt : public AstNode {
: AstNode(fl) {}
ASTNODE_BASE_FUNCS(NodeStmt)
// METHODS
virtual void addNextStmt(AstNode* newp, AstNode* belowp); // Stop statement searchback here
virtual void addBeforeStmt(AstNode* newp, AstNode* belowp); // Stop statement searchback here
virtual void addNextStmt(AstNode* newp, AstNode* belowp); // Stop statement searchback here
virtual void addBeforeStmt(AstNode* newp, AstNode* belowp); // Stop statement searchback here
};
struct AstNodeAssign : public AstNodeStmt {
@@ -1179,6 +1206,7 @@ struct AstNodeAssign : public AstNodeStmt {
AstNode* lhsp() const { return op2p()->castNode(); } // op2 = Assign to
void rhsp(AstNode* np) { setOp1p(np); }
void lhsp(AstNode* np) { setOp2p(np); }
virtual bool hasDType() const { return true; }
virtual bool cleanRhs() { return true; }
virtual int instrCount() const { return widthInstrs(); }
virtual V3Hash sameHash() const { return V3Hash(); }
@@ -1261,18 +1289,21 @@ private:
string m_name; // Name of variable
string m_hiername; // Scope converted into name-> for emitting
bool m_hierThis; // Hiername points to "this" function
void init();
public:
AstNodeVarRef(FileLine* fl, const string& name, bool lvalue)
: AstNodeMath(fl), m_lvalue(lvalue), m_varp(NULL), m_varScopep(NULL),
m_packagep(NULL), m_name(name), m_hierThis(false) {
init();
}
AstNodeVarRef(FileLine* fl, const string& name, AstVar* varp, bool lvalue)
: AstNodeMath(fl), m_lvalue(lvalue), m_varp(varp), m_varScopep(NULL),
m_packagep(NULL), m_name(name), m_hierThis(false) {
// May have varp==NULL
if (m_varp) widthSignedFrom((AstNode*)m_varp);
init();
}
ASTNODE_BASE_FUNCS(NodeVarRef)
virtual bool hasDType() const { return true; }
virtual bool broken() const;
virtual int instrCount() const { return widthInstrs(); }
virtual void cloneRelink();
@@ -1318,10 +1349,16 @@ struct AstNodeDType : public AstNode {
AstNodeDType(FileLine* fl) : AstNode(fl) {}
ASTNODE_BASE_FUNCS(NodeDType)
// Accessors
virtual void dump(ostream& str);
virtual bool hasDType() const { return true; }
virtual AstBasicDType* basicp() const = 0; // (Slow) recurse down to find basic data type
virtual AstNodeDType* skipRefp() const = 0; // recurses over typedefs to next non-typeref type
virtual int widthAlignBytes() const = 0; // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this)
virtual int widthTotalBytes() const = 0; // (Slow) recurses - Width in bytes rounding up 1,2,4,8,12,...
virtual bool maybePointedTo() const { return true; }
AstNodeDType* dtypeDimensionp(int depth);
pair<uint32_t,uint32_t> dimensions();
uint32_t arrayElements(); // 1, or total multiplication of all dimensions
};
struct AstNodeSel : public AstNodeBiop {
@@ -1334,6 +1371,7 @@ struct AstNodeSel : public AstNodeBiop {
AstNode* bitp() const { return op2p()->castNode(); } // op2 = Msb selection expression
void bitp(AstNode* nodep) { setOp2p(nodep); }
int bitConst() const;
virtual bool hasDType() const { return true; }
};
//######################################################################
@@ -1497,10 +1535,15 @@ public:
//######################################################################
// Inline ACCESSORS
inline bool AstNode::isDouble() const { return numeric().isDouble(); }
inline bool AstNode::isSigned() const { return numeric().isSigned(); }
inline bool AstNode::isZero() { return (this->castConst() && this->castConst()->num().isEqZero()); }
inline bool AstNode::isNeqZero() { return (this->castConst() && this->castConst()->num().isNeqZero()); }
inline bool AstNode::isOne() { return (this->castConst() && this->castConst()->num().isEqOne()); }
inline bool AstNode::isAllOnes() { return (this->castConst() && this->castConst()->isEqAllOnes()); }
inline bool AstNode::isAllOnesV() { return (this->castConst() && this->castConst()->isEqAllOnesV()); }
inline void AstNodeVarRef::init() { if (m_varp) widthSignedFrom((AstNode*)m_varp); }
#endif // Guard
+30 -25
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Ast node structures
//
@@ -245,7 +246,7 @@ string AstVar::scType() const {
}
}
AstNodeDType* AstVar::dtypeDimensionp(int dimension) const {
AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) {
// dimension passed from AstArraySel::dimension
// Dimension 0 means the VAR itself, 1 is the closest SEL to the AstVar,
// which is the lowest in the dtype list.
@@ -258,18 +259,18 @@ AstNodeDType* AstVar::dtypeDimensionp(int dimension) const {
// *or* VAR a (ARRAYSEL0 (ARRAYSEL1 (ARRAYSEL2 (ARRAYSEL3 (DT))))
// SEL1 needs to select from entire variable which is a pointer to ARRAYSEL0
int dim = 0;
for (AstNodeDType* dtypep=this->dtypep(); dtypep; ) {
for (AstNodeDType* dtypep=this; dtypep; ) {
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
if ((dim++)==dimension) {
return dtypep;
}
dtypep = adtypep->dtypep();
dtypep = adtypep->subDTypep();
continue;
}
else if (AstBasicDType* adtypep = dtypep->castBasicDType()) {
// AstBasicDType - nothing below, return null
if (adtypep->rangep()) {
if (adtypep->isRanged()) {
if ((dim++) == dimension) {
return adtypep;
}
@@ -282,13 +283,13 @@ AstNodeDType* AstVar::dtypeDimensionp(int dimension) const {
return NULL;
}
uint32_t AstVar::arrayElements() const {
uint32_t AstNodeDType::arrayElements() {
uint32_t entries=1;
for (AstNodeDType* dtypep=this->dtypep(); dtypep; ) {
for (AstNodeDType* dtypep=this; dtypep; ) {
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
entries *= adtypep->elementsConst();
dtypep = adtypep->dtypep();
dtypep = adtypep->subDTypep();
}
else {
// AstBasicDType - nothing below, 1
@@ -298,16 +299,16 @@ uint32_t AstVar::arrayElements() const {
return entries;
}
pair<uint32_t,uint32_t> AstVar::dimensions() const {
pair<uint32_t,uint32_t> AstNodeDType::dimensions() {
// How many array dimensions (packed,unpacked) does this Var have?
uint32_t packed = 0;
uint32_t unpacked = 0;
for (AstNodeDType* dtypep=this->dtypep(); dtypep; ) {
for (AstNodeDType* dtypep=this; dtypep; ) {
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
if (adtypep->isPacked()) packed += 1;
else unpacked += 1;
dtypep = adtypep->dtypep();
dtypep = adtypep->subDTypep();
}
else {
// AstBasicDType - nothing below, 1
@@ -496,21 +497,21 @@ void AstWhile::addNextStmt(AstNode* newp, AstNode* belowp) {
//======================================================================
// Per-type Debugging
void AstNode::dump(ostream& os) {
os<<typeName()<<" "<<(void*)this
void AstNode::dump(ostream& str) {
str<<typeName()<<" "<<(void*)this
//<<" "<<(void*)this->m_backp
<<" <e"<<dec<<editCount()
<<((editCount()>=editCountLast())?"#>":">")
<<" {"<<fileline()->filenameLetters()<<dec<<fileline()->lineno()<<"}"
<<" "<<(isSigned()?"s":"")
<<(isDouble()?"d":"")
<<"w"<<(widthSized()?"":"u")<<width();
if (!widthSized()) os<<"/"<<widthMin();
if (name()!="") os<<" "<<AstNode::quoteName(name());
<<" <e"<<dec<<editCount()
<<((editCount()>=editCountLast())?"#>":">")
<<" {"<<fileline()->filenameLetters()<<dec<<fileline()->lineno()<<"}"
<<" "<<(isSigned()?"s":"")
<<(isDouble()?"d":"")
<<"w"<<(widthSized()?"":"u")<<width();
if (!widthSized()) str<<"/"<<widthMin();
if (name()!="") str<<" "<<AstNode::quoteName(name());
}
void AstArrayDType::dump(ostream& str) {
this->AstNode::dump(str);
this->AstNodeDType::dump(str);
if (isPacked()) str<<" [PACKED]";
}
void AstArraySel::dump(ostream& str) {
@@ -522,8 +523,9 @@ void AstAttrOf::dump(ostream& str) {
str<<" ["<<attrType().ascii()<<"]";
}
void AstBasicDType::dump(ostream& str) {
this->AstNode::dump(str);
str<<" ["<<keyword().ascii()<<"]";
this->AstNodeDType::dump(str);
str<<" kwd="<<keyword().ascii();
if (isRanged() && !rangep()) str<<" range=["<<left()<<":"<<right()<<"]";
if (implicit()) str<<" [IMPLICIT]";
}
void AstCCast::dump(ostream& str) {
@@ -566,7 +568,7 @@ void AstRange::dump(ostream& str) {
if (littleEndian()) str<<" [LITTLE]";
}
void AstRefDType::dump(ostream& str) {
this->AstNode::dump(str);
this->AstNodeDType::dump(str);
if (defp()) { str<<" -> "; defp()->dump(str); }
else { str<<" -> UNLINKED"; }
}
@@ -580,6 +582,9 @@ void AstVarXRef::dump(ostream& str) {
else if (varp()) { varp()->dump(str); }
else { str<<"UNLINKED"; }
}
void AstNodeDType::dump(ostream& str) {
this->AstNode::dump(str);
}
void AstNodeModule::dump(ostream& str) {
this->AstNode::dump(str);
str<<" L"<<level();
@@ -616,7 +621,7 @@ void AstVar::dump(ostream& str) {
if (isConst()) str<<" [CONST]";
if (isUsedClock()) str<<" [CLK]";
if (isSigPublic()) str<<" [P]";
if (isUsedLoopIdx()) str<<" [LOOP]";
if (isUsedLoopIdx()) str<<" [LOOP]";
if (attrClockEn()) str<<" [aCLKEN]";
if (attrIsolateAssign()) str<<" [aISO]";
if (attrFileDescr()) str<<" [aFD]";
+214 -133
View File
File diff suppressed because it is too large Load Diff
+81 -6
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Removal of named begin blocks
//
@@ -45,9 +46,31 @@
//######################################################################
class BeginState {
private:
// NODE STATE
//Entire netlist:
// AstNodeFTask::user1 -> bool, 1=processed
AstUser1InUse m_inuser1;
bool m_anyFuncInBegin;
public:
BeginState() {
m_anyFuncInBegin = false;
}
~BeginState() {}
void userMarkChanged(AstNodeFTask* nodep) {
nodep->user1(true);
m_anyFuncInBegin = true;
}
bool anyFuncInBegin() const { return m_anyFuncInBegin; }
};
//######################################################################
class BeginVisitor : public AstNVisitor {
private:
// STATE
BeginState* m_statep; // Current global state
AstNodeModule* m_modp; // Current module
AstNodeFTask* m_ftaskp; // Current function/task
string m_namedScope; // Name of begin blocks above us
@@ -70,9 +93,27 @@ private:
m_modp = NULL;
}
virtual void visit(AstNodeFTask* nodep, AstNUser*) {
m_ftaskp = nodep;
nodep->iterateChildren(*this);
m_ftaskp = NULL;
UINFO(8," "<<nodep<<endl);
// Rename it
if (m_unnamedScope != "") {
nodep->name(m_unnamedScope+"__DOT__"+nodep->name());
UINFO(8," rename to "<<nodep->name()<<endl);
m_statep->userMarkChanged(nodep);
}
// BEGIN wrapping a function rename that function, but don't affect the inside function's variables
// We then restart with empty naming; so that any begin's inside the function will rename inside the function
// Process children
string oldScope = m_namedScope;
string oldUnnamed = m_unnamedScope;
{
m_namedScope = "";
m_unnamedScope = "";
m_ftaskp = nodep;
nodep->iterateChildren(*this);
m_ftaskp = NULL;
}
m_namedScope = oldScope;
m_unnamedScope = oldUnnamed;
}
virtual void visit(AstBegin* nodep, AstNUser*) {
// Begin blocks were only useful in variable creation, change names and delete
@@ -80,7 +121,7 @@ private:
string oldScope = m_namedScope;
string oldUnnamed = m_unnamedScope;
{
//UINFO(8,"nname "<<m_namedScope<<endl);
UINFO(8,"nname "<<m_namedScope<<endl);
if (nodep->name() != "") { // Else unneeded unnamed block
// Create data for dotted variable resolution
string dottedname = nodep->name() + "__DOT__"; // So always found
@@ -186,7 +227,8 @@ private:
}
public:
// CONSTUCTORS
BeginVisitor(AstNetlist* nodep) {
BeginVisitor(AstNetlist* nodep, BeginState* statep) {
m_statep = statep;
m_modp = NULL;
m_ftaskp = NULL;
m_repeatNum = 0;
@@ -196,10 +238,43 @@ public:
virtual ~BeginVisitor() {}
};
//######################################################################
class BeginRelinkVisitor : public AstNVisitor {
// Replace tasks with new pointer
private:
// NODE STATE
// Input:
// AstNodeFTask::user1p // Node replaced, rename it
// VISITORS
virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) {
if (nodep->taskp()->user1()) { // It was converted
UINFO(9, " relinkFTask "<<nodep<<endl);
nodep->name(nodep->taskp()->name());
}
nodep->iterateChildren(*this);
}
//--------------------
virtual void visit(AstNode* nodep, AstNUser*) {
nodep->iterateChildren(*this);
}
public:
// CONSTUCTORS
BeginRelinkVisitor(AstNetlist* nodep, BeginState*) {
nodep->accept(*this);
}
virtual ~BeginRelinkVisitor() {}
};
//######################################################################
// Task class functions
void V3Begin::debeginAll(AstNetlist* nodep) {
UINFO(2,__FUNCTION__<<": "<<endl);
BeginVisitor bvisitor (nodep);
BeginState state;
{ BeginVisitor bvisitor (nodep,&state); }
if (state.anyFuncInBegin()) {
BeginRelinkVisitor brvisitor (nodep,&state);
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Removal of named begin blocks
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Branch prediction
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Branch prediction
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Find broken links in tree
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Find broken links in tree
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break case statements up and add Unknown assigns
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break case statements up and add Unknown assigns
//
+2 -2
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add C++ casts across expression size changes
//
@@ -77,8 +78,7 @@ private:
AstNRelinker relinkHandle;
nodep->unlinkFrBack(&relinkHandle);
//
AstCCast* castp = new AstCCast (nodep->fileline(), nodep, needsize);
castp->width(needsize, nodep->widthMin());
AstCCast* castp = new AstCCast (nodep->fileline(), nodep, needsize, nodep->widthMin());
relinkHandle.relink(castp);
//if (debug()>8) castp->dumpTree(cout,"-castins: ");
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add C++ casts across expression size changes
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Clock Domain Crossing Lint
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity block domains
//
+45 -13
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add temporaries, such as for changed nodes
//
@@ -59,6 +60,12 @@ private:
AstScope* m_scopetopp; // Scope under TOPSCOPE
AstCFunc* m_chgFuncp; // Change function we're building
// CONSTANTS
enum MiscConsts {
DETECTARRAY_MAX_INDEXES = 256 // How many indexes before error
// Ok to increase this, but may result in much slower model
};
// METHODS
static int debug() {
static int level = -1;
@@ -66,14 +73,33 @@ private:
return level;
}
AstNode* aselIfNeeded(bool isArray, int index, AstNode* childp) {
if (isArray) {
return new AstArraySel(childp->fileline(), childp,
new AstConst(childp->fileline(), index));
} else {
return childp;
}
}
void genChangeDet(AstVarScope* vscp) {
#ifdef NEW_ORDERING
vscp->v3fatalSrc("Not applicable\n");
#endif
AstVar* varp = vscp->varp();
vscp->v3warn(IMPERFECTSCH,"Imperfect scheduling of variable: "<<vscp);
if (!varp->dtypeSkipRefp()->castBasicDType()) {
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on arrayed variable (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName());
AstArrayDType* arrayp = varp->dtypeSkipRefp()->castArrayDType();
bool isArray = arrayp;
int msb = isArray ? arrayp->msb() : 0;
int lsb = isArray ? arrayp->lsb() : 0;
if (isArray && ((msb - lsb + 1) > DETECTARRAY_MAX_INDEXES)) {
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect more than "<<cvtToStr(DETECTARRAY_MAX_INDEXES)
<<" array indexes (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName());
vscp->v3warn(E_DETECTARRAY, "... Could recompile with DETECTARRAY_MAX_INDEXES increased to at least "<<cvtToStr(msb-lsb+1));
} else if (!isArray
&& !varp->dtypeSkipRefp()->castBasicDType()) {
if (debug()) varp->dumpTree(cout,"-DETECTARRAY-");
vscp->v3warn(E_DETECTARRAY, "Unsupported: Can't detect changes on complex variable (probably with UNOPTFLAT warning suppressed): "<<varp->prettyName());
} else {
string newvarname = "__Vchglast__"+vscp->scopep()->nameDotless()+"__"+varp->shortName();
// Create: VARREF(_last)
@@ -84,17 +110,23 @@ private:
m_topModp->addStmtp(newvarp);
AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopetopp, newvarp);
m_scopetopp->addVarp(newvscp);
AstChangeDet* changep
= new AstChangeDet (vscp->fileline(),
new AstVarRef(vscp->fileline(), vscp, false),
new AstVarRef(vscp->fileline(), newvscp, false),
false);
m_chgFuncp->addStmtsp(changep);
AstAssign* initp
= new AstAssign (vscp->fileline(),
new AstVarRef(vscp->fileline(), newvscp, true),
new AstVarRef(vscp->fileline(), vscp, false));
m_chgFuncp->addFinalsp(initp);
for (int index=lsb; index<=msb; ++index) {
AstChangeDet* changep
= new AstChangeDet (vscp->fileline(),
aselIfNeeded(isArray, index,
new AstVarRef(vscp->fileline(), vscp, false)),
aselIfNeeded(isArray, index,
new AstVarRef(vscp->fileline(), newvscp, false)),
false);
m_chgFuncp->addStmtsp(changep);
AstAssign* initp
= new AstAssign (vscp->fileline(),
aselIfNeeded(isArray, index,
new AstVarRef(vscp->fileline(), newvscp, true)),
aselIfNeeded(isArray, index,
new AstVarRef(vscp->fileline(), vscp, false)));
m_chgFuncp->addFinalsp(initp);
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Pre C-Emit stage changes
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add temporaries, such as for clean nodes
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Pre C-Emit stage changes
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity active domains
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into clock gated blocks
//
+3 -2
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Clocking POS/NEGEDGE insertion
//
@@ -85,7 +86,7 @@ private:
AstVar* varp = vscp->varp();
if (!varp->width1()) varp->v3error("Unsupported: Clock edge on non-single bit signal: "<<varp->prettyName());
string newvarname = ((string)"__Vclklast__"+vscp->scopep()->nameDotless()+"__"+varp->shortName());
AstVar* newvarp = new AstVar (vscp->fileline(), AstVarType::MODULETEMP, newvarname, AstLogicPacked(), 1);
AstVar* newvarp = new AstVar (vscp->fileline(), AstVarType::MODULETEMP, newvarname, VFlagLogicPacked(), 1);
m_modp->addStmtp(newvarp);
AstVarScope* newvscp = new AstVarScope(vscp->fileline(), m_scopep, newvarp);
vscp->user1p(newvscp);
@@ -103,7 +104,7 @@ private:
AstVarScope* getCreateLocalVar(FileLine* fl, const string& name, AstVar* examplep, int width) {
AstVar* newvarp;
if (width) {
newvarp = new AstVar (fl, AstVarType::BLOCKTEMP, name, AstLogicPacked(), width);
newvarp = new AstVar (fl, AstVarType::BLOCKTEMP, name, VFlagLogicPacked(), width);
} else {
newvarp = new AstVar (fl, AstVarType::BLOCKTEMP, name, examplep); // No range; 1 bit.
}
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Clocking POS/NEGEDGE insertion
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Combine common code into functions
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Combine common code into functions
//
+2 -1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Configuration Files
//
@@ -62,7 +63,7 @@ class V3ConfigIgnores {
IgnFiles m_ignWilds; // Ignores for each wildcarded filename
IgnFiles m_ignFiles; // Ignores for each non-wildcarded filename
static V3ConfigIgnores s_singleton; // Singleton (not via local static, as that's slow)
V3ConfigIgnores() { m_lastLineno = -1; }
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Configuration Files
//
+14 -7
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Constant folding
//
@@ -150,7 +151,7 @@ private:
// BIASV(CONSTa,BIASV(b...,BIASV(CONSTc,d...))) // hits operandAsvUp
// BIASV(CONSTa,BIASV(CONSTc,BIASV(c...,d...))) // hits operandAsvConst
// BIASV(BIASV(CONSTa,CONSTc),BIASV(c...,d...))) // hits normal constant propagation
// BIASV(CONST_a_c,BIASV(c...,d...)))
// BIASV(CONST_a_c,BIASV(c...,d...)))
//
// Idea for the future: All BiComAsvs could be lists, sorted by if they're constant
AstNodeBiComAsv* bnodep = nodep->castNodeBiComAsv();
@@ -374,7 +375,7 @@ private:
if (m_warn
&& nodep->lsbp()->castConst()
&& nodep->widthp()->castConst()
&& (!bdtypep->rangep() || bdtypep->msb())) { // else it's non-resolvable parameterized
&& (!bdtypep->isRanged() || bdtypep->msb())) { // else it's non-resolvable parameterized
if (nodep->lsbp()->castConst()->num().isFourState()
|| nodep->widthp()->castConst()->num().isFourState()) {
nodep->v3error("Selection index is constantly unknown or tristated: "
@@ -385,7 +386,7 @@ private:
else if ((nodep->msbConst() > bdtypep->msbMaxSelect())
|| (nodep->lsbConst() > bdtypep->msbMaxSelect())) {
// See also warning in V3Width
nodep->v3error("Selection index out of range: "
nodep->v3warn(SELRANGE, "Selection index out of range: "
<<nodep->msbConst()<<":"<<nodep->lsbConst()
<<" outside "<<bdtypep->msbMaxSelect()<<":0"
<<(bdtypep->lsb()>=0 ? ""
@@ -858,9 +859,9 @@ private:
string name1 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
string name2 = ((string)"__Vconcswap"+cvtToStr(m_modp->varNumGetInc()));
AstVar* temp1p = new AstVar(sel1p->fileline(), AstVarType::BLOCKTEMP, name1,
AstLogicPacked(), msb1-lsb1+1);
VFlagLogicPacked(), msb1-lsb1+1);
AstVar* temp2p = new AstVar(sel2p->fileline(), AstVarType::BLOCKTEMP, name2,
AstLogicPacked(), msb2-lsb2+1);
VFlagLogicPacked(), msb2-lsb2+1);
m_modp->addStmtp(temp1p);
m_modp->addStmtp(temp2p);
AstNodeAssign* asn1ap=nodep->cloneType
@@ -1382,7 +1383,7 @@ private:
break;
}
}
// Pass2, remove dup edges
for (AstNodeSenItem* nextp, * senp = nodep->sensesp()->castNodeSenItem();
senp; senp=nextp) {
@@ -1627,6 +1628,12 @@ private:
}
}
// Simplify
virtual void visit(AstBasicDType* nodep, AstNUser*) {
nodep->iterateChildren(*this);
nodep->cvtRangeConst();
}
//-----
// Jump elimination
@@ -1947,7 +1954,7 @@ public:
PROC_V_EXPENSIVE,
PROC_CPP
};
// CONSTUCTORS
ConstVisitor(ProcMode pmode) {
m_params = false;
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Propagate constants across AST
//
+4 -3
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Netlist (top level) functions
//
@@ -87,7 +88,7 @@ private:
if (prettyName.find("._") != string::npos)
return "Inlined leading underscore";
}
if ((nodep->width()*nodep->arrayElements()) > 256) return "Wide bus/array > 256 bits";
if ((nodep->width()*nodep->dtypep()->arrayElements()) > 256) return "Wide bus/array > 256 bits";
// We allow this, though tracing doesn't
// if (nodep->arrayp(1)) return "Unsupported: Multi-dimensional array";
return NULL;
@@ -193,7 +194,7 @@ private:
const ToggleEnt& above,
AstVar* varp, AstVar* chgVarp) { // Constant
if (AstBasicDType* bdtypep = dtypep->castBasicDType()) {
if (bdtypep->rangep()) {
if (bdtypep->isRanged()) {
for (int index_docs=bdtypep->lsb(); index_docs<bdtypep->msb()+1; index_docs++) {
int index_code = index_docs - bdtypep->lsb();
ToggleEnt newent (above.m_comment+string("[")+cvtToStr(index_docs)+"]",
@@ -216,7 +217,7 @@ private:
ToggleEnt newent (above.m_comment+string("[")+cvtToStr(index_docs)+"]",
new AstArraySel(varp->fileline(), above.m_varRefp->cloneTree(true), index_code),
new AstArraySel(varp->fileline(), above.m_chgRefp->cloneTree(true), index_code));
toggleVarRecurse(adtypep->dtypeSkipRefp(), depth+1,
toggleVarRecurse(adtypep->subDTypep()->skipRefp(), depth+1,
newent,
varp, chgVarp);
newent.cleanup();
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Coverage modules/signals together
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Netlist (top level) functions
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Coverage modules/signals together
//
+26 -10
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Dead code elimination
//
@@ -70,16 +71,16 @@ class DeadVisitor : public AstNVisitor {
private:
// NODE STATE
// Entire Netlist:
// AstNodeModule::user() -> int. Count of number of cells referencing this module.
// AstVar::user() -> int. Count of number of references
// AstVarScope::user() -> int. Count of number of references
// AstNodeModule::user1() -> int. Count of number of cells referencing this module.
// AstVar::user1() -> int. Count of number of references
// AstVarScope::user1() -> int. Count of number of references
AstUser1InUse m_inuser1;
// TYPES
typedef multimap<AstVarScope*,AstNodeAssign*> AssignMap;
// STATE
vector<AstVar*> m_varsp; // List of all encountered to avoid another loop through tree
vector<AstNode*> m_varEtcsp; // List of all encountered to avoid another loop through tree
vector<AstVarScope*> m_vscsp; // List of all encountered to avoid another loop through tree
AssignMap m_assignMap; // List of all simple assignments for each variable
bool m_elimUserVars; // Allow removal of user's vars
@@ -91,14 +92,18 @@ private:
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
return level;
}
void checkAll(AstNode* nodep) {
}
// VISITORS
virtual void visit(AstCell* nodep, AstNUser*) {
nodep->iterateChildren(*this);
checkAll(nodep);
nodep->modp()->user1Inc();
}
virtual void visit(AstNodeVarRef* nodep, AstNUser*) {
nodep->iterateChildren(*this);
checkAll(nodep);
if (nodep->varScopep()) {
nodep->varScopep()->user1Inc();
nodep->varScopep()->varp()->user1Inc();
@@ -112,29 +117,38 @@ private:
}
virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) {
nodep->iterateChildren(*this);
checkAll(nodep);
if (nodep->packagep()) {
nodep->packagep()->user1Inc();
}
}
virtual void visit(AstRefDType* nodep, AstNUser*) {
nodep->iterateChildren(*this);
checkAll(nodep);
if (nodep->packagep()) {
nodep->packagep()->user1Inc();
}
}
virtual void visit(AstEnumItemRef* nodep, AstNUser*) {
nodep->iterateChildren(*this);
checkAll(nodep);
if (nodep->packagep()) {
nodep->packagep()->user1Inc();
}
}
virtual void visit(AstVarScope* nodep, AstNUser*) {
nodep->iterateChildren(*this);
m_vscsp.push_back(nodep);
checkAll(nodep);
if (mightElim(nodep->varp())) {
m_vscsp.push_back(nodep);
}
}
virtual void visit(AstVar* nodep, AstNUser*) {
nodep->iterateChildren(*this);
m_varsp.push_back(nodep);
checkAll(nodep);
if (mightElim(nodep)) {
m_varEtcsp.push_back(nodep);
}
}
virtual void visit(AstNodeAssign* nodep, AstNUser*) {
@@ -150,12 +164,14 @@ private:
} else { // Track like any other statement
nodep->lhsp()->iterateAndNext(*this);
}
checkAll(nodep);
}
//-----
virtual void visit(AstNode* nodep, AstNUser*) {
if (nodep->isOutputter()) m_sideEffect=true;
nodep->iterateChildren(*this);
checkAll(nodep);
}
// METHODS
@@ -180,7 +196,7 @@ private:
}
}
}
bool canElim(AstVar* nodep) {
bool mightElim(AstVar* nodep) {
return (!nodep->isSigPublic() // Can't elim publics!
&& !nodep->isIO()
&& (nodep->isTemp() || nodep->isParam() || m_elimUserVars));
@@ -189,7 +205,7 @@ private:
// Delete any unused varscopes
for (vector<AstVarScope*>::iterator it = m_vscsp.begin(); it!=m_vscsp.end(); ++it) {
AstVarScope* vscp = *it;
if (vscp->user1() == 0 && canElim(vscp->varp())) {
if (vscp->user1() == 0) {
UINFO(4," Dead "<<vscp<<endl);
pair <AssignMap::iterator,AssignMap::iterator> eqrange = m_assignMap.equal_range(vscp);
for (AssignMap::iterator it = eqrange.first; it != eqrange.second; ++it) {
@@ -200,8 +216,8 @@ private:
vscp->unlinkFrBack()->deleteTree(); vscp=NULL;
}
}
for (vector<AstVar*>::iterator it = m_varsp.begin(); it!=m_varsp.end(); ++it) {
if ((*it)->user1() == 0 && canElim((*it))) {
for (vector<AstNode*>::iterator it = m_varEtcsp.begin(); it!=m_varEtcsp.end(); ++it) {
if ((*it)->user1() == 0) {
UINFO(4," Dead "<<(*it)<<endl);
(*it)->unlinkFrBack()->deleteTree(); (*it)=NULL;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Dead branch elimination
//
+58 -40
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add temporaries, such as for delayed nodes
//
@@ -74,14 +75,15 @@ private:
// NODE STATE
// Cleared each module:
// AstVarScope::user1p() -> AstVarScope*. Points to temp var created.
// AstVarScope::user2p() -> AstActive*. Points to activity block of signal
// AstVarScope::user2p() -> AstActive*. Points to activity block of signal (valid when AstVarScope::user1p is valid)
// AstVarScope::user4p() -> AstAlwaysPost*. Post block for this variable
// AstVarScope::user5() -> VarUsage. Tracks delayed vs non-delayed usage
// AstVar::user2() -> bool. Set true if already made warning
// AstVar::user4() -> int. Vector number, for assignment creation
// AstVarRef::user2() -> bool. Set true if already processed
// AstAlwaysPost::user2() -> ActActive*. Points to activity block of signal (valid when AstAlwaysPost::user4p is valid)
// AstAlwaysPost::user4() -> AstIf*. Last IF (__Vdlyvset__) created under this AlwaysPost
// Cleared each scope:
// Cleared each scope/active:
// AstAssignDly::user3() -> AstVarScope*. __Vdlyvset__ created for this assign
// AstAlwaysPost::user3() -> AstVarScope*. __Vdlyvset__ last referenced in IF
AstUser1InUse m_inuser1;
@@ -132,8 +134,8 @@ private:
if (width==0) {
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, oldvarscp->varp());
varp->widthSignedFrom(oldvarscp);
} else {
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, AstLogicPacked(), width);
} else { // Used for vset and dimensions, so can zero init
varp = new AstVar (oldvarscp->fileline(), AstVarType::BLOCKTEMP, name, VFlagBitPacked(), width);
}
addmodp->addStmtp(varp);
m_modVarMap.insert(make_pair(make_pair(addmodp, name), varp));
@@ -144,6 +146,40 @@ private:
return varscp;
}
AstActive* createActivePost(AstVarRef* varrefp) {
AstActive* newactp = new AstActive (varrefp->fileline(), "sequentdly",
m_activep->sensesp());
m_activep->addNext(newactp);
return newactp;
}
void checkActivePost(AstVarRef* varrefp, AstActive* oldactivep) {
// Check for MULTIDRIVEN, and if so make new sentree that joins old & new sentree
if (!oldactivep) varrefp->v3fatalSrc("<= old dly assignment not put under sensitivity block");
if (oldactivep->sensesp() != m_activep->sensesp()) {
if (!varrefp->varp()->fileline()->warnIsOff(V3ErrorCode::MULTIDRIVEN)
&& !varrefp->varp()->user2()) {
varrefp->varp()->v3warn(MULTIDRIVEN,"Signal has multiple driving blocks: "<<varrefp->varp()->prettyName());
varrefp->v3warn(MULTIDRIVEN,"... Location of first driving block");
oldactivep->v3warn(MULTIDRIVEN,"... Location of other driving block");
varrefp->varp()->user2(true);
}
UINFO(4,"AssignDupDlyVar: "<<varrefp<<endl);
UINFO(4," Act: "<<m_activep<<endl);
UINFO(4," Act: "<<oldactivep<<endl);
// Make a new sensitivity list, which is the combination of both blocks
AstNodeSenItem* sena = m_activep->sensesp()->sensesp()->cloneTree(true);
AstNodeSenItem* senb = oldactivep->sensesp()->sensesp()->cloneTree(true);
AstSenTree* treep = new AstSenTree(m_activep->fileline(), sena);
if (senb) treep->addSensesp(senb);
if (AstSenTree* storep = oldactivep->sensesStorep()) {
storep->unlinkFrBack();
pushDeletep(storep);
}
oldactivep->sensesStorep(treep);
oldactivep->sensesp(treep);
}
}
AstNode* createDlyArray(AstAssignDly* nodep, AstNode* lhsp) {
// Create delayed assignment
// See top of this file for transformation
@@ -225,6 +261,7 @@ private:
//
//=== Setting/not setting boolean: __Vdlyvset__
AstVarScope* setvscp;
AstAssignPre* setinitp = NULL;
if (nodep->user3p()) {
// Simplistic optimization. If the previous statement in same scope was also a =>,
@@ -236,11 +273,9 @@ private:
} else { // Create new one
string setvarname = (string("__Vdlyvset__")+oldvarp->shortName()+"__v"+cvtToStr(modVecNum));
setvscp = createVarSc(varrefp->varScopep(), setvarname, 1);
AstAssignPre* setinitp
= new AstAssignPre (nodep->fileline(),
new AstVarRef(nodep->fileline(), setvscp, true),
new AstConst(nodep->fileline(), 0));
m_activep->addStmtsp(setinitp);
setinitp = new AstAssignPre (nodep->fileline(),
new AstVarRef(nodep->fileline(), setvscp, true),
new AstConst(nodep->fileline(), 0));
AstAssign* setassignp
= new AstAssign (nodep->fileline(),
new AstVarRef(nodep->fileline(), setvscp, true),
@@ -269,11 +304,18 @@ private:
UINFO(9," For "<<setvscp<<endl);
UINFO(9," & "<<varrefp<<endl);
AstAlwaysPost* finalp = varrefp->varScopep()->user4p()->castNode()->castAlwaysPost();
if (!finalp) {
if (finalp) {
AstActive* oldactivep = finalp->user2p()->castNode()->castActive();
checkActivePost(varrefp, oldactivep);
if (setinitp) oldactivep->addStmtsp(setinitp);
} else { // first time we've dealt with this memory
finalp = new AstAlwaysPost(nodep->fileline(), NULL/*sens*/, NULL/*body*/);
UINFO(9," Created "<<finalp<<endl);
m_activep->addStmtsp(finalp);
AstActive* newactp = createActivePost(varrefp);
newactp->addStmtsp(finalp);
varrefp->varScopep()->user4p(finalp);
finalp->user2p(newactp);
if (setinitp) newactp->addStmtsp(setinitp);
}
AstIf* postLogicp;
if (finalp->user3p()->castNode() == setvscp) {
@@ -292,7 +334,6 @@ private:
finalp->user4p(postLogicp); // and the associated IF, as we may be able to reuse it
}
postLogicp->addIfsp(new AstAssign(nodep->fileline(), selectsp, valreadp));
return newlhsp;
}
@@ -316,6 +357,7 @@ private:
m_activep = nodep;
bool oldinit = m_inInitial;
m_inInitial = nodep->hasInitial();
AstNode::user3ClearTree(); // Two sets to same variable in different actives must use different vars.
nodep->iterateChildren(*this);
m_inInitial = oldinit;
}
@@ -342,6 +384,7 @@ private:
m_inDly = false;
m_nextDlyp = NULL;
}
virtual void visit(AstVarRef* nodep, AstNUser*) {
if (!nodep->user2Inc()) { // Not done yet
if (m_inDly && nodep->lvalue()) {
@@ -354,30 +397,7 @@ private:
AstVarScope* dlyvscp = oldvscp->user1p()->castNode()->castVarScope();
if (dlyvscp) { // Multiple use of delayed variable
AstActive* oldactivep = dlyvscp->user2p()->castNode()->castActive();
if (!oldactivep) nodep->v3fatalSrc("<= old dly assignment not put under sensitivity block");
if (oldactivep->sensesp() != m_activep->sensesp()) {
if (!nodep->varp()->fileline()->warnIsOff(V3ErrorCode::MULTIDRIVEN)
&& !nodep->varp()->user2()) {
nodep->varp()->v3warn(MULTIDRIVEN,"Signal has multiple driving blocks: "<<nodep->varp()->prettyName());
nodep->v3warn(MULTIDRIVEN,"... Location of first driving block");
oldactivep->v3warn(MULTIDRIVEN,"... Location of other driving block");
nodep->varp()->user2(true);
}
UINFO(4,"AssignDupDlyVar: "<<nodep<<endl);
UINFO(4," Act: "<<m_activep<<endl);
UINFO(4," Act: "<<oldactivep<<endl);
// Make a new sensitivity list, which is the combination of both blocks
AstNodeSenItem* sena = m_activep->sensesp()->sensesp()->cloneTree(true);
AstNodeSenItem* senb = oldactivep->sensesp()->sensesp()->cloneTree(true);
AstSenTree* treep = new AstSenTree(m_activep->fileline(), sena);
if (senb) treep->addSensesp(senb);
if (AstSenTree* storep = oldactivep->sensesStorep()) {
storep->unlinkFrBack();
pushDeletep(storep);
}
oldactivep->sensesStorep(treep);
oldactivep->sensesp(treep);
}
checkActivePost(nodep, oldactivep);
}
if (!dlyvscp) { // First use of this delayed variable
string newvarname = (string("__Vdly__")+nodep->varp()->shortName());
@@ -393,12 +413,10 @@ private:
postp->lhsp()->user2(true); // Don't detect this assignment
oldvscp->user1p(dlyvscp); // So we can find it later
// Make new ACTIVE with identical sensitivity tree
AstActive* newactp = new AstActive (nodep->fileline(), "sequentdly",
m_activep->sensesp());
AstActive* newactp = createActivePost(nodep);
dlyvscp->user2p(newactp);
newactp->addStmtsp(prep); // Add to FRONT of statements
newactp->addStmtsp(postp);
m_activep->addNext(newactp);
dlyvscp->user2p(newactp);
}
AstVarRef* newrefp = new AstVarRef(nodep->fileline(), dlyvscp, true);
newrefp->user2(true); // No reason to do it again
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Pre C-Emit stage changes
//
+3 -1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Prevent very deep expressions
//
@@ -68,7 +69,8 @@ private:
// Width, not widthMin, as we may be in middle of BITSEL expression which
// though it's one bit wide, needs the mask in the upper bits.
// (Someday we'll have a valid bitmask instead of widths....)
AstLogicPacked(), nodep->width());
// See t_func_crc for an example test that requires this
VFlagLogicPacked(), nodep->width());
if (!m_funcp) nodep->v3fatalSrc("Deep expression not under a function");
m_funcp->addInitsp(varp);
// Replace node tree with reference to var
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Prevent very deep expressions
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Prevent very deep expressions
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Prevent very deep expressions
//
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Rename scope references to module-local references
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Rename scope references to module-local references
//
+69 -38
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit C++ for tree
//
@@ -33,7 +34,7 @@
#include "V3EmitC.h"
#include "V3EmitCBase.h"
#define VL_VALUE_STRING_MAX_WIDTH 1024 // We use a static char array in VL_VALUE_STRING
#define VL_VALUE_STRING_MAX_WIDTH 8192 // We use a static char array in VL_VALUE_STRING
//######################################################################
// Emit statements and math operators
@@ -322,7 +323,7 @@ public:
AstVarRef* varrefp = nodep->memp()->castVarRef();
if (!varrefp) { nodep->v3error("Readmem loading non-variable"); }
else if (AstArrayDType* adtypep = varrefp->varp()->dtypeSkipRefp()->castArrayDType()) {
puts(cvtToStr(varrefp->varp()->arrayElements()));
puts(cvtToStr(varrefp->varp()->dtypep()->arrayElements()));
array_lsb = adtypep->lsb();
}
else {
@@ -661,10 +662,10 @@ class EmitCImp : EmitCStmts {
changep->lhsp()->iterateAndNext(*this);
}
else {
AstVarRef* lhsp = changep->lhsp()->castVarRef();
AstVarRef* rhsp = changep->rhsp()->castVarRef();
if (!lhsp) changep->v3fatalSrc("Not ref?");
if (!rhsp) changep->v3fatalSrc("Not ref?");
AstNode* lhsp = changep->lhsp();
AstNode* rhsp = changep->rhsp();
if (!lhsp->castVarRef() && !lhsp->castArraySel()) changep->v3fatalSrc("Not ref?");
if (!rhsp->castVarRef() && !rhsp->castArraySel()) changep->v3fatalSrc("Not ref?");
for (int word=0; word<changep->lhsp()->widthWords(); word++) {
if (!gotOne) {
gotOne = true;
@@ -677,10 +678,10 @@ class EmitCImp : EmitCStmts {
puts(" | (");
}
changep->lhsp()->iterateAndNext(*this);
if (changep->isWide()) puts("["+cvtToStr(word)+"]");
if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]");
puts(" ^ ");
changep->rhsp()->iterateAndNext(*this);
if (changep->isWide()) puts("["+cvtToStr(word)+"]");
if (changep->lhsp()->isWide()) puts("["+cvtToStr(word)+"]");
puts(")");
}
}
@@ -872,9 +873,6 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
if (nodep->isIO()) {
bool isArray = !nodep->dtypeSkipRefp()->castBasicDType();
if (nodep->isSc()) {
if (isArray) {
nodep->v3error("Unsupported: SystemC inputs and outputs must be simple data types; no arrays");
}
m_ctorVarsVec.push_back(nodep);
ofp()->putAlign(nodep->isStatic(), 4); // sc stuff is a structure, so bigger alignment
if (nodep->attrScClocked() && nodep->isInput()) {
@@ -889,6 +887,12 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
puts(">\t");
}
puts(nodep->name());
if (isArray) {
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
puts("["+cvtToStr(arrayp->elementsConst())+"]");
}
}
puts(";\n");
} else { // C++ signals
ofp()->putAlign(nodep->isStatic(), nodep->dtypeSkipRefp()->widthAlignBytes(),
@@ -905,7 +909,8 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
if (isArray) {
if (nodep->isWide()) puts("W");
puts("("+nodep->name());
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp; arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
puts("["+cvtToStr(arrayp->elementsConst())+"]");
}
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
@@ -926,7 +931,8 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
// strings and other fundamental c types
puts(nodep->vlArgType(true,false));
// This isn't very robust and may need cleanup for other data types
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp; arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
puts("["+cvtToStr(arrayp->elementsConst())+"]");
}
puts(";\n");
@@ -951,7 +957,8 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
if (prefixIfImp!="") { puts(prefixIfImp); puts("::"); }
puts(nodep->name());
// This isn't very robust and may need cleanup for other data types
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp; arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
puts("["+cvtToStr(arrayp->elementsConst())+"]");
}
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
@@ -961,22 +968,29 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
}
void EmitCStmts::emitVarCtors() {
ofp()->indentInc();
bool first = true;
for (vector<AstVar*>::iterator it = m_ctorVarsVec.begin(); it != m_ctorVarsVec.end(); ++it) {
if (first) {
first=false;
puts("\n");
puts("#if (SYSTEMC_VERSION>20011000)\n"); // SystemC 2.0.1 and newer
puts(" : ");
if (!m_ctorVarsVec.empty()) {
ofp()->indentInc();
puts("\n");
puts("#if (SYSTEMC_VERSION>20011000)\n"); // SystemC 2.0.1 and newer
bool first = true;
for (vector<AstVar*>::iterator it = m_ctorVarsVec.begin(); it != m_ctorVarsVec.end(); ++it) {
AstVar* varp = *it;
bool isArray = !varp->dtypeSkipRefp()->castBasicDType();
if (isArray) {
puts("// Skipping array: ");
puts(varp->name());
puts("\n");
} else {
if (first) { puts(" : "); first=false; }
else puts(", ");
if (ofp()->exceededWidth()) puts("\n ");
puts(varp->name());
puts("("); putsQuoted(varp->name()); puts(")");
}
}
else puts(", ");
if (ofp()->exceededWidth()) puts("\n ");
puts((*it)->name());
puts("("); putsQuoted((*it)->name()); puts(")");
puts ("\n#endif\n");
ofp()->indentDec();
}
if (!first) puts ("\n#endif\n");
ofp()->indentDec();
}
bool EmitCStmts::emitSimpleOk(AstNodeMath* nodep) {
@@ -1049,7 +1063,7 @@ void EmitCStmts::emitOpName(AstNode* nodep, const string& format,
++pos;
switch (pos[0]) {
case 'q': emitIQW(detailp); break;
case 'w':
case 'w':
COMMA;
puts(cvtToStr(detailp->widthMin()));
needComma = true;
@@ -1182,7 +1196,7 @@ void EmitCStmts::displayArg(AstNode* dispp, AstNode** elistp, bool isScan,
return;
}
if (argp->widthMin() > VL_VALUE_STRING_MAX_WIDTH) {
dispp->v3error("Exceeded limit of 1024 bits for any display arguments");
dispp->v3error("Exceeded limit of "+cvtToStr(VL_VALUE_STRING_MAX_WIDTH)+" bits for any display arguments");
}
if (argp && argp->isWide()
&& (fmtLetter=='d'||fmtLetter=='u')) {
@@ -1327,7 +1341,7 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
int vects = 0;
// This isn't very robust and may need cleanup for other data types
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
int vecnum = vects++;
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
string ivar = string("__Vi")+cvtToStr(vecnum);
@@ -1353,7 +1367,7 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
puts(varp->name());
for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
if (zeroit) {
puts("= 0;\n");
puts(" = 0;\n");
} else {
puts(" = VL_RAND_RESET_");
emitIQW(varp);
@@ -1500,7 +1514,22 @@ void EmitCImp::emitSensitives() {
for (AstNode* nodep=m_modp->stmtsp(); nodep; nodep = nodep->nextp()) {
if (AstVar* varp = nodep->castVar()) {
if (varp->isInput() && (varp->isScSensitive() || varp->isUsedClock())) {
puts("sensitive << "+varp->name()+";\n");
int vects = 0;
// This isn't very robust and may need cleanup for other data types
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
int vecnum = vects++;
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
string ivar = string("__Vi")+cvtToStr(vecnum);
// MSVC++ pre V7 doesn't support 'for (int ...)', so declare in sep block
puts("{ int __Vi"+cvtToStr(vecnum)+"="+cvtToStr(arrayp->lsb())+";");
puts(" for (; "+ivar+"<="+cvtToStr(arrayp->msb()));
puts("; ++"+ivar+") {\n");
}
puts("sensitive << "+varp->name());
for (int v=0; v<vects; ++v) puts( "[__Vi"+cvtToStr(v)+"]");
puts(";\n");
for (int v=0; v<vects; ++v) puts( "}}\n");
}
}
}
@@ -2048,7 +2077,7 @@ class EmitCTrace : EmitCStmts {
puts("vcdp->declArray");
} else if (nodep->isQuad()) {
puts("vcdp->declQuad ");
} else if (nodep->msbEndianed() || nodep->lsbEndianed()) {
} else if (nodep->left() || nodep->right()) {
puts("vcdp->declBus ");
} else {
puts("vcdp->declBit ");
@@ -2062,8 +2091,9 @@ class EmitCTrace : EmitCStmts {
} else {
puts(",-1");
}
if (nodep->msbEndianed() || nodep->lsbEndianed()) {
puts(","+cvtToStr(nodep->msbEndianed())+","+cvtToStr(nodep->lsbEndianed()));
if (!nodep->isDouble() // When float/double no longer have widths this can go
&& (nodep->left() || nodep->right())) {
puts(","+cvtToStr(nodep->left())+","+cvtToStr(nodep->right()));
}
puts(");");
}
@@ -2079,7 +2109,7 @@ class EmitCTrace : EmitCStmts {
puts("vcdp->"+full+"Array");
} else if (nodep->isQuad()) {
puts("vcdp->"+full+"Quad ");
} else if (nodep->declp()->msbEndianed() || nodep->declp()->lsbEndianed()) {
} else if (nodep->declp()->left() || nodep->declp()->right()) {
puts("vcdp->"+full+"Bus ");
} else {
puts("vcdp->"+full+"Bit ");
@@ -2088,7 +2118,8 @@ class EmitCTrace : EmitCStmts {
+ ((arrayindex<0) ? 0 : (arrayindex*nodep->declp()->widthWords()))));
puts(",");
emitTraceValue(nodep, arrayindex);
if (nodep->declp()->msbEndianed() || nodep->declp()->lsbEndianed() || emitTraceIsScBv(nodep)) {
if (!nodep->isDouble() // When float/double no longer have widths this can go
&& (nodep->declp()->left() || nodep->declp()->right() || emitTraceIsScBv(nodep))) {
puts(","+cvtToStr(nodep->declp()->widthMin()));
}
puts(");\n");
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit C++ code for module tree
//
+1 -69
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit C++ for tree
//
@@ -34,74 +34,6 @@
#include "V3File.h"
#include "V3Ast.h"
//######################################################################
// V3OutCFile: A class for abstracting out SystemC/C++ details
class V3OutCFile : public V3OutFile {
int m_private;
public:
V3OutCFile(const string& filename) : V3OutFile(filename) {
resetPrivate();
}
virtual ~V3OutCFile() {}
virtual void putsCellDecl(const string& classname, const string& cellname) {
this->printf("%-19s\t%s;\n",
(classname + "*").c_str(),cellname.c_str());
}
virtual void putsHeader() { puts("// Verilated -*- C++ -*-\n"); }
virtual void putsIntTopInclude() { }
// Print out public/privates
void resetPrivate() { m_private = 0; }
void putsPrivate(bool setPrivate) {
if (setPrivate && m_private!=1) {
puts("private:\n");
m_private = 1;
} else if (!setPrivate && m_private!=2) {
puts("public:\n");
m_private = 2;
}
}
};
class V3OutScFile : public V3OutCFile {
public:
V3OutScFile(const string& filename) : V3OutCFile(filename) {}
virtual ~V3OutScFile() {}
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
virtual void putsIntTopInclude() {
puts("#include \"systemc.h\"\n");
puts("#include \"verilated_sc.h\"\n");
}
};
class V3OutSpFile : public V3OutCFile {
public:
V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
virtual ~V3OutSpFile() {}
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
virtual void putsIntTopInclude() {
puts("#include \"systemperl.h\"\n");
puts("#include \"verilated_sc.h\"\n");
}
};
class V3OutVFile : public V3OutFile {
public:
V3OutVFile(const string& filename) : V3OutFile(filename) {}
virtual ~V3OutVFile() {}
virtual void putsHeader() { puts("// Verilated -*- Verilog -*-\n"); }
};
class V3OutMkFile : public V3OutFile {
public:
V3OutMkFile(const string& filename) : V3OutFile(filename) {}
virtual ~V3OutMkFile() {}
virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); }
// No automatic indentation yet.
void puts(const char* strg) { putsNoTracking(strg); }
void puts(const string& strg) { putsNoTracking(strg); }
};
//######################################################################
// Base Visitor class -- holds output file pointer
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit C++ for tree
//
+7 -6
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit C++ for tree
//
@@ -453,9 +454,9 @@ void EmitCSyms::emitSymImp() {
string bounds;
if (AstBasicDType* basicp = varp->basicp()) {
// Range is always first, it's not in "C" order
if (basicp->rangep()) {
bounds += " ,"; bounds += cvtToStr(basicp->rangep()->msbConst());
bounds += ","; bounds += cvtToStr(basicp->rangep()->lsbConst());
if (basicp->isRanged()) {
bounds += " ,"; bounds += cvtToStr(basicp->msb());
bounds += ","; bounds += cvtToStr(basicp->lsb());
dim++;
}
for (AstNodeDType* dtypep=varp->dtypep(); dtypep; ) {
@@ -464,7 +465,7 @@ void EmitCSyms::emitSymImp() {
bounds += " ,"; bounds += cvtToStr(adtypep->arrayp()->msbConst());
bounds += ","; bounds += cvtToStr(adtypep->arrayp()->lsbConst());
dim++;
dtypep = adtypep->dtypep();
dtypep = adtypep->subDTypep();
}
else break; // AstBasicDType - nothing below, 1
}
@@ -525,7 +526,7 @@ void EmitCSyms::emitDpiHdr() {
puts("extern \"C\" {\n");
puts("#endif\n");
puts("\n");
int firstExp = 0;
int firstImp = 0;
for (vector<AstCFunc*>::iterator it = m_dpis.begin(); it != m_dpis.end(); ++it) {
@@ -571,7 +572,7 @@ void EmitCSyms::emitDpiImp() {
puts("// or 2. Compile all __Dpi.cpp files in the same compiler run,\n");
puts("// and #ifdefs already inserted here will sort everything out.\n");
puts("\n");
puts("#include \""+topClassName()+"__Dpi.h\"\n");
puts("#include \""+topClassName()+".h\"\n");
puts("\n");
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit Makefile
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit Makefile
//
+15 -8
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit Verilog from tree
//
@@ -61,7 +62,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
putsNoTracking(AstNode::quoteName(str));
putsNoTracking("\"");
}
// VISITORS
virtual void visit(AstNetlist* nodep, AstNUser*) {
nodep->iterateChildren(*this);
@@ -447,11 +448,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
puts("[");
if (nodep->msbp()->castConst() && nodep->lsbp()->castConst()) {
// Looks nicer if we print [1:0] rather than [32'sh1:32sh0]
puts(cvtToStr(nodep->msbEndianedp()->castConst()->toSInt())); puts(":");
puts(cvtToStr(nodep->lsbEndianedp()->castConst()->toSInt())); puts("]");
puts(cvtToStr(nodep->leftp()->castConst()->toSInt())); puts(":");
puts(cvtToStr(nodep->rightp()->castConst()->toSInt())); puts("]");
} else {
nodep->msbEndianedp()->iterateAndNext(*this); puts(":");
nodep->lsbEndianedp()->iterateAndNext(*this); puts("]");
nodep->leftp()->iterateAndNext(*this); puts(":");
nodep->rightp()->iterateAndNext(*this); puts("]");
}
}
virtual void visit(AstSel* nodep, AstNUser*) {
@@ -486,10 +487,15 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
if (nodep->isSigned()) putfs(nodep,"signed ");
putfs(nodep,nodep->prettyName());
if (nodep->rangep()) { puts(" "); nodep->rangep()->iterateAndNext(*this); puts(" "); }
else if (nodep->isRanged()) { puts(" ["); puts(cvtToStr(nodep->msb())); puts(":0] "); }
}
virtual void visit(AstConstDType* nodep, AstNUser*) {
putfs(nodep,"const ");
nodep->dtypep()->iterateAndNext(*this);
nodep->subDTypep()->iterateAndNext(*this);
}
virtual void visit(AstArrayDType* nodep, AstNUser*) {
nodep->subDTypep()->iterateAndNext(*this);
nodep->arrayp()->iterateAndNext(*this);
}
virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) {
if (nodep->dotted()!="") { putfs(nodep,nodep->dotted()); puts("."); puts(nodep->prettyName()); }
@@ -595,7 +601,7 @@ class EmitVStreamVisitor : public EmitVBaseVisitor {
virtual void putbs(const string& str) { puts(str); }
virtual void putfs(AstNode*, const string& str) { putbs(str); }
virtual void putqs(AstNode*, const string& str) { putbs(str); }
public:
public:
EmitVStreamVisitor(AstNode* nodep, ostream& os)
: m_os(os) {
nodep->accept(*this);
@@ -634,7 +640,8 @@ public:
FileLine* prefixFl() const { return m_prefixFl; }
int column() const { return m_column; }
EmitVPrefixedFormatter(ostream& os, const string& prefix, int flWidth)
: V3OutFormatter("__STREAM", true), m_os(os), m_prefix(prefix), m_flWidth(flWidth) {
: V3OutFormatter("__STREAM", V3OutFormatter::LA_VERILOG)
, m_os(os), m_prefix(prefix), m_flWidth(flWidth) {
m_column = 0;
m_prefixFl = v3Global.rootp()->fileline(); // NETLIST's fileline instead of NULL to avoid NULL checks
}
+1 -1
View File
@@ -1,4 +1,4 @@
//-*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit Verilog code for module tree
//
+197
View File
@@ -0,0 +1,197 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit Verilog from tree
//
// Code available from: http://www.veripool.org/verilator
//
// AUTHORS: Wilson Snyder with Paul Wasson, Duane Gabli
//
//*************************************************************************
//
// Copyright 2004-2012 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
//
// Verilator is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//*************************************************************************
#include "config_build.h"
#include "verilatedos.h"
#include <cstdio>
#include <cstdarg>
#include <unistd.h>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include "V3Global.h"
#include "V3EmitXml.h"
#include "V3EmitCBase.h"
//######################################################################
// Emit statements and math operators
class EmitXmlFileVisitor : public EmitCBaseVisitor {
// MEMBERS
V3OutFile* m_ofp;
// METHODS
static int debug() {
static int level = -1;
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
return level;
}
// Outfile methods
V3OutFile* ofp() const { return m_ofp; }
virtual void puts(const string& str) { ofp()->puts(str); }
virtual void putbs(const string& str) { ofp()->putbs(str); }
virtual void putfs(AstNode*, const string& str) { putbs(str); }
virtual void putqs(AstNode*, const string& str) { putbs(str); }
virtual void putsNoTracking(const string& str) { ofp()->putsNoTracking(str); }
virtual void putsQuoted(const string& str) {
// Quote \ and " for use inside C programs
// Don't use to quote a filename for #include - #include doesn't \ escape.
// Duplicate in V3File - here so we can print to string
putsNoTracking("\"");
putsNoTracking(AstNode::quoteName(str));
putsNoTracking("\"");
}
// XML methods
void outputTag(AstNode* nodep, string tag) {
if (tag=="") tag = V3Options::downcase(nodep->typeName());
puts("<"+tag+" "+nodep->fileline()->xml());
if (nodep->name()!="") { puts(" name="); putsQuoted(nodep->prettyName()); }
}
void outputChildrenEnd(AstNode* nodep, string tag) {
if (tag=="") tag = V3Options::downcase(nodep->typeName());
if (nodep->op1p() || nodep->op2p() || nodep->op3p() || nodep->op4p()) {
puts(">\n");
nodep->iterateChildren(*this);
puts("</"+tag+">\n");
} else {
puts("/>\n");
}
}
// VISITORS
virtual void visit(AstNetlist* nodep, AstNUser*) {
puts("<netlist>\n");
nodep->iterateChildren(*this);
puts("</netlist>\n");
}
virtual void visit(AstNodeModule* nodep, AstNUser*) {
outputTag(nodep, "");
if (nodep->level()==1 || nodep->level()==2) // ==2 because we don't add wrapper when in XML mode
puts(" topModule=\"1\""); // IEEE vpiTopModule
outputChildrenEnd(nodep, "");
}
virtual void visit(AstCell* nodep, AstNUser*) {
outputTag(nodep, "instance"); // IEEE: vpiInstance
puts(" defName="); putsQuoted(nodep->modName()); // IEEE vpiDefName
outputChildrenEnd(nodep, "instance");
}
virtual void visit(AstPin* nodep, AstNUser*) {
// What we call a pin in verilator is a port in the IEEE spec.
outputTag(nodep, "port"); // IEEE: vpiPort
if (nodep->modVarp()->isInOnly())
puts(" direction=\"in\"");
else if (nodep->modVarp()->isOutOnly())
puts(" direction=\"out\"");
else puts(" direction=\"inout\"");
puts(" portIndex=\""+cvtToStr(nodep->pinNum())+"\""); // IEEE: vpiPortIndex
// Children includes vpiHighConn and vpiLowConn; we don't support port bits (yet?)
outputChildrenEnd(nodep, "port");
}
virtual void visit(AstAssignW* nodep, AstNUser*) {
outputTag(nodep, "contAssign"); // IEEE: vpiContAssign
outputChildrenEnd(nodep, "contAssign");
}
// Data types
virtual void visit(AstBasicDType* nodep, AstNUser*) {
outputTag(nodep, "basicDType ");
if (nodep->isRanged()) {
puts(" left=\""+cvtToStr(nodep->left())+"\"");
puts(" right=\""+cvtToStr(nodep->right())+"\"");
}
puts("/>\n");
}
// Default
virtual void visit(AstNode* nodep, AstNUser*) {
outputTag(nodep, "");
outputChildrenEnd(nodep, "");
}
public:
EmitXmlFileVisitor(AstNode* nodep, V3OutFile* ofp) {
m_ofp = ofp;
nodep->accept(*this);
}
virtual ~EmitXmlFileVisitor() {}
};
//######################################################################
// Emit to a stream (perhaps stringstream)
class EmitXmlPrefixedFormatter : public V3OutFormatter {
ostream& m_os;
string m_prefix; // What to print at beginning of each line
int m_flWidth; // Padding of fileline
int m_column; // Rough location; need just zero or non-zero
FileLine* m_prefixFl;
// METHODS
virtual void putcOutput(char chr) {
if (chr == '\n') {
m_column = 0;
m_os<<chr;
} else {
if (m_column == 0) {
m_column = 10;
m_os<<m_prefixFl->ascii()+":";
m_os<<V3OutFile::indentSpaces(m_flWidth-(m_prefixFl->ascii().length()+1));
m_os<<" ";
m_os<<m_prefix;
}
m_column++;
m_os<<chr;
}
}
public:
void prefixFl(FileLine* fl) { m_prefixFl = fl; }
FileLine* prefixFl() const { return m_prefixFl; }
int column() const { return m_column; }
EmitXmlPrefixedFormatter(ostream& os, const string& prefix, int flWidth)
: V3OutFormatter("__STREAM", V3OutFormatter::LA_VERILOG)
, m_os(os), m_prefix(prefix), m_flWidth(flWidth) {
m_column = 0;
m_prefixFl = v3Global.rootp()->fileline(); // NETLIST's fileline instead of NULL to avoid NULL checks
}
virtual ~EmitXmlPrefixedFormatter() {}
};
//######################################################################
// EmitXml class functions
void V3EmitXml::emitxml() {
UINFO(2,__FUNCTION__<<": "<<endl);
// All-in-one file
V3OutXmlFile of (v3Global.opt.makeDir()+"/"+v3Global.opt.prefix()+".xml");
of.putsHeader();
of.puts("<!-- DESCR" "IPTION: Verilator output: XML representation of netlist -->\n");
of.puts("<verilator_xml>\n");
{
stringstream sstr;
FileLine::fileNameNumMapDumpXml(sstr);
of.puts(sstr.str());
}
EmitXmlFileVisitor visitor (v3Global.rootp(), &of);
of.puts("</verilator_xml>\n");
}
+37
View File
@@ -0,0 +1,37 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Emit XML code
//
// Code available from: http://www.veripool.org/verilator
//
// AUTHORS: Wilson Snyder with Paul Wasson, Duane Gabli
//
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
//
// Verilator is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//*************************************************************************
#ifndef _V3EMITXML_H_
#define _V3EMITXML_H_ 1
#include "config_build.h"
#include "verilatedos.h"
#include "V3Error.h"
#include "V3Ast.h"
//============================================================================
class V3EmitXml {
public:
static void emitxml();
};
#endif // Guard
+23 -14
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Error handling
//
@@ -67,11 +68,24 @@ V3ErrorCode::V3ErrorCode(const char* msgp) {
//######################################################################
// FileLineSingleton class functions
const string FileLineSingleton::filenameLetters(int no) {
const int size = 1 + (64 / 4); // Each letter retires more than 4 bits of a > 64 bit number
char out[size];
char* op = out+size-1;
*--op = '\0'; // We build backwards
int num = no;
do {
*--op = 'a'+num%26;
num /= 26;
} while (num);
return op;
}
int FileLineSingleton::nameToNumber(const string& filename) {
// Convert filenames to a filenameno
// This lets us assign a nice small identifier for debug messages, but more
// importantly lets us use a 4 byte int instead of 8 byte pointer in every FileLine.
map<string,int>::const_iterator iter = m_namemap.find(filename);
FileNameNumMap::const_iterator iter = m_namemap.find(filename);
if (VL_LIKELY(iter != m_namemap.end())) return iter->second;
int num = m_names.size();
m_names.push_back(filename);
@@ -79,6 +93,14 @@ int FileLineSingleton::nameToNumber(const string& filename) {
return num;
}
void FileLineSingleton::fileNameNumMapDumpXml(ostream& os) {
os<<"<files>\n";
for (FileNameNumMap::const_iterator it = m_namemap.begin(); it != m_namemap.end(); ++it) {
os<<"<file id=\""<<filenameLetters(it->second)<<"\" filename=\""<<it->first<<"\"/>\n";
}
os<<"</files>\n";
}
//######################################################################
// FileLine class functions
@@ -94,19 +116,6 @@ FileLine::FileLine(FileLine::EmptySecret) {
}
}
const string FileLine::filenameLetters() const {
const int size = 1 + (64 / 4); // Each letter retires more than 4 bits of a > 64 bit number
char out[size];
char* op = out+size-1;
*--op = '\0'; // We build backwards
int num = m_filenameno;
do {
*--op = 'a'+num%26;
num /= 26;
} while (num);
return op;
}
string FileLine::lineDirectiveStrg(int enterExit) const {
char numbuf[20]; sprintf(numbuf, "%d", lineno());
char levelbuf[20]; sprintf(levelbuf, "%d", enterExit);
+19 -8
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Error handling
//
@@ -69,6 +69,7 @@ public:
COMBDLY, // Combinatorial delayed assignment
DEFPARAM, // Style: Defparam
DECLFILENAME, // Declaration doesn't match filename
ENDLABEL, // End lable name mismatch
GENCLK, // Generated Clock
IFDEPTH, // If statements too deep
IMPERFECTSCH, // Imperfect schedule (disabled by default)
@@ -80,6 +81,7 @@ public:
MULTIDRIVEN, // Driven from multiple blocks
REALCVT, // Real conversion
REDEFMACRO, // Redefining existing define macro
SELRANGE, // Selection index out of range
STMTDLY, // Delayed statement
SYMRSVDWORD, // Symbol is Reserved Word
SYNCASYNCNET, // Mixed sync + async reset
@@ -114,12 +116,12 @@ public:
"BLKANDNBLK", "BLKSEQ",
"CASEINCOMPLETE", "CASEOVERLAP", "CASEWITHX", "CASEX", "CDCRSTLOGIC", "CMPCONST",
"COMBDLY", "DEFPARAM", "DECLFILENAME",
"GENCLK",
"ENDLABEL", "GENCLK",
"IFDEPTH", "IMPERFECTSCH", "IMPLICIT", "IMPURE", "INCABSPATH",
"LITENDIAN", "MODDUP",
"MULTIDRIVEN",
"REALCVT", "REDEFMACRO",
"STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
"SELRANGE", "STMTDLY", "SYMRSVDWORD", "SYNCASYNCNET",
"UNDRIVEN", "UNOPT", "UNOPTFLAT", "UNSIGNED", "UNUSED",
"VARHIDDEN", "WIDTH", "WIDTHCONCAT",
" MAX"
@@ -141,6 +143,7 @@ public:
bool lintError() const { return ( m_e==CASEINCOMPLETE || m_e==CASEOVERLAP
|| m_e==CASEWITHX || m_e==CASEX
|| m_e==CMPCONST
|| m_e==ENDLABEL
|| m_e==IMPLICIT
|| m_e==LITENDIAN
|| m_e==REALCVT
@@ -242,10 +245,10 @@ template< class T> std::string cvtToStr (const T& t) {
ostringstream os; os<<t; return os.str();
}
inline uint32_t cvtToHash(void* vp) {
inline uint32_t cvtToHash(const void* vp) {
// We can shove a 64 bit pointer into a 32 bit bucket
// On 32 bit systems, lower is always 0, but who cares?
union { void* up; struct {uint32_t upper; uint32_t lower;} l;} u;
union { const void* up; struct {uint32_t upper; uint32_t lower;} l;} u;
u.l.upper=0; u.l.lower=0; u.up=vp;
return u.l.upper^u.l.lower;
}
@@ -255,7 +258,10 @@ inline uint32_t cvtToHash(void* vp) {
class FileLine;
class FileLineSingleton {
map<string,int> m_namemap; // filenameno for each filename
// TYPES
typedef map<string,int> FileNameNumMap;
// MEMBERS
FileNameNumMap m_namemap; // filenameno for each filename
deque<string> m_names; // filename text for each filenameno
// COSNTRUCTORS
FileLineSingleton() { }
@@ -266,6 +272,8 @@ protected:
int nameToNumber(const string& filename);
const string numberToName(int filenameno) const { return m_names[filenameno]; }
void clear() { m_namemap.clear(); m_names.clear(); }
void fileNameNumMapDumpXml(ostream& os);
static const string filenameLetters(int fileno);
};
class FileLine {
@@ -317,10 +325,11 @@ public:
int lineno () const { return m_lineno; }
string ascii() const;
const string filename () const { return singleton().numberToName(m_filenameno); }
const string filenameLetters() const;
const string filenameLetters() const { return singleton().filenameLetters(m_filenameno); }
const string filebasename () const;
const string filebasenameNoExt () const;
const string profileFuncname() const;
const string xml() const { return "fl=\""+filenameLetters()+cvtToStr(lineno())+"\""; }
string lineDirectiveStrg(int enter_exit_level) const;
void warnOn(V3ErrorCode code, bool flag) { m_warnOn.set(code,flag); } // Turn on/off warning messages on this line.
void warnOff(V3ErrorCode code, bool flag) { warnOn(code,!flag); }
@@ -346,13 +355,15 @@ public:
defaultFileLine().warnOff(code, flag); }
static bool globalWarnOff(const string& code, bool flag) {
return defaultFileLine().warnOff(code, flag); }
static void fileNameNumMapDumpXml(ostream& os) {
singleton().fileNameNumMapDumpXml(os); }
// METHODS - Called from netlist
// Merge warning disables from another fileline
void modifyStateInherit(const FileLine* fromp);
// Change the current fileline due to actions discovered after parsing
// and may have side effects on other nodes sharing this FileLine.
// Use only when this is intended
// Use only when this is intended
void modifyWarnOff(V3ErrorCode code, bool flag) { warnOff(code,flag); }
// OPERATORS
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Add temporaries, such as for expand nodes
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Expansion of wide operator macros to C operators
//
+36 -16
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: File stream wrapper that understands indentation
//
@@ -436,7 +437,7 @@ private:
dup2(fd_stdout[P_WR], 1);
// And stderr comes from parent
execl("/bin/sh", "sh", "-c", command.c_str(), NULL);
execl("/bin/sh", "sh", "-c", command.c_str(), (char*)NULL);
// Don't use v3fatal, we don't share the common structures any more
fprintf(stderr,"--pipe-filter: exec failed: %s\n",strerror(errno));
_exit(10);
@@ -546,8 +547,8 @@ 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, bool verilog)
: m_filename(filename), m_verilog(verilog)
V3OutFormatter::V3OutFormatter(const string& filename, V3OutFormatter::Language lang)
: m_filename(filename), m_lang(lang)
, m_lineno(1), m_column(0)
, m_nobreak(false), m_prependIndent(true), m_indentLevel(0)
, m_declSAlign(0), m_declNSAlign(0), m_declPadNum(0) {
@@ -560,7 +561,7 @@ const char* V3OutFormatter::indentStr(int num) {
static char str[MAXSPACE+20];
char* cp = str;
if (num>MAXSPACE) num=MAXSPACE;
if (!m_verilog) { // verilogPrefixedTree doesn't want tabs
if (!m_lang==LA_VERILOG) { // verilogPrefixedTree doesn't want tabs
while (num>=8) {
*cp++ = '\t';
num -= 8;
@@ -625,8 +626,13 @@ int V3OutFormatter::endLevels (const char *strg) {
case ')':
levels-=INDBLK;
break;
case '<':
if (m_lang==LA_XML) {
if (cp[1] == '/') levels-=INDBLK;
}
break;
case 'e':
if (m_verilog && tokenEnd(cp)) {
if (m_lang==LA_VERILOG && tokenEnd(cp)) {
levels-=INDBLK;
}
break;
@@ -668,39 +674,53 @@ void V3OutFormatter::puts (const char *strg) {
case '{':
indentInc();
break;
case '}':
indentDec();
break;
case '(':
indentInc();
m_parenVec.push(m_column);
break;
case '}':
indentDec();
break;
case ')':
if (!m_parenVec.empty()) m_parenVec.pop();
indentDec();
break;
case '<':
if (m_lang==LA_XML) {
if (cp[1] == '/') {} // Zero as the > will result in net decrease by one
else if (cp[1] == '!' || cp[1] == '?') { indentInc(); } // net same indent
else { indentInc(); indentInc(); } // net increase by one
}
break;
case '>':
if (m_lang==LA_XML) {
indentDec();
if (cp>strg && cp[-1]=='/') indentDec(); // < ..... /> stays same level
}
break;
case 'b':
if (wordstart && m_verilog && tokenStart(cp,"begin")) {
if (wordstart && m_lang==LA_VERILOG && tokenStart(cp,"begin")) {
indentInc();
}
wordstart = false;
break;
case 'c':
if (wordstart && m_verilog && (tokenStart(cp,"case")
|| tokenStart(cp,"casex")
|| tokenStart(cp,"casez"))) {
if (wordstart && m_lang==LA_VERILOG
&& (tokenStart(cp,"case")
|| tokenStart(cp,"casex")
|| tokenStart(cp,"casez"))) {
indentInc();
}
wordstart = false;
break;
case 'e':
if (wordstart && m_verilog && tokenEnd(cp)) {
if (wordstart && m_lang==LA_VERILOG && tokenEnd(cp)) {
indentDec();
}
wordstart = false;
break;
case 'm':
if (wordstart && m_verilog && tokenStart(cp,"module")) {
if (wordstart && m_lang==LA_VERILOG && tokenStart(cp,"module")) {
indentInc();
}
wordstart = false;
@@ -801,8 +821,8 @@ void V3OutFormatter::printf (const char *fmt...) {
//######################################################################
// V3OutFormatter: A class for printing to a file, with automatic indentation of C++ code.
V3OutFile::V3OutFile(const string& filename)
: V3OutFormatter(filename, false) {
V3OutFile::V3OutFile(const string& filename, V3OutFormatter::Language lang)
: V3OutFormatter(filename, lang) {
if ((m_fp = V3File::new_fopen_w(filename.c_str())) == NULL) {
v3fatal("Cannot write "<<filename);
}
+86 -5
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: File stream wrapper that understands indentation
//
@@ -84,7 +84,7 @@ public:
typedef list<string> StrList;
// METHODS
// Read file contents and return it. Return true on success.
// Read file contents and return it. Return true on success.
bool readWholefile(const string& filename, StrList& outl);
// CONSTRUCTORS
@@ -105,11 +105,17 @@ public:
enum AlignClass {
AL_AUTO = 0,
AL_STATIC = 1};
enum Language {
LA_C = 0,
LA_VERILOG = 1,
LA_MK = 2,
LA_XML = 3,
};
private:
// MEMBERS
string m_filename;
bool m_verilog; // Indenting Verilog code
Language m_lang; // Indenting Verilog code
int m_lineno;
int m_column;
int m_nobreak; // Basic operator or begin paren, don't break next
@@ -125,7 +131,7 @@ private:
void putcNoTracking(char chr);
public:
V3OutFormatter(const string& filename, bool verilog);
V3OutFormatter(const string& filename, Language lang);
virtual ~V3OutFormatter() {}
// ACCESSORS
int column() const { return m_column; }
@@ -166,11 +172,86 @@ class V3OutFile : public V3OutFormatter {
// MEMBERS
FILE* m_fp;
public:
V3OutFile(const string& filename);
V3OutFile(const string& filename, V3OutFormatter::Language lang);
virtual ~V3OutFile();
private:
// CALLBACKS
virtual void putcOutput(char chr) { fputc(chr, m_fp); }
};
//######################################################################
// V3OutCFile: A class for abstracting out SystemC/C++ details
class V3OutCFile : public V3OutFile {
int m_private;
public:
V3OutCFile(const string& filename) : V3OutFile(filename, V3OutFormatter::LA_C) {
resetPrivate();
}
virtual ~V3OutCFile() {}
virtual void putsCellDecl(const string& classname, const string& cellname) {
this->printf("%-19s\t%s;\n",
(classname + "*").c_str(),cellname.c_str());
}
virtual void putsHeader() { puts("// Verilated -*- C++ -*-\n"); }
virtual void putsIntTopInclude() { }
// Print out public/privates
void resetPrivate() { m_private = 0; }
void putsPrivate(bool setPrivate) {
if (setPrivate && m_private!=1) {
puts("private:\n");
m_private = 1;
} else if (!setPrivate && m_private!=2) {
puts("public:\n");
m_private = 2;
}
}
};
class V3OutScFile : public V3OutCFile {
public:
V3OutScFile(const string& filename) : V3OutCFile(filename) {}
virtual ~V3OutScFile() {}
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
virtual void putsIntTopInclude() {
puts("#include \"systemc.h\"\n");
puts("#include \"verilated_sc.h\"\n");
}
};
class V3OutSpFile : public V3OutCFile {
public:
V3OutSpFile(const string& filename) : V3OutCFile(filename) {}
virtual ~V3OutSpFile() {}
virtual void putsHeader() { puts("// Verilated -*- SystemC -*-\n"); }
virtual void putsIntTopInclude() {
puts("#include \"systemperl.h\"\n");
puts("#include \"verilated_sc.h\"\n");
}
};
class V3OutVFile : public V3OutFile {
public:
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) {}
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) {}
virtual ~V3OutMkFile() {}
virtual void putsHeader() { puts("# Verilated -*- Makefile -*-\n"); }
// No automatic indentation yet.
void puts(const char* strg) { putsNoTracking(strg); }
void puts(const string& strg) { putsNoTracking(strg); }
};
#endif // Guard
+1
View File
@@ -1,3 +1,4 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Gate optimizations, such as wire elimination
//
+1 -1
View File
@@ -1,4 +1,4 @@
// -*- C++ -*-
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Break always into sensitivity block domains
//

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