Compare commits

...
100 Commits
Author SHA1 Message Date
Wilson Snyder d3797ade95 Version bump 2020-04-04 08:40:47 -04:00
Wilson Snyder 19b472cf0b Internals: Cleanup unused nodep in visitors. No functional change intended. 2020-04-04 08:31:14 -04:00
Wilson Snyder 38a31ae168 Cleanup misc clang-tidy warnings. No functional change intended 2020-04-03 22:31:54 -04:00
Wilson Snyder 27516b565d Commentary 2020-04-03 20:08:24 -04:00
Wilson Snyder c288a7bfb9 Add GCC10-style line number prefix when showing source text for errors. 2020-04-03 20:07:46 -04:00
Maciej Sobkowski b44cd57866 Add myself to CONTRIBUTORS, #2223 2020-04-03 18:06:48 -04:00
Wilson Snyder b88a7f5152 Commentary - sort names. 2020-04-03 17:59:19 -04:00
Marco Widmer 7f9aa057bf Support split_var in vit files (#2219) 2020-04-03 08:08:23 -04:00
Marco Widmer 305b4f3c75 Fix configuration file documentation (#2221) 2020-04-02 17:32:06 -04:00
Wilson Snyder 6f4a8fe695 Fix Travis-CI failures. 2020-04-02 09:22:10 -04:00
Wilson Snyder 8aec436b5e Commentary 2020-04-02 08:26:06 -04:00
Wilson Snyder aef2b7ea3c Internals: clang-format cleanup. No functional change. 2020-04-02 08:25:44 -04:00
Wilson Snyder dcde026bac With --Wpedantic, report forward typedefs that are unused. 2020-04-02 07:39:14 -04:00
Wilson Snyder 926209706f Report REALCVT on $display format mistakes. 2020-04-01 20:42:47 -04:00
Wilson Snyder bd5d4c61c6 Suppress REALCVT for small whole real numbers. 2020-04-01 19:24:07 -04:00
Wilson Snyder 19abce5535 Suppress REALCVT for whole real numbers. 2020-04-01 18:43:53 -04:00
Wilson Snyder ab058c85bf Fix clang warning. 2020-04-01 12:40:49 -04:00
Wilson Snyder 4361c4b57a Add vlsint8_t types. 2020-03-31 21:30:18 -04:00
Wilson Snyder e6beab4037 Fix implicit conversion of floats to wide integers. 2020-03-31 20:42:07 -04:00
Wilson Snyder ebeb645539 Commentary 2020-03-30 20:09:55 -04:00
Wilson Snyder 5c72f01598 Fix assertions with unique case inside, #2199. 2020-03-30 18:13:51 -04:00
Wilson Snyder 0cf44a9c4f Internals: Refactor InsideRange common code. No functional change intended. 2020-03-30 18:12:50 -04:00
Sean Cross 1fe5d5db79 Fix mingw build (#2215)
* v3Os: include <windows.h> instead of <winnt.h>

The windows.h header file should be included prior to any other headers,
in order to ensure all definitions are available.  By only including
some headers, such as winnt.h, many "undefined symbol" messages are
generated.

Include "windows.h" to fix the build on msys2 under mingw64.

Signed-off-by: Sean Cross <[email protected]>

* configure: check for bcrypt and psapi on windows

These two libraries must be linked in order to have access to
BCryptGenRandom and GetProcessMemoryInfo respectively.

Signed-off-by: Sean Cross <[email protected]>
2020-03-29 12:29:40 -04:00
Sean Cross a1a2650f1e Modernize va args (#2214)
Verilator uses a form of variadic macros that are nonstandard, making it
unable to be compiled under MSVC.  Replace the old synax with the
standard syntax.  This fixes MSVC usage.

Signed-off-by: Sean Cross <[email protected]>
2020-03-29 10:29:12 -04:00
Wilson Snyder 07d00f26aa Fix docker exit status when Verilator fails, #2153. 2020-03-28 19:15:06 -04:00
Wilson Snyder 8d3d185e3b Fix docker exit status when Verilator fails, #2153. 2020-03-28 17:25:20 -04:00
Wilson Snyder 81a63b0c7d Commentary 2020-03-28 17:18:12 -04:00
Matthew Ballance 510be53521 Expose VPI cbNextDeadline via the public API (#2212)
Signed-off-by: Matthew Ballance <[email protected]>
2020-03-28 13:47:21 -04:00
Wilson Snyder 4145a38c47 Fix duplicate typedefs in generate for, #2205. 2020-03-26 18:10:20 -04:00
Wilson Snyder 590b1853d0 Fix packages as enum base types, #2202. 2020-03-24 17:57:12 -04:00
Wilson Snyder 08a51e3e09 Fix VCD open with empty filename, #2198. 2020-03-24 17:32:47 -04:00
Wilson Snyder 75ebe7a4be Update gtkwave from upstream. 2020-03-21 21:45:57 -04:00
Wilson Snyder 1e0e51edd3 Fix parameter type redeclaring a type, #2195. 2020-03-21 12:13:55 -04:00
Wilson Snyder 0ca07e4d58 Tests: Remove t_emit_memb_limit/vltmt as slow 2020-03-21 12:08:38 -04:00
Wilson Snyder 1ce360ed5b Add SPDX license identifiers. No functional change. 2020-03-21 11:24:24 -04:00
Wilson Snyder 172583eb03 Commentary - fix error regexp, #2191. 2020-03-17 15:39:50 -04:00
Wilson Snyder c2b49f0174 Internals: clang-format cleanups. No functional change. 2020-03-15 23:20:33 -04:00
Wilson Snyder 92d62a6568 Internals: clang-format cleanups for V3Inline. No functional change. 2020-03-15 22:30:20 -04:00
Wilson Snyder 5d9d1cc09f Internals: Favor const_iterator (in a few obvious spots, more needed). No functional change. 2020-03-15 18:34:09 -04:00
Wilson Snyder 57068b95ef Internals: Move code, no functional change. 2020-03-15 13:39:36 -04:00
Wilson Snyder 5f63b24c50 Change --quiet-exit to also suppress 'Exiting due to N errors'. 2020-03-15 08:09:51 -04:00
Wilson Snyder 81c659957e Add column numbers to errors and warnings. 2020-03-14 22:02:42 -04:00
Wilson Snyder ee8dd32c04 Check and document error format, #2191. 2020-03-14 21:48:26 -04:00
Wilson Snyder 0a755e6ecf Tests: Favor use of expect_filename. No functional change. 2020-03-14 17:42:15 -04:00
Wilson Snyder e6c91f59ab Tests: Allow --numsets 2/2 2020-03-09 17:57:27 -04:00
Wilson Snyder 9f947bcb5f Internals: Refactor flags in V3Undriven. No functional change intended. 2020-03-08 21:37:07 -04:00
Wilson Snyder 135ccf6595 Tests: Fix ormux on travis. 2020-03-08 09:48:13 -04:00
Wilson Snyder 9a2a3f8db7 Tests: Add t_gate_ormux, #2186, #2187. 2020-03-08 09:18:12 -04:00
Wilson Snyder 8ccc17f30b Add setting VM_PARALLEL_BUILDS=1 when using --output-split, #2185. 2020-03-08 09:03:29 -04:00
Wilson Snyder 9392eac6a7 devel release 2020-03-08 08:40:33 -04:00
Wilson Snyder 95c4b6aaba Version bump 2020-03-08 08:38:53 -04:00
Wilson Snyder 1c1319079b Tests: Add driver --hashset for Travis. 2020-03-07 22:02:03 -05:00
Wilson Snyder 328fef8190 Tests: Add driver --hashset for Travis. 2020-03-07 21:38:44 -05:00
Wilson Snyder e2dec043a0 Tests: Backout part of previous commit. 2020-03-07 21:01:36 -05:00
Wilson Snyder bd42e31b2a Tests: For travis, skip Bit::Vector and show intall dates. 2020-03-07 20:08:41 -05:00
Wilson Snyder 6d73237b27 Travis: Don't cpan test to save time. 2020-03-07 19:24:05 -05:00
Wilson Snyder 6c6d70a5e5 Fix FST when multi-model tracing. 2020-03-07 18:39:58 -05:00
Wilson Snyder 6f49f802b1 Tests: Add fst_identical. 2020-03-07 16:59:46 -05:00
Wilson Snyder 808c958d42 Internals: Add AstNodeCCall and other items towards classes. 2020-03-07 12:52:11 -05:00
Wilson Snyder 961ac49c5c Internals: Merge parse type from classes branch. No functional change intended. 2020-03-07 11:00:57 -05:00
Wilson Snyder 2d52f525c5 Add --structs-packed for forward compatibility, #1541. 2020-03-07 10:51:06 -05:00
Wilson Snyder e70cba77e6 Add support for dynamic arrays, #379. 2020-03-07 10:24:27 -05:00
Wilson Snyder 8054fc47ea Internals: Refectoring. No functional change intended. 2020-03-07 08:24:57 -05:00
Wilson Snyder e673875b3b Fix clang warning, last commit. 2020-03-06 07:31:56 -05:00
Wilson Snyder 29923b78fd Internals: Use VL_TO_STRING instead of to_string. 2020-03-05 23:28:41 -05:00
Wilson Snyder 135cbcd79a Internals: Move 'new' unsupported forward from parse into Ast. 2020-03-05 22:33:31 -05:00
Wilson Snyder 75ecad591a Implement $displayb/o/h, $writeb/o/h, etc, Closes #1637. 2020-03-05 21:49:25 -05:00
Wilson Snyder c108f5def9 Commentary, Closes #2177. 2020-03-05 19:09:58 -05:00
Wilson Snyder dab1cb610a Tests: Allow iv to run SystemVerilog tests 2020-03-05 18:12:10 -05:00
Wilson Snyder fd656f6cc1 Fix clang asserted missing lock on m_dumping. 2020-03-03 19:20:04 -05:00
Wilson Snyder a7e65379fa Ignore $dumpflush, think causes travis thread error. 2020-03-02 17:56:42 -05:00
Wilson Snyder 905067d13f Fix $dumpvar multithreaded assert, broke last commit. 2020-03-02 07:43:10 -05:00
Wilson Snyder 30a33a6104 Add support for and , #2126. 2020-03-01 21:39:23 -05:00
Wilson Snyder 0ca0e07354 Internals: Vcd doesn't need code when registering. No functional change intended. 2020-02-29 20:42:52 -05:00
Wilson Snyder aac02acf92 Tests: Rename 2020-02-29 10:06:52 -05:00
Wilson Snyder 082c9e0b1d Tests: Add two-design trace tests. 2020-02-29 09:44:51 -05:00
Wilson Snyder a7bd934fe3 Tests: Cleanup false used as 0. No functional change. 2020-02-29 08:56:49 -05:00
David Stanford e98a380b44 Tests: Update some tests to skip if prerequisites aren't installed (#2181) 2020-02-29 07:20:23 -05:00
Wilson Snyder 4878fe3a1f Add split_var metacomment to assist UNOPTFLAT fixes, #2066. 2020-02-28 19:15:08 -05:00
Wilson Snyder c6b755a12e Commentary 2020-02-27 19:35:49 -05:00
Wilson Snyder 991d81cd0a Recommend -Os. 2020-02-27 07:46:34 -05:00
Wilson Snyder c06a97a221 Remove OBJCACHE_HOSTS; dead code. 2020-02-27 07:18:15 -05:00
Wilson Snyder 6131bcdbb0 Verilator_gantt: Fix CPU count in report. 2020-02-27 07:12:50 -05:00
Wilson Snyder 68b6a0b667 Fix genblk naming with directly nested generate blocks, #2176. 2020-02-25 22:21:16 -05:00
Wilson Snyder 4c438bbc67 Commentary 2020-02-25 19:01:14 -05:00
Wilson Snyder 5b83484f20 Remove dead genblk code & some cleanups. 2020-02-25 18:57:51 -05:00
Wilson Snyder 93ac79981b Tests: Rename t_var_dotted. No functional change. 2020-02-24 18:51:44 -05:00
Wilson Snyder c9b74847d1 Docs: Tighter margins, save 10 pages. 2020-02-24 18:11:56 -05:00
Wilson Snyder 23eb96579c Fix duplicate __STDC_FORMAT_MACROS definition. 2020-02-24 18:11:41 -05:00
Todd Strader 8319ea6c73 Changes 2020-02-24 06:36:13 -05:00
Todd Strader 60f82961b4 De-tabify 2020-02-24 06:36:13 -05:00
Todd Strader f7d1c6ca72 emacs verilog-batch-indent 2020-02-24 06:36:13 -05:00
Todd Strader 4b4f10f5e6 Follow other clock gating examples 2020-02-24 06:36:13 -05:00
Todd Strader 120f62fe85 Fix is probably to mark as a clock 2020-02-24 06:36:13 -05:00
Todd Strader db6ecbd57e Test for #2169 2020-02-24 06:36:13 -05:00
Wilson Snyder 28e19cef90 Fix undeclared VL_SHIFTR_WWQ, #2114. 2020-02-23 19:33:37 -05:00
Tobias Wölfel 18f8cd0529 Allow assert disable (#2168)
* Add +verilator+noassert flag

This allows to disable the assert check per simulation argument.

* Add AssertOn check for assert

Insert the check AssertOn to allow disabling of asserts.
Asserts can be disabled by not using the `--assert` flag or by calling
`AssertOn(false)`, or passing the "+verilator+noassert" runtime flag.
Add tests for this behavior.
Bad tests check that the assert still causes a stop.
Non bad tests check that asserts are properly disabled and cause no stop
of the simulation.

Fixes #2162.

Signed-off-by: Tobias Wölfel <[email protected]>

* Correct file location

Signed-off-by: Tobias Wölfel <[email protected]>

* Add description for single test execution

Without this description it is not obvious how to run a single test from
the regression test suite.

Signed-off-by: Tobias Wölfel <[email protected]>
2020-02-15 18:17:23 -06:00
Wilson Snyder 02786b3f09 Commentary 2020-02-12 22:46:59 -05:00
Wilson Snyder 70358e8587 Fix compiler warning. 2020-02-08 10:58:07 -05:00
Wilson Snyder 95b66feeb8 devel release 2020-02-08 09:16:35 -05:00
2849 changed files with 20064 additions and 10548 deletions
+14 -6
View File
@@ -1,8 +1,10 @@
# DESCRIPTION: Travis-CI config # DESCRIPTION: Travis-CI config
# #
# Copyright 2003-2019 by Todd Strader. Verilator is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU Lesser # can redistribute it and/or modify it under the terms of either the GNU
# General Public License Version 3 or the Perl Artistic License Version 2.0. # 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 version: ~> 1.0
@@ -25,7 +27,8 @@ cache:
before_install: before_install:
# Perl modules needed for testing # 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 gdb gtkwave
- sudo apt-get install libgoogle-perftools-dev - sudo apt-get install libgoogle-perftools-dev
before_script: before_script:
@@ -58,9 +61,14 @@ jobs:
script: ci/test.sh vlt script: ci/test.sh vlt
- if: type != cron - if: type != cron
stage: test stage: test
name: Vltmt test name: Vltmt set 0 test
compiler: gcc 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 # Cron builds try different OS/compiler combinations
- if: type = cron - if: type = cron
stage: "Build Verilator" stage: "Build Verilator"
+56 -1
View File
@@ -3,6 +3,58 @@ Revision history for Verilator
The contributors that suggested a given feature are shown in []. Thanks! 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 * Verilator 4.028 2020-02-08
** Support attributes (public, isolate_assignments, etc.) in configuration files. ** Support attributes (public, isolate_assignments, etc.) in configuration files.
@@ -45,6 +97,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix OpenSolaris issues, #2154. [brancoliticus] **** Fix OpenSolaris issues, #2154. [brancoliticus]
**** Fix gated clocks under --protect-lib, #2169. [Todd Strader]
* Verilator 4.026 2020-01-11 * Verilator 4.026 2020-01-11
@@ -3513,10 +3567,11 @@ of input ports exists for tracing.
This uses outline mode in Emacs. See C-h m [M-x describe-mode]. 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 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. Version 2.0.
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
Local variables: Local variables:
mode: outline mode: outline
+2 -1
View File
@@ -28,7 +28,7 @@
/obj_vcs/ /obj_vcs/
/obj_vlt/ /obj_vlt/
/obj_vltmt/ /obj_vltmt/
/INCA_libs/ INCA_libs/
/cov_work/ /cov_work/
/logs/ /logs/
^Makefile$ ^Makefile$
@@ -37,6 +37,7 @@ bin/verilator_bin.*
bin/verilator_coverage_bin.* bin/verilator_coverage_bin.*
docs/.*\.html$ docs/.*\.html$
docs/Makefile$ docs/Makefile$
docs/clang-format.txt$
docs/doxygen-doc/.* docs/doxygen-doc/.*
examples/xml_py/copied/ examples/xml_py/copied/
examples/xml_py/graph.* examples/xml_py/graph.*
+3 -13
View File
@@ -7,15 +7,11 @@
# #
#***************************************************************************** #*****************************************************************************
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
# #
#****************************************************************************/ #****************************************************************************/
# #
@@ -208,12 +204,6 @@ EXAMPLES_FIRST = \
EXAMPLES = $(EXAMPLES_FIRST) $(filter-out $(EXAMPLES_FIRST), $(sort $(wildcard examples/*))) 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 # 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 VL_INST_MAN_FILES = verilator.1 verilator_coverage.1 verilator_gantt.1 verilator_profcfunc.1
+2 -2
View File
@@ -25,7 +25,7 @@ endif::[]
^.^| *Welcome to Verilator, the fastest free Verilog HDL simulator.* ^.^| *Welcome to Verilator, the fastest free Verilog HDL simulator.*
+++ <br/> +++ &bullet; Accepts synthesizable Verilog or SystemVerilog +++ <br/> +++ &bullet; Accepts synthesizable Verilog or SystemVerilog
+++ <br/> +++ &bullet; Performs lint code-quality checks +++ <br/> +++ &bullet; Performs lint code-quality checks
+++ <br/> +++ &bullet; Compiles into multithreaded {cpp}, SystemC, or (soon) {cpp}-under-Python +++ <br/> +++ &bullet; Compiles into multithreaded {cpp}, or SystemC
+++ <br/> +++ &bullet; Creates XML to front-end your own tools +++ <br/> +++ &bullet; Creates XML to front-end your own tools
<.^|image:https://www.veripool.org/img/verilator_256_200_min.png[Logo,256,200] <.^|image:https://www.veripool.org/img/verilator_256_200_min.png[Logo,256,200]
@@ -81,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 Verilator does not simply convert Verilog HDL to {cpp} or SystemC. Rather
than only translate, Verilator compiles your code into a much faster than only translate, Verilator compiles your code into a much faster
optimized and optionally thread-partitioned model, which is in turn wrapped 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 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 SystemC, and on a single thread is about 100 times faster than interpreted
Verilog simulators such as http://iverilog.icarus.com[Icarus Verilog simulators such as http://iverilog.icarus.com[Icarus
+222 -67
View File
@@ -5,11 +5,7 @@
# can redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
# #
###################################################################### ######################################################################
@@ -421,6 +417,7 @@ more information.
+verilator+prof+threads+window+I<value> Set profile duration +verilator+prof+threads+window+I<value> Set profile duration
+verilator+rand+reset+I<value> Set random reset technique +verilator+rand+reset+I<value> Set random reset technique
+verilator+seed+I<value> Set random seed +verilator+seed+I<value> Set random seed
+verilator+noassert Disable assert checking
+verilator+V Verbose version and config +verilator+V Verbose version and config
+verilator+version Show version and exit +verilator+version Show version and exit
@@ -1082,8 +1079,8 @@ and the remaining files can be compiled on parallel machines. Using
design --output-split 20000 resulted in splitting into approximately design --output-split 20000 resulted in splitting into approximately
one-minute-compile chunks. one-minute-compile chunks.
Typically when using this, make with VM_PARALLEL_BUILDS=1, and use Typically when using this, make with VM_PARALLEL_BUILDS=1 (set for you if
I<ccache>. using the default makefiles), and use I<ccache>.
=item --output-split-cfuncs I<statements> =item --output-split-cfuncs I<statements>
@@ -1272,7 +1269,8 @@ detailed description.
=item --quiet-exit =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 =item --relative-includes
@@ -1343,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 size (plain --stats just gives a count). See --stats, which is implied by
this. 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 =item -sv
Specifies SystemVerilog language features should be enabled; equivalent to Specifies SystemVerilog language features should be enabled; equivalent to
@@ -1773,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 value. If zero or not specified picks a value from the system random
number generator. 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 =item +verilator+V
Shows the verbose version, including configuration information. Shows the verbose version, including configuration information.
@@ -1900,13 +1910,13 @@ Now we run Verilator on our little example.
We then can compile it We then can compile it
cd obj_dir make -j -C obj_dir -f Vour.mk Vour__ALL.a
make -j -f Vour.mk Vour__ALL.a make -j -C obj_dir -f Vour.mk ../sc_main.o verilated.o
make -j -f Vour.mk ../sc_main.o verilated.o
And link with SystemC. Note your path to the libraries may vary, And link with SystemC. Note your path to the libraries may vary,
depending on the operating system. depending on the operating system.
cd obj_dir
export SYSTEMC_LIBDIR=/path/to/where/libsystemc.a/exists export SYSTEMC_LIBDIR=/path/to/where/libsystemc.a/exists
export LD_LIBRARY_PATH=$SYSTEMC_LIBDIR:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$SYSTEMC_LIBDIR:$LD_LIBRARY_PATH
# Might be needed if SystemC 2.3.0 # Might be needed if SystemC 2.3.0
@@ -1930,6 +1940,39 @@ when your source changes it will automatically run all of these steps. See
the examples directory in the distribution. 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 =head1 BENCHMARKING & OPTIMIZATION
For best performance, run Verilator with the "-O3 --x-assign fast For best performance, run Verilator with the "-O3 --x-assign fast
@@ -1958,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 the compiler or linker. Or, just for one run, pass them on the command
line to make: 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 OPT_FAST specifies optimizations for those programs that are part of the
fast path, mostly code that is executed every cycle. OPT_SLOW specifies fast path, mostly code that is executed every cycle. OPT_SLOW specifies
optimizations for slow-path files (plus tracing), which execute only optimizations for slow-path files (plus tracing), which execute only
rarely, yet take a long time to compile with optimization on. OPT rarely, yet take a long time to compile with optimization on. OPT
specifies overall optimization and affects all compiles, including those 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 with "-static". Nearly the same results can be had with much better
compile times with OPT_FAST="-O1 -fstrict-aliasing". Higher optimization 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 such as "-O2" or "-O3" may help, but gcc compile times may be excessive
even medium sized designs. Alternatively, some larger designs report under O3 on even medium sized designs.
better performance using "-Os".
Unfortunately, using the optimizer with SystemC files can result in Unfortunately, using the optimizer with SystemC files can result in
compiles taking several minutes. (The SystemC libraries have many little compiles taking several minutes. (The SystemC libraries have many little
inlined functions that drive the compiler nuts.) inlined functions that drive the compiler nuts.)
For best results, use GCC 3.3 or newer. GCC 3.2 and earlier have For best results, use the latest clang compiler (about 10% faster than
optimization bugs around pointer aliasing detection, which can result in 2x GCC). Note the now fairly old GCC 3.2 and earlier have optimization bugs
performance losses. around pointer aliasing detection, which can result in 2x performance
losses.
If you will be running many simulations on a single compile, investigate If you will be running many simulations on a single compile, investigate
feedback driven compilation. With GCC, using -fprofile-arcs, then feedback driven compilation. With GCC, using -fprofile-arcs, then
@@ -1989,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 both compilation and link. Note LTO may cause excessive compile times on
large designs. 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 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 code with -DVL_INLINE_OPT=inline. This will inline functions, however this
requires that all cpp files be compiled in a single compiler run. requires that all cpp files be compiled in a single compiler run.
@@ -1999,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 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. 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. how Verilator compares, and may be able to suggest additional improvements.
@@ -2074,7 +2120,7 @@ After running Make, the C++ compiler may produce the following:
A generic Linux/OS variable specifying what directories have shared object A generic Linux/OS variable specifying what directories have shared object
(.so) files. This path should include SystemC and any other shared objects (.so) files. This path should include SystemC and any other shared objects
needed at simultion runtime. needed at simulation runtime.
=item OBJCACHE =item OBJCACHE
@@ -2203,7 +2249,7 @@ example:
Note signals are read and written as member variables of the lower module. 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 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, 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 =head1 CONNECTING TO SYSTEMC
@@ -2806,7 +2852,7 @@ and range of line numbers (or all lines if omitted).
For tracing_off, cells below any module in the files/ranges specified will For tracing_off, cells below any module in the files/ranges specified will
also not be traced. also not be traced.
=item clock_enable -module "<modulename>" -signal "<signame>" =item clock_enable -module "<modulename>" -var "<signame>"
Indicate the signal is used to gate a clock, and the user takes responsibility Indicate the signal is used to gate a clock, and the user takes responsibility
for insuring there are no races related to it. for insuring there are no races related to it.
@@ -2814,13 +2860,13 @@ for insuring there are no races related to it.
Same as /*verilator clock_enable*/, see L</"LANGUAGE EXTENSIONS"> for Same as /*verilator clock_enable*/, see L</"LANGUAGE EXTENSIONS"> for
more information and an example. more information and an example.
=item clocker -module "<modulename>" [-task "<taskname>"] -signal "<signame>" =item clocker -module "<modulename>" [-task "<taskname>"] -var "<signame>"
=item clocker -module "<modulename>" [-function "<funcname>"] -signal "<signame>" =item clocker -module "<modulename>" [-function "<funcname>"] -var "<signame>"
=item no_clocker -module "<modulename>" [-task "<taskname>"] -signal "<signame>" =item no_clocker -module "<modulename>" [-task "<taskname>"] -var "<signame>"
=item no_clocker -module "<modulename>" [-function "<funcname>"] -signal "<signame>" =item no_clocker -module "<modulename>" [-function "<funcname>"] -var "<signame>"
Indicate the signal is used as clock or not. This information is used by 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 Verilator to mark the signal as clocker and propagate the clocker attribute
@@ -2862,9 +2908,9 @@ routines will replace the __DOT__ with the period.
Same as /*verilator inline_module*/, see L</"LANGUAGE EXTENSIONS"> for Same as /*verilator inline_module*/, see L</"LANGUAGE EXTENSIONS"> for
more information. more information.
=item isolate_assignments -module "<modulename>" [-task "<taskname>"] -signal "<signame>" =item isolate_assignments -module "<modulename>" [-task "<taskname>"] -var "<signame>"
=item isolate_assignments -module "<modulename>" [-function "<funcname>"] -signal "<signame>" =item isolate_assignments -module "<modulename>" [-function "<funcname>"] -var "<signame>"
=item isolate_assignments -module "<modulename>" -function "<fname>" =item isolate_assignments -module "<modulename>" -function "<fname>"
@@ -2899,9 +2945,9 @@ outside the task itself.
Same as /*verilator no_inline_task*/, see L</"LANGUAGE EXTENSIONS"> Same as /*verilator no_inline_task*/, see L</"LANGUAGE EXTENSIONS">
for more information. for more information.
=item sc_bv -module "<modulename>" [-task "<taskname>"] -signal "<signame>" =item sc_bv -module "<modulename>" [-task "<taskname>"] -var "<signame>"
=item sc_bv -module "<modulename>" [-function "<funcname>"] -signal "<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 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 vluint64_t. This may be useful if the port width is parameterized and
@@ -2913,9 +2959,9 @@ significantly.
Same as /*verilator sc_bv*/, see L</"LANGUAGE EXTENSIONS"> for more Same as /*verilator sc_bv*/, see L</"LANGUAGE EXTENSIONS"> for more
information. information.
=item sformat [-module "<modulename>"] [-task "<taskname>"] -signal "<signame>" =item sformat [-module "<modulename>"] [-task "<taskname>"] -var "<signame>"
=item sformat [-module "<modulename>"] [-function "<funcname>"] -signal "<signame>" =item sformat [-module "<modulename>"] [-function "<funcname>"] -var "<signame>"
Final input of a function or task "input string" to indicate the Final input of a function or task "input string" to indicate the
function or task should pass all remaining arguments through function or task should pass all remaining arguments through
@@ -2925,6 +2971,17 @@ behavior. See the test_regress/t/t_dpi_display.v file for an example.
Same as /*verilator sformat*/, see L</"LANGUAGE EXTENSIONS"> for more Same as /*verilator sformat*/, see L</"LANGUAGE EXTENSIONS"> for more
information. 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 =back
@@ -3411,6 +3468,36 @@ 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"> Same as C<sformat> in configuration files, see L</"CONFIGURATION FILES">
for more information. 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...>*/ =item /*verilator tag <text...>*/
Attached after a variable or structure member to indicate opaque (to Attached after a variable or structure member to indicate opaque (to
@@ -3746,17 +3833,29 @@ $unsigned, $warning.
Generally supported. 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 =item $displayb, $displayh, $displayo, $writeb, $writeh, $writeo, etc
The sized display functions are rarely used and so not supported. Replace The sized display functions are rarely used and so not supported. Replace
them with a $write with the appropriate format specifier. 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 =item $finish, $stop
The rarely used optional parameter to $finish and $stop is ignored. The rarely used optional parameter to $finish and $stop is ignored.
@@ -3826,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 code without knowing the magic set of disables needed to successfully
compile your design. 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 =over 4
@@ -4374,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 simulators, if the increased precision of real affects your model or DPI
calls. 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 =item STMTDLY
Warns that you have a statement with a delayed time in front of it, for Warns that you have a statement with a delayed time in front of it, for
@@ -4505,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 bus processed by another series of always blocks. The fix is the
same; split it into two separate signals generated from each block. 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 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 reported path going through a clock gating cell. To fix these, use the
clock_enable meta comment described above. clock_enable meta comment described above.
@@ -4771,19 +4915,20 @@ designs have topped 16GB.
See the next question for tracing in SystemC mode. See the next question for tracing in SystemC mode.
Add the --trace switch to Verilator, and in your top level C code, call A. Add the --trace switch to Verilator, and in your top level C code, call
Verilated::traceEverOn(true). Then create a VerilatedVcdC object, and Verilated::traceEverOn(true). Then you may use $dumpfile and $dumpvars to
in your main loop call "trace_object->dump(time)" every time step, and enable traces, same as with any Verilog simulator. See
finally call "trace_object->close()". For an example, see below and the C<examples/make_tracing_c>.
examples/make_tracing_c/sim_main.cpp file of the distribution.
You also need to compile verilated_vcd_c.cpp and add it to your link, B. Or, for finer-grained control, or C++ files with multiple Verilated
preferably by adding the dependencies in $(VK_GLOBAL_OBJS) to your modules you may also create the trace purely from C++. Create a
Makefile's link rule. This is done for you if using the Verilator --exe VerilatedVcdC object, and in your main loop call "trace_object->dump(time)"
flag. 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
Note you can also call ->trace on multiple Verilated objects with the same adding the dependencies in $(VK_GLOBAL_OBJS) to your Makefile's link rule.
trace file if you want all data to land in the same output file. 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" #include "verilated_vcd_c.h"
... ...
@@ -4803,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? =item How do I generate waveforms (traces) in SystemC?
Add the --trace switch to Verilator, and in your top level C sc_main code, A. Add the --trace switch to Verilator, and in your top level sc_main, call
include verilated_vcd_sc.h. Then call Verilated::traceEverOn(true). Then Verilated::traceEverOn(true). Then you may use $dumpfile and $dumpvars to
create a VerilatedVcdSc object as you would create a normal SystemC trace enable traces, same as with any Verilog simulator, see the non-SystemC
file. For an example, see the call to VerilatedVcdSc in the example in C<examples/make_tracing_c>. This will trace only the module
examples/make_tracing_sc/sc_main.cpp file of the distribution, and below. 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 Alternatively you may use the C++ trace mechanism described in the previous
question, however the timescale and timeprecision will not inherited from question, however the timescale and timeprecision will not inherited from
@@ -4837,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++? =item How do I generate FST waveforms (traces) in C++?
FST a format by GTKWave. FST a format by GTKWave. This version provides a basic FST support. To
This version provides a basic FST support. dump FST format, add the --trace-fst switch to Verilator and either A. use
To dump FST format, add the --trace-fst switch to Verilator and change the include $dumpfile/$dumpvars in Verilog as described in the VCD example above, or
path in the testbench to: B. in C++ change the include described in the VCD example above:
#include "verilated_fst_c.h" #include "verilated_fst_c.h"
VerilatedFstC* tfp = new VerilatedFstC; VerilatedFstC* tfp = new VerilatedFstC;
Note that currently supporting both FST and VCD in a single simulation is impossible, Note that currently supporting both FST and VCD in a single simulation is
but such requirement could be rare. 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 The FST library from GTKWave does not currently support SystemC; use VCD
format instead. 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 Verilator makes standard VCD (Value Change Dump) and FST files. VCD files are viewable
with the public domain GTKWave (recommended) or Dinotrace (legacy) with the public domain GTKWave (recommended) or Dinotrace (legacy)
@@ -5236,11 +5387,15 @@ remain anonymous.
The latest version is available from L<https://verilator.org>. 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 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 either the GNU Lesser General Public License Version 3 or the Perl Artistic
License Version 2.0. 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 =head1 SEE ALSO
@@ -5248,7 +5403,7 @@ L<verilator_coverage>, L<verilator_gantt>, L<verilator_profcfunc>, L<make>,
L<verilator --help> which is the source for this document, L<verilator --help> which is the source for this document,
and internals.txt in the distribution. and docs/internals.adoc in the distribution.
=cut =cut
+6 -9
View File
@@ -6,11 +6,6 @@
# 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. # 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; require 5.006_001;
@@ -269,10 +264,12 @@ Specifies a module search directory.
The latest version is available from L<https://verilator.org>. 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
redistribute it and/or modify the Verilator internals under the terms of can redistribute it and/or modify the Verilator internals under the terms
either the GNU Lesser General Public License Version 3 or the Perl Artistic of either the GNU Lesser General Public License Version 3 or the Perl
License Version 2.0. Artistic License Version 2.0.
SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
=head1 AUTHORS =head1 AUTHORS
+6 -3
View File
@@ -233,9 +233,12 @@ Do not show differences in line numbering.
The latest version is available from L<https://verilator.org>. The latest version is available from L<https://verilator.org>.
Copyright 2005-2020 by Wilson Snyder. This package is free software; you can Copyright 2005-2020 by Wilson Snyder. This program is free software; you
redistribute it and/or modify it under the terms of either the GNU Lesser can redistribute it and/or modify it under the terms of either the GNU
General Public License Version 3 or the Perl Artistic License Version 2.0. 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 =head1 AUTHORS
+8 -5
View File
@@ -123,13 +123,13 @@ sub report {
} }
my $nthreads = scalar keys %Threads; my $nthreads = scalar keys %Threads;
$Global{cpus}{cpu_time} = {}; $Global{cpus} = {};
foreach my $thread (keys %Threads) { foreach my $thread (keys %Threads) {
# Make potentially multiple characters per column # Make potentially multiple characters per column
foreach my $start (keys %{$Threads{$thread}}) { foreach my $start (keys %{$Threads{$thread}}) {
my $cpu = $Threads{$thread}{$start}{cpu}; my $cpu = $Threads{$thread}{$start}{cpu};
my $elapsed = $Threads{$thread}{$start}{end} - $start; 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>. The latest version is available from L<https://verilator.org>.
Copyright 2018-2020 by Wilson Snyder. Verilator is free software; you can Copyright 2018-2020 by Wilson Snyder. This program is free software; you
redistribute it and/or modify it under the terms of either the GNU Lesser can redistribute it and/or modify it under the terms of either the GNU
General Public License Version 3 or the Perl Artistic License Version 2.0. 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 =head1 AUTHORS
+5 -3
View File
@@ -1,9 +1,11 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# DESCRIPTION: Print include statements for each ARGV # DESCRIPTION: Print include statements for each ARGV
# #
# Copyright 2003-2020 by Wilson Snyder. This package is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU Lesser # can redistribute it and/or modify it under the terms of either the GNU
# General Public License Version 3 or the Perl Artistic License Version 2.0. # 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; require 5.005;
+6 -3
View File
@@ -228,9 +228,12 @@ Displays this message and program version and exits.
The latest version is available from L<https://verilator.org>. The latest version is available from L<https://verilator.org>.
Copyright 2007-2020 by Wilson Snyder. Verilator is free software; you can Copyright 2007-2020 by Wilson Snyder. This program is free software; you
redistribute it and/or modify it under the terms of either the GNU Lesser can redistribute it and/or modify it under the terms of either the GNU
General Public License Version 3 or the Perl Artistic License Version 2.0. 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 =head1 AUTHORS
+3 -2
View File
@@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Verilator: Build script for vcddiff # DESCRIPTION: Verilator: Build script for vcddiff
# #
# Copyright 2019 by Todd Strader. This program is free software; you can # Copyright 2019 by Todd Strader. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
set -e set -e
# NB: it would be better to add this via a PPA # NB: it would be better to add this via a PPA
+3 -2
View File
@@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Verilator: Travis CI build script # DESCRIPTION: Verilator: Travis CI build script
# #
# Copyright 2019 by Todd Strader. This program is free software; you can # Copyright 2019 by Todd Strader. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # 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 # This script builds and caches the Verilator binaries for Travis CI
# (and possibly other CI platforms). The Verilator CI system uses this # (and possibly other CI platforms). The Verilator CI system uses this
+5 -4
View File
@@ -1,9 +1,10 @@
# DESCRIPTION: Dockerfile for env to build and fully test Verilator # DESCRIPTION: Dockerfile for env to build and fully test Verilator
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
FROM ubuntu:18.04 FROM ubuntu:18.04
+14 -15
View File
@@ -1,7 +1,7 @@
= Verilator Build Environment = Verilator Docker Build Environment
This container is set up to compile and test a Verilator build based This Verilator Build container is set up to compile and test a Verilator
on the following parameters: build. It uses the following parameters:
* Source repository (default: https://github.com/verilator/verilator) * Source repository (default: https://github.com/verilator/verilator)
* Source revision (default: master) * Source revision (default: master)
@@ -10,7 +10,7 @@ on the following parameters:
The container is published as `verilator/verilator-buildenv` on The container is published as `verilator/verilator-buildenv` on
https://hub.docker.com/repository/docker/verilator/verilator-buildenv[docker hub]. 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 docker run -ti verilator/verilator-buildenv
@@ -18,7 +18,7 @@ To also run tests:
docker run -ti verilator/verilator-buildenv test 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 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 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 Rather then building using a remote git repository you may prefer to use a
instead use a local working copy. You can mount the local working copy working copy on the local filesystem. Mount the local working copy path as
path as a volume and use this as repo. Be careful, that it can only a volume and use that in place of git. When doing this be careful to have
use committed changes, so you may want to use a work-in-progress all changes committed to the local git area. To build the current HEAD from
commit or so. To build the current HEAD from top of a repository: 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 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 . docker build .
It will build SystemC in all supported compiler variants to reduce the This will also build SystemC under all supported compiler variants to
impact on testing cycles. A build script will be the entrypoint to the reduce the SystemC testing time.
container that will perform a standard build and test procedure.
+5 -4
View File
@@ -1,10 +1,11 @@
#!/bin/bash -e #!/bin/bash -e
# DESCRIPTION: Build SystemC in Ubuntu 18.04 with different g++/gcc # DESCRIPTION: Build SystemC in Ubuntu 18.04 with different g++/gcc
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
build_variant () { build_variant () {
version=$($1 --version | grep gcc | awk '{print $4}') version=$($1 --version | grep gcc | awk '{print $4}')
+5 -4
View File
@@ -1,10 +1,11 @@
#!/bin/bash -e #!/bin/bash -e
# DESCRIPTION: Build Verilator (inside container) # DESCRIPTION: Build Verilator (inside container)
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
: "${REPO:=https://github.com/verilator/verilator}" : "${REPO:=https://github.com/verilator/verilator}"
: "${REV:=master}" : "${REV:=master}"
+5 -4
View File
@@ -1,9 +1,10 @@
# DESCRIPTION: Dockerfile for image to run Verilator inside # DESCRIPTION: Dockerfile for image to run Verilator inside
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
FROM ubuntu:18.04 FROM ubuntu:18.04
+35 -25
View File
@@ -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 docker run -ti verilator/verilator:latest --version
This is in particular useful to compare against older version or to This will install the container, run the latest Verilator and print
check when an issue was introduced. Verilator's version.
You will need to give it access to your files as a volume and fix the Containers are automatically built for all released versions, so you may
user rights: 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 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 This method can only access files below the current directory. An
directory then, a workaround is to adopt the volume and set alternative is setup the volume `-workdir`.
`-workdir`.
There is a convenience script in this folder that wraps around the You can also work in the container by setting the entrypoint
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
(don't forget to mount a volume if you want your work persistent): (don't forget to mount a volume if you want your work persistent):
docker run -ti --entrypoint /bin/bash verilator/verilator:latest docker run -ti --entrypoint /bin/bash verilator/verilator:latest
The other files in this folder all for building the containers and to You can also use the container to build Verilator at a specific
store in them. You could use it to build Verilator at a specific
commit: commit:
docker build --build-arg SOURCE_COMMIT=<commit> . docker build --build-arg SOURCE_COMMIT=<commit> .
== Internals == Internals
The Dockerfile is pretty straight-forward, it builds Verilator and The Dockerfile builds Verilator and removes the tree when completed to
removes the tree after that to reduce the image size. It sets a reduce the image size. The entrypoint is set as a wrapper script
wrapper script (`verilator-wrap.sh`) as entrypoint. This script calls (`verilator-wrap.sh`). That script 1. calls Verilator, and 2. copies the
Verilator but also copies the verilated runtime files to the `obj_dir` Verilated runtime files to the `obj_dir` or the `-Mdir` respectively. This
or the `-Mdir` respectively. This allows the user to build the C++ allows the user to have the files to they may later build the C++ output
output with the matching runtime files. The wrapper patches the with the matching runtime files. The wrapper also patches the Verilated
generated Makefile accordingly. Makefile accordingly.
There is also a hook defined that is run by docker hub via automated There is also a hook defined that is run by docker hub via automated
builds. builds.
+5 -4
View File
@@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Docker hub hook to pass SOURCE_COMMIT # DESCRIPTION: Docker hub hook to pass SOURCE_COMMIT
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0.FROM ubuntu:18.04 # 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 . docker build --build-arg SOURCE_COMMIT=${SOURCE_COMMIT} -f $DOCKERFILE_PATH -t $IMAGE_NAME .
+5 -4
View File
@@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Docker hub hook to tag the latest release (stable) # DESCRIPTION: Docker hub hook to tag the latest release (stable)
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0.FROM ubuntu:18.04 # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
if [ "$SOURCE_BRANCH"="stable" ]; then if [ "$SOURCE_BRANCH"="stable" ]; then
docker tag $IMAGE_NAME $DOCKER_REPO:latest docker tag $IMAGE_NAME $DOCKER_REPO:latest
+5 -4
View File
@@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Wrap a verilator call to run a docker container # DESCRIPTION: Wrap a verilator call to run a docker container
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
docker pull verilator/verilator:$1 >/dev/null docker pull verilator/verilator:$1 >/dev/null
docker run -ti -v ${PWD}:/work --user $(id -u):$(id -g) verilator/verilator:$1 "${@:2}" docker run -ti -v ${PWD}:/work --user $(id -u):$(id -g) verilator/verilator:$1 "${@:2}"
+10 -5
View File
@@ -1,13 +1,18 @@
#!/bin/bash -e #!/bin/bash
# DESCRIPTION: Wrap a Verilator call and copy vlt includes # DESCRIPTION: Wrap a Verilator call and copy vlt includes
# (inside docker container) # (inside docker container)
# #
# Copyright 2020 by Stefan Wallentowitz. This program is free # Copyright 2020 by Stefan Wallentowitz. This program is free software; you
# software; you can redistribute it and/or modify it under the terms # can redistribute it and/or modify it under the terms of either the GNU
# of either the GNU Lesser General Public License Version 3 or the # Lesser General Public License Version 3 or the Perl Artistic License
# Perl Artistic License Version 2.0. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
perl /usr/local/bin/verilator "$@" perl /usr/local/bin/verilator "$@"
status=$?
if [ $status -ne 0 ]; then
exit $status
fi
# Check if user set an obj_dir # Check if user set an obj_dir
obj_dir=$(echo " $@" | grep -oP '\s--Mdir\s*\K\S+') obj_dir=$(echo " $@" | grep -oP '\s--Mdir\s*\K\S+')
+10 -2
View File
@@ -1,10 +1,12 @@
#!/bin/bash #!/bin/bash
# DESCRIPTION: Verilator: Travis CI test script # DESCRIPTION: Verilator: Travis CI test script
# #
# Copyright 2019 by Todd Strader. This program is free software; you can # Copyright 2019 by Todd Strader. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
set -e set -e
export DRIVER_FLAGS='-j 0 --quiet --rerun' export DRIVER_FLAGS='-j 0 --quiet --rerun'
@@ -19,6 +21,12 @@ case $1 in
vltmt) vltmt)
make -C test_regress SCENARIOS=--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)" echo "Usage: test.sh (dist|vlt|vltmt)"
exit -1 exit -1
+9 -4
View File
@@ -1,12 +1,13 @@
# DESCRIPTION: Process this file with autoconf to produce a configure script. # DESCRIPTION: Process this file with autoconf to produce a configure script.
# #
# Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can # Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you
# redistribute it and/or modify it under the terms of either the GNU Lesser # 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. # 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],[#.### YYYY-MM-DD])
#AC_INIT([Verilator],[#.### devel]) #AC_INIT([Verilator],[#.### devel])
AC_INIT([Verilator],[4.028 2020-02-06], AC_INIT([Verilator],[4.032 2020-04-04],
[https://verilator.org], [https://verilator.org],
[verilator],[https://verilator.org]) [verilator],[https://verilator.org])
# When releasing, also update header of Changes file # When releasing, also update header of Changes file
@@ -301,7 +302,6 @@ AC_SUBST(CFG_CXXFLAGS_WEXTRA)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Qunused-arguments) _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,-faligned-new)
_MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-unused-parameter) _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) _MY_CXX_CHECK_OPT(CFG_CXXFLAGS_SRC,-Wno-shadow)
AC_SUBST(CFG_CXXFLAGS_SRC) AC_SUBST(CFG_CXXFLAGS_SRC)
@@ -369,8 +369,13 @@ AC_SUBST(CFG_LDFLAGS_SRC)
# The pthread library is required by tcmalloc, so add it if it exists. If it # 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 # does not, the tcmalloc check below will fail anyway, and linking against
# pthreads is harmless otherwise. # pthreads is harmless otherwise.
CFG_LIBS="$LIBS $CFG_LIBS"
_MY_LDLIBS_CHECK_OPT(CFG_LIBS, -lpthread) _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 # Check if tcmalloc is available based on --enable-tcmalloc
_MY_LDLIBS_CHECK_IFELSE( _MY_LDLIBS_CHECK_IFELSE(
$LTCMALLOC, $LTCMALLOC,
+6 -6
View File
@@ -50,13 +50,13 @@ contributions flow more efficiently.
link:CONTRIBUTORS[docs/CONTRIBUTORS] and you are agreeing all future link:CONTRIBUTORS[docs/CONTRIBUTORS] and you are agreeing all future
contributions are also certified. contributions are also certified.
** We occasionally accept contributions where people do not want their ** We occasionally accept contributions where people do not want their name
name published. Please email us; you must still certify your published. Please email us; you must still privately certify your
contribution using email. contribution.
* Your test contributions are generally considered released into the public * Your test contributions are generally considered released into the
domain, unless you request otherwise or put a GNU/Artistic license on Creative Commons Public Domain (CC0), unless you request otherwise or put
your test file. a GNU/Artistic license on your file.
* Most important is we get your patch. If you'd like to clean up * Most important is we get your patch. If you'd like to clean up
indentation and related issues ahead of our feedback, that is indentation and related issues ahead of our feedback, that is
+5
View File
@@ -8,6 +8,7 @@ all.
Ahmed El-Mahmoudy Ahmed El-Mahmoudy
Alex Chadwick Alex Chadwick
Chris Randall Chris Randall
David Stanford
Driss Hafdi Driss Hafdi
Eric Rippey Eric Rippey
Garrett Smith Garrett Smith
@@ -23,6 +24,8 @@ Kevin Kiningham
Kuba Ober Kuba Ober
Lukasz Dalek Lukasz Dalek
Maarten De Braekeleer Maarten De Braekeleer
Maciej Sobkowski
Marco Widmer
Matthew Ballance Matthew Ballance
Mike Popoloski Mike Popoloski
Patrick Stewart Patrick Stewart
@@ -30,9 +33,11 @@ Peter Monsson
Philipp Wagner Philipp Wagner
Pieter Kapsenberg Pieter Kapsenberg
Richard Myers Richard Myers
Sean Cross
Sebastien Van Cauwenberghe Sebastien Van Cauwenberghe
Stefan Wallentowitz Stefan Wallentowitz
Tobias Rosenkranz Tobias Rosenkranz
Tobias Wölfel
Todd Strader Todd Strader
Wilson Snyder Wilson Snyder
Yutetsu TAKATSUKASA Yutetsu TAKATSUKASA
+3 -7
View File
@@ -7,15 +7,11 @@
# #
#***************************************************************************** #*****************************************************************************
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# # SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
# #
#****************************************************************************/ #****************************************************************************/
# #
+1 -7
View File
@@ -4,6 +4,7 @@
// redistribute it and/or modify it under the terms of either the GNU // 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. // Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
* Language support: * Language support:
** Fix ordering of each bit separately in a signal (mips) ** Fix ordering of each bit separately in a signal (mips)
@@ -22,17 +23,10 @@
** Assertions ** Assertions
** Tristate support ** Tristate support
* Configure/Make/Install
** Distribute with flex/bison already expanded?
Flex library not needed. Probably too difficult to be worth it.
* Testing: * Testing:
** Capture all inputs into global "rerun it" file
** Code to make wrapper that sets signals, so can do comparison checks ** Code to make wrapper that sets signals, so can do comparison checks
** New random program generator ** New random program generator
** Better graph viewer with search and zoom ** 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: * Usability:
** Detect and pre-remove most UNOPTFLATs ** Detect and pre-remove most UNOPTFLATs
+159
View File
@@ -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
+4 -1
View File
@@ -98,9 +98,11 @@ Additionally, to build or run Verilator you need these standard packages:
Those developing Verilator may also want these (see internals.adoc): 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 Pod::Perldoc
cpan install Unix::Processors cpan install Unix::Processors
cpan install Parallel::Forker
cpan install Bit::Vector
==== Install SystemC ==== Install SystemC
@@ -301,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 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 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. General Public License Version 3 or the Perl Artistic License Version 2.0.
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
+13 -1
View File
@@ -625,13 +625,17 @@ with e.g. "sudo cpan install Parallel::Forker".
* vcddiff to find differences in VCD outputs. See the readme at * vcddiff to find differences in VCD outputs. See the readme at
https://github.com/veripool/vcddiff https://github.com/veripool/vcddiff
* Cmake for build paths that use it.
* Bit::Vector to test vgen.pl
=== Controlling the Test Driver === Controlling the Test Driver
Test drivers are written in PERL. All invoke the main test driver script, 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 which can provide detailed help on all the features available when writing
a test driver. 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 For convenience, a summary of the most commonly used features is provided
here. All drivers require a call to `compile` subroutine to compile the here. All drivers require a call to `compile` subroutine to compile the
@@ -716,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 dependent, but on Fedora Linux it would require editing the
`/etc/security/limits.conf` file as root. `/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 === Continuous Integration
Verilator has a https://travis-ci.com/verilator/verilator[Travis CI environment] Verilator has a https://travis-ci.com/verilator/verilator[Travis CI environment]
@@ -987,3 +998,4 @@ list in `src/Makefile_obj.in` and reconfigure.
Copyright 2008-2020 by Wilson Snyder. Verilator is free software; you can 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 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. 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
View File
@@ -63,3 +63,10 @@ each describing the contents of that module, and a single `<typetable>`...
`</typetable>` element which lists all used types used within the `</typetable>` element which lists all used types used within the
modules. Each type has a numeric `id` attribute that is referred to by modules. Each type has a numeric `id` attribute that is referred to by
elements in the `<module>` elements using the `dtype_id` attribute. 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
+3 -2
View File
@@ -5,10 +5,11 @@
# This is an example cmake script to build a verilog to systemc project # This is an example cmake script to build a verilog to systemc project
# using cmake and verilator. # using cmake and verilator.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -6,10 +6,11 @@
# This makefile is here for testing the examples and should # This makefile is here for testing the examples and should
# generally not be added to a CMake project. # generally not be added to a CMake project.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -5,10 +5,11 @@
# This is an example cmake script to build a verilog to SystemC project # This is an example cmake script to build a verilog to SystemC project
# using CMake and Verilator. # using CMake and Verilator.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -6,10 +6,11 @@
# This makefile is here for testing the examples and should # This makefile is here for testing the examples and should
# generally not be added to a CMake project. # generally not be added to a CMake project.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -5,10 +5,11 @@
# This is an example cmake script to build a verilog to systemc project # This is an example cmake script to build a verilog to systemc project
# using cmake and verilator. # using cmake and verilator.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -6,10 +6,11 @@
# This makefile is here for testing the examples and should # This makefile is here for testing the examples and should
# generally not be added to a CMake project. # generally not be added to a CMake project.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+4 -3
View File
@@ -5,10 +5,11 @@
# This is an example cmake script to build a verilog to systemc project # This is an example cmake script to build a verilog to systemc project
# using cmake and verilator. # using cmake and verilator.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # 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 # Add the Verilated circuit to the target
verilate(example COVERAGE TRACE verilate(example COVERAGE TRACE
INCLUDE_DIRS "../make_tracing_c" 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) SOURCES ../make_tracing_c/top.v)
+3 -2
View File
@@ -6,10 +6,11 @@
# This makefile is here for testing the examples and should # This makefile is here for testing the examples and should
# generally not be added to a CMake project. # generally not be added to a CMake project.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+4 -3
View File
@@ -5,10 +5,11 @@
# This is an example cmake script to build a verilog to SystemC project # This is an example cmake script to build a verilog to SystemC project
# using CMake and Verilator. # using CMake and Verilator.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # 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 # Add the Verilated circuit to the target
verilate(example SYSTEMC COVERAGE TRACE verilate(example SYSTEMC COVERAGE TRACE
INCLUDE_DIRS "../make_tracing_sc" 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) SOURCES ../make_tracing_sc/top.v)
verilator_link_systemc(example) verilator_link_systemc(example)
+3 -2
View File
@@ -6,10 +6,11 @@
# This makefile is here for testing the examples and should # This makefile is here for testing the examples and should
# generally not be added to a CMake project. # generally not be added to a CMake project.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -5,10 +5,11 @@
# This calls the object directory makefile. That allows the objects to # This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile. # be placed in the "current directory" which simplifies the Makefile.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
# Check for sanity to avoid later confusion # Check for sanity to avoid later confusion
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
//====================================================================== //======================================================================
// Include common routines // Include common routines
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// See also the EXAMPLE section in the verilator manpage/document. // See also the EXAMPLE section in the verilator manpage/document.
module top; module top;
+3 -2
View File
@@ -5,10 +5,11 @@
# This calls the object directory makefile. That allows the objects to # This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile. # be placed in the "current directory" which simplifies the Makefile.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
# Check for sanity to avoid later confusion # Check for sanity to avoid later confusion
+3 -2
View File
@@ -1,8 +1,9 @@
// -*- SystemC -*- // -*- SystemC -*-
// DESCRIPTION: Verilator Example: Top level main for invoking SystemC model // DESCRIPTION: Verilator Example: Top level main for invoking SystemC model
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
//====================================================================== //======================================================================
// SystemC global header // SystemC global header
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// See also the EXAMPLE section in the verilator manpage/document. // See also the EXAMPLE section in the verilator manpage/document.
module top; module top;
+4 -3
View File
@@ -5,10 +5,11 @@
# This calls the object directory makefiles. That allows the objects to # This calls the object directory makefiles. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile. # be placed in the "current directory" which simplifies the Makefile.
# #
# Copyright 2019 by Todd Strader. This program is free software; you can # Copyright 2019 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
# Check for sanity to avoid later confusion # Check for sanity to avoid later confusion
@@ -34,7 +35,7 @@ VERILATOR_FLAGS =
# Generate C++ # Generate C++
VERILATOR_FLAGS += -cc VERILATOR_FLAGS += -cc
# Optimize # 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 # Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall VERILATOR_FLAGS += -Wall
# Make waveforms # Make waveforms
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: --protect-lib example secret module // DESCRIPTION: Verilator: --protect-lib example secret module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2019 by Todd Strader. // 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 // This module will be used as libsecret.a or libsecret.so without
// exposing the source. // exposing the source.
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: --protect-lib example module // DESCRIPTION: Verilator: --protect-lib example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2019 by Todd Strader. // any use, without warranty, 2019 by Todd Strader.
// SPDX-License-Identifier: CC0-1.0
//====================================================================== //======================================================================
// See examples/tracing_c for notes on tracing // See examples/tracing_c for notes on tracing
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: --protect-lib example module // DESCRIPTION: Verilator: --protect-lib example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2019 by Todd Strader. // any use, without warranty, 2019 by Todd Strader.
// SPDX-License-Identifier: CC0-1.0
// See also the EXAMPLE section in the verilator manpage/document. // See also the EXAMPLE section in the verilator manpage/document.
module top (input clk); module top (input clk);
+4 -3
View File
@@ -5,10 +5,11 @@
# This calls the object directory makefile. That allows the objects to # This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile. # be placed in the "current directory" which simplifies the Makefile.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
# Check for sanity to avoid later confusion # Check for sanity to avoid later confusion
@@ -38,7 +39,7 @@ VERILATOR_FLAGS += -cc --exe
# Generate makefile dependencies (not shown as complicates the Makefile) # Generate makefile dependencies (not shown as complicates the Makefile)
#VERILATOR_FLAGS += -MMD #VERILATOR_FLAGS += -MMD
# Optimize # 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 # Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall VERILATOR_FLAGS += -Wall
# Make waveforms # Make waveforms
+4 -3
View File
@@ -5,10 +5,11 @@
# #
# This is executed in the object directory, and called by ../Makefile # This is executed in the object directory, and called by ../Makefile
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # 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. # SystemC takes minutes to optimize, thus it is off by default.
OPT_SLOW = OPT_SLOW =
# Fast path optimizations. Most time is spent in these classes. # 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 = -O
#OPT_FAST = #OPT_FAST =
+27 -48
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
//====================================================================== //======================================================================
// Include common routines // Include common routines
@@ -10,11 +11,6 @@
// Include model header, generated from Verilating "top.v" // Include model header, generated from Verilating "top.v"
#include "Vtop.h" #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) // Current simulation time (64-bit unsigned)
vluint64_t main_time = 0; vluint64_t main_time = 0;
// Called by $time in Verilog // Called by $time in Verilog
@@ -36,31 +32,21 @@ int main(int argc, char** argv, char** env) {
// May be overridden by commandArgs // May be overridden by commandArgs
Verilated::randReset(2); Verilated::randReset(2);
// Verilator must compute traced signals
Verilated::traceEverOn(true);
// Pass arguments so Verilated code can see them, e.g. $value$plusargs // Pass arguments so Verilated code can see them, e.g. $value$plusargs
// This needs to be called before you create any model // This needs to be called before you create any model
Verilated::commandArgs(argc, argv); 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" // 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 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 // Set some inputs
top->reset_l = !0; top->reset_l = !0;
top->fastclk = 0;
top->clk = 0; top->clk = 0;
top->in_small = 1; top->in_small = 1;
top->in_quad = 0x1234; top->in_quad = 0x1234;
@@ -72,31 +58,29 @@ int main(int argc, char** argv, char** env) {
while (!Verilated::gotFinish()) { while (!Verilated::gotFinish()) {
main_time++; // Time passes... main_time++; // Time passes...
// Toggle clocks and such // Toggle a fast (time/2 period) clock
top->fastclk = !top->fastclk; top->clk = !top->clk;
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
}
// Assign some other inputs // Toggle control signals on an edge that doesn't correspond
top->in_quad += 0x12; // 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 // 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(); top->eval();
#if VM_TRACE
// Dump trace data for this cycle
if (tfp) tfp->dump(main_time);
#endif
// Read outputs // Read outputs
VL_PRINTF("[%" VL_PRI64 "d] clk=%x rstl=%x iquad=%" VL_PRI64 "x" VL_PRINTF("[%" VL_PRI64 "d] clk=%x rstl=%x iquad=%" VL_PRI64 "x"
" -> oquad=%" VL_PRI64"x owide=%x_%08x_%08x\n", " -> oquad=%" VL_PRI64"x owide=%x_%08x_%08x\n",
@@ -107,11 +91,6 @@ int main(int argc, char** argv, char** env) {
// Final model cleanup // Final model cleanup
top->final(); top->final();
// Close trace if opened
#if VM_TRACE
if (tfp) { tfp->close(); tfp = NULL; }
#endif
// Coverage analysis (since test passed) // Coverage analysis (since test passed)
#if VM_COVERAGE #if VM_COVERAGE
Verilated::mkdir("logs"); Verilated::mkdir("logs");
+3 -19
View File
@@ -1,31 +1,17 @@
// DESCRIPTION: Verilator: Verilog Test module // DESCRIPTION: Verilator: Verilog Test module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2003 by Wilson Snyder. // any use, without warranty, 2003 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// ====================================================================== // ======================================================================
module sub module sub
( (
input clk, input clk,
input fastclk,
input reset_l input reset_l
); );
// Example counter/flop // 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; reg [31:0] count_c;
always_ff @ (posedge clk) begin always_ff @ (posedge clk) begin
if (!reset_l) begin if (!reset_l) begin
@@ -37,8 +23,6 @@ module sub
else begin else begin
count_c <= count_c + 1; count_c <= count_c + 1;
if (count_c >= 3) begin 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 // This write is a magic value the Makefile uses to make sure the
// test completes successfully. // test completes successfully.
$write("*-* All Finished *-*\n"); $write("*-* All Finished *-*\n");
+8 -4
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2003 by Wilson Snyder. // 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 // 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 // Declare some signals so we can see how I/O works
input clk, input clk,
input fastclk,
input reset_l, input reset_l,
output wire [1:0] out_small, output wire [1:0] out_small,
@@ -31,11 +31,15 @@ module top
sub sub (/*AUTOINST*/ sub sub (/*AUTOINST*/
// Inputs // Inputs
.clk (clk), .clk (clk),
.fastclk (fastclk),
.reset_l (reset_l)); .reset_l (reset_l));
// Print some stuff as an example // Print some stuff as an example
initial begin 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); $display("[%0t] Model running...\n", $time);
end end
+4 -3
View File
@@ -5,10 +5,11 @@
# This calls the object directory makefile. That allows the objects to # This calls the object directory makefile. That allows the objects to
# be placed in the "current directory" which simplifies the Makefile. # be placed in the "current directory" which simplifies the Makefile.
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
# Check for sanity to avoid later confusion # Check for sanity to avoid later confusion
@@ -38,7 +39,7 @@ VERILATOR_FLAGS += -sc --exe
# Generate makefile dependencies (not shown as complicates the Makefile) # Generate makefile dependencies (not shown as complicates the Makefile)
#VERILATOR_FLAGS += -MMD #VERILATOR_FLAGS += -MMD
# Optimize # 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 # Warn abount lint issues; may not want this on less solid designs
VERILATOR_FLAGS += -Wall VERILATOR_FLAGS += -Wall
# Make waveforms # Make waveforms
+4 -3
View File
@@ -5,10 +5,11 @@
# #
# This is executed in the object directory, and called by ../Makefile # This is executed in the object directory, and called by ../Makefile
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # 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. # SystemC takes minutes to optimize, thus it is off by default.
OPT_SLOW = OPT_SLOW =
# Fast path optimizations. Most time is spent in these classes. # 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 = -O
#OPT_FAST = #OPT_FAST =
+6 -2
View File
@@ -1,8 +1,9 @@
// -*- SystemC -*- // -*- SystemC -*-
// DESCRIPTION: Verilator Example: Top level main for invoking SystemC model // DESCRIPTION: Verilator Example: Top level main for invoking SystemC model
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2017 by Wilson Snyder. // any use, without warranty, 2017 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
//====================================================================== //======================================================================
// SystemC global header // SystemC global header
@@ -37,6 +38,9 @@ int sc_main(int argc, char* argv[]) {
// This needs to be called before you create any model // This needs to be called before you create any model
Verilated::commandArgs(argc, argv); Verilated::commandArgs(argc, argv);
// Create logs/ directory in case we have traces to put under it
Verilated::mkdir("logs");
// General logfile // General logfile
ios::sync_with_stdio(); ios::sync_with_stdio();
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog Test module // DESCRIPTION: Verilator: Verilog Test module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2003 by Wilson Snyder. // any use, without warranty, 2003 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// ====================================================================== // ======================================================================
module sub module sub
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2003 by Wilson Snyder. // 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 // This is intended to be a complex example of several features, please also
+3 -2
View File
@@ -2,10 +2,11 @@
# #
# DESCRIPTION: Verilator Example: XML tests # DESCRIPTION: Verilator Example: XML tests
# #
# Copyright 2003-2020 by Wilson Snyder. This program is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU # 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. # Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
# #
###################################################################### ######################################################################
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog Test module // DESCRIPTION: Verilator: Verilog Test module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2019 by Wilson Snyder. // any use, without warranty, 2019 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// ====================================================================== // ======================================================================
module sub module sub
+3 -2
View File
@@ -1,7 +1,8 @@
// DESCRIPTION: Verilator: Verilog example module // DESCRIPTION: Verilator: Verilog example module
// //
// This file ONLY is placed into the Public Domain, for any use, // This file ONLY is placed under the Creative Commons Public Domain, for
// without warranty, 2019 by Wilson Snyder. // any use, without warranty, 2019 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
// ====================================================================== // ======================================================================
module top module top
+4 -2
View File
@@ -84,8 +84,10 @@ Example usage:
-v <filename> Verilog library -v <filename> Verilog library
-y <dir> Directory to search for modules -y <dir> Directory to search for modules
This file ONLY is placed into the Public Domain, for any use, without This file ONLY is placed under the Creative Commons Public Domain, for
warranty, 2019 by Wilson Snyder.""" any use, without warranty, 2019 by Wilson Snyder.
SPDX-License-Identifier: CC0-1.0
"""
) )
parser.add_argument('-debug', '--debug', parser.add_argument('-debug', '--debug',
action='store_const', const=9, action='store_const', const=9,
+4 -2
View File
@@ -108,8 +108,10 @@ Example usage:
-v <filename> Verilog library -v <filename> Verilog library
-y <dir> Directory to search for modules -y <dir> Directory to search for modules
This file ONLY is placed into the Public Domain, for any use, without This file ONLY is placed under the Creative Commons Public Domain, for
warranty, 2019 by Wilson Snyder.""" any use, without warranty, 2019 by Wilson Snyder.
SPDX-License-Identifier: CC0-1.0
"""
) )
parser.add_argument('-debug', '--debug', parser.add_argument('-debug', '--debug',
action='store_const', const=9, action='store_const', const=9,
+2
View File
@@ -22,6 +22,8 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
SPDX-License-Identifier: MIT
*/ */
#include "fastlz.h" #include "fastlz.h"
+2
View File
@@ -22,6 +22,8 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
SPDX-License-Identifier: MIT
*/ */
#ifndef FASTLZ_H #ifndef FASTLZ_H
+4
View File
@@ -18,6 +18,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * 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 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * 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) static void fstDestroyMmaps(struct fstWriterContext *xc, int is_closing)
{ {
#if !defined __CYGWIN__ && !defined __MINGW32__
(void)is_closing; (void)is_closing;
#endif
fstMunmap(xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t)); fstMunmap(xc->valpos_mem, xc->maxhandle * 4 * sizeof(uint32_t));
xc->valpos_mem = NULL; xc->valpos_mem = NULL;
+2
View File
@@ -18,6 +18,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * 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 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/ */
#ifndef FST_API_H #ifndef FST_API_H
+2
View File
@@ -27,6 +27,8 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SPDX-License-Identifier: BSD-2-Clause
You can contact the author at : You can contact the author at :
- LZ4 source repository : https://github.com/Cyan4973/lz4 - LZ4 source repository : https://github.com/Cyan4973/lz4
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
+2
View File
@@ -28,6 +28,8 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SPDX-License-Identifier: BSD-2-Clause
You can contact the author at : You can contact the author at :
- LZ4 source repository : https://github.com/Cyan4973/lz4 - LZ4 source repository : https://github.com/Cyan4973/lz4
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
+2
View File
@@ -18,6 +18,8 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * 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 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
*/ */
#ifndef WAVE_ALLOCA_H #ifndef WAVE_ALLOCA_H
+32 -16
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//========================================================================= //=========================================================================
/// ///
@@ -888,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, static inline void _vl_vsss_skipspace(FILE* fp, int& floc,
WDataInP fromp, const std::string& fstr) VL_MT_SAFE { WDataInP fromp, const std::string& fstr) VL_MT_SAFE {
while (1) { while (true) {
int c = _vl_vsss_peek(fp, floc, fromp, fstr); int c = _vl_vsss_peek(fp, floc, fromp, fstr);
if (c==EOF || !isspace(c)) return; if (c==EOF || !isspace(c)) return;
_vl_vsss_advance(fp, floc); _vl_vsss_advance(fp, floc);
@@ -898,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 { char* tmpp, const char* acceptp) VL_MT_SAFE {
// Read into tmp, consisting of characters from acceptp list // Read into tmp, consisting of characters from acceptp list
char* cp = tmpp; char* cp = tmpp;
while (1) { while (true) {
int c = _vl_vsss_peek(fp, floc, fromp, fstr); int c = _vl_vsss_peek(fp, floc, fromp, fstr);
if (c==EOF || isspace(c)) break; if (c==EOF || isspace(c)) break;
if (acceptp // String - allow anything if (acceptp // String - allow anything
@@ -1344,7 +1340,7 @@ IData VL_FREAD_I(int width, int array_lsb, int array_size,
// Read the data // Read the data
// We process a character at a time, as then we don't need to deal // We process a character at a time, as then we don't need to deal
// with changing buffer sizes dynamically, etc. // with changing buffer sizes dynamically, etc.
while (1) { while (true) {
int c = fgetc(fp); int c = fgetc(fp);
if (VL_UNLIKELY(c == EOF)) break; if (VL_UNLIKELY(c == EOF)) break;
// Shift value in // Shift value in
@@ -1602,6 +1598,25 @@ IData VL_ATOI_N(const std::string& str, int base) VL_PURE {
return static_cast<IData>(v); 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 // Readmem/writemem
@@ -1653,7 +1668,7 @@ bool VlReadMem::get(QData& addrr, std::string& valuer) {
// Read the data // Read the data
// We process a character at a time, as then we don't need to deal // We process a character at a time, as then we don't need to deal
// with changing buffer sizes dynamically, etc. // with changing buffer sizes dynamically, etc.
while (1) { while (true) {
int c = fgetc(m_fp); int c = fgetc(m_fp);
if (VL_UNLIKELY(c == EOF)) break; if (VL_UNLIKELY(c == EOF)) break;
// printf("%d: Got '%c' Addr%lx IN%d IgE%d IgC%d\n", // printf("%d: Got '%c' Addr%lx IN%d IgE%d IgC%d\n",
@@ -1832,13 +1847,13 @@ void VL_READMEM_N(bool hex, // Hex format, else binary
QData end // Last row address to read QData end // Last row address to read
) VL_MT_SAFE { ) VL_MT_SAFE {
QData addr_max = array_lsb + depth - 1; QData addr_max = array_lsb + depth - 1;
if (start < array_lsb) start = array_lsb; if (start < static_cast<QData>(array_lsb)) start = array_lsb;
QData addr_end = end; QData addr_end = end;
if (addr_end > addr_max) addr_end = addr_max; if (addr_end > addr_max) addr_end = addr_max;
VlReadMem rmem(hex, bits, filename, start, end); VlReadMem rmem(hex, bits, filename, start, end);
if (VL_UNLIKELY(!rmem.isOpen())) return; if (VL_UNLIKELY(!rmem.isOpen())) return;
while (1) { while (true) {
QData addr; QData addr;
std::string value; std::string value;
if (rmem.get(addr /*ref*/, value/*ref*/)) { if (rmem.get(addr /*ref*/, value/*ref*/)) {
@@ -1883,7 +1898,7 @@ void VL_WRITEMEM_N(bool hex, // Hex format, else binary
QData end // Last address to write, or ~0 when not specified QData end // Last address to write, or ~0 when not specified
) VL_MT_SAFE { ) VL_MT_SAFE {
QData addr_max = array_lsb + depth - 1; QData addr_max = array_lsb + depth - 1;
if (start < array_lsb) start = array_lsb; if (start < static_cast<QData>(array_lsb)) start = array_lsb;
if (end > addr_max) end = addr_max; if (end > addr_max) end = addr_max;
VlWriteMem wmem(hex, bits, filename, start, end); VlWriteMem wmem(hex, bits, filename, start, end);
@@ -2168,9 +2183,7 @@ void VerilatedImp::commandArgsAddGuts(int argc, const char** argv) VL_REQUIRES(s
void VerilatedImp::commandArgVl(const std::string& arg) { void VerilatedImp::commandArgVl(const std::string& arg) {
if (0 == strncmp(arg.c_str(), "+verilator+", strlen("+verilator+"))) { if (0 == strncmp(arg.c_str(), "+verilator+", strlen("+verilator+"))) {
std::string value; std::string value;
if (0) { if (arg == "+verilator+debug") {
}
else if (arg == "+verilator+debug") {
Verilated::debug(4); Verilated::debug(4);
} }
else if (commandArgVlValue(arg, "+verilator+debugi+", value/*ref*/)) { else if (commandArgVlValue(arg, "+verilator+debugi+", value/*ref*/)) {
@@ -2199,6 +2212,9 @@ void VerilatedImp::commandArgVl(const std::string& arg) {
else if (commandArgVlValue(arg, "+verilator+seed+", value/*ref*/)) { else if (commandArgVlValue(arg, "+verilator+seed+", value/*ref*/)) {
Verilated::randSeed(atoi(value.c_str())); Verilated::randSeed(atoi(value.c_str()));
} }
else if (arg == "+verilator+noassert") {
Verilated::assertOn(false);
}
else if (arg == "+verilator+V") { else if (arg == "+verilator+V") {
versionDump(); // Someday more info too versionDump(); // Someday more info too
VL_FATAL_MT("COMMAND_LINE", 0, "", VL_FATAL_MT("COMMAND_LINE", 0, "",
+86 -18
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
@@ -83,6 +79,7 @@ class VerilatedVar;
class VerilatedVarNameMap; class VerilatedVarNameMap;
class VerilatedVcd; class VerilatedVcd;
class VerilatedVcdC; class VerilatedVcdC;
class VerilatedVcdSc;
class VerilatedFst; class VerilatedFst;
class VerilatedFstC; class VerilatedFstC;
@@ -200,13 +197,19 @@ public:
/// Check that the current thread ID is the same as the construction thread ID /// Check that the current thread ID is the same as the construction thread ID
void check() VL_MT_UNSAFE_ONE { void check() VL_MT_UNSAFE_ONE {
if (VL_UNCOVERABLE(m_threadid != VL_THREAD_ID())) { 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; static void fatal_different() VL_MT_SAFE;
#else // !VL_THREADED || !VL_DEBUG #else // !VL_THREADED || !VL_DEBUG
public: public:
void check() {} void check() {}
void changeThread() {}
#endif #endif
}; };
@@ -313,7 +316,7 @@ private:
public: // But internals only - called from VerilatedModule's public: // But internals only - called from VerilatedModule's
VerilatedScope(); VerilatedScope();
~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; const char* identifier, const Type type) VL_MT_UNSAFE;
void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE; void exportInsert(int finalize, const char* namep, void* cb) VL_MT_UNSAFE;
void varInsert(int finalize, const char* namep, void* datap, void varInsert(int finalize, const char* namep, void* datap,
@@ -692,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; } union { double d; QData q; } u; u.d=lhs; return u.q; }
/// Return double from QData (numeric) /// Return double from QData (numeric)
static inline double VL_ITOR_D_I(IData lhs) VL_PURE { 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) /// Return QData from double (numeric)
static inline IData VL_RTOI_I_D(double lhs) VL_PURE { static inline IData VL_RTOI_I_D(double lhs) VL_PURE {
return static_cast<vlsint32_t>(VL_TRUNC(lhs)); } 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)); }
// Sign extend such that if MSB set, we get ffff_ffff, else 0s // Sign extend such that if MSB set, we get ffff_ffff, else 0s
// (Requires clean input) // (Requires clean input)
@@ -1317,6 +1319,14 @@ static inline WDataOutP VL_NEGATE_W(int words, WDataOutP owp, WDataInP lwp) VL_M
} }
return owp; 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_MUL: oclean=dirty; lclean==clean; rclean==clean;
// EMIT_RULE: VL_DIV: oclean=dirty; lclean==clean; rclean==clean; // EMIT_RULE: VL_DIV: oclean=dirty; lclean==clean; rclean==clean;
@@ -1643,18 +1653,22 @@ static inline void _VL_INSERT_WW(int, WDataOutP owp, WDataInP lwp, int hbit, int
int oword = lword+i; int oword = lword+i;
EData d = lwp[i] << loffset; EData d = lwp[i] << loffset;
EData od = (owp[oword] & ~linsmask) | (d & linsmask); EData od = (owp[oword] & ~linsmask) | (d & linsmask);
if (oword == hword) if (oword == hword) {
owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask); owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask);
else owp[oword] = od; } else {
owp[oword] = od;
}
} }
{ // Upper word { // Upper word
int oword = lword+i+1; int oword = lword+i+1;
if (oword <= hword) { if (oword <= hword) {
EData d = lwp[i] >> nbitsonright; EData d = lwp[i] >> nbitsonright;
EData od = (d & ~linsmask) | (owp[oword] & linsmask); EData od = (d & ~linsmask) | (owp[oword] & linsmask);
if (oword == hword) if (oword == hword) {
owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask); owp[oword] = (owp[oword] & ~hinsmask) | (od & hinsmask);
else owp[oword] = od; } else {
owp[oword] = od;
}
} }
} }
} }
@@ -2013,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]); 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 { 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) { for (int i = 1; i < VL_WORDS_I(rbits); ++i) {
if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more if (VL_UNLIKELY(rwp[i])) { // Huge shift 1>>32 or more
@@ -2098,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]); 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, static inline IData VL_SHIFTRS_IIW(int obits, int lbits, int rbits,
IData lhs, WDataInP rwp) VL_MT_SAFE { IData lhs, WDataInP rwp) VL_MT_SAFE {
EData overshift = 0; // Huge shift 1>>32 or more EData overshift = 0; // Huge shift 1>>32 or more
@@ -2222,6 +2247,49 @@ static inline WDataOutP VL_SEL_WWII(int obits, int lbits, int, int,
return owp; 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 // Range assignments
+6 -4
View File
@@ -2,9 +2,11 @@
###################################################################### ######################################################################
# DESCRIPTION: Makefile commands for all verilated target files # DESCRIPTION: Makefile commands for all verilated target files
# #
# Copyright 2003-2020 by Wilson Snyder. Verilator is free software; you can # Copyright 2003-2020 by Wilson Snyder. This program is free software; you
# redistribute it and/or modify it under the terms of either the GNU Lesser # can redistribute it and/or modify it under the terms of either the GNU
# General Public License Version 3 or the Perl Artistic License Version 2.0. # 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@ PERL = @PERL@
@@ -86,7 +88,7 @@ LDLIBS += $(VM_USER_LDLIBS)
# SystemC takes minutes to optimize, thus it is off by default. # SystemC takes minutes to optimize, thus it is off by default.
#OPT_SLOW = #OPT_SLOW =
# Fast path optimizations. Most time is spent in these classes. # 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 = -O
#OPT_FAST = #OPT_FAST =
+2 -6
View File
@@ -6,13 +6,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//========================================================================= //=========================================================================
// //
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
+6 -9
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -77,7 +74,7 @@ public:
virtual void zero() const VL_OVERRIDE { *m_countp = 0; } virtual void zero() const VL_OVERRIDE { *m_countp = 0; }
// CONSTRUCTORS // CONSTRUCTORS
// cppcheck-suppress noExplicitConstructor // cppcheck-suppress noExplicitConstructor
VerilatedCoverItemSpec(T* countp) : m_countp(countp) { *m_countp = 0; } explicit VerilatedCoverItemSpec(T* countp) : m_countp(countp) { *m_countp = 0; }
virtual ~VerilatedCoverItemSpec() VL_OVERRIDE {} virtual ~VerilatedCoverItemSpec() VL_OVERRIDE {}
}; };
+15 -12
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -32,9 +29,15 @@
/// Conditionally compile coverage code /// Conditionally compile coverage code
#ifdef VM_COVERAGE #ifdef VM_COVERAGE
# define VL_IF_COVER(stmts) do { stmts ; } while(0) # define VL_IF_COVER(stmts) \
do { \
stmts; \
} while (false)
#else #else
# define VL_IF_COVER(stmts) do { if(0) { stmts ; } } while(0) # define VL_IF_COVER(stmts) \
do { \
if (false) { stmts; } \
} while (false)
#endif #endif
//============================================================================= //=============================================================================
@@ -65,10 +68,10 @@
/// VL_COVER_INSERT(&m_cases[i], "comment", "Coverage Case", "i", cvtToNumStr(i)); /// 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); \ VL_IF_COVER(VerilatedCov::_inserti(countp); \
VerilatedCov::_insertf(__FILE__, __LINE__); \ VerilatedCov::_insertf(__FILE__, __LINE__); \
VerilatedCov::_insertp("hier", name(), args)) VerilatedCov::_insertp("hier", name(), __VA_ARGS__))
//============================================================================= //=============================================================================
/// Convert VL_COVER_INSERT value arguments to strings /// Convert VL_COVER_INSERT value arguments to strings
+5 -8
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
+4 -8
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//========================================================================= //=========================================================================
/// ///
@@ -46,8 +42,8 @@
VL_FATAL_MT(__FILE__, __LINE__, "", \ VL_FATAL_MT(__FILE__, __LINE__, "", \
(std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str()) (std::string("%%Error: Unsupported DPI function: ")+VL_FUNC).c_str())
#define _VL_SVDPI_WARN(message...) \ #define _VL_SVDPI_WARN(...) \
VL_PRINTF_MT(message) VL_PRINTF_MT(__VA_ARGS__)
// Function requires a "context" in the import declaration // Function requires a "context" in the import declaration
#define _VL_SVDPI_CONTEXT_WARN() \ #define _VL_SVDPI_CONTEXT_WARN() \
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
+35 -27
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -64,9 +61,12 @@ protected:
vluint32_t m_code; ///< Starting code number vluint32_t m_code; ///< Starting code number
// CONSTRUCTORS // CONSTRUCTORS
VerilatedFstCallInfo(VerilatedFstCallback_t icb, VerilatedFstCallback_t fcb, VerilatedFstCallInfo(VerilatedFstCallback_t icb, VerilatedFstCallback_t fcb,
VerilatedFstCallback_t changecb, VerilatedFstCallback_t changecb, void* ut)
void* ut, vluint32_t code) : m_initcb(icb)
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {} , m_fullcb(fcb)
, m_changecb(changecb)
, m_userthis(ut)
, m_code(1) {}
~VerilatedFstCallInfo() {} ~VerilatedFstCallInfo() {}
}; };
@@ -74,10 +74,11 @@ protected:
// VerilatedFst // VerilatedFst
VerilatedFst::VerilatedFst(void* fst) VerilatedFst::VerilatedFst(void* fst)
: m_fst(fst), : m_fst(fst)
m_fullDump(true), , m_fullDump(true)
m_scopeEscape('.') { , m_nextCode(1)
m_valueStrBuffer.reserve(64+1); // Need enough room for quad , m_scopeEscape('.') {
m_valueStrBuffer.reserve(64 + 1); // Need enough room for quad
} }
void VerilatedFst::open(const char* filename) VL_MT_UNSAFE { void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
@@ -88,10 +89,12 @@ void VerilatedFst::open(const char* filename) VL_MT_UNSAFE {
fstWriterSetParallelMode(m_fst, 1); fstWriterSetParallelMode(m_fst, 1);
#endif #endif
m_curScope.clear(); m_curScope.clear();
m_nextCode = 1;
for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) { for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[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); (cip->m_initcb)(this, cip->m_userthis, cip->m_code);
} }
@@ -118,9 +121,15 @@ void VerilatedFst::declDTypeEnum(int dtypenum, const char* name, vluint32_t elem
m_local2fstdtype[dtypenum] = enumNum; m_local2fstdtype[dtypenum] = enumNum;
} }
void VerilatedFst::declSymbol(vluint32_t code, const char* name, void VerilatedFst::declSymbol(vluint32_t code, const char* name, int dtypenum, fstVarDir vardir,
int dtypenum, fstVarDir vardir, fstVarType vartype, fstVarType vartype, bool array, int arraynum, vluint32_t len,
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 std::pair<Code2SymbolType::iterator, bool> p
= m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL))); = m_code2symbol.insert(std::make_pair(code, static_cast<fstHandle>(NULL)));
std::istringstream nameiss(name); std::istringstream nameiss(name);
@@ -173,17 +182,16 @@ void VerilatedFst::declSymbol(vluint32_t code, const char* name,
//============================================================================= //=============================================================================
// Callbacks // Callbacks
void VerilatedFst::addCallback( void VerilatedFst::addCallback(VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb,
VerilatedFstCallback_t initcb, VerilatedFstCallback_t fullcb, VerilatedFstCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
VerilatedFstCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
m_assertOne.check(); m_assertOne.check();
if (VL_UNLIKELY(isOpen())) { if (VL_UNLIKELY(isOpen())) {
std::string msg = (std::string("Internal: ")+__FILE__+"::"+__FUNCTION__ std::string msg = (std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
+" called with already open file"); + " called with already open file");
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
} }
VerilatedFstCallInfo* vci = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis, 1); VerilatedFstCallInfo* cip = new VerilatedFstCallInfo(initcb, fullcb, changecb, userthis);
m_callbacks.push_back(vci); m_callbacks.push_back(cip);
} }
//============================================================================= //=============================================================================
@@ -192,7 +200,7 @@ void VerilatedFst::addCallback(
void VerilatedFst::dump(vluint64_t timeui) { void VerilatedFst::dump(vluint64_t timeui) {
if (!isOpen()) return; if (!isOpen()) return;
if (VL_UNLIKELY(m_fullDump)) { 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) { for (vluint32_t ent = 0; ent< m_callbacks.size(); ++ent) {
VerilatedFstCallInfo* cip = m_callbacks[ent]; VerilatedFstCallInfo* cip = m_callbacks[ent];
(cip->m_fullcb)(this, cip->m_userthis, cip->m_code); (cip->m_fullcb)(this, cip->m_userthis, cip->m_code);
+24 -20
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -50,6 +47,7 @@ private:
void* m_fst; void* m_fst;
VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
bool m_fullDump; bool m_fullDump;
vluint32_t m_nextCode; ///< Next code number to assign
char m_scopeEscape; char m_scopeEscape;
std::string m_module; std::string m_module;
CallbackVec m_callbacks; ///< Routines to perform dumping CallbackVec m_callbacks; ///< Routines to perform dumping
@@ -60,12 +58,13 @@ private:
VL_UNCOPYABLE(VerilatedFst); VL_UNCOPYABLE(VerilatedFst);
void declSymbol(vluint32_t code, const char* name, void declSymbol(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, vluint32_t len); bool array, int arraynum, vluint32_t len, vluint32_t bits);
// helpers // helpers
std::vector<char> m_valueStrBuffer; std::vector<char> m_valueStrBuffer;
public: public:
explicit VerilatedFst(void* fst=NULL); explicit VerilatedFst(void* fst=NULL);
~VerilatedFst() { if (m_fst == NULL) { fstWriterClose(m_fst); } } ~VerilatedFst() { if (m_fst == NULL) { fstWriterClose(m_fst); } }
void changeThread() { m_assertOne.changeThread(); }
bool isOpen() const { return m_fst != NULL; } bool isOpen() const { return m_fst != NULL; }
void open(const char* filename) VL_MT_UNSAFE; void open(const char* filename) VL_MT_UNSAFE;
void flush() VL_MT_UNSAFE { fstWriterFlushContext(m_fst); } void flush() VL_MT_UNSAFE { fstWriterFlushContext(m_fst); }
@@ -104,32 +103,35 @@ public:
void declBit(vluint32_t code, const char* name, void declBit(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) { 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, void declBus(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) { 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, void declDouble(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) { 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, void declFloat(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum) { 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, void declQuad(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) { 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, void declArray(vluint32_t code, const char* name,
int dtypenum, fstVarDir vardir, fstVarType vartype, int dtypenum, fstVarDir vardir, fstVarType vartype,
bool array, int arraynum, int msb, int lsb) { 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 /// 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) { void fullArray(vluint32_t code, const vluint32_t* newval, int bits) {
chgArray(code, newval, bits); } chgArray(code, newval, bits); }
void declTriBit (vluint32_t code, const char* name, int arraynum); 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 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 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 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 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 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); void fullTriQuad(vluint32_t code, const vluint64_t newval, const vluint32_t newtri, int bits);
@@ -198,7 +200,9 @@ class VerilatedFstC {
VL_UNCOPYABLE(VerilatedFstC); VL_UNCOPYABLE(VerilatedFstC);
public: public:
explicit VerilatedFstC(void* filep=NULL) : m_sptrace(filep) {} 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: public:
// ACCESSORS // ACCESSORS
/// Is file open? /// Is file open?
+33 -13
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2010-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
@@ -37,10 +33,10 @@
//=================================================================== //===================================================================
// String formatters (required by below containers) // String formatters (required by below containers)
extern std::string VL_TO_STRING(CData obj); extern std::string VL_TO_STRING(CData lhs);
extern std::string VL_TO_STRING(SData obj); extern std::string VL_TO_STRING(SData lhs);
extern std::string VL_TO_STRING(IData obj); extern std::string VL_TO_STRING(IData lhs);
extern std::string VL_TO_STRING(QData obj); extern std::string VL_TO_STRING(QData lhs);
inline std::string VL_TO_STRING(const std::string& obj) { return "\"" + obj + "\""; } inline std::string VL_TO_STRING(const std::string& obj) { return "\"" + obj + "\""; }
extern std::string VL_TO_STRING_W(int words, WDataInP obj); extern std::string VL_TO_STRING_W(int words, WDataInP obj);
@@ -162,7 +158,7 @@ public:
int next(T_Key& indexr) const { int next(T_Key& indexr) const {
typename Map::const_iterator it = m_map.find(indexr); typename Map::const_iterator it = m_map.find(indexr);
if (VL_UNLIKELY(it == m_map.end())) return 0; if (VL_UNLIKELY(it == m_map.end())) return 0;
it++; ++it;
if (VL_UNLIKELY(it == m_map.end())) return 0; if (VL_UNLIKELY(it == m_map.end())) return 0;
indexr = it->first; indexr = it->first;
return 1; return 1;
@@ -221,7 +217,7 @@ 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 { VlAssocArray<T_Key, T_Value>& obj, QData start, QData end) VL_MT_SAFE {
VlReadMem rmem(hex, bits, filename, start, end); VlReadMem rmem(hex, bits, filename, start, end);
if (VL_UNLIKELY(!rmem.isOpen())) return; if (VL_UNLIKELY(!rmem.isOpen())) return;
while (1) { while (true) {
QData addr; QData addr;
std::string data; std::string data;
if (rmem.get(addr /*ref*/, data /*ref*/)) { if (rmem.get(addr /*ref*/, data /*ref*/)) {
@@ -245,11 +241,12 @@ void VL_WRITEMEM_N(bool hex, int bits, const std::string& filename,
} }
//=================================================================== //===================================================================
// Verilog queue container // Verilog queue and dynamic array container
// There are no multithreaded locks on this; the base variable must // There are no multithreaded locks on this; the base variable must
// be protected by other means // be protected by other means
// //
// Bound here is the maximum size() allowed, e.g. 1 + SystemVerilog bound // 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 { template <class T_Value, size_t T_MaxSize = 0> class VlQueue {
private: private:
// TYPES // TYPES
@@ -279,6 +276,21 @@ public:
void clear() { m_deque.clear(); } void clear() { m_deque.clear(); }
void erase(size_t index) { if (VL_LIKELY(index < m_deque.size())) m_deque.erase(index); } 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) // function void q.push_front(value)
void push_front(const T_Value& value) { void push_front(const T_Value& value) {
m_deque.push_front(value); m_deque.push_front(value);
@@ -304,6 +316,7 @@ public:
// because we need to be able to insert only when the value is set // because we need to be able to insert only when the value is set
T_Value& at(size_t index) { T_Value& at(size_t index) {
static T_Value s_throwAway; static T_Value s_throwAway;
// Needs to work for dynamic arrays, so does not use T_MaxSize
if (VL_UNLIKELY(index >= m_deque.size())) { if (VL_UNLIKELY(index >= m_deque.size())) {
s_throwAway = atDefault(); s_throwAway = atDefault();
return s_throwAway; return s_throwAway;
@@ -313,6 +326,7 @@ public:
// Accessing. Verilog: v = assoc[index] // Accessing. Verilog: v = assoc[index]
const T_Value& at(size_t index) const { const T_Value& at(size_t index) const {
static T_Value s_throwAway; 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(); if (VL_UNLIKELY(index >= m_deque.size())) return atDefault();
else return m_deque[index]; else return m_deque[index];
} }
@@ -441,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; 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 #endif // Guard
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//========================================================================= //=========================================================================
/// ///
+7 -10
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -187,7 +184,7 @@ void VerilatedSave::flush() VL_MT_UNSAFE_ONE {
m_assertOne.check(); m_assertOne.check();
if (VL_UNLIKELY(!isOpen())) return; if (VL_UNLIKELY(!isOpen())) return;
vluint8_t* wp = m_bufp; vluint8_t* wp = m_bufp;
while (1) { while (true) {
ssize_t remaining = (m_cp - wp); ssize_t remaining = (m_cp - wp);
if (remaining==0) break; if (remaining==0) break;
errno = 0; errno = 0;
@@ -216,7 +213,7 @@ void VerilatedRestore::fill() VL_MT_UNSAFE_ONE {
m_endp = m_bufp + (m_endp - m_cp); m_endp = m_bufp + (m_endp - m_cp);
m_cp = m_bufp; // Reset buffer m_cp = m_bufp; // Reset buffer
// Read into buffer starting at m_endp // Read into buffer starting at m_endp
while (1) { while (true) {
ssize_t remaining = (m_bufp+bufferSize() - m_endp); ssize_t remaining = (m_bufp+bufferSize() - m_endp);
if (remaining==0) break; if (remaining==0) break;
errno = 0; errno = 0;
+5 -8
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2012-2020 by Wilson Snyder. This program is free software; // Copyright 2000-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2009-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
+2 -6
View File
@@ -3,13 +3,9 @@
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // 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 // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
/// ///
+10 -14
View File
@@ -1,16 +1,11 @@
// -*- mode: C++; c-file-style: "cc-mode" -*- // -*- 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
// Copyright 2012-2020 by Wilson Snyder. This program is free software; // Lesser General Public License Version 3 or the Perl Artistic License
// you can redistribute it and/or modify it under the terms of either the GNU // Version 2.0.
// 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 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.
// //
//============================================================================= //=============================================================================
/// ///
@@ -41,7 +36,8 @@ VlMTaskVertex::VlMTaskVertex(vluint32_t upstreamDepCount)
// VlWorkerThread // VlWorkerThread
VlWorkerThread::VlWorkerThread(VlThreadPool* poolp, bool profiling) VlWorkerThread::VlWorkerThread(VlThreadPool* poolp, bool profiling)
: m_ready_size(0) : m_waiting(false)
, m_ready_size(0)
, m_poolp(poolp) , m_poolp(poolp)
, m_profiling(profiling) , m_profiling(profiling)
, m_exiting(false) , m_exiting(false)
@@ -63,7 +59,7 @@ void VlWorkerThread::workerLoop() {
ExecRec work; ExecRec work;
work.m_fnp = NULL; work.m_fnp = NULL;
while (1) { while (true) {
if (VL_LIKELY(!work.m_fnp)) { if (VL_LIKELY(!work.m_fnp)) {
dequeWork(&work); dequeWork(&work);
} }
@@ -173,12 +169,12 @@ void VlThreadPool::profileDump(const char* filenamep, vluint64_t ticksElapsed) {
VlMTaskVertex::yields()); VlMTaskVertex::yields());
vluint32_t thread_id = 0; 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) { pit != m_allProfiles.end(); ++pit) {
++thread_id; ++thread_id;
bool printing = false; // False while in warmup phase 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) { eit != (*pit)->end(); ++eit) {
switch (eit->m_type) { switch (eit->m_type) {
case VlProfileRec::TYPE_BARRIER: case VlProfileRec::TYPE_BARRIER:
+5 -8
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2012-2020 by Wilson Snyder. This program is free software; // Copyright 2012-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
+4 -8
View File
@@ -7,15 +7,11 @@
// //
//************************************************************************* //*************************************************************************
// //
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you can // Copyright 2003-2020 by Wilson Snyder. This program is free software; you
// redistribute it and/or modify it under the terms of either the GNU // 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. // Version 2.0.
// // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-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.
// //
//************************************************************************* //*************************************************************************
@@ -151,7 +147,7 @@ public:
return (!this->operator==(other)); return (!this->operator==(other));
} }
void advanceUntilValid() { void advanceUntilValid() {
while (1) { while (true) {
if (m_bit != m_setp->m_bucketsp[m_bucketIdx].end()) { if (m_bit != m_setp->m_bucketsp[m_bucketIdx].end()) {
// Valid iterator in this bucket; we're done. // Valid iterator in this bucket; we're done.
return; return;
+42 -40
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -57,8 +54,8 @@ class VerilatedVcdSingleton {
private: private:
typedef std::vector<VerilatedVcd*> VcdVec; typedef std::vector<VerilatedVcd*> VcdVec;
struct Singleton { struct Singleton {
VerilatedMutex s_vcdMutex; ///< Protect the singleton VerilatedMutex s_vcdMutex; ///< Protect the singleton
VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces VcdVec s_vcdVecp VL_GUARDED_BY(s_vcdMutex); ///< List of all created traces
}; };
static Singleton& singleton() { static Singleton s; return s; } static Singleton& singleton() { static Singleton s; return s; }
public: public:
@@ -96,16 +93,19 @@ public:
class VerilatedVcdCallInfo { class VerilatedVcdCallInfo {
protected: protected:
friend class VerilatedVcd; friend class VerilatedVcd;
VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function VerilatedVcdCallback_t m_initcb; ///< Initialization Callback function
VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function VerilatedVcdCallback_t m_fullcb; ///< Full Dumping Callback function
VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function VerilatedVcdCallback_t m_changecb; ///< Incremental Dumping Callback function
void* m_userthis; ///< Fake "this" for caller void* m_userthis; ///< Fake "this" for caller
vluint32_t m_code; ///< Starting code number vluint32_t m_code; ///< Starting code number (set later by traceInit)
// CONSTRUCTORS // CONSTRUCTORS
VerilatedVcdCallInfo(VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb, VerilatedVcdCallInfo(VerilatedVcdCallback_t icb, VerilatedVcdCallback_t fcb,
VerilatedVcdCallback_t changecb, VerilatedVcdCallback_t changecb, void* ut)
void* ut, vluint32_t code) : m_initcb(icb)
: m_initcb(icb), m_fullcb(fcb), m_changecb(changecb), m_userthis(ut), m_code(code) {} , m_fullcb(fcb)
, m_changecb(changecb)
, m_userthis(ut)
, m_code(1) {}
~VerilatedVcdCallInfo() {} ~VerilatedVcdCallInfo() {}
}; };
@@ -116,7 +116,7 @@ protected:
bool VerilatedVcdFile::open(const std::string& name) VL_MT_UNSAFE { 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); 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 { 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 // Opening/Closing
VerilatedVcd::VerilatedVcd(VerilatedVcdFile* filep) 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 // Not in header to avoid link issue if header is included without this .cpp file
m_fileNewed = (filep == NULL); m_fileNewed = (filep == NULL);
m_filep = m_fileNewed ? new VerilatedVcdFile : filep; m_filep = m_fileNewed ? new VerilatedVcdFile : filep;
@@ -156,7 +159,7 @@ void VerilatedVcd::open(const char* filename) {
if (isOpen()) return; if (isOpen()) return;
// Set member variables // Set member variables
m_filename = filename; m_filename = filename; // "" is ok, as someone may overload open
VerilatedVcdSingleton::pushVcd(this); VerilatedVcdSingleton::pushVcd(this);
// SPDIFF_OFF // SPDIFF_OFF
@@ -230,9 +233,10 @@ void VerilatedVcd::makeNameMap() {
deleteNameMap(); deleteNameMap();
m_nextCode = 1; m_nextCode = 1;
m_namemapp = new NameMap; 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]; VerilatedVcdCallInfo* cip = m_callbacks[ent];
cip->m_code = m_nextCode; cip->m_code = m_nextCode;
// Initialize; callbacks will call decl* which update m_nextCode
(cip->m_initcb)(this, cip->m_userthis, cip->m_code); (cip->m_initcb)(this, cip->m_userthis, cip->m_code);
} }
@@ -360,7 +364,7 @@ void VerilatedVcd::bufferFlush() VL_MT_UNSAFE_ONE {
m_assertOne.check(); m_assertOne.check();
if (VL_UNLIKELY(!isOpen())) return; if (VL_UNLIKELY(!isOpen())) return;
char* wp = m_wrBufp; char* wp = m_wrBufp;
while (1) { while (true) {
ssize_t remaining = (m_writep - wp); ssize_t remaining = (m_writep - wp);
if (remaining==0) break; if (remaining==0) break;
errno = 0; errno = 0;
@@ -513,7 +517,7 @@ void VerilatedVcd::dumpHeader() {
printIndent(-1); printIndent(-1);
printStr("$enddefinitions $end\n\n\n"); printStr("$enddefinitions $end\n\n\n");
assert(m_modDepth==0); assert(m_modDepth == 0);
// Reclaim storage // Reclaim storage
deleteNameMap(); deleteNameMap();
@@ -529,12 +533,12 @@ void VerilatedVcd::declare(vluint32_t code, const char* name, const char* wirep,
if (!code) { VL_FATAL_MT(__FILE__, __LINE__, "", if (!code) { VL_FATAL_MT(__FILE__, __LINE__, "",
"Internal: internal trace problem, code 0 is illegal"); } "Internal: internal trace problem, code 0 is illegal"); }
int bits = ((msb>lsb)?(msb-lsb):(lsb-msb))+1; int bits = ((msb > lsb) ? (msb - lsb) : (lsb - msb)) + 1;
int codesNeeded = 1+int(bits/32); int codesNeeded = 1 + int(bits / 32);
if (tri) codesNeeded *= 2; // Space in change array for __en signals if (tri) codesNeeded *= 2; // Space in change array for __en signals
// Make sure array is large enough // 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) { if (m_sigs.capacity() <= m_nextCode) {
m_sigs.reserve(m_nextCode*2); // Power-of-2 allocation speeds things up 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 // Callbacks
void VerilatedVcd::addCallback( void VerilatedVcd::addCallback(VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb,
VerilatedVcdCallback_t initcb, VerilatedVcdCallback_t fullcb, VerilatedVcdCallback_t changecb, VerilatedVcdCallback_t changecb, void* userthis) VL_MT_UNSAFE_ONE {
void* userthis) VL_MT_UNSAFE_ONE
{
m_assertOne.check(); m_assertOne.check();
if (VL_UNLIKELY(isOpen())) { if (VL_UNLIKELY(isOpen())) {
std::string msg = std::string("Internal: ")+__FILE__+"::"+__FUNCTION__ std::string msg = std::string("Internal: ") + __FILE__ + "::" + __FUNCTION__
+" called with already open file"; + " called with already open file";
VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str()); VL_FATAL_MT(__FILE__, __LINE__, "", msg.c_str());
} }
VerilatedVcdCallInfo* vci VerilatedVcdCallInfo* cip = new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis);
= new VerilatedVcdCallInfo(initcb, fullcb, changecb, userthis, m_nextCode); m_callbacks.push_back(cip);
m_callbacks.push_back(vci);
} }
//============================================================================= //=============================================================================
@@ -680,7 +681,7 @@ void VerilatedVcd::dumpFull(vluint64_t timeui) {
m_assertOne.check(); m_assertOne.check();
dumpPrep(timeui); dumpPrep(timeui);
Verilated::quiesce(); 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]; VerilatedVcdCallInfo* cip = m_callbacks[ent];
(cip->m_fullcb)(this, cip->m_userthis, cip->m_code); (cip->m_fullcb)(this, cip->m_userthis, cip->m_code);
} }
@@ -690,7 +691,7 @@ void VerilatedVcd::dump(vluint64_t timeui) {
m_assertOne.check(); m_assertOne.check();
if (!isOpen()) return; if (!isOpen()) return;
if (VL_UNLIKELY(m_fullDump)) { 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); dumpFull(timeui);
return; return;
} }
@@ -700,7 +701,7 @@ void VerilatedVcd::dump(vluint64_t timeui) {
} }
dumpPrep(timeui); dumpPrep(timeui);
Verilated::quiesce(); 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]; VerilatedVcdCallInfo* cip = m_callbacks[ent];
(cip->m_changecb)(this, cip->m_userthis, cip->m_code); (cip->m_changecb)(this, cip->m_userthis, cip->m_code);
} }
@@ -829,6 +830,7 @@ main() {
#endif #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: // 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: // End:
+12 -11
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///
@@ -103,9 +100,9 @@ private:
typedef std::vector<VerilatedVcdSig> SigVec; typedef std::vector<VerilatedVcdSig> SigVec;
SigVec m_sigs; ///< Pointer to signal information SigVec m_sigs; ///< Pointer to signal information
typedef std::vector<VerilatedVcdCallInfo*> CallbackVec; 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; 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 VerilatedAssertOneThread m_assertOne; ///< Assert only called from single thread
@@ -159,6 +156,8 @@ private:
public: public:
explicit VerilatedVcd(VerilatedVcdFile* filep = NULL); explicit VerilatedVcd(VerilatedVcdFile* filep = NULL);
~VerilatedVcd(); ~VerilatedVcd();
/// Routines can only be called from one thread; allow next call from different thread
void changeThread() { m_assertOne.changeThread(); }
// ACCESSORS // ACCESSORS
/// Set size in megabytes after which new file should be created /// Set size in megabytes after which new file should be created
@@ -445,7 +444,9 @@ class VerilatedVcdC {
public: public:
explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL) explicit VerilatedVcdC(VerilatedVcdFile* filep = NULL)
: m_sptrace(filep) {} : 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: public:
// ACCESSORS // ACCESSORS
/// Is file open? /// Is file open?
+5 -8
View File
@@ -3,14 +3,11 @@
// //
// THIS MODULE IS PUBLICLY LICENSED // THIS MODULE IS PUBLICLY LICENSED
// //
// Copyright 2001-2020 by Wilson Snyder. This program is free software; // Copyright 2001-2020 by Wilson Snyder. This program is free software; you
// you can redistribute it and/or modify it under the terms of either the GNU // 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. // 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 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
// //
//============================================================================= //=============================================================================
/// ///

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