mirror of
https://github.com/verilator/verilator.git
synced 2026-10-03 00:23:35 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3797ade95 | ||
|
|
19b472cf0b | ||
|
|
38a31ae168 | ||
|
|
27516b565d | ||
|
|
c288a7bfb9 | ||
|
|
b44cd57866 | ||
|
|
b88a7f5152 | ||
|
|
7f9aa057bf | ||
|
|
305b4f3c75 | ||
|
|
6f4a8fe695 | ||
|
|
8aec436b5e | ||
|
|
aef2b7ea3c | ||
|
|
dcde026bac | ||
|
|
926209706f | ||
|
|
bd5d4c61c6 | ||
|
|
19abce5535 | ||
|
|
ab058c85bf | ||
|
|
4361c4b57a | ||
|
|
e6beab4037 | ||
|
|
ebeb645539 | ||
|
|
5c72f01598 | ||
|
|
0cf44a9c4f | ||
|
|
1fe5d5db79 | ||
|
|
a1a2650f1e | ||
|
|
07d00f26aa | ||
|
|
8d3d185e3b | ||
|
|
81a63b0c7d | ||
|
|
510be53521 | ||
|
|
4145a38c47 | ||
|
|
590b1853d0 | ||
|
|
08a51e3e09 | ||
|
|
75ebe7a4be | ||
|
|
1e0e51edd3 | ||
|
|
0ca07e4d58 | ||
|
|
1ce360ed5b | ||
|
|
172583eb03 | ||
|
|
c2b49f0174 | ||
|
|
92d62a6568 | ||
|
|
5d9d1cc09f | ||
|
|
57068b95ef | ||
|
|
5f63b24c50 | ||
|
|
81c659957e | ||
|
|
ee8dd32c04 | ||
|
|
0a755e6ecf | ||
|
|
e6c91f59ab | ||
|
|
9f947bcb5f | ||
|
|
135ccf6595 | ||
|
|
9a2a3f8db7 | ||
|
|
8ccc17f30b | ||
|
|
9392eac6a7 | ||
|
|
95c4b6aaba | ||
|
|
1c1319079b | ||
|
|
328fef8190 | ||
|
|
e2dec043a0 | ||
|
|
bd42e31b2a | ||
|
|
6d73237b27 | ||
|
|
6c6d70a5e5 | ||
|
|
6f49f802b1 | ||
|
|
808c958d42 | ||
|
|
961ac49c5c | ||
|
|
2d52f525c5 | ||
|
|
e70cba77e6 | ||
|
|
8054fc47ea | ||
|
|
e673875b3b | ||
|
|
29923b78fd | ||
|
|
135cbcd79a | ||
|
|
75ecad591a | ||
|
|
c108f5def9 | ||
|
|
dab1cb610a | ||
|
|
fd656f6cc1 | ||
|
|
a7e65379fa | ||
|
|
905067d13f | ||
|
|
30a33a6104 | ||
|
|
0ca0e07354 | ||
|
|
aac02acf92 | ||
|
|
082c9e0b1d | ||
|
|
a7bd934fe3 | ||
|
|
e98a380b44 | ||
|
|
4878fe3a1f | ||
|
|
c6b755a12e | ||
|
|
991d81cd0a | ||
|
|
c06a97a221 | ||
|
|
6131bcdbb0 | ||
|
|
68b6a0b667 | ||
|
|
4c438bbc67 | ||
|
|
5b83484f20 | ||
|
|
93ac79981b | ||
|
|
c9b74847d1 | ||
|
|
23eb96579c | ||
|
|
8319ea6c73 | ||
|
|
60f82961b4 | ||
|
|
f7d1c6ca72 | ||
|
|
4b4f10f5e6 | ||
|
|
120f62fe85 | ||
|
|
db6ecbd57e | ||
|
|
28e19cef90 | ||
|
|
18f8cd0529 | ||
|
|
02786b3f09 | ||
|
|
70358e8587 | ||
|
|
95b66feeb8 | ||
|
|
890cecc15b | ||
|
|
f7bad37e88 | ||
|
|
134b5efd70 | ||
|
|
0d6ebf21b3 | ||
|
|
2d1b804e80 | ||
|
|
77f1b3eef4 | ||
|
|
609a5dc26d | ||
|
|
0aabe6ce00 | ||
|
|
20cc4e57d5 | ||
|
|
f3ebdc40c6 | ||
|
|
2ca9f73b31 | ||
|
|
73f5e3f808 | ||
|
|
8d3dad510f | ||
|
|
2576c136f6 | ||
|
|
a8ad97eef2 | ||
|
|
ee7da1e690 | ||
|
|
969a46faf6 | ||
|
|
820df28ad9 | ||
|
|
50fb7fc8b4 | ||
|
|
119162912a | ||
|
|
80d94891e1 | ||
|
|
f00ff61559 | ||
|
|
2d195ebae5 | ||
|
|
9a6bc3ddcf | ||
|
|
d218f1746c | ||
|
|
8d8eb1b9f3 | ||
|
|
d4614c290e | ||
|
|
027cce35c0 | ||
|
|
9fd81b2c6b | ||
|
|
5430e4ac9b | ||
|
|
619214b48f | ||
|
|
68fa82fb14 | ||
|
|
cac50282eb | ||
|
|
b50ef9ff39 | ||
|
|
8a8f1135b7 | ||
|
|
f0b2336345 | ||
|
|
52907e7b02 | ||
|
|
ef5250f0ca | ||
|
|
eafed88a6e | ||
|
|
d64e6b3f9c | ||
|
|
d68ffba8cd | ||
|
|
f0f370490f | ||
|
|
708fd36563 | ||
|
|
a4e8d39932 | ||
|
|
8f0e8e0696 | ||
|
|
11380bc3b2 | ||
|
|
7ab2bdb6bb | ||
|
|
5d037c3c8c | ||
|
|
c5d04631d1 | ||
|
|
957c1d606b | ||
|
|
48dd358c03 | ||
|
|
220daa5f33 | ||
|
|
d76b5b7823 | ||
|
|
4266d31443 | ||
|
|
fbdf5f2dad | ||
|
|
8e26bdd098 | ||
|
|
22088c907f | ||
|
|
d87648c258 | ||
|
|
abf3850d08 | ||
|
|
4a122fd0f2 | ||
|
|
0352ceea44 | ||
|
|
e8ff191a17 | ||
|
|
5ae09daf5b | ||
|
|
1acff950d0 | ||
|
|
f28d837930 | ||
|
|
1dd9a74b6c | ||
|
|
165833a97c | ||
|
|
18e837336a | ||
|
|
835f668aaa | ||
|
|
09199f79a6 | ||
|
|
2f4954ca68 | ||
|
|
7024ea8cb6 | ||
|
|
623c4ec103 | ||
|
|
023526ad4b | ||
|
|
e2ba1c041f | ||
|
|
b41b9417b9 | ||
|
|
4443ab34fd | ||
|
|
e9a309ea8d | ||
|
|
81e8127168 | ||
|
|
47803c3591 | ||
|
|
af38e8d387 | ||
|
|
67bb0c78c8 | ||
|
|
918df2e618 | ||
|
|
7bed17b14b | ||
|
|
fad465abf1 | ||
|
|
98fb7ec193 | ||
|
|
b71eb76252 | ||
|
|
1d2a7b2f41 | ||
|
|
cd38e88fb8 | ||
|
|
a15aa0b82b | ||
|
|
fe94f9891b | ||
|
|
fe9cf9bd42 |
@@ -17,6 +17,7 @@
|
||||
README
|
||||
TAGS
|
||||
autom4te.cache
|
||||
compile_commands.json
|
||||
config.cache
|
||||
config.status
|
||||
configure
|
||||
|
||||
+16
-6
@@ -1,8 +1,10 @@
|
||||
# DESCRIPTION: Travis-CI config
|
||||
#
|
||||
# Copyright 2003-2019 by Todd Strader. Verilator 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.
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
version: ~> 1.0
|
||||
|
||||
@@ -16,6 +18,7 @@ env:
|
||||
- VERILATOR_ROOT=$PWD
|
||||
- VERILATOR_NUM_JOBS=$(echo `nproc` + 1 | bc)
|
||||
- VERILATOR_CONFIG_FLAGS="--enable-maintainer-mode --enable-longtests"
|
||||
- VERILATOR_AUTHOR_SITE=1
|
||||
- OBJCACHE=ccache
|
||||
|
||||
cache:
|
||||
@@ -24,8 +27,10 @@ cache:
|
||||
|
||||
before_install:
|
||||
# Perl modules needed for testing
|
||||
- yes yes | sudo cpan -fi Unix::Processors Parallel::Forker Bit::Vector
|
||||
# Not listing Bit::Vector as slow to install, and only skips one test
|
||||
- yes yes | sudo cpan -fi Unix::Processors Parallel::Forker
|
||||
- sudo apt-get install gdb gtkwave
|
||||
- sudo apt-get install libgoogle-perftools-dev
|
||||
before_script:
|
||||
- bash -x ci/build_vcddiff.sh
|
||||
- bash -x ci/build_verilator.sh
|
||||
@@ -56,9 +61,14 @@ jobs:
|
||||
script: ci/test.sh vlt
|
||||
- if: type != cron
|
||||
stage: test
|
||||
name: Vltmt test
|
||||
name: Vltmt set 0 test
|
||||
compiler: gcc
|
||||
script: ci/test.sh vltmt
|
||||
script: ci/test.sh vltmt0
|
||||
- if: type != cron
|
||||
stage: test
|
||||
name: Vltmt set 1 test
|
||||
compiler: gcc
|
||||
script: ci/test.sh vltmt1
|
||||
# Cron builds try different OS/compiler combinations
|
||||
- if: type = cron
|
||||
stage: "Build Verilator"
|
||||
|
||||
@@ -2,6 +2,104 @@ Revision history for Verilator
|
||||
|
||||
The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
|
||||
* Verilator 4.032 2020-04-04
|
||||
|
||||
*** Add column numbers to errors and warnings.
|
||||
|
||||
*** Add GCC 9-style line number prefix when showing source text for errors.
|
||||
|
||||
*** Add setting VM_PARALLEL_BUILDS=1 when using --output-split, #2185.
|
||||
|
||||
*** Change --quiet-exit to also suppress 'Exiting due to N errors'.
|
||||
|
||||
**** Suppress REALCVT for whole real numbers.
|
||||
|
||||
**** Support split_var in vlt files, #2219. [Marco Widmer]
|
||||
|
||||
**** Fix parameter type redeclaring a type, #2195. [hdzhangdoc]
|
||||
|
||||
**** Fix VCD open with empty filename, #2198. [Julius Baxter]
|
||||
|
||||
**** Fix packages as enum base types, #2202. [Driss Hafdi]
|
||||
|
||||
**** Fix duplicate typedefs in generate for, #2205. [hdzhangdoc]
|
||||
|
||||
**** Fix MinW portability, #2114. [Sean Cross]
|
||||
|
||||
**** Fix assertions with unique case inside, #2199. [hdzhangdoc]
|
||||
|
||||
**** Fix implicit conversion of floats to wide integers.
|
||||
|
||||
|
||||
* Verilator 4.030 2020-03-08
|
||||
|
||||
** Add split_var metacomment to assist UNOPTFLAT fixes, #2066. [Yutetsu TAKATSUKASA]
|
||||
|
||||
** Add support for $dumpfile and $dumpvars, #2126. [Alexander Grobman]
|
||||
|
||||
** Add support for dynamic arrays, #379.
|
||||
|
||||
*** Add +verilator+noassert flag to disable assertion checking. [Tobias Wölfel]
|
||||
|
||||
*** Add check for assertOn for asserts, #2162. [Tobias Wölfel]
|
||||
|
||||
*** Add --structs-packed for forward compatibility.
|
||||
|
||||
*** Fix genblk naming with directly nested generate blocks, #2176. [Alexander Grobman]
|
||||
|
||||
**** Implement $displayb/o/h, $writeb/o/h, etc, #1637.
|
||||
|
||||
**** Use gcc -Os in examples instead of -O2 for better average performance.
|
||||
|
||||
**** Fix undeclared VL_SHIFTR_WWQ, #2114. [Alex Solomatnikov]
|
||||
|
||||
|
||||
* Verilator 4.028 2020-02-08
|
||||
|
||||
** Support attributes (public, isolate_assignments, etc.) in configuration files.
|
||||
|
||||
** Add -match to lint_off to waive warnings. [Philipp Wagner]
|
||||
|
||||
*** Link Verilator binary partially statically, #2146. [Geza Lore]
|
||||
|
||||
*** Verilation speed improvements, #2133, #2138. [Geza Lore]
|
||||
|
||||
*** Support libgoogle-perftools-dev's libtcmalloc if available, #2137. [Geza Lore]
|
||||
|
||||
*** Support $readmem/$writemem with assoc arrarys, #2100. [agrobman]
|
||||
|
||||
**** Support type(expression) operator and $typename, #1650.
|
||||
|
||||
**** Support left justified $display, #2101. [Pieter Kapsenberg]
|
||||
|
||||
**** Support string character access via indexing.
|
||||
|
||||
**** Support enum.next(k) with constant k > 1, #2125. [Tobias Rosenkranz]
|
||||
|
||||
**** Support parameter access from arrays of interfaces, #2155. [Todd Strader]
|
||||
|
||||
**** Add parameter values in XML. #2110. [Pieter Kapsenberg]
|
||||
|
||||
**** Add loc column location in XML (replaces fl), #2122. [Pieter Kapsenberg]
|
||||
|
||||
**** Add error on misused define. [Topa Tota]
|
||||
|
||||
**** Add parameter to set maximum signal width, #2082. [Øyvind Harboe]
|
||||
|
||||
**** Add warning on genvar in normal for loop, #2143. [yurivict]
|
||||
|
||||
**** Fix VPI scope naming for public modules. [Nandu Raj]
|
||||
|
||||
**** Fix FST tracing of enums inside structs. [fsiegle]
|
||||
|
||||
**** Fix WIDTH warning on </<= of narrower value, #2141. [agrobman]
|
||||
|
||||
**** Fix OpenSolaris issues, #2154. [brancoliticus]
|
||||
|
||||
**** Fix gated clocks under --protect-lib, #2169. [Todd Strader]
|
||||
|
||||
|
||||
* Verilator 4.026 2020-01-11
|
||||
|
||||
** Docker images are now available for Verilator releases.
|
||||
@@ -128,10 +226,10 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
* Verilator 4.020 2019-10-06
|
||||
|
||||
*** Support $fseek, $ftell, $frewind, #1496. [Howard Su]
|
||||
|
||||
*** Add --public-flat-rw, #1511. [Stefan Wallentowitz]
|
||||
|
||||
*** Support $fseek, $ftell, $frewind, #1496. [Howard Su]
|
||||
|
||||
*** Support vpiModule, #1469. [Stefan Wallentowitz]
|
||||
|
||||
**** Make Syms file honor --output-split-cfuncs, #1499. [Todd Strader]
|
||||
@@ -152,6 +250,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
|
||||
|
||||
**** Fix case statements with strings, #1536. [Philipp Wagner]
|
||||
|
||||
**** Fix some coverage lost when multithreaded, #2151.
|
||||
|
||||
|
||||
* Verilator 4.018 2019-08-29
|
||||
|
||||
@@ -3467,10 +3567,11 @@ of input ports exists for tracing.
|
||||
|
||||
This uses outline mode in Emacs. See C-h m [M-x describe-mode].
|
||||
|
||||
Copyright 2001-2020 by Wilson Snyder. This program is free software; you
|
||||
Copyright 2001-2020 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.
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
Local variables:
|
||||
mode: outline
|
||||
|
||||
+5
-3
@@ -19,15 +19,16 @@
|
||||
\.codacy\.yml
|
||||
\.travis\.yml
|
||||
/build/
|
||||
/obj_dir/
|
||||
/obj_dbg/
|
||||
/obj_dir/
|
||||
/obj_dist/
|
||||
/obj_iv/
|
||||
/obj_nc/
|
||||
/obj_opt/
|
||||
/obj_vcs/
|
||||
/obj_vlt/
|
||||
/obj_vltmt/
|
||||
/obj_dist/
|
||||
/INCA_libs/
|
||||
INCA_libs/
|
||||
/cov_work/
|
||||
/logs/
|
||||
^Makefile$
|
||||
@@ -36,6 +37,7 @@ bin/verilator_bin.*
|
||||
bin/verilator_coverage_bin.*
|
||||
docs/.*\.html$
|
||||
docs/Makefile$
|
||||
docs/clang-format.txt$
|
||||
docs/doxygen-doc/.*
|
||||
examples/xml_py/copied/
|
||||
examples/xml_py/graph.*
|
||||
|
||||
+4
-13
@@ -7,15 +7,11 @@
|
||||
#
|
||||
#*****************************************************************************
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
#****************************************************************************/
|
||||
#
|
||||
@@ -148,6 +144,7 @@ DISTFILES_INC = $(INFOS) .gitignore \
|
||||
docs/install.adoc \
|
||||
docs/internals.adoc \
|
||||
docs/verilator_logo.png \
|
||||
docs/xml.adoc \
|
||||
install-sh configure *.pod \
|
||||
include/*.[chv]* \
|
||||
include/*.in \
|
||||
@@ -207,12 +204,6 @@ EXAMPLES_FIRST = \
|
||||
|
||||
EXAMPLES = $(EXAMPLES_FIRST) $(filter-out $(EXAMPLES_FIRST), $(sort $(wildcard examples/*)))
|
||||
|
||||
ifeq ($(OBJCACHE_JOBS),)
|
||||
ifneq ($(OBJCACHE_HOSTS),)
|
||||
export OBJCACHE_JOBS := -j $(shell objcache --jobs "$(OBJCACHE_HOSTS)")
|
||||
endif
|
||||
endif
|
||||
|
||||
# See uninstall also - don't put wildcards in this variable, it might uninstall other stuff
|
||||
VL_INST_MAN_FILES = verilator.1 verilator_coverage.1 verilator_gantt.1 verilator_profcfunc.1
|
||||
|
||||
|
||||
+16
-5
@@ -16,6 +16,7 @@ ifndef::env-github[]
|
||||
:link_verilator_contributing: https://github.com/verilator/verilator/blob/master/docs/CONTRIBUTING.adoc
|
||||
:link_verilator_install: https://verilator.org/install
|
||||
endif::[]
|
||||
:link_verilator_commercial_support: https://verilator.org/verilator_commercial_support
|
||||
|
||||
== Welcome to Verilator
|
||||
|
||||
@@ -24,7 +25,7 @@ endif::[]
|
||||
^.^| *Welcome to Verilator, the fastest free Verilog HDL simulator.*
|
||||
+++ <br/> +++ • Accepts synthesizable Verilog or SystemVerilog
|
||||
+++ <br/> +++ • Performs lint code-quality checks
|
||||
+++ <br/> +++ • Compiles into multithreaded {cpp}, SystemC, or (soon) {cpp}-under-Python
|
||||
+++ <br/> +++ • Compiles into multithreaded {cpp}, or SystemC
|
||||
+++ <br/> +++ • Creates XML to front-end your own tools
|
||||
<.^|image:https://www.veripool.org/img/verilator_256_200_min.png[Logo,256,200]
|
||||
|
||||
@@ -38,12 +39,18 @@ endif::[]
|
||||
+++ <br/> +++ • Out-of-the-box support from Arm, and RISC-V vendor IP
|
||||
<.^|image:https://www.veripool.org/img/verilator_usage_400x200-min.png[,400,200]
|
||||
|
||||
>.^|image:https://www.veripool.org/img/chips_alliance_logo_225x75-min.png[CHIPS Alliance,link=https://chipsalliance.org]
|
||||
image:https://www.veripool.org/img/osi_logo_125x125-min.png[,125,125]
|
||||
>.^|image:https://www.veripool.org/img/verilator_community_400x125-min.png[,400,125]
|
||||
^.^| *Community Driven & Openly Licensed*
|
||||
+++ <br/> +++ • Guided by the https://chipsalliance.org/[CHIPS Alliance] and https://www.linuxfoundation.org/[Linux Foundation]
|
||||
+++ <br/> +++ • Open, and free as in both speech and beer
|
||||
+++ <br/> +++ • More simulation for your verification budget
|
||||
|
||||
^.^| *Commercial Support Available*
|
||||
+++ <br/> +++ • Commercial support contracts
|
||||
+++ <br/> +++ • Design support contracts
|
||||
+++ <br/> +++ • Enhancement contracts
|
||||
<.^|image:https://www.veripool.org/img/verilator_support_400x125-min.png[,400,125]
|
||||
|
||||
|===
|
||||
|
||||
== What Verilator Does
|
||||
@@ -74,7 +81,7 @@ touch of {cpp} code, Verilator is the tool for you.
|
||||
Verilator does not simply convert Verilog HDL to {cpp} or SystemC. Rather
|
||||
than only translate, Verilator compiles your code into a much faster
|
||||
optimized and optionally thread-partitioned model, which is in turn wrapped
|
||||
inside a {cpp}/SystemC/Python module. The results are a compiled Verilog
|
||||
inside a {cpp}/SystemC/{cpp}-under-Python module. The results are a compiled Verilog
|
||||
model that executes even on a single-thread over 10x faster than standalone
|
||||
SystemC, and on a single thread is about 100 times faster than interpreted
|
||||
Verilog simulators such as http://iverilog.icarus.com[Icarus
|
||||
@@ -109,7 +116,7 @@ or https://verilator.org/verilator_doc.pdf[Verilator manual (PDF)]
|
||||
|
||||
* https://verilator.org/issues[Verilator Issues]
|
||||
|
||||
== Community Supported
|
||||
== Support
|
||||
|
||||
Verilator is a community project, guided by the
|
||||
https://chipsalliance.org/[CHIPS Alliance] under the
|
||||
@@ -120,6 +127,10 @@ We appreciate and welcome your contributions in whatever form; please see
|
||||
https://verilator.org/verilator_doc.html#CONTRIBUTORS[Contributors and
|
||||
Sponsors].
|
||||
|
||||
Verilator also supports and encourages commercial support models and
|
||||
organizations; please see {link_verilator_commercial_support}[Verilator
|
||||
Commercial Support].
|
||||
|
||||
== Related Projects
|
||||
|
||||
* http://gtkwave.sourceforge.net/[GTKwave] - Waveform viewer for Verilator
|
||||
|
||||
+423
-61
@@ -5,11 +5,7 @@
|
||||
# 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.
|
||||
#
|
||||
# This program 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
@@ -323,6 +319,7 @@ detailed descriptions in L</"VERILATION ARGUMENTS"> for more information.
|
||||
--language <lang> Default language standard to parse
|
||||
+libext+<ext>+[ext]... Extensions for finding modules
|
||||
--lint-only Lint, but do not make output
|
||||
--max-num-width <value> Maximum number width (default: 64K)
|
||||
--MMD Create .d dependency files
|
||||
--MP Create phony dependency targets
|
||||
--Mdir <directory> Name of output object directory
|
||||
@@ -420,6 +417,7 @@ more information.
|
||||
+verilator+prof+threads+window+I<value> Set profile duration
|
||||
+verilator+rand+reset+I<value> Set random reset technique
|
||||
+verilator+seed+I<value> Set random seed
|
||||
+verilator+noassert Disable assert checking
|
||||
+verilator+V Verbose version and config
|
||||
+verilator+version Show version and exit
|
||||
|
||||
@@ -968,6 +966,11 @@ stylistic and not enabled by default.
|
||||
If the design is not to be completely Verilated see also the --bbox-sys and
|
||||
--bbox-unsup options.
|
||||
|
||||
=item --max-num-width I<value>
|
||||
|
||||
Set the maximum number literal width (e.g. in 1024'd22 this it the 1024).
|
||||
Defaults to 64K.
|
||||
|
||||
=item --MMD
|
||||
=item --no-MMD
|
||||
|
||||
@@ -1076,8 +1079,8 @@ and the remaining files can be compiled on parallel machines. Using
|
||||
design --output-split 20000 resulted in splitting into approximately
|
||||
one-minute-compile chunks.
|
||||
|
||||
Typically when using this, make with VM_PARALLEL_BUILDS=1, and use
|
||||
I<ccache>.
|
||||
Typically when using this, make with VM_PARALLEL_BUILDS=1 (set for you if
|
||||
using the default makefiles), and use I<ccache>.
|
||||
|
||||
=item --output-split-cfuncs I<statements>
|
||||
|
||||
@@ -1266,7 +1269,8 @@ detailed description.
|
||||
|
||||
=item --quiet-exit
|
||||
|
||||
When exiting due to an error, do not display the "Command Failed" message.
|
||||
When exiting due to an error, do not display the "Exiting due to Errors"
|
||||
nor "Command Failed" messages.
|
||||
|
||||
=item --relative-includes
|
||||
|
||||
@@ -1337,6 +1341,13 @@ Creates more detailed statistics, including a list of all the variables by
|
||||
size (plain --stats just gives a count). See --stats, which is implied by
|
||||
this.
|
||||
|
||||
=item --structs-packed
|
||||
|
||||
Converts all unpacked structures to packed structures and issues a UNPACKED
|
||||
warning. Currently this is the default and --no-structs-packed will not
|
||||
work. Specifying this option allows for forward compatibility when a
|
||||
future version of Verilator no longer always packs unpacked structures.
|
||||
|
||||
=item -sv
|
||||
|
||||
Specifies SystemVerilog language features should be enabled; equivalent to
|
||||
@@ -1767,6 +1778,11 @@ For $random and "-x-initial unique", set the simulation runtime random seed
|
||||
value. If zero or not specified picks a value from the system random
|
||||
number generator.
|
||||
|
||||
=item +verilator+noassert
|
||||
|
||||
Disable assert checking per runtime argument. This is the same as calling
|
||||
"Verilated::assertOn(false)" in the model.
|
||||
|
||||
=item +verilator+V
|
||||
|
||||
Shows the verbose version, including configuration information.
|
||||
@@ -1894,13 +1910,13 @@ Now we run Verilator on our little example.
|
||||
|
||||
We then can compile it
|
||||
|
||||
cd obj_dir
|
||||
make -j -f Vour.mk Vour__ALL.a
|
||||
make -j -f Vour.mk ../sc_main.o verilated.o
|
||||
make -j -C obj_dir -f Vour.mk Vour__ALL.a
|
||||
make -j -C obj_dir -f Vour.mk ../sc_main.o verilated.o
|
||||
|
||||
And link with SystemC. Note your path to the libraries may vary,
|
||||
depending on the operating system.
|
||||
|
||||
cd obj_dir
|
||||
export SYSTEMC_LIBDIR=/path/to/where/libsystemc.a/exists
|
||||
export LD_LIBRARY_PATH=$SYSTEMC_LIBDIR:$LD_LIBRARY_PATH
|
||||
# Might be needed if SystemC 2.3.0
|
||||
@@ -1924,6 +1940,39 @@ when your source changes it will automatically run all of these steps. See
|
||||
the examples directory in the distribution.
|
||||
|
||||
|
||||
=head1 EVALUATION LOOP
|
||||
|
||||
When using SystemC, when Verilator is evaluated is managed by the SystemC
|
||||
kernel, and for the most part can be ignored. When using C++, the user
|
||||
must call eval(), or eval_step() and eval_end_step().
|
||||
|
||||
1. When there is a single design instantiated at the C++ level that need to
|
||||
evaluate, just call designp->eval().
|
||||
|
||||
2. When there are multiple designs instantiated each at the C++ level that
|
||||
need to evaluate, call first_designp->eval_step() then ->eval_step() on all
|
||||
other designs. Then call ->eval_end_step() on the first design then all
|
||||
other designs. If there is only a single design, you would call
|
||||
eval_step() then eval_end_step(); in fact eval() described above is just a
|
||||
wrapper which calls these two functions.
|
||||
|
||||
When eval() is called Verilator looks for changes in clock signals and
|
||||
evaluates related sequential always blocks, such as computing always_ff @
|
||||
(posedge...) outputs. Then Verilator evaluates combinatorial logic.
|
||||
|
||||
Note combinatorial logic is not computed before sequential always blocks
|
||||
are computed (for speed reasons). Therefore it is best to set any non-clock
|
||||
inputs up with a separate eval() call before changing clocks().
|
||||
|
||||
Alternatively, if all always_ff statements use only the posedge of clocks,
|
||||
or all inputs go directly to always_ff statements, as is typical, then you
|
||||
can change non-clock inputs on the negative edge of the input clock, which
|
||||
will be faster as there will be fewer eval() calls.
|
||||
|
||||
For more information on evaluation, see docs/internals.adoc in the
|
||||
distribution.
|
||||
|
||||
|
||||
=head1 BENCHMARKING & OPTIMIZATION
|
||||
|
||||
For best performance, run Verilator with the "-O3 --x-assign fast
|
||||
@@ -1952,27 +2001,27 @@ OPT, OPT_FAST, or OPT_SLOW lib/verilated.mk. Or, use the -CFLAGS and/or
|
||||
the compiler or linker. Or, just for one run, pass them on the command
|
||||
line to make:
|
||||
|
||||
make OPT_FAST="-O2 -fno-stack-protector" -f Vour.mk Vour__ALL.a
|
||||
make OPT_FAST="-Os -fno-stack-protector" -f Vour.mk Vour__ALL.a
|
||||
|
||||
OPT_FAST specifies optimizations for those programs that are part of the
|
||||
fast path, mostly code that is executed every cycle. OPT_SLOW specifies
|
||||
optimizations for slow-path files (plus tracing), which execute only
|
||||
rarely, yet take a long time to compile with optimization on. OPT
|
||||
specifies overall optimization and affects all compiles, including those
|
||||
OPT_FAST and OPT_SLOW control. For best results, use OPT="-O2", and link
|
||||
OPT_FAST and OPT_SLOW control. For best results, use OPT="-Os", and link
|
||||
with "-static". Nearly the same results can be had with much better
|
||||
compile times with OPT_FAST="-O1 -fstrict-aliasing". Higher optimization
|
||||
such as "-O3" may help, but gcc compile times may be excessive under O3 on
|
||||
even medium sized designs. Alternatively, some larger designs report
|
||||
better performance using "-Os".
|
||||
such as "-O2" or "-O3" may help, but gcc compile times may be excessive
|
||||
under O3 on even medium sized designs.
|
||||
|
||||
Unfortunately, using the optimizer with SystemC files can result in
|
||||
compiles taking several minutes. (The SystemC libraries have many little
|
||||
inlined functions that drive the compiler nuts.)
|
||||
|
||||
For best results, use GCC 3.3 or newer. GCC 3.2 and earlier have
|
||||
optimization bugs around pointer aliasing detection, which can result in 2x
|
||||
performance losses.
|
||||
For best results, use the latest clang compiler (about 10% faster than
|
||||
GCC). Note the now fairly old GCC 3.2 and earlier have optimization bugs
|
||||
around pointer aliasing detection, which can result in 2x performance
|
||||
losses.
|
||||
|
||||
If you will be running many simulations on a single compile, investigate
|
||||
feedback driven compilation. With GCC, using -fprofile-arcs, then
|
||||
@@ -1983,6 +2032,9 @@ especially if you link in DPI code. To enable LTO on GCC, pass "-flto" in
|
||||
both compilation and link. Note LTO may cause excessive compile times on
|
||||
large designs.
|
||||
|
||||
Using profile driven compiler optimization, with feedback from a real
|
||||
design, can yield up to30% improvements.
|
||||
|
||||
If you are using your own makefiles, you may want to compile the Verilated
|
||||
code with -DVL_INLINE_OPT=inline. This will inline functions, however this
|
||||
requires that all cpp files be compiled in a single compiler run.
|
||||
@@ -1993,7 +2045,7 @@ either oprofile or gprof to see where in the C++ code the time is spent.
|
||||
Run the gprof output through verilator_profcfunc and it will tell you what
|
||||
Verilog line numbers on which most of the time is being spent.
|
||||
|
||||
When done, please let the author know the results. I like to keep tabs on
|
||||
When done, please let the author know the results. We like to keep tabs on
|
||||
how Verilator compares, and may be able to suggest additional improvements.
|
||||
|
||||
|
||||
@@ -2068,7 +2120,7 @@ After running Make, the C++ compiler may produce the following:
|
||||
|
||||
A generic Linux/OS variable specifying what directories have shared object
|
||||
(.so) files. This path should include SystemC and any other shared objects
|
||||
needed at simultion runtime.
|
||||
needed at simulation runtime.
|
||||
|
||||
=item OBJCACHE
|
||||
|
||||
@@ -2197,7 +2249,7 @@ example:
|
||||
Note signals are read and written as member variables of the lower module.
|
||||
You call the eval() method to evaluate the model. When the simulation is
|
||||
complete call the final() method to wrap up any SystemVerilog final blocks,
|
||||
and complete any assertions.
|
||||
and complete any assertions. See L</"EVALUATION LOOP">.
|
||||
|
||||
|
||||
=head1 CONNECTING TO SYSTEMC
|
||||
@@ -2769,6 +2821,8 @@ purposes.
|
||||
|
||||
=item lint_off [-rule <message>] [-file "<filename>" [-lines <line> [ - <line>]]]
|
||||
|
||||
=item lint_off [-rule <message>] [-file "<filename>"] [-match "<string>"]
|
||||
|
||||
Enable/disables the specified lint warning, in the specified filename (or
|
||||
wildcard with '*' or '?', or all files if omitted) and range of line
|
||||
numbers (or all lines if omitted).
|
||||
@@ -2780,6 +2834,10 @@ If the -rule is omitted, all lint warnings (see list in -Wno-lint) are
|
||||
enabled/disabled. This will override all later lint warning enables for
|
||||
the specified region.
|
||||
|
||||
If -match is set the linter warnings are matched against this (wildcard)
|
||||
string and are waived in case they match iff rule and file (with wildcard)
|
||||
also match.
|
||||
|
||||
In previous versions -rule was named -msg. The latter is deprecated, but
|
||||
still works with a deprecation info, it may be removed in future versions.
|
||||
|
||||
@@ -2794,6 +2852,135 @@ and range of line numbers (or all lines if omitted).
|
||||
For tracing_off, cells below any module in the files/ranges specified will
|
||||
also not be traced.
|
||||
|
||||
=item clock_enable -module "<modulename>" -var "<signame>"
|
||||
|
||||
Indicate the signal is used to gate a clock, and the user takes responsibility
|
||||
for insuring there are no races related to it.
|
||||
|
||||
Same as /*verilator clock_enable*/, see L</"LANGUAGE EXTENSIONS"> for
|
||||
more information and an example.
|
||||
|
||||
=item clocker -module "<modulename>" [-task "<taskname>"] -var "<signame>"
|
||||
|
||||
=item clocker -module "<modulename>" [-function "<funcname>"] -var "<signame>"
|
||||
|
||||
=item no_clocker -module "<modulename>" [-task "<taskname>"] -var "<signame>"
|
||||
|
||||
=item no_clocker -module "<modulename>" [-function "<funcname>"] -var "<signame>"
|
||||
|
||||
Indicate the signal is used as clock or not. This information is used by
|
||||
Verilator to mark the signal as clocker and propagate the clocker attribute
|
||||
automatically to derived signals. See C<--clk> for more information.
|
||||
|
||||
Same as /*verilator clocker*/, see L</"LANGUAGE EXTENSIONS"> for more
|
||||
information.
|
||||
|
||||
=item coverage_block_off -module "<modulename>" -block "<blockname>"
|
||||
|
||||
=item coverage_block_off -file "<filename>" -line <lineno>
|
||||
|
||||
Specifies the entire begin/end block should be ignored for coverage
|
||||
analysis purposes. Can either be specified as a named block or as a
|
||||
filename and line number.
|
||||
|
||||
Same as /*verilator coverage_block_off*/, see L</"LANGUAGE
|
||||
EXTENSIONS"> for more information.
|
||||
|
||||
=item full_case -file "<filename>" -lines <lineno>
|
||||
|
||||
=item parallel_case -file "<filename>" -lines <lineno>
|
||||
|
||||
Same as "//synopsys full_case" and "//synopsys parallel_case". When
|
||||
these synthesis directives are discovered, Verilator will either
|
||||
formally prove the directive to be true, or failing that, will insert
|
||||
the appropriate code to detect failing cases at simulation runtime and
|
||||
print an "Assertion failed" error message.
|
||||
|
||||
=item inline -module "<modulename>"
|
||||
|
||||
Specifies the module may be inlined into any modules that use this
|
||||
module. This is useful to speed up simulation runtime with some small
|
||||
loss of trace visibility and modularity. Note signals under inlined
|
||||
submodules will be named I<submodule>__DOT__I<subsignal> as C++ does
|
||||
not allow "." in signal names. When tracing such signals the tracing
|
||||
routines will replace the __DOT__ with the period.
|
||||
|
||||
Same as /*verilator inline_module*/, see L</"LANGUAGE EXTENSIONS"> for
|
||||
more information.
|
||||
|
||||
=item isolate_assignments -module "<modulename>" [-task "<taskname>"] -var "<signame>"
|
||||
|
||||
=item isolate_assignments -module "<modulename>" [-function "<funcname>"] -var "<signame>"
|
||||
|
||||
=item isolate_assignments -module "<modulename>" -function "<fname>"
|
||||
|
||||
Used to indicate the assignments to this signal in any blocks should be
|
||||
isolated into new blocks. When there is a large combinatorial block that
|
||||
is resulting in a UNOPTFLAT warning, attaching this to the signal causing
|
||||
a false loop may clear up the problem.
|
||||
|
||||
Same as /* verilator isolate_assignments */, see L</"LANGUAGE
|
||||
EXTENSIONS"> for more information.
|
||||
|
||||
=item no_inline -module "<modulename>"
|
||||
|
||||
Specifies the module should not be inlined into any modules that use
|
||||
this module. This is useful especially at the top level module to
|
||||
reduce the size of the interface class, to aid compile time at a small
|
||||
performance loss.
|
||||
|
||||
Same as /*verilator no_inline_module*/, see L</"LANGUAGE EXTENSIONS">
|
||||
for more information.
|
||||
|
||||
=item no_inline [-module "<modulename>"] -task "<taskname>"
|
||||
|
||||
=item no_inline [-module "<modulename>"] -function "<funcname>"
|
||||
|
||||
Specify the function or task should not be inlined into where it is
|
||||
used. This may reduce the size of the final executable when a task is
|
||||
used a very large number of times. For this flag to work, the task
|
||||
and tasks below it must be pure; they cannot reference any variables
|
||||
outside the task itself.
|
||||
|
||||
Same as /*verilator no_inline_task*/, see L</"LANGUAGE EXTENSIONS">
|
||||
for more information.
|
||||
|
||||
=item sc_bv -module "<modulename>" [-task "<taskname>"] -var "<signame>"
|
||||
|
||||
=item sc_bv -module "<modulename>" [-function "<funcname>"] -var "<signame>"
|
||||
|
||||
Sets the port to be of sc_bv<I<width>> type, instead of bool, vluint32_t or
|
||||
vluint64_t. This may be useful if the port width is parameterized and
|
||||
different of such modules interface a templated module (such as a transactor)
|
||||
or for other reasons. In general you should avoid using this attribute when
|
||||
not necessary as with increasing usage of sc_bv the performance decreases
|
||||
significantly.
|
||||
|
||||
Same as /*verilator sc_bv*/, see L</"LANGUAGE EXTENSIONS"> for more
|
||||
information.
|
||||
|
||||
=item sformat [-module "<modulename>"] [-task "<taskname>"] -var "<signame>"
|
||||
|
||||
=item sformat [-module "<modulename>"] [-function "<funcname>"] -var "<signame>"
|
||||
|
||||
Final input of a function or task "input string" to indicate the
|
||||
function or task should pass all remaining arguments through
|
||||
$sformatf. This allows creation of DPI functions with $display like
|
||||
behavior. See the test_regress/t/t_dpi_display.v file for an example.
|
||||
|
||||
Same as /*verilator sformat*/, see L</"LANGUAGE EXTENSIONS"> for more
|
||||
information.
|
||||
|
||||
=item split_var [-module "<modulename>"] [-task "<taskname>"] -var "<varname>"
|
||||
|
||||
=item split_var [-module "<modulename>"] [-function "<funcname>"] -var "<varname>"
|
||||
|
||||
Break the variable into multiple pieces typically to resolve UNOPTFLAT
|
||||
performance issues. Typically the variables to attach this to are
|
||||
recommeded by Verilator itself, see UNOPTFLAT.
|
||||
|
||||
Same as /*verilator split_var*/, see L</"LANGUAGE EXTENSIONS"> for more
|
||||
information.
|
||||
|
||||
=back
|
||||
|
||||
@@ -2929,7 +3116,8 @@ per the C standard (it's unspecified in Verilog).
|
||||
|
||||
Specifies the entire begin/end block should be ignored for coverage
|
||||
analysis. Must be inside a basic block, e.g. within a begin/end pair.
|
||||
Same as /* verilator coverage_block_off */.
|
||||
Same as /* verilator coverage_block_off */ and C<coverage_block_off> in
|
||||
L</"CONFIGURATION FILES">.
|
||||
|
||||
=item `systemc_header
|
||||
|
||||
@@ -3019,7 +3207,10 @@ analysis.) For example:
|
||||
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.
|
||||
IMPERFECTSCH warning, to ensure all clock enables are properly recognized.
|
||||
|
||||
Same as C<clock_enable> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator clocker*/
|
||||
|
||||
@@ -3030,11 +3221,17 @@ not. This information is used by Verilator to mark the signal as clocker
|
||||
and propagate the clocker attribute automatically to derived signals. See
|
||||
C<--clk> for more information.
|
||||
|
||||
Same as C<clocker> and C<no_clocker> in configuration files, see
|
||||
L</"CONFIGURATION FILES"> for more information.
|
||||
|
||||
=item /*verilator coverage_block_off*/
|
||||
|
||||
Specifies the entire begin/end block should be ignored for coverage
|
||||
analysis purposes.
|
||||
|
||||
Same as C<coverage_block_off> in configuration files, see
|
||||
L</"CONFIGURATION FILES"> for more information.
|
||||
|
||||
=item /*verilator coverage_off*/
|
||||
|
||||
Specifies that following lines of code should have coverage disabled.
|
||||
@@ -3055,6 +3252,9 @@ submodules will be named I<submodule>__DOT__I<subsignal> as C++ does not
|
||||
allow "." in signal names. When tracing such signals the tracing routines
|
||||
will replace the __DOT__ with the period.
|
||||
|
||||
Same as C<inline> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator isolate_assignments*/
|
||||
|
||||
Used after a signal declaration to indicate the assignments to this signal
|
||||
@@ -3091,6 +3291,9 @@ It would then internally break it into (sort of):
|
||||
end
|
||||
end
|
||||
|
||||
Same as C<isolate_assignments> in configuration files, see
|
||||
L</"CONFIGURATION FILES"> for more information.
|
||||
|
||||
=item /*verilator lint_off I<msg>*/
|
||||
|
||||
Disable the specified warning message for any warnings following the comment.
|
||||
@@ -3126,6 +3329,9 @@ modules that use this module. This is useful especially at the top level
|
||||
module to reduce the size of the interface class, to aid compile time at a
|
||||
small performance loss.
|
||||
|
||||
Same as C<no_inline> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator no_inline_task*/
|
||||
|
||||
Used in a function or task variable definition section to specify the
|
||||
@@ -3134,6 +3340,9 @@ reduce the size of the final executable when a task is used a very large
|
||||
number of times. For this flag to work, the task and tasks below it must
|
||||
be pure; they cannot reference any variables outside the task itself.
|
||||
|
||||
Same as C<no_inline> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator public*/ (parameter)
|
||||
|
||||
Used after a parameter declaration to indicate the emitted C code should
|
||||
@@ -3161,6 +3370,9 @@ Instead of using public variables, consider instead making a DPI or public
|
||||
function that accesses the variable. This is nicer as it provides an
|
||||
obvious entry point that is also compatible across simulators.
|
||||
|
||||
Same as C<public> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator public*/ (task/function)
|
||||
|
||||
Used inside the declaration section of a function or task declaration to
|
||||
@@ -3183,6 +3395,9 @@ the model will NOT notice changes made to variables in these functions.
|
||||
You may want to use DPI exports instead, as it's compatible with other
|
||||
simulators.
|
||||
|
||||
Same as C<public> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator public_flat*/ (variable)
|
||||
|
||||
Used after an input, output, register, or wire declaration to indicate the
|
||||
@@ -3191,11 +3406,17 @@ signal. This will not declare this module public, which means the name of
|
||||
the signal or path to it may change based upon the module inlining which
|
||||
takes place.
|
||||
|
||||
Same as C<public_flat> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator public_flat_rd*/ (variable)
|
||||
|
||||
Used after an input, output, register, or wire declaration to indicate the
|
||||
signal should be declared public_flat (see above), but read-only.
|
||||
|
||||
Same as C<public_flat_rd> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator public_flat_rw @(<edge_list>) */ (variable)
|
||||
|
||||
Used after an input, output, register, or wire declaration to indicate the
|
||||
@@ -3204,6 +3425,9 @@ where writes should be considered to have the timing specified by the given
|
||||
sensitivity edge list. Set for all variables, ports and wires using the
|
||||
--public-flat-rw switch.
|
||||
|
||||
Same as C<public_flat_rw> in configuration files, see L</"CONFIGURATION
|
||||
FILES"> for more information.
|
||||
|
||||
=item /*verilator public_module*/
|
||||
|
||||
Used after a module statement to indicate the module should not be inlined
|
||||
@@ -3212,9 +3436,12 @@ Verilator automatically sets this attribute when the module contains any
|
||||
public signals or `systemc_ directives. Also set for all modules when
|
||||
using the --public switch.
|
||||
|
||||
Same as C<public> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator sc_clock*/
|
||||
|
||||
Rarely needed. Used after an input declaration to indicate the signal
|
||||
Deprecated. Used after an input declaration to indicate the signal
|
||||
should be declared in SystemC as a sc_clock instead of a bool. This was
|
||||
needed in SystemC 1.1 and 1.2 only; versions 2.0 and later do not require
|
||||
clock pins to be sc_clocks and this is no longer needed.
|
||||
@@ -3226,7 +3453,10 @@ type, instead of bool, vluint32_t or vluint64_t. This may be useful if
|
||||
the port width is parameterized and different of such modules interface
|
||||
a templated module (such as a transactor) or for other reasons. In general
|
||||
you should avoid using this attribute when not necessary as with increasing
|
||||
usage of sc_bv the performance increases significantly.
|
||||
usage of sc_bv the performance decreases significantly.
|
||||
|
||||
Same as C<sc_bv> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator sformat*/
|
||||
|
||||
@@ -3235,6 +3465,39 @@ indicate the function or task should pass all remaining arguments through
|
||||
$sformatf. This allows creation of DPI functions with $display like
|
||||
behavior. See the test_regress/t/t_dpi_display.v file for an example.
|
||||
|
||||
Same as C<sformat> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator split_var*/
|
||||
|
||||
Attached to a variable or a net declaration to break the variable into
|
||||
multiple pieces typically to resolve UNOPTFLAT performance issues.
|
||||
Typically the variables to attach this to are recommeded by Verilator
|
||||
itself, see UNOPTFLAT below.
|
||||
|
||||
For example, Verilator will internally convert a variable with the
|
||||
metacomment such as:
|
||||
|
||||
logic [7:0] x [0:1] /*verilator split_var*/;
|
||||
|
||||
To:
|
||||
|
||||
logic [7:0] x__BRA__0__KET__ /*verilator split_var*/;
|
||||
logic [7:0] x__BRA__1__KET__ /*verilator split_var*/;
|
||||
|
||||
Note that the generated packed variables retain the split_var metacomment
|
||||
because they may be split into further smaller pieces accorting to the
|
||||
access patterns.
|
||||
|
||||
This only supports unpacked arrays, packed arrays, and packed structs of
|
||||
integer types (reg, logic, bit, byte, int...); otherwise if a split was
|
||||
requested but cannot occur a SPLITVAR warning is issued. Splitting large
|
||||
arrays may slow donw the Verilation speed, so use this only on variables
|
||||
that require it.
|
||||
|
||||
Same as C<split_var> in configuration files, see L</"CONFIGURATION FILES">
|
||||
for more information.
|
||||
|
||||
=item /*verilator tag <text...>*/
|
||||
|
||||
Attached after a variable or structure member to indicate opaque (to
|
||||
@@ -3570,17 +3833,29 @@ $unsigned, $warning.
|
||||
|
||||
Generally supported.
|
||||
|
||||
=item $display, $write, $fdisplay, $fwrite, $swrite
|
||||
|
||||
$display and friends must have a constant format string as the first
|
||||
argument (as with C's printf). The rare usage which lists variables
|
||||
standalone without a format is not supported.
|
||||
|
||||
=item $displayb, $displayh, $displayo, $writeb, $writeh, $writeo, etc
|
||||
|
||||
The sized display functions are rarely used and so not supported. Replace
|
||||
them with a $write with the appropriate format specifier.
|
||||
|
||||
=item $dump/$dumpports and related
|
||||
|
||||
$dumpfile or $dumpports will create a VCD or FST file (which is based on
|
||||
the --trace argument given when the model was Verilated). This will take
|
||||
effect starting at the next eval() call. If you have multiple Verilated
|
||||
designs under the same C model, then this will dump signals only from the
|
||||
design containing the $dumpvar.
|
||||
|
||||
$dumpvars and $dumpports module identifier is ignored; the traced instances
|
||||
will always start at the top of the design. The levels argument is also
|
||||
ignored, use tracing_on/tracing_off pragmas instead.
|
||||
|
||||
$dumpportson/$dumpportsoff/$dumpportsall/$dumpportslimit filename argument
|
||||
is ignored, only a single trace file may be active at once.
|
||||
|
||||
$dumpall/$dumpportsall, $dumpon/$dumpportson, $dumpoff/$dumpportsoff, and
|
||||
$dumplimit/$dumpportlimit are currently ignored.
|
||||
|
||||
=item $finish, $stop
|
||||
|
||||
The rarely used optional parameter to $finish and $stop is ignored.
|
||||
@@ -3650,7 +3925,24 @@ checking across the designs, and prevents other users from compiling your
|
||||
code without knowing the magic set of disables needed to successfully
|
||||
compile your design.
|
||||
|
||||
List of all warnings:
|
||||
=head2 Error and Warning Format
|
||||
|
||||
Warnings and errors printed by Verilator always match this regular
|
||||
expression:
|
||||
|
||||
%(Error|Warning)(-[A-Z0-9_]+)?: ((\S+):(\d+):((\d+):)? )?.*
|
||||
|
||||
Errors and warning start with a percent sign (historical heritage from
|
||||
Digital Equipment Corporation). Some errors or warning have a code
|
||||
attached, with meanings described below. Some errors also have a filename,
|
||||
line number and optional column number (starting at column 1 to match GCC).
|
||||
|
||||
Following an the error message, Verilator will typically show the user's
|
||||
source code corresponding to the error, prefixed by the line number and a "
|
||||
| ". Following this is typically an arrow and ~ pointing at the error on
|
||||
the source line directly above.
|
||||
|
||||
=head2 List of all warnings
|
||||
|
||||
=over 4
|
||||
|
||||
@@ -4198,6 +4490,29 @@ Ignoring this warning may make Verilator simulations differ from other
|
||||
simulators, if the increased precision of real affects your model or DPI
|
||||
calls.
|
||||
|
||||
=item SPLITVAR
|
||||
|
||||
Warns that a variable with a C<split_var> metacomment was not split.
|
||||
Some possible reasons for this are:
|
||||
|
||||
* The datatype of the variable is not supported for splitting. (e.g. is a
|
||||
real).
|
||||
|
||||
* The access pattern of the variable can not be determined
|
||||
statically. (e.g. is accessed as a memory).
|
||||
|
||||
* The index of the array exceeds the array size.
|
||||
|
||||
* The variable is accessed from outside using dotted reference.
|
||||
(e.g. top.instance0.variable0 = 1).
|
||||
|
||||
* The variable is not declared in a module, but in a package or an
|
||||
interface.
|
||||
|
||||
* The variable is a parameter, localparam, genvar, or queue.
|
||||
|
||||
* The variable is tirstate or bidirectional. (e.g. inout or ref).
|
||||
|
||||
=item STMTDLY
|
||||
|
||||
Warns that you have a statement with a delayed time in front of it, for
|
||||
@@ -4329,6 +4644,11 @@ being generated from an always statement that consumed high bits of the
|
||||
same bus processed by another series of always blocks. The fix is the
|
||||
same; split it into two separate signals generated from each block.
|
||||
|
||||
Another way to resolve this warning is to add a C<split_var> metacomment
|
||||
described above. This will cause the variable to be split internally,
|
||||
potentially resolving the conflict. If you run with --report-unoptflat
|
||||
Verilator will suggest possible candidates for C<split_var>.
|
||||
|
||||
The UNOPTFLAT warning may also be due to clock enables, identified from the
|
||||
reported path going through a clock gating cell. To fix these, use the
|
||||
clock_enable meta comment described above.
|
||||
@@ -4476,6 +4796,37 @@ that is not yet supported in Verilator. See the Limitations chapter.
|
||||
=back
|
||||
|
||||
|
||||
=head1 DEPRECATIONS
|
||||
|
||||
The following deprecated items are scheduled for future removal:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Pre-C++11 compiler support
|
||||
|
||||
Verilator supports pre-C++11 compilers for non-threaded models when
|
||||
configured with --enable-prec11. This flag will be removed and C++11
|
||||
compilers will be required for both compiling Verilator and compiling
|
||||
Verilated models no sooner than September 2020.
|
||||
|
||||
=item SystemC 2.1 and earlier support
|
||||
|
||||
Support for SystemC versions 2.1 and earlier and the related sc_clock
|
||||
variable attribute will be removed no sooner than July 2020.
|
||||
|
||||
=item Configuration File -msg
|
||||
|
||||
The -msg argument to lint_off has been replaced with -rule. -msg is
|
||||
planned for removal no sooner than January 2021.
|
||||
|
||||
=item XML locations
|
||||
|
||||
The XML C<fl> attribute has been replaced with C<loc>. C<fl> is planned
|
||||
for removal no sooner than January 2021.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 FAQ/FREQUENTLY ASKED QUESTIONS
|
||||
|
||||
=over 4
|
||||
@@ -4564,19 +4915,20 @@ designs have topped 16GB.
|
||||
|
||||
See the next question for tracing in SystemC mode.
|
||||
|
||||
Add the --trace switch to Verilator, and in your top level C code, call
|
||||
Verilated::traceEverOn(true). Then create a VerilatedVcdC object, and
|
||||
in your main loop call "trace_object->dump(time)" every time step, and
|
||||
finally call "trace_object->close()". For an example, see below and the
|
||||
examples/make_tracing_c/sim_main.cpp file of the distribution.
|
||||
A. Add the --trace switch to Verilator, and in your top level C code, call
|
||||
Verilated::traceEverOn(true). Then you may use $dumpfile and $dumpvars to
|
||||
enable traces, same as with any Verilog simulator. See
|
||||
C<examples/make_tracing_c>.
|
||||
|
||||
You also need to compile verilated_vcd_c.cpp and add it to your link,
|
||||
preferably by adding the dependencies in $(VK_GLOBAL_OBJS) to your
|
||||
Makefile's link rule. This is done for you if using the Verilator --exe
|
||||
flag.
|
||||
|
||||
Note you can also call ->trace on multiple Verilated objects with the same
|
||||
trace file if you want all data to land in the same output file.
|
||||
B. Or, for finer-grained control, or C++ files with multiple Verilated
|
||||
modules you may also create the trace purely from C++. Create a
|
||||
VerilatedVcdC object, and in your main loop call "trace_object->dump(time)"
|
||||
every time step, and finally call "trace_object->close()". You also need
|
||||
to compile verilated_vcd_c.cpp and add it to your link, preferably by
|
||||
adding the dependencies in $(VK_GLOBAL_OBJS) to your Makefile's link rule.
|
||||
This is done for you if using the Verilator --exe flag. Note you can also
|
||||
call ->trace on multiple Verilated objects with the same trace file if you
|
||||
want all data to land in the same output file.
|
||||
|
||||
#include "verilated_vcd_c.h"
|
||||
...
|
||||
@@ -4596,11 +4948,17 @@ trace file if you want all data to land in the same output file.
|
||||
|
||||
=item How do I generate waveforms (traces) in SystemC?
|
||||
|
||||
Add the --trace switch to Verilator, and in your top level C sc_main code,
|
||||
include verilated_vcd_sc.h. Then call Verilated::traceEverOn(true). Then
|
||||
create a VerilatedVcdSc object as you would create a normal SystemC trace
|
||||
file. For an example, see the call to VerilatedVcdSc in the
|
||||
examples/make_tracing_sc/sc_main.cpp file of the distribution, and below.
|
||||
A. Add the --trace switch to Verilator, and in your top level sc_main, call
|
||||
Verilated::traceEverOn(true). Then you may use $dumpfile and $dumpvars to
|
||||
enable traces, same as with any Verilog simulator, see the non-SystemC
|
||||
example in C<examples/make_tracing_c>. This will trace only the module
|
||||
containing the $dumpvar.
|
||||
|
||||
B. Or, you may create a trace purely from SystemC, which may trace all
|
||||
Verilated designs in the SystemC model. Create a VerilatedVcdSc object as
|
||||
you would create a normal SystemC trace file. For an example, see the call
|
||||
to VerilatedVcdSc in the examples/make_tracing_sc/sc_main.cpp file of the
|
||||
distribution, and below.
|
||||
|
||||
Alternatively you may use the C++ trace mechanism described in the previous
|
||||
question, however the timescale and timeprecision will not inherited from
|
||||
@@ -4630,23 +4988,23 @@ trace file if you want all data to land in the same output file.
|
||||
|
||||
=item How do I generate FST waveforms (traces) in C++?
|
||||
|
||||
FST a format by GTKWave.
|
||||
This version provides a basic FST support.
|
||||
To dump FST format, add the --trace-fst switch to Verilator and change the include
|
||||
path in the testbench to:
|
||||
FST a format by GTKWave. This version provides a basic FST support. To
|
||||
dump FST format, add the --trace-fst switch to Verilator and either A. use
|
||||
$dumpfile/$dumpvars in Verilog as described in the VCD example above, or
|
||||
B. in C++ change the include described in the VCD example above:
|
||||
|
||||
#include "verilated_fst_c.h"
|
||||
VerilatedFstC* tfp = new VerilatedFstC;
|
||||
|
||||
Note that currently supporting both FST and VCD in a single simulation is impossible,
|
||||
but such requirement could be rare.
|
||||
Note that currently supporting both FST and VCD in a single simulation is
|
||||
impossible, but such requirement should be rare.
|
||||
|
||||
=item How do I generate FST waveforms (traces) in SystemC?
|
||||
=item How do I generate FST waveforms (aka dumps or traces) in SystemC?
|
||||
|
||||
The FST library from GTKWave does not currently support SystemC; use VCD
|
||||
format instead.
|
||||
|
||||
=item How do I view waveforms (traces)?
|
||||
=item How do I view waveforms (aka dumps or traces)?
|
||||
|
||||
Verilator makes standard VCD (Value Change Dump) and FST files. VCD files are viewable
|
||||
with the public domain GTKWave (recommended) or Dinotrace (legacy)
|
||||
@@ -4707,7 +5065,7 @@ Most synthesis tools similarly define SYNTHESIS for you.
|
||||
=item Why do I get "unexpected `do'" or "unexpected `bit'" errors?
|
||||
|
||||
Do, bit, ref, return, and other words are now SystemVerilog keywords. You
|
||||
should change your code to not use them to insure it works with newer
|
||||
should change your code to not use them to ensure it works with newer
|
||||
tools. Alternatively, surround them by the Verilog 2005/SystemVerilog
|
||||
begin_keywords pragma to indicate Verilog 2001 code.
|
||||
|
||||
@@ -5029,11 +5387,15 @@ remain anonymous.
|
||||
|
||||
The latest version is available from L<https://verilator.org>.
|
||||
|
||||
Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can
|
||||
Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
redistribute it and/or modify the Verilator internals under the terms of
|
||||
either the GNU Lesser General Public License Version 3 or the Perl Artistic
|
||||
License Version 2.0.
|
||||
|
||||
All Verilog and C++/SystemC code quoted within this documentation file are
|
||||
released as Creative Commons Public Domain (CC0). Many example files and
|
||||
test files are likewise released under CC0 into effectively the Public
|
||||
Domain as described in the files themselves.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
@@ -5041,7 +5403,7 @@ L<verilator_coverage>, L<verilator_gantt>, L<verilator_profcfunc>, L<make>,
|
||||
|
||||
L<verilator --help> which is the source for this document,
|
||||
|
||||
and internals.txt in the distribution.
|
||||
and docs/internals.adoc in the distribution.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
######################################################################
|
||||
|
||||
require 5.006_001;
|
||||
@@ -269,10 +264,12 @@ Specifies a module search directory.
|
||||
|
||||
The latest version is available from L<https://verilator.org>.
|
||||
|
||||
Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can
|
||||
redistribute it and/or modify the Verilator internals under the terms of
|
||||
either the GNU Lesser General Public License Version 3 or the Perl Artistic
|
||||
License Version 2.0.
|
||||
Copyright 2003-2020 by Wilson Snyder. This program is free software; you
|
||||
can redistribute it and/or modify the Verilator internals under the terms
|
||||
of either the GNU Lesser General Public License Version 3 or the Perl
|
||||
Artistic License Version 2.0.
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
|
||||
@@ -233,9 +233,12 @@ Do not show differences in line numbering.
|
||||
|
||||
The latest version is available from L<https://verilator.org>.
|
||||
|
||||
Copyright 2005-2020 by Wilson Snyder. This package 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.
|
||||
Copyright 2005-2020 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.
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
|
||||
+8
-5
@@ -123,13 +123,13 @@ sub report {
|
||||
}
|
||||
|
||||
my $nthreads = scalar keys %Threads;
|
||||
$Global{cpus}{cpu_time} = {};
|
||||
$Global{cpus} = {};
|
||||
foreach my $thread (keys %Threads) {
|
||||
# Make potentially multiple characters per column
|
||||
foreach my $start (keys %{$Threads{$thread}}) {
|
||||
my $cpu = $Threads{$thread}{$start}{cpu};
|
||||
my $elapsed = $Threads{$thread}{$start}{end} - $start;
|
||||
$Global{cpus}{cpu_time}{$cpu} += $elapsed;
|
||||
$Global{cpus}{$cpu}{cpu_time} += $elapsed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,9 +538,12 @@ verilator_gantt.vcd.
|
||||
|
||||
The latest version is available from L<https://verilator.org>.
|
||||
|
||||
Copyright 2018-2020 by Wilson Snyder. Verilator 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.
|
||||
Copyright 2018-2020 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.
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#!/usr/bin/env perl
|
||||
# DESCRIPTION: Print include statements for each ARGV
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This package 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.
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
######################################################################
|
||||
|
||||
require 5.005;
|
||||
|
||||
@@ -228,9 +228,12 @@ Displays this message and program version and exits.
|
||||
|
||||
The latest version is available from L<https://verilator.org>.
|
||||
|
||||
Copyright 2007-2020 by Wilson Snyder. Verilator 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.
|
||||
Copyright 2007-2020 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.
|
||||
|
||||
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Verilator: Build script for vcddiff
|
||||
#
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
set -e
|
||||
|
||||
# NB: it would be better to add this via a PPA
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Verilator: Travis CI build script
|
||||
#
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
# This script builds and caches the Verilator binaries for Travis CI
|
||||
# (and possibly other CI platforms). The Verilator CI system uses this
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# DESCRIPTION: Dockerfile for env to build and fully test Verilator
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
= Verilator Build Environment
|
||||
= Verilator Docker Build Environment
|
||||
|
||||
This container is set up to compile and test a Verilator build based
|
||||
on the following parameters:
|
||||
This Verilator Build container is set up to compile and test a Verilator
|
||||
build. It uses the following parameters:
|
||||
|
||||
* Source repository (default: https://github.com/verilator/verilator)
|
||||
* Source revision (default: master)
|
||||
@@ -10,7 +10,7 @@ on the following parameters:
|
||||
The container is published as `verilator/verilator-buildenv` on
|
||||
https://hub.docker.com/repository/docker/verilator/verilator-buildenv[docker hub].
|
||||
|
||||
To run the basic build of current master:
|
||||
To run the basic build using the current Verilator master:
|
||||
|
||||
docker run -ti verilator/verilator-buildenv
|
||||
|
||||
@@ -18,7 +18,7 @@ To also run tests:
|
||||
|
||||
docker run -ti verilator/verilator-buildenv test
|
||||
|
||||
Change the compiler:
|
||||
To change the compiler:
|
||||
|
||||
docker run -ti -e CC=gcc-4.8 -e CXX=g++-4.8 verilator/verilator-buildenv test
|
||||
|
||||
@@ -29,22 +29,21 @@ To run those too:
|
||||
docker run -ti -v ${PWD}:/tmp/repo -e REPO=/tmp/repo -e REV=`git rev-parse --short HEAD` -e CC=gcc-4.8 -e CXX=g++-4.8 --cap-add=SYS_PTRACE --security-opt seccomp=unconfined verilator/verilator-buildenv test
|
||||
....
|
||||
|
||||
You may want to avoid pushing your changes to a remote repository and
|
||||
instead use a local working copy. You can mount the local working copy
|
||||
path as a volume and use this as repo. Be careful, that it can only
|
||||
use committed changes, so you may want to use a work-in-progress
|
||||
commit or so. To build the current HEAD from top of a repository:
|
||||
Rather then building using a remote git repository you may prefer to use a
|
||||
working copy on the local filesystem. Mount the local working copy path as
|
||||
a volume and use that in place of git. When doing this be careful to have
|
||||
all changes committed to the local git area. To build the current HEAD from
|
||||
top of a repository:
|
||||
|
||||
....
|
||||
docker run -ti -v ${PWD}:/tmp/repo -e REPO=/tmp/repo -e REV=`git rev-parse --short HEAD` --cap-add=SYS_PTRACE --security-opt seccomp=unconfined verilator/verilator-buildenv test
|
||||
....
|
||||
|
||||
== Under the Hood
|
||||
== Rebuilding
|
||||
|
||||
To rebuild the image, simply run:
|
||||
To rebuild the Verilator-buildenv docker image, run:
|
||||
|
||||
docker build .
|
||||
|
||||
It will build SystemC in all supported compiler variants to reduce the
|
||||
impact on testing cycles. A build script will be the entrypoint to the
|
||||
container that will perform a standard build and test procedure.
|
||||
This will also build SystemC under all supported compiler variants to
|
||||
reduce the SystemC testing time.
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash -e
|
||||
# DESCRIPTION: Build SystemC in Ubuntu 18.04 with different g++/gcc
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
build_variant () {
|
||||
version=$($1 --version | grep gcc | awk '{print $4}')
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash -e
|
||||
# DESCRIPTION: Build Verilator (inside container)
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
: "${REPO:=https://github.com/verilator/verilator}"
|
||||
: "${REV:=master}"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# DESCRIPTION: Dockerfile for image to run Verilator inside
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
FROM ubuntu:18.04
|
||||
|
||||
|
||||
+35
-25
@@ -1,49 +1,59 @@
|
||||
= Docker Container as Verilator executable
|
||||
= Verilator Executable Docker Container
|
||||
|
||||
This allows you to run Verilator easily as a docker image, e.g.:
|
||||
The Verilator Executable Docker Container allows you to run Verilator
|
||||
easily as a docker image, e.g.:
|
||||
|
||||
docker run -ti verilator/verilator:latest --version
|
||||
|
||||
This is in particular useful to compare against older version or to
|
||||
check when an issue was introduced.
|
||||
This will install the container, run the latest Verilator and print
|
||||
Verilator's version.
|
||||
|
||||
You will need to give it access to your files as a volume and fix the
|
||||
user rights:
|
||||
Containers are automatically built for all released versions, so you may
|
||||
easily compare results across versions, e.g.:
|
||||
|
||||
docker run -ti verilator/verilator:4.030 --version
|
||||
|
||||
Verilator needs to read and write files on the local system. To simplify
|
||||
this process, use the `verilator-docker` convenience script. This script
|
||||
takes the version number, and all remaining arguments are passed through to
|
||||
Verilator. e.g.:
|
||||
|
||||
./verilator-docker 4.030 --version
|
||||
|
||||
or
|
||||
|
||||
./verilator-docker 4.030 --cc test.v
|
||||
|
||||
If you prefer not to use `verilator-docker` you must give the container
|
||||
access to your files as a volume with appropriate user rights. For example
|
||||
to Verilate test.v:
|
||||
|
||||
....
|
||||
docker run -ti -v ${PWD}:/work --user $(id -u):$(id -g) verilator/verilator:latest --cc test.v
|
||||
....
|
||||
|
||||
The caveat is that it can only access files below the current
|
||||
directory then, a workaround is to adopt the volume and set
|
||||
`-workdir`.
|
||||
This method can only access files below the current directory. An
|
||||
alternative is setup the volume `-workdir`.
|
||||
|
||||
There is a convenience script in this folder that wraps around the
|
||||
docker calls:
|
||||
|
||||
$ verilator-docker 3.922 --version
|
||||
Verilator 3.922 2018-03-17 rev UNKNOWN_REV
|
||||
|
||||
Finally, you can also work in the container by setting the entrypoint
|
||||
You can also work in the container by setting the entrypoint
|
||||
(don't forget to mount a volume if you want your work persistent):
|
||||
|
||||
docker run -ti --entrypoint /bin/bash verilator/verilator:latest
|
||||
|
||||
The other files in this folder all for building the containers and to
|
||||
store in them. You could use it to build Verilator at a specific
|
||||
You can also use the container to build Verilator at a specific
|
||||
commit:
|
||||
|
||||
docker build --build-arg SOURCE_COMMIT=<commit> .
|
||||
|
||||
== Internals
|
||||
|
||||
The Dockerfile is pretty straight-forward, it builds Verilator and
|
||||
removes the tree after that to reduce the image size. It sets a
|
||||
wrapper script (`verilator-wrap.sh`) as entrypoint. This script calls
|
||||
Verilator but also copies the verilated runtime files to the `obj_dir`
|
||||
or the `-Mdir` respectively. This allows the user to build the C++
|
||||
output with the matching runtime files. The wrapper patches the
|
||||
generated Makefile accordingly.
|
||||
The Dockerfile builds Verilator and removes the tree when completed to
|
||||
reduce the image size. The entrypoint is set as a wrapper script
|
||||
(`verilator-wrap.sh`). That script 1. calls Verilator, and 2. copies the
|
||||
Verilated runtime files to the `obj_dir` or the `-Mdir` respectively. This
|
||||
allows the user to have the files to they may later build the C++ output
|
||||
with the matching runtime files. The wrapper also patches the Verilated
|
||||
Makefile accordingly.
|
||||
|
||||
There is also a hook defined that is run by docker hub via automated
|
||||
builds.
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Docker hub hook to pass SOURCE_COMMIT
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.FROM ubuntu:18.04
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
docker build --build-arg SOURCE_COMMIT=${SOURCE_COMMIT} -f $DOCKERFILE_PATH -t $IMAGE_NAME .
|
||||
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Docker hub hook to tag the latest release (stable)
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
if [ "$SOURCE_BRANCH"="stable" ]; then
|
||||
docker tag $IMAGE_NAME $DOCKER_REPO:latest
|
||||
docker push $DOCKER_REPO:latest
|
||||
fi
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Wrap a verilator call to run a docker container
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
docker pull verilator/verilator:$1 >/dev/null
|
||||
docker run -ti -v ${PWD}:/work --user $(id -u):$(id -g) verilator/verilator:$1 "${@:2}"
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
#!/bin/bash -e
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Wrap a Verilator call and copy vlt includes
|
||||
# (inside docker container)
|
||||
#
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# Copyright 2020 by Stefan Wallentowitz. 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
perl /usr/local/bin/verilator "$@"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
exit $status
|
||||
fi
|
||||
|
||||
# Check if user set an obj_dir
|
||||
obj_dir=$(echo " $@" | grep -oP '\s--Mdir\s*\K\S+')
|
||||
|
||||
+10
-2
@@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
# DESCRIPTION: Verilator: Travis CI test script
|
||||
#
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you
|
||||
# can redistribute it and/or modify it under the terms of either the GNU
|
||||
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||
# Version 2.0.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
set -e
|
||||
|
||||
export DRIVER_FLAGS='-j 0 --quiet --rerun'
|
||||
@@ -19,6 +21,12 @@ case $1 in
|
||||
vltmt)
|
||||
make -C test_regress SCENARIOS=--vltmt
|
||||
;;
|
||||
vltmt0)
|
||||
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=0/2
|
||||
;;
|
||||
vltmt1)
|
||||
make -C test_regress SCENARIOS=--vltmt DRIVER_HASHSET=--hashset=1/2
|
||||
;;
|
||||
*)
|
||||
echo "Usage: test.sh (dist|vlt|vltmt)"
|
||||
exit -1
|
||||
|
||||
+95
-12
@@ -1,12 +1,13 @@
|
||||
# DESCRIPTION: Process this file with autoconf to produce a configure script.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU Lesser
|
||||
# Copyright 2003-2020 by Wilson Snyder. Verilator 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
#AC_INIT([Verilator],[#.### YYYY-MM-DD])
|
||||
#AC_INIT([Verilator],[#.### devel])
|
||||
AC_INIT([Verilator],[4.026 2020-01-11],
|
||||
AC_INIT([Verilator],[4.032 2020-04-04],
|
||||
[https://verilator.org],
|
||||
[verilator],[https://verilator.org])
|
||||
# When releasing, also update header of Changes file
|
||||
@@ -25,11 +26,43 @@ AC_ARG_ENABLE([maintainer-mode],
|
||||
AC_ARG_ENABLE([silent-rules],
|
||||
[AS_HELP_STRING([--disable-silent-rules], [ignored])])
|
||||
|
||||
# Flag to enable linking specific libraries statically
|
||||
AC_MSG_CHECKING(whether to perform partial static linking of Verilator binary)
|
||||
AC_ARG_ENABLE([partial-static],
|
||||
[AS_HELP_STRING([--disable-partial-static],
|
||||
[By default, for Verilation peformance, Verilator
|
||||
is linked against some of its dependencies
|
||||
statically. Use this to link the Verilator binary
|
||||
fully dynamically.])],
|
||||
[case "${enableval}" in
|
||||
yes) CFG_ENABLE_PARTIAL_STATIC=yes ;;
|
||||
no) CFG_ENABLE_PARTIAL_STATIC=no ;;
|
||||
*) AC_MSG_ERROR([bad value '${enableval}' for --disable-partial-static]) ;;
|
||||
esac],
|
||||
CFG_ENABLE_PARTIAL_STATIC=yes)
|
||||
AC_MSG_RESULT($CFG_ENABLE_PARTIAL_STATIC)
|
||||
|
||||
# Flag to enable linking Verilator with tcmalloc if available
|
||||
AC_MSG_CHECKING(whether to use tcmalloc)
|
||||
AC_ARG_ENABLE([tcmalloc],
|
||||
[AS_HELP_STRING([--enable-tcmalloc],
|
||||
[Use libtcmalloc_minimal for faster dynamic memory
|
||||
management in Verilator binary@<:@default=check@:>@])],
|
||||
[case "${enableval}" in
|
||||
yes) CFG_WITH_TCMALLOC=yes ;;
|
||||
no) CFG_WITH_TCMALLOC=no ;;
|
||||
*) AC_MSG_ERROR([bad value '${enableval}' for --enable-tcmalloc]) ;;
|
||||
esac],
|
||||
[CFG_WITH_TCMALLOC=check;])
|
||||
AC_MSG_RESULT($CFG_WITH_TCMALLOC)
|
||||
|
||||
# Special Substitutions - CFG_WITH_DEFENV
|
||||
AC_MSG_CHECKING(whether to use hardcoded paths)
|
||||
AC_ARG_ENABLE([defenv],
|
||||
[AS_HELP_STRING([--disable-defenv],
|
||||
[disable using some hardcoded data paths extracted from some default environment variables (the default is to use hardcoded paths)])],
|
||||
[disable using some hardcoded data paths extracted
|
||||
from some default environment variables (the default
|
||||
is to use hardcoded paths) in Verilator binary])],
|
||||
[case "${enableval}" in
|
||||
yes) CFG_WITH_DEFENV=yes ;;
|
||||
no) CFG_WITH_DEFENV=no ;;
|
||||
@@ -43,7 +76,8 @@ AC_MSG_RESULT($CFG_WITH_DEFENV)
|
||||
AC_MSG_CHECKING(whether to show and stop on compilation warnings)
|
||||
AC_ARG_ENABLE([ccwarn],
|
||||
[AS_HELP_STRING([--enable-ccwarn],
|
||||
[enable showing and stopping on compilation warnings])],
|
||||
[enable showing and stopping on compilation warnings
|
||||
in Verilator binrary and Verilated makefiles])],
|
||||
[case "${enableval}" in
|
||||
yes) CFG_WITH_CCWARN=yes ;;
|
||||
no) CFG_WITH_CCWARN=no ;;
|
||||
@@ -79,7 +113,8 @@ AC_MSG_RESULT($CFG_WITH_LONGTESTS)
|
||||
AC_MSG_CHECKING(whether allow pre-C++11)
|
||||
AC_ARG_ENABLE([prec11],
|
||||
[AS_HELP_STRING([--enable-prec11],
|
||||
[enable pre-C++11 compilers])],
|
||||
[enable pre-C++11 compilers for Verilator binary
|
||||
and Verilated makefiles])],
|
||||
[case "${enableval}" in
|
||||
yes) CFG_WITH_PREC11=yes ;;
|
||||
no) CFG_WITH_PREC11=no ;;
|
||||
@@ -209,15 +244,26 @@ AC_DEFUN([_MY_LDLIBS_CHECK_FLAG],
|
||||
LIBS="$ACO_SAVE_LIBS"
|
||||
])
|
||||
|
||||
AC_DEFUN([_MY_LDLIBS_CHECK_OPT],
|
||||
[# _MY_LDLIBS_CHECK_OPT(flag) -- Check if linker supports specific options
|
||||
# If it does, append flag to variable
|
||||
_MY_LDLIBS_CHECK_FLAG($2)
|
||||
AC_DEFUN([_MY_LDLIBS_CHECK_IFELSE],
|
||||
[# _MY_LDLIBS_CHECK_IFELSE(flag,action-if-supported,action-if-not-supported)
|
||||
# Check if linker supports specific flag, if it does do action-if-supported
|
||||
# otherwise do action-if-not-supported
|
||||
_MY_LDLIBS_CHECK_FLAG($1)
|
||||
if test "$_my_result" = "yes" ; then
|
||||
$1="$$1 $2"
|
||||
true
|
||||
$2
|
||||
else
|
||||
true
|
||||
$3
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([_MY_LDLIBS_CHECK_OPT],
|
||||
[# _MY_LDLIBS_CHECK_OPT(variable, flag) -- Check if linker supports specific
|
||||
# options. If it does, append flag to variable.
|
||||
_MY_LDLIBS_CHECK_IFELSE($2, $1="$$1 $2")
|
||||
])
|
||||
|
||||
# Flag to select newest language standard supported
|
||||
# Macros work such that first option that passes is the one we take
|
||||
# gnu++17 code is clean, but SystemC in 2018 doesn't link with it (bug1339)
|
||||
@@ -256,7 +302,6 @@ AC_SUBST(CFG_CXXFLAGS_WEXTRA)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Qunused-arguments)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-faligned-new)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-unused-parameter)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-undefined-bool-conversion)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-shadow)
|
||||
AC_SUBST(CFG_CXXFLAGS_SRC)
|
||||
|
||||
@@ -310,6 +355,44 @@ m4_foreach([ldflag], [
|
||||
AC_SUBST(CFG_LDLIBS_THREADS)
|
||||
AC_SUBST(CFG_LDFLAGS_THREADS_CMAKE)
|
||||
|
||||
# When linking partially statically
|
||||
if test "$CFG_ENABLE_PARTIAL_STATIC" = "yes"; then
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -static-libgcc)
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -static-libstdc++)
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LDFLAGS_SRC, -Xlinker -gc-sections)
|
||||
LTCMALLOC=-l:libtcmalloc_minimal.a
|
||||
else
|
||||
LTCMALLOC=-ltcmalloc_minimal
|
||||
fi
|
||||
AC_SUBST(CFG_LDFLAGS_SRC)
|
||||
|
||||
# The pthread library is required by tcmalloc, so add it if it exists. If it
|
||||
# does not, the tcmalloc check below will fail anyway, and linking against
|
||||
# pthreads is harmless otherwise.
|
||||
CFG_LIBS="$LIBS $CFG_LIBS"
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LIBS, -lpthread)
|
||||
|
||||
# Check libraries for MingW
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LIBS, -lbcrypt)
|
||||
_MY_LDLIBS_CHECK_OPT(CFG_LIBS, -lpsapi)
|
||||
|
||||
# Check if tcmalloc is available based on --enable-tcmalloc
|
||||
_MY_LDLIBS_CHECK_IFELSE(
|
||||
$LTCMALLOC,
|
||||
[if test "$CFG_WITH_TCMALLOC" != "no"; then
|
||||
CFG_LIBS="$LTCMALLOC $CFG_LIBS";
|
||||
# If using tcmalloc, add some extra options to make the compiler not assume
|
||||
# it is using it's own versions of the standard library functions
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-malloc)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-calloc)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-realloc)
|
||||
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-fno-builtin-free)
|
||||
fi],
|
||||
[if test "$CFG_WITH_TCMALLOC" = "yes"; then
|
||||
AC_MSG_ERROR([--enable-tcmalloc was given but test for ${LTCMALLOC} failed])
|
||||
fi])
|
||||
AC_SUBST(CFG_LIBS)
|
||||
|
||||
# Set CFG_WITH_THREADED if can support threading
|
||||
AC_MSG_CHECKING(whether $CXX supports Verilated threads)
|
||||
ACO_SAVE_CXXFLAGS="$CXXFLAGS"
|
||||
|
||||
@@ -11,7 +11,7 @@ contributions flow more efficiently.
|
||||
https://verilator.org/issues[Verilator Issues].
|
||||
|
||||
* If you're unable to find an open issue addressing the problem,
|
||||
https://verilator.org/issues/new[open a new issue].
|
||||
https://verilator.org/issues/new[open a new Verilator issue].
|
||||
|
||||
** Be sure to include a **code sample** or an **executable test case**
|
||||
demonstrating the bug and expected behavior that is not occurring.
|
||||
@@ -50,13 +50,13 @@ contributions flow more efficiently.
|
||||
link:CONTRIBUTORS[docs/CONTRIBUTORS] and you are agreeing all future
|
||||
contributions are also certified.
|
||||
|
||||
** We occasionally accept contributions where people do not want their
|
||||
name published. Please email us; you must still certify your
|
||||
contribution using email.
|
||||
** We occasionally accept contributions where people do not want their name
|
||||
published. Please email us; you must still privately certify your
|
||||
contribution.
|
||||
|
||||
* Your test contributions are generally considered released into the public
|
||||
domain, unless you request otherwise or put a GNU/Artistic license on
|
||||
your test file.
|
||||
* Your test contributions are generally considered released into the
|
||||
Creative Commons Public Domain (CC0), unless you request otherwise or put
|
||||
a GNU/Artistic license on your file.
|
||||
|
||||
* Most important is we get your patch. If you'd like to clean up
|
||||
indentation and related issues ahead of our feedback, that is
|
||||
|
||||
+9
-1
@@ -8,9 +8,11 @@ all.
|
||||
Ahmed El-Mahmoudy
|
||||
Alex Chadwick
|
||||
Chris Randall
|
||||
David Stanford
|
||||
Driss Hafdi
|
||||
Eric Rippey
|
||||
Garrett Smith
|
||||
Geza Lore
|
||||
Gianfranco Costamagna
|
||||
Howard Su
|
||||
Iztok Jeras
|
||||
@@ -22,14 +24,20 @@ Kevin Kiningham
|
||||
Kuba Ober
|
||||
Lukasz Dalek
|
||||
Maarten De Braekeleer
|
||||
Maciej Sobkowski
|
||||
Marco Widmer
|
||||
Matthew Ballance
|
||||
Mike Popoloski
|
||||
Peter Monsson
|
||||
Patrick Stewart
|
||||
Peter Monsson
|
||||
Philipp Wagner
|
||||
Pieter Kapsenberg
|
||||
Richard Myers
|
||||
Sean Cross
|
||||
Sebastien Van Cauwenberghe
|
||||
Stefan Wallentowitz
|
||||
Tobias Rosenkranz
|
||||
Tobias Wölfel
|
||||
Todd Strader
|
||||
Wilson Snyder
|
||||
Yutetsu TAKATSUKASA
|
||||
|
||||
+3
-7
@@ -7,15 +7,11 @@
|
||||
#
|
||||
#*****************************************************************************
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
#****************************************************************************/
|
||||
#
|
||||
|
||||
@@ -4,6 +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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
* Language support:
|
||||
** Fix ordering of each bit separately in a signal (mips)
|
||||
@@ -22,17 +23,10 @@
|
||||
** Assertions
|
||||
** Tristate support
|
||||
|
||||
* Configure/Make/Install
|
||||
** Distribute with flex/bison already expanded?
|
||||
Flex library not needed. Probably too difficult to be worth it.
|
||||
|
||||
* Testing:
|
||||
** Capture all inputs into global "rerun it" file
|
||||
** Code to make wrapper that sets signals, so can do comparison checks
|
||||
** New random program generator
|
||||
** Better graph viewer with search and zoom
|
||||
** Port and test against opencores.org code
|
||||
** // verilator debug in code so can see only tree affecting those nodes
|
||||
|
||||
* Usability:
|
||||
** Detect and pre-remove most UNOPTFLATs
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
clang-format is used to standardize the indentation of the internal C++
|
||||
code.
|
||||
|
||||
For the most part clang-format changes provide good consistency, the two
|
||||
main exceptions being the indentation of preprocessor directives, and
|
||||
tables of statements.
|
||||
|
||||
Reformatting is generally performed only before other large changes are to
|
||||
be made to a file. The following files are not yet clang-format clean:
|
||||
|
||||
clang-format -i include/verilated.h
|
||||
clang-format -i include/verilated_dpi.h
|
||||
clang-format -i include/verilated_fst_c.h
|
||||
clang-format -i include/verilated_heavy.h
|
||||
clang-format -i include/verilated_imp.h
|
||||
clang-format -i include/verilated_save.h
|
||||
clang-format -i include/verilated_sym_props.h
|
||||
clang-format -i include/verilated_unordered_set_map.h
|
||||
clang-format -i include/verilated_vcd_c.h
|
||||
clang-format -i include/verilatedos.h
|
||||
|
||||
clang-format -i include/verilated.cpp
|
||||
clang-format -i include/verilated_cov.cpp
|
||||
clang-format -i include/verilated_dpi.cpp
|
||||
clang-format -i include/verilated_fst_c.cpp
|
||||
clang-format -i include/verilated_save.cpp
|
||||
clang-format -i include/verilated_threads.cpp
|
||||
clang-format -i include/verilated_vcd_c.cpp
|
||||
clang-format -i include/verilated_vpi.cpp
|
||||
|
||||
clang-format -i src/V3Ast.h
|
||||
clang-format -i src/V3AstNodes.h
|
||||
clang-format -i src/V3EmitCBase.h
|
||||
clang-format -i src/V3Error.h
|
||||
clang-format -i src/V3File.h
|
||||
clang-format -i src/V3FileLine.h
|
||||
clang-format -i src/V3Global.h
|
||||
clang-format -i src/V3Graph.h
|
||||
clang-format -i src/V3GraphDfa.h
|
||||
clang-format -i src/V3GraphStream.h
|
||||
clang-format -i src/V3Hashed.h
|
||||
clang-format -i src/V3LanguageWords.h
|
||||
clang-format -i src/V3LinkDot.h
|
||||
clang-format -i src/V3List.h
|
||||
clang-format -i src/V3Number.h
|
||||
clang-format -i src/V3Options.h
|
||||
clang-format -i src/V3OrderGraph.h
|
||||
clang-format -i src/V3Os.h
|
||||
clang-format -i src/V3ParseImp.h
|
||||
clang-format -i src/V3ParseSym.h
|
||||
clang-format -i src/V3Partition.h
|
||||
clang-format -i src/V3PartitionGraph.h
|
||||
clang-format -i src/V3PreLex.h
|
||||
clang-format -i src/V3PreProc.h
|
||||
clang-format -i src/V3Scoreboard.h
|
||||
clang-format -i src/V3SenTree.h
|
||||
clang-format -i src/V3Simulate.h
|
||||
clang-format -i src/V3Stats.h
|
||||
clang-format -i src/V3String.h
|
||||
clang-format -i src/V3SymTable.h
|
||||
clang-format -i src/V3TSP.h
|
||||
clang-format -i src/V3Task.h
|
||||
clang-format -i src/V3WidthCommit.h
|
||||
|
||||
clang-format -i src/V3Active.cpp
|
||||
clang-format -i src/V3ActiveTop.cpp
|
||||
clang-format -i src/V3Assert.cpp
|
||||
clang-format -i src/V3AssertPre.cpp
|
||||
clang-format -i src/V3Ast.cpp
|
||||
clang-format -i src/V3AstNodes.cpp
|
||||
clang-format -i src/V3Begin.cpp
|
||||
clang-format -i src/V3Branch.cpp
|
||||
clang-format -i src/V3Broken.cpp
|
||||
clang-format -i src/V3CCtors.cpp
|
||||
clang-format -i src/V3Case.cpp
|
||||
clang-format -i src/V3Cast.cpp
|
||||
clang-format -i src/V3Cdc.cpp
|
||||
clang-format -i src/V3Changed.cpp
|
||||
clang-format -i src/V3Clean.cpp
|
||||
clang-format -i src/V3Clock.cpp
|
||||
clang-format -i src/V3Combine.cpp
|
||||
clang-format -i src/V3Const.cpp
|
||||
clang-format -i src/V3Coverage.cpp
|
||||
clang-format -i src/V3CoverageJoin.cpp
|
||||
clang-format -i src/V3Dead.cpp
|
||||
clang-format -i src/V3Delayed.cpp
|
||||
clang-format -i src/V3Depth.cpp
|
||||
clang-format -i src/V3DepthBlock.cpp
|
||||
clang-format -i src/V3EmitC.cpp
|
||||
clang-format -i src/V3EmitCInlines.cpp
|
||||
clang-format -i src/V3EmitCMake.cpp
|
||||
clang-format -i src/V3EmitCSyms.cpp
|
||||
clang-format -i src/V3EmitMk.cpp
|
||||
clang-format -i src/V3EmitV.cpp
|
||||
clang-format -i src/V3EmitXml.cpp
|
||||
clang-format -i src/V3Error.cpp
|
||||
clang-format -i src/V3Expand.cpp
|
||||
clang-format -i src/V3File.cpp
|
||||
clang-format -i src/V3FileLine.cpp
|
||||
clang-format -i src/V3Gate.cpp
|
||||
clang-format -i src/V3GenClk.cpp
|
||||
clang-format -i src/V3Graph.cpp
|
||||
clang-format -i src/V3GraphAcyc.cpp
|
||||
clang-format -i src/V3GraphAlg.cpp
|
||||
clang-format -i src/V3GraphDfa.cpp
|
||||
clang-format -i src/V3GraphPathChecker.cpp
|
||||
clang-format -i src/V3GraphTest.cpp
|
||||
clang-format -i src/V3Hashed.cpp
|
||||
clang-format -i src/V3Inline.cpp
|
||||
clang-format -i src/V3Inst.cpp
|
||||
clang-format -i src/V3InstrCount.cpp
|
||||
clang-format -i src/V3Life.cpp
|
||||
clang-format -i src/V3LifePost.cpp
|
||||
clang-format -i src/V3LinkCells.cpp
|
||||
clang-format -i src/V3LinkDot.cpp
|
||||
clang-format -i src/V3LinkJump.cpp
|
||||
clang-format -i src/V3LinkLValue.cpp
|
||||
clang-format -i src/V3LinkLevel.cpp
|
||||
clang-format -i src/V3LinkParse.cpp
|
||||
clang-format -i src/V3LinkResolve.cpp
|
||||
clang-format -i src/V3Localize.cpp
|
||||
clang-format -i src/V3Name.cpp
|
||||
clang-format -i src/V3Number.cpp
|
||||
clang-format -i src/V3Number_test.cpp
|
||||
clang-format -i src/V3Options.cpp
|
||||
clang-format -i src/V3Order.cpp
|
||||
clang-format -i src/V3Os.cpp
|
||||
clang-format -i src/V3Param.cpp
|
||||
clang-format -i src/V3ParseGrammar.cpp
|
||||
clang-format -i src/V3ParseImp.cpp
|
||||
clang-format -i src/V3ParseLex.cpp
|
||||
clang-format -i src/V3Partition.cpp
|
||||
clang-format -i src/V3PreProc.cpp
|
||||
clang-format -i src/V3PreShell.cpp
|
||||
clang-format -i src/V3Premit.cpp
|
||||
clang-format -i src/V3ProtectLib.cpp
|
||||
clang-format -i src/V3Reloop.cpp
|
||||
clang-format -i src/V3Scope.cpp
|
||||
clang-format -i src/V3Scoreboard.cpp
|
||||
clang-format -i src/V3Slice.cpp
|
||||
clang-format -i src/V3Split.cpp
|
||||
clang-format -i src/V3SplitAs.cpp
|
||||
clang-format -i src/V3SplitVar.cpp
|
||||
clang-format -i src/V3Stats.cpp
|
||||
clang-format -i src/V3StatsReport.cpp
|
||||
clang-format -i src/V3String.cpp
|
||||
clang-format -i src/V3Subst.cpp
|
||||
clang-format -i src/V3TSP.cpp
|
||||
clang-format -i src/V3Table.cpp
|
||||
clang-format -i src/V3Task.cpp
|
||||
clang-format -i src/V3Trace.cpp
|
||||
clang-format -i src/V3TraceDecl.cpp
|
||||
clang-format -i src/V3Tristate.cpp
|
||||
clang-format -i src/V3Undriven.cpp
|
||||
clang-format -i src/V3Unknown.cpp
|
||||
clang-format -i src/V3Unroll.cpp
|
||||
clang-format -i src/V3Width.cpp
|
||||
clang-format -i src/V3WidthSel.cpp
|
||||
clang-format -i src/Verilator.cpp
|
||||
+8
-1
@@ -84,6 +84,10 @@ To build Verilator you will need to install some standard packages:
|
||||
sudo apt-get install autoconf
|
||||
sudo apt-get install flex bison
|
||||
|
||||
The following are optional, but improve compilation speed:
|
||||
|
||||
sudo apt-get install libgoogle-perftools-dev
|
||||
|
||||
Additionally, to build or run Verilator you need these standard packages:
|
||||
|
||||
sudo apt-get install perl python3
|
||||
@@ -94,9 +98,11 @@ Additionally, to build or run Verilator you need these standard packages:
|
||||
|
||||
Those developing Verilator may also want these (see internals.adoc):
|
||||
|
||||
sudo apt-get install gdb asciidoctor graphviz
|
||||
sudo apt-get install gdb asciidoctor graphviz cmake
|
||||
cpan install Pod::Perldoc
|
||||
cpan install Unix::Processors
|
||||
cpan install Parallel::Forker
|
||||
cpan install Bit::Vector
|
||||
|
||||
==== Install SystemC
|
||||
|
||||
@@ -297,3 +303,4 @@ or https://verilator.org/verilator_doc.pdf[Verilator manual (PDF)].
|
||||
Copyright 2008-2020 by Wilson Snyder. Verilator 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
+20
-4
@@ -70,7 +70,10 @@ The AST is represented at the top level by the class `AstNode`. This
|
||||
abstract class has derived classes for the individual components
|
||||
(e.g. `AstGenerate` for a generate block) or groups of components
|
||||
(e.g. `AstNodeFTask` for functions and tasks, which in turn has `AstFunc`
|
||||
and `AstTask` as derived classes).
|
||||
and `AstTask` as derived classes). An important property of the `AstNode`
|
||||
type hierarchy is that all non-final subclasses of `AstNode` (i.e.: those
|
||||
which themselves have subclasses) must be abstract as well, and be named
|
||||
with the prefix `AstNode*`. The `astgen` (see below) script relies on this.
|
||||
|
||||
Each `AstNode` has pointers to up to four children, accessed by the `op1p`
|
||||
through `op4p` methods. These methods are then abstracted in a specific
|
||||
@@ -394,7 +397,7 @@ e.g. threads.
|
||||
We will work with contributors to fix up indentation style issues, but it
|
||||
is appreciated if you could match our style:
|
||||
|
||||
* All files should contain the magic header to insure standard indentation:
|
||||
* All files should contain the magic header to ensure standard indentation:
|
||||
+
|
||||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
+
|
||||
@@ -622,13 +625,17 @@ with e.g. "sudo cpan install Parallel::Forker".
|
||||
* vcddiff to find differences in VCD outputs. See the readme at
|
||||
https://github.com/veripool/vcddiff
|
||||
|
||||
* Cmake for build paths that use it.
|
||||
|
||||
* Bit::Vector to test vgen.pl
|
||||
|
||||
=== Controlling the Test Driver
|
||||
|
||||
Test drivers are written in PERL. All invoke the main test driver script,
|
||||
which can provide detailed help on all the features available when writing
|
||||
a test driver.
|
||||
|
||||
test_regress/t/driver.pl --help
|
||||
test_regress/driver.pl --help
|
||||
|
||||
For convenience, a summary of the most commonly used features is provided
|
||||
here. All drivers require a call to `compile` subroutine to compile the
|
||||
@@ -713,6 +720,13 @@ respectively 16,384 and 4,096. The method of doing this is system
|
||||
dependent, but on Fedora Linux it would require editing the
|
||||
`/etc/security/limits.conf` file as root.
|
||||
|
||||
=== Manual Test Execution
|
||||
|
||||
A specific regression test can be executed manually. To start the "EXAMPLE"
|
||||
test, run the following command.
|
||||
|
||||
test_regress/t/t_EXAMPLE.pl
|
||||
|
||||
=== Continuous Integration
|
||||
|
||||
Verilator has a https://travis-ci.com/verilator/verilator[Travis CI environment]
|
||||
@@ -959,7 +973,8 @@ src/VParseGrammar.y, as this grammar supports the full SystemVerilog
|
||||
language and has a lot of back-and-forth with Verilator's grammar. Copy
|
||||
the appropriate rules to src/verilog.y and modify the productions.
|
||||
|
||||
. If a new Ast type is needed, add it to V3AstNodes.h.
|
||||
. If a new Ast type is needed, add it to V3AstNodes.h. Follow the convention
|
||||
described above about the AstNode type hierarchy.
|
||||
|
||||
. Now you can run "test_regress/t/t_{new testcase}.pl --debug" and it'll
|
||||
probably fail but you'll see a test_regress/obj_dir/t_{newtestcase}/*.tree
|
||||
@@ -983,3 +998,4 @@ list in `src/Makefile_obj.in` and reconfigure.
|
||||
Copyright 2008-2020 by Wilson Snyder. Verilator 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
= Verilator XML Output
|
||||
:toc: right
|
||||
|
||||
// Github doesn't render unless absolute URL
|
||||
image::https://www.veripool.org/img/verilator_256_200_min.png[Logo,256,200,role="right"]
|
||||
|
||||
== Introduction
|
||||
|
||||
This document describes Verilator's XML output. For more general information
|
||||
please see https://verilator.org[verilator.org].
|
||||
|
||||
== General
|
||||
|
||||
Verilator's XML output is enabled with the `--xml-only` flag. It contains
|
||||
limited information about the elaborated design including files, modules,
|
||||
instance hierarchy, logic and data types. There is no formal schema since part
|
||||
of the structure of the XML document matches the compiled code which would
|
||||
require the schema to describe legal SystemVerilog structure. The intended
|
||||
usage is to enable other downstream tools to take advantage of Verilator's
|
||||
parser.
|
||||
|
||||
== Structure
|
||||
|
||||
The XML document is consists of 4 sections within the top level `verilator_xml`
|
||||
element:
|
||||
|
||||
`<files>`...`</files>`::
|
||||
|
||||
This section contains a list of all design files read, including the
|
||||
built-in constructs and the command line as their own entries. Each
|
||||
`<file>` has an attribute `id` which is a short ASCII string unique to that
|
||||
file. Other elements' `loc` attributes use this id to refer to a particular
|
||||
file.
|
||||
|
||||
`<module_files>`...`</module_files>`::
|
||||
|
||||
All files containing Verilog module definitions are listed in this section.
|
||||
This element's contents is a subset of the `<files>` element's contents.
|
||||
|
||||
`<cells>`...`</cells>`::
|
||||
|
||||
The cells section of the XML document contains the design instance
|
||||
hierarchy. Each instance is represented with the `<cell>` element with the
|
||||
following attributes:
|
||||
|
||||
* `fl` (deprecated): The file id and line number where the module was
|
||||
instanced. Use `loc` instead.
|
||||
|
||||
* `loc`: The file id, first line number, last line number, first column
|
||||
number and last column number of the identifier where the module was
|
||||
instanced, separated by commas.
|
||||
|
||||
* `name`: The instance name.
|
||||
|
||||
* `submodname`: The module name uniquified with particular parameter values (if any).
|
||||
|
||||
* `hier`: The full hierarchy path.
|
||||
|
||||
`<netlist>`...`</netlist>`::
|
||||
|
||||
The netlist section contains a number of `<module>`...`</module>` elements,
|
||||
each describing the contents of that module, and a single `<typetable>`...
|
||||
`</typetable>` element which lists all used types used within the
|
||||
modules. Each type has a numeric `id` attribute that is referred to by
|
||||
elements in the `<module>` elements using the `dtype_id` attribute.
|
||||
|
||||
== Distribution
|
||||
|
||||
Copyright 2020-2020 by Wilson Snyder. Verilator 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
@@ -5,10 +5,11 @@
|
||||
# This is an example cmake script to build a verilog to systemc project
|
||||
# using cmake and verilator.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
# This makefile is here for testing the examples and should
|
||||
# generally not be added to a CMake project.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This is an example cmake script to build a verilog to SystemC project
|
||||
# using CMake and Verilator.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
# This makefile is here for testing the examples and should
|
||||
# generally not be added to a CMake project.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This is an example cmake script to build a verilog to systemc project
|
||||
# using cmake and verilator.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
# This makefile is here for testing the examples and should
|
||||
# generally not be added to a CMake project.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This is an example cmake script to build a verilog to systemc project
|
||||
# using cmake and verilator.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
@@ -34,5 +35,5 @@ add_executable(example ../make_tracing_c/sim_main.cpp)
|
||||
# Add the Verilated circuit to the target
|
||||
verilate(example COVERAGE TRACE
|
||||
INCLUDE_DIRS "../make_tracing_c"
|
||||
VERILATOR_ARGS -f ../make_tracing_c/input.vc -O2 -x-assign 0
|
||||
VERILATOR_ARGS -f ../make_tracing_c/input.vc -Os -x-assign 0
|
||||
SOURCES ../make_tracing_c/top.v)
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
# This makefile is here for testing the examples and should
|
||||
# generally not be added to a CMake project.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This is an example cmake script to build a verilog to SystemC project
|
||||
# using CMake and Verilator.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
@@ -41,7 +42,7 @@ add_executable(example ../make_tracing_sc/sc_main.cpp)
|
||||
# Add the Verilated circuit to the target
|
||||
verilate(example SYSTEMC COVERAGE TRACE
|
||||
INCLUDE_DIRS "../make_tracing_sc"
|
||||
VERILATOR_ARGS -f ../make_tracing_sc/input.vc -O2 -x-assign 0
|
||||
VERILATOR_ARGS -f ../make_tracing_sc/input.vc -Os -x-assign 0
|
||||
SOURCES ../make_tracing_sc/top.v)
|
||||
|
||||
verilator_link_systemc(example)
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
# This makefile is here for testing the examples and should
|
||||
# generally not be added to a CMake project.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This calls the object directory makefile. That allows the objects to
|
||||
# be placed in the "current directory" which simplifies the Makefile.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
# Check for sanity to avoid later confusion
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//======================================================================
|
||||
|
||||
// Include common routines
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// See also the EXAMPLE section in the verilator manpage/document.
|
||||
module top;
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This calls the object directory makefile. That allows the objects to
|
||||
# be placed in the "current directory" which simplifies the Makefile.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
# Check for sanity to avoid later confusion
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// -*- SystemC -*-
|
||||
// DESCRIPTION: Verilator Example: Top level main for invoking SystemC model
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//======================================================================
|
||||
|
||||
// SystemC global header
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// See also the EXAMPLE section in the verilator manpage/document.
|
||||
module top;
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This calls the object directory makefiles. That allows the objects to
|
||||
# be placed in the "current directory" which simplifies the Makefile.
|
||||
#
|
||||
# Copyright 2019 by Todd Strader. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2019 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
# Check for sanity to avoid later confusion
|
||||
@@ -34,7 +35,7 @@ VERILATOR_FLAGS =
|
||||
# Generate C++
|
||||
VERILATOR_FLAGS += -cc
|
||||
# Optimize
|
||||
VERILATOR_FLAGS += -O2 -x-assign 0
|
||||
VERILATOR_FLAGS += -Os -x-assign 0
|
||||
# Warn abount lint issues; may not want this on less solid designs
|
||||
VERILATOR_FLAGS += -Wall
|
||||
# Make waveforms
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: --protect-lib example secret module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Todd Strader.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Todd Strader.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// This module will be used as libsecret.a or libsecret.so without
|
||||
// exposing the source.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: --protect-lib example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Todd Strader.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Todd Strader.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//======================================================================
|
||||
|
||||
// See examples/tracing_c for notes on tracing
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: --protect-lib example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Todd Strader.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Todd Strader.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
// See also the EXAMPLE section in the verilator manpage/document.
|
||||
module top (input clk);
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This calls the object directory makefile. That allows the objects to
|
||||
# be placed in the "current directory" which simplifies the Makefile.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
# Check for sanity to avoid later confusion
|
||||
@@ -38,7 +39,7 @@ VERILATOR_FLAGS += -cc --exe
|
||||
# Generate makefile dependencies (not shown as complicates the Makefile)
|
||||
#VERILATOR_FLAGS += -MMD
|
||||
# Optimize
|
||||
VERILATOR_FLAGS += -O2 -x-assign 0
|
||||
VERILATOR_FLAGS += -Os -x-assign 0
|
||||
# Warn abount lint issues; may not want this on less solid designs
|
||||
VERILATOR_FLAGS += -Wall
|
||||
# Make waveforms
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
#
|
||||
# This is executed in the object directory, and called by ../Makefile
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
@@ -38,7 +39,7 @@ endif
|
||||
# SystemC takes minutes to optimize, thus it is off by default.
|
||||
OPT_SLOW =
|
||||
# Fast path optimizations. Most time is spent in these classes.
|
||||
OPT_FAST = -O2 -fstrict-aliasing
|
||||
OPT_FAST = -Os -fstrict-aliasing
|
||||
#OPT_FAST = -O
|
||||
#OPT_FAST =
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//======================================================================
|
||||
|
||||
// Include common routines
|
||||
@@ -10,11 +11,6 @@
|
||||
// Include model header, generated from Verilating "top.v"
|
||||
#include "Vtop.h"
|
||||
|
||||
// If "verilator --trace" is used, include the tracing class
|
||||
#if VM_TRACE
|
||||
# include <verilated_vcd_c.h>
|
||||
#endif
|
||||
|
||||
// Current simulation time (64-bit unsigned)
|
||||
vluint64_t main_time = 0;
|
||||
// Called by $time in Verilog
|
||||
@@ -36,31 +32,21 @@ int main(int argc, char** argv, char** env) {
|
||||
// May be overridden by commandArgs
|
||||
Verilated::randReset(2);
|
||||
|
||||
// Verilator must compute traced signals
|
||||
Verilated::traceEverOn(true);
|
||||
|
||||
// Pass arguments so Verilated code can see them, e.g. $value$plusargs
|
||||
// This needs to be called before you create any model
|
||||
Verilated::commandArgs(argc, argv);
|
||||
|
||||
// Create logs/ directory in case we have traces to put under it
|
||||
Verilated::mkdir("logs");
|
||||
|
||||
// Construct the Verilated model, from Vtop.h generated from Verilating "top.v"
|
||||
Vtop* top = new Vtop; // Or use a const unique_ptr, or the VL_UNIQUE_PTR wrapper
|
||||
|
||||
#if VM_TRACE
|
||||
// If verilator was invoked with --trace argument,
|
||||
// and if at run time passed the +trace argument, turn on tracing
|
||||
VerilatedVcdC* tfp = NULL;
|
||||
const char* flag = Verilated::commandArgsPlusMatch("trace");
|
||||
if (flag && 0==strcmp(flag, "+trace")) {
|
||||
Verilated::traceEverOn(true); // Verilator must compute traced signals
|
||||
VL_PRINTF("Enabling waves into logs/vlt_dump.vcd...\n");
|
||||
tfp = new VerilatedVcdC;
|
||||
top->trace(tfp, 99); // Trace 99 levels of hierarchy
|
||||
Verilated::mkdir("logs");
|
||||
tfp->open("logs/vlt_dump.vcd"); // Open the dump file
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set some inputs
|
||||
top->reset_l = !0;
|
||||
top->fastclk = 0;
|
||||
top->clk = 0;
|
||||
top->in_small = 1;
|
||||
top->in_quad = 0x1234;
|
||||
@@ -72,31 +58,29 @@ int main(int argc, char** argv, char** env) {
|
||||
while (!Verilated::gotFinish()) {
|
||||
main_time++; // Time passes...
|
||||
|
||||
// Toggle clocks and such
|
||||
top->fastclk = !top->fastclk;
|
||||
if ((main_time % 10) == 3) {
|
||||
top->clk = 1;
|
||||
}
|
||||
if ((main_time % 10) == 8) {
|
||||
top->clk = 0;
|
||||
}
|
||||
if (main_time > 1 && main_time < 10) {
|
||||
top->reset_l = !1; // Assert reset
|
||||
} else {
|
||||
top->reset_l = !0; // Deassert reset
|
||||
}
|
||||
// Toggle a fast (time/2 period) clock
|
||||
top->clk = !top->clk;
|
||||
|
||||
// Assign some other inputs
|
||||
top->in_quad += 0x12;
|
||||
// Toggle control signals on an edge that doesn't correspond
|
||||
// to where the controls are sampled; in this example we do
|
||||
// this only on a negedge of clk, because we know
|
||||
// reset is not sampled there.
|
||||
if (!top->clk) {
|
||||
if (main_time > 1 && main_time < 10) {
|
||||
top->reset_l = !1; // Assert reset
|
||||
} else {
|
||||
top->reset_l = !0; // Deassert reset
|
||||
}
|
||||
// Assign some other inputs
|
||||
top->in_quad += 0x12;
|
||||
}
|
||||
|
||||
// Evaluate model
|
||||
// (If you have multiple models being simulated in the same
|
||||
// timestep then instead of eval(), call eval_step() on each, then
|
||||
// eval_end_step() on each.)
|
||||
top->eval();
|
||||
|
||||
#if VM_TRACE
|
||||
// Dump trace data for this cycle
|
||||
if (tfp) tfp->dump(main_time);
|
||||
#endif
|
||||
|
||||
// Read outputs
|
||||
VL_PRINTF("[%" VL_PRI64 "d] clk=%x rstl=%x iquad=%" VL_PRI64 "x"
|
||||
" -> oquad=%" VL_PRI64"x owide=%x_%08x_%08x\n",
|
||||
@@ -107,11 +91,6 @@ int main(int argc, char** argv, char** env) {
|
||||
// Final model cleanup
|
||||
top->final();
|
||||
|
||||
// Close trace if opened
|
||||
#if VM_TRACE
|
||||
if (tfp) { tfp->close(); tfp = NULL; }
|
||||
#endif
|
||||
|
||||
// Coverage analysis (since test passed)
|
||||
#if VM_COVERAGE
|
||||
Verilated::mkdir("logs");
|
||||
|
||||
@@ -1,31 +1,17 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2003 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
module sub
|
||||
(
|
||||
input clk,
|
||||
input fastclk,
|
||||
input reset_l
|
||||
);
|
||||
|
||||
// Example counter/flop
|
||||
reg [31:0] count_f;
|
||||
always_ff @ (posedge fastclk) begin
|
||||
if (!reset_l) begin
|
||||
/*AUTORESET*/
|
||||
// Beginning of autoreset for uninitialized flops
|
||||
count_f <= 32'h0;
|
||||
// End of automatics
|
||||
end
|
||||
else begin
|
||||
count_f <= count_f + 1;
|
||||
end
|
||||
end
|
||||
|
||||
// Another example flop
|
||||
reg [31:0] count_c;
|
||||
always_ff @ (posedge clk) begin
|
||||
if (!reset_l) begin
|
||||
@@ -37,8 +23,6 @@ module sub
|
||||
else begin
|
||||
count_c <= count_c + 1;
|
||||
if (count_c >= 3) begin
|
||||
$display("[%0t] fastclk is %0d times faster than clk\n",
|
||||
$time, count_f/count_c);
|
||||
// This write is a magic value the Makefile uses to make sure the
|
||||
// test completes successfully.
|
||||
$write("*-* All Finished *-*\n");
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2003 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
// This is intended to be a complex example of several features, please also
|
||||
@@ -11,7 +12,6 @@ module top
|
||||
(
|
||||
// Declare some signals so we can see how I/O works
|
||||
input clk,
|
||||
input fastclk,
|
||||
input reset_l,
|
||||
|
||||
output wire [1:0] out_small,
|
||||
@@ -31,11 +31,15 @@ module top
|
||||
sub sub (/*AUTOINST*/
|
||||
// Inputs
|
||||
.clk (clk),
|
||||
.fastclk (fastclk),
|
||||
.reset_l (reset_l));
|
||||
|
||||
// Print some stuff as an example
|
||||
initial begin
|
||||
if ($test$plusargs("trace") != 0) begin
|
||||
$display("[%0t] Tracing to logs/vlt_dump.vcd...\n", $time);
|
||||
$dumpfile("logs/vlt_dump.vcd");
|
||||
$dumpvars();
|
||||
end
|
||||
$display("[%0t] Model running...\n", $time);
|
||||
end
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
# This calls the object directory makefile. That allows the objects to
|
||||
# be placed in the "current directory" which simplifies the Makefile.
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
# Check for sanity to avoid later confusion
|
||||
@@ -38,7 +39,7 @@ VERILATOR_FLAGS += -sc --exe
|
||||
# Generate makefile dependencies (not shown as complicates the Makefile)
|
||||
#VERILATOR_FLAGS += -MMD
|
||||
# Optimize
|
||||
VERILATOR_FLAGS += -O2 -x-assign 0
|
||||
VERILATOR_FLAGS += -Os -x-assign 0
|
||||
# Warn abount lint issues; may not want this on less solid designs
|
||||
VERILATOR_FLAGS += -Wall
|
||||
# Make waveforms
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
#
|
||||
# This is executed in the object directory, and called by ../Makefile
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
@@ -46,7 +47,7 @@ endif
|
||||
# SystemC takes minutes to optimize, thus it is off by default.
|
||||
OPT_SLOW =
|
||||
# Fast path optimizations. Most time is spent in these classes.
|
||||
OPT_FAST = -O2 -fstrict-aliasing
|
||||
OPT_FAST = -Os -fstrict-aliasing
|
||||
#OPT_FAST = -O
|
||||
#OPT_FAST =
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// -*- SystemC -*-
|
||||
// DESCRIPTION: Verilator Example: Top level main for invoking SystemC model
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2017 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2017 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
//======================================================================
|
||||
|
||||
// SystemC global header
|
||||
@@ -37,6 +38,9 @@ int sc_main(int argc, char* argv[]) {
|
||||
// This needs to be called before you create any model
|
||||
Verilated::commandArgs(argc, argv);
|
||||
|
||||
// Create logs/ directory in case we have traces to put under it
|
||||
Verilated::mkdir("logs");
|
||||
|
||||
// General logfile
|
||||
ios::sync_with_stdio();
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2003 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
module sub
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2003 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2003 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
// This is intended to be a complex example of several features, please also
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
#
|
||||
# DESCRIPTION: Verilator Example: XML tests
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
module sub
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// DESCRIPTION: Verilator: Verilog example module
|
||||
//
|
||||
// This file ONLY is placed into the Public Domain, for any use,
|
||||
// without warranty, 2019 by Wilson Snyder.
|
||||
// This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
// any use, without warranty, 2019 by Wilson Snyder.
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
// ======================================================================
|
||||
|
||||
module top
|
||||
|
||||
@@ -84,8 +84,10 @@ Example usage:
|
||||
-v <filename> Verilog library
|
||||
-y <dir> Directory to search for modules
|
||||
|
||||
This file ONLY is placed into the Public Domain, for any use, without
|
||||
warranty, 2019 by Wilson Snyder."""
|
||||
This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
any use, without warranty, 2019 by Wilson Snyder.
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
"""
|
||||
)
|
||||
parser.add_argument('-debug', '--debug',
|
||||
action='store_const', const=9,
|
||||
|
||||
@@ -108,8 +108,10 @@ Example usage:
|
||||
-v <filename> Verilog library
|
||||
-y <dir> Directory to search for modules
|
||||
|
||||
This file ONLY is placed into the Public Domain, for any use, without
|
||||
warranty, 2019 by Wilson Snyder."""
|
||||
This file ONLY is placed under the Creative Commons Public Domain, for
|
||||
any use, without warranty, 2019 by Wilson Snyder.
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
"""
|
||||
)
|
||||
parser.add_argument('-debug', '--debug',
|
||||
action='store_const', const=9,
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "fastlz.h"
|
||||
@@ -418,9 +420,7 @@ static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void
|
||||
const flzuint8* ip = (const flzuint8*) input;
|
||||
const flzuint8* ip_limit = ip + length;
|
||||
flzuint8* op = (flzuint8*) output;
|
||||
#ifdef FASTLZ_SAFE
|
||||
flzuint8* op_limit = op + maxout;
|
||||
#endif
|
||||
flzuint32 ctrl = (*ip++) & 31;
|
||||
int loop = 1;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef FASTLZ_H
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -1024,7 +1026,9 @@ if(!xc->curval_mem)
|
||||
|
||||
static void fstDestroyMmaps(struct fstWriterContext *xc, int is_closing)
|
||||
{
|
||||
#if !defined __CYGWIN__ && !defined __MINGW32__
|
||||
(void)is_closing;
|
||||
#endif
|
||||
|
||||
fstMunmap(xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t));
|
||||
xc->valpos_mem = NULL;
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef FST_API_H
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 source repository : https://github.com/Cyan4973/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 source repository : https://github.com/Cyan4973/lz4
|
||||
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef WAVE_ALLOCA_H
|
||||
@@ -33,9 +35,6 @@
|
||||
#else
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#include <malloc.h>
|
||||
#define alloca _alloca
|
||||
#endif
|
||||
#define wave_alloca alloca
|
||||
#endif
|
||||
|
||||
+368
-308
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=========================================================================
|
||||
///
|
||||
@@ -618,7 +614,8 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
const char* pctp = NULL; // Most recent %##.##g format
|
||||
bool inPct = false;
|
||||
bool widthSet = false;
|
||||
int width = 0;
|
||||
bool left = false;
|
||||
size_t width = 0;
|
||||
for (const char* pos = formatp; *pos; ++pos) {
|
||||
if (!inPct && pos[0]=='%') {
|
||||
pctp = pos;
|
||||
@@ -643,6 +640,10 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
widthSet = true;
|
||||
width = width*10 + (fmt - '0');
|
||||
break;
|
||||
case '-':
|
||||
left = true;
|
||||
inPct = true; // Get more digits
|
||||
break;
|
||||
case '.':
|
||||
inPct = true; // Get more digits
|
||||
break;
|
||||
@@ -662,8 +663,9 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
case '@': { // Verilog/C++ string
|
||||
va_arg(ap, int); // # bits is ignored
|
||||
const std::string* cstrp = va_arg(ap, const std::string*);
|
||||
if (width > cstrp->size()) output += std::string(width - cstrp->size(), ' ');
|
||||
output += *cstrp;
|
||||
std::string padding;
|
||||
if (width > cstrp->size()) padding.append(width - cstrp->size(), ' ');
|
||||
output += left ? (*cstrp + padding) : (padding + *cstrp);
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
@@ -721,8 +723,9 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
IData charval = VL_BITRSHIFT_W(lwp, lsb) & 0xff;
|
||||
field += (charval==0)?' ':charval;
|
||||
}
|
||||
if (width > field.size()) output += std::string(width - field.size(), ' ');
|
||||
output += field;
|
||||
std::string padding;
|
||||
if (width > field.size()) padding.append(width - field.size(), ' ');
|
||||
output += left ? (field + padding) : (padding + field);
|
||||
break;
|
||||
}
|
||||
case 'd': { // Signed decimal
|
||||
@@ -743,14 +746,15 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
digits = append.length();
|
||||
}
|
||||
int needmore = width-digits;
|
||||
std::string padding;
|
||||
if (needmore>0) {
|
||||
if (pctp && pctp[0] && pctp[1]=='0') { // %0
|
||||
output.append(needmore, '0'); // Pre-pad zero
|
||||
padding.append(needmore, '0'); // Pre-pad zero
|
||||
} else {
|
||||
output.append(needmore, ' '); // Pre-pad spaces
|
||||
padding.append(needmore, ' '); // Pre-pad spaces
|
||||
}
|
||||
}
|
||||
output += append;
|
||||
output += left ? (append + padding) : (padding + append);
|
||||
break;
|
||||
}
|
||||
case '#': { // Unsigned decimal
|
||||
@@ -764,14 +768,15 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
digits = append.length();
|
||||
}
|
||||
int needmore = width-digits;
|
||||
std::string padding;
|
||||
if (needmore>0) {
|
||||
if (pctp && pctp[0] && pctp[1]=='0') { // %0
|
||||
output.append(needmore, '0'); // Pre-pad zero
|
||||
padding.append(needmore, '0'); // Pre-pad zero
|
||||
} else {
|
||||
output.append(needmore, ' '); // Pre-pad spaces
|
||||
padding.append(needmore, ' '); // Pre-pad spaces
|
||||
}
|
||||
}
|
||||
output += append;
|
||||
output += left ? (append + padding) : (padding + append);
|
||||
break;
|
||||
}
|
||||
case 't': { // Time
|
||||
@@ -786,8 +791,9 @@ void _vl_vsformat(std::string& output, const char* formatp, va_list ap) VL_MT_SA
|
||||
VL_FATAL_MT(__FILE__, __LINE__, "", "Unsupported VL_TIME_MULTIPLIER");
|
||||
}
|
||||
int needmore = width-digits;
|
||||
if (needmore>0) output.append(needmore, ' '); // Pre-pad spaces
|
||||
output += tmp;
|
||||
std::string padding;
|
||||
if (needmore>0) padding.append(needmore, ' '); // Pad with spaces
|
||||
output += left ? (tmp + padding) : (padding + tmp);
|
||||
break;
|
||||
}
|
||||
case 'b':
|
||||
@@ -878,7 +884,7 @@ static inline int _vl_vsss_peek(FILE* fp, int& floc, WDataInP fromp,
|
||||
}
|
||||
static inline void _vl_vsss_skipspace(FILE* fp, int& floc,
|
||||
WDataInP fromp, const std::string& fstr) VL_MT_SAFE {
|
||||
while (1) {
|
||||
while (true) {
|
||||
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
||||
if (c==EOF || !isspace(c)) return;
|
||||
_vl_vsss_advance(fp, floc);
|
||||
@@ -888,7 +894,7 @@ static inline void _vl_vsss_read(FILE* fp, int& floc, WDataInP fromp, const std:
|
||||
char* tmpp, const char* acceptp) VL_MT_SAFE {
|
||||
// Read into tmp, consisting of characters from acceptp list
|
||||
char* cp = tmpp;
|
||||
while (1) {
|
||||
while (true) {
|
||||
int c = _vl_vsss_peek(fp, floc, fromp, fstr);
|
||||
if (c==EOF || isspace(c)) break;
|
||||
if (acceptp // String - allow anything
|
||||
@@ -1320,146 +1326,6 @@ IData VL_SSCANF_INX(int, const std::string& ld, const char* formatp, ...) VL_MT_
|
||||
return got;
|
||||
}
|
||||
|
||||
void VL_WRITEMEM_Q(bool hex, int width, int depth, int array_lsb, int,
|
||||
QData filename, const void* memp, IData start,
|
||||
IData end) VL_MT_SAFE {
|
||||
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
||||
return VL_WRITEMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
||||
}
|
||||
|
||||
void VL_WRITEMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
WDataInP filenamep, const void* memp, IData start,
|
||||
IData end) VL_MT_SAFE {
|
||||
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
||||
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
||||
std::string filenames(filenamez);
|
||||
return VL_WRITEMEM_N(hex, width, depth, array_lsb, filenames, memp, start, end);
|
||||
}
|
||||
|
||||
const char* memhFormat(int nBits) {
|
||||
assert((nBits >= 1) && (nBits <= 32));
|
||||
|
||||
static char buf[32];
|
||||
switch ((nBits - 1) / 4) {
|
||||
case 0: VL_SNPRINTF(buf, 32, "%%01x"); break;
|
||||
case 1: VL_SNPRINTF(buf, 32, "%%02x"); break;
|
||||
case 2: VL_SNPRINTF(buf, 32, "%%03x"); break;
|
||||
case 3: VL_SNPRINTF(buf, 32, "%%04x"); break;
|
||||
case 4: VL_SNPRINTF(buf, 32, "%%05x"); break;
|
||||
case 5: VL_SNPRINTF(buf, 32, "%%06x"); break;
|
||||
case 6: VL_SNPRINTF(buf, 32, "%%07x"); break;
|
||||
case 7: VL_SNPRINTF(buf, 32, "%%08x"); break;
|
||||
default: assert(false); break; // LCOV_EXCL_LINE
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
void VL_WRITEMEM_N(
|
||||
bool hex, // Hex format, else binary
|
||||
int width, // Width of each array row
|
||||
int depth, // Number of rows
|
||||
int array_lsb, // Index of first row. Valid row addresses
|
||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||
const std::string& filename, // Output file name
|
||||
const void* memp, // Array state
|
||||
IData start, // First array row address to write
|
||||
IData end // Last address to write, or ~0 when not specified
|
||||
) VL_MT_SAFE {
|
||||
if (VL_UNLIKELY(!hex)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "",
|
||||
"VL_WRITEMEM_N only supports hex format for now, sorry!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate row address limits
|
||||
size_t row_min = array_lsb;
|
||||
size_t row_max = row_min + depth - 1;
|
||||
|
||||
// Normalize the last address argument: ~0 => row_max
|
||||
size_t nend = (end == ~0u) ? row_max : end;
|
||||
|
||||
// Bounds check the write address range
|
||||
if (VL_UNLIKELY((start < row_min) || (start > row_max)
|
||||
|| (nend < row_min) || (nend > row_max))) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "",
|
||||
"$writemem specified address out-of-bounds");
|
||||
return;
|
||||
}
|
||||
|
||||
if (VL_UNLIKELY(start > nend)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "",
|
||||
"$writemem invalid address range");
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate row offset range
|
||||
size_t row_start = start - row_min;
|
||||
size_t row_end = nend - row_min;
|
||||
|
||||
// Bail out on possible 32-bit size_t overflow
|
||||
if (VL_UNLIKELY(row_end + 1 == 0)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem address is too large");
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* fp = fopen(filename.c_str(), "w");
|
||||
if (VL_UNLIKELY(!fp)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem file not found");
|
||||
// cppcheck-suppress resourceLeak // fp is NULL - bug in cppcheck
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t row_offset = row_start; row_offset <= row_end; ++row_offset) {
|
||||
if (width <= 8) {
|
||||
const CData* datap
|
||||
= &(reinterpret_cast<const CData*>(memp))[row_offset];
|
||||
fprintf(fp, memhFormat(width), VL_MASK_I(width) & *datap);
|
||||
fprintf(fp, "\n");
|
||||
} else if (width <= 16) {
|
||||
const SData* datap
|
||||
= &(reinterpret_cast<const SData*>(memp))[row_offset];
|
||||
fprintf(fp, memhFormat(width), VL_MASK_I(width) & *datap);
|
||||
fprintf(fp, "\n");
|
||||
} else if (width <= 32) {
|
||||
const IData* datap
|
||||
= &(reinterpret_cast<const IData*>(memp))[row_offset];
|
||||
fprintf(fp, memhFormat(width), VL_MASK_I(width) & *datap);
|
||||
fprintf(fp, "\n");
|
||||
} else if (width <= 64) {
|
||||
const QData* datap
|
||||
= &(reinterpret_cast<const QData*>(memp))[row_offset];
|
||||
vluint64_t value = VL_MASK_Q(width) & *datap;
|
||||
vluint32_t lo = value & 0xffffffff;
|
||||
vluint32_t hi = value >> 32;
|
||||
fprintf(fp, memhFormat(width - 32), hi);
|
||||
fprintf(fp, "%08x\n", lo);
|
||||
} else {
|
||||
WDataInP memDatap = reinterpret_cast<WDataInP>(memp);
|
||||
WDataInP datap = &memDatap[row_offset * VL_WORDS_I(width)];
|
||||
// output as a sequence of VL_EDATASIZE'd words
|
||||
// from MSB to LSB. Mask off the MSB word which could
|
||||
// contain junk above the top of valid data.
|
||||
int word_idx = ((width - 1) / VL_EDATASIZE);
|
||||
bool first = true;
|
||||
while (word_idx >= 0) {
|
||||
EData data = datap[word_idx];
|
||||
if (first) {
|
||||
data &= VL_MASK_E(width);
|
||||
int top_word_nbits = ((width - 1) & (VL_EDATASIZE - 1)) + 1;
|
||||
fprintf(fp, memhFormat(top_word_nbits), data);
|
||||
} else {
|
||||
fprintf(fp, "%08x", data);
|
||||
}
|
||||
word_idx--;
|
||||
first = false;
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||
void* memp, IData fpi, IData start, IData count) VL_MT_SAFE {
|
||||
// While threadsafe, each thread can only access different file handles
|
||||
@@ -1469,14 +1335,14 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||
// Prep for reading
|
||||
IData read_count = 0;
|
||||
IData read_elements = 0;
|
||||
int start_shift = (width-1) & ~7; // bit+7:bit gets first character
|
||||
int start_shift = (width - 1) & ~7; // bit+7:bit gets first character
|
||||
int shift = start_shift;
|
||||
// Read the data
|
||||
// We process a character at a time, as then we don't need to deal
|
||||
// with changing buffer sizes dynamically, etc.
|
||||
while (1) {
|
||||
while (true) {
|
||||
int c = fgetc(fp);
|
||||
if (VL_UNLIKELY(c==EOF)) break;
|
||||
if (VL_UNLIKELY(c == EOF)) break;
|
||||
// Shift value in
|
||||
IData entry = read_elements + start - array_lsb;
|
||||
if (width <= 8) {
|
||||
@@ -1513,144 +1379,6 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||
return read_count;
|
||||
}
|
||||
|
||||
void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int,
|
||||
QData filename, void* memp, IData start, IData end) VL_MT_SAFE {
|
||||
WData fnw[VL_WQ_WORDS_E]; VL_SET_WQ(fnw, filename);
|
||||
return VL_READMEM_W(hex, width, depth, array_lsb, VL_WQ_WORDS_E, fnw, memp, start, end);
|
||||
}
|
||||
|
||||
void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
WDataInP filenamep, void* memp, IData start, IData end) VL_MT_SAFE {
|
||||
char filenamez[VL_TO_STRING_MAX_WORDS * VL_EDATASIZE + 1];
|
||||
_VL_VINT_TO_STRING(fnwords * VL_EDATASIZE, filenamez, filenamep);
|
||||
std::string filenames(filenamez);
|
||||
return VL_READMEM_N(hex, width, depth, array_lsb, filenames, memp, start, end);
|
||||
}
|
||||
|
||||
void VL_READMEM_N(
|
||||
bool hex, // Hex format, else binary
|
||||
int width, // Width of each array row
|
||||
int depth, // Number of rows
|
||||
int array_lsb, // Index of first row. Valid row addresses
|
||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||
const std::string& filename, // Input file name
|
||||
void* memp, // Array state
|
||||
IData start, // First array row address to read
|
||||
IData end // Last row address to read
|
||||
) VL_MT_SAFE {
|
||||
FILE* fp = fopen(filename.c_str(), "r");
|
||||
if (VL_UNLIKELY(!fp)) {
|
||||
// We don't report the Verilog source filename as it slow to have to pass it down
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$readmem file not found");
|
||||
// cppcheck-suppress resourceLeak // fp is NULL - bug in cppcheck
|
||||
return;
|
||||
}
|
||||
// Prep for reading
|
||||
IData addr = start;
|
||||
int linenum = 1;
|
||||
bool innum = false;
|
||||
bool ignore_to_eol = false;
|
||||
bool ignore_to_cmt = false;
|
||||
bool needinc = false;
|
||||
bool reading_addr = false;
|
||||
int lastc = ' ';
|
||||
// Read the data
|
||||
// We process a character at a time, as then we don't need to deal
|
||||
// with changing buffer sizes dynamically, etc.
|
||||
while (1) {
|
||||
int c = fgetc(fp);
|
||||
if (VL_UNLIKELY(c==EOF)) break;
|
||||
//printf("%d: Got '%c' Addr%x IN%d IgE%d IgC%d ninc%d\n",
|
||||
// linenum, c, addr, innum, ignore_to_eol, ignore_to_cmt, needinc);
|
||||
if (c=='\n') {
|
||||
linenum++; ignore_to_eol = false;
|
||||
if (innum) reading_addr = false;
|
||||
innum = false;
|
||||
}
|
||||
else if (c=='\t' || c==' ' || c=='\r' || c=='\f') {
|
||||
if (innum) reading_addr = false;
|
||||
innum = false;
|
||||
}
|
||||
// Skip // comments and detect /* comments
|
||||
else if (ignore_to_cmt && lastc=='*' && c=='/') {
|
||||
ignore_to_cmt = false; if (innum) reading_addr=false; innum=false;
|
||||
} else if (!ignore_to_eol && !ignore_to_cmt) {
|
||||
if (lastc=='/' && c=='*') { ignore_to_cmt = true; }
|
||||
else if (lastc=='/' && c=='/') { ignore_to_eol = true; }
|
||||
else if (c=='/') {} // Part of /* or //
|
||||
else if (c=='#') { ignore_to_eol = true; }
|
||||
else if (c=='_') {}
|
||||
else if (c=='@') { reading_addr = true; innum=false; needinc=false; }
|
||||
// Check for hex or binary digits as file format requests
|
||||
else if (isxdigit(c) || (!reading_addr && (c=='x' || c=='X'))) {
|
||||
c = tolower(c);
|
||||
int value = (c >= 'a' ? (c=='x' ? VL_RAND_RESET_I(4) : (c-'a'+10)) : (c-'0'));
|
||||
if (!innum) { // Prep for next number
|
||||
if (needinc) { addr++; needinc=false; }
|
||||
}
|
||||
if (reading_addr) {
|
||||
// Decode @ addresses
|
||||
if (!innum) addr=0;
|
||||
addr = (addr<<4) + value;
|
||||
} else {
|
||||
needinc = true;
|
||||
//printf(" Value width=%d @%x = %c\n", width, addr, c);
|
||||
if (VL_UNLIKELY(addr >= static_cast<IData>(depth+array_lsb)
|
||||
|| addr < static_cast<IData>(array_lsb))) {
|
||||
VL_FATAL_MT(filename.c_str(), linenum, "",
|
||||
"$readmem file address beyond bounds of array");
|
||||
} else {
|
||||
int entry = addr - array_lsb;
|
||||
QData shift = hex ? VL_ULL(4) : VL_ULL(1);
|
||||
// Shift value in
|
||||
if (width<=8) {
|
||||
CData* datap = &(reinterpret_cast<CData*>(memp))[entry];
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
|
||||
} else if (width<=16) {
|
||||
SData* datap = &(reinterpret_cast<SData*>(memp))[entry];
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
|
||||
} else if (width <= VL_IDATASIZE) {
|
||||
IData* datap = &(reinterpret_cast<IData*>(memp))[entry];
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(width);
|
||||
} else if (width<=VL_QUADSIZE) {
|
||||
QData* datap = &(reinterpret_cast<QData*>(memp))[entry];
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << static_cast<QData>(shift))
|
||||
+ static_cast<QData>(value)) & VL_MASK_Q(width);
|
||||
} else {
|
||||
WDataOutP datap = &(reinterpret_cast<WDataOutP>(memp))
|
||||
[ entry*VL_WORDS_I(width) ];
|
||||
if (!innum) { VL_ZERO_RESET_W(width, datap); }
|
||||
_VL_SHIFTL_INPLACE_W(width, datap, static_cast<IData>(shift));
|
||||
datap[0] |= value;
|
||||
}
|
||||
if (VL_UNLIKELY(value>=(1<<shift))) {
|
||||
VL_FATAL_MT(filename.c_str(), linenum, "",
|
||||
"$readmemb (binary) file contains hex characters");
|
||||
}
|
||||
}
|
||||
}
|
||||
innum = true;
|
||||
}
|
||||
else {
|
||||
VL_FATAL_MT(filename.c_str(), linenum, "", "$readmem file syntax error");
|
||||
}
|
||||
}
|
||||
lastc = c;
|
||||
}
|
||||
if (needinc) { addr++; }
|
||||
|
||||
// Final checks
|
||||
fclose(fp);
|
||||
if (VL_UNLIKELY(end != VL_UL(0xffffffff) && addr != (end+1))) {
|
||||
VL_FATAL_MT(filename.c_str(), linenum, "",
|
||||
"$readmem file ended before specified ending-address");
|
||||
}
|
||||
}
|
||||
|
||||
IData VL_SYSTEM_IQ(QData lhs) VL_MT_SAFE {
|
||||
WData lhsw[VL_WQ_WORDS_E]; VL_SET_WQ(lhsw, lhs);
|
||||
return VL_SYSTEM_IW(VL_WQ_WORDS_E, lhsw);
|
||||
@@ -1795,6 +1523,9 @@ std::string VL_TO_STRING(IData lhs) {
|
||||
std::string VL_TO_STRING(QData lhs) {
|
||||
return VL_SFORMATF_NX("'h%0x", 64, lhs);
|
||||
}
|
||||
std::string VL_TO_STRING_W(int words, WDataInP obj) {
|
||||
return VL_SFORMATF_NX("'h%0x", words * VL_EDATASIZE, obj);
|
||||
}
|
||||
|
||||
std::string VL_TOLOWER_NN(const std::string& ld) VL_MT_SAFE {
|
||||
std::string out = ld;
|
||||
@@ -1867,6 +1598,334 @@ IData VL_ATOI_N(const std::string& str, int base) VL_PURE {
|
||||
return static_cast<IData>(v);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Dumping
|
||||
|
||||
const char* vl_dumpctl_filenamep(bool setit, const std::string& filename) VL_MT_SAFE {
|
||||
// This function performs both accessing and setting so it's easy to make an in-function static
|
||||
static VL_THREAD_LOCAL std::string t_filename;
|
||||
if (setit) {
|
||||
t_filename = filename;
|
||||
} else {
|
||||
static VL_THREAD_LOCAL bool t_warned = false;
|
||||
if (VL_UNLIKELY(t_filename.empty() && !t_warned)) {
|
||||
t_warned = true;
|
||||
VL_PRINTF_MT("%%Warning: $dumpvar ignored as not proceeded by $dumpfile\n");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return t_filename.c_str();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Readmem/writemem
|
||||
|
||||
static const char* memhFormat(int nBits) {
|
||||
assert((nBits >= 1) && (nBits <= 32));
|
||||
|
||||
static char buf[32];
|
||||
switch ((nBits - 1) / 4) {
|
||||
case 0: VL_SNPRINTF(buf, 32, "%%01x"); break;
|
||||
case 1: VL_SNPRINTF(buf, 32, "%%02x"); break;
|
||||
case 2: VL_SNPRINTF(buf, 32, "%%03x"); break;
|
||||
case 3: VL_SNPRINTF(buf, 32, "%%04x"); break;
|
||||
case 4: VL_SNPRINTF(buf, 32, "%%05x"); break;
|
||||
case 5: VL_SNPRINTF(buf, 32, "%%06x"); break;
|
||||
case 6: VL_SNPRINTF(buf, 32, "%%07x"); break;
|
||||
case 7: VL_SNPRINTF(buf, 32, "%%08x"); break;
|
||||
default: assert(false); break; // LCOV_EXCL_LINE
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
VlReadMem::VlReadMem(bool hex, int bits, const std::string& filename, QData start, QData end)
|
||||
: m_hex(hex)
|
||||
, m_bits(bits)
|
||||
, m_filename(filename)
|
||||
, m_end(end)
|
||||
, m_addr(start)
|
||||
, m_linenum(0) {
|
||||
m_fp = fopen(filename.c_str(), "r");
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
// We don't report the Verilog source filename as it slow to have to pass it down
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$readmem file not found");
|
||||
// cppcheck-suppress resourceLeak // m_fp is NULL - bug in cppcheck
|
||||
return;
|
||||
}
|
||||
}
|
||||
VlReadMem::~VlReadMem() {
|
||||
if (m_fp) { fclose(m_fp); m_fp = NULL; }
|
||||
}
|
||||
bool VlReadMem::get(QData& addrr, std::string& valuer) {
|
||||
if (VL_UNLIKELY(!m_fp)) return false;
|
||||
valuer = "";
|
||||
// Prep for reading
|
||||
bool indata = false;
|
||||
bool ignore_to_eol = false;
|
||||
bool ignore_to_cmt = false;
|
||||
bool reading_addr = false;
|
||||
int lastc = ' ';
|
||||
// Read the data
|
||||
// We process a character at a time, as then we don't need to deal
|
||||
// with changing buffer sizes dynamically, etc.
|
||||
while (true) {
|
||||
int c = fgetc(m_fp);
|
||||
if (VL_UNLIKELY(c == EOF)) break;
|
||||
// printf("%d: Got '%c' Addr%lx IN%d IgE%d IgC%d\n",
|
||||
// m_linenum, c, m_addr, indata, ignore_to_eol, ignore_to_cmt);
|
||||
// See if previous data value has completed, and if so return
|
||||
if (c == '_') continue; // Ignore _ e.g. inside a number
|
||||
if (indata && !isxdigit(c) && c != 'x' && c != 'X') {
|
||||
// printf("Got data @%lx = %s\n", m_addr, valuer.c_str());
|
||||
indata = false;
|
||||
ungetc(c, m_fp);
|
||||
addrr = m_addr;
|
||||
++m_addr;
|
||||
return true;
|
||||
}
|
||||
// Parse line
|
||||
if (c == '\n') {
|
||||
++m_linenum; ignore_to_eol = false;
|
||||
reading_addr = false;
|
||||
} else if (c == '\t' || c == ' ' || c == '\r' || c == '\f') {
|
||||
reading_addr = false;
|
||||
}
|
||||
// Skip // comments and detect /* comments
|
||||
else if (ignore_to_cmt && lastc == '*' && c == '/') {
|
||||
ignore_to_cmt = false;
|
||||
reading_addr = false;
|
||||
} else if (!ignore_to_eol && !ignore_to_cmt) {
|
||||
if (lastc == '/' && c == '*') { ignore_to_cmt = true; }
|
||||
else if (lastc == '/' && c == '/') { ignore_to_eol = true; }
|
||||
else if (c == '/') {} // Part of /* or //
|
||||
else if (c == '#') { ignore_to_eol = true; }
|
||||
else if (c == '@') { reading_addr = true; m_addr = 0; }
|
||||
// Check for hex or binary digits as file format requests
|
||||
else if (isxdigit(c) || (!reading_addr && (c == 'x' || c == 'X'))) {
|
||||
c = tolower(c);
|
||||
int value = (c >= 'a' ? (c == 'x' ? VL_RAND_RESET_I(4) : (c-'a'+10)) : (c-'0'));
|
||||
if (reading_addr) {
|
||||
// Decode @ addresses
|
||||
m_addr = (m_addr << 4) + value;
|
||||
} else {
|
||||
indata = true;
|
||||
valuer += c;
|
||||
// printf(" Value width=%d @%x = %c\n", width, m_addr, c);
|
||||
if (VL_UNLIKELY(value > 1 && !m_hex)) {
|
||||
VL_FATAL_MT(m_filename.c_str(), m_linenum, "",
|
||||
"$readmemb (binary) file contains hex characters");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
VL_FATAL_MT(m_filename.c_str(), m_linenum, "", "$readmem file syntax error");
|
||||
}
|
||||
}
|
||||
lastc = c;
|
||||
}
|
||||
|
||||
if (VL_UNLIKELY(m_end != ~VL_ULL(0) && m_addr <= m_end)) {
|
||||
VL_FATAL_MT(m_filename.c_str(), m_linenum, "",
|
||||
"$readmem file ended before specified final address (IEEE 2017 21.4)");
|
||||
}
|
||||
|
||||
return false; // EOF
|
||||
}
|
||||
void VlReadMem::setData(void* valuep, const std::string& rhs) {
|
||||
QData shift = m_hex ? VL_ULL(4) : VL_ULL(1);
|
||||
bool innum = false;
|
||||
// Shift value in
|
||||
for (std::string::const_iterator it = rhs.begin(); it != rhs.end(); ++it) {
|
||||
char c = tolower(*it);
|
||||
int value = (c >= 'a' ? (c == 'x' ? VL_RAND_RESET_I(4) : (c - 'a' + 10)) : (c - '0'));
|
||||
if (m_bits <= 8) {
|
||||
CData* datap = reinterpret_cast<CData*>(valuep);
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(m_bits);
|
||||
} else if (m_bits <= 16) {
|
||||
SData* datap = reinterpret_cast<SData*>(valuep);
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(m_bits);
|
||||
} else if (m_bits <= VL_IDATASIZE) {
|
||||
IData* datap = reinterpret_cast<IData*>(valuep);
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << shift) + value) & VL_MASK_I(m_bits);
|
||||
} else if (m_bits <= VL_QUADSIZE) {
|
||||
QData* datap = reinterpret_cast<QData*>(valuep);
|
||||
if (!innum) { *datap = 0; }
|
||||
*datap = ((*datap << static_cast<QData>(shift)) + static_cast<QData>(value))
|
||||
& VL_MASK_Q(m_bits);
|
||||
} else {
|
||||
WDataOutP datap = reinterpret_cast<WDataOutP>(valuep);
|
||||
if (!innum) { VL_ZERO_RESET_W(m_bits, datap); }
|
||||
_VL_SHIFTL_INPLACE_W(m_bits, datap, static_cast<IData>(shift));
|
||||
datap[0] |= value;
|
||||
}
|
||||
innum = true;
|
||||
}
|
||||
}
|
||||
|
||||
VlWriteMem::VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end)
|
||||
: m_bits(bits)
|
||||
, m_addr(0) {
|
||||
if (VL_UNLIKELY(!hex)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "",
|
||||
"Unsupported: $writemem binary format (suggest hex format)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (VL_UNLIKELY(start > end)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem invalid address range");
|
||||
return;
|
||||
}
|
||||
|
||||
m_fp = fopen(filename.c_str(), "w");
|
||||
if (VL_UNLIKELY(!m_fp)) {
|
||||
VL_FATAL_MT(filename.c_str(), 0, "", "$writemem file not found");
|
||||
// cppcheck-suppress resourceLeak // m_fp is NULL - bug in cppcheck
|
||||
return;
|
||||
}
|
||||
}
|
||||
VlWriteMem::~VlWriteMem() {
|
||||
if (m_fp) { fclose(m_fp); m_fp = NULL; }
|
||||
}
|
||||
void VlWriteMem::print(QData addr, bool addrstamp, const void* valuep) {
|
||||
if (VL_UNLIKELY(!m_fp)) return;
|
||||
if (addr != m_addr && addrstamp) { // Only assoc has time stamps
|
||||
fprintf(m_fp, "@%" VL_PRI64 "x\n", addr);
|
||||
}
|
||||
m_addr = addr + 1;
|
||||
if (m_bits <= 8) {
|
||||
const CData* datap = reinterpret_cast<const CData*>(valuep);
|
||||
fprintf(m_fp, memhFormat(m_bits), VL_MASK_I(m_bits) & *datap);
|
||||
fprintf(m_fp, "\n");
|
||||
} else if (m_bits <= 16) {
|
||||
const SData* datap = reinterpret_cast<const SData*>(valuep);
|
||||
fprintf(m_fp, memhFormat(m_bits), VL_MASK_I(m_bits) & *datap);
|
||||
fprintf(m_fp, "\n");
|
||||
} else if (m_bits <= 32) {
|
||||
const IData* datap = reinterpret_cast<const IData*>(valuep);
|
||||
fprintf(m_fp, memhFormat(m_bits), VL_MASK_I(m_bits) & *datap);
|
||||
fprintf(m_fp, "\n");
|
||||
} else if (m_bits <= 64) {
|
||||
const QData* datap = reinterpret_cast<const QData*>(valuep);
|
||||
vluint64_t value = VL_MASK_Q(m_bits) & *datap;
|
||||
vluint32_t lo = value & 0xffffffff;
|
||||
vluint32_t hi = value >> 32;
|
||||
fprintf(m_fp, memhFormat(m_bits - 32), hi);
|
||||
fprintf(m_fp, "%08x\n", lo);
|
||||
} else {
|
||||
WDataInP datap = reinterpret_cast<WDataInP>(valuep);
|
||||
// output as a sequence of VL_EDATASIZE'd words
|
||||
// from MSB to LSB. Mask off the MSB word which could
|
||||
// contain junk above the top of valid data.
|
||||
int word_idx = ((m_bits - 1) / VL_EDATASIZE);
|
||||
bool first = true;
|
||||
while (word_idx >= 0) {
|
||||
EData data = datap[word_idx];
|
||||
if (first) {
|
||||
data &= VL_MASK_E(m_bits);
|
||||
int top_word_nbits = VL_BITBIT_E(m_bits - 1) + 1;
|
||||
fprintf(m_fp, memhFormat(top_word_nbits), data);
|
||||
} else {
|
||||
fprintf(m_fp, "%08x", data);
|
||||
}
|
||||
word_idx--;
|
||||
first = false;
|
||||
}
|
||||
fprintf(m_fp, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void VL_READMEM_N(bool hex, // Hex format, else binary
|
||||
int bits, // M_Bits of each array row
|
||||
QData depth, // Number of rows
|
||||
int array_lsb, // Index of first row. Valid row addresses
|
||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||
const std::string& filename, // Input file name
|
||||
void* memp, // Array state
|
||||
QData start, // First array row address to read
|
||||
QData end // Last row address to read
|
||||
) VL_MT_SAFE {
|
||||
QData addr_max = array_lsb + depth - 1;
|
||||
if (start < static_cast<QData>(array_lsb)) start = array_lsb;
|
||||
QData addr_end = end;
|
||||
if (addr_end > addr_max) addr_end = addr_max;
|
||||
|
||||
VlReadMem rmem(hex, bits, filename, start, end);
|
||||
if (VL_UNLIKELY(!rmem.isOpen())) return;
|
||||
while (true) {
|
||||
QData addr;
|
||||
std::string value;
|
||||
if (rmem.get(addr /*ref*/, value/*ref*/)) {
|
||||
if (VL_UNLIKELY(addr < static_cast<QData>(array_lsb)
|
||||
|| addr >= static_cast<QData>(array_lsb + depth))) {
|
||||
VL_FATAL_MT(filename.c_str(), rmem.linenum(), "",
|
||||
"$readmem file address beyond bounds of array");
|
||||
} else {
|
||||
QData entry = addr - array_lsb;
|
||||
if (bits <= 8) {
|
||||
CData* datap = &(reinterpret_cast<CData*>(memp))[entry];
|
||||
rmem.setData(datap, value);
|
||||
} else if (bits <= 16) {
|
||||
SData* datap = &(reinterpret_cast<SData*>(memp))[entry];
|
||||
rmem.setData(datap, value);
|
||||
} else if (bits <= VL_IDATASIZE) {
|
||||
IData* datap = &(reinterpret_cast<IData*>(memp))[entry];
|
||||
rmem.setData(datap, value);
|
||||
} else if (bits <= VL_QUADSIZE) {
|
||||
QData* datap = &(reinterpret_cast<QData*>(memp))[entry];
|
||||
rmem.setData(datap, value);
|
||||
} else {
|
||||
WDataOutP datap = &(reinterpret_cast<WDataOutP>(memp))
|
||||
[ entry*VL_WORDS_I(bits) ];
|
||||
rmem.setData(datap, value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VL_WRITEMEM_N(bool hex, // Hex format, else binary
|
||||
int bits, // Width of each array row
|
||||
QData depth, // Number of rows
|
||||
int array_lsb, // Index of first row. Valid row addresses
|
||||
// // range from array_lsb up to (array_lsb + depth - 1)
|
||||
const std::string& filename, // Output file name
|
||||
const void* memp, // Array state
|
||||
QData start, // First array row address to write
|
||||
QData end // Last address to write, or ~0 when not specified
|
||||
) VL_MT_SAFE {
|
||||
QData addr_max = array_lsb + depth - 1;
|
||||
if (start < static_cast<QData>(array_lsb)) start = array_lsb;
|
||||
if (end > addr_max) end = addr_max;
|
||||
|
||||
VlWriteMem wmem(hex, bits, filename, start, end);
|
||||
if (VL_UNLIKELY(!wmem.isOpen())) return;
|
||||
|
||||
for (QData addr = start; addr <= end; ++addr) {
|
||||
QData row_offset = addr - array_lsb;
|
||||
if (bits <= 8) {
|
||||
const CData* datap = &(reinterpret_cast<const CData*>(memp))[row_offset];
|
||||
wmem.print(addr, false, datap);
|
||||
} else if (bits <= 16) {
|
||||
const SData* datap = &(reinterpret_cast<const SData*>(memp))[row_offset];
|
||||
wmem.print(addr, false, datap);
|
||||
} else if (bits <= 32) {
|
||||
const IData* datap = &(reinterpret_cast<const IData*>(memp))[row_offset];
|
||||
wmem.print(addr, false, datap);
|
||||
} else if (bits <= 64) {
|
||||
const QData* datap = &(reinterpret_cast<const QData*>(memp))[row_offset];
|
||||
wmem.print(addr, false, datap);
|
||||
} else {
|
||||
WDataInP memDatap = reinterpret_cast<WDataInP>(memp);
|
||||
WDataInP datap = &memDatap[row_offset * VL_WORDS_I(bits)];
|
||||
wmem.print(addr, false, datap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Timescale conversion
|
||||
|
||||
@@ -2124,9 +2183,7 @@ void VerilatedImp::commandArgsAddGuts(int argc, const char** argv) VL_REQUIRES(s
|
||||
void VerilatedImp::commandArgVl(const std::string& arg) {
|
||||
if (0 == strncmp(arg.c_str(), "+verilator+", strlen("+verilator+"))) {
|
||||
std::string value;
|
||||
if (0) {
|
||||
}
|
||||
else if (arg == "+verilator+debug") {
|
||||
if (arg == "+verilator+debug") {
|
||||
Verilated::debug(4);
|
||||
}
|
||||
else if (commandArgVlValue(arg, "+verilator+debugi+", value/*ref*/)) {
|
||||
@@ -2155,6 +2212,9 @@ void VerilatedImp::commandArgVl(const std::string& arg) {
|
||||
else if (commandArgVlValue(arg, "+verilator+seed+", value/*ref*/)) {
|
||||
Verilated::randSeed(atoi(value.c_str()));
|
||||
}
|
||||
else if (arg == "+verilator+noassert") {
|
||||
Verilated::assertOn(false);
|
||||
}
|
||||
else if (arg == "+verilator+V") {
|
||||
versionDump(); // Someday more info too
|
||||
VL_FATAL_MT("COMMAND_LINE", 0, "",
|
||||
@@ -2352,9 +2412,9 @@ VerilatedVar* VerilatedScope::varFind(const char* namep) const VL_MT_SAFE_POSTIN
|
||||
|
||||
void* VerilatedScope::exportFindNullError(int funcnum) VL_MT_SAFE {
|
||||
// Slowpath - Called only when find has failed
|
||||
std::string msg = (std::string("Testbench C called '")
|
||||
+VerilatedImp::exportName(funcnum)
|
||||
+"' but scope wasn't set, perhaps due to dpi import call without 'context'");
|
||||
std::string msg = (std::string("Testbench C called '") + VerilatedImp::exportName(funcnum)
|
||||
+ "' but scope wasn't set, perhaps due to dpi import call without "
|
||||
+ "'context', or missing svSetScope. See IEEE 1800-2017 35.5.3.");
|
||||
VL_FATAL_MT("unknown", 0, "", msg.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+86
-34
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
@@ -83,6 +79,7 @@ class VerilatedVar;
|
||||
class VerilatedVarNameMap;
|
||||
class VerilatedVcd;
|
||||
class VerilatedVcdC;
|
||||
class VerilatedVcdSc;
|
||||
class VerilatedFst;
|
||||
class VerilatedFstC;
|
||||
|
||||
@@ -200,13 +197,19 @@ public:
|
||||
/// Check that the current thread ID is the same as the construction thread ID
|
||||
void check() VL_MT_UNSAFE_ONE {
|
||||
if (VL_UNCOVERABLE(m_threadid != VL_THREAD_ID())) {
|
||||
fatal_different(); // LCOV_EXCL_LINE
|
||||
if (m_threadid == 0) {
|
||||
m_threadid = VL_THREAD_ID();
|
||||
} else {
|
||||
fatal_different(); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
void changeThread() { m_threadid = 0; } // Allow intentional change-of-thread
|
||||
static void fatal_different() VL_MT_SAFE;
|
||||
#else // !VL_THREADED || !VL_DEBUG
|
||||
public:
|
||||
void check() {}
|
||||
void changeThread() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -313,7 +316,7 @@ private:
|
||||
public: // But internals only - called from VerilatedModule's
|
||||
VerilatedScope();
|
||||
~VerilatedScope();
|
||||
void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffix,
|
||||
void configure(VerilatedSyms* symsp, const char* prefixp, const char* suffixp,
|
||||
const char* identifier, const Type type) VL_MT_UNSAFE;
|
||||
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
|
||||
void varInsert(int finalize, const char* namep, void* datap,
|
||||
@@ -630,22 +633,6 @@ extern void VL_FCLOSE_I(IData fdi);
|
||||
extern IData VL_FREAD_I(int width, int array_lsb, int array_size,
|
||||
void* memp, IData fpi, IData start, IData count);
|
||||
|
||||
extern void VL_READMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
WDataInP filenamep, void* memp, IData start, IData end);
|
||||
extern void VL_READMEM_Q(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
QData filename, void* memp, IData start, IData end);
|
||||
inline void VL_READMEM_I(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
IData filename, void* memp, IData start, IData end) VL_MT_SAFE {
|
||||
VL_READMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
||||
|
||||
extern void VL_WRITEMEM_W(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
WDataInP filenamep, const void* memp, IData start, IData end);
|
||||
extern void VL_WRITEMEM_Q(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
QData filename, const void* memp, IData start, IData end);
|
||||
inline void VL_WRITEMEM_I(bool hex, int width, int depth, int array_lsb, int fnwords,
|
||||
IData filename, const void* memp, IData start, IData end) VL_MT_SAFE {
|
||||
VL_WRITEMEM_Q(hex, width, depth, array_lsb, fnwords, filename, memp, start, end); }
|
||||
|
||||
extern void VL_WRITEF(const char* formatp, ...);
|
||||
extern void VL_FWRITEF(IData fpi, const char* formatp, ...);
|
||||
|
||||
@@ -708,13 +695,12 @@ static inline QData VL_CVT_Q_D(double lhs) VL_PURE {
|
||||
union { double d; QData q; } u; u.d=lhs; return u.q; }
|
||||
/// Return double from QData (numeric)
|
||||
static inline double VL_ITOR_D_I(IData lhs) VL_PURE {
|
||||
return static_cast<double>(static_cast<vlsint32_t>(lhs)); }
|
||||
return static_cast<double>(static_cast<vlsint32_t>(lhs));
|
||||
}
|
||||
/// Return QData from double (numeric)
|
||||
static inline IData VL_RTOI_I_D(double lhs) VL_PURE {
|
||||
return static_cast<vlsint32_t>(VL_TRUNC(lhs)); }
|
||||
/// Return QData from double (numeric)
|
||||
static inline IData VL_RTOIROUND_I_D(double lhs) VL_PURE {
|
||||
return static_cast<vlsint32_t>(VL_ROUND(lhs)); }
|
||||
static inline IData VL_RTOI_I_D(double lhs) VL_PURE {
|
||||
return static_cast<vlsint32_t>(VL_TRUNC(lhs));
|
||||
}
|
||||
|
||||
// Sign extend such that if MSB set, we get ffff_ffff, else 0s
|
||||
// (Requires clean input)
|
||||
@@ -1333,6 +1319,14 @@ static inline WDataOutP VL_NEGATE_W(int words, WDataOutP owp, WDataInP lwp) VL_M
|
||||
}
|
||||
return owp;
|
||||
}
|
||||
static void VL_NEGATE_INPLACE_W(int words, WDataOutP owp_lwp) VL_MT_SAFE {
|
||||
EData carry = 1;
|
||||
for (int i = 0; i < words; ++i) {
|
||||
EData word = ~owp_lwp[i] + carry;
|
||||
carry = (word < ~owp_lwp[i]);
|
||||
owp_lwp[i] = word;
|
||||
}
|
||||
}
|
||||
|
||||
// EMIT_RULE: VL_MUL: oclean=dirty; lclean==clean; rclean==clean;
|
||||
// EMIT_RULE: VL_DIV: oclean=dirty; lclean==clean; rclean==clean;
|
||||
@@ -1659,18 +1653,22 @@ static inline void _VL_INSERT_WW(int, WDataOutP owp, WDataInP lwp, int hbit, int
|
||||
int oword = lword+i;
|
||||
EData d = lwp[i] << loffset;
|
||||
EData od = (owp[oword] & ~linsmask) | (d & linsmask);
|
||||
if (oword == hword)
|
||||
if (oword == hword) {
|
||||
owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask);
|
||||
else owp[oword] = od;
|
||||
} else {
|
||||
owp[oword] = od;
|
||||
}
|
||||
}
|
||||
{ // Upper word
|
||||
int oword = lword+i+1;
|
||||
if (oword <= hword) {
|
||||
EData d = lwp[i] >> nbitsonright;
|
||||
EData od = (d & ~linsmask) | (owp[oword] & linsmask);
|
||||
if (oword == hword)
|
||||
if (oword == hword) {
|
||||
owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask);
|
||||
else owp[oword] = od;
|
||||
} else {
|
||||
owp[oword] = od;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2029,6 +2027,12 @@ static inline WDataOutP VL_SHIFTR_WWW(int obits, int lbits, int rbits,
|
||||
}
|
||||
return VL_SHIFTR_WWI(obits, lbits, 32, owp, lwp, rwp[0]);
|
||||
}
|
||||
static inline WDataOutP VL_SHIFTR_WWQ(int obits, int lbits, int rbits,
|
||||
WDataOutP owp, WDataInP lwp, QData rd) VL_MT_SAFE {
|
||||
WData rwp[VL_WQ_WORDS_E]; VL_SET_WQ(rwp, rd);
|
||||
return VL_SHIFTR_WWW(obits, lbits, rbits, owp, lwp, rwp);
|
||||
}
|
||||
|
||||
static inline IData VL_SHIFTR_IIW(int obits, int, int rbits, IData lhs, WDataInP rwp) VL_MT_SAFE {
|
||||
for (int i = 1; i < VL_WORDS_I(rbits); ++i) {
|
||||
if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more
|
||||
@@ -2114,6 +2118,11 @@ static inline WDataOutP VL_SHIFTRS_WWW(int obits, int lbits, int rbits,
|
||||
}
|
||||
return VL_SHIFTRS_WWI(obits, lbits, 32, owp, lwp, rwp[0]);
|
||||
}
|
||||
static inline WDataOutP VL_SHIFTRS_WWQ(int obits, int lbits, int rbits,
|
||||
WDataOutP owp, WDataInP lwp, QData rd) VL_MT_SAFE {
|
||||
WData rwp[VL_WQ_WORDS_E]; VL_SET_WQ(rwp, rd);
|
||||
return VL_SHIFTRS_WWW(obits, lbits, rbits, owp, lwp, rwp);
|
||||
}
|
||||
static inline IData VL_SHIFTRS_IIW(int obits, int lbits, int rbits,
|
||||
IData lhs, WDataInP rwp) VL_MT_SAFE {
|
||||
EData overshift = 0; // Huge shift 1>>32 or more
|
||||
@@ -2238,6 +2247,49 @@ static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int,
|
||||
return owp;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Math needing insert/select
|
||||
|
||||
/// Return QData from double (numeric)
|
||||
// EMIT_RULE: VL_RTOIROUND_Q_D: oclean=dirty; lclean==clean/real
|
||||
static inline QData VL_RTOIROUND_Q_D(int bits, double lhs) VL_PURE {
|
||||
// IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa
|
||||
// This does not need to support subnormals as they are sub-integral
|
||||
lhs = VL_ROUND(lhs);
|
||||
if (lhs == 0.0) return 0;
|
||||
QData q = VL_CVT_Q_D(lhs);
|
||||
int lsb = static_cast<int>((q >> VL_ULL(52)) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (VL_ULL(1) << 52);
|
||||
vluint64_t out = 0;
|
||||
if (lsb < 0) {
|
||||
out = mantissa >> -lsb;
|
||||
} else if (lsb < 64) {
|
||||
out = mantissa << lsb;
|
||||
}
|
||||
if (lhs < 0) out = -out;
|
||||
return out;
|
||||
}
|
||||
static inline IData VL_RTOIROUND_I_D(int bits, double lhs) VL_PURE {
|
||||
return static_cast<IData>(VL_RTOIROUND_Q_D(bits, lhs));
|
||||
}
|
||||
static inline WDataOutP VL_RTOIROUND_W_D(int obits, WDataOutP owp, double lhs) VL_PURE {
|
||||
// IEEE format: [63]=sign [62:52]=exp+1023 [51:0]=mantissa
|
||||
// This does not need to support subnormals as they are sub-integral
|
||||
lhs = VL_ROUND(lhs);
|
||||
VL_ZERO_W(obits, owp);
|
||||
if (lhs == 0.0) return owp;
|
||||
QData q = VL_CVT_Q_D(lhs);
|
||||
int lsb = static_cast<int>((q >> VL_ULL(52)) & VL_MASK_Q(11)) - 1023 - 52;
|
||||
vluint64_t mantissa = (q & VL_MASK_Q(52)) | (VL_ULL(1) << 52);
|
||||
if (lsb < 0) {
|
||||
VL_SET_WQ(owp, mantissa >> -lsb);
|
||||
} else if (lsb < obits) {
|
||||
_VL_INSERT_WQ(obits, owp, mantissa, lsb + 52, lsb);
|
||||
}
|
||||
if (lhs < 0) VL_NEGATE_INPLACE_W(VL_WORDS_I(obits), owp);
|
||||
return owp;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Range assignments
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
######################################################################
|
||||
# DESCRIPTION: Makefile commands for all verilated target files
|
||||
#
|
||||
# Copyright 2003-2020 by Wilson Snyder. Verilator 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.
|
||||
# Copyright 2003-2020 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.
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
######################################################################
|
||||
|
||||
PERL = @PERL@
|
||||
@@ -86,7 +88,7 @@ LDLIBS += $(VM_USER_LDLIBS)
|
||||
# SystemC takes minutes to optimize, thus it is off by default.
|
||||
#OPT_SLOW =
|
||||
# Fast path optimizations. Most time is spent in these classes.
|
||||
#OPT_FAST = -O2 -fstrict-aliasing
|
||||
#OPT_FAST = -Os -fstrict-aliasing
|
||||
#OPT_FAST = -O
|
||||
#OPT_FAST =
|
||||
|
||||
|
||||
+2
-6
@@ -6,13 +6,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// Lesser General Public License Version 3 or the Perl Artistic License
|
||||
// Version 2.0.
|
||||
//
|
||||
// This 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=========================================================================
|
||||
//
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
|
||||
+11
-14
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -73,12 +70,12 @@ private:
|
||||
public:
|
||||
// METHODS
|
||||
// cppcheck-suppress truncLongCastReturn
|
||||
virtual vluint64_t count() const { return *m_countp; }
|
||||
virtual void zero() const { *m_countp = 0; }
|
||||
virtual vluint64_t count() const VL_OVERRIDE { return *m_countp; }
|
||||
virtual void zero() const VL_OVERRIDE { *m_countp = 0; }
|
||||
// CONSTRUCTORS
|
||||
// cppcheck-suppress noExplicitConstructor
|
||||
VerilatedCoverItemSpec(T* countp) : m_countp(countp) { *m_countp = 0; }
|
||||
virtual ~VerilatedCoverItemSpec() {}
|
||||
explicit VerilatedCoverItemSpec(T* countp) : m_countp(countp) { *m_countp = 0; }
|
||||
virtual ~VerilatedCoverItemSpec() VL_OVERRIDE {}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
@@ -222,7 +219,7 @@ private:
|
||||
void clearGuts() VL_REQUIRES(m_mutex) {
|
||||
for (ItemList::const_iterator it=m_items.begin(); it!=m_items.end(); ++it) {
|
||||
VerilatedCovImpItem* itemp = *(it);
|
||||
delete itemp;
|
||||
VL_DO_DANGLING(delete itemp, itemp);
|
||||
}
|
||||
m_items.clear();
|
||||
m_indexValues.clear();
|
||||
@@ -244,7 +241,7 @@ public:
|
||||
for (ItemList::iterator it=m_items.begin(); it!=m_items.end(); ++it) {
|
||||
VerilatedCovImpItem* itemp = *(it);
|
||||
if (!itemMatchesString(itemp, matchp)) {
|
||||
delete itemp;
|
||||
VL_DO_DANGLING(delete itemp, itemp);
|
||||
} else {
|
||||
newlist.push_back(itemp);
|
||||
}
|
||||
|
||||
+15
-12
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -32,9 +29,15 @@
|
||||
/// Conditionally compile coverage code
|
||||
|
||||
#ifdef VM_COVERAGE
|
||||
# define VL_IF_COVER(stmts) do { stmts ; } while(0)
|
||||
# define VL_IF_COVER(stmts) \
|
||||
do { \
|
||||
stmts; \
|
||||
} while (false)
|
||||
#else
|
||||
# define VL_IF_COVER(stmts) do { if(0) { stmts ; } } while(0)
|
||||
# define VL_IF_COVER(stmts) \
|
||||
do { \
|
||||
if (false) { stmts; } \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
@@ -65,10 +68,10 @@
|
||||
/// VL_COVER_INSERT(&m_cases[i], "comment", "Coverage Case", "i", cvtToNumStr(i));
|
||||
/// }
|
||||
|
||||
#define VL_COVER_INSERT(countp,args...) \
|
||||
#define VL_COVER_INSERT(countp,...) \
|
||||
VL_IF_COVER(VerilatedCov::_inserti(countp); \
|
||||
VerilatedCov::_insertf(__FILE__, __LINE__); \
|
||||
VerilatedCov::_insertp("hier", name(), args))
|
||||
VerilatedCov::_insertp("hier", name(), __VA_ARGS__))
|
||||
|
||||
//=============================================================================
|
||||
/// Convert VL_COVER_INSERT value arguments to strings
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2009-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=========================================================================
|
||||
///
|
||||
@@ -46,8 +42,8 @@
|
||||
VL_FATAL_MT(__FILE__, __LINE__, "", \
|
||||
(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
|
||||
|
||||
#define _VL_SVDPI_WARN(message...) \
|
||||
VL_PRINTF_MT(message)
|
||||
#define _VL_SVDPI_WARN(...) \
|
||||
VL_PRINTF_MT(__VA_ARGS__)
|
||||
|
||||
// Function requires a "context" in the import declaration
|
||||
#define _VL_SVDPI_CONTEXT_WARN() \
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
|
||||
+37
-27
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -20,6 +17,7 @@
|
||||
//=============================================================================
|
||||
// SPDIFF_OFF
|
||||
|
||||
#define __STDC_LIMIT_MACROS // UINT64_MAX
|
||||
#include "verilatedos.h"
|
||||
#include "verilated.h"
|
||||
#include "verilated_fst_c.h"
|
||||
@@ -47,6 +45,7 @@
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||
# include <io.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -62,9 +61,12 @@ protected:
|
||||
vluint32_t m_code; ///< Starting code number
|
||||
// CONSTRUCTORS
|
||||
VerilatedFstCallInfo(VerilatedFstCallback_t icb, VerilatedFstCallback_t fcb,
|
||||
VerilatedFstCallback_t changecb,
|
||||
void* ut, vluint32_t code)
|
||||
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {}
|
||||
VerilatedFstCallback_t changecb, void* ut)
|
||||
: m_initcb(icb)
|
||||
, m_fullcb(fcb)
|
||||
, m_changecb(changecb)
|
||||
, m_userthis(ut)
|
||||
, m_code(1) {}
|
||||
~VerilatedFstCallInfo() {}
|
||||
};
|
||||
|
||||
@@ -72,10 +74,11 @@ protected:
|
||||
// VerilatedFst
|
||||
|
||||
VerilatedFst::VerilatedFst(void* fst)
|
||||
: m_fst(fst),
|
||||
m_fullDump(true),
|
||||
m_scopeEscape('.') {
|
||||
m_valueStrBuffer.reserve(64+1); // Need enough room for quad
|
||||
: m_fst(fst)
|
||||
, m_fullDump(true)
|
||||
, m_nextCode(1)
|
||||
, m_scopeEscape('.') {
|
||||
m_valueStrBuffer.reserve(64 + 1); // Need enough room for quad
|
||||
}
|
||||
|
||||
void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
|
||||
@@ -86,10 +89,12 @@ void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
|
||||
fstWriterSetParallelMode(m_fst, 1);
|
||||
#endif
|
||||
m_curScope.clear();
|
||||
m_nextCode = 1;
|
||||
|
||||
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
|
||||
VerilatedFstCallInfo* cip = m_callbacks[ent];
|
||||
cip->m_code = 1;
|
||||
cip->m_code = m_nextCode;
|
||||
// Initialize; callbacks will call decl* which update m_nextCode
|
||||
(cip->m_initcb)(this, cip->m_userthis, cip->m_code);
|
||||
}
|
||||
|
||||
@@ -116,9 +121,15 @@ void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elem
|
||||
m_local2fstdtype[dtypenum] = enumNum;
|
||||
}
|
||||
|
||||
void VerilatedFst::declSymbol(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum, vluint32_t len) {
|
||||
void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
|
||||
fstVarType vartype, bool array, int arraynum, vluint32_t len,
|
||||
vluint32_t bits) {
|
||||
|
||||
// Make sure deduplicate tracking increments for future declarations
|
||||
int codesNeeded = 1 + int(bits / 32);
|
||||
//Not supported: if (tri) codesNeeded *= 2; // Space in change array for __en signals
|
||||
m_nextCode = std::max(m_nextCode, code + codesNeeded);
|
||||
|
||||
std::pair<Code2SymbolType::iterator, bool> p
|
||||
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
|
||||
std::istringstream nameiss(name);
|
||||
@@ -171,17 +182,16 @@ void VerilatedFst::declSymbol(vluint32_t code, const char* name,
|
||||
//=============================================================================
|
||||
// Callbacks
|
||||
|
||||
void VerilatedFst::addCallback(
|
||||
VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb,
|
||||
VerilatedFstCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
|
||||
void VerilatedFst::addCallback(VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb,
|
||||
VerilatedFstCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
|
||||
m_assertOne.check();
|
||||
if (VL_UNLIKELY(isOpen())) {
|
||||
std::string msg = (std::string("Internal: ")+__FILE__+"::"+__FUNCTION__
|
||||
+" called with already open file");
|
||||
std::string msg = (std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
|
||||
+ " called with already open file");
|
||||
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
|
||||
}
|
||||
VerilatedFstCallInfo* vci = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis, 1);
|
||||
m_callbacks.push_back(vci);
|
||||
VerilatedFstCallInfo* cip = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis);
|
||||
m_callbacks.push_back(cip);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@@ -190,7 +200,7 @@ void VerilatedFst::addCallback(
|
||||
void VerilatedFst::dump(vluint64_t timeui) {
|
||||
if (!isOpen()) return;
|
||||
if (VL_UNLIKELY(m_fullDump)) {
|
||||
m_fullDump = false; // No need for more full dumps
|
||||
m_fullDump = false; // No more need for next dump to be full
|
||||
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
|
||||
VerilatedFstCallInfo* cip = m_callbacks[ent];
|
||||
(cip->m_fullcb)(this, cip->m_userthis, cip->m_code);
|
||||
|
||||
+24
-20
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -50,6 +47,7 @@ private:
|
||||
void* m_fst;
|
||||
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
||||
bool m_fullDump;
|
||||
vluint32_t m_nextCode; ///< Next code number to assign
|
||||
char m_scopeEscape;
|
||||
std::string m_module;
|
||||
CallbackVec m_callbacks; ///< Routines to perform dumping
|
||||
@@ -60,12 +58,13 @@ private:
|
||||
VL_UNCOPYABLE(VerilatedFst);
|
||||
void declSymbol(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum, vluint32_t len);
|
||||
bool array, int arraynum, vluint32_t len, vluint32_t bits);
|
||||
// helpers
|
||||
std::vector<char> m_valueStrBuffer;
|
||||
public:
|
||||
explicit VerilatedFst(void* fst=NULL);
|
||||
~VerilatedFst() { if (m_fst == NULL) { fstWriterClose(m_fst); } }
|
||||
void changeThread() { m_assertOne.changeThread(); }
|
||||
bool isOpen() const { return m_fst != NULL; }
|
||||
void open(const char* filename) VL_MT_UNSAFE;
|
||||
void flush() VL_MT_UNSAFE { fstWriterFlushContext(m_fst); }
|
||||
@@ -104,32 +103,35 @@ public:
|
||||
void declBit(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 1);
|
||||
}
|
||||
void declBus(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum, int msb, int lsb) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
|
||||
msb - lsb + 1);
|
||||
}
|
||||
void declDouble(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 2);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 2, 64);
|
||||
}
|
||||
void declFloat(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, 1, 32);
|
||||
}
|
||||
void declQuad(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum, int msb, int lsb) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
|
||||
msb - lsb + 1);
|
||||
}
|
||||
void declArray(vluint32_t code, const char* name,
|
||||
int dtypenum, fstVarDir vardir, fstVarType vartype,
|
||||
bool array, int arraynum, int msb, int lsb) {
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1);
|
||||
declSymbol(code, name, dtypenum, vardir, vartype, array, arraynum, msb - lsb + 1,
|
||||
msb - lsb + 1);
|
||||
}
|
||||
|
||||
/// Inside dumping routines, dump one signal if it has changed
|
||||
@@ -167,10 +169,10 @@ public:
|
||||
void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
|
||||
chgArray(code, newval, bits); }
|
||||
|
||||
void declTriBit (vluint32_t code, const char* name, int arraynum);
|
||||
void declTriBus (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void declTriQuad (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void declTriArray (vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void declTriBit(vluint32_t code, const char* name, int arraynum);
|
||||
void declTriBus(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void declTriQuad(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void declTriArray(vluint32_t code, const char* name, int arraynum, int msb, int lsb);
|
||||
void fullTriBit(vluint32_t code, const vluint32_t newval, const vluint32_t newtri);
|
||||
void fullTriBus(vluint32_t code, const vluint32_t newval, const vluint32_t newtri, int bits);
|
||||
void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits);
|
||||
@@ -198,7 +200,9 @@ class VerilatedFstC {
|
||||
VL_UNCOPYABLE(VerilatedFstC);
|
||||
public:
|
||||
explicit VerilatedFstC(void* filep=NULL) : m_sptrace(filep) {}
|
||||
~VerilatedFstC() {}
|
||||
~VerilatedFstC() { close(); }
|
||||
/// Routines can only be called from one thread; allow next call from different thread
|
||||
void changeThread() { spTrace()->changeThread(); }
|
||||
public:
|
||||
// ACCESSORS
|
||||
/// Is file open?
|
||||
|
||||
+102
-18
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2010-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
@@ -37,11 +33,43 @@
|
||||
//===================================================================
|
||||
// String formatters (required by below containers)
|
||||
|
||||
extern std::string VL_TO_STRING(CData obj);
|
||||
extern std::string VL_TO_STRING(SData obj);
|
||||
extern std::string VL_TO_STRING(IData obj);
|
||||
extern std::string VL_TO_STRING(QData obj);
|
||||
extern std::string VL_TO_STRING(CData lhs);
|
||||
extern std::string VL_TO_STRING(SData lhs);
|
||||
extern std::string VL_TO_STRING(IData lhs);
|
||||
extern std::string VL_TO_STRING(QData lhs);
|
||||
inline std::string VL_TO_STRING(const std::string& obj) { return "\"" + obj + "\""; }
|
||||
extern std::string VL_TO_STRING_W(int words, WDataInP obj);
|
||||
|
||||
//===================================================================
|
||||
// Readmem/Writemem operation classes
|
||||
|
||||
class VlReadMem {
|
||||
bool m_hex; // Hex format
|
||||
int m_bits; // Bit width of values
|
||||
const std::string& m_filename; // Filename
|
||||
QData m_end; // End address (as specified by user)
|
||||
FILE* m_fp; // File handle for filename
|
||||
QData m_addr; // Next address to read
|
||||
int m_linenum; // Line number last read from file
|
||||
public:
|
||||
VlReadMem(bool hex, int bits, const std::string& filename, QData start, QData end);
|
||||
~VlReadMem();
|
||||
bool isOpen() const { return m_fp != NULL; }
|
||||
int linenum() const { return m_linenum; }
|
||||
bool get(QData& addrr, std::string& valuer);
|
||||
void setData(void* valuep, const std::string& rhs);
|
||||
};
|
||||
|
||||
class VlWriteMem {
|
||||
int m_bits; // Bit width of values
|
||||
FILE* m_fp; // File handle for filename
|
||||
QData m_addr; // Next address to write
|
||||
public:
|
||||
VlWriteMem(bool hex, int bits, const std::string& filename, QData start, QData end);
|
||||
~VlWriteMem();
|
||||
bool isOpen() const { return m_fp != NULL; }
|
||||
void print(QData addr, bool addrstamp, const void* valuep);
|
||||
};
|
||||
|
||||
//===================================================================
|
||||
// Verilog array container
|
||||
@@ -72,6 +100,10 @@ VlWide<T_Words>& VL_CVT_W_A(WDataInP inp, const VlWide<T_Words>&) {
|
||||
return *((VlWide<T_Words>*)inp);
|
||||
}
|
||||
|
||||
template <std::size_t T_Words>
|
||||
std::string VL_TO_STRING(const VlWide<T_Words>& obj) {
|
||||
return VL_TO_STRING_W(T_Words, obj.data());
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
// Verilog associative array container
|
||||
@@ -126,7 +158,7 @@ public:
|
||||
int next(T_Key& indexr) const {
|
||||
typename Map::const_iterator it = m_map.find(indexr);
|
||||
if (VL_UNLIKELY(it == m_map.end())) return 0;
|
||||
it++;
|
||||
++it;
|
||||
if (VL_UNLIKELY(it == m_map.end())) return 0;
|
||||
indexr = it->first;
|
||||
return 1;
|
||||
@@ -180,12 +212,41 @@ std::string VL_TO_STRING(const VlAssocArray<T_Key, T_Value>& obj) {
|
||||
return obj.to_string();
|
||||
}
|
||||
|
||||
template <class T_Key, class T_Value>
|
||||
void VL_READMEM_N(bool hex, int bits, const std::string& filename,
|
||||
VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
|
||||
VlReadMem rmem(hex, bits, filename, start, end);
|
||||
if (VL_UNLIKELY(!rmem.isOpen())) return;
|
||||
while (true) {
|
||||
QData addr;
|
||||
std::string data;
|
||||
if (rmem.get(addr /*ref*/, data /*ref*/)) {
|
||||
rmem.setData(&(obj.at(addr)), data);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T_Key, class T_Value>
|
||||
void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename,
|
||||
const VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
|
||||
VlWriteMem wmem(hex, bits, filename, start, end);
|
||||
if (VL_UNLIKELY(!wmem.isOpen())) return;
|
||||
for (typename VlAssocArray<T_Key, T_Value>::const_iterator it = obj.begin(); it != obj.end();
|
||||
++it) {
|
||||
QData addr = it->first;
|
||||
if (addr >= start && addr <= end) wmem.print(addr, true, &(it->second));
|
||||
}
|
||||
}
|
||||
|
||||
//===================================================================
|
||||
// Verilog queue container
|
||||
// Verilog queue and dynamic array container
|
||||
// There are no multithreaded locks on this; the base variable must
|
||||
// be protected by other means
|
||||
//
|
||||
// Bound here is the maximum size() allowed, e.g. 1 + SystemVerilog bound
|
||||
// For dynamic arrays it is always zero
|
||||
template <class T_Value, size_t T_MaxSize = 0> class VlQueue {
|
||||
private:
|
||||
// TYPES
|
||||
@@ -215,6 +276,21 @@ public:
|
||||
void clear() { m_deque.clear(); }
|
||||
void erase(size_t index) { if (VL_LIKELY(index < m_deque.size())) m_deque.erase(index); }
|
||||
|
||||
// Dynamic array new[] becomes a renew()
|
||||
void renew(size_t size) {
|
||||
clear();
|
||||
m_deque.resize(size, atDefault());
|
||||
}
|
||||
// Dynamic array new[]() becomes a renew_copy()
|
||||
void renew_copy(size_t size, const VlQueue<T_Value,T_MaxSize>& rhs) {
|
||||
if (size == 0) {
|
||||
clear();
|
||||
} else {
|
||||
*this = rhs;
|
||||
m_deque.resize(size, atDefault());
|
||||
}
|
||||
}
|
||||
|
||||
// function void q.push_front(value)
|
||||
void push_front(const T_Value& value) {
|
||||
m_deque.push_front(value);
|
||||
@@ -240,6 +316,7 @@ public:
|
||||
// because we need to be able to insert only when the value is set
|
||||
T_Value& at(size_t index) {
|
||||
static T_Value s_throwAway;
|
||||
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
||||
if (VL_UNLIKELY(index >= m_deque.size())) {
|
||||
s_throwAway = atDefault();
|
||||
return s_throwAway;
|
||||
@@ -249,6 +326,7 @@ public:
|
||||
// Accessing. Verilog: v = assoc[index]
|
||||
const T_Value& at(size_t index) const {
|
||||
static T_Value s_throwAway;
|
||||
// Needs to work for dynamic arrays, so does not use T_MaxSize
|
||||
if (VL_UNLIKELY(index >= m_deque.size())) return atDefault();
|
||||
else return m_deque[index];
|
||||
}
|
||||
@@ -312,12 +390,12 @@ extern std::string VL_TOLOWER_NN(const std::string& ld);
|
||||
extern std::string VL_TOUPPER_NN(const std::string& ld);
|
||||
|
||||
extern IData VL_FOPEN_NI(const std::string& filename, IData mode) VL_MT_SAFE;
|
||||
extern void VL_READMEM_N(bool hex, int width, int depth, int array_lsb,
|
||||
const std::string& filename,
|
||||
void* memp, IData start, IData end) VL_MT_SAFE;
|
||||
extern void VL_WRITEMEM_N(bool hex, int width, int depth, int array_lsb,
|
||||
const std::string& filename,
|
||||
const void* memp, IData start, IData end) VL_MT_SAFE;
|
||||
extern void VL_READMEM_N(bool hex, int bits, QData depth, int array_lsb,
|
||||
const std::string& filename, void* memp, QData start,
|
||||
QData end) VL_MT_SAFE;
|
||||
extern void VL_WRITEMEM_N(bool hex, int bits, QData depth, int array_lsb,
|
||||
const std::string& filename, const void* memp, QData start,
|
||||
QData end) VL_MT_SAFE;
|
||||
extern IData VL_SSCANF_INX(int lbits, const std::string& ld,
|
||||
const char* formatp, ...) VL_MT_SAFE;
|
||||
extern void VL_SFORMAT_X(int obits_ignored, std::string& output,
|
||||
@@ -377,4 +455,10 @@ inline IData VL_CMP_NN(const std::string& lhs, const std::string& rhs, bool igno
|
||||
|
||||
extern IData VL_ATOI_N(const std::string& str, int base) VL_PURE;
|
||||
|
||||
//======================================================================
|
||||
// Dumping
|
||||
|
||||
extern const char* vl_dumpctl_filenamep(bool setit = false,
|
||||
const std::string& filename = "") VL_MT_SAFE;
|
||||
|
||||
#endif // Guard
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2009-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=========================================================================
|
||||
///
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -187,7 +184,7 @@ void VerilatedSave::flush() VL_MT_UNSAFE_ONE {
|
||||
m_assertOne.check();
|
||||
if (VL_UNLIKELY(!isOpen())) return;
|
||||
vluint8_t* wp = m_bufp;
|
||||
while (1) {
|
||||
while (true) {
|
||||
ssize_t remaining = (m_cp - wp);
|
||||
if (remaining==0) break;
|
||||
errno = 0;
|
||||
@@ -216,7 +213,7 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
|
||||
m_endp = m_bufp + (m_endp - m_cp);
|
||||
m_cp = m_bufp; // Reset buffer
|
||||
// Read into buffer starting at m_endp
|
||||
while (1) {
|
||||
while (true) {
|
||||
ssize_t remaining = (m_bufp+bufferSize() - m_endp);
|
||||
if (remaining==0) break;
|
||||
errno = 0;
|
||||
|
||||
+12
-15
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2012-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2000-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -164,12 +161,12 @@ private:
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
VerilatedSave() { m_fd = -1; }
|
||||
virtual ~VerilatedSave() { close(); }
|
||||
virtual ~VerilatedSave() VL_OVERRIDE { close(); }
|
||||
// METHODS
|
||||
void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
|
||||
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
||||
virtual void close() VL_MT_UNSAFE_ONE;
|
||||
virtual void flush() VL_MT_UNSAFE_ONE;
|
||||
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
||||
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
@@ -183,14 +180,14 @@ private:
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
VerilatedRestore() { m_fd = -1; }
|
||||
virtual ~VerilatedRestore() { close(); }
|
||||
virtual ~VerilatedRestore() VL_OVERRIDE { close(); }
|
||||
|
||||
// METHODS
|
||||
void open(const char* filenamep) VL_MT_UNSAFE_ONE; ///< Open the file; call isOpen() to see if errors
|
||||
void open(const std::string& filename) VL_MT_UNSAFE_ONE { open(filename.c_str()); }
|
||||
virtual void close() VL_MT_UNSAFE_ONE;
|
||||
virtual void flush() VL_MT_UNSAFE_ONE {}
|
||||
virtual void fill() VL_MT_UNSAFE_ONE;
|
||||
virtual void close() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
||||
virtual void flush() VL_OVERRIDE VL_MT_UNSAFE_ONE {}
|
||||
virtual void fill() VL_OVERRIDE VL_MT_UNSAFE_ONE;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2009-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
//
|
||||
// Copyright 2003-2020 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.
|
||||
// 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
///
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
||||
//=============================================================================
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2012-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2012-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -41,7 +36,8 @@ VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
|
||||
// VlWorkerThread
|
||||
|
||||
VlWorkerThread::VlWorkerThread(VlThreadPool* poolp, bool profiling)
|
||||
: m_ready_size(0)
|
||||
: m_waiting(false)
|
||||
, m_ready_size(0)
|
||||
, m_poolp(poolp)
|
||||
, m_profiling(profiling)
|
||||
, m_exiting(false)
|
||||
@@ -63,7 +59,7 @@ void VlWorkerThread::workerLoop() {
|
||||
ExecRec work;
|
||||
work.m_fnp = NULL;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (VL_LIKELY(!work.m_fnp)) {
|
||||
dequeWork(&work);
|
||||
}
|
||||
@@ -173,12 +169,12 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
|
||||
VlMTaskVertex::yields());
|
||||
|
||||
vluint32_t thread_id = 0;
|
||||
for (ProfileSet::iterator pit = m_allProfiles.begin();
|
||||
for (ProfileSet::const_iterator pit = m_allProfiles.begin();
|
||||
pit != m_allProfiles.end(); ++pit) {
|
||||
++thread_id;
|
||||
|
||||
bool printing = false; // False while in warmup phase
|
||||
for (ProfileTrace::iterator eit = (*pit)->begin();
|
||||
for (ProfileTrace::const_iterator eit = (*pit)->begin();
|
||||
eit != (*pit)->end(); ++eit) {
|
||||
switch (eit->m_type) {
|
||||
case VlProfileRec::TYPE_BARRIER:
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2012-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2012-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
|
||||
@@ -7,15 +7,11 @@
|
||||
//
|
||||
//*************************************************************************
|
||||
//
|
||||
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can
|
||||
// redistribute it and/or modify it under the terms of either the GNU
|
||||
// Copyright 2003-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//*************************************************************************
|
||||
|
||||
@@ -151,7 +147,7 @@ public:
|
||||
return (!this->operator==(other));
|
||||
}
|
||||
void advanceUntilValid() {
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (m_bit != m_setp->m_bucketsp[m_bucketIdx].end()) {
|
||||
// Valid iterator in this bucket; we're done.
|
||||
return;
|
||||
@@ -212,7 +208,7 @@ public:
|
||||
}
|
||||
}
|
||||
~vl_unordered_set() {
|
||||
delete [] m_bucketsp; VL_DANGLING(m_bucketsp);
|
||||
VL_DO_DANGLING(delete [] m_bucketsp, m_bucketsp);
|
||||
}
|
||||
|
||||
vl_unordered_set& operator=(const vl_unordered_set& other) {
|
||||
|
||||
+42
-40
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -57,8 +54,8 @@ class VerilatedVcdSingleton {
|
||||
private:
|
||||
typedef std::vector<VerilatedVcd*> VcdVec;
|
||||
struct Singleton {
|
||||
VerilatedMutex s_vcdMutex; ///< Protect the singleton
|
||||
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
||||
VerilatedMutex s_vcdMutex; ///< Protect the singleton
|
||||
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
|
||||
};
|
||||
static Singleton& singleton() { static Singleton s; return s; }
|
||||
public:
|
||||
@@ -96,16 +93,19 @@ public:
|
||||
class VerilatedVcdCallInfo {
|
||||
protected:
|
||||
friend class VerilatedVcd;
|
||||
VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function
|
||||
VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function
|
||||
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
|
||||
void* m_userthis; ///< Fake "this" for caller
|
||||
vluint32_t m_code; ///< Starting code number
|
||||
VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function
|
||||
VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function
|
||||
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
|
||||
void* m_userthis; ///< Fake "this" for caller
|
||||
vluint32_t m_code; ///< Starting code number (set later by traceInit)
|
||||
// CONSTRUCTORS
|
||||
VerilatedVcdCallInfo(VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb,
|
||||
VerilatedVcdCallback_t changecb,
|
||||
void* ut, vluint32_t code)
|
||||
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {}
|
||||
VerilatedVcdCallback_t changecb, void* ut)
|
||||
: m_initcb(icb)
|
||||
, m_fullcb(fcb)
|
||||
, m_changecb(changecb)
|
||||
, m_userthis(ut)
|
||||
, m_code(1) {}
|
||||
~VerilatedVcdCallInfo() {}
|
||||
};
|
||||
|
||||
@@ -116,7 +116,7 @@ protected:
|
||||
|
||||
bool VerilatedVcdFile::open(const std::string& name) VL_MT_UNSAFE {
|
||||
m_fd = ::open(name.c_str(), O_CREAT|O_WRONLY|O_TRUNC|O_LARGEFILE|O_NONBLOCK|O_CLOEXEC, 0666);
|
||||
return (m_fd>=0);
|
||||
return m_fd >= 0;
|
||||
}
|
||||
|
||||
void VerilatedVcdFile::close() VL_MT_UNSAFE {
|
||||
@@ -133,7 +133,10 @@ ssize_t VerilatedVcdFile::write(const char* bufp, ssize_t len) VL_MT_UNSAFE {
|
||||
// Opening/Closing
|
||||
|
||||
VerilatedVcd::VerilatedVcd(VerilatedVcdFile* filep)
|
||||
: m_isOpen(false), m_rolloverMB(0), m_modDepth(0), m_nextCode(1) {
|
||||
: m_isOpen(false)
|
||||
, m_rolloverMB(0)
|
||||
, m_modDepth(0)
|
||||
, m_nextCode(1) {
|
||||
// Not in header to avoid link issue if header is included without this .cpp file
|
||||
m_fileNewed = (filep == NULL);
|
||||
m_filep = m_fileNewed ? new VerilatedVcdFile : filep;
|
||||
@@ -156,7 +159,7 @@ void VerilatedVcd::open(const char* filename) {
|
||||
if (isOpen()) return;
|
||||
|
||||
// Set member variables
|
||||
m_filename = filename;
|
||||
m_filename = filename; // "" is ok, as someone may overload open
|
||||
VerilatedVcdSingleton::pushVcd(this);
|
||||
|
||||
// SPDIFF_OFF
|
||||
@@ -230,9 +233,10 @@ void VerilatedVcd::makeNameMap() {
|
||||
deleteNameMap();
|
||||
m_nextCode = 1;
|
||||
m_namemapp = new NameMap;
|
||||
for (vluint32_t ent = 0; ent< m_callbacks.size(); ent++) {
|
||||
for (vluint32_t ent = 0; ent < m_callbacks.size(); ent++) {
|
||||
VerilatedVcdCallInfo* cip = m_callbacks[ent];
|
||||
cip->m_code = m_nextCode;
|
||||
// Initialize; callbacks will call decl* which update m_nextCode
|
||||
(cip->m_initcb)(this, cip->m_userthis, cip->m_code);
|
||||
}
|
||||
|
||||
@@ -360,7 +364,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
|
||||
m_assertOne.check();
|
||||
if (VL_UNLIKELY(!isOpen())) return;
|
||||
char* wp = m_wrBufp;
|
||||
while (1) {
|
||||
while (true) {
|
||||
ssize_t remaining = (m_writep - wp);
|
||||
if (remaining==0) break;
|
||||
errno = 0;
|
||||
@@ -513,7 +517,7 @@ void VerilatedVcd::dumpHeader() {
|
||||
|
||||
printIndent(-1);
|
||||
printStr("$enddefinitions $end\n\n\n");
|
||||
assert(m_modDepth==0);
|
||||
assert(m_modDepth == 0);
|
||||
|
||||
// Reclaim storage
|
||||
deleteNameMap();
|
||||
@@ -529,12 +533,12 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
|
||||
if (!code) { VL_FATAL_MT(__FILE__, __LINE__, "",
|
||||
"Internal: internal trace problem, code 0 is illegal"); }
|
||||
|
||||
int bits = ((msb>lsb)?(msb-lsb):(lsb-msb))+1;
|
||||
int codesNeeded = 1+int(bits/32);
|
||||
int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
|
||||
int codesNeeded = 1 + int(bits / 32);
|
||||
if (tri) codesNeeded *= 2; // Space in change array for __en signals
|
||||
|
||||
// Make sure array is large enough
|
||||
m_nextCode = std::max(m_nextCode, code+codesNeeded);
|
||||
m_nextCode = std::max(m_nextCode, code + codesNeeded);
|
||||
if (m_sigs.capacity() <= m_nextCode) {
|
||||
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up
|
||||
}
|
||||
@@ -658,19 +662,16 @@ void VerilatedVcd::fullFloat(vluint32_t code, const float newval) {
|
||||
//=============================================================================
|
||||
// Callbacks
|
||||
|
||||
void VerilatedVcd::addCallback(
|
||||
VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb, VerilatedVcdCallback_t changecb,
|
||||
void* userthis) VL_MT_UNSAFE_ONE
|
||||
{
|
||||
void VerilatedVcd::addCallback(VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb,
|
||||
VerilatedVcdCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
|
||||
m_assertOne.check();
|
||||
if (VL_UNLIKELY(isOpen())) {
|
||||
std::string msg = std::string("Internal: ")+__FILE__+"::"+__FUNCTION__
|
||||
+" called with already open file";
|
||||
std::string msg = std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
|
||||
+ " called with already open file";
|
||||
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
|
||||
}
|
||||
VerilatedVcdCallInfo* vci
|
||||
= new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, m_nextCode);
|
||||
m_callbacks.push_back(vci);
|
||||
VerilatedVcdCallInfo* cip = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis);
|
||||
m_callbacks.push_back(cip);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@@ -680,7 +681,7 @@ void VerilatedVcd::dumpFull(vluint64_t timeui) {
|
||||
m_assertOne.check();
|
||||
dumpPrep(timeui);
|
||||
Verilated::quiesce();
|
||||
for (vluint32_t ent = 0; ent< m_callbacks.size(); ent++) {
|
||||
for (vluint32_t ent = 0; ent < m_callbacks.size(); ent++) {
|
||||
VerilatedVcdCallInfo* cip = m_callbacks[ent];
|
||||
(cip->m_fullcb)(this, cip->m_userthis, cip->m_code);
|
||||
}
|
||||
@@ -690,7 +691,7 @@ void VerilatedVcd::dump(vluint64_t timeui) {
|
||||
m_assertOne.check();
|
||||
if (!isOpen()) return;
|
||||
if (VL_UNLIKELY(m_fullDump)) {
|
||||
m_fullDump = false; // No need for more full dumps
|
||||
m_fullDump = false; // No more need for next dump to be full
|
||||
dumpFull(timeui);
|
||||
return;
|
||||
}
|
||||
@@ -700,7 +701,7 @@ void VerilatedVcd::dump(vluint64_t timeui) {
|
||||
}
|
||||
dumpPrep(timeui);
|
||||
Verilated::quiesce();
|
||||
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
|
||||
for (vluint32_t ent = 0; ent < m_callbacks.size(); ++ent) {
|
||||
VerilatedVcdCallInfo* cip = m_callbacks[ent];
|
||||
(cip->m_changecb)(this, cip->m_userthis, cip->m_code);
|
||||
}
|
||||
@@ -829,6 +830,7 @@ main() {
|
||||
#endif
|
||||
|
||||
//********************************************************************
|
||||
// ;compile-command: "mkdir -p ../test_dir && cd ../test_dir && c++ -DVERILATED_VCD_TEST ../include/verilated_vcd_c.cpp -o verilated_vcd_c && ./verilated_vcd_c && cat test.vcd"
|
||||
//
|
||||
// Local Variables:
|
||||
// compile-command: "mkdir -p ../test_dir && cd ../test_dir && c++ -DVERILATED_VCD_TEST ../include/verilated_vcd_c.cpp -o verilated_vcd_c && ./verilated_vcd_c && cat test.vcd"
|
||||
// End:
|
||||
|
||||
+12
-11
@@ -3,14 +3,11 @@
|
||||
//
|
||||
// THIS MODULE IS PUBLICLY LICENSED
|
||||
//
|
||||
// Copyright 2001-2020 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.
|
||||
//
|
||||
// This 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.
|
||||
// Copyright 2001-2020 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.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
//
|
||||
//=============================================================================
|
||||
///
|
||||
@@ -103,9 +100,9 @@ private:
|
||||
typedef std::vector<VerilatedVcdSig> SigVec;
|
||||
SigVec m_sigs; ///< Pointer to signal information
|
||||
typedef std::vector<VerilatedVcdCallInfo*> CallbackVec;
|
||||
CallbackVec m_callbacks; ///< Routines to perform dumping
|
||||
CallbackVec m_callbacks; ///< Routines to perform dumping
|
||||
typedef std::map<std::string,std::string> NameMap;
|
||||
NameMap* m_namemapp; ///< List of names for the header
|
||||
NameMap* m_namemapp; ///< List of names for the header
|
||||
|
||||
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
|
||||
|
||||
@@ -159,6 +156,8 @@ private:
|
||||
public:
|
||||
explicit VerilatedVcd(VerilatedVcdFile* filep = NULL);
|
||||
~VerilatedVcd();
|
||||
/// Routines can only be called from one thread; allow next call from different thread
|
||||
void changeThread() { m_assertOne.changeThread(); }
|
||||
|
||||
// ACCESSORS
|
||||
/// Set size in megabytes after which new file should be created
|
||||
@@ -445,7 +444,9 @@ class VerilatedVcdC {
|
||||
public:
|
||||
explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL)
|
||||
: m_sptrace(filep) {}
|
||||
~VerilatedVcdC() {}
|
||||
~VerilatedVcdC() { close(); }
|
||||
/// Routines can only be called from one thread; allow next call from different thread
|
||||
void changeThread() { spTrace()->changeThread(); }
|
||||
public:
|
||||
// ACCESSORS
|
||||
/// Is file open?
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user